@bitrix24/b24ui-nuxt 0.5.11 → 0.6.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 (199) hide show
  1. package/.nuxt/b24ui/input-menu.ts +2 -2
  2. package/.nuxt/b24ui/select-menu.ts +4 -4
  3. package/.nuxt/b24ui/select.ts +2 -2
  4. package/dist/meta.d.mts +5208 -5061
  5. package/dist/meta.mjs +5208 -5061
  6. package/dist/module.json +3 -3
  7. package/dist/module.mjs +2 -2
  8. package/dist/runtime/components/Advice.vue +27 -54
  9. package/dist/runtime/components/Advice.vue.d.ts +170 -0
  10. package/dist/runtime/components/Alert.vue +35 -96
  11. package/dist/runtime/components/Alert.vue.d.ts +464 -0
  12. package/dist/runtime/components/App.vue +24 -34
  13. package/dist/runtime/components/App.vue.d.ts +23 -0
  14. package/dist/runtime/components/Avatar.vue +43 -81
  15. package/dist/runtime/components/Avatar.vue.d.ts +281 -0
  16. package/dist/runtime/components/AvatarGroup.vue +40 -76
  17. package/dist/runtime/components/AvatarGroup.vue.d.ts +204 -0
  18. package/dist/runtime/components/Badge.vue +40 -83
  19. package/dist/runtime/components/Badge.vue.d.ts +517 -0
  20. package/dist/runtime/components/Button.vue +96 -155
  21. package/dist/runtime/components/Button.vue.d.ts +640 -0
  22. package/dist/runtime/components/ButtonGroup.vue +19 -51
  23. package/dist/runtime/components/ButtonGroup.vue.d.ts +116 -0
  24. package/dist/runtime/components/Calendar.vue +73 -152
  25. package/dist/runtime/components/Calendar.vue.d.ts +437 -0
  26. package/dist/runtime/components/Checkbox.vue +42 -73
  27. package/dist/runtime/components/Checkbox.vue.d.ts +354 -0
  28. package/dist/runtime/components/Chip.vue +26 -74
  29. package/dist/runtime/components/Chip.vue.d.ts +271 -0
  30. package/dist/runtime/components/Collapsible.vue +22 -41
  31. package/dist/runtime/components/Collapsible.vue.d.ts +118 -0
  32. package/dist/runtime/components/Container.vue +13 -27
  33. package/dist/runtime/components/Container.vue.d.ts +27 -0
  34. package/dist/runtime/components/Countdown.vue +153 -378
  35. package/dist/runtime/components/Countdown.vue.d.ts +356 -0
  36. package/dist/runtime/components/DescriptionList.vue +78 -149
  37. package/dist/runtime/components/DescriptionList.vue.d.ts +379 -0
  38. package/dist/runtime/components/DropdownMenu.vue +38 -139
  39. package/dist/runtime/components/DropdownMenu.vue.d.ts +533 -0
  40. package/dist/runtime/components/DropdownMenuContent.vue +68 -80
  41. package/dist/runtime/components/DropdownMenuContent.vue.d.ts +228 -0
  42. package/dist/runtime/components/Form.vue +130 -217
  43. package/dist/runtime/components/Form.vue.d.ts +55 -0
  44. package/dist/runtime/components/FormField.vue +36 -80
  45. package/dist/runtime/components/FormField.vue.d.ts +282 -0
  46. package/dist/runtime/components/Input.vue +79 -179
  47. package/dist/runtime/components/Input.vue.d.ts +755 -0
  48. package/dist/runtime/components/InputMenu.vue +185 -381
  49. package/dist/runtime/components/InputMenu.vue.d.ts +1523 -0
  50. package/dist/runtime/components/InputNumber.vue +77 -175
  51. package/dist/runtime/components/InputNumber.vue.d.ts +658 -0
  52. package/dist/runtime/components/Kbd.vue +18 -45
  53. package/dist/runtime/components/Kbd.vue.d.ts +109 -0
  54. package/dist/runtime/components/Link.vue +92 -173
  55. package/dist/runtime/components/Link.vue.d.ts +129 -0
  56. package/dist/runtime/components/LinkBase.vue +33 -42
  57. package/dist/runtime/components/LinkBase.vue.d.ts +48 -0
  58. package/dist/runtime/components/Modal.vue +48 -127
  59. package/dist/runtime/components/Modal.vue.d.ts +327 -0
  60. package/dist/runtime/components/ModalDialogClose.vue +5 -8
  61. package/dist/runtime/components/ModalDialogClose.vue.d.ts +10 -0
  62. package/dist/runtime/components/Navbar.vue +15 -33
  63. package/dist/runtime/components/Navbar.vue.d.ts +101 -0
  64. package/dist/runtime/components/NavbarDivider.vue +15 -33
  65. package/dist/runtime/components/NavbarDivider.vue.d.ts +101 -0
  66. package/dist/runtime/components/NavbarSection.vue +15 -33
  67. package/dist/runtime/components/NavbarSection.vue.d.ts +101 -0
  68. package/dist/runtime/components/NavbarSpacer.vue +15 -33
  69. package/dist/runtime/components/NavbarSpacer.vue.d.ts +101 -0
  70. package/dist/runtime/components/NavigationMenu.vue +74 -208
  71. package/dist/runtime/components/NavigationMenu.vue.d.ts +824 -0
  72. package/dist/runtime/components/OverlayProvider.vue +14 -18
  73. package/dist/runtime/components/OverlayProvider.vue.d.ts +2 -0
  74. package/dist/runtime/components/Popover.vue +40 -81
  75. package/dist/runtime/components/Popover.vue.d.ts +147 -0
  76. package/dist/runtime/components/Progress.vue +70 -136
  77. package/dist/runtime/components/Progress.vue.d.ts +592 -0
  78. package/dist/runtime/components/RadioGroup.vue +59 -134
  79. package/dist/runtime/components/RadioGroup.vue.d.ts +723 -0
  80. package/dist/runtime/components/Range.vue +46 -85
  81. package/dist/runtime/components/Range.vue.d.ts +417 -0
  82. package/dist/runtime/components/Select.vue +110 -260
  83. package/dist/runtime/components/Select.vue.d.ts +1201 -0
  84. package/dist/runtime/components/SelectMenu.vue +161 -347
  85. package/dist/runtime/components/SelectMenu.vue.d.ts +1298 -0
  86. package/dist/runtime/components/Separator.vue +28 -71
  87. package/dist/runtime/components/Separator.vue.d.ts +400 -0
  88. package/dist/runtime/components/Sidebar.vue +15 -33
  89. package/dist/runtime/components/Sidebar.vue.d.ts +101 -0
  90. package/dist/runtime/components/SidebarBody.vue +17 -38
  91. package/dist/runtime/components/SidebarBody.vue.d.ts +90 -0
  92. package/dist/runtime/components/SidebarFooter.vue +15 -33
  93. package/dist/runtime/components/SidebarFooter.vue.d.ts +101 -0
  94. package/dist/runtime/components/SidebarHeader.vue +15 -33
  95. package/dist/runtime/components/SidebarHeader.vue.d.ts +101 -0
  96. package/dist/runtime/components/SidebarHeading.vue +15 -33
  97. package/dist/runtime/components/SidebarHeading.vue.d.ts +101 -0
  98. package/dist/runtime/components/SidebarLayout.vue +34 -70
  99. package/dist/runtime/components/SidebarLayout.vue.d.ts +222 -0
  100. package/dist/runtime/components/SidebarSection.vue +15 -33
  101. package/dist/runtime/components/SidebarSection.vue.d.ts +101 -0
  102. package/dist/runtime/components/SidebarSpacer.vue +15 -33
  103. package/dist/runtime/components/SidebarSpacer.vue.d.ts +101 -0
  104. package/dist/runtime/components/Skeleton.vue +12 -22
  105. package/dist/runtime/components/Skeleton.vue.d.ts +26 -0
  106. package/dist/runtime/components/Slideover.vue +50 -131
  107. package/dist/runtime/components/Slideover.vue.d.ts +360 -0
  108. package/dist/runtime/components/StackedLayout.vue +34 -73
  109. package/dist/runtime/components/StackedLayout.vue.d.ts +192 -0
  110. package/dist/runtime/components/Switch.vue +46 -95
  111. package/dist/runtime/components/Switch.vue.d.ts +587 -0
  112. package/dist/runtime/components/Tabs.vue +37 -105
  113. package/dist/runtime/components/Tabs.vue.d.ts +453 -0
  114. package/dist/runtime/components/Textarea.vue +92 -201
  115. package/dist/runtime/components/Textarea.vue.d.ts +601 -0
  116. package/dist/runtime/components/Toast.vue +47 -105
  117. package/dist/runtime/components/Toast.vue.d.ts +438 -0
  118. package/dist/runtime/components/Toaster.vue +70 -115
  119. package/dist/runtime/components/Toaster.vue.d.ts +219 -0
  120. package/dist/runtime/components/Tooltip.vue +36 -64
  121. package/dist/runtime/components/Tooltip.vue.d.ts +186 -0
  122. package/dist/runtime/components/content/TableWrapper.vue +24 -70
  123. package/dist/runtime/components/content/TableWrapper.vue.d.ts +237 -0
  124. package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
  125. package/dist/runtime/composables/useButtonGroup.d.ts +2 -2
  126. package/dist/runtime/composables/useComponentIcons.d.ts +3 -3
  127. package/dist/runtime/composables/useFormField.d.ts +2 -2
  128. package/dist/runtime/composables/useOverlay.d.ts +14 -7
  129. package/dist/runtime/composables/useOverlay.js +14 -6
  130. package/dist/runtime/prose/A.vue +12 -23
  131. package/dist/runtime/prose/A.vue.d.ts +84 -0
  132. package/dist/runtime/prose/Blockquote.vue +12 -23
  133. package/dist/runtime/prose/Blockquote.vue.d.ts +84 -0
  134. package/dist/runtime/prose/Code.vue +14 -31
  135. package/dist/runtime/prose/Code.vue.d.ts +97 -0
  136. package/dist/runtime/prose/Em.vue +12 -23
  137. package/dist/runtime/prose/Em.vue.d.ts +84 -0
  138. package/dist/runtime/prose/H1.vue +12 -23
  139. package/dist/runtime/prose/H1.vue.d.ts +97 -0
  140. package/dist/runtime/prose/H2.vue +12 -23
  141. package/dist/runtime/prose/H2.vue.d.ts +123 -0
  142. package/dist/runtime/prose/H3.vue +12 -23
  143. package/dist/runtime/prose/H3.vue.d.ts +123 -0
  144. package/dist/runtime/prose/H4.vue +12 -23
  145. package/dist/runtime/prose/H4.vue.d.ts +123 -0
  146. package/dist/runtime/prose/H5.vue +12 -23
  147. package/dist/runtime/prose/H5.vue.d.ts +123 -0
  148. package/dist/runtime/prose/H6.vue +12 -23
  149. package/dist/runtime/prose/H6.vue.d.ts +123 -0
  150. package/dist/runtime/prose/Hr.vue +12 -19
  151. package/dist/runtime/prose/Hr.vue.d.ts +74 -0
  152. package/dist/runtime/prose/Img.vue +12 -23
  153. package/dist/runtime/prose/Img.vue.d.ts +77 -0
  154. package/dist/runtime/prose/Li.vue +12 -23
  155. package/dist/runtime/prose/Li.vue.d.ts +84 -0
  156. package/dist/runtime/prose/Ol.vue +12 -23
  157. package/dist/runtime/prose/Ol.vue.d.ts +84 -0
  158. package/dist/runtime/prose/P.vue +12 -23
  159. package/dist/runtime/prose/P.vue.d.ts +84 -0
  160. package/dist/runtime/prose/Pre.vue +16 -33
  161. package/dist/runtime/prose/Pre.vue.d.ts +117 -0
  162. package/dist/runtime/prose/Strong.vue +12 -23
  163. package/dist/runtime/prose/Strong.vue.d.ts +84 -0
  164. package/dist/runtime/prose/Table.vue +19 -54
  165. package/dist/runtime/prose/Table.vue.d.ts +144 -0
  166. package/dist/runtime/prose/Tbody.vue +12 -23
  167. package/dist/runtime/prose/Tbody.vue.d.ts +84 -0
  168. package/dist/runtime/prose/Td.vue +12 -23
  169. package/dist/runtime/prose/Td.vue.d.ts +84 -0
  170. package/dist/runtime/prose/Th.vue +12 -23
  171. package/dist/runtime/prose/Th.vue.d.ts +84 -0
  172. package/dist/runtime/prose/Thead.vue +12 -23
  173. package/dist/runtime/prose/Thead.vue.d.ts +84 -0
  174. package/dist/runtime/prose/Tr.vue +12 -23
  175. package/dist/runtime/prose/Tr.vue.d.ts +84 -0
  176. package/dist/runtime/prose/Ul.vue +12 -23
  177. package/dist/runtime/prose/Ul.vue.d.ts +84 -0
  178. package/dist/runtime/utils/link.d.ts +3 -3
  179. package/dist/runtime/vue/components/Link.vue +115 -202
  180. package/dist/runtime/vue/components/Link.vue.d.ts +129 -0
  181. package/dist/shared/{b24ui-nuxt.CS9Lf0os.mjs → b24ui-nuxt.BA6Y2FnC.mjs} +6 -6
  182. package/dist/types.d.mts +3 -5
  183. package/dist/unplugin.mjs +1 -1
  184. package/dist/vite.mjs +1 -1
  185. package/package.json +14 -22
  186. package/dist/meta.cjs +0 -72112
  187. package/dist/meta.d.cts +0 -72110
  188. package/dist/meta.d.ts +0 -72110
  189. package/dist/module.cjs +0 -63
  190. package/dist/module.d.cts +0 -15
  191. package/dist/module.d.ts +0 -15
  192. package/dist/shared/b24ui-nuxt.DrKwIWoc.cjs +0 -7721
  193. package/dist/types.d.ts +0 -7
  194. package/dist/unplugin.cjs +0 -236
  195. package/dist/unplugin.d.cts +0 -33
  196. package/dist/unplugin.d.ts +0 -33
  197. package/dist/vite.cjs +0 -21
  198. package/dist/vite.d.cts +0 -14
  199. package/dist/vite.d.ts +0 -14
@@ -1,208 +1,13 @@
1
- <script lang="ts">
2
- import type { VariantProps } from 'tailwind-variants'
3
- import type { ComboboxRootProps, ComboboxRootEmits, ComboboxContentProps, ComboboxContentEmits, ComboboxArrowProps } from 'reka-ui'
4
- import type { AppConfig } from '@nuxt/schema'
5
- import _appConfig from '#build/app.config'
6
- import theme from '#build/b24ui/select-menu'
7
- import type { UseComponentIconsProps } from '../composables/useComponentIcons'
8
- import { tv } from '../utils/tv'
9
- import type { AvatarProps, ChipProps, InputProps, IconComponent } from '../types'
10
- import type {
11
- AcceptableValue,
12
- ArrayOrNested,
13
- GetItemKeys,
14
- GetItemValue,
15
- GetModelValue,
16
- GetModelValueEmits,
17
- NestedItem,
18
- PartialString,
19
- EmitsToProps
20
- } from '../types/utils'
21
-
22
- const appConfigSelectMenu = _appConfig as AppConfig & { b24ui: { selectMenu: Partial<typeof theme> } }
23
-
24
- const selectMenu = tv({ extend: tv(theme), ...(appConfigSelectMenu.b24ui?.selectMenu || {}) })
25
-
26
- interface _SelectMenuItem {
27
- label?: string
28
- /**
29
- * Display an icon on the left side.
30
- * @IconComponent
31
- */
32
- icon?: IconComponent
33
- avatar?: AvatarProps
34
- color?: SelectMenuVariants['color']
35
- chip?: ChipProps
36
- /**
37
- * The item type.
38
- * @defaultValue 'item'
39
- */
40
- type?: 'label' | 'separator' | 'item'
41
- disabled?: boolean
42
- onSelect?(e?: Event): void
43
- [key: string]: any
44
- }
45
- export type SelectMenuItem = _SelectMenuItem | AcceptableValue | boolean
46
-
47
- type SelectMenuVariants = VariantProps<typeof selectMenu>
48
-
49
- export interface SelectMenuProps<T extends ArrayOrNested<SelectMenuItem> = ArrayOrNested<SelectMenuItem>, VK extends GetItemKeys<T> | undefined = undefined, M extends boolean = false> extends Pick<ComboboxRootProps<T>, 'open' | 'defaultOpen' | 'disabled' | 'name' | 'resetSearchTermOnBlur' | 'highlightOnHover'>, UseComponentIconsProps {
50
- id?: string
51
- /** The placeholder text when the select is empty. */
52
- placeholder?: string
53
- /**
54
- * Whether to display the search input or not.
55
- * Can be an object to pass additional props to the input.
56
- * `{ placeholder: 'Search...', type: 'search' }`{lang="ts"}
57
- * @defaultValue true
58
- */
59
- searchInput?: boolean | InputProps
60
- /**
61
- * @defaultValue 'primary'
62
- */
63
- color?: SelectMenuVariants['color']
64
- /**
65
- * @defaultValue 'md'
66
- */
67
- size?: SelectMenuVariants['size']
68
- /**
69
- * Removes padding from input
70
- * @defaultValue false
71
- */
72
- noPadding?: boolean
73
- /**
74
- * Removes all borders (rings)
75
- * @defaultValue false
76
- */
77
- noBorder?: boolean
78
- /**
79
- * Removes all borders (rings) except the bottom one
80
- * @defaultValue false
81
- */
82
- underline?: boolean
83
- /**
84
- * Rounds the corners of the button
85
- * @defaultValue false
86
- */
87
- rounded?: boolean
88
- tag?: string
89
- /**
90
- * @defaultValue 'primary'
91
- */
92
- tagColor?: SelectMenuVariants['tagColor']
93
- /**
94
- * @defaultValue false
95
- */
96
- required?: boolean
97
- /**
98
- * The icon displayed to open the menu.
99
- * @defaultValue icons.chevronDown
100
- * @IconComponent
101
- */
102
- trailingIcon?: IconComponent
103
- /**
104
- * The icon displayed when an item is selected.
105
- * @defaultValue icons.check
106
- * @IconComponent
107
- */
108
- selectedIcon?: IconComponent
109
- /**
110
- * The content of the menu.
111
- * @defaultValue { side: 'bottom', sideOffset: 8, collisionPadding: 8, position: 'popper' }
112
- */
113
- content?: Omit<ComboboxContentProps, 'as' | 'asChild' | 'forceMount'> & Partial<EmitsToProps<ComboboxContentEmits>>
114
- /**
115
- * Display an arrow alongside the menu.
116
- * @defaultValue false
117
- */
118
- arrow?: boolean | Omit<ComboboxArrowProps, 'as' | 'asChild'>
119
- /**
120
- * Render the menu in a portal.
121
- * @defaultValue true
122
- */
123
- portal?: boolean
124
- /**
125
- * When `items` is an array of objects, select the field to use as the value instead of the object itself.
126
- * @defaultValue undefined
127
- */
128
- valueKey?: VK
129
- /**
130
- * When `items` is an array of objects, select the field to use as the label.
131
- * @defaultValue 'label'
132
- */
133
- labelKey?: keyof NestedItem<T>
134
- items?: T
135
- /**
136
- * The value of the SelectMenu when initially rendered. Use when you do not need to control the state of the SelectMenu
137
- */
138
- defaultValue?: GetModelValue<T, VK, M>
139
- /**
140
- * The controlled value of the SelectMenu. Can be binded-with with `v-model`
141
- */
142
- modelValue?: GetModelValue<T, VK, M>
143
- /**
144
- * Whether multiple options can be selected or not
145
- * @defaultValue false
146
- */
147
- multiple?: M & boolean
148
- /**
149
- * Highlight the ring color like a focus state
150
- * @defaultValue false
151
- */
152
- highlight?: boolean
153
- /**
154
- * Determines if custom user input that does not exist in options can be added.
155
- * @defaultValue false
156
- */
157
- createItem?: boolean | 'always' | { position?: 'top' | 'bottom', when?: 'empty' | 'always' }
158
- /**
159
- * Fields to filter items by.
160
- * @defaultValue [labelKey]
161
- */
162
- filterFields?: string[]
163
- /**
164
- * When `true`, disable the default filters, useful for custom filtering (useAsyncData, useFetch, etc.).
165
- * @defaultValue false
166
- */
167
- ignoreFilter?: boolean
168
- class?: any
169
- b24ui?: PartialString<typeof selectMenu.slots>
170
- }
171
-
172
- export type SelectMenuEmits<A extends ArrayOrNested<SelectMenuItem>, VK extends GetItemKeys<A> | undefined, M extends boolean> = Pick<ComboboxRootEmits, 'update:open'> & {
173
- change: [payload: Event]
174
- blur: [payload: FocusEvent]
175
- focus: [payload: FocusEvent]
176
- create: [item: string]
177
- /** Event handler when highlighted element changes. */
178
- highlight: [payload: {
179
- ref: HTMLElement
180
- value: GetModelValue<A, VK, M>
181
- } | undefined]
182
- } & GetModelValueEmits<A, VK, M>
183
-
184
- type SlotProps<T extends SelectMenuItem> = (props: { item: T, index: number }) => any
185
-
186
- export interface SelectMenuSlots<
187
- A extends ArrayOrNested<SelectMenuItem> = ArrayOrNested<SelectMenuItem>,
188
- VK extends GetItemKeys<A> | undefined = undefined,
189
- M extends boolean = false,
190
- T extends NestedItem<A> = NestedItem<A>
191
- > {
192
- 'leading'(props: { modelValue?: GetModelValue<A, VK, M>, open: boolean, b24ui: ReturnType<typeof selectMenu> }): any
193
- 'default'(props: { modelValue?: GetModelValue<A, VK, M>, open: boolean }): any
194
- 'trailing'(props: { modelValue?: GetModelValue<A, VK, M>, open: boolean, b24ui: ReturnType<typeof selectMenu> }): any
195
- 'empty'(props: { searchTerm?: string }): any
196
- 'item': SlotProps<T>
197
- 'item-leading': SlotProps<T>
198
- 'item-label': SlotProps<T>
199
- 'item-trailing': SlotProps<T>
200
- 'create-item-label'(props: { item: string }): any
201
- }
1
+ <script>
2
+ import _appConfig from "#build/app.config";
3
+ import theme from "#build/b24ui/select-menu";
4
+ import { tv } from "../utils/tv";
5
+ const appConfigSelectMenu = _appConfig;
6
+ const selectMenu = tv({ extend: tv(theme), ...appConfigSelectMenu.b24ui?.selectMenu || {} });
202
7
  </script>
203
8
 
204
- <script setup lang="ts" generic="T extends ArrayOrNested<SelectMenuItem>, VK extends GetItemKeys<T> | undefined = undefined, M extends boolean = false">
205
- import { computed, toRef, toRaw } from 'vue'
9
+ <script setup>
10
+ import { computed, toRef, toRaw } from "vue";
206
11
  import {
207
12
  ComboboxRoot,
208
13
  ComboboxArrow,
@@ -222,55 +27,81 @@ import {
222
27
  useForwardPropsEmits,
223
28
  useFilter,
224
29
  Primitive
225
- } from 'reka-ui'
226
- import { defu } from 'defu'
227
- import { reactivePick, createReusableTemplate } from '@vueuse/core'
228
- import { useButtonGroup } from '../composables/useButtonGroup'
229
- import { useComponentIcons } from '../composables/useComponentIcons'
230
- import { useFormField } from '../composables/useFormField'
231
- import { useLocale } from '../composables/useLocale'
232
- import { compare, get, isArrayOfArray } from '../utils'
233
- import icons from '../dictionary/icons'
234
- import B24Avatar from './Avatar.vue'
235
- import B24Chip from './Chip.vue'
236
- import B24Input from './Input.vue'
237
-
238
- defineOptions({ inheritAttrs: false })
239
-
240
- const props = withDefaults(defineProps<SelectMenuProps<T, VK, M>>(), {
241
- portal: true,
242
- searchInput: true,
243
- labelKey: 'label' as never,
244
- resetSearchTermOnBlur: true
245
- })
246
- const emits = defineEmits<SelectMenuEmits<T, VK, M>>()
247
- const slots = defineSlots<SelectMenuSlots<T, VK, M>>()
248
-
249
- const searchTerm = defineModel<string>('searchTerm', { default: '' })
250
-
251
- const { t } = useLocale()
252
- const { contains } = useFilter({ sensitivity: 'base' })
253
-
254
- const rootProps = useForwardPropsEmits(reactivePick(props, 'modelValue', 'defaultValue', 'open', 'defaultOpen', 'required', 'multiple', 'resetSearchTermOnBlur', 'highlightOnHover'), emits)
255
- const contentProps = toRef(() => defu(props.content, { side: 'bottom', sideOffset: 8, collisionPadding: 8, position: 'popper' }) as ComboboxContentProps)
256
- const arrowProps = toRef(() => props.arrow as ComboboxArrowProps)
257
- const searchInputProps = toRef(() => defu(props.searchInput, { placeholder: t('selectMenu.search'), type: 'search' }) as InputProps)
258
-
259
- const { emitFormBlur, emitFormFocus, emitFormInput, emitFormChange, size: formGroupSize, color, id, name, highlight, disabled, ariaAttrs } = useFormField<InputProps>(props)
260
- const { orientation, size: buttonGroupSize } = useButtonGroup<InputProps>(props)
30
+ } from "reka-ui";
31
+ import { defu } from "defu";
32
+ import { reactivePick, createReusableTemplate } from "@vueuse/core";
33
+ import { useButtonGroup } from "../composables/useButtonGroup";
34
+ import { useComponentIcons } from "../composables/useComponentIcons";
35
+ import { useFormField } from "../composables/useFormField";
36
+ import { useLocale } from "../composables/useLocale";
37
+ import { compare, get, isArrayOfArray } from "../utils";
38
+ import icons from "../dictionary/icons";
39
+ import B24Avatar from "./Avatar.vue";
40
+ import B24Chip from "./Chip.vue";
41
+ import B24Input from "./Input.vue";
42
+ defineOptions({ inheritAttrs: false });
43
+ const props = defineProps({
44
+ id: { type: String, required: false },
45
+ placeholder: { type: String, required: false },
46
+ searchInput: { type: [Boolean, Object], required: false, default: true },
47
+ color: { type: null, required: false },
48
+ size: { type: null, required: false },
49
+ noPadding: { type: Boolean, required: false },
50
+ noBorder: { type: Boolean, required: false },
51
+ underline: { type: Boolean, required: false },
52
+ rounded: { type: Boolean, required: false },
53
+ tag: { type: String, required: false },
54
+ tagColor: { type: null, required: false },
55
+ required: { type: Boolean, required: false },
56
+ trailingIcon: { type: [Function, Object], required: false },
57
+ selectedIcon: { type: [Function, Object], required: false },
58
+ content: { type: Object, required: false },
59
+ arrow: { type: [Boolean, Object], required: false },
60
+ portal: { type: Boolean, required: false, default: true },
61
+ valueKey: { type: null, required: false },
62
+ labelKey: { type: null, required: false, default: "label" },
63
+ items: { type: null, required: false },
64
+ defaultValue: { type: null, required: false },
65
+ modelValue: { type: null, required: false },
66
+ multiple: { type: Boolean, required: false },
67
+ highlight: { type: Boolean, required: false },
68
+ createItem: { type: [Boolean, String, Object], required: false },
69
+ filterFields: { type: Array, required: false },
70
+ ignoreFilter: { type: Boolean, required: false },
71
+ class: { type: null, required: false },
72
+ b24ui: { type: null, required: false },
73
+ open: { type: Boolean, required: false },
74
+ defaultOpen: { type: Boolean, required: false },
75
+ disabled: { type: Boolean, required: false },
76
+ name: { type: String, required: false },
77
+ resetSearchTermOnBlur: { type: Boolean, required: false, default: true },
78
+ resetSearchTermOnSelect: { type: Boolean, required: false, default: true },
79
+ highlightOnHover: { type: Boolean, required: false },
80
+ icon: { type: [Function, Object], required: false },
81
+ avatar: { type: Object, required: false },
82
+ loading: { type: Boolean, required: false },
83
+ trailing: { type: Boolean, required: false }
84
+ });
85
+ const emits = defineEmits(["update:open", "change", "blur", "focus", "create", "highlight", "update:modelValue"]);
86
+ const slots = defineSlots();
87
+ const searchTerm = defineModel("searchTerm", { type: String, ...{ default: "" } });
88
+ const { t } = useLocale();
89
+ const { contains } = useFilter({ sensitivity: "base" });
90
+ const rootProps = useForwardPropsEmits(reactivePick(props, "modelValue", "defaultValue", "open", "defaultOpen", "required", "multiple", "resetSearchTermOnBlur", "resetSearchTermOnSelect", "highlightOnHover"), emits);
91
+ const contentProps = toRef(() => defu(props.content, { side: "bottom", sideOffset: 8, collisionPadding: 8, position: "popper" }));
92
+ const arrowProps = toRef(() => props.arrow);
93
+ const searchInputProps = toRef(() => defu(props.searchInput, { placeholder: t("selectMenu.search"), type: "search" }));
94
+ const { emitFormBlur, emitFormFocus, emitFormInput, emitFormChange, size: formGroupSize, color, id, name, highlight, disabled, ariaAttrs } = useFormField(props);
95
+ const { orientation, size: buttonGroupSize } = useButtonGroup(props);
261
96
  const { isLeading, isTrailing, leadingIconName, trailingIconName } = useComponentIcons(toRef(() => defu(
262
97
  props,
263
98
  { trailingIcon: icons.chevronDown }
264
- )))
265
-
266
- const selectSize = computed(() => buttonGroupSize.value || formGroupSize.value)
267
-
268
- const [DefineCreateItemTemplate, ReuseCreateItemTemplate] = createReusableTemplate()
269
-
99
+ )));
100
+ const selectSize = computed(() => buttonGroupSize.value || formGroupSize.value);
101
+ const [DefineCreateItemTemplate, ReuseCreateItemTemplate] = createReusableTemplate();
270
102
  const isTag = computed(() => {
271
- return props.tag
272
- })
273
-
103
+ return props.tag;
104
+ });
274
105
  const b24ui = computed(() => selectMenu({
275
106
  color: color.value,
276
107
  size: selectSize?.value,
@@ -284,115 +115,98 @@ const b24ui = computed(() => selectMenu({
284
115
  leading: Boolean(isLeading.value || !!props.avatar || !!slots.leading),
285
116
  trailing: Boolean(isTrailing.value || !!slots.trailing),
286
117
  buttonGroup: orientation.value
287
- }))
288
-
289
- function displayValue(value: GetItemValue<T, VK> | GetItemValue<T, VK>[]): string {
118
+ }));
119
+ function displayValue(value) {
290
120
  if (props.multiple && Array.isArray(value)) {
291
- return value.map(v => displayValue(v)).filter(Boolean).join(', ')
121
+ return value.map((v) => displayValue(v)).filter(Boolean).join(", ");
292
122
  }
293
-
294
123
  if (!props.valueKey) {
295
- return value && (typeof value === 'object' ? get(value, props.labelKey as string) : value)
124
+ return value && (typeof value === "object" ? get(value, props.labelKey) : value);
296
125
  }
297
-
298
- const item = items.value.find(item => compare(typeof item === 'object' ? get(item as Record<string, any>, props.valueKey as string) : item, value))
299
- return item && (typeof item === 'object' ? get(item, props.labelKey as string) : item)
126
+ const item = items.value.find((item2) => compare(typeof item2 === "object" ? get(item2, props.valueKey) : item2, value));
127
+ return item && (typeof item === "object" ? get(item, props.labelKey) : item);
300
128
  }
301
-
302
- const groups = computed<SelectMenuItem[][]>(() =>
303
- props.items?.length
304
- ? isArrayOfArray(props.items)
305
- ? props.items
306
- : [props.items]
307
- : []
308
- )
309
- // eslint-disable-next-line vue/no-dupe-keys
310
- const items = computed(() => groups.value.flatMap(group => group) as T[])
311
-
129
+ const groups = computed(
130
+ () => props.items?.length ? isArrayOfArray(props.items) ? props.items : [props.items] : []
131
+ );
132
+ const items = computed(() => groups.value.flatMap((group) => group));
312
133
  const filteredGroups = computed(() => {
313
134
  if (props.ignoreFilter || !searchTerm.value) {
314
- return groups.value
135
+ return groups.value;
315
136
  }
316
-
317
- const fields = Array.isArray(props.filterFields) ? props.filterFields : [props.labelKey] as string[]
318
-
319
- return groups.value.map(items => items.filter((item) => {
320
- if (typeof item !== 'object' || item === null) {
321
- return contains(String(item), searchTerm.value)
137
+ const fields = Array.isArray(props.filterFields) ? props.filterFields : [props.labelKey];
138
+ return groups.value.map((items2) => items2.filter((item) => {
139
+ if (typeof item !== "object" || item === null) {
140
+ return contains(String(item), searchTerm.value);
322
141
  }
323
-
324
- if (item.type && ['label', 'separator'].includes(item.type)) {
325
- return true
142
+ if (item.type && ["label", "separator"].includes(item.type)) {
143
+ return true;
326
144
  }
327
-
328
- return fields.some(field => contains(get(item, field), searchTerm.value))
329
- })).filter(group => group.filter(item =>
330
- !isSelectItem(item) || (isSelectItem(item) && (!item.type || !['label', 'separator'].includes(item.type)))
331
- ).length > 0)
332
- })
333
- const filteredItems = computed(() => filteredGroups.value.flatMap(group => group))
334
-
145
+ return fields.some((field) => contains(get(item, field), searchTerm.value));
146
+ })).filter((group) => group.filter(
147
+ (item) => !isSelectItem(item) || isSelectItem(item) && (!item.type || !["label", "separator"].includes(item.type))
148
+ ).length > 0);
149
+ });
150
+ const filteredItems = computed(() => filteredGroups.value.flatMap((group) => group));
335
151
  const createItem = computed(() => {
336
152
  if (!props.createItem || !searchTerm.value) {
337
- return false
153
+ return false;
338
154
  }
339
-
340
- const newItem = props.valueKey ? { [props.valueKey]: searchTerm.value } as NestedItem<T> : searchTerm.value
341
-
342
- if ((typeof props.createItem === 'object' && props.createItem.when === 'always') || props.createItem === 'always') {
343
- return !filteredItems.value.find(item => compare(item, newItem, String(props.valueKey)))
155
+ const newItem = props.valueKey ? { [props.valueKey]: searchTerm.value } : searchTerm.value;
156
+ if (typeof props.createItem === "object" && props.createItem.when === "always" || props.createItem === "always") {
157
+ return !filteredItems.value.find((item) => compare(item, newItem, String(props.valueKey)));
344
158
  }
345
-
346
- return !filteredItems.value.length
347
- })
348
- const createItemPosition = computed(() => typeof props.createItem === 'object' ? props.createItem.position : 'bottom')
349
-
350
- function onUpdate(value: any) {
159
+ return !filteredItems.value.length;
160
+ });
161
+ const createItemPosition = computed(() => typeof props.createItem === "object" ? props.createItem.position : "bottom");
162
+ function onUpdate(value) {
351
163
  if (toRaw(props.modelValue) === value) {
352
- return
164
+ return;
165
+ }
166
+ const event = new Event("change", { target: { value } });
167
+ emits("change", event);
168
+ emitFormChange();
169
+ emitFormInput();
170
+ if (props.resetSearchTermOnSelect) {
171
+ searchTerm.value = "";
353
172
  }
354
- // @ts-expect-error - 'target' does not exist in type 'EventInit'
355
- const event = new Event('change', { target: { value } })
356
- emits('change', event)
357
-
358
- emitFormChange()
359
- emitFormInput()
360
173
  }
361
-
362
- function onUpdateOpen(value: boolean) {
363
- let timeoutId: ReturnType<typeof setTimeout> | undefined
364
-
174
+ function onUpdateOpen(value) {
175
+ let timeoutId;
365
176
  if (!value) {
366
- const event = new FocusEvent('blur')
367
-
368
- emits('blur', event)
369
- emitFormBlur()
370
-
371
- // Since we use `displayValue` prop inside ComboboxInput we should reset searchTerm manually
372
- // https://reka-ui.com/docs/components/combobox#api-reference
177
+ const event = new FocusEvent("blur");
178
+ emits("blur", event);
179
+ emitFormBlur();
373
180
  if (props.resetSearchTermOnBlur) {
374
- const STATE_ANIMATION_DELAY_MS = 100
375
-
181
+ const STATE_ANIMATION_DELAY_MS = 100;
376
182
  timeoutId = setTimeout(() => {
377
- searchTerm.value = ''
378
- }, STATE_ANIMATION_DELAY_MS)
183
+ searchTerm.value = "";
184
+ }, STATE_ANIMATION_DELAY_MS);
379
185
  }
380
186
  } else {
381
- const event = new FocusEvent('focus')
382
- emits('focus', event)
383
- emitFormFocus()
187
+ const event = new FocusEvent("focus");
188
+ emits("focus", event);
189
+ emitFormFocus();
384
190
  if (timeoutId) {
385
- clearTimeout(timeoutId)
191
+ clearTimeout(timeoutId);
386
192
  }
387
193
  }
388
194
  }
389
-
390
- function isSelectItem(item: SelectMenuItem): item is _SelectMenuItem {
391
- return typeof item === 'object' && item !== null
195
+ function onSelect(e, item) {
196
+ if (!isSelectItem(item)) {
197
+ return;
198
+ }
199
+ if (item.disabled) {
200
+ e.preventDefault();
201
+ return;
202
+ }
203
+ item.onSelect?.(e);
204
+ }
205
+ function isSelectItem(item) {
206
+ return typeof item === "object" && item !== null;
392
207
  }
393
208
  </script>
394
209
 
395
- <!-- eslint-disable vue/no-template-shadow -->
396
210
  <template>
397
211
  <Primitive as="div" :class="b24ui.root({ addNew: true, class: [props.b24ui?.root] })">
398
212
  <DefineCreateItemTemplate>
@@ -432,29 +246,29 @@ function isSelectItem(item: SelectMenuItem): item is _SelectMenuItem {
432
246
  {{ props.tag }}
433
247
  </div>
434
248
  <span v-if="isLeading || !!avatar || !!slots.leading" :class="b24ui.leading({ class: props.b24ui?.leading })">
435
- <slot name="leading" :model-value="(modelValue as GetModelValue<T, VK, M>)" :open="open" :b24ui="b24ui">
249
+ <slot name="leading" :model-value="modelValue" :open="open" :b24ui="b24ui">
436
250
  <Component
437
251
  :is="leadingIconName"
438
252
  v-if="isLeading && leadingIconName"
439
253
  :class="b24ui.leadingIcon({ class: props.b24ui?.leadingIcon })"
440
254
  />
441
- <B24Avatar v-else-if="!!avatar" :size="((props.b24ui?.itemLeadingAvatarSize || b24ui.itemLeadingAvatarSize()) as AvatarProps['size'])" v-bind="avatar" :class="b24ui.itemLeadingAvatar({ class: props.b24ui?.itemLeadingAvatar })" />
255
+ <B24Avatar v-else-if="!!avatar" :size="props.b24ui?.itemLeadingAvatarSize || b24ui.itemLeadingAvatarSize()" v-bind="avatar" :class="b24ui.itemLeadingAvatar({ class: props.b24ui?.itemLeadingAvatar })" />
442
256
  </slot>
443
257
  </span>
444
258
 
445
- <slot :model-value="(modelValue as GetModelValue<T, VK, M>)" :open="open">
446
- <template v-for="displayedModelValue in [displayValue(modelValue as GetModelValue<T, VK, M>)]" :key="displayedModelValue">
259
+ <slot :model-value="modelValue" :open="open">
260
+ <template v-for="displayedModelValue in [displayValue(modelValue)]" :key="displayedModelValue">
447
261
  <span v-if="displayedModelValue" :class="b24ui.value({ class: props.b24ui?.value })">
448
262
  {{ displayedModelValue }}
449
263
  </span>
450
264
  <span v-else :class="b24ui.placeholder({ class: props.b24ui?.placeholder })">
451
- {{ placeholder ?? '&nbsp;' }}
265
+ {{ placeholder ?? '\xA0' }}
452
266
  </span>
453
267
  </template>
454
268
  </slot>
455
269
 
456
270
  <span v-if="isTrailing || !!slots.trailing" :class="b24ui.trailing({ class: props.b24ui?.trailing })">
457
- <slot name="trailing" :model-value="(modelValue as GetModelValue<T, VK, M>)" :open="open" :b24ui="b24ui">
271
+ <slot name="trailing" :model-value="modelValue" :open="open" :b24ui="b24ui">
458
272
  <Component
459
273
  :is="trailingIconName"
460
274
  v-if="trailingIconName"
@@ -484,29 +298,29 @@ function isSelectItem(item: SelectMenuItem): item is _SelectMenuItem {
484
298
  <ComboboxGroup v-for="(group, groupIndex) in filteredGroups" :key="`group-${groupIndex}`" :class="b24ui.group({ class: props.b24ui?.group })">
485
299
  <template v-for="(item, index) in group" :key="`group-${groupIndex}-${index}`">
486
300
  <ComboboxLabel v-if="isSelectItem(item) && item.type === 'label'" :class="b24ui.label({ class: props.b24ui?.label })">
487
- {{ get(item, props.labelKey as string) }}
301
+ {{ get(item, props.labelKey) }}
488
302
  </ComboboxLabel>
489
303
 
490
304
  <ComboboxSeparator v-else-if="isSelectItem(item) && item.type === 'separator'" :class="b24ui.separator({ class: props.b24ui?.separator })" />
491
305
 
492
306
  <ComboboxItem
493
307
  v-else
494
- :class="b24ui.item({ class: props.b24ui?.item, colorItem: isSelectItem(item) ? item?.color : undefined })"
308
+ :class="b24ui.item({ class: props.b24ui?.item, colorItem: isSelectItem(item) ? item?.color : void 0 })"
495
309
  :disabled="isSelectItem(item) && item.disabled"
496
- :value="props.valueKey && isSelectItem(item) ? get(item, props.valueKey as string) : item"
497
- @select="isSelectItem(item) && item.onSelect?.($event)"
310
+ :value="props.valueKey && isSelectItem(item) ? get(item, props.valueKey) : item"
311
+ @select="onSelect($event, item)"
498
312
  >
499
- <slot name="item" :item="(item as NestedItem<T>)" :index="index">
500
- <slot name="item-leading" :item="(item as NestedItem<T>)" :index="index">
313
+ <slot name="item" :item="item" :index="index">
314
+ <slot name="item-leading" :item="item" :index="index">
501
315
  <Component
502
316
  :is="item.icon"
503
317
  v-if="isSelectItem(item) && item.icon"
504
318
  :class="b24ui.itemLeadingIcon({ class: props.b24ui?.itemLeadingIcon, colorItem: item?.color })"
505
319
  />
506
- <B24Avatar v-else-if="isSelectItem(item) && item.avatar" :size="((props.b24ui?.itemLeadingAvatarSize || b24ui.itemLeadingAvatarSize()) as AvatarProps['size'])" v-bind="item.avatar" :class="b24ui.itemLeadingAvatar({ class: props.b24ui?.itemLeadingAvatar, colorItem: item?.color })" />
320
+ <B24Avatar v-else-if="isSelectItem(item) && item.avatar" :size="props.b24ui?.itemLeadingAvatarSize || b24ui.itemLeadingAvatarSize()" v-bind="item.avatar" :class="b24ui.itemLeadingAvatar({ class: props.b24ui?.itemLeadingAvatar, colorItem: item?.color })" />
507
321
  <B24Chip
508
322
  v-else-if="isSelectItem(item) && item.chip"
509
- :size="((props.b24ui?.itemLeadingChipSize || b24ui.itemLeadingChipSize()) as ChipProps['size'])"
323
+ :size="props.b24ui?.itemLeadingChipSize || b24ui.itemLeadingChipSize()"
510
324
  inset
511
325
  standalone
512
326
  v-bind="item.chip"
@@ -515,18 +329,18 @@ function isSelectItem(item: SelectMenuItem): item is _SelectMenuItem {
515
329
  </slot>
516
330
 
517
331
  <span :class="b24ui.itemLabel({ class: props.b24ui?.itemLabel })">
518
- <slot name="item-label" :item="(item as NestedItem<T>)" :index="index">
519
- {{ isSelectItem(item) ? get(item, props.labelKey as string) : item }}
332
+ <slot name="item-label" :item="item" :index="index">
333
+ {{ isSelectItem(item) ? get(item, props.labelKey) : item }}
520
334
  </slot>
521
335
  </span>
522
336
 
523
- <span :class="b24ui.itemTrailing({ class: props.b24ui?.itemTrailing, colorItem: isSelectItem(item) ? item?.color : undefined })">
524
- <slot name="item-trailing" :item="(item as NestedItem<T>)" :index="index" />
337
+ <span :class="b24ui.itemTrailing({ class: props.b24ui?.itemTrailing, colorItem: isSelectItem(item) ? item?.color : void 0 })">
338
+ <slot name="item-trailing" :item="item" :index="index" />
525
339
 
526
340
  <ComboboxItemIndicator as-child>
527
341
  <Component
528
342
  :is="selectedIcon || icons.check"
529
- :class="b24ui.itemTrailingIcon({ class: props.b24ui?.itemTrailingIcon, colorItem: isSelectItem(item) ? item?.color : undefined })"
343
+ :class="b24ui.itemTrailingIcon({ class: props.b24ui?.itemTrailingIcon, colorItem: isSelectItem(item) ? item?.color : void 0 })"
530
344
  />
531
345
  </ComboboxItemIndicator>
532
346
  </span>