@byyuurin/ui 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/dist/module.json +1 -1
- package/dist/module.mjs +2 -2
- package/dist/runtime/components/Accordion.vue +43 -43
- package/dist/runtime/components/Alert.vue +65 -64
- package/dist/runtime/components/App.vue +10 -10
- package/dist/runtime/components/Avatar.vue +31 -30
- package/dist/runtime/components/AvatarGroup.vue +6 -5
- package/dist/runtime/components/Badge.vue +36 -35
- package/dist/runtime/components/Breadcrumb.vue +51 -51
- package/dist/runtime/components/Button.vue +54 -55
- package/dist/runtime/components/Calendar.vue +76 -75
- package/dist/runtime/components/Card.vue +43 -42
- package/dist/runtime/components/Carousel.vue +68 -67
- package/dist/runtime/components/Checkbox.vue +50 -48
- package/dist/runtime/components/CheckboxGroup.vue +33 -32
- package/dist/runtime/components/Chip.vue +20 -16
- package/dist/runtime/components/Collapsible.vue +16 -15
- package/dist/runtime/components/Drawer.vue +78 -77
- package/dist/runtime/components/DropdownMenu.vue +29 -29
- package/dist/runtime/components/DropdownMenuContent.vue +152 -152
- package/dist/runtime/components/FieldGroup.vue +5 -4
- package/dist/runtime/components/FileUpload.vue +267 -0
- package/dist/runtime/components/FileUpload.vue.d.ts +178 -0
- package/dist/runtime/components/Form.vue +11 -10
- package/dist/runtime/components/FormField.vue +39 -38
- package/dist/runtime/components/Icon.vue +2 -2
- package/dist/runtime/components/Input.vue +52 -52
- package/dist/runtime/components/InputNumber.vue +50 -49
- package/dist/runtime/components/InputTags.vue +55 -55
- package/dist/runtime/components/Kbd.vue +5 -4
- package/dist/runtime/components/Link.vue +25 -24
- package/dist/runtime/components/LinkBase.vue +3 -3
- package/dist/runtime/components/Marquee.vue +7 -6
- package/dist/runtime/components/Modal.vue +76 -75
- package/dist/runtime/components/NavigationMenu.vue +230 -230
- package/dist/runtime/components/OverlayProvider.vue +9 -9
- package/dist/runtime/components/Pagination.vue +49 -48
- package/dist/runtime/components/PinInput.vue +25 -25
- package/dist/runtime/components/Popover.vue +23 -23
- package/dist/runtime/components/Progress.vue +27 -26
- package/dist/runtime/components/RadioGroup.vue +53 -53
- package/dist/runtime/components/ScrollArea.vue +34 -33
- package/dist/runtime/components/Select.vue +203 -203
- package/dist/runtime/components/Separator.vue +32 -31
- package/dist/runtime/components/Skeleton.vue +13 -12
- package/dist/runtime/components/Slider.vue +27 -26
- package/dist/runtime/components/Stepper.vue +53 -52
- package/dist/runtime/components/Stepper.vue.d.ts +2 -2
- package/dist/runtime/components/Switch.vue +33 -34
- package/dist/runtime/components/Table.vue +139 -138
- package/dist/runtime/components/Tabs.vue +76 -76
- package/dist/runtime/components/Textarea.vue +50 -50
- package/dist/runtime/components/Timeline.vue +49 -48
- package/dist/runtime/components/Toast.vue +95 -94
- package/dist/runtime/components/ToastProvider.vue +31 -31
- package/dist/runtime/components/Tooltip.vue +26 -25
- package/dist/runtime/components/Tree.vue +133 -133
- package/dist/runtime/composables/useFileUpload.d.ts +19 -0
- package/dist/runtime/composables/useFileUpload.js +79 -0
- package/dist/runtime/composables/useLocale.d.ts +6 -0
- package/dist/runtime/locale/en.d.ts +3 -0
- package/dist/runtime/locale/en.js +3 -0
- package/dist/runtime/locale/zh_tw.d.ts +3 -0
- package/dist/runtime/locale/zh_tw.js +3 -0
- package/dist/runtime/types/index.d.ts +1 -0
- package/dist/runtime/types/index.js +1 -0
- package/dist/runtime/types/locale.d.ts +3 -0
- package/dist/runtime/types/unocss.d.ts +4 -4
- package/dist/runtime/types/utils.d.ts +1 -1
- package/dist/runtime/vue/components/Icon.vue +2 -2
- package/dist/setup.d.mts +1 -1
- package/dist/shared/{ui.D8Bg1HWt.d.mts → ui.CGCKYv7g.d.mts} +4 -2
- package/dist/shared/{ui.9kQouwss.mjs → ui.DYMXCXO6.mjs} +4 -2
- package/dist/shared/{ui.DpkP12cX.mjs → ui.DcEKQd0n.mjs} +230 -5
- package/dist/unocss.mjs +1 -1
- package/dist/unplugin.d.mts +1 -1
- package/dist/unplugin.mjs +2 -2
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +2 -2
- package/package.json +10 -10
- package/vue-plugin.d.ts +5 -5
|
@@ -7,7 +7,7 @@ import { reactivePick } from "@vueuse/core";
|
|
|
7
7
|
import { TabsContent, TabsIndicator, TabsList, TabsRoot, TabsTrigger, useForwardPropsEmits } from "reka-ui";
|
|
8
8
|
import { computed, ref } from "vue";
|
|
9
9
|
import { useAppConfig } from "#imports";
|
|
10
|
-
import { get } from "../utils";
|
|
10
|
+
import { get, pick } from "../utils";
|
|
11
11
|
import { cv, merge } from "../utils/style";
|
|
12
12
|
import Avatar from "./Avatar.vue";
|
|
13
13
|
import Badge from "./Badge.vue";
|
|
@@ -34,7 +34,7 @@ const rootProps = useForwardPropsEmits(reactivePick(props, "as", "unmountOnHide"
|
|
|
34
34
|
const appConfig = useAppConfig();
|
|
35
35
|
const ui = computed(() => {
|
|
36
36
|
const styler = cv(merge(theme, appConfig.ui.tabs));
|
|
37
|
-
return styler(props);
|
|
37
|
+
return styler(pick(props, ["color", "variant", "size", "orientation"]));
|
|
38
38
|
});
|
|
39
39
|
const triggersRef = ref([]);
|
|
40
40
|
defineExpose({
|
|
@@ -43,78 +43,78 @@ defineExpose({
|
|
|
43
43
|
</script>
|
|
44
44
|
|
|
45
45
|
<template>
|
|
46
|
-
<TabsRoot
|
|
47
|
-
v-bind="rootProps"
|
|
48
|
-
:model-value="props.modelValue"
|
|
49
|
-
:default-value="props.defaultValue"
|
|
50
|
-
:orientation="props.orientation"
|
|
51
|
-
:activation-mode="props.activationMode"
|
|
52
|
-
:class="ui.root({ class: [props.ui?.root, props.class] })"
|
|
53
|
-
data-part="root"
|
|
54
|
-
>
|
|
55
|
-
<TabsList :class="ui.list({ class: props.ui?.list })" data-part="list">
|
|
56
|
-
<TabsIndicator :class="ui.indicator({ class: props.ui?.indicator })" data-part="indicator" />
|
|
57
|
-
|
|
58
|
-
<slot name="list-leading">
|
|
59
|
-
</slot>
|
|
60
|
-
|
|
61
|
-
<TabsTrigger
|
|
62
|
-
v-for="(item, index) of items"
|
|
63
|
-
:ref="(el) => triggersRef[index] = el"
|
|
64
|
-
:key="index"
|
|
65
|
-
:value="item.value ?? String(index)"
|
|
66
|
-
:disabled="item.disabled"
|
|
67
|
-
:class="ui.trigger({ class: [props.ui?.trigger, item.ui?.trigger] })"
|
|
68
|
-
data-part="trigger"
|
|
69
|
-
>
|
|
70
|
-
<slot name="leading" :item="item" :index="index" :ui="ui">
|
|
71
|
-
<Icon
|
|
72
|
-
v-if="item.icon"
|
|
73
|
-
:name="item.icon"
|
|
74
|
-
:class="ui.leadingIcon({ class: [props.ui?.leadingIcon, item.ui?.leadingIcon] })"
|
|
75
|
-
data-part="leadingIcon"
|
|
76
|
-
/>
|
|
77
|
-
<Avatar
|
|
78
|
-
v-else-if="item.avatar"
|
|
79
|
-
:size="item.ui?.leadingAvatarSize || props.ui?.leadingAvatarSize || ui.leadingAvatarSize()"
|
|
80
|
-
v-bind="item.avatar"
|
|
81
|
-
:class="ui.leadingAvatar({ class: [props.ui?.leadingAvatar, item.ui?.leadingAvatar] })"
|
|
82
|
-
data-part="leadingAvatar"
|
|
83
|
-
/>
|
|
84
|
-
</slot>
|
|
85
|
-
|
|
86
|
-
<span v-if="get(item, props.labelKey) || !!slots.default" :class="ui.label({ class: [props.ui?.label, item.ui?.label] })" data-part="label">
|
|
87
|
-
<slot :item="item" :index="index">{{ get(item, props.labelKey) }}</slot>
|
|
88
|
-
</span>
|
|
89
|
-
|
|
90
|
-
<slot name="trailing" :item="item" :index="index" :ui="ui">
|
|
91
|
-
<Badge
|
|
92
|
-
v-if="item.badge !== void 0"
|
|
93
|
-
color="neutral"
|
|
94
|
-
variant="outline"
|
|
95
|
-
:size="item.ui?.trailingBadgeSize || props.ui?.trailingBadgeSize || ui.trailingBadgeSize()"
|
|
96
|
-
v-bind="typeof item.badge === 'string' || typeof item.badge === 'number' ? { label: item.badge } : item.badge"
|
|
97
|
-
:class="ui.trailingBadge({ class: [props.ui?.trailingBadge, item.ui?.trailingBadge] })"
|
|
98
|
-
data-part="trailingBadge"
|
|
99
|
-
/>
|
|
100
|
-
</slot>
|
|
101
|
-
</TabsTrigger>
|
|
102
|
-
|
|
103
|
-
<slot name="list-trailing"></slot>
|
|
104
|
-
</TabsList>
|
|
105
|
-
|
|
106
|
-
<template v-if="props.content">
|
|
107
|
-
<TabsContent
|
|
108
|
-
v-for="(item, index) of items"
|
|
109
|
-
:key="index"
|
|
110
|
-
:value="item.value ?? String(index)"
|
|
111
|
-
:class="ui.content({ class: [props.ui?.content, item.ui?.content] })"
|
|
112
|
-
data-part="content"
|
|
113
|
-
>
|
|
114
|
-
<slot :name="item.slot || 'content'" :item="item" :index="index" :ui="ui">
|
|
115
|
-
{{ item.content }}
|
|
116
|
-
</slot>
|
|
117
|
-
</TabsContent>
|
|
118
|
-
</template>
|
|
119
|
-
</TabsRoot>
|
|
46
|
+
<TabsRoot
|
|
47
|
+
v-bind="rootProps"
|
|
48
|
+
:model-value="props.modelValue"
|
|
49
|
+
:default-value="props.defaultValue"
|
|
50
|
+
:orientation="props.orientation"
|
|
51
|
+
:activation-mode="props.activationMode"
|
|
52
|
+
:class="ui.root({ class: [props.ui?.root, props.class] })"
|
|
53
|
+
data-part="root"
|
|
54
|
+
>
|
|
55
|
+
<TabsList :class="ui.list({ class: props.ui?.list })" data-part="list">
|
|
56
|
+
<TabsIndicator :class="ui.indicator({ class: props.ui?.indicator })" data-part="indicator" />
|
|
57
|
+
|
|
58
|
+
<slot name="list-leading">
|
|
59
|
+
</slot>
|
|
60
|
+
|
|
61
|
+
<TabsTrigger
|
|
62
|
+
v-for="(item, index) of items"
|
|
63
|
+
:ref="(el) => triggersRef[index] = el"
|
|
64
|
+
:key="index"
|
|
65
|
+
:value="item.value ?? String(index)"
|
|
66
|
+
:disabled="item.disabled"
|
|
67
|
+
:class="ui.trigger({ class: [props.ui?.trigger, item.ui?.trigger] })"
|
|
68
|
+
data-part="trigger"
|
|
69
|
+
>
|
|
70
|
+
<slot name="leading" :item="item" :index="index" :ui="ui">
|
|
71
|
+
<Icon
|
|
72
|
+
v-if="item.icon"
|
|
73
|
+
:name="item.icon"
|
|
74
|
+
:class="ui.leadingIcon({ class: [props.ui?.leadingIcon, item.ui?.leadingIcon] })"
|
|
75
|
+
data-part="leadingIcon"
|
|
76
|
+
/>
|
|
77
|
+
<Avatar
|
|
78
|
+
v-else-if="item.avatar"
|
|
79
|
+
:size="item.ui?.leadingAvatarSize || props.ui?.leadingAvatarSize || ui.leadingAvatarSize()"
|
|
80
|
+
v-bind="item.avatar"
|
|
81
|
+
:class="ui.leadingAvatar({ class: [props.ui?.leadingAvatar, item.ui?.leadingAvatar] })"
|
|
82
|
+
data-part="leadingAvatar"
|
|
83
|
+
/>
|
|
84
|
+
</slot>
|
|
85
|
+
|
|
86
|
+
<span v-if="get(item, props.labelKey) || !!slots.default" :class="ui.label({ class: [props.ui?.label, item.ui?.label] })" data-part="label">
|
|
87
|
+
<slot :item="item" :index="index">{{ get(item, props.labelKey) }}</slot>
|
|
88
|
+
</span>
|
|
89
|
+
|
|
90
|
+
<slot name="trailing" :item="item" :index="index" :ui="ui">
|
|
91
|
+
<Badge
|
|
92
|
+
v-if="item.badge !== void 0"
|
|
93
|
+
color="neutral"
|
|
94
|
+
variant="outline"
|
|
95
|
+
:size="item.ui?.trailingBadgeSize || props.ui?.trailingBadgeSize || ui.trailingBadgeSize()"
|
|
96
|
+
v-bind="typeof item.badge === 'string' || typeof item.badge === 'number' ? { label: item.badge } : item.badge"
|
|
97
|
+
:class="ui.trailingBadge({ class: [props.ui?.trailingBadge, item.ui?.trailingBadge] })"
|
|
98
|
+
data-part="trailingBadge"
|
|
99
|
+
/>
|
|
100
|
+
</slot>
|
|
101
|
+
</TabsTrigger>
|
|
102
|
+
|
|
103
|
+
<slot name="list-trailing"></slot>
|
|
104
|
+
</TabsList>
|
|
105
|
+
|
|
106
|
+
<template v-if="props.content">
|
|
107
|
+
<TabsContent
|
|
108
|
+
v-for="(item, index) of items"
|
|
109
|
+
:key="index"
|
|
110
|
+
:value="item.value ?? String(index)"
|
|
111
|
+
:class="ui.content({ class: [props.ui?.content, item.ui?.content] })"
|
|
112
|
+
data-part="content"
|
|
113
|
+
>
|
|
114
|
+
<slot :name="item.slot || 'content'" :item="item" :index="index" :ui="ui">
|
|
115
|
+
{{ item.content }}
|
|
116
|
+
</slot>
|
|
117
|
+
</TabsContent>
|
|
118
|
+
</template>
|
|
119
|
+
</TabsRoot>
|
|
120
120
|
</template>
|
|
@@ -9,7 +9,7 @@ import { computed, nextTick, onMounted, shallowRef, watch } from "vue";
|
|
|
9
9
|
import { useAppConfig } from "#imports";
|
|
10
10
|
import { useComponentIcons } from "../composables/useComponentIcons";
|
|
11
11
|
import { useFormField } from "../composables/useFormField";
|
|
12
|
-
import { looseToNumber } from "../utils";
|
|
12
|
+
import { looseToNumber, pick } from "../utils";
|
|
13
13
|
import { cv, merge } from "../utils/style";
|
|
14
14
|
import Avatar from "./Avatar.vue";
|
|
15
15
|
import Icon from "./Icon.vue";
|
|
@@ -54,9 +54,9 @@ const appConfig = useAppConfig();
|
|
|
54
54
|
const ui = computed(() => {
|
|
55
55
|
const styler = cv(merge(theme, appConfig.ui.textarea));
|
|
56
56
|
return styler({
|
|
57
|
-
...props,
|
|
58
|
-
size: size.value,
|
|
57
|
+
...pick(props, ["variant", "loading", "autoresize"]),
|
|
59
58
|
color: color.value,
|
|
59
|
+
size: size.value,
|
|
60
60
|
highlight: highlight.value,
|
|
61
61
|
leading: isLeading.value || !!props.avatar || !!slots.leading,
|
|
62
62
|
trailing: isTrailing.value || !!slots.trailing
|
|
@@ -125,51 +125,51 @@ defineExpose({
|
|
|
125
125
|
</script>
|
|
126
126
|
|
|
127
127
|
<template>
|
|
128
|
-
<Primitive :as="props.as" :class="ui.root({ class: [props.ui?.root, props.class] })" data-part="root">
|
|
129
|
-
<span v-if="isLeading || props.avatar || !!slots.leading" :class="ui.leading({ class: props.ui?.leading })" data-part="leading">
|
|
130
|
-
<slot name="leading" :ui="ui">
|
|
131
|
-
<Icon
|
|
132
|
-
v-if="isLeading && leadingIconName"
|
|
133
|
-
:name="leadingIconName"
|
|
134
|
-
:class="ui.leadingIcon({ class: props.ui?.leadingIcon })"
|
|
135
|
-
data-part="leadingIcon"
|
|
136
|
-
/>
|
|
137
|
-
<Avatar
|
|
138
|
-
v-else-if="props.avatar"
|
|
139
|
-
:size="props.ui?.leadingAvatarSize || ui.leadingAvatarSize()"
|
|
140
|
-
v-bind="props.avatar"
|
|
141
|
-
:class="ui.leadingAvatar({ class: props.ui?.leadingAvatar })"
|
|
142
|
-
data-part="leadingAvatar"
|
|
143
|
-
/>
|
|
144
|
-
</slot>
|
|
145
|
-
</span>
|
|
146
|
-
|
|
147
|
-
<textarea
|
|
148
|
-
ref="textareaRef"
|
|
149
|
-
:value="modelValue"
|
|
150
|
-
:rows="props.rows"
|
|
151
|
-
:placeholder="props.placeholder"
|
|
152
|
-
:required="props.required"
|
|
153
|
-
v-bind="{ id, name, disabled, ...$attrs, ...ariaAttrs }"
|
|
154
|
-
:class="ui.base({ class: props.ui?.base })"
|
|
155
|
-
data-part="base"
|
|
156
|
-
@input="onInput"
|
|
157
|
-
@blur="onBlur"
|
|
158
|
-
@change="onChange"
|
|
159
|
-
@focus="emitFormFocus"
|
|
160
|
-
></textarea>
|
|
161
|
-
|
|
162
|
-
<slot :ui="ui"></slot>
|
|
163
|
-
|
|
164
|
-
<span v-if="isTrailing || !!slots.trailing" :class="ui.trailing({ class: props.ui?.trailing })" data-part="trailing">
|
|
165
|
-
<slot name="trailing" :ui="ui">
|
|
166
|
-
<Icon
|
|
167
|
-
v-if="trailingIconName"
|
|
168
|
-
:name="trailingIconName"
|
|
169
|
-
:class="ui.trailingIcon({ class: props.ui?.trailingIcon })"
|
|
170
|
-
data-part="trailingIcon"
|
|
171
|
-
/>
|
|
172
|
-
</slot>
|
|
173
|
-
</span>
|
|
174
|
-
</Primitive>
|
|
128
|
+
<Primitive :as="props.as" :class="ui.root({ class: [props.ui?.root, props.class] })" data-part="root">
|
|
129
|
+
<span v-if="isLeading || props.avatar || !!slots.leading" :class="ui.leading({ class: props.ui?.leading })" data-part="leading">
|
|
130
|
+
<slot name="leading" :ui="ui">
|
|
131
|
+
<Icon
|
|
132
|
+
v-if="isLeading && leadingIconName"
|
|
133
|
+
:name="leadingIconName"
|
|
134
|
+
:class="ui.leadingIcon({ class: props.ui?.leadingIcon })"
|
|
135
|
+
data-part="leadingIcon"
|
|
136
|
+
/>
|
|
137
|
+
<Avatar
|
|
138
|
+
v-else-if="props.avatar"
|
|
139
|
+
:size="props.ui?.leadingAvatarSize || ui.leadingAvatarSize()"
|
|
140
|
+
v-bind="props.avatar"
|
|
141
|
+
:class="ui.leadingAvatar({ class: props.ui?.leadingAvatar })"
|
|
142
|
+
data-part="leadingAvatar"
|
|
143
|
+
/>
|
|
144
|
+
</slot>
|
|
145
|
+
</span>
|
|
146
|
+
|
|
147
|
+
<textarea
|
|
148
|
+
ref="textareaRef"
|
|
149
|
+
:value="modelValue"
|
|
150
|
+
:rows="props.rows"
|
|
151
|
+
:placeholder="props.placeholder"
|
|
152
|
+
:required="props.required"
|
|
153
|
+
v-bind="{ id, name, disabled, ...$attrs, ...ariaAttrs }"
|
|
154
|
+
:class="ui.base({ class: props.ui?.base })"
|
|
155
|
+
data-part="base"
|
|
156
|
+
@input="onInput"
|
|
157
|
+
@blur="onBlur"
|
|
158
|
+
@change="onChange"
|
|
159
|
+
@focus="emitFormFocus"
|
|
160
|
+
></textarea>
|
|
161
|
+
|
|
162
|
+
<slot :ui="ui"></slot>
|
|
163
|
+
|
|
164
|
+
<span v-if="isTrailing || !!slots.trailing" :class="ui.trailing({ class: props.ui?.trailing })" data-part="trailing">
|
|
165
|
+
<slot name="trailing" :ui="ui">
|
|
166
|
+
<Icon
|
|
167
|
+
v-if="trailingIconName"
|
|
168
|
+
:name="trailingIconName"
|
|
169
|
+
:class="ui.trailingIcon({ class: props.ui?.trailingIcon })"
|
|
170
|
+
data-part="trailingIcon"
|
|
171
|
+
/>
|
|
172
|
+
</slot>
|
|
173
|
+
</span>
|
|
174
|
+
</Primitive>
|
|
175
175
|
</template>
|
|
@@ -7,6 +7,7 @@ import { useVModel } from "@vueuse/core";
|
|
|
7
7
|
import { Primitive, Separator } from "reka-ui";
|
|
8
8
|
import { computed } from "vue";
|
|
9
9
|
import { useAppConfig } from "#imports";
|
|
10
|
+
import { pick } from "../utils";
|
|
10
11
|
import { cv, merge } from "../utils/style";
|
|
11
12
|
import Avatar from "./Avatar.vue";
|
|
12
13
|
const props = defineProps({
|
|
@@ -44,59 +45,59 @@ function getItemState(index) {
|
|
|
44
45
|
const appConfig = useAppConfig();
|
|
45
46
|
const ui = computed(() => {
|
|
46
47
|
const styler = cv(merge(theme, appConfig.ui.timeline));
|
|
47
|
-
return styler(props);
|
|
48
|
+
return styler(pick(props, ["orientation", "size", "color", "reverse"]));
|
|
48
49
|
});
|
|
49
50
|
</script>
|
|
50
51
|
|
|
51
52
|
<template>
|
|
52
|
-
<Primitive :as="props.as" :data-orientation="props.orientation" :class="ui.root({ class: [props.ui?.root, props.class] })" data-part="root">
|
|
53
|
-
<div
|
|
54
|
-
v-for="(item, index) in props.items"
|
|
55
|
-
:key="item.value ?? index"
|
|
56
|
-
:class="ui.item({ class: [props.ui?.item, item.ui?.item, item.class] })"
|
|
57
|
-
data-part="item"
|
|
58
|
-
:data-state="getItemState(index)"
|
|
59
|
-
>
|
|
60
|
-
<div :class="ui.container({ class: [props.ui?.container, item.ui?.container] })" data-part="container">
|
|
61
|
-
<Avatar
|
|
62
|
-
:size="props.size"
|
|
63
|
-
:icon="item.icon"
|
|
64
|
-
v-bind="typeof item.avatar === 'object' ? item.avatar : {}"
|
|
53
|
+
<Primitive :as="props.as" :data-orientation="props.orientation" :class="ui.root({ class: [props.ui?.root, props.class] })" data-part="root">
|
|
54
|
+
<div
|
|
55
|
+
v-for="(item, index) in props.items"
|
|
56
|
+
:key="item.value ?? index"
|
|
57
|
+
:class="ui.item({ class: [props.ui?.item, item.ui?.item, item.class] })"
|
|
58
|
+
data-part="item"
|
|
59
|
+
:data-state="getItemState(index)"
|
|
60
|
+
>
|
|
61
|
+
<div :class="ui.container({ class: [props.ui?.container, item.ui?.container] })" data-part="container">
|
|
62
|
+
<Avatar
|
|
63
|
+
:size="props.size"
|
|
64
|
+
:icon="item.icon"
|
|
65
|
+
v-bind="typeof item.avatar === 'object' ? item.avatar : {}"
|
|
65
66
|
:ui="{
|
|
66
67
|
icon: ui.indicatorIcon({ class: props.ui?.indicatorIcon }),
|
|
67
68
|
fallback: ui.indicatorFallback({ class: props.ui?.indicatorFallback })
|
|
68
|
-
}"
|
|
69
|
-
:class="ui.indicator({ class: [props.ui?.indicator, item.ui?.indicator] })"
|
|
70
|
-
data-part="indicator"
|
|
71
|
-
>
|
|
72
|
-
<slot :name="item.slot ? `${item.slot}-indicator` : 'indicator'" :item="item"></slot>
|
|
73
|
-
</Avatar>
|
|
74
|
-
|
|
75
|
-
<Separator
|
|
76
|
-
v-if="index < items.length - 1"
|
|
77
|
-
:orientation="props.orientation"
|
|
78
|
-
:class="ui.separator({ class: [props.ui?.separator, item.ui?.separator] })"
|
|
79
|
-
data-part="separator"
|
|
80
|
-
/>
|
|
81
|
-
</div>
|
|
82
|
-
|
|
83
|
-
<div :class="ui.wrapper({ class: [props.ui?.wrapper, item.ui?.wrapper] })" data-part="wrapper">
|
|
84
|
-
<div v-if="item.date" :class="ui.date({ class: [props.ui?.date, item.ui?.date] })" data-part="date">
|
|
85
|
-
<slot :name="item.slot ? `${item.slot}-date` : 'date'" :item="item">
|
|
86
|
-
{{ item.date }}
|
|
87
|
-
</slot>
|
|
88
|
-
</div>
|
|
89
|
-
<div v-if="item.title || !!slots.title" :class="ui.title({ class: [props.ui?.title, item.ui?.title] })" data-part="title">
|
|
90
|
-
<slot :name="item.slot ? `${item.slot}-title` : 'title'" :item="item">
|
|
91
|
-
{{ item.title }}
|
|
92
|
-
</slot>
|
|
93
|
-
</div>
|
|
94
|
-
<div v-if="item.description || !!slots.description" :class="ui.description({ class: [props.ui?.description, item.ui?.description] })" data-part="description">
|
|
95
|
-
<slot :name="item.slot ? `${item.slot}-description` : 'description'" :item="item">
|
|
96
|
-
{{ item.description }}
|
|
97
|
-
</slot>
|
|
98
|
-
</div>
|
|
99
|
-
</div>
|
|
100
|
-
</div>
|
|
101
|
-
</Primitive>
|
|
69
|
+
}"
|
|
70
|
+
:class="ui.indicator({ class: [props.ui?.indicator, item.ui?.indicator] })"
|
|
71
|
+
data-part="indicator"
|
|
72
|
+
>
|
|
73
|
+
<slot :name="item.slot ? `${item.slot}-indicator` : 'indicator'" :item="item"></slot>
|
|
74
|
+
</Avatar>
|
|
75
|
+
|
|
76
|
+
<Separator
|
|
77
|
+
v-if="index < items.length - 1"
|
|
78
|
+
:orientation="props.orientation"
|
|
79
|
+
:class="ui.separator({ class: [props.ui?.separator, item.ui?.separator] })"
|
|
80
|
+
data-part="separator"
|
|
81
|
+
/>
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
<div :class="ui.wrapper({ class: [props.ui?.wrapper, item.ui?.wrapper] })" data-part="wrapper">
|
|
85
|
+
<div v-if="item.date" :class="ui.date({ class: [props.ui?.date, item.ui?.date] })" data-part="date">
|
|
86
|
+
<slot :name="item.slot ? `${item.slot}-date` : 'date'" :item="item">
|
|
87
|
+
{{ item.date }}
|
|
88
|
+
</slot>
|
|
89
|
+
</div>
|
|
90
|
+
<div v-if="item.title || !!slots.title" :class="ui.title({ class: [props.ui?.title, item.ui?.title] })" data-part="title">
|
|
91
|
+
<slot :name="item.slot ? `${item.slot}-title` : 'title'" :item="item">
|
|
92
|
+
{{ item.title }}
|
|
93
|
+
</slot>
|
|
94
|
+
</div>
|
|
95
|
+
<div v-if="item.description || !!slots.description" :class="ui.description({ class: [props.ui?.description, item.ui?.description] })" data-part="description">
|
|
96
|
+
<slot :name="item.slot ? `${item.slot}-description` : 'description'" :item="item">
|
|
97
|
+
{{ item.description }}
|
|
98
|
+
</slot>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
</Primitive>
|
|
102
103
|
</template>
|
|
@@ -8,6 +8,7 @@ import { ToastAction, ToastClose, ToastDescription, ToastRoot, ToastTitle, useFo
|
|
|
8
8
|
import { computed, nextTick, onMounted, shallowRef } from "vue";
|
|
9
9
|
import { useAppConfig } from "#imports";
|
|
10
10
|
import { useLocale } from "../composables/useLocale";
|
|
11
|
+
import { pick } from "../utils";
|
|
11
12
|
import { cv, merge } from "../utils/style";
|
|
12
13
|
import Avatar from "./Avatar.vue";
|
|
13
14
|
import Button from "./Button.vue";
|
|
@@ -40,7 +41,7 @@ const appConfig = useAppConfig();
|
|
|
40
41
|
const ui = computed(() => {
|
|
41
42
|
const styler = cv(merge(theme, appConfig.ui.toast));
|
|
42
43
|
return styler({
|
|
43
|
-
...props,
|
|
44
|
+
...pick(props, ["color", "orientation"]),
|
|
44
45
|
title: !!props.title || !!slots.title
|
|
45
46
|
});
|
|
46
47
|
});
|
|
@@ -59,97 +60,97 @@ defineExpose({
|
|
|
59
60
|
</script>
|
|
60
61
|
|
|
61
62
|
<template>
|
|
62
|
-
<ToastRoot
|
|
63
|
-
ref="el"
|
|
64
|
-
v-slot="{ remaining, duration, open }"
|
|
65
|
-
v-bind="rootProps"
|
|
66
|
-
:class="ui.root({ class: [props.ui?.root, props.class] })"
|
|
67
|
-
:data-orientation="props.orientation"
|
|
68
|
-
data-part="root"
|
|
69
|
-
:style="{ '--height': height }"
|
|
70
|
-
>
|
|
71
|
-
<slot name="leading" :ui="ui">
|
|
72
|
-
<Avatar
|
|
73
|
-
v-if="props.avatar"
|
|
74
|
-
:size="props.ui?.avatarSize || ui.avatarSize()"
|
|
75
|
-
v-bind="props.avatar"
|
|
76
|
-
:class="ui.avatar({ class: props.ui?.avatar })"
|
|
77
|
-
data-part="avatar"
|
|
78
|
-
/>
|
|
79
|
-
<Icon
|
|
80
|
-
v-else-if="props.icon"
|
|
81
|
-
:name="props.icon"
|
|
82
|
-
:class="ui.icon({ class: props.ui?.icon })"
|
|
83
|
-
data-part="icon"
|
|
84
|
-
/>
|
|
85
|
-
</slot>
|
|
86
|
-
|
|
87
|
-
<div :class="ui.wrapper({ class: props.ui?.wrapper })" data-part="wrapper">
|
|
88
|
-
<ToastTitle v-if="props.title || !!slots.title" :class="ui.title({ class: props.ui?.title })" data-part="title">
|
|
89
|
-
<slot name="title">
|
|
90
|
-
<component :is="props.title()" v-if="typeof props.title === 'function'" />
|
|
91
|
-
<component :is="props.title" v-else-if="typeof props.title === 'object'" />
|
|
92
|
-
<template v-else>
|
|
93
|
-
{{ props.title }}
|
|
94
|
-
</template>
|
|
95
|
-
</slot>
|
|
96
|
-
</ToastTitle>
|
|
97
|
-
<ToastDescription v-if="props.description || !!slots.description" :class="ui.description({ class: props.ui?.description })" data-part="description">
|
|
98
|
-
<slot name="description">
|
|
99
|
-
<component :is="props.description()" v-if="typeof props.description === 'function'" />
|
|
100
|
-
<component :is="props.description" v-else-if="typeof props.description === 'object'" />
|
|
101
|
-
<template v-else>
|
|
102
|
-
{{ props.description }}
|
|
103
|
-
</template>
|
|
104
|
-
</slot>
|
|
105
|
-
</ToastDescription>
|
|
106
|
-
|
|
107
|
-
<div v-if="props.orientation === 'vertical' && (props.actions?.length || slots.actions)" :class="ui.actions({ class: props.ui?.actions })" data-part="actions">
|
|
108
|
-
<slot name="actions">
|
|
109
|
-
<ToastAction v-for="(action, index) in props.actions" :key="index" :alt-text="action.label || 'Action'" as-child @click.stop>
|
|
110
|
-
<Button size="xs" :color="props.color" v-bind="action" />
|
|
111
|
-
</ToastAction>
|
|
112
|
-
</slot>
|
|
113
|
-
</div>
|
|
114
|
-
</div>
|
|
115
|
-
|
|
116
|
-
<div
|
|
117
|
-
v-if="props.orientation === 'horizontal' && (props.actions?.length || !!slots.actions) || props.close"
|
|
118
|
-
:class="ui.actions({ class: props.ui?.actions })"
|
|
119
|
-
data-part="actions"
|
|
120
|
-
>
|
|
121
|
-
<template v-if="props.orientation === 'horizontal'">
|
|
122
|
-
<slot name="actions">
|
|
123
|
-
<ToastAction v-for="(action, index) in props.actions" :key="index" :alt-text="action.label || 'Action'" as-child @click.stop>
|
|
124
|
-
<Button size="xs" :color="props.color" v-bind="action" />
|
|
125
|
-
</ToastAction>
|
|
126
|
-
</slot>
|
|
127
|
-
</template>
|
|
128
|
-
|
|
129
|
-
<ToastClose v-if="props.close || !!slots.close" as-child>
|
|
130
|
-
<slot name="close" :ui="ui">
|
|
131
|
-
<Button
|
|
132
|
-
v-if="props.close"
|
|
133
|
-
:icon="props.closeIcon || appConfig.ui.icons.close"
|
|
134
|
-
color="neutral"
|
|
135
|
-
variant="link"
|
|
136
|
-
:aria-label="t('toast.close')"
|
|
137
|
-
v-bind="typeof props.close === 'object' ? props.close : {}"
|
|
138
|
-
:class="ui.close({ class: props.ui?.close })"
|
|
139
|
-
data-part="close"
|
|
140
|
-
@click.stop
|
|
141
|
-
/>
|
|
142
|
-
</slot>
|
|
143
|
-
</ToastClose>
|
|
144
|
-
</div>
|
|
145
|
-
|
|
146
|
-
<Progress
|
|
147
|
-
v-if="props.progress && open && remaining >= 0 && duration"
|
|
148
|
-
:model-value="remaining / duration * 100"
|
|
149
|
-
:color="props.color"
|
|
150
|
-
v-bind="typeof props.progress === 'object' ? props.progress : {}"
|
|
151
|
-
size="sm"
|
|
152
|
-
:class="ui.progress({ class: props.ui?.progress })"
|
|
153
|
-
/>
|
|
154
|
-
</ToastRoot>
|
|
63
|
+
<ToastRoot
|
|
64
|
+
ref="el"
|
|
65
|
+
v-slot="{ remaining, duration, open }"
|
|
66
|
+
v-bind="rootProps"
|
|
67
|
+
:class="ui.root({ class: [props.ui?.root, props.class] })"
|
|
68
|
+
:data-orientation="props.orientation"
|
|
69
|
+
data-part="root"
|
|
70
|
+
:style="{ '--height': height }"
|
|
71
|
+
>
|
|
72
|
+
<slot name="leading" :ui="ui">
|
|
73
|
+
<Avatar
|
|
74
|
+
v-if="props.avatar"
|
|
75
|
+
:size="props.ui?.avatarSize || ui.avatarSize()"
|
|
76
|
+
v-bind="props.avatar"
|
|
77
|
+
:class="ui.avatar({ class: props.ui?.avatar })"
|
|
78
|
+
data-part="avatar"
|
|
79
|
+
/>
|
|
80
|
+
<Icon
|
|
81
|
+
v-else-if="props.icon"
|
|
82
|
+
:name="props.icon"
|
|
83
|
+
:class="ui.icon({ class: props.ui?.icon })"
|
|
84
|
+
data-part="icon"
|
|
85
|
+
/>
|
|
86
|
+
</slot>
|
|
87
|
+
|
|
88
|
+
<div :class="ui.wrapper({ class: props.ui?.wrapper })" data-part="wrapper">
|
|
89
|
+
<ToastTitle v-if="props.title || !!slots.title" :class="ui.title({ class: props.ui?.title })" data-part="title">
|
|
90
|
+
<slot name="title">
|
|
91
|
+
<component :is="props.title()" v-if="typeof props.title === 'function'" />
|
|
92
|
+
<component :is="props.title" v-else-if="typeof props.title === 'object'" />
|
|
93
|
+
<template v-else>
|
|
94
|
+
{{ props.title }}
|
|
95
|
+
</template>
|
|
96
|
+
</slot>
|
|
97
|
+
</ToastTitle>
|
|
98
|
+
<ToastDescription v-if="props.description || !!slots.description" :class="ui.description({ class: props.ui?.description })" data-part="description">
|
|
99
|
+
<slot name="description">
|
|
100
|
+
<component :is="props.description()" v-if="typeof props.description === 'function'" />
|
|
101
|
+
<component :is="props.description" v-else-if="typeof props.description === 'object'" />
|
|
102
|
+
<template v-else>
|
|
103
|
+
{{ props.description }}
|
|
104
|
+
</template>
|
|
105
|
+
</slot>
|
|
106
|
+
</ToastDescription>
|
|
107
|
+
|
|
108
|
+
<div v-if="props.orientation === 'vertical' && (props.actions?.length || slots.actions)" :class="ui.actions({ class: props.ui?.actions })" data-part="actions">
|
|
109
|
+
<slot name="actions">
|
|
110
|
+
<ToastAction v-for="(action, index) in props.actions" :key="index" :alt-text="action.label || 'Action'" as-child @click.stop>
|
|
111
|
+
<Button size="xs" :color="props.color" v-bind="action" />
|
|
112
|
+
</ToastAction>
|
|
113
|
+
</slot>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
<div
|
|
118
|
+
v-if="props.orientation === 'horizontal' && (props.actions?.length || !!slots.actions) || props.close"
|
|
119
|
+
:class="ui.actions({ class: props.ui?.actions })"
|
|
120
|
+
data-part="actions"
|
|
121
|
+
>
|
|
122
|
+
<template v-if="props.orientation === 'horizontal'">
|
|
123
|
+
<slot name="actions">
|
|
124
|
+
<ToastAction v-for="(action, index) in props.actions" :key="index" :alt-text="action.label || 'Action'" as-child @click.stop>
|
|
125
|
+
<Button size="xs" :color="props.color" v-bind="action" />
|
|
126
|
+
</ToastAction>
|
|
127
|
+
</slot>
|
|
128
|
+
</template>
|
|
129
|
+
|
|
130
|
+
<ToastClose v-if="props.close || !!slots.close" as-child>
|
|
131
|
+
<slot name="close" :ui="ui">
|
|
132
|
+
<Button
|
|
133
|
+
v-if="props.close"
|
|
134
|
+
:icon="props.closeIcon || appConfig.ui.icons.close"
|
|
135
|
+
color="neutral"
|
|
136
|
+
variant="link"
|
|
137
|
+
:aria-label="t('toast.close')"
|
|
138
|
+
v-bind="typeof props.close === 'object' ? props.close : {}"
|
|
139
|
+
:class="ui.close({ class: props.ui?.close })"
|
|
140
|
+
data-part="close"
|
|
141
|
+
@click.stop
|
|
142
|
+
/>
|
|
143
|
+
</slot>
|
|
144
|
+
</ToastClose>
|
|
145
|
+
</div>
|
|
146
|
+
|
|
147
|
+
<Progress
|
|
148
|
+
v-if="props.progress && open && remaining >= 0 && duration"
|
|
149
|
+
:model-value="remaining / duration * 100"
|
|
150
|
+
:color="props.color"
|
|
151
|
+
v-bind="typeof props.progress === 'object' ? props.progress : {}"
|
|
152
|
+
size="sm"
|
|
153
|
+
:class="ui.progress({ class: props.ui?.progress })"
|
|
154
|
+
/>
|
|
155
|
+
</ToastRoot>
|
|
155
156
|
</template>
|