@byyuurin/ui 0.0.10 → 0.0.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 (194) hide show
  1. package/README.md +2 -2
  2. package/dist/module.json +3 -3
  3. package/dist/module.mjs +1 -1
  4. package/dist/module.mjs.map +1 -1
  5. package/dist/runtime/app/injections.d.ts +388 -364
  6. package/dist/runtime/components/Accordion.vue +38 -67
  7. package/dist/runtime/components/Accordion.vue.d.ts +52 -0
  8. package/dist/runtime/components/Alert.vue +37 -75
  9. package/dist/runtime/components/Alert.vue.d.ts +59 -0
  10. package/dist/runtime/components/App.vue +25 -40
  11. package/dist/runtime/components/App.vue.d.ts +24 -0
  12. package/dist/runtime/components/Avatar.vue +31 -51
  13. package/dist/runtime/components/Avatar.vue.d.ts +25 -0
  14. package/dist/runtime/components/AvatarGroup.vue +38 -69
  15. package/dist/runtime/components/AvatarGroup.vue.d.ts +27 -0
  16. package/dist/runtime/components/Badge.vue +25 -51
  17. package/dist/runtime/components/Badge.vue.d.ts +44 -0
  18. package/dist/runtime/components/Breadcrumb.vue +36 -74
  19. package/dist/runtime/components/Breadcrumb.vue.d.ts +52 -0
  20. package/dist/runtime/components/Button.vue +62 -51
  21. package/dist/runtime/components/Button.vue.d.ts +29 -0
  22. package/dist/runtime/components/ButtonGroup.vue +17 -37
  23. package/dist/runtime/components/ButtonGroup.vue.d.ts +26 -0
  24. package/dist/runtime/components/Calendar.vue +75 -110
  25. package/dist/runtime/components/Calendar.vue.d.ts +75 -0
  26. package/dist/runtime/components/Card.vue +25 -42
  27. package/dist/runtime/components/Card.vue.d.ts +30 -0
  28. package/dist/runtime/components/Carousel.vue +118 -225
  29. package/dist/runtime/components/Carousel.vue.d.ts +104 -0
  30. package/dist/runtime/components/Checkbox.vue +46 -73
  31. package/dist/runtime/components/Checkbox.vue.d.ts +56 -0
  32. package/dist/runtime/components/Chip.vue +31 -48
  33. package/dist/runtime/components/Chip.vue.d.ts +30 -0
  34. package/dist/runtime/components/Collapsible.vue +22 -30
  35. package/dist/runtime/components/Collapsible.vue.d.ts +26 -0
  36. package/dist/runtime/components/Drawer.vue +51 -101
  37. package/dist/runtime/components/Drawer.vue.d.ts +80 -0
  38. package/dist/runtime/components/DropdownMenu.vue +37 -115
  39. package/dist/runtime/components/DropdownMenu.vue.d.ts +99 -0
  40. package/dist/runtime/components/DropdownMenuContent.vue +81 -77
  41. package/dist/runtime/components/DropdownMenuContent.vue.d.ts +39 -0
  42. package/dist/runtime/components/Form.vue +140 -254
  43. package/dist/runtime/components/Form.vue.d.ts +78 -0
  44. package/dist/runtime/components/FormItem.vue +50 -89
  45. package/dist/runtime/components/FormItem.vue.d.ts +60 -0
  46. package/dist/runtime/components/Input.vue +79 -115
  47. package/dist/runtime/components/Input.vue.d.ts +64 -0
  48. package/dist/runtime/components/InputNumber.vue +74 -117
  49. package/dist/runtime/components/InputNumber.vue.d.ts +245 -0
  50. package/dist/runtime/components/Kbd.vue +18 -39
  51. package/dist/runtime/components/Kbd.vue.d.ts +28 -0
  52. package/dist/runtime/components/Link.vue +168 -257
  53. package/dist/runtime/components/Link.vue.d.ts +95 -0
  54. package/dist/runtime/components/LinkBase.vue +36 -54
  55. package/dist/runtime/components/LinkBase.vue.d.ts +28 -0
  56. package/dist/runtime/components/Modal.vue +49 -84
  57. package/dist/runtime/components/Modal.vue.d.ts +66 -0
  58. package/dist/runtime/components/OverlayProvider.vue +10 -14
  59. package/dist/runtime/components/OverlayProvider.vue.d.ts +2 -0
  60. package/dist/runtime/components/Pagination.vue +55 -121
  61. package/dist/runtime/components/Pagination.vue.d.ts +93 -0
  62. package/dist/runtime/components/PinInput.vue +49 -58
  63. package/dist/runtime/components/PinInput.vue.d.ts +35 -0
  64. package/dist/runtime/components/Popover.vue +39 -68
  65. package/dist/runtime/components/Popover.vue.d.ts +45 -0
  66. package/dist/runtime/components/Progress.vue +68 -120
  67. package/dist/runtime/components/Progress.vue.d.ts +54 -0
  68. package/dist/runtime/components/RadioGroup.vue +67 -125
  69. package/dist/runtime/components/RadioGroup.vue.d.ts +74 -0
  70. package/dist/runtime/components/ScrollArea.vue +31 -31
  71. package/dist/runtime/components/ScrollArea.vue.d.ts +17 -0
  72. package/dist/runtime/components/Select.vue +114 -204
  73. package/dist/runtime/components/Select.vue.d.ts +119 -0
  74. package/dist/runtime/components/Separator.vue +26 -44
  75. package/dist/runtime/components/Separator.vue.d.ts +27 -0
  76. package/dist/runtime/components/Skeleton.vue +12 -21
  77. package/dist/runtime/components/Skeleton.vue.d.ts +19 -0
  78. package/dist/runtime/components/Slider.vue +52 -74
  79. package/dist/runtime/components/Slider.vue.d.ts +36 -0
  80. package/dist/runtime/components/Switch.vue +51 -71
  81. package/dist/runtime/components/Switch.vue.d.ts +49 -0
  82. package/dist/runtime/components/Table.vue +108 -194
  83. package/dist/runtime/components/Table.vue.d.ts +148 -0
  84. package/dist/runtime/components/Tabs.vue +36 -81
  85. package/dist/runtime/components/Tabs.vue.d.ts +65 -0
  86. package/dist/runtime/components/Textarea.vue +77 -124
  87. package/dist/runtime/components/Textarea.vue.d.ts +60 -0
  88. package/dist/runtime/components/Toast.vue +47 -75
  89. package/dist/runtime/components/Toast.vue.d.ts +131 -0
  90. package/dist/runtime/components/ToastProvider.vue +65 -101
  91. package/dist/runtime/components/ToastProvider.vue.d.ts +38 -0
  92. package/dist/runtime/components/Tooltip.vue +36 -47
  93. package/dist/runtime/components/Tooltip.vue.d.ts +31 -0
  94. package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
  95. package/dist/runtime/composables/useButtonGroup.d.ts +2 -2
  96. package/dist/runtime/composables/useFormItem.d.ts +2 -2
  97. package/dist/runtime/composables/useKbd.d.ts +1 -1
  98. package/dist/runtime/composables/useLocale.d.ts +3 -3
  99. package/dist/runtime/composables/useTheme.d.ts +1 -1
  100. package/dist/runtime/composables/useToast.d.ts +1 -1
  101. package/dist/runtime/locale/en.d.ts +1 -1
  102. package/dist/runtime/locale/zh-tw.d.ts +1 -1
  103. package/dist/runtime/theme/accordion.d.ts +45 -51
  104. package/dist/runtime/theme/accordion.js +1 -1
  105. package/dist/runtime/theme/alert.d.ts +115 -121
  106. package/dist/runtime/theme/alert.js +1 -1
  107. package/dist/runtime/theme/avatar-group.d.ts +42 -48
  108. package/dist/runtime/theme/avatar-group.js +1 -1
  109. package/dist/runtime/theme/avatar.d.ts +46 -52
  110. package/dist/runtime/theme/avatar.js +1 -1
  111. package/dist/runtime/theme/badge.d.ts +60 -66
  112. package/dist/runtime/theme/badge.js +1 -1
  113. package/dist/runtime/theme/breadcrumb.d.ts +52 -58
  114. package/dist/runtime/theme/breadcrumb.js +1 -1
  115. package/dist/runtime/theme/button-group.d.ts +36 -42
  116. package/dist/runtime/theme/button.d.ts +162 -168
  117. package/dist/runtime/theme/button.js +1 -1
  118. package/dist/runtime/theme/calendar.d.ts +52 -50
  119. package/dist/runtime/theme/calendar.js +20 -3
  120. package/dist/runtime/theme/card.d.ts +52 -58
  121. package/dist/runtime/theme/card.js +1 -1
  122. package/dist/runtime/theme/carousel.d.ts +98 -104
  123. package/dist/runtime/theme/carousel.js +1 -1
  124. package/dist/runtime/theme/checkbox.d.ts +77 -83
  125. package/dist/runtime/theme/checkbox.js +1 -1
  126. package/dist/runtime/theme/chip.d.ts +50 -56
  127. package/dist/runtime/theme/chip.js +1 -1
  128. package/dist/runtime/theme/collapsible.d.ts +29 -35
  129. package/dist/runtime/theme/collapsible.js +1 -1
  130. package/dist/runtime/theme/drawer.d.ts +120 -126
  131. package/dist/runtime/theme/drawer.js +1 -1
  132. package/dist/runtime/theme/dropdown-menu.d.ts +55 -61
  133. package/dist/runtime/theme/dropdown-menu.js +1 -1
  134. package/dist/runtime/theme/form-item.d.ts +63 -69
  135. package/dist/runtime/theme/form-item.js +1 -1
  136. package/dist/runtime/theme/form.d.ts +1 -7
  137. package/dist/runtime/theme/input-number.d.ts +98 -104
  138. package/dist/runtime/theme/input-number.js +1 -1
  139. package/dist/runtime/theme/input.d.ts +153 -159
  140. package/dist/runtime/theme/input.js +1 -1
  141. package/dist/runtime/theme/kbd.d.ts +30 -36
  142. package/dist/runtime/theme/link.d.ts +37 -43
  143. package/dist/runtime/theme/modal.d.ts +36 -42
  144. package/dist/runtime/theme/modal.js +1 -1
  145. package/dist/runtime/theme/pagination.d.ts +71 -77
  146. package/dist/runtime/theme/pagination.js +1 -1
  147. package/dist/runtime/theme/pinInput.d.ts +80 -86
  148. package/dist/runtime/theme/pinInput.js +1 -1
  149. package/dist/runtime/theme/popover.d.ts +29 -35
  150. package/dist/runtime/theme/popover.js +1 -1
  151. package/dist/runtime/theme/progress.d.ts +163 -169
  152. package/dist/runtime/theme/progress.js +1 -1
  153. package/dist/runtime/theme/radio-group.d.ts +99 -105
  154. package/dist/runtime/theme/radio-group.js +1 -1
  155. package/dist/runtime/theme/scroll-area.d.ts +62 -68
  156. package/dist/runtime/theme/scroll-area.js +1 -1
  157. package/dist/runtime/theme/select.d.ts +165 -171
  158. package/dist/runtime/theme/select.js +1 -1
  159. package/dist/runtime/theme/separator.d.ts +62 -68
  160. package/dist/runtime/theme/separator.js +1 -1
  161. package/dist/runtime/theme/skeleton.d.ts +1 -7
  162. package/dist/runtime/theme/slider.d.ts +62 -68
  163. package/dist/runtime/theme/slider.js +1 -1
  164. package/dist/runtime/theme/switch.d.ts +111 -117
  165. package/dist/runtime/theme/switch.js +1 -1
  166. package/dist/runtime/theme/table.d.ts +75 -81
  167. package/dist/runtime/theme/table.js +1 -1
  168. package/dist/runtime/theme/tabs.d.ts +114 -120
  169. package/dist/runtime/theme/tabs.js +1 -1
  170. package/dist/runtime/theme/textarea.d.ts +76 -82
  171. package/dist/runtime/theme/textarea.js +1 -1
  172. package/dist/runtime/theme/toast-provider.d.ts +106 -112
  173. package/dist/runtime/theme/toast-provider.js +1 -1
  174. package/dist/runtime/theme/toast.d.ts +74 -80
  175. package/dist/runtime/theme/toast.js +1 -1
  176. package/dist/runtime/theme/tooltip.d.ts +35 -41
  177. package/dist/runtime/theme/tooltip.js +1 -1
  178. package/dist/runtime/types/utils.d.ts +5 -5
  179. package/dist/runtime/utils/link.d.ts +3 -5
  180. package/dist/runtime/utils/styler.d.ts +2 -2
  181. package/dist/runtime/utils/styler.js +2 -2
  182. package/dist/shared/ui.D1BTWZFB.mjs +5 -0
  183. package/dist/shared/ui.D1BTWZFB.mjs.map +1 -0
  184. package/dist/types.d.mts +1 -1
  185. package/dist/unocss.mjs +5 -4
  186. package/dist/unocss.mjs.map +1 -1
  187. package/dist/unplugin.mjs +1 -1
  188. package/dist/unplugin.mjs.map +1 -1
  189. package/dist/vite.mjs +1 -1
  190. package/package.json +77 -75
  191. package/dist/module.cjs +0 -5
  192. package/dist/shared/ui.3e7fad19.mjs +0 -5
  193. package/dist/shared/ui.3e7fad19.mjs.map +0 -1
  194. package/dist/types.d.ts +0 -1
@@ -1,141 +1,88 @@
1
- <script lang="ts">
2
- import type { VariantProps } from '@byyuurin/ui-kit'
3
- import type { PrimitiveProps, ProgressRootEmits, ProgressRootProps } from 'reka-ui'
4
- import type { progress } from '../theme'
5
- import type { ComponentAttrs } from '../types'
1
+ <script>
6
2
 
7
- export interface ProgressEmits extends ProgressRootEmits {}
8
-
9
- export type ProgressSlots = {
10
- status?: (props: { percent?: number }) => any
11
- } & {
12
- [key: `step-${number}`]: (props: { step: string | number }) => any
13
- }
14
-
15
- type ProgressVariants = VariantProps<typeof progress>
16
-
17
- export interface ProgressProps extends ComponentAttrs<typeof progress>, Pick<ProgressRootProps, 'getValueLabel' | 'modelValue'> {
18
- /**
19
- * The element or component this component should render as.
20
- * @default "div"
21
- */
22
- as?: PrimitiveProps['as']
23
- /** The maximum progress value. */
24
- max?: number | string[]
25
- /**
26
- * @default "md"
27
- */
28
- size?: ProgressVariants['size']
29
- /**
30
- * The orientation of the progress bar.
31
- * @default "horizontal"
32
- */
33
- orientation?: ProgressVariants['orientation']
34
- /** Display the current progress value. */
35
- status?: boolean
36
- /** Whether the progress is visually inverted. */
37
- inverted?: boolean
38
- }
39
3
  </script>
40
4
 
41
- <script setup lang="ts">
42
- import { reactivePick } from '@vueuse/core'
43
- import { Primitive, ProgressIndicator, ProgressRoot, useForwardPropsEmits } from 'reka-ui'
44
- import { computed } from 'vue'
45
- import { useLocale } from '../composables/useLocale'
46
- import { useTheme } from '../composables/useTheme'
47
-
48
- const props = withDefaults(defineProps<ProgressProps>(), {
49
- modelValue: null,
50
- orientation: 'horizontal',
51
- })
52
- const emit = defineEmits<ProgressEmits>()
53
- const slots = defineSlots<ProgressSlots>()
54
-
55
- const rootProps = useForwardPropsEmits(reactivePick(props, 'getValueLabel', 'modelValue'), emit)
56
-
57
- const isIndeterminate = computed(() => rootProps.value.modelValue === null || Number.isNaN(+rootProps.value.modelValue))
58
- const hasSteps = computed(() => Array.isArray(props.max))
59
-
5
+ <script setup>
6
+ import { reactivePick } from "@vueuse/core";
7
+ import { Primitive, ProgressIndicator, ProgressRoot, useForwardPropsEmits } from "reka-ui";
8
+ import { computed } from "vue";
9
+ import { useLocale } from "../composables/useLocale";
10
+ import { useTheme } from "../composables/useTheme";
11
+ const props = defineProps({
12
+ as: { type: null, required: false },
13
+ max: { type: [Number, Array], required: false },
14
+ size: { type: null, required: false },
15
+ orientation: { type: null, required: false, default: "horizontal" },
16
+ status: { type: Boolean, required: false },
17
+ inverted: { type: Boolean, required: false },
18
+ class: { type: null, required: false },
19
+ ui: { type: null, required: false },
20
+ getValueLabel: { type: Function, required: false },
21
+ modelValue: { type: [Number, null], required: false, default: null }
22
+ });
23
+ const emit = defineEmits(["update:modelValue", "update:max"]);
24
+ const slots = defineSlots();
25
+ const rootProps = useForwardPropsEmits(reactivePick(props, "getValueLabel", "modelValue"), emit);
26
+ const isIndeterminate = computed(() => rootProps.value.modelValue === null || Number.isNaN(+rootProps.value.modelValue));
27
+ const hasSteps = computed(() => Array.isArray(props.max));
60
28
  const max = computed(() => {
61
29
  if (isIndeterminate.value || !props.max)
62
- return
63
-
30
+ return;
64
31
  if (Array.isArray(props.max))
65
- return props.max.length - 1
66
-
67
- return Number(props.max)
68
- })
69
-
32
+ return props.max.length - 1;
33
+ return Number(props.max);
34
+ });
70
35
  const percent = computed(() => {
71
36
  if (isIndeterminate.value)
72
- return
73
-
74
- if (rootProps.value.modelValue! < 0)
75
- return 0
76
-
77
- const _max = max.value ?? 100
78
-
79
- if (rootProps.value.modelValue! > _max)
80
- return 100
81
-
82
- return Math.round((rootProps.value.modelValue! / _max) * 100)
83
- })
84
-
85
- const { dir } = useLocale()
86
- const { generateStyle } = useTheme()
87
- const style = computed(() => generateStyle('progress', props))
88
-
37
+ return;
38
+ if (rootProps.value.modelValue < 0)
39
+ return 0;
40
+ const _max = max.value ?? 100;
41
+ if (rootProps.value.modelValue > _max)
42
+ return 100;
43
+ return Math.round(rootProps.value.modelValue / _max * 100);
44
+ });
45
+ const { dir } = useLocale();
46
+ const { generateStyle } = useTheme();
47
+ const style = computed(() => generateStyle("progress", props));
89
48
  const indicatorStyle = computed(() => {
90
- if (percent.value === undefined)
91
- return
92
-
93
- if (props.orientation === 'vertical')
94
- return { transform: `translateY(${props.inverted ? '' : '-'}${100 - percent.value}%)` }
95
-
96
- if (dir.value === 'rtl')
97
- return { transform: `translateX(${props.inverted ? '-' : ''}${100 - percent.value}%)` }
98
-
99
- return { transform: `translateX(${props.inverted ? '' : '-'}${100 - percent.value}%)` }
100
- })
101
-
49
+ if (percent.value === void 0)
50
+ return;
51
+ if (props.orientation === "vertical")
52
+ return { transform: `translateY(${props.inverted ? "" : "-"}${100 - percent.value}%)` };
53
+ if (dir.value === "rtl")
54
+ return { transform: `translateX(${props.inverted ? "-" : ""}${100 - percent.value}%)` };
55
+ return { transform: `translateX(${props.inverted ? "" : "-"}${100 - percent.value}%)` };
56
+ });
102
57
  const statusStyle = computed(() => {
103
58
  return {
104
- [props.orientation === 'vertical' ? 'height' : 'width']: percent.value ? `${percent.value}%` : 'fit-content',
105
- }
106
- })
107
-
108
- function isActive(index: number) {
109
- return index === Number(props.modelValue)
59
+ [props.orientation === "vertical" ? "height" : "width"]: percent.value ? `${percent.value}%` : "fit-content"
60
+ };
61
+ });
62
+ function isActive(index) {
63
+ return index === Number(props.modelValue);
110
64
  }
111
-
112
- function isFirst(index: number) {
113
- return index === 0
65
+ function isFirst(index) {
66
+ return index === 0;
114
67
  }
115
-
116
- function isLast(index: number) {
117
- return index === max.value
68
+ function isLast(index) {
69
+ return index === max.value;
118
70
  }
119
-
120
- function stepVariant(index: number | string) {
121
- index = Number(index)
122
-
71
+ function stepVariant(index) {
72
+ index = Number(index);
123
73
  if (isActive(index) && !isFirst(index))
124
- return 'active'
125
-
74
+ return "active";
126
75
  if (isFirst(index) && isActive(index))
127
- return 'first'
128
-
76
+ return "first";
129
77
  if (isLast(index) && isActive(index))
130
- return 'last'
131
-
132
- return 'other'
78
+ return "last";
79
+ return "other";
133
80
  }
134
81
  </script>
135
82
 
136
83
  <template>
137
- <Primitive :as="props.as" :class="style.wrapper({ class: [props.class, props.ui?.wrapper] })">
138
- <div v-if="!isIndeterminate && (props.status || slots.status)" :class="style.status({ class: props.ui?.status })" :style="statusStyle">
84
+ <Primitive :as="props.as" :class="style.wrapper({ class: [props.class, props.ui?.wrapper] })" data-part="wrapper">
85
+ <div v-if="!isIndeterminate && (props.status || slots.status)" :class="style.status({ class: props.ui?.status })" data-part="status" :style="statusStyle">
139
86
  <slot name="status" :percent="percent">
140
87
  {{ percent }}%
141
88
  </slot>
@@ -146,13 +93,14 @@ function stepVariant(index: number | string) {
146
93
  :model-value="Number.isNaN(rootProps.modelValue) ? null : rootProps.modelValue"
147
94
  :max="max"
148
95
  :class="style.root({ class: props.ui?.root })"
96
+ data-part="root"
149
97
  style="transform: translateZ(0)"
150
98
  >
151
- <ProgressIndicator :class="style.indicator({ class: props.ui?.indicator })" :style="indicatorStyle" />
99
+ <ProgressIndicator :class="style.indicator({ class: props.ui?.indicator })" data-part="indicator" :style="indicatorStyle" />
152
100
  </ProgressRoot>
153
101
 
154
- <div v-if="hasSteps" :class="style.steps({ class: props.ui?.steps })">
155
- <div v-for="(step, index) in props.max" :key="index" :class="style.step({ class: props.ui?.step, step: stepVariant(index) })">
102
+ <div v-if="hasSteps" :class="style.steps({ class: props.ui?.steps })" data-part="steps">
103
+ <div v-for="(step, index) in props.max" :key="index" :class="style.step({ class: props.ui?.step, step: stepVariant(index) })" data-part="step">
156
104
  <slot :name="`step-${index}`" :step="step">
157
105
  {{ step }}
158
106
  </slot>
@@ -0,0 +1,54 @@
1
+ import type { VariantProps } from '@byyuurin/ui-kit';
2
+ import type { PrimitiveProps, ProgressRootEmits, ProgressRootProps } from 'reka-ui';
3
+ import type { progress } from '../theme/index.js';
4
+ import type { ComponentAttrs } from '../types/index.js';
5
+ export interface ProgressEmits extends ProgressRootEmits {
6
+ }
7
+ export type ProgressSlots = {
8
+ status?: (props: {
9
+ percent?: number;
10
+ }) => any;
11
+ } & {
12
+ [key: `step-${number}`]: (props: {
13
+ step: string | number;
14
+ }) => any;
15
+ };
16
+ type ProgressVariants = VariantProps<typeof progress>;
17
+ export interface ProgressProps extends ComponentAttrs<typeof progress>, Pick<ProgressRootProps, 'getValueLabel' | 'modelValue'> {
18
+ /**
19
+ * The element or component this component should render as.
20
+ * @default "div"
21
+ */
22
+ as?: PrimitiveProps['as'];
23
+ /** The maximum progress value. */
24
+ max?: number | string[];
25
+ /**
26
+ * @default "md"
27
+ */
28
+ size?: ProgressVariants['size'];
29
+ /**
30
+ * The orientation of the progress bar.
31
+ * @default "horizontal"
32
+ */
33
+ orientation?: ProgressVariants['orientation'];
34
+ /** Display the current progress value. */
35
+ status?: boolean;
36
+ /** Whether the progress is visually inverted. */
37
+ inverted?: boolean;
38
+ }
39
+ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<ProgressProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
40
+ "update:modelValue": (value: string[] | undefined) => any;
41
+ "update:max": (value: number) => any;
42
+ }, string, import("vue").PublicProps, Readonly<ProgressProps> & Readonly<{
43
+ "onUpdate:modelValue"?: ((value: string[] | undefined) => any) | undefined;
44
+ "onUpdate:max"?: ((value: number) => any) | undefined;
45
+ }>, {
46
+ orientation: "horizontal" | "vertical";
47
+ modelValue: number | null;
48
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, ProgressSlots>;
49
+ export default _default;
50
+ type __VLS_WithSlots<T, S> = T & {
51
+ new (): {
52
+ $slots: S;
53
+ };
54
+ };
@@ -1,141 +1,81 @@
1
- <script lang="ts">
2
- import type { VariantProps } from '@byyuurin/ui-kit'
3
- import type { PrimitiveProps, RadioGroupRootProps } from 'reka-ui'
4
- import type { radioGroup } from '../theme'
5
- import type { AcceptableValue, ComponentAttrs } from '../types'
1
+ <script>
6
2
 
7
- export interface RadioGroupEmits {
8
- 'update:modelValue': [payload: string]
9
- 'change': [payload: Event]
10
- }
11
-
12
- export type RadioGroupValue = AcceptableValue
13
-
14
- export type RadioGroupItem = {
15
- label?: string
16
- description?: string
17
- disabled?: boolean
18
- value?: RadioGroupValue
19
- [key: string]: any
20
- } | RadioGroupValue
21
-
22
- type SlotProps<T extends RadioGroupItem> = (props: { item: T & { id: string }, modelValue?: RadioGroupValue }) => any
23
-
24
- export interface RadioGroupSlots<T extends RadioGroupItem = RadioGroupItem> {
25
- legend?: any
26
- label?: SlotProps<T>
27
- description?: SlotProps<T>
28
- }
29
-
30
- type RadioGroupVariants = VariantProps<typeof radioGroup>
31
-
32
- export interface RadioGroupProps<T extends RadioGroupItem = RadioGroupItem> extends ComponentAttrs<typeof radioGroup>, Pick<RadioGroupRootProps, 'defaultValue' | 'disabled' | 'loop' | 'modelValue' | 'name' | 'required'> {
33
- /**
34
- * The element or component this component should render as.
35
- * @default "div"
36
- */
37
- as?: PrimitiveProps['as']
38
- legend?: string
39
- /**
40
- * When `options` is an array of objects, select the field to use as the value.
41
- * @default "value"
42
- */
43
- valueKey?: string
44
- /**
45
- * When `options` is an array of objects, select the field to use as the label.
46
- * @default "label"
47
- */
48
- labelKey?: string
49
- /**
50
- * When `options` is an array of objects, select the field to use as the description.
51
- * @default "description"
52
- */
53
- descriptionKey?: string
54
- options?: T[]
55
- size?: RadioGroupVariants['size']
56
- /**
57
- * The orientation the radio buttons are laid out.
58
- * @default "vertical"
59
- */
60
- orientation?: RadioGroupRootProps['orientation']
61
- }
62
3
  </script>
63
4
 
64
- <script lang="ts" setup generic="T extends RadioGroupItem">
65
- import { reactivePick } from '@vueuse/core'
66
- import { Label, RadioGroupIndicator, RadioGroupItem, RadioGroupRoot, useForwardPropsEmits } from 'reka-ui'
67
- import { computed, useId } from 'vue'
68
- import { useFormItem } from '../composables/useFormItem'
69
- import { useTheme } from '../composables/useTheme'
70
- import { get } from '../utils'
71
-
72
- const props = withDefaults(defineProps<RadioGroupProps<T>>(), {
73
- valueKey: 'value',
74
- labelKey: 'label',
75
- descriptionKey: 'description',
76
- orientation: 'vertical',
77
- })
78
-
79
- const emit = defineEmits<RadioGroupEmits>()
80
- const slots = defineSlots<RadioGroupSlots<T>>()
81
-
82
- const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'modelValue', 'defaultValue', 'orientation', 'loop', 'required'), emit)
83
-
84
- const { id: _id, name, size, disabled, ariaAttrs, emitFormChange, emitFormInput } = useFormItem<RadioGroupProps<T>>(props)
85
- const id = _id.value ?? useId()
86
-
87
- const { generateStyle } = useTheme()
88
- const style = computed(() => generateStyle('radioGroup', {
5
+ <script setup>
6
+ import { reactivePick } from "@vueuse/core";
7
+ import { Label, RadioGroupIndicator, RadioGroupItem, RadioGroupRoot, useForwardPropsEmits } from "reka-ui";
8
+ import { computed, useId } from "vue";
9
+ import { useFormItem } from "../composables/useFormItem";
10
+ import { useTheme } from "../composables/useTheme";
11
+ import { get } from "../utils";
12
+ const props = defineProps({
13
+ as: { type: null, required: false },
14
+ legend: { type: String, required: false },
15
+ valueKey: { type: String, required: false, default: "value" },
16
+ labelKey: { type: String, required: false, default: "label" },
17
+ descriptionKey: { type: String, required: false, default: "description" },
18
+ options: { type: Array, required: false },
19
+ size: { type: null, required: false },
20
+ orientation: { type: null, required: false, default: "vertical" },
21
+ class: { type: null, required: false },
22
+ ui: { type: null, required: false },
23
+ defaultValue: { type: null, required: false },
24
+ disabled: { type: Boolean, required: false },
25
+ loop: { type: Boolean, required: false },
26
+ modelValue: { type: null, required: false },
27
+ name: { type: String, required: false },
28
+ required: { type: Boolean, required: false }
29
+ });
30
+ const emit = defineEmits(["update:modelValue", "change"]);
31
+ const slots = defineSlots();
32
+ const rootProps = useForwardPropsEmits(reactivePick(props, "as", "modelValue", "defaultValue", "orientation", "loop", "required"), emit);
33
+ const { id: _id, name, size, disabled, ariaAttrs, emitFormChange, emitFormInput } = useFormItem(props);
34
+ const id = _id.value ?? useId();
35
+ const { generateStyle } = useTheme();
36
+ const style = computed(() => generateStyle("radioGroup", {
89
37
  ...props,
90
38
  size: size.value,
91
- disabled: disabled.value,
92
- }))
93
-
94
- function normalizeItem(item: any) {
39
+ disabled: disabled.value
40
+ }));
41
+ function normalizeItem(item) {
95
42
  if (item === null) {
96
43
  return {
97
44
  id: `${id}:null`,
98
- label: undefined,
99
- value: undefined,
100
- }
45
+ label: void 0,
46
+ value: void 0
47
+ };
101
48
  }
102
-
103
- if (typeof item === 'string' || typeof item === 'number') {
49
+ if (typeof item === "string" || typeof item === "number") {
104
50
  return {
105
51
  id: `${id}:${item}`,
106
52
  label: String(item),
107
53
  value: item,
108
- disabled: disabled.value,
109
- }
54
+ disabled: disabled.value
55
+ };
110
56
  }
111
-
112
- const value = get(item, props.valueKey)
113
- const label = get(item, props.labelKey)
114
- const description = get(item, props.descriptionKey)
115
-
57
+ const value = get(item, props.valueKey);
58
+ const label = get(item, props.labelKey);
59
+ const description = get(item, props.descriptionKey);
116
60
  return {
117
61
  ...item,
118
62
  id: `${id}:${value}`,
119
63
  label,
120
64
  value,
121
65
  description,
122
- disabled: disabled.value || item.disabled,
123
- }
66
+ disabled: disabled.value || item.disabled
67
+ };
124
68
  }
125
-
126
69
  const normalizedItems = computed(() => {
127
70
  if (!props.options)
128
- return []
129
-
130
- return props.options.map(normalizeItem)
131
- })
132
-
133
- function onUpdate(value: any) {
134
- // @ts-expect-error - 'target' does not exist in type 'EventInit'
135
- const event = new Event('change', { target: { value } })
136
- emit('change', event)
137
- emitFormChange()
138
- emitFormInput()
71
+ return [];
72
+ return props.options.map(normalizeItem);
73
+ });
74
+ function onUpdate(value) {
75
+ const event = new Event("change", { target: { value } });
76
+ emit("change", event);
77
+ emitFormChange();
78
+ emitFormInput();
139
79
  }
140
80
  </script>
141
81
 
@@ -144,32 +84,34 @@ function onUpdate(value: any) {
144
84
  v-slot="{ modelValue }"
145
85
  v-bind="{ ...rootProps, id, name, disabled }"
146
86
  :class="style.root({ class: [props.class, props.ui?.root] })"
87
+ data-part="root"
147
88
  @update:model-value="onUpdate"
148
89
  >
149
- <fieldset v-bind="ariaAttrs" :class="style.fieldset({ class: props.ui?.fieldset })">
150
- <legend v-if="props.legend || slots.legend" :class="style.legend({ class: props.ui?.legend })">
90
+ <fieldset v-bind="ariaAttrs" :class="style.fieldset({ class: props.ui?.fieldset })" data-part="fieldset">
91
+ <legend v-if="props.legend || slots.legend" :class="style.legend({ class: props.ui?.legend })" data-part="legend">
151
92
  <slot name="legend">
152
93
  {{ props.legend }}
153
94
  </slot>
154
95
  </legend>
155
- <div v-for="item in normalizedItems" :key="item.value" :class="style.item({ class: props.ui?.item, disabled: item.disabled })">
156
- <div :class="style.container({ class: props.ui?.container })">
96
+ <div v-for="item in normalizedItems" :key="item.value" :class="style.item({ class: props.ui?.item, disabled: item.disabled })" data-part="item">
97
+ <div :class="style.container({ class: props.ui?.container })" data-part="container">
157
98
  <RadioGroupItem
158
99
  :id="item.id"
159
100
  :value="item.value"
160
101
  :disabled="item.disabled"
161
102
  :class="style.base({ class: props.ui?.base })"
103
+ data-part="base"
162
104
  >
163
- <RadioGroupIndicator :class="style.indicator({ class: props.ui?.indicator })" force-mount />
105
+ <RadioGroupIndicator :class="style.indicator({ class: props.ui?.indicator })" data-part="indicator" force-mount />
164
106
  </RadioGroupItem>
165
107
  </div>
166
108
 
167
- <div :class="style.wrapper({ class: props.ui?.wrapper })">
168
- <Label :for="item.id" :class="style.label({ class: props.ui?.label })">
169
- <slot name="label" :item="item" :model-value="(modelValue as RadioGroupValue)">{{ item.label }}</slot>
109
+ <div :class="style.wrapper({ class: props.ui?.wrapper })" data-part="wrapper">
110
+ <Label :for="item.id" :class="style.label({ class: props.ui?.label })" data-part="label">
111
+ <slot name="label" :item="item" :model-value="modelValue">{{ item.label }}</slot>
170
112
  </Label>
171
- <p v-if="item.description || slots.description" :class="style.description({ class: props.ui?.description })">
172
- <slot name="description" :item="item" :model-value="(modelValue as RadioGroupValue)">
113
+ <p v-if="item.description || slots.description" :class="style.description({ class: props.ui?.description })" data-part="description">
114
+ <slot name="description" :item="item" :model-value="modelValue">
173
115
  {{ item.description }}
174
116
  </slot>
175
117
  </p>
@@ -0,0 +1,74 @@
1
+ import type { VariantProps } from '@byyuurin/ui-kit';
2
+ import type { PrimitiveProps, RadioGroupRootProps } from 'reka-ui';
3
+ import type { radioGroup } from '../theme/index.js';
4
+ import type { AcceptableValue, ComponentAttrs } from '../types/index.js';
5
+ export interface RadioGroupEmits {
6
+ 'update:modelValue': [payload: string];
7
+ 'change': [payload: Event];
8
+ }
9
+ export type RadioGroupValue = AcceptableValue;
10
+ export type RadioGroupItem = {
11
+ label?: string;
12
+ description?: string;
13
+ disabled?: boolean;
14
+ value?: RadioGroupValue;
15
+ [key: string]: any;
16
+ } | RadioGroupValue;
17
+ type SlotProps<T extends RadioGroupItem> = (props: {
18
+ item: T & {
19
+ id: string;
20
+ };
21
+ modelValue?: RadioGroupValue;
22
+ }) => any;
23
+ export interface RadioGroupSlots<T extends RadioGroupItem = RadioGroupItem> {
24
+ legend?: any;
25
+ label?: SlotProps<T>;
26
+ description?: SlotProps<T>;
27
+ }
28
+ type RadioGroupVariants = VariantProps<typeof radioGroup>;
29
+ export interface RadioGroupProps<T extends RadioGroupItem = RadioGroupItem> extends ComponentAttrs<typeof radioGroup>, Pick<RadioGroupRootProps, 'defaultValue' | 'disabled' | 'loop' | 'modelValue' | 'name' | 'required'> {
30
+ /**
31
+ * The element or component this component should render as.
32
+ * @default "div"
33
+ */
34
+ as?: PrimitiveProps['as'];
35
+ legend?: string;
36
+ /**
37
+ * When `options` is an array of objects, select the field to use as the value.
38
+ * @default "value"
39
+ */
40
+ valueKey?: string;
41
+ /**
42
+ * When `options` is an array of objects, select the field to use as the label.
43
+ * @default "label"
44
+ */
45
+ labelKey?: string;
46
+ /**
47
+ * When `options` is an array of objects, select the field to use as the description.
48
+ * @default "description"
49
+ */
50
+ descriptionKey?: string;
51
+ options?: T[];
52
+ size?: RadioGroupVariants['size'];
53
+ /**
54
+ * The orientation the radio buttons are laid out.
55
+ * @default "vertical"
56
+ */
57
+ orientation?: RadioGroupRootProps['orientation'];
58
+ }
59
+ declare const _default: <T extends RadioGroupItem>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
60
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
61
+ readonly onChange?: ((payload: Event) => any) | undefined;
62
+ readonly "onUpdate:modelValue"?: ((payload: string) => any) | undefined;
63
+ } & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, "onChange" | "onUpdate:modelValue"> & RadioGroupProps<T> & Partial<{}>> & import("vue").PublicProps;
64
+ expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
65
+ attrs: any;
66
+ slots: RadioGroupSlots<T>;
67
+ emit: ((evt: "change", payload: Event) => void) & ((evt: "update:modelValue", payload: string) => void);
68
+ }>) => import("vue").VNode & {
69
+ __ctx?: Awaited<typeof __VLS_setup>;
70
+ };
71
+ export default _default;
72
+ type __VLS_PrettifyLocal<T> = {
73
+ [K in keyof T]: T[K];
74
+ } & {};