@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.
- package/README.md +2 -5
- package/dist/module.json +3 -3
- package/dist/module.mjs +1 -1
- package/dist/module.mjs.map +1 -1
- package/dist/runtime/app/injections.d.ts +9323 -3
- package/dist/runtime/app/injections.js +35 -0
- package/dist/runtime/components/Accordion.vue +36 -69
- package/dist/runtime/components/Accordion.vue.d.ts +52 -0
- package/dist/runtime/components/Alert.vue +37 -75
- package/dist/runtime/components/Alert.vue.d.ts +59 -0
- package/dist/runtime/components/App.vue +25 -40
- package/dist/runtime/components/App.vue.d.ts +24 -0
- package/dist/runtime/components/Avatar.vue +31 -51
- package/dist/runtime/components/Avatar.vue.d.ts +25 -0
- package/dist/runtime/components/AvatarGroup.vue +38 -69
- package/dist/runtime/components/AvatarGroup.vue.d.ts +27 -0
- package/dist/runtime/components/Badge.vue +25 -51
- package/dist/runtime/components/Badge.vue.d.ts +44 -0
- package/dist/runtime/components/Breadcrumb.vue +35 -77
- package/dist/runtime/components/Breadcrumb.vue.d.ts +52 -0
- package/dist/runtime/components/Button.vue +62 -51
- package/dist/runtime/components/Button.vue.d.ts +29 -0
- package/dist/runtime/components/ButtonGroup.vue +17 -37
- package/dist/runtime/components/ButtonGroup.vue.d.ts +26 -0
- package/dist/runtime/components/Calendar.vue +75 -101
- package/dist/runtime/components/Calendar.vue.d.ts +75 -0
- package/dist/runtime/components/Card.vue +25 -42
- package/dist/runtime/components/Card.vue.d.ts +30 -0
- package/dist/runtime/components/Carousel.vue +118 -223
- package/dist/runtime/components/Carousel.vue.d.ts +104 -0
- package/dist/runtime/components/Checkbox.vue +49 -71
- package/dist/runtime/components/Checkbox.vue.d.ts +56 -0
- package/dist/runtime/components/Chip.vue +31 -48
- package/dist/runtime/components/Chip.vue.d.ts +30 -0
- package/dist/runtime/components/Collapsible.vue +22 -30
- package/dist/runtime/components/Collapsible.vue.d.ts +26 -0
- package/dist/runtime/components/Drawer.vue +52 -102
- package/dist/runtime/components/Drawer.vue.d.ts +80 -0
- package/dist/runtime/components/DropdownMenu.vue +65 -0
- package/dist/runtime/components/DropdownMenu.vue.d.ts +99 -0
- package/dist/runtime/components/DropdownMenuContent.vue +192 -0
- package/dist/runtime/components/DropdownMenuContent.vue.d.ts +39 -0
- package/dist/runtime/components/Form.vue +197 -0
- package/dist/runtime/components/Form.vue.d.ts +78 -0
- package/dist/runtime/components/FormItem.vue +90 -0
- package/dist/runtime/components/FormItem.vue.d.ts +60 -0
- package/dist/runtime/components/Input.vue +93 -115
- package/dist/runtime/components/Input.vue.d.ts +64 -0
- package/dist/runtime/components/InputNumber.vue +81 -116
- package/dist/runtime/components/InputNumber.vue.d.ts +245 -0
- package/dist/runtime/components/Kbd.vue +18 -39
- package/dist/runtime/components/Kbd.vue.d.ts +28 -0
- package/dist/runtime/components/Link.vue +170 -244
- package/dist/runtime/components/Link.vue.d.ts +95 -0
- package/dist/runtime/components/LinkBase.vue +36 -54
- package/dist/runtime/components/LinkBase.vue.d.ts +28 -0
- package/dist/runtime/components/Modal.vue +50 -85
- package/dist/runtime/components/Modal.vue.d.ts +66 -0
- package/dist/runtime/components/OverlayProvider.vue +10 -14
- package/dist/runtime/components/OverlayProvider.vue.d.ts +2 -0
- package/dist/runtime/components/Pagination.vue +55 -121
- package/dist/runtime/components/Pagination.vue.d.ts +93 -0
- package/dist/runtime/components/PinInput.vue +57 -57
- package/dist/runtime/components/PinInput.vue.d.ts +35 -0
- package/dist/runtime/components/Popover.vue +39 -68
- package/dist/runtime/components/Popover.vue.d.ts +45 -0
- package/dist/runtime/components/Progress.vue +68 -120
- package/dist/runtime/components/Progress.vue.d.ts +54 -0
- package/dist/runtime/components/RadioGroup.vue +75 -129
- package/dist/runtime/components/RadioGroup.vue.d.ts +74 -0
- package/dist/runtime/components/ScrollArea.vue +31 -31
- package/dist/runtime/components/ScrollArea.vue.d.ts +17 -0
- package/dist/runtime/components/Select.vue +119 -199
- package/dist/runtime/components/Select.vue.d.ts +119 -0
- package/dist/runtime/components/Separator.vue +26 -44
- package/dist/runtime/components/Separator.vue.d.ts +27 -0
- package/dist/runtime/components/Skeleton.vue +12 -21
- package/dist/runtime/components/Skeleton.vue.d.ts +19 -0
- package/dist/runtime/components/Slider.vue +54 -71
- package/dist/runtime/components/Slider.vue.d.ts +36 -0
- package/dist/runtime/components/Switch.vue +54 -68
- package/dist/runtime/components/Switch.vue.d.ts +49 -0
- package/dist/runtime/components/Table.vue +113 -186
- package/dist/runtime/components/Table.vue.d.ts +148 -0
- package/dist/runtime/components/Tabs.vue +35 -79
- package/dist/runtime/components/Tabs.vue.d.ts +65 -0
- package/dist/runtime/components/Textarea.vue +82 -123
- package/dist/runtime/components/Textarea.vue.d.ts +60 -0
- package/dist/runtime/components/Toast.vue +51 -76
- package/dist/runtime/components/Toast.vue.d.ts +131 -0
- package/dist/runtime/components/ToastProvider.vue +65 -101
- package/dist/runtime/components/ToastProvider.vue.d.ts +38 -0
- package/dist/runtime/components/Tooltip.vue +36 -47
- package/dist/runtime/components/Tooltip.vue.d.ts +31 -0
- package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
- package/dist/runtime/composables/useButtonGroup.d.ts +2 -2
- package/dist/runtime/composables/useFormItem.d.ts +27 -0
- package/dist/runtime/composables/useFormItem.js +64 -0
- package/dist/runtime/composables/useKbd.d.ts +1 -1
- package/dist/runtime/composables/useLocale.d.ts +3 -3
- package/dist/runtime/composables/useTheme.d.ts +1 -1
- package/dist/runtime/composables/useTheme.js +2 -1
- package/dist/runtime/composables/useToast.d.ts +1 -1
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.js +3 -0
- package/dist/runtime/locale/en.d.ts +1 -1
- package/dist/runtime/locale/zh-tw.d.ts +1 -1
- package/dist/runtime/theme/accordion.d.ts +45 -51
- package/dist/runtime/theme/accordion.js +1 -1
- package/dist/runtime/theme/alert.d.ts +115 -121
- package/dist/runtime/theme/alert.js +1 -1
- package/dist/runtime/theme/app.d.ts +1 -0
- package/dist/runtime/theme/app.js +2 -1
- package/dist/runtime/theme/avatar-group.d.ts +42 -48
- package/dist/runtime/theme/avatar-group.js +1 -1
- package/dist/runtime/theme/avatar.d.ts +46 -52
- package/dist/runtime/theme/avatar.js +1 -1
- package/dist/runtime/theme/badge.d.ts +63 -93
- package/dist/runtime/theme/badge.js +1 -1
- package/dist/runtime/theme/breadcrumb.d.ts +52 -58
- package/dist/runtime/theme/breadcrumb.js +1 -1
- package/dist/runtime/theme/button-group.d.ts +36 -42
- package/dist/runtime/theme/button.d.ts +165 -117
- package/dist/runtime/theme/button.js +1 -1
- package/dist/runtime/theme/calendar.d.ts +52 -50
- package/dist/runtime/theme/calendar.js +20 -3
- package/dist/runtime/theme/card.d.ts +52 -58
- package/dist/runtime/theme/card.js +1 -1
- package/dist/runtime/theme/carousel.d.ts +98 -104
- package/dist/runtime/theme/carousel.js +1 -1
- package/dist/runtime/theme/checkbox.d.ts +77 -83
- package/dist/runtime/theme/checkbox.js +1 -1
- package/dist/runtime/theme/chip.d.ts +50 -89
- package/dist/runtime/theme/chip.js +1 -1
- package/dist/runtime/theme/collapsible.d.ts +29 -35
- package/dist/runtime/theme/collapsible.js +1 -1
- package/dist/runtime/theme/drawer.d.ts +131 -102
- package/dist/runtime/theme/drawer.js +1 -1
- package/dist/runtime/theme/dropdown-menu.d.ts +65 -0
- package/dist/runtime/theme/dropdown-menu.js +83 -0
- package/dist/runtime/theme/form-item.d.ts +70 -0
- package/dist/runtime/theme/form-item.js +34 -0
- package/dist/runtime/theme/form.d.ts +2 -0
- package/dist/runtime/theme/form.js +7 -0
- package/dist/runtime/theme/index.d.ts +3 -0
- package/dist/runtime/theme/index.js +3 -0
- package/dist/runtime/theme/input-number.d.ts +100 -126
- package/dist/runtime/theme/input-number.js +1 -1
- package/dist/runtime/theme/input.d.ts +153 -131
- package/dist/runtime/theme/input.js +3 -3
- package/dist/runtime/theme/kbd.d.ts +30 -36
- package/dist/runtime/theme/link.d.ts +37 -43
- package/dist/runtime/theme/modal.d.ts +35 -69
- package/dist/runtime/theme/modal.js +1 -1
- package/dist/runtime/theme/pagination.d.ts +71 -77
- package/dist/runtime/theme/pagination.js +1 -1
- package/dist/runtime/theme/pinInput.d.ts +82 -88
- package/dist/runtime/theme/pinInput.js +2 -2
- package/dist/runtime/theme/popover.d.ts +29 -35
- package/dist/runtime/theme/popover.js +1 -1
- package/dist/runtime/theme/progress.d.ts +167 -109
- package/dist/runtime/theme/progress.js +1 -1
- package/dist/runtime/theme/radio-group.d.ts +99 -105
- package/dist/runtime/theme/radio-group.js +1 -1
- package/dist/runtime/theme/scroll-area.d.ts +62 -68
- package/dist/runtime/theme/scroll-area.js +1 -1
- package/dist/runtime/theme/select.d.ts +168 -158
- package/dist/runtime/theme/select.js +3 -2
- package/dist/runtime/theme/separator.d.ts +64 -85
- package/dist/runtime/theme/separator.js +1 -1
- package/dist/runtime/theme/skeleton.d.ts +1 -7
- package/dist/runtime/theme/slider.d.ts +62 -68
- package/dist/runtime/theme/slider.js +1 -1
- package/dist/runtime/theme/switch.d.ts +111 -117
- package/dist/runtime/theme/switch.js +1 -1
- package/dist/runtime/theme/table.d.ts +75 -78
- package/dist/runtime/theme/table.js +3 -2
- package/dist/runtime/theme/tabs.d.ts +116 -139
- package/dist/runtime/theme/tabs.js +1 -1
- package/dist/runtime/theme/textarea.d.ts +78 -90
- package/dist/runtime/theme/textarea.js +2 -2
- package/dist/runtime/theme/toast-provider.d.ts +110 -131
- package/dist/runtime/theme/toast-provider.js +1 -1
- package/dist/runtime/theme/toast.d.ts +74 -80
- package/dist/runtime/theme/toast.js +1 -1
- package/dist/runtime/theme/tooltip.d.ts +35 -41
- package/dist/runtime/theme/tooltip.js +1 -1
- package/dist/runtime/types/components.d.ts +3 -0
- package/dist/runtime/types/form.d.ts +45 -0
- package/dist/runtime/types/form.js +0 -0
- package/dist/runtime/types/index.d.ts +5 -2
- package/dist/runtime/types/index.js +1 -0
- package/dist/runtime/types/utils.d.ts +37 -16
- package/dist/runtime/utils/extend-theme.js +15 -4
- package/dist/runtime/utils/form.d.ts +5 -0
- package/dist/runtime/utils/form.js +24 -0
- package/dist/runtime/utils/index.d.ts +2 -0
- package/dist/runtime/utils/index.js +4 -0
- package/dist/runtime/utils/link.d.ts +4 -28
- package/dist/runtime/utils/link.js +10 -3
- package/dist/runtime/utils/styler.d.ts +2 -2
- package/dist/runtime/utils/styler.js +2 -2
- package/dist/shared/ui.D1BTWZFB.mjs +5 -0
- package/dist/shared/ui.D1BTWZFB.mjs.map +1 -0
- package/dist/types.d.mts +1 -1
- package/dist/unocss.mjs +7 -6
- package/dist/unocss.mjs.map +1 -1
- package/dist/unplugin.mjs +1 -1
- package/dist/unplugin.mjs.map +1 -1
- package/dist/vite.mjs +1 -1
- package/package.json +78 -74
- package/dist/module.cjs +0 -5
- package/dist/shared/ui.1a1f119c.mjs +0 -5
- package/dist/shared/ui.1a1f119c.mjs.map +0 -1
- package/dist/types.d.ts +0 -1
|
@@ -1,86 +1,40 @@
|
|
|
1
|
-
<script
|
|
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
|
-
type SlotProps<T> = (props: { item: T, index: number }) => any
|
|
10
|
-
|
|
11
|
-
export type TabsSlots<T extends { slot?: string }> = {
|
|
12
|
-
leading?: SlotProps<T>
|
|
13
|
-
default?: SlotProps<T>
|
|
14
|
-
trailing?: SlotProps<T>
|
|
15
|
-
content?: SlotProps<T>
|
|
16
|
-
} & DynamicSlots<T, SlotProps<T>>
|
|
17
|
-
|
|
18
|
-
export interface TabsItem {
|
|
19
|
-
label?: string
|
|
20
|
-
icon?: string
|
|
21
|
-
slot?: string
|
|
22
|
-
content?: string
|
|
23
|
-
/** A unique value for the tab item. Defaults to the index. */
|
|
24
|
-
value?: string | number
|
|
25
|
-
disabled?: boolean
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
type TabsVariants = VariantProps<typeof tabs>
|
|
29
|
-
|
|
30
|
-
export interface TabsProps<T> extends ComponentAttrs<typeof tabs>, Pick<TabsRootProps<string | number>, 'defaultValue' | 'modelValue' | 'activationMode' | 'unmountOnHide'> {
|
|
31
|
-
/**
|
|
32
|
-
* The element or component this component should render as.
|
|
33
|
-
* @default "div"
|
|
34
|
-
*/
|
|
35
|
-
as?: TabsRootProps<string | number>['as']
|
|
36
|
-
items?: T[]
|
|
37
|
-
variant?: TabsVariants['variant']
|
|
38
|
-
orientation?: TabsVariants['orientation']
|
|
39
|
-
size?: TabsVariants['size']
|
|
40
|
-
/** @default true */
|
|
41
|
-
evenly?: boolean
|
|
42
|
-
/**
|
|
43
|
-
* The content of the tabs, can be disabled to prevent rendering the content.
|
|
44
|
-
* @default true
|
|
45
|
-
*/
|
|
46
|
-
content?: boolean
|
|
47
|
-
/**
|
|
48
|
-
* The key used to get the label from the item.
|
|
49
|
-
* @default "label"
|
|
50
|
-
*/
|
|
51
|
-
labelKey?: string
|
|
52
|
-
}
|
|
53
3
|
</script>
|
|
54
4
|
|
|
55
|
-
<script
|
|
56
|
-
import { reactivePick } from
|
|
57
|
-
import { TabsContent, TabsIndicator, TabsList, TabsRoot, TabsTrigger, useForwardPropsEmits } from
|
|
58
|
-
import { computed } from
|
|
59
|
-
import { useTheme } from
|
|
60
|
-
import { get } from
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
variant:
|
|
65
|
-
orientation:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
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));
|
|
78
32
|
</script>
|
|
79
33
|
|
|
80
34
|
<template>
|
|
81
|
-
<TabsRoot v-bind="rootProps" :class="style.root({ class: [props.class, props.ui?.root] })">
|
|
82
|
-
<TabsList :class="style.list({ class: props.ui?.list })">
|
|
83
|
-
<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" />
|
|
84
38
|
|
|
85
39
|
<TabsTrigger
|
|
86
40
|
v-for="(item, index) of items"
|
|
@@ -88,12 +42,13 @@ const style = computed(() => generateStyle('tabs', props))
|
|
|
88
42
|
:value="item.value || String(index)"
|
|
89
43
|
:disabled="item.disabled"
|
|
90
44
|
:class="style.trigger({ class: props.ui?.trigger })"
|
|
45
|
+
data-part="trigger"
|
|
91
46
|
>
|
|
92
47
|
<slot name="leading" :item="item" :index="index">
|
|
93
|
-
<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>
|
|
94
49
|
</slot>
|
|
95
50
|
|
|
96
|
-
<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">
|
|
97
52
|
<slot :item="item" :index="index">{{ get(item, props.labelKey) }}</slot>
|
|
98
53
|
</span>
|
|
99
54
|
|
|
@@ -107,6 +62,7 @@ const style = computed(() => generateStyle('tabs', props))
|
|
|
107
62
|
:key="index"
|
|
108
63
|
:value="item.value || String(index)"
|
|
109
64
|
:class="style.content({ class: props.ui?.content })"
|
|
65
|
+
data-part="content"
|
|
110
66
|
>
|
|
111
67
|
<slot :name="item.slot || 'content'" :item="item" :index="index">
|
|
112
68
|
{{ item.content }}
|
|
@@ -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,166 +1,125 @@
|
|
|
1
|
-
<script
|
|
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
|
-
(e: 'update:modelValue', payload: string): void
|
|
9
|
-
(e: 'blur', event: FocusEvent): void
|
|
10
|
-
(e: 'change', event: Event): void
|
|
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
|
|
43
|
-
import { Primitive } from
|
|
44
|
-
import { computed, nextTick, onMounted,
|
|
45
|
-
import {
|
|
46
|
-
|
|
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";
|
|
47
10
|
defineOptions({
|
|
48
|
-
inheritAttrs: false
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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", {
|
|
39
|
+
...props,
|
|
40
|
+
size: size.value,
|
|
41
|
+
highlight: highlight.value
|
|
42
|
+
}));
|
|
67
43
|
function autoFocus() {
|
|
68
44
|
if (props.autofocus)
|
|
69
|
-
textareaRef.value?.focus()
|
|
45
|
+
textareaRef.value?.focus();
|
|
70
46
|
}
|
|
71
|
-
|
|
72
|
-
function updateInput(value: string) {
|
|
47
|
+
function updateInput(value) {
|
|
73
48
|
if (modelModifiers.trim)
|
|
74
|
-
value = value.trim()
|
|
75
|
-
|
|
76
|
-
|
|
49
|
+
value = value.trim();
|
|
50
|
+
modelValue.value = value;
|
|
51
|
+
emitFormInput();
|
|
77
52
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
autoResize()
|
|
81
|
-
|
|
53
|
+
function onInput(event) {
|
|
54
|
+
autoResize();
|
|
82
55
|
if (!modelModifiers.lazy)
|
|
83
|
-
updateInput(
|
|
56
|
+
updateInput(event.target.value);
|
|
84
57
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const value = (event.target as HTMLInputElement).value
|
|
88
|
-
|
|
58
|
+
function onChange(event) {
|
|
59
|
+
const value = event.target.value;
|
|
89
60
|
if (modelModifiers.lazy)
|
|
90
|
-
updateInput(value)
|
|
91
|
-
|
|
61
|
+
updateInput(value);
|
|
92
62
|
if (modelModifiers.trim)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
63
|
+
event.target.value = value.trim();
|
|
64
|
+
emit("change", event);
|
|
65
|
+
emitFormChange();
|
|
96
66
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
67
|
+
function onBlur(event) {
|
|
68
|
+
emit("blur", event);
|
|
69
|
+
emitFormBlur();
|
|
100
70
|
}
|
|
101
|
-
|
|
102
71
|
function autoResize() {
|
|
103
72
|
if (!props.autoResize)
|
|
104
|
-
return
|
|
105
|
-
|
|
73
|
+
return;
|
|
106
74
|
if (!textareaRef.value)
|
|
107
|
-
return
|
|
108
|
-
|
|
109
|
-
textareaRef.value.
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
const
|
|
117
|
-
const
|
|
118
|
-
const lineHeight = Number.parseInt(styles.lineHeight)
|
|
119
|
-
const { scrollHeight } = textareaRef.value
|
|
120
|
-
const newRows = Math.ceil((scrollHeight - padding) / lineHeight)
|
|
121
|
-
|
|
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);
|
|
122
86
|
if (newRows > props.rows)
|
|
123
|
-
textareaRef.value.rows = props.maxRows ? Math.min(newRows, props.maxRows) : newRows
|
|
124
|
-
|
|
125
|
-
textareaRef.value.style.overflow = overflow
|
|
87
|
+
textareaRef.value.rows = props.maxRows ? Math.min(newRows, props.maxRows) : newRows;
|
|
88
|
+
textareaRef.value.style.overflow = overflow;
|
|
126
89
|
}
|
|
127
|
-
|
|
128
90
|
watch(modelValue, () => {
|
|
129
|
-
nextTick(autoResize)
|
|
130
|
-
})
|
|
131
|
-
|
|
91
|
+
nextTick(autoResize);
|
|
92
|
+
});
|
|
132
93
|
defineExpose({
|
|
133
|
-
textareaRef
|
|
134
|
-
})
|
|
135
|
-
|
|
94
|
+
textareaRef
|
|
95
|
+
});
|
|
136
96
|
onMounted(() => {
|
|
137
97
|
setTimeout(() => {
|
|
138
|
-
autoFocus()
|
|
139
|
-
}, props.autofocusDelay)
|
|
140
|
-
})
|
|
98
|
+
autoFocus();
|
|
99
|
+
}, props.autofocusDelay);
|
|
100
|
+
});
|
|
141
101
|
</script>
|
|
142
102
|
|
|
143
103
|
<template>
|
|
144
104
|
<Primitive
|
|
145
105
|
:as="props.as"
|
|
106
|
+
:aria-disabled="disabled ? true : void 0"
|
|
146
107
|
:class="style.root({ class: [props.class, props.ui?.root] })"
|
|
147
|
-
:
|
|
108
|
+
:data-part="$attrs['data-part'] ?? 'root'"
|
|
148
109
|
>
|
|
149
110
|
<textarea
|
|
150
|
-
:id="props.id"
|
|
151
111
|
ref="textareaRef"
|
|
112
|
+
:class="style.base({ class: props.ui?.base })"
|
|
113
|
+
data-part="base"
|
|
152
114
|
:value="modelValue"
|
|
153
|
-
:name="props.name"
|
|
154
115
|
:rows="props.rows"
|
|
155
116
|
:placeholder="props.placeholder"
|
|
156
|
-
:class="style.base({ class: props.ui?.base })"
|
|
157
|
-
:disabled="props.disabled"
|
|
158
117
|
:required="props.required"
|
|
159
|
-
v-bind="
|
|
118
|
+
v-bind="{ ...$attrs, ...ariaAttrs, id, name, disabled }"
|
|
160
119
|
@input="onInput"
|
|
161
120
|
@blur="onBlur"
|
|
162
121
|
@change="onChange"
|
|
163
|
-
@focus="
|
|
122
|
+
@focus="emitFormFocus"
|
|
164
123
|
></textarea>
|
|
165
124
|
|
|
166
125
|
<slot></slot>
|
|
@@ -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
|
+
};
|