@nuxt/ui 3.0.2 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/.nuxt/ui/accordion.ts +2 -2
  2. package/.nuxt/ui/alert.ts +29 -29
  3. package/.nuxt/ui/avatar-group.ts +1 -1
  4. package/.nuxt/ui/avatar.ts +3 -3
  5. package/.nuxt/ui/badge.ts +33 -33
  6. package/.nuxt/ui/breadcrumb.ts +5 -5
  7. package/.nuxt/ui/button.ts +43 -43
  8. package/.nuxt/ui/calendar.ts +17 -17
  9. package/.nuxt/ui/card.ts +5 -5
  10. package/.nuxt/ui/carousel.ts +6 -6
  11. package/.nuxt/ui/checkbox-group.ts +61 -0
  12. package/.nuxt/ui/checkbox.ts +140 -27
  13. package/.nuxt/ui/chip.ts +8 -8
  14. package/.nuxt/ui/color-picker.ts +3 -3
  15. package/.nuxt/ui/command-palette.ts +14 -14
  16. package/.nuxt/ui/context-menu.ts +33 -33
  17. package/.nuxt/ui/drawer.ts +10 -10
  18. package/.nuxt/ui/dropdown-menu.ts +34 -34
  19. package/.nuxt/ui/form-field.ts +6 -6
  20. package/.nuxt/ui/index.ts +1 -0
  21. package/.nuxt/ui/input-menu.ts +42 -42
  22. package/.nuxt/ui/input-number.ts +20 -20
  23. package/.nuxt/ui/input.ts +23 -23
  24. package/.nuxt/ui/kbd.ts +4 -4
  25. package/.nuxt/ui/link.ts +3 -3
  26. package/.nuxt/ui/modal.ts +5 -5
  27. package/.nuxt/ui/navigation-menu.ts +78 -80
  28. package/.nuxt/ui/pin-input.ts +20 -20
  29. package/.nuxt/ui/popover.ts +2 -2
  30. package/.nuxt/ui/progress.ts +17 -17
  31. package/.nuxt/ui/radio-group.ts +250 -35
  32. package/.nuxt/ui/select-menu.ts +36 -33
  33. package/.nuxt/ui/select.ts +32 -32
  34. package/.nuxt/ui/separator.ts +8 -8
  35. package/.nuxt/ui/skeleton.ts +1 -1
  36. package/.nuxt/ui/slideover.ts +4 -4
  37. package/.nuxt/ui/slider.ts +16 -16
  38. package/.nuxt/ui/stepper.ts +18 -18
  39. package/.nuxt/ui/switch.ts +20 -20
  40. package/.nuxt/ui/table.ts +15 -15
  41. package/.nuxt/ui/tabs.ts +32 -32
  42. package/.nuxt/ui/textarea.ts +40 -35
  43. package/.nuxt/ui/toast.ts +24 -24
  44. package/.nuxt/ui/tooltip.ts +2 -2
  45. package/.nuxt/ui/tree.ts +18 -18
  46. package/.nuxt/ui.css +63 -12
  47. package/README.md +15 -0
  48. package/cli/templates.mjs +18 -17
  49. package/dist/module.json +5 -5
  50. package/dist/module.mjs +12 -7
  51. package/dist/runtime/components/Accordion.vue +36 -93
  52. package/dist/runtime/components/Accordion.vue.d.ts +75 -0
  53. package/dist/runtime/components/Alert.vue +37 -100
  54. package/dist/runtime/components/Alert.vue.d.ts +81 -0
  55. package/dist/runtime/components/App.vue +28 -34
  56. package/dist/runtime/components/App.vue.d.ts +24 -0
  57. package/dist/runtime/components/Avatar.vue +42 -75
  58. package/dist/runtime/components/Avatar.vue.d.ts +39 -0
  59. package/dist/runtime/components/AvatarGroup.vue +40 -77
  60. package/dist/runtime/components/AvatarGroup.vue.d.ts +31 -0
  61. package/dist/runtime/components/Badge.vue +33 -62
  62. package/dist/runtime/components/Badge.vue.d.ts +41 -0
  63. package/dist/runtime/components/Breadcrumb.vue +37 -90
  64. package/dist/runtime/components/Breadcrumb.vue.d.ts +64 -0
  65. package/dist/runtime/components/Button.vue +95 -104
  66. package/dist/runtime/components/Button.vue.d.ts +48 -0
  67. package/dist/runtime/components/ButtonGroup.vue +20 -46
  68. package/dist/runtime/components/ButtonGroup.vue.d.ts +34 -0
  69. package/dist/runtime/components/Calendar.vue +67 -150
  70. package/dist/runtime/components/Calendar.vue.d.ts +111 -0
  71. package/dist/runtime/components/Card.vue +18 -40
  72. package/dist/runtime/components/Card.vue.d.ts +29 -0
  73. package/dist/runtime/components/Carousel.vue +112 -234
  74. package/dist/runtime/components/Carousel.vue.d.ts +122 -0
  75. package/dist/runtime/components/Checkbox.vue +52 -93
  76. package/dist/runtime/components/Checkbox.vue.d.ts +73 -0
  77. package/dist/runtime/components/CheckboxGroup.vue +121 -0
  78. package/dist/runtime/components/CheckboxGroup.vue.d.ts +78 -0
  79. package/dist/runtime/components/Chip.vue +26 -69
  80. package/dist/runtime/components/Chip.vue.d.ts +57 -0
  81. package/dist/runtime/components/Collapsible.vue +22 -41
  82. package/dist/runtime/components/Collapsible.vue.d.ts +35 -0
  83. package/dist/runtime/components/ColorPicker.vue +111 -197
  84. package/dist/runtime/components/ColorPicker.vue.d.ts +48 -0
  85. package/dist/runtime/components/CommandPalette.vue +96 -237
  86. package/dist/runtime/components/CommandPalette.vue.d.ts +161 -0
  87. package/dist/runtime/components/Container.vue +15 -28
  88. package/dist/runtime/components/Container.vue.d.ts +18 -0
  89. package/dist/runtime/components/ContextMenu.vue +34 -133
  90. package/dist/runtime/components/ContextMenu.vue.d.ts +107 -0
  91. package/dist/runtime/components/ContextMenuContent.vue +73 -81
  92. package/dist/runtime/components/ContextMenuContent.vue.d.ts +65 -0
  93. package/dist/runtime/components/Drawer.vue +49 -83
  94. package/dist/runtime/components/Drawer.vue.d.ts +78 -0
  95. package/dist/runtime/components/DropdownMenu.vue +39 -142
  96. package/dist/runtime/components/DropdownMenu.vue.d.ts +117 -0
  97. package/dist/runtime/components/DropdownMenuContent.vue +78 -88
  98. package/dist/runtime/components/DropdownMenuContent.vue.d.ts +68 -0
  99. package/dist/runtime/components/Form.vue +135 -220
  100. package/dist/runtime/components/Form.vue.d.ts +69 -0
  101. package/dist/runtime/components/FormField.vue +35 -77
  102. package/dist/runtime/components/FormField.vue.d.ts +61 -0
  103. package/dist/runtime/components/Icon.vue +12 -19
  104. package/dist/runtime/components/Icon.vue.d.ts +8 -0
  105. package/dist/runtime/components/Input.vue +82 -140
  106. package/dist/runtime/components/Input.vue.d.ts +76 -0
  107. package/dist/runtime/components/InputMenu.vue +185 -332
  108. package/dist/runtime/components/InputMenu.vue.d.ts +324 -0
  109. package/dist/runtime/components/InputNumber.vue +71 -133
  110. package/dist/runtime/components/InputNumber.vue.d.ts +182 -0
  111. package/dist/runtime/components/Kbd.vue +20 -46
  112. package/dist/runtime/components/Kbd.vue.d.ts +34 -0
  113. package/dist/runtime/components/Link.vue +98 -176
  114. package/dist/runtime/components/Link.vue.d.ts +93 -0
  115. package/dist/runtime/components/LinkBase.vue +33 -42
  116. package/dist/runtime/components/LinkBase.vue.d.ts +25 -0
  117. package/dist/runtime/components/Modal.vue +53 -116
  118. package/dist/runtime/components/Modal.vue.d.ts +93 -0
  119. package/dist/runtime/components/NavigationMenu.vue +77 -209
  120. package/dist/runtime/components/NavigationMenu.vue.d.ts +139 -0
  121. package/dist/runtime/components/OverlayProvider.vue +14 -18
  122. package/dist/runtime/components/OverlayProvider.vue.d.ts +2 -0
  123. package/dist/runtime/components/Pagination.vue +46 -140
  124. package/dist/runtime/components/Pagination.vue.d.ts +119 -0
  125. package/dist/runtime/components/PinInput.vue +61 -78
  126. package/dist/runtime/components/PinInput.vue.d.ts +57 -0
  127. package/dist/runtime/components/Popover.vue +47 -84
  128. package/dist/runtime/components/Popover.vue.d.ts +63 -0
  129. package/dist/runtime/components/Progress.vue +70 -131
  130. package/dist/runtime/components/Progress.vue.d.ts +66 -0
  131. package/dist/runtime/components/RadioGroup.vue +70 -132
  132. package/dist/runtime/components/RadioGroup.vue.d.ts +91 -0
  133. package/dist/runtime/components/Select.vue +110 -224
  134. package/dist/runtime/components/Select.vue.d.ts +145 -0
  135. package/dist/runtime/components/SelectMenu.vue +161 -310
  136. package/dist/runtime/components/SelectMenu.vue.d.ts +196 -0
  137. package/dist/runtime/components/Separator.vue +29 -71
  138. package/dist/runtime/components/Separator.vue.d.ts +54 -0
  139. package/dist/runtime/components/Skeleton.vue +21 -23
  140. package/dist/runtime/components/Skeleton.vue.d.ts +17 -0
  141. package/dist/runtime/components/Slideover.vue +53 -120
  142. package/dist/runtime/components/Slideover.vue.d.ts +94 -0
  143. package/dist/runtime/components/Slider.vue +46 -84
  144. package/dist/runtime/components/Slider.vue.d.ts +52 -0
  145. package/dist/runtime/components/Stepper.vue +45 -115
  146. package/dist/runtime/components/Stepper.vue.d.ts +83 -0
  147. package/dist/runtime/components/Switch.vue +45 -93
  148. package/dist/runtime/components/Switch.vue.d.ts +70 -0
  149. package/dist/runtime/components/Table.vue +163 -267
  150. package/dist/runtime/components/Table.vue.d.ts +183 -0
  151. package/dist/runtime/components/Tabs.vue +41 -107
  152. package/dist/runtime/components/Tabs.vue.d.ts +88 -0
  153. package/dist/runtime/components/Textarea.vue +113 -158
  154. package/dist/runtime/components/Textarea.vue.d.ts +78 -0
  155. package/dist/runtime/components/Toast.vue +49 -110
  156. package/dist/runtime/components/Toast.vue.d.ts +157 -0
  157. package/dist/runtime/components/Toaster.vue +70 -107
  158. package/dist/runtime/components/Toaster.vue.d.ts +38 -0
  159. package/dist/runtime/components/Tooltip.vue +38 -65
  160. package/dist/runtime/components/Tooltip.vue.d.ts +50 -0
  161. package/dist/runtime/components/Tree.vue +59 -166
  162. package/dist/runtime/components/Tree.vue.d.ts +111 -0
  163. package/dist/runtime/composables/defineShortcuts.d.ts +1 -1
  164. package/dist/runtime/composables/defineShortcuts.js +6 -0
  165. package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
  166. package/dist/runtime/composables/useButtonGroup.d.ts +2 -2
  167. package/dist/runtime/composables/useFormField.d.ts +2 -2
  168. package/dist/runtime/composables/useKbd.d.ts +1 -0
  169. package/dist/runtime/composables/useKbd.js +4 -3
  170. package/dist/runtime/composables/useOverlay.d.ts +14 -8
  171. package/dist/runtime/composables/useOverlay.js +20 -7
  172. package/dist/runtime/composables/usePortal.d.ts +6 -0
  173. package/dist/runtime/composables/usePortal.js +17 -0
  174. package/dist/runtime/index.css +1 -1
  175. package/dist/runtime/inertia/components/Link.vue +146 -0
  176. package/dist/runtime/inertia/components/Link.vue.d.ts +63 -0
  177. package/dist/runtime/inertia/stubs.d.ts +43 -0
  178. package/dist/runtime/inertia/stubs.js +82 -0
  179. package/dist/runtime/locale/bg.d.ts +3 -0
  180. package/dist/runtime/locale/bg.js +54 -0
  181. package/dist/runtime/locale/index.d.ts +5 -1
  182. package/dist/runtime/locale/index.js +5 -1
  183. package/dist/runtime/locale/kk.d.ts +3 -0
  184. package/dist/runtime/locale/kk.js +54 -0
  185. package/dist/runtime/locale/tj.d.ts +3 -0
  186. package/dist/runtime/locale/tj.js +54 -0
  187. package/dist/runtime/locale/ug_cn.d.ts +3 -0
  188. package/dist/runtime/locale/ug_cn.js +55 -0
  189. package/dist/runtime/types/form.d.ts +4 -1
  190. package/dist/runtime/types/index.d.ts +1 -0
  191. package/dist/runtime/types/index.js +1 -0
  192. package/dist/runtime/types/tv.d.ts +53 -0
  193. package/dist/runtime/types/tv.js +0 -0
  194. package/dist/runtime/types/utils.d.ts +7 -17
  195. package/dist/runtime/types/utils.js +1 -0
  196. package/dist/runtime/utils/link.d.ts +3 -3
  197. package/dist/runtime/utils/link.js +1 -0
  198. package/dist/runtime/utils/tv.js +2 -2
  199. package/dist/runtime/vue/components/Icon.vue +7 -8
  200. package/dist/runtime/vue/components/Icon.vue.d.ts +5 -0
  201. package/dist/runtime/vue/components/Link.vue +118 -202
  202. package/dist/runtime/vue/components/Link.vue.d.ts +93 -0
  203. package/dist/runtime/vue/stubs.d.ts +2 -2
  204. package/dist/shared/{ui.BkNUP964.mjs → ui.CbtTMMzt.mjs} +631 -366
  205. package/dist/types.d.mts +3 -5
  206. package/dist/unplugin.d.mts +6 -2
  207. package/dist/unplugin.mjs +25 -4
  208. package/dist/vite.d.mts +1 -1
  209. package/dist/vite.mjs +2 -2
  210. package/package.json +96 -54
  211. package/dist/module.cjs +0 -62
  212. package/dist/module.d.cts +0 -45
  213. package/dist/module.d.ts +0 -45
  214. package/dist/shared/ui.BL-XB3u1.cjs +0 -3555
  215. package/dist/types.d.ts +0 -7
  216. package/dist/unplugin.cjs +0 -232
  217. package/dist/unplugin.d.cts +0 -62
  218. package/dist/unplugin.d.ts +0 -62
  219. package/dist/vite.cjs +0 -23
  220. package/dist/vite.d.cts +0 -15
  221. package/dist/vite.d.ts +0 -15
@@ -1,256 +1,116 @@
1
- <!-- eslint-disable vue/block-tag-newline -->
2
- <script lang="ts">
3
- import type { ListboxRootProps, ListboxRootEmits } from 'reka-ui'
4
- import type { FuseResult } from 'fuse.js'
5
- import type { AppConfig } from '@nuxt/schema'
6
- import type { UseFuseOptions } from '@vueuse/integrations/useFuse'
7
- import _appConfig from '#build/app.config'
8
- import theme from '#build/ui/command-palette'
9
- import type { UseComponentIconsProps } from '../composables/useComponentIcons'
10
- import { tv } from '../utils/tv'
11
- import type { AvatarProps, ButtonProps, ChipProps, KbdProps, InputProps, LinkProps } from '../types'
12
- import type { PartialString } from '../types/utils'
13
-
14
- const appConfigCommandPalette = _appConfig as AppConfig & { ui: { commandPalette: Partial<typeof theme> } }
15
-
16
- const commandPalette = tv({ extend: tv(theme), ...(appConfigCommandPalette.ui?.commandPalette || {}) })
17
-
18
- export interface CommandPaletteItem extends Omit<LinkProps, 'type' | 'raw' | 'custom'> {
19
- prefix?: string
20
- label?: string
21
- suffix?: string
22
- /**
23
- * @IconifyIcon
24
- */
25
- icon?: string
26
- avatar?: AvatarProps
27
- chip?: ChipProps
28
- kbds?: KbdProps['value'][] | KbdProps[]
29
- active?: boolean
30
- loading?: boolean
31
- disabled?: boolean
32
- slot?: string
33
- onSelect?(e?: Event): void
34
- [key: string]: any
35
- }
36
-
37
- export interface CommandPaletteGroup<T> {
38
- id: string
39
- label?: string
40
- slot?: string
41
- items?: T[]
42
- /**
43
- * Whether to filter group items with [useFuse](https://vueuse.org/integrations/useFuse).
44
- * When `true`, items will not be filtered which is useful for custom filtering (useAsyncData, useFetch, etc.).
45
- * @defaultValue false
46
- */
47
- ignoreFilter?: boolean
48
- /** Filter group items after the search happened. */
49
- postFilter?: (searchTerm: string, items: T[]) => T[]
50
- /**
51
- * The icon displayed when an item is highlighted.
52
- * @IconifyIcon
53
- */
54
- highlightedIcon?: string
55
- }
56
-
57
- export interface CommandPaletteProps<G, T> extends Pick<ListboxRootProps, 'multiple' | 'disabled' | 'modelValue' | 'defaultValue' | 'highlightOnHover'>, Pick<UseComponentIconsProps, 'loading' | 'loadingIcon'> {
58
- /**
59
- * The element or component this component should render as.
60
- * @defaultValue 'div'
61
- */
62
- as?: any
63
- /**
64
- * The icon displayed in the input.
65
- * @defaultValue appConfig.ui.icons.search
66
- * @IconifyIcon
67
- */
68
- icon?: string
69
- /**
70
- * The icon displayed when an item is selected.
71
- * @defaultValue appConfig.ui.icons.check
72
- * @IconifyIcon
73
- */
74
- selectedIcon?: string
75
- /**
76
- * The placeholder text for the input.
77
- * @defaultValue t('commandPalette.placeholder')
78
- */
79
- placeholder?: InputProps['placeholder']
80
- /**
81
- * Automatically focus the input when component is mounted.
82
- * @defaultValue true
83
- */
84
- autofocus?: boolean
85
- /**
86
- * Display a close button in the input (useful when inside a Modal for example).
87
- * `{ size: 'md', color: 'neutral', variant: 'ghost' }`{lang="ts-type"}
88
- * @emits 'update:open'
89
- * @defaultValue false
90
- */
91
- close?: boolean | Partial<ButtonProps>
92
- /**
93
- * The icon displayed in the close button.
94
- * @defaultValue appConfig.ui.icons.close
95
- * @IconifyIcon
96
- */
97
- closeIcon?: string
98
- groups?: G[]
99
- /**
100
- * Options for [useFuse](https://vueuse.org/integrations/useFuse).
101
- * @defaultValue {
102
- fuseOptions: {
103
- ignoreLocation: true,
104
- threshold: 0.1,
105
- keys: ['label', 'suffix']
106
- },
107
- resultLimit: 12,
108
- matchAllWhenSearchEmpty: true
109
- }
110
- */
111
- fuse?: UseFuseOptions<T>
112
- /**
113
- * The key used to get the label from the item.
114
- * @defaultValue 'label'
115
- */
116
- labelKey?: string
117
- class?: any
118
- ui?: PartialString<typeof commandPalette.slots>
119
- }
120
-
121
- export type CommandPaletteEmits<T> = ListboxRootEmits<T> & {
122
- 'update:open': [value: boolean]
123
- }
124
-
125
- type SlotProps<T> = (props: { item: T, index: number }) => any
126
-
127
- export type CommandPaletteSlots<G extends { slot?: string }, T extends { slot?: string }> = {
128
- 'empty'(props: { searchTerm?: string }): any
129
- 'close'(props: { ui: ReturnType<typeof commandPalette> }): any
130
- 'item': SlotProps<T>
131
- 'item-leading': SlotProps<T>
132
- 'item-label': SlotProps<T>
133
- 'item-trailing': SlotProps<T>
134
- } & Record<string, SlotProps<G>> & Record<string, SlotProps<T>>
135
-
1
+ <script>
2
+ import theme from "#build/ui/command-palette";
136
3
  </script>
137
4
 
138
- <script setup lang="ts" generic="G extends CommandPaletteGroup<T>, T extends CommandPaletteItem">
139
- import { computed } from 'vue'
140
- import { ListboxRoot, ListboxFilter, ListboxContent, ListboxGroup, ListboxGroupLabel, ListboxItem, ListboxItemIndicator, useForwardProps, useForwardPropsEmits } from 'reka-ui'
141
- import { defu } from 'defu'
142
- import { reactivePick } from '@vueuse/core'
143
- import { useFuse } from '@vueuse/integrations/useFuse'
144
- import { useAppConfig } from '#imports'
145
- import { useLocale } from '../composables/useLocale'
146
- import { omit, get } from '../utils'
147
- import { highlight } from '../utils/fuse'
148
- import { pickLinkProps } from '../utils/link'
149
- import UIcon from './Icon.vue'
150
- import UAvatar from './Avatar.vue'
151
- import UButton from './Button.vue'
152
- import UChip from './Chip.vue'
153
- import ULinkBase from './LinkBase.vue'
154
- import ULink from './Link.vue'
155
- import UInput from './Input.vue'
156
- import UKbd from './Kbd.vue'
157
-
158
- const props = withDefaults(defineProps<CommandPaletteProps<G, T>>(), {
159
- modelValue: '',
160
- labelKey: 'label',
161
- autofocus: true
162
- })
163
- const emits = defineEmits<CommandPaletteEmits<T>>()
164
- const slots = defineSlots<CommandPaletteSlots<G, T>>()
165
-
166
- const searchTerm = defineModel<string>('searchTerm', { default: '' })
167
-
168
- const { t } = useLocale()
169
- const appConfig = useAppConfig()
170
-
171
- const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'disabled', 'multiple', 'modelValue', 'defaultValue', 'highlightOnHover'), emits)
172
- const inputProps = useForwardProps(reactivePick(props, 'loading', 'loadingIcon'))
173
-
174
- // eslint-disable-next-line vue/no-dupe-keys
175
- const ui = commandPalette()
176
-
5
+ <script setup>
6
+ import { computed } from "vue";
7
+ import { ListboxRoot, ListboxFilter, ListboxContent, ListboxGroup, ListboxGroupLabel, ListboxItem, ListboxItemIndicator, useForwardProps, useForwardPropsEmits } from "reka-ui";
8
+ import { defu } from "defu";
9
+ import { reactivePick } from "@vueuse/core";
10
+ import { useFuse } from "@vueuse/integrations/useFuse";
11
+ import { useAppConfig } from "#imports";
12
+ import { useLocale } from "../composables/useLocale";
13
+ import { omit, get } from "../utils";
14
+ import { tv } from "../utils/tv";
15
+ import { highlight } from "../utils/fuse";
16
+ import { pickLinkProps } from "../utils/link";
17
+ import UIcon from "./Icon.vue";
18
+ import UAvatar from "./Avatar.vue";
19
+ import UButton from "./Button.vue";
20
+ import UChip from "./Chip.vue";
21
+ import ULinkBase from "./LinkBase.vue";
22
+ import ULink from "./Link.vue";
23
+ import UInput from "./Input.vue";
24
+ import UKbd from "./Kbd.vue";
25
+ const props = defineProps({
26
+ as: { type: null, required: false },
27
+ icon: { type: String, required: false },
28
+ selectedIcon: { type: String, required: false },
29
+ placeholder: { type: String, required: false },
30
+ autofocus: { type: Boolean, required: false, default: true },
31
+ close: { type: [Boolean, Object], required: false },
32
+ closeIcon: { type: String, required: false },
33
+ groups: { type: Array, required: false },
34
+ fuse: { type: Object, required: false },
35
+ labelKey: { type: String, required: false, default: "label" },
36
+ class: { type: null, required: false },
37
+ ui: { type: null, required: false },
38
+ multiple: { type: Boolean, required: false },
39
+ disabled: { type: Boolean, required: false },
40
+ modelValue: { type: null, required: false, default: "" },
41
+ defaultValue: { type: null, required: false },
42
+ highlightOnHover: { type: Boolean, required: false },
43
+ loading: { type: Boolean, required: false },
44
+ loadingIcon: { type: String, required: false }
45
+ });
46
+ const emits = defineEmits(["update:modelValue", "highlight", "entryFocus", "leave", "update:open"]);
47
+ const slots = defineSlots();
48
+ const searchTerm = defineModel("searchTerm", { type: String, ...{ default: "" } });
49
+ const { t } = useLocale();
50
+ const appConfig = useAppConfig();
51
+ const rootProps = useForwardPropsEmits(reactivePick(props, "as", "disabled", "multiple", "modelValue", "defaultValue", "highlightOnHover"), emits);
52
+ const inputProps = useForwardProps(reactivePick(props, "loading", "loadingIcon"));
53
+ const ui = computed(() => tv({ extend: tv(theme), ...appConfig.ui?.commandPalette || {} })());
177
54
  const fuse = computed(() => defu({}, props.fuse, {
178
55
  fuseOptions: {
179
56
  ignoreLocation: true,
180
57
  threshold: 0.1,
181
- keys: [props.labelKey, 'suffix']
58
+ keys: [props.labelKey, "suffix"]
182
59
  },
183
60
  resultLimit: 12,
184
61
  matchAllWhenSearchEmpty: true
185
- }))
186
-
62
+ }));
187
63
  const items = computed(() => props.groups?.filter((group) => {
188
64
  if (!group.id) {
189
- console.warn(`[@nuxt/ui] CommandPalette group is missing an \`id\` property`)
190
- return false
65
+ console.warn(`[@nuxt/ui] CommandPalette group is missing an \`id\` property`);
66
+ return false;
191
67
  }
192
-
193
68
  if (group.ignoreFilter) {
194
- return false
69
+ return false;
195
70
  }
196
-
197
- return true
198
- }).flatMap(group => group.items?.map(item => ({ ...item, group: group.id })) || []) || [])
199
-
200
- const { results: fuseResults } = useFuse<typeof items.value[number]>(searchTerm, items, fuse)
201
-
202
- function getGroupWithItems(group: G, items: (T & { matches?: FuseResult<T>['matches'] })[]) {
203
- if (group?.postFilter && typeof group.postFilter === 'function') {
204
- items = group.postFilter(searchTerm.value, items)
71
+ return true;
72
+ }).flatMap((group) => group.items?.map((item) => ({ ...item, group: group.id })) || []) || []);
73
+ const { results: fuseResults } = useFuse(searchTerm, items, fuse);
74
+ function getGroupWithItems(group, items2) {
75
+ if (group?.postFilter && typeof group.postFilter === "function") {
76
+ items2 = group.postFilter(searchTerm.value, items2);
205
77
  }
206
-
207
78
  return {
208
79
  ...group,
209
- items: items.slice(0, fuse.value.resultLimit).map((item) => {
80
+ items: items2.slice(0, fuse.value.resultLimit).map((item) => {
210
81
  return {
211
82
  ...item,
212
- labelHtml: highlight<T>(item, searchTerm.value, props.labelKey),
213
- suffixHtml: highlight<T>(item, searchTerm.value, undefined, [props.labelKey])
214
- }
83
+ labelHtml: highlight(item, searchTerm.value, props.labelKey),
84
+ suffixHtml: highlight(item, searchTerm.value, void 0, [props.labelKey])
85
+ };
215
86
  })
216
- }
87
+ };
217
88
  }
218
-
219
89
  const groups = computed(() => {
220
90
  const groupsById = fuseResults.value.reduce((acc, result) => {
221
- const { item, matches } = result
91
+ const { item, matches } = result;
222
92
  if (!item.group) {
223
- return acc
93
+ return acc;
224
94
  }
225
-
226
- acc[item.group] ||= []
227
- acc[item.group]?.push({ ...item, matches })
228
-
229
- return acc
230
- }, {} as Record<string, (T & { matches?: FuseResult<T>['matches'] })[]>)
231
-
232
- const fuseGroups = Object.entries(groupsById).map(([id, items]) => {
233
- const group = props.groups?.find(group => group.id === id)
95
+ acc[item.group] ||= [];
96
+ acc[item.group]?.push({ ...item, matches });
97
+ return acc;
98
+ }, {});
99
+ const fuseGroups = Object.entries(groupsById).map(([id, items2]) => {
100
+ const group = props.groups?.find((group2) => group2.id === id);
234
101
  if (!group) {
235
- return
102
+ return;
236
103
  }
237
-
238
- return getGroupWithItems(group, items)
239
- }).filter(group => !!group)
240
-
241
- const nonFuseGroups = props.groups
242
- ?.map((group, index) => ({ ...group, index }))
243
- ?.filter(group => group.ignoreFilter && group.items?.length)
244
- ?.map(group => ({ ...getGroupWithItems(group, group.items || []), index: group.index })) || []
245
-
104
+ return getGroupWithItems(group, items2);
105
+ }).filter((group) => !!group);
106
+ const nonFuseGroups = props.groups?.map((group, index) => ({ ...group, index }))?.filter((group) => group.ignoreFilter && group.items?.length)?.map((group) => ({ ...getGroupWithItems(group, group.items || []), index: group.index })) || [];
246
107
  return nonFuseGroups.reduce((acc, group) => {
247
- acc.splice(group.index, 0, group)
248
- return acc
249
- }, [...fuseGroups])
250
- })
108
+ acc.splice(group.index, 0, group);
109
+ return acc;
110
+ }, [...fuseGroups]);
111
+ });
251
112
  </script>
252
113
 
253
- <!-- eslint-disable vue/no-v-html -->
254
114
  <template>
255
115
  <ListboxRoot v-bind="rootProps" :class="ui.root({ class: [props.class, props.ui?.root] })">
256
116
  <ListboxFilter v-model="searchTerm" as-child>
@@ -258,7 +118,6 @@ const groups = computed(() => {
258
118
  :placeholder="placeholder || t('commandPalette.placeholder')"
259
119
  variant="none"
260
120
  :autofocus="autofocus"
261
- size="lg"
262
121
  v-bind="inputProps"
263
122
  :icon="icon || appConfig.ui.icons.search"
264
123
  :class="ui.input({ class: props.ui?.input })"
@@ -272,7 +131,7 @@ const groups = computed(() => {
272
131
  color="neutral"
273
132
  variant="ghost"
274
133
  :aria-label="t('commandPalette.close')"
275
- v-bind="(typeof close === 'object' ? close as Partial<ButtonProps> : {})"
134
+ v-bind="typeof close === 'object' ? close : {}"
276
135
  :class="ui.close({ class: props.ui?.close })"
277
136
  @click="emits('update:open', false)"
278
137
  />
@@ -284,28 +143,28 @@ const groups = computed(() => {
284
143
  <ListboxContent :class="ui.content({ class: props.ui?.content })">
285
144
  <div v-if="groups?.length" :class="ui.viewport({ class: props.ui?.viewport })">
286
145
  <ListboxGroup v-for="group in groups" :key="`group-${group.id}`" :class="ui.group({ class: props.ui?.group })">
287
- <ListboxGroupLabel v-if="get(group, props.labelKey as string)" :class="ui.label({ class: props.ui?.label })">
288
- {{ get(group, props.labelKey as string) }}
146
+ <ListboxGroupLabel v-if="get(group, props.labelKey)" :class="ui.label({ class: props.ui?.label })">
147
+ {{ get(group, props.labelKey) }}
289
148
  </ListboxGroupLabel>
290
149
 
291
150
  <ListboxItem
292
151
  v-for="(item, index) in group.items"
293
152
  :key="`group-${group.id}-${index}`"
294
- :value="omit(item, ['matches' as any, 'group' as any, 'onSelect', 'labelHtml', 'suffixHtml'])"
153
+ :value="omit(item, ['matches', 'group', 'onSelect', 'labelHtml', 'suffixHtml'])"
295
154
  :disabled="item.disabled"
296
155
  as-child
297
156
  @select="item.onSelect"
298
157
  >
299
158
  <ULink v-slot="{ active, ...slotProps }" v-bind="pickLinkProps(item)" custom>
300
159
  <ULinkBase v-bind="slotProps" :class="ui.item({ class: props.ui?.item, active: active || item.active })">
301
- <slot :name="((item.slot || group.slot || 'item') as keyof CommandPaletteSlots<G, T>)" :item="(item as any)" :index="index">
302
- <slot :name="((item.slot ? `${item.slot}-leading` : group.slot ? `${group.slot}-leading` : `item-leading`) as keyof CommandPaletteSlots<G, T>)" :item="(item as any)" :index="index">
160
+ <slot :name="item.slot || group.slot || 'item'" :item="item" :index="index">
161
+ <slot :name="item.slot ? `${item.slot}-leading` : group.slot ? `${group.slot}-leading` : `item-leading`" :item="item" :index="index">
303
162
  <UIcon v-if="item.loading" :name="loadingIcon || appConfig.ui.icons.loading" :class="ui.itemLeadingIcon({ class: props.ui?.itemLeadingIcon, loading: true })" />
304
163
  <UIcon v-else-if="item.icon" :name="item.icon" :class="ui.itemLeadingIcon({ class: props.ui?.itemLeadingIcon, active: active || item.active })" />
305
- <UAvatar v-else-if="item.avatar" :size="((props.ui?.itemLeadingAvatarSize || ui.itemLeadingAvatarSize()) as AvatarProps['size'])" v-bind="item.avatar" :class="ui.itemLeadingAvatar({ class: props.ui?.itemLeadingAvatar, active: active || item.active })" />
164
+ <UAvatar v-else-if="item.avatar" :size="props.ui?.itemLeadingAvatarSize || ui.itemLeadingAvatarSize()" v-bind="item.avatar" :class="ui.itemLeadingAvatar({ class: props.ui?.itemLeadingAvatar, active: active || item.active })" />
306
165
  <UChip
307
166
  v-else-if="item.chip"
308
- :size="((props.ui?.itemLeadingChipSize || ui.itemLeadingChipSize()) as ChipProps['size'])"
167
+ :size="props.ui?.itemLeadingChipSize || ui.itemLeadingChipSize()"
309
168
  inset
310
169
  standalone
311
170
  v-bind="item.chip"
@@ -313,20 +172,20 @@ const groups = computed(() => {
313
172
  />
314
173
  </slot>
315
174
 
316
- <span v-if="item.labelHtml || get(item, props.labelKey as string) || !!slots[(item.slot ? `${item.slot}-label` : group.slot ? `${group.slot}-label` : `item-label`) as keyof CommandPaletteSlots<G, T>]" :class="ui.itemLabel({ class: props.ui?.itemLabel, active: active || item.active })">
317
- <slot :name="((item.slot ? `${item.slot}-label` : group.slot ? `${group.slot}-label` : `item-label`) as keyof CommandPaletteSlots<G, T>)" :item="(item as any)" :index="index">
175
+ <span v-if="item.labelHtml || get(item, props.labelKey) || !!slots[item.slot ? `${item.slot}-label` : group.slot ? `${group.slot}-label` : `item-label`]" :class="ui.itemLabel({ class: props.ui?.itemLabel, active: active || item.active })">
176
+ <slot :name="item.slot ? `${item.slot}-label` : group.slot ? `${group.slot}-label` : `item-label`" :item="item" :index="index">
318
177
  <span v-if="item.prefix" :class="ui.itemLabelPrefix({ class: props.ui?.itemLabelPrefix })">{{ item.prefix }}</span>
319
178
 
320
- <span :class="ui.itemLabelBase({ class: props.ui?.itemLabelBase, active: active || item.active })" v-html="item.labelHtml || get(item, props.labelKey as string)" />
179
+ <span :class="ui.itemLabelBase({ class: props.ui?.itemLabelBase, active: active || item.active })" v-html="item.labelHtml || get(item, props.labelKey)" />
321
180
 
322
181
  <span :class="ui.itemLabelSuffix({ class: props.ui?.itemLabelSuffix, active: active || item.active })" v-html="item.suffixHtml || item.suffix" />
323
182
  </slot>
324
183
  </span>
325
184
 
326
185
  <span :class="ui.itemTrailing({ class: props.ui?.itemTrailing })">
327
- <slot :name="((item.slot ? `${item.slot}-trailing` : group.slot ? `${group.slot}-trailing` : `item-trailing`) as keyof CommandPaletteSlots<G, T>)" :item="(item as any)" :index="index">
186
+ <slot :name="item.slot ? `${item.slot}-trailing` : group.slot ? `${group.slot}-trailing` : `item-trailing`" :item="item" :index="index">
328
187
  <span v-if="item.kbds?.length" :class="ui.itemTrailingKbds({ class: props.ui?.itemTrailingKbds })">
329
- <UKbd v-for="(kbd, kbdIndex) in item.kbds" :key="kbdIndex" :size="((props.ui?.itemTrailingKbdsSize || ui.itemTrailingKbdsSize()) as KbdProps['size'])" v-bind="typeof kbd === 'string' ? { value: kbd } : kbd" />
188
+ <UKbd v-for="(kbd, kbdIndex) in item.kbds" :key="kbdIndex" :size="props.ui?.itemTrailingKbdsSize || ui.itemTrailingKbdsSize()" v-bind="typeof kbd === 'string' ? { value: kbd } : kbd" />
330
189
  </span>
331
190
  <UIcon v-else-if="group.highlightedIcon" :name="group.highlightedIcon" :class="ui.itemTrailingHighlightedIcon({ class: props.ui?.itemTrailingHighlightedIcon })" />
332
191
  </slot>
@@ -0,0 +1,161 @@
1
+ import type { ListboxRootProps, ListboxRootEmits } from 'reka-ui';
2
+ import type { AppConfig } from '@nuxt/schema';
3
+ import type { UseFuseOptions } from '@vueuse/integrations/useFuse';
4
+ import theme from '#build/ui/command-palette';
5
+ import type { UseComponentIconsProps } from '../composables/useComponentIcons';
6
+ import type { AvatarProps, ButtonProps, ChipProps, KbdProps, InputProps, LinkProps } from '../types';
7
+ import type { ComponentConfig } from '../types/utils';
8
+ type CommandPalette = ComponentConfig<typeof theme, AppConfig, 'commandPalette'>;
9
+ export interface CommandPaletteItem extends Omit<LinkProps, 'type' | 'raw' | 'custom'> {
10
+ prefix?: string;
11
+ label?: string;
12
+ suffix?: string;
13
+ /**
14
+ * @IconifyIcon
15
+ */
16
+ icon?: string;
17
+ avatar?: AvatarProps;
18
+ chip?: ChipProps;
19
+ kbds?: KbdProps['value'][] | KbdProps[];
20
+ active?: boolean;
21
+ loading?: boolean;
22
+ disabled?: boolean;
23
+ slot?: string;
24
+ onSelect?(e?: Event): void;
25
+ [key: string]: any;
26
+ }
27
+ export interface CommandPaletteGroup<T> {
28
+ id: string;
29
+ label?: string;
30
+ slot?: string;
31
+ items?: T[];
32
+ /**
33
+ * Whether to filter group items with [useFuse](https://vueuse.org/integrations/useFuse).
34
+ * When `true`, items will not be filtered which is useful for custom filtering (useAsyncData, useFetch, etc.).
35
+ * @defaultValue false
36
+ */
37
+ ignoreFilter?: boolean;
38
+ /** Filter group items after the search happened. */
39
+ postFilter?: (searchTerm: string, items: T[]) => T[];
40
+ /**
41
+ * The icon displayed when an item is highlighted.
42
+ * @IconifyIcon
43
+ */
44
+ highlightedIcon?: string;
45
+ }
46
+ export interface CommandPaletteProps<G, T> extends Pick<ListboxRootProps, 'multiple' | 'disabled' | 'modelValue' | 'defaultValue' | 'highlightOnHover'>, Pick<UseComponentIconsProps, 'loading' | 'loadingIcon'> {
47
+ /**
48
+ * The element or component this component should render as.
49
+ * @defaultValue 'div'
50
+ */
51
+ as?: any;
52
+ /**
53
+ * The icon displayed in the input.
54
+ * @defaultValue appConfig.ui.icons.search
55
+ * @IconifyIcon
56
+ */
57
+ icon?: string;
58
+ /**
59
+ * The icon displayed when an item is selected.
60
+ * @defaultValue appConfig.ui.icons.check
61
+ * @IconifyIcon
62
+ */
63
+ selectedIcon?: string;
64
+ /**
65
+ * The placeholder text for the input.
66
+ * @defaultValue t('commandPalette.placeholder')
67
+ */
68
+ placeholder?: InputProps['placeholder'];
69
+ /**
70
+ * Automatically focus the input when component is mounted.
71
+ * @defaultValue true
72
+ */
73
+ autofocus?: boolean;
74
+ /**
75
+ * Display a close button in the input (useful when inside a Modal for example).
76
+ * `{ size: 'md', color: 'neutral', variant: 'ghost' }`{lang="ts-type"}
77
+ * @emits 'update:open'
78
+ * @defaultValue false
79
+ */
80
+ close?: boolean | Partial<ButtonProps>;
81
+ /**
82
+ * The icon displayed in the close button.
83
+ * @defaultValue appConfig.ui.icons.close
84
+ * @IconifyIcon
85
+ */
86
+ closeIcon?: string;
87
+ groups?: G[];
88
+ /**
89
+ * Options for [useFuse](https://vueuse.org/integrations/useFuse).
90
+ * @defaultValue {
91
+ fuseOptions: {
92
+ ignoreLocation: true,
93
+ threshold: 0.1,
94
+ keys: ['label', 'suffix']
95
+ },
96
+ resultLimit: 12,
97
+ matchAllWhenSearchEmpty: true
98
+ }
99
+ */
100
+ fuse?: UseFuseOptions<T>;
101
+ /**
102
+ * The key used to get the label from the item.
103
+ * @defaultValue 'label'
104
+ */
105
+ labelKey?: string;
106
+ class?: any;
107
+ ui?: CommandPalette['slots'];
108
+ }
109
+ export type CommandPaletteEmits<T> = ListboxRootEmits<T> & {
110
+ 'update:open': [value: boolean];
111
+ };
112
+ type SlotProps<T> = (props: {
113
+ item: T;
114
+ index: number;
115
+ }) => any;
116
+ export type CommandPaletteSlots<G extends {
117
+ slot?: string;
118
+ }, T extends {
119
+ slot?: string;
120
+ }> = {
121
+ 'empty'(props: {
122
+ searchTerm?: string;
123
+ }): any;
124
+ 'close'(props: {
125
+ ui: {
126
+ [K in keyof Required<CommandPalette['slots']>]: (props?: Record<string, any>) => string;
127
+ };
128
+ }): any;
129
+ 'item': SlotProps<T>;
130
+ 'item-leading': SlotProps<T>;
131
+ 'item-label': SlotProps<T>;
132
+ 'item-trailing': SlotProps<T>;
133
+ } & Record<string, SlotProps<G>> & Record<string, SlotProps<T>>;
134
+ declare const _default: <G extends CommandPaletteGroup<T>, T extends CommandPaletteItem>(__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<{
135
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
136
+ readonly "onUpdate:open"?: ((value: boolean) => any) | undefined;
137
+ readonly "onUpdate:modelValue"?: ((value: T) => any) | undefined;
138
+ readonly onHighlight?: ((payload: {
139
+ ref: HTMLElement;
140
+ value: T;
141
+ } | undefined) => any) | undefined;
142
+ readonly "onUpdate:searchTerm"?: ((value: string) => any) | undefined;
143
+ readonly onEntryFocus?: ((event: CustomEvent<any>) => any) | undefined;
144
+ readonly onLeave?: ((event: Event) => any) | undefined;
145
+ } & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, "onUpdate:open" | "onUpdate:modelValue" | "onHighlight" | "onUpdate:searchTerm" | "onEntryFocus" | "onLeave"> & (CommandPaletteProps<G, T> & {
146
+ searchTerm?: string;
147
+ }) & Partial<{}>> & import("vue").PublicProps;
148
+ expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
149
+ attrs: any;
150
+ slots: CommandPaletteSlots<G, T>;
151
+ emit: (((evt: "update:open", value: boolean) => void) & ((evt: "update:modelValue", value: T) => void) & ((evt: "highlight", payload: {
152
+ ref: HTMLElement;
153
+ value: T;
154
+ } | undefined) => void) & ((evt: "entryFocus", event: CustomEvent<any>) => void) & ((evt: "leave", event: Event) => void)) & ((evt: "update:searchTerm", value: string) => void);
155
+ }>) => import("vue").VNode & {
156
+ __ctx?: Awaited<typeof __VLS_setup>;
157
+ };
158
+ export default _default;
159
+ type __VLS_PrettifyLocal<T> = {
160
+ [K in keyof T]: T[K];
161
+ } & {};
@@ -1,36 +1,23 @@
1
- <script lang="ts">
2
- import type { AppConfig } from '@nuxt/schema'
3
- import _appConfig from '#build/app.config'
4
- import theme from '#build/ui/container'
5
- import { tv } from '../utils/tv'
6
-
7
- const appConfigContainer = _appConfig as AppConfig & { ui: { container: Partial<typeof theme> } }
8
-
9
- const container = tv({ extend: tv(theme), ...(appConfigContainer.ui?.container || {}) })
10
-
11
- export interface ContainerProps {
12
- /**
13
- * The element or component this component should render as.
14
- * @defaultValue 'div'
15
- */
16
- as?: any
17
- class?: any
18
- }
19
-
20
- export interface ContainerSlots {
21
- default(props?: {}): any
22
- }
1
+ <script>
2
+ import theme from "#build/ui/container";
23
3
  </script>
24
4
 
25
- <script setup lang="ts">
26
- import { Primitive } from 'reka-ui'
27
-
28
- const props = defineProps<ContainerProps>()
29
- defineSlots<ContainerSlots>()
5
+ <script setup>
6
+ import { computed } from "vue";
7
+ import { Primitive } from "reka-ui";
8
+ import { useAppConfig } from "#imports";
9
+ import { tv } from "../utils/tv";
10
+ const props = defineProps({
11
+ as: { type: null, required: false },
12
+ class: { type: null, required: false }
13
+ });
14
+ defineSlots();
15
+ const appConfig = useAppConfig();
16
+ const ui = computed(() => tv({ extend: tv(theme), ...appConfig.ui?.container || {} }));
30
17
  </script>
31
18
 
32
19
  <template>
33
- <Primitive :as="as" :class="container({ class: props.class })">
20
+ <Primitive :as="as" :class="ui({ class: props.class })">
34
21
  <slot />
35
22
  </Primitive>
36
23
  </template>
@@ -0,0 +1,18 @@
1
+ export interface ContainerProps {
2
+ /**
3
+ * The element or component this component should render as.
4
+ * @defaultValue 'div'
5
+ */
6
+ as?: any;
7
+ class?: any;
8
+ }
9
+ export interface ContainerSlots {
10
+ default(props?: {}): any;
11
+ }
12
+ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<ContainerProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ContainerProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, ContainerSlots>;
13
+ export default _default;
14
+ type __VLS_WithSlots<T, S> = T & {
15
+ new (): {
16
+ $slots: S;
17
+ };
18
+ };