@byyuurin/ui 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/README.md +2 -2
  2. package/dist/module.json +3 -3
  3. package/dist/module.mjs +1 -1
  4. package/dist/module.mjs.map +1 -1
  5. package/dist/runtime/app/injections.d.ts +388 -364
  6. package/dist/runtime/components/Accordion.vue +38 -67
  7. package/dist/runtime/components/Accordion.vue.d.ts +52 -0
  8. package/dist/runtime/components/Alert.vue +37 -75
  9. package/dist/runtime/components/Alert.vue.d.ts +59 -0
  10. package/dist/runtime/components/App.vue +25 -40
  11. package/dist/runtime/components/App.vue.d.ts +24 -0
  12. package/dist/runtime/components/Avatar.vue +31 -51
  13. package/dist/runtime/components/Avatar.vue.d.ts +25 -0
  14. package/dist/runtime/components/AvatarGroup.vue +38 -69
  15. package/dist/runtime/components/AvatarGroup.vue.d.ts +27 -0
  16. package/dist/runtime/components/Badge.vue +25 -51
  17. package/dist/runtime/components/Badge.vue.d.ts +44 -0
  18. package/dist/runtime/components/Breadcrumb.vue +36 -74
  19. package/dist/runtime/components/Breadcrumb.vue.d.ts +52 -0
  20. package/dist/runtime/components/Button.vue +62 -51
  21. package/dist/runtime/components/Button.vue.d.ts +29 -0
  22. package/dist/runtime/components/ButtonGroup.vue +17 -37
  23. package/dist/runtime/components/ButtonGroup.vue.d.ts +26 -0
  24. package/dist/runtime/components/Calendar.vue +75 -110
  25. package/dist/runtime/components/Calendar.vue.d.ts +75 -0
  26. package/dist/runtime/components/Card.vue +25 -42
  27. package/dist/runtime/components/Card.vue.d.ts +30 -0
  28. package/dist/runtime/components/Carousel.vue +118 -225
  29. package/dist/runtime/components/Carousel.vue.d.ts +104 -0
  30. package/dist/runtime/components/Checkbox.vue +46 -73
  31. package/dist/runtime/components/Checkbox.vue.d.ts +56 -0
  32. package/dist/runtime/components/Chip.vue +31 -48
  33. package/dist/runtime/components/Chip.vue.d.ts +30 -0
  34. package/dist/runtime/components/Collapsible.vue +22 -30
  35. package/dist/runtime/components/Collapsible.vue.d.ts +26 -0
  36. package/dist/runtime/components/Drawer.vue +51 -101
  37. package/dist/runtime/components/Drawer.vue.d.ts +80 -0
  38. package/dist/runtime/components/DropdownMenu.vue +37 -115
  39. package/dist/runtime/components/DropdownMenu.vue.d.ts +99 -0
  40. package/dist/runtime/components/DropdownMenuContent.vue +81 -77
  41. package/dist/runtime/components/DropdownMenuContent.vue.d.ts +39 -0
  42. package/dist/runtime/components/Form.vue +140 -254
  43. package/dist/runtime/components/Form.vue.d.ts +78 -0
  44. package/dist/runtime/components/FormItem.vue +50 -89
  45. package/dist/runtime/components/FormItem.vue.d.ts +60 -0
  46. package/dist/runtime/components/Input.vue +79 -115
  47. package/dist/runtime/components/Input.vue.d.ts +64 -0
  48. package/dist/runtime/components/InputNumber.vue +74 -117
  49. package/dist/runtime/components/InputNumber.vue.d.ts +245 -0
  50. package/dist/runtime/components/Kbd.vue +18 -39
  51. package/dist/runtime/components/Kbd.vue.d.ts +28 -0
  52. package/dist/runtime/components/Link.vue +168 -257
  53. package/dist/runtime/components/Link.vue.d.ts +95 -0
  54. package/dist/runtime/components/LinkBase.vue +36 -54
  55. package/dist/runtime/components/LinkBase.vue.d.ts +28 -0
  56. package/dist/runtime/components/Modal.vue +49 -84
  57. package/dist/runtime/components/Modal.vue.d.ts +66 -0
  58. package/dist/runtime/components/OverlayProvider.vue +10 -14
  59. package/dist/runtime/components/OverlayProvider.vue.d.ts +2 -0
  60. package/dist/runtime/components/Pagination.vue +55 -121
  61. package/dist/runtime/components/Pagination.vue.d.ts +93 -0
  62. package/dist/runtime/components/PinInput.vue +49 -58
  63. package/dist/runtime/components/PinInput.vue.d.ts +35 -0
  64. package/dist/runtime/components/Popover.vue +39 -68
  65. package/dist/runtime/components/Popover.vue.d.ts +45 -0
  66. package/dist/runtime/components/Progress.vue +68 -120
  67. package/dist/runtime/components/Progress.vue.d.ts +54 -0
  68. package/dist/runtime/components/RadioGroup.vue +67 -125
  69. package/dist/runtime/components/RadioGroup.vue.d.ts +74 -0
  70. package/dist/runtime/components/ScrollArea.vue +31 -31
  71. package/dist/runtime/components/ScrollArea.vue.d.ts +17 -0
  72. package/dist/runtime/components/Select.vue +114 -204
  73. package/dist/runtime/components/Select.vue.d.ts +119 -0
  74. package/dist/runtime/components/Separator.vue +26 -44
  75. package/dist/runtime/components/Separator.vue.d.ts +27 -0
  76. package/dist/runtime/components/Skeleton.vue +12 -21
  77. package/dist/runtime/components/Skeleton.vue.d.ts +19 -0
  78. package/dist/runtime/components/Slider.vue +52 -74
  79. package/dist/runtime/components/Slider.vue.d.ts +36 -0
  80. package/dist/runtime/components/Switch.vue +51 -71
  81. package/dist/runtime/components/Switch.vue.d.ts +49 -0
  82. package/dist/runtime/components/Table.vue +108 -194
  83. package/dist/runtime/components/Table.vue.d.ts +148 -0
  84. package/dist/runtime/components/Tabs.vue +36 -81
  85. package/dist/runtime/components/Tabs.vue.d.ts +65 -0
  86. package/dist/runtime/components/Textarea.vue +77 -124
  87. package/dist/runtime/components/Textarea.vue.d.ts +60 -0
  88. package/dist/runtime/components/Toast.vue +47 -75
  89. package/dist/runtime/components/Toast.vue.d.ts +131 -0
  90. package/dist/runtime/components/ToastProvider.vue +65 -101
  91. package/dist/runtime/components/ToastProvider.vue.d.ts +38 -0
  92. package/dist/runtime/components/Tooltip.vue +36 -47
  93. package/dist/runtime/components/Tooltip.vue.d.ts +31 -0
  94. package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
  95. package/dist/runtime/composables/useButtonGroup.d.ts +2 -2
  96. package/dist/runtime/composables/useFormItem.d.ts +2 -2
  97. package/dist/runtime/composables/useKbd.d.ts +1 -1
  98. package/dist/runtime/composables/useLocale.d.ts +3 -3
  99. package/dist/runtime/composables/useTheme.d.ts +1 -1
  100. package/dist/runtime/composables/useToast.d.ts +1 -1
  101. package/dist/runtime/locale/en.d.ts +1 -1
  102. package/dist/runtime/locale/zh-tw.d.ts +1 -1
  103. package/dist/runtime/theme/accordion.d.ts +45 -51
  104. package/dist/runtime/theme/accordion.js +1 -1
  105. package/dist/runtime/theme/alert.d.ts +115 -121
  106. package/dist/runtime/theme/alert.js +1 -1
  107. package/dist/runtime/theme/avatar-group.d.ts +42 -48
  108. package/dist/runtime/theme/avatar-group.js +1 -1
  109. package/dist/runtime/theme/avatar.d.ts +46 -52
  110. package/dist/runtime/theme/avatar.js +1 -1
  111. package/dist/runtime/theme/badge.d.ts +60 -66
  112. package/dist/runtime/theme/badge.js +1 -1
  113. package/dist/runtime/theme/breadcrumb.d.ts +52 -58
  114. package/dist/runtime/theme/breadcrumb.js +1 -1
  115. package/dist/runtime/theme/button-group.d.ts +36 -42
  116. package/dist/runtime/theme/button.d.ts +162 -168
  117. package/dist/runtime/theme/button.js +1 -1
  118. package/dist/runtime/theme/calendar.d.ts +52 -50
  119. package/dist/runtime/theme/calendar.js +20 -3
  120. package/dist/runtime/theme/card.d.ts +52 -58
  121. package/dist/runtime/theme/card.js +1 -1
  122. package/dist/runtime/theme/carousel.d.ts +98 -104
  123. package/dist/runtime/theme/carousel.js +1 -1
  124. package/dist/runtime/theme/checkbox.d.ts +77 -83
  125. package/dist/runtime/theme/checkbox.js +1 -1
  126. package/dist/runtime/theme/chip.d.ts +50 -56
  127. package/dist/runtime/theme/chip.js +1 -1
  128. package/dist/runtime/theme/collapsible.d.ts +29 -35
  129. package/dist/runtime/theme/collapsible.js +1 -1
  130. package/dist/runtime/theme/drawer.d.ts +120 -126
  131. package/dist/runtime/theme/drawer.js +1 -1
  132. package/dist/runtime/theme/dropdown-menu.d.ts +55 -61
  133. package/dist/runtime/theme/dropdown-menu.js +1 -1
  134. package/dist/runtime/theme/form-item.d.ts +63 -69
  135. package/dist/runtime/theme/form-item.js +1 -1
  136. package/dist/runtime/theme/form.d.ts +1 -7
  137. package/dist/runtime/theme/input-number.d.ts +98 -104
  138. package/dist/runtime/theme/input-number.js +1 -1
  139. package/dist/runtime/theme/input.d.ts +153 -159
  140. package/dist/runtime/theme/input.js +1 -1
  141. package/dist/runtime/theme/kbd.d.ts +30 -36
  142. package/dist/runtime/theme/link.d.ts +37 -43
  143. package/dist/runtime/theme/modal.d.ts +36 -42
  144. package/dist/runtime/theme/modal.js +1 -1
  145. package/dist/runtime/theme/pagination.d.ts +71 -77
  146. package/dist/runtime/theme/pagination.js +1 -1
  147. package/dist/runtime/theme/pinInput.d.ts +80 -86
  148. package/dist/runtime/theme/pinInput.js +1 -1
  149. package/dist/runtime/theme/popover.d.ts +29 -35
  150. package/dist/runtime/theme/popover.js +1 -1
  151. package/dist/runtime/theme/progress.d.ts +163 -169
  152. package/dist/runtime/theme/progress.js +1 -1
  153. package/dist/runtime/theme/radio-group.d.ts +99 -105
  154. package/dist/runtime/theme/radio-group.js +1 -1
  155. package/dist/runtime/theme/scroll-area.d.ts +62 -68
  156. package/dist/runtime/theme/scroll-area.js +1 -1
  157. package/dist/runtime/theme/select.d.ts +165 -171
  158. package/dist/runtime/theme/select.js +1 -1
  159. package/dist/runtime/theme/separator.d.ts +62 -68
  160. package/dist/runtime/theme/separator.js +1 -1
  161. package/dist/runtime/theme/skeleton.d.ts +1 -7
  162. package/dist/runtime/theme/slider.d.ts +62 -68
  163. package/dist/runtime/theme/slider.js +1 -1
  164. package/dist/runtime/theme/switch.d.ts +111 -117
  165. package/dist/runtime/theme/switch.js +1 -1
  166. package/dist/runtime/theme/table.d.ts +75 -81
  167. package/dist/runtime/theme/table.js +1 -1
  168. package/dist/runtime/theme/tabs.d.ts +114 -120
  169. package/dist/runtime/theme/tabs.js +1 -1
  170. package/dist/runtime/theme/textarea.d.ts +76 -82
  171. package/dist/runtime/theme/textarea.js +1 -1
  172. package/dist/runtime/theme/toast-provider.d.ts +106 -112
  173. package/dist/runtime/theme/toast-provider.js +1 -1
  174. package/dist/runtime/theme/toast.d.ts +74 -80
  175. package/dist/runtime/theme/toast.js +1 -1
  176. package/dist/runtime/theme/tooltip.d.ts +35 -41
  177. package/dist/runtime/theme/tooltip.js +1 -1
  178. package/dist/runtime/types/utils.d.ts +5 -5
  179. package/dist/runtime/utils/link.d.ts +3 -5
  180. package/dist/runtime/utils/styler.d.ts +2 -2
  181. package/dist/runtime/utils/styler.js +2 -2
  182. package/dist/shared/ui.D1BTWZFB.mjs +5 -0
  183. package/dist/shared/ui.D1BTWZFB.mjs.map +1 -0
  184. package/dist/types.d.mts +1 -1
  185. package/dist/unocss.mjs +5 -4
  186. package/dist/unocss.mjs.map +1 -1
  187. package/dist/unplugin.mjs +1 -1
  188. package/dist/unplugin.mjs.map +1 -1
  189. package/dist/vite.mjs +1 -1
  190. package/package.json +77 -75
  191. package/dist/module.cjs +0 -5
  192. package/dist/shared/ui.3e7fad19.mjs +0 -5
  193. package/dist/shared/ui.3e7fad19.mjs.map +0 -1
  194. package/dist/types.d.ts +0 -1
@@ -1,87 +1,40 @@
1
- <script lang="ts">
2
- import type { VariantProps } from '@byyuurin/ui-kit'
3
- import type { TabsRootEmits, TabsRootProps } from 'reka-ui'
4
- import type { tabs } from '../theme'
5
- import type { ComponentAttrs, DynamicSlots } from '../types'
1
+ <script>
6
2
 
7
- export interface TabsEmits extends TabsRootEmits<string | number> {}
8
-
9
- export interface TabsItem {
10
- label?: string
11
- icon?: string
12
- slot?: string
13
- content?: string
14
- /** A unique value for the tab item. Defaults to the index. */
15
- value?: string | number
16
- disabled?: boolean
17
- [key: string]: any
18
- }
19
-
20
- type SlotProps<T extends TabsItem> = (props: { item: T, index: number }) => any
21
-
22
- export type TabsSlots<T extends TabsItem = TabsItem> = {
23
- leading?: SlotProps<T>
24
- default?: SlotProps<T>
25
- trailing?: SlotProps<T>
26
- content?: SlotProps<T>
27
- } & DynamicSlots<T, undefined, SlotProps<T>>
28
-
29
- type TabsVariants = VariantProps<typeof tabs>
30
-
31
- export interface TabsProps<T extends TabsItem = TabsItem> extends ComponentAttrs<typeof tabs>, Pick<TabsRootProps<string | number>, 'defaultValue' | 'modelValue' | 'activationMode' | 'unmountOnHide'> {
32
- /**
33
- * The element or component this component should render as.
34
- * @default "div"
35
- */
36
- as?: TabsRootProps<string | number>['as']
37
- items?: T[]
38
- variant?: TabsVariants['variant']
39
- orientation?: TabsVariants['orientation']
40
- size?: TabsVariants['size']
41
- /** @default true */
42
- evenly?: boolean
43
- /**
44
- * The content of the tabs, can be disabled to prevent rendering the content.
45
- * @default true
46
- */
47
- content?: boolean
48
- /**
49
- * The key used to get the label from the item.
50
- * @default "label"
51
- */
52
- labelKey?: string
53
- }
54
3
  </script>
55
4
 
56
- <script lang="ts" setup generic="T extends TabsItem">
57
- import { reactivePick } from '@vueuse/core'
58
- import { TabsContent, TabsIndicator, TabsList, TabsRoot, TabsTrigger, useForwardPropsEmits } from 'reka-ui'
59
- import { computed } from 'vue'
60
- import { useTheme } from '../composables/useTheme'
61
- import { get } from '../utils'
62
-
63
- const props = withDefaults(defineProps<TabsProps<T>>(), {
64
- defaultValue: '0',
65
- variant: 'solid',
66
- orientation: 'horizontal',
67
- evenly: true,
68
- content: true,
69
- labelKey: 'label',
70
- })
71
-
72
- const emit = defineEmits<TabsEmits>()
73
- const slots = defineSlots<TabsSlots<T>>()
74
-
75
- const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'modelValue', 'defaultValue', 'orientation', 'activationMode', 'unmountOnHide'), emit)
76
-
77
- const { generateStyle } = useTheme()
78
- const style = computed(() => generateStyle('tabs', props))
5
+ <script setup>
6
+ import { reactivePick } from "@vueuse/core";
7
+ import { TabsContent, TabsIndicator, TabsList, TabsRoot, TabsTrigger, useForwardPropsEmits } from "reka-ui";
8
+ import { computed } from "vue";
9
+ import { useTheme } from "../composables/useTheme";
10
+ import { get } from "../utils";
11
+ const props = defineProps({
12
+ as: { type: null, required: false },
13
+ items: { type: Array, required: false },
14
+ variant: { type: null, required: false, default: "solid" },
15
+ orientation: { type: null, required: false, default: "horizontal" },
16
+ size: { type: null, required: false },
17
+ evenly: { type: Boolean, required: false, default: true },
18
+ content: { type: Boolean, required: false, default: true },
19
+ labelKey: { type: String, required: false, default: "label" },
20
+ class: { type: null, required: false },
21
+ ui: { type: null, required: false },
22
+ defaultValue: { type: [String, Number], required: false, default: "0" },
23
+ modelValue: { type: [String, Number], required: false },
24
+ activationMode: { type: String, required: false },
25
+ unmountOnHide: { type: Boolean, required: false }
26
+ });
27
+ const emit = defineEmits(["update:modelValue"]);
28
+ const slots = defineSlots();
29
+ const rootProps = useForwardPropsEmits(reactivePick(props, "as", "modelValue", "defaultValue", "orientation", "activationMode", "unmountOnHide"), emit);
30
+ const { generateStyle } = useTheme();
31
+ const style = computed(() => generateStyle("tabs", props));
79
32
  </script>
80
33
 
81
34
  <template>
82
- <TabsRoot v-bind="rootProps" :class="style.root({ class: [props.class, props.ui?.root] })">
83
- <TabsList :class="style.list({ class: props.ui?.list })">
84
- <TabsIndicator :class="style.indicator({ class: props.ui?.indicator })" />
35
+ <TabsRoot v-bind="rootProps" :class="style.root({ class: [props.class, props.ui?.root] })" data-part="root">
36
+ <TabsList :class="style.list({ class: props.ui?.list })" data-part="list">
37
+ <TabsIndicator :class="style.indicator({ class: props.ui?.indicator })" data-part="indicator" />
85
38
 
86
39
  <TabsTrigger
87
40
  v-for="(item, index) of items"
@@ -89,12 +42,13 @@ const style = computed(() => generateStyle('tabs', props))
89
42
  :value="item.value || String(index)"
90
43
  :disabled="item.disabled"
91
44
  :class="style.trigger({ class: props.ui?.trigger })"
45
+ data-part="trigger"
92
46
  >
93
47
  <slot name="leading" :item="item" :index="index">
94
- <span v-if="item.icon" :class="style.leadingIcon({ class: [item.icon, props.ui?.leadingIcon] })"></span>
48
+ <span v-if="item.icon" :class="style.leadingIcon({ class: [item.icon, props.ui?.leadingIcon] })" data-part="leading-icon"></span>
95
49
  </slot>
96
50
 
97
- <span v-if="get(item, props.labelKey) || slots.default" :class="style.label({ class: props.ui?.label })">
51
+ <span v-if="get(item, props.labelKey) || slots.default" :class="style.label({ class: props.ui?.label })" data-part="label">
98
52
  <slot :item="item" :index="index">{{ get(item, props.labelKey) }}</slot>
99
53
  </span>
100
54
 
@@ -108,8 +62,9 @@ const style = computed(() => generateStyle('tabs', props))
108
62
  :key="index"
109
63
  :value="item.value || String(index)"
110
64
  :class="style.content({ class: props.ui?.content })"
65
+ data-part="content"
111
66
  >
112
- <slot :name="((item.slot || 'content') as keyof TabsSlots<T>)" :item="(item as Extract<T, { slot: string }>)" :index="index">
67
+ <slot :name="item.slot || 'content'" :item="item" :index="index">
113
68
  {{ item.content }}
114
69
  </slot>
115
70
  </TabsContent>
@@ -0,0 +1,65 @@
1
+ import type { VariantProps } from '@byyuurin/ui-kit';
2
+ import type { TabsRootEmits, TabsRootProps } from 'reka-ui';
3
+ import type { tabs } from '../theme/index.js';
4
+ import type { ComponentAttrs, DynamicSlots } from '../types/index.js';
5
+ export interface TabsEmits extends TabsRootEmits<string | number> {
6
+ }
7
+ export interface TabsItem {
8
+ label?: string;
9
+ icon?: string;
10
+ slot?: string;
11
+ content?: string;
12
+ /** A unique value for the tab item. Defaults to the index. */
13
+ value?: string | number;
14
+ disabled?: boolean;
15
+ [key: string]: any;
16
+ }
17
+ type SlotProps<T extends TabsItem> = (props: {
18
+ item: T;
19
+ index: number;
20
+ }) => any;
21
+ export type TabsSlots<T extends TabsItem = TabsItem> = {
22
+ leading?: SlotProps<T>;
23
+ default?: SlotProps<T>;
24
+ trailing?: SlotProps<T>;
25
+ content?: SlotProps<T>;
26
+ } & DynamicSlots<T, undefined, SlotProps<T>>;
27
+ type TabsVariants = VariantProps<typeof tabs>;
28
+ export interface TabsProps<T extends TabsItem = TabsItem> extends ComponentAttrs<typeof tabs>, Pick<TabsRootProps<string | number>, 'defaultValue' | 'modelValue' | 'activationMode' | 'unmountOnHide'> {
29
+ /**
30
+ * The element or component this component should render as.
31
+ * @default "div"
32
+ */
33
+ as?: TabsRootProps<string | number>['as'];
34
+ items?: T[];
35
+ variant?: TabsVariants['variant'];
36
+ orientation?: TabsVariants['orientation'];
37
+ size?: TabsVariants['size'];
38
+ /** @default true */
39
+ evenly?: boolean;
40
+ /**
41
+ * The content of the tabs, can be disabled to prevent rendering the content.
42
+ * @default true
43
+ */
44
+ content?: boolean;
45
+ /**
46
+ * The key used to get the label from the item.
47
+ * @default "label"
48
+ */
49
+ labelKey?: string;
50
+ }
51
+ declare const _default: <T extends TabsItem>(__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<{
52
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
53
+ readonly "onUpdate:modelValue"?: ((payload: string | number) => any) | undefined;
54
+ } & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, "onUpdate:modelValue"> & TabsProps<T> & Partial<{}>> & import("vue").PublicProps;
55
+ expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
56
+ attrs: any;
57
+ slots: TabsSlots<T>;
58
+ emit: (evt: "update:modelValue", payload: string | number) => void;
59
+ }>) => import("vue").VNode & {
60
+ __ctx?: Awaited<typeof __VLS_setup>;
61
+ };
62
+ export default _default;
63
+ type __VLS_PrettifyLocal<T> = {
64
+ [K in keyof T]: T[K];
65
+ } & {};
@@ -1,163 +1,116 @@
1
- <script lang="ts">
2
- import type { VariantProps } from '@byyuurin/ui-kit'
3
- import type { PrimitiveProps } from 'reka-ui'
4
- import type { textarea } from '../theme'
5
- import type { ComponentAttrs } from '../types'
1
+ <script>
6
2
 
7
- export interface TextareaEmits {
8
- 'update:modelValue': [payload: string]
9
- 'blur': [event: FocusEvent]
10
- 'change': [event: Event]
11
- }
12
-
13
- export interface TextareaSlots {
14
- default?: (props?: {}) => any
15
- }
16
-
17
- type TextareaVariants = VariantProps<typeof textarea>
18
-
19
- export interface TextareaProps extends ComponentAttrs<typeof textarea> {
20
- /**
21
- * The element or component this component should render as.
22
- * @default "div"
23
- */
24
- as?: PrimitiveProps['as']
25
- id?: string
26
- name?: string
27
- placeholder?: string
28
- size?: TextareaVariants['size']
29
- variant?: TextareaVariants['variant']
30
- highlight?: boolean
31
- underline?: boolean
32
- required?: boolean
33
- autofocus?: boolean
34
- autofocusDelay?: number
35
- disabled?: boolean
36
- rows?: number
37
- maxRows?: number
38
- autoResize?: boolean
39
- }
40
3
  </script>
41
4
 
42
- <script setup lang="ts">
43
- import { Primitive } from 'reka-ui'
44
- import { computed, nextTick, onMounted, useTemplateRef, watch } from 'vue'
45
- import { useFormItem } from '../composables/useFormItem'
46
- import { useTheme } from '../composables/useTheme'
47
-
5
+ <script setup>
6
+ import { Primitive } from "reka-ui";
7
+ import { computed, nextTick, onMounted, useTemplateRef, watch } from "vue";
8
+ import { useFormItem } from "../composables/useFormItem";
9
+ import { useTheme } from "../composables/useTheme";
48
10
  defineOptions({
49
- inheritAttrs: false,
50
- })
51
-
52
- const props = withDefaults(defineProps<TextareaProps>(), {
53
- variant: 'outline',
54
- rows: 3,
55
- maxRows: 0,
56
- autofocusDelay: 0,
57
- })
58
-
59
- const emit = defineEmits<TextareaEmits>()
60
- defineSlots<TextareaSlots>()
61
- const [modelValue, modelModifiers] = defineModel<string | number>()
62
-
63
- const textareaRef = useTemplateRef('textareaRef')
64
-
65
- const { id, name, size, highlight, disabled, ariaAttrs, emitFormInput, emitFormChange, emitFormBlur, emitFormFocus } = useFormItem<TextareaProps>(props)
66
- const { generateStyle } = useTheme()
67
- const style = computed(() => generateStyle('textarea', {
11
+ inheritAttrs: false
12
+ });
13
+ const props = defineProps({
14
+ as: { type: null, required: false },
15
+ id: { type: String, required: false },
16
+ name: { type: String, required: false },
17
+ placeholder: { type: String, required: false },
18
+ size: { type: null, required: false },
19
+ variant: { type: null, required: false, default: "outline" },
20
+ highlight: { type: Boolean, required: false },
21
+ underline: { type: Boolean, required: false },
22
+ required: { type: Boolean, required: false },
23
+ autofocus: { type: Boolean, required: false },
24
+ autofocusDelay: { type: Number, required: false, default: 0 },
25
+ disabled: { type: Boolean, required: false },
26
+ rows: { type: Number, required: false, default: 3 },
27
+ maxRows: { type: Number, required: false, default: 0 },
28
+ autoResize: { type: Boolean, required: false },
29
+ class: { type: null, required: false },
30
+ ui: { type: null, required: false }
31
+ });
32
+ const emit = defineEmits(["update:modelValue", "blur", "change"]);
33
+ defineSlots();
34
+ const [modelValue, modelModifiers] = defineModel({ type: [String, Number] });
35
+ const textareaRef = useTemplateRef("textareaRef");
36
+ const { id, name, size, highlight, disabled, ariaAttrs, emitFormInput, emitFormChange, emitFormBlur, emitFormFocus } = useFormItem(props);
37
+ const { generateStyle } = useTheme();
38
+ const style = computed(() => generateStyle("textarea", {
68
39
  ...props,
69
40
  size: size.value,
70
- highlight: highlight.value,
71
- }))
72
-
41
+ highlight: highlight.value
42
+ }));
73
43
  function autoFocus() {
74
44
  if (props.autofocus)
75
- textareaRef.value?.focus()
45
+ textareaRef.value?.focus();
76
46
  }
77
-
78
- function updateInput(value: string) {
47
+ function updateInput(value) {
79
48
  if (modelModifiers.trim)
80
- value = value.trim()
81
-
82
- modelValue.value = value
83
- emitFormInput()
49
+ value = value.trim();
50
+ modelValue.value = value;
51
+ emitFormInput();
84
52
  }
85
-
86
- function onInput(event: Event) {
87
- autoResize()
88
-
53
+ function onInput(event) {
54
+ autoResize();
89
55
  if (!modelModifiers.lazy)
90
- updateInput((event.target as HTMLInputElement).value)
56
+ updateInput(event.target.value);
91
57
  }
92
-
93
- function onChange(event: Event) {
94
- const value = (event.target as HTMLInputElement).value
95
-
58
+ function onChange(event) {
59
+ const value = event.target.value;
96
60
  if (modelModifiers.lazy)
97
- updateInput(value)
98
-
61
+ updateInput(value);
99
62
  if (modelModifiers.trim)
100
- (event.target as HTMLInputElement).value = value.trim()
101
-
102
- emit('change', event)
103
- emitFormChange()
63
+ event.target.value = value.trim();
64
+ emit("change", event);
65
+ emitFormChange();
104
66
  }
105
-
106
- function onBlur(event: FocusEvent) {
107
- emit('blur', event)
108
- emitFormBlur()
67
+ function onBlur(event) {
68
+ emit("blur", event);
69
+ emitFormBlur();
109
70
  }
110
-
111
71
  function autoResize() {
112
72
  if (!props.autoResize)
113
- return
114
-
73
+ return;
115
74
  if (!textareaRef.value)
116
- return
117
-
118
- textareaRef.value.rows = props.rows
119
-
120
- const overflow = textareaRef.value.style.overflow
121
- textareaRef.value.style.overflow = 'hidden'
122
-
123
- const styles = window.getComputedStyle(textareaRef.value)
124
- const paddingTop = Number.parseInt(styles.paddingTop)
125
- const paddingBottom = Number.parseInt(styles.paddingBottom)
126
- const padding = paddingTop + paddingBottom
127
- const lineHeight = Number.parseInt(styles.lineHeight)
128
- const { scrollHeight } = textareaRef.value
129
- const newRows = Math.ceil((scrollHeight - padding) / lineHeight)
130
-
75
+ return;
76
+ textareaRef.value.rows = props.rows;
77
+ const overflow = textareaRef.value.style.overflow;
78
+ textareaRef.value.style.overflow = "hidden";
79
+ const styles = window.getComputedStyle(textareaRef.value);
80
+ const paddingTop = Number.parseInt(styles.paddingTop);
81
+ const paddingBottom = Number.parseInt(styles.paddingBottom);
82
+ const padding = paddingTop + paddingBottom;
83
+ const lineHeight = Number.parseInt(styles.lineHeight);
84
+ const { scrollHeight } = textareaRef.value;
85
+ const newRows = Math.ceil((scrollHeight - padding) / lineHeight);
131
86
  if (newRows > props.rows)
132
- textareaRef.value.rows = props.maxRows ? Math.min(newRows, props.maxRows) : newRows
133
-
134
- textareaRef.value.style.overflow = overflow
87
+ textareaRef.value.rows = props.maxRows ? Math.min(newRows, props.maxRows) : newRows;
88
+ textareaRef.value.style.overflow = overflow;
135
89
  }
136
-
137
90
  watch(modelValue, () => {
138
- nextTick(autoResize)
139
- })
140
-
91
+ nextTick(autoResize);
92
+ });
141
93
  defineExpose({
142
- textareaRef,
143
- })
144
-
94
+ textareaRef
95
+ });
145
96
  onMounted(() => {
146
97
  setTimeout(() => {
147
- autoFocus()
148
- }, props.autofocusDelay)
149
- })
98
+ autoFocus();
99
+ }, props.autofocusDelay);
100
+ });
150
101
  </script>
151
102
 
152
103
  <template>
153
104
  <Primitive
154
105
  :as="props.as"
106
+ :aria-disabled="disabled ? true : void 0"
155
107
  :class="style.root({ class: [props.class, props.ui?.root] })"
156
- :aria-disabled="disabled ? true : undefined"
108
+ :data-part="$attrs['data-part'] ?? 'root'"
157
109
  >
158
110
  <textarea
159
111
  ref="textareaRef"
160
112
  :class="style.base({ class: props.ui?.base })"
113
+ data-part="base"
161
114
  :value="modelValue"
162
115
  :rows="props.rows"
163
116
  :placeholder="props.placeholder"
@@ -0,0 +1,60 @@
1
+ import type { VariantProps } from '@byyuurin/ui-kit';
2
+ import type { PrimitiveProps } from 'reka-ui';
3
+ import type { textarea } from '../theme/index.js';
4
+ import type { ComponentAttrs } from '../types/index.js';
5
+ export interface TextareaEmits {
6
+ 'update:modelValue': [payload: string];
7
+ 'blur': [event: FocusEvent];
8
+ 'change': [event: Event];
9
+ }
10
+ export interface TextareaSlots {
11
+ default?: (props?: {}) => any;
12
+ }
13
+ type TextareaVariants = VariantProps<typeof textarea>;
14
+ export interface TextareaProps extends ComponentAttrs<typeof textarea> {
15
+ /**
16
+ * The element or component this component should render as.
17
+ * @default "div"
18
+ */
19
+ as?: PrimitiveProps['as'];
20
+ id?: string;
21
+ name?: string;
22
+ placeholder?: string;
23
+ size?: TextareaVariants['size'];
24
+ variant?: TextareaVariants['variant'];
25
+ highlight?: boolean;
26
+ underline?: boolean;
27
+ required?: boolean;
28
+ autofocus?: boolean;
29
+ autofocusDelay?: number;
30
+ disabled?: boolean;
31
+ rows?: number;
32
+ maxRows?: number;
33
+ autoResize?: boolean;
34
+ }
35
+ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<TextareaProps & {
36
+ modelValue?: string | number;
37
+ }, {
38
+ textareaRef: Readonly<import("vue").ShallowRef<HTMLTextAreaElement | null>>;
39
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
40
+ blur: (event: FocusEvent) => any;
41
+ change: (event: Event) => any;
42
+ "update:modelValue": (...args: unknown[]) => any;
43
+ }, string, import("vue").PublicProps, Readonly<TextareaProps & {
44
+ modelValue?: string | number;
45
+ }> & Readonly<{
46
+ onBlur?: ((event: FocusEvent) => any) | undefined;
47
+ onChange?: ((event: Event) => any) | undefined;
48
+ "onUpdate:modelValue"?: ((...args: unknown[]) => any) | undefined;
49
+ }>, {
50
+ variant: "outline" | "soft" | "soft-outline" | "ghost" | "none";
51
+ autofocusDelay: number;
52
+ rows: number;
53
+ maxRows: number;
54
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, TextareaSlots>;
55
+ export default _default;
56
+ type __VLS_WithSlots<T, S> = T & {
57
+ new (): {
58
+ $slots: S;
59
+ };
60
+ };