@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,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,82 +1,59 @@
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, MaybeArray } from '../types'
1
+ <script>
6
2
 
7
- export interface SliderEmits {
8
- 'update:modelValue': [payload: MaybeArray<number>]
9
- 'change': [payload: Event]
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 { useFormItem } from '../composables/useFormItem'
32
- import { useTheme } from '../composables/useTheme'
33
-
34
- const props = withDefaults(defineProps<SliderProps>(), {
35
- orientation: 'horizontal',
36
- step: 1,
37
- max: 100,
38
- })
39
-
40
- const emit = defineEmits<SliderEmits>()
41
-
42
- const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'orientation', 'min', 'max', 'step', 'minStepsBetweenThumbs', 'inverted'), emit)
43
-
44
- const modelValue = defineModel<number | number[]>()
45
-
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] });
46
30
  const defaultSliderValue = computed(() => {
47
- if (typeof props.defaultValue === 'number')
48
- return [props.defaultValue]
49
-
50
- return props.defaultValue
51
- })
52
-
31
+ if (typeof props.defaultValue === "number")
32
+ return [props.defaultValue];
33
+ return props.defaultValue;
34
+ });
53
35
  const sliderValue = computed({
54
36
  get() {
55
- if (typeof modelValue.value === 'number')
56
- return [modelValue.value]
57
-
58
- return modelValue.value ?? defaultSliderValue.value
37
+ if (typeof modelValue.value === "number")
38
+ return [modelValue.value];
39
+ return modelValue.value ?? defaultSliderValue.value;
59
40
  },
60
41
  set(value) {
61
- modelValue.value = value?.length === 1 ? value[0] : value
62
- },
63
- })
64
-
65
- const thumbsCount = computed(() => sliderValue.value?.length ?? 1)
66
-
67
- const { id, size, name, disabled, ariaAttrs, emitFormChange, emitFormInput } = useFormItem<SliderProps>(props)
68
- const { generateStyle } = useTheme()
69
- const style = computed(() => generateStyle('slider', {
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", {
70
49
  ...props,
71
- size: size.value,
72
- }))
73
-
74
- function onChange(value: any) {
75
- // @ts-expect-error - 'target' does not exist in type 'EventInit'
76
- const event = new Event('change', { target: { value } })
77
- emit('change', event)
78
- emitFormChange()
79
- emitFormInput()
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();
80
57
  }
81
58
  </script>
82
59
 
@@ -84,15 +61,16 @@ function onChange(value: any) {
84
61
  <SliderRoot
85
62
  v-bind="{ ...rootProps, ...ariaAttrs, id, name, disabled }"
86
63
  v-model="sliderValue"
87
- :class="style.root({ class: [props.class, props.ui?.root] })"
88
64
  :default-value="defaultSliderValue"
65
+ :class="style.root({ class: [props.class, props.ui?.root] })"
66
+ data-part="root"
89
67
  :data-steps="thumbsCount"
90
68
  @value-commit="onChange"
91
69
  >
92
- <SliderTrack :class="style.track({ class: props.ui?.track })">
93
- <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" />
94
72
  </SliderTrack>
95
73
 
96
- <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" />
97
75
  </SliderRoot>
98
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,98 +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
- change: [payload: Event]
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 { useFormItem } from '../composables/useFormItem'
41
- import { useTheme } from '../composables/useTheme'
42
-
43
- const props = withDefaults(defineProps<SwitchProps>(), {})
44
- const emit = defineEmits<SwitchEmits>()
45
- const slots = defineSlots<SwitchSlots>()
46
- const modelValue = defineModel<boolean>({ default: undefined })
47
-
48
- const rootProps = useForwardProps(reactivePick(props, 'required', 'value', 'defaultValue'))
49
-
50
- const { id: _id, size, name, disabled, ariaAttrs, emitFormChange, emitFormInput } = useFormItem<SwitchProps>(props)
51
- const id = _id.value ?? useId()
52
-
53
- const { theme, generateStyle } = useTheme()
54
- 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", {
55
37
  ...props,
56
38
  size: size.value,
57
39
  disabled: disabled.value,
58
40
  checked: false,
59
- unchecked: false,
60
- }))
61
-
62
- function onUpdate(value: any) {
63
- // @ts-expect-error - 'target' does not exist in type 'EventInit'
64
- const event = new Event('change', { target: { value } })
65
-
66
- emit('change', event)
67
- emitFormChange()
68
- emitFormInput()
41
+ unchecked: false
42
+ }));
43
+ function onUpdate(value) {
44
+ const event = new Event("change", { target: { value } });
45
+ emit("change", event);
46
+ emitFormChange();
47
+ emitFormInput();
69
48
  }
70
49
  </script>
71
50
 
72
51
  <template>
73
- <Primitive :as="props.as" :class="style.root({ class: [props.class, props.ui?.root] })">
74
- <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">
75
54
  <SwitchRoot
76
55
  v-bind="{ ...rootProps, ...ariaAttrs, id, name }"
77
56
  v-model="modelValue"
78
- :class="style.base({ class: props.ui?.base })"
79
57
  :disabled="disabled || props.loading"
58
+ :class="style.base({ class: props.ui?.base })"
59
+ data-part="base"
80
60
  @update:model-value="onUpdate"
81
61
  >
82
- <SwitchThumb :class="style.thumb({ class: props.ui?.thumb })">
83
- <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>
84
64
  <template v-else>
85
- <span v-if="props.checkedIcon" :class="style.icon({ class: [props.checkedIcon, props.ui?.icon], checked: true })"></span>
86
- <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>
87
67
  </template>
88
68
  </SwitchThumb>
89
69
  </SwitchRoot>
90
70
  </div>
91
- <div v-if="props.label || slots.label || props.description || slots.description" :class="style.wrapper({ class: props.ui?.wrapper })">
92
- <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">
93
73
  <slot name="label" :label="props.label">{{ props.label }}</slot>
94
74
  </Label>
95
- <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">
96
76
  <slot name="description" :description="props.description">
97
77
  {{ props.description }}
98
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
+ };