@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.
Files changed (289) hide show
  1. package/README.md +170 -58
  2. package/dist/module.d.mts +4 -13
  3. package/dist/module.json +4 -4
  4. package/dist/module.mjs +54 -20
  5. package/dist/runtime/components/Accordion.vue +28 -23
  6. package/dist/runtime/components/Accordion.vue.d.ts +51 -29
  7. package/dist/runtime/components/Alert.vue +47 -27
  8. package/dist/runtime/components/Alert.vue.d.ts +37 -25
  9. package/dist/runtime/components/App.vue +9 -8
  10. package/dist/runtime/components/App.vue.d.ts +22 -20
  11. package/dist/runtime/components/Avatar.vue +65 -21
  12. package/dist/runtime/components/Avatar.vue.d.ts +27 -13
  13. package/dist/runtime/components/AvatarGroup.vue +14 -10
  14. package/dist/runtime/components/AvatarGroup.vue.d.ts +12 -9
  15. package/dist/runtime/components/Badge.vue +64 -32
  16. package/dist/runtime/components/Badge.vue.d.ts +30 -29
  17. package/dist/runtime/components/Breadcrumb.vue +40 -22
  18. package/dist/runtime/components/Breadcrumb.vue.d.ts +48 -21
  19. package/dist/runtime/components/Button.vue +113 -52
  20. package/dist/runtime/components/Button.vue.d.ts +36 -20
  21. package/dist/runtime/components/Calendar.vue +48 -39
  22. package/dist/runtime/components/Calendar.vue.d.ts +58 -31
  23. package/dist/runtime/components/Card.vue +18 -14
  24. package/dist/runtime/components/Card.vue.d.ts +18 -14
  25. package/dist/runtime/components/Carousel.vue +80 -46
  26. package/dist/runtime/components/Carousel.vue.d.ts +46 -25
  27. package/dist/runtime/components/Checkbox.vue +60 -35
  28. package/dist/runtime/components/Checkbox.vue.d.ts +35 -28
  29. package/dist/runtime/components/Chip.vue +35 -32
  30. package/dist/runtime/components/Chip.vue.d.ts +33 -15
  31. package/dist/runtime/components/Collapsible.vue +13 -9
  32. package/dist/runtime/components/Collapsible.vue.d.ts +16 -8
  33. package/dist/runtime/components/Drawer.vue +80 -70
  34. package/dist/runtime/components/Drawer.vue.d.ts +51 -28
  35. package/dist/runtime/components/DropdownMenu.vue +23 -16
  36. package/dist/runtime/components/DropdownMenu.vue.d.ts +77 -36
  37. package/dist/runtime/components/DropdownMenuContent.vue +133 -103
  38. package/dist/runtime/components/DropdownMenuContent.vue.d.ts +38 -26
  39. package/dist/runtime/components/FieldGroup.vue +33 -0
  40. package/dist/runtime/components/FieldGroup.vue.d.ts +33 -0
  41. package/dist/runtime/components/Form.vue +172 -88
  42. package/dist/runtime/components/Form.vue.d.ts +69 -44
  43. package/dist/runtime/components/FormField.vue +108 -0
  44. package/dist/runtime/components/FormField.vue.d.ts +63 -0
  45. package/dist/runtime/components/Icon.vue +20 -0
  46. package/dist/runtime/components/Icon.vue.d.ts +9 -0
  47. package/dist/runtime/components/Input.vue +82 -77
  48. package/dist/runtime/components/Input.vue.d.ts +55 -43
  49. package/dist/runtime/components/InputNumber.vue +65 -49
  50. package/dist/runtime/components/InputNumber.vue.d.ts +51 -105
  51. package/dist/runtime/components/Kbd.vue +11 -5
  52. package/dist/runtime/components/Kbd.vue.d.ts +17 -11
  53. package/dist/runtime/components/Link.vue +54 -197
  54. package/dist/runtime/components/Link.vue.d.ts +17 -17
  55. package/dist/runtime/components/LinkBase.vue +11 -33
  56. package/dist/runtime/components/LinkBase.vue.d.ts +8 -3
  57. package/dist/runtime/components/Modal.vue +53 -39
  58. package/dist/runtime/components/Modal.vue.d.ts +64 -34
  59. package/dist/runtime/components/NavigationMenu.vue +336 -0
  60. package/dist/runtime/components/NavigationMenu.vue.d.ts +181 -0
  61. package/dist/runtime/components/OverlayProvider.vue +3 -3
  62. package/dist/runtime/components/OverlayProvider.vue.d.ts +2 -1
  63. package/dist/runtime/components/Pagination.vue +39 -47
  64. package/dist/runtime/components/Pagination.vue.d.ts +54 -31
  65. package/dist/runtime/components/PinInput.vue +46 -32
  66. package/dist/runtime/components/PinInput.vue.d.ts +40 -21
  67. package/dist/runtime/components/Popover.vue +33 -19
  68. package/dist/runtime/components/Popover.vue.d.ts +57 -32
  69. package/dist/runtime/components/Progress.vue +31 -26
  70. package/dist/runtime/components/Progress.vue.d.ts +32 -23
  71. package/dist/runtime/components/RadioGroup.vue +75 -48
  72. package/dist/runtime/components/RadioGroup.vue.d.ts +58 -36
  73. package/dist/runtime/components/ScrollArea.vue +33 -31
  74. package/dist/runtime/components/ScrollArea.vue.d.ts +9 -5
  75. package/dist/runtime/components/Select.vue +166 -76
  76. package/dist/runtime/components/Select.vue.d.ts +206 -65
  77. package/dist/runtime/components/Separator.vue +42 -16
  78. package/dist/runtime/components/Separator.vue.d.ts +35 -14
  79. package/dist/runtime/components/Skeleton.vue +18 -6
  80. package/dist/runtime/components/Skeleton.vue.d.ts +4 -4
  81. package/dist/runtime/components/Slider.vue +42 -24
  82. package/dist/runtime/components/Slider.vue.d.ts +43 -27
  83. package/dist/runtime/components/Switch.vue +40 -31
  84. package/dist/runtime/components/Switch.vue.d.ts +36 -27
  85. package/dist/runtime/components/Table.vue +279 -51
  86. package/dist/runtime/components/Table.vue.d.ts +151 -65
  87. package/dist/runtime/components/Tabs.vue +70 -23
  88. package/dist/runtime/components/Tabs.vue.d.ts +61 -29
  89. package/dist/runtime/components/Textarea.vue +102 -54
  90. package/dist/runtime/components/Textarea.vue.d.ts +57 -41
  91. package/dist/runtime/components/Toast.vue +84 -38
  92. package/dist/runtime/components/Toast.vue.d.ts +48 -27
  93. package/dist/runtime/components/ToastProvider.vue +31 -22
  94. package/dist/runtime/components/ToastProvider.vue.d.ts +30 -17
  95. package/dist/runtime/components/Tooltip.vue +33 -21
  96. package/dist/runtime/components/Tooltip.vue.d.ts +37 -15
  97. package/dist/runtime/composables/defineShortcuts.d.ts +16 -0
  98. package/dist/runtime/composables/defineShortcuts.js +129 -0
  99. package/dist/runtime/composables/useAvatarGroup.d.ts +8 -3
  100. package/dist/runtime/composables/useAvatarGroup.js +10 -3
  101. package/dist/runtime/composables/useComponentIcons.d.ts +9 -6
  102. package/dist/runtime/composables/useComponentIcons.js +4 -4
  103. package/dist/runtime/composables/useFieldGroup.d.ts +8 -0
  104. package/dist/runtime/composables/useFieldGroup.js +14 -0
  105. package/dist/runtime/composables/useFormField.d.ts +62 -0
  106. package/dist/runtime/composables/useFormField.js +99 -0
  107. package/dist/runtime/composables/useKbd.d.ts +3 -2
  108. package/dist/runtime/composables/useKbd.js +3 -2
  109. package/dist/runtime/composables/useLocale.d.ts +68 -5
  110. package/dist/runtime/composables/useLocale.js +11 -11
  111. package/dist/runtime/composables/useOverlay.d.ts +51 -15
  112. package/dist/runtime/composables/useOverlay.js +44 -30
  113. package/dist/runtime/composables/usePortal.d.ts +6 -0
  114. package/dist/runtime/composables/usePortal.js +17 -0
  115. package/dist/runtime/composables/useToast.d.ts +12 -5
  116. package/dist/runtime/composables/useToast.js +12 -7
  117. package/dist/runtime/locale/en.d.ts +30 -1
  118. package/dist/runtime/locale/en.js +2 -1
  119. package/dist/runtime/locale/index.d.ts +2 -2
  120. package/dist/runtime/locale/index.js +1 -1
  121. package/dist/runtime/locale/zh_tw.d.ts +31 -0
  122. package/dist/runtime/locale/{zh-tw.js → zh_tw.js} +2 -1
  123. package/dist/runtime/plugins/colors.d.ts +2 -0
  124. package/dist/runtime/plugins/colors.js +50 -0
  125. package/dist/runtime/types/app.config.d.ts +6 -0
  126. package/dist/runtime/types/form.d.ts +58 -17
  127. package/dist/runtime/types/form.js +11 -0
  128. package/dist/runtime/types/index.d.ts +51 -8
  129. package/dist/runtime/types/index.js +45 -2
  130. package/dist/runtime/types/input.d.ts +8 -0
  131. package/dist/runtime/types/locale.d.ts +5 -0
  132. package/dist/runtime/types/style.d.ts +33 -0
  133. package/dist/runtime/types/style.js +0 -0
  134. package/dist/runtime/types/unocss.d.ts +4 -0
  135. package/dist/runtime/types/utils.d.ts +38 -37
  136. package/dist/runtime/utils/form.d.ts +5 -1
  137. package/dist/runtime/utils/form.js +49 -0
  138. package/dist/runtime/utils/index.d.ts +10 -13
  139. package/dist/runtime/utils/index.js +41 -48
  140. package/dist/runtime/utils/link.d.ts +3 -2
  141. package/dist/runtime/utils/link.js +16 -2
  142. package/dist/runtime/utils/locale.d.ts +5 -0
  143. package/dist/runtime/utils/locale.js +10 -0
  144. package/dist/runtime/utils/style.d.ts +94 -0
  145. package/dist/runtime/utils/style.js +37 -0
  146. package/dist/runtime/vue/components/Icon.vue +15 -0
  147. package/dist/runtime/vue/components/Icon.vue.d.ts +7 -0
  148. package/dist/runtime/vue/components/Link.vue +163 -0
  149. package/dist/runtime/vue/components/Link.vue.d.ts +95 -0
  150. package/dist/runtime/vue/composables/useAppConfig.d.ts +1 -0
  151. package/dist/runtime/vue/composables/useAppConfig.js +4 -0
  152. package/dist/runtime/vue/plugins/color-mode.d.ts +4 -0
  153. package/dist/runtime/vue/plugins/color-mode.js +6 -0
  154. package/dist/runtime/vue/plugins/head.d.ts +4 -0
  155. package/dist/runtime/vue/plugins/head.js +9 -0
  156. package/dist/runtime/vue/stubs.d.ts +16 -1
  157. package/dist/runtime/vue/stubs.js +32 -1
  158. package/dist/setup.d.mts +13 -0
  159. package/dist/setup.mjs +12 -0
  160. package/dist/shared/ui.CzIlLITK.mjs +51 -0
  161. package/dist/shared/ui.DSyJHSTk.mjs +3787 -0
  162. package/dist/shared/ui.DpbffTXs.d.mts +84 -0
  163. package/dist/shared/ui.IulR-OYx.d.mts +64 -0
  164. package/dist/types.d.mts +3 -1
  165. package/dist/unocss.d.mts +12 -52
  166. package/dist/unocss.mjs +144 -254
  167. package/dist/unplugin.d.mts +13 -26
  168. package/dist/unplugin.mjs +193 -18
  169. package/dist/vite.d.mts +10 -1
  170. package/dist/vite.mjs +12 -3
  171. package/package.json +154 -87
  172. package/vue-plugin.d.ts +5 -0
  173. package/dist/module.d.ts +0 -13
  174. package/dist/module.mjs.map +0 -1
  175. package/dist/runtime/app/injections.d.ts +0 -9331
  176. package/dist/runtime/app/injections.js +0 -61
  177. package/dist/runtime/components/ButtonGroup.vue +0 -26
  178. package/dist/runtime/components/ButtonGroup.vue.d.ts +0 -26
  179. package/dist/runtime/components/FormItem.vue +0 -90
  180. package/dist/runtime/components/FormItem.vue.d.ts +0 -60
  181. package/dist/runtime/composables/useButtonGroup.d.ts +0 -5
  182. package/dist/runtime/composables/useButtonGroup.js +0 -9
  183. package/dist/runtime/composables/useFormItem.d.ts +0 -27
  184. package/dist/runtime/composables/useFormItem.js +0 -64
  185. package/dist/runtime/composables/useTheme.d.ts +0 -9
  186. package/dist/runtime/composables/useTheme.js +0 -23
  187. package/dist/runtime/index.d.ts +0 -44
  188. package/dist/runtime/index.js +0 -44
  189. package/dist/runtime/locale/zh-tw.d.ts +0 -2
  190. package/dist/runtime/theme/accordion.d.ts +0 -50
  191. package/dist/runtime/theme/accordion.js +0 -28
  192. package/dist/runtime/theme/alert.d.ts +0 -119
  193. package/dist/runtime/theme/alert.js +0 -47
  194. package/dist/runtime/theme/app.d.ts +0 -19
  195. package/dist/runtime/theme/app.js +0 -19
  196. package/dist/runtime/theme/avatar-group.d.ts +0 -46
  197. package/dist/runtime/theme/avatar-group.js +0 -32
  198. package/dist/runtime/theme/avatar.d.ts +0 -50
  199. package/dist/runtime/theme/avatar.js +0 -34
  200. package/dist/runtime/theme/badge.d.ts +0 -76
  201. package/dist/runtime/theme/badge.js +0 -92
  202. package/dist/runtime/theme/breadcrumb.d.ts +0 -61
  203. package/dist/runtime/theme/breadcrumb.js +0 -44
  204. package/dist/runtime/theme/button-group.d.ts +0 -60
  205. package/dist/runtime/theme/button-group.js +0 -42
  206. package/dist/runtime/theme/button.d.ts +0 -184
  207. package/dist/runtime/theme/button.js +0 -164
  208. package/dist/runtime/theme/calendar.d.ts +0 -58
  209. package/dist/runtime/theme/calendar.js +0 -86
  210. package/dist/runtime/theme/card.d.ts +0 -56
  211. package/dist/runtime/theme/card.js +0 -37
  212. package/dist/runtime/theme/carousel.d.ts +0 -107
  213. package/dist/runtime/theme/carousel.js +0 -43
  214. package/dist/runtime/theme/checkbox.d.ts +0 -82
  215. package/dist/runtime/theme/checkbox.js +0 -54
  216. package/dist/runtime/theme/chip.d.ts +0 -61
  217. package/dist/runtime/theme/chip.js +0 -66
  218. package/dist/runtime/theme/collapsible.d.ts +0 -32
  219. package/dist/runtime/theme/collapsible.js +0 -10
  220. package/dist/runtime/theme/drawer.d.ts +0 -142
  221. package/dist/runtime/theme/drawer.js +0 -113
  222. package/dist/runtime/theme/dropdown-menu.d.ts +0 -65
  223. package/dist/runtime/theme/dropdown-menu.js +0 -83
  224. package/dist/runtime/theme/form-item.d.ts +0 -70
  225. package/dist/runtime/theme/form-item.js +0 -34
  226. package/dist/runtime/theme/form.d.ts +0 -2
  227. package/dist/runtime/theme/form.js +0 -7
  228. package/dist/runtime/theme/index.d.ts +0 -41
  229. package/dist/runtime/theme/index.js +0 -41
  230. package/dist/runtime/theme/input-number.d.ts +0 -115
  231. package/dist/runtime/theme/input-number.js +0 -95
  232. package/dist/runtime/theme/input.d.ts +0 -172
  233. package/dist/runtime/theme/input.js +0 -151
  234. package/dist/runtime/theme/kbd.d.ts +0 -33
  235. package/dist/runtime/theme/kbd.js +0 -26
  236. package/dist/runtime/theme/link.d.ts +0 -38
  237. package/dist/runtime/theme/link.js +0 -26
  238. package/dist/runtime/theme/modal.d.ts +0 -42
  239. package/dist/runtime/theme/modal.js +0 -55
  240. package/dist/runtime/theme/pagination.d.ts +0 -74
  241. package/dist/runtime/theme/pagination.js +0 -17
  242. package/dist/runtime/theme/pinInput.d.ts +0 -94
  243. package/dist/runtime/theme/pinInput.js +0 -111
  244. package/dist/runtime/theme/popover.d.ts +0 -32
  245. package/dist/runtime/theme/popover.js +0 -13
  246. package/dist/runtime/theme/progress.d.ts +0 -180
  247. package/dist/runtime/theme/progress.js +0 -95
  248. package/dist/runtime/theme/radio-group.d.ts +0 -104
  249. package/dist/runtime/theme/radio-group.js +0 -61
  250. package/dist/runtime/theme/scroll-area.d.ts +0 -67
  251. package/dist/runtime/theme/scroll-area.js +0 -33
  252. package/dist/runtime/theme/select.d.ts +0 -186
  253. package/dist/runtime/theme/select.js +0 -173
  254. package/dist/runtime/theme/separator.d.ts +0 -74
  255. package/dist/runtime/theme/separator.js +0 -53
  256. package/dist/runtime/theme/skeleton.d.ts +0 -2
  257. package/dist/runtime/theme/skeleton.js +0 -7
  258. package/dist/runtime/theme/slider.d.ts +0 -70
  259. package/dist/runtime/theme/slider.js +0 -52
  260. package/dist/runtime/theme/switch.d.ts +0 -116
  261. package/dist/runtime/theme/switch.js +0 -78
  262. package/dist/runtime/theme/table.d.ts +0 -86
  263. package/dist/runtime/theme/table.js +0 -36
  264. package/dist/runtime/theme/tabs.d.ts +0 -129
  265. package/dist/runtime/theme/tabs.js +0 -146
  266. package/dist/runtime/theme/textarea.d.ts +0 -90
  267. package/dist/runtime/theme/textarea.js +0 -116
  268. package/dist/runtime/theme/toast-provider.d.ts +0 -116
  269. package/dist/runtime/theme/toast-provider.js +0 -97
  270. package/dist/runtime/theme/toast.d.ts +0 -83
  271. package/dist/runtime/theme/toast.js +0 -35
  272. package/dist/runtime/theme/tooltip.d.ts +0 -38
  273. package/dist/runtime/theme/tooltip.js +0 -11
  274. package/dist/runtime/types/components.d.ts +0 -42
  275. package/dist/runtime/utils/extend-theme.d.ts +0 -9
  276. package/dist/runtime/utils/extend-theme.js +0 -27
  277. package/dist/runtime/utils/styler.d.ts +0 -4
  278. package/dist/runtime/utils/styler.js +0 -10
  279. package/dist/runtime/utils/translator.d.ts +0 -18
  280. package/dist/runtime/utils/translator.js +0 -8
  281. package/dist/shared/ui.D1BTWZFB.mjs +0 -5
  282. package/dist/shared/ui.D1BTWZFB.mjs.map +0 -1
  283. package/dist/unocss.d.ts +0 -52
  284. package/dist/unocss.mjs.map +0 -1
  285. package/dist/unplugin.d.ts +0 -26
  286. package/dist/unplugin.mjs.map +0 -1
  287. package/dist/vite.d.ts +0 -9
  288. package/dist/vite.mjs.map +0 -1
  289. /package/dist/runtime/types/{components.js → input.js} +0 -0
@@ -1,39 +1,51 @@
1
1
  import type { VariantProps } from '@byyuurin/ui-kit';
2
2
  import type { DropdownMenuContentEmits as RekaDropdownMenuContentEmits, DropdownMenuContentProps as RekaDropdownMenuContentProps } from 'reka-ui';
3
- import type { dropdownMenu } from '../theme/index.js';
4
- import type { ArrayOrNested, ComponentAttrs, DropdownMenuItem, DropdownMenuSlots, NestedItem } from '../types/index.js';
5
- export type DropdownMenuContentSlots<T extends ArrayOrNested<DropdownMenuItem>> = Omit<DropdownMenuSlots<T>, 'default'> & {
6
- default?: any;
7
- };
8
- export interface DropdownMenuContentEmits extends RekaDropdownMenuContentEmits {
9
- }
10
- type DropdownMenuVariants = VariantProps<typeof dropdownMenu>;
11
- export interface DropdownMenuContentProps<T extends ArrayOrNested<DropdownMenuItem>> extends ComponentAttrs<typeof dropdownMenu>, Omit<RekaDropdownMenuContentProps, 'as' | 'asChild' | 'forceMount'> {
12
- size?: DropdownMenuVariants['size'];
3
+ import type theme from '#build/ui/dropdown-menu';
4
+ import type { ComponentBaseProps, ComponentStyler, ComponentUIProps, DropdownMenuItem, DropdownMenuSlots, IconProps } from '../types';
5
+ import type { ArrayOrNested, DynamicSlots, GetItemKeys, MergeTypes, NestedItem, StaticSlot } from '../types/utils';
6
+ type ThemeVariants = VariantProps<typeof theme>;
7
+ export interface DropdownMenuContentProps<T extends ArrayOrNested<DropdownMenuItem>> extends ComponentBaseProps, Omit<RekaDropdownMenuContentProps, 'as' | 'asChild' | 'forceMount'> {
8
+ size?: ThemeVariants['size'];
13
9
  items?: T;
14
- portal?: boolean;
10
+ portal?: boolean | string | HTMLElement;
15
11
  sub?: boolean;
16
- labelKey: keyof NestedItem<T>;
17
- checkedIcon?: string;
18
- loadingIcon?: string;
19
- externalIcon?: boolean | string;
12
+ labelKey: GetItemKeys<T>;
13
+ descriptionKey: GetItemKeys<T>;
14
+ checkedIcon?: IconProps['name'];
15
+ loadingIcon?: IconProps['name'];
16
+ externalIcon?: boolean | IconProps['name'];
17
+ ui: ComponentStyler<typeof theme>;
18
+ uiOverride?: ComponentUIProps<typeof theme>;
19
+ }
20
+ export interface DropdownMenuContentEmits extends RekaDropdownMenuContentEmits {
20
21
  }
21
- declare const _default: <T extends ArrayOrNested<DropdownMenuItem>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
22
- props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
23
- readonly onEscapeKeyDown?: ((event: KeyboardEvent) => any) | undefined;
24
- readonly onPointerDownOutside?: ((event: import("reka-ui").PointerDownOutsideEvent) => any) | undefined;
25
- readonly onFocusOutside?: ((event: import("reka-ui").FocusOutsideEvent) => any) | undefined;
26
- readonly onInteractOutside?: ((event: import("reka-ui").PointerDownOutsideEvent | import("reka-ui").FocusOutsideEvent) => any) | undefined;
27
- readonly onCloseAutoFocus?: ((event: Event) => any) | undefined;
28
- } & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, "onEscapeKeyDown" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside" | "onCloseAutoFocus"> & DropdownMenuContentProps<T> & Partial<{}>> & import("vue").PublicProps;
29
- expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
22
+ export type DropdownMenuContentSlots<A extends ArrayOrNested<DropdownMenuItem> = ArrayOrNested<DropdownMenuItem>, T extends NestedItem<A> = NestedItem<A>> = Pick<DropdownMenuSlots<A>, 'item' | 'item-leading' | 'item-label' | 'item-description' | 'item-trailing' | 'content-top' | 'content-bottom'> & {
23
+ default: StaticSlot;
24
+ } & DynamicSlots<MergeTypes<T>, 'label' | 'description', {
25
+ active: boolean;
26
+ index: number;
27
+ }> & DynamicSlots<MergeTypes<T>, 'leading' | 'trailing', {
28
+ active: boolean;
29
+ index: number;
30
+ ui: ComponentStyler<typeof theme>;
31
+ }>;
32
+ declare const __VLS_export: <T extends ArrayOrNested<DropdownMenuItem>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
33
+ props: __VLS_PrettifyLocal<DropdownMenuContentProps<T> & {
34
+ onEscapeKeyDown?: ((event: KeyboardEvent) => any) | undefined;
35
+ onPointerDownOutside?: ((event: import("reka-ui").PointerDownOutsideEvent) => any) | undefined;
36
+ onFocusOutside?: ((event: import("reka-ui").FocusOutsideEvent) => any) | undefined;
37
+ onInteractOutside?: ((event: import("reka-ui").PointerDownOutsideEvent | import("reka-ui").FocusOutsideEvent) => any) | undefined;
38
+ onCloseAutoFocus?: ((event: Event) => any) | undefined;
39
+ }> & import("vue").PublicProps;
40
+ expose: (exposed: {}) => void;
30
41
  attrs: any;
31
- slots: DropdownMenuContentSlots<T>;
42
+ slots: DropdownMenuContentSlots<T, NestedItem<T>>;
32
43
  emit: ((evt: "escapeKeyDown", event: KeyboardEvent) => void) & ((evt: "pointerDownOutside", event: import("reka-ui").PointerDownOutsideEvent) => void) & ((evt: "focusOutside", event: import("reka-ui").FocusOutsideEvent) => void) & ((evt: "interactOutside", event: import("reka-ui").PointerDownOutsideEvent | import("reka-ui").FocusOutsideEvent) => void) & ((evt: "closeAutoFocus", event: Event) => void);
33
44
  }>) => import("vue").VNode & {
34
45
  __ctx?: Awaited<typeof __VLS_setup>;
35
46
  };
47
+ declare const _default: typeof __VLS_export;
36
48
  export default _default;
37
49
  type __VLS_PrettifyLocal<T> = {
38
- [K in keyof T]: T[K];
50
+ [K in keyof T as K]: T[K];
39
51
  } & {};
@@ -0,0 +1,33 @@
1
+ <script>
2
+ import theme from "#build/ui/field-group";
3
+ </script>
4
+
5
+ <script setup>
6
+ import { Primitive } from "reka-ui";
7
+ import { computed } from "vue";
8
+ import { useAppConfig } from "#imports";
9
+ import { provideFieldGroup } from "../composables/useFieldGroup";
10
+ import { cv, merge } from "../utils/style";
11
+ const props = defineProps({
12
+ as: { type: null, required: false },
13
+ size: { type: null, required: false },
14
+ orientation: { type: null, required: false, default: "horizontal" },
15
+ class: { type: [Object, String, Number, Boolean, null, Array], required: false, skipCheck: true }
16
+ });
17
+ defineSlots();
18
+ const appConfig = useAppConfig();
19
+ const ui = computed(() => {
20
+ const styler = cv(merge(theme, appConfig.ui.fieldGroup));
21
+ return styler(props);
22
+ });
23
+ provideFieldGroup(computed(() => ({
24
+ orientation: props.orientation,
25
+ size: props.size
26
+ })));
27
+ </script>
28
+
29
+ <template>
30
+ <Primitive :as="props.as" :class="ui.base({ class: props.class })" :data-orientation="props.orientation" data-part="base">
31
+ <slot></slot>
32
+ </Primitive>
33
+ </template>
@@ -0,0 +1,33 @@
1
+ import type { VariantProps } from '@byyuurin/ui-kit';
2
+ import type { PrimitiveProps } from 'reka-ui';
3
+ import theme from '#build/ui/field-group';
4
+ import type { ComponentBaseProps } from '../types';
5
+ import type { StaticSlot } from '../types/utils';
6
+ type ThemeVariant = VariantProps<typeof theme>;
7
+ export interface FieldGroupProps extends ComponentBaseProps {
8
+ /**
9
+ * The element or component this component should render as.
10
+ * @default "div"
11
+ */
12
+ as?: PrimitiveProps['as'];
13
+ /** @default "md" */
14
+ size?: ThemeVariant['size'];
15
+ /**
16
+ * The orientation the buttons are laid out.
17
+ * @default "horizontal"
18
+ */
19
+ orientation?: ThemeVariant['orientation'];
20
+ }
21
+ export interface FieldGroupSlots {
22
+ default: StaticSlot;
23
+ }
24
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<FieldGroupProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FieldGroupProps> & Readonly<{}>, {
25
+ orientation: "horizontal" | "vertical";
26
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, FieldGroupSlots>;
27
+ declare const _default: typeof __VLS_export;
28
+ export default _default;
29
+ type __VLS_WithSlots<T, S> = T & {
30
+ new (): {
31
+ $slots: S;
32
+ };
33
+ };
@@ -1,48 +1,59 @@
1
1
  <script>
2
- export class FormValidationExceptionError extends Error {
3
- formId;
4
- errors;
5
- children;
6
- constructor(formId, errors, childErrors) {
7
- super("Form validation exception");
8
- this.name = "FormValidationExceptionError";
9
- this.formId = formId;
10
- this.errors = errors;
11
- this.children = childErrors;
12
- Object.setPrototypeOf(this, FormValidationExceptionError.prototype);
13
- }
14
- }
2
+ import theme from "#build/ui/form";
15
3
  </script>
16
4
 
17
5
  <script setup>
18
6
  import { useEventBus } from "@vueuse/core";
19
- import { computed, nextTick, onMounted, onUnmounted, readonly, ref, useId } from "vue";
20
- import { injectFormBus, provideFormBus, provideFormErrors, provideFormInputs, provideFormLoading, provideFormOptions } from "../app/injections";
21
- import { useTheme } from "../composables/useTheme";
22
- import { validateSchema } from "../utils";
7
+ import { computed, nextTick, onMounted, onUnmounted, reactive, readonly, ref, shallowRef, useId } from "vue";
8
+ import { useAppConfig } from "#imports";
9
+ import { injectFormBus, injectFormState, provideFormBus, provideFormErrors, provideFormInputs, provideFormLoading, provideFormOptions, provideFormState } from "../composables/useFormField";
10
+ import { FormValidationException } from "../types/form";
11
+ import { getAtPath, setAtPath, validateSchema } from "../utils/form";
12
+ import { cv, merge } from "../utils/style";
23
13
  const props = defineProps({
24
14
  id: { type: [String, Number], required: false },
25
15
  schema: { type: null, required: false },
26
- state: { type: Object, required: true },
16
+ state: { type: null, required: true },
27
17
  validate: { type: Function, required: false },
28
18
  validateOn: { type: Array, required: false, default: () => ["input", "blur", "change"] },
29
19
  disabled: { type: Boolean, required: false },
20
+ name: { type: null, required: false },
30
21
  validateOnInputDelay: { type: Number, required: false, default: 300 },
31
22
  transform: { type: Boolean, required: false, default: true },
23
+ nested: { type: Boolean, required: false },
24
+ loadingAuto: { type: Boolean, required: false, default: true },
32
25
  onSubmit: { type: Function, required: false },
33
- class: { type: null, required: false }
26
+ class: { type: [Object, String, Number, Boolean, null, Array], required: false, skipCheck: true }
34
27
  });
35
28
  const emit = defineEmits(["submit", "error"]);
36
29
  defineSlots();
37
30
  const formId = props.id ?? useId();
38
31
  const bus = useEventBus(`form-${formId}`);
39
- const parentBus = injectFormBus();
32
+ const parentBus = props.nested && injectFormBus();
33
+ const parentState = props.nested ? injectFormState() : void 0;
34
+ const state = computed(() => {
35
+ if (parentState?.value)
36
+ return props.name ? getAtPath(parentState.value, props.name) : parentState.value;
37
+ return props.state;
38
+ });
40
39
  provideFormBus(bus);
40
+ provideFormState(state);
41
41
  const nestedForms = ref(/* @__PURE__ */ new Map());
42
+ onMounted(async () => {
43
+ if (parentBus) {
44
+ await nextTick();
45
+ parentBus.emit({ type: "attach", validate: validateFn, formId, name: props.name, api });
46
+ }
47
+ });
48
+ onUnmounted(() => {
49
+ bus.reset();
50
+ if (parentBus)
51
+ parentBus.emit({ type: "detach", formId });
52
+ });
42
53
  onMounted(() => {
43
54
  bus.on(async (event) => {
44
55
  if (event.type === "attach") {
45
- nestedForms.value.set(event.formId, { validate: event.validate });
56
+ nestedForms.value.set(event.formId, { validate: event.validate, name: event.name, api: event.api });
46
57
  } else if (event.type === "detach") {
47
58
  nestedForms.value.delete(event.formId);
48
59
  } else if (props.validateOn?.includes(event.type) && !loading.value) {
@@ -59,26 +70,13 @@ onMounted(() => {
59
70
  dirtyFields.add(event.name);
60
71
  });
61
72
  });
62
- onUnmounted(() => {
63
- bus.reset();
64
- });
65
- onMounted(async () => {
66
- if (parentBus) {
67
- await nextTick();
68
- parentBus.emit({ type: "attach", validate: validateFn, formId });
69
- }
70
- });
71
- onUnmounted(() => {
72
- if (parentBus)
73
- parentBus.emit({ type: "detach", formId });
74
- });
75
73
  const errors = ref([]);
76
74
  provideFormErrors(errors);
77
75
  const inputs = ref({});
78
76
  provideFormInputs(inputs);
79
- const dirtyFields = /* @__PURE__ */ new Set();
80
- const touchedFields = /* @__PURE__ */ new Set();
81
- const blurredFields = /* @__PURE__ */ new Set();
77
+ const dirtyFields = reactive(/* @__PURE__ */ new Set());
78
+ const touchedFields = reactive(/* @__PURE__ */ new Set());
79
+ const blurredFields = reactive(/* @__PURE__ */ new Set());
82
80
  function resolveErrorIds(errs) {
83
81
  return errs.map((err) => ({
84
82
  ...err,
@@ -97,61 +95,50 @@ async function getErrors() {
97
95
  }
98
96
  return resolveErrorIds(errs);
99
97
  }
100
- async function validateFn(options) {
101
- const _options = {
102
- silent: false,
103
- nested: true,
104
- transform: false,
105
- ...options
106
- };
107
- const names = _options.name && !Array.isArray(_options.name) ? [_options.name] : _options.name;
108
- const nestedValidatePromises = !names && _options.nested ? Array.from(nestedForms.value.values()).map(
109
- ({ validate }) => validate(_options).then(() => {
110
- }).catch((error) => {
111
- if (!(error instanceof FormValidationExceptionError))
112
- throw error;
113
- return error;
114
- })
115
- ) : [];
116
- if (names) {
117
- const otherErrors = errors.value.filter((error) => !names.some((name) => {
118
- const pattern = inputs.value?.[name]?.pattern;
119
- return name === error.name || pattern && error.name?.match(pattern);
120
- }));
121
- const pathErrors = (await getErrors()).filter((error) => names.some((name) => {
122
- const pattern = inputs.value?.[name]?.pattern;
123
- return name === error.name || pattern && error.name?.match(pattern);
124
- }));
125
- errors.value = otherErrors.concat(pathErrors);
126
- } else {
127
- errors.value = await getErrors();
98
+ async function validateFn(opts = { silent: false, nested: false, transform: false }) {
99
+ const names = opts.name && !Array.isArray(opts.name) ? [opts.name] : opts.name;
100
+ let nestedResults = [];
101
+ let nestedErrors = [];
102
+ if (!names && opts.nested) {
103
+ const validations = Array.from(nestedForms.value.values()).map((form) => validateNestedForm(form, opts));
104
+ const results = await Promise.all(validations);
105
+ nestedErrors = results.filter((r) => r.error).flatMap((r) => r.error.errors.map((e) => addFormPath(e, r.name)));
106
+ nestedResults = results.filter((r) => r.output !== void 0);
128
107
  }
129
- const childErrors = (await Promise.all(nestedValidatePromises)).filter((val) => val !== void 0);
130
- if (errors.value.length + childErrors.length > 0) {
131
- if (_options.silent)
108
+ const currentErrors = await getErrors();
109
+ const allErrors = [...currentErrors, ...nestedErrors];
110
+ errors.value = names ? filterErrorsByNames(allErrors, names) : allErrors;
111
+ if (errors.value?.length) {
112
+ if (opts.silent)
132
113
  return false;
133
- throw new FormValidationExceptionError(formId, errors.value, childErrors);
114
+ throw new FormValidationException(formId, errors.value);
134
115
  }
135
- if (_options.transform)
136
- Object.assign(props.state, transformedState.value);
137
- return props.state;
116
+ if (opts.transform) {
117
+ nestedResults.forEach((result) => {
118
+ if (result.name)
119
+ setAtPath(transformedState.value, result.name, result.output);
120
+ else
121
+ Object.assign(transformedState.value, result.output);
122
+ });
123
+ return transformedState.value ?? state.value;
124
+ }
125
+ return state.value;
138
126
  }
139
- const loading = ref(false);
127
+ const loading = shallowRef(false);
140
128
  provideFormLoading(readonly(loading));
141
129
  async function onSubmitWrapper(payload) {
142
- loading.value = true;
130
+ loading.value = props.loadingAuto && true;
143
131
  const event = payload;
144
132
  try {
145
133
  event.data = await validateFn({ nested: true, transform: props.transform });
146
134
  await props.onSubmit?.(event);
147
135
  dirtyFields.clear();
148
136
  } catch (error) {
149
- if (!(error instanceof FormValidationExceptionError))
137
+ if (!(error instanceof FormValidationException))
150
138
  throw error;
151
139
  const errorEvent = {
152
140
  ...event,
153
- errors: error.errors,
154
- children: error.children
141
+ errors: error.errors
155
142
  };
156
143
  emit("error", errorEvent);
157
144
  } finally {
@@ -163,35 +150,132 @@ provideFormOptions(computed(() => ({
163
150
  disabled: disabled.value,
164
151
  validateOnInputDelay: props.validateOnInputDelay
165
152
  })));
166
- defineExpose({
153
+ async function validateNestedForm(form, opts) {
154
+ try {
155
+ const result = await form.validate({ ...opts, silent: false });
156
+ return { name: form.name, output: result };
157
+ } catch (error) {
158
+ if (!(error instanceof FormValidationException))
159
+ throw error;
160
+ return { name: form.name, error };
161
+ }
162
+ }
163
+ function addFormPath(error, formPath) {
164
+ if (!formPath || !error.name)
165
+ return error;
166
+ return { ...error, name: `${formPath}.${error.name}` };
167
+ }
168
+ function stripFormPath(error, formPath) {
169
+ const prefix = `${formPath}.`;
170
+ const name = error?.name?.startsWith(prefix) ? error.name.slice(prefix.length) : error.name;
171
+ return { ...error, name };
172
+ }
173
+ function filterFormErrors(errors2, formPath) {
174
+ if (!formPath)
175
+ return errors2;
176
+ return errors2.filter((e) => e?.name?.startsWith(`${formPath}.`)).map((e) => stripFormPath(e, formPath));
177
+ }
178
+ function getFormErrors(form) {
179
+ return form.api.getErrors().map((e) => form.name ? { ...e, name: `${form.name}.${e.name}` } : e);
180
+ }
181
+ function matchesTarget(target, path) {
182
+ if (!target || !path)
183
+ return true;
184
+ if (target instanceof RegExp)
185
+ return target.test(path);
186
+ return path === target || typeof target === "string" && target.startsWith(`${path}.`);
187
+ }
188
+ function getNestedTarget(target, formPath) {
189
+ if (!target || target instanceof RegExp)
190
+ return target;
191
+ if (formPath === target)
192
+ return void 0;
193
+ if (typeof target === "string" && target.startsWith(`${formPath}.`))
194
+ return target.slice(Math.max(0, formPath.length + 1));
195
+ return target;
196
+ }
197
+ function filterErrorsByNames(allErrors, names) {
198
+ const nameSet = new Set(names);
199
+ const patterns = names.map((name) => inputs.value?.[name]?.pattern).filter(Boolean);
200
+ const matchesNames = (error) => {
201
+ if (!error.name)
202
+ return false;
203
+ if (nameSet.has(error.name))
204
+ return true;
205
+ return patterns.some((pattern) => pattern.test(error.name));
206
+ };
207
+ const keepErrors = errors.value.filter((error) => !matchesNames(error));
208
+ const newErrors = allErrors.filter(matchesNames);
209
+ return [...keepErrors, ...newErrors];
210
+ }
211
+ function filterErrorsByTarget(currentErrors, target) {
212
+ return currentErrors.filter((err) => target instanceof RegExp ? !(err.name && target.test(err.name)) : !err.name || err.name !== target);
213
+ }
214
+ function isLocalError(error) {
215
+ return !error.name || !!inputs.value[error.name];
216
+ }
217
+ const api = {
167
218
  validate: validateFn,
219
+ // FIXME: type issue
168
220
  errors,
169
221
  setErrors(errs, name) {
170
- errors.value = name ? errors.value.filter((error) => error.name !== name).concat(resolveErrorIds(errs)) : resolveErrorIds(errs);
222
+ const localErrors = resolveErrorIds(errs.filter(isLocalError));
223
+ const nestedErrors = [];
224
+ for (const form of nestedForms.value.values()) {
225
+ if (matchesTarget(name, form.name)) {
226
+ const formErrors = filterFormErrors(errs, form.name);
227
+ form.api.setErrors(formErrors, getNestedTarget(name, form.name || ""));
228
+ nestedErrors.push(...getFormErrors(form));
229
+ }
230
+ }
231
+ if (name) {
232
+ const keepErrors = filterErrorsByTarget(errors.value, name);
233
+ errors.value = [...keepErrors, ...localErrors, ...nestedErrors];
234
+ } else {
235
+ errors.value = [...localErrors, ...nestedErrors];
236
+ }
171
237
  },
172
238
  async submit() {
173
239
  await onSubmitWrapper(new Event("submit"));
174
240
  },
175
241
  getErrors(name) {
176
- if (name)
177
- return errors.value.filter((err) => err.name === name);
178
- return errors.value;
242
+ if (!name)
243
+ return errors.value;
244
+ return errors.value.filter((err) => name instanceof RegExp ? err.name && name.test(err.name) : err.name === name);
179
245
  },
180
246
  clear(name) {
181
- errors.value = name ? errors.value.filter((err) => err.name !== name) : [];
247
+ const localErrors = name ? errors.value.filter((err) => isLocalError(err) && (name instanceof RegExp ? !(err.name && name.test(err.name)) : err.name !== name)) : [];
248
+ const nestedErrors = [];
249
+ for (const form of nestedForms.value.values()) {
250
+ if (matchesTarget(name, form.name))
251
+ form.api.clear();
252
+ nestedErrors.push(...getFormErrors(form));
253
+ }
254
+ errors.value = [...localErrors, ...nestedErrors];
182
255
  },
183
256
  disabled,
184
- dirty: computed(() => dirtyFields.size > 0),
257
+ loading,
258
+ dirty: computed(() => !!dirtyFields.size),
185
259
  dirtyFields: readonly(dirtyFields),
186
260
  blurredFields: readonly(blurredFields),
187
261
  touchedFields: readonly(touchedFields)
262
+ };
263
+ defineExpose(api);
264
+ const appConfig = useAppConfig();
265
+ const ui = computed(() => {
266
+ const styler = cv(merge(theme, appConfig.ui.form));
267
+ return styler(props);
188
268
  });
189
- const { generateStyle } = useTheme();
190
- const style = computed(() => generateStyle("form", props));
191
269
  </script>
192
270
 
193
271
  <template>
194
- <component :is="parentBus ? 'div' : 'form'" :id="formId" :class="style.base()" data-part="base" @submit.prevent="onSubmitWrapper">
195
- <slot :errors="errors"></slot>
272
+ <component
273
+ :is="parentBus ? 'div' : 'form'"
274
+ :id="formId"
275
+ :class="ui.base({ class: props.class })"
276
+ data-part="base"
277
+ @submit.prevent="onSubmitWrapper"
278
+ >
279
+ <slot :errors="errors" :loading="loading"></slot>
196
280
  </component>
197
281
  </template>
@@ -1,47 +1,30 @@
1
- import type { ComputedRef, DeepReadonly, Ref } from 'vue';
2
- import type { form } from '../theme/index.js';
3
- import type { ComponentAttrs, FormError, FormErrorEvent, FormErrorWithId, FormInputEvents, FormSchema, FormSubmitEvent, FormValidateOptions } from '../types/index.js';
4
- export interface FormEmits<T extends object> {
5
- submit: [payload: FormSubmitEvent<T>];
6
- error: [payload: FormErrorEvent];
7
- }
8
- export interface FormSlots {
9
- default?: (props?: {
10
- errors: FormError[];
11
- }) => any;
12
- }
13
- export interface FormExpose<T extends object> {
14
- validate: (options?: FormValidateOptions<T>) => Promise<T | false>;
15
- clear: (path?: string) => void;
16
- errors: Ref<FormError[]>;
17
- setErrors: (errors: FormError[], name?: keyof T) => void;
18
- getErrors: (name?: keyof T) => FormError[];
19
- submit: () => Promise<void>;
20
- disabled: ComputedRef<boolean>;
21
- dirty: ComputedRef<boolean>;
22
- dirtyFields: DeepReadonly<Set<keyof T>>;
23
- touchedFields: DeepReadonly<Set<keyof T>>;
24
- blurredFields: DeepReadonly<Set<keyof T>>;
25
- }
26
- export interface FormProps<T extends object> extends Omit<ComponentAttrs<typeof form>, 'ui'> {
1
+ import type { ComponentBaseProps, FormData, FormError, FormErrorEvent, FormErrorWithId, FormInputEvents, FormSchema, FormSubmitEvent, InferInput } from '../types';
2
+ import type { StaticSlot } from '../types/utils';
3
+ export interface FormProps<S extends FormSchema, T extends boolean = true, N extends boolean = false> extends ComponentBaseProps {
27
4
  id?: string | number;
28
- /** Schema to validate the form state. */
29
- schema?: FormSchema<T>;
5
+ /** Schema to validate the form state. Supports Standard Schema objects, Yup, Joi, and Superstructs. */
6
+ schema?: S;
30
7
  /** An object representing the current state of the form. */
31
- state: Partial<T>;
8
+ state: N extends false ? Partial<InferInput<S>> : never;
32
9
  /**
33
10
  * Custom validation function to validate the form state.
34
11
  * @param state - The current state of the form.
35
12
  * @returns A promise that resolves to an array of FormError objects, or an array of FormError objects directly.
36
13
  */
37
- validate?: (state: Partial<T>) => Promise<FormError[]> | FormError[];
14
+ validate?: (state: Partial<InferInput<S>>) => Promise<FormError[]> | FormError[];
38
15
  /**
39
16
  * The list of input events that trigger the form validation.
17
+ * @remarks The form always validates on submit.
40
18
  * @default ["blur", "change", "input"]
41
19
  */
42
20
  validateOn?: FormInputEvents[];
43
21
  /** Disable all inputs inside the form. */
44
22
  disabled?: boolean;
23
+ /**
24
+ * Path of the form's state within it's parent form.
25
+ * Used for nesting forms. Only available if `nested` is true.
26
+ */
27
+ name?: N extends true ? string : never;
45
28
  /**
46
29
  * Delay in milliseconds before validating the form on input events.
47
30
  * @default 300
@@ -51,28 +34,70 @@ export interface FormProps<T extends object> extends Omit<ComponentAttrs<typeof
51
34
  * If true, schema transformations will be applied to the state on submit.
52
35
  * @default true
53
36
  */
54
- transform?: boolean;
37
+ transform?: T & boolean;
38
+ /**
39
+ * If true, this form will attach to its parent Form and validate at the same time.
40
+ * @default false
41
+ */
42
+ nested?: N & boolean;
43
+ /**
44
+ * When `true`, all form elements will be disabled on `@submit` event.
45
+ *
46
+ * This will cause any focused input elements to lose their focus state.
47
+ * @default true
48
+ */
49
+ loadingAuto?: boolean;
55
50
  onSubmit?: ((event: FormSubmitEvent<T>) => void | Promise<void>) | (() => void | Promise<void>);
56
51
  }
57
- export declare class FormValidationExceptionError extends Error {
58
- formId: string | number;
59
- errors: FormErrorWithId[];
60
- children?: FormValidationExceptionError[];
61
- constructor(formId: string | number, errors: FormErrorWithId[], childErrors?: FormValidationExceptionError[]);
52
+ export interface FormEmits<S extends FormSchema, T extends boolean = true> {
53
+ submit: [event: FormSubmitEvent<FormData<S, T>>];
54
+ error: [event: FormErrorEvent];
55
+ }
56
+ export interface FormSlots {
57
+ default: StaticSlot<{
58
+ errors: FormError[];
59
+ loading: boolean;
60
+ }>;
62
61
  }
63
- declare const _default: <T extends object>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
64
- props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
65
- readonly onError?: ((payload: FormErrorEvent) => any) | undefined;
66
- readonly onSubmit?: ((payload: FormSubmitEvent<T>) => any) | undefined;
67
- } & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, "onSubmit" | "onError"> & FormProps<T> & Partial<{}>> & import("vue").PublicProps;
68
- expose(exposed: import("vue").ShallowUnwrapRef<FormExpose<T>>): void;
62
+ declare const __VLS_export: <S extends FormSchema, T extends boolean = true, N extends boolean = false>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
63
+ props: __VLS_PrettifyLocal<FormProps<S, T, N> & {
64
+ onError?: ((event: FormErrorEvent) => any) | undefined;
65
+ onSubmit?: ((event: FormSubmitEvent<FormData<S, T>>) => any) | undefined;
66
+ }> & import("vue").PublicProps;
67
+ expose: (exposed: import("vue").ShallowUnwrapRef<{
68
+ validate: any;
69
+ errors: import("vue").Ref<{
70
+ id?: string | undefined;
71
+ name?: string | undefined;
72
+ message: string;
73
+ }[], FormErrorWithId[] | {
74
+ id?: string | undefined;
75
+ name?: string | undefined;
76
+ message: string;
77
+ }[]>;
78
+ setErrors(errs: FormError[], name?: keyof InferInput<S> | string | RegExp): void;
79
+ submit(): Promise<void>;
80
+ getErrors(name?: keyof InferInput<S> | string | RegExp): {
81
+ id?: string | undefined;
82
+ name?: string | undefined;
83
+ message: string;
84
+ }[];
85
+ clear(name?: keyof InferInput<S> | string | RegExp): void;
86
+ disabled: import("vue").ComputedRef<boolean>;
87
+ loading: import("vue").ShallowRef<boolean, boolean>;
88
+ dirty: import("vue").ComputedRef<boolean>;
89
+ dirtyFields: ReadonlySet<import("vue").DeepReadonly<import("@vue/reactivity").UnwrapRefSimple<keyof InferInput<S>>>>;
90
+ blurredFields: ReadonlySet<import("vue").DeepReadonly<import("@vue/reactivity").UnwrapRefSimple<keyof InferInput<S>>>>;
91
+ touchedFields: ReadonlySet<import("vue").DeepReadonly<import("@vue/reactivity").UnwrapRefSimple<keyof InferInput<S>>>>;
92
+ }>) => void;
69
93
  attrs: any;
70
94
  slots: FormSlots;
71
- emit: ((evt: "error", payload: FormErrorEvent) => void) & ((evt: "submit", payload: FormSubmitEvent<T>) => void);
95
+ emit: ((evt: "error", event: FormErrorEvent) => void) & ((evt: "submit", event: FormSubmitEvent<FormData<S, T>>) => void);
72
96
  }>) => import("vue").VNode & {
73
97
  __ctx?: Awaited<typeof __VLS_setup>;
74
98
  };
99
+ declare const _default: typeof __VLS_export;
75
100
  export default _default;
76
101
  type __VLS_PrettifyLocal<T> = {
77
- [K in keyof T]: T[K];
102
+ [K in keyof T as K]: T[K];
78
103
  } & {};