@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,80 +1,92 @@
1
- <script>
2
- import _appConfig from "#build/app.config";
3
- import theme from "#build/b24ui/avatar";
4
- import { tv } from "../utils/tv";
5
- const appConfigAvatar = _appConfig;
6
- const avatar = tv({ extend: tv(theme), ...appConfigAvatar.b24ui?.avatar || {} });
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/avatar'
6
+ import { tv } from '../utils/tv'
7
+ import type { IconComponent } from '../types'
8
+
9
+ const appConfigAvatar = _appConfig as AppConfig & { b24ui: { avatar: Partial<typeof theme> } }
10
+
11
+ const avatar = tv({ extend: tv(theme), ...(appConfigAvatar.b24ui?.avatar || {}) })
12
+
13
+ type AvatarVariants = VariantProps<typeof avatar>
14
+
15
+ export interface AvatarProps {
16
+ /**
17
+ * The element or component this component should render as.
18
+ * @defaultValue 'span'
19
+ */
20
+ as?: any
21
+ src?: string
22
+ alt?: string
23
+ /**
24
+ * Display an icon on the left side.
25
+ * @IconComponent
26
+ */
27
+ icon?: IconComponent
28
+ text?: string
29
+ /**
30
+ * @defaultValue 'md'
31
+ */
32
+ size?: AvatarVariants['size']
33
+ class?: any
34
+ style?: any
35
+ b24ui?: Partial<typeof avatar.slots>
36
+ }
37
+
38
+ export interface AvatarSlots {
39
+ default(props?: {}): any
40
+ }
7
41
  </script>
8
42
 
9
- <script setup>
10
- import { ref, computed, watch } from "vue";
11
- import { useAvatarGroup } from "../composables/useAvatarGroup";
12
- defineOptions({ inheritAttrs: false });
13
- const props = defineProps({
14
- as: {
15
- type: null,
16
- required: false,
17
- default: "span"
18
- },
19
- src: {
20
- type: String,
21
- required: false
22
- },
23
- alt: {
24
- type: String,
25
- required: false
26
- },
27
- icon: {
28
- type: [Function, Object],
29
- required: false
30
- },
31
- text: {
32
- type: String,
33
- required: false
34
- },
35
- size: {
36
- type: null,
37
- required: false
38
- },
39
- class: {
40
- type: null,
41
- required: false
42
- },
43
- style: {
44
- type: null,
45
- required: false
46
- },
47
- b24ui: {
48
- type: Object,
49
- required: false
50
- }
51
- });
52
- const fallback = computed(
53
- () => props.text || (props.alt || "").replace(/[+\-*)(}\][{]/g, "").split(" ").map((word) => word.charAt(0)).join("").substring(0, 2)
54
- );
55
- const { size } = useAvatarGroup(props);
43
+ <script setup lang="ts">
44
+ import { ref, computed, watch } from 'vue'
45
+ import { Primitive, Slot } from 'reka-ui'
46
+ import ImageComponent from '#build/b24ui-image-component'
47
+ import { useAvatarGroup } from '../composables/useAvatarGroup'
48
+
49
+ defineOptions({ inheritAttrs: false })
50
+
51
+ const props = withDefaults(defineProps<AvatarProps>(), { as: 'span' })
52
+
53
+ const fallback = computed(() => props.text || (props.alt || '')
54
+ .replace(/[+\-*)(}\][{]/g, '')
55
+ .split(' ')
56
+ .map(word => word.charAt(0))
57
+ .join('')
58
+ .substring(0, 2)
59
+ )
60
+
61
+ const { size } = useAvatarGroup(props)
62
+
63
+ // eslint-disable-next-line vue/no-dupe-keys
56
64
  const b24ui = computed(() => avatar({
57
65
  size: size.value
58
- }));
66
+ }))
67
+
59
68
  const sizePx = computed(() => ({
60
- "3xs": 10,
61
- "2xs": 14,
62
- "xs": 18,
63
- "sm": 22,
64
- "md": 32,
65
- "lg": 42,
66
- "xl": 48,
67
- "2xl": 60,
68
- "3xl": 94
69
- })[props.size || "md"]);
70
- const error = ref(false);
69
+ '3xs': 10,
70
+ '2xs': 14,
71
+ 'xs': 18,
72
+ 'sm': 22,
73
+ 'md': 32,
74
+ 'lg': 42,
75
+ 'xl': 48,
76
+ '2xl': 60,
77
+ '3xl': 94
78
+ })[props.size || 'md'])
79
+
80
+ const error = ref(false)
81
+
71
82
  watch(() => props.src, () => {
72
83
  if (error.value) {
73
- error.value = false;
84
+ error.value = false
74
85
  }
75
- });
86
+ })
87
+
76
88
  function onError() {
77
- error.value = true;
89
+ error.value = true
78
90
  }
79
91
  </script>
80
92
 
@@ -96,7 +108,7 @@ function onError() {
96
108
  <Slot v-else v-bind="$attrs">
97
109
  <slot>
98
110
  <Component :is="icon" v-if="icon" :class="b24ui.icon({ class: props.b24ui?.icon })" />
99
- <span v-else :class="b24ui.fallback({ class: props.b24ui?.fallback })">{{ fallback || "\xA0" }}</span>
111
+ <span v-else :class="b24ui.fallback({ class: props.b24ui?.fallback })">{{ fallback || '&nbsp;' }}</span>
100
112
  </slot>
101
113
  </Slot>
102
114
  </Primitive>
@@ -1,74 +1,97 @@
1
- <script>
2
- import _appConfig from "#build/app.config";
3
- import theme from "#build/b24ui/avatar-group";
4
- import { tv } from "../utils/tv";
5
- const appConfigAvatarGroup = _appConfig;
6
- const avatarGroup = tv({ extend: tv(theme), ...appConfigAvatarGroup.b24ui?.avatarGroup || {} });
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/avatar-group'
6
+ import { tv } from '../utils/tv'
7
+
8
+ const appConfigAvatarGroup = _appConfig as AppConfig & { b24ui: { avatarGroup: Partial<typeof theme> } }
9
+
10
+ const avatarGroup = tv({ extend: tv(theme), ...(appConfigAvatarGroup.b24ui?.avatarGroup || {}) })
11
+
12
+ type AvatarGroupVariants = VariantProps<typeof avatarGroup>
13
+
14
+ export interface AvatarGroupProps {
15
+ /**
16
+ * The element or component this component should render as.
17
+ * @defaultValue 'div'
18
+ */
19
+ as?: any
20
+ /**
21
+ * @defaultValue 'md'
22
+ */
23
+ size?: AvatarGroupVariants['size']
24
+ /**
25
+ * The maximum number of avatars to display.
26
+ */
27
+ max?: number | string
28
+ class?: any
29
+ b24ui?: Partial<typeof avatarGroup.slots>
30
+ }
31
+
32
+ export interface AvatarGroupSlots {
33
+ default(props?: {}): any
34
+ }
7
35
  </script>
8
36
 
9
- <script setup>
10
- import { computed, provide } from "vue";
11
- import { avatarGroupInjectionKey } from "../composables/useAvatarGroup";
12
- const props = defineProps({
13
- as: {
14
- type: null,
15
- required: false
16
- },
17
- size: {
18
- type: null,
19
- required: false
20
- },
21
- max: {
22
- type: [Number, String],
23
- required: false
24
- },
25
- class: {
26
- type: null,
27
- required: false
28
- },
29
- b24ui: {
30
- type: Object,
31
- required: false
32
- }
33
- });
34
- const slots = defineSlots();
37
+ <script setup lang="ts">
38
+ import { computed, provide } from 'vue'
39
+ import { Primitive } from 'reka-ui'
40
+ import { avatarGroupInjectionKey } from '../composables/useAvatarGroup'
41
+ import B24Avatar from './Avatar.vue'
42
+
43
+ const props = defineProps<AvatarGroupProps>()
44
+ const slots = defineSlots<AvatarGroupSlots>()
45
+
35
46
  const b24ui = computed(() => avatarGroup({
36
47
  size: props.size
37
- }));
38
- const max = computed(() => typeof props.max === "string" ? Number.parseInt(props.max, 10) : props.max);
48
+ }))
49
+
50
+ const max = computed(() => typeof props.max === 'string' ? Number.parseInt(props.max, 10) : props.max)
51
+
39
52
  const children = computed(() => {
40
- let children2 = slots.default?.();
41
- if (children2?.length) {
42
- children2 = children2.flatMap((child) => {
43
- if (typeof child.type === "symbol") {
44
- if (typeof child.children === "string") {
45
- return;
53
+ let children = slots.default?.()
54
+ if (children?.length) {
55
+ children = children.flatMap((child: any) => {
56
+ if (typeof child.type === 'symbol') {
57
+ // `v-if="false"` or commented node
58
+ if (typeof child.children === 'string') {
59
+ return
46
60
  }
47
- return child.children;
61
+
62
+ return child.children
48
63
  }
49
- return child;
50
- }).filter(Boolean);
64
+
65
+ return child
66
+ }).filter(Boolean)
51
67
  }
52
- return children2 || [];
53
- });
68
+
69
+ return children || []
70
+ })
71
+
54
72
  const visibleAvatars = computed(() => {
55
73
  if (!children.value.length) {
56
- return [];
74
+ return []
57
75
  }
76
+
58
77
  if (!max.value || max.value <= 0) {
59
- return [...children.value];
78
+ return [...children.value]
60
79
  }
61
- return [...children.value].slice(0, max.value);
62
- });
80
+
81
+ return [...children.value].slice(0, max.value)
82
+ })
83
+
63
84
  const hiddenCount = computed(() => {
64
85
  if (!children.value.length) {
65
- return 0;
86
+ return 0
66
87
  }
67
- return children.value.length - visibleAvatars.value.length;
68
- });
88
+
89
+ return children.value.length - visibleAvatars.value.length
90
+ })
91
+
69
92
  provide(avatarGroupInjectionKey, computed(() => ({
70
93
  size: props.size
71
- })));
94
+ })))
72
95
  </script>
73
96
 
74
97
  <template>
@@ -1,88 +1,88 @@
1
- <script>
2
- import _appConfig from "#build/app.config";
3
- import theme from "#build/b24ui/badge";
4
- import { tv } from "../utils/tv";
5
- const appConfigBadge = _appConfig;
6
- const badge = tv({ extend: tv(theme), ...appConfigBadge.b24ui?.badge || {} });
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/badge'
6
+ import type { UseComponentIconsProps } from '../composables/useComponentIcons'
7
+ import { tv } from '../utils/tv'
8
+ import type { AvatarProps } from '../types'
9
+
10
+ const appConfigBadge = _appConfig as AppConfig & { b24ui: { badge: Partial<typeof theme> } }
11
+
12
+ const badge = tv({ extend: tv(theme), ...(appConfigBadge.b24ui?.badge || {}) })
13
+
14
+ type BadgeVariants = VariantProps<typeof badge>
15
+
16
+ export interface BadgeProps extends Omit<UseComponentIconsProps, 'loading' | 'loadingIcon'> {
17
+ /**
18
+ * The element or component this component should render as.
19
+ * @defaultValue 'span'
20
+ */
21
+ as?: any
22
+ label?: string | number
23
+ /**
24
+ * @defaultValue 'default'
25
+ */
26
+ color?: BadgeVariants['color']
27
+ /**
28
+ * @defaultValue 'normal'
29
+ */
30
+ depth?: BadgeVariants['depth']
31
+ /**
32
+ * @defaultValue 'md'
33
+ */
34
+ size?: BadgeVariants['size']
35
+ /**
36
+ * Shows 'underline' on hover
37
+ * @defaultValue false
38
+ */
39
+ useLink?: boolean
40
+ /**
41
+ * Shows icons.close on the right side
42
+ * @defaultValue false
43
+ */
44
+ useClose?: boolean
45
+ onCloseClick?: ((event: MouseEvent) => void | Promise<void>) | Array<((event: MouseEvent) => void | Promise<void>)>
46
+ /**
47
+ * Fills the background
48
+ * @defaultValue false
49
+ */
50
+ useFill?: boolean
51
+ class?: any
52
+ b24ui?: Partial<typeof badge.slots>
53
+ }
54
+
55
+ export interface BadgeSlots {
56
+ leading(props?: {}): any
57
+ default(props?: {}): any
58
+ trailing(props?: {}): any
59
+ }
7
60
  </script>
8
61
 
9
- <script setup>
10
- import { computed } from "vue";
11
- import { useButtonGroup } from "../composables/useButtonGroup";
12
- import { useComponentIcons } from "../composables/useComponentIcons";
13
- const props = defineProps({
14
- as: {
15
- type: null,
16
- required: false,
17
- default: "span"
18
- },
19
- label: {
20
- type: [String, Number],
21
- required: false
22
- },
23
- color: {
24
- type: null,
25
- required: false
26
- },
27
- depth: {
28
- type: null,
29
- required: false
30
- },
31
- size: {
32
- type: null,
33
- required: false
34
- },
35
- useLink: {
36
- type: Boolean,
37
- required: false
38
- },
39
- useClose: {
40
- type: Boolean,
41
- required: false
42
- },
43
- onCloseClick: {
44
- type: [Function, Array],
45
- required: false
46
- },
47
- useFill: {
48
- type: Boolean,
49
- required: false
50
- },
51
- class: {
52
- type: null,
53
- required: false
54
- },
55
- b24ui: {
56
- type: Object,
57
- required: false
58
- },
59
- icon: {
60
- type: [Function, Object],
61
- required: false
62
- },
63
- avatar: {
64
- type: Object,
65
- required: false
66
- },
67
- trailing: {
68
- type: Boolean,
69
- required: false
70
- },
71
- trailingIcon: {
72
- type: [Function, Object],
73
- required: false
74
- }
75
- });
76
- defineSlots();
77
- async function onCloseClickWrapper(event) {
78
- const callbacks = Array.isArray(props.onCloseClick) ? props.onCloseClick : [props.onCloseClick];
62
+ <script setup lang="ts">
63
+ import { computed } from 'vue'
64
+ import { Primitive } from 'reka-ui'
65
+ import { useButtonGroup } from '../composables/useButtonGroup'
66
+ import { useComponentIcons } from '../composables/useComponentIcons'
67
+ import Cross20Icon from '@bitrix24/b24icons-vue/actions/Cross20Icon'
68
+ import B24Avatar from './Avatar.vue'
69
+
70
+ const props = withDefaults(defineProps<BadgeProps>(), {
71
+ as: 'span'
72
+ })
73
+
74
+ defineSlots<BadgeSlots>()
75
+
76
+ async function onCloseClickWrapper(event: MouseEvent) {
77
+ const callbacks = Array.isArray(props.onCloseClick) ? props.onCloseClick : [props.onCloseClick]
79
78
  try {
80
- await Promise.all(callbacks.map((fn) => fn?.(event)));
81
- } finally {
82
- }
79
+ await Promise.all(callbacks.map(fn => fn?.(event)))
80
+ } finally { /* empty */ }
83
81
  }
84
- const { orientation, size: buttonGroupSize } = useButtonGroup(props);
85
- const { isLeading, leadingIconName } = useComponentIcons(props);
82
+
83
+ const { orientation, size: buttonGroupSize } = useButtonGroup<BadgeProps>(props)
84
+ const { isLeading, leadingIconName } = useComponentIcons(props)
85
+
86
86
  const b24ui = computed(() => badge({
87
87
  color: props.color,
88
88
  depth: props.depth,
@@ -92,7 +92,7 @@ const b24ui = computed(() => badge({
92
92
  useClose: Boolean(props.useClose),
93
93
  useFill: Boolean(props.useFill),
94
94
  leading: Boolean(isLeading.value)
95
- }));
95
+ }))
96
96
  </script>
97
97
 
98
98
  <template>
@@ -112,7 +112,7 @@ const b24ui = computed(() => badge({
112
112
  />
113
113
  <B24Avatar
114
114
  v-else-if="!!avatar"
115
- :size="props.b24ui?.leadingAvatarSize || b24ui.leadingAvatarSize()"
115
+ :size="((props.b24ui?.leadingAvatarSize || b24ui.leadingAvatarSize()) as AvatarProps['size'])"
116
116
  v-bind="avatar"
117
117
  :class="b24ui.leadingAvatar({ class: props.b24ui?.leadingAvatar })"
118
118
  />