@nuxt/ui 2.18.6 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.d.mts +1 -1
- package/dist/module.d.ts +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +3 -3
- package/dist/runtime/components/data/Table.vue +82 -27
- package/dist/runtime/components/data/Table.vue.d.ts +49 -41
- package/dist/runtime/components/elements/Alert.vue.d.ts +1 -1
- package/dist/runtime/components/elements/AvatarGroup.js +2 -2
- package/dist/runtime/components/elements/Carousel.vue +16 -7
- package/dist/runtime/components/elements/Carousel.vue.d.ts +9 -0
- package/dist/runtime/components/elements/Dropdown.vue +7 -3
- package/dist/runtime/components/elements/MeterGroup.d.ts +1 -1
- package/dist/runtime/components/elements/Progress.vue +1 -1
- package/dist/runtime/components/forms/Checkbox.vue.d.ts +5 -5
- package/dist/runtime/components/forms/Form.vue +104 -43
- package/dist/runtime/components/forms/Form.vue.d.ts +5 -3
- package/dist/runtime/components/forms/Input.vue +5 -2
- package/dist/runtime/components/forms/Input.vue.d.ts +5 -2
- package/dist/runtime/components/forms/InputMenu.vue +419 -8
- package/dist/runtime/components/forms/InputMenu.vue.d.ts +22 -3
- package/dist/runtime/components/forms/Radio.vue.d.ts +5 -5
- package/dist/runtime/components/forms/RadioGroup.vue +3 -4
- package/dist/runtime/components/forms/RadioGroup.vue.d.ts +8 -8
- package/dist/runtime/components/forms/Range.vue.d.ts +2 -2
- package/dist/runtime/components/forms/Select.vue.d.ts +3 -3
- package/dist/runtime/components/forms/SelectMenu.vue +501 -11
- package/dist/runtime/components/forms/SelectMenu.vue.d.ts +33 -5
- package/dist/runtime/components/forms/Textarea.vue +7 -4
- package/dist/runtime/components/forms/Textarea.vue.d.ts +5 -2
- package/dist/runtime/components/forms/Toggle.vue.d.ts +2 -2
- package/dist/runtime/components/layout/Divider.vue +1 -1
- package/dist/runtime/components/layout/Divider.vue.d.ts +5 -2
- package/dist/runtime/components/navigation/CommandPalette.vue +1 -1
- package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +1 -1
- package/dist/runtime/components/navigation/CommandPaletteGroup.vue.d.ts +1 -1
- package/dist/runtime/components/navigation/Pagination.vue +4 -4
- package/dist/runtime/components/navigation/Pagination.vue.d.ts +1 -1
- package/dist/runtime/components/navigation/Tabs.vue +1 -1
- package/dist/runtime/components/navigation/VerticalNavigation.vue.d.ts +6 -2
- package/dist/runtime/components/overlays/Modal.vue +1 -1
- package/dist/runtime/components/overlays/Notification.vue.d.ts +1 -1
- package/dist/runtime/components/overlays/Notifications.vue +1 -1
- package/dist/runtime/components/overlays/Notifications.vue.d.ts +1 -1
- package/dist/runtime/components/overlays/Popover.vue +7 -3
- package/dist/runtime/components/overlays/Tooltip.vue +5 -3
- package/dist/runtime/components/overlays/Tooltip.vue.d.ts +1 -0
- package/dist/runtime/composables/defineShortcuts.js +1 -1
- package/dist/runtime/composables/useButtonGroup.d.ts +1 -1
- package/dist/runtime/composables/useUI.js +1 -1
- package/dist/runtime/plugins/modals.js +1 -1
- package/dist/runtime/plugins/slideovers.js +1 -1
- package/dist/runtime/types/accordion.d.ts +1 -1
- package/dist/runtime/types/alert.d.ts +4 -4
- package/dist/runtime/types/avatar.d.ts +3 -3
- package/dist/runtime/types/badge.d.ts +3 -3
- package/dist/runtime/types/button.d.ts +3 -5
- package/dist/runtime/types/chip.d.ts +2 -2
- package/dist/runtime/types/command-palette.d.ts +2 -2
- package/dist/runtime/types/component.d.ts +3 -3
- package/dist/runtime/types/divider.d.ts +3 -3
- package/dist/runtime/types/dropdown.d.ts +1 -1
- package/dist/runtime/types/form-group.d.ts +2 -2
- package/dist/runtime/types/form.d.ts +7 -2
- package/dist/runtime/types/index.d.ts +1 -0
- package/dist/runtime/types/index.js +1 -0
- package/dist/runtime/types/input.d.ts +3 -3
- package/dist/runtime/types/kbd.d.ts +2 -2
- package/dist/runtime/types/meter.d.ts +2 -2
- package/dist/runtime/types/modal.d.ts +2 -2
- package/dist/runtime/types/notification.d.ts +1 -1
- package/dist/runtime/types/progress.d.ts +2 -2
- package/dist/runtime/types/range.d.ts +3 -3
- package/dist/runtime/types/select.d.ts +3 -3
- package/dist/runtime/types/table.d.ts +18 -0
- package/dist/runtime/types/textarea.d.ts +3 -3
- package/dist/runtime/types/toggle.d.ts +3 -3
- package/dist/runtime/types/utils.d.ts +2 -2
- package/dist/runtime/ui.config/data/table.d.ts +1 -0
- package/dist/runtime/ui.config/data/table.js +1 -0
- package/dist/runtime/ui.config/elements/avatar.js +15 -15
- package/dist/runtime/ui.config/elements/button.js +25 -25
- package/dist/runtime/ui.config/elements/buttonGroup.js +1 -1
- package/dist/runtime/ui.config/elements/carousel.js +2 -2
- package/dist/runtime/ui.config/elements/chip.js +5 -5
- package/dist/runtime/ui.config/elements/meter.js +20 -20
- package/dist/runtime/ui.config/elements/meterGroup.js +1 -1
- package/dist/runtime/ui.config/elements/progress.js +18 -18
- package/dist/runtime/ui.config/forms/formGroup.js +5 -6
- package/dist/runtime/ui.config/forms/input.js +40 -40
- package/dist/runtime/ui.config/forms/inputMenu.d.ts +6 -0
- package/dist/runtime/ui.config/forms/inputMenu.js +7 -1
- package/dist/runtime/ui.config/forms/range.js +20 -20
- package/dist/runtime/ui.config/forms/selectMenu.d.ts +9 -0
- package/dist/runtime/ui.config/forms/selectMenu.js +10 -1
- package/dist/runtime/ui.config/forms/toggle.js +20 -20
- package/dist/runtime/ui.config/layout/divider.d.ts +1 -0
- package/dist/runtime/ui.config/layout/divider.js +12 -11
- package/dist/runtime/ui.config/navigation/horizontalNavigation.js +1 -1
- package/dist/runtime/ui.config/navigation/verticalNavigation.js +1 -1
- package/dist/runtime/ui.config/popper.js +0 -1
- package/dist/runtime/utils/colors.js +7 -7
- package/dist/runtime/utils/index.js +4 -4
- package/dist/runtime/utils/link.js +1 -1
- package/dist/runtime/utils/lodash.js +1 -1
- package/package.json +23 -21
|
@@ -166,7 +166,7 @@ export default defineComponent({
|
|
|
166
166
|
}
|
|
167
167
|
});
|
|
168
168
|
function onTouchStart(event) {
|
|
169
|
-
if (!event.cancelable || !menuApi.value) {
|
|
169
|
+
if (!event.cancelable || !menuApi.value || props.mode === "click") {
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
172
|
if (menuApi.value.menuState === 0) {
|
|
@@ -187,7 +187,9 @@ export default defineComponent({
|
|
|
187
187
|
return;
|
|
188
188
|
}
|
|
189
189
|
openTimeout = openTimeout || setTimeout(() => {
|
|
190
|
-
|
|
190
|
+
if (menuApi.value.openMenu) {
|
|
191
|
+
menuApi.value.openMenu();
|
|
192
|
+
}
|
|
191
193
|
openTimeout = null;
|
|
192
194
|
}, props.openDelay);
|
|
193
195
|
}
|
|
@@ -203,7 +205,9 @@ export default defineComponent({
|
|
|
203
205
|
return;
|
|
204
206
|
}
|
|
205
207
|
closeTimeout = closeTimeout || setTimeout(() => {
|
|
206
|
-
|
|
208
|
+
if (menuApi.value.closeMenu) {
|
|
209
|
+
menuApi.value.closeMenu();
|
|
210
|
+
}
|
|
207
211
|
closeTimeout = null;
|
|
208
212
|
}, props.closeDelay);
|
|
209
213
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { VNode, SlotsType, PropType } from 'vue';
|
|
2
|
-
import Meter from './Meter.vue.js';
|
|
3
2
|
import type { Strategy, MeterSize } from '../../types/index.js';
|
|
3
|
+
import type Meter from './Meter.vue.js';
|
|
4
4
|
declare const meterGroupConfig: {
|
|
5
5
|
wrapper: string;
|
|
6
6
|
base: string;
|
|
@@ -199,5 +199,5 @@ export default defineComponent({
|
|
|
199
199
|
</script>
|
|
200
200
|
|
|
201
201
|
<style scoped>
|
|
202
|
-
progress:indeterminate{@apply relative}progress:indeterminate:after{@apply content-[""];@apply absolute inset-0;@apply bg-current}progress:indeterminate::-webkit-progress-value{@apply bg-current}progress:indeterminate::-moz-progress-bar{@apply bg-current}progress:indeterminate.bar-animation-carousel:after{animation:carousel 2s ease-in-out infinite}progress:indeterminate.bar-animation-carousel::-webkit-progress-value{animation:carousel 2s ease-in-out infinite}progress:indeterminate.bar-animation-carousel::-moz-progress-bar{animation:carousel 2s ease-in-out infinite}progress:indeterminate.bar-animation-carousel-inverse:after{animation:carousel-inverse 2s ease-in-out infinite}progress:indeterminate.bar-animation-carousel-inverse::-webkit-progress-value{animation:carousel-inverse 2s ease-in-out infinite}progress:indeterminate.bar-animation-carousel-inverse::-moz-progress-bar{animation:carousel-inverse 2s ease-in-out infinite}progress:indeterminate.bar-animation-swing:after{animation:swing 3s ease-in-out infinite}progress:indeterminate.bar-animation-swing::-webkit-progress-value{animation:swing 3s ease-in-out infinite}progress:indeterminate.bar-animation-swing::-moz-progress-bar{animation:swing 3s ease-in-out infinite}progress:indeterminate.bar-animation-elastic:after{animation:elastic 3s ease-in-out infinite}progress:indeterminate.bar-animation-elastic::-webkit-progress-value{animation:elastic 3s ease-in-out infinite}progress:indeterminate.bar-animation-elastic::-moz-progress-bar{animation:elastic 3s ease-in-out infinite}@keyframes carousel{0%,to{width:50%}0%{transform:translateX(-100%)}to{transform:translateX(200%)}}@keyframes carousel-inverse{0%,to{width:50%}0%{transform:translateX(200%)}to{transform:translateX(-100%)}}@keyframes swing{0%,to{width:50%}0%,to{transform:translateX(-25%)}50%{transform:translateX(125%)}}@keyframes elastic{0%,to{margin-left:25%;width:50%}50%{margin-left:5%;width:90%}}
|
|
202
|
+
progress:indeterminate{@apply relative}progress:indeterminate:after{@apply content-[""];@apply absolute inset-0;@apply bg-current}progress:indeterminate::-webkit-progress-value{@apply bg-current}progress:indeterminate::-moz-progress-bar{@apply bg-current}progress:indeterminate.bar-animation-carousel:after{animation:carousel 2s ease-in-out infinite}progress:indeterminate.bar-animation-carousel::-webkit-progress-value{animation:carousel 2s ease-in-out infinite}progress:indeterminate.bar-animation-carousel::-moz-progress-bar{animation:carousel 2s ease-in-out infinite}[dir=rtl] progress:indeterminate.bar-animation-carousel:after{animation:carousel-rtl 2s ease-in-out infinite}[dir=rtl] progress:indeterminate.bar-animation-carousel::-webkit-progress-value{animation:carousel-rtl 2s ease-in-out infinite}[dir=rtl] progress:indeterminate.bar-animation-carousel::-moz-progress-bar{animation:carousel-rtl 2s ease-in-out infinite}progress:indeterminate.bar-animation-carousel-inverse:after{animation:carousel-inverse 2s ease-in-out infinite}progress:indeterminate.bar-animation-carousel-inverse::-webkit-progress-value{animation:carousel-inverse 2s ease-in-out infinite}progress:indeterminate.bar-animation-carousel-inverse::-moz-progress-bar{animation:carousel-inverse 2s ease-in-out infinite}[dir=rtl] progress:indeterminate.bar-animation-carousel-inverse:after{animation:carousel-inverse-rtl 2s ease-in-out infinite}[dir=rtl] progress:indeterminate.bar-animation-carousel-inverse::-webkit-progress-value{animation:carousel-inverse-rtl 2s ease-in-out infinite}[dir=rtl] progress:indeterminate.bar-animation-carousel-inverse::-moz-progress-bar{animation:carousel-inverse-rtl 2s ease-in-out infinite}progress:indeterminate.bar-animation-swing:after{animation:swing 3s ease-in-out infinite}progress:indeterminate.bar-animation-swing::-webkit-progress-value{animation:swing 3s ease-in-out infinite}progress:indeterminate.bar-animation-swing::-moz-progress-bar{animation:swing 3s ease-in-out infinite}progress:indeterminate.bar-animation-elastic:after{animation:elastic 3s ease-in-out infinite}progress:indeterminate.bar-animation-elastic::-webkit-progress-value{animation:elastic 3s ease-in-out infinite}progress:indeterminate.bar-animation-elastic::-moz-progress-bar{animation:elastic 3s ease-in-out infinite}@keyframes carousel{0%,to{width:50%}0%{transform:translateX(-100%)}to{transform:translateX(200%)}}@keyframes carousel-rtl{0%,to{width:50%}0%{transform:translateX(100%)}to{transform:translateX(-200%)}}@keyframes carousel-inverse{0%,to{width:50%}0%{transform:translateX(200%)}to{transform:translateX(-100%)}}@keyframes carousel-inverse-rtl{0%,to{width:50%}0%{transform:translateX(-200%)}to{transform:translateX(100%)}}@keyframes swing{0%,to{width:50%}0%,to{transform:translateX(-25%)}50%{transform:translateX(125%)}}@keyframes elastic{0%,to{margin-left:25%;width:50%}50%{margin-left:5%;width:90%}}
|
|
203
203
|
</style>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PropType } from 'vue';
|
|
2
2
|
import type { DeepPartial, Strategy } from '../../types/index.js';
|
|
3
|
-
import colors from '#ui-colors';
|
|
3
|
+
import type colors from '#ui-colors';
|
|
4
4
|
declare const config: {
|
|
5
5
|
wrapper: string;
|
|
6
6
|
container: string;
|
|
@@ -29,7 +29,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
29
29
|
default: any;
|
|
30
30
|
};
|
|
31
31
|
modelValue: {
|
|
32
|
-
type:
|
|
32
|
+
type: PropType<boolean | Array<any> | null>;
|
|
33
33
|
default: any;
|
|
34
34
|
};
|
|
35
35
|
name: {
|
|
@@ -97,7 +97,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
97
97
|
attrs: import("vue").ComputedRef<Pick<{
|
|
98
98
|
[x: string]: unknown;
|
|
99
99
|
}, string>>;
|
|
100
|
-
toggle: import("vue").WritableComputedRef<boolean |
|
|
100
|
+
toggle: import("vue").WritableComputedRef<boolean | any[], boolean | any[]>;
|
|
101
101
|
inputId: string;
|
|
102
102
|
name: import("vue").ComputedRef<string>;
|
|
103
103
|
inputClass: import("vue").ComputedRef<string>;
|
|
@@ -112,7 +112,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
112
112
|
default: any;
|
|
113
113
|
};
|
|
114
114
|
modelValue: {
|
|
115
|
-
type:
|
|
115
|
+
type: PropType<boolean | Array<any> | null>;
|
|
116
116
|
default: any;
|
|
117
117
|
};
|
|
118
118
|
name: {
|
|
@@ -191,7 +191,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
191
191
|
strategy?: Strategy;
|
|
192
192
|
};
|
|
193
193
|
id: string;
|
|
194
|
-
modelValue: boolean |
|
|
194
|
+
modelValue: boolean | any[];
|
|
195
195
|
value: string | number | boolean | Record<string, any>;
|
|
196
196
|
help: string;
|
|
197
197
|
indeterminate: boolean;
|
|
@@ -56,16 +56,11 @@ export default defineComponent({
|
|
|
56
56
|
async function getErrors() {
|
|
57
57
|
let errs = await props.validate(props.state);
|
|
58
58
|
if (props.schema) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
errs = errs.concat(await getYupErrors(props.state, props.schema));
|
|
63
|
-
} else if (isJoiSchema(props.schema)) {
|
|
64
|
-
errs = errs.concat(await getJoiErrors(props.state, props.schema));
|
|
65
|
-
} else if (isValibotSchema(props.schema)) {
|
|
66
|
-
errs = errs.concat(await getValibotError(props.state, props.schema));
|
|
59
|
+
const { errors: errors2, result } = await parseSchema(props.state, props.schema);
|
|
60
|
+
if (errors2) {
|
|
61
|
+
errs = errs.concat(errors2);
|
|
67
62
|
} else {
|
|
68
|
-
|
|
63
|
+
Object.assign(props.state, result);
|
|
69
64
|
}
|
|
70
65
|
}
|
|
71
66
|
return errs;
|
|
@@ -157,64 +152,130 @@ function isYupSchema(schema) {
|
|
|
157
152
|
function isYupError(error) {
|
|
158
153
|
return error.inner !== void 0;
|
|
159
154
|
}
|
|
160
|
-
|
|
155
|
+
function isSuperStructSchema(schema) {
|
|
156
|
+
return "schema" in schema && typeof schema.coercer === "function" && typeof schema.validator === "function" && typeof schema.refiner === "function";
|
|
157
|
+
}
|
|
158
|
+
function isJoiSchema(schema) {
|
|
159
|
+
return schema.validateAsync !== void 0 && schema.id !== void 0;
|
|
160
|
+
}
|
|
161
|
+
function isJoiError(error) {
|
|
162
|
+
return error.isJoi === true;
|
|
163
|
+
}
|
|
164
|
+
function isValibotSchema(schema) {
|
|
165
|
+
return "_parse" in schema || "_run" in schema || typeof schema === "function" && "schema" in schema;
|
|
166
|
+
}
|
|
167
|
+
function isZodSchema(schema) {
|
|
168
|
+
return schema.parse !== void 0;
|
|
169
|
+
}
|
|
170
|
+
async function validateValibotSchema(state, schema) {
|
|
171
|
+
const result = await ("_parse" in schema ? schema._parse(state) : "_run" in schema ? schema._run({ typed: false, value: state }, {}) : schema(state));
|
|
172
|
+
if (!result.issues || result.issues.length === 0) {
|
|
173
|
+
const output = "output" in result ? result.output : "value" in result ? result.value : null;
|
|
174
|
+
return {
|
|
175
|
+
errors: null,
|
|
176
|
+
result: output
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
const errors = result.issues.map((issue) => ({
|
|
180
|
+
path: issue.path?.map((item) => item.key).join(".") || "",
|
|
181
|
+
message: issue.message
|
|
182
|
+
}));
|
|
183
|
+
return {
|
|
184
|
+
errors,
|
|
185
|
+
result: null
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
async function validateJoiSchema(state, schema) {
|
|
161
189
|
try {
|
|
162
|
-
await schema.
|
|
163
|
-
return
|
|
190
|
+
await schema.validateAsync(state, { abortEarly: false });
|
|
191
|
+
return {
|
|
192
|
+
errors: null,
|
|
193
|
+
result: state
|
|
194
|
+
};
|
|
164
195
|
} catch (error) {
|
|
165
|
-
if (
|
|
166
|
-
|
|
167
|
-
path: issue.path
|
|
196
|
+
if (isJoiError(error)) {
|
|
197
|
+
const errors = error.details.map((issue) => ({
|
|
198
|
+
path: issue.path.join("."),
|
|
168
199
|
message: issue.message
|
|
169
200
|
}));
|
|
201
|
+
return {
|
|
202
|
+
errors,
|
|
203
|
+
result: null
|
|
204
|
+
};
|
|
170
205
|
} else {
|
|
171
206
|
throw error;
|
|
172
207
|
}
|
|
173
208
|
}
|
|
174
209
|
}
|
|
175
|
-
function
|
|
176
|
-
return schema.parse !== void 0;
|
|
177
|
-
}
|
|
178
|
-
async function getZodErrors(state, schema) {
|
|
210
|
+
async function validateZodSchema(state, schema) {
|
|
179
211
|
const result = await schema.safeParseAsync(state);
|
|
180
212
|
if (result.success === false) {
|
|
181
|
-
|
|
213
|
+
const errors = result.error.issues.map((issue) => ({
|
|
182
214
|
path: issue.path.join("."),
|
|
183
215
|
message: issue.message
|
|
184
216
|
}));
|
|
217
|
+
return {
|
|
218
|
+
errors,
|
|
219
|
+
result: null
|
|
220
|
+
};
|
|
185
221
|
}
|
|
186
|
-
return
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
222
|
+
return {
|
|
223
|
+
result: result.data,
|
|
224
|
+
errors: null
|
|
225
|
+
};
|
|
190
226
|
}
|
|
191
|
-
function
|
|
192
|
-
|
|
227
|
+
async function validateSuperstructSchema(state, schema) {
|
|
228
|
+
const [err, result] = schema.validate(state);
|
|
229
|
+
if (err) {
|
|
230
|
+
const errors = err.failures().map((error) => ({
|
|
231
|
+
message: error.message,
|
|
232
|
+
path: error.path.join(".")
|
|
233
|
+
}));
|
|
234
|
+
return {
|
|
235
|
+
errors,
|
|
236
|
+
result: null
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
errors: null,
|
|
241
|
+
result
|
|
242
|
+
};
|
|
193
243
|
}
|
|
194
|
-
async function
|
|
244
|
+
async function validateYupSchema(state, schema) {
|
|
195
245
|
try {
|
|
196
|
-
|
|
197
|
-
return
|
|
246
|
+
const result = schema.validateSync(state, { abortEarly: false });
|
|
247
|
+
return {
|
|
248
|
+
errors: null,
|
|
249
|
+
result
|
|
250
|
+
};
|
|
198
251
|
} catch (error) {
|
|
199
|
-
if (
|
|
200
|
-
|
|
201
|
-
path:
|
|
202
|
-
message:
|
|
252
|
+
if (isYupError(error)) {
|
|
253
|
+
const errors = error.inner.map((issue) => ({
|
|
254
|
+
path: issue.path ?? "",
|
|
255
|
+
message: issue.message
|
|
203
256
|
}));
|
|
257
|
+
return {
|
|
258
|
+
errors,
|
|
259
|
+
result: null
|
|
260
|
+
};
|
|
204
261
|
} else {
|
|
205
262
|
throw error;
|
|
206
263
|
}
|
|
207
264
|
}
|
|
208
265
|
}
|
|
209
|
-
function
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}))
|
|
266
|
+
function parseSchema(state, schema) {
|
|
267
|
+
if (isZodSchema(schema)) {
|
|
268
|
+
return validateZodSchema(state, schema);
|
|
269
|
+
} else if (isJoiSchema(schema)) {
|
|
270
|
+
return validateJoiSchema(state, schema);
|
|
271
|
+
} else if (isValibotSchema(schema)) {
|
|
272
|
+
return validateValibotSchema(state, schema);
|
|
273
|
+
} else if (isYupSchema(schema)) {
|
|
274
|
+
return validateYupSchema(state, schema);
|
|
275
|
+
} else if (isSuperStructSchema(schema)) {
|
|
276
|
+
return validateSuperstructSchema(state, schema);
|
|
277
|
+
} else {
|
|
278
|
+
throw new Error("Form validation failed: Unsupported form schema");
|
|
279
|
+
}
|
|
219
280
|
}
|
|
220
281
|
</script>
|
|
@@ -5,10 +5,12 @@ import type { ObjectSchema as YupObjectSchema } from 'yup';
|
|
|
5
5
|
import type { BaseSchema as ValibotSchema30, BaseSchemaAsync as ValibotSchemaAsync30 } from 'valibot30';
|
|
6
6
|
import type { GenericSchema as ValibotSchema31, GenericSchemaAsync as ValibotSchemaAsync31, SafeParser as ValibotSafeParser31, SafeParserAsync as ValibotSafeParserAsync31 } from 'valibot31';
|
|
7
7
|
import type { GenericSchema as ValibotSchema, GenericSchemaAsync as ValibotSchemaAsync, SafeParser as ValibotSafeParser, SafeParserAsync as ValibotSafeParserAsync } from 'valibot';
|
|
8
|
+
import type { Struct } from 'superstruct';
|
|
8
9
|
import type { FormError, FormEventType } from '../../types/form.js';
|
|
10
|
+
type Schema = PropType<ZodSchema> | PropType<YupObjectSchema<any>> | PropType<JoiSchema> | PropType<ValibotSchema30 | ValibotSchemaAsync30> | PropType<ValibotSchema31 | ValibotSchemaAsync31> | PropType<ValibotSafeParser31<any, any> | ValibotSafeParserAsync31<any, any>> | PropType<ValibotSchema | ValibotSchemaAsync> | PropType<ValibotSafeParser<any, any> | ValibotSafeParserAsync<any, any>> | PropType<Struct<any, any>>;
|
|
9
11
|
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
10
12
|
schema: {
|
|
11
|
-
type:
|
|
13
|
+
type: Schema;
|
|
12
14
|
default: any;
|
|
13
15
|
};
|
|
14
16
|
state: {
|
|
@@ -34,7 +36,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
34
36
|
}[]>>;
|
|
35
37
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("error" | "submit")[], "error" | "submit", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
36
38
|
schema: {
|
|
37
|
-
type:
|
|
39
|
+
type: Schema;
|
|
38
40
|
default: any;
|
|
39
41
|
};
|
|
40
42
|
state: {
|
|
@@ -53,7 +55,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
53
55
|
onSubmit?: (...args: any[]) => any;
|
|
54
56
|
onError?: (...args: any[]) => any;
|
|
55
57
|
}>, {
|
|
56
|
-
schema: ZodSchema<any, import("zod").ZodTypeDef, any> | YupObjectSchema<any, import("yup").AnyObject, any, ""> | import("joi").AnySchema<any> | ValibotSchema30<any, any> | ValibotSchemaAsync30<any, any> | ValibotSchema31<unknown, unknown, import("valibot31").BaseIssue<unknown>> | ValibotSchemaAsync31<unknown, unknown, import("valibot31").BaseIssue<unknown>> | ValibotSafeParser31<any, any> | ValibotSafeParserAsync31<any, any> | ValibotSchema<unknown, unknown, import("valibot").BaseIssue<unknown>> | ValibotSchemaAsync<unknown, unknown, import("valibot").BaseIssue<unknown
|
|
58
|
+
schema: ZodSchema<any, import("zod").ZodTypeDef, any> | YupObjectSchema<any, import("yup").AnyObject, any, ""> | import("joi").AnySchema<any> | ValibotSchema30<any, any> | ValibotSchemaAsync30<any, any> | ValibotSchema31<unknown, unknown, import("valibot31").BaseIssue<unknown>> | ValibotSchemaAsync31<unknown, unknown, import("valibot31").BaseIssue<unknown>> | ValibotSafeParser31<any, any> | ValibotSafeParserAsync31<any, any> | ValibotSchema<unknown, unknown, import("valibot").BaseIssue<unknown>> | ValibotSchemaAsync<unknown, unknown, import("valibot").BaseIssue<unknown>> | Struct<any, any>;
|
|
57
59
|
validate: ((state: any) => Promise<FormError[]>) | ((state: any) => FormError[]);
|
|
58
60
|
validateOn: FormEventType[];
|
|
59
61
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
<script>
|
|
34
34
|
import { ref, computed, toRef, onMounted, defineComponent } from "vue";
|
|
35
35
|
import { twMerge, twJoin } from "tailwind-merge";
|
|
36
|
-
import UIcon from "../elements/Icon.vue";
|
|
37
36
|
import { defu } from "defu";
|
|
37
|
+
import UIcon from "../elements/Icon.vue";
|
|
38
38
|
import { useUI } from "../../composables/useUI";
|
|
39
39
|
import { useFormGroup } from "../../composables/useFormGroup";
|
|
40
40
|
import { mergeConfig, looseToNumber } from "../../utils";
|
|
@@ -163,7 +163,7 @@ export default defineComponent({
|
|
|
163
163
|
const { size: sizeButtonGroup, rounded } = useInjectButtonGroup({ ui, props });
|
|
164
164
|
const { emitFormBlur, emitFormInput, size: sizeFormGroup, color, inputId, name } = useFormGroup(props, config);
|
|
165
165
|
const size = computed(() => sizeButtonGroup.value ?? sizeFormGroup.value);
|
|
166
|
-
const modelModifiers = ref(defu({}, props.modelModifiers, { trim: false, lazy: false, number: false }));
|
|
166
|
+
const modelModifiers = ref(defu({}, props.modelModifiers, { trim: false, lazy: false, number: false, nullify: false }));
|
|
167
167
|
const input2 = ref(null);
|
|
168
168
|
const autoFocus = () => {
|
|
169
169
|
if (props.autofocus) {
|
|
@@ -177,6 +177,9 @@ export default defineComponent({
|
|
|
177
177
|
if (modelModifiers.value.number || props.type === "number") {
|
|
178
178
|
value = looseToNumber(value);
|
|
179
179
|
}
|
|
180
|
+
if (modelModifiers.value.nullify) {
|
|
181
|
+
value ||= null;
|
|
182
|
+
}
|
|
180
183
|
emit("update:modelValue", value);
|
|
181
184
|
emitFormInput();
|
|
182
185
|
};
|
|
@@ -111,7 +111,7 @@ declare const config: {
|
|
|
111
111
|
};
|
|
112
112
|
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
113
113
|
modelValue: {
|
|
114
|
-
type:
|
|
114
|
+
type: PropType<string | number | null>;
|
|
115
115
|
default: string;
|
|
116
116
|
};
|
|
117
117
|
type: {
|
|
@@ -212,6 +212,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
212
212
|
trim?: boolean;
|
|
213
213
|
lazy?: boolean;
|
|
214
214
|
number?: boolean;
|
|
215
|
+
nullify?: boolean;
|
|
215
216
|
}>;
|
|
216
217
|
default: () => {};
|
|
217
218
|
};
|
|
@@ -345,7 +346,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
345
346
|
onBlur: (event: FocusEvent) => void;
|
|
346
347
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("blur" | "change" | "update:modelValue")[], "blur" | "change" | "update:modelValue", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
347
348
|
modelValue: {
|
|
348
|
-
type:
|
|
349
|
+
type: PropType<string | number | null>;
|
|
349
350
|
default: string;
|
|
350
351
|
};
|
|
351
352
|
type: {
|
|
@@ -446,6 +447,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
446
447
|
trim?: boolean;
|
|
447
448
|
lazy?: boolean;
|
|
448
449
|
number?: boolean;
|
|
450
|
+
nullify?: boolean;
|
|
449
451
|
}>;
|
|
450
452
|
default: () => {};
|
|
451
453
|
};
|
|
@@ -593,6 +595,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
593
595
|
trim?: boolean;
|
|
594
596
|
lazy?: boolean;
|
|
595
597
|
number?: boolean;
|
|
598
|
+
nullify?: boolean;
|
|
596
599
|
};
|
|
597
600
|
}, {}, {
|
|
598
601
|
UIcon: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|