@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,56 +1,38 @@
1
- <script lang="ts">
2
- import type { VariantProps } from '@byyuurin/ui-kit'
3
- import type { PrimitiveProps } from 'reka-ui'
4
- import type { card } from '../theme'
5
- import type { ComponentAttrs } from '../types'
1
+ <script>
6
2
 
7
- export interface CardSlots {
8
- default?: (props?: {}) => any
9
- content?: (props?: {}) => any
10
- header?: (props?: {}) => any
11
- title?: (props?: {}) => any
12
- description?: (props?: {}) => any
13
- footer?: (props?: {}) => any
14
- }
15
-
16
- type CardVariants = VariantProps<typeof card>
17
-
18
- export interface CardProps extends ComponentAttrs<typeof card> {
19
- /**
20
- * The element or component this component should render as.
21
- * @default "div"
22
- */
23
- as?: PrimitiveProps['as']
24
- variant?: CardVariants['variant']
25
- title?: string
26
- description?: string
27
- }
28
3
  </script>
29
4
 
30
- <script setup lang="ts">
31
- import { Primitive } from 'reka-ui'
32
- import { computed } from 'vue'
33
- import { useTheme } from '../composables/useTheme'
34
-
35
- const props = withDefaults(defineProps<CardProps>(), {})
36
- const slots = defineSlots<CardSlots>()
37
-
38
- const { generateStyle } = useTheme()
39
- const style = computed(() => generateStyle('card', 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
+ variant: { type: null, required: false },
12
+ title: { type: String, required: false },
13
+ description: { type: String, required: false },
14
+ class: { type: null, required: false },
15
+ ui: { type: null, required: false }
16
+ });
17
+ const slots = defineSlots();
18
+ const { generateStyle } = useTheme();
19
+ const style = computed(() => generateStyle("card", props));
40
20
  </script>
41
21
 
42
22
  <template>
43
- <Primitive :as="props.as" :class="style.root({ class: [props.class, props.ui?.root] })">
23
+ <Primitive :as="props.as" :class="style.root({ class: [props.class, props.ui?.root] })" data-part="root">
44
24
  <slot name="content">
45
25
  <div
46
- v-if="slots.header || props.title || slots.title || props.description || slots.description "
26
+ v-if="slots.header || props.title || slots.title || props.description || slots.description"
47
27
  :class="style.header({ class: props.ui?.header })"
28
+ data-part="header"
48
29
  >
49
30
  <slot name="header">
50
31
  <Primitive
51
32
  v-if="props.title || slots.title"
52
- :as="slots.title ? undefined : 'h2'"
33
+ :as="slots.title ? void 0 : 'h2'"
53
34
  :class="style.title({ class: props.ui?.title })"
35
+ data-part="title"
54
36
  >
55
37
  <slot name="title">
56
38
  {{ props.title }}
@@ -58,9 +40,10 @@ const style = computed(() => generateStyle('card', props))
58
40
  </Primitive>
59
41
  <Primitive
60
42
  v-if="props.description || slots.description"
61
- :as="slots.description ? undefined : 'p'"
43
+ :as="slots.description ? void 0 : 'p'"
62
44
  :as-child="!!slots.description"
63
45
  :class="style.description({ class: props.ui?.description })"
46
+ data-part="description"
64
47
  >
65
48
  <slot name="description">
66
49
  {{ props.description }}
@@ -69,11 +52,11 @@ const style = computed(() => generateStyle('card', props))
69
52
  </slot>
70
53
  </div>
71
54
 
72
- <div v-if="slots.default" :class="style.body({ class: props.ui?.body })">
55
+ <div v-if="slots.default" :class="style.body({ class: props.ui?.body })" data-part="body">
73
56
  <slot></slot>
74
57
  </div>
75
58
 
76
- <div v-if="slots.footer" :class="style.footer({ class: props.ui?.footer })">
59
+ <div v-if="slots.footer" :class="style.footer({ class: props.ui?.footer })" data-part="footer">
77
60
  <slot name="footer"></slot>
78
61
  </div>
79
62
  </slot>
@@ -0,0 +1,30 @@
1
+ import type { VariantProps } from '@byyuurin/ui-kit';
2
+ import type { PrimitiveProps } from 'reka-ui';
3
+ import type { card } from '../theme/index.js';
4
+ import type { ComponentAttrs } from '../types/index.js';
5
+ export interface CardSlots {
6
+ default?: (props?: {}) => any;
7
+ content?: (props?: {}) => any;
8
+ header?: (props?: {}) => any;
9
+ title?: (props?: {}) => any;
10
+ description?: (props?: {}) => any;
11
+ footer?: (props?: {}) => any;
12
+ }
13
+ type CardVariants = VariantProps<typeof card>;
14
+ export interface CardProps extends ComponentAttrs<typeof card> {
15
+ /**
16
+ * The element or component this component should render as.
17
+ * @default "div"
18
+ */
19
+ as?: PrimitiveProps['as'];
20
+ variant?: CardVariants['variant'];
21
+ title?: string;
22
+ description?: string;
23
+ }
24
+ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<CardProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<CardProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, CardSlots>;
25
+ export default _default;
26
+ type __VLS_WithSlots<T, S> = T & {
27
+ new (): {
28
+ $slots: S;
29
+ };
30
+ };
@@ -1,252 +1,142 @@
1
- <script lang="ts">
2
- import type { VariantProps } from '@byyuurin/ui-kit'
3
- import type { EmblaCarouselType, EmblaOptionsType, EmblaPluginType } from 'embla-carousel'
4
- import type { AutoHeightOptionsType } from 'embla-carousel-auto-height'
5
- import type { AutoScrollOptionsType } from 'embla-carousel-auto-scroll'
6
- import type { AutoplayOptionsType } from 'embla-carousel-autoplay'
7
- import type { ClassNamesOptionsType } from 'embla-carousel-class-names'
8
- import type { FadeOptionsType } from 'embla-carousel-fade'
9
- import type { WheelGesturesPluginOptions } from 'embla-carousel-wheel-gestures'
10
- import type { AcceptableValue, PrimitiveProps } from 'reka-ui'
11
- import type { carousel } from '../theme'
12
- import type { ButtonProps, ComponentAttrs } from '../types'
1
+ <script>
13
2
 
14
- export interface CarouselSlots<T> {
15
- default?: (props: { item: T, index: number }) => any
16
- }
17
-
18
- type CarouselVariants = VariantProps<typeof carousel>
19
-
20
- export interface CarouselProps<T> extends ComponentAttrs<typeof carousel>, Omit<EmblaOptionsType, 'axis' | 'container' | 'slides' | 'direction'> {
21
- /**
22
- * The element or component this component should render as.
23
- * @default "div"
24
- */
25
- as?: PrimitiveProps['as']
26
- /**
27
- * Configure the prev button when arrows are enabled.
28
- * @default { size: 'md', variant: 'link' }
29
- */
30
- prev?: ButtonProps
31
- /**
32
- * The icon displayed in the prev button.
33
- * @default app.icons.chevronLeft
34
- */
35
- prevIcon?: string
36
- /**
37
- * Configure the next button when arrows are enabled.
38
- * @default { size: 'md', variant: 'link' }
39
- */
40
- next?: ButtonProps
41
- /**
42
- * The icon displayed in the next button.
43
- * @default app.icons.chevronRight
44
- */
45
- nextIcon?: string
46
- /**
47
- * Display prev and next buttons to scroll the carousel.
48
- * @default false
49
- */
50
- arrows?: boolean
51
- /**
52
- * Display dots to scroll to a specific slide.
53
- * @default false
54
- */
55
- dots?: boolean
56
- orientation?: CarouselVariants['orientation']
57
- items?: T[]
58
- /**
59
- * Enable Autoplay plugin
60
- * @link https://www.embla-carousel.com/plugins/autoplay/
61
- */
62
- autoplay?: boolean | AutoplayOptionsType
63
- /**
64
- * Enable Auto Scroll plugin
65
- * @link https://www.embla-carousel.com/plugins/auto-scroll/
66
- */
67
- autoScroll?: boolean | AutoScrollOptionsType
68
- /**
69
- * Enable Auto Height plugin
70
- * @link https://www.embla-carousel.com/plugins/auto-height/
71
- */
72
- autoHeight?: boolean | AutoHeightOptionsType
73
- /**
74
- * Enable Class Names plugin
75
- * @link https://www.embla-carousel.com/plugins/class-names/
76
- */
77
- classNames?: boolean | ClassNamesOptionsType
78
- /**
79
- * Enable Fade plugin
80
- * @link https://www.embla-carousel.com/plugins/fade/
81
- */
82
- fade?: boolean | FadeOptionsType
83
- /**
84
- * Enable Wheel Gestures plugin
85
- * @link https://www.embla-carousel.com/plugins/wheel-gestures/
86
- */
87
- wheelGestures?: boolean | WheelGesturesPluginOptions
88
- }
89
3
  </script>
90
4
 
91
- <script setup lang="ts" generic="T extends AcceptableValue">
92
- import { computedAsync, reactivePick } from '@vueuse/core'
93
- import useEmblaCarousel from 'embla-carousel-vue'
94
- import { Primitive, useForwardProps } from 'reka-ui'
95
- import { computed, onMounted, ref, watch } from 'vue'
96
- import { useLocale } from '../composables/useLocale'
97
- import { useTheme } from '../composables/useTheme'
98
- import Button from './Button.vue'
99
-
100
- const props = withDefaults(defineProps<CarouselProps<T>>(), {
101
- orientation: 'horizontal',
102
- arrows: false,
103
- dots: false,
104
-
105
- // Embla Options
106
- active: true,
107
- align: 'center',
108
- breakpoints: () => ({}),
109
- containScroll: 'trimSnaps',
110
- dragFree: false,
111
- dragThreshold: 10,
112
- duration: 25,
113
- inViewThreshold: 0,
114
- loop: false,
115
- skipSnaps: false,
116
- slidesToScroll: 1,
117
- startIndex: 0,
118
- watchDrag: true,
119
- watchResize: true,
120
- watchSlides: true,
121
- watchFocus: true,
122
-
123
- // Embla Plugins
124
- autoplay: false,
125
- autoScroll: false,
126
- autoHeight: false,
127
- classNames: false,
128
- fade: false,
129
- wheelGestures: false,
130
- })
131
- defineSlots<CarouselSlots<T>>()
132
-
133
- const rootProps = useForwardProps(reactivePick(props, 'active', 'align', 'breakpoints', 'containScroll', 'dragFree', 'dragThreshold', 'duration', 'inViewThreshold', 'loop', 'skipSnaps', 'slidesToScroll', 'startIndex', 'watchDrag', 'watchResize', 'watchSlides', 'watchFocus'))
134
-
135
- const { t, dir } = useLocale()
136
- const { theme, generateStyle } = useTheme()
137
- const style = computed(() => generateStyle('carousel', props))
138
-
139
- const prevIcon = computed(() => props.prevIcon || (dir.value === 'rtl' ? theme.value.app.icons.chevronRight : theme.value.app.icons.chevronLeft))
140
- const nextIcon = computed(() => props.nextIcon || (dir.value === 'rtl' ? theme.value.app.icons.chevronLeft : theme.value.app.icons.chevronRight))
141
-
142
- const options = computed<EmblaOptionsType>(() => ({
143
- ...(props.fade ? { align: 'center', containScroll: false } : {}),
5
+ <script setup>
6
+ import { computedAsync, reactivePick } from "@vueuse/core";
7
+ import useEmblaCarousel from "embla-carousel-vue";
8
+ import { Primitive, useForwardProps } from "reka-ui";
9
+ import { computed, onMounted, ref, watch } from "vue";
10
+ import { useLocale } from "../composables/useLocale";
11
+ import { useTheme } from "../composables/useTheme";
12
+ import Button from "./Button.vue";
13
+ const props = defineProps({
14
+ as: { type: null, required: false },
15
+ prev: { type: Object, required: false },
16
+ prevIcon: { type: String, required: false },
17
+ next: { type: Object, required: false },
18
+ nextIcon: { type: String, required: false },
19
+ arrows: { type: Boolean, required: false, default: false },
20
+ dots: { type: Boolean, required: false, default: false },
21
+ orientation: { type: null, required: false, default: "horizontal" },
22
+ items: { type: Array, required: false },
23
+ autoplay: { type: [Boolean, Object], required: false, default: false },
24
+ autoScroll: { type: [Boolean, Object], required: false, default: false },
25
+ autoHeight: { type: [Boolean, Object], required: false, default: false },
26
+ classNames: { type: [Boolean, Object], required: false, default: false },
27
+ fade: { type: [Boolean, Object], required: false, default: false },
28
+ wheelGestures: { type: Boolean, required: false, skipCheck: true, default: false },
29
+ class: { type: null, required: false },
30
+ ui: { type: null, required: false },
31
+ align: { type: [String, Function], required: false, default: "center" },
32
+ containScroll: { type: [Boolean, String], required: false, default: "trimSnaps" },
33
+ slidesToScroll: { type: [String, Number], required: false, default: 1 },
34
+ dragFree: { type: Boolean, required: false, default: false },
35
+ dragThreshold: { type: Number, required: false, default: 10 },
36
+ inViewThreshold: { type: null, required: false, default: 0 },
37
+ loop: { type: Boolean, required: false, default: false },
38
+ skipSnaps: { type: Boolean, required: false, default: false },
39
+ duration: { type: Number, required: false, default: 25 },
40
+ startIndex: { type: Number, required: false, default: 0 },
41
+ watchDrag: { type: [Boolean, Function], required: false, default: true },
42
+ watchResize: { type: [Boolean, Function], required: false, default: true },
43
+ watchSlides: { type: [Boolean, Function], required: false, default: true },
44
+ watchFocus: { type: [Boolean, Function], required: false, default: true },
45
+ active: { type: Boolean, required: false, default: true },
46
+ breakpoints: { type: Object, required: false, default: () => ({}) }
47
+ });
48
+ defineSlots();
49
+ const rootProps = useForwardProps(reactivePick(props, "active", "align", "breakpoints", "containScroll", "dragFree", "dragThreshold", "duration", "inViewThreshold", "loop", "skipSnaps", "slidesToScroll", "startIndex", "watchDrag", "watchResize", "watchSlides", "watchFocus"));
50
+ const { t, dir } = useLocale();
51
+ const { theme, generateStyle } = useTheme();
52
+ const style = computed(() => generateStyle("carousel", props));
53
+ const prevIcon = computed(() => props.prevIcon || (dir.value === "rtl" ? theme.value.app.icons.chevronRight : theme.value.app.icons.chevronLeft));
54
+ const nextIcon = computed(() => props.nextIcon || (dir.value === "rtl" ? theme.value.app.icons.chevronLeft : theme.value.app.icons.chevronRight));
55
+ const options = computed(() => ({
56
+ ...props.fade ? { align: "center", containScroll: false } : {},
144
57
  ...rootProps.value,
145
- axis: props.orientation === 'horizontal' ? 'x' : 'y',
146
- direction: dir.value === 'rtl' ? 'rtl' : 'ltr',
147
- }))
148
-
149
- const plugins = computedAsync<EmblaPluginType[]>(async () => {
150
- const plugins: EmblaPluginType[] = []
151
-
58
+ axis: props.orientation === "horizontal" ? "x" : "y",
59
+ direction: dir.value === "rtl" ? "rtl" : "ltr"
60
+ }));
61
+ const plugins = computedAsync(async () => {
62
+ const plugins2 = [];
152
63
  if (props.autoplay) {
153
- const AutoplayPlugin = await import('embla-carousel-autoplay').then((r) => r.default)
154
- plugins.push(AutoplayPlugin(typeof props.autoplay === 'boolean' ? {} : props.autoplay))
64
+ const AutoplayPlugin = await import("embla-carousel-autoplay").then((r) => r.default);
65
+ plugins2.push(AutoplayPlugin(typeof props.autoplay === "boolean" ? {} : props.autoplay));
155
66
  }
156
-
157
67
  if (props.autoScroll) {
158
- const AutoScrollPlugin = await import('embla-carousel-auto-scroll').then((r) => r.default)
159
- plugins.push(AutoScrollPlugin(typeof props.autoScroll === 'boolean' ? {} : props.autoScroll))
68
+ const AutoScrollPlugin = await import("embla-carousel-auto-scroll").then((r) => r.default);
69
+ plugins2.push(AutoScrollPlugin(typeof props.autoScroll === "boolean" ? {} : props.autoScroll));
160
70
  }
161
-
162
71
  if (props.autoHeight) {
163
- const AutoHeightPlugin = await import('embla-carousel-auto-height').then((r) => r.default)
164
- plugins.push(AutoHeightPlugin(typeof props.autoHeight === 'boolean' ? {} : props.autoHeight))
72
+ const AutoHeightPlugin = await import("embla-carousel-auto-height").then((r) => r.default);
73
+ plugins2.push(AutoHeightPlugin(typeof props.autoHeight === "boolean" ? {} : props.autoHeight));
165
74
  }
166
-
167
75
  if (props.classNames) {
168
- const ClassNamesPlugin = await import('embla-carousel-class-names').then((r) => r.default)
169
- plugins.push(ClassNamesPlugin(typeof props.classNames === 'boolean' ? {} : props.classNames))
76
+ const ClassNamesPlugin = await import("embla-carousel-class-names").then((r) => r.default);
77
+ plugins2.push(ClassNamesPlugin(typeof props.classNames === "boolean" ? {} : props.classNames));
170
78
  }
171
-
172
79
  if (props.fade) {
173
- const FadePlugin = await import('embla-carousel-fade').then((r) => r.default)
174
- plugins.push(FadePlugin(typeof props.fade === 'boolean' ? {} : props.fade))
80
+ const FadePlugin = await import("embla-carousel-fade").then((r) => r.default);
81
+ plugins2.push(FadePlugin(typeof props.fade === "boolean" ? {} : props.fade));
175
82
  }
176
-
177
83
  if (props.wheelGestures) {
178
- const { WheelGesturesPlugin } = await import('embla-carousel-wheel-gestures')
179
- plugins.push(WheelGesturesPlugin(typeof props.wheelGestures === 'boolean' ? {} : props.wheelGestures))
84
+ const { WheelGesturesPlugin } = await import("embla-carousel-wheel-gestures");
85
+ plugins2.push(WheelGesturesPlugin(typeof props.wheelGestures === "boolean" ? {} : props.wheelGestures));
180
86
  }
181
-
182
- return plugins
183
- })
184
-
185
- const [emblaRef, emblaApi] = useEmblaCarousel(options.value, plugins.value)
186
-
87
+ return plugins2;
88
+ });
89
+ const [emblaRef, emblaApi] = useEmblaCarousel(options.value, plugins.value);
187
90
  watch([options, plugins], () => {
188
- emblaApi.value?.reInit(options.value, plugins.value)
189
- })
190
-
91
+ emblaApi.value?.reInit(options.value, plugins.value);
92
+ });
191
93
  function scrollPrev() {
192
- emblaApi.value?.scrollPrev()
94
+ emblaApi.value?.scrollPrev();
193
95
  }
194
-
195
96
  function scrollNext() {
196
- emblaApi.value?.scrollNext()
97
+ emblaApi.value?.scrollNext();
197
98
  }
198
-
199
- function scrollTo(index: number) {
200
- emblaApi.value?.scrollTo(index)
99
+ function scrollTo(index) {
100
+ emblaApi.value?.scrollTo(index);
201
101
  }
202
-
203
- function onKeyDown(event: KeyboardEvent) {
204
- const prevKey = props.orientation === 'vertical' ? 'ArrowUp' : 'ArrowLeft'
205
- const nextKey = props.orientation === 'vertical' ? 'ArrowDown' : 'ArrowRight'
206
-
102
+ function onKeyDown(event) {
103
+ const prevKey = props.orientation === "vertical" ? "ArrowUp" : "ArrowLeft";
104
+ const nextKey = props.orientation === "vertical" ? "ArrowDown" : "ArrowRight";
207
105
  if (event.key === prevKey) {
208
- event.preventDefault()
209
- scrollPrev()
210
-
211
- return
106
+ event.preventDefault();
107
+ scrollPrev();
108
+ return;
212
109
  }
213
-
214
110
  if (event.key === nextKey) {
215
- event.preventDefault()
216
- scrollNext()
111
+ event.preventDefault();
112
+ scrollNext();
217
113
  }
218
114
  }
219
-
220
- const canScrollNext = ref(false)
221
- const canScrollPrev = ref(false)
222
- const selectedIndex = ref<number>(0)
223
- const scrollSnaps = ref<number[]>([])
224
-
225
- function onInit(api: EmblaCarouselType) {
226
- scrollSnaps.value = api?.scrollSnapList() || []
115
+ const canScrollNext = ref(false);
116
+ const canScrollPrev = ref(false);
117
+ const selectedIndex = ref(0);
118
+ const scrollSnaps = ref([]);
119
+ function onInit(api) {
120
+ scrollSnaps.value = api?.scrollSnapList() || [];
227
121
  }
228
-
229
- function onSelect(api: EmblaCarouselType) {
230
- canScrollNext.value = api?.canScrollNext() || false
231
- canScrollPrev.value = api?.canScrollPrev() || false
232
- selectedIndex.value = api?.selectedScrollSnap() || 0
122
+ function onSelect(api) {
123
+ canScrollNext.value = api?.canScrollNext() || false;
124
+ canScrollPrev.value = api?.canScrollPrev() || false;
125
+ selectedIndex.value = api?.selectedScrollSnap() || 0;
233
126
  }
234
-
235
127
  onMounted(() => {
236
128
  if (!emblaApi.value)
237
- return
238
-
239
- emblaApi.value?.on('init', onInit)
240
- emblaApi.value?.on('init', onSelect)
241
- emblaApi.value?.on('reInit', onInit)
242
- emblaApi.value?.on('reInit', onSelect)
243
- emblaApi.value?.on('select', onSelect)
244
- })
245
-
129
+ return;
130
+ emblaApi.value?.on("init", onInit);
131
+ emblaApi.value?.on("init", onSelect);
132
+ emblaApi.value?.on("reInit", onInit);
133
+ emblaApi.value?.on("reInit", onSelect);
134
+ emblaApi.value?.on("select", onSelect);
135
+ });
246
136
  defineExpose({
247
137
  emblaRef,
248
- emblaApi,
249
- })
138
+ emblaApi
139
+ });
250
140
  </script>
251
141
 
252
142
  <template>
@@ -256,32 +146,35 @@ defineExpose({
256
146
  aria-roledescription="carousel"
257
147
  tabindex="0"
258
148
  :class="style.root({ class: [props.class, props.ui?.root] })"
149
+ data-part="root"
259
150
  @keydown="onKeyDown"
260
151
  >
261
- <div ref="emblaRef" :class="style.viewport({ class: props.ui?.viewport })">
262
- <div :class="style.container({ class: props.ui?.container })">
152
+ <div ref="emblaRef" :class="style.viewport({ class: props.ui?.viewport })" data-part="viewport">
153
+ <div :class="style.container({ class: props.ui?.container })" data-part="container">
263
154
  <div
264
155
  v-for="(item, index) in props.items"
265
156
  :key="index"
266
157
  role="group"
267
158
  aria-roledescription="slide"
268
159
  :class="style.item({ class: props.ui?.item })"
160
+ data-part="item"
269
161
  >
270
162
  <slot :item="item" :index="index"></slot>
271
163
  </div>
272
164
  </div>
273
165
  </div>
274
166
 
275
- <div v-if="props.arrows || props.dots" :class="style.controls({ class: props.ui?.controls })">
276
- <div v-if="props.arrows" :class="style.arrows({ class: props.ui?.arrows })">
167
+ <div v-if="props.arrows || props.dots" :class="style.controls({ class: props.ui?.controls })" data-part="controls">
168
+ <div v-if="props.arrows" :class="style.arrows({ class: props.ui?.arrows })" data-part="arrows">
277
169
  <Button
278
170
  :disabled="!canScrollPrev"
279
171
  :icon="prevIcon"
280
172
  size="md"
281
173
  variant="outline"
282
174
  :aria-label="t('carousel.prev')"
283
- v-bind="typeof props.prev === 'object' ? props.prev : undefined"
175
+ v-bind="typeof props.prev === 'object' ? props.prev : void 0"
284
176
  :class="style.prev({ class: props.ui?.prev })"
177
+ data-part="prev"
285
178
  @click="scrollPrev"
286
179
  />
287
180
  <Button
@@ -290,17 +183,19 @@ defineExpose({
290
183
  size="md"
291
184
  variant="outline"
292
185
  :aria-label="t('carousel.next')"
293
- v-bind="typeof props.next === 'object' ? props.next : undefined"
186
+ v-bind="typeof props.next === 'object' ? props.next : void 0"
294
187
  :class="style.next({ class: props.ui?.next })"
188
+ data-part="next"
295
189
  @click="scrollNext"
296
190
  />
297
191
  </div>
298
192
 
299
- <div v-if="props.dots" :class="style.dots({ class: props.ui?.dots })">
193
+ <div v-if="props.dots" :class="style.dots({ class: props.ui?.dots })" data-part="dots">
300
194
  <template v-for="(_, index) in scrollSnaps" :key="index">
301
195
  <button
302
196
  :aria-label="t('carousel.goto', { page: index + 1 })"
303
197
  :class="style.dot({ class: props.ui?.dot, active: selectedIndex === index })"
198
+ data-part="dot"
304
199
  @click="scrollTo(index)"
305
200
  ></button>
306
201
  </template>
@@ -0,0 +1,104 @@
1
+ import type { VariantProps } from '@byyuurin/ui-kit';
2
+ import type { EmblaCarouselType, EmblaOptionsType } from 'embla-carousel';
3
+ import type { AutoHeightOptionsType } from 'embla-carousel-auto-height';
4
+ import type { AutoScrollOptionsType } from 'embla-carousel-auto-scroll';
5
+ import type { AutoplayOptionsType } from 'embla-carousel-autoplay';
6
+ import type { ClassNamesOptionsType } from 'embla-carousel-class-names';
7
+ import type { FadeOptionsType } from 'embla-carousel-fade';
8
+ import type { WheelGesturesPluginOptions } from 'embla-carousel-wheel-gestures';
9
+ import type { AcceptableValue, PrimitiveProps } from 'reka-ui';
10
+ import type { carousel } from '../theme/index.js';
11
+ import type { ButtonProps, ComponentAttrs } from '../types/index.js';
12
+ export type CarouselItem = AcceptableValue;
13
+ export interface CarouselSlots<T extends CarouselItem = CarouselItem> {
14
+ default?: (props: {
15
+ item: T;
16
+ index: number;
17
+ }) => any;
18
+ }
19
+ type CarouselVariants = VariantProps<typeof carousel>;
20
+ export interface CarouselProps<T extends CarouselItem = CarouselItem> extends ComponentAttrs<typeof carousel>, Omit<EmblaOptionsType, 'axis' | 'container' | 'slides' | 'direction'> {
21
+ /**
22
+ * The element or component this component should render as.
23
+ * @default "div"
24
+ */
25
+ as?: PrimitiveProps['as'];
26
+ /**
27
+ * Configure the prev button when arrows are enabled.
28
+ * @default { size: 'md', variant: 'link' }
29
+ */
30
+ prev?: ButtonProps;
31
+ /**
32
+ * The icon displayed in the prev button.
33
+ * @default app.icons.chevronLeft
34
+ */
35
+ prevIcon?: string;
36
+ /**
37
+ * Configure the next button when arrows are enabled.
38
+ * @default { size: 'md', variant: 'link' }
39
+ */
40
+ next?: ButtonProps;
41
+ /**
42
+ * The icon displayed in the next button.
43
+ * @default app.icons.chevronRight
44
+ */
45
+ nextIcon?: string;
46
+ /**
47
+ * Display prev and next buttons to scroll the carousel.
48
+ * @default false
49
+ */
50
+ arrows?: boolean;
51
+ /**
52
+ * Display dots to scroll to a specific slide.
53
+ * @default false
54
+ */
55
+ dots?: boolean;
56
+ orientation?: CarouselVariants['orientation'];
57
+ items?: T[];
58
+ /**
59
+ * Enable Autoplay plugin
60
+ * @link https://www.embla-carousel.com/plugins/autoplay/
61
+ */
62
+ autoplay?: boolean | AutoplayOptionsType;
63
+ /**
64
+ * Enable Auto Scroll plugin
65
+ * @link https://www.embla-carousel.com/plugins/auto-scroll/
66
+ */
67
+ autoScroll?: boolean | AutoScrollOptionsType;
68
+ /**
69
+ * Enable Auto Height plugin
70
+ * @link https://www.embla-carousel.com/plugins/auto-height/
71
+ */
72
+ autoHeight?: boolean | AutoHeightOptionsType;
73
+ /**
74
+ * Enable Class Names plugin
75
+ * @link https://www.embla-carousel.com/plugins/class-names/
76
+ */
77
+ classNames?: boolean | ClassNamesOptionsType;
78
+ /**
79
+ * Enable Fade plugin
80
+ * @link https://www.embla-carousel.com/plugins/fade/
81
+ */
82
+ fade?: boolean | FadeOptionsType;
83
+ /**
84
+ * Enable Wheel Gestures plugin
85
+ * @link https://www.embla-carousel.com/plugins/wheel-gestures/
86
+ */
87
+ wheelGestures?: boolean | WheelGesturesPluginOptions;
88
+ }
89
+ declare const _default: <T extends CarouselItem>(__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<{
90
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, never> & CarouselProps<T> & Partial<{}>> & import("vue").PublicProps;
91
+ expose(exposed: import("vue").ShallowUnwrapRef<{
92
+ emblaRef: import("vue").Ref<HTMLElement | undefined, HTMLElement | undefined>;
93
+ emblaApi: import("vue").Ref<EmblaCarouselType | undefined, EmblaCarouselType | undefined>;
94
+ }>): void;
95
+ attrs: any;
96
+ slots: CarouselSlots<T>;
97
+ emit: {};
98
+ }>) => import("vue").VNode & {
99
+ __ctx?: Awaited<typeof __VLS_setup>;
100
+ };
101
+ export default _default;
102
+ type __VLS_PrettifyLocal<T> = {
103
+ [K in keyof T]: T[K];
104
+ } & {};