@nuxt/ui 3.0.0-alpha.0 → 3.0.0-alpha.2

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 (173) hide show
  1. package/README.md +1 -1
  2. package/cli/node_modules/.ignored/citty/LICENSE +36 -0
  3. package/cli/node_modules/.ignored/citty/README.md +134 -0
  4. package/cli/node_modules/.ignored/citty/dist/index.cjs +475 -0
  5. package/cli/node_modules/.ignored/citty/dist/index.d.cts +80 -0
  6. package/cli/node_modules/.ignored/citty/dist/index.d.mts +80 -0
  7. package/cli/node_modules/.ignored/citty/dist/index.d.ts +80 -0
  8. package/cli/node_modules/.ignored/citty/dist/index.mjs +463 -0
  9. package/cli/node_modules/.ignored/citty/package.json +49 -0
  10. package/cli/node_modules/.ignored/consola/LICENSE +47 -0
  11. package/cli/node_modules/.ignored/consola/README.md +318 -0
  12. package/cli/node_modules/.ignored/consola/core.d.ts +1 -0
  13. package/cli/node_modules/.ignored/consola/dist/basic.cjs +32 -0
  14. package/cli/node_modules/.ignored/consola/dist/basic.d.ts +9 -0
  15. package/cli/node_modules/.ignored/consola/dist/basic.mjs +24 -0
  16. package/cli/node_modules/.ignored/consola/dist/browser.cjs +80 -0
  17. package/cli/node_modules/.ignored/consola/dist/browser.d.ts +7 -0
  18. package/cli/node_modules/.ignored/consola/dist/browser.mjs +72 -0
  19. package/cli/node_modules/.ignored/consola/dist/chunks/prompt.cjs +436 -0
  20. package/cli/node_modules/.ignored/consola/dist/chunks/prompt.mjs +429 -0
  21. package/cli/node_modules/.ignored/consola/dist/core.cjs +415 -0
  22. package/cli/node_modules/.ignored/consola/dist/core.d.ts +124 -0
  23. package/cli/node_modules/.ignored/consola/dist/core.mjs +410 -0
  24. package/cli/node_modules/.ignored/consola/dist/index.cjs +21 -0
  25. package/cli/node_modules/.ignored/consola/dist/index.d.ts +9 -0
  26. package/cli/node_modules/.ignored/consola/dist/index.mjs +8 -0
  27. package/cli/node_modules/.ignored/consola/dist/shared/consola.06ad8a64.mjs +62 -0
  28. package/cli/node_modules/.ignored/consola/dist/shared/consola.36c0034f.mjs +636 -0
  29. package/cli/node_modules/.ignored/consola/dist/shared/consola.4bbae468.cjs +645 -0
  30. package/cli/node_modules/.ignored/consola/dist/shared/consola.deac7d5a.cjs +65 -0
  31. package/cli/node_modules/.ignored/consola/dist/utils.cjs +308 -0
  32. package/cli/node_modules/.ignored/consola/dist/utils.d.ts +169 -0
  33. package/cli/node_modules/.ignored/consola/dist/utils.mjs +284 -0
  34. package/cli/node_modules/.ignored/consola/lib/index.cjs +9 -0
  35. package/cli/node_modules/.ignored/consola/package.json +101 -0
  36. package/cli/node_modules/.ignored/consola/utils.d.ts +1 -0
  37. package/cli/node_modules/.ignored/pathe/LICENSE +44 -0
  38. package/cli/node_modules/.ignored/pathe/README.md +69 -0
  39. package/cli/node_modules/.ignored/pathe/dist/index.cjs +23 -0
  40. package/cli/node_modules/.ignored/pathe/dist/index.d.cts +36 -0
  41. package/cli/node_modules/.ignored/pathe/dist/index.d.mts +36 -0
  42. package/cli/node_modules/.ignored/pathe/dist/index.d.ts +36 -0
  43. package/cli/node_modules/.ignored/pathe/dist/index.mjs +1 -0
  44. package/cli/node_modules/.ignored/pathe/dist/shared/pathe.1f0a373c.cjs +238 -0
  45. package/cli/node_modules/.ignored/pathe/dist/shared/pathe.ff20891b.mjs +221 -0
  46. package/cli/node_modules/.ignored/pathe/dist/utils.cjs +58 -0
  47. package/cli/node_modules/.ignored/pathe/dist/utils.d.cts +5 -0
  48. package/cli/node_modules/.ignored/pathe/dist/utils.d.mts +5 -0
  49. package/cli/node_modules/.ignored/pathe/dist/utils.d.ts +5 -0
  50. package/cli/node_modules/.ignored/pathe/dist/utils.mjs +54 -0
  51. package/cli/node_modules/.ignored/pathe/package.json +48 -0
  52. package/cli/node_modules/.ignored/pathe/utils.d.ts +1 -0
  53. package/cli/node_modules/.ignored/scule/LICENSE +21 -0
  54. package/cli/node_modules/.ignored/scule/README.md +149 -0
  55. package/cli/node_modules/.ignored/scule/dist/index.cjs +92 -0
  56. package/cli/node_modules/.ignored/scule/dist/index.d.cts +57 -0
  57. package/cli/node_modules/.ignored/scule/dist/index.d.mts +57 -0
  58. package/cli/node_modules/.ignored/scule/dist/index.d.ts +57 -0
  59. package/cli/node_modules/.ignored/scule/dist/index.mjs +80 -0
  60. package/cli/node_modules/.ignored/scule/package.json +43 -0
  61. package/cli/node_modules/.package-lock.json +33 -0
  62. package/dist/module.d.mts +9 -2
  63. package/dist/module.d.ts +9 -2
  64. package/dist/module.json +3 -3
  65. package/dist/module.mjs +62 -103
  66. package/dist/runtime/components/Accordion.vue +49 -6
  67. package/dist/runtime/components/Alert.vue +58 -6
  68. package/dist/runtime/components/App.vue +12 -2
  69. package/dist/runtime/components/Avatar.vue +27 -6
  70. package/dist/runtime/components/AvatarGroup.vue +30 -6
  71. package/dist/runtime/components/Badge.vue +28 -6
  72. package/dist/runtime/components/Breadcrumb.vue +44 -6
  73. package/dist/runtime/components/Button.vue +68 -10
  74. package/dist/runtime/components/ButtonGroup.vue +30 -6
  75. package/dist/runtime/components/Card.vue +25 -6
  76. package/dist/runtime/components/Checkbox.vue +45 -6
  77. package/dist/runtime/components/Chip.vue +39 -6
  78. package/dist/runtime/components/Collapsible.vue +27 -6
  79. package/dist/runtime/components/CommandPalette.vue +100 -7
  80. package/dist/runtime/components/Container.vue +22 -6
  81. package/dist/runtime/components/ContextMenu.vue +58 -6
  82. package/dist/runtime/components/ContextMenuContent.vue +18 -4
  83. package/dist/runtime/components/Drawer.vue +48 -6
  84. package/dist/runtime/components/DropdownMenu.vue +66 -6
  85. package/dist/runtime/components/DropdownMenuContent.vue +22 -4
  86. package/dist/runtime/components/Form.vue +58 -26
  87. package/dist/runtime/components/FormField.vue +41 -16
  88. package/dist/runtime/components/Icon.vue +12 -2
  89. package/dist/runtime/components/Input.vue +46 -6
  90. package/dist/runtime/components/InputMenu.vue +113 -6
  91. package/dist/runtime/components/Kbd.vue +28 -6
  92. package/dist/runtime/components/Link.vue +81 -17
  93. package/dist/runtime/components/LinkBase.vue +18 -7
  94. package/dist/runtime/components/Modal.vue +69 -6
  95. package/dist/runtime/components/NavigationMenu.vue +76 -6
  96. package/dist/runtime/components/Pagination.vue +99 -6
  97. package/dist/runtime/components/Popover.vue +42 -6
  98. package/dist/runtime/components/Progress.vue +44 -6
  99. package/dist/runtime/components/RadioGroup.vue +55 -7
  100. package/dist/runtime/components/Select.vue +89 -7
  101. package/dist/runtime/components/SelectMenu.vue +105 -7
  102. package/dist/runtime/components/Separator.vue +41 -6
  103. package/dist/runtime/components/Skeleton.vue +18 -6
  104. package/dist/runtime/components/Slideover.vue +67 -6
  105. package/dist/runtime/components/Slider.vue +36 -6
  106. package/dist/runtime/components/Switch.vue +50 -6
  107. package/dist/runtime/components/Tabs.vue +59 -6
  108. package/dist/runtime/components/Textarea.vue +46 -6
  109. package/dist/runtime/components/Toast.vue +55 -6
  110. package/dist/runtime/components/Toaster.vue +28 -7
  111. package/dist/runtime/components/Tooltip.vue +42 -6
  112. package/dist/runtime/composables/useAvatarGroup.d.ts +2 -2
  113. package/dist/runtime/composables/useButtonGroup.d.ts +3 -3
  114. package/dist/runtime/composables/useFormField.d.ts +7 -3
  115. package/dist/runtime/composables/useFormField.js +12 -7
  116. package/dist/runtime/composables/useModal.d.ts +1 -1
  117. package/dist/runtime/composables/useSlideover.d.ts +1 -1
  118. package/dist/runtime/composables/useToast.d.ts +2 -2
  119. package/dist/runtime/index.css +1 -0
  120. package/dist/runtime/plugins/colors.d.ts +2 -0
  121. package/dist/runtime/plugins/modal.d.ts +2 -0
  122. package/dist/runtime/plugins/slideover.d.ts +2 -0
  123. package/dist/runtime/types/form.d.ts +1 -2
  124. package/dist/runtime/utils/index.d.ts +1 -1
  125. package/dist/runtime/utils/link.d.ts +23 -55
  126. package/package.json +26 -25
  127. package/dist/runtime/assets/css/animations.css +0 -1
  128. package/dist/runtime/components/Accordion.vue.d.ts +0 -492
  129. package/dist/runtime/components/Alert.vue.d.ts +0 -548
  130. package/dist/runtime/components/App.vue.d.ts +0 -25
  131. package/dist/runtime/components/Avatar.vue.d.ts +0 -384
  132. package/dist/runtime/components/AvatarGroup.vue.d.ts +0 -381
  133. package/dist/runtime/components/Badge.vue.d.ts +0 -422
  134. package/dist/runtime/components/Breadcrumb.vue.d.ts +0 -307
  135. package/dist/runtime/components/Button.vue.d.ts +0 -949
  136. package/dist/runtime/components/ButtonGroup.vue.d.ts +0 -182
  137. package/dist/runtime/components/Card.vue.d.ts +0 -191
  138. package/dist/runtime/components/Checkbox.vue.d.ts +0 -819
  139. package/dist/runtime/components/Chip.vue.d.ts +0 -590
  140. package/dist/runtime/components/Collapsible.vue.d.ts +0 -159
  141. package/dist/runtime/components/CommandPalette.vue.d.ts +0 -684
  142. package/dist/runtime/components/Container.vue.d.ts +0 -27
  143. package/dist/runtime/components/ContextMenu.vue.d.ts +0 -796
  144. package/dist/runtime/components/ContextMenuContent.vue.d.ts +0 -0
  145. package/dist/runtime/components/Drawer.vue.d.ts +0 -343
  146. package/dist/runtime/components/DropdownMenu.vue.d.ts +0 -815
  147. package/dist/runtime/components/DropdownMenuContent.vue.d.ts +0 -0
  148. package/dist/runtime/components/Form.vue.d.ts +0 -39
  149. package/dist/runtime/components/FormField.vue.d.ts +0 -356
  150. package/dist/runtime/components/Icon.vue.d.ts +0 -17
  151. package/dist/runtime/components/Input.vue.d.ts +0 -1137
  152. package/dist/runtime/components/InputMenu.vue.d.ts +0 -2121
  153. package/dist/runtime/components/Kbd.vue.d.ts +0 -169
  154. package/dist/runtime/components/Link.vue.d.ts +0 -76
  155. package/dist/runtime/components/LinkBase.vue.d.ts +0 -49
  156. package/dist/runtime/components/Modal.vue.d.ts +0 -319
  157. package/dist/runtime/components/NavigationMenu.vue.d.ts +0 -1789
  158. package/dist/runtime/components/Pagination.vue.d.ts +0 -295
  159. package/dist/runtime/components/Popover.vue.d.ts +0 -197
  160. package/dist/runtime/components/Progress.vue.d.ts +0 -1781
  161. package/dist/runtime/components/RadioGroup.vue.d.ts +0 -1715
  162. package/dist/runtime/components/Select.vue.d.ts +0 -1569
  163. package/dist/runtime/components/SelectMenu.vue.d.ts +0 -1661
  164. package/dist/runtime/components/Separator.vue.d.ts +0 -0
  165. package/dist/runtime/components/Skeleton.vue.d.ts +0 -26
  166. package/dist/runtime/components/Slideover.vue.d.ts +0 -375
  167. package/dist/runtime/components/Slider.vue.d.ts +0 -0
  168. package/dist/runtime/components/Switch.vue.d.ts +0 -1676
  169. package/dist/runtime/components/Tabs.vue.d.ts +0 -934
  170. package/dist/runtime/components/Textarea.vue.d.ts +0 -1133
  171. package/dist/runtime/components/Toast.vue.d.ts +0 -0
  172. package/dist/runtime/components/Toaster.vue.d.ts +0 -362
  173. package/dist/runtime/components/Tooltip.vue.d.ts +0 -248
@@ -1,9 +1,51 @@
1
- <script>
2
- import { tv } from "tailwind-variants";
3
- import _appConfig from "#build/app.config";
4
- import theme from "#build/ui/drawer";
5
- const appConfig = _appConfig;
6
- const drawer = tv({ extend: tv(theme), ...appConfig.ui?.drawer || {} });
1
+ <script lang="ts">
2
+ import { tv } from 'tailwind-variants'
3
+ import type { DrawerRootProps, DrawerRootEmits } from 'vaul-vue'
4
+ import type { DialogContentProps } from 'radix-vue'
5
+ import type { AppConfig } from '@nuxt/schema'
6
+ import _appConfig from '#build/app.config'
7
+ import theme from '#build/ui/drawer'
8
+
9
+ const appConfig = _appConfig as AppConfig & { ui: { drawer: Partial<typeof theme> } }
10
+
11
+ const drawer = tv({ extend: tv(theme), ...(appConfig.ui?.drawer || {}) })
12
+
13
+ export interface DrawerProps extends Pick<DrawerRootProps, 'activeSnapPoint' | 'closeThreshold' | 'defaultOpen' | 'direction' | 'dismissible' | 'fadeFromIndex' | 'fixed' | 'modal' | 'nested' | 'open' | 'scrollLockTimeout' | 'shouldScaleBackground' | 'snapPoints'> {
14
+ /**
15
+ * The element or component this component should render as.
16
+ * @defaultValue 'div'
17
+ */
18
+ as?: any
19
+ title?: string
20
+ description?: string
21
+ /** The content of the drawer. */
22
+ content?: Omit<DialogContentProps, 'as' | 'asChild' | 'forceMount'>
23
+ /**
24
+ * Render an overlay behind the drawer.
25
+ * @defaultValue true
26
+ */
27
+ overlay?: boolean
28
+ /**
29
+ * Render the drawer in a portal.
30
+ * @defaultValue true
31
+ */
32
+ portal?: boolean
33
+ class?: any
34
+ ui?: Partial<typeof drawer.slots>
35
+ }
36
+
37
+ export interface DrawerEmits extends DrawerRootEmits {}
38
+
39
+ export interface DrawerSlots {
40
+ default(props?: {}): any
41
+ handle(props?: {}): any
42
+ content(props?: {}): any
43
+ header(props?: {}): any
44
+ title(props?: {}): any
45
+ description(props?: {}): any
46
+ body(props?: {}): any
47
+ footer(props?: {}): any
48
+ }
7
49
  </script>
8
50
 
9
51
  <script setup lang="ts">
@@ -1,9 +1,69 @@
1
- <script>
2
- import { tv } from "tailwind-variants";
3
- import _appConfig from "#build/app.config";
4
- import theme from "#build/ui/dropdown-menu";
5
- const appConfig = _appConfig;
6
- const dropdownMenu = tv({ extend: tv(theme), ...appConfig.ui?.dropdownMenu || {} });
1
+ <script lang="ts">
2
+ import { tv, type VariantProps } from 'tailwind-variants'
3
+ import type { DropdownMenuRootProps, DropdownMenuRootEmits, DropdownMenuContentProps, DropdownMenuArrowProps, DropdownMenuTriggerProps, DropdownMenuItemProps } from 'radix-vue'
4
+ import type { AppConfig } from '@nuxt/schema'
5
+ import _appConfig from '#build/app.config'
6
+ import theme from '#build/ui/dropdown-menu'
7
+ import type { AvatarProps, KbdProps, LinkProps } from '../types'
8
+ import type { DynamicSlots } from '../types/utils'
9
+
10
+ const appConfig = _appConfig as AppConfig & { ui: { dropdownMenu: Partial<typeof theme> } }
11
+
12
+ const dropdownMenu = tv({ extend: tv(theme), ...(appConfig.ui?.dropdownMenu || {}) })
13
+
14
+ export interface DropdownMenuItem extends Omit<LinkProps, 'type' | 'raw' | 'custom'>, Pick<DropdownMenuItemProps, 'disabled'> {
15
+ label?: string
16
+ icon?: string
17
+ avatar?: AvatarProps
18
+ content?: Omit<DropdownMenuContentProps, 'as' | 'asChild' | 'forceMount'>
19
+ kbds?: KbdProps['value'][] | KbdProps[]
20
+ /**
21
+ * The item type.
22
+ * @defaultValue 'link'
23
+ */
24
+ type?: 'label' | 'separator' | 'link'
25
+ slot?: string
26
+ open?: boolean
27
+ defaultOpen?: boolean
28
+ children?: DropdownMenuItem[] | DropdownMenuItem[][]
29
+ select?(e: Event): void
30
+ }
31
+
32
+ type DropdownMenuVariants = VariantProps<typeof dropdownMenu>
33
+
34
+ export interface DropdownMenuProps<T> extends Omit<DropdownMenuRootProps, 'dir'>, Pick<DropdownMenuTriggerProps, 'disabled'> {
35
+ size?: DropdownMenuVariants['size']
36
+ items?: T[] | T[][]
37
+ /**
38
+ * The content of the menu.
39
+ * @defaultValue { side: 'bottom', sideOffset: 8 }
40
+ */
41
+ content?: Omit<DropdownMenuContentProps, 'as' | 'asChild' | 'forceMount'>
42
+ /**
43
+ * Display an arrow alongside the menu.
44
+ * @defaultValue false
45
+ */
46
+ arrow?: boolean | Omit<DropdownMenuArrowProps, 'as' | 'asChild'>
47
+ /**
48
+ * Render the menu in a portal.
49
+ * @defaultValue true
50
+ */
51
+ portal?: boolean
52
+ class?: any
53
+ ui?: Partial<typeof dropdownMenu.slots>
54
+ }
55
+
56
+ export interface DropdownMenuEmits extends DropdownMenuRootEmits {}
57
+
58
+ type SlotProps<T> = (props: { item: T, active?: boolean, index: number }) => any
59
+
60
+ export type DropdownMenuSlots<T extends { slot?: string }> = {
61
+ 'default'(props: { open: boolean }): any
62
+ 'item': SlotProps<T>
63
+ 'item-leading': SlotProps<T>
64
+ 'item-label': SlotProps<T>
65
+ 'item-trailing': SlotProps<T>
66
+ } & DynamicSlots<T, SlotProps<T>>
7
67
  </script>
8
68
 
9
69
  <script setup lang="ts" generic="T extends DropdownMenuItem">
@@ -1,7 +1,25 @@
1
- <script>
2
- import { tv } from "tailwind-variants";
3
- import theme from "#build/ui/dropdown-menu";
4
- const dropdownMenu = tv(theme)();
1
+ <script lang="ts">
2
+ import { tv } from 'tailwind-variants'
3
+ import type { DropdownMenuContentProps as RadixDropdownMenuContentProps, DropdownMenuContentEmits as RadixDropdownMenuContentEmits } from 'radix-vue'
4
+ import theme from '#build/ui/dropdown-menu'
5
+ import type { KbdProps, AvatarProps, DropdownMenuItem, DropdownMenuSlots } from '../types'
6
+
7
+ const _dropdownMenu = tv(theme)()
8
+
9
+ interface DropdownMenuContentProps<T> extends Omit<RadixDropdownMenuContentProps, 'as' | 'asChild' | 'forceMount'> {
10
+ items?: T[] | T[][]
11
+ portal?: boolean
12
+ sub?: boolean
13
+ class?: any
14
+ ui: typeof _dropdownMenu
15
+ uiOverride?: any
16
+ }
17
+
18
+ interface DropdownMenuContentEmits extends RadixDropdownMenuContentEmits {}
19
+
20
+ type DropdownMenuContentSlots<T extends { slot?: string }> = Omit<DropdownMenuSlots<T>, 'default'> & {
21
+ default(props?: {}): any
22
+ }
5
23
  </script>
6
24
 
7
25
  <script setup lang="ts" generic="T extends DropdownMenuItem">
@@ -1,15 +1,40 @@
1
- <script>
2
- import { tv } from "tailwind-variants";
3
- import _appConfig from "#build/app.config";
4
- import theme from "#build/ui/form";
5
- const appConfig = _appConfig;
6
- const form = tv({ extend: tv(theme), ...appConfig.ui?.form || {} });
1
+ <script lang="ts">
2
+ import { tv } from 'tailwind-variants'
3
+ import type { AppConfig } from '@nuxt/schema'
4
+ import _appConfig from '#build/app.config'
5
+ import theme from '#build/ui/form'
6
+ import type { FormSchema, FormError, FormInputEvents, FormErrorEvent, FormSubmitEvent, FormEvent, Form, FormErrorWithId } from '../types/form'
7
+
8
+ const appConfig = _appConfig as AppConfig & { ui: { form: Partial<typeof theme> } }
9
+
10
+ const form = tv({ extend: tv(theme), ...(appConfig.ui?.form || {}) })
11
+
12
+ export interface FormProps<T extends object> {
13
+ id?: string | number
14
+ schema?: FormSchema<T>
15
+ state: Partial<T>
16
+ validate?: (state: Partial<T>) => Promise<FormError[]> | FormError[]
17
+ validateOn?: FormInputEvents[]
18
+ disabled?: boolean
19
+ validateOnInputDelay?: number
20
+ class?: any
21
+ onSubmit?: ((event: FormSubmitEvent<T>) => void | Promise<void>) | (() => void | Promise<void>)
22
+ }
23
+
24
+ export interface FormEmits<T extends object> {
25
+ (e: 'submit', payload: FormSubmitEvent<T>): void
26
+ (e: 'error', payload: FormErrorEvent): void
27
+ }
28
+
29
+ export interface FormSlots {
30
+ default(props?: {}): any
31
+ }
7
32
  </script>
8
33
 
9
34
  <script lang="ts" setup generic="T extends object">
10
- import { provide, inject, nextTick, ref, onUnmounted, onMounted, computed, useId } from 'vue'
35
+ import { provide, inject, nextTick, ref, onUnmounted, onMounted, computed, useId, readonly } from 'vue'
11
36
  import { useEventBus } from '@vueuse/core'
12
- import { formOptionsInjectionKey, formInputsInjectionKey, formBusInjectionKey } from '../composables/useFormField'
37
+ import { formOptionsInjectionKey, formInputsInjectionKey, formBusInjectionKey, formLoadingInjectionKey } from '../composables/useFormField'
13
38
  import { getYupErrors, isYupSchema, getValibotError, isValibotSchema, getZodErrors, isZodSchema, getJoiErrors, isJoiSchema } from '../utils/form'
14
39
  import { FormValidationException } from '../types/form'
15
40
 
@@ -22,13 +47,14 @@ const props = withDefaults(defineProps<FormProps<T>>(), {
22
47
  const emits = defineEmits<FormEmits<T>>()
23
48
  defineSlots<FormSlots>()
24
49
 
25
- const formId = props.id ?? useId()
50
+ const formId = props.id ?? useId() as string
26
51
 
27
52
  const bus = useEventBus<FormEvent>(`form-${formId}`)
28
53
  const parentBus = inject(
29
54
  formBusInjectionKey,
30
55
  undefined
31
56
  )
57
+
32
58
  provide(formBusInjectionKey, bus)
33
59
 
34
60
  const nestedForms = ref<Map<string | number, { validate: () => any }>>(new Map())
@@ -62,11 +88,6 @@ onUnmounted(() => {
62
88
  }
63
89
  })
64
90
 
65
- provide(formOptionsInjectionKey, computed(() => ({
66
- disabled: props.disabled,
67
- validateOnInputDelay: props.validateOnInputDelay
68
- })))
69
-
70
91
  const errors = ref<FormErrorWithId[]>([])
71
92
  provide('form-errors', errors)
72
93
 
@@ -123,7 +144,8 @@ async function _validate(opts: { name?: string | string[], silent?: boolean, nes
123
144
  errors.value = await getErrors()
124
145
  }
125
146
 
126
- const childErrors = nestedValidatePromises ? await Promise.all(nestedValidatePromises) : []
147
+ const childErrors = (await Promise.all(nestedValidatePromises)).filter(val => val)
148
+
127
149
  if (errors.value.length + childErrors.length > 0) {
128
150
  if (opts.silent) return false
129
151
  throw new FormValidationException(formId, errors.value, childErrors)
@@ -132,16 +154,18 @@ async function _validate(opts: { name?: string | string[], silent?: boolean, nes
132
154
  return props.state as T
133
155
  }
134
156
 
135
- async function onSubmit(payload: Event) {
136
- const event = payload as SubmitEvent
157
+ const loading = ref(false)
158
+ provide(formLoadingInjectionKey, readonly(loading))
159
+
160
+ async function onSubmitWrapper(payload: Event) {
161
+ loading.value = true
162
+
163
+ const event = payload as FormSubmitEvent<any>
137
164
 
138
165
  try {
139
166
  await _validate({ nested: true })
140
- const submitEvent: FormSubmitEvent<any> = {
141
- ...event,
142
- data: props.state
143
- }
144
- emits('submit', submitEvent)
167
+ event.data = props.state
168
+ await props.onSubmit?.(event)
145
169
  } catch (error) {
146
170
  if (!(error instanceof FormValidationException)) {
147
171
  throw error
@@ -152,11 +176,19 @@ async function onSubmit(payload: Event) {
152
176
  errors: error.errors,
153
177
  childrens: error.childrens
154
178
  }
155
-
156
179
  emits('error', errorEvent)
157
180
  }
181
+
182
+ loading.value = false
158
183
  }
159
184
 
185
+ const disabled = computed(() => props.disabled || loading.value)
186
+
187
+ provide(formOptionsInjectionKey, computed(() => ({
188
+ disabled: disabled.value,
189
+ validateOnInputDelay: props.validateOnInputDelay
190
+ })))
191
+
160
192
  defineExpose<Form<T>>({
161
193
  validate: _validate,
162
194
  errors,
@@ -172,7 +204,7 @@ defineExpose<Form<T>>({
172
204
  },
173
205
 
174
206
  async submit() {
175
- await onSubmit(new Event('submit'))
207
+ await onSubmitWrapper(new Event('submit'))
176
208
  },
177
209
 
178
210
  getErrors(name?: string) {
@@ -190,7 +222,7 @@ defineExpose<Form<T>>({
190
222
  }
191
223
  },
192
224
 
193
- disabled: computed(() => props.disabled)
225
+ disabled
194
226
  })
195
227
  </script>
196
228
 
@@ -199,7 +231,7 @@ defineExpose<Form<T>>({
199
231
  :is="parentBus ? 'div' : 'form'"
200
232
  :id="formId"
201
233
  :class="form({ class: props.class })"
202
- @submit.prevent="onSubmit"
234
+ @submit.prevent="onSubmitWrapper"
203
235
  >
204
236
  <slot />
205
237
  </component>
@@ -1,16 +1,45 @@
1
- <script>
2
- import { tv } from "tailwind-variants";
3
- import _appConfig from "#build/app.config";
4
- import theme from "#build/ui/form-field";
5
- const appConfig = _appConfig;
6
- const formField = tv({ extend: tv(theme), ...appConfig.ui?.formField || {} });
1
+ <script lang="ts">
2
+ import { tv, type VariantProps } from 'tailwind-variants'
3
+ import type { AppConfig } from '@nuxt/schema'
4
+ import _appConfig from '#build/app.config'
5
+ import theme from '#build/ui/form-field'
6
+
7
+ const appConfig = _appConfig as AppConfig & { ui: { formField: Partial<typeof theme> } }
8
+
9
+ const formField = tv({ extend: tv(theme), ...(appConfig.ui?.formField || {}) })
10
+
11
+ type FormFieldVariants = VariantProps<typeof formField>
12
+
13
+ export interface FormFieldProps {
14
+ name?: string
15
+ label?: string
16
+ description?: string
17
+ help?: string
18
+ error?: string | boolean
19
+ hint?: string
20
+ size?: FormFieldVariants['size']
21
+ required?: boolean
22
+ eagerValidation?: boolean
23
+ validateOnInputDelay?: number
24
+ class?: any
25
+ ui?: Partial<typeof formField.slots>
26
+ }
27
+
28
+ export interface FormFieldSlots {
29
+ label(props: { label?: string }): any
30
+ hint(props: { hint?: string }): any
31
+ description(props: { description?: string }): any
32
+ help(props: { help?: string }): any
33
+ error(props: { error?: string | boolean }): any
34
+ default(props: { error?: string | boolean }): any
35
+ }
7
36
  </script>
8
37
 
9
38
  <script setup lang="ts">
10
39
  import { computed, ref, inject, provide, type Ref, useId } from 'vue'
11
40
  import { Label } from 'radix-vue'
12
- import { formFieldInjectionKey } from '../composables/useFormField'
13
- import type { FormError } from '../types/form'
41
+ import { formFieldInjectionKey, inputIdInjectionKey } from '../composables/useFormField'
42
+ import type { FormError, FormFieldInjectedOptions } from '../types/form'
14
43
 
15
44
  const props = defineProps<FormFieldProps>()
16
45
  const slots = defineSlots<FormFieldSlots>()
@@ -22,23 +51,19 @@ const ui = computed(() => formField({
22
51
 
23
52
  const formErrors = inject<Ref<FormError[]> | null>('form-errors', null)
24
53
 
25
- const error = computed(() => {
26
- return (props.error && typeof props.error === 'string')
27
- || typeof props.error === 'boolean'
28
- ? props.error
29
- : formErrors?.value?.find(error => error.name === props.name)?.message
30
- })
54
+ const error = computed(() => props.error || formErrors?.value?.find(error => error.name === props.name)?.message)
31
55
 
32
56
  const id = ref(useId())
33
57
 
58
+ provide(inputIdInjectionKey, id)
59
+
34
60
  provide(formFieldInjectionKey, computed(() => ({
35
- id: id.value,
36
61
  error: error.value,
37
62
  name: props.name,
38
63
  size: props.size,
39
64
  eagerValidation: props.eagerValidation,
40
65
  validateOnInputDelay: props.validateOnInputDelay
41
- })))
66
+ }) as FormFieldInjectedOptions<FormFieldProps>))
42
67
  </script>
43
68
 
44
69
  <template>
@@ -1,5 +1,15 @@
1
- <script>
2
-
1
+ <script lang="ts">
2
+ export interface IconProps {
3
+ name: string
4
+ mode?: 'svg' | 'css'
5
+ size?: string | number
6
+ customize?: (
7
+ content: string,
8
+ name?: string,
9
+ prefix?: string,
10
+ provider?: string
11
+ ) => string
12
+ }
3
13
  </script>
4
14
 
5
15
  <script setup lang="ts">
@@ -1,9 +1,49 @@
1
- <script>
2
- import { tv } from "tailwind-variants";
3
- import _appConfig from "#build/app.config";
4
- import theme from "#build/ui/input";
5
- const appConfig = _appConfig;
6
- const input = tv({ extend: tv(theme), ...appConfig.ui?.input || {} });
1
+ <script lang="ts">
2
+ import type { InputHTMLAttributes } from 'vue'
3
+ import { tv, type VariantProps } from 'tailwind-variants'
4
+ import type { AppConfig } from '@nuxt/schema'
5
+ import _appConfig from '#build/app.config'
6
+ import theme from '#build/ui/input'
7
+ import type { UseComponentIconsProps } from '../composables/useComponentIcons'
8
+ import type { PartialString } from '../types/utils'
9
+
10
+ const appConfig = _appConfig as AppConfig & { ui: { input: Partial<typeof theme> } }
11
+
12
+ const input = tv({ extend: tv(theme), ...(appConfig.ui?.input || {}) })
13
+
14
+ type InputVariants = VariantProps<typeof input>
15
+
16
+ export interface InputProps extends UseComponentIconsProps {
17
+ id?: string
18
+ name?: string
19
+ type?: InputHTMLAttributes['type']
20
+ /** The placeholder text when the input is empty. */
21
+ placeholder?: string
22
+ color?: InputVariants['color']
23
+ variant?: InputVariants['variant']
24
+ size?: InputVariants['size']
25
+ required?: boolean
26
+ autocomplete?: InputHTMLAttributes['autocomplete']
27
+ autofocus?: boolean
28
+ autofocusDelay?: number
29
+ disabled?: boolean
30
+ /** Highlight the ring color like a focus state. */
31
+ highlight?: boolean
32
+ class?: any
33
+ ui?: PartialString<typeof input.slots>
34
+ }
35
+
36
+ export interface InputEmits {
37
+ (e: 'update:modelValue', payload: string | number): void
38
+ (e: 'blur', event: FocusEvent): void
39
+ (e: 'change', event: Event): void
40
+ }
41
+
42
+ export interface InputSlots {
43
+ leading(props?: {}): any
44
+ default(props?: {}): any
45
+ trailing(props?: {}): any
46
+ }
7
47
  </script>
8
48
 
9
49
  <script setup lang="ts">
@@ -1,9 +1,116 @@
1
- <script>
2
- import { tv } from "tailwind-variants";
3
- import _appConfig from "#build/app.config";
4
- import theme from "#build/ui/input-menu";
5
- const appConfig = _appConfig;
6
- const inputMenu = tv({ extend: tv(theme), ...appConfig.ui?.inputMenu || {} });
1
+ <script lang="ts">
2
+ import type { InputHTMLAttributes } from 'vue'
3
+ import { tv, type VariantProps } from 'tailwind-variants'
4
+ import type { ComboboxRootProps, ComboboxRootEmits, ComboboxContentProps, ComboboxItemProps, ComboboxArrowProps } from 'radix-vue'
5
+ import type { AppConfig } from '@nuxt/schema'
6
+ import _appConfig from '#build/app.config'
7
+ import theme from '#build/ui/input-menu'
8
+ import type { UseComponentIconsProps } from '../composables/useComponentIcons'
9
+ import type { AvatarProps, ChipProps, InputProps } from '../types'
10
+ import type { AcceptableValue, ArrayOrWrapped, PartialString } from '../types/utils'
11
+
12
+ const appConfig = _appConfig as AppConfig & { ui: { inputMenu: Partial<typeof theme> } }
13
+
14
+ const inputMenu = tv({ extend: tv(theme), ...(appConfig.ui?.inputMenu || {}) })
15
+
16
+ export interface InputMenuItem extends Pick<ComboboxItemProps, 'disabled'> {
17
+ label?: string
18
+ icon?: string
19
+ avatar?: AvatarProps
20
+ chip?: ChipProps
21
+ /**
22
+ * The item type.
23
+ * @defaultValue 'item'
24
+ */
25
+ type?: 'label' | 'separator' | 'item'
26
+ }
27
+
28
+ type InputMenuVariants = VariantProps<typeof inputMenu>
29
+
30
+ export interface InputMenuProps<T> extends Pick<ComboboxRootProps<T>, 'modelValue' | 'defaultValue' | 'selectedValue' | 'open' | 'defaultOpen' | 'searchTerm' | 'multiple' | 'disabled' | 'name' | 'resetSearchTermOnBlur'>, UseComponentIconsProps {
31
+ /**
32
+ * The element or component this component should render as.
33
+ * @defaultValue 'div'
34
+ */
35
+ as?: any
36
+ id?: string
37
+ type?: InputHTMLAttributes['type']
38
+ /** The placeholder text when the input is empty. */
39
+ placeholder?: string
40
+ color?: InputMenuVariants['color']
41
+ variant?: InputMenuVariants['variant']
42
+ size?: InputMenuVariants['size']
43
+ required?: boolean
44
+ autofocus?: boolean
45
+ autofocusDelay?: number
46
+ /**
47
+ * The icon displayed to open the menu.
48
+ * @defaultValue appConfig.ui.icons.chevronDown
49
+ */
50
+ trailingIcon?: string
51
+ /**
52
+ * The icon displayed when an item is selected.
53
+ * @defaultValue appConfig.ui.icons.check
54
+ */
55
+ selectedIcon?: string
56
+ /**
57
+ * The icon displayed to delete a tag.
58
+ * Works only when `multiple` is `true`.
59
+ * @defaultValue appConfig.ui.icons.close
60
+ */
61
+ deleteIcon?: string
62
+ /**
63
+ * The content of the menu.
64
+ * @defaultValue { side: 'bottom', sideOffset: 8, position: 'popper' }
65
+ */
66
+ content?: Omit<ComboboxContentProps, 'as' | 'asChild' | 'forceMount'>
67
+ /**
68
+ * Display an arrow alongside the menu.
69
+ * @defaultValue false
70
+ */
71
+ arrow?: boolean | Omit<ComboboxArrowProps, 'as' | 'asChild'>
72
+ /**
73
+ * Render the menu in a portal.
74
+ * @defaultValue true
75
+ */
76
+ portal?: boolean
77
+ /**
78
+ * Whether to filter items or not, can be an array of fields to filter.
79
+ * When `false`, items will not be filtered which is useful for custom filtering.
80
+ * @defaultValue ['label']
81
+ */
82
+ filter?: boolean | string[]
83
+ /**
84
+ * When `items` is an array of objects, select the field to use as the value instead of the object itself.
85
+ * @defaultValue undefined
86
+ */
87
+ valueKey?: keyof T
88
+ items?: T[] | T[][]
89
+ /** Highlight the ring color like a focus state. */
90
+ highlight?: boolean
91
+ class?: any
92
+ ui?: PartialString<typeof inputMenu.slots>
93
+ }
94
+
95
+ export type InputMenuEmits<T> = ComboboxRootEmits<T> & {
96
+ change: [payload: Event]
97
+ blur: [payload: FocusEvent]
98
+ focus: [payload: FocusEvent]
99
+ }
100
+
101
+ type SlotProps<T> = (props: { item: T, index: number }) => any
102
+
103
+ export type InputMenuSlots<T> = {
104
+ 'leading'(props: { modelValue: T, open: boolean, ui: any }): any
105
+ 'trailing'(props: { modelValue: T, open: boolean, ui: any }): any
106
+ 'empty'(props: { searchTerm?: string }): any
107
+ 'item': SlotProps<T>
108
+ 'item-leading': SlotProps<T>
109
+ 'item-label': SlotProps<T>
110
+ 'item-trailing': SlotProps<T>
111
+ 'tags-item-text': SlotProps<T>
112
+ 'tags-item-delete': SlotProps<T>
113
+ }
7
114
  </script>
8
115
 
9
116
  <script setup lang="ts" generic="T extends InputMenuItem | AcceptableValue">
@@ -1,9 +1,31 @@
1
- <script>
2
- import { tv } from "tailwind-variants";
3
- import _appConfig from "#build/app.config";
4
- import theme from "#build/ui/kbd";
5
- const appConfig = _appConfig;
6
- const kbd = tv({ extend: tv(theme), ...appConfig.ui?.kbd || {} });
1
+ <script lang="ts">
2
+ import { tv, type VariantProps } from 'tailwind-variants'
3
+ import type { AppConfig } from '@nuxt/schema'
4
+ import _appConfig from '#build/app.config'
5
+ import theme from '#build/ui/kbd'
6
+ import type { KbdKey } from '../composables/useKbd'
7
+
8
+ const appConfig = _appConfig as AppConfig & { ui: { kbd: Partial<typeof theme> } }
9
+
10
+ const kbd = tv({ extend: tv(theme), ...(appConfig.ui?.kbd || {}) })
11
+
12
+ type KbdVariants = VariantProps<typeof kbd>
13
+
14
+ export interface KbdProps {
15
+ /**
16
+ * The element or component this component should render as.
17
+ * @defaultValue 'kbd'
18
+ */
19
+ as?: any
20
+ value?: KbdKey | string
21
+ variant?: KbdVariants['variant']
22
+ size?: KbdVariants['size']
23
+ class?: any
24
+ }
25
+
26
+ export interface KbdSlots {
27
+ default(props?: {}): any
28
+ }
7
29
  </script>
8
30
 
9
31
  <script setup lang="ts">