@bitrix24/b24ui-nuxt 0.5.11 → 0.6.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 (252) hide show
  1. package/.nuxt/b24ui/advice.ts +10 -2
  2. package/.nuxt/b24ui/alert.ts +10 -2
  3. package/.nuxt/b24ui/avatar-group.ts +10 -2
  4. package/.nuxt/b24ui/avatar.ts +10 -2
  5. package/.nuxt/b24ui/badge.ts +10 -2
  6. package/.nuxt/b24ui/button-group.ts +10 -2
  7. package/.nuxt/b24ui/button.ts +16 -6
  8. package/.nuxt/b24ui/calendar.ts +10 -2
  9. package/.nuxt/b24ui/checkbox.ts +10 -2
  10. package/.nuxt/b24ui/chip.ts +10 -2
  11. package/.nuxt/b24ui/collapsible.ts +10 -2
  12. package/.nuxt/b24ui/container.ts +10 -2
  13. package/.nuxt/b24ui/countdown.ts +10 -2
  14. package/.nuxt/b24ui/description-list.ts +10 -2
  15. package/.nuxt/b24ui/dropdown-menu.ts +10 -2
  16. package/.nuxt/b24ui/form-field.ts +10 -2
  17. package/.nuxt/b24ui/form.ts +10 -2
  18. package/.nuxt/b24ui/input-menu.ts +12 -4
  19. package/.nuxt/b24ui/input-number.ts +10 -2
  20. package/.nuxt/b24ui/input.ts +10 -2
  21. package/.nuxt/b24ui/kbd.ts +10 -2
  22. package/.nuxt/b24ui/link.ts +10 -2
  23. package/.nuxt/b24ui/modal.ts +10 -2
  24. package/.nuxt/b24ui/navbar-divider.ts +10 -2
  25. package/.nuxt/b24ui/navbar-section.ts +10 -2
  26. package/.nuxt/b24ui/navbar-spacer.ts +10 -2
  27. package/.nuxt/b24ui/navbar.ts +10 -2
  28. package/.nuxt/b24ui/navigation-menu.ts +10 -2
  29. package/.nuxt/b24ui/popover.ts +10 -2
  30. package/.nuxt/b24ui/progress.ts +10 -2
  31. package/.nuxt/b24ui/radio-group.ts +10 -2
  32. package/.nuxt/b24ui/range.ts +10 -2
  33. package/.nuxt/b24ui/select-menu.ts +14 -6
  34. package/.nuxt/b24ui/select.ts +12 -4
  35. package/.nuxt/b24ui/separator.ts +10 -2
  36. package/.nuxt/b24ui/sidebar-body.ts +10 -2
  37. package/.nuxt/b24ui/sidebar-footer.ts +10 -2
  38. package/.nuxt/b24ui/sidebar-header.ts +10 -2
  39. package/.nuxt/b24ui/sidebar-heading.ts +10 -2
  40. package/.nuxt/b24ui/sidebar-layout.ts +10 -2
  41. package/.nuxt/b24ui/sidebar-section.ts +10 -2
  42. package/.nuxt/b24ui/sidebar-spacer.ts +10 -2
  43. package/.nuxt/b24ui/sidebar.ts +10 -2
  44. package/.nuxt/b24ui/skeleton.ts +10 -2
  45. package/.nuxt/b24ui/slideover.ts +10 -2
  46. package/.nuxt/b24ui/stacked-layout.ts +10 -2
  47. package/.nuxt/b24ui/switch.ts +10 -2
  48. package/.nuxt/b24ui/tabs.ts +10 -2
  49. package/.nuxt/b24ui/textarea.ts +10 -2
  50. package/.nuxt/b24ui/toast.ts +10 -2
  51. package/.nuxt/b24ui/toaster.ts +10 -2
  52. package/.nuxt/b24ui/tooltip.ts +10 -2
  53. package/cli/templates.mjs +19 -15
  54. package/dist/meta.d.mts +5675 -7513
  55. package/dist/meta.mjs +5675 -7513
  56. package/dist/module.json +3 -3
  57. package/dist/module.mjs +2 -2
  58. package/dist/runtime/components/Advice.vue +27 -55
  59. package/dist/runtime/components/Advice.vue.d.ts +56 -0
  60. package/dist/runtime/components/Alert.vue +35 -97
  61. package/dist/runtime/components/Alert.vue.d.ts +97 -0
  62. package/dist/runtime/components/App.vue +24 -34
  63. package/dist/runtime/components/App.vue.d.ts +23 -0
  64. package/dist/runtime/components/Avatar.vue +43 -82
  65. package/dist/runtime/components/Avatar.vue.d.ts +62 -0
  66. package/dist/runtime/components/AvatarGroup.vue +40 -77
  67. package/dist/runtime/components/AvatarGroup.vue.d.ts +40 -0
  68. package/dist/runtime/components/Badge.vue +40 -84
  69. package/dist/runtime/components/Badge.vue.d.ts +78 -0
  70. package/dist/runtime/components/Button.vue +107 -164
  71. package/dist/runtime/components/Button.vue.d.ts +115 -0
  72. package/dist/runtime/components/ButtonGroup.vue +25 -52
  73. package/dist/runtime/components/ButtonGroup.vue.d.ts +63 -0
  74. package/dist/runtime/components/Calendar.vue +73 -153
  75. package/dist/runtime/components/Calendar.vue.d.ts +107 -0
  76. package/dist/runtime/components/Checkbox.vue +42 -74
  77. package/dist/runtime/components/Checkbox.vue.d.ts +55 -0
  78. package/dist/runtime/components/Chip.vue +26 -75
  79. package/dist/runtime/components/Chip.vue.d.ts +77 -0
  80. package/dist/runtime/components/Collapsible.vue +22 -41
  81. package/dist/runtime/components/Collapsible.vue.d.ts +50 -0
  82. package/dist/runtime/components/Container.vue +15 -28
  83. package/dist/runtime/components/Container.vue.d.ts +27 -0
  84. package/dist/runtime/components/Countdown.vue +153 -379
  85. package/dist/runtime/components/Countdown.vue.d.ts +122 -0
  86. package/dist/runtime/components/DescriptionList.vue +78 -150
  87. package/dist/runtime/components/DescriptionList.vue.d.ts +109 -0
  88. package/dist/runtime/components/DropdownMenu.vue +38 -140
  89. package/dist/runtime/components/DropdownMenu.vue.d.ts +133 -0
  90. package/dist/runtime/components/DropdownMenuContent.vue +65 -79
  91. package/dist/runtime/components/DropdownMenuContent.vue.d.ts +51 -0
  92. package/dist/runtime/components/Form.vue +132 -218
  93. package/dist/runtime/components/Form.vue.d.ts +55 -0
  94. package/dist/runtime/components/FormField.vue +36 -81
  95. package/dist/runtime/components/FormField.vue.d.ts +73 -0
  96. package/dist/runtime/components/Input.vue +79 -180
  97. package/dist/runtime/components/Input.vue.d.ts +135 -0
  98. package/dist/runtime/components/InputMenu.vue +185 -382
  99. package/dist/runtime/components/InputMenu.vue.d.ts +357 -0
  100. package/dist/runtime/components/InputNumber.vue +77 -176
  101. package/dist/runtime/components/InputNumber.vue.d.ts +238 -0
  102. package/dist/runtime/components/Kbd.vue +20 -46
  103. package/dist/runtime/components/Kbd.vue.d.ts +55 -0
  104. package/dist/runtime/components/Link.vue +99 -179
  105. package/dist/runtime/components/Link.vue.d.ts +129 -0
  106. package/dist/runtime/components/LinkBase.vue +33 -42
  107. package/dist/runtime/components/LinkBase.vue.d.ts +48 -0
  108. package/dist/runtime/components/Modal.vue +48 -128
  109. package/dist/runtime/components/Modal.vue.d.ts +124 -0
  110. package/dist/runtime/components/ModalDialogClose.vue +5 -8
  111. package/dist/runtime/components/ModalDialogClose.vue.d.ts +10 -0
  112. package/dist/runtime/components/Navbar.vue +15 -33
  113. package/dist/runtime/components/Navbar.vue.d.ts +46 -0
  114. package/dist/runtime/components/NavbarDivider.vue +15 -33
  115. package/dist/runtime/components/NavbarDivider.vue.d.ts +46 -0
  116. package/dist/runtime/components/NavbarSection.vue +15 -33
  117. package/dist/runtime/components/NavbarSection.vue.d.ts +46 -0
  118. package/dist/runtime/components/NavbarSpacer.vue +15 -33
  119. package/dist/runtime/components/NavbarSpacer.vue.d.ts +46 -0
  120. package/dist/runtime/components/NavigationMenu.vue +74 -209
  121. package/dist/runtime/components/NavigationMenu.vue.d.ts +159 -0
  122. package/dist/runtime/components/OverlayProvider.vue +14 -18
  123. package/dist/runtime/components/OverlayProvider.vue.d.ts +2 -0
  124. package/dist/runtime/components/Popover.vue +40 -82
  125. package/dist/runtime/components/Popover.vue.d.ts +79 -0
  126. package/dist/runtime/components/Progress.vue +70 -137
  127. package/dist/runtime/components/Progress.vue.d.ts +103 -0
  128. package/dist/runtime/components/RadioGroup.vue +59 -135
  129. package/dist/runtime/components/RadioGroup.vue.d.ts +88 -0
  130. package/dist/runtime/components/Range.vue +46 -86
  131. package/dist/runtime/components/Range.vue.d.ts +73 -0
  132. package/dist/runtime/components/Select.vue +110 -261
  133. package/dist/runtime/components/Select.vue.d.ts +170 -0
  134. package/dist/runtime/components/SelectMenu.vue +161 -348
  135. package/dist/runtime/components/SelectMenu.vue.d.ts +217 -0
  136. package/dist/runtime/components/Separator.vue +28 -72
  137. package/dist/runtime/components/Separator.vue.d.ts +77 -0
  138. package/dist/runtime/components/Sidebar.vue +15 -33
  139. package/dist/runtime/components/Sidebar.vue.d.ts +46 -0
  140. package/dist/runtime/components/SidebarBody.vue +17 -39
  141. package/dist/runtime/components/SidebarBody.vue.d.ts +53 -0
  142. package/dist/runtime/components/SidebarFooter.vue +15 -33
  143. package/dist/runtime/components/SidebarFooter.vue.d.ts +46 -0
  144. package/dist/runtime/components/SidebarHeader.vue +15 -33
  145. package/dist/runtime/components/SidebarHeader.vue.d.ts +46 -0
  146. package/dist/runtime/components/SidebarHeading.vue +15 -33
  147. package/dist/runtime/components/SidebarHeading.vue.d.ts +46 -0
  148. package/dist/runtime/components/SidebarLayout.vue +34 -71
  149. package/dist/runtime/components/SidebarLayout.vue.d.ts +65 -0
  150. package/dist/runtime/components/SidebarSection.vue +15 -33
  151. package/dist/runtime/components/SidebarSection.vue.d.ts +46 -0
  152. package/dist/runtime/components/SidebarSpacer.vue +15 -33
  153. package/dist/runtime/components/SidebarSpacer.vue.d.ts +46 -0
  154. package/dist/runtime/components/Skeleton.vue +14 -23
  155. package/dist/runtime/components/Skeleton.vue.d.ts +26 -0
  156. package/dist/runtime/components/Slideover.vue +50 -132
  157. package/dist/runtime/components/Slideover.vue.d.ts +127 -0
  158. package/dist/runtime/components/StackedLayout.vue +34 -74
  159. package/dist/runtime/components/StackedLayout.vue.d.ts +65 -0
  160. package/dist/runtime/components/Switch.vue +46 -96
  161. package/dist/runtime/components/Switch.vue.d.ts +77 -0
  162. package/dist/runtime/components/Tabs.vue +41 -106
  163. package/dist/runtime/components/Tabs.vue.d.ts +104 -0
  164. package/dist/runtime/components/Textarea.vue +92 -202
  165. package/dist/runtime/components/Textarea.vue.d.ts +141 -0
  166. package/dist/runtime/components/Toast.vue +47 -106
  167. package/dist/runtime/components/Toast.vue.d.ts +95 -0
  168. package/dist/runtime/components/Toaster.vue +70 -116
  169. package/dist/runtime/components/Toaster.vue.d.ts +70 -0
  170. package/dist/runtime/components/Tooltip.vue +36 -65
  171. package/dist/runtime/components/Tooltip.vue.d.ts +65 -0
  172. package/dist/runtime/components/content/TableWrapper.vue +24 -71
  173. package/dist/runtime/components/content/TableWrapper.vue.d.ts +83 -0
  174. package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
  175. package/dist/runtime/composables/useButtonGroup.d.ts +2 -2
  176. package/dist/runtime/composables/useComponentIcons.d.ts +3 -3
  177. package/dist/runtime/composables/useFormField.d.ts +2 -2
  178. package/dist/runtime/composables/useOverlay.d.ts +14 -7
  179. package/dist/runtime/composables/useOverlay.js +14 -6
  180. package/dist/runtime/prose/A.vue +16 -26
  181. package/dist/runtime/prose/A.vue.d.ts +27 -0
  182. package/dist/runtime/prose/Blockquote.vue +14 -26
  183. package/dist/runtime/prose/Blockquote.vue.d.ts +27 -0
  184. package/dist/runtime/prose/Code.vue +15 -32
  185. package/dist/runtime/prose/Code.vue.d.ts +31 -0
  186. package/dist/runtime/prose/Em.vue +16 -26
  187. package/dist/runtime/prose/Em.vue.d.ts +27 -0
  188. package/dist/runtime/prose/H1.vue +14 -26
  189. package/dist/runtime/prose/H1.vue.d.ts +27 -0
  190. package/dist/runtime/prose/H2.vue +14 -26
  191. package/dist/runtime/prose/H2.vue.d.ts +27 -0
  192. package/dist/runtime/prose/H3.vue +14 -26
  193. package/dist/runtime/prose/H3.vue.d.ts +27 -0
  194. package/dist/runtime/prose/H4.vue +14 -26
  195. package/dist/runtime/prose/H4.vue.d.ts +27 -0
  196. package/dist/runtime/prose/H5.vue +14 -26
  197. package/dist/runtime/prose/H5.vue.d.ts +27 -0
  198. package/dist/runtime/prose/H6.vue +14 -26
  199. package/dist/runtime/prose/H6.vue.d.ts +27 -0
  200. package/dist/runtime/prose/Hr.vue +13 -22
  201. package/dist/runtime/prose/Hr.vue.d.ts +19 -0
  202. package/dist/runtime/prose/Img.vue +13 -26
  203. package/dist/runtime/prose/Img.vue.d.ts +19 -0
  204. package/dist/runtime/prose/Li.vue +14 -26
  205. package/dist/runtime/prose/Li.vue.d.ts +27 -0
  206. package/dist/runtime/prose/Ol.vue +14 -26
  207. package/dist/runtime/prose/Ol.vue.d.ts +27 -0
  208. package/dist/runtime/prose/P.vue +14 -26
  209. package/dist/runtime/prose/P.vue.d.ts +27 -0
  210. package/dist/runtime/prose/Pre.vue +17 -33
  211. package/dist/runtime/prose/Pre.vue.d.ts +47 -0
  212. package/dist/runtime/prose/Strong.vue +14 -26
  213. package/dist/runtime/prose/Strong.vue.d.ts +27 -0
  214. package/dist/runtime/prose/Table.vue +21 -57
  215. package/dist/runtime/prose/Table.vue.d.ts +74 -0
  216. package/dist/runtime/prose/Tbody.vue +14 -26
  217. package/dist/runtime/prose/Tbody.vue.d.ts +27 -0
  218. package/dist/runtime/prose/Td.vue +14 -26
  219. package/dist/runtime/prose/Td.vue.d.ts +27 -0
  220. package/dist/runtime/prose/Th.vue +14 -26
  221. package/dist/runtime/prose/Th.vue.d.ts +27 -0
  222. package/dist/runtime/prose/Thead.vue +14 -26
  223. package/dist/runtime/prose/Thead.vue.d.ts +27 -0
  224. package/dist/runtime/prose/Tr.vue +14 -26
  225. package/dist/runtime/prose/Tr.vue.d.ts +27 -0
  226. package/dist/runtime/prose/Ul.vue +14 -26
  227. package/dist/runtime/prose/Ul.vue.d.ts +27 -0
  228. package/dist/runtime/types/form.d.ts +1 -0
  229. package/dist/runtime/types/utils.d.ts +42 -3
  230. package/dist/runtime/utils/link.d.ts +3 -3
  231. package/dist/runtime/utils/tv.js +2 -2
  232. package/dist/runtime/vue/components/Link.vue +122 -208
  233. package/dist/runtime/vue/components/Link.vue.d.ts +129 -0
  234. package/dist/shared/{b24ui-nuxt.CS9Lf0os.mjs → b24ui-nuxt.wBs9vEU5.mjs} +33 -8
  235. package/dist/types.d.mts +3 -5
  236. package/dist/unplugin.mjs +1 -1
  237. package/dist/vite.mjs +1 -1
  238. package/package.json +19 -27
  239. package/dist/meta.cjs +0 -72112
  240. package/dist/meta.d.cts +0 -72110
  241. package/dist/meta.d.ts +0 -72110
  242. package/dist/module.cjs +0 -63
  243. package/dist/module.d.cts +0 -15
  244. package/dist/module.d.ts +0 -15
  245. package/dist/shared/b24ui-nuxt.DrKwIWoc.cjs +0 -7721
  246. package/dist/types.d.ts +0 -7
  247. package/dist/unplugin.cjs +0 -236
  248. package/dist/unplugin.d.cts +0 -33
  249. package/dist/unplugin.d.ts +0 -33
  250. package/dist/vite.cjs +0 -21
  251. package/dist/vite.d.cts +0 -14
  252. package/dist/vite.d.ts +0 -14
@@ -1,208 +1,9 @@
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 theme from "#build/b24ui/select-menu";
202
3
  </script>
203
4
 
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'
5
+ <script setup>
6
+ import { computed, toRef, toRaw } from "vue";
206
7
  import {
207
8
  ComboboxRoot,
208
9
  ComboboxArrow,
@@ -222,56 +23,85 @@ import {
222
23
  useForwardPropsEmits,
223
24
  useFilter,
224
25
  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)
26
+ } from "reka-ui";
27
+ import { defu } from "defu";
28
+ import { reactivePick, createReusableTemplate } from "@vueuse/core";
29
+ import { useAppConfig } from "#imports";
30
+ import { useButtonGroup } from "../composables/useButtonGroup";
31
+ import { useComponentIcons } from "../composables/useComponentIcons";
32
+ import { useFormField } from "../composables/useFormField";
33
+ import { useLocale } from "../composables/useLocale";
34
+ import { compare, get, isArrayOfArray } from "../utils";
35
+ import { tv } from "../utils/tv";
36
+ import icons from "../dictionary/icons";
37
+ import B24Avatar from "./Avatar.vue";
38
+ import B24Chip from "./Chip.vue";
39
+ import B24Input from "./Input.vue";
40
+ defineOptions({ inheritAttrs: false });
41
+ const props = defineProps({
42
+ id: { type: String, required: false },
43
+ placeholder: { type: String, required: false },
44
+ searchInput: { type: [Boolean, Object], required: false, default: true },
45
+ color: { type: null, required: false },
46
+ size: { type: null, required: false },
47
+ noPadding: { type: Boolean, required: false },
48
+ noBorder: { type: Boolean, required: false },
49
+ underline: { type: Boolean, required: false },
50
+ rounded: { type: Boolean, required: false },
51
+ tag: { type: String, required: false },
52
+ tagColor: { type: null, required: false },
53
+ required: { type: Boolean, required: false },
54
+ trailingIcon: { type: [Function, Object], required: false },
55
+ selectedIcon: { type: [Function, Object], required: false },
56
+ content: { type: Object, required: false },
57
+ arrow: { type: [Boolean, Object], required: false },
58
+ portal: { type: Boolean, required: false, default: true },
59
+ valueKey: { type: null, required: false },
60
+ labelKey: { type: null, required: false, default: "label" },
61
+ items: { type: null, required: false },
62
+ defaultValue: { type: null, required: false },
63
+ modelValue: { type: null, required: false },
64
+ multiple: { type: Boolean, required: false },
65
+ highlight: { type: Boolean, required: false },
66
+ createItem: { type: [Boolean, String, Object], required: false },
67
+ filterFields: { type: Array, required: false },
68
+ ignoreFilter: { type: Boolean, required: false },
69
+ class: { type: null, required: false },
70
+ b24ui: { type: null, required: false },
71
+ open: { type: Boolean, required: false },
72
+ defaultOpen: { type: Boolean, required: false },
73
+ disabled: { type: Boolean, required: false },
74
+ name: { type: String, required: false },
75
+ resetSearchTermOnBlur: { type: Boolean, required: false, default: true },
76
+ resetSearchTermOnSelect: { type: Boolean, required: false, default: true },
77
+ highlightOnHover: { type: Boolean, required: false },
78
+ icon: { type: [Function, Object], required: false },
79
+ avatar: { type: Object, required: false },
80
+ loading: { type: Boolean, required: false },
81
+ trailing: { type: Boolean, required: false }
82
+ });
83
+ const emits = defineEmits(["update:open", "change", "blur", "focus", "create", "highlight", "update:modelValue"]);
84
+ const slots = defineSlots();
85
+ const searchTerm = defineModel("searchTerm", { type: String, ...{ default: "" } });
86
+ const { t } = useLocale();
87
+ const appConfig = useAppConfig();
88
+ const { contains } = useFilter({ sensitivity: "base" });
89
+ const rootProps = useForwardPropsEmits(reactivePick(props, "modelValue", "defaultValue", "open", "defaultOpen", "required", "multiple", "resetSearchTermOnBlur", "resetSearchTermOnSelect", "highlightOnHover"), emits);
90
+ const contentProps = toRef(() => defu(props.content, { side: "bottom", sideOffset: 8, collisionPadding: 8, position: "popper" }));
91
+ const arrowProps = toRef(() => props.arrow);
92
+ const searchInputProps = toRef(() => defu(props.searchInput, { placeholder: t("selectMenu.search"), type: "search" }));
93
+ const { emitFormBlur, emitFormFocus, emitFormInput, emitFormChange, size: formGroupSize, color, id, name, highlight, disabled, ariaAttrs } = useFormField(props);
94
+ const { orientation, size: buttonGroupSize } = useButtonGroup(props);
261
95
  const { isLeading, isTrailing, leadingIconName, trailingIconName } = useComponentIcons(toRef(() => defu(
262
96
  props,
263
97
  { trailingIcon: icons.chevronDown }
264
- )))
265
-
266
- const selectSize = computed(() => buttonGroupSize.value || formGroupSize.value)
267
-
268
- const [DefineCreateItemTemplate, ReuseCreateItemTemplate] = createReusableTemplate()
269
-
98
+ )));
99
+ const selectSize = computed(() => buttonGroupSize.value || formGroupSize.value);
100
+ const [DefineCreateItemTemplate, ReuseCreateItemTemplate] = createReusableTemplate();
270
101
  const isTag = computed(() => {
271
- return props.tag
272
- })
273
-
274
- const b24ui = computed(() => selectMenu({
102
+ return props.tag;
103
+ });
104
+ const b24ui = computed(() => tv({ extend: tv(theme), ...appConfig.b24ui?.selectMenu || {} })({
275
105
  color: color.value,
276
106
  size: selectSize?.value,
277
107
  loading: props.loading,
@@ -284,115 +114,98 @@ const b24ui = computed(() => selectMenu({
284
114
  leading: Boolean(isLeading.value || !!props.avatar || !!slots.leading),
285
115
  trailing: Boolean(isTrailing.value || !!slots.trailing),
286
116
  buttonGroup: orientation.value
287
- }))
288
-
289
- function displayValue(value: GetItemValue<T, VK> | GetItemValue<T, VK>[]): string {
117
+ }));
118
+ function displayValue(value) {
290
119
  if (props.multiple && Array.isArray(value)) {
291
- return value.map(v => displayValue(v)).filter(Boolean).join(', ')
120
+ return value.map((v) => displayValue(v)).filter(Boolean).join(", ");
292
121
  }
293
-
294
122
  if (!props.valueKey) {
295
- return value && (typeof value === 'object' ? get(value, props.labelKey as string) : value)
123
+ return value && (typeof value === "object" ? get(value, props.labelKey) : value);
296
124
  }
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)
125
+ const item = items.value.find((item2) => compare(typeof item2 === "object" ? get(item2, props.valueKey) : item2, value));
126
+ return item && (typeof item === "object" ? get(item, props.labelKey) : item);
300
127
  }
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
-
128
+ const groups = computed(
129
+ () => props.items?.length ? isArrayOfArray(props.items) ? props.items : [props.items] : []
130
+ );
131
+ const items = computed(() => groups.value.flatMap((group) => group));
312
132
  const filteredGroups = computed(() => {
313
133
  if (props.ignoreFilter || !searchTerm.value) {
314
- return groups.value
134
+ return groups.value;
315
135
  }
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)
136
+ const fields = Array.isArray(props.filterFields) ? props.filterFields : [props.labelKey];
137
+ return groups.value.map((items2) => items2.filter((item) => {
138
+ if (typeof item !== "object" || item === null) {
139
+ return contains(String(item), searchTerm.value);
322
140
  }
323
-
324
- if (item.type && ['label', 'separator'].includes(item.type)) {
325
- return true
141
+ if (item.type && ["label", "separator"].includes(item.type)) {
142
+ return true;
326
143
  }
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
-
144
+ return fields.some((field) => contains(get(item, field), searchTerm.value));
145
+ })).filter((group) => group.filter(
146
+ (item) => !isSelectItem(item) || isSelectItem(item) && (!item.type || !["label", "separator"].includes(item.type))
147
+ ).length > 0);
148
+ });
149
+ const filteredItems = computed(() => filteredGroups.value.flatMap((group) => group));
335
150
  const createItem = computed(() => {
336
151
  if (!props.createItem || !searchTerm.value) {
337
- return false
152
+ return false;
338
153
  }
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)))
154
+ const newItem = props.valueKey ? { [props.valueKey]: searchTerm.value } : searchTerm.value;
155
+ if (typeof props.createItem === "object" && props.createItem.when === "always" || props.createItem === "always") {
156
+ return !filteredItems.value.find((item) => compare(item, newItem, String(props.valueKey)));
344
157
  }
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) {
158
+ return !filteredItems.value.length;
159
+ });
160
+ const createItemPosition = computed(() => typeof props.createItem === "object" ? props.createItem.position : "bottom");
161
+ function onUpdate(value) {
351
162
  if (toRaw(props.modelValue) === value) {
352
- return
163
+ return;
164
+ }
165
+ const event = new Event("change", { target: { value } });
166
+ emits("change", event);
167
+ emitFormChange();
168
+ emitFormInput();
169
+ if (props.resetSearchTermOnSelect) {
170
+ searchTerm.value = "";
353
171
  }
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
172
  }
361
-
362
- function onUpdateOpen(value: boolean) {
363
- let timeoutId: ReturnType<typeof setTimeout> | undefined
364
-
173
+ function onUpdateOpen(value) {
174
+ let timeoutId;
365
175
  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
176
+ const event = new FocusEvent("blur");
177
+ emits("blur", event);
178
+ emitFormBlur();
373
179
  if (props.resetSearchTermOnBlur) {
374
- const STATE_ANIMATION_DELAY_MS = 100
375
-
180
+ const STATE_ANIMATION_DELAY_MS = 100;
376
181
  timeoutId = setTimeout(() => {
377
- searchTerm.value = ''
378
- }, STATE_ANIMATION_DELAY_MS)
182
+ searchTerm.value = "";
183
+ }, STATE_ANIMATION_DELAY_MS);
379
184
  }
380
185
  } else {
381
- const event = new FocusEvent('focus')
382
- emits('focus', event)
383
- emitFormFocus()
186
+ const event = new FocusEvent("focus");
187
+ emits("focus", event);
188
+ emitFormFocus();
384
189
  if (timeoutId) {
385
- clearTimeout(timeoutId)
190
+ clearTimeout(timeoutId);
386
191
  }
387
192
  }
388
193
  }
389
-
390
- function isSelectItem(item: SelectMenuItem): item is _SelectMenuItem {
391
- return typeof item === 'object' && item !== null
194
+ function onSelect(e, item) {
195
+ if (!isSelectItem(item)) {
196
+ return;
197
+ }
198
+ if (item.disabled) {
199
+ e.preventDefault();
200
+ return;
201
+ }
202
+ item.onSelect?.(e);
203
+ }
204
+ function isSelectItem(item) {
205
+ return typeof item === "object" && item !== null;
392
206
  }
393
207
  </script>
394
208
 
395
- <!-- eslint-disable vue/no-template-shadow -->
396
209
  <template>
397
210
  <Primitive as="div" :class="b24ui.root({ addNew: true, class: [props.b24ui?.root] })">
398
211
  <DefineCreateItemTemplate>
@@ -432,29 +245,29 @@ function isSelectItem(item: SelectMenuItem): item is _SelectMenuItem {
432
245
  {{ props.tag }}
433
246
  </div>
434
247
  <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">
248
+ <slot name="leading" :model-value="modelValue" :open="open" :b24ui="b24ui">
436
249
  <Component
437
250
  :is="leadingIconName"
438
251
  v-if="isLeading && leadingIconName"
439
252
  :class="b24ui.leadingIcon({ class: props.b24ui?.leadingIcon })"
440
253
  />
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 })" />
254
+ <B24Avatar v-else-if="!!avatar" :size="props.b24ui?.itemLeadingAvatarSize || b24ui.itemLeadingAvatarSize()" v-bind="avatar" :class="b24ui.itemLeadingAvatar({ class: props.b24ui?.itemLeadingAvatar })" />
442
255
  </slot>
443
256
  </span>
444
257
 
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">
258
+ <slot :model-value="modelValue" :open="open">
259
+ <template v-for="displayedModelValue in [displayValue(modelValue)]" :key="displayedModelValue">
447
260
  <span v-if="displayedModelValue" :class="b24ui.value({ class: props.b24ui?.value })">
448
261
  {{ displayedModelValue }}
449
262
  </span>
450
263
  <span v-else :class="b24ui.placeholder({ class: props.b24ui?.placeholder })">
451
- {{ placeholder ?? '&nbsp;' }}
264
+ {{ placeholder ?? '\xA0' }}
452
265
  </span>
453
266
  </template>
454
267
  </slot>
455
268
 
456
269
  <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">
270
+ <slot name="trailing" :model-value="modelValue" :open="open" :b24ui="b24ui">
458
271
  <Component
459
272
  :is="trailingIconName"
460
273
  v-if="trailingIconName"
@@ -484,29 +297,29 @@ function isSelectItem(item: SelectMenuItem): item is _SelectMenuItem {
484
297
  <ComboboxGroup v-for="(group, groupIndex) in filteredGroups" :key="`group-${groupIndex}`" :class="b24ui.group({ class: props.b24ui?.group })">
485
298
  <template v-for="(item, index) in group" :key="`group-${groupIndex}-${index}`">
486
299
  <ComboboxLabel v-if="isSelectItem(item) && item.type === 'label'" :class="b24ui.label({ class: props.b24ui?.label })">
487
- {{ get(item, props.labelKey as string) }}
300
+ {{ get(item, props.labelKey) }}
488
301
  </ComboboxLabel>
489
302
 
490
303
  <ComboboxSeparator v-else-if="isSelectItem(item) && item.type === 'separator'" :class="b24ui.separator({ class: props.b24ui?.separator })" />
491
304
 
492
305
  <ComboboxItem
493
306
  v-else
494
- :class="b24ui.item({ class: props.b24ui?.item, colorItem: isSelectItem(item) ? item?.color : undefined })"
307
+ :class="b24ui.item({ class: props.b24ui?.item, colorItem: isSelectItem(item) ? item?.color : void 0 })"
495
308
  :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)"
309
+ :value="props.valueKey && isSelectItem(item) ? get(item, props.valueKey) : item"
310
+ @select="onSelect($event, item)"
498
311
  >
499
- <slot name="item" :item="(item as NestedItem<T>)" :index="index">
500
- <slot name="item-leading" :item="(item as NestedItem<T>)" :index="index">
312
+ <slot name="item" :item="item" :index="index">
313
+ <slot name="item-leading" :item="item" :index="index">
501
314
  <Component
502
315
  :is="item.icon"
503
316
  v-if="isSelectItem(item) && item.icon"
504
317
  :class="b24ui.itemLeadingIcon({ class: props.b24ui?.itemLeadingIcon, colorItem: item?.color })"
505
318
  />
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 })" />
319
+ <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
320
  <B24Chip
508
321
  v-else-if="isSelectItem(item) && item.chip"
509
- :size="((props.b24ui?.itemLeadingChipSize || b24ui.itemLeadingChipSize()) as ChipProps['size'])"
322
+ :size="props.b24ui?.itemLeadingChipSize || b24ui.itemLeadingChipSize()"
510
323
  inset
511
324
  standalone
512
325
  v-bind="item.chip"
@@ -515,18 +328,18 @@ function isSelectItem(item: SelectMenuItem): item is _SelectMenuItem {
515
328
  </slot>
516
329
 
517
330
  <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 }}
331
+ <slot name="item-label" :item="item" :index="index">
332
+ {{ isSelectItem(item) ? get(item, props.labelKey) : item }}
520
333
  </slot>
521
334
  </span>
522
335
 
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" />
336
+ <span :class="b24ui.itemTrailing({ class: props.b24ui?.itemTrailing, colorItem: isSelectItem(item) ? item?.color : void 0 })">
337
+ <slot name="item-trailing" :item="item" :index="index" />
525
338
 
526
339
  <ComboboxItemIndicator as-child>
527
340
  <Component
528
341
  :is="selectedIcon || icons.check"
529
- :class="b24ui.itemTrailingIcon({ class: props.b24ui?.itemTrailingIcon, colorItem: isSelectItem(item) ? item?.color : undefined })"
342
+ :class="b24ui.itemTrailingIcon({ class: props.b24ui?.itemTrailingIcon, colorItem: isSelectItem(item) ? item?.color : void 0 })"
530
343
  />
531
344
  </ComboboxItemIndicator>
532
345
  </span>