@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,122 +1,176 @@
1
- <script>
2
- import _appConfig from "#build/app.config";
3
- import theme from "#build/b24ui/navigation-menu";
4
- import { tv } from "../utils/tv";
5
- const appConfigNavigationMenu = _appConfig;
6
- const navigationMenu = tv({ extend: tv(theme), ...appConfigNavigationMenu.b24ui?.navigationMenu || {} });
1
+ <!-- eslint-disable vue/block-tag-newline -->
2
+ <script lang="ts">
3
+ import type { VariantProps } from 'tailwind-variants'
4
+ import type { NavigationMenuRootProps, NavigationMenuRootEmits, NavigationMenuContentProps, NavigationMenuContentEmits, CollapsibleRootProps } from 'reka-ui'
5
+ import type { AppConfig } from '@nuxt/schema'
6
+ import _appConfig from '#build/app.config'
7
+ import theme from '#build/b24ui/navigation-menu'
8
+ import { tv } from '../utils/tv'
9
+ import type { AvatarProps, BadgeProps, 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 appConfigNavigationMenu = _appConfig as AppConfig & { b24ui: { navigationMenu: Partial<typeof theme> } }
20
+
21
+ const navigationMenu = tv({ extend: tv(theme), ...(appConfigNavigationMenu.b24ui?.navigationMenu || {}) })
22
+
23
+ export interface NavigationMenuChildItem extends Omit<NavigationMenuItem, 'type'> {
24
+ /** Description is only used when `orientation` is `horizontal`. */
25
+ description?: string
26
+ [key: string]: any
27
+ }
28
+
29
+ export interface NavigationMenuItem extends Omit<LinkProps, 'type' | 'raw' | 'custom'>, Pick<CollapsibleRootProps, 'defaultOpen' | 'open'> {
30
+ label?: string
31
+ /**
32
+ * @IconComponent
33
+ */
34
+ icon?: IconComponent
35
+ avatar?: AvatarProps
36
+ /**
37
+ * Display a badge on the item.
38
+ * `{ size: 'sm', color: 'neutral', variant: 'outline' }`{lang="ts-type"}
39
+ */
40
+ badge?: string | number | BadgeProps
41
+ /**
42
+ * @IconComponent
43
+ */
44
+ trailingIcon?: IconComponent
45
+ /**
46
+ * The type of the item.
47
+ * The `label` type only works on `vertical` orientation.
48
+ * @defaultValue 'link'
49
+ */
50
+ type?: 'label' | 'link'
51
+ slot?: string
52
+ value?: string
53
+ children?: NavigationMenuChildItem[]
54
+ /**
55
+ * With orientation=`horizontal` if `true` it will position the dropdown menu correctly
56
+ */
57
+ viewportRtl?: boolean
58
+ onSelect?(e: Event): void
59
+ [key: string]: any
60
+ }
61
+
62
+ type NavigationMenuVariants = VariantProps<typeof navigationMenu>
63
+
64
+ export interface NavigationMenuProps<T extends ArrayOrNested<NavigationMenuItem> = ArrayOrNested<NavigationMenuItem>> extends Pick<NavigationMenuRootProps, 'modelValue' | 'defaultValue' | 'delayDuration' | 'disableClickTrigger' | 'disableHoverTrigger' | 'skipDelayDuration' | 'disablePointerLeaveClose' | 'unmountOnHide'> {
65
+ /**
66
+ * The element or component this component should render as.
67
+ * @defaultValue 'div'
68
+ */
69
+ as?: any
70
+ /**
71
+ * The icon displayed to open the menu.
72
+ * @defaultValue icons.chevronDown
73
+ * @IconComponent
74
+ */
75
+ trailingIcon?: IconComponent
76
+ /**
77
+ * The icon displayed when the item is an external link.
78
+ * Set to `false` to hide the external icon.
79
+ * @defaultValue icons.external
80
+ * @IconComponent
81
+ */
82
+ externalIcon?: boolean | IconComponent
83
+ items?: T
84
+ /**
85
+ * @defaultValue 'primary'
86
+ */
87
+ color?: NavigationMenuVariants['color']
88
+ /**
89
+ * @defaultValue 'pill'
90
+ */
91
+ variant?: NavigationMenuVariants['variant']
92
+ /**
93
+ * The orientation of the menu.
94
+ * @defaultValue 'horizontal'
95
+ */
96
+ orientation?: NavigationMenuRootProps['orientation']
97
+ /**
98
+ * Collapse the navigation menu to only show icons.
99
+ * Only works when `orientation` is `vertical`.
100
+ * @defaultValue false
101
+ */
102
+ collapsed?: boolean
103
+ /** Display a line next to the active item. */
104
+ highlight?: boolean
105
+ /**
106
+ * @defaultValue 'primary'
107
+ */
108
+ highlightColor?: NavigationMenuVariants['highlightColor']
109
+ /**
110
+ * The content of the menu.
111
+ */
112
+ content?: Omit<NavigationMenuContentProps, 'as' | 'asChild' | 'forceMount'> & Partial<EmitsToProps<NavigationMenuContentEmits>>
113
+ /**
114
+ * The orientation of the content.
115
+ * Only works when `orientation` is `horizontal`.
116
+ * @defaultValue 'vertical'
117
+ */
118
+ contentOrientation?: NavigationMenuVariants['contentOrientation']
119
+ /**
120
+ * Display an arrow alongside the menu.
121
+ * @defaultValue false
122
+ */
123
+ arrow?: boolean
124
+ /**
125
+ * The key used to get the label from the item.
126
+ * @defaultValue 'label'
127
+ */
128
+ labelKey?: keyof NestedItem<T>
129
+ class?: any
130
+ b24ui?: PartialString<typeof navigationMenu.slots>
131
+ }
132
+
133
+ export interface NavigationMenuEmits extends NavigationMenuRootEmits {}
134
+
135
+ type SlotProps<T extends NavigationMenuItem> = (props: { item: T, index: number, active?: boolean }) => any
136
+
137
+ export type NavigationMenuSlots<
138
+ A extends ArrayOrNested<NavigationMenuItem> = ArrayOrNested<NavigationMenuItem>,
139
+ T extends NestedItem<A> = NestedItem<A>
140
+ > = {
141
+ 'item': SlotProps<T>
142
+ 'item-leading': SlotProps<T>
143
+ 'item-label': SlotProps<T>
144
+ 'item-trailing': SlotProps<T>
145
+ 'item-content': SlotProps<T>
146
+ } & DynamicSlots<MergeTypes<T>, 'leading' | 'label' | 'trailing' | 'content', { index: number, active?: boolean }>
147
+
7
148
  </script>
8
149
 
9
- <script setup>
10
- import { computed, toRef } from "vue";
11
- import { useForwardPropsEmits } from "reka-ui";
12
- import { createReusableTemplate } from "@vueuse/core";
13
- import { isArrayOfArray } from "../utils";
14
- const props = defineProps({
15
- as: {
16
- type: null,
17
- required: false
18
- },
19
- trailingIcon: {
20
- type: [Function, Object],
21
- required: false
22
- },
23
- externalIcon: {
24
- type: [Boolean, Function, Object],
25
- required: false,
26
- default: true
27
- },
28
- items: {
29
- type: null,
30
- required: false
31
- },
32
- color: {
33
- type: null,
34
- required: false
35
- },
36
- variant: {
37
- type: null,
38
- required: false
39
- },
40
- orientation: {
41
- type: null,
42
- required: false,
43
- default: "horizontal"
44
- },
45
- collapsed: {
46
- type: Boolean,
47
- required: false
48
- },
49
- highlight: {
50
- type: Boolean,
51
- required: false
52
- },
53
- highlightColor: {
54
- type: null,
55
- required: false
56
- },
57
- content: {
58
- type: Object,
59
- required: false
60
- },
61
- contentOrientation: {
62
- type: null,
63
- required: false,
64
- default: "vertical"
65
- },
66
- arrow: {
67
- type: Boolean,
68
- required: false
69
- },
70
- labelKey: {
71
- type: null,
72
- required: false,
73
- default: "label"
74
- },
75
- class: {
76
- type: null,
77
- required: false
78
- },
79
- b24ui: {
80
- type: null,
81
- required: false
82
- },
83
- modelValue: {
84
- type: String,
85
- required: false
86
- },
87
- defaultValue: {
88
- type: String,
89
- required: false
90
- },
91
- delayDuration: {
92
- type: Number,
93
- required: false,
94
- default: 0
95
- },
96
- disableClickTrigger: {
97
- type: Boolean,
98
- required: false
99
- },
100
- disableHoverTrigger: {
101
- type: Boolean,
102
- required: false
103
- },
104
- skipDelayDuration: {
105
- type: Number,
106
- required: false
107
- },
108
- disablePointerLeaveClose: {
109
- type: Boolean,
110
- required: false
111
- },
112
- unmountOnHide: {
113
- type: Boolean,
114
- required: false,
115
- default: true
116
- }
117
- });
118
- const emits = defineEmits(["update:modelValue"]);
119
- const slots = defineSlots();
150
+ <script setup lang="ts" generic="T extends ArrayOrNested<NavigationMenuItem>">
151
+ import { computed, toRef } from 'vue'
152
+ import { NavigationMenuRoot, NavigationMenuList, NavigationMenuItem, NavigationMenuTrigger, NavigationMenuContent, NavigationMenuLink, NavigationMenuIndicator, NavigationMenuViewport, useForwardPropsEmits } from 'reka-ui'
153
+ import { createReusableTemplate } from '@vueuse/core'
154
+ import { get, isArrayOfArray } from '../utils'
155
+ import { pickLinkProps } from '../utils/link'
156
+ import icons from '../dictionary/icons'
157
+ import B24LinkBase from './LinkBase.vue'
158
+ import B24Link from './Link.vue'
159
+ import B24Avatar from './Avatar.vue'
160
+ import B24Badge from './Badge.vue'
161
+ import B24Collapsible from './Collapsible.vue'
162
+
163
+ const props = withDefaults(defineProps<NavigationMenuProps<T>>(), {
164
+ orientation: 'horizontal',
165
+ contentOrientation: 'vertical',
166
+ externalIcon: true,
167
+ delayDuration: 0,
168
+ unmountOnHide: true,
169
+ labelKey: 'label'
170
+ })
171
+ const emits = defineEmits<NavigationMenuEmits>()
172
+ const slots = defineSlots<NavigationMenuSlots<T>>()
173
+
120
174
  const rootProps = useForwardPropsEmits(computed(() => ({
121
175
  as: props.as,
122
176
  modelValue: props.modelValue,
@@ -128,10 +182,12 @@ const rootProps = useForwardPropsEmits(computed(() => ({
128
182
  disableHoverTrigger: props.disableHoverTrigger,
129
183
  disablePointerLeaveClose: props.disablePointerLeaveClose,
130
184
  unmountOnHide: props.unmountOnHide
131
- })), emits);
132
- const contentProps = toRef(() => props.content);
133
- const [DefineLinkTemplate, ReuseLinkTemplate] = createReusableTemplate();
134
- const [DefineItemTemplate, ReuseItemTemplate] = createReusableTemplate({
185
+ })), emits)
186
+
187
+ const contentProps = toRef(() => props.content)
188
+
189
+ const [DefineLinkTemplate, ReuseLinkTemplate] = createReusableTemplate<{ item: NavigationMenuItem, index: number, active?: boolean }>()
190
+ const [DefineItemTemplate, ReuseItemTemplate] = createReusableTemplate<{ item: NavigationMenuItem, index: number, level?: number }>({
135
191
  props: {
136
192
  item: Object,
137
193
  index: Number,
@@ -141,7 +197,12 @@ const [DefineItemTemplate, ReuseItemTemplate] = createReusableTemplate({
141
197
  default: 0
142
198
  }
143
199
  }
144
- });
200
+ })
201
+
202
+ const getLabel = (item: NavigationMenuItem) => {
203
+ return get(item, props.labelKey as string)
204
+ }
205
+
145
206
  const b24ui = computed(() => navigationMenu({
146
207
  orientation: props.orientation,
147
208
  contentOrientation: props.contentOrientation,
@@ -150,31 +211,36 @@ const b24ui = computed(() => navigationMenu({
150
211
  variant: props.variant,
151
212
  highlight: props.highlight,
152
213
  highlightColor: props.highlightColor || props.color
153
- }));
154
- const lists = computed(
155
- () => props.items?.length ? isArrayOfArray(props.items) ? props.items : [props.items] : []
156
- );
214
+ }))
215
+
216
+ const lists = computed<NavigationMenuItem[][]>(() =>
217
+ props.items?.length
218
+ ? isArrayOfArray(props.items)
219
+ ? props.items
220
+ : [props.items]
221
+ : []
222
+ )
157
223
  </script>
158
224
 
159
225
  <template>
160
226
  <DefineLinkTemplate v-slot="{ item, active, index }">
161
- <slot :name="item.slot || 'item'" :item="item" :index="index">
227
+ <slot :name="((item.slot || 'item') as keyof NavigationMenuSlots<T>)" :item="item" :index="index">
162
228
  <span :class="b24ui.linkLabelWrapper({ class: props.b24ui?.linkLabelWrapper, active })">
163
- <slot :name="item.slot ? `${item.slot}-leading` : 'item-leading'" :item="item" :active="active" :index="index">
229
+ <slot :name="((item.slot ? `${item.slot}-leading` : 'item-leading') as keyof NavigationMenuSlots<T>)" :item="item" :active="active" :index="index">
164
230
  <Component
165
231
  :is="item.icon"
166
232
  v-if="item.icon"
167
233
  :class="b24ui.linkLeadingIcon({ class: props.b24ui?.linkLeadingIcon, active, disabled: !!item.disabled })"
168
234
  />
169
- <B24Avatar v-else-if="item.avatar" :size="props.b24ui?.linkLeadingAvatarSize || b24ui.linkLeadingAvatarSize()" v-bind="item.avatar" :class="b24ui.linkLeadingAvatar({ class: props.b24ui?.linkLeadingAvatar, active, disabled: !!item.disabled })" />
235
+ <B24Avatar v-else-if="item.avatar" :size="((props.b24ui?.linkLeadingAvatarSize || b24ui.linkLeadingAvatarSize()) as AvatarProps['size'])" v-bind="item.avatar" :class="b24ui.linkLeadingAvatar({ class: props.b24ui?.linkLeadingAvatar, active, disabled: !!item.disabled })" />
170
236
  </slot>
171
237
 
172
238
  <span
173
- v-if="(!collapsed || orientation !== 'vertical') && (get(item, props.labelKey) || !!slots[item.slot ? `${item.slot}-label` : 'item-label'])"
239
+ v-if="(!collapsed || orientation !== 'vertical') && (getLabel(item) || !!slots[(item.slot ? `${item.slot}-label` : 'item-label') as keyof NavigationMenuSlots<T>])"
174
240
  :class="b24ui.linkLabel({ class: props.b24ui?.linkLabel, active })"
175
241
  >
176
- <slot :name="item.slot ? `${item.slot}-label` : 'item-label'" :item="item" :active="active" :index="index">
177
- {{ get(item, props.labelKey) }}
242
+ <slot :name="((item.slot ? `${item.slot}-label` : 'item-label') as keyof NavigationMenuSlots<T>)" :item="item" :active="active" :index="index">
243
+ {{ getLabel(item) }}
178
244
  </slot>
179
245
 
180
246
  <Component
@@ -184,11 +250,11 @@ const lists = computed(
184
250
  />
185
251
  </span>
186
252
  </span>
187
- <span v-if="(!collapsed || orientation !== 'vertical') && (item.badge || orientation === 'horizontal' && (item.children?.length || !!slots[item.slot ? `${item.slot}-content` : 'item-content']) || orientation === 'vertical' && item.children?.length || item.trailingIcon || !!slots[item.slot ? `${item.slot}-trailing` : 'item-trailing'])" :class="b24ui.linkTrailing({ class: props.b24ui?.linkTrailing })">
188
- <slot :name="item.slot ? `${item.slot}-trailing` : 'item-trailing'" :item="item" :active="active" :index="index">
253
+ <span v-if="(!collapsed || orientation !== 'vertical') && (item.badge || (orientation === 'horizontal' && (item.children?.length || !!slots[(item.slot ? `${item.slot}-content` : 'item-content') as keyof NavigationMenuSlots<T>])) || (orientation === 'vertical' && item.children?.length) || item.trailingIcon || !!slots[(item.slot ? `${item.slot}-trailing` : 'item-trailing') as keyof NavigationMenuSlots<T>])" :class="b24ui.linkTrailing({ class: props.b24ui?.linkTrailing })">
254
+ <slot :name="((item.slot ? `${item.slot}-trailing` : 'item-trailing') as keyof NavigationMenuSlots<T>)" :item="item" :active="active" :index="index">
189
255
  <Component
190
256
  :is="item.trailingIcon || trailingIcon || icons.chevronDown"
191
- v-if="orientation === 'horizontal' && (item.children?.length || !!slots[item.slot ? `${item.slot}-content` : 'item-content']) || orientation === 'vertical' && item.children?.length"
257
+ v-if="(orientation === 'horizontal' && (item.children?.length || !!slots[(item.slot ? `${item.slot}-content` : 'item-content') as keyof NavigationMenuSlots<T>])) || (orientation === 'vertical' && item.children?.length)"
192
258
  :class="b24ui.linkTrailingIcon({ class: props.b24ui?.linkTrailingIcon, active })"
193
259
  />
194
260
  <Component
@@ -202,8 +268,8 @@ const lists = computed(
202
268
  color="danger"
203
269
  depth="dark"
204
270
  :use-fill="true"
205
- :size="props.b24ui?.linkTrailingBadgeSize || b24ui.linkTrailingBadgeSize()"
206
- v-bind="typeof item.badge === 'string' || typeof item.badge === 'number' ? { label: item.badge } : item.badge"
271
+ :size="((props.b24ui?.linkTrailingBadgeSize || b24ui.linkTrailingBadgeSize()) as BadgeProps['size'])"
272
+ v-bind="(typeof item.badge === 'string' || typeof item.badge === 'number') ? { label: item.badge } : item.badge"
207
273
  :class="b24ui.linkTrailingBadge({ class: props.b24ui?.linkTrailingBadge })"
208
274
  />
209
275
  </slot>
@@ -213,19 +279,19 @@ const lists = computed(
213
279
 
214
280
  <DefineItemTemplate v-slot="{ item, index, level }">
215
281
  <component
216
- :is="orientation === 'vertical' && item.children?.length && !collapsed ? B24Collapsible : NavigationMenuItem"
282
+ :is="(orientation === 'vertical' && item.children?.length && !collapsed) ? B24Collapsible : NavigationMenuItem"
217
283
  as="li"
218
284
  :value="item.value || String(index)"
219
285
  :default-open="item.defaultOpen"
220
- :unmount-on-hide="orientation === 'vertical' && item.children?.length && !collapsed ? unmountOnHide : void 0"
286
+ :unmount-on-hide="(orientation === 'vertical' && item.children?.length && !collapsed) ? unmountOnHide : undefined"
221
287
  :open="item.open"
222
288
  >
223
289
  <div v-if="orientation === 'vertical' && item.type === 'label'" :class="b24ui.label({ class: props.b24ui?.label })">
224
290
  <ReuseLinkTemplate :item="item" :index="index" />
225
291
  </div>
226
- <B24Link v-else-if="item.type !== 'label'" v-slot="{ active, ...slotProps }" v-bind="orientation === 'vertical' && item.children?.length && !collapsed ? {} : pickLinkProps(item)" custom>
292
+ <B24Link v-else-if="item.type !== 'label'" v-slot="{ active, ...slotProps }" v-bind="(orientation === 'vertical' && item.children?.length && !collapsed) ? {} : pickLinkProps(item as Omit<NavigationMenuItem, 'type'>)" custom>
227
293
  <component
228
- :is="orientation === 'horizontal' && (item.children?.length || !!slots[item.slot ? `${item.slot}-content` : 'item-content']) ? NavigationMenuTrigger : NavigationMenuLink"
294
+ :is="(orientation === 'horizontal' && (item.children?.length || !!slots[(item.slot ? `${item.slot}-content` : 'item-content') as keyof NavigationMenuSlots<T>])) ? NavigationMenuTrigger : NavigationMenuLink"
229
295
  as-child
230
296
  :active="active || item.active"
231
297
  :disabled="item.disabled"
@@ -237,12 +303,12 @@ const lists = computed(
237
303
  </component>
238
304
 
239
305
  <NavigationMenuContent
240
- v-if="orientation === 'horizontal' && (item.children?.length || !!slots[item.slot ? `${item.slot}-content` : 'item-content'])"
306
+ v-if="orientation === 'horizontal' && (item.children?.length || !!slots[(item.slot ? `${item.slot}-content` : 'item-content') as keyof NavigationMenuSlots<T>])"
241
307
  v-bind="contentProps"
242
308
  :data-viewport="item.viewportRtl ? 'rtl' : 'ltr'"
243
309
  :class="b24ui.content({ class: props.b24ui?.content })"
244
310
  >
245
- <slot :name="item.slot ? `${item.slot}-content` : 'item-content'" :item="item" :active="active" :index="index">
311
+ <slot :name="((item.slot ? `${item.slot}-content` : 'item-content') as keyof NavigationMenuSlots<T>)" :item="item" :active="active" :index="index">
246
312
  <ul :class="b24ui.childList({ class: props.b24ui?.childList })">
247
313
  <li v-for="(childItem, childIndex) in item.children" :key="childIndex" :class="b24ui.childItem({ class: props.b24ui?.childItem })">
248
314
  <B24Link v-slot="{ active: childActive, ...childSlotProps }" v-bind="pickLinkProps(childItem)" custom>
@@ -256,7 +322,7 @@ const lists = computed(
256
322
 
257
323
  <div :class="b24ui.childLinkWrapper({ class: props.b24ui?.childLinkWrapper })">
258
324
  <p :class="b24ui.childLinkLabel({ class: props.b24ui?.childLinkLabel, active: childActive })">
259
- {{ get(childItem, props.labelKey) }}
325
+ {{ getLabel(childItem) }}
260
326
 
261
327
  <Component
262
328
  :is="typeof externalIcon === 'string' ? externalIcon : icons.external"
@@ -1,15 +1,19 @@
1
- <script setup>
2
- import { computed } from "vue";
3
- import { useOverlay } from "../composables/useOverlay";
4
- const { overlays, unMount, close } = useOverlay();
5
- const mountedOverlays = computed(() => overlays.filter((overlay) => overlay.isMounted));
6
- const onAfterLeave = (id) => {
7
- close(id);
8
- unMount(id);
9
- };
10
- const onClose = (id, value) => {
11
- close(id, value);
12
- };
1
+ <script setup lang="ts">
2
+ import { computed } from 'vue'
3
+ import { useOverlay, type Overlay } from '../composables/useOverlay'
4
+
5
+ const { overlays, unMount, close } = useOverlay()
6
+
7
+ const mountedOverlays = computed(() => overlays.filter((overlay: Overlay) => overlay.isMounted))
8
+
9
+ const onAfterLeave = (id: symbol) => {
10
+ close(id)
11
+ unMount(id)
12
+ }
13
+
14
+ const onClose = (id: symbol, value: any) => {
15
+ close(id, value)
16
+ }
13
17
  </script>
14
18
 
15
19
  <template>
@@ -19,7 +23,7 @@ const onClose = (id, value) => {
19
23
  :key="overlay.id"
20
24
  v-bind="overlay.props"
21
25
  v-model:open="overlay.modelValue"
22
- @close="(value) => onClose(overlay.id, value)"
26
+ @close="(value:any) => onClose(overlay.id, value)"
23
27
  @after:leave="onAfterLeave(overlay.id)"
24
28
  />
25
29
  </template>
@@ -1,92 +1,92 @@
1
- <script>
2
- import _appConfig from "#build/app.config";
3
- import theme from "#build/b24ui/popover";
4
- import { tv } from "../utils/tv";
5
- const appConfigPopover = _appConfig;
6
- const popover = tv({ extend: tv(theme), ...appConfigPopover.b24ui?.popover || {} });
1
+ <script lang="ts">
2
+ import type { PopoverRootProps, HoverCardRootProps, PopoverRootEmits, PopoverContentProps, PopoverContentEmits, PopoverArrowProps } from 'reka-ui'
3
+ import type { AppConfig } from '@nuxt/schema'
4
+ import _appConfig from '#build/app.config'
5
+ import theme from '#build/b24ui/popover'
6
+ import { tv } from '../utils/tv'
7
+ import type { EmitsToProps } from '../types/utils'
8
+
9
+ const appConfigPopover = _appConfig as AppConfig & { b24ui: { popover: Partial<typeof theme> } }
10
+
11
+ const popover = tv({ extend: tv(theme), ...(appConfigPopover.b24ui?.popover || {}) })
12
+
13
+ export interface PopoverProps extends PopoverRootProps, Pick<HoverCardRootProps, 'openDelay' | 'closeDelay'> {
14
+ /**
15
+ * The display mode of the popover.
16
+ * @defaultValue 'click'
17
+ */
18
+ mode?: 'click' | 'hover'
19
+ /**
20
+ * The content of the popover.
21
+ * @defaultValue { side: 'bottom', sideOffset: 8, collisionPadding: 8 }
22
+ */
23
+ content?: Omit<PopoverContentProps, 'as' | 'asChild' | 'forceMount'> & Partial<EmitsToProps<PopoverContentEmits>>
24
+ /**
25
+ * Display an arrow alongside the popover.
26
+ * @defaultValue false
27
+ */
28
+ arrow?: boolean | Omit<PopoverArrowProps, 'as' | 'asChild'>
29
+ /**
30
+ * Render the popover in a portal.
31
+ * @defaultValue true
32
+ */
33
+ portal?: boolean
34
+ /**
35
+ * When `false`, the popover will not close when clicking outside or pressing escape.
36
+ * @defaultValue true
37
+ */
38
+ dismissible?: boolean
39
+ class?: any
40
+ b24ui?: Partial<typeof popover.slots>
41
+ }
42
+
43
+ export interface PopoverEmits extends PopoverRootEmits {}
44
+
45
+ export interface PopoverSlots {
46
+ default(props: { open: boolean }): any
47
+ content(props?: {}): any
48
+ }
7
49
  </script>
8
50
 
9
- <script setup>
10
- import { computed, toRef } from "vue";
11
- import { defu } from "defu";
12
- import { useForwardPropsEmits } from "reka-ui";
13
- import { Popover, HoverCard } from "reka-ui/namespaced";
14
- import { reactivePick } from "@vueuse/core";
15
- const props = defineProps({
16
- mode: {
17
- type: String,
18
- required: false,
19
- default: "click"
20
- },
21
- content: {
22
- type: Object,
23
- required: false
24
- },
25
- arrow: {
26
- type: [Boolean, Object],
27
- required: false
28
- },
29
- portal: {
30
- type: Boolean,
31
- required: false,
32
- default: true
33
- },
34
- dismissible: {
35
- type: Boolean,
36
- required: false,
37
- default: true
38
- },
39
- class: {
40
- type: null,
41
- required: false
42
- },
43
- b24ui: {
44
- type: Object,
45
- required: false
46
- },
47
- defaultOpen: {
48
- type: Boolean,
49
- required: false
50
- },
51
- open: {
52
- type: Boolean,
53
- required: false
54
- },
55
- modal: {
56
- type: Boolean,
57
- required: false
58
- },
59
- openDelay: {
60
- type: Number,
61
- required: false,
62
- default: 0
63
- },
64
- closeDelay: {
65
- type: Number,
66
- required: false,
67
- default: 0
68
- }
69
- });
70
- const emits = defineEmits(["update:open"]);
71
- const slots = defineSlots();
72
- const pick = props.mode === "hover" ? reactivePick(props, "defaultOpen", "open", "openDelay", "closeDelay") : reactivePick(props, "defaultOpen", "open", "modal");
73
- const rootProps = useForwardPropsEmits(pick, emits);
74
- const contentProps = toRef(() => defu(props.content, { side: "bottom", sideOffset: 8, collisionPadding: 8 }));
51
+ <script setup lang="ts">
52
+ import { computed, toRef } from 'vue'
53
+ import { defu } from 'defu'
54
+ import { useForwardPropsEmits } from 'reka-ui'
55
+ import { Popover, HoverCard } from 'reka-ui/namespaced'
56
+ import { reactivePick } from '@vueuse/core'
57
+
58
+ const props = withDefaults(defineProps<PopoverProps>(), {
59
+ portal: true,
60
+ mode: 'click',
61
+ openDelay: 0,
62
+ closeDelay: 0,
63
+ dismissible: true
64
+ })
65
+ const emits = defineEmits<PopoverEmits>()
66
+ const slots = defineSlots<PopoverSlots>()
67
+
68
+ const pick = props.mode === 'hover' ? reactivePick(props, 'defaultOpen', 'open', 'openDelay', 'closeDelay') : reactivePick(props, 'defaultOpen', 'open', 'modal')
69
+ const rootProps = useForwardPropsEmits(pick, emits)
70
+ const contentProps = toRef(() => defu(props.content, { side: 'bottom', sideOffset: 8, collisionPadding: 8 }) as PopoverContentProps)
75
71
  const contentEvents = computed(() => {
76
72
  if (!props.dismissible) {
77
73
  return {
78
- pointerDownOutside: (e) => e.preventDefault(),
79
- interactOutside: (e) => e.preventDefault(),
80
- escapeKeyDown: (e) => e.preventDefault()
81
- };
74
+ pointerDownOutside: (e: Event) => e.preventDefault(),
75
+ interactOutside: (e: Event) => e.preventDefault(),
76
+ escapeKeyDown: (e: Event) => e.preventDefault()
77
+ }
82
78
  }
83
- return {};
84
- });
85
- const arrowProps = toRef(() => props.arrow);
79
+
80
+ return {}
81
+ })
82
+ const arrowProps = toRef(() => props.arrow as PopoverArrowProps)
83
+
84
+ // eslint-disable-next-line vue/no-dupe-keys
86
85
  const b24ui = computed(() => popover({
87
86
  side: contentProps.value.side
88
- }));
89
- const Component = computed(() => props.mode === "hover" ? HoverCard : Popover);
87
+ }))
88
+
89
+ const Component = computed(() => props.mode === 'hover' ? HoverCard : Popover)
90
90
  </script>
91
91
 
92
92
  <template>