@bitrix24/b24ui-nuxt 0.1.1

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 (159) hide show
  1. package/.nuxt/b24ui/advice.ts +52 -0
  2. package/.nuxt/b24ui/alert.ts +118 -0
  3. package/.nuxt/b24ui/avatar-group.ts +52 -0
  4. package/.nuxt/b24ui/avatar.ts +63 -0
  5. package/.nuxt/b24ui/badge.ts +256 -0
  6. package/.nuxt/b24ui/button-group.ts +27 -0
  7. package/.nuxt/b24ui/button.ts +342 -0
  8. package/.nuxt/b24ui/checkbox.ts +128 -0
  9. package/.nuxt/b24ui/chip.ts +205 -0
  10. package/.nuxt/b24ui/container.ts +3 -0
  11. package/.nuxt/b24ui/content/description-list.ts +62 -0
  12. package/.nuxt/b24ui/countdown.ts +94 -0
  13. package/.nuxt/b24ui/form-field.ts +57 -0
  14. package/.nuxt/b24ui/form.ts +3 -0
  15. package/.nuxt/b24ui/index.ts +28 -0
  16. package/.nuxt/b24ui/input.ts +472 -0
  17. package/.nuxt/b24ui/kbd.ts +31 -0
  18. package/.nuxt/b24ui/link.ts +20 -0
  19. package/.nuxt/b24ui/progress.ts +303 -0
  20. package/.nuxt/b24ui/radio-group.ts +135 -0
  21. package/.nuxt/b24ui/range.ts +172 -0
  22. package/.nuxt/b24ui/select.ts +550 -0
  23. package/.nuxt/b24ui/separator.ts +176 -0
  24. package/.nuxt/b24ui/skeleton.ts +3 -0
  25. package/.nuxt/b24ui/switch.ts +134 -0
  26. package/.nuxt/b24ui/tabs.ts +341 -0
  27. package/.nuxt/b24ui/textarea.ts +332 -0
  28. package/.nuxt/b24ui/toast.ts +89 -0
  29. package/.nuxt/b24ui/toaster.ts +91 -0
  30. package/.nuxt/b24ui/tooltip.ts +16 -0
  31. package/LICENSE +21 -0
  32. package/README.md +101 -0
  33. package/cli/commands/make/component.mjs +95 -0
  34. package/cli/commands/make/index.mjs +14 -0
  35. package/cli/commands/make/locale.mjs +64 -0
  36. package/cli/index.mjs +15 -0
  37. package/cli/package.json +13 -0
  38. package/cli/templates.mjs +240 -0
  39. package/cli/utils.mjs +31 -0
  40. package/dist/meta.cjs +23610 -0
  41. package/dist/meta.d.cts +23608 -0
  42. package/dist/meta.d.mts +23608 -0
  43. package/dist/meta.d.ts +23608 -0
  44. package/dist/meta.mjs +23608 -0
  45. package/dist/module.cjs +54 -0
  46. package/dist/module.d.cts +14 -0
  47. package/dist/module.d.mts +14 -0
  48. package/dist/module.d.ts +14 -0
  49. package/dist/module.json +13 -0
  50. package/dist/module.mjs +51 -0
  51. package/dist/runtime/components/Advice.vue +115 -0
  52. package/dist/runtime/components/Alert.vue +136 -0
  53. package/dist/runtime/components/App.vue +52 -0
  54. package/dist/runtime/components/Avatar.vue +118 -0
  55. package/dist/runtime/components/AvatarGroup.vue +99 -0
  56. package/dist/runtime/components/Badge.vue +114 -0
  57. package/dist/runtime/components/Button.vue +177 -0
  58. package/dist/runtime/components/ButtonGroup.vue +58 -0
  59. package/dist/runtime/components/Checkbox.vue +110 -0
  60. package/dist/runtime/components/Chip.vue +81 -0
  61. package/dist/runtime/components/Container.vue +36 -0
  62. package/dist/runtime/components/Countdown.vue +498 -0
  63. package/dist/runtime/components/Form.vue +271 -0
  64. package/dist/runtime/components/FormField.vue +128 -0
  65. package/dist/runtime/components/Input.vue +224 -0
  66. package/dist/runtime/components/Kbd.vue +50 -0
  67. package/dist/runtime/components/Link.vue +219 -0
  68. package/dist/runtime/components/LinkBase.vue +63 -0
  69. package/dist/runtime/components/Progress.vue +182 -0
  70. package/dist/runtime/components/RadioGroup.vue +178 -0
  71. package/dist/runtime/components/Range.vue +114 -0
  72. package/dist/runtime/components/Select.vue +328 -0
  73. package/dist/runtime/components/Separator.vue +82 -0
  74. package/dist/runtime/components/Skeleton.vue +31 -0
  75. package/dist/runtime/components/Switch.vue +133 -0
  76. package/dist/runtime/components/Tabs.vue +127 -0
  77. package/dist/runtime/components/Textarea.vue +216 -0
  78. package/dist/runtime/components/Toast.vue +168 -0
  79. package/dist/runtime/components/Toaster.vue +143 -0
  80. package/dist/runtime/components/Tooltip.vue +94 -0
  81. package/dist/runtime/components/content/DescriptionList.vue +220 -0
  82. package/dist/runtime/composables/defineLocale.d.ts +9 -0
  83. package/dist/runtime/composables/defineLocale.js +4 -0
  84. package/dist/runtime/composables/defineShortcuts.d.ts +15 -0
  85. package/dist/runtime/composables/defineShortcuts.js +135 -0
  86. package/dist/runtime/composables/useAvatarGroup.d.ts +10 -0
  87. package/dist/runtime/composables/useAvatarGroup.js +10 -0
  88. package/dist/runtime/composables/useButtonGroup.d.ts +17 -0
  89. package/dist/runtime/composables/useButtonGroup.js +10 -0
  90. package/dist/runtime/composables/useComponentIcons.d.ts +20 -0
  91. package/dist/runtime/composables/useComponentIcons.js +25 -0
  92. package/dist/runtime/composables/useFormField.d.ts +42 -0
  93. package/dist/runtime/composables/useFormField.js +65 -0
  94. package/dist/runtime/composables/useKbd.d.ts +35 -0
  95. package/dist/runtime/composables/useKbd.js +52 -0
  96. package/dist/runtime/composables/useLocale.d.ts +4 -0
  97. package/dist/runtime/composables/useLocale.js +10 -0
  98. package/dist/runtime/composables/useToast.d.ts +12 -0
  99. package/dist/runtime/composables/useToast.js +62 -0
  100. package/dist/runtime/dictionary/icons.d.ts +20 -0
  101. package/dist/runtime/dictionary/icons.js +35 -0
  102. package/dist/runtime/index.css +1 -0
  103. package/dist/runtime/keyframes.css +1 -0
  104. package/dist/runtime/locale/en.d.ts +2 -0
  105. package/dist/runtime/locale/en.js +48 -0
  106. package/dist/runtime/locale/es.d.ts +2 -0
  107. package/dist/runtime/locale/es.js +48 -0
  108. package/dist/runtime/locale/index.d.ts +3 -0
  109. package/dist/runtime/locale/index.js +3 -0
  110. package/dist/runtime/locale/ru.d.ts +2 -0
  111. package/dist/runtime/locale/ru.js +48 -0
  112. package/dist/runtime/plugins/colors.d.ts +2 -0
  113. package/dist/runtime/plugins/colors.js +40 -0
  114. package/dist/runtime/types/app.config.d.ts +6 -0
  115. package/dist/runtime/types/form.d.ts +84 -0
  116. package/dist/runtime/types/form.js +12 -0
  117. package/dist/runtime/types/icons.d.ts +3 -0
  118. package/dist/runtime/types/icons.js +0 -0
  119. package/dist/runtime/types/index.d.ts +33 -0
  120. package/dist/runtime/types/index.js +33 -0
  121. package/dist/runtime/types/locale.d.ts +50 -0
  122. package/dist/runtime/types/locale.js +0 -0
  123. package/dist/runtime/types/utils.d.ts +22 -0
  124. package/dist/runtime/types/utils.js +0 -0
  125. package/dist/runtime/utils/form.d.ts +17 -0
  126. package/dist/runtime/utils/form.js +153 -0
  127. package/dist/runtime/utils/fuse.d.ts +4 -0
  128. package/dist/runtime/utils/fuse.js +63 -0
  129. package/dist/runtime/utils/index.d.ts +6 -0
  130. package/dist/runtime/utils/index.js +63 -0
  131. package/dist/runtime/utils/link.d.ts +29 -0
  132. package/dist/runtime/utils/link.js +4 -0
  133. package/dist/runtime/utils/locale.d.ts +15 -0
  134. package/dist/runtime/utils/locale.js +25 -0
  135. package/dist/runtime/utils/tv.d.ts +1 -0
  136. package/dist/runtime/utils/tv.js +4 -0
  137. package/dist/runtime/vue/components/Link.vue +203 -0
  138. package/dist/runtime/vue/plugins/color-mode.d.ts +4 -0
  139. package/dist/runtime/vue/plugins/color-mode.js +6 -0
  140. package/dist/runtime/vue/plugins/head.d.ts +4 -0
  141. package/dist/runtime/vue/plugins/head.js +6 -0
  142. package/dist/runtime/vue/stubs.d.ts +15 -0
  143. package/dist/runtime/vue/stubs.js +27 -0
  144. package/dist/shared/b24ui-nuxt.CNGvMe2S.mjs +4074 -0
  145. package/dist/shared/b24ui-nuxt.D22QQtm8.cjs +4079 -0
  146. package/dist/types.d.mts +1 -0
  147. package/dist/types.d.ts +1 -0
  148. package/dist/unplugin.cjs +213 -0
  149. package/dist/unplugin.d.cts +22 -0
  150. package/dist/unplugin.d.mts +22 -0
  151. package/dist/unplugin.d.ts +22 -0
  152. package/dist/unplugin.mjs +202 -0
  153. package/dist/vite.cjs +21 -0
  154. package/dist/vite.d.cts +12 -0
  155. package/dist/vite.d.mts +12 -0
  156. package/dist/vite.d.ts +12 -0
  157. package/dist/vite.mjs +19 -0
  158. package/package.json +166 -0
  159. package/vue-plugin.d.ts +5 -0
@@ -0,0 +1,114 @@
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
+ color?: BadgeVariants['color']
24
+ depth?: BadgeVariants['depth']
25
+ size?: BadgeVariants['size']
26
+ /** Shows 'underline' on hover */
27
+ useLink?: boolean
28
+ /** Shows `Cross20Icon` icon on the right side */
29
+ useClose?: boolean
30
+ onCloseClick?: ((event: MouseEvent) => void | Promise<void>) | Array<((event: MouseEvent) => void | Promise<void>)>
31
+ /** Fills the background */
32
+ useFill?: boolean
33
+ class?: any
34
+ b24ui?: Partial<typeof badge.slots>
35
+ }
36
+
37
+ export interface BadgeSlots {
38
+ leading(props?: {}): any
39
+ default(props?: {}): any
40
+ trailing(props?: {}): any
41
+ }
42
+ </script>
43
+
44
+ <script setup lang="ts">
45
+ import { computed } from 'vue'
46
+ import { Primitive } from 'reka-ui'
47
+ import { useComponentIcons } from '../composables/useComponentIcons'
48
+ import Cross20Icon from '@bitrix24/b24icons-vue/actions/Cross20Icon'
49
+
50
+ const props = withDefaults(defineProps<BadgeProps>(), {
51
+ as: 'span'
52
+ })
53
+
54
+ defineSlots<BadgeSlots>()
55
+
56
+ async function onCloseClickWrapper(event: MouseEvent) {
57
+ const callbacks = Array.isArray(props.onCloseClick) ? props.onCloseClick : [props.onCloseClick]
58
+ try {
59
+ await Promise.all(callbacks.map(fn => fn?.(event)))
60
+ } finally { /* empty */ }
61
+ }
62
+
63
+ const { isLeading, leadingIconName } = useComponentIcons(props)
64
+
65
+ const b24ui = computed(() => badge({
66
+ color: props.color,
67
+ depth: props.depth,
68
+ size: props.size,
69
+ useLink: Boolean(props.useLink),
70
+ useClose: Boolean(props.useClose),
71
+ useFill: Boolean(props.useFill),
72
+ leading: Boolean(isLeading.value)
73
+ }))
74
+ </script>
75
+
76
+ <template>
77
+ <Primitive
78
+ :as="as"
79
+ :class="b24ui.base({ class: [props.class, props.b24ui?.base] })"
80
+ >
81
+ <Primitive
82
+ :as="as"
83
+ :class="b24ui.wrapper({ class: props.b24ui?.wrapper })"
84
+ >
85
+ <slot name="leading">
86
+ <Component
87
+ :is="leadingIconName"
88
+ v-if="isLeading && leadingIconName"
89
+ :class="b24ui.leadingIcon({ class: props.b24ui?.leadingIcon })"
90
+ />
91
+ <B24Avatar
92
+ v-else-if="!!avatar"
93
+ :size="((props.b24ui?.leadingAvatarSize || b24ui.leadingAvatarSize()) as AvatarProps['size'])"
94
+ v-bind="avatar"
95
+ :class="b24ui.leadingAvatar({ class: props.b24ui?.leadingAvatar })"
96
+ />
97
+ </slot>
98
+
99
+ <slot>
100
+ <span v-if="label" :class="b24ui.label({ class: props.b24ui?.label })">
101
+ {{ label }}
102
+ </span>
103
+ </slot>
104
+ </Primitive>
105
+ <slot name="trailing">
106
+ <Cross20Icon
107
+ v-if="useClose"
108
+ :class="b24ui.trailingIcon({ class: props.b24ui?.trailingIcon })"
109
+ aria-hidden="true"
110
+ @click.stop.prevent="onCloseClickWrapper"
111
+ />
112
+ </slot>
113
+ </Primitive>
114
+ </template>
@@ -0,0 +1,177 @@
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/button'
6
+ import type { LinkProps } from './Link.vue'
7
+ import type { UseComponentIconsProps } from '../composables/useComponentIcons'
8
+ import { tv } from '../utils/tv'
9
+ import type { AvatarProps } from '../types'
10
+ import type { PartialString } from '../types/utils'
11
+
12
+ const appConfigButton = _appConfig as AppConfig & { b24ui: { button: Partial<typeof theme> } }
13
+
14
+ const button = tv({ extend: tv(theme), ...(appConfigButton.b24ui?.button || {}) })
15
+
16
+ type ButtonVariants = VariantProps<typeof button>
17
+
18
+ export interface ButtonProps extends Omit<UseComponentIconsProps, 'trailing' | 'trailingIcon'>, Omit<LinkProps, 'raw' | 'custom'> {
19
+ label?: string
20
+ color?: ButtonVariants['color']
21
+ depth?: ButtonVariants['depth']
22
+ size?: ButtonVariants['size']
23
+ /** Rounds the corners of the button. */
24
+ rounded?: boolean
25
+ /** Render the button full width. */
26
+ block?: boolean
27
+ /** Set loading state automatically based on the `@click` promise state */
28
+ loadingAuto?: boolean
29
+ /** Disable uppercase label */
30
+ normalCase?: boolean
31
+ /** Shows `Wait` icon in loading mode */
32
+ useWait?: boolean
33
+ /** Shows `Clock` icon in loading mode */
34
+ useClock?: boolean
35
+ /** Shows `ChevronDownIcon` icon on the right side */
36
+ useDropdown?: boolean
37
+ onClick?: ((event: MouseEvent) => void | Promise<void>) | Array<((event: MouseEvent) => void | Promise<void>)>
38
+ class?: any
39
+ b24ui?: PartialString<typeof button.slots>
40
+ }
41
+
42
+ export interface ButtonSlots {
43
+ leading(props?: {}): any
44
+ default(props?: {}): any
45
+ trailing(props?: {}): any
46
+ }
47
+ </script>
48
+
49
+ <script setup lang="ts">
50
+ import { type Ref, computed, ref, inject } from 'vue'
51
+ import { useForwardProps } from 'reka-ui'
52
+ import { useComponentIcons } from '../composables/useComponentIcons'
53
+ import { useButtonGroup } from '../composables/useButtonGroup'
54
+ import { formLoadingInjectionKey } from '../composables/useFormField'
55
+ import { omit } from '../utils'
56
+ import { pickLinkProps } from '../utils/link'
57
+ import B24Avatar from './Avatar.vue'
58
+ import B24Link from './Link.vue'
59
+ import ChevronDownIcon from '@bitrix24/b24icons-vue/actions/ChevronDownIcon'
60
+ import LoaderWaitIcon from '@bitrix24/b24icons-vue/animated/LoaderWaitIcon'
61
+ import LoaderClockIcon from '@bitrix24/b24icons-vue/animated/LoaderClockIcon'
62
+ import SpinnerIcon from '@bitrix24/b24icons-vue/specialized/SpinnerIcon'
63
+
64
+ const props = withDefaults(defineProps<ButtonProps>(), {
65
+ type: 'button'
66
+ })
67
+
68
+ const slots = defineSlots<ButtonSlots>()
69
+
70
+ const linkProps = useForwardProps(pickLinkProps(props))
71
+
72
+ const { orientation, size: buttonSize, noSplit } = useButtonGroup<ButtonProps>(props)
73
+
74
+ const loadingAutoState = ref(false)
75
+ const formLoading = inject<Ref<boolean> | undefined>(formLoadingInjectionKey, undefined)
76
+
77
+ async function onClickWrapper(event: MouseEvent) {
78
+ loadingAutoState.value = true
79
+ const callbacks = Array.isArray(props.onClick) ? props.onClick : [props.onClick]
80
+ try {
81
+ await Promise.all(callbacks.map(fn => fn?.(event)))
82
+ } finally {
83
+ loadingAutoState.value = false
84
+ }
85
+ }
86
+
87
+ const isLoading = computed(() => {
88
+ return props.loading || (props.loadingAuto && (loadingAutoState.value || (formLoading?.value && props.type === 'submit')))
89
+ })
90
+
91
+ const { isLeading, leadingIconName } = useComponentIcons(
92
+ computed(() => ({ ...props, loading: false }))
93
+ )
94
+
95
+ const isLabel = computed(() => {
96
+ let isUseSlot = false
97
+
98
+ if (slots && !!slots.default) {
99
+ isUseSlot = true
100
+ }
101
+
102
+ return (props?.label || '').length > 0 || isUseSlot
103
+ })
104
+
105
+ const b24ui = computed(() => button({
106
+ color: props.color,
107
+ depth: props.depth,
108
+ size: buttonSize.value,
109
+ noSplit: Boolean(noSplit.value),
110
+ loading: Boolean(isLoading.value),
111
+ useLabel: Boolean(isLabel.value),
112
+ block: Boolean(props.block),
113
+ normalCase: Boolean(props.normalCase),
114
+ rounded: Boolean(props.rounded),
115
+ useDropdown: Boolean(props.useDropdown),
116
+ useWait: Boolean(props.useWait),
117
+ useClock: Boolean(props.useClock),
118
+ leading: Boolean(isLeading.value),
119
+ buttonGroup: orientation.value
120
+ }))
121
+ </script>
122
+
123
+ <template>
124
+ <B24Link
125
+ :type="type"
126
+ :disabled="disabled || isLoading"
127
+ :class="b24ui.base({ class: [props.class, props.b24ui?.base] })"
128
+ v-bind="omit(linkProps, ['type', 'disabled'])"
129
+ raw
130
+ @click="onClickWrapper"
131
+ >
132
+ <div
133
+ class="h-full w-full absolute inset-0 flex flex-row flex-nowrap items-center justify-center"
134
+ :class="[
135
+ isLoading ? 'visible' : 'invisible'
136
+ ]"
137
+ >
138
+ <LoaderWaitIcon v-if="useWait" class="size-2xl" aria-hidden="true" />
139
+ <LoaderClockIcon v-else-if="useClock" class="size-2xl" aria-hidden="true" />
140
+ <SpinnerIcon v-else class="animate-spin stroke-2 size-lg" />
141
+ </div>
142
+ <div
143
+ :class="[
144
+ b24ui.baseLine({ class: [props.b24ui?.baseLine] }),
145
+ isLoading ? 'invisible' : ''
146
+ ]"
147
+ >
148
+ <slot name="leading">
149
+ <Component
150
+ :is="leadingIconName"
151
+ v-if="isLeading && (typeof leadingIconName !== 'undefined')"
152
+ :class="b24ui.leadingIcon({ class: props.b24ui?.leadingIcon })"
153
+ />
154
+ <B24Avatar
155
+ v-else-if="!!avatar"
156
+ :size="((props.b24ui?.leadingAvatarSize || b24ui.leadingAvatarSize()) as AvatarProps['size'])"
157
+ v-bind="avatar"
158
+ :class="b24ui.leadingAvatar({ class: props.b24ui?.leadingAvatar })"
159
+ />
160
+ </slot>
161
+
162
+ <slot>
163
+ <span v-if="label" :class="b24ui.label({ class: props.b24ui?.label })">
164
+ {{ label }}
165
+ </span>
166
+ </slot>
167
+
168
+ <slot name="trailing">
169
+ <ChevronDownIcon
170
+ v-if="useDropdown"
171
+ :class="b24ui.trailingIcon({ class: props.b24ui?.trailingIcon })"
172
+ aria-hidden="true"
173
+ />
174
+ </slot>
175
+ </div>
176
+ </B24Link>
177
+ </template>
@@ -0,0 +1,58 @@
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/button-group'
6
+ import { tv } from '../utils/tv'
7
+
8
+ const appConfigButtonGroup = _appConfig as AppConfig & { b24ui: { buttonGroup: Partial<typeof theme> } }
9
+
10
+ const buttonGroup = tv({ extend: tv(theme), ...(appConfigButtonGroup.b24ui?.buttonGroup) })
11
+
12
+ type ButtonGroupVariants = VariantProps<typeof buttonGroup>
13
+
14
+ export interface ButtonGroupProps {
15
+ /**
16
+ * The element or component this component should render as.
17
+ * @defaultValue 'div'
18
+ */
19
+ as?: any
20
+ size?: ButtonGroupVariants['size']
21
+ /**
22
+ * The orientation the buttons are laid out.
23
+ * @defaultValue 'horizontal'
24
+ */
25
+ orientation?: ButtonGroupVariants['orientation']
26
+ /** Disable split */
27
+ noSplit?: boolean
28
+ class?: any
29
+ }
30
+
31
+ export interface ButtonGroupSlots {
32
+ default(props?: {}): any
33
+ }
34
+ </script>
35
+
36
+ <script setup lang="ts">
37
+ import { provide, computed } from 'vue'
38
+ import { Primitive } from 'reka-ui'
39
+ import { buttonGroupInjectionKey } from '../composables/useButtonGroup'
40
+
41
+ const props = withDefaults(defineProps<ButtonGroupProps>(), {
42
+ orientation: 'horizontal',
43
+ noSplit: false
44
+ })
45
+ defineSlots<ButtonGroupSlots>()
46
+
47
+ provide(buttonGroupInjectionKey, computed(() => ({
48
+ orientation: props.orientation,
49
+ noSplit: Boolean(props.noSplit),
50
+ size: props.size
51
+ })))
52
+ </script>
53
+
54
+ <template>
55
+ <Primitive :as="as" :class="buttonGroup({ orientation, class: props.class })">
56
+ <slot />
57
+ </Primitive>
58
+ </template>
@@ -0,0 +1,110 @@
1
+ <script lang="ts">
2
+ import type { VariantProps } from 'tailwind-variants'
3
+ import type { CheckboxRootProps } from 'reka-ui'
4
+ import type { AppConfig } from '@nuxt/schema'
5
+ import _appConfig from '#build/app.config'
6
+ import theme from '#build/b24ui/checkbox'
7
+ import { tv } from '../utils/tv'
8
+
9
+ const appConfigCheckbox = _appConfig as AppConfig & { b24ui: { checkbox: Partial<typeof theme> } }
10
+
11
+ const checkbox = tv({ extend: tv(theme), ...(appConfigCheckbox.b24ui?.checkbox || {}) })
12
+
13
+ type CheckboxVariants = VariantProps<typeof checkbox>
14
+
15
+ export interface CheckboxProps extends Pick<CheckboxRootProps, 'disabled' | 'required' | 'name' | 'value' | 'id' | 'defaultValue'> {
16
+ /**
17
+ * The element or component this component should render as.
18
+ * @defaultValue 'div'
19
+ */
20
+ as?: any
21
+ label?: string
22
+ description?: string
23
+ color?: CheckboxVariants['color']
24
+ size?: CheckboxVariants['size']
25
+ class?: any
26
+ b24ui?: Partial<typeof checkbox.slots>
27
+ }
28
+
29
+ export type CheckboxEmits = {
30
+ change: [payload: Event]
31
+ }
32
+
33
+ export interface CheckboxSlots {
34
+ label(props: { label?: string }): any
35
+ description(props: { description?: string }): any
36
+ }
37
+ </script>
38
+
39
+ <script setup lang="ts">
40
+ import { computed, useId } from 'vue'
41
+ import { Primitive, CheckboxRoot, CheckboxIndicator, Label, useForwardProps } from 'reka-ui'
42
+ import { reactivePick } from '@vueuse/core'
43
+ import { useFormField } from '../composables/useFormField'
44
+ import Minus20Icon from '@bitrix24/b24icons-vue/actions/Minus20Icon'
45
+ import CheckIcon from '@bitrix24/b24icons-vue/main/CheckIcon'
46
+
47
+ const props = defineProps<CheckboxProps>()
48
+ const slots = defineSlots<CheckboxSlots>()
49
+ const emits = defineEmits<CheckboxEmits>()
50
+
51
+ const modelValue = defineModel<boolean | 'indeterminate'>({ default: undefined })
52
+
53
+ const rootProps = useForwardProps(reactivePick(props, 'required', 'value', 'defaultValue'))
54
+
55
+ const { id: _id, emitFormChange, emitFormInput, size, color, name, disabled, ariaAttrs } = useFormField<CheckboxProps>(props)
56
+ const id = _id.value ?? useId()
57
+
58
+ const b24ui = computed(() => checkbox({
59
+ size: size.value,
60
+ color: color.value,
61
+ required: props.required,
62
+ disabled: disabled.value,
63
+ checked: Boolean(modelValue.value ?? props.defaultValue)
64
+ }))
65
+
66
+ function onUpdate(value: any) {
67
+ // @ts-expect-error - 'target' does not exist in type 'EventInit'
68
+ const event = new Event('change', { target: { value } })
69
+ emits('change', event)
70
+ emitFormChange()
71
+ emitFormInput()
72
+ }
73
+ </script>
74
+
75
+ <!-- eslint-disable vue/no-template-shadow -->
76
+ <template>
77
+ <Primitive :as="as" :class="b24ui.root({ class: [props.class, props.b24ui?.root] })">
78
+ <div :class="b24ui.container({ class: props.b24ui?.container })">
79
+ <CheckboxRoot
80
+ :id="id"
81
+ v-bind="{ ...rootProps, ...ariaAttrs }"
82
+ v-model="modelValue"
83
+ :name="name"
84
+ :disabled="disabled"
85
+ :class="b24ui.base({ class: props.b24ui?.base })"
86
+ @update:model-value="onUpdate"
87
+ >
88
+ <template #default="{ modelValue }">
89
+ <CheckboxIndicator as-child>
90
+ <Minus20Icon v-if="modelValue === 'indeterminate'" :class="b24ui.icon({ class: props.b24ui?.icon })" />
91
+ <CheckIcon v-else :class="b24ui.icon({ class: props.b24ui?.icon })" />
92
+ </CheckboxIndicator>
93
+ </template>
94
+ </CheckboxRoot>
95
+ </div>
96
+
97
+ <div v-if="(label || !!slots.label) || (description || !!slots.description)" :class="b24ui.wrapper({ class: props.b24ui?.wrapper })">
98
+ <Label v-if="label || !!slots.label" :for="id" :class="b24ui.label({ class: props.b24ui?.label })">
99
+ <slot name="label" :label="label">
100
+ {{ label }}
101
+ </slot>
102
+ </Label>
103
+ <p v-if="description || !!slots.description" :class="b24ui.description({ class: props.b24ui?.description })">
104
+ <slot name="description" :description="description">
105
+ {{ description }}
106
+ </slot>
107
+ </p>
108
+ </div>
109
+ </Primitive>
110
+ </template>
@@ -0,0 +1,81 @@
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/chip'
6
+ import { tv } from '../utils/tv'
7
+
8
+ const appConfigChip = _appConfig as AppConfig & { b24ui: { chip: Partial<typeof theme> } }
9
+
10
+ const chip = tv({ extend: tv(theme), ...(appConfigChip.b24ui?.chip || {}) })
11
+
12
+ type ChipVariants = VariantProps<typeof chip>
13
+
14
+ export interface ChipProps {
15
+ /**
16
+ * The element or component this component should render as.
17
+ * @defaultValue 'div'
18
+ */
19
+ as?: any
20
+ /** Display some text inside the chip. */
21
+ text?: string | number
22
+ color?: ChipVariants['color']
23
+ size?: ChipVariants['size']
24
+ position?: ChipVariants['position']
25
+ /** When `true`, keep the chip inside the component for rounded elements */
26
+ inset?: boolean
27
+ /** When `true`, render the chip relatively to the parent. */
28
+ standalone?: boolean
29
+ class?: any
30
+ b24ui?: Partial<typeof chip.slots>
31
+ }
32
+
33
+ export interface ChipEmits {
34
+ (e: 'update:show', payload: boolean): void
35
+ }
36
+
37
+ export interface ChipSlots {
38
+ default(props?: {}): any
39
+ content(props?: {}): any
40
+ }
41
+ </script>
42
+
43
+ <script setup lang="ts">
44
+ import { computed } from 'vue'
45
+ import { Primitive, Slot } from 'reka-ui'
46
+ import { useAvatarGroup } from '../composables/useAvatarGroup'
47
+
48
+ defineOptions({ inheritAttrs: false })
49
+
50
+ const props = withDefaults(defineProps<ChipProps>(), {
51
+ inset: false,
52
+ standalone: false
53
+ })
54
+ defineSlots<ChipSlots>()
55
+
56
+ const show = defineModel<boolean>('show', { default: true })
57
+
58
+ const { size } = useAvatarGroup(props)
59
+
60
+ const b24ui = computed(() => chip({
61
+ color: props.color,
62
+ size: size.value,
63
+ position: props.position,
64
+ inset: Boolean(props.inset),
65
+ standalone: Boolean(props.standalone)
66
+ }))
67
+ </script>
68
+
69
+ <template>
70
+ <Primitive :as="as" :class="b24ui.root({ class: [props.class, props.b24ui?.root] })">
71
+ <Slot v-bind="$attrs">
72
+ <slot />
73
+ </Slot>
74
+
75
+ <span v-if="show" :class="b24ui.base({ class: props.b24ui?.base })">
76
+ <slot name="content">
77
+ {{ text }}
78
+ </slot>
79
+ </span>
80
+ </Primitive>
81
+ </template>
@@ -0,0 +1,36 @@
1
+ <script lang="ts">
2
+ import type { AppConfig } from '@nuxt/schema'
3
+ import _appConfig from '#build/app.config'
4
+ import theme from '#build/b24ui/container'
5
+ import { tv } from '../utils/tv'
6
+
7
+ const appConfigContainer = _appConfig as AppConfig & { b24ui: { container: Partial<typeof theme> } }
8
+
9
+ const container = tv({ extend: tv(theme), ...(appConfigContainer.b24ui?.container || {}) })
10
+
11
+ export interface ContainerProps {
12
+ /**
13
+ * The element or component this component should render as.
14
+ * @defaultValue 'div'
15
+ */
16
+ as?: any
17
+ class?: any
18
+ }
19
+
20
+ export interface ContainerSlots {
21
+ default(props?: {}): any
22
+ }
23
+ </script>
24
+
25
+ <script setup lang="ts">
26
+ import { Primitive } from 'reka-ui'
27
+
28
+ const props = defineProps<ContainerProps>()
29
+ defineSlots<ContainerSlots>()
30
+ </script>
31
+
32
+ <template>
33
+ <Primitive :as="as" :class="container({ class: props.class })">
34
+ <slot />
35
+ </Primitive>
36
+ </template>