@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,36 +1,32 @@
1
- <script lang="ts">
2
- import type { ScrollAreaRootProps } from 'reka-ui'
3
- import type { scrollArea } from '../theme'
4
- import { transitionProps } from '../theme/scroll-area'
5
- import type { ComponentAttrs } from '../types'
6
-
7
- export interface ScrollAreaProps extends ComponentAttrs<typeof scrollArea>, Pick<ScrollAreaRootProps, 'type' | 'dir' | 'scrollHideDelay'> {}
1
+ <script>
2
+ import { transitionProps } from "../theme/scroll-area";
8
3
  </script>
9
4
 
10
- <script setup lang="ts">
11
- import { reactivePick } from '@vueuse/core'
12
- import { ScrollAreaCorner, ScrollAreaRoot, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport } from 'reka-ui'
13
- import { computed, ref } from 'vue'
14
- import { useTheme } from '../composables/useTheme'
15
-
16
- const props = withDefaults(defineProps<ScrollAreaProps>(), {})
17
- const rootRef = ref<InstanceType<typeof ScrollAreaRoot>>()
18
- const rootProps = reactivePick(props, 'type', 'dir', 'scrollHideDelay')
19
-
20
- const { generateStyle } = useTheme()
21
- const style = computed(() => generateStyle('scrollArea', props))
22
-
5
+ <script setup>
6
+ import { reactivePick } from "@vueuse/core";
7
+ import { ScrollAreaCorner, ScrollAreaRoot, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport } from "reka-ui";
8
+ import { computed, ref } from "vue";
9
+ import { useTheme } from "../composables/useTheme";
10
+ const props = defineProps({
11
+ class: { type: null, required: false },
12
+ ui: { type: null, required: false },
13
+ type: { type: String, required: false },
14
+ dir: { type: String, required: false },
15
+ scrollHideDelay: { type: Number, required: false }
16
+ });
17
+ const rootRef = ref();
18
+ const rootProps = reactivePick(props, "type", "dir", "scrollHideDelay");
19
+ const { generateStyle } = useTheme();
20
+ const style = computed(() => generateStyle("scrollArea", props));
23
21
  defineExpose({
24
22
  scrollTop,
25
- scrollTopLeft,
26
- })
27
-
23
+ scrollTopLeft
24
+ });
28
25
  function scrollTop() {
29
- rootRef.value?.scrollTop()
26
+ rootRef.value?.scrollTop();
30
27
  }
31
-
32
28
  function scrollTopLeft() {
33
- rootRef.value?.scrollTopLeft()
29
+ rootRef.value?.scrollTopLeft();
34
30
  }
35
31
  </script>
36
32
 
@@ -39,29 +35,33 @@ function scrollTopLeft() {
39
35
  ref="rootRef"
40
36
  v-bind="rootProps"
41
37
  :class="style.root({ class: [props.class, props.ui?.root] })"
38
+ data-part="root"
42
39
  >
43
- <ScrollAreaViewport :class="style.viewport({ class: props.ui?.viewport })">
40
+ <ScrollAreaViewport :class="style.viewport({ class: props.ui?.viewport })" data-part="viewport">
44
41
  <slot></slot>
45
42
  </ScrollAreaViewport>
46
43
 
47
44
  <TransitionGroup v-bind="transitionProps">
48
45
  <ScrollAreaScrollbar
49
46
  key="scrollbar-horizontal"
50
- :class="style.scrollbar({ class: props.ui?.scrollbar })"
51
47
  orientation="horizontal"
48
+ :class="style.scrollbar({ class: props.ui?.scrollbar })"
49
+ data-part="scrollbar"
52
50
  >
53
- <ScrollAreaThumb :class="style.thumb({ class: props.ui?.thumb })" />
51
+ <ScrollAreaThumb :class="style.thumb({ class: props.ui?.thumb })" data-part="thumb" />
54
52
  </ScrollAreaScrollbar>
55
53
  <ScrollAreaScrollbar
56
54
  key="scrollbar-vertical"
57
- :class="style.scrollbar({ class: props.ui?.scrollbar })"
58
55
  orientation="vertical"
56
+ :class="style.scrollbar({ class: props.ui?.scrollbar })"
57
+ data-part="scrollbar"
59
58
  >
60
- <ScrollAreaThumb :class="style.thumb({ class: props.ui?.thumb })" />
59
+ <ScrollAreaThumb :class="style.thumb({ class: props.ui?.thumb })" data-part="thumb" />
61
60
  </ScrollAreaScrollbar>
62
61
  <ScrollAreaCorner
63
62
  key="corner"
64
63
  :class="style.corner({ class: props.ui?.corner })"
64
+ data-part="corner"
65
65
  />
66
66
  </TransitionGroup>
67
67
  </ScrollAreaRoot>
@@ -0,0 +1,17 @@
1
+ import type { ScrollAreaRootProps } from 'reka-ui';
2
+ import type { scrollArea } from '../theme/index.js';
3
+ import type { ComponentAttrs } from '../types/index.js';
4
+ export interface ScrollAreaProps extends ComponentAttrs<typeof scrollArea>, Pick<ScrollAreaRootProps, 'type' | 'dir' | 'scrollHideDelay'> {
5
+ }
6
+ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<ScrollAreaProps, {
7
+ scrollTop: () => void;
8
+ scrollTopLeft: () => void;
9
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ScrollAreaProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
10
+ default?: (props: {}) => any;
11
+ }>;
12
+ export default _default;
13
+ type __VLS_WithSlots<T, S> = T & {
14
+ new (): {
15
+ $slots: S;
16
+ };
17
+ };
@@ -1,181 +1,100 @@
1
- <script lang="ts">
2
- import type { VariantProps } from '@byyuurin/ui-kit'
3
- import type { AcceptableValue, SelectArrowProps, SelectContentProps, SelectRootProps } from 'reka-ui'
4
- import type { UseComponentIconsProps } from '../composables/useComponentIcons'
5
- import type { select } from '../theme'
6
- import type { ComponentAttrs, MaybeArray, MaybeArrayOfArray, MaybeArrayOfArrayItem, SelectModelValue, SelectOptionKey } from '../types'
1
+ <script>
7
2
 
8
- export interface SelectEmits<T, V, M extends boolean> {
9
- (event: 'update:open', value: boolean): void
10
- (event: 'update:modelValue', payload: SelectModelValue<T, V, M, T extends { value: infer U } ? U : never>): void
11
- (event: 'change', payload: Event): void
12
- (event: 'blur', payload: FocusEvent): void
13
- (event: 'focus', payload: FocusEvent): void
14
- }
15
-
16
- type SlotProps<T> = (props: { item: T, index: number }) => any
17
-
18
- export interface SelectSlots<T, M extends boolean> {
19
- 'leading'?: (props: { modelValue?: M extends true ? AcceptableValue[] : AcceptableValue, open: boolean, ui: ComponentAttrs<typeof select>['ui'] }) => any
20
- 'default'?: (props: { modelValue?: M extends true ? AcceptableValue[] : AcceptableValue, open: boolean }) => any
21
- 'trailing'?: (props: { modelValue?: M extends true ? AcceptableValue[] : AcceptableValue, open: boolean, ui: ComponentAttrs<typeof select>['ui'] }) => any
22
- 'item'?: SlotProps<T>
23
- 'item-leading'?: SlotProps<T>
24
- 'item-label'?: SlotProps<T>
25
- 'item-trailing'?: SlotProps<T>
26
- }
27
-
28
- type SelectVariants = VariantProps<typeof select>
29
-
30
- export interface SelectOption {
31
- label?: string
32
- icon?: string
33
- /**
34
- * The option type.
35
- * @default "option"
36
- */
37
- type?: 'label' | 'separator' | 'option'
38
- value?: string
39
- disabled?: boolean
40
- }
41
-
42
- export type SelectOptionValue = SelectOption | AcceptableValue | boolean
43
-
44
- export interface SelectProps<
45
- T extends MaybeArrayOfArrayItem<I>,
46
- I extends MaybeArrayOfArray<SelectOptionValue> = MaybeArrayOfArray<SelectOptionValue>,
47
- V extends SelectOptionKey<T> | undefined = undefined,
48
- M extends boolean = false,
49
- > extends Omit<SelectRootProps<T>, 'dir' | 'multiple' | 'modelValue' | 'defaultValue' | 'by'>, ComponentAttrs<typeof select>, UseComponentIconsProps {
50
- id?: string
51
- /** The placeholder text when the select is empty. */
52
- placeholder?: string
53
- variant?: SelectVariants['variant']
54
- size?: SelectVariants['size']
55
- /**
56
- * The icon displayed to open the menu.
57
- * @default app.icons.chevronDown
58
- */
59
- trailingIcon?: string
60
- /**
61
- * The icon displayed when an item is selected.
62
- * @default app.icons.check
63
- */
64
- selectedIcon?: string
65
- /**
66
- * The content of the menu.
67
- * @default { side: 'bottom', sideOffset: 8, collisionPadding: 8, position: 'popper' }
68
- */
69
- content?: Omit<SelectContentProps, 'as' | 'asChild' | 'forceMount'>
70
- /**
71
- * Display an arrow alongside the menu.
72
- * @default false
73
- */
74
- arrow?: boolean | Omit<SelectArrowProps, 'as' | 'asChild'>
75
- /**
76
- * Render the menu in a portal.
77
- * @default true
78
- */
79
- portal?: boolean
80
- /**
81
- * When `options` is an array of objects, select the field to use as the value.
82
- * @default "value"
83
- */
84
- valueKey?: V
85
- /**
86
- * When `options` is an array of objects, select the field to use as the label.
87
- * @default "label"
88
- */
89
- labelKey?: V
90
- options?: I
91
- /** The value of the Select when initially rendered. Use when you do not need to control the state of the Select. */
92
- defaultValue?: SelectModelValue<T, V, M, T extends { value: infer U } ? U : never>
93
- /** The controlled value of the Select. Can be bind as `v-model`. */
94
- modelValue?: SelectModelValue<T, V, M, T extends { value: infer U } ? U : never>
95
- /** Whether multiple options can be selected or not. */
96
- multiple?: M & boolean
97
- /** Highlight the ring color like a focus state. */
98
- highlight?: boolean
99
- underline?: boolean
100
- }
101
3
  </script>
102
4
 
103
- <script lang="ts" setup generic="T extends MaybeArrayOfArrayItem<I>, I extends MaybeArrayOfArray<SelectOption | AcceptableValue | boolean> = MaybeArrayOfArray<SelectOption | AcceptableValue | boolean>, V extends SelectOptionKey<T> | undefined = undefined, M extends boolean = false">
104
- import { reactivePick } from '@vueuse/core'
105
- import { defu } from 'defu'
106
- import { SelectArrow, SelectContent, SelectGroup, SelectItem, SelectItemIndicator, SelectItemText, SelectLabel, SelectPortal, SelectRoot, SelectSeparator, SelectTrigger, SelectViewport, useForwardPropsEmits } from 'reka-ui'
107
- import { computed, toRef } from 'vue'
108
- import { useButtonGroup } from '../composables/useButtonGroup'
109
- import { useComponentIcons } from '../composables/useComponentIcons'
110
- import { useTheme } from '../composables/useTheme'
111
- import { compare, get } from '../utils'
112
-
113
- const props = withDefaults(defineProps<SelectProps<T, I, V, M>>(), {
114
- variant: 'outline',
115
- valueKey: 'value' as never,
116
- labelKey: 'label' as never,
117
- portal: true,
118
- })
119
-
120
- const emit = defineEmits<SelectEmits<T, V, M>>()
121
- const slots = defineSlots<SelectSlots<T, M>>()
122
-
123
- const rootProps = useForwardPropsEmits(reactivePick(props, 'open', 'defaultOpen', 'disabled', 'autocomplete', 'required', 'multiple'), emit)
124
- const contentProps = toRef(() => defu(props.content, { side: 'bottom', sideOffset: 8, collisionPadding: 8, position: 'popper' }) as SelectContentProps)
125
- const arrowProps = toRef(() => props.arrow as SelectArrowProps)
126
-
127
- const { theme, generateStyle } = useTheme()
128
-
129
- const { size, orientation } = useButtonGroup(props)
5
+ <script setup>
6
+ import { reactivePick } from "@vueuse/core";
7
+ import { defu } from "defu";
8
+ import { SelectArrow, SelectContent, SelectGroup, SelectItem, SelectItemIndicator, SelectItemText, SelectLabel, SelectPortal, SelectRoot, SelectSeparator, SelectTrigger, SelectViewport, useForwardPropsEmits } from "reka-ui";
9
+ import { computed, toRef } from "vue";
10
+ import { useButtonGroup } from "../composables/useButtonGroup";
11
+ import { useComponentIcons } from "../composables/useComponentIcons";
12
+ import { useFormItem } from "../composables/useFormItem";
13
+ import { useTheme } from "../composables/useTheme";
14
+ import { compare, get, isArrayOfArray } from "../utils";
15
+ defineOptions({
16
+ inheritAttrs: false
17
+ });
18
+ const props = defineProps({
19
+ id: { type: String, required: false },
20
+ placeholder: { type: String, required: false },
21
+ variant: { type: null, required: false },
22
+ size: { type: null, required: false },
23
+ trailingIcon: { type: String, required: false },
24
+ selectedIcon: { type: String, required: false },
25
+ content: { type: Object, required: false },
26
+ arrow: { type: [Boolean, Object], required: false },
27
+ portal: { type: Boolean, required: false, default: true },
28
+ valueKey: { type: null, required: false, default: "value" },
29
+ labelKey: { type: null, required: false, default: "label" },
30
+ options: { type: null, required: false },
31
+ defaultValue: { type: null, required: false },
32
+ modelValue: { type: null, required: false },
33
+ multiple: { type: Boolean, required: false },
34
+ highlight: { type: Boolean, required: false },
35
+ underline: { type: Boolean, required: false },
36
+ class: { type: null, required: false },
37
+ ui: { type: null, required: false },
38
+ icon: { type: String, required: false },
39
+ leading: { type: Boolean, required: false },
40
+ leadingIcon: { type: String, required: false },
41
+ trailing: { type: Boolean, required: false },
42
+ loading: { type: Boolean, required: false },
43
+ loadingIcon: { type: String, required: false },
44
+ open: { type: Boolean, required: false },
45
+ defaultOpen: { type: Boolean, required: false },
46
+ autocomplete: { type: String, required: false },
47
+ disabled: { type: Boolean, required: false },
48
+ name: { type: String, required: false },
49
+ required: { type: Boolean, required: false }
50
+ });
51
+ const emit = defineEmits(["update:open", "change", "blur", "focus", "update:modelValue"]);
52
+ const slots = defineSlots();
53
+ const rootProps = useForwardPropsEmits(reactivePick(props, "open", "defaultOpen", "disabled", "autocomplete", "required", "multiple"), emit);
54
+ const contentProps = toRef(() => defu(props.content, { side: "bottom", sideOffset: 8, collisionPadding: 8, position: "popper" }));
55
+ const arrowProps = toRef(() => props.arrow);
56
+ const { id, name, size: formItemSize, highlight, disabled, ariaAttrs, emitFormChange, emitFormInput, emitFormBlur, emitFormFocus } = useFormItem(props);
57
+ const { size: buttonGroupSize, orientation } = useButtonGroup(props);
58
+ const { theme, generateStyle } = useTheme();
130
59
  const { isLeading, isTrailing, leadingIconName, trailingIconName } = useComponentIcons(toRef(() => defu(props, {
131
- trailingIcon: theme.value.app.icons.chevronDown,
132
- })))
133
-
134
- const style = computed(() => generateStyle('select', {
60
+ trailingIcon: theme.value.app.icons.chevronDown
61
+ })));
62
+ const style = computed(() => generateStyle("select", {
135
63
  ...props,
136
- size: size.value,
137
64
  groupOrientation: orientation.value,
65
+ size: buttonGroupSize.value || formItemSize.value,
66
+ highlight: highlight.value,
138
67
  leading: isLeading.value,
139
- trailing: isTrailing.value,
140
- }))
141
-
142
- const groups = computed(() => props.options?.length ? (Array.isArray(props.options[0]) ? props.options : [props.options]) as SelectOption[][] : [])
143
- const items = computed(() => groups.value.flat() as T[])
144
-
145
- function typedItem(item: SelectOption) {
146
- return item as unknown as T
147
- }
148
-
149
- function typedValue<V extends MaybeArray<AcceptableValue>>(value?: V) {
150
- return value as unknown as M extends true ? AcceptableValue[] : AcceptableValue
151
- }
152
-
153
- function typedModelValue(value: any) {
154
- return value as MaybeArray<AcceptableValue> | undefined
155
- }
156
-
157
- function displayValue(value?: MaybeArray<AcceptableValue>): string | undefined {
68
+ trailing: isTrailing.value
69
+ }));
70
+ const groups = computed(
71
+ () => props.options?.length ? isArrayOfArray(props.options) ? props.options : [props.options] : []
72
+ );
73
+ const items = computed(() => groups.value.flat());
74
+ function displayValue(value) {
158
75
  if (props.multiple && Array.isArray(value))
159
- return value.map((v) => displayValue(v)).filter(Boolean).join(', ')
160
-
161
- const item = items.value.find((item) => compare(typeof item === 'object' ? get(item as Record<string, any>, props.valueKey as string) : item, value))
162
- return (item != null) && (typeof item === 'object' ? get(item, props.labelKey as string) : item.toString())
76
+ return value.map((v) => displayValue(v)).filter(Boolean).join(", ");
77
+ const item = items.value.find((item2) => compare(typeof item2 === "object" ? get(item2, props.valueKey) : item2, value));
78
+ return item != null && (typeof item === "object" ? get(item, props.labelKey) : String(item));
163
79
  }
164
-
165
- function onUpdate(value: any) {
166
- // @ts-expect-error - 'target' does not exist in type 'EventInit'
167
- const event = new Event('change', { target: { value } })
168
- emit('change', event)
80
+ function isSelectItem(item) {
81
+ return typeof item === "object" && item !== null;
169
82
  }
170
-
171
- function onUpdateOpen(value: boolean) {
83
+ function onUpdate(value) {
84
+ const event = new Event("change", { target: { value } });
85
+ emit("change", event);
86
+ emitFormChange();
87
+ emitFormInput();
88
+ }
89
+ function onUpdateOpen(value) {
172
90
  if (value) {
173
- const event = new FocusEvent('focus')
174
- emit('focus', event)
175
- }
176
- else {
177
- const event = new FocusEvent('blur')
178
- emit('blur', event)
91
+ const event = new FocusEvent("focus");
92
+ emit("focus", event);
93
+ emitFormFocus();
94
+ } else {
95
+ const event = new FocusEvent("blur");
96
+ emit("blur", event);
97
+ emitFormBlur();
179
98
  }
180
99
  }
181
100
  </script>
@@ -183,72 +102,73 @@ function onUpdateOpen(value: boolean) {
183
102
  <template>
184
103
  <SelectRoot
185
104
  v-slot="{ modelValue: innerValue, open }"
186
- :name="props.name"
187
105
  v-bind="rootProps"
106
+ :name="name"
188
107
  :autocomplete="props.autocomplete"
189
- :disabled="props.disabled"
190
- :default-value="typedModelValue(props.defaultValue)"
191
- :model-value="typedModelValue(props.modelValue)"
108
+ :disabled="disabled"
109
+ :default-value="props.defaultValue"
110
+ :model-value="props.modelValue"
192
111
  @update:model-value="onUpdate"
193
112
  @update:open="onUpdateOpen"
194
113
  >
195
- <SelectTrigger :id="props.id" :class="style.base({ class: [props.class, props.ui?.base] })">
196
- <span v-if="isLeading || slots.leading" :class="style.leading({ class: props.ui?.leading })">
197
- <slot name="leading" :model-value="typedValue(innerValue)" :open="open" :ui="props.ui">
198
- <span v-if="isLeading && leadingIconName" :class="style.leadingIcon({ class: [leadingIconName, props.ui?.leadingIcon] })"></span>
114
+ <SelectTrigger v-bind="{ ...$attrs, ...ariaAttrs, id }" :class="style.base({ class: [props.class, props.ui?.base] })" data-part="base">
115
+ <span v-if="isLeading || slots.leading" :class="style.leading({ class: props.ui?.leading })" data-part="leading">
116
+ <slot name="leading" :model-value="innerValue" :open="open" :ui="props.ui">
117
+ <span v-if="isLeading && leadingIconName" :class="style.leadingIcon({ class: [leadingIconName, props.ui?.leadingIcon] })" data-part="leading-icon"></span>
199
118
  </slot>
200
119
  </span>
201
120
 
202
- <slot :model-value="typedValue(innerValue)" :open="open">
121
+ <slot :model-value="innerValue" :open="open">
203
122
  <template v-for="displayedModelValue in [displayValue(innerValue)]" :key="displayedModelValue">
204
- <span v-if="displayedModelValue" :class="style.value({ class: props.ui?.value })">
123
+ <span v-if="displayedModelValue" :class="style.value({ class: props.ui?.value })" data-part="value">
205
124
  {{ displayedModelValue }}
206
125
  </span>
207
- <span v-else :class="style.placeholder({ class: props.ui?.placeholder })">
126
+ <span v-else :class="style.placeholder({ class: props.ui?.placeholder })" data-part="placeholder">
208
127
  {{ placeholder }}&nbsp;
209
128
  </span>
210
129
  </template>
211
130
  </slot>
212
131
 
213
- <span v-if="isTrailing || !!slots.trailing" :class="style.trailing({ class: props.ui?.trailing })">
214
- <slot name="trailing" :model-value="typedValue(innerValue)" :open="open" :ui="props.ui">
215
- <span v-if="trailingIconName" :class="style.trailingIcon({ class: [trailingIconName, props.ui?.trailingIcon] })"></span>
132
+ <span v-if="isTrailing || !!slots.trailing" :class="style.trailing({ class: props.ui?.trailing })" data-part="trailing">
133
+ <slot name="trailing" :model-value="innerValue" :open="open" :ui="props.ui">
134
+ <span v-if="trailingIconName" :class="style.trailingIcon({ class: [trailingIconName, props.ui?.trailingIcon] })" data-part="trailing-icon"></span>
216
135
  </slot>
217
136
  </span>
218
137
  </SelectTrigger>
219
138
 
220
139
  <SelectPortal :disabled="!props.portal">
221
- <SelectContent v-bind="contentProps" :class="style.content({ class: props.ui?.content })">
222
- <SelectViewport :class="style.viewport({ class: props.ui?.viewport })">
223
- <SelectGroup v-for="(group, groupIndex) in groups" :key="`group-${groupIndex}`" :class="style.group({ class: props.ui?.group })">
140
+ <SelectContent v-bind="contentProps" :class="style.content({ class: props.ui?.content })" data-part="content">
141
+ <SelectViewport :class="style.viewport({ class: props.ui?.viewport })" data-part="viewport">
142
+ <SelectGroup v-for="(group, groupIndex) in groups" :key="`group-${groupIndex}`" :class="style.group({ class: props.ui?.group })" data-part="group">
224
143
  <template v-for="(item, index) in group" :key="`group-${groupIndex}-${index}`">
225
- <SelectLabel v-if="item.type === 'label'" :class="style.label({ class: props.ui?.label })">
226
- {{ get(item, props.labelKey as string) }}
144
+ <SelectLabel v-if="isSelectItem(item) && item.type === 'label'" :class="style.label({ class: props.ui?.label })" data-part="label">
145
+ {{ get(item, props.labelKey) }}
227
146
  </SelectLabel>
228
- <SelectSeparator v-else-if="item.type === 'separator'" :class="style.separator({ class: props.ui?.separator })" />
147
+ <SelectSeparator v-else-if="isSelectItem(item) && item.type === 'separator'" :class="style.separator({ class: props.ui?.separator })" data-part="separator" />
229
148
 
230
149
  <SelectItem
231
150
  v-else
151
+ :value="isSelectItem(item) ? get(item, props.valueKey) : item"
152
+ :disabled="isSelectItem(item) && item.disabled"
232
153
  :class="style.item({ class: props.ui?.item })"
233
- :disabled="item.disabled"
234
- :value="typeof item === 'object' ? get(item, props.valueKey as string) : item"
154
+ data-part="item"
235
155
  >
236
- <slot name="item" :item="typedItem(item)" :index="index">
237
- <slot name="item-leading" :item="typedItem(item)" :index="index">
238
- <span v-if="item.icon" :class="style.itemLeadingIcon({ class: [item.icon, props.ui?.itemLeadingIcon] })"></span>
156
+ <slot name="item" :item="item" :index="index">
157
+ <slot name="item-leading" :item="item" :index="index">
158
+ <span v-if="isSelectItem(item) && item.icon" :class="style.itemLeadingIcon({ class: [item.icon, props.ui?.itemLeadingIcon] })" data-part="item-leading-icon"></span>
239
159
  </slot>
240
160
 
241
- <SelectItemText :class="style.itemLabel({ class: props.ui?.itemLabel })">
242
- <slot name="item-label" :item="typedItem(item)" :index="index">
243
- {{ typeof item === 'object' ? get(item, props.labelKey as string) : item }}
161
+ <SelectItemText :class="style.itemLabel({ class: props.ui?.itemLabel })" data-part="item-label">
162
+ <slot name="item-label" :item="item" :index="index">
163
+ {{ isSelectItem(item) ? get(item, props.labelKey) : item }}
244
164
  </slot>
245
165
  </SelectItemText>
246
166
 
247
- <span :class="style.itemTrailing({ class: props.ui?.itemTrailing })">
248
- <slot name="item-trailing" :item="typedItem(item)" :index="index"></slot>
167
+ <span :class="style.itemTrailing({ class: props.ui?.itemTrailing })" data-part="item-trailing">
168
+ <slot name="item-trailing" :item="item" :index="index"></slot>
249
169
 
250
170
  <SelectItemIndicator as-child>
251
- <span :class="style.itemTrailingIcon({ class: [props.selectedIcon || theme.app.icons.check, props.ui?.itemTrailingIcon] })"></span>
171
+ <span :class="style.itemTrailingIcon({ class: [props.selectedIcon || theme.app.icons.check, props.ui?.itemTrailingIcon] })" data-part="item-trailing-icon"></span>
252
172
  </SelectItemIndicator>
253
173
  </span>
254
174
  </slot>
@@ -257,7 +177,7 @@ function onUpdateOpen(value: boolean) {
257
177
  </SelectGroup>
258
178
  </SelectViewport>
259
179
 
260
- <SelectArrow v-if="!!props.arrow" v-bind="arrowProps" :class="style.arrow({ class: props.ui?.arrow })" />
180
+ <SelectArrow v-if="!!props.arrow" v-bind="arrowProps" :class="style.arrow({ class: props.ui?.arrow })" data-part="arrow" />
261
181
  </SelectContent>
262
182
  </SelectPortal>
263
183
  </SelectRoot>
@@ -0,0 +1,119 @@
1
+ import type { VariantProps } from '@byyuurin/ui-kit';
2
+ import type { SelectArrowProps, SelectContentEmits, SelectContentProps, SelectRootEmits, SelectRootProps } from 'reka-ui';
3
+ import type { UseComponentIconsProps } from '../composables/useComponentIcons.js';
4
+ import type { select } from '../theme/index.js';
5
+ import type { AcceptableValue, ArrayOrNested, ComponentAttrs, EmitsToProps, GetItemKeys, GetModelValue, GetModelValueEmits, NestedItem } from '../types/index.js';
6
+ interface SelectItemBase {
7
+ label?: string;
8
+ icon?: string;
9
+ /**
10
+ * The option type.
11
+ * @default "option"
12
+ */
13
+ type?: 'label' | 'separator' | 'option';
14
+ value?: AcceptableValue;
15
+ disabled?: boolean;
16
+ [key: string]: any;
17
+ }
18
+ export type SelectItem = SelectItemBase | string | number | boolean;
19
+ export type SelectEmits<T extends ArrayOrNested<SelectItem>, VK extends GetItemKeys<T> | undefined, M extends boolean> = Omit<SelectRootEmits, 'update:modelValue'> & {
20
+ change: [payload: Event];
21
+ blur: [payload: FocusEvent];
22
+ focus: [payload: FocusEvent];
23
+ } & GetModelValueEmits<T, VK, M>;
24
+ type SlotProps<T extends SelectItem> = (props: {
25
+ item: T;
26
+ index: number;
27
+ }) => any;
28
+ export interface SelectSlots<T extends ArrayOrNested<SelectItem> = ArrayOrNested<SelectItem>, VK extends GetItemKeys<T> | undefined = undefined, M extends boolean = false, I extends NestedItem<T> = NestedItem<T>> {
29
+ 'leading'?: (props: {
30
+ modelValue?: GetModelValue<T, VK, M>;
31
+ open: boolean;
32
+ ui: ComponentAttrs<typeof select>['ui'];
33
+ }) => any;
34
+ 'default'?: (props: {
35
+ modelValue?: GetModelValue<T, VK, M>;
36
+ open: boolean;
37
+ }) => any;
38
+ 'trailing'?: (props: {
39
+ modelValue?: GetModelValue<T, VK, M>;
40
+ open: boolean;
41
+ ui: ComponentAttrs<typeof select>['ui'];
42
+ }) => any;
43
+ 'item'?: SlotProps<I>;
44
+ 'item-leading'?: SlotProps<I>;
45
+ 'item-label'?: SlotProps<I>;
46
+ 'item-trailing'?: SlotProps<I>;
47
+ }
48
+ type SelectVariants = VariantProps<typeof select>;
49
+ export interface SelectProps<T extends ArrayOrNested<SelectItem> = ArrayOrNested<SelectItem>, VK extends GetItemKeys<T> = 'value', M extends boolean = false> extends ComponentAttrs<typeof select>, UseComponentIconsProps, Omit<SelectRootProps<T>, 'dir' | 'multiple' | 'modelValue' | 'defaultValue' | 'by'> {
50
+ id?: string;
51
+ /** The placeholder text when the select is empty. */
52
+ placeholder?: string;
53
+ variant?: SelectVariants['variant'];
54
+ size?: SelectVariants['size'];
55
+ /**
56
+ * The icon displayed to open the menu.
57
+ * @default app.icons.chevronDown
58
+ */
59
+ trailingIcon?: string;
60
+ /**
61
+ * The icon displayed when an item is selected.
62
+ * @default app.icons.check
63
+ */
64
+ selectedIcon?: string;
65
+ /**
66
+ * The content of the menu.
67
+ * @default { side: 'bottom', sideOffset: 8, collisionPadding: 8, position: 'popper' }
68
+ */
69
+ content?: Omit<SelectContentProps, 'as' | 'asChild' | 'forceMount'> & Partial<EmitsToProps<SelectContentEmits>>;
70
+ /**
71
+ * Display an arrow alongside the menu.
72
+ * @default false
73
+ */
74
+ arrow?: boolean | Omit<SelectArrowProps, 'as' | 'asChild'>;
75
+ /**
76
+ * Render the menu in a portal.
77
+ * @default true
78
+ */
79
+ portal?: boolean;
80
+ /**
81
+ * When `options` is an array of objects, select the field to use as the value.
82
+ * @default "value"
83
+ */
84
+ valueKey?: VK;
85
+ /**
86
+ * When `options` is an array of objects, select the field to use as the label.
87
+ * @default "label"
88
+ */
89
+ labelKey?: VK;
90
+ options?: T;
91
+ /** The value of the Select when initially rendered. Use when you do not need to control the state of the Select. */
92
+ defaultValue?: GetModelValue<T, VK, M> | null;
93
+ /** The controlled value of the Select. Can be bind as `v-model`. */
94
+ modelValue?: GetModelValue<T, VK, M> | null;
95
+ /** Whether multiple options can be selected or not. */
96
+ multiple?: M & boolean;
97
+ /** Highlight the ring color like a focus state. */
98
+ highlight?: boolean;
99
+ underline?: boolean;
100
+ }
101
+ declare const _default: <T extends ArrayOrNested<SelectItem>, VK extends GetItemKeys<T> = "value", M extends boolean = false>(__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<{
102
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
103
+ readonly onBlur?: ((payload: FocusEvent) => any) | undefined;
104
+ readonly onChange?: ((payload: Event) => any) | undefined;
105
+ readonly onFocus?: ((payload: FocusEvent) => any) | undefined;
106
+ readonly "onUpdate:open"?: ((value: boolean) => any) | undefined;
107
+ readonly "onUpdate:modelValue"?: ((payload: GetModelValue<T, VK, M>) => any) | undefined;
108
+ } & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, "onFocus" | "onBlur" | "onChange" | "onUpdate:open" | "onUpdate:modelValue"> & SelectProps<T, VK, M> & Partial<{}>> & import("vue").PublicProps;
109
+ expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
110
+ attrs: any;
111
+ slots: SelectSlots<T, VK, M, NestedItem<T>>;
112
+ emit: ((evt: "blur", payload: FocusEvent) => void) & ((evt: "change", payload: Event) => void) & ((evt: "focus", payload: FocusEvent) => void) & ((evt: "update:open", value: boolean) => void) & ((evt: "update:modelValue", payload: GetModelValue<T, VK, M>) => void);
113
+ }>) => import("vue").VNode & {
114
+ __ctx?: Awaited<typeof __VLS_setup>;
115
+ };
116
+ export default _default;
117
+ type __VLS_PrettifyLocal<T> = {
118
+ [K in keyof T]: T[K];
119
+ } & {};