@byyuurin/ui 0.0.11 → 0.1.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/README.md +170 -58
- package/dist/module.d.mts +4 -13
- package/dist/module.json +4 -4
- package/dist/module.mjs +54 -20
- package/dist/runtime/components/Accordion.vue +28 -23
- package/dist/runtime/components/Accordion.vue.d.ts +51 -29
- package/dist/runtime/components/Alert.vue +47 -27
- package/dist/runtime/components/Alert.vue.d.ts +37 -25
- package/dist/runtime/components/App.vue +9 -8
- package/dist/runtime/components/App.vue.d.ts +22 -20
- package/dist/runtime/components/Avatar.vue +65 -21
- package/dist/runtime/components/Avatar.vue.d.ts +27 -13
- package/dist/runtime/components/AvatarGroup.vue +14 -10
- package/dist/runtime/components/AvatarGroup.vue.d.ts +12 -9
- package/dist/runtime/components/Badge.vue +64 -32
- package/dist/runtime/components/Badge.vue.d.ts +30 -29
- package/dist/runtime/components/Breadcrumb.vue +40 -22
- package/dist/runtime/components/Breadcrumb.vue.d.ts +48 -21
- package/dist/runtime/components/Button.vue +113 -52
- package/dist/runtime/components/Button.vue.d.ts +36 -20
- package/dist/runtime/components/Calendar.vue +48 -39
- package/dist/runtime/components/Calendar.vue.d.ts +58 -31
- package/dist/runtime/components/Card.vue +18 -14
- package/dist/runtime/components/Card.vue.d.ts +18 -14
- package/dist/runtime/components/Carousel.vue +80 -46
- package/dist/runtime/components/Carousel.vue.d.ts +46 -25
- package/dist/runtime/components/Checkbox.vue +60 -35
- package/dist/runtime/components/Checkbox.vue.d.ts +35 -28
- package/dist/runtime/components/Chip.vue +35 -32
- package/dist/runtime/components/Chip.vue.d.ts +33 -15
- package/dist/runtime/components/Collapsible.vue +13 -9
- package/dist/runtime/components/Collapsible.vue.d.ts +16 -8
- package/dist/runtime/components/Drawer.vue +80 -70
- package/dist/runtime/components/Drawer.vue.d.ts +51 -28
- package/dist/runtime/components/DropdownMenu.vue +23 -16
- package/dist/runtime/components/DropdownMenu.vue.d.ts +77 -36
- package/dist/runtime/components/DropdownMenuContent.vue +133 -103
- package/dist/runtime/components/DropdownMenuContent.vue.d.ts +38 -26
- package/dist/runtime/components/FieldGroup.vue +33 -0
- package/dist/runtime/components/FieldGroup.vue.d.ts +33 -0
- package/dist/runtime/components/Form.vue +172 -88
- package/dist/runtime/components/Form.vue.d.ts +69 -44
- package/dist/runtime/components/FormField.vue +108 -0
- package/dist/runtime/components/FormField.vue.d.ts +63 -0
- package/dist/runtime/components/Icon.vue +20 -0
- package/dist/runtime/components/Icon.vue.d.ts +9 -0
- package/dist/runtime/components/Input.vue +82 -77
- package/dist/runtime/components/Input.vue.d.ts +55 -43
- package/dist/runtime/components/InputNumber.vue +65 -49
- package/dist/runtime/components/InputNumber.vue.d.ts +51 -105
- package/dist/runtime/components/Kbd.vue +11 -5
- package/dist/runtime/components/Kbd.vue.d.ts +17 -11
- package/dist/runtime/components/Link.vue +54 -197
- package/dist/runtime/components/Link.vue.d.ts +17 -17
- package/dist/runtime/components/LinkBase.vue +11 -33
- package/dist/runtime/components/LinkBase.vue.d.ts +8 -3
- package/dist/runtime/components/Modal.vue +53 -39
- package/dist/runtime/components/Modal.vue.d.ts +64 -34
- package/dist/runtime/components/NavigationMenu.vue +336 -0
- package/dist/runtime/components/NavigationMenu.vue.d.ts +181 -0
- package/dist/runtime/components/OverlayProvider.vue +3 -3
- package/dist/runtime/components/OverlayProvider.vue.d.ts +2 -1
- package/dist/runtime/components/Pagination.vue +39 -47
- package/dist/runtime/components/Pagination.vue.d.ts +54 -31
- package/dist/runtime/components/PinInput.vue +46 -32
- package/dist/runtime/components/PinInput.vue.d.ts +40 -21
- package/dist/runtime/components/Popover.vue +33 -19
- package/dist/runtime/components/Popover.vue.d.ts +57 -32
- package/dist/runtime/components/Progress.vue +31 -26
- package/dist/runtime/components/Progress.vue.d.ts +32 -23
- package/dist/runtime/components/RadioGroup.vue +75 -48
- package/dist/runtime/components/RadioGroup.vue.d.ts +58 -36
- package/dist/runtime/components/ScrollArea.vue +33 -31
- package/dist/runtime/components/ScrollArea.vue.d.ts +9 -5
- package/dist/runtime/components/Select.vue +166 -76
- package/dist/runtime/components/Select.vue.d.ts +206 -65
- package/dist/runtime/components/Separator.vue +42 -16
- package/dist/runtime/components/Separator.vue.d.ts +35 -14
- package/dist/runtime/components/Skeleton.vue +18 -6
- package/dist/runtime/components/Skeleton.vue.d.ts +4 -4
- package/dist/runtime/components/Slider.vue +42 -24
- package/dist/runtime/components/Slider.vue.d.ts +43 -27
- package/dist/runtime/components/Switch.vue +40 -31
- package/dist/runtime/components/Switch.vue.d.ts +36 -27
- package/dist/runtime/components/Table.vue +279 -51
- package/dist/runtime/components/Table.vue.d.ts +151 -65
- package/dist/runtime/components/Tabs.vue +70 -23
- package/dist/runtime/components/Tabs.vue.d.ts +61 -29
- package/dist/runtime/components/Textarea.vue +102 -54
- package/dist/runtime/components/Textarea.vue.d.ts +57 -41
- package/dist/runtime/components/Toast.vue +84 -38
- package/dist/runtime/components/Toast.vue.d.ts +48 -27
- package/dist/runtime/components/ToastProvider.vue +31 -22
- package/dist/runtime/components/ToastProvider.vue.d.ts +30 -17
- package/dist/runtime/components/Tooltip.vue +33 -21
- package/dist/runtime/components/Tooltip.vue.d.ts +37 -15
- package/dist/runtime/composables/defineShortcuts.d.ts +16 -0
- package/dist/runtime/composables/defineShortcuts.js +129 -0
- package/dist/runtime/composables/useAvatarGroup.d.ts +8 -3
- package/dist/runtime/composables/useAvatarGroup.js +10 -3
- package/dist/runtime/composables/useComponentIcons.d.ts +9 -6
- package/dist/runtime/composables/useComponentIcons.js +4 -4
- package/dist/runtime/composables/useFieldGroup.d.ts +8 -0
- package/dist/runtime/composables/useFieldGroup.js +14 -0
- package/dist/runtime/composables/useFormField.d.ts +62 -0
- package/dist/runtime/composables/useFormField.js +99 -0
- package/dist/runtime/composables/useKbd.d.ts +3 -2
- package/dist/runtime/composables/useKbd.js +3 -2
- package/dist/runtime/composables/useLocale.d.ts +68 -5
- package/dist/runtime/composables/useLocale.js +11 -11
- package/dist/runtime/composables/useOverlay.d.ts +51 -15
- package/dist/runtime/composables/useOverlay.js +44 -30
- package/dist/runtime/composables/usePortal.d.ts +6 -0
- package/dist/runtime/composables/usePortal.js +17 -0
- package/dist/runtime/composables/useToast.d.ts +12 -5
- package/dist/runtime/composables/useToast.js +12 -7
- package/dist/runtime/locale/en.d.ts +30 -1
- package/dist/runtime/locale/en.js +2 -1
- package/dist/runtime/locale/index.d.ts +2 -2
- package/dist/runtime/locale/index.js +1 -1
- package/dist/runtime/locale/zh_tw.d.ts +31 -0
- package/dist/runtime/locale/{zh-tw.js → zh_tw.js} +2 -1
- package/dist/runtime/plugins/colors.d.ts +2 -0
- package/dist/runtime/plugins/colors.js +50 -0
- package/dist/runtime/types/app.config.d.ts +6 -0
- package/dist/runtime/types/form.d.ts +58 -17
- package/dist/runtime/types/form.js +11 -0
- package/dist/runtime/types/index.d.ts +51 -8
- package/dist/runtime/types/index.js +45 -2
- package/dist/runtime/types/input.d.ts +8 -0
- package/dist/runtime/types/locale.d.ts +5 -0
- package/dist/runtime/types/style.d.ts +33 -0
- package/dist/runtime/types/style.js +0 -0
- package/dist/runtime/types/unocss.d.ts +4 -0
- package/dist/runtime/types/utils.d.ts +38 -37
- package/dist/runtime/utils/form.d.ts +5 -1
- package/dist/runtime/utils/form.js +49 -0
- package/dist/runtime/utils/index.d.ts +10 -13
- package/dist/runtime/utils/index.js +41 -48
- package/dist/runtime/utils/link.d.ts +3 -2
- package/dist/runtime/utils/link.js +16 -2
- package/dist/runtime/utils/locale.d.ts +5 -0
- package/dist/runtime/utils/locale.js +10 -0
- package/dist/runtime/utils/style.d.ts +94 -0
- package/dist/runtime/utils/style.js +37 -0
- package/dist/runtime/vue/components/Icon.vue +15 -0
- package/dist/runtime/vue/components/Icon.vue.d.ts +7 -0
- package/dist/runtime/vue/components/Link.vue +163 -0
- package/dist/runtime/vue/components/Link.vue.d.ts +95 -0
- package/dist/runtime/vue/composables/useAppConfig.d.ts +1 -0
- package/dist/runtime/vue/composables/useAppConfig.js +4 -0
- package/dist/runtime/vue/plugins/color-mode.d.ts +4 -0
- package/dist/runtime/vue/plugins/color-mode.js +6 -0
- package/dist/runtime/vue/plugins/head.d.ts +4 -0
- package/dist/runtime/vue/plugins/head.js +9 -0
- package/dist/runtime/vue/stubs.d.ts +16 -1
- package/dist/runtime/vue/stubs.js +32 -1
- package/dist/setup.d.mts +13 -0
- package/dist/setup.mjs +12 -0
- package/dist/shared/ui.CzIlLITK.mjs +51 -0
- package/dist/shared/ui.DSyJHSTk.mjs +3787 -0
- package/dist/shared/ui.DpbffTXs.d.mts +84 -0
- package/dist/shared/ui.IulR-OYx.d.mts +64 -0
- package/dist/types.d.mts +3 -1
- package/dist/unocss.d.mts +12 -52
- package/dist/unocss.mjs +144 -254
- package/dist/unplugin.d.mts +13 -26
- package/dist/unplugin.mjs +193 -18
- package/dist/vite.d.mts +10 -1
- package/dist/vite.mjs +12 -3
- package/package.json +154 -87
- package/vue-plugin.d.ts +5 -0
- package/dist/module.d.ts +0 -13
- package/dist/module.mjs.map +0 -1
- package/dist/runtime/app/injections.d.ts +0 -9331
- package/dist/runtime/app/injections.js +0 -61
- package/dist/runtime/components/ButtonGroup.vue +0 -26
- package/dist/runtime/components/ButtonGroup.vue.d.ts +0 -26
- package/dist/runtime/components/FormItem.vue +0 -90
- package/dist/runtime/components/FormItem.vue.d.ts +0 -60
- package/dist/runtime/composables/useButtonGroup.d.ts +0 -5
- package/dist/runtime/composables/useButtonGroup.js +0 -9
- package/dist/runtime/composables/useFormItem.d.ts +0 -27
- package/dist/runtime/composables/useFormItem.js +0 -64
- package/dist/runtime/composables/useTheme.d.ts +0 -9
- package/dist/runtime/composables/useTheme.js +0 -23
- package/dist/runtime/index.d.ts +0 -44
- package/dist/runtime/index.js +0 -44
- package/dist/runtime/locale/zh-tw.d.ts +0 -2
- package/dist/runtime/theme/accordion.d.ts +0 -50
- package/dist/runtime/theme/accordion.js +0 -28
- package/dist/runtime/theme/alert.d.ts +0 -119
- package/dist/runtime/theme/alert.js +0 -47
- package/dist/runtime/theme/app.d.ts +0 -19
- package/dist/runtime/theme/app.js +0 -19
- package/dist/runtime/theme/avatar-group.d.ts +0 -46
- package/dist/runtime/theme/avatar-group.js +0 -32
- package/dist/runtime/theme/avatar.d.ts +0 -50
- package/dist/runtime/theme/avatar.js +0 -34
- package/dist/runtime/theme/badge.d.ts +0 -76
- package/dist/runtime/theme/badge.js +0 -92
- package/dist/runtime/theme/breadcrumb.d.ts +0 -61
- package/dist/runtime/theme/breadcrumb.js +0 -44
- package/dist/runtime/theme/button-group.d.ts +0 -60
- package/dist/runtime/theme/button-group.js +0 -42
- package/dist/runtime/theme/button.d.ts +0 -184
- package/dist/runtime/theme/button.js +0 -164
- package/dist/runtime/theme/calendar.d.ts +0 -58
- package/dist/runtime/theme/calendar.js +0 -86
- package/dist/runtime/theme/card.d.ts +0 -56
- package/dist/runtime/theme/card.js +0 -37
- package/dist/runtime/theme/carousel.d.ts +0 -107
- package/dist/runtime/theme/carousel.js +0 -43
- package/dist/runtime/theme/checkbox.d.ts +0 -82
- package/dist/runtime/theme/checkbox.js +0 -54
- package/dist/runtime/theme/chip.d.ts +0 -61
- package/dist/runtime/theme/chip.js +0 -66
- package/dist/runtime/theme/collapsible.d.ts +0 -32
- package/dist/runtime/theme/collapsible.js +0 -10
- package/dist/runtime/theme/drawer.d.ts +0 -142
- package/dist/runtime/theme/drawer.js +0 -113
- package/dist/runtime/theme/dropdown-menu.d.ts +0 -65
- package/dist/runtime/theme/dropdown-menu.js +0 -83
- package/dist/runtime/theme/form-item.d.ts +0 -70
- package/dist/runtime/theme/form-item.js +0 -34
- package/dist/runtime/theme/form.d.ts +0 -2
- package/dist/runtime/theme/form.js +0 -7
- package/dist/runtime/theme/index.d.ts +0 -41
- package/dist/runtime/theme/index.js +0 -41
- package/dist/runtime/theme/input-number.d.ts +0 -115
- package/dist/runtime/theme/input-number.js +0 -95
- package/dist/runtime/theme/input.d.ts +0 -172
- package/dist/runtime/theme/input.js +0 -151
- package/dist/runtime/theme/kbd.d.ts +0 -33
- package/dist/runtime/theme/kbd.js +0 -26
- package/dist/runtime/theme/link.d.ts +0 -38
- package/dist/runtime/theme/link.js +0 -26
- package/dist/runtime/theme/modal.d.ts +0 -42
- package/dist/runtime/theme/modal.js +0 -55
- package/dist/runtime/theme/pagination.d.ts +0 -74
- package/dist/runtime/theme/pagination.js +0 -17
- package/dist/runtime/theme/pinInput.d.ts +0 -94
- package/dist/runtime/theme/pinInput.js +0 -111
- package/dist/runtime/theme/popover.d.ts +0 -32
- package/dist/runtime/theme/popover.js +0 -13
- package/dist/runtime/theme/progress.d.ts +0 -180
- package/dist/runtime/theme/progress.js +0 -95
- package/dist/runtime/theme/radio-group.d.ts +0 -104
- package/dist/runtime/theme/radio-group.js +0 -61
- package/dist/runtime/theme/scroll-area.d.ts +0 -67
- package/dist/runtime/theme/scroll-area.js +0 -33
- package/dist/runtime/theme/select.d.ts +0 -186
- package/dist/runtime/theme/select.js +0 -173
- package/dist/runtime/theme/separator.d.ts +0 -74
- package/dist/runtime/theme/separator.js +0 -53
- package/dist/runtime/theme/skeleton.d.ts +0 -2
- package/dist/runtime/theme/skeleton.js +0 -7
- package/dist/runtime/theme/slider.d.ts +0 -70
- package/dist/runtime/theme/slider.js +0 -52
- package/dist/runtime/theme/switch.d.ts +0 -116
- package/dist/runtime/theme/switch.js +0 -78
- package/dist/runtime/theme/table.d.ts +0 -86
- package/dist/runtime/theme/table.js +0 -36
- package/dist/runtime/theme/tabs.d.ts +0 -129
- package/dist/runtime/theme/tabs.js +0 -146
- package/dist/runtime/theme/textarea.d.ts +0 -90
- package/dist/runtime/theme/textarea.js +0 -116
- package/dist/runtime/theme/toast-provider.d.ts +0 -116
- package/dist/runtime/theme/toast-provider.js +0 -97
- package/dist/runtime/theme/toast.d.ts +0 -83
- package/dist/runtime/theme/toast.js +0 -35
- package/dist/runtime/theme/tooltip.d.ts +0 -38
- package/dist/runtime/theme/tooltip.js +0 -11
- package/dist/runtime/types/components.d.ts +0 -42
- package/dist/runtime/utils/extend-theme.d.ts +0 -9
- package/dist/runtime/utils/extend-theme.js +0 -27
- package/dist/runtime/utils/styler.d.ts +0 -4
- package/dist/runtime/utils/styler.js +0 -10
- package/dist/runtime/utils/translator.d.ts +0 -18
- package/dist/runtime/utils/translator.js +0 -8
- package/dist/shared/ui.D1BTWZFB.mjs +0 -5
- package/dist/shared/ui.D1BTWZFB.mjs.map +0 -1
- package/dist/unocss.d.ts +0 -52
- package/dist/unocss.mjs.map +0 -1
- package/dist/unplugin.d.ts +0 -26
- package/dist/unplugin.mjs.map +0 -1
- package/dist/vite.d.ts +0 -9
- package/dist/vite.mjs.map +0 -1
- /package/dist/runtime/types/{components.js → input.js} +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
declare const _default: Required<import("@byyuurin/ui-kit").Locale<{
|
|
2
|
+
alert: {
|
|
3
|
+
close: string;
|
|
4
|
+
};
|
|
5
|
+
calendar: {
|
|
6
|
+
prevYear: string;
|
|
7
|
+
nextYear: string;
|
|
8
|
+
prevMonth: string;
|
|
9
|
+
nextMonth: string;
|
|
10
|
+
};
|
|
11
|
+
carousel: {
|
|
12
|
+
dots: string;
|
|
13
|
+
prev: string;
|
|
14
|
+
next: string;
|
|
15
|
+
goto: string;
|
|
16
|
+
};
|
|
17
|
+
inputNumber: {
|
|
18
|
+
increment: string;
|
|
19
|
+
decrement: string;
|
|
20
|
+
};
|
|
21
|
+
modal: {
|
|
22
|
+
close: string;
|
|
23
|
+
};
|
|
24
|
+
table: {
|
|
25
|
+
noData: string;
|
|
26
|
+
};
|
|
27
|
+
toast: {
|
|
28
|
+
close: string;
|
|
29
|
+
};
|
|
30
|
+
}>>;
|
|
31
|
+
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineLocale } from "../utils/
|
|
1
|
+
import { defineLocale } from "../utils/locale.js";
|
|
2
2
|
export default defineLocale({
|
|
3
3
|
name: "\u7E41\u9AD4\u4E2D\u6587",
|
|
4
4
|
code: "zh-TW",
|
|
@@ -13,6 +13,7 @@ export default defineLocale({
|
|
|
13
13
|
nextMonth: "\u4E0B\u500B\u6708"
|
|
14
14
|
},
|
|
15
15
|
carousel: {
|
|
16
|
+
dots: "\u9078\u64C7\u8981\u986F\u793A\u7684\u6295\u5F71\u7247",
|
|
16
17
|
prev: "\u4E0A\u4E00\u9801",
|
|
17
18
|
next: "\u4E0B\u4E00\u9801",
|
|
18
19
|
goto: "\u8DF3\u8F49\u5230\u7B2C {page} \u9801"
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { colors } from "@unocss/preset-wind4/colors";
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { defineNuxtPlugin, useAppConfig, useHead, useNuxtApp } from "#imports";
|
|
4
|
+
const themeShades = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
|
|
5
|
+
function getColor(color, shade) {
|
|
6
|
+
if (color in colors && typeof colors[color] === "object" && shade in colors[color])
|
|
7
|
+
return colors[color][shade];
|
|
8
|
+
return "";
|
|
9
|
+
}
|
|
10
|
+
function generateShades(key, value) {
|
|
11
|
+
return themeShades.map((shade) => `--ui-color-${key}-${shade}: var(--colors-${value === "neutral" ? "tw-neutral" : value}-${shade}, ${getColor(value, shade)});`).join("\n ");
|
|
12
|
+
}
|
|
13
|
+
function generateColor(key, shade) {
|
|
14
|
+
return `--ui-${key}: var(--ui-color-${key}-${shade});`;
|
|
15
|
+
}
|
|
16
|
+
export default defineNuxtPlugin(() => {
|
|
17
|
+
const appConfig = useAppConfig();
|
|
18
|
+
const nuxtApp = useNuxtApp();
|
|
19
|
+
const root = computed(() => {
|
|
20
|
+
const { neutral, ...colors2 } = appConfig.ui.colors;
|
|
21
|
+
return `:root {
|
|
22
|
+
${Object.entries(appConfig.ui.colors).map(([key, value]) => generateShades(key, value)).join("\n ")}
|
|
23
|
+
}
|
|
24
|
+
:root,
|
|
25
|
+
.light {
|
|
26
|
+
${Object.keys(colors2).map((key) => generateColor(key, 500)).join("\n ")}
|
|
27
|
+
}
|
|
28
|
+
.dark {
|
|
29
|
+
${Object.keys(colors2).map((key) => generateColor(key, 400)).join("\n ")}
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
});
|
|
33
|
+
const headData = {
|
|
34
|
+
style: [{
|
|
35
|
+
innerHTML: () => root.value,
|
|
36
|
+
tagPriority: -2,
|
|
37
|
+
id: "ui-colors"
|
|
38
|
+
}]
|
|
39
|
+
};
|
|
40
|
+
if (import.meta.client && nuxtApp.isHydrating && !nuxtApp.payload.serverRendered) {
|
|
41
|
+
const style = document.createElement("style");
|
|
42
|
+
style.innerHTML = root.value;
|
|
43
|
+
style.dataset.uiColors = "";
|
|
44
|
+
document.head.append(style);
|
|
45
|
+
headData.script = [{
|
|
46
|
+
innerHTML: "document.head.removeChild(document.querySelector('[data-ui-colors]'))"
|
|
47
|
+
}];
|
|
48
|
+
}
|
|
49
|
+
useHead(headData);
|
|
50
|
+
});
|
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type { Struct as SuperstructSchema } from 'superstruct';
|
|
3
|
+
import type { ComputedRef, DeepReadonly, Ref } from 'vue';
|
|
4
|
+
import type { GetObjectField, MaybeNull } from './utils';
|
|
5
|
+
export interface Form<S extends FormSchema> {
|
|
6
|
+
validate: <T extends boolean>(opts?: {
|
|
7
|
+
name?: keyof FormData<S, false> | (keyof FormData<S, false>)[];
|
|
8
|
+
silent?: boolean;
|
|
9
|
+
nested?: boolean;
|
|
10
|
+
transform?: T;
|
|
11
|
+
}) => Promise<FormData<S, T> | false>;
|
|
12
|
+
clear: (path?: keyof FormData<S, false> | string | RegExp) => void;
|
|
13
|
+
errors: Ref<FormError[]>;
|
|
14
|
+
setErrors: (errs: FormError[], name?: keyof FormData<S, false> | string | RegExp) => void;
|
|
15
|
+
getErrors: (name?: keyof FormData<S, false> | string | RegExp) => FormError[];
|
|
16
|
+
submit: () => Promise<void>;
|
|
17
|
+
disabled: ComputedRef<boolean>;
|
|
18
|
+
dirty: ComputedRef<boolean>;
|
|
19
|
+
loading: Ref<boolean>;
|
|
20
|
+
dirtyFields: ReadonlySet<DeepReadonly<keyof FormData<S, false>>>;
|
|
21
|
+
touchedFields: ReadonlySet<DeepReadonly<keyof FormData<S, false>>>;
|
|
22
|
+
blurredFields: ReadonlySet<DeepReadonly<keyof FormData<S, false>>>;
|
|
23
|
+
}
|
|
24
|
+
export type FormSchema<I extends object = object, O extends object = I> = SuperstructSchema<any, any> | StandardSchemaV1<I, O>;
|
|
25
|
+
export type InferInput<Schema> = Schema extends StandardSchemaV1 ? StandardSchemaV1.InferInput<Schema> : Schema extends SuperstructSchema<infer I, any> ? I : Schema extends StandardSchemaV1 ? StandardSchemaV1.InferInput<Schema> : never;
|
|
26
|
+
export type InferOutput<Schema> = Schema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<Schema> : Schema extends SuperstructSchema<infer O, any> ? O : never;
|
|
27
|
+
export type FormData<S extends FormSchema, T extends boolean = true> = T extends true ? InferOutput<S> : InferInput<S>;
|
|
28
|
+
export type FormInputEvents = 'input' | 'blur' | 'change' | 'focus';
|
|
4
29
|
export interface FormError<P extends string = string> {
|
|
5
30
|
name?: P;
|
|
6
31
|
message: string;
|
|
@@ -8,15 +33,21 @@ export interface FormError<P extends string = string> {
|
|
|
8
33
|
export interface FormErrorWithId extends FormError {
|
|
9
34
|
id?: string;
|
|
10
35
|
}
|
|
11
|
-
export type FormInputEvents = 'input' | 'blur' | 'change' | 'focus';
|
|
12
|
-
export type FormEventType = FormInputEvents;
|
|
13
36
|
export type FormSubmitEvent<T> = SubmitEvent & {
|
|
14
37
|
data: T;
|
|
15
38
|
};
|
|
16
|
-
export interface
|
|
39
|
+
export interface FormValidationError {
|
|
40
|
+
errors: FormErrorWithId[];
|
|
41
|
+
children?: FormErrorWithId[];
|
|
42
|
+
}
|
|
43
|
+
export type FormErrorEvent = SubmitEvent & FormValidationError;
|
|
44
|
+
export type FormEventType = FormInputEvents;
|
|
45
|
+
export interface FormChildAttachEvent<S extends FormSchema> {
|
|
17
46
|
type: 'attach';
|
|
18
47
|
formId: string | number;
|
|
19
|
-
validate:
|
|
48
|
+
validate: Form<any>['validate'];
|
|
49
|
+
name?: string;
|
|
50
|
+
api: Form<S>;
|
|
20
51
|
}
|
|
21
52
|
export interface FormChildDetachEvent {
|
|
22
53
|
type: 'detach';
|
|
@@ -27,19 +58,29 @@ export interface FormInputEvent<T extends object> {
|
|
|
27
58
|
name: keyof T;
|
|
28
59
|
eager?: boolean;
|
|
29
60
|
}
|
|
30
|
-
export type FormEvent<T extends object> = FormInputEvent<T> | FormChildAttachEvent | FormChildDetachEvent;
|
|
31
|
-
export interface
|
|
32
|
-
|
|
33
|
-
|
|
61
|
+
export type FormEvent<T extends object> = FormInputEvent<T> | FormChildAttachEvent<any> | FormChildDetachEvent;
|
|
62
|
+
export interface FormInjectedOptions {
|
|
63
|
+
disabled?: boolean;
|
|
64
|
+
validateOnInputDelay?: number;
|
|
65
|
+
}
|
|
66
|
+
export interface FormFieldInjectedOptions<T> {
|
|
67
|
+
name?: string;
|
|
68
|
+
size?: GetObjectField<T, 'size'>;
|
|
69
|
+
error?: string | boolean;
|
|
70
|
+
eagerValidation?: boolean;
|
|
71
|
+
validateOnInputDelay?: number;
|
|
72
|
+
errorPattern?: RegExp;
|
|
73
|
+
hint?: string;
|
|
74
|
+
description?: string;
|
|
75
|
+
help?: string;
|
|
76
|
+
ariaId: string;
|
|
34
77
|
}
|
|
35
|
-
export type FormErrorEvent = SubmitEvent & FormValidationError;
|
|
36
78
|
export interface ValidateReturnSchema<T> {
|
|
37
79
|
result: T;
|
|
38
|
-
errors: FormError[]
|
|
80
|
+
errors: MaybeNull<FormError[]>;
|
|
39
81
|
}
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
transform?: boolean;
|
|
82
|
+
export declare class FormValidationException extends Error {
|
|
83
|
+
formId: string | number;
|
|
84
|
+
errors: FormErrorWithId[];
|
|
85
|
+
constructor(formId: string | number, errors: FormErrorWithId[]);
|
|
45
86
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export class FormValidationException extends Error {
|
|
2
|
+
formId;
|
|
3
|
+
errors;
|
|
4
|
+
// eslint-disable-next-line unicorn/custom-error-definition
|
|
5
|
+
constructor(formId, errors) {
|
|
6
|
+
super("Form validation exception");
|
|
7
|
+
this.formId = formId;
|
|
8
|
+
this.errors = errors;
|
|
9
|
+
Object.setPrototypeOf(this, FormValidationException.prototype);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1,9 +1,52 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
export * from '
|
|
4
|
-
export * from '
|
|
5
|
-
export * from '
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import type { AppConfig } from '@nuxt/schema';
|
|
2
|
+
import type { AppConfigUI } from '#build/types/ui';
|
|
3
|
+
export * from '../components/Accordion.vue';
|
|
4
|
+
export * from '../components/Alert.vue';
|
|
5
|
+
export * from '../components/App.vue';
|
|
6
|
+
export * from '../components/Avatar.vue';
|
|
7
|
+
export * from '../components/AvatarGroup.vue';
|
|
8
|
+
export * from '../components/Badge.vue';
|
|
9
|
+
export * from '../components/Breadcrumb.vue';
|
|
10
|
+
export * from '../components/Button.vue';
|
|
11
|
+
export * from '../components/Calendar.vue';
|
|
12
|
+
export * from '../components/Card.vue';
|
|
13
|
+
export * from '../components/Carousel.vue';
|
|
14
|
+
export * from '../components/Checkbox.vue';
|
|
15
|
+
export * from '../components/Chip.vue';
|
|
16
|
+
export * from '../components/Collapsible.vue';
|
|
17
|
+
export * from '../components/Drawer.vue';
|
|
18
|
+
export * from '../components/DropdownMenu.vue';
|
|
19
|
+
export * from '../components/FieldGroup.vue';
|
|
20
|
+
export * from '../components/Form.vue';
|
|
21
|
+
export * from '../components/FormField.vue';
|
|
22
|
+
export * from '../components/Icon.vue';
|
|
23
|
+
export * from '../components/Input.vue';
|
|
24
|
+
export * from '../components/InputNumber.vue';
|
|
25
|
+
export * from '../components/Kbd.vue';
|
|
26
|
+
export * from '../components/Link.vue';
|
|
27
|
+
export * from '../components/Modal.vue';
|
|
28
|
+
export * from '../components/NavigationMenu.vue';
|
|
29
|
+
export * from '../components/OverlayProvider.vue';
|
|
30
|
+
export * from '../components/Pagination.vue';
|
|
31
|
+
export * from '../components/PinInput.vue';
|
|
32
|
+
export * from '../components/Popover.vue';
|
|
33
|
+
export * from '../components/Progress.vue';
|
|
34
|
+
export * from '../components/RadioGroup.vue';
|
|
35
|
+
export * from '../components/ScrollArea.vue';
|
|
36
|
+
export * from '../components/Select.vue';
|
|
37
|
+
export * from '../components/Separator.vue';
|
|
38
|
+
export * from '../components/Skeleton.vue';
|
|
39
|
+
export * from '../components/Slider.vue';
|
|
40
|
+
export * from '../components/Switch.vue';
|
|
41
|
+
export * from '../components/Table.vue';
|
|
42
|
+
export * from '../components/Tabs.vue';
|
|
43
|
+
export * from '../components/Textarea.vue';
|
|
44
|
+
export * from '../components/Toast.vue';
|
|
45
|
+
export * from '../components/ToastProvider.vue';
|
|
46
|
+
export * from '../components/Tooltip.vue';
|
|
47
|
+
export * from './form';
|
|
48
|
+
export * from './locale';
|
|
49
|
+
export * from './style';
|
|
50
|
+
export type RuntimeAppConfig = AppConfig & {
|
|
51
|
+
ui: AppConfigUI;
|
|
8
52
|
};
|
|
9
|
-
export type ThemeExtension = MergeThemes<typeof theme>;
|
|
@@ -1,4 +1,47 @@
|
|
|
1
|
-
export * from "
|
|
1
|
+
export * from "../components/Accordion.vue";
|
|
2
|
+
export * from "../components/Alert.vue";
|
|
3
|
+
export * from "../components/App.vue";
|
|
4
|
+
export * from "../components/Avatar.vue";
|
|
5
|
+
export * from "../components/AvatarGroup.vue";
|
|
6
|
+
export * from "../components/Badge.vue";
|
|
7
|
+
export * from "../components/Breadcrumb.vue";
|
|
8
|
+
export * from "../components/Button.vue";
|
|
9
|
+
export * from "../components/Calendar.vue";
|
|
10
|
+
export * from "../components/Card.vue";
|
|
11
|
+
export * from "../components/Carousel.vue";
|
|
12
|
+
export * from "../components/Checkbox.vue";
|
|
13
|
+
export * from "../components/Chip.vue";
|
|
14
|
+
export * from "../components/Collapsible.vue";
|
|
15
|
+
export * from "../components/Drawer.vue";
|
|
16
|
+
export * from "../components/DropdownMenu.vue";
|
|
17
|
+
export * from "../components/FieldGroup.vue";
|
|
18
|
+
export * from "../components/Form.vue";
|
|
19
|
+
export * from "../components/FormField.vue";
|
|
20
|
+
export * from "../components/Icon.vue";
|
|
21
|
+
export * from "../components/Input.vue";
|
|
22
|
+
export * from "../components/InputNumber.vue";
|
|
23
|
+
export * from "../components/Kbd.vue";
|
|
24
|
+
export * from "../components/Link.vue";
|
|
25
|
+
export * from "../components/Modal.vue";
|
|
26
|
+
export * from "../components/NavigationMenu.vue";
|
|
27
|
+
export * from "../components/OverlayProvider.vue";
|
|
28
|
+
export * from "../components/Pagination.vue";
|
|
29
|
+
export * from "../components/PinInput.vue";
|
|
30
|
+
export * from "../components/Popover.vue";
|
|
31
|
+
export * from "../components/Progress.vue";
|
|
32
|
+
export * from "../components/RadioGroup.vue";
|
|
33
|
+
export * from "../components/ScrollArea.vue";
|
|
34
|
+
export * from "../components/Select.vue";
|
|
35
|
+
export * from "../components/Separator.vue";
|
|
36
|
+
export * from "../components/Skeleton.vue";
|
|
37
|
+
export * from "../components/Slider.vue";
|
|
38
|
+
export * from "../components/Switch.vue";
|
|
39
|
+
export * from "../components/Table.vue";
|
|
40
|
+
export * from "../components/Tabs.vue";
|
|
41
|
+
export * from "../components/Textarea.vue";
|
|
42
|
+
export * from "../components/Toast.vue";
|
|
43
|
+
export * from "../components/ToastProvider.vue";
|
|
44
|
+
export * from "../components/Tooltip.vue";
|
|
2
45
|
export * from "./form.js";
|
|
3
46
|
export * from "./locale.js";
|
|
4
|
-
export * from "./
|
|
47
|
+
export * from "./style.js";
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import type { Locale as DefineLocale, LocaleDirection } from '@byyuurin/ui-kit';
|
|
2
|
+
export type DefineLocaleOptions<M> = DefineLocale<M>;
|
|
3
|
+
export type Locale<M> = Required<DefineLocale<M>>;
|
|
4
|
+
export type Direction = LocaleDirection;
|
|
1
5
|
export interface Messages {
|
|
2
6
|
alert: {
|
|
3
7
|
close: string;
|
|
@@ -9,6 +13,7 @@ export interface Messages {
|
|
|
9
13
|
nextMonth: string;
|
|
10
14
|
};
|
|
11
15
|
carousel: {
|
|
16
|
+
dots: string;
|
|
12
17
|
prev: string;
|
|
13
18
|
next: string;
|
|
14
19
|
goto: string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ClassProp, ClassValue, CVDefaultVariants, CVParts, CVScopeMeta, CVVariants, MaybeArray, StringToBoolean, VariantProps } from '@byyuurin/ui-kit';
|
|
2
|
+
export interface ComponentBaseProps {
|
|
3
|
+
class?: ClassValue;
|
|
4
|
+
}
|
|
5
|
+
export type ComponentStyler<T> = T extends {
|
|
6
|
+
parts: infer P;
|
|
7
|
+
variants: infer V;
|
|
8
|
+
} ? {
|
|
9
|
+
[Part in keyof P]: V extends undefined ? (props: {
|
|
10
|
+
class?: ClassValue;
|
|
11
|
+
}) => string : (props?: VariantProps<T> & {
|
|
12
|
+
class?: ClassValue;
|
|
13
|
+
}) => string;
|
|
14
|
+
} : Record<string, never>;
|
|
15
|
+
export type ComponentUIProps<T> = T extends {
|
|
16
|
+
parts: infer P;
|
|
17
|
+
} ? {
|
|
18
|
+
[Part in keyof P]?: string;
|
|
19
|
+
} : Record<string, never>;
|
|
20
|
+
type UIConfigPartial<T> = {
|
|
21
|
+
[P in keyof T as T[P] extends undefined ? never : P]?: T[P] extends Array<infer V> ? V extends string ? V extends '' ? '' : string : V[] : T[P] extends object ? UIConfigPartial<T[P]> : T[P] extends string ? T[P] extends '' ? '' : string : T[P];
|
|
22
|
+
};
|
|
23
|
+
type PartsName<P extends CVParts, B extends ClassValue> = B extends undefined ? keyof P : keyof P | 'base';
|
|
24
|
+
type PartsClassValue<S extends CVParts, B extends ClassValue> = {
|
|
25
|
+
[K in PartsName<S, B>]?: string;
|
|
26
|
+
};
|
|
27
|
+
type CVCompoundVariants<V extends CVVariants<P>, P extends CVParts, B extends ClassValue> = Array<{
|
|
28
|
+
[K in keyof V]?: MaybeArray<StringToBoolean<keyof V[K]>>;
|
|
29
|
+
} & (P extends undefined ? ClassProp<PartsClassValue<P, B> | string> : ClassProp<PartsClassValue<P, B>>)>;
|
|
30
|
+
export type UIConfig<Themes extends Record<string, any>> = {
|
|
31
|
+
[Component in keyof Themes]?: Themes[Component] extends CVScopeMeta<infer V, any, any, infer B, infer P> ? UIConfigPartial<CVScopeMeta<V, CVCompoundVariants<V, P, B>, CVDefaultVariants<V, P>, B, P>> : never;
|
|
32
|
+
};
|
|
33
|
+
export {};
|
|
File without changes
|
|
@@ -1,52 +1,53 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { AcceptableValue as _AcceptableValue } from 'reka-ui';
|
|
2
|
+
import type { VNode } from 'vue';
|
|
3
|
+
export type Nullable<T> = T | null | undefined;
|
|
4
|
+
export type MaybeNull<T> = T | null;
|
|
3
5
|
export type MaybeArray<T> = T | T[];
|
|
4
|
-
export type
|
|
5
|
-
export type
|
|
6
|
-
[
|
|
6
|
+
export type Defined<T> = Exclude<T, undefined>;
|
|
7
|
+
export type DeepPartial<T> = {
|
|
8
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P] | undefined;
|
|
9
|
+
};
|
|
10
|
+
type SlotProps<T> = T extends Record<string, any> ? {
|
|
11
|
+
[P in keyof T & string]: T[P] extends undefined ? T[P] | undefined : T[P];
|
|
12
|
+
} : Record<string, never>;
|
|
13
|
+
export type StaticSlot<P extends Record<string, any> | undefined = undefined> = P extends Record<string, any> ? (props: SlotProps<P>) => any : (props?: SlotProps<undefined>) => any;
|
|
14
|
+
export type DynamicSlotsKeys<Name extends string | undefined, Suffix extends string | undefined = undefined> = (Name extends string ? Suffix extends string ? Name | `${Name}-${Suffix}` : Name : never);
|
|
15
|
+
export type DynamicSlots<T extends {
|
|
16
|
+
slot?: string;
|
|
17
|
+
}, Suffix extends string | undefined = undefined, ExtraProps extends object = Record<string, never>> = {
|
|
18
|
+
[K in DynamicSlotsKeys<T['slot'], Suffix>]: StaticSlot<{
|
|
19
|
+
item: Extract<T, {
|
|
20
|
+
slot: K extends `${infer Base}-${Suffix}` ? Base : K;
|
|
21
|
+
}>;
|
|
22
|
+
} & ExtraProps>;
|
|
7
23
|
};
|
|
24
|
+
export type GetObjectField<MaybeObject, Key extends string> = MaybeObject extends Record<string, any> ? MaybeObject[Key] : never;
|
|
25
|
+
export type AcceptableValue = Exclude<_AcceptableValue, Record<string, any>> | boolean;
|
|
26
|
+
export type ArrayOrNested<T> = T[] | T[][];
|
|
27
|
+
export type NestedItem<T> = T extends Array<infer I> ? NestedItem<I> : T;
|
|
8
28
|
type AllKeys<T> = T extends any ? keyof T : never;
|
|
9
29
|
type NonCommonKeys<T extends object> = Exclude<AllKeys<T>, keyof T>;
|
|
10
30
|
type PickTypeOf<T, K extends string | number | symbol> = K extends AllKeys<T> ? T extends {
|
|
11
31
|
[k in K]?: any;
|
|
12
32
|
} ? T[K] : undefined : never;
|
|
13
33
|
export type MergeTypes<T extends object> = {
|
|
14
|
-
[
|
|
34
|
+
[k in keyof T]: PickTypeOf<T, k>;
|
|
15
35
|
} & {
|
|
16
|
-
[
|
|
36
|
+
[k in NonCommonKeys<T>]?: PickTypeOf<T, k>;
|
|
17
37
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}>;
|
|
25
|
-
} & Omit<SlotProps, 'item'>) => any;
|
|
26
|
-
};
|
|
27
|
-
export type ArrayOrNested<T> = T[] | T[][];
|
|
28
|
-
export type NestedItem<T> = T extends Array<infer I> ? NestedItem<I> : T;
|
|
29
|
-
export type GetItemKeys<T> = keyof Extract<NestedItem<T>, object>;
|
|
30
|
-
export type GetItemValue<I, VK extends GetItemKeys<I> | undefined, T extends NestedItem<I> = NestedItem<I>> = T extends object ? VK extends undefined ? T : VK extends keyof T ? T[VK] : never : T;
|
|
38
|
+
type DotPathKeys<T> = T extends Array<any> ? never : T extends object ? {
|
|
39
|
+
[K in keyof T & string]: T[K] extends Record<string, any> ? K | `${K}.${DotPathKeys<T[K]>}` : K;
|
|
40
|
+
}[keyof T & string] : never;
|
|
41
|
+
type DotPathValue<T, P extends DotPathKeys<T> | (string & {})> = P extends `${infer K}.${infer Rest}` ? K extends keyof T ? DotPathValue<T[K], Rest> : never : P extends keyof T ? T[P] : never;
|
|
42
|
+
export type GetItemKeys<I> = keyof Extract<NestedItem<I>, object> | DotPathKeys<Extract<NestedItem<I>, object>>;
|
|
43
|
+
export type GetItemValue<I, VK extends GetItemKeys<I> | undefined, T extends NestedItem<I> = NestedItem<I>> = T extends object ? VK extends undefined ? T : VK extends DotPathKeys<T> ? DotPathValue<T, VK> : never : T;
|
|
31
44
|
export type GetModelValue<T, VK extends GetItemKeys<T> | undefined, M extends boolean> = M extends true ? GetItemValue<T, VK>[] : GetItemValue<T, VK>;
|
|
32
45
|
export interface GetModelValueEmits<T, VK extends GetItemKeys<T> | undefined, M extends boolean> {
|
|
33
46
|
/** Event handler called when the value changes. */
|
|
34
|
-
'update:modelValue': [
|
|
47
|
+
'update:modelValue': [value: GetModelValue<T, VK, M>];
|
|
35
48
|
}
|
|
36
|
-
export type
|
|
37
|
-
export
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
parts: infer P;
|
|
41
|
-
} ? {
|
|
42
|
-
[Part in keyof P]?: string;
|
|
43
|
-
} : never;
|
|
44
|
-
}
|
|
45
|
-
export type StylerTheme<T> = T extends CVScopeMeta<infer V, any, any, infer B, infer S> ? CVReturnType<V, S, B> : never;
|
|
46
|
-
export interface StylerBaseProps {
|
|
47
|
-
class?: ClassValue;
|
|
48
|
-
}
|
|
49
|
-
export type StylerProps<T> = T extends CVScopeMeta<infer V, any, any, infer B, infer S> ? Parameters<Styler<CVReturnType<V, S, B>>>[0] : never;
|
|
50
|
-
export type StylerReturnType<T> = T extends CVReturnType<infer V, infer S, infer B> ? ReturnType<CVReturnType<V, S, B>> : never;
|
|
51
|
-
export type Styler<T> = T extends CVReturnType<infer V, any, any> ? [keyof V] extends string[] ? (props: VariantProps<T> & StylerBaseProps) => StylerReturnType<T> : (props?: StylerBaseProps) => StylerReturnType<T> : never;
|
|
49
|
+
export type StringOrVNode = string | VNode | (() => VNode);
|
|
50
|
+
export type EmitsToProps<T> = {
|
|
51
|
+
[K in keyof T as `on${Capitalize<string & K>}`]: T[K] extends [...args: infer Args] ? (...args: Args) => void : never;
|
|
52
|
+
};
|
|
52
53
|
export {};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Struct } from 'superstruct';
|
|
3
|
+
import type { FormSchema, ValidateReturnSchema } from '../types/form';
|
|
4
|
+
export declare function isSuperStructSchema(schema: any): schema is Struct<any, any>;
|
|
3
5
|
export declare function isStandardSchema(schema: any): schema is StandardSchemaV1;
|
|
4
6
|
export declare function validateStandardSchema(state: any, schema: StandardSchemaV1): Promise<ValidateReturnSchema<typeof state>>;
|
|
5
7
|
export declare function validateSchema<T extends object>(state: T, schema: FormSchema<T>): Promise<ValidateReturnSchema<typeof state>>;
|
|
8
|
+
export declare function getAtPath<T extends object>(data: T, path?: string): any;
|
|
9
|
+
export declare function setAtPath<T extends object>(data: T, path: string, value: any): T;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export function isSuperStructSchema(schema) {
|
|
2
|
+
return "schema" in schema && typeof schema.coercer === "function" && typeof schema.validator === "function" && typeof schema.refiner === "function";
|
|
3
|
+
}
|
|
1
4
|
export function isStandardSchema(schema) {
|
|
2
5
|
return "~standard" in schema;
|
|
3
6
|
}
|
|
@@ -17,8 +20,54 @@ export async function validateStandardSchema(state, schema) {
|
|
|
17
20
|
result: result.value
|
|
18
21
|
};
|
|
19
22
|
}
|
|
23
|
+
async function validateSuperstructSchema(state, schema) {
|
|
24
|
+
const [err, result] = schema.validate(state);
|
|
25
|
+
if (err) {
|
|
26
|
+
const errors = err.failures().map((error) => ({
|
|
27
|
+
message: error.message,
|
|
28
|
+
name: error.path.join(".")
|
|
29
|
+
}));
|
|
30
|
+
return {
|
|
31
|
+
errors,
|
|
32
|
+
result: null
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
errors: null,
|
|
37
|
+
result
|
|
38
|
+
};
|
|
39
|
+
}
|
|
20
40
|
export function validateSchema(state, schema) {
|
|
21
41
|
if (isStandardSchema(schema))
|
|
22
42
|
return validateStandardSchema(state, schema);
|
|
43
|
+
else if (isSuperStructSchema(schema))
|
|
44
|
+
return validateSuperstructSchema(state, schema);
|
|
23
45
|
throw new Error("Form validation failed: Unsupported form schema");
|
|
24
46
|
}
|
|
47
|
+
export function getAtPath(data, path) {
|
|
48
|
+
if (!path)
|
|
49
|
+
return data;
|
|
50
|
+
const value = path.split(".").reduce(
|
|
51
|
+
(value2, key) => value2?.[key],
|
|
52
|
+
data
|
|
53
|
+
);
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
export function setAtPath(data, path, value) {
|
|
57
|
+
if (!path)
|
|
58
|
+
return Object.assign(data, value);
|
|
59
|
+
if (!data)
|
|
60
|
+
return data;
|
|
61
|
+
const keys = path.split(".");
|
|
62
|
+
let current = data;
|
|
63
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
64
|
+
const key = keys[i];
|
|
65
|
+
if (current[key] === void 0 || current[key] === null) {
|
|
66
|
+
current[key] = i + 1 < keys.length && !Number.isNaN(Number(keys[i + 1])) ? [] : {};
|
|
67
|
+
}
|
|
68
|
+
current = current[key];
|
|
69
|
+
}
|
|
70
|
+
const lastKey = keys[keys.length - 1];
|
|
71
|
+
current[lastKey] = value;
|
|
72
|
+
return data;
|
|
73
|
+
}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export
|
|
6
|
-
export * from './styler.js';
|
|
7
|
-
export * from './translator.js';
|
|
8
|
-
export * from './vue.js';
|
|
1
|
+
import type { GetItemKeys, Nullable } from '../types/utils';
|
|
2
|
+
export * from './form';
|
|
3
|
+
export * from './link';
|
|
4
|
+
export * from './vue';
|
|
5
|
+
export { get, omit, pick, set } from '@byyuurin/ui-kit';
|
|
9
6
|
export { looseToNumber } from '@vue/shared';
|
|
10
|
-
export declare function defineLocale(locale: Locale<Messages>): Locale<Messages>;
|
|
11
|
-
export declare function pick<Data extends object, Keys extends keyof Data>(data: Data, keys: Keys[]): Pick<Data, Keys>;
|
|
12
|
-
export declare function omit<Data extends object, Keys extends keyof Data>(data: Data, keys: Keys[]): Omit<Data, Keys>;
|
|
13
|
-
export declare function get(object: Record<string, any> | undefined, path: (string | number)[] | string, defaultValue?: any): any;
|
|
14
|
-
export declare function set(object: Record<string, any>, path: (string | number)[] | string, value: any): void;
|
|
15
7
|
export declare function compare<T>(value?: T, currentValue?: T, comparator?: string | ((a: T, b: T) => boolean)): boolean;
|
|
8
|
+
export declare function isEmpty(value: unknown): boolean;
|
|
9
|
+
export declare function getDisplayValue<T extends Array<any>, V>(items: T, value: Nullable<V>, options?: {
|
|
10
|
+
valueKey?: GetItemKeys<T>;
|
|
11
|
+
labelKey?: GetItemKeys<T>;
|
|
12
|
+
}): string | undefined;
|
|
16
13
|
export declare function isArrayOfArray<T>(item: T[] | T[][]): item is T[][];
|