@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,110 +1,105 @@
1
- <script>
2
- import _appConfig from "#build/app.config";
3
- import theme from "#build/b24ui/switch";
4
- import { tv } from "../utils/tv";
5
- const appConfigSwitch = _appConfig;
6
- const switchTv = tv({ extend: tv(theme), ...appConfigSwitch.b24ui?.switch || {} });
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 "vue";
11
- import { useForwardProps } from "reka-ui";
12
- import { reactivePick } from "@vueuse/core";
13
- import { useFormField } from "../composables/useFormField";
14
- defineOptions({ inheritAttrs: false });
15
- const props = defineProps({
16
- as: {
17
- type: null,
18
- required: false
19
- },
20
- color: {
21
- type: null,
22
- required: false
23
- },
24
- size: {
25
- type: null,
26
- required: false
27
- },
28
- loading: {
29
- type: Boolean,
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
- function onUpdate(value) {
104
- const event = new Event("change", { target: { value } });
105
- emits("change", event);
106
- emitFormChange();
107
- emitFormInput();
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 _appConfig from "#build/app.config";
3
- import theme from "#build/b24ui/tabs";
4
- import { tv } from "../utils/tv";
5
- const appConfigTabs = _appConfig;
6
- const tabs = tv({ extend: tv(theme), ...appConfigTabs.b24ui?.tabs || {} });
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 "vue";
11
- import { useForwardPropsEmits } from "reka-ui";
12
- import { reactivePick } from "@vueuse/core";
13
- const props = defineProps({
14
- as: {
15
- type: null,
16
- required: false
17
- },
18
- items: {
19
- type: Array,
20
- required: false
21
- },
22
- color: {
23
- type: null,
24
- required: false
25
- },
26
- variant: {
27
- type: null,
28
- required: false
29
- },
30
- size: {
31
- type: null,
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="get(item, props.labelKey) || !!slots.default" :class="b24ui.label({ class: props.b24ui?.label })">
103
- <slot :item="item" :index="index">{{ get(item, props.labelKey) }}</slot>
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>