@byyuurin/ui 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/README.md +5 -3
- package/dist/module.json +1 -1
- package/dist/module.mjs +2 -2
- package/dist/runtime/components/Accordion.vue +41 -41
- package/dist/runtime/components/Accordion.vue.d.ts +11 -7
- package/dist/runtime/components/Alert.vue +63 -63
- package/dist/runtime/components/Alert.vue.d.ts +4 -4
- package/dist/runtime/components/App.vue +11 -10
- package/dist/runtime/components/App.vue.d.ts +11 -7
- package/dist/runtime/components/Avatar.vue +29 -29
- package/dist/runtime/components/Avatar.vue.d.ts +4 -3
- package/dist/runtime/components/AvatarGroup.vue +4 -4
- package/dist/runtime/components/AvatarGroup.vue.d.ts +1 -1
- package/dist/runtime/components/Badge.vue +32 -32
- package/dist/runtime/components/Badge.vue.d.ts +2 -2
- package/dist/runtime/components/Breadcrumb.vue +49 -49
- package/dist/runtime/components/Breadcrumb.vue.d.ts +10 -6
- package/dist/runtime/components/Button.vue +52 -51
- package/dist/runtime/components/Button.vue.d.ts +1 -1
- package/dist/runtime/components/Calendar.vue +75 -77
- package/dist/runtime/components/Calendar.vue.d.ts +16 -12
- package/dist/runtime/components/Card.vue +41 -41
- package/dist/runtime/components/Card.vue.d.ts +1 -1
- package/dist/runtime/components/Carousel.vue +85 -66
- package/dist/runtime/components/Carousel.vue.d.ts +14 -10
- package/dist/runtime/components/Checkbox.vue +46 -46
- package/dist/runtime/components/Checkbox.vue.d.ts +4 -3
- package/dist/runtime/components/CheckboxGroup.vue +131 -0
- package/dist/runtime/components/CheckboxGroup.vue.d.ts +93 -0
- package/dist/runtime/components/Chip.vue +15 -15
- package/dist/runtime/components/Chip.vue.d.ts +2 -2
- package/dist/runtime/components/Collapsible.vue +14 -14
- package/dist/runtime/components/Collapsible.vue.d.ts +2 -2
- package/dist/runtime/components/Drawer.vue +76 -76
- package/dist/runtime/components/Drawer.vue.d.ts +6 -6
- package/dist/runtime/components/DropdownMenu.vue +28 -28
- package/dist/runtime/components/DropdownMenu.vue.d.ts +17 -9
- package/dist/runtime/components/DropdownMenuContent.vue +152 -153
- package/dist/runtime/components/DropdownMenuContent.vue.d.ts +11 -7
- package/dist/runtime/components/FieldGroup.vue +3 -3
- package/dist/runtime/components/FieldGroup.vue.d.ts +2 -2
- package/dist/runtime/components/Form.vue +9 -9
- package/dist/runtime/components/Form.vue.d.ts +13 -8
- package/dist/runtime/components/FormField.vue +39 -38
- package/dist/runtime/components/FormField.vue.d.ts +7 -2
- package/dist/runtime/components/Icon.vue +2 -2
- package/dist/runtime/components/Icon.vue.d.ts +1 -1
- package/dist/runtime/components/Input.vue +48 -48
- package/dist/runtime/components/Input.vue.d.ts +16 -12
- package/dist/runtime/components/InputNumber.vue +48 -50
- package/dist/runtime/components/InputNumber.vue.d.ts +128 -129
- package/dist/runtime/components/InputTags.vue +156 -0
- package/dist/runtime/components/InputTags.vue.d.ts +90 -0
- package/dist/runtime/components/Kbd.vue +3 -3
- package/dist/runtime/components/Kbd.vue.d.ts +2 -2
- package/dist/runtime/components/Link.vue +26 -25
- package/dist/runtime/components/Link.vue.d.ts +16 -6
- package/dist/runtime/components/LinkBase.vue +3 -3
- package/dist/runtime/components/LinkBase.vue.d.ts +2 -2
- package/dist/runtime/components/Marquee.vue +38 -0
- package/dist/runtime/components/Marquee.vue.d.ts +54 -0
- package/dist/runtime/components/Modal.vue +74 -74
- package/dist/runtime/components/Modal.vue.d.ts +6 -6
- package/dist/runtime/components/NavigationMenu.vue +243 -234
- package/dist/runtime/components/NavigationMenu.vue.d.ts +53 -14
- package/dist/runtime/components/OverlayProvider.vue +9 -9
- package/dist/runtime/components/Pagination.vue +47 -47
- package/dist/runtime/components/Pagination.vue.d.ts +4 -4
- package/dist/runtime/components/PinInput.vue +23 -23
- package/dist/runtime/components/PinInput.vue.d.ts +14 -10
- package/dist/runtime/components/Popover.vue +22 -22
- package/dist/runtime/components/Popover.vue.d.ts +11 -7
- package/dist/runtime/components/Progress.vue +25 -25
- package/dist/runtime/components/Progress.vue.d.ts +2 -2
- package/dist/runtime/components/RadioGroup.vue +50 -50
- package/dist/runtime/components/RadioGroup.vue.d.ts +13 -9
- package/dist/runtime/components/ScrollArea.vue +32 -32
- package/dist/runtime/components/ScrollArea.vue.d.ts +2 -2
- package/dist/runtime/components/Select.vue +299 -148
- package/dist/runtime/components/Select.vue.d.ts +103 -123
- package/dist/runtime/components/Separator.vue +30 -30
- package/dist/runtime/components/Separator.vue.d.ts +2 -2
- package/dist/runtime/components/Skeleton.vue +11 -11
- package/dist/runtime/components/Skeleton.vue.d.ts +2 -2
- package/dist/runtime/components/Slider.vue +25 -25
- package/dist/runtime/components/Slider.vue.d.ts +11 -7
- package/dist/runtime/components/Stepper.vue +116 -0
- package/dist/runtime/components/Stepper.vue.d.ts +83 -0
- package/dist/runtime/components/Switch.vue +30 -30
- package/dist/runtime/components/Switch.vue.d.ts +4 -3
- package/dist/runtime/components/Table.vue +188 -166
- package/dist/runtime/components/Table.vue.d.ts +27 -22
- package/dist/runtime/components/Tabs.vue +74 -74
- package/dist/runtime/components/Tabs.vue.d.ts +12 -8
- package/dist/runtime/components/Textarea.vue +47 -47
- package/dist/runtime/components/Textarea.vue.d.ts +16 -11
- package/dist/runtime/components/Timeline.vue +102 -0
- package/dist/runtime/components/Timeline.vue.d.ts +78 -0
- package/dist/runtime/components/Toast.vue +93 -93
- package/dist/runtime/components/Toast.vue.d.ts +5 -5
- package/dist/runtime/components/ToastProvider.vue +29 -29
- package/dist/runtime/components/ToastProvider.vue.d.ts +3 -3
- package/dist/runtime/components/Tooltip.vue +24 -25
- package/dist/runtime/components/Tooltip.vue.d.ts +2 -2
- package/dist/runtime/components/Tree.vue +241 -0
- package/dist/runtime/components/Tree.vue.d.ts +121 -0
- package/dist/runtime/composables/defineShortcuts.d.ts +1 -0
- package/dist/runtime/composables/defineShortcuts.js +44 -8
- package/dist/runtime/composables/useLocale.d.ts +12 -0
- package/dist/runtime/locale/en.d.ts +6 -0
- package/dist/runtime/locale/en.js +6 -0
- package/dist/runtime/locale/zh_tw.d.ts +6 -0
- package/dist/runtime/locale/zh_tw.js +6 -0
- package/dist/runtime/types/html.d.ts +8 -0
- package/dist/runtime/types/html.js +0 -0
- package/dist/runtime/types/index.d.ts +7 -0
- package/dist/runtime/types/index.js +7 -0
- package/dist/runtime/types/input.d.ts +5 -5
- package/dist/runtime/types/locale.d.ts +6 -0
- package/dist/runtime/types/unocss.d.ts +4 -4
- package/dist/runtime/types/utils.d.ts +9 -6
- package/dist/runtime/utils/index.d.ts +3 -3
- package/dist/runtime/utils/link.d.ts +2 -1
- package/dist/runtime/utils/link.js +40 -29
- package/dist/runtime/vue/components/Icon.vue +2 -2
- package/dist/runtime/vue/components/Icon.vue.d.ts +1 -1
- package/dist/runtime/vue/components/Link.vue +7 -12
- package/dist/runtime/vue/components/Link.vue.d.ts +11 -40
- package/dist/setup.d.mts +1 -1
- package/dist/shared/{ui.CzIlLITK.mjs → ui.9kQouwss.mjs} +5 -3
- package/dist/shared/{ui.DpbffTXs.d.mts → ui.D8Bg1HWt.d.mts} +2 -0
- package/dist/shared/{ui.DSyJHSTk.mjs → ui.DpkP12cX.mjs} +784 -84
- 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 +29 -29
- package/vue-plugin.d.ts +5 -5
|
@@ -59,97 +59,97 @@ defineExpose({
|
|
|
59
59
|
</script>
|
|
60
60
|
|
|
61
61
|
<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>
|
|
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>
|
|
155
155
|
</template>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { VariantProps } from '@byyuurin/ui-kit';
|
|
2
2
|
import type { PrimitiveProps, ToastRootEmits, ToastRootProps } from 'reka-ui';
|
|
3
3
|
import theme from '#build/ui/toast';
|
|
4
|
-
import type { AvatarProps, ButtonProps, ComponentBaseProps, ComponentStyler, ComponentUIProps, IconProps, ProgressProps } from '../types';
|
|
4
|
+
import type { AvatarProps, ButtonProps, ComponentBaseProps, ComponentStyler, ComponentUIProps, IconProps, LinkPropsKeys, ProgressProps } from '../types';
|
|
5
5
|
import type { StaticSlot, StringOrVNode } from '../types/utils';
|
|
6
6
|
type ThemeVariants = VariantProps<typeof theme>;
|
|
7
7
|
export interface ToastProps extends ComponentBaseProps, Pick<ToastRootProps, 'defaultOpen' | 'open' | 'type' | 'duration'> {
|
|
@@ -28,7 +28,7 @@ export interface ToastProps extends ComponentBaseProps, Pick<ToastRootProps, 'de
|
|
|
28
28
|
* Display a close button to dismiss the toast.
|
|
29
29
|
* @default true
|
|
30
30
|
*/
|
|
31
|
-
close?: boolean |
|
|
31
|
+
close?: boolean | Omit<ButtonProps, LinkPropsKeys>;
|
|
32
32
|
/**
|
|
33
33
|
* The icon displayed in the close button.
|
|
34
34
|
* @default app.icons.close
|
|
@@ -54,6 +54,8 @@ export interface ToastSlots {
|
|
|
54
54
|
ui: ComponentStyler<typeof theme>;
|
|
55
55
|
}>;
|
|
56
56
|
}
|
|
57
|
+
declare const _default: typeof __VLS_export;
|
|
58
|
+
export default _default;
|
|
57
59
|
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<ToastProps, {
|
|
58
60
|
height: import("vue").ShallowRef<number, number>;
|
|
59
61
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
@@ -139,12 +141,10 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<ToastP
|
|
|
139
141
|
};
|
|
140
142
|
}>, "currentTarget">) => any) | undefined;
|
|
141
143
|
}>, {
|
|
142
|
-
close: boolean |
|
|
144
|
+
close: boolean | Omit<ButtonProps, LinkPropsKeys>;
|
|
143
145
|
progress: boolean | Pick<ProgressProps, "color" | "ui">;
|
|
144
146
|
orientation: "horizontal" | "vertical";
|
|
145
147
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, ToastSlots>;
|
|
146
|
-
declare const _default: typeof __VLS_export;
|
|
147
|
-
export default _default;
|
|
148
148
|
type __VLS_WithSlots<T, S> = T & {
|
|
149
149
|
new (): {
|
|
150
150
|
$slots: S;
|
|
@@ -69,17 +69,17 @@ function getOffset(index) {
|
|
|
69
69
|
</script>
|
|
70
70
|
|
|
71
71
|
<template>
|
|
72
|
-
<RekaToastProvider :swipe-direction="swipeDirection" v-bind="providerProps">
|
|
73
|
-
<slot></slot>
|
|
74
|
-
|
|
75
|
-
<Toast
|
|
76
|
-
v-for="(toast, index) of toasts"
|
|
77
|
-
:key="toast.id"
|
|
78
|
-
ref="refs"
|
|
79
|
-
:progress="props.progress"
|
|
80
|
-
v-bind="omit(toast, ['id', 'close'])"
|
|
81
|
-
:data-expanded="expanded"
|
|
82
|
-
:data-front="!expanded && index === toasts.length - 1"
|
|
72
|
+
<RekaToastProvider :swipe-direction="swipeDirection" v-bind="providerProps">
|
|
73
|
+
<slot></slot>
|
|
74
|
+
|
|
75
|
+
<Toast
|
|
76
|
+
v-for="(toast, index) of toasts"
|
|
77
|
+
:key="toast.id"
|
|
78
|
+
ref="refs"
|
|
79
|
+
:progress="props.progress"
|
|
80
|
+
v-bind="omit(toast, ['id', 'close'])"
|
|
81
|
+
:data-expanded="expanded"
|
|
82
|
+
:data-front="!expanded && index === toasts.length - 1"
|
|
83
83
|
:style="{
|
|
84
84
|
'--index': index - toasts.length + toasts.length,
|
|
85
85
|
'--before': toasts.length - 1 - index,
|
|
@@ -87,30 +87,30 @@ function getOffset(index) {
|
|
|
87
87
|
'--scale': expanded ? '1' : 'calc(1 - var(--before) * var(--scale-factor))',
|
|
88
88
|
'--translate': expanded ? 'calc(var(--offset) * var(--translate-factor))' : 'calc(var(--before) * var(--gap))',
|
|
89
89
|
'--transform': 'translateY(var(--translate)) scale(var(--scale))'
|
|
90
|
-
}"
|
|
91
|
-
:class="ui.base({ class: props.ui?.base })"
|
|
92
|
-
data-part="base"
|
|
93
|
-
@update:open="onUpdateOpen($event, toast.id)"
|
|
94
|
-
@click="toast.onClick && toast.onClick(toast)"
|
|
95
|
-
/>
|
|
96
|
-
|
|
97
|
-
<ToastPortal v-bind="portalProps">
|
|
98
|
-
<ToastViewport
|
|
99
|
-
:data-expanded="expanded"
|
|
100
|
-
:class="ui.viewport({ class: [props.ui?.viewport, props.class] })"
|
|
101
|
-
data-part="viewport"
|
|
90
|
+
}"
|
|
91
|
+
:class="ui.base({ class: props.ui?.base })"
|
|
92
|
+
data-part="base"
|
|
93
|
+
@update:open="onUpdateOpen($event, toast.id)"
|
|
94
|
+
@click="toast.onClick && toast.onClick(toast)"
|
|
95
|
+
/>
|
|
96
|
+
|
|
97
|
+
<ToastPortal v-bind="portalProps">
|
|
98
|
+
<ToastViewport
|
|
99
|
+
:data-expanded="expanded"
|
|
100
|
+
:class="ui.viewport({ class: [props.ui?.viewport, props.class] })"
|
|
101
|
+
data-part="viewport"
|
|
102
102
|
:style="{
|
|
103
103
|
'--scale-factor': '0.05',
|
|
104
104
|
'--translate-factor': position?.startsWith('top') ? '1px' : '-1px',
|
|
105
105
|
'--gap': position?.startsWith('top') ? '16px' : '-16px',
|
|
106
106
|
'--front-height': `${frontHeight}px`,
|
|
107
107
|
'--height': `${height}px`
|
|
108
|
-
}"
|
|
109
|
-
@mouseenter="hovered = true"
|
|
110
|
-
@mouseleave="hovered = false"
|
|
111
|
-
/>
|
|
112
|
-
</ToastPortal>
|
|
113
|
-
</RekaToastProvider>
|
|
108
|
+
}"
|
|
109
|
+
@mouseenter="hovered = true"
|
|
110
|
+
@mouseleave="hovered = false"
|
|
111
|
+
/>
|
|
112
|
+
</ToastPortal>
|
|
113
|
+
</RekaToastProvider>
|
|
114
114
|
</template>
|
|
115
115
|
|
|
116
116
|
<style>
|
|
@@ -35,15 +35,15 @@ export interface ToastProviderProps extends ComponentBaseProps, Omit<RekaToastPr
|
|
|
35
35
|
export interface ToasterSlots {
|
|
36
36
|
default: StaticSlot;
|
|
37
37
|
}
|
|
38
|
+
declare const _default: typeof __VLS_export;
|
|
39
|
+
export default _default;
|
|
38
40
|
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<ToastProviderProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ToastProviderProps> & Readonly<{}>, {
|
|
39
41
|
progress: boolean;
|
|
42
|
+
max: number;
|
|
40
43
|
portal: boolean | string | HTMLElement;
|
|
41
44
|
duration: number;
|
|
42
|
-
max: number;
|
|
43
45
|
expand: boolean;
|
|
44
46
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, ToasterSlots>;
|
|
45
|
-
declare const _default: typeof __VLS_export;
|
|
46
|
-
export default _default;
|
|
47
47
|
type __VLS_WithSlots<T, S> = T & {
|
|
48
48
|
new (): {
|
|
49
49
|
$slots: S;
|
|
@@ -41,29 +41,28 @@ const ui = computed(() => {
|
|
|
41
41
|
</script>
|
|
42
42
|
|
|
43
43
|
<template>
|
|
44
|
-
<TooltipRoot v-slot="{ open }" v-bind="rootProps" :disabled="!(props.text || props.kbds?.length || !!slots.content) || props.disabled">
|
|
45
|
-
<TooltipTrigger v-if="!!slots.default" as-child :class="props.class">
|
|
46
|
-
<slot :open="open">
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
</TooltipRoot>
|
|
44
|
+
<TooltipRoot v-slot="{ open }" v-bind="rootProps" :disabled="!(props.text || props.kbds?.length || !!slots.content) || props.disabled">
|
|
45
|
+
<TooltipTrigger v-if="!!slots.default || props.reference" v-bind="$attrs" as-child :reference="props.reference" :class="props.class">
|
|
46
|
+
<slot :open="open"></slot>
|
|
47
|
+
</TooltipTrigger>
|
|
48
|
+
|
|
49
|
+
<TooltipPortal v-bind="portalProps">
|
|
50
|
+
<TooltipContent v-bind="contentProps" :class="ui.content({ class: [props.ui?.content, !slots.default && props.class] })" data-part="content">
|
|
51
|
+
<slot name="content" :ui="ui">
|
|
52
|
+
<span v-if="props.text" :class="ui.text({ class: props.ui?.text })" data-part="text">{{ props.text }}</span>
|
|
53
|
+
|
|
54
|
+
<span v-if="props.kbds?.length" :class="ui.kbds({ class: props.ui?.kbds })" data-part="kbds">
|
|
55
|
+
<Kbd
|
|
56
|
+
v-for="(kbd, index) in props.kbds"
|
|
57
|
+
:key="index"
|
|
58
|
+
:size="props.ui?.kbdsSize || ui.kbdsSize()"
|
|
59
|
+
v-bind="typeof kbd === 'string' ? { value: kbd } : kbd"
|
|
60
|
+
/>
|
|
61
|
+
</span>
|
|
62
|
+
</slot>
|
|
63
|
+
|
|
64
|
+
<TooltipArrow v-if="props.arrow" v-bind="arrowProps" :class="ui.arrow({ class: props.ui?.arrow })" data-part="arrow" />
|
|
65
|
+
</TooltipContent>
|
|
66
|
+
</TooltipPortal>
|
|
67
|
+
</TooltipRoot>
|
|
69
68
|
</template>
|
|
@@ -37,6 +37,8 @@ export interface TooltipSlots {
|
|
|
37
37
|
ui: ComponentStyler<typeof theme>;
|
|
38
38
|
}>;
|
|
39
39
|
}
|
|
40
|
+
declare const _default: typeof __VLS_export;
|
|
41
|
+
export default _default;
|
|
40
42
|
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<TooltipProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
41
43
|
"update:open": (value: boolean) => any;
|
|
42
44
|
}, string, import("vue").PublicProps, Readonly<TooltipProps> & Readonly<{
|
|
@@ -44,8 +46,6 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<Toolti
|
|
|
44
46
|
}>, {
|
|
45
47
|
portal: boolean | string | HTMLElement;
|
|
46
48
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, TooltipSlots>;
|
|
47
|
-
declare const _default: typeof __VLS_export;
|
|
48
|
-
export default _default;
|
|
49
49
|
type __VLS_WithSlots<T, S> = T & {
|
|
50
50
|
new (): {
|
|
51
51
|
$slots: S;
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import theme from "#build/ui/tree";
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script setup>
|
|
6
|
+
import { createReusableTemplate, reactivePick } from "@vueuse/core";
|
|
7
|
+
import { defu } from "defu";
|
|
8
|
+
import { TreeItem, TreeRoot, useForwardPropsEmits } from "reka-ui";
|
|
9
|
+
import { computed, shallowRef } from "vue";
|
|
10
|
+
import { useAppConfig } from "#imports";
|
|
11
|
+
import { get } from "../utils";
|
|
12
|
+
import { cv, merge } from "../utils/style";
|
|
13
|
+
import Icon from "./Icon.vue";
|
|
14
|
+
defineOptions({ inheritAttrs: false });
|
|
15
|
+
const props = defineProps({
|
|
16
|
+
as: { type: null, required: false },
|
|
17
|
+
color: { type: null, required: false },
|
|
18
|
+
size: { type: null, required: false },
|
|
19
|
+
getKey: { type: Function, required: false },
|
|
20
|
+
labelKey: { type: null, required: false, default: "label" },
|
|
21
|
+
trailingIcon: { type: [String, Object], required: false },
|
|
22
|
+
expandedIcon: { type: [String, Object], required: false },
|
|
23
|
+
collapsedIcon: { type: [String, Object], required: false },
|
|
24
|
+
items: { type: null, required: false },
|
|
25
|
+
modelValue: { type: null, required: false },
|
|
26
|
+
defaultValue: { type: null, required: false },
|
|
27
|
+
multiple: { type: Boolean, required: false },
|
|
28
|
+
nested: { type: Boolean, required: false, default: true },
|
|
29
|
+
onSelect: { type: Function, required: false },
|
|
30
|
+
onToggle: { type: Function, required: false },
|
|
31
|
+
ui: { type: null, required: false },
|
|
32
|
+
class: { type: [Object, String, Number, Boolean, null, Array], required: false, skipCheck: true },
|
|
33
|
+
expanded: { type: Array, required: false },
|
|
34
|
+
defaultExpanded: { type: Array, required: false },
|
|
35
|
+
selectionBehavior: { type: String, required: false },
|
|
36
|
+
propagateSelect: { type: Boolean, required: false },
|
|
37
|
+
disabled: { type: Boolean, required: false },
|
|
38
|
+
bubbleSelect: { type: Boolean, required: false }
|
|
39
|
+
});
|
|
40
|
+
const emit = defineEmits(["update:modelValue", "update:expanded"]);
|
|
41
|
+
const slots = defineSlots();
|
|
42
|
+
const rootProps = useForwardPropsEmits(reactivePick(props, "items", "expanded", "disabled", "propagateSelect", "bubbleSelect"), emit);
|
|
43
|
+
const as = computed(() => {
|
|
44
|
+
if (typeof props.as === "string" || props.as && "render" in props.as && typeof props.as?.render === "function")
|
|
45
|
+
return { root: props.as, link: "button" };
|
|
46
|
+
return defu(props.as, { root: "ul", link: "button" });
|
|
47
|
+
});
|
|
48
|
+
const flattenedPaddingFormula = computed(() => {
|
|
49
|
+
const sizeConfig = {
|
|
50
|
+
xs: { base: 2, perLevel: 5.5 },
|
|
51
|
+
// px-2, ms-4 + ps-1.5
|
|
52
|
+
sm: { base: 2.5, perLevel: 6 },
|
|
53
|
+
// px-2.5, ms-4.5 + ps-1.5
|
|
54
|
+
md: { base: 2.5, perLevel: 6.5 },
|
|
55
|
+
// px-2.5, ms-5 + ps-1.5
|
|
56
|
+
lg: { base: 3, perLevel: 7 },
|
|
57
|
+
// px-3, ms-5.5 + ps-1.5
|
|
58
|
+
xl: { base: 3, perLevel: 7.5 }
|
|
59
|
+
// px-3, ms-6 + ps-1.5
|
|
60
|
+
};
|
|
61
|
+
const config = sizeConfig[props.size || "md"];
|
|
62
|
+
return (level) => `calc(var(--spacing) * ${(level - 1) * config.perLevel + config.base})`;
|
|
63
|
+
});
|
|
64
|
+
const { define: DefineTreeTemplate, reuse: ReuseTreeTemplate } = createReusableTemplate();
|
|
65
|
+
const { define: DefineItemTemplate, reuse: ReuseItemTemplate } = createReusableTemplate({
|
|
66
|
+
props: {
|
|
67
|
+
item: {
|
|
68
|
+
type: Object,
|
|
69
|
+
required: true
|
|
70
|
+
},
|
|
71
|
+
index: {
|
|
72
|
+
type: Number,
|
|
73
|
+
required: true
|
|
74
|
+
},
|
|
75
|
+
level: {
|
|
76
|
+
type: Number,
|
|
77
|
+
required: true
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
const rootRef = shallowRef();
|
|
82
|
+
function getItemLabel(item) {
|
|
83
|
+
return get(item, props.labelKey);
|
|
84
|
+
}
|
|
85
|
+
function getItemKey(item) {
|
|
86
|
+
return props.getKey ? props.getKey(item) || getItemLabel(item) : getItemLabel(item);
|
|
87
|
+
}
|
|
88
|
+
function getDefaultOpenedItems(item) {
|
|
89
|
+
const currentItem = item.defaultExpanded ? getItemKey(item) : null;
|
|
90
|
+
const childItems = item.children?.flatMap((child) => getDefaultOpenedItems(child)) ?? [];
|
|
91
|
+
return [currentItem, ...childItems].filter(Boolean);
|
|
92
|
+
}
|
|
93
|
+
const appConfig = useAppConfig();
|
|
94
|
+
const ui = computed(() => {
|
|
95
|
+
const styler = cv(merge(theme, appConfig.ui.tree));
|
|
96
|
+
return styler(props);
|
|
97
|
+
});
|
|
98
|
+
const defaultExpanded = computed(() => props.defaultExpanded ?? props.items?.flatMap((item) => getDefaultOpenedItems(item)));
|
|
99
|
+
defineExpose({
|
|
100
|
+
get $el() {
|
|
101
|
+
return rootRef.value?.$el;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
function onUpdate(value) {
|
|
105
|
+
emit("update:modelValue", props.multiple && !Array.isArray(value) ? [value] : value);
|
|
106
|
+
}
|
|
107
|
+
</script>
|
|
108
|
+
|
|
109
|
+
<template>
|
|
110
|
+
<DefineItemTemplate v-slot="{ item, index, level }">
|
|
111
|
+
<li
|
|
112
|
+
role="presentation"
|
|
113
|
+
:class="props.nested && level > 1 ? ui.itemWithChildren({ class: [props.ui?.itemWithChildren, item.ui?.itemWithChildren] }) : ui.item({ class: [props.ui?.item, item.ui?.item] })"
|
|
114
|
+
:data-part="props.nested && level > 1 ? 'itemWithChildren' : 'item'"
|
|
115
|
+
>
|
|
116
|
+
<TreeItem
|
|
117
|
+
v-slot="{ isExpanded, isSelected, isIndeterminate, handleSelect, handleToggle }"
|
|
118
|
+
:level="level"
|
|
119
|
+
:value="item"
|
|
120
|
+
as-child
|
|
121
|
+
@toggle="(item.onToggle ?? props.onToggle)?.($event, item)"
|
|
122
|
+
@select="(item.onSelect ?? props.onSelect)?.($event, item)"
|
|
123
|
+
>
|
|
124
|
+
<slot
|
|
125
|
+
:name="`${item.slot ?? 'item'}-wrapper`"
|
|
126
|
+
v-bind="{ index, level, expanded: isExpanded, selected: isSelected, indeterminate: isIndeterminate, handleSelect, handleToggle, ui }"
|
|
127
|
+
:item="item"
|
|
128
|
+
>
|
|
129
|
+
<component
|
|
130
|
+
:is="as.link"
|
|
131
|
+
:type="as.link === 'button' ? 'button' : void 0"
|
|
132
|
+
:disabled="item.disabled || props.disabled"
|
|
133
|
+
:class="ui.link({ class: [props.ui?.link, item.ui?.link, item.class], selected: isSelected, disabled: item.disabled || props.disabled })"
|
|
134
|
+
data-part="link"
|
|
135
|
+
:style="!props.nested && level > 1 ? { paddingLeft: flattenedPaddingFormula(level) } : void 0"
|
|
136
|
+
>
|
|
137
|
+
<slot
|
|
138
|
+
:name="item.slot || 'item'"
|
|
139
|
+
v-bind="{ index, level, expanded: isExpanded, selected: isSelected, indeterminate: isIndeterminate, handleSelect, handleToggle, ui }"
|
|
140
|
+
:item="item"
|
|
141
|
+
>
|
|
142
|
+
<slot
|
|
143
|
+
:name="`${item.slot || 'item'}-leading`"
|
|
144
|
+
v-bind="{ index, level, expanded: isExpanded, selected: isSelected, indeterminate: isIndeterminate, handleSelect, handleToggle, ui }"
|
|
145
|
+
:item="item"
|
|
146
|
+
>
|
|
147
|
+
<Icon
|
|
148
|
+
v-if="item.icon"
|
|
149
|
+
:name="item.icon"
|
|
150
|
+
:class="ui.linkLeadingIcon({ class: [props.ui?.linkLeadingIcon, item.ui?.linkLeadingIcon] })"
|
|
151
|
+
data-part="linkLeadingIcon"
|
|
152
|
+
/>
|
|
153
|
+
<Icon
|
|
154
|
+
v-else-if="item.children?.length"
|
|
155
|
+
:name="isExpanded ? props.expandedIcon ?? appConfig.ui.icons.folderOpen : props.collapsedIcon ?? appConfig.ui.icons.folder"
|
|
156
|
+
:class="ui.linkLeadingIcon({ class: [props.ui?.linkLeadingIcon, item.ui?.linkLeadingIcon] })"
|
|
157
|
+
data-part="linkLeadingIcon"
|
|
158
|
+
/>
|
|
159
|
+
</slot>
|
|
160
|
+
|
|
161
|
+
<span v-if="getItemLabel(item) || slots[`${item.slot || 'item'}-label`]" :class="ui.linkLabel({ class: [props.ui?.linkLabel, item.ui?.linkLabel] })" data-part="linkLabel">
|
|
162
|
+
<slot
|
|
163
|
+
:name="`${item.slot || 'item'}-label`"
|
|
164
|
+
v-bind="{ index, level, expanded: isExpanded, selected: isSelected, indeterminate: isIndeterminate, handleSelect, handleToggle, ui }"
|
|
165
|
+
:item="item"
|
|
166
|
+
>
|
|
167
|
+
{{ getItemLabel(item) }}
|
|
168
|
+
</slot>
|
|
169
|
+
</span>
|
|
170
|
+
|
|
171
|
+
<span
|
|
172
|
+
v-if="item.trailingIcon || item.children?.length || slots[`${item.slot || 'item'}-trailing`]"
|
|
173
|
+
:class="ui.linkTrailing({ class: [props.ui?.linkTrailing, item.ui?.linkTrailing] })"
|
|
174
|
+
data-part="linkTrailing"
|
|
175
|
+
>
|
|
176
|
+
<slot
|
|
177
|
+
:name="`${item.slot || 'item'}-trailing`"
|
|
178
|
+
v-bind="{ index, level, expanded: isExpanded, selected: isSelected, indeterminate: isIndeterminate, handleSelect, handleToggle, ui }"
|
|
179
|
+
:item="item"
|
|
180
|
+
>
|
|
181
|
+
<Icon
|
|
182
|
+
v-if="item.trailingIcon"
|
|
183
|
+
:name="item.trailingIcon"
|
|
184
|
+
:class="ui.linkTrailingIcon({ class: [props.trailingIcon, item.ui?.linkTrailingIcon] })"
|
|
185
|
+
data-part="linkTrailingIcon"
|
|
186
|
+
/>
|
|
187
|
+
<Icon
|
|
188
|
+
v-else-if="item.children?.length"
|
|
189
|
+
:name="props.trailingIcon ?? appConfig.ui.icons.chevronDown"
|
|
190
|
+
:class="ui.linkTrailingIcon({ class: [props.ui?.linkTrailingIcon, item.ui?.linkTrailingIcon] })"
|
|
191
|
+
data-part="linkTrailingIcon"
|
|
192
|
+
/>
|
|
193
|
+
</slot>
|
|
194
|
+
</span>
|
|
195
|
+
</slot>
|
|
196
|
+
</component>
|
|
197
|
+
</slot>
|
|
198
|
+
|
|
199
|
+
<ul
|
|
200
|
+
v-if="props.nested && item.children?.length && isExpanded"
|
|
201
|
+
role="group"
|
|
202
|
+
:class="ui.listWithChildren({ class: [props.ui?.listWithChildren, item.ui?.listWithChildren] })"
|
|
203
|
+
data-part="listWithChildren"
|
|
204
|
+
>
|
|
205
|
+
<ReuseTreeTemplate :items="item.children" :level="level + 1" />
|
|
206
|
+
</ul>
|
|
207
|
+
</TreeItem>
|
|
208
|
+
</li>
|
|
209
|
+
</DefineItemTemplate>
|
|
210
|
+
|
|
211
|
+
<DefineTreeTemplate v-slot="{ items, level }">
|
|
212
|
+
<ReuseItemTemplate v-for="(item, index) in items" :key="`${level}-${index}`" :item="item" :index="index" :level="level" />
|
|
213
|
+
</DefineTreeTemplate>
|
|
214
|
+
|
|
215
|
+
<TreeRoot
|
|
216
|
+
ref="rootRef"
|
|
217
|
+
v-slot="{ flattenItems }"
|
|
218
|
+
v-bind="{ ...rootProps, ...$attrs }"
|
|
219
|
+
:as="as.root"
|
|
220
|
+
:model-value="props.modelValue"
|
|
221
|
+
:default-value="props.defaultValue"
|
|
222
|
+
:get-key="getItemKey"
|
|
223
|
+
:default-expanded="defaultExpanded"
|
|
224
|
+
:selection-behavior="props.selectionBehavior"
|
|
225
|
+
:multiple="props.multiple"
|
|
226
|
+
:class="ui.root({ class: [props.ui?.root, props.class] })"
|
|
227
|
+
data-part="root"
|
|
228
|
+
@update:model-value="onUpdate"
|
|
229
|
+
>
|
|
230
|
+
<template v-if="!props.nested">
|
|
231
|
+
<ReuseItemTemplate
|
|
232
|
+
v-for="(item, index) in flattenItems"
|
|
233
|
+
:key="item._id"
|
|
234
|
+
:item="item.value"
|
|
235
|
+
:index="index"
|
|
236
|
+
:level="item.level"
|
|
237
|
+
/>
|
|
238
|
+
</template>
|
|
239
|
+
<ReuseTreeTemplate v-else :items="props.items" :level="1" />
|
|
240
|
+
</TreeRoot>
|
|
241
|
+
</template>
|