@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,110 +1,105 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { VariantProps } from 'tailwind-variants'
|
|
3
|
+
import type { SwitchRootProps } from 'reka-ui'
|
|
4
|
+
import type { AppConfig } from '@nuxt/schema'
|
|
5
|
+
import _appConfig from '#build/app.config'
|
|
6
|
+
import theme from '#build/b24ui/switch'
|
|
7
|
+
import { tv } from '../utils/tv'
|
|
8
|
+
import type { IconComponent } from '../types'
|
|
9
|
+
import type { PartialString } from '../types/utils'
|
|
10
|
+
|
|
11
|
+
const appConfigSwitch = _appConfig as AppConfig & { b24ui: { switch: Partial<typeof theme> } }
|
|
12
|
+
|
|
13
|
+
const switchTv = tv({ extend: tv(theme), ...(appConfigSwitch.b24ui?.switch || {}) })
|
|
14
|
+
|
|
15
|
+
type SwitchVariants = VariantProps<typeof switchTv>
|
|
16
|
+
|
|
17
|
+
export interface SwitchProps extends Pick<SwitchRootProps, 'disabled' | 'id' | 'name' | 'required' | 'value' | 'defaultValue'> {
|
|
18
|
+
/**
|
|
19
|
+
* The element or component this component should render as.
|
|
20
|
+
* @defaultValue 'div'
|
|
21
|
+
*/
|
|
22
|
+
as?: any
|
|
23
|
+
/**
|
|
24
|
+
* @defaultValue 'primary'
|
|
25
|
+
*/
|
|
26
|
+
color?: SwitchVariants['color']
|
|
27
|
+
/**
|
|
28
|
+
* @defaultValue 'md'
|
|
29
|
+
*/
|
|
30
|
+
size?: SwitchVariants['size']
|
|
31
|
+
/**
|
|
32
|
+
* When `true`, the loading icon will be displayed
|
|
33
|
+
* @defaultValue false
|
|
34
|
+
*/
|
|
35
|
+
loading?: boolean
|
|
36
|
+
/**
|
|
37
|
+
* The icon when the `loading` prop is `true`.
|
|
38
|
+
* @defaultValue icons.refresh
|
|
39
|
+
* @IconComponent
|
|
40
|
+
*/
|
|
41
|
+
loadingIcon?: IconComponent
|
|
42
|
+
/**
|
|
43
|
+
* Display an icon when the switch is checked.
|
|
44
|
+
* @IconComponent
|
|
45
|
+
*/
|
|
46
|
+
checkedIcon?: IconComponent
|
|
47
|
+
/**
|
|
48
|
+
* Display an icon when the switch is unchecked.
|
|
49
|
+
* @IconComponent
|
|
50
|
+
*/
|
|
51
|
+
uncheckedIcon?: IconComponent
|
|
52
|
+
label?: string
|
|
53
|
+
description?: string
|
|
54
|
+
class?: any
|
|
55
|
+
b24ui?: PartialString<typeof switchTv.slots>
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type SwitchEmits = {
|
|
59
|
+
change: [payload: Event]
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface SwitchSlots {
|
|
63
|
+
label(props: { label?: string }): any
|
|
64
|
+
description(props: { description?: string }): any
|
|
65
|
+
}
|
|
7
66
|
</script>
|
|
8
67
|
|
|
9
|
-
<script setup>
|
|
10
|
-
import { computed, useId } from
|
|
11
|
-
import { useForwardProps } from
|
|
12
|
-
import { reactivePick } from
|
|
13
|
-
import { useFormField } from
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
required: false
|
|
31
|
-
},
|
|
32
|
-
loadingIcon: {
|
|
33
|
-
type: [Function, Object],
|
|
34
|
-
required: false
|
|
35
|
-
},
|
|
36
|
-
checkedIcon: {
|
|
37
|
-
type: [Function, Object],
|
|
38
|
-
required: false
|
|
39
|
-
},
|
|
40
|
-
uncheckedIcon: {
|
|
41
|
-
type: [Function, Object],
|
|
42
|
-
required: false
|
|
43
|
-
},
|
|
44
|
-
label: {
|
|
45
|
-
type: String,
|
|
46
|
-
required: false
|
|
47
|
-
},
|
|
48
|
-
description: {
|
|
49
|
-
type: String,
|
|
50
|
-
required: false
|
|
51
|
-
},
|
|
52
|
-
class: {
|
|
53
|
-
type: null,
|
|
54
|
-
required: false
|
|
55
|
-
},
|
|
56
|
-
b24ui: {
|
|
57
|
-
type: null,
|
|
58
|
-
required: false
|
|
59
|
-
},
|
|
60
|
-
disabled: {
|
|
61
|
-
type: Boolean,
|
|
62
|
-
required: false
|
|
63
|
-
},
|
|
64
|
-
id: {
|
|
65
|
-
type: String,
|
|
66
|
-
required: false
|
|
67
|
-
},
|
|
68
|
-
name: {
|
|
69
|
-
type: String,
|
|
70
|
-
required: false
|
|
71
|
-
},
|
|
72
|
-
required: {
|
|
73
|
-
type: Boolean,
|
|
74
|
-
required: false
|
|
75
|
-
},
|
|
76
|
-
value: {
|
|
77
|
-
type: String,
|
|
78
|
-
required: false
|
|
79
|
-
},
|
|
80
|
-
defaultValue: {
|
|
81
|
-
type: Boolean,
|
|
82
|
-
required: false
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
const slots = defineSlots();
|
|
86
|
-
const emits = defineEmits(["change"]);
|
|
87
|
-
const modelValue = defineModel({
|
|
88
|
-
"type": Boolean,
|
|
89
|
-
...{
|
|
90
|
-
default: void 0
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
const rootProps = useForwardProps(reactivePick(props, "required", "value", "defaultValue"));
|
|
94
|
-
const { id: _id, emitFormChange, emitFormInput, size, color, name, disabled, ariaAttrs } = useFormField(props);
|
|
95
|
-
const id = _id.value ?? useId();
|
|
68
|
+
<script setup lang="ts">
|
|
69
|
+
import { computed, useId } from 'vue'
|
|
70
|
+
import { Primitive, SwitchRoot, SwitchThumb, useForwardProps, Label } from 'reka-ui'
|
|
71
|
+
import { reactivePick } from '@vueuse/core'
|
|
72
|
+
import { useFormField } from '../composables/useFormField'
|
|
73
|
+
import { omit } from '../utils'
|
|
74
|
+
import icons from '../dictionary/icons'
|
|
75
|
+
|
|
76
|
+
defineOptions({ inheritAttrs: false })
|
|
77
|
+
|
|
78
|
+
const props = defineProps<SwitchProps>()
|
|
79
|
+
const slots = defineSlots<SwitchSlots>()
|
|
80
|
+
const emits = defineEmits<SwitchEmits>()
|
|
81
|
+
|
|
82
|
+
const modelValue = defineModel<boolean>({ default: undefined })
|
|
83
|
+
|
|
84
|
+
const rootProps = useForwardProps(reactivePick(props, 'required', 'value', 'defaultValue'))
|
|
85
|
+
|
|
86
|
+
const { id: _id, emitFormChange, emitFormInput, size, color, name, disabled, ariaAttrs } = useFormField<SwitchProps>(props)
|
|
87
|
+
const id = _id.value ?? useId()
|
|
88
|
+
|
|
96
89
|
const b24ui = computed(() => switchTv({
|
|
97
90
|
size: size.value,
|
|
98
91
|
color: color.value,
|
|
99
92
|
required: props.required,
|
|
100
93
|
loading: props.loading,
|
|
101
94
|
disabled: disabled.value || props.loading
|
|
102
|
-
}))
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
95
|
+
}))
|
|
96
|
+
|
|
97
|
+
function onUpdate(value: any) {
|
|
98
|
+
// @ts-expect-error - 'target' does not exist in type 'EventInit'
|
|
99
|
+
const event = new Event('change', { target: { value } })
|
|
100
|
+
emits('change', event)
|
|
101
|
+
emitFormChange()
|
|
102
|
+
emitFormInput()
|
|
108
103
|
}
|
|
109
104
|
</script>
|
|
110
105
|
|
|
@@ -141,7 +136,7 @@ function onUpdate(value) {
|
|
|
141
136
|
</SwitchThumb>
|
|
142
137
|
</SwitchRoot>
|
|
143
138
|
</div>
|
|
144
|
-
<div v-if="label || !!slots.label || (description || !!slots.description)" :class="b24ui.wrapper({ class: props.b24ui?.wrapper })">
|
|
139
|
+
<div v-if="(label || !!slots.label) || (description || !!slots.description)" :class="b24ui.wrapper({ class: props.b24ui?.wrapper })">
|
|
145
140
|
<Label v-if="label || !!slots.label" :for="id" :class="b24ui.label({ class: props.b24ui?.label })">
|
|
146
141
|
<slot name="label" :label="label">
|
|
147
142
|
{{ label }}
|
|
@@ -1,87 +1,113 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { VariantProps } from 'tailwind-variants'
|
|
3
|
+
import type { TabsRootProps, TabsRootEmits } from 'reka-ui'
|
|
4
|
+
import type { AppConfig } from '@nuxt/schema'
|
|
5
|
+
import _appConfig from '#build/app.config'
|
|
6
|
+
import theme from '#build/b24ui/tabs'
|
|
7
|
+
import { tv } from '../utils/tv'
|
|
8
|
+
import type { AvatarProps, IconComponent } from '../types'
|
|
9
|
+
import type { DynamicSlots, PartialString } from '../types/utils'
|
|
10
|
+
|
|
11
|
+
const appConfigTabs = _appConfig as AppConfig & { b24ui: { tabs: Partial<typeof theme> } }
|
|
12
|
+
|
|
13
|
+
const tabs = tv({ extend: tv(theme), ...(appConfigTabs.b24ui?.tabs || {}) })
|
|
14
|
+
|
|
15
|
+
export interface TabsItem {
|
|
16
|
+
label?: string
|
|
17
|
+
/**
|
|
18
|
+
* @IconComponent
|
|
19
|
+
*/
|
|
20
|
+
icon?: IconComponent
|
|
21
|
+
avatar?: AvatarProps
|
|
22
|
+
slot?: string
|
|
23
|
+
content?: string
|
|
24
|
+
/** A unique value for the tab item. Defaults to the index. */
|
|
25
|
+
value?: string | number
|
|
26
|
+
disabled?: boolean
|
|
27
|
+
[key: string]: any
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type TabsVariants = VariantProps<typeof tabs>
|
|
31
|
+
|
|
32
|
+
export interface TabsProps<T extends TabsItem = TabsItem> extends Pick<TabsRootProps<string | number>, 'defaultValue' | 'modelValue' | 'activationMode' | 'unmountOnHide'> {
|
|
33
|
+
/**
|
|
34
|
+
* The element or component this component should render as.
|
|
35
|
+
* @defaultValue 'div'
|
|
36
|
+
*/
|
|
37
|
+
as?: any
|
|
38
|
+
items?: T[]
|
|
39
|
+
/**
|
|
40
|
+
* @defaultValue 'default'
|
|
41
|
+
*/
|
|
42
|
+
color?: TabsVariants['color']
|
|
43
|
+
/**
|
|
44
|
+
* @defaultValue 'link'
|
|
45
|
+
*/
|
|
46
|
+
variant?: TabsVariants['variant']
|
|
47
|
+
/**
|
|
48
|
+
* @defaultValue 'md'
|
|
49
|
+
*/
|
|
50
|
+
size?: TabsVariants['size']
|
|
51
|
+
/**
|
|
52
|
+
* The orientation of the tabs.
|
|
53
|
+
* @defaultValue 'horizontal'
|
|
54
|
+
*/
|
|
55
|
+
orientation?: TabsRootProps['orientation']
|
|
56
|
+
/**
|
|
57
|
+
* The content of the tabs, can be disabled to prevent rendering the content.
|
|
58
|
+
* @defaultValue true
|
|
59
|
+
*/
|
|
60
|
+
content?: boolean
|
|
61
|
+
/**
|
|
62
|
+
* The key used to get the label from the item.
|
|
63
|
+
* @defaultValue 'label'
|
|
64
|
+
*/
|
|
65
|
+
labelKey?: string
|
|
66
|
+
class?: any
|
|
67
|
+
b24ui?: PartialString<typeof tabs.slots>
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface TabsEmits extends TabsRootEmits<string | number> {}
|
|
71
|
+
|
|
72
|
+
type SlotProps<T extends TabsItem> = (props: { item: T, index: number }) => any
|
|
73
|
+
|
|
74
|
+
export type TabsSlots<T extends TabsItem = TabsItem> = {
|
|
75
|
+
leading: SlotProps<T>
|
|
76
|
+
default: SlotProps<T>
|
|
77
|
+
trailing: SlotProps<T>
|
|
78
|
+
content: SlotProps<T>
|
|
79
|
+
} & DynamicSlots<T, undefined, { index: number }>
|
|
7
80
|
</script>
|
|
8
81
|
|
|
9
|
-
<script setup>
|
|
10
|
-
import { computed } from
|
|
11
|
-
import { useForwardPropsEmits } from
|
|
12
|
-
import { reactivePick } from
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
required: false
|
|
33
|
-
},
|
|
34
|
-
orientation: {
|
|
35
|
-
type: null,
|
|
36
|
-
required: false,
|
|
37
|
-
default: "horizontal"
|
|
38
|
-
},
|
|
39
|
-
content: {
|
|
40
|
-
type: Boolean,
|
|
41
|
-
required: false,
|
|
42
|
-
default: true
|
|
43
|
-
},
|
|
44
|
-
labelKey: {
|
|
45
|
-
type: String,
|
|
46
|
-
required: false,
|
|
47
|
-
default: "label"
|
|
48
|
-
},
|
|
49
|
-
class: {
|
|
50
|
-
type: null,
|
|
51
|
-
required: false
|
|
52
|
-
},
|
|
53
|
-
b24ui: {
|
|
54
|
-
type: null,
|
|
55
|
-
required: false
|
|
56
|
-
},
|
|
57
|
-
defaultValue: {
|
|
58
|
-
type: null,
|
|
59
|
-
required: false,
|
|
60
|
-
default: "0"
|
|
61
|
-
},
|
|
62
|
-
modelValue: {
|
|
63
|
-
type: null,
|
|
64
|
-
required: false
|
|
65
|
-
},
|
|
66
|
-
activationMode: {
|
|
67
|
-
type: String,
|
|
68
|
-
required: false
|
|
69
|
-
},
|
|
70
|
-
unmountOnHide: {
|
|
71
|
-
type: Boolean,
|
|
72
|
-
required: false,
|
|
73
|
-
default: true
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
const emits = defineEmits(["update:modelValue"]);
|
|
77
|
-
const slots = defineSlots();
|
|
78
|
-
const rootProps = useForwardPropsEmits(reactivePick(props, "as", "modelValue", "defaultValue", "orientation", "activationMode", "unmountOnHide"), emits);
|
|
82
|
+
<script setup lang="ts" generic="T extends TabsItem">
|
|
83
|
+
import { computed } from 'vue'
|
|
84
|
+
import { TabsRoot, TabsList, TabsIndicator, TabsTrigger, TabsContent, useForwardPropsEmits } from 'reka-ui'
|
|
85
|
+
import { reactivePick } from '@vueuse/core'
|
|
86
|
+
import { get } from '../utils'
|
|
87
|
+
import B24Avatar from './Avatar.vue'
|
|
88
|
+
|
|
89
|
+
const props = withDefaults(defineProps<TabsProps<T>>(), {
|
|
90
|
+
content: true,
|
|
91
|
+
defaultValue: '0',
|
|
92
|
+
orientation: 'horizontal',
|
|
93
|
+
unmountOnHide: true,
|
|
94
|
+
labelKey: 'label'
|
|
95
|
+
})
|
|
96
|
+
const emits = defineEmits<TabsEmits>()
|
|
97
|
+
const slots = defineSlots<TabsSlots<T>>()
|
|
98
|
+
|
|
99
|
+
const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'modelValue', 'defaultValue', 'orientation', 'activationMode', 'unmountOnHide'), emits)
|
|
100
|
+
|
|
101
|
+
const getLabel = (item: TabsItem) => {
|
|
102
|
+
return get(item, props.labelKey as string)
|
|
103
|
+
}
|
|
104
|
+
|
|
79
105
|
const b24ui = computed(() => tabs({
|
|
80
106
|
color: props.color,
|
|
81
107
|
variant: props.variant,
|
|
82
108
|
size: props.size,
|
|
83
109
|
orientation: props.orientation
|
|
84
|
-
}))
|
|
110
|
+
}))
|
|
85
111
|
</script>
|
|
86
112
|
|
|
87
113
|
<template>
|
|
@@ -96,11 +122,11 @@ const b24ui = computed(() => tabs({
|
|
|
96
122
|
v-if="item.icon"
|
|
97
123
|
:class="b24ui.leadingIcon({ class: props.b24ui?.leadingIcon })"
|
|
98
124
|
/>
|
|
99
|
-
<B24Avatar v-else-if="item.avatar" :size="props.b24ui?.leadingAvatarSize || b24ui.leadingAvatarSize()" v-bind="item.avatar" :class="b24ui.leadingAvatar({ class: props.b24ui?.leadingAvatar })" />
|
|
125
|
+
<B24Avatar v-else-if="item.avatar" :size="((props.b24ui?.leadingAvatarSize || b24ui.leadingAvatarSize()) as AvatarProps['size'])" v-bind="item.avatar" :class="b24ui.leadingAvatar({ class: props.b24ui?.leadingAvatar })" />
|
|
100
126
|
</slot>
|
|
101
127
|
|
|
102
|
-
<span v-if="
|
|
103
|
-
<slot :item="item" :index="index">{{
|
|
128
|
+
<span v-if="getLabel(item) || !!slots.default" :class="b24ui.label({ class: props.b24ui?.label })">
|
|
129
|
+
<slot :item="item" :index="index">{{ getLabel(item) }}</slot>
|
|
104
130
|
</span>
|
|
105
131
|
|
|
106
132
|
<slot name="trailing" :item="item" :index="index" />
|
|
@@ -109,7 +135,7 @@ const b24ui = computed(() => tabs({
|
|
|
109
135
|
|
|
110
136
|
<template v-if="!!content">
|
|
111
137
|
<TabsContent v-for="(item, index) in items" :key="index" :value="item.value || String(index)" :class="b24ui.content({ class: props.b24ui?.content })">
|
|
112
|
-
<slot :name="item.slot || 'content'" :item="item" :index="index">
|
|
138
|
+
<slot :name="((item.slot || 'content') as keyof TabsSlots<T>)" :item="(item as Extract<T, { slot: string; }>)" :index="index">
|
|
113
139
|
{{ item.content }}
|
|
114
140
|
</slot>
|
|
115
141
|
</TabsContent>
|