@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,59 +1,41 @@
1
- <script lang="ts">
2
- import type { VariantProps } from '@byyuurin/ui-kit'
3
- import type { SeparatorProps as RekaSeparatorProps } from 'reka-ui'
4
- import type { separator } from '../theme'
5
- import type { ComponentAttrs } from '../types'
1
+ <script>
6
2
 
7
- export interface SeparatorSlots {
8
- default?: (props: {}) => any
9
- }
10
-
11
- type SeparatorVariants = VariantProps<typeof separator>
12
-
13
- export interface SeparatorProps extends ComponentAttrs<typeof separator>, Pick<RekaSeparatorProps, 'as' | 'decorative'> {
14
- orientation?: SeparatorVariants['orientation']
15
- align?: 'start' | 'end' | 'center'
16
- /** Display a label in the middle. */
17
- label?: string
18
- /**
19
- * Display an icon in the middle.
20
- */
21
- icon?: string
22
- }
23
3
  </script>
24
4
 
25
- <script setup lang="ts">
26
- import { reactivePick } from '@vueuse/core'
27
- import { Separator, useForwardProps } from 'reka-ui'
28
- import { computed } from 'vue'
29
- import { useTheme } from '../composables/useTheme'
30
-
31
- const props = withDefaults(defineProps<SeparatorProps>(), {
32
- orientation: 'horizontal',
33
- position: 'center',
34
- })
35
-
36
- const slots = defineSlots<SeparatorSlots>()
37
-
38
- const rootProps = useForwardProps(reactivePick(props, 'as', 'decorative', 'orientation'))
39
-
40
- const { generateStyle } = useTheme()
41
- const style = computed(() => generateStyle('separator', props))
5
+ <script setup>
6
+ import { reactivePick } from "@vueuse/core";
7
+ import { Separator, useForwardProps } from "reka-ui";
8
+ import { computed } from "vue";
9
+ import { useTheme } from "../composables/useTheme";
10
+ const props = defineProps({
11
+ orientation: { type: null, required: false, default: "horizontal" },
12
+ align: { type: String, required: false },
13
+ label: { type: String, required: false },
14
+ icon: { type: String, required: false },
15
+ class: { type: null, required: false },
16
+ ui: { type: null, required: false },
17
+ as: { type: null, required: false },
18
+ decorative: { type: Boolean, required: false }
19
+ });
20
+ const slots = defineSlots();
21
+ const rootProps = useForwardProps(reactivePick(props, "as", "decorative", "orientation"));
22
+ const { generateStyle } = useTheme();
23
+ const style = computed(() => generateStyle("separator", props));
42
24
  </script>
43
25
 
44
26
  <template>
45
- <Separator v-bind="rootProps" :class="style.root({ class: [props.class, props.ui?.root] })">
46
- <div :class="style.line({ class: props.ui?.line, start: props.align === 'start' })"></div>
27
+ <Separator v-bind="rootProps" :class="style.root({ class: [props.class, props.ui?.root] })" data-part="root">
28
+ <div :class="style.line({ class: props.ui?.line, start: props.align === 'start' })" data-part="line"></div>
47
29
 
48
30
  <template v-if="props.label || props.icon || slots.default">
49
- <div :class="style.container({ class: props.ui?.container })">
31
+ <div :class="style.container({ class: props.ui?.container })" data-part="container">
50
32
  <slot>
51
- <span v-if="props.label" :class="style.label({ class: props.ui?.label })">{{ props.label }}</span>
52
- <span v-else-if="props.icon" :class="style.icon({ class: [props.icon, props.ui?.icon] })"></span>
33
+ <span v-if="props.label" :class="style.label({ class: props.ui?.label })" data-part="label">{{ props.label }}</span>
34
+ <span v-else-if="props.icon" :class="style.icon({ class: [props.icon, props.ui?.icon] })" data-part="icon"></span>
53
35
  </slot>
54
36
  </div>
55
37
 
56
- <div :class="style.line({ class: props.ui?.line, end: props.align === 'end' })"></div>
38
+ <div :class="style.line({ class: props.ui?.line, end: props.align === 'end' })" data-part="line"></div>
57
39
  </template>
58
40
  </Separator>
59
41
  </template>
@@ -0,0 +1,27 @@
1
+ import type { VariantProps } from '@byyuurin/ui-kit';
2
+ import type { SeparatorProps as RekaSeparatorProps } from 'reka-ui';
3
+ import type { separator } from '../theme/index.js';
4
+ import type { ComponentAttrs } from '../types/index.js';
5
+ export interface SeparatorSlots {
6
+ default?: (props: {}) => any;
7
+ }
8
+ type SeparatorVariants = VariantProps<typeof separator>;
9
+ export interface SeparatorProps extends ComponentAttrs<typeof separator>, Pick<RekaSeparatorProps, 'as' | 'decorative'> {
10
+ orientation?: SeparatorVariants['orientation'];
11
+ align?: 'start' | 'end' | 'center';
12
+ /** Display a label in the middle. */
13
+ label?: string;
14
+ /**
15
+ * Display an icon in the middle.
16
+ */
17
+ icon?: string;
18
+ }
19
+ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<SeparatorProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<SeparatorProps> & Readonly<{}>, {
20
+ orientation: "horizontal" | "vertical";
21
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, SeparatorSlots>;
22
+ export default _default;
23
+ type __VLS_WithSlots<T, S> = T & {
24
+ new (): {
25
+ $slots: S;
26
+ };
27
+ };
@@ -1,30 +1,21 @@
1
- <script lang="ts">
2
- import type { PrimitiveProps } from 'reka-ui'
3
- import type { skeleton } from '../theme'
4
- import type { ComponentAttrs } from '../types'
1
+ <script>
5
2
 
6
- export interface SkeletonProps extends Omit<ComponentAttrs<typeof skeleton>, 'ui'> {
7
- /**
8
- * The element or component this component should render as.
9
- * @default "div"
10
- */
11
- as?: PrimitiveProps['as']
12
- }
13
3
  </script>
14
4
 
15
- <script setup lang="ts">
16
- import { Primitive } from 'reka-ui'
17
- import { computed } from 'vue'
18
- import { useTheme } from '../composables/useTheme'
19
-
20
- const props = withDefaults(defineProps<SkeletonProps>(), {})
21
-
22
- const { generateStyle } = useTheme()
23
- const styler = computed(() => generateStyle('skeleton', props))
5
+ <script setup>
6
+ import { Primitive } from "reka-ui";
7
+ import { computed } from "vue";
8
+ import { useTheme } from "../composables/useTheme";
9
+ const props = defineProps({
10
+ as: { type: null, required: false },
11
+ class: { type: null, required: false }
12
+ });
13
+ const { generateStyle } = useTheme();
14
+ const styler = computed(() => generateStyle("skeleton", props));
24
15
  </script>
25
16
 
26
17
  <template>
27
- <Primitive :as="props.as" :class="styler">
18
+ <Primitive :as="props.as" :class="styler" data-part="base">
28
19
  <slot></slot>
29
20
  </Primitive>
30
21
  </template>
@@ -0,0 +1,19 @@
1
+ import type { PrimitiveProps } from 'reka-ui';
2
+ import type { skeleton } from '../theme/index.js';
3
+ import type { ComponentAttrs } from '../types/index.js';
4
+ export interface SkeletonProps extends Omit<ComponentAttrs<typeof skeleton>, 'ui'> {
5
+ /**
6
+ * The element or component this component should render as.
7
+ * @default "div"
8
+ */
9
+ as?: PrimitiveProps['as'];
10
+ }
11
+ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<SkeletonProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<SkeletonProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
12
+ default?: (props: {}) => any;
13
+ }>;
14
+ export default _default;
15
+ type __VLS_WithSlots<T, S> = T & {
16
+ new (): {
17
+ $slots: S;
18
+ };
19
+ };
@@ -1,93 +1,76 @@
1
- <script lang="ts">
2
- import type { VariantProps } from '@byyuurin/ui-kit'
3
- import type { SliderRootProps } from 'reka-ui'
4
- import type { slider } from '../theme'
5
- import type { ComponentAttrs } from '../types'
1
+ <script>
6
2
 
7
- export interface SliderEmits {
8
- (event: 'update:modelValue', payload: number | number[]): void
9
- (event: 'change', payload: Event): void
10
- }
11
-
12
- type SliderVariants = VariantProps<typeof slider>
13
-
14
- export interface SliderProps extends ComponentAttrs<typeof slider>, Pick<SliderRootProps, 'as' | 'name' | 'disabled' | 'inverted' | 'min' | 'max' | 'step' | 'minStepsBetweenThumbs'> {
15
- modelValue?: number | number[]
16
- size?: SliderVariants['size']
17
- /**
18
- * The orientation of the slider.
19
- * @default "horizontal"
20
- */
21
- orientation?: SliderVariants['orientation']
22
- /** The value of the slider when initially rendered. Use when you do not need to control the state of the slider. */
23
- defaultValue?: number | number[]
24
- }
25
3
  </script>
26
4
 
27
- <script setup lang="ts">
28
- import { reactivePick } from '@vueuse/core'
29
- import { SliderRange, SliderRoot, SliderThumb, SliderTrack, useForwardPropsEmits } from 'reka-ui'
30
- import { computed } from 'vue'
31
- import { useTheme } from '../composables/useTheme'
32
-
33
- const props = withDefaults(defineProps<SliderProps>(), {
34
- orientation: 'horizontal',
35
- step: 1,
36
- max: 100,
37
- })
38
-
39
- const emit = defineEmits<SliderEmits>()
40
-
41
- const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'orientation', 'min', 'max', 'step', 'minStepsBetweenThumbs', 'inverted'), emit)
42
-
43
- const modelValue = defineModel<number | number[]>()
44
-
5
+ <script setup>
6
+ import { reactivePick } from "@vueuse/core";
7
+ import { SliderRange, SliderRoot, SliderThumb, SliderTrack, useForwardPropsEmits } from "reka-ui";
8
+ import { computed } from "vue";
9
+ import { useFormItem } from "../composables/useFormItem";
10
+ import { useTheme } from "../composables/useTheme";
11
+ const props = defineProps({
12
+ modelValue: { type: [Number, Array], required: false },
13
+ size: { type: null, required: false },
14
+ orientation: { type: null, required: false, default: "horizontal" },
15
+ defaultValue: { type: [Number, Array], required: false },
16
+ class: { type: null, required: false },
17
+ ui: { type: null, required: false },
18
+ as: { type: null, required: false },
19
+ name: { type: String, required: false },
20
+ disabled: { type: Boolean, required: false },
21
+ inverted: { type: Boolean, required: false },
22
+ min: { type: Number, required: false },
23
+ max: { type: Number, required: false, default: 100 },
24
+ step: { type: Number, required: false, default: 1 },
25
+ minStepsBetweenThumbs: { type: Number, required: false }
26
+ });
27
+ const emit = defineEmits(["update:modelValue", "change"]);
28
+ const rootProps = useForwardPropsEmits(reactivePick(props, "as", "orientation", "min", "max", "step", "minStepsBetweenThumbs", "inverted"), emit);
29
+ const modelValue = defineModel({ type: [Number, Array] });
45
30
  const defaultSliderValue = computed(() => {
46
- if (typeof props.defaultValue === 'number')
47
- return [props.defaultValue]
48
-
49
- return props.defaultValue
50
- })
51
-
31
+ if (typeof props.defaultValue === "number")
32
+ return [props.defaultValue];
33
+ return props.defaultValue;
34
+ });
52
35
  const sliderValue = computed({
53
36
  get() {
54
- if (typeof modelValue.value === 'number')
55
- return [modelValue.value]
56
-
57
- return modelValue.value ?? defaultSliderValue.value
37
+ if (typeof modelValue.value === "number")
38
+ return [modelValue.value];
39
+ return modelValue.value ?? defaultSliderValue.value;
58
40
  },
59
41
  set(value) {
60
- modelValue.value = value?.length === 1 ? value[0] : value
61
- },
62
- })
63
-
64
- const thumbsCount = computed(() => sliderValue.value?.length ?? 1)
65
-
66
- const { generateStyle } = useTheme()
67
- const style = computed(() => generateStyle('slider', props))
68
-
69
- function onChange(value: any) {
70
- // @ts-expect-error - 'target' does not exist in type 'EventInit'
71
- const event = new Event('change', { target: { value } })
72
- emit('change', event)
42
+ modelValue.value = value?.length === 1 ? value[0] : value;
43
+ }
44
+ });
45
+ const thumbsCount = computed(() => sliderValue.value?.length ?? 1);
46
+ const { id, size, name, disabled, ariaAttrs, emitFormChange, emitFormInput } = useFormItem(props);
47
+ const { generateStyle } = useTheme();
48
+ const style = computed(() => generateStyle("slider", {
49
+ ...props,
50
+ size: size.value
51
+ }));
52
+ function onChange(value) {
53
+ const event = new Event("change", { target: { value } });
54
+ emit("change", event);
55
+ emitFormChange();
56
+ emitFormInput();
73
57
  }
74
58
  </script>
75
59
 
76
60
  <template>
77
61
  <SliderRoot
78
- v-bind="rootProps"
62
+ v-bind="{ ...rootProps, ...ariaAttrs, id, name, disabled }"
79
63
  v-model="sliderValue"
80
- :name="props.name"
81
- :disabled="props.disabled"
82
- :class="style.root({ class: [props.class, props.ui?.root] })"
83
64
  :default-value="defaultSliderValue"
65
+ :class="style.root({ class: [props.class, props.ui?.root] })"
66
+ data-part="root"
84
67
  :data-steps="thumbsCount"
85
68
  @value-commit="onChange"
86
69
  >
87
- <SliderTrack :class="style.track({ class: props.ui?.track })">
88
- <SliderRange :class="style.range({ class: props.ui?.range })" />
70
+ <SliderTrack :class="style.track({ class: props.ui?.track })" data-part="track">
71
+ <SliderRange :class="style.range({ class: props.ui?.range })" data-part="range" />
89
72
  </SliderTrack>
90
73
 
91
- <SliderThumb v-for="count in thumbsCount" :key="count" :class="style.thumb({ class: props.ui?.thumb })" />
74
+ <SliderThumb v-for="count in thumbsCount" :key="count" :class="style.thumb({ class: props.ui?.thumb })" data-part="thumb" />
92
75
  </SliderRoot>
93
76
  </template>
@@ -0,0 +1,36 @@
1
+ import type { VariantProps } from '@byyuurin/ui-kit';
2
+ import type { SliderRootProps } from 'reka-ui';
3
+ import type { slider } from '../theme/index.js';
4
+ import type { ComponentAttrs, MaybeArray } from '../types/index.js';
5
+ export interface SliderEmits {
6
+ 'update:modelValue': [payload: MaybeArray<number>];
7
+ 'change': [payload: Event];
8
+ }
9
+ type SliderVariants = VariantProps<typeof slider>;
10
+ export interface SliderProps extends ComponentAttrs<typeof slider>, Pick<SliderRootProps, 'as' | 'name' | 'disabled' | 'inverted' | 'min' | 'max' | 'step' | 'minStepsBetweenThumbs'> {
11
+ modelValue?: number | number[];
12
+ size?: SliderVariants['size'];
13
+ /**
14
+ * The orientation of the slider.
15
+ * @default "horizontal"
16
+ */
17
+ orientation?: SliderVariants['orientation'];
18
+ /** The value of the slider when initially rendered. Use when you do not need to control the state of the slider. */
19
+ defaultValue?: number | number[];
20
+ }
21
+ declare const _default: import("vue").DefineComponent<SliderProps & {
22
+ modelValue?: number | number[];
23
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
24
+ change: (payload: Event) => any;
25
+ "update:modelValue": (...args: unknown[]) => any;
26
+ }, string, import("vue").PublicProps, Readonly<SliderProps & {
27
+ modelValue?: number | number[];
28
+ }> & Readonly<{
29
+ onChange?: ((payload: Event) => any) | undefined;
30
+ "onUpdate:modelValue"?: ((...args: unknown[]) => any) | undefined;
31
+ }>, {
32
+ orientation: "horizontal" | "vertical";
33
+ step: number;
34
+ max: number;
35
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
36
+ export default _default;
@@ -1,92 +1,78 @@
1
- <script lang="ts">
2
- import type { VariantProps } from '@byyuurin/ui-kit'
3
- import type { SwitchRootProps } from 'reka-ui'
4
- import type { switch as _switch } from '../theme'
5
- import type { ComponentAttrs } from '../types'
1
+ <script>
6
2
 
7
- export interface SwitchEmits {
8
- (event: 'change', payload: Event): void
9
- }
10
-
11
- export interface SwitchSlots {
12
- label?: (props: { label?: string }) => any
13
- description?: (props: { description?: string }) => any
14
- }
15
-
16
- type SwitchVariants = VariantProps<typeof _switch>
17
-
18
- export interface SwitchProps extends ComponentAttrs<typeof _switch>, Pick<SwitchRootProps, 'as' | 'disabled' | 'id' | 'name' | 'required' | 'value' | 'defaultValue'> {
19
- size?: SwitchVariants['size']
20
- /** When `true`, the loading icon will be displayed. */
21
- loading?: boolean
22
- /**
23
- * The icon when the `loading` prop is `true`.
24
- * @default app.icons.loading
25
- */
26
- loadingIcon?: string
27
- /** Display an icon when the switch is checked. */
28
- checkedIcon?: string
29
- /** Display an icon when the switch is unchecked. */
30
- uncheckedIcon?: string
31
- label?: string
32
- description?: string
33
- }
34
3
  </script>
35
4
 
36
- <script lang="ts" setup>
37
- import { reactivePick } from '@vueuse/core'
38
- import { Label, Primitive, SwitchRoot, SwitchThumb, useForwardProps } from 'reka-ui'
39
- import { computed, useId } from 'vue'
40
- import { useTheme } from '../composables/useTheme'
41
-
42
- const props = withDefaults(defineProps<SwitchProps>(), {})
43
- const emit = defineEmits<SwitchEmits>()
44
- const slots = defineSlots<SwitchSlots>()
45
- const modelValue = defineModel<boolean>({ default: undefined })
46
-
47
- const rootProps = useForwardProps(reactivePick(props, 'required', 'value', 'defaultValue'))
48
- const id = useId()
49
-
50
- const { theme, generateStyle } = useTheme()
51
- const style = computed(() => generateStyle('switch', {
5
+ <script setup>
6
+ import { reactivePick } from "@vueuse/core";
7
+ import { Label, Primitive, SwitchRoot, SwitchThumb, useForwardProps } from "reka-ui";
8
+ import { computed, useId } from "vue";
9
+ import { useFormItem } from "../composables/useFormItem";
10
+ import { useTheme } from "../composables/useTheme";
11
+ const props = defineProps({
12
+ size: { type: null, required: false },
13
+ loading: { type: Boolean, required: false },
14
+ loadingIcon: { type: String, required: false },
15
+ checkedIcon: { type: String, required: false },
16
+ uncheckedIcon: { type: String, required: false },
17
+ label: { type: String, required: false },
18
+ description: { type: String, required: false },
19
+ class: { type: null, required: false },
20
+ ui: { type: null, required: false },
21
+ as: { type: null, required: false },
22
+ disabled: { type: Boolean, required: false },
23
+ id: { type: String, required: false },
24
+ name: { type: String, required: false },
25
+ required: { type: Boolean, required: false },
26
+ value: { type: String, required: false },
27
+ defaultValue: { type: Boolean, required: false }
28
+ });
29
+ const emit = defineEmits(["change"]);
30
+ const slots = defineSlots();
31
+ const modelValue = defineModel({ type: Boolean, ...{ default: void 0 } });
32
+ const rootProps = useForwardProps(reactivePick(props, "required", "value", "defaultValue"));
33
+ const { id: _id, size, name, disabled, ariaAttrs, emitFormChange, emitFormInput } = useFormItem(props);
34
+ const id = _id.value ?? useId();
35
+ const { theme, generateStyle } = useTheme();
36
+ const style = computed(() => generateStyle("switch", {
52
37
  ...props,
38
+ size: size.value,
39
+ disabled: disabled.value,
53
40
  checked: false,
54
- unchecked: false,
55
- }))
56
-
57
- function onUpdate(value: any) {
58
- // @ts-expect-error - 'target' does not exist in type 'EventInit'
59
- const event = new Event('change', { target: { value } })
60
- emit('change', event)
41
+ unchecked: false
42
+ }));
43
+ function onUpdate(value) {
44
+ const event = new Event("change", { target: { value } });
45
+ emit("change", event);
46
+ emitFormChange();
47
+ emitFormInput();
61
48
  }
62
49
  </script>
63
50
 
64
51
  <template>
65
- <Primitive :as="props.as" :class="style.root({ class: [props.class, props.ui?.root] })">
66
- <div :class="style.container({ class: props.ui?.container })">
52
+ <Primitive :as="props.as" :class="style.root({ class: [props.class, props.ui?.root] })" data-part="root">
53
+ <div :class="style.container({ class: props.ui?.container })" data-part="container">
67
54
  <SwitchRoot
68
- :id="id"
69
- v-bind="rootProps"
55
+ v-bind="{ ...rootProps, ...ariaAttrs, id, name }"
70
56
  v-model="modelValue"
71
- :name="props.name"
72
- :disabled="props.disabled || props.loading"
57
+ :disabled="disabled || props.loading"
73
58
  :class="style.base({ class: props.ui?.base })"
59
+ data-part="base"
74
60
  @update:model-value="onUpdate"
75
61
  >
76
- <SwitchThumb :class="style.thumb({ class: props.ui?.thumb })">
77
- <span v-if="props.loading" :class="style.icon({ class: [theme.app.icons.loading, props.ui?.icon], checked: true, unchecked: true })"></span>
62
+ <SwitchThumb :class="style.thumb({ class: props.ui?.thumb })" data-part="thumb">
63
+ <span v-if="props.loading" :class="style.icon({ class: [theme.app.icons.loading, props.ui?.icon], checked: true, unchecked: true })" data-part="icon"></span>
78
64
  <template v-else>
79
- <span v-if="props.checkedIcon" :class="style.icon({ class: [props.checkedIcon, props.ui?.icon], checked: true })"></span>
80
- <span v-if="props.uncheckedIcon" :class="style.icon({ class: [props.uncheckedIcon, props.ui?.icon], unchecked: true })"></span>
65
+ <span v-if="props.checkedIcon" :class="style.icon({ class: [props.checkedIcon, props.ui?.icon], checked: true })" data-part="icon"></span>
66
+ <span v-if="props.uncheckedIcon" :class="style.icon({ class: [props.uncheckedIcon, props.ui?.icon], unchecked: true })" data-part="icon"></span>
81
67
  </template>
82
68
  </SwitchThumb>
83
69
  </SwitchRoot>
84
70
  </div>
85
- <div v-if="props.label || slots.label || props.description || slots.description" :class="style.wrapper({ class: props.ui?.wrapper })">
86
- <Label v-if="props.label || slots.label" :for="id" :class="style.label({ class: props.ui?.label })">
71
+ <div v-if="props.label || slots.label || props.description || slots.description" :class="style.wrapper({ class: props.ui?.wrapper })" data-part="wrapper">
72
+ <Label v-if="props.label || slots.label" :for="id" :class="style.label({ class: props.ui?.label })" data-part="label">
87
73
  <slot name="label" :label="props.label">{{ props.label }}</slot>
88
74
  </Label>
89
- <p v-if="props.description || slots.description" :class="style.description({ class: props.ui?.description })">
75
+ <p v-if="props.description || slots.description" :class="style.description({ class: props.ui?.description })" data-part="description">
90
76
  <slot name="description" :description="props.description">
91
77
  {{ props.description }}
92
78
  </slot>
@@ -0,0 +1,49 @@
1
+ import type { VariantProps } from '@byyuurin/ui-kit';
2
+ import type { SwitchRootProps } from 'reka-ui';
3
+ import type { switch as _switch } from '../theme/index.js';
4
+ import type { ComponentAttrs } from '../types/index.js';
5
+ export interface SwitchEmits {
6
+ change: [payload: Event];
7
+ }
8
+ export interface SwitchSlots {
9
+ label?: (props: {
10
+ label?: string;
11
+ }) => any;
12
+ description?: (props: {
13
+ description?: string;
14
+ }) => any;
15
+ }
16
+ type SwitchVariants = VariantProps<typeof _switch>;
17
+ export interface SwitchProps extends ComponentAttrs<typeof _switch>, Pick<SwitchRootProps, 'as' | 'disabled' | 'id' | 'name' | 'required' | 'value' | 'defaultValue'> {
18
+ size?: SwitchVariants['size'];
19
+ /** When `true`, the loading icon will be displayed. */
20
+ loading?: boolean;
21
+ /**
22
+ * The icon when the `loading` prop is `true`.
23
+ * @default app.icons.loading
24
+ */
25
+ loadingIcon?: string;
26
+ /** Display an icon when the switch is checked. */
27
+ checkedIcon?: string;
28
+ /** Display an icon when the switch is unchecked. */
29
+ uncheckedIcon?: string;
30
+ label?: string;
31
+ description?: string;
32
+ }
33
+ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<SwitchProps & {
34
+ modelValue?: boolean;
35
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
36
+ change: (payload: Event) => any;
37
+ "update:modelValue": (value: boolean) => any;
38
+ }, string, import("vue").PublicProps, Readonly<SwitchProps & {
39
+ modelValue?: boolean;
40
+ }> & Readonly<{
41
+ onChange?: ((payload: Event) => any) | undefined;
42
+ "onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
43
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, SwitchSlots>;
44
+ export default _default;
45
+ type __VLS_WithSlots<T, S> = T & {
46
+ new (): {
47
+ $slots: S;
48
+ };
49
+ };