@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,80 +1,92 @@
|
|
|
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/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
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
})[props.size ||
|
|
70
|
-
|
|
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 ||
|
|
111
|
+
<span v-else :class="b24ui.fallback({ class: props.b24ui?.fallback })">{{ fallback || ' ' }}</span>
|
|
100
112
|
</slot>
|
|
101
113
|
</Slot>
|
|
102
114
|
</Primitive>
|
|
@@ -1,74 +1,97 @@
|
|
|
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/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
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
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
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
if (typeof child.type ===
|
|
44
|
-
if
|
|
45
|
-
|
|
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
|
-
|
|
61
|
+
|
|
62
|
+
return child.children
|
|
48
63
|
}
|
|
49
|
-
|
|
50
|
-
|
|
64
|
+
|
|
65
|
+
return child
|
|
66
|
+
}).filter(Boolean)
|
|
51
67
|
}
|
|
52
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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/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
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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(
|
|
81
|
-
} finally {
|
|
82
|
-
}
|
|
79
|
+
await Promise.all(callbacks.map(fn => fn?.(event)))
|
|
80
|
+
} finally { /* empty */ }
|
|
83
81
|
}
|
|
84
|
-
|
|
85
|
-
const {
|
|
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
|
/>
|