Skip to content

Commit ef56260

Browse files
[DEV] fixing and updating minor stuff
1 parent e2c76f0 commit ef56260

File tree

9 files changed

+48
-83
lines changed

9 files changed

+48
-83
lines changed

src/plugin/VStepperForm.vue

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@
1212
</h2>
1313
</v-col>
1414
</v-row>
15-
<v-row>
16-
<v-col>
17-
stepperMode: {{ stepperModel }}
18-
<br />
19-
currentPageHasErrors: {{ currentPageHasErrors }}
20-
<br />
21-
errorPageIndexes: {{ errorPageIndexes }}
22-
</v-col>
23-
</v-row>
2415
</v-container>
2516

2617
<v-container
@@ -185,12 +176,12 @@ const injectedOptions = inject(globalOptions, {});
185176
186177
// -------------------------------------------------- Props //
187178
const props = withDefaults(defineProps<Props>(), AllProps);
188-
const stepperProps = reactive<Settings>(useMergeProps(attrs, injectedOptions, props));
179+
const stepperProps: Settings = reactive<Settings>(useMergeProps(attrs, injectedOptions, props));
189180
const { direction, title, width } = toRefs(props);
190181
const pages = reactive<Page[]>(props.pages);
191182
const originalPages = JSON.parse(JSON.stringify(pages));
192183
193-
const settings = ref<Settings>({
184+
const settings: Ref<Settings> = ref<Settings>({
194185
altLabels: stepperProps.altLabels,
195186
autoPage: stepperProps.autoPage,
196187
autoPageDelay: stepperProps.autoPageDelay,
@@ -226,7 +217,7 @@ const settings = ref<Settings>({
226217
});
227218
228219
229-
const allFieldsArray = ref<Field[]>([]);
220+
const allFieldsArray: Ref<Field[]> = ref<Field[]>([]);
230221
231222
Object.values(pages).forEach((p: Page) => {
232223
Object.values(p.fields).forEach((field: Field) => {
@@ -266,7 +257,7 @@ const stepperModel = ref(1);
266257
267258
268259
const { sm } = useDisplay();
269-
const transition = computed<Props['transition']>(() => stepperProps.transition);
260+
const transition: ComputedRef<Props['transition']> = computed(() => stepperProps.transition);
270261
const parentForm = useTemplateRef<PrivateFormContext>('stepperFormRef');
271262
272263
provide('parentForm', parentForm);
@@ -324,7 +315,7 @@ function headerItemDisabled(page: Page): boolean {
324315
const validationSchema = computed(() => toTypedSchema(props.validationSchema as Props['validationSchema']));
325316
const fieldsHaveErrors = ref(false);
326317
const currentPageHasErrors = ref(false);
327-
const errorPageIndexes = ref<number[]>([]);
318+
const errorPageIndexes: Ref<number[]> = ref<number[]>([]);
328319
329320
// ------------------------ Run Validation //
330321
function runValidation(

src/plugin/__tests__/index.test.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/plugin/components/fields/VSFCheckbox/VSFCheckbox.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@
8383
@change="onActions(validate, 'change')"
8484
@input="onActions(validate, 'input')"
8585
>
86-
<template #message>
86+
<!-- ! TODO: This needs to be fixed as it doesn't work when using inline prop -->
87+
<template
88+
v-if="!field.inline"
89+
#message
90+
>
8791
{{ Object.keys(field?.options as KeyStringAny).length - 1 === key ? errorMessage : '' }}
8892
</template>
8993
</v-checkbox>

src/plugin/components/fields/VSFSwitch/VSFSwitch.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
v-model="modelValue"
1414
:error="errorMessage ? errorMessage?.length > 0 : false"
1515
:error-messages="errorMessage"
16-
@blur="onActions(validate, 'blur')"
17-
@change="onActions(validate, 'change')"
18-
@input="onActions(validate, 'input')"
16+
@blur="onActions((validate as ValidateFieldResult), 'blur')"
17+
@change="onActions((validate as ValidateFieldResult), 'change')"
18+
@input="onActions((validate as ValidateFieldResult), 'input')"
1919
>
2020
<template #label>
2121
<FieldLabel
@@ -51,7 +51,7 @@ const fieldValidateOn = computed(() => field?.validateOn ?? settings?.validateOn
5151
5252
5353
// ------------------------- Validate On Actions //
54-
async function onActions(validate: FieldValidateResult, action: ValidateAction): Promise<void> {
54+
async function onActions(validate: ValidateFieldResult, action: ValidateAction): Promise<void> {
5555
useOnActions({
5656
action,
5757
emit,

src/plugin/components/shared/PageContainer.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ import {
132132
VTextarea,
133133
VTextField,
134134
} from 'vuetify/components';
135-
import { VColorField } from '@wdns/vuetify-color-field';
135+
import VColorField from '@wdns/vuetify-color-field';
136136
import { useColumnErrorCheck } from '../../composables/helpers';
137137
138138
@@ -218,7 +218,6 @@ function getColumnClasses(field: Field) {
218218
});
219219
220220
return {
221-
'py-0': true,
222221
'v-col-12': true,
223222
'v-cols': true,
224223
[`v-col-sm-${field?.columns?.sm ?? columnsMerged.value.sm}`]: true,

src/plugin/composables/__tests__/__snapshots__/classes.test.ts.snap

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
exports[`Classes Composable > useContainerClasses > should return class object 1`] = `
44
{
5-
"v-plugin-template": true,
6-
"v-plugin-template--container": true,
7-
"v-plugin-template--container-option": true,
5+
"d-flex flex-column justify-center align-center": false,
6+
"v-stepper-form": true,
7+
"v-stepper-form--container": true,
8+
"v-stepper-form--container-undefined": true,
89
}
910
`;
Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,38 @@
11
import { describe, it, expect } from 'vitest';
22
import {
3-
useConvertToUnit,
3+
useColumnErrorCheck,
44
} from '../helpers';
55

66
describe('Helpers Composable', () => {
7-
describe('useConvertToUnit', () => {
8-
it('should return string with a default px unit', () => {
9-
const unit = useConvertToUnit({ value: '10' });
10-
expect(unit).toBe('10px');
11-
});
12-
13-
it('should return number with a default px unit', () => {
14-
const unit = useConvertToUnit({ value: 10 });
15-
expect(unit).toBe('10px');
16-
});
7+
describe('useColumnErrorCheck', () => {
8+
describe('Errors', () => {
9+
const propName = 'columns';
1710

18-
it('should return string with a supplied unit', () => {
19-
const unit = useConvertToUnit({ unit: 'em', value: '10' });
20-
expect(unit).toBe('10em');
21-
});
11+
it('should return without throwing error if using correct column values', () => {
12+
expect(() => useColumnErrorCheck({
13+
columns: {
14+
lg: 12,
15+
md: 12,
16+
sm: 12,
17+
xl: 12,
18+
},
19+
propName: 'columns',
20+
}))
21+
.not.toThrow();
22+
});
2223

23-
it('should return number with a supplied unit', () => {
24-
const unit = useConvertToUnit({ unit: 'em', value: 10 });
25-
expect(unit).toBe('10em');
24+
it('should fail if using incorrect column values', () => {
25+
expect(() => useColumnErrorCheck({
26+
columns: {
27+
lg: 120,
28+
md: 120,
29+
sm: 120,
30+
xl: 120,
31+
},
32+
propName: propName,
33+
}))
34+
.toThrowError(`The ${propName} prop column values must be between 1 and 12`);
35+
});
2636
});
2737
});
2838
});

src/plugin/composables/styles.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/plugin/types/index.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
/* eslint-disable no-unused-vars */
3-
import { App, CSSProperties } from 'vue';
3+
import { App } from 'vue';
44
import type {
55
VBtn,
66
// VIcon,
@@ -292,16 +292,6 @@ export interface UseStepperContainerClasses {
292292
): ComputedClasses;
293293
}
294294

295-
// ------------------------- Styles //
296-
export interface UseContainerStyle {
297-
(
298-
options: {
299-
displayType?: string;
300-
}
301-
): CSSProperties;
302-
}
303-
304-
305295
// -------------------------------------------------- Plugin Component //
306296
declare module "vue" {
307297
interface ComponentCustomProperties { }

0 commit comments

Comments
 (0)