@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,212 +1,75 @@
1
- <script lang="ts">
2
- import type { VariantProps } from 'tailwind-variants'
3
- import type { SelectRootProps, SelectRootEmits, SelectContentProps, SelectContentEmits, SelectArrowProps } from 'reka-ui'
4
- import type { AppConfig } from '@nuxt/schema'
5
- import _appConfig from '#build/app.config'
6
- import theme from '#build/b24ui/select'
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 appConfigSelect = _appConfig as AppConfig & { b24ui: { select: Partial<typeof theme> } }
23
-
24
- const select = tv({ extend: tv(theme), ...(appConfigSelect.b24ui?.select || {}) })
25
-
26
- type SelectVariants = VariantProps<typeof select>
27
-
28
- interface SelectItemBase {
29
- label?: string
30
- /**
31
- * Display an icon on the left side.
32
- * @IconComponent
33
- */
34
- icon?: IconComponent
35
- avatar?: AvatarProps
36
- color?: SelectVariants['color']
37
- chip?: ChipProps
38
- /**
39
- * The item type.
40
- * @defaultValue 'item'
41
- */
42
- type?: 'label' | 'separator' | 'item'
43
- value?: string | number
44
- disabled?: boolean
45
- [key: string]: any
46
- }
47
- export type SelectItem = SelectItemBase | AcceptableValue | boolean
48
-
49
- export interface SelectProps<T extends ArrayOrNested<SelectItem> = ArrayOrNested<SelectItem>, VK extends GetItemKeys<T> = 'value', M extends boolean = false> extends Omit<SelectRootProps<T>, 'dir' | 'multiple' | 'modelValue' | 'defaultValue' | 'by'>, UseComponentIconsProps {
50
- id?: string
51
- /** The placeholder text when the select is empty. */
52
- placeholder?: string
53
- /**
54
- * @defaultValue 'primary'
55
- */
56
- color?: SelectVariants['color']
57
- /**
58
- * @defaultValue 'md'
59
- */
60
- size?: SelectVariants['size']
61
- /**
62
- * Removes padding from input
63
- * @defaultValue false
64
- */
65
- noPadding?: boolean
66
- /**
67
- * Removes all borders (rings)
68
- * @defaultValue false
69
- */
70
- noBorder?: boolean
71
- /**
72
- * Removes all borders (rings) except the bottom one
73
- * @defaultValue false
74
- */
75
- underline?: boolean
76
- /**
77
- * Rounds the corners of the button
78
- * @defaultValue false
79
- */
80
- rounded?: boolean
81
- tag?: string
82
- /**
83
- * @defaultValue 'primary'
84
- */
85
- tagColor?: SelectVariants['tagColor']
86
- /**
87
- * The icon displayed to open the menu.
88
- * @defaultValue icons.chevronDown
89
- * @IconComponent
90
- */
91
- trailingIcon?: IconComponent
92
- /**
93
- * The icon displayed when an item is selected.
94
- * @defaultValue icons.check
95
- * @IconComponent
96
- */
97
- selectedIcon?: IconComponent
98
- /**
99
- * The content of the menu.
100
- * @defaultValue { side: 'bottom', sideOffset: 8, collisionPadding: 8, position: 'popper' }
101
- */
102
- content?: Omit<SelectContentProps, 'as' | 'asChild' | 'forceMount'> & Partial<EmitsToProps<SelectContentEmits>>
103
- /**
104
- * Display an arrow alongside the menu.
105
- * @defaultValue false
106
- */
107
- arrow?: boolean | Omit<SelectArrowProps, 'as' | 'asChild'>
108
- /**
109
- * Render the menu in a portal.
110
- * @defaultValue true
111
- */
112
- portal?: boolean
113
- /**
114
- * When `items` is an array of objects, select the field to use as the value.
115
- * @defaultValue 'value'
116
- */
117
- valueKey?: VK
118
- /**
119
- * When `items` is an array of objects, select the field to use as the label.
120
- * @defaultValue 'label'
121
- */
122
- labelKey?: keyof NestedItem<T>
123
- items?: T
124
- /**
125
- * The value of the Select when initially rendered. Use when you do not need to control the state of the Select
126
- */
127
- defaultValue?: GetModelValue<T, VK, M>
128
- /**
129
- * The controlled value of the Select. Can be bind as `v-model`
130
- */
131
- modelValue?: GetModelValue<T, VK, M>
132
- /**
133
- * Whether multiple options can be selected or not
134
- * @defaultValue false
135
- */
136
- multiple?: M & boolean
137
- /**
138
- * Highlight the ring color like a focus state
139
- * @defaultValue false
140
- */
141
- highlight?: boolean
142
- class?: any
143
- b24ui?: PartialString<typeof select.slots>
144
- }
145
-
146
- export type SelectEmits<A extends ArrayOrNested<SelectItem>, VK extends GetItemKeys<A> | undefined, M extends boolean> = Omit<SelectRootEmits, 'update:modelValue'> & {
147
- change: [payload: Event]
148
- blur: [payload: FocusEvent]
149
- focus: [payload: FocusEvent]
150
- } & GetModelValueEmits<A, VK, M>
151
-
152
- type SlotProps<T extends SelectItem> = (props: { item: T, index: number }) => any
153
-
154
- export interface SelectSlots<
155
- A extends ArrayOrNested<SelectItem> = ArrayOrNested<SelectItem>,
156
- VK extends GetItemKeys<A> | undefined = undefined,
157
- M extends boolean = false,
158
- T extends NestedItem<A> = NestedItem<A>
159
- > {
160
- 'leading'(props: { modelValue?: GetModelValue<A, VK, M>, open: boolean, b24ui: ReturnType<typeof select> }): any
161
- 'default'(props: { modelValue?: GetModelValue<A, VK, M>, open: boolean }): any
162
- 'trailing'(props: { modelValue?: GetModelValue<A, VK, M>, open: boolean, b24ui: ReturnType<typeof select> }): any
163
- 'item': SlotProps<T>
164
- 'item-leading': SlotProps<T>
165
- 'item-label': SlotProps<T>
166
- 'item-trailing': SlotProps<T>
167
- }
1
+ <script>
2
+ import _appConfig from "#build/app.config";
3
+ import theme from "#build/b24ui/select";
4
+ import { tv } from "../utils/tv";
5
+ const appConfigSelect = _appConfig;
6
+ const select = tv({ extend: tv(theme), ...appConfigSelect.b24ui?.select || {} });
168
7
  </script>
169
8
 
170
- <script setup lang="ts" generic="T extends ArrayOrNested<SelectItem>, VK extends GetItemKeys<T> = 'value', M extends boolean = false">
171
- import { computed, toRef } from 'vue'
172
- import { Primitive, SelectRoot, SelectArrow, SelectTrigger, SelectPortal, SelectContent, SelectViewport, SelectScrollUpButton, SelectScrollDownButton, SelectLabel, SelectGroup, SelectItem, SelectItemIndicator, SelectItemText, SelectSeparator, useForwardPropsEmits } from 'reka-ui'
173
- import { defu } from 'defu'
174
- import { reactivePick } from '@vueuse/core'
175
- import { useButtonGroup } from '../composables/useButtonGroup'
176
- import { useComponentIcons } from '../composables/useComponentIcons'
177
- import { useFormField } from '../composables/useFormField'
178
- import { compare, get, isArrayOfArray } from '../utils'
179
- import icons from '../dictionary/icons'
180
- import B24Avatar from './Avatar.vue'
181
- import B24Chip from './Chip.vue'
182
-
183
- defineOptions({ inheritAttrs: false })
184
-
185
- const props = withDefaults(defineProps<SelectProps<T, VK, M>>(), {
186
- valueKey: 'value' as never,
187
- labelKey: 'label' as never,
188
- portal: true
189
- })
190
- const emits = defineEmits<SelectEmits<T, VK, M>>()
191
- const slots = defineSlots<SelectSlots<T, VK, M>>()
192
-
193
- const rootProps = useForwardPropsEmits(reactivePick(props, 'open', 'defaultOpen', 'disabled', 'autocomplete', 'required', 'multiple'), emits)
194
- const contentProps = toRef(() => defu(props.content, { side: 'bottom', sideOffset: 8, collisionPadding: 8, position: 'popper' }) as SelectContentProps)
195
- const arrowProps = toRef(() => props.arrow as SelectArrowProps)
196
-
197
- const { emitFormChange, emitFormInput, emitFormBlur, emitFormFocus, size: formGroupSize, color, id, name, highlight, disabled, ariaAttrs } = useFormField<InputProps>(props)
198
- const { orientation, size: buttonGroupSize } = useButtonGroup<InputProps>(props)
9
+ <script setup>
10
+ import { computed, toRef } from "vue";
11
+ import { Primitive, SelectRoot, SelectArrow, SelectTrigger, SelectPortal, SelectContent, SelectViewport, SelectScrollUpButton, SelectScrollDownButton, SelectLabel, SelectGroup, SelectItem, SelectItemIndicator, SelectItemText, SelectSeparator, useForwardPropsEmits } from "reka-ui";
12
+ import { defu } from "defu";
13
+ import { reactivePick } from "@vueuse/core";
14
+ import { useButtonGroup } from "../composables/useButtonGroup";
15
+ import { useComponentIcons } from "../composables/useComponentIcons";
16
+ import { useFormField } from "../composables/useFormField";
17
+ import { compare, get, isArrayOfArray } from "../utils";
18
+ import icons from "../dictionary/icons";
19
+ import B24Avatar from "./Avatar.vue";
20
+ import B24Chip from "./Chip.vue";
21
+ defineOptions({ inheritAttrs: false });
22
+ const props = defineProps({
23
+ id: { type: String, required: false },
24
+ placeholder: { type: String, required: false },
25
+ color: { type: null, required: false },
26
+ size: { type: null, required: false },
27
+ noPadding: { type: Boolean, required: false },
28
+ noBorder: { type: Boolean, required: false },
29
+ underline: { type: Boolean, required: false },
30
+ rounded: { type: Boolean, required: false },
31
+ tag: { type: String, required: false },
32
+ tagColor: { type: null, required: false },
33
+ trailingIcon: { type: [Function, Object], required: false },
34
+ selectedIcon: { type: [Function, Object], required: false },
35
+ content: { type: Object, required: false },
36
+ arrow: { type: [Boolean, Object], required: false },
37
+ portal: { type: Boolean, required: false, default: true },
38
+ valueKey: { type: null, required: false, default: "value" },
39
+ labelKey: { type: null, required: false, default: "label" },
40
+ items: { type: null, required: false },
41
+ defaultValue: { type: null, required: false },
42
+ modelValue: { type: null, required: false },
43
+ multiple: { type: Boolean, required: false },
44
+ highlight: { type: Boolean, required: false },
45
+ class: { type: null, required: false },
46
+ b24ui: { type: null, required: false },
47
+ open: { type: Boolean, required: false },
48
+ defaultOpen: { type: Boolean, required: false },
49
+ autocomplete: { type: String, required: false },
50
+ disabled: { type: Boolean, required: false },
51
+ name: { type: String, required: false },
52
+ required: { type: Boolean, required: false },
53
+ icon: { type: [Function, Object], required: false },
54
+ avatar: { type: Object, required: false },
55
+ loading: { type: Boolean, required: false },
56
+ trailing: { type: Boolean, required: false }
57
+ });
58
+ const emits = defineEmits(["update:open", "change", "blur", "focus", "update:modelValue"]);
59
+ const slots = defineSlots();
60
+ const rootProps = useForwardPropsEmits(reactivePick(props, "open", "defaultOpen", "disabled", "autocomplete", "required", "multiple"), emits);
61
+ const contentProps = toRef(() => defu(props.content, { side: "bottom", sideOffset: 8, collisionPadding: 8, position: "popper" }));
62
+ const arrowProps = toRef(() => props.arrow);
63
+ const { emitFormChange, emitFormInput, emitFormBlur, emitFormFocus, size: formGroupSize, color, id, name, highlight, disabled, ariaAttrs } = useFormField(props);
64
+ const { orientation, size: buttonGroupSize } = useButtonGroup(props);
199
65
  const { isLeading, isTrailing, leadingIconName, trailingIconName } = useComponentIcons(toRef(() => defu(
200
66
  props,
201
67
  { trailingIcon: icons.chevronDown }
202
- )))
203
-
204
- const selectSize = computed(() => buttonGroupSize.value || formGroupSize.value)
205
-
68
+ )));
69
+ const selectSize = computed(() => buttonGroupSize.value || formGroupSize.value);
206
70
  const isTag = computed(() => {
207
- return props.tag
208
- })
209
-
71
+ return props.tag;
72
+ });
210
73
  const b24ui = computed(() => select({
211
74
  color: color.value,
212
75
  size: selectSize?.value,
@@ -220,54 +83,40 @@ const b24ui = computed(() => select({
220
83
  leading: Boolean(isLeading.value || !!props.avatar || !!slots.leading),
221
84
  trailing: Boolean(isTrailing.value || !!slots.trailing),
222
85
  buttonGroup: orientation.value
223
- }))
224
-
225
- const groups = computed<SelectItem[][]>(() =>
226
- props.items?.length
227
- ? isArrayOfArray(props.items)
228
- ? props.items
229
- : [props.items]
230
- : []
231
- )
232
- // eslint-disable-next-line vue/no-dupe-keys
233
- const items = computed(() => groups.value.flatMap(group => group) as T[])
234
-
235
- function displayValue(value?: GetItemValue<T, VK> | GetItemValue<T, VK>[]): string {
86
+ }));
87
+ const groups = computed(
88
+ () => props.items?.length ? isArrayOfArray(props.items) ? props.items : [props.items] : []
89
+ );
90
+ const items = computed(() => groups.value.flatMap((group) => group));
91
+ function displayValue(value) {
236
92
  if (props.multiple && Array.isArray(value)) {
237
- return value.map(v => displayValue(v)).filter(Boolean).join(', ')
93
+ return value.map((v) => displayValue(v)).filter(Boolean).join(", ");
238
94
  }
239
-
240
- const item = items.value.find(item => compare(typeof item === 'object' ? get(item as Record<string, any>, props.valueKey as string) : item, value))
241
- return item && (typeof item === 'object' ? get(item, props.labelKey as string) : item)
95
+ const item = items.value.find((item2) => compare(typeof item2 === "object" ? get(item2, props.valueKey) : item2, value));
96
+ return item && (typeof item === "object" ? get(item, props.labelKey) : item);
242
97
  }
243
-
244
- function onUpdate(value: any) {
245
- // @ts-expect-error - 'target' does not exist in type 'EventInit'
246
- const event = new Event('change', { target: { value } })
247
- emits('change', event)
248
-
249
- emitFormChange()
250
- emitFormInput()
98
+ function onUpdate(value) {
99
+ const event = new Event("change", { target: { value } });
100
+ emits("change", event);
101
+ emitFormChange();
102
+ emitFormInput();
251
103
  }
252
-
253
- function onUpdateOpen(value: boolean) {
104
+ function onUpdateOpen(value) {
254
105
  if (!value) {
255
- const event = new FocusEvent('blur')
256
- emits('blur', event)
257
- emitFormBlur()
106
+ const event = new FocusEvent("blur");
107
+ emits("blur", event);
108
+ emitFormBlur();
258
109
  } else {
259
- const event = new FocusEvent('focus')
260
- emits('focus', event)
261
- emitFormFocus()
110
+ const event = new FocusEvent("focus");
111
+ emits("focus", event);
112
+ emitFormFocus();
262
113
  }
263
114
  }
264
-
265
- function isSelectItem(item: SelectItem): item is SelectItemBase {
266
- return typeof item === 'object' && item !== null
115
+ function isSelectItem(item) {
116
+ return typeof item === "object" && item !== null;
267
117
  }
268
118
  </script>
269
119
 
270
- <!-- eslint-disable vue/no-template-shadow -->
271
120
  <template>
272
121
  <Primitive as="div" :class="b24ui.root({ class: [props.b24ui?.root] })">
273
122
  <SelectRoot
@@ -276,8 +125,8 @@ function isSelectItem(item: SelectItem): item is SelectItemBase {
276
125
  v-bind="rootProps"
277
126
  :autocomplete="autocomplete"
278
127
  :disabled="disabled"
279
- :default-value="(defaultValue as (AcceptableValue | AcceptableValue[]))"
280
- :model-value="(modelValue as (AcceptableValue | AcceptableValue[]))"
128
+ :default-value="defaultValue"
129
+ :model-value="modelValue"
281
130
  @update:model-value="onUpdate"
282
131
  @update:open="onUpdateOpen"
283
132
  >
@@ -287,29 +136,29 @@ function isSelectItem(item: SelectItem): item is SelectItemBase {
287
136
  </div>
288
137
 
289
138
  <span v-if="isLeading || !!avatar || !!slots.leading" :class="b24ui.leading({ class: props.b24ui?.leading })">
290
- <slot name="leading" :model-value="(modelValue as GetModelValue<T, VK, M>)" :open="open" :b24ui="b24ui">
139
+ <slot name="leading" :model-value="modelValue" :open="open" :b24ui="b24ui">
291
140
  <Component
292
141
  :is="leadingIconName"
293
142
  v-if="isLeading && leadingIconName"
294
143
  :class="b24ui.leadingIcon({ class: props.b24ui?.leadingIcon })"
295
144
  />
296
- <B24Avatar v-else-if="!!avatar" :size="((props.b24ui?.itemLeadingAvatarSize || b24ui.itemLeadingAvatarSize()) as AvatarProps['size'])" v-bind="avatar" :class="b24ui.itemLeadingAvatar({ class: props.b24ui?.itemLeadingAvatar })" />
145
+ <B24Avatar v-else-if="!!avatar" :size="props.b24ui?.itemLeadingAvatarSize || b24ui.itemLeadingAvatarSize()" v-bind="avatar" :class="b24ui.itemLeadingAvatar({ class: props.b24ui?.itemLeadingAvatar })" />
297
146
  </slot>
298
147
  </span>
299
148
 
300
- <slot :model-value="(modelValue as GetModelValue<T, VK, M>)" :open="open">
301
- <template v-for="displayedModelValue in [displayValue(modelValue as GetModelValue<T, VK, M>)]" :key="displayedModelValue">
149
+ <slot :model-value="modelValue" :open="open">
150
+ <template v-for="displayedModelValue in [displayValue(modelValue)]" :key="displayedModelValue">
302
151
  <span v-if="displayedModelValue" :class="b24ui.value({ class: props.b24ui?.value })">
303
152
  {{ displayedModelValue }}
304
153
  </span>
305
154
  <span v-else :class="b24ui.placeholder({ class: props.b24ui?.placeholder })">
306
- {{ placeholder ?? '&nbsp;' }}
155
+ {{ placeholder ?? '\xA0' }}
307
156
  </span>
308
157
  </template>
309
158
  </slot>
310
159
 
311
160
  <span v-if="isTrailing || !!slots.trailing" :class="b24ui.trailing({ class: props.b24ui?.trailing })">
312
- <slot name="trailing" :model-value="(modelValue as GetModelValue<T, VK, M>)" :open="open" :b24ui="b24ui">
161
+ <slot name="trailing" :model-value="modelValue" :open="open" :b24ui="b24ui">
313
162
  <Component
314
163
  :is="trailingIconName"
315
164
  v-if="trailingIconName"
@@ -331,28 +180,29 @@ function isSelectItem(item: SelectItem): item is SelectItemBase {
331
180
  <SelectGroup v-for="(group, groupIndex) in groups" :key="`group-${groupIndex}`" :class="b24ui.group({ class: props.b24ui?.group })">
332
181
  <template v-for="(item, index) in group" :key="`group-${groupIndex}-${index}`">
333
182
  <SelectLabel v-if="isSelectItem(item) && item.type === 'label'" :class="b24ui.label({ class: props.b24ui?.label })">
334
- {{ get(item, props.labelKey as string) }}
183
+ {{ get(item, props.labelKey) }}
335
184
  </SelectLabel>
336
185
 
337
186
  <SelectSeparator v-else-if="isSelectItem(item) && item.type === 'separator'" :class="b24ui.separator({ class: props.b24ui?.separator })" />
338
187
 
339
188
  <SelectItem
340
189
  v-else
341
- :class="b24ui.item({ class: props.b24ui?.item, colorItem: isSelectItem(item) ? item?.color : undefined })"
190
+ :class="b24ui.item({ class: props.b24ui?.item, colorItem: isSelectItem(item) ? item?.color : void 0 })"
342
191
  :disabled="isSelectItem(item) && item.disabled"
343
- :value="isSelectItem(item) ? get(item, props.valueKey as string) : item"
192
+ :value="isSelectItem(item) ? get(item, props.valueKey) : item"
193
+ @select="isSelectItem(item) && item.onSelect?.($event)"
344
194
  >
345
- <slot name="item" :item="(item as NestedItem<T>)" :index="index">
346
- <slot name="item-leading" :item="(item as NestedItem<T>)" :index="index">
195
+ <slot name="item" :item="item" :index="index">
196
+ <slot name="item-leading" :item="item" :index="index">
347
197
  <Component
348
198
  :is="item.icon"
349
199
  v-if="isSelectItem(item) && item.icon"
350
200
  :class="b24ui.itemLeadingIcon({ class: props.b24ui?.itemLeadingIcon, colorItem: item?.color })"
351
201
  />
352
- <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 })" />
202
+ <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 })" />
353
203
  <B24Chip
354
204
  v-else-if="isSelectItem(item) && item.chip"
355
- :size="((props.b24ui?.itemLeadingChipSize || b24ui.itemLeadingChipSize()) as ChipProps['size'])"
205
+ :size="props.b24ui?.itemLeadingChipSize || b24ui.itemLeadingChipSize()"
356
206
  inset
357
207
  standalone
358
208
  v-bind="item.chip"
@@ -361,18 +211,18 @@ function isSelectItem(item: SelectItem): item is SelectItemBase {
361
211
  </slot>
362
212
 
363
213
  <SelectItemText :class="b24ui.itemLabel({ class: props.b24ui?.itemLabel })">
364
- <slot name="item-label" :item="(item as NestedItem<T>)" :index="index">
365
- {{ isSelectItem(item) ? get(item, props.labelKey as string) : item }}
214
+ <slot name="item-label" :item="item" :index="index">
215
+ {{ isSelectItem(item) ? get(item, props.labelKey) : item }}
366
216
  </slot>
367
217
  </SelectItemText>
368
218
 
369
- <span :class="b24ui.itemTrailing({ class: props.b24ui?.itemTrailing, colorItem: isSelectItem(item) ? item?.color : undefined })">
370
- <slot name="item-trailing" :item="(item as NestedItem<T>)" :index="index" />
219
+ <span :class="b24ui.itemTrailing({ class: props.b24ui?.itemTrailing, colorItem: isSelectItem(item) ? item?.color : void 0 })">
220
+ <slot name="item-trailing" :item="item" :index="index" />
371
221
 
372
222
  <SelectItemIndicator as-child>
373
223
  <Component
374
224
  :is="selectedIcon || icons.check"
375
- :class="b24ui.itemTrailingIcon({ class: props.b24ui?.itemTrailingIcon, colorItem: isSelectItem(item) ? item?.color : undefined })"
225
+ :class="b24ui.itemTrailingIcon({ class: props.b24ui?.itemTrailingIcon, colorItem: isSelectItem(item) ? item?.color : void 0 })"
376
226
  />
377
227
  </SelectItemIndicator>
378
228
  </span>