@bitrix24/b24ui-nuxt 0.5.10 → 0.5.11

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 (190) hide show
  1. package/dist/meta.cjs +72112 -0
  2. package/dist/meta.d.cts +72110 -0
  3. package/dist/meta.d.mts +5060 -5060
  4. package/dist/meta.d.ts +72110 -0
  5. package/dist/meta.mjs +5060 -5060
  6. package/dist/module.cjs +63 -0
  7. package/dist/module.d.cts +15 -0
  8. package/dist/module.d.ts +15 -0
  9. package/dist/module.json +3 -3
  10. package/dist/module.mjs +1 -1
  11. package/dist/runtime/components/Advice.vue +54 -47
  12. package/dist/runtime/components/Alert.vue +96 -71
  13. package/dist/runtime/components/App.vue +34 -37
  14. package/dist/runtime/components/Avatar.vue +81 -69
  15. package/dist/runtime/components/AvatarGroup.vue +76 -53
  16. package/dist/runtime/components/Badge.vue +83 -83
  17. package/dist/runtime/components/Button.vue +157 -220
  18. package/dist/runtime/components/ButtonGroup.vue +51 -35
  19. package/dist/runtime/components/Calendar.vue +152 -186
  20. package/dist/runtime/components/Checkbox.vue +73 -84
  21. package/dist/runtime/components/Chip.vue +74 -59
  22. package/dist/runtime/components/Collapsible.vue +41 -44
  23. package/dist/runtime/components/Container.vue +27 -18
  24. package/dist/runtime/components/Countdown.vue +378 -198
  25. package/dist/runtime/components/DescriptionList.vue +149 -102
  26. package/dist/runtime/components/DropdownMenu.vue +139 -83
  27. package/dist/runtime/components/DropdownMenuContent.vue +84 -137
  28. package/dist/runtime/components/Form.vue +216 -162
  29. package/dist/runtime/components/FormField.vue +80 -76
  30. package/dist/runtime/components/Input.vue +179 -160
  31. package/dist/runtime/components/InputMenu.vue +380 -300
  32. package/dist/runtime/components/InputNumber.vue +175 -178
  33. package/dist/runtime/components/Kbd.vue +45 -33
  34. package/dist/runtime/components/Link.vue +173 -179
  35. package/dist/runtime/components/LinkBase.vue +42 -64
  36. package/dist/runtime/components/Modal.vue +127 -105
  37. package/dist/runtime/components/ModalDialogClose.vue +8 -4
  38. package/dist/runtime/components/Navbar.vue +33 -24
  39. package/dist/runtime/components/NavbarDivider.vue +33 -24
  40. package/dist/runtime/components/NavbarSection.vue +33 -24
  41. package/dist/runtime/components/NavbarSpacer.vue +33 -24
  42. package/dist/runtime/components/NavigationMenu.vue +210 -144
  43. package/dist/runtime/components/OverlayProvider.vue +17 -13
  44. package/dist/runtime/components/Popover.vue +81 -81
  45. package/dist/runtime/components/Progress.vue +136 -109
  46. package/dist/runtime/components/RadioGroup.vue +134 -120
  47. package/dist/runtime/components/Range.vue +85 -94
  48. package/dist/runtime/components/Select.vue +260 -212
  49. package/dist/runtime/components/SelectMenu.vue +365 -272
  50. package/dist/runtime/components/Separator.vue +71 -61
  51. package/dist/runtime/components/Sidebar.vue +33 -24
  52. package/dist/runtime/components/SidebarBody.vue +38 -30
  53. package/dist/runtime/components/SidebarFooter.vue +33 -24
  54. package/dist/runtime/components/SidebarHeader.vue +33 -24
  55. package/dist/runtime/components/SidebarHeading.vue +33 -24
  56. package/dist/runtime/components/SidebarLayout.vue +70 -40
  57. package/dist/runtime/components/SidebarSection.vue +33 -24
  58. package/dist/runtime/components/SidebarSpacer.vue +33 -24
  59. package/dist/runtime/components/Skeleton.vue +22 -17
  60. package/dist/runtime/components/Slideover.vue +131 -108
  61. package/dist/runtime/components/StackedLayout.vue +73 -40
  62. package/dist/runtime/components/Switch.vue +95 -100
  63. package/dist/runtime/components/Tabs.vue +107 -81
  64. package/dist/runtime/components/Textarea.vue +201 -177
  65. package/dist/runtime/components/Toast.vue +105 -94
  66. package/dist/runtime/components/Toaster.vue +116 -94
  67. package/dist/runtime/components/Tooltip.vue +64 -78
  68. package/dist/runtime/components/content/TableWrapper.vue +70 -58
  69. package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
  70. package/dist/runtime/composables/useButtonGroup.d.ts +2 -2
  71. package/dist/runtime/composables/useComponentIcons.d.ts +3 -3
  72. package/dist/runtime/composables/useFormField.d.ts +1 -1
  73. package/dist/runtime/prose/A.vue +23 -18
  74. package/dist/runtime/prose/Blockquote.vue +23 -18
  75. package/dist/runtime/prose/Code.vue +31 -23
  76. package/dist/runtime/prose/Em.vue +23 -18
  77. package/dist/runtime/prose/H1.vue +23 -18
  78. package/dist/runtime/prose/H2.vue +23 -18
  79. package/dist/runtime/prose/H3.vue +23 -18
  80. package/dist/runtime/prose/H4.vue +23 -18
  81. package/dist/runtime/prose/H5.vue +23 -18
  82. package/dist/runtime/prose/H6.vue +23 -18
  83. package/dist/runtime/prose/Hr.vue +19 -18
  84. package/dist/runtime/prose/Img.vue +23 -18
  85. package/dist/runtime/prose/Li.vue +23 -18
  86. package/dist/runtime/prose/Ol.vue +23 -18
  87. package/dist/runtime/prose/P.vue +23 -18
  88. package/dist/runtime/prose/Pre.vue +33 -28
  89. package/dist/runtime/prose/Strong.vue +23 -18
  90. package/dist/runtime/prose/Table.vue +54 -44
  91. package/dist/runtime/prose/Tbody.vue +23 -18
  92. package/dist/runtime/prose/Td.vue +23 -18
  93. package/dist/runtime/prose/Th.vue +23 -18
  94. package/dist/runtime/prose/Thead.vue +23 -18
  95. package/dist/runtime/prose/Tr.vue +23 -18
  96. package/dist/runtime/prose/Ul.vue +23 -18
  97. package/dist/runtime/vue/components/Link.vue +202 -201
  98. package/dist/shared/b24ui-nuxt.DrKwIWoc.cjs +7721 -0
  99. package/dist/types.d.mts +5 -3
  100. package/dist/types.d.ts +7 -0
  101. package/dist/unplugin.cjs +236 -0
  102. package/dist/unplugin.d.cts +33 -0
  103. package/dist/unplugin.d.ts +33 -0
  104. package/dist/vite.cjs +21 -0
  105. package/dist/vite.d.cts +14 -0
  106. package/dist/vite.d.ts +14 -0
  107. package/package.json +25 -13
  108. package/dist/runtime/components/Advice.vue.d.ts +0 -170
  109. package/dist/runtime/components/Alert.vue.d.ts +0 -464
  110. package/dist/runtime/components/App.vue.d.ts +0 -23
  111. package/dist/runtime/components/Avatar.vue.d.ts +0 -281
  112. package/dist/runtime/components/AvatarGroup.vue.d.ts +0 -204
  113. package/dist/runtime/components/Badge.vue.d.ts +0 -517
  114. package/dist/runtime/components/Button.vue.d.ts +0 -640
  115. package/dist/runtime/components/ButtonGroup.vue.d.ts +0 -116
  116. package/dist/runtime/components/Calendar.vue.d.ts +0 -437
  117. package/dist/runtime/components/Checkbox.vue.d.ts +0 -354
  118. package/dist/runtime/components/Chip.vue.d.ts +0 -271
  119. package/dist/runtime/components/Collapsible.vue.d.ts +0 -118
  120. package/dist/runtime/components/Container.vue.d.ts +0 -27
  121. package/dist/runtime/components/Countdown.vue.d.ts +0 -356
  122. package/dist/runtime/components/DescriptionList.vue.d.ts +0 -379
  123. package/dist/runtime/components/DropdownMenu.vue.d.ts +0 -533
  124. package/dist/runtime/components/DropdownMenuContent.vue.d.ts +0 -228
  125. package/dist/runtime/components/Form.vue.d.ts +0 -55
  126. package/dist/runtime/components/FormField.vue.d.ts +0 -282
  127. package/dist/runtime/components/Input.vue.d.ts +0 -755
  128. package/dist/runtime/components/InputMenu.vue.d.ts +0 -1504
  129. package/dist/runtime/components/InputNumber.vue.d.ts +0 -658
  130. package/dist/runtime/components/Kbd.vue.d.ts +0 -109
  131. package/dist/runtime/components/Link.vue.d.ts +0 -129
  132. package/dist/runtime/components/LinkBase.vue.d.ts +0 -48
  133. package/dist/runtime/components/Modal.vue.d.ts +0 -327
  134. package/dist/runtime/components/ModalDialogClose.vue.d.ts +0 -10
  135. package/dist/runtime/components/Navbar.vue.d.ts +0 -101
  136. package/dist/runtime/components/NavbarDivider.vue.d.ts +0 -101
  137. package/dist/runtime/components/NavbarSection.vue.d.ts +0 -101
  138. package/dist/runtime/components/NavbarSpacer.vue.d.ts +0 -101
  139. package/dist/runtime/components/NavigationMenu.vue.d.ts +0 -824
  140. package/dist/runtime/components/OverlayProvider.vue.d.ts +0 -2
  141. package/dist/runtime/components/Popover.vue.d.ts +0 -147
  142. package/dist/runtime/components/Progress.vue.d.ts +0 -592
  143. package/dist/runtime/components/RadioGroup.vue.d.ts +0 -723
  144. package/dist/runtime/components/Range.vue.d.ts +0 -417
  145. package/dist/runtime/components/Select.vue.d.ts +0 -1200
  146. package/dist/runtime/components/SelectMenu.vue.d.ts +0 -1298
  147. package/dist/runtime/components/Separator.vue.d.ts +0 -400
  148. package/dist/runtime/components/Sidebar.vue.d.ts +0 -101
  149. package/dist/runtime/components/SidebarBody.vue.d.ts +0 -90
  150. package/dist/runtime/components/SidebarFooter.vue.d.ts +0 -101
  151. package/dist/runtime/components/SidebarHeader.vue.d.ts +0 -101
  152. package/dist/runtime/components/SidebarHeading.vue.d.ts +0 -101
  153. package/dist/runtime/components/SidebarLayout.vue.d.ts +0 -222
  154. package/dist/runtime/components/SidebarSection.vue.d.ts +0 -101
  155. package/dist/runtime/components/SidebarSpacer.vue.d.ts +0 -101
  156. package/dist/runtime/components/Skeleton.vue.d.ts +0 -26
  157. package/dist/runtime/components/Slideover.vue.d.ts +0 -360
  158. package/dist/runtime/components/StackedLayout.vue.d.ts +0 -192
  159. package/dist/runtime/components/Switch.vue.d.ts +0 -587
  160. package/dist/runtime/components/Tabs.vue.d.ts +0 -453
  161. package/dist/runtime/components/Textarea.vue.d.ts +0 -601
  162. package/dist/runtime/components/Toast.vue.d.ts +0 -438
  163. package/dist/runtime/components/Toaster.vue.d.ts +0 -219
  164. package/dist/runtime/components/Tooltip.vue.d.ts +0 -186
  165. package/dist/runtime/components/content/TableWrapper.vue.d.ts +0 -237
  166. package/dist/runtime/prose/A.vue.d.ts +0 -84
  167. package/dist/runtime/prose/Blockquote.vue.d.ts +0 -84
  168. package/dist/runtime/prose/Code.vue.d.ts +0 -97
  169. package/dist/runtime/prose/Em.vue.d.ts +0 -84
  170. package/dist/runtime/prose/H1.vue.d.ts +0 -97
  171. package/dist/runtime/prose/H2.vue.d.ts +0 -123
  172. package/dist/runtime/prose/H3.vue.d.ts +0 -123
  173. package/dist/runtime/prose/H4.vue.d.ts +0 -123
  174. package/dist/runtime/prose/H5.vue.d.ts +0 -123
  175. package/dist/runtime/prose/H6.vue.d.ts +0 -123
  176. package/dist/runtime/prose/Hr.vue.d.ts +0 -74
  177. package/dist/runtime/prose/Img.vue.d.ts +0 -77
  178. package/dist/runtime/prose/Li.vue.d.ts +0 -84
  179. package/dist/runtime/prose/Ol.vue.d.ts +0 -84
  180. package/dist/runtime/prose/P.vue.d.ts +0 -84
  181. package/dist/runtime/prose/Pre.vue.d.ts +0 -117
  182. package/dist/runtime/prose/Strong.vue.d.ts +0 -84
  183. package/dist/runtime/prose/Table.vue.d.ts +0 -144
  184. package/dist/runtime/prose/Tbody.vue.d.ts +0 -84
  185. package/dist/runtime/prose/Td.vue.d.ts +0 -84
  186. package/dist/runtime/prose/Th.vue.d.ts +0 -84
  187. package/dist/runtime/prose/Thead.vue.d.ts +0 -84
  188. package/dist/runtime/prose/Tr.vue.d.ts +0 -84
  189. package/dist/runtime/prose/Ul.vue.d.ts +0 -84
  190. package/dist/runtime/vue/components/Link.vue.d.ts +0 -129
@@ -1,78 +1,125 @@
1
- <script>
2
- import _appConfig from "#build/app.config";
3
- import theme from "#build/b24ui/description-list";
4
- import { tv } from "../utils/tv";
5
- const appConfigDescriptionList = _appConfig;
6
- const descriptionList = tv({ extend: tv(theme), ...appConfigDescriptionList.b24ui?.descriptionList || {} });
1
+ <script lang="ts">
2
+ import type { VariantProps } from 'tailwind-variants'
3
+ import type { AppConfig } from '@nuxt/schema'
4
+ import _appConfig from '#build/app.config'
5
+ import theme from '#build/b24ui/description-list'
6
+ import { tv } from '../utils/tv'
7
+ import type { AvatarProps, ButtonProps, IconComponent } from '../types'
8
+ import type { DynamicSlots } from '../types/utils'
9
+
10
+ const appConfigDescriptionList = _appConfig as AppConfig & { b24ui: { descriptionList: Partial<typeof theme> } }
11
+
12
+ const descriptionList = tv({ extend: tv(theme), ...(appConfigDescriptionList.b24ui?.descriptionList || {}) })
13
+
14
+ type DescriptionListVariants = VariantProps<typeof descriptionList>
15
+
16
+ export interface DescriptionListItem {
17
+ label?: string
18
+ /**
19
+ * Display an icon on the left side.
20
+ * @IconComponent
21
+ */
22
+ icon?: IconComponent
23
+ avatar?: AvatarProps
24
+ slot?: string
25
+ description?: string
26
+ /**
27
+ * The orientation between the content and the actions.
28
+ * @defaultValue 'vertical'
29
+ */
30
+ orientation?: DescriptionListVariants['orientation']
31
+ /**
32
+ * Display a list of actions:
33
+ * - under the description when orientation is `vertical`
34
+ * - next to the description when orientation is `horizontal`
35
+ * `{ size: 'xs' }`{lang="ts"}
36
+ */
37
+ actions?: ButtonProps[]
38
+ class?: any
39
+ b24ui?: Partial<typeof descriptionList.slots>
40
+ [key: string]: any
41
+ }
42
+
43
+ export interface DescriptionListProps<T extends DescriptionListItem = DescriptionListItem> {
44
+ legend?: string
45
+ text?: string
46
+ /**
47
+ * The key used to get the label from the item.
48
+ * @defaultValue 'label'
49
+ */
50
+ labelKey?: string
51
+ /**
52
+ * The key used to get the description from the item.
53
+ * @defaultValue 'description'
54
+ */
55
+ descriptionKey?: string
56
+ items?: T[]
57
+ /**
58
+ * @defaultValue 'md'
59
+ */
60
+ size?: DescriptionListVariants['size']
61
+ class?: any
62
+ b24ui?: Partial<typeof descriptionList.slots>
63
+ }
64
+
65
+ type SlotProps<T extends DescriptionListItem> = (props: { item: T, index: number }) => any
66
+
67
+ export type DescriptionListSlots<T extends DescriptionListItem = DescriptionListItem> = {
68
+ legend(props?: {}): any
69
+ text(props?: {}): any
70
+ leading: SlotProps<T>
71
+ label: SlotProps<T>
72
+ description: SlotProps<T>
73
+ actions: SlotProps<T>
74
+ content: SlotProps<T>
75
+ footer(props?: { b24ui: any }): any
76
+ } & DynamicSlots<T, undefined, { index: number }>
7
77
  </script>
8
78
 
9
- <script setup>
10
- import { computed } from "vue";
11
- import { get } from "../utils";
12
- const props = defineProps({
13
- legend: {
14
- type: String,
15
- required: false
16
- },
17
- text: {
18
- type: String,
19
- required: false
20
- },
21
- labelKey: {
22
- type: String,
23
- required: false,
24
- default: "label"
25
- },
26
- descriptionKey: {
27
- type: String,
28
- required: false,
29
- default: "description"
30
- },
31
- items: {
32
- type: Array,
33
- required: false
34
- },
35
- size: {
36
- type: null,
37
- required: false
38
- },
39
- class: {
40
- type: null,
41
- required: false
42
- },
43
- b24ui: {
44
- type: Object,
45
- required: false
46
- }
47
- });
48
- const slots = defineSlots();
79
+ <script setup lang="ts" generic="T extends DescriptionListItem">
80
+ import { computed } from 'vue'
81
+ import { get } from '../utils'
82
+ import B24Avatar from './Avatar.vue'
83
+ import B24Button from './Button.vue'
84
+
85
+ const props = withDefaults(defineProps<DescriptionListProps<T>>(), {
86
+ labelKey: 'label',
87
+ descriptionKey: 'description'
88
+ })
89
+ const slots = defineSlots<DescriptionListSlots<T>>()
90
+
49
91
  const b24ui = computed(() => descriptionList({
50
92
  size: props.size
51
- }));
52
- function normalizeItem(item) {
93
+ }))
94
+
95
+ function normalizeItem(item: any) {
53
96
  if (item === null) {
54
97
  return {
55
- label: void 0,
56
- description: void 0,
57
- orientation: void 0
58
- };
98
+ label: undefined,
99
+ description: undefined,
100
+ orientation: undefined
101
+ }
59
102
  }
60
- const label = get(item, props.labelKey);
61
- const description = get(item, props.descriptionKey);
62
- const orientation = item?.orientation || "vertical";
103
+
104
+ const label = get(item, props.labelKey as string)
105
+ const description = get(item, props.descriptionKey as string)
106
+ const orientation = item?.orientation || 'vertical'
107
+
63
108
  return {
64
109
  ...item,
65
110
  label,
66
111
  description,
67
112
  orientation
68
- };
113
+ }
69
114
  }
115
+
70
116
  const normalizedItems = computed(() => {
71
117
  if (!props.items) {
72
- return [];
118
+ return []
73
119
  }
74
- return props.items.map(normalizeItem);
75
- });
120
+
121
+ return props.items.map(normalizeItem)
122
+ })
76
123
  </script>
77
124
 
78
125
  <template>
@@ -94,49 +141,49 @@ const normalizedItems = computed(() => {
94
141
  :key="index"
95
142
  >
96
143
  <slot
97
- :name="item.slot || 'content'"
98
- :item="item"
144
+ :name="((item.slot || 'content') as keyof DescriptionListSlots<T>)"
145
+ :item="(item as Extract<T, { slot: string; }>)"
99
146
  :index="index"
100
147
  >
101
148
  <dt
102
149
  :class="b24ui.labelWrapper({
103
- class: [
104
- props.b24ui?.labelWrapper,
105
- item?.b24ui?.labelWrapper
106
- ]
107
- })"
150
+ class: [
151
+ props.b24ui?.labelWrapper,
152
+ item?.b24ui?.labelWrapper
153
+ ]
154
+ })"
108
155
  >
109
156
  <slot name="leading" :item="item" :index="index">
110
157
  <Component
111
158
  :is="item.icon"
112
159
  v-if="item.icon"
113
160
  :class="b24ui.icon({
114
- class: [
115
- props.b24ui?.icon,
116
- item?.b24ui?.icon
117
- ]
118
- })"
161
+ class: [
162
+ props.b24ui?.icon,
163
+ item?.b24ui?.icon
164
+ ]
165
+ })"
119
166
  />
120
167
  <B24Avatar
121
168
  v-else-if="item.avatar"
122
- :size="props.b24ui?.avatarSize || b24ui.avatarSize()"
169
+ :size="((props.b24ui?.avatarSize || b24ui.avatarSize()) as AvatarProps['size'])"
123
170
  v-bind="item.avatar"
124
171
  :class="b24ui.avatar({
125
- class: [
126
- props.b24ui?.avatar,
127
- item?.b24ui?.avatar
128
- ]
129
- })"
172
+ class: [
173
+ props.b24ui?.avatar,
174
+ item?.b24ui?.avatar
175
+ ]
176
+ })"
130
177
  />
131
178
  </slot>
132
179
  <span
133
180
  :class="b24ui.label({
134
- class: [
135
- item?.class,
136
- props.b24ui?.label,
137
- item?.b24ui?.label
138
- ]
139
- })"
181
+ class: [
182
+ item?.class,
183
+ props.b24ui?.label,
184
+ item?.b24ui?.label
185
+ ]
186
+ })"
140
187
  >
141
188
  <slot name="label" :item="item" :index="index">
142
189
  {{ item.label }}
@@ -146,22 +193,22 @@ const normalizedItems = computed(() => {
146
193
  <dd
147
194
  :data-orientation="item.orientation"
148
195
  :class="b24ui.descriptionWrapper({
149
- class: [
150
- props.b24ui?.descriptionWrapper,
151
- item?.b24ui?.descriptionWrapper
152
- ],
153
- orientation: item.orientation
154
- })"
196
+ class: [
197
+ props.b24ui?.descriptionWrapper,
198
+ item?.b24ui?.descriptionWrapper
199
+ ],
200
+ orientation: item.orientation
201
+ })"
155
202
  >
156
203
  <span
157
204
  :class="b24ui.description({
158
- class: [
159
- item?.class,
160
- props.b24ui?.description,
161
- item?.b24ui?.description
162
- ],
163
- orientation: item.orientation
164
- })"
205
+ class: [
206
+ item?.class,
207
+ props.b24ui?.description,
208
+ item?.b24ui?.description
209
+ ],
210
+ orientation: item.orientation
211
+ })"
165
212
  >
166
213
  <slot name="description" :item="item" :index="index">
167
214
  {{ item.description }}
@@ -170,12 +217,12 @@ const normalizedItems = computed(() => {
170
217
  <span
171
218
  v-if="item.actions?.length || !!slots.actions"
172
219
  :class="b24ui.actions({
173
- class: [
174
- props.b24ui?.actions,
175
- item?.b24ui?.actions
176
- ],
177
- orientation: item.orientation
178
- })"
220
+ class: [
221
+ props.b24ui?.actions,
222
+ item?.b24ui?.actions
223
+ ],
224
+ orientation: item.orientation
225
+ })"
179
226
  >
180
227
  <slot name="actions" :item="item" :index="index">
181
228
  <B24Button
@@ -1,88 +1,144 @@
1
- <script>
2
- import _appConfig from "#build/app.config";
3
- import theme from "#build/b24ui/dropdown-menu";
4
- import { tv } from "../utils/tv";
5
- const appConfigDropdownMenu = _appConfig;
6
- const dropdownMenu = tv({ extend: tv(theme), ...appConfigDropdownMenu.b24ui?.dropdownMenu || {} });
1
+ <!-- eslint-disable vue/block-tag-newline -->
2
+ <script lang="ts">
3
+ import type { VariantProps } from 'tailwind-variants'
4
+ import type { DropdownMenuRootProps, DropdownMenuRootEmits, DropdownMenuContentProps, DropdownMenuContentEmits, DropdownMenuArrowProps } from 'reka-ui'
5
+ import type { AppConfig } from '@nuxt/schema'
6
+ import _appConfig from '#build/app.config'
7
+ import theme from '#build/b24ui/dropdown-menu'
8
+ import { tv } from '../utils/tv'
9
+ import type { AvatarProps, KbdProps, LinkProps, IconComponent } from '../types'
10
+ import type {
11
+ ArrayOrNested,
12
+ DynamicSlots,
13
+ MergeTypes,
14
+ NestedItem,
15
+ PartialString,
16
+ EmitsToProps
17
+ } from '../types/utils'
18
+
19
+ const appConfigDropdownMenu = _appConfig as AppConfig & { b24ui: { dropdownMenu: Partial<typeof theme> } }
20
+
21
+ const dropdownMenu = tv({ extend: tv(theme), ...(appConfigDropdownMenu.b24ui?.dropdownMenu || {}) })
22
+
23
+ type DropdownMenuVariants = VariantProps<typeof dropdownMenu>
24
+
25
+ export interface DropdownMenuItem extends Omit<LinkProps, 'type' | 'raw' | 'custom'> {
26
+ label?: string
27
+ /**
28
+ * Display an icon on the left side.
29
+ * @IconComponent
30
+ */
31
+ icon?: IconComponent
32
+ color?: DropdownMenuVariants['color']
33
+ avatar?: AvatarProps
34
+ content?: Omit<DropdownMenuContentProps, 'as' | 'asChild' | 'forceMount'> & Partial<EmitsToProps<DropdownMenuContentEmits>>
35
+ kbds?: KbdProps['value'][] | KbdProps[]
36
+ /**
37
+ * The item type.
38
+ * @defaultValue 'link'
39
+ */
40
+ type?: 'label' | 'separator' | 'link' | 'checkbox'
41
+ slot?: string
42
+ loading?: boolean
43
+ disabled?: boolean
44
+ checked?: boolean
45
+ open?: boolean
46
+ defaultOpen?: boolean
47
+ children?: ArrayOrNested<DropdownMenuItem>
48
+ onSelect?(e: Event): void
49
+ onUpdateChecked?(checked: boolean): void
50
+ [key: string]: any
51
+ }
52
+
53
+ export interface DropdownMenuProps<T extends ArrayOrNested<DropdownMenuItem> = ArrayOrNested<DropdownMenuItem>> extends Omit<DropdownMenuRootProps, 'dir'> {
54
+ /**
55
+ * @defaultValue 'md'
56
+ */
57
+ size?: DropdownMenuVariants['size']
58
+ items?: T
59
+ /**
60
+ * The icon displayed when an item is checked.
61
+ * @defaultValue icons.check
62
+ * @IconComponent
63
+ */
64
+ checkedIcon?: IconComponent
65
+ /**
66
+ * The icon displayed when the item is an external link.
67
+ * Set to `false` to hide the external icon.
68
+ * @defaultValue icons.external
69
+ * @IconComponent
70
+ */
71
+ externalIcon?: boolean | IconComponent
72
+ /**
73
+ * The content of the menu.
74
+ * @defaultValue { side: 'bottom', sideOffset: 8, collisionPadding: 8 }
75
+ */
76
+ content?: Omit<DropdownMenuContentProps, 'as' | 'asChild' | 'forceMount'> & Partial<EmitsToProps<DropdownMenuContentEmits>>
77
+ /**
78
+ * Display an arrow alongside the menu.
79
+ * @defaultValue false
80
+ */
81
+ arrow?: boolean | Omit<DropdownMenuArrowProps, 'as' | 'asChild'>
82
+ /**
83
+ * Render the menu in a portal.
84
+ * @defaultValue true
85
+ */
86
+ portal?: boolean
87
+ /**
88
+ * The key used to get the label from the item.
89
+ * @defaultValue 'label'
90
+ */
91
+ labelKey?: keyof NestedItem<T>
92
+ /**
93
+ * @defaultValue false
94
+ */
95
+ disabled?: boolean
96
+ class?: any
97
+ b24ui?: PartialString<typeof dropdownMenu.slots>
98
+ }
99
+
100
+ export interface DropdownMenuEmits extends DropdownMenuRootEmits {}
101
+
102
+ type SlotProps<T extends DropdownMenuItem> = (props: { item: T, active?: boolean, index: number }) => any
103
+
104
+ export type DropdownMenuSlots<
105
+ A extends ArrayOrNested<DropdownMenuItem> = ArrayOrNested<DropdownMenuItem>,
106
+ T extends NestedItem<A> = NestedItem<A>
107
+ > = {
108
+ 'default'(props: { open: boolean }): any
109
+ 'item': SlotProps<T>
110
+ 'item-leading': SlotProps<T>
111
+ 'item-label': SlotProps<T>
112
+ 'item-trailing': SlotProps<T>
113
+ } & DynamicSlots<MergeTypes<T>, 'leading' | 'label' | 'trailing', { active?: boolean, index: number }>
114
+
7
115
  </script>
8
116
 
9
- <script setup>
10
- import { computed, toRef } from "vue";
11
- import { defu } from "defu";
12
- import { useForwardPropsEmits } from "reka-ui";
13
- import { reactivePick } from "@vueuse/core";
14
- import { omit } from "../utils";
15
- const props = defineProps({
16
- size: {
17
- type: null,
18
- required: false
19
- },
20
- items: {
21
- type: null,
22
- required: false
23
- },
24
- checkedIcon: {
25
- type: [Function, Object],
26
- required: false
27
- },
28
- externalIcon: {
29
- type: [Boolean, Function, Object],
30
- required: false,
31
- default: true
32
- },
33
- content: {
34
- type: Object,
35
- required: false
36
- },
37
- arrow: {
38
- type: [Boolean, Object],
39
- required: false
40
- },
41
- portal: {
42
- type: Boolean,
43
- required: false,
44
- default: true
45
- },
46
- labelKey: {
47
- type: null,
48
- required: false,
49
- default: "label"
50
- },
51
- disabled: {
52
- type: Boolean,
53
- required: false
54
- },
55
- class: {
56
- type: null,
57
- required: false
58
- },
59
- b24ui: {
60
- type: null,
61
- required: false
62
- },
63
- defaultOpen: {
64
- type: Boolean,
65
- required: false
66
- },
67
- open: {
68
- type: Boolean,
69
- required: false
70
- },
71
- modal: {
72
- type: Boolean,
73
- required: false,
74
- default: true
75
- }
76
- });
77
- const emits = defineEmits(["update:open"]);
78
- const slots = defineSlots();
79
- const rootProps = useForwardPropsEmits(reactivePick(props, "defaultOpen", "open", "modal"), emits);
80
- const contentProps = toRef(() => defu(props.content, { side: "bottom", sideOffset: 8, collisionPadding: 8 }));
81
- const arrowProps = toRef(() => props.arrow);
82
- const proxySlots = omit(slots, ["default"]);
117
+ <script setup lang="ts" generic="T extends ArrayOrNested<DropdownMenuItem>">
118
+ import { computed, toRef } from 'vue'
119
+ import { defu } from 'defu'
120
+ import { DropdownMenuRoot, DropdownMenuTrigger, DropdownMenuArrow, useForwardPropsEmits } from 'reka-ui'
121
+ import { reactivePick } from '@vueuse/core'
122
+ import { omit } from '../utils'
123
+ import B24DropdownMenuContent from './DropdownMenuContent.vue'
124
+
125
+ const props = withDefaults(defineProps<DropdownMenuProps<T>>(), {
126
+ portal: true,
127
+ modal: true,
128
+ externalIcon: true,
129
+ labelKey: 'label'
130
+ })
131
+ const emits = defineEmits<DropdownMenuEmits>()
132
+ const slots = defineSlots<DropdownMenuSlots<T>>()
133
+
134
+ const rootProps = useForwardPropsEmits(reactivePick(props, 'defaultOpen', 'open', 'modal'), emits)
135
+ const contentProps = toRef(() => defu(props.content, { side: 'bottom', sideOffset: 8, collisionPadding: 8 }) as DropdownMenuContentProps)
136
+ const arrowProps = toRef(() => props.arrow as DropdownMenuArrowProps)
137
+ const proxySlots = omit(slots, ['default'])
138
+
83
139
  const b24ui = computed(() => dropdownMenu({
84
140
  size: props.size
85
- }));
141
+ }))
86
142
  </script>
87
143
 
88
144
  <template>
@@ -98,12 +154,12 @@ const b24ui = computed(() => dropdownMenu({
98
154
  v-bind="contentProps"
99
155
  :items="items"
100
156
  :portal="portal"
101
- :label-key="labelKey"
157
+ :label-key="(labelKey as keyof NestedItem<T>)"
102
158
  :checked-icon="checkedIcon"
103
159
  :external-icon="externalIcon"
104
160
  >
105
161
  <template v-for="(_, name) in proxySlots" #[name]="slotData">
106
- <slot :name="name" v-bind="slotData" />
162
+ <slot :name="(name as keyof DropdownMenuSlots<T>)" v-bind="slotData" />
107
163
  </template>
108
164
 
109
165
  <DropdownMenuArrow v-if="!!arrow" v-bind="arrowProps" :class="b24ui.arrow({ class: props.b24ui?.arrow })" />