@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,151 +1,178 @@
1
- <script>
2
- import _appConfig from "#build/app.config";
3
- import theme from "#build/b24ui/progress";
4
- import { tv } from "../utils/tv";
5
- const appConfigProgress = _appConfig;
6
- const progress = tv({ extend: tv(theme), ...appConfigProgress.b24ui?.progress || {} });
1
+ <!-- eslint-disable vue/block-tag-newline -->
2
+ <script lang="ts">
3
+ import type { VariantProps } from 'tailwind-variants'
4
+ import type { ProgressRootProps, ProgressRootEmits } from 'reka-ui'
5
+ import type { AppConfig } from '@nuxt/schema'
6
+ import _appConfig from '#build/app.config'
7
+ import theme from '#build/b24ui/progress'
8
+ import { tv } from '../utils/tv'
9
+
10
+ const appConfigProgress = _appConfig as AppConfig & { b24ui: { progress: Partial<typeof theme> } }
11
+
12
+ const progress = tv({ extend: tv(theme), ...(appConfigProgress.b24ui?.progress || {}) })
13
+
14
+ type ProgressVariants = VariantProps<typeof progress>
15
+
16
+ export interface ProgressProps extends Pick<ProgressRootProps, 'getValueLabel' | 'modelValue'> {
17
+ /**
18
+ * The element or component this component should render as.
19
+ * @defaultValue 'div'
20
+ */
21
+ as?: any
22
+ /**
23
+ * The maximum progress value
24
+ */
25
+ max?: number | Array<any>
26
+ /**
27
+ * Display the current progress value
28
+ */
29
+ status?: boolean
30
+ /**
31
+ * Whether the progress is visually inverted
32
+ * @defaultValue false
33
+ */
34
+ inverted?: boolean
35
+ /**
36
+ * @defaultValue 'md'
37
+ */
38
+ size?: ProgressVariants['size']
39
+ /**
40
+ * @defaultValue 'primary'
41
+ */
42
+ color?: ProgressVariants['color']
43
+ /**
44
+ * The orientation of the progress bar.
45
+ * @defaultValue 'horizontal'
46
+ */
47
+ orientation?: ProgressVariants['orientation']
48
+ /**
49
+ * @defaultValue 'loading'
50
+ */
51
+ animation?: ProgressVariants['animation']
52
+ class?: any
53
+ b24ui?: Partial<typeof progress.slots>
54
+ }
55
+
56
+ export interface ProgressEmits extends ProgressRootEmits {}
57
+
58
+ export type ProgressSlots = {
59
+ status(props: { percent?: number }): any
60
+ } & {
61
+ [key: string]: (props: { step: number }) => any
62
+ }
63
+
7
64
  </script>
8
65
 
9
- <script setup>
10
- import { computed } from "vue";
11
- import { useForwardPropsEmits } from "reka-ui";
12
- import { reactivePick } from "@vueuse/core";
13
- import { useLocale } from "../composables/useLocale";
14
- const props = defineProps({
15
- as: {
16
- type: null,
17
- required: false
18
- },
19
- max: {
20
- type: [Number, Array],
21
- required: false
22
- },
23
- status: {
24
- type: Boolean,
25
- required: false
26
- },
27
- inverted: {
28
- type: Boolean,
29
- required: false,
30
- default: false
31
- },
32
- size: {
33
- type: null,
34
- required: false
35
- },
36
- color: {
37
- type: null,
38
- required: false
39
- },
40
- orientation: {
41
- type: null,
42
- required: false,
43
- default: "horizontal"
44
- },
45
- animation: {
46
- type: null,
47
- required: false
48
- },
49
- class: {
50
- type: null,
51
- required: false
52
- },
53
- b24ui: {
54
- type: Object,
55
- required: false
56
- },
57
- getValueLabel: {
58
- type: Function,
59
- required: false
60
- },
61
- modelValue: {
62
- type: [Number, null],
63
- required: false,
64
- default: null
65
- }
66
- });
67
- const emits = defineEmits(["update:modelValue", "update:max"]);
68
- const slots = defineSlots();
69
- const { dir } = useLocale();
70
- const rootProps = useForwardPropsEmits(reactivePick(props, "getValueLabel", "modelValue"), emits);
71
- const isIndeterminate = computed(() => rootProps.value.modelValue === null);
72
- const hasSteps = computed(() => Array.isArray(props.max));
66
+ <script setup lang="ts">
67
+ import { computed } from 'vue'
68
+ import { Primitive, ProgressRoot, ProgressIndicator, useForwardPropsEmits } from 'reka-ui'
69
+ import { reactivePick } from '@vueuse/core'
70
+ import { useLocale } from '../composables/useLocale'
71
+
72
+ const props = withDefaults(defineProps<ProgressProps>(), {
73
+ inverted: false,
74
+ modelValue: null,
75
+ orientation: 'horizontal'
76
+ })
77
+ const emits = defineEmits<ProgressEmits>()
78
+ const slots = defineSlots<ProgressSlots>()
79
+
80
+ const { dir } = useLocale()
81
+
82
+ const rootProps = useForwardPropsEmits(reactivePick(props, 'getValueLabel', 'modelValue'), emits)
83
+
84
+ const isIndeterminate = computed(() => rootProps.value.modelValue === null)
85
+ const hasSteps = computed(() => Array.isArray(props.max))
86
+
73
87
  const realMax = computed(() => {
74
88
  if (isIndeterminate.value || !props.max) {
75
- return void 0;
89
+ return undefined
76
90
  }
91
+
77
92
  if (Array.isArray(props.max)) {
78
- return props.max.length - 1;
93
+ return props.max.length - 1
79
94
  }
80
- return Number(props.max);
81
- });
95
+
96
+ return Number(props.max)
97
+ })
98
+
82
99
  const percent = computed(() => {
83
100
  if (isIndeterminate.value) {
84
- return void 0;
101
+ return undefined
85
102
  }
103
+
86
104
  switch (true) {
87
- case rootProps.value.modelValue < 0:
88
- return 0;
89
- case rootProps.value.modelValue > (realMax.value ?? 100):
90
- return 100;
91
- default:
92
- return Math.round(rootProps.value.modelValue / (realMax.value ?? 100) * 100);
105
+ case rootProps.value.modelValue! < 0: return 0
106
+ case rootProps.value.modelValue! > (realMax.value ?? 100): return 100
107
+ default: return Math.round((rootProps.value.modelValue! / (realMax.value ?? 100)) * 100)
93
108
  }
94
- });
109
+ })
110
+
95
111
  const indicatorStyle = computed(() => {
96
- if (percent.value === void 0) {
97
- return;
112
+ if (percent.value === undefined) {
113
+ return
98
114
  }
99
- if (props.orientation === "vertical") {
115
+
116
+ if (props.orientation === 'vertical') {
100
117
  return {
101
- transform: `translateY(${props.inverted ? "" : "-"}${100 - percent.value}%)`
102
- };
118
+ transform: `translateY(${props.inverted ? '' : '-'}${100 - percent.value}%)`
119
+ }
103
120
  } else {
104
- if (dir.value === "rtl") {
121
+ if (dir.value === 'rtl') {
105
122
  return {
106
- transform: `translateX(${props.inverted ? "-" : ""}${100 - percent.value}%)`
107
- };
123
+ transform: `translateX(${props.inverted ? '-' : ''}${100 - percent.value}%)`
124
+ }
108
125
  } else {
109
126
  return {
110
- transform: `translateX(${props.inverted ? "" : "-"}${100 - percent.value}%)`
111
- };
127
+ transform: `translateX(${props.inverted ? '' : '-'}${100 - percent.value}%)`
128
+ }
112
129
  }
113
130
  }
114
- });
131
+ })
132
+
115
133
  const statusStyle = computed(() => {
116
134
  return {
117
- [props.orientation === "vertical" ? "height" : "width"]: percent.value ? `${percent.value}%` : "fit-content"
118
- };
119
- });
120
- function isActive(index) {
121
- return index === Number(props.modelValue);
135
+ [props.orientation === 'vertical' ? 'height' : 'width']: percent.value ? `${percent.value}%` : 'fit-content'
136
+ }
137
+ })
138
+
139
+ function isActive(index: number) {
140
+ return index === Number(props.modelValue)
122
141
  }
123
- function isFirst(index) {
124
- return index === 0;
142
+
143
+ function isFirst(index: number) {
144
+ return index === 0
125
145
  }
126
- function isLast(index) {
127
- return index === realMax.value;
146
+
147
+ function isLast(index: number) {
148
+ return index === realMax.value
128
149
  }
129
- function stepVariant(index) {
130
- index = Number(index);
150
+
151
+ function stepVariant(index: number | string) {
152
+ index = Number(index)
153
+
131
154
  if (isActive(index) && !isFirst(index)) {
132
- return "active";
155
+ return 'active'
133
156
  }
157
+
134
158
  if (isFirst(index) && isActive(index)) {
135
- return "first";
159
+ return 'first'
136
160
  }
161
+
137
162
  if (isLast(index) && isActive(index)) {
138
- return "last";
163
+ return 'last'
139
164
  }
140
- return "other";
165
+
166
+ return 'other'
141
167
  }
168
+
142
169
  const b24ui = computed(() => progress({
143
170
  animation: props.animation,
144
171
  size: props.size,
145
172
  color: props.color,
146
173
  orientation: props.orientation,
147
174
  inverted: props.inverted
148
- }));
175
+ }))
149
176
  </script>
150
177
 
151
178
  <template>
@@ -1,104 +1,110 @@
1
- <script>
2
- import _appConfig from "#build/app.config";
3
- import theme from "#build/b24ui/radio-group";
4
- import { tv } from "../utils/tv";
5
- const appConfigRadioGroup = _appConfig;
6
- const radioGroup = tv({ extend: tv(theme), ...appConfigRadioGroup.b24ui?.radioGroup || {} });
1
+ <script lang="ts">
2
+ import type { VariantProps } from 'tailwind-variants'
3
+ import type { RadioGroupRootProps, RadioGroupRootEmits } from 'reka-ui'
4
+ import type { AppConfig } from '@nuxt/schema'
5
+ import _appConfig from '#build/app.config'
6
+ import theme from '#build/b24ui/radio-group'
7
+ import { tv } from '../utils/tv'
8
+ import type { AcceptableValue } from '../types/utils'
9
+
10
+ const appConfigRadioGroup = _appConfig as AppConfig & { b24ui: { radioGroup: Partial<typeof theme> } }
11
+
12
+ const radioGroup = tv({ extend: tv(theme), ...(appConfigRadioGroup.b24ui?.radioGroup || {}) })
13
+
14
+ type RadioGroupVariants = VariantProps<typeof radioGroup>
15
+
16
+ export type RadioGroupValue = AcceptableValue
17
+ export type RadioGroupItem = {
18
+ label?: string
19
+ description?: string
20
+ disabled?: boolean
21
+ value?: string
22
+ [key: string]: any
23
+ } | RadioGroupValue
24
+
25
+ export interface RadioGroupProps<T extends RadioGroupItem = RadioGroupItem> extends Pick<RadioGroupRootProps, 'defaultValue' | 'disabled' | 'loop' | 'modelValue' | 'name' | 'required'> {
26
+ /**
27
+ * The element or component this component should render as.
28
+ * @defaultValue 'div'
29
+ */
30
+ as?: any
31
+ legend?: string
32
+ /**
33
+ * When `items` is an array of objects, select the field to use as the value.
34
+ * @defaultValue 'value'
35
+ */
36
+ valueKey?: string
37
+ /**
38
+ * When `items` is an array of objects, select the field to use as the label.
39
+ * @defaultValue 'label'
40
+ */
41
+ labelKey?: string
42
+ /**
43
+ * When `items` is an array of objects, select the field to use as the description.
44
+ * @defaultValue 'description'
45
+ */
46
+ descriptionKey?: string
47
+ items?: T[]
48
+ /**
49
+ * @defaultValue 'md'
50
+ */
51
+ size?: RadioGroupVariants['size']
52
+ /**
53
+ * @defaultValue 'list'
54
+ */
55
+ variant?: RadioGroupVariants['variant']
56
+ /**
57
+ * @defaultValue 'primary'
58
+ */
59
+ color?: RadioGroupVariants['color']
60
+ /**
61
+ * The orientation the radio buttons are laid out.
62
+ * @defaultValue 'vertical'
63
+ */
64
+ orientation?: RadioGroupRootProps['orientation']
65
+ /**
66
+ * Position of the indicator.
67
+ * @defaultValue 'start'
68
+ */
69
+ indicator?: RadioGroupVariants['indicator']
70
+ class?: any
71
+ b24ui?: Partial<typeof radioGroup.slots>
72
+ }
73
+
74
+ export type RadioGroupEmits = RadioGroupRootEmits & {
75
+ change: [payload: Event]
76
+ }
77
+
78
+ type SlotProps<T extends RadioGroupItem> = (props: { item: T & { id: string }, modelValue?: RadioGroupValue }) => any
79
+
80
+ export interface RadioGroupSlots<T extends RadioGroupItem = RadioGroupItem> {
81
+ legend(props?: {}): any
82
+ label: SlotProps<T>
83
+ description: SlotProps<T>
84
+ }
7
85
  </script>
8
86
 
9
- <script setup>
10
- import { computed, useId } from "vue";
11
- import { useForwardPropsEmits } from "reka-ui";
12
- import { reactivePick } from "@vueuse/core";
13
- import { useFormField } from "../composables/useFormField";
14
- import { get } from "../utils";
15
- const props = defineProps({
16
- as: {
17
- type: null,
18
- required: false
19
- },
20
- legend: {
21
- type: String,
22
- required: false
23
- },
24
- valueKey: {
25
- type: String,
26
- required: false,
27
- default: "value"
28
- },
29
- labelKey: {
30
- type: String,
31
- required: false,
32
- default: "label"
33
- },
34
- descriptionKey: {
35
- type: String,
36
- required: false,
37
- default: "description"
38
- },
39
- items: {
40
- type: Array,
41
- required: false
42
- },
43
- size: {
44
- type: null,
45
- required: false
46
- },
47
- variant: {
48
- type: null,
49
- required: false
50
- },
51
- color: {
52
- type: null,
53
- required: false
54
- },
55
- orientation: {
56
- type: null,
57
- required: false,
58
- default: "vertical"
59
- },
60
- indicator: {
61
- type: null,
62
- required: false
63
- },
64
- class: {
65
- type: null,
66
- required: false
67
- },
68
- b24ui: {
69
- type: Object,
70
- required: false
71
- },
72
- defaultValue: {
73
- type: [String, Number, Object, null],
74
- required: false
75
- },
76
- disabled: {
77
- type: Boolean,
78
- required: false
79
- },
80
- loop: {
81
- type: Boolean,
82
- required: false
83
- },
84
- modelValue: {
85
- type: [String, Number, Object, null],
86
- required: false
87
- },
88
- name: {
89
- type: String,
90
- required: false
91
- },
92
- required: {
93
- type: Boolean,
94
- required: false
95
- }
96
- });
97
- const emits = defineEmits(["update:modelValue", "change"]);
98
- const slots = defineSlots();
99
- const rootProps = useForwardPropsEmits(reactivePick(props, "as", "modelValue", "defaultValue", "orientation", "loop", "required"), emits);
100
- const { emitFormChange, emitFormInput, color, name, size, id: _id, disabled, ariaAttrs } = useFormField(props, { bind: false });
101
- const id = _id.value ?? useId();
87
+ <script setup lang="ts" generic="T extends RadioGroupItem">
88
+ import { computed, useId } from 'vue'
89
+ import { RadioGroupRoot, RadioGroupItem, RadioGroupIndicator, Label, useForwardPropsEmits } from 'reka-ui'
90
+ import { reactivePick } from '@vueuse/core'
91
+ import { useFormField } from '../composables/useFormField'
92
+ import { get } from '../utils'
93
+
94
+ const props = withDefaults(defineProps<RadioGroupProps<T>>(), {
95
+ valueKey: 'value',
96
+ labelKey: 'label',
97
+ descriptionKey: 'description',
98
+ orientation: 'vertical'
99
+ })
100
+ const emits = defineEmits<RadioGroupEmits>()
101
+ const slots = defineSlots<RadioGroupSlots<T>>()
102
+
103
+ const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'modelValue', 'defaultValue', 'orientation', 'loop', 'required'), emits)
104
+
105
+ const { emitFormChange, emitFormInput, color, name, size, id: _id, disabled, ariaAttrs } = useFormField<RadioGroupProps<T>>(props, { bind: false })
106
+ const id = _id.value ?? useId()
107
+
102
108
  const b24ui = computed(() => radioGroup({
103
109
  size: size.value,
104
110
  color: color.value,
@@ -107,44 +113,52 @@ const b24ui = computed(() => radioGroup({
107
113
  orientation: props.orientation,
108
114
  variant: props.variant,
109
115
  indicator: props.indicator
110
- }));
111
- function normalizeItem(item) {
116
+ }))
117
+
118
+ function normalizeItem(item: any) {
112
119
  if (item === null) {
113
120
  return {
114
121
  id: `${id}:null`,
115
- value: void 0,
116
- label: void 0
117
- };
122
+ value: undefined,
123
+ label: undefined
124
+ }
118
125
  }
119
- if (typeof item === "string" || typeof item === "number") {
126
+
127
+ if (typeof item === 'string' || typeof item === 'number') {
120
128
  return {
121
129
  id: `${id}:${item}`,
122
130
  value: String(item),
123
131
  label: String(item)
124
- };
132
+ }
125
133
  }
126
- const value = get(item, props.valueKey);
127
- const label = get(item, props.labelKey);
128
- const description = get(item, props.descriptionKey);
134
+
135
+ const value = get(item, props.valueKey as string)
136
+ const label = get(item, props.labelKey as string)
137
+ const description = get(item, props.descriptionKey as string)
138
+
129
139
  return {
130
140
  ...item,
131
141
  value,
132
142
  label,
133
143
  description,
134
144
  id: `${id}:${value}`
135
- };
145
+ }
136
146
  }
147
+
137
148
  const normalizedItems = computed(() => {
138
149
  if (!props.items) {
139
- return [];
150
+ return []
140
151
  }
141
- return props.items.map(normalizeItem);
142
- });
143
- function onUpdate(value) {
144
- const event = new Event("change", { target: { value } });
145
- emits("change", event);
146
- emitFormChange();
147
- emitFormInput();
152
+
153
+ return props.items.map(normalizeItem)
154
+ })
155
+
156
+ function onUpdate(value: any) {
157
+ // @ts-expect-error - 'target' does not exist in type 'EventInit'
158
+ const event = new Event('change', { target: { value } })
159
+ emits('change', event)
160
+ emitFormChange()
161
+ emitFormInput()
148
162
  }
149
163
  </script>
150
164
 
@@ -178,12 +192,12 @@ function onUpdate(value) {
178
192
 
179
193
  <div :class="b24ui.wrapper({ class: props.b24ui?.wrapper })">
180
194
  <component :is="variant === 'list' ? Label : 'p'" :class="b24ui.label({ class: props.b24ui?.label })" :for="item.id">
181
- <slot name="label" :item="item" :model-value="modelValue">
195
+ <slot name="label" :item="item" :model-value="(modelValue as RadioGroupValue)">
182
196
  {{ item.label }}
183
197
  </slot>
184
198
  </component>
185
199
  <p v-if="item.description || !!slots.description" :class="b24ui.description({ class: props.b24ui?.description })">
186
- <slot name="description" :item="item" :model-value="modelValue">
200
+ <slot name="description" :item="item" :model-value="(modelValue as RadioGroupValue)">
187
201
  {{ item.description }}
188
202
  </slot>
189
203
  </p>