Skip to content

Commit a7ab5c7

Browse files
Merge pull request #32 from webdevnerdstuff/dev
Dev
2 parents 521daca + f3fc515 commit a7ab5c7

File tree

22 files changed

+1102
-1812
lines changed

22 files changed

+1102
-1812
lines changed

cypress.config.ts

+2
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ export default defineConfig({
2323
viewportHeight: 800,
2424
viewportWidth: 1920,
2525
},
26+
27+
numTestsKeptInMemory: 0,
2628
});

cypress/support/component.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import VStepperForm from '../../src/plugin/VStepperForm.vue';
77
import * as DATA from '../templates/testData';
88
import type { Component } from 'vue';
99
import "cypress-real-events";
10+
import { pluginOptionsInjectionKey } from '../../src/plugin/utils/globals';
1011

1112

1213
// declare global {
@@ -95,7 +96,7 @@ Cypress.Commands.add('mountComponent', (options: MountComponentOptions = {}) =>
9596
validationSchema: stepperProps.validationSchema ?? undefined,
9697
...stepperProps,
9798
},
98-
global: { provide: { globalOptions: { ...globalOptions, ...globalProps }, }, },
99+
global: { provide: { [pluginOptionsInjectionKey]: { ...globalOptions, ...globalProps }, }, },
99100
}).as('wrapper');
100101
});
101102
});

cypress/templates/testData.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
object as yupObject,
66
} from 'yup';
77
import { useDeepMerge } from '../../src/plugin/composables/helpers';
8+
import { pluginOptionsInjectionKey } from '../../src/plugin/utils/globals';
89

910

1011
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Shared //
@@ -143,7 +144,6 @@ const defaultFields = {
143144
name: 'combobox',
144145
placeholder: 'Select an item',
145146
type: 'combobox' as const,
146-
variant: 'outlined',
147147
},
148148
color: {
149149
label: 'Color',
@@ -592,7 +592,7 @@ const navigationTest = {
592592
},
593593
global: {
594594
provide: {
595-
globalOptions: {
595+
[pluginOptionsInjectionKey]: {
596596
color: 'primary',
597597
validateOn: 'blur',
598598
variant: 'outlined',

dist/FieldLabel-BRQ0K1ZH.mjs renamed to dist/FieldLabel-C78b4p01.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { FieldLabel as a } from "./vuetify-stepper-form.es.js";
22
/**
33
* @name @wdns/vuetify-stepper-form
4-
* @version 1.0.0
4+
* @version 1.0.1
55
* @description The Vuetify Stepper Form plugin provides a structured way to create multi-step forms using Vue 3, TypeScript, and Vuetify. It features a stepper layout that allows users to navigate between steps with form validation. The plugin is customizable and streamlines building dynamic, interactive forms that guide users through sequential steps.
66
* @author WebDevNerdStuff & Bunnies... lots and lots of bunnies! <[email protected]> (https://webdevnerdstuff.com)
77
* @copyright Copyright 2024, WebDevNerdStuff

dist/FieldLabel-mS_InZKL.js renamed to dist/FieldLabel-_ATH8rEz.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";/**
22
* @name @wdns/vuetify-stepper-form
3-
* @version 1.0.0
3+
* @version 1.0.1
44
* @description The Vuetify Stepper Form plugin provides a structured way to create multi-step forms using Vue 3, TypeScript, and Vuetify. It features a stepper layout that allows users to navigate between steps with form validation. The plugin is customizable and streamlines building dynamic, interactive forms that guide users through sequential steps.
55
* @author WebDevNerdStuff & Bunnies... lots and lots of bunnies! <[email protected]> (https://webdevnerdstuff.com)
66
* @copyright Copyright 2024, WebDevNerdStuff

dist/plugin/components/fields/VSFCustom/VSFCustom.vue.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ declare function __VLS_template(): {
5353
blur: () => Promise<void>;
5454
change: () => Promise<void>;
5555
input: () => Promise<void>;
56+
onUpdate: (value: any) => void;
5657
field: {
5758
options: KeyStringAny<any> | undefined;
5859
required: boolean | undefined;
@@ -101,7 +102,6 @@ declare function __VLS_template(): {
101102
variant?: string | undefined;
102103
transition?: import('vuetify/lib/components/index.mjs').VStepperWindowItem["transition"] | undefined;
103104
errorMessages: any;
104-
modelValue: any;
105105
};
106106
}) => any>>;
107107
refs: {};

dist/plugin/index.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { PluginOptions } from './types';
22
import { Plugin } from 'vue';
33
import { default as FieldLabel } from './components/shared/FieldLabel.vue';
44
import { default as VStepperForm } from './VStepperForm.vue';
5-
export declare const globalOptions: unique symbol;
65
export declare function createVStepperForm(options?: PluginOptions): Plugin;
76
export default VStepperForm;
87
export { FieldLabel, VStepperForm, };

dist/plugin/utils/globals.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
import { InjectionKey } from 'vue';
2+
import { PluginOptions } from '../types';
13
export declare const componentName = "v-stepper-form";
4+
export declare const pluginOptionsInjectionKey: InjectionKey<PluginOptions>;

dist/vuetify-stepper-form.cjs.js

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vuetify-stepper-form.es.js

+731-732
Large diffs are not rendered by default.

eslint.config.mjs

+3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ export default tseslint.config(
1111
...wdnsConfig,
1212
{
1313
ignores: [
14+
'*__TEMP.*',
15+
'*__TEMP/',
1416
'**/*.cy.ts',
1517
'**/cypress/**',
1618
'cypress.config.ts',
19+
'src/playground/*',
1720
'src/playground/configs/templates/PlaygroundPage.vue',
1821
'src/types/cypress.d.ts',
1922
'vite.build.config.mts',

src/documentation/components/examples/ConditionalFieldExample.vue

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<template>
22
<VStepperForm
3-
v-model="answers"
3+
v-model="formAnswers"
44
:pages="pages"
55
@submit="submitForm"
66
/>
77

88
<AnswersDialog
99
v-model="dialog"
10-
:answers="answers"
10+
:answers="formAnswers"
1111
/>
1212
</template>
1313

@@ -17,7 +17,7 @@ import AnswersDialog from '../AnswersDialog.vue';
1717
1818
1919
const dialog = ref(false);
20-
const answers = ref({
20+
const formAnswers = ref({
2121
bar: null,
2222
conditionalParent: null,
2323
foo: null,
@@ -46,16 +46,16 @@ const pages = [
4646
label: 'Foo',
4747
name: 'foo',
4848
type: 'text' as const,
49-
when() {
50-
return answers.value.conditionalParent === 'foo';
49+
when(answers: any) {
50+
return answers.conditionalParent === 'foo';
5151
},
5252
},
5353
{
5454
label: 'Bar',
5555
name: 'bar',
5656
type: 'text' as const,
57-
when() {
58-
return answers.value.conditionalParent === 'bar';
57+
when(answers: any) {
58+
return answers.conditionalParent === 'bar';
5959
},
6060
},
6161
],
@@ -68,7 +68,7 @@ function submitForm(): void {
6868
6969
const templateCode = `<template>
7070
<VStepperForm
71-
v-model="answers"
71+
v-model="formAnswers"
7272
:pages="pages"
7373
@submit="submitForm"
7474
/>
@@ -79,7 +79,7 @@ const scriptCode = `\<script setup\>
7979
import { ref } from 'vue';
8080
8181
82-
const answers = ref({
82+
const formAnswers = ref({
8383
bar: null,
8484
conditionalParent: null,
8585
foo: null,
@@ -108,16 +108,16 @@ const pages = [
108108
label: 'Foo',
109109
name: 'foo',
110110
type: 'text' as const,
111-
when() {
112-
return answers.value.conditionalParent === 'foo';
111+
when(answers) {
112+
return answers.conditionalParent === 'foo';
113113
},
114114
},
115115
{
116116
label: 'Bar',
117117
name: 'bar',
118118
type: 'text' as const,
119-
when() {
120-
return answers.value.conditionalParent === 'bar';
119+
when(answers) {
120+
return answers.conditionalParent === 'bar';
121121
},
122122
},
123123
],

src/documentation/components/examples/FieldSlotExample.vue

+19-29
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,35 @@
44
:pages="pages"
55
@submit="submitForm"
66
>
7-
<template #[`field.foo`]="{ errorMessage, field, blur, change, input, FieldLabel }">
7+
<template #[`field.foo`]="props">
88
<v-text-field
9-
v-model="answers.foo"
10-
v-bind="field"
11-
:error="errorMessage"
12-
:error-messages="errorMessage"
13-
@blur="blur"
14-
@change="change"
15-
@input="input"
9+
v-bind="props.field"
10+
@blur="props.blur()"
11+
@change="props.change()"
12+
@input="props.input()"
13+
@update:modelValue="props.onUpdate($event)"
1614
>
1715
<template #label>
1816
<component
19-
:is="FieldLabel"
20-
:label="field.label"
21-
:required="!!field.required"
17+
:is="props.FieldLabel"
18+
:label="props.field.label"
2219
/>
2320
</template>
2421
</v-text-field>
2522
</template>
2623

2724
<template #[`field.bar`]="props">
2825
<v-text-field
29-
v-model="answers.bar"
3026
v-bind="props.field"
31-
:error="props.errorMessage"
32-
:error-messages="props.errorMessage"
3327
@blur="props.blur()"
3428
@change="props.change()"
3529
@input="props.input()"
30+
@update:modelValue="props.onUpdate($event)"
3631
>
3732
<template #label>
3833
<component
3934
:is="props.FieldLabel"
4035
:label="props.field.label"
41-
:required="!!props.field.required"
4236
/>
4337
</template>
4438
</v-text-field>
@@ -91,35 +85,31 @@ const templateCode = `<template>
9185
title="Field Slots"
9286
@submit="submitForm"
9387
>
94-
<template #[\`field.foo\`]="{ errorMessage, field, blur, change, input, FieldLabel }">
88+
<template #[\`field.foo\`]="props">
9589
<v-text-field
96-
v-model="answers.foo"
97-
v-bind="field"
98-
:error="errorMessage"
99-
:error-messages="errorMessage"
100-
@blur="blur"
101-
@change="change"
102-
@input="input"
90+
v-bind="props.field"
91+
@blur="props.blur()"
92+
@change="props.change()"
93+
@input="props.input()"
94+
@update:modelValue="props.onUpdate($event)"
10395
>
10496
<template #label>
10597
<component
106-
:is="FieldLabel"
107-
:label="field.label"
108-
:required="!!field.required"
98+
:is="props.FieldLabel"
99+
:label="props.field.label"
100+
:required="!!props.field.required"
109101
/>
110102
</template>
111103
</v-text-field>
112104
</template>
113105
114106
<template #[\`field.bar\`]="props">
115107
<v-text-field
116-
v-model="answers.bar"
117108
v-bind="props.field"
118-
:error="props.errorMessage"
119-
:error-messages="props.errorMessage"
120109
@blur="props.blur()"
121110
@change="props.change()"
122111
@input="props.input()"
112+
@update:modelValue="props.onUpdate($event)"
123113
>
124114
<template #label>
125115
<component

src/documentation/sections/SlotsSection.vue

+12-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@
4040
>[`field.${string}`]</a>
4141
</span>
4242
</td>
43-
<td>
44-
Slot that is used for adding your own fields
43+
<td class="compact">
44+
Slot for adding custom fields. Ensure to include the <code class="ic">onUpdate($event)</code> event
45+
listener so the form can detect and handle updates properly. Refer to the <a
46+
href="#examples-field-slots"
47+
>Field Slot</a> example for usage.
4548
</td>
4649
</tr>
4750
<tr>
@@ -86,6 +89,9 @@ const displaySlotsCode = `{
8689
change: () => void,
8790
input: () => void,
8891
92+
// Updating the model value
93+
onUpdate: (value: any) => void,
94+
8995
// Internal FieldLabel component
9096
FieldLabel: Component
9197
}`;
@@ -101,6 +107,10 @@ const displaySlotsCode = `{
101107
> div {
102108
padding: 0.5rem 0 !important;
103109
}
110+
111+
&.compact {
112+
line-height: 1.4 !important;
113+
}
104114
}
105115
}
106116
</style>

src/playground/configs/playground.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ import PlaygroundApp from './PlaygroundApp.vue';
1010

1111
const app = createApp(PlaygroundApp);
1212

13+
app.use(createVStepperForm({
14+
// variant: 'outlined',
15+
},
16+
));
1317
app.use(createVCodeBlock());
14-
app.use(createVStepperForm());
1518
app.use(createPinia());
1619
app.component('font-awesome-icon', FontAwesomeIcon);
1720

0 commit comments

Comments
 (0)