@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.
- package/dist/meta.cjs +72112 -0
- package/dist/meta.d.cts +72110 -0
- package/dist/meta.d.mts +5060 -5060
- package/dist/meta.d.ts +72110 -0
- package/dist/meta.mjs +5060 -5060
- package/dist/module.cjs +63 -0
- package/dist/module.d.cts +15 -0
- package/dist/module.d.ts +15 -0
- package/dist/module.json +3 -3
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/Advice.vue +54 -47
- package/dist/runtime/components/Alert.vue +96 -71
- package/dist/runtime/components/App.vue +34 -37
- package/dist/runtime/components/Avatar.vue +81 -69
- package/dist/runtime/components/AvatarGroup.vue +76 -53
- package/dist/runtime/components/Badge.vue +83 -83
- package/dist/runtime/components/Button.vue +157 -220
- package/dist/runtime/components/ButtonGroup.vue +51 -35
- package/dist/runtime/components/Calendar.vue +152 -186
- package/dist/runtime/components/Checkbox.vue +73 -84
- package/dist/runtime/components/Chip.vue +74 -59
- package/dist/runtime/components/Collapsible.vue +41 -44
- package/dist/runtime/components/Container.vue +27 -18
- package/dist/runtime/components/Countdown.vue +378 -198
- package/dist/runtime/components/DescriptionList.vue +149 -102
- package/dist/runtime/components/DropdownMenu.vue +139 -83
- package/dist/runtime/components/DropdownMenuContent.vue +84 -137
- package/dist/runtime/components/Form.vue +216 -162
- package/dist/runtime/components/FormField.vue +80 -76
- package/dist/runtime/components/Input.vue +179 -160
- package/dist/runtime/components/InputMenu.vue +380 -300
- package/dist/runtime/components/InputNumber.vue +175 -178
- package/dist/runtime/components/Kbd.vue +45 -33
- package/dist/runtime/components/Link.vue +173 -179
- package/dist/runtime/components/LinkBase.vue +42 -64
- package/dist/runtime/components/Modal.vue +127 -105
- package/dist/runtime/components/ModalDialogClose.vue +8 -4
- package/dist/runtime/components/Navbar.vue +33 -24
- package/dist/runtime/components/NavbarDivider.vue +33 -24
- package/dist/runtime/components/NavbarSection.vue +33 -24
- package/dist/runtime/components/NavbarSpacer.vue +33 -24
- package/dist/runtime/components/NavigationMenu.vue +210 -144
- package/dist/runtime/components/OverlayProvider.vue +17 -13
- package/dist/runtime/components/Popover.vue +81 -81
- package/dist/runtime/components/Progress.vue +136 -109
- package/dist/runtime/components/RadioGroup.vue +134 -120
- package/dist/runtime/components/Range.vue +85 -94
- package/dist/runtime/components/Select.vue +260 -212
- package/dist/runtime/components/SelectMenu.vue +365 -272
- package/dist/runtime/components/Separator.vue +71 -61
- package/dist/runtime/components/Sidebar.vue +33 -24
- package/dist/runtime/components/SidebarBody.vue +38 -30
- package/dist/runtime/components/SidebarFooter.vue +33 -24
- package/dist/runtime/components/SidebarHeader.vue +33 -24
- package/dist/runtime/components/SidebarHeading.vue +33 -24
- package/dist/runtime/components/SidebarLayout.vue +70 -40
- package/dist/runtime/components/SidebarSection.vue +33 -24
- package/dist/runtime/components/SidebarSpacer.vue +33 -24
- package/dist/runtime/components/Skeleton.vue +22 -17
- package/dist/runtime/components/Slideover.vue +131 -108
- package/dist/runtime/components/StackedLayout.vue +73 -40
- package/dist/runtime/components/Switch.vue +95 -100
- package/dist/runtime/components/Tabs.vue +107 -81
- package/dist/runtime/components/Textarea.vue +201 -177
- package/dist/runtime/components/Toast.vue +105 -94
- package/dist/runtime/components/Toaster.vue +116 -94
- package/dist/runtime/components/Tooltip.vue +64 -78
- package/dist/runtime/components/content/TableWrapper.vue +70 -58
- package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
- package/dist/runtime/composables/useButtonGroup.d.ts +2 -2
- package/dist/runtime/composables/useComponentIcons.d.ts +3 -3
- package/dist/runtime/composables/useFormField.d.ts +1 -1
- package/dist/runtime/prose/A.vue +23 -18
- package/dist/runtime/prose/Blockquote.vue +23 -18
- package/dist/runtime/prose/Code.vue +31 -23
- package/dist/runtime/prose/Em.vue +23 -18
- package/dist/runtime/prose/H1.vue +23 -18
- package/dist/runtime/prose/H2.vue +23 -18
- package/dist/runtime/prose/H3.vue +23 -18
- package/dist/runtime/prose/H4.vue +23 -18
- package/dist/runtime/prose/H5.vue +23 -18
- package/dist/runtime/prose/H6.vue +23 -18
- package/dist/runtime/prose/Hr.vue +19 -18
- package/dist/runtime/prose/Img.vue +23 -18
- package/dist/runtime/prose/Li.vue +23 -18
- package/dist/runtime/prose/Ol.vue +23 -18
- package/dist/runtime/prose/P.vue +23 -18
- package/dist/runtime/prose/Pre.vue +33 -28
- package/dist/runtime/prose/Strong.vue +23 -18
- package/dist/runtime/prose/Table.vue +54 -44
- package/dist/runtime/prose/Tbody.vue +23 -18
- package/dist/runtime/prose/Td.vue +23 -18
- package/dist/runtime/prose/Th.vue +23 -18
- package/dist/runtime/prose/Thead.vue +23 -18
- package/dist/runtime/prose/Tr.vue +23 -18
- package/dist/runtime/prose/Ul.vue +23 -18
- package/dist/runtime/vue/components/Link.vue +202 -201
- package/dist/shared/b24ui-nuxt.DrKwIWoc.cjs +7721 -0
- package/dist/types.d.mts +5 -3
- package/dist/types.d.ts +7 -0
- package/dist/unplugin.cjs +236 -0
- package/dist/unplugin.d.cts +33 -0
- package/dist/unplugin.d.ts +33 -0
- package/dist/vite.cjs +21 -0
- package/dist/vite.d.cts +14 -0
- package/dist/vite.d.ts +14 -0
- package/package.json +25 -13
- package/dist/runtime/components/Advice.vue.d.ts +0 -170
- package/dist/runtime/components/Alert.vue.d.ts +0 -464
- package/dist/runtime/components/App.vue.d.ts +0 -23
- package/dist/runtime/components/Avatar.vue.d.ts +0 -281
- package/dist/runtime/components/AvatarGroup.vue.d.ts +0 -204
- package/dist/runtime/components/Badge.vue.d.ts +0 -517
- package/dist/runtime/components/Button.vue.d.ts +0 -640
- package/dist/runtime/components/ButtonGroup.vue.d.ts +0 -116
- package/dist/runtime/components/Calendar.vue.d.ts +0 -437
- package/dist/runtime/components/Checkbox.vue.d.ts +0 -354
- package/dist/runtime/components/Chip.vue.d.ts +0 -271
- package/dist/runtime/components/Collapsible.vue.d.ts +0 -118
- package/dist/runtime/components/Container.vue.d.ts +0 -27
- package/dist/runtime/components/Countdown.vue.d.ts +0 -356
- package/dist/runtime/components/DescriptionList.vue.d.ts +0 -379
- package/dist/runtime/components/DropdownMenu.vue.d.ts +0 -533
- package/dist/runtime/components/DropdownMenuContent.vue.d.ts +0 -228
- package/dist/runtime/components/Form.vue.d.ts +0 -55
- package/dist/runtime/components/FormField.vue.d.ts +0 -282
- package/dist/runtime/components/Input.vue.d.ts +0 -755
- package/dist/runtime/components/InputMenu.vue.d.ts +0 -1504
- package/dist/runtime/components/InputNumber.vue.d.ts +0 -658
- package/dist/runtime/components/Kbd.vue.d.ts +0 -109
- package/dist/runtime/components/Link.vue.d.ts +0 -129
- package/dist/runtime/components/LinkBase.vue.d.ts +0 -48
- package/dist/runtime/components/Modal.vue.d.ts +0 -327
- package/dist/runtime/components/ModalDialogClose.vue.d.ts +0 -10
- package/dist/runtime/components/Navbar.vue.d.ts +0 -101
- package/dist/runtime/components/NavbarDivider.vue.d.ts +0 -101
- package/dist/runtime/components/NavbarSection.vue.d.ts +0 -101
- package/dist/runtime/components/NavbarSpacer.vue.d.ts +0 -101
- package/dist/runtime/components/NavigationMenu.vue.d.ts +0 -824
- package/dist/runtime/components/OverlayProvider.vue.d.ts +0 -2
- package/dist/runtime/components/Popover.vue.d.ts +0 -147
- package/dist/runtime/components/Progress.vue.d.ts +0 -592
- package/dist/runtime/components/RadioGroup.vue.d.ts +0 -723
- package/dist/runtime/components/Range.vue.d.ts +0 -417
- package/dist/runtime/components/Select.vue.d.ts +0 -1200
- package/dist/runtime/components/SelectMenu.vue.d.ts +0 -1298
- package/dist/runtime/components/Separator.vue.d.ts +0 -400
- package/dist/runtime/components/Sidebar.vue.d.ts +0 -101
- package/dist/runtime/components/SidebarBody.vue.d.ts +0 -90
- package/dist/runtime/components/SidebarFooter.vue.d.ts +0 -101
- package/dist/runtime/components/SidebarHeader.vue.d.ts +0 -101
- package/dist/runtime/components/SidebarHeading.vue.d.ts +0 -101
- package/dist/runtime/components/SidebarLayout.vue.d.ts +0 -222
- package/dist/runtime/components/SidebarSection.vue.d.ts +0 -101
- package/dist/runtime/components/SidebarSpacer.vue.d.ts +0 -101
- package/dist/runtime/components/Skeleton.vue.d.ts +0 -26
- package/dist/runtime/components/Slideover.vue.d.ts +0 -360
- package/dist/runtime/components/StackedLayout.vue.d.ts +0 -192
- package/dist/runtime/components/Switch.vue.d.ts +0 -587
- package/dist/runtime/components/Tabs.vue.d.ts +0 -453
- package/dist/runtime/components/Textarea.vue.d.ts +0 -601
- package/dist/runtime/components/Toast.vue.d.ts +0 -438
- package/dist/runtime/components/Toaster.vue.d.ts +0 -219
- package/dist/runtime/components/Tooltip.vue.d.ts +0 -186
- package/dist/runtime/components/content/TableWrapper.vue.d.ts +0 -237
- package/dist/runtime/prose/A.vue.d.ts +0 -84
- package/dist/runtime/prose/Blockquote.vue.d.ts +0 -84
- package/dist/runtime/prose/Code.vue.d.ts +0 -97
- package/dist/runtime/prose/Em.vue.d.ts +0 -84
- package/dist/runtime/prose/H1.vue.d.ts +0 -97
- package/dist/runtime/prose/H2.vue.d.ts +0 -123
- package/dist/runtime/prose/H3.vue.d.ts +0 -123
- package/dist/runtime/prose/H4.vue.d.ts +0 -123
- package/dist/runtime/prose/H5.vue.d.ts +0 -123
- package/dist/runtime/prose/H6.vue.d.ts +0 -123
- package/dist/runtime/prose/Hr.vue.d.ts +0 -74
- package/dist/runtime/prose/Img.vue.d.ts +0 -77
- package/dist/runtime/prose/Li.vue.d.ts +0 -84
- package/dist/runtime/prose/Ol.vue.d.ts +0 -84
- package/dist/runtime/prose/P.vue.d.ts +0 -84
- package/dist/runtime/prose/Pre.vue.d.ts +0 -117
- package/dist/runtime/prose/Strong.vue.d.ts +0 -84
- package/dist/runtime/prose/Table.vue.d.ts +0 -144
- package/dist/runtime/prose/Tbody.vue.d.ts +0 -84
- package/dist/runtime/prose/Td.vue.d.ts +0 -84
- package/dist/runtime/prose/Th.vue.d.ts +0 -84
- package/dist/runtime/prose/Thead.vue.d.ts +0 -84
- package/dist/runtime/prose/Tr.vue.d.ts +0 -84
- package/dist/runtime/prose/Ul.vue.d.ts +0 -84
- package/dist/runtime/vue/components/Link.vue.d.ts +0 -129
|
@@ -1,78 +1,125 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
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
|
|
11
|
-
import { get } from
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
93
|
+
}))
|
|
94
|
+
|
|
95
|
+
function normalizeItem(item: any) {
|
|
53
96
|
if (item === null) {
|
|
54
97
|
return {
|
|
55
|
-
label:
|
|
56
|
-
description:
|
|
57
|
-
orientation:
|
|
58
|
-
}
|
|
98
|
+
label: undefined,
|
|
99
|
+
description: undefined,
|
|
100
|
+
orientation: undefined
|
|
101
|
+
}
|
|
59
102
|
}
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
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
|
|
11
|
-
import { defu } from
|
|
12
|
-
import { useForwardPropsEmits } from
|
|
13
|
-
import { reactivePick } from
|
|
14
|
-
import { omit } from
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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 })" />
|