@byyuurin/ui 0.1.0 → 0.3.0

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 (140) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +5 -3
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +2 -2
  5. package/dist/runtime/components/Accordion.vue +41 -41
  6. package/dist/runtime/components/Accordion.vue.d.ts +11 -7
  7. package/dist/runtime/components/Alert.vue +63 -63
  8. package/dist/runtime/components/Alert.vue.d.ts +4 -4
  9. package/dist/runtime/components/App.vue +11 -10
  10. package/dist/runtime/components/App.vue.d.ts +11 -7
  11. package/dist/runtime/components/Avatar.vue +29 -29
  12. package/dist/runtime/components/Avatar.vue.d.ts +4 -3
  13. package/dist/runtime/components/AvatarGroup.vue +4 -4
  14. package/dist/runtime/components/AvatarGroup.vue.d.ts +1 -1
  15. package/dist/runtime/components/Badge.vue +32 -32
  16. package/dist/runtime/components/Badge.vue.d.ts +2 -2
  17. package/dist/runtime/components/Breadcrumb.vue +49 -49
  18. package/dist/runtime/components/Breadcrumb.vue.d.ts +10 -6
  19. package/dist/runtime/components/Button.vue +52 -51
  20. package/dist/runtime/components/Button.vue.d.ts +1 -1
  21. package/dist/runtime/components/Calendar.vue +75 -77
  22. package/dist/runtime/components/Calendar.vue.d.ts +16 -12
  23. package/dist/runtime/components/Card.vue +41 -41
  24. package/dist/runtime/components/Card.vue.d.ts +1 -1
  25. package/dist/runtime/components/Carousel.vue +85 -66
  26. package/dist/runtime/components/Carousel.vue.d.ts +14 -10
  27. package/dist/runtime/components/Checkbox.vue +46 -46
  28. package/dist/runtime/components/Checkbox.vue.d.ts +4 -3
  29. package/dist/runtime/components/CheckboxGroup.vue +131 -0
  30. package/dist/runtime/components/CheckboxGroup.vue.d.ts +93 -0
  31. package/dist/runtime/components/Chip.vue +15 -15
  32. package/dist/runtime/components/Chip.vue.d.ts +2 -2
  33. package/dist/runtime/components/Collapsible.vue +14 -14
  34. package/dist/runtime/components/Collapsible.vue.d.ts +2 -2
  35. package/dist/runtime/components/Drawer.vue +76 -76
  36. package/dist/runtime/components/Drawer.vue.d.ts +6 -6
  37. package/dist/runtime/components/DropdownMenu.vue +28 -28
  38. package/dist/runtime/components/DropdownMenu.vue.d.ts +17 -9
  39. package/dist/runtime/components/DropdownMenuContent.vue +152 -153
  40. package/dist/runtime/components/DropdownMenuContent.vue.d.ts +11 -7
  41. package/dist/runtime/components/FieldGroup.vue +3 -3
  42. package/dist/runtime/components/FieldGroup.vue.d.ts +2 -2
  43. package/dist/runtime/components/Form.vue +9 -9
  44. package/dist/runtime/components/Form.vue.d.ts +13 -8
  45. package/dist/runtime/components/FormField.vue +39 -38
  46. package/dist/runtime/components/FormField.vue.d.ts +7 -2
  47. package/dist/runtime/components/Icon.vue +2 -2
  48. package/dist/runtime/components/Icon.vue.d.ts +1 -1
  49. package/dist/runtime/components/Input.vue +48 -48
  50. package/dist/runtime/components/Input.vue.d.ts +16 -12
  51. package/dist/runtime/components/InputNumber.vue +48 -50
  52. package/dist/runtime/components/InputNumber.vue.d.ts +128 -129
  53. package/dist/runtime/components/InputTags.vue +156 -0
  54. package/dist/runtime/components/InputTags.vue.d.ts +90 -0
  55. package/dist/runtime/components/Kbd.vue +3 -3
  56. package/dist/runtime/components/Kbd.vue.d.ts +2 -2
  57. package/dist/runtime/components/Link.vue +26 -25
  58. package/dist/runtime/components/Link.vue.d.ts +16 -6
  59. package/dist/runtime/components/LinkBase.vue +3 -3
  60. package/dist/runtime/components/LinkBase.vue.d.ts +2 -2
  61. package/dist/runtime/components/Marquee.vue +38 -0
  62. package/dist/runtime/components/Marquee.vue.d.ts +54 -0
  63. package/dist/runtime/components/Modal.vue +74 -74
  64. package/dist/runtime/components/Modal.vue.d.ts +6 -6
  65. package/dist/runtime/components/NavigationMenu.vue +243 -234
  66. package/dist/runtime/components/NavigationMenu.vue.d.ts +53 -14
  67. package/dist/runtime/components/OverlayProvider.vue +9 -9
  68. package/dist/runtime/components/Pagination.vue +47 -47
  69. package/dist/runtime/components/Pagination.vue.d.ts +4 -4
  70. package/dist/runtime/components/PinInput.vue +23 -23
  71. package/dist/runtime/components/PinInput.vue.d.ts +14 -10
  72. package/dist/runtime/components/Popover.vue +22 -22
  73. package/dist/runtime/components/Popover.vue.d.ts +11 -7
  74. package/dist/runtime/components/Progress.vue +25 -25
  75. package/dist/runtime/components/Progress.vue.d.ts +2 -2
  76. package/dist/runtime/components/RadioGroup.vue +50 -50
  77. package/dist/runtime/components/RadioGroup.vue.d.ts +13 -9
  78. package/dist/runtime/components/ScrollArea.vue +32 -32
  79. package/dist/runtime/components/ScrollArea.vue.d.ts +2 -2
  80. package/dist/runtime/components/Select.vue +299 -148
  81. package/dist/runtime/components/Select.vue.d.ts +103 -123
  82. package/dist/runtime/components/Separator.vue +30 -30
  83. package/dist/runtime/components/Separator.vue.d.ts +2 -2
  84. package/dist/runtime/components/Skeleton.vue +11 -11
  85. package/dist/runtime/components/Skeleton.vue.d.ts +2 -2
  86. package/dist/runtime/components/Slider.vue +25 -25
  87. package/dist/runtime/components/Slider.vue.d.ts +11 -7
  88. package/dist/runtime/components/Stepper.vue +116 -0
  89. package/dist/runtime/components/Stepper.vue.d.ts +83 -0
  90. package/dist/runtime/components/Switch.vue +30 -30
  91. package/dist/runtime/components/Switch.vue.d.ts +4 -3
  92. package/dist/runtime/components/Table.vue +188 -166
  93. package/dist/runtime/components/Table.vue.d.ts +27 -22
  94. package/dist/runtime/components/Tabs.vue +74 -74
  95. package/dist/runtime/components/Tabs.vue.d.ts +12 -8
  96. package/dist/runtime/components/Textarea.vue +47 -47
  97. package/dist/runtime/components/Textarea.vue.d.ts +16 -11
  98. package/dist/runtime/components/Timeline.vue +102 -0
  99. package/dist/runtime/components/Timeline.vue.d.ts +78 -0
  100. package/dist/runtime/components/Toast.vue +93 -93
  101. package/dist/runtime/components/Toast.vue.d.ts +5 -5
  102. package/dist/runtime/components/ToastProvider.vue +29 -29
  103. package/dist/runtime/components/ToastProvider.vue.d.ts +3 -3
  104. package/dist/runtime/components/Tooltip.vue +24 -25
  105. package/dist/runtime/components/Tooltip.vue.d.ts +2 -2
  106. package/dist/runtime/components/Tree.vue +241 -0
  107. package/dist/runtime/components/Tree.vue.d.ts +121 -0
  108. package/dist/runtime/composables/defineShortcuts.d.ts +1 -0
  109. package/dist/runtime/composables/defineShortcuts.js +44 -8
  110. package/dist/runtime/composables/useLocale.d.ts +12 -0
  111. package/dist/runtime/locale/en.d.ts +6 -0
  112. package/dist/runtime/locale/en.js +6 -0
  113. package/dist/runtime/locale/zh_tw.d.ts +6 -0
  114. package/dist/runtime/locale/zh_tw.js +6 -0
  115. package/dist/runtime/types/html.d.ts +8 -0
  116. package/dist/runtime/types/html.js +0 -0
  117. package/dist/runtime/types/index.d.ts +7 -0
  118. package/dist/runtime/types/index.js +7 -0
  119. package/dist/runtime/types/input.d.ts +5 -5
  120. package/dist/runtime/types/locale.d.ts +6 -0
  121. package/dist/runtime/types/unocss.d.ts +4 -4
  122. package/dist/runtime/types/utils.d.ts +9 -6
  123. package/dist/runtime/utils/index.d.ts +3 -3
  124. package/dist/runtime/utils/link.d.ts +2 -1
  125. package/dist/runtime/utils/link.js +40 -29
  126. package/dist/runtime/vue/components/Icon.vue +2 -2
  127. package/dist/runtime/vue/components/Icon.vue.d.ts +1 -1
  128. package/dist/runtime/vue/components/Link.vue +7 -12
  129. package/dist/runtime/vue/components/Link.vue.d.ts +11 -40
  130. package/dist/setup.d.mts +1 -1
  131. package/dist/shared/{ui.CzIlLITK.mjs → ui.9kQouwss.mjs} +5 -3
  132. package/dist/shared/{ui.DpbffTXs.d.mts → ui.D8Bg1HWt.d.mts} +2 -0
  133. package/dist/shared/{ui.DSyJHSTk.mjs → ui.DpkP12cX.mjs} +784 -84
  134. package/dist/unocss.mjs +1 -1
  135. package/dist/unplugin.d.mts +1 -1
  136. package/dist/unplugin.mjs +2 -2
  137. package/dist/vite.d.mts +1 -1
  138. package/dist/vite.mjs +2 -2
  139. package/package.json +29 -29
  140. package/vue-plugin.d.ts +5 -5
@@ -24,45 +24,45 @@ const ui = computed(() => {
24
24
  </script>
25
25
 
26
26
  <template>
27
- <Primitive :as="props.as" :class="ui.root({ class: [props.class, props.ui?.root] })" data-part="root">
28
- <slot name="content">
29
- <div
30
- v-if="slots.header || props.title || slots.title || props.description || slots.description"
31
- :class="ui.header({ class: props.ui?.header })"
32
- data-part="header"
33
- >
34
- <slot name="header">
35
- <Primitive
36
- v-if="props.title || slots.title"
37
- :as="!!slots.title ? void 0 : 'h2'"
38
- :class="ui.title({ class: props.ui?.title })"
39
- data-part="title"
40
- >
41
- <slot name="title">
42
- {{ props.title }}
43
- </slot>
44
- </Primitive>
45
- <Primitive
46
- v-if="props.description || slots.description"
47
- :as="!!slots.description ? void 0 : 'p'"
48
- :as-child="!!slots.description"
49
- :class="ui.description({ class: props.ui?.description })"
50
- data-part="description"
51
- >
52
- <slot name="description">
53
- {{ props.description }}
54
- </slot>
55
- </Primitive>
56
- </slot>
57
- </div>
58
-
59
- <div v-if="!!slots.default" :class="ui.body({ class: props.ui?.body })" data-part="body">
60
- <slot></slot>
61
- </div>
62
-
63
- <div v-if="!!slots.footer" :class="ui.footer({ class: props.ui?.footer })" data-part="footer">
64
- <slot name="footer"></slot>
65
- </div>
66
- </slot>
67
- </Primitive>
27
+ <Primitive :as="props.as" :class="ui.root({ class: [props.class, props.ui?.root] })" data-part="root">
28
+ <slot name="content">
29
+ <div
30
+ v-if="slots.header || props.title || slots.title || props.description || slots.description"
31
+ :class="ui.header({ class: props.ui?.header })"
32
+ data-part="header"
33
+ >
34
+ <slot name="header">
35
+ <Primitive
36
+ v-if="props.title || slots.title"
37
+ :as="!!slots.title ? void 0 : 'h2'"
38
+ :class="ui.title({ class: props.ui?.title })"
39
+ data-part="title"
40
+ >
41
+ <slot name="title">
42
+ {{ props.title }}
43
+ </slot>
44
+ </Primitive>
45
+ <Primitive
46
+ v-if="props.description || slots.description"
47
+ :as="!!slots.description ? void 0 : 'p'"
48
+ :as-child="!!slots.description"
49
+ :class="ui.description({ class: props.ui?.description })"
50
+ data-part="description"
51
+ >
52
+ <slot name="description">
53
+ {{ props.description }}
54
+ </slot>
55
+ </Primitive>
56
+ </slot>
57
+ </div>
58
+
59
+ <div v-if="!!slots.default" :class="ui.body({ class: props.ui?.body })" data-part="body">
60
+ <slot></slot>
61
+ </div>
62
+
63
+ <div v-if="!!slots.footer" :class="ui.footer({ class: props.ui?.footer })" data-part="footer">
64
+ <slot name="footer"></slot>
65
+ </div>
66
+ </slot>
67
+ </Primitive>
68
68
  </template>
@@ -24,9 +24,9 @@ export interface CardSlots {
24
24
  description: StaticSlot;
25
25
  footer: StaticSlot;
26
26
  }
27
- declare const __VLS_export: __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>;
28
27
  declare const _default: typeof __VLS_export;
29
28
  export default _default;
29
+ declare const __VLS_export: __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>;
30
30
  type __VLS_WithSlots<T, S> = T & {
31
31
  new (): {
32
32
  $slots: S;
@@ -57,6 +57,16 @@ const ui = computed(() => {
57
57
  const rootProps = useForwardProps(reactivePick(props, "active", "align", "breakpoints", "containScroll", "dragFree", "dragThreshold", "duration", "inViewThreshold", "loop", "skipSnaps", "slidesToScroll", "startIndex", "watchDrag", "watchResize", "watchSlides", "watchFocus"));
58
58
  const prevIcon = computed(() => props.prevIcon || (dir.value === "rtl" ? appConfig.ui.icons.chevronRight : appConfig.ui.icons.chevronLeft));
59
59
  const nextIcon = computed(() => props.nextIcon || (dir.value === "rtl" ? appConfig.ui.icons.chevronLeft : appConfig.ui.icons.chevronRight));
60
+ const stopAutoplayOnInteraction = computed(() => {
61
+ if (typeof props.autoplay == "boolean")
62
+ return true;
63
+ return props.autoplay.stopOnInteraction ?? true;
64
+ });
65
+ const stopAutoScrollOnInteraction = computed(() => {
66
+ if (typeof props.autoScroll === "boolean")
67
+ return true;
68
+ return props.autoScroll.stopOnInteraction ?? true;
69
+ });
60
70
  const options = computed(() => ({
61
71
  ...props.fade ? { align: "center", containScroll: false } : {},
62
72
  ...rootProps.value,
@@ -100,14 +110,23 @@ const [emblaRef, emblaApi] = useEmblaCarousel(options, plugins);
100
110
  watch(options, () => {
101
111
  emblaApi.value?.reInit(options.value, plugins.value);
102
112
  }, { flush: "post" });
113
+ function stopOnInteraction() {
114
+ if (stopAutoplayOnInteraction.value)
115
+ emblaApi.value?.plugins().autoplay?.stop();
116
+ if (stopAutoScrollOnInteraction.value)
117
+ emblaApi.value?.plugins().autoScroll?.stop();
118
+ }
103
119
  function scrollPrev() {
104
120
  emblaApi.value?.scrollPrev();
121
+ stopOnInteraction();
105
122
  }
106
123
  function scrollNext() {
107
124
  emblaApi.value?.scrollNext();
125
+ stopOnInteraction();
108
126
  }
109
127
  function scrollTo(index) {
110
128
  emblaApi.value?.scrollTo(index);
129
+ stopOnInteraction();
111
130
  }
112
131
  function onKeyDown(event) {
113
132
  let prevKey;
@@ -170,70 +189,70 @@ defineExpose({
170
189
  </script>
171
190
 
172
191
  <template>
173
- <Primitive
174
- :as="props.as"
175
- role="region"
176
- tabindex="0"
177
- :class="ui.root({ class: [props.class, props.ui?.root] })"
178
- aria-roledescription="carousel"
179
- :data-orientation="props.orientation"
180
- data-part="root"
181
- @keydown="onKeyDown"
182
- >
183
- <div ref="emblaRef" :class="ui.viewport({ class: props.ui?.viewport })" data-part="viewport">
184
- <div :class="ui.container({ class: props.ui?.container })" data-part="container">
185
- <div
186
- v-for="(item, index) in props.items"
187
- :key="index"
188
- v-bind="props.dots ? { role: 'tabpanel' } : { 'role': 'group', 'aria-roledescription': 'slide' }"
189
- :class="ui.item({ class: [props.ui?.item, ...isCarouselItem(item) ? [item.ui?.item, item.class] : []] })"
190
- data-part="item"
191
- >
192
- <slot :item="item" :index="index"></slot>
193
- </div>
194
- </div>
195
- </div>
196
-
197
- <div v-if="props.arrows || props.dots" :class="ui.controls({ class: props.ui?.controls })" data-part="controls">
198
- <div v-if="props.arrows" :class="ui.arrows({ class: props.ui?.arrows })" data-part="arrows">
199
- <Button
200
- :disabled="!canScrollPrev"
201
- :icon="prevIcon"
202
- color="neutral"
203
- variant="outline"
204
- :aria-label="t('carousel.prev')"
205
- v-bind="typeof props.prev === 'object' ? props.prev : void 0"
206
- :class="ui.prev({ class: props.ui?.prev })"
207
- data-part="prev"
208
- @click="scrollPrev"
209
- />
210
- <Button
211
- :disabled="!canScrollNext"
212
- :icon="nextIcon"
213
- color="neutral"
214
- variant="outline"
215
- :aria-label="t('carousel.next')"
216
- v-bind="typeof props.next === 'object' ? props.next : void 0"
217
- :class="ui.next({ class: props.ui?.next })"
218
- data-part="next"
219
- @click="scrollNext"
220
- />
221
- </div>
222
-
223
- <div v-if="props.dots" role="tablist" :aria-label="t('carousel.dots')" :class="ui.dots({ class: props.ui?.dots })" data-part="dots">
224
- <template v-for="(_, index) in scrollSnaps" :key="index">
225
- <button
226
- type="button"
227
- role="tab"
228
- :aria-label="t('carousel.goto', { page: index + 1 })"
229
- :aria-selected="selectedIndex === index"
230
- :class="ui.dot({ class: props.ui?.dot, active: selectedIndex === index })"
231
- data-part="dot"
232
- :data-state="selectedIndex === index ? 'active' : void 0"
233
- @click="scrollTo(index)"
234
- ></button>
235
- </template>
236
- </div>
237
- </div>
238
- </Primitive>
192
+ <Primitive
193
+ :as="props.as"
194
+ role="region"
195
+ tabindex="0"
196
+ :class="ui.root({ class: [props.class, props.ui?.root] })"
197
+ aria-roledescription="carousel"
198
+ :data-orientation="props.orientation"
199
+ data-part="root"
200
+ @keydown="onKeyDown"
201
+ >
202
+ <div ref="emblaRef" :class="ui.viewport({ class: props.ui?.viewport })" data-part="viewport">
203
+ <div :class="ui.container({ class: props.ui?.container })" data-part="container">
204
+ <div
205
+ v-for="(item, index) in props.items"
206
+ :key="index"
207
+ v-bind="props.dots ? { role: 'tabpanel' } : { 'role': 'group', 'aria-roledescription': 'slide' }"
208
+ :class="ui.item({ class: [props.ui?.item, ...isCarouselItem(item) ? [item.ui?.item, item.class] : []] })"
209
+ data-part="item"
210
+ >
211
+ <slot :item="item" :index="index"></slot>
212
+ </div>
213
+ </div>
214
+ </div>
215
+
216
+ <div v-if="props.arrows || props.dots" :class="ui.controls({ class: props.ui?.controls })" data-part="controls">
217
+ <div v-if="props.arrows" :class="ui.arrows({ class: props.ui?.arrows })" data-part="arrows">
218
+ <Button
219
+ :disabled="!canScrollPrev"
220
+ :icon="prevIcon"
221
+ color="neutral"
222
+ variant="outline"
223
+ :aria-label="t('carousel.prev')"
224
+ v-bind="typeof props.prev === 'object' ? props.prev : void 0"
225
+ :class="ui.prev({ class: props.ui?.prev })"
226
+ data-part="prev"
227
+ @click="scrollPrev"
228
+ />
229
+ <Button
230
+ :disabled="!canScrollNext"
231
+ :icon="nextIcon"
232
+ color="neutral"
233
+ variant="outline"
234
+ :aria-label="t('carousel.next')"
235
+ v-bind="typeof props.next === 'object' ? props.next : void 0"
236
+ :class="ui.next({ class: props.ui?.next })"
237
+ data-part="next"
238
+ @click="scrollNext"
239
+ />
240
+ </div>
241
+
242
+ <div v-if="props.dots" role="tablist" :aria-label="t('carousel.dots')" :class="ui.dots({ class: props.ui?.dots })" data-part="dots">
243
+ <template v-for="(_, index) in scrollSnaps" :key="index">
244
+ <button
245
+ type="button"
246
+ role="tab"
247
+ :aria-label="t('carousel.goto', { page: index + 1 })"
248
+ :aria-selected="selectedIndex === index"
249
+ :class="ui.dot({ class: props.ui?.dot, active: selectedIndex === index })"
250
+ data-part="dot"
251
+ :data-state="selectedIndex === index ? 'active' : void 0"
252
+ @click="scrollTo(index)"
253
+ ></button>
254
+ </template>
255
+ </div>
256
+ </div>
257
+ </Primitive>
239
258
  </template>
@@ -8,7 +8,7 @@ import type { FadeOptionsType } from 'embla-carousel-fade';
8
8
  import type { WheelGesturesPluginOptions } from 'embla-carousel-wheel-gestures';
9
9
  import type { PrimitiveProps } from 'reka-ui';
10
10
  import theme from '#build/ui/carousel';
11
- import type { ButtonProps, ComponentBaseProps, ComponentUIProps } from '../types';
11
+ import type { ButtonProps, ComponentBaseProps, ComponentUIProps, LinkPropsKeys } from '../types';
12
12
  import type { AcceptableValue, StaticSlot } from '../types/utils';
13
13
  export type CarouselValue = AcceptableValue;
14
14
  export type CarouselItem = AcceptableValue | {
@@ -27,7 +27,7 @@ export interface CarouselProps<T extends CarouselItem = CarouselItem> extends Co
27
27
  * Configure the prev button when arrows are enabled.
28
28
  * @default { size: 'md', variant: 'link' }
29
29
  */
30
- prev?: ButtonProps;
30
+ prev?: Omit<ButtonProps, LinkPropsKeys>;
31
31
  /**
32
32
  * The icon displayed in the prev button.
33
33
  * @default app.icons.chevronLeft
@@ -37,7 +37,7 @@ export interface CarouselProps<T extends CarouselItem = CarouselItem> extends Co
37
37
  * Configure the next button when arrows are enabled.
38
38
  * @default { size: 'md', variant: 'link' }
39
39
  */
40
- next?: ButtonProps;
40
+ next?: Omit<ButtonProps, LinkPropsKeys>;
41
41
  /**
42
42
  * The icon displayed in the next button.
43
43
  * @default app.icons.chevronRight
@@ -104,10 +104,14 @@ export interface CarouselSlots<T extends CarouselItem = CarouselItem> {
104
104
  index: number;
105
105
  }>;
106
106
  }
107
- declare const __VLS_export: <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<{
108
- props: __VLS_PrettifyLocal<CarouselProps<T> & {
107
+ declare const _default: typeof __VLS_export;
108
+ export default _default;
109
+ declare const __VLS_export: <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_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
110
+ props: import("vue").PublicProps & __VLS_PrettifyLocal<CarouselProps<T> & {
109
111
  onSelect?: ((selectedIndex: number) => any) | undefined;
110
- }> & import("vue").PublicProps;
112
+ }> & (typeof globalThis extends {
113
+ __VLS_PROPS_FALLBACK: infer P;
114
+ } ? P : {});
111
115
  expose: (exposed: import("vue").ShallowUnwrapRef<{
112
116
  emblaRef: import("vue").Ref<HTMLElement | undefined, HTMLElement | undefined>;
113
117
  emblaApi: import("vue").Ref<EmblaCarouselType | undefined, EmblaCarouselType | undefined>;
@@ -118,8 +122,8 @@ declare const __VLS_export: <T extends CarouselItem>(__VLS_props: NonNullable<Aw
118
122
  }>) => import("vue").VNode & {
119
123
  __ctx?: Awaited<typeof __VLS_setup>;
120
124
  };
121
- declare const _default: typeof __VLS_export;
122
- export default _default;
123
- type __VLS_PrettifyLocal<T> = {
125
+ type __VLS_PrettifyLocal<T> = (T extends any ? {
126
+ [K in keyof T]: T[K];
127
+ } : {
124
128
  [K in keyof T as K]: T[K];
125
- } & {};
129
+ }) & {};
@@ -55,50 +55,50 @@ function onUpdate(value) {
55
55
  </script>
56
56
 
57
57
  <template>
58
- <Primitive :as="!props.variant || props.variant === 'list' ? props.as : Label" :class="ui.root({ class: [props.ui?.root, props.class] })" data-part="root">
59
- <div :class="ui.container({ class: props.ui?.container })" data-part="container">
60
- <CheckboxRoot
61
- v-bind="{ id, ...rootProps, ...$attrs, ...ariaAttrs, name, disabled }"
62
- v-model="modelValue"
63
- :class="ui.base({ class: props.ui?.base })"
64
- data-part="base"
65
- @update:model-value="onUpdate"
66
- >
67
- <template #default="{ modelValue }">
68
- <CheckboxIndicator :class="ui.indicator({ class: props.ui?.indicator })" data-part="indicator">
69
- <Icon
70
- v-if="modelValue === 'indeterminate'"
71
- :name="props.indeterminateIcon || appConfig.ui.icons.minus"
72
- :class="ui.icon({ class: props.ui?.icon })"
73
- data-part="icon"
74
- />
75
- <Icon
76
- v-else
77
- :name="props.icon || appConfig.ui.icons.check"
78
- :class="ui.icon({ class: props.ui?.icon })"
79
- data-part="icon"
80
- />
81
- </CheckboxIndicator>
82
- </template>
83
- </CheckboxRoot>
84
- </div>
85
- <div v-if="props.label || !!slots.label || props.description || !!slots.description" :class="ui.wrapper({ class: props.ui?.wrapper })" data-part="wrapper">
86
- <component
87
- :is="!props.variant || props.variant === 'list' ? Label : 'p'"
88
- v-if="props.label || !!slots.label"
89
- :for="id"
90
- :class="ui.label({ class: props.ui?.label })"
91
- data-part="label"
92
- >
93
- <slot name="label" :label="props.label">
94
- {{ props.label }}
95
- </slot>
96
- </component>
97
- <p v-if="props.description || !!slots.description" :class="ui.description({ class: props.ui?.description })" data-part="description">
98
- <slot name="description" :description="props.description">
99
- {{ props.description }}
100
- </slot>
101
- </p>
102
- </div>
103
- </Primitive>
58
+ <Primitive :as="props.variant && props.variant !== 'list' ? Label : props.as" :class="ui.root({ class: [props.ui?.root, props.class] })" data-part="root">
59
+ <div :class="ui.container({ class: props.ui?.container })" data-part="container">
60
+ <CheckboxRoot
61
+ v-bind="{ id, ...rootProps, ...$attrs, ...ariaAttrs, name, disabled }"
62
+ v-model="modelValue"
63
+ :class="ui.base({ class: props.ui?.base })"
64
+ data-part="base"
65
+ @update:model-value="onUpdate"
66
+ >
67
+ <template #default="{ modelValue }">
68
+ <CheckboxIndicator :class="ui.indicator({ class: props.ui?.indicator })" data-part="indicator">
69
+ <Icon
70
+ v-if="modelValue === 'indeterminate'"
71
+ :name="props.indeterminateIcon || appConfig.ui.icons.minus"
72
+ :class="ui.icon({ class: props.ui?.icon })"
73
+ data-part="icon"
74
+ />
75
+ <Icon
76
+ v-else
77
+ :name="props.icon || appConfig.ui.icons.check"
78
+ :class="ui.icon({ class: props.ui?.icon })"
79
+ data-part="icon"
80
+ />
81
+ </CheckboxIndicator>
82
+ </template>
83
+ </CheckboxRoot>
84
+ </div>
85
+ <div v-if="props.label || !!slots.label || props.description || !!slots.description" :class="ui.wrapper({ class: props.ui?.wrapper })" data-part="wrapper">
86
+ <component
87
+ :is="!props.variant || props.variant === 'list' ? Label : 'p'"
88
+ v-if="props.label || !!slots.label"
89
+ :for="id"
90
+ :class="ui.label({ class: props.ui?.label })"
91
+ data-part="label"
92
+ >
93
+ <slot name="label" :label="props.label">
94
+ {{ props.label }}
95
+ </slot>
96
+ </component>
97
+ <p v-if="props.description || !!slots.description" :class="ui.description({ class: props.ui?.description })" data-part="description">
98
+ <slot name="description" :description="props.description">
99
+ {{ props.description }}
100
+ </slot>
101
+ </p>
102
+ </div>
103
+ </Primitive>
104
104
  </template>
@@ -2,9 +2,10 @@ import type { VariantProps } from '@byyuurin/ui-kit';
2
2
  import type { CheckboxRootEmits, CheckboxRootProps, PrimitiveProps } from 'reka-ui';
3
3
  import theme from '#build/ui/checkbox';
4
4
  import type { ComponentBaseProps, ComponentUIProps, IconProps } from '../types';
5
+ import type { ButtonHTMLAttributes } from '../types/html';
5
6
  import type { StaticSlot } from '../types/utils';
6
7
  type ThemeVariants = VariantProps<typeof theme>;
7
- export interface CheckboxProps extends ComponentBaseProps, Pick<CheckboxRootProps, 'disabled' | 'required' | 'name' | 'value' | 'id' | 'defaultValue'> {
8
+ export interface CheckboxProps extends ComponentBaseProps, Pick<CheckboxRootProps, 'disabled' | 'required' | 'name' | 'value' | 'id' | 'defaultValue'>, /** @vue-ignore */ Omit<ButtonHTMLAttributes, 'type' | 'disabled' | 'value' | 'name'> {
8
9
  /**
9
10
  * The element or component this component should render as.
10
11
  * @default "div"
@@ -44,6 +45,8 @@ export interface CheckboxSlots {
44
45
  description?: string;
45
46
  }>;
46
47
  }
48
+ declare const _default: typeof __VLS_export;
49
+ export default _default;
47
50
  declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<CheckboxProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
48
51
  change: (event: Event) => any;
49
52
  "update:modelValue": (value: boolean | "indeterminate") => any;
@@ -54,8 +57,6 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<Checkb
54
57
  disabled: boolean;
55
58
  required: boolean;
56
59
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, CheckboxSlots>;
57
- declare const _default: typeof __VLS_export;
58
- export default _default;
59
60
  type __VLS_WithSlots<T, S> = T & {
60
61
  new (): {
61
62
  $slots: S;
@@ -0,0 +1,131 @@
1
+ <script>
2
+ import theme from "#build/ui/checkbox-group";
3
+ </script>
4
+
5
+ <script setup>
6
+ import { reactivePick } from "@vueuse/core";
7
+ import { CheckboxGroupRoot, useForwardProps, useForwardPropsEmits } from "reka-ui";
8
+ import { computed, useId } from "vue";
9
+ import { useAppConfig } from "#imports";
10
+ import { useFormField } from "../composables/useFormField";
11
+ import { get, omit } from "../utils";
12
+ import { cv, merge } from "../utils/style";
13
+ import Checkbox from "./Checkbox.vue";
14
+ const props = defineProps({
15
+ as: { type: null, required: false },
16
+ legend: { type: String, required: false },
17
+ valueKey: { type: null, required: false, default: "value" },
18
+ labelKey: { type: null, required: false, default: "label" },
19
+ descriptionKey: { type: null, required: false, default: "description" },
20
+ items: { type: null, required: false },
21
+ modelValue: { type: null, required: false },
22
+ defaultValue: { type: null, required: false },
23
+ size: { type: null, required: false },
24
+ variant: { type: null, required: false },
25
+ orientation: { type: null, required: false, default: "vertical" },
26
+ ui: { type: null, required: false },
27
+ class: { type: [Object, String, Number, Boolean, null, Array], required: false, skipCheck: true },
28
+ disabled: { type: Boolean, required: false },
29
+ loop: { type: Boolean, required: false },
30
+ name: { type: String, required: false },
31
+ required: { type: Boolean, required: false },
32
+ color: { type: null, required: false },
33
+ indicator: { type: null, required: false },
34
+ icon: { type: [String, Object], required: false }
35
+ });
36
+ const emit = defineEmits(["update:modelValue", "change"]);
37
+ const slots = defineSlots();
38
+ const rootProps = useForwardPropsEmits(reactivePick(props, "as", "modelValue", "defaultValue", "orientation", "loop", "required"), emit);
39
+ const checkboxProps = useForwardProps(reactivePick(props, "indicator", "icon"));
40
+ const getProxySlots = () => omit(slots, ["legend"]);
41
+ const { id: _id, name, color, size, disabled, ariaAttrs, emitFormChange, emitFormInput } = useFormField(props, { bind: false });
42
+ const id = _id.value ?? useId();
43
+ function normalizeItem(item) {
44
+ const itemBase = {
45
+ disabled: disabled.value,
46
+ label: void 0,
47
+ description: void 0,
48
+ value: void 0,
49
+ ui: void 0,
50
+ class: void 0
51
+ };
52
+ if (typeof item === "object" && item === null) {
53
+ return {
54
+ ...itemBase,
55
+ id: `${id}:null`,
56
+ value: null
57
+ };
58
+ }
59
+ if (typeof item === "boolean" || typeof item === "string" || typeof item === "number" || typeof item === "bigint") {
60
+ return {
61
+ ...itemBase,
62
+ id: `${id}:${item}`,
63
+ label: String(item),
64
+ value: item
65
+ };
66
+ }
67
+ const value = get(item, props.valueKey);
68
+ const label = get(item, props.labelKey);
69
+ const description = get(item, props.descriptionKey);
70
+ return {
71
+ ...itemBase,
72
+ ...item,
73
+ value,
74
+ label,
75
+ description,
76
+ id: `${id}:${value}`
77
+ };
78
+ }
79
+ const normalizedItems = computed(() => {
80
+ if (!props.items)
81
+ return [];
82
+ return props.items.map(normalizeItem);
83
+ });
84
+ function onUpdate(value) {
85
+ const event = new Event("change", { target: { value } });
86
+ emit("change", event);
87
+ emitFormChange();
88
+ emitFormInput();
89
+ }
90
+ const appConfig = useAppConfig();
91
+ const ui = computed(() => {
92
+ const styler = cv(merge(theme, appConfig.ui.checkboxGroup));
93
+ return styler({
94
+ ...props,
95
+ size: size.value,
96
+ color: color.value
97
+ });
98
+ });
99
+ </script>
100
+
101
+ <template>
102
+ <CheckboxGroupRoot
103
+ v-bind="{ ...rootProps, id, name, disabled }"
104
+ :class="ui.root({ class: [props.ui?.root, props.class] })"
105
+ data-part="root"
106
+ @update:model-value="onUpdate"
107
+ >
108
+ <fieldset v-bind="ariaAttrs" :class="ui.fieldset({ class: props.ui?.fieldset })" data-part="fieldset">
109
+ <legend v-if="props.legend || !!slots.legend" :class="ui.legend({ class: props.ui?.legend })" data-part="legend">
110
+ <slot name="legend">
111
+ {{ props.legend }}
112
+ </slot>
113
+ </legend>
114
+
115
+ <Checkbox
116
+ v-for="item in normalizedItems"
117
+ :key="item.id"
118
+ v-bind="{ ...item, ...checkboxProps, color, size, name }"
119
+ :variant="props.variant"
120
+ :disabled="item.disabled || disabled"
121
+ :ui="{ ...props.ui ? omit(props.ui, ['root']) : void 0, ...item.ui || {} }"
122
+ :class="ui.item({ disabled: item.disabled || disabled, class: [props.ui?.item, item.ui?.item, item.class] })"
123
+ data-part="item"
124
+ >
125
+ <template v-for="(_, name) in getProxySlots()" #[name]>
126
+ <slot :name="name" :item="item"></slot>
127
+ </template>
128
+ </Checkbox>
129
+ </fieldset>
130
+ </CheckboxGroupRoot>
131
+ </template>