@nuxt/ui 0.4.1 → 2.8.1
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/LICENSE.md +9 -0
- package/README.md +63 -50
- package/dist/module.cjs +5 -0
- package/dist/module.d.mts +1234 -0
- package/dist/module.d.ts +1234 -0
- package/dist/module.json +8 -0
- package/dist/module.mjs +407 -0
- package/dist/runtime/app.config.d.ts +1203 -0
- package/dist/runtime/app.config.mjs +1057 -0
- package/dist/runtime/components/data/Table.vue +251 -0
- package/dist/runtime/components/data/Table.vue.d.ts +215 -0
- package/dist/runtime/components/elements/Accordion.vue +138 -0
- package/dist/runtime/components/elements/Accordion.vue.d.ts +80 -0
- package/dist/runtime/components/elements/Alert.vue +120 -0
- package/dist/runtime/components/elements/Alert.vue.d.ts +107 -0
- package/dist/runtime/components/elements/Avatar.vue +149 -0
- package/dist/runtime/components/elements/Avatar.vue.d.ts +115 -0
- package/dist/runtime/components/elements/AvatarGroup.d.ts +37 -0
- package/dist/runtime/components/elements/AvatarGroup.mjs +53 -0
- package/dist/runtime/components/elements/Badge.vue +69 -0
- package/dist/runtime/components/elements/Badge.vue.d.ts +63 -0
- package/dist/runtime/components/elements/Button.vue +182 -0
- package/dist/runtime/components/elements/Button.vue.d.ts +187 -0
- package/dist/runtime/components/elements/ButtonGroup.d.ts +39 -0
- package/dist/runtime/components/elements/ButtonGroup.mjs +70 -0
- package/dist/runtime/components/elements/Dropdown.vue +172 -0
- package/dist/runtime/components/elements/Dropdown.vue.d.ts +96 -0
- package/dist/runtime/components/elements/Icon.vue +15 -0
- package/dist/runtime/components/elements/Icon.vue.d.ts +12 -0
- package/dist/runtime/components/elements/Kbd.vue +55 -0
- package/dist/runtime/components/elements/Kbd.vue.d.ts +42 -0
- package/dist/runtime/components/elements/Link.vue +80 -0
- package/dist/runtime/components/elements/Link.vue.d.ts +9 -0
- package/dist/runtime/components/forms/Checkbox.vue +136 -0
- package/dist/runtime/components/forms/Checkbox.vue.d.ts +129 -0
- package/dist/runtime/components/forms/Form.vue +185 -0
- package/dist/runtime/components/forms/Form.vue.d.ts +50 -0
- package/dist/runtime/components/forms/FormGroup.vue +97 -0
- package/dist/runtime/components/forms/FormGroup.vue.d.ts +98 -0
- package/dist/runtime/components/forms/Input.vue +250 -0
- package/dist/runtime/components/forms/Input.vue.d.ts +214 -0
- package/dist/runtime/components/forms/Radio.vue +122 -0
- package/dist/runtime/components/forms/Radio.vue.d.ts +109 -0
- package/dist/runtime/components/forms/Range.vue +163 -0
- package/dist/runtime/components/forms/Range.vue.d.ts +119 -0
- package/dist/runtime/components/forms/Select.vue +307 -0
- package/dist/runtime/components/forms/Select.vue.d.ts +229 -0
- package/dist/runtime/components/forms/SelectMenu.vue +429 -0
- package/dist/runtime/components/forms/SelectMenu.vue.d.ts +330 -0
- package/dist/runtime/components/forms/Textarea.vue +184 -0
- package/dist/runtime/components/forms/Textarea.vue.d.ts +161 -0
- package/dist/runtime/components/forms/Toggle.vue +113 -0
- package/dist/runtime/components/forms/Toggle.vue.d.ts +83 -0
- package/dist/runtime/components/layout/Card.vue +58 -0
- package/dist/runtime/components/layout/Card.vue.d.ts +31 -0
- package/dist/runtime/components/layout/Container.vue +43 -0
- package/dist/runtime/components/layout/Container.vue.d.ts +31 -0
- package/dist/runtime/components/layout/Skeleton.vue +37 -0
- package/dist/runtime/components/layout/Skeleton.vue.d.ts +22 -0
- package/dist/runtime/components/navigation/CommandPalette.vue +304 -0
- package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +224 -0
- package/dist/runtime/components/navigation/CommandPaletteGroup.vue +152 -0
- package/dist/runtime/components/navigation/CommandPaletteGroup.vue.d.ts +63 -0
- package/dist/runtime/components/navigation/Pagination.vue +197 -0
- package/dist/runtime/components/navigation/Pagination.vue.d.ts +125 -0
- package/dist/runtime/components/navigation/Tabs.vue +138 -0
- package/dist/runtime/components/navigation/Tabs.vue.d.ts +69 -0
- package/dist/runtime/components/navigation/VerticalNavigation.vue +79 -0
- package/dist/runtime/components/navigation/VerticalNavigation.vue.d.ts +37 -0
- package/dist/runtime/components/overlays/ContextMenu.vue +74 -0
- package/dist/runtime/components/overlays/ContextMenu.vue.d.ts +54 -0
- package/dist/runtime/components/overlays/Modal.vue +113 -0
- package/dist/runtime/components/overlays/Modal.vue.d.ts +82 -0
- package/dist/runtime/components/overlays/Notification.vue +197 -0
- package/dist/runtime/components/overlays/Notification.vue.d.ts +126 -0
- package/dist/runtime/components/overlays/Notifications.vue +61 -0
- package/dist/runtime/components/overlays/Notifications.vue.d.ts +41 -0
- package/dist/runtime/components/overlays/Popover.vue +139 -0
- package/dist/runtime/components/overlays/Popover.vue.d.ts +82 -0
- package/dist/runtime/components/overlays/Slideover.vue +103 -0
- package/dist/runtime/components/overlays/Slideover.vue.d.ts +84 -0
- package/dist/runtime/components/overlays/Tooltip.vue +118 -0
- package/dist/runtime/components/overlays/Tooltip.vue.d.ts +82 -0
- package/dist/runtime/composables/defineShortcuts.d.ts +13 -0
- package/dist/runtime/composables/defineShortcuts.mjs +108 -0
- package/dist/runtime/composables/useCopyToClipboard.d.ts +10 -0
- package/dist/runtime/composables/useCopyToClipboard.mjs +26 -0
- package/dist/runtime/composables/useFormGroup.d.ts +6 -0
- package/dist/runtime/composables/useFormGroup.mjs +30 -0
- package/dist/runtime/composables/usePopper.d.ts +232 -0
- package/dist/runtime/composables/usePopper.mjs +78 -0
- package/dist/runtime/composables/useShortcuts.d.ts +12 -0
- package/dist/runtime/composables/useShortcuts.mjs +24 -0
- package/dist/runtime/composables/useTimer.d.ts +8 -0
- package/dist/runtime/composables/useTimer.mjs +51 -0
- package/dist/runtime/composables/useToast.d.ts +18 -0
- package/dist/runtime/composables/useToast.mjs +22 -0
- package/dist/runtime/plugins/colors.d.ts +2 -0
- package/dist/runtime/plugins/colors.mjs +46 -0
- package/dist/runtime/types/accordion.d.ts +9 -0
- package/dist/runtime/types/avatar.d.ts +9 -0
- package/dist/runtime/types/button.d.ts +23 -0
- package/dist/runtime/types/clipboard.d.ts +3 -0
- package/dist/runtime/types/command-palette.d.ts +26 -0
- package/dist/runtime/types/dropdown.d.ts +13 -0
- package/dist/runtime/types/form.d.ts +21 -0
- package/dist/runtime/types/index.d.ts +12 -0
- package/dist/runtime/types/link.d.ts +8 -0
- package/dist/runtime/types/notification.d.ts +22 -0
- package/dist/runtime/types/popper.d.ts +14 -0
- package/dist/runtime/types/tabs.d.ts +6 -0
- package/dist/runtime/types/vertical-navigation.d.ts +11 -0
- package/dist/runtime/ui.css +13 -0
- package/dist/runtime/utils/StateEmitter.d.ts +17 -0
- package/dist/runtime/utils/StateEmitter.mjs +21 -0
- package/dist/runtime/utils/index.d.ts +11 -0
- package/dist/runtime/utils/index.mjs +33 -0
- package/dist/types.d.mts +15 -0
- package/dist/types.d.ts +15 -0
- package/package.json +56 -39
- package/LICENSE +0 -21
- package/dist/assets/styles.css +0 -14
- package/dist/components/NButton.vue +0 -22
- package/dist/components/NCard.vue +0 -5
- package/dist/components/NCheckbox.vue +0 -35
- package/dist/components/NDarkToggle.vue +0 -28
- package/dist/components/NDialog.vue +0 -59
- package/dist/components/NDropdown.vue +0 -31
- package/dist/components/NIcon.vue +0 -9
- package/dist/components/NLink.vue +0 -20
- package/dist/components/NRadio.vue +0 -40
- package/dist/components/NSwitch.vue +0 -37
- package/dist/components/NTextInput.vue +0 -34
- package/dist/components/NTip.vue +0 -16
- package/dist/components/NuxtContentLogo.vue +0 -7
- package/dist/components/NuxtExampleLayout.vue +0 -82
- package/dist/components/NuxtLogo.vue +0 -20
- package/dist/components/nuxt/NDarkToggle.vue +0 -28
- package/dist/nuxt.d.ts +0 -16
- package/dist/nuxt.mjs +0 -36
- package/dist/unocss.d.ts +0 -7
- package/dist/unocss.mjs +0 -127
- package/nuxt.cjs +0 -7
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
import type { PropType } from 'vue';
|
|
3
|
+
declare const _default: import("vue").DefineComponent<{
|
|
4
|
+
value: {
|
|
5
|
+
type: (ObjectConstructor | BooleanConstructor | StringConstructor | NumberConstructor)[];
|
|
6
|
+
default: null;
|
|
7
|
+
};
|
|
8
|
+
modelValue: {
|
|
9
|
+
type: (BooleanConstructor | ArrayConstructor)[];
|
|
10
|
+
default: null;
|
|
11
|
+
};
|
|
12
|
+
name: {
|
|
13
|
+
type: StringConstructor;
|
|
14
|
+
default: null;
|
|
15
|
+
};
|
|
16
|
+
disabled: {
|
|
17
|
+
type: BooleanConstructor;
|
|
18
|
+
default: boolean;
|
|
19
|
+
};
|
|
20
|
+
checked: {
|
|
21
|
+
type: BooleanConstructor;
|
|
22
|
+
default: boolean;
|
|
23
|
+
};
|
|
24
|
+
indeterminate: {
|
|
25
|
+
type: BooleanConstructor;
|
|
26
|
+
default: boolean;
|
|
27
|
+
};
|
|
28
|
+
help: {
|
|
29
|
+
type: StringConstructor;
|
|
30
|
+
default: null;
|
|
31
|
+
};
|
|
32
|
+
label: {
|
|
33
|
+
type: StringConstructor;
|
|
34
|
+
default: null;
|
|
35
|
+
};
|
|
36
|
+
required: {
|
|
37
|
+
type: BooleanConstructor;
|
|
38
|
+
default: boolean;
|
|
39
|
+
};
|
|
40
|
+
color: {
|
|
41
|
+
type: StringConstructor;
|
|
42
|
+
default: () => any;
|
|
43
|
+
validator(value: string): any;
|
|
44
|
+
};
|
|
45
|
+
inputClass: {
|
|
46
|
+
type: StringConstructor;
|
|
47
|
+
default: string;
|
|
48
|
+
};
|
|
49
|
+
ui: {
|
|
50
|
+
type: PropType<any>;
|
|
51
|
+
default: () => {};
|
|
52
|
+
};
|
|
53
|
+
}, {
|
|
54
|
+
attrs: import("lodash").Omit<{
|
|
55
|
+
[x: string]: unknown;
|
|
56
|
+
}, "class">;
|
|
57
|
+
ui: import("vue").ComputedRef<any>;
|
|
58
|
+
toggle: import("vue").WritableComputedRef<boolean | unknown[]>;
|
|
59
|
+
wrapperClass: import("vue").ComputedRef<string>;
|
|
60
|
+
inputClass: import("vue").ComputedRef<string>;
|
|
61
|
+
onChange: (event: Event) => void;
|
|
62
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "update:modelValue")[], "change" | "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
63
|
+
value: {
|
|
64
|
+
type: (ObjectConstructor | BooleanConstructor | StringConstructor | NumberConstructor)[];
|
|
65
|
+
default: null;
|
|
66
|
+
};
|
|
67
|
+
modelValue: {
|
|
68
|
+
type: (BooleanConstructor | ArrayConstructor)[];
|
|
69
|
+
default: null;
|
|
70
|
+
};
|
|
71
|
+
name: {
|
|
72
|
+
type: StringConstructor;
|
|
73
|
+
default: null;
|
|
74
|
+
};
|
|
75
|
+
disabled: {
|
|
76
|
+
type: BooleanConstructor;
|
|
77
|
+
default: boolean;
|
|
78
|
+
};
|
|
79
|
+
checked: {
|
|
80
|
+
type: BooleanConstructor;
|
|
81
|
+
default: boolean;
|
|
82
|
+
};
|
|
83
|
+
indeterminate: {
|
|
84
|
+
type: BooleanConstructor;
|
|
85
|
+
default: boolean;
|
|
86
|
+
};
|
|
87
|
+
help: {
|
|
88
|
+
type: StringConstructor;
|
|
89
|
+
default: null;
|
|
90
|
+
};
|
|
91
|
+
label: {
|
|
92
|
+
type: StringConstructor;
|
|
93
|
+
default: null;
|
|
94
|
+
};
|
|
95
|
+
required: {
|
|
96
|
+
type: BooleanConstructor;
|
|
97
|
+
default: boolean;
|
|
98
|
+
};
|
|
99
|
+
color: {
|
|
100
|
+
type: StringConstructor;
|
|
101
|
+
default: () => any;
|
|
102
|
+
validator(value: string): any;
|
|
103
|
+
};
|
|
104
|
+
inputClass: {
|
|
105
|
+
type: StringConstructor;
|
|
106
|
+
default: string;
|
|
107
|
+
};
|
|
108
|
+
ui: {
|
|
109
|
+
type: PropType<any>;
|
|
110
|
+
default: () => {};
|
|
111
|
+
};
|
|
112
|
+
}>> & {
|
|
113
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
114
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
115
|
+
}, {
|
|
116
|
+
color: string;
|
|
117
|
+
ui: any;
|
|
118
|
+
name: string;
|
|
119
|
+
value: string | number | boolean | Record<string, any>;
|
|
120
|
+
label: string;
|
|
121
|
+
modelValue: boolean | unknown[];
|
|
122
|
+
indeterminate: boolean;
|
|
123
|
+
disabled: boolean;
|
|
124
|
+
required: boolean;
|
|
125
|
+
checked: boolean;
|
|
126
|
+
help: string;
|
|
127
|
+
inputClass: string;
|
|
128
|
+
}, {}>;
|
|
129
|
+
export default _default;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<form @submit.prevent="onSubmit">
|
|
3
|
+
<slot />
|
|
4
|
+
</form>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import { provide, ref, defineComponent } from "vue";
|
|
9
|
+
import { useEventBus } from "@vueuse/core";
|
|
10
|
+
export default defineComponent({
|
|
11
|
+
props: {
|
|
12
|
+
schema: {
|
|
13
|
+
type: Object,
|
|
14
|
+
default: void 0
|
|
15
|
+
},
|
|
16
|
+
state: {
|
|
17
|
+
type: Object,
|
|
18
|
+
required: true
|
|
19
|
+
},
|
|
20
|
+
validate: {
|
|
21
|
+
type: Function,
|
|
22
|
+
default: () => []
|
|
23
|
+
},
|
|
24
|
+
validateOn: {
|
|
25
|
+
type: Array,
|
|
26
|
+
default: () => ["blur", "input", "change", "submit"]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
emits: ["submit"],
|
|
30
|
+
setup(props, { expose, emit }) {
|
|
31
|
+
const seed = Math.random().toString(36).substring(7);
|
|
32
|
+
const bus = useEventBus(`form-${seed}`);
|
|
33
|
+
bus.on(async (event) => {
|
|
34
|
+
if (event.type !== "submit" && props.validateOn?.includes(event.type)) {
|
|
35
|
+
await validate(event.path, { silent: true });
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const errors = ref([]);
|
|
39
|
+
provide("form-errors", errors);
|
|
40
|
+
provide("form-events", bus);
|
|
41
|
+
async function getErrors() {
|
|
42
|
+
let errs = await props.validate(props.state);
|
|
43
|
+
if (props.schema) {
|
|
44
|
+
if (isZodSchema(props.schema)) {
|
|
45
|
+
errs = errs.concat(await getZodErrors(props.state, props.schema));
|
|
46
|
+
} else if (isYupSchema(props.schema)) {
|
|
47
|
+
errs = errs.concat(await getYupErrors(props.state, props.schema));
|
|
48
|
+
} else if (isJoiSchema(props.schema)) {
|
|
49
|
+
errs = errs.concat(await getJoiErrors(props.state, props.schema));
|
|
50
|
+
} else if (isValibotSchema(props.schema)) {
|
|
51
|
+
errs = errs.concat(await getValibotError(props.state, props.schema));
|
|
52
|
+
} else {
|
|
53
|
+
throw new Error("Form validation failed: Unsupported form schema");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return errs;
|
|
57
|
+
}
|
|
58
|
+
async function validate(path, opts = { silent: false }) {
|
|
59
|
+
if (path) {
|
|
60
|
+
const otherErrors = errors.value.filter(
|
|
61
|
+
(error) => error.path !== path
|
|
62
|
+
);
|
|
63
|
+
const pathErrors = (await getErrors()).filter(
|
|
64
|
+
(error) => error.path === path
|
|
65
|
+
);
|
|
66
|
+
errors.value = otherErrors.concat(pathErrors);
|
|
67
|
+
} else {
|
|
68
|
+
errors.value = await getErrors();
|
|
69
|
+
}
|
|
70
|
+
if (!opts.silent && errors.value.length > 0) {
|
|
71
|
+
throw new Error(
|
|
72
|
+
`Form validation failed: ${JSON.stringify(errors.value, null, 2)}`
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
return props.state;
|
|
76
|
+
}
|
|
77
|
+
async function onSubmit(event) {
|
|
78
|
+
if (props.validateOn?.includes("submit")) {
|
|
79
|
+
await validate();
|
|
80
|
+
}
|
|
81
|
+
const submitEvent = event;
|
|
82
|
+
submitEvent.data = props.state;
|
|
83
|
+
emit("submit", event);
|
|
84
|
+
}
|
|
85
|
+
expose({
|
|
86
|
+
validate,
|
|
87
|
+
errors,
|
|
88
|
+
setErrors(errs, path) {
|
|
89
|
+
errors.value = errs;
|
|
90
|
+
if (path) {
|
|
91
|
+
errors.value = errors.value.filter(
|
|
92
|
+
(error) => error.path !== path
|
|
93
|
+
).concat(errs);
|
|
94
|
+
} else {
|
|
95
|
+
errors.value = errs;
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
getErrors(path) {
|
|
99
|
+
if (path) {
|
|
100
|
+
return errors.value.filter((err) => err.path === path);
|
|
101
|
+
}
|
|
102
|
+
return errors.value;
|
|
103
|
+
},
|
|
104
|
+
clear(path) {
|
|
105
|
+
if (path) {
|
|
106
|
+
errors.value = errors.value.filter((err) => err.path === path);
|
|
107
|
+
} else {
|
|
108
|
+
errors.value = [];
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
return {
|
|
113
|
+
onSubmit
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
function isYupSchema(schema) {
|
|
118
|
+
return schema.validate && schema.__isYupSchema__;
|
|
119
|
+
}
|
|
120
|
+
function isYupError(error) {
|
|
121
|
+
return error.inner !== void 0;
|
|
122
|
+
}
|
|
123
|
+
async function getYupErrors(state, schema) {
|
|
124
|
+
try {
|
|
125
|
+
await schema.validate(state, { abortEarly: false });
|
|
126
|
+
return [];
|
|
127
|
+
} catch (error) {
|
|
128
|
+
if (isYupError(error)) {
|
|
129
|
+
return error.inner.map((issue) => ({
|
|
130
|
+
path: issue.path ?? "",
|
|
131
|
+
message: issue.message
|
|
132
|
+
}));
|
|
133
|
+
} else {
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function isZodSchema(schema) {
|
|
139
|
+
return schema.parse !== void 0;
|
|
140
|
+
}
|
|
141
|
+
async function getZodErrors(state, schema) {
|
|
142
|
+
const result = await schema.safeParseAsync(state);
|
|
143
|
+
if (result.success === false) {
|
|
144
|
+
return result.error.issues.map((issue) => ({
|
|
145
|
+
path: issue.path.join("."),
|
|
146
|
+
message: issue.message
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
return [];
|
|
150
|
+
}
|
|
151
|
+
function isJoiSchema(schema) {
|
|
152
|
+
return schema.validateAsync !== void 0 && schema.id !== void 0;
|
|
153
|
+
}
|
|
154
|
+
function isJoiError(error) {
|
|
155
|
+
return error.isJoi === true;
|
|
156
|
+
}
|
|
157
|
+
async function getJoiErrors(state, schema) {
|
|
158
|
+
try {
|
|
159
|
+
await schema.validateAsync(state, { abortEarly: false });
|
|
160
|
+
return [];
|
|
161
|
+
} catch (error) {
|
|
162
|
+
if (isJoiError(error)) {
|
|
163
|
+
return error.details.map((detail) => ({
|
|
164
|
+
path: detail.path.join("."),
|
|
165
|
+
message: detail.message
|
|
166
|
+
}));
|
|
167
|
+
} else {
|
|
168
|
+
throw error;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function isValibotSchema(schema) {
|
|
173
|
+
return schema._parse !== void 0;
|
|
174
|
+
}
|
|
175
|
+
async function getValibotError(state, schema) {
|
|
176
|
+
const result = await schema._parse(state);
|
|
177
|
+
if (result.issues) {
|
|
178
|
+
return result.issues.map((issue) => ({
|
|
179
|
+
path: issue.path.map((p) => p.key).join("."),
|
|
180
|
+
message: issue.message
|
|
181
|
+
}));
|
|
182
|
+
}
|
|
183
|
+
return [];
|
|
184
|
+
}
|
|
185
|
+
</script>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type PropType } from 'vue';
|
|
2
|
+
import type { ZodSchema } from 'zod';
|
|
3
|
+
import type { Schema as JoiSchema } from 'joi';
|
|
4
|
+
import type { ObjectSchema as YupObjectSchema } from 'yup';
|
|
5
|
+
import type { ObjectSchemaAsync as ValibotObjectSchema } from 'valibot';
|
|
6
|
+
import type { FormError, FormEventType } from '../../types/form';
|
|
7
|
+
declare const _default: import("vue").DefineComponent<{
|
|
8
|
+
schema: {
|
|
9
|
+
type: PropType<ZodSchema<any, import("zod").ZodTypeDef, any>> | PropType<YupObjectSchema<any, import("yup").AnyObject, any, "">> | PropType<JoiSchema> | PropType<ValibotObjectSchema<any>>;
|
|
10
|
+
default: undefined;
|
|
11
|
+
};
|
|
12
|
+
state: {
|
|
13
|
+
type: ObjectConstructor;
|
|
14
|
+
required: true;
|
|
15
|
+
};
|
|
16
|
+
validate: {
|
|
17
|
+
type: PropType<(state: any) => Promise<FormError[]>> | PropType<(state: any) => FormError[]>;
|
|
18
|
+
default: () => never[];
|
|
19
|
+
};
|
|
20
|
+
validateOn: {
|
|
21
|
+
type: PropType<FormEventType[]>;
|
|
22
|
+
default: () => string[];
|
|
23
|
+
};
|
|
24
|
+
}, {
|
|
25
|
+
onSubmit: (event: SubmitEvent) => Promise<void>;
|
|
26
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "submit"[], "submit", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
27
|
+
schema: {
|
|
28
|
+
type: PropType<ZodSchema<any, import("zod").ZodTypeDef, any>> | PropType<YupObjectSchema<any, import("yup").AnyObject, any, "">> | PropType<JoiSchema> | PropType<ValibotObjectSchema<any>>;
|
|
29
|
+
default: undefined;
|
|
30
|
+
};
|
|
31
|
+
state: {
|
|
32
|
+
type: ObjectConstructor;
|
|
33
|
+
required: true;
|
|
34
|
+
};
|
|
35
|
+
validate: {
|
|
36
|
+
type: PropType<(state: any) => Promise<FormError[]>> | PropType<(state: any) => FormError[]>;
|
|
37
|
+
default: () => never[];
|
|
38
|
+
};
|
|
39
|
+
validateOn: {
|
|
40
|
+
type: PropType<FormEventType[]>;
|
|
41
|
+
default: () => string[];
|
|
42
|
+
};
|
|
43
|
+
}>> & {
|
|
44
|
+
onSubmit?: ((...args: any[]) => any) | undefined;
|
|
45
|
+
}, {
|
|
46
|
+
schema: ZodSchema<any, import("zod").ZodTypeDef, any> | YupObjectSchema<any, import("yup").AnyObject, any, ""> | import("joi").AnySchema<any> | ValibotObjectSchema<any>;
|
|
47
|
+
validate: ((state: any) => Promise<FormError[]>) | ((state: any) => FormError[]);
|
|
48
|
+
validateOn: FormEventType[];
|
|
49
|
+
}, {}>;
|
|
50
|
+
export default _default;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="wrapperClass" v-bind="attrs">
|
|
3
|
+
<label>
|
|
4
|
+
<div v-if="label" :class="[ui.label.wrapper, size]">
|
|
5
|
+
<p :class="[ui.label.base, required ? ui.label.required : '']">{{ label }}</p>
|
|
6
|
+
<span v-if="hint" :class="[ui.hint]">{{ hint }}</span>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
<p v-if="description" :class="[ui.description, size]">{{ description }}</p>
|
|
10
|
+
|
|
11
|
+
<div :class="[label ? ui.container : '']">
|
|
12
|
+
<slot v-bind="{ error }" />
|
|
13
|
+
|
|
14
|
+
<p v-if="error && typeof error !== 'boolean'" :class="[ui.error, size]">{{ error }}</p>
|
|
15
|
+
<p v-else-if="help" :class="[ui.help, size]">{{ help }}</p>
|
|
16
|
+
</div>
|
|
17
|
+
</label>
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script>
|
|
22
|
+
import { computed, defineComponent, provide, inject } from "vue";
|
|
23
|
+
import { omit } from "lodash-es";
|
|
24
|
+
import { twMerge } from "tailwind-merge";
|
|
25
|
+
import { defuTwMerge } from "../../utils";
|
|
26
|
+
import { useAppConfig } from "#imports";
|
|
27
|
+
import appConfig from "#build/app.config";
|
|
28
|
+
export default defineComponent({
|
|
29
|
+
inheritAttrs: false,
|
|
30
|
+
props: {
|
|
31
|
+
name: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: null
|
|
34
|
+
},
|
|
35
|
+
size: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: null,
|
|
38
|
+
validator(value) {
|
|
39
|
+
return Object.keys(appConfig.ui.formGroup.size).includes(value);
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
label: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: null
|
|
45
|
+
},
|
|
46
|
+
description: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: null
|
|
49
|
+
},
|
|
50
|
+
required: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: false
|
|
53
|
+
},
|
|
54
|
+
help: {
|
|
55
|
+
type: String,
|
|
56
|
+
default: null
|
|
57
|
+
},
|
|
58
|
+
error: {
|
|
59
|
+
type: [String, Boolean],
|
|
60
|
+
default: null
|
|
61
|
+
},
|
|
62
|
+
hint: {
|
|
63
|
+
type: String,
|
|
64
|
+
default: null
|
|
65
|
+
},
|
|
66
|
+
ui: {
|
|
67
|
+
type: Object,
|
|
68
|
+
default: () => ({})
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
setup(props, { attrs }) {
|
|
72
|
+
const appConfig2 = useAppConfig();
|
|
73
|
+
const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.formGroup));
|
|
74
|
+
const wrapperClass = computed(() => twMerge(ui.value.wrapper, attrs.class));
|
|
75
|
+
const formErrors = inject("form-errors", null);
|
|
76
|
+
const error = computed(() => {
|
|
77
|
+
return props.error && typeof props.error === "string" || typeof props.error === "boolean" ? props.error : formErrors?.value?.find((error2) => error2.path === props.name)?.message;
|
|
78
|
+
});
|
|
79
|
+
const size = computed(() => ui.value.size[props.size ?? appConfig2.ui.input.default.size]);
|
|
80
|
+
provide("form-group", {
|
|
81
|
+
error,
|
|
82
|
+
name: computed(() => props.name),
|
|
83
|
+
size: computed(() => props.size)
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
attrs: omit(attrs, ["class"]),
|
|
87
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
88
|
+
ui,
|
|
89
|
+
wrapperClass,
|
|
90
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
91
|
+
size,
|
|
92
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
93
|
+
error
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
</script>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
import type { PropType } from 'vue';
|
|
3
|
+
declare const _default: import("vue").DefineComponent<{
|
|
4
|
+
name: {
|
|
5
|
+
type: StringConstructor;
|
|
6
|
+
default: null;
|
|
7
|
+
};
|
|
8
|
+
size: {
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
default: null;
|
|
11
|
+
validator(value: string): boolean;
|
|
12
|
+
};
|
|
13
|
+
label: {
|
|
14
|
+
type: StringConstructor;
|
|
15
|
+
default: null;
|
|
16
|
+
};
|
|
17
|
+
description: {
|
|
18
|
+
type: StringConstructor;
|
|
19
|
+
default: null;
|
|
20
|
+
};
|
|
21
|
+
required: {
|
|
22
|
+
type: BooleanConstructor;
|
|
23
|
+
default: boolean;
|
|
24
|
+
};
|
|
25
|
+
help: {
|
|
26
|
+
type: StringConstructor;
|
|
27
|
+
default: null;
|
|
28
|
+
};
|
|
29
|
+
error: {
|
|
30
|
+
type: (BooleanConstructor | StringConstructor)[];
|
|
31
|
+
default: null;
|
|
32
|
+
};
|
|
33
|
+
hint: {
|
|
34
|
+
type: StringConstructor;
|
|
35
|
+
default: null;
|
|
36
|
+
};
|
|
37
|
+
ui: {
|
|
38
|
+
type: PropType<any>;
|
|
39
|
+
default: () => {};
|
|
40
|
+
};
|
|
41
|
+
}, {
|
|
42
|
+
attrs: import("lodash").Omit<{
|
|
43
|
+
[x: string]: unknown;
|
|
44
|
+
}, "class">;
|
|
45
|
+
ui: import("vue").ComputedRef<any>;
|
|
46
|
+
wrapperClass: import("vue").ComputedRef<string>;
|
|
47
|
+
size: import("vue").ComputedRef<any>;
|
|
48
|
+
error: import("vue").ComputedRef<any>;
|
|
49
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
50
|
+
name: {
|
|
51
|
+
type: StringConstructor;
|
|
52
|
+
default: null;
|
|
53
|
+
};
|
|
54
|
+
size: {
|
|
55
|
+
type: StringConstructor;
|
|
56
|
+
default: null;
|
|
57
|
+
validator(value: string): boolean;
|
|
58
|
+
};
|
|
59
|
+
label: {
|
|
60
|
+
type: StringConstructor;
|
|
61
|
+
default: null;
|
|
62
|
+
};
|
|
63
|
+
description: {
|
|
64
|
+
type: StringConstructor;
|
|
65
|
+
default: null;
|
|
66
|
+
};
|
|
67
|
+
required: {
|
|
68
|
+
type: BooleanConstructor;
|
|
69
|
+
default: boolean;
|
|
70
|
+
};
|
|
71
|
+
help: {
|
|
72
|
+
type: StringConstructor;
|
|
73
|
+
default: null;
|
|
74
|
+
};
|
|
75
|
+
error: {
|
|
76
|
+
type: (BooleanConstructor | StringConstructor)[];
|
|
77
|
+
default: null;
|
|
78
|
+
};
|
|
79
|
+
hint: {
|
|
80
|
+
type: StringConstructor;
|
|
81
|
+
default: null;
|
|
82
|
+
};
|
|
83
|
+
ui: {
|
|
84
|
+
type: PropType<any>;
|
|
85
|
+
default: () => {};
|
|
86
|
+
};
|
|
87
|
+
}>>, {
|
|
88
|
+
error: string | boolean;
|
|
89
|
+
description: string;
|
|
90
|
+
ui: any;
|
|
91
|
+
name: string;
|
|
92
|
+
label: string;
|
|
93
|
+
required: boolean;
|
|
94
|
+
size: string;
|
|
95
|
+
help: string;
|
|
96
|
+
hint: string;
|
|
97
|
+
}, {}>;
|
|
98
|
+
export default _default;
|