@byyuurin/ui 0.0.9 → 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 (215) hide show
  1. package/README.md +2 -5
  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 +9323 -3
  6. package/dist/runtime/app/injections.js +35 -0
  7. package/dist/runtime/components/Accordion.vue +36 -69
  8. package/dist/runtime/components/Accordion.vue.d.ts +52 -0
  9. package/dist/runtime/components/Alert.vue +37 -75
  10. package/dist/runtime/components/Alert.vue.d.ts +59 -0
  11. package/dist/runtime/components/App.vue +25 -40
  12. package/dist/runtime/components/App.vue.d.ts +24 -0
  13. package/dist/runtime/components/Avatar.vue +31 -51
  14. package/dist/runtime/components/Avatar.vue.d.ts +25 -0
  15. package/dist/runtime/components/AvatarGroup.vue +38 -69
  16. package/dist/runtime/components/AvatarGroup.vue.d.ts +27 -0
  17. package/dist/runtime/components/Badge.vue +25 -51
  18. package/dist/runtime/components/Badge.vue.d.ts +44 -0
  19. package/dist/runtime/components/Breadcrumb.vue +35 -77
  20. package/dist/runtime/components/Breadcrumb.vue.d.ts +52 -0
  21. package/dist/runtime/components/Button.vue +62 -51
  22. package/dist/runtime/components/Button.vue.d.ts +29 -0
  23. package/dist/runtime/components/ButtonGroup.vue +17 -37
  24. package/dist/runtime/components/ButtonGroup.vue.d.ts +26 -0
  25. package/dist/runtime/components/Calendar.vue +75 -101
  26. package/dist/runtime/components/Calendar.vue.d.ts +75 -0
  27. package/dist/runtime/components/Card.vue +25 -42
  28. package/dist/runtime/components/Card.vue.d.ts +30 -0
  29. package/dist/runtime/components/Carousel.vue +118 -223
  30. package/dist/runtime/components/Carousel.vue.d.ts +104 -0
  31. package/dist/runtime/components/Checkbox.vue +49 -71
  32. package/dist/runtime/components/Checkbox.vue.d.ts +56 -0
  33. package/dist/runtime/components/Chip.vue +31 -48
  34. package/dist/runtime/components/Chip.vue.d.ts +30 -0
  35. package/dist/runtime/components/Collapsible.vue +22 -30
  36. package/dist/runtime/components/Collapsible.vue.d.ts +26 -0
  37. package/dist/runtime/components/Drawer.vue +52 -102
  38. package/dist/runtime/components/Drawer.vue.d.ts +80 -0
  39. package/dist/runtime/components/DropdownMenu.vue +65 -0
  40. package/dist/runtime/components/DropdownMenu.vue.d.ts +99 -0
  41. package/dist/runtime/components/DropdownMenuContent.vue +192 -0
  42. package/dist/runtime/components/DropdownMenuContent.vue.d.ts +39 -0
  43. package/dist/runtime/components/Form.vue +197 -0
  44. package/dist/runtime/components/Form.vue.d.ts +78 -0
  45. package/dist/runtime/components/FormItem.vue +90 -0
  46. package/dist/runtime/components/FormItem.vue.d.ts +60 -0
  47. package/dist/runtime/components/Input.vue +93 -115
  48. package/dist/runtime/components/Input.vue.d.ts +64 -0
  49. package/dist/runtime/components/InputNumber.vue +81 -116
  50. package/dist/runtime/components/InputNumber.vue.d.ts +245 -0
  51. package/dist/runtime/components/Kbd.vue +18 -39
  52. package/dist/runtime/components/Kbd.vue.d.ts +28 -0
  53. package/dist/runtime/components/Link.vue +170 -244
  54. package/dist/runtime/components/Link.vue.d.ts +95 -0
  55. package/dist/runtime/components/LinkBase.vue +36 -54
  56. package/dist/runtime/components/LinkBase.vue.d.ts +28 -0
  57. package/dist/runtime/components/Modal.vue +50 -85
  58. package/dist/runtime/components/Modal.vue.d.ts +66 -0
  59. package/dist/runtime/components/OverlayProvider.vue +10 -14
  60. package/dist/runtime/components/OverlayProvider.vue.d.ts +2 -0
  61. package/dist/runtime/components/Pagination.vue +55 -121
  62. package/dist/runtime/components/Pagination.vue.d.ts +93 -0
  63. package/dist/runtime/components/PinInput.vue +57 -57
  64. package/dist/runtime/components/PinInput.vue.d.ts +35 -0
  65. package/dist/runtime/components/Popover.vue +39 -68
  66. package/dist/runtime/components/Popover.vue.d.ts +45 -0
  67. package/dist/runtime/components/Progress.vue +68 -120
  68. package/dist/runtime/components/Progress.vue.d.ts +54 -0
  69. package/dist/runtime/components/RadioGroup.vue +75 -129
  70. package/dist/runtime/components/RadioGroup.vue.d.ts +74 -0
  71. package/dist/runtime/components/ScrollArea.vue +31 -31
  72. package/dist/runtime/components/ScrollArea.vue.d.ts +17 -0
  73. package/dist/runtime/components/Select.vue +119 -199
  74. package/dist/runtime/components/Select.vue.d.ts +119 -0
  75. package/dist/runtime/components/Separator.vue +26 -44
  76. package/dist/runtime/components/Separator.vue.d.ts +27 -0
  77. package/dist/runtime/components/Skeleton.vue +12 -21
  78. package/dist/runtime/components/Skeleton.vue.d.ts +19 -0
  79. package/dist/runtime/components/Slider.vue +54 -71
  80. package/dist/runtime/components/Slider.vue.d.ts +36 -0
  81. package/dist/runtime/components/Switch.vue +54 -68
  82. package/dist/runtime/components/Switch.vue.d.ts +49 -0
  83. package/dist/runtime/components/Table.vue +113 -186
  84. package/dist/runtime/components/Table.vue.d.ts +148 -0
  85. package/dist/runtime/components/Tabs.vue +35 -79
  86. package/dist/runtime/components/Tabs.vue.d.ts +65 -0
  87. package/dist/runtime/components/Textarea.vue +82 -123
  88. package/dist/runtime/components/Textarea.vue.d.ts +60 -0
  89. package/dist/runtime/components/Toast.vue +51 -76
  90. package/dist/runtime/components/Toast.vue.d.ts +131 -0
  91. package/dist/runtime/components/ToastProvider.vue +65 -101
  92. package/dist/runtime/components/ToastProvider.vue.d.ts +38 -0
  93. package/dist/runtime/components/Tooltip.vue +36 -47
  94. package/dist/runtime/components/Tooltip.vue.d.ts +31 -0
  95. package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
  96. package/dist/runtime/composables/useButtonGroup.d.ts +2 -2
  97. package/dist/runtime/composables/useFormItem.d.ts +27 -0
  98. package/dist/runtime/composables/useFormItem.js +64 -0
  99. package/dist/runtime/composables/useKbd.d.ts +1 -1
  100. package/dist/runtime/composables/useLocale.d.ts +3 -3
  101. package/dist/runtime/composables/useTheme.d.ts +1 -1
  102. package/dist/runtime/composables/useTheme.js +2 -1
  103. package/dist/runtime/composables/useToast.d.ts +1 -1
  104. package/dist/runtime/index.d.ts +3 -0
  105. package/dist/runtime/index.js +3 -0
  106. package/dist/runtime/locale/en.d.ts +1 -1
  107. package/dist/runtime/locale/zh-tw.d.ts +1 -1
  108. package/dist/runtime/theme/accordion.d.ts +45 -51
  109. package/dist/runtime/theme/accordion.js +1 -1
  110. package/dist/runtime/theme/alert.d.ts +115 -121
  111. package/dist/runtime/theme/alert.js +1 -1
  112. package/dist/runtime/theme/app.d.ts +1 -0
  113. package/dist/runtime/theme/app.js +2 -1
  114. package/dist/runtime/theme/avatar-group.d.ts +42 -48
  115. package/dist/runtime/theme/avatar-group.js +1 -1
  116. package/dist/runtime/theme/avatar.d.ts +46 -52
  117. package/dist/runtime/theme/avatar.js +1 -1
  118. package/dist/runtime/theme/badge.d.ts +63 -93
  119. package/dist/runtime/theme/badge.js +1 -1
  120. package/dist/runtime/theme/breadcrumb.d.ts +52 -58
  121. package/dist/runtime/theme/breadcrumb.js +1 -1
  122. package/dist/runtime/theme/button-group.d.ts +36 -42
  123. package/dist/runtime/theme/button.d.ts +165 -117
  124. package/dist/runtime/theme/button.js +1 -1
  125. package/dist/runtime/theme/calendar.d.ts +52 -50
  126. package/dist/runtime/theme/calendar.js +20 -3
  127. package/dist/runtime/theme/card.d.ts +52 -58
  128. package/dist/runtime/theme/card.js +1 -1
  129. package/dist/runtime/theme/carousel.d.ts +98 -104
  130. package/dist/runtime/theme/carousel.js +1 -1
  131. package/dist/runtime/theme/checkbox.d.ts +77 -83
  132. package/dist/runtime/theme/checkbox.js +1 -1
  133. package/dist/runtime/theme/chip.d.ts +50 -89
  134. package/dist/runtime/theme/chip.js +1 -1
  135. package/dist/runtime/theme/collapsible.d.ts +29 -35
  136. package/dist/runtime/theme/collapsible.js +1 -1
  137. package/dist/runtime/theme/drawer.d.ts +131 -102
  138. package/dist/runtime/theme/drawer.js +1 -1
  139. package/dist/runtime/theme/dropdown-menu.d.ts +65 -0
  140. package/dist/runtime/theme/dropdown-menu.js +83 -0
  141. package/dist/runtime/theme/form-item.d.ts +70 -0
  142. package/dist/runtime/theme/form-item.js +34 -0
  143. package/dist/runtime/theme/form.d.ts +2 -0
  144. package/dist/runtime/theme/form.js +7 -0
  145. package/dist/runtime/theme/index.d.ts +3 -0
  146. package/dist/runtime/theme/index.js +3 -0
  147. package/dist/runtime/theme/input-number.d.ts +100 -126
  148. package/dist/runtime/theme/input-number.js +1 -1
  149. package/dist/runtime/theme/input.d.ts +153 -131
  150. package/dist/runtime/theme/input.js +3 -3
  151. package/dist/runtime/theme/kbd.d.ts +30 -36
  152. package/dist/runtime/theme/link.d.ts +37 -43
  153. package/dist/runtime/theme/modal.d.ts +35 -69
  154. package/dist/runtime/theme/modal.js +1 -1
  155. package/dist/runtime/theme/pagination.d.ts +71 -77
  156. package/dist/runtime/theme/pagination.js +1 -1
  157. package/dist/runtime/theme/pinInput.d.ts +82 -88
  158. package/dist/runtime/theme/pinInput.js +2 -2
  159. package/dist/runtime/theme/popover.d.ts +29 -35
  160. package/dist/runtime/theme/popover.js +1 -1
  161. package/dist/runtime/theme/progress.d.ts +167 -109
  162. package/dist/runtime/theme/progress.js +1 -1
  163. package/dist/runtime/theme/radio-group.d.ts +99 -105
  164. package/dist/runtime/theme/radio-group.js +1 -1
  165. package/dist/runtime/theme/scroll-area.d.ts +62 -68
  166. package/dist/runtime/theme/scroll-area.js +1 -1
  167. package/dist/runtime/theme/select.d.ts +168 -158
  168. package/dist/runtime/theme/select.js +3 -2
  169. package/dist/runtime/theme/separator.d.ts +64 -85
  170. package/dist/runtime/theme/separator.js +1 -1
  171. package/dist/runtime/theme/skeleton.d.ts +1 -7
  172. package/dist/runtime/theme/slider.d.ts +62 -68
  173. package/dist/runtime/theme/slider.js +1 -1
  174. package/dist/runtime/theme/switch.d.ts +111 -117
  175. package/dist/runtime/theme/switch.js +1 -1
  176. package/dist/runtime/theme/table.d.ts +75 -78
  177. package/dist/runtime/theme/table.js +3 -2
  178. package/dist/runtime/theme/tabs.d.ts +116 -139
  179. package/dist/runtime/theme/tabs.js +1 -1
  180. package/dist/runtime/theme/textarea.d.ts +78 -90
  181. package/dist/runtime/theme/textarea.js +2 -2
  182. package/dist/runtime/theme/toast-provider.d.ts +110 -131
  183. package/dist/runtime/theme/toast-provider.js +1 -1
  184. package/dist/runtime/theme/toast.d.ts +74 -80
  185. package/dist/runtime/theme/toast.js +1 -1
  186. package/dist/runtime/theme/tooltip.d.ts +35 -41
  187. package/dist/runtime/theme/tooltip.js +1 -1
  188. package/dist/runtime/types/components.d.ts +3 -0
  189. package/dist/runtime/types/form.d.ts +45 -0
  190. package/dist/runtime/types/form.js +0 -0
  191. package/dist/runtime/types/index.d.ts +5 -2
  192. package/dist/runtime/types/index.js +1 -0
  193. package/dist/runtime/types/utils.d.ts +37 -16
  194. package/dist/runtime/utils/extend-theme.js +15 -4
  195. package/dist/runtime/utils/form.d.ts +5 -0
  196. package/dist/runtime/utils/form.js +24 -0
  197. package/dist/runtime/utils/index.d.ts +2 -0
  198. package/dist/runtime/utils/index.js +4 -0
  199. package/dist/runtime/utils/link.d.ts +4 -28
  200. package/dist/runtime/utils/link.js +10 -3
  201. package/dist/runtime/utils/styler.d.ts +2 -2
  202. package/dist/runtime/utils/styler.js +2 -2
  203. package/dist/shared/ui.D1BTWZFB.mjs +5 -0
  204. package/dist/shared/ui.D1BTWZFB.mjs.map +1 -0
  205. package/dist/types.d.mts +1 -1
  206. package/dist/unocss.mjs +7 -6
  207. package/dist/unocss.mjs.map +1 -1
  208. package/dist/unplugin.mjs +1 -1
  209. package/dist/unplugin.mjs.map +1 -1
  210. package/dist/vite.mjs +1 -1
  211. package/package.json +78 -74
  212. package/dist/module.cjs +0 -5
  213. package/dist/shared/ui.1a1f119c.mjs +0 -5
  214. package/dist/shared/ui.1a1f119c.mjs.map +0 -1
  215. 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,170 +1,116 @@
1
- <script lang="ts">
2
- import type { VariantProps } from '@byyuurin/ui-kit'
3
- import type { AcceptableValue, PrimitiveProps, RadioGroupRootProps } from 'reka-ui'
4
- import type { radioGroup } from '../theme'
5
- import type { ComponentAttrs } from '../types'
1
+ <script>
6
2
 
7
- export interface RadioGroupEmits {
8
- (event: 'update:modelValue', payload: string): void
9
- (event: 'change', payload: Event): void
10
- }
11
-
12
- type SlotProps<T> = (props: { item: NormalizeItem<T>, modelValue?: AcceptableValue }) => any
13
-
14
- export interface RadioGroupSlots<T> {
15
- legend?: (props?: {}) => any
16
- label?: SlotProps<T>
17
- description?: SlotProps<T>
18
- }
19
-
20
- type NormalizeItem<T> = { id: string } & (
21
- T extends RadioOption
22
- ? T
23
- : {
24
- id: string
25
- label: string
26
- value: any
27
- description: string
28
- disabled: boolean
29
- }
30
- )
31
-
32
- type RadioGroupVariants = VariantProps<typeof radioGroup>
33
-
34
- export interface RadioOption {
35
- label?: string
36
- description?: string
37
- disabled?: boolean
38
- value?: string
39
- }
40
-
41
- export interface RadioGroupProps<T> extends ComponentAttrs<typeof radioGroup>, Pick<RadioGroupRootProps, 'defaultValue' | 'disabled' | 'loop' | 'modelValue' | 'name' | 'required'> {
42
- /**
43
- * The element or component this component should render as.
44
- * @default "div"
45
- */
46
- as?: PrimitiveProps['as']
47
- legend?: string
48
- /**
49
- * When `options` is an array of objects, select the field to use as the value.
50
- * @default "value"
51
- */
52
- valueKey?: string
53
- /**
54
- * When `options` is an array of objects, select the field to use as the label.
55
- * @default "label"
56
- */
57
- labelKey?: string
58
- /**
59
- * When `options` is an array of objects, select the field to use as the description.
60
- * @default "description"
61
- */
62
- descriptionKey?: string
63
- options?: T[]
64
- size?: RadioGroupVariants['size']
65
- /**
66
- * The orientation the radio buttons are laid out.
67
- * @default "vertical"
68
- */
69
- orientation?: RadioGroupRootProps['orientation']
70
- }
71
3
  </script>
72
4
 
73
- <script lang="ts" setup generic="T extends RadioOption | AcceptableValue">
74
- import { reactivePick } from '@vueuse/core'
75
- import { Label, RadioGroupIndicator, RadioGroupItem, RadioGroupRoot, useForwardPropsEmits } from 'reka-ui'
76
- import { computed, useId } from 'vue'
77
- import { useTheme } from '../composables/useTheme'
78
- import { get } from '../utils'
79
-
80
- const props = withDefaults(defineProps<RadioGroupProps<T>>(), {
81
- valueKey: 'value',
82
- labelKey: 'label',
83
- descriptionKey: 'description',
84
- orientation: 'vertical',
85
- })
86
-
87
- const emit = defineEmits<RadioGroupEmits>()
88
- const slots = defineSlots<RadioGroupSlots<T>>()
89
-
90
- const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'modelValue', 'defaultValue', 'orientation', 'loop', 'required'), emit)
91
- const id = useId()
92
-
93
- const { generateStyle } = useTheme()
94
- const style = computed(() => generateStyle('radioGroup', props))
95
-
96
- function normalizeItem(item: any): NormalizeItem<T> {
97
- if (['string', 'number', 'boolean'].includes(typeof item)) {
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", {
37
+ ...props,
38
+ size: size.value,
39
+ disabled: disabled.value
40
+ }));
41
+ function normalizeItem(item) {
42
+ if (item === null) {
43
+ return {
44
+ id: `${id}:null`,
45
+ label: void 0,
46
+ value: void 0
47
+ };
48
+ }
49
+ if (typeof item === "string" || typeof item === "number") {
98
50
  return {
99
51
  id: `${id}:${item}`,
52
+ label: String(item),
100
53
  value: item,
101
- label: item,
102
- description: '',
103
- disabled: props.disabled,
104
- } as any
54
+ disabled: disabled.value
55
+ };
105
56
  }
106
-
107
- const value = get(item, props.valueKey)
108
- const label = get(item, props.labelKey)
109
- const description = get(item, props.descriptionKey)
110
-
57
+ const value = get(item, props.valueKey);
58
+ const label = get(item, props.labelKey);
59
+ const description = get(item, props.descriptionKey);
111
60
  return {
112
61
  ...item,
113
- value,
62
+ id: `${id}:${value}`,
114
63
  label,
64
+ value,
115
65
  description,
116
- id: `${id}:${value}`,
117
- disabled: props.disabled || item.disabled,
118
- }
66
+ disabled: disabled.value || item.disabled
67
+ };
119
68
  }
120
-
121
69
  const normalizedItems = computed(() => {
122
70
  if (!props.options)
123
- return []
124
-
125
- return props.options.map(normalizeItem)
126
- })
127
-
128
- function onUpdate(value: any) {
129
- // @ts-expect-error - 'target' does not exist in type 'EventInit'
130
- const event = new Event('change', { target: { value } })
131
- emit('change', event)
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();
132
79
  }
133
80
  </script>
134
81
 
135
82
  <template>
136
83
  <RadioGroupRoot
137
- :id="id"
138
84
  v-slot="{ modelValue }"
139
- v-bind="rootProps"
140
- :name="props.name"
141
- :disabled="props.disabled"
85
+ v-bind="{ ...rootProps, id, name, disabled }"
142
86
  :class="style.root({ class: [props.class, props.ui?.root] })"
87
+ data-part="root"
143
88
  @update:model-value="onUpdate"
144
89
  >
145
- <fieldset :class="style.fieldset({ class: props.ui?.fieldset })">
146
- <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">
147
92
  <slot name="legend">
148
93
  {{ props.legend }}
149
94
  </slot>
150
95
  </legend>
151
- <div v-for="item in normalizedItems" :key="item.value" :class="style.item({ class: props.ui?.item, disabled: item.disabled })">
152
- <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">
153
98
  <RadioGroupItem
154
99
  :id="item.id"
155
100
  :value="item.value"
156
101
  :disabled="item.disabled"
157
102
  :class="style.base({ class: props.ui?.base })"
103
+ data-part="base"
158
104
  >
159
- <RadioGroupIndicator :class="style.indicator({ class: props.ui?.indicator })" force-mount />
105
+ <RadioGroupIndicator :class="style.indicator({ class: props.ui?.indicator })" data-part="indicator" force-mount />
160
106
  </RadioGroupItem>
161
107
  </div>
162
108
 
163
- <div :class="style.wrapper({ class: props.ui?.wrapper })">
164
- <Label :for="item.id" :class="style.label({ class: props.ui?.label })">
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">
165
111
  <slot name="label" :item="item" :model-value="modelValue">{{ item.label }}</slot>
166
112
  </Label>
167
- <p v-if="item.description || slots.description" :class="style.description({ class: props.ui?.description })">
113
+ <p v-if="item.description || slots.description" :class="style.description({ class: props.ui?.description })" data-part="description">
168
114
  <slot name="description" :item="item" :model-value="modelValue">
169
115
  {{ item.description }}
170
116
  </slot>
@@ -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
+ } & {};