@nuxt/ui 0.4.1 → 2.8.1
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.md +9 -0
- package/README.md +63 -50
- package/dist/module.cjs +5 -0
- package/dist/module.d.mts +1234 -0
- package/dist/module.d.ts +1234 -0
- package/dist/module.json +8 -0
- package/dist/module.mjs +407 -0
- package/dist/runtime/app.config.d.ts +1203 -0
- package/dist/runtime/app.config.mjs +1057 -0
- package/dist/runtime/components/data/Table.vue +251 -0
- package/dist/runtime/components/data/Table.vue.d.ts +215 -0
- package/dist/runtime/components/elements/Accordion.vue +138 -0
- package/dist/runtime/components/elements/Accordion.vue.d.ts +80 -0
- package/dist/runtime/components/elements/Alert.vue +120 -0
- package/dist/runtime/components/elements/Alert.vue.d.ts +107 -0
- package/dist/runtime/components/elements/Avatar.vue +149 -0
- package/dist/runtime/components/elements/Avatar.vue.d.ts +115 -0
- package/dist/runtime/components/elements/AvatarGroup.d.ts +37 -0
- package/dist/runtime/components/elements/AvatarGroup.mjs +53 -0
- package/dist/runtime/components/elements/Badge.vue +69 -0
- package/dist/runtime/components/elements/Badge.vue.d.ts +63 -0
- package/dist/runtime/components/elements/Button.vue +182 -0
- package/dist/runtime/components/elements/Button.vue.d.ts +187 -0
- package/dist/runtime/components/elements/ButtonGroup.d.ts +39 -0
- package/dist/runtime/components/elements/ButtonGroup.mjs +70 -0
- package/dist/runtime/components/elements/Dropdown.vue +172 -0
- package/dist/runtime/components/elements/Dropdown.vue.d.ts +96 -0
- package/dist/runtime/components/elements/Icon.vue +15 -0
- package/dist/runtime/components/elements/Icon.vue.d.ts +12 -0
- package/dist/runtime/components/elements/Kbd.vue +55 -0
- package/dist/runtime/components/elements/Kbd.vue.d.ts +42 -0
- package/dist/runtime/components/elements/Link.vue +80 -0
- package/dist/runtime/components/elements/Link.vue.d.ts +9 -0
- package/dist/runtime/components/forms/Checkbox.vue +136 -0
- package/dist/runtime/components/forms/Checkbox.vue.d.ts +129 -0
- package/dist/runtime/components/forms/Form.vue +185 -0
- package/dist/runtime/components/forms/Form.vue.d.ts +50 -0
- package/dist/runtime/components/forms/FormGroup.vue +97 -0
- package/dist/runtime/components/forms/FormGroup.vue.d.ts +98 -0
- package/dist/runtime/components/forms/Input.vue +250 -0
- package/dist/runtime/components/forms/Input.vue.d.ts +214 -0
- package/dist/runtime/components/forms/Radio.vue +122 -0
- package/dist/runtime/components/forms/Radio.vue.d.ts +109 -0
- package/dist/runtime/components/forms/Range.vue +163 -0
- package/dist/runtime/components/forms/Range.vue.d.ts +119 -0
- package/dist/runtime/components/forms/Select.vue +307 -0
- package/dist/runtime/components/forms/Select.vue.d.ts +229 -0
- package/dist/runtime/components/forms/SelectMenu.vue +429 -0
- package/dist/runtime/components/forms/SelectMenu.vue.d.ts +330 -0
- package/dist/runtime/components/forms/Textarea.vue +184 -0
- package/dist/runtime/components/forms/Textarea.vue.d.ts +161 -0
- package/dist/runtime/components/forms/Toggle.vue +113 -0
- package/dist/runtime/components/forms/Toggle.vue.d.ts +83 -0
- package/dist/runtime/components/layout/Card.vue +58 -0
- package/dist/runtime/components/layout/Card.vue.d.ts +31 -0
- package/dist/runtime/components/layout/Container.vue +43 -0
- package/dist/runtime/components/layout/Container.vue.d.ts +31 -0
- package/dist/runtime/components/layout/Skeleton.vue +37 -0
- package/dist/runtime/components/layout/Skeleton.vue.d.ts +22 -0
- package/dist/runtime/components/navigation/CommandPalette.vue +304 -0
- package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +224 -0
- package/dist/runtime/components/navigation/CommandPaletteGroup.vue +152 -0
- package/dist/runtime/components/navigation/CommandPaletteGroup.vue.d.ts +63 -0
- package/dist/runtime/components/navigation/Pagination.vue +197 -0
- package/dist/runtime/components/navigation/Pagination.vue.d.ts +125 -0
- package/dist/runtime/components/navigation/Tabs.vue +138 -0
- package/dist/runtime/components/navigation/Tabs.vue.d.ts +69 -0
- package/dist/runtime/components/navigation/VerticalNavigation.vue +79 -0
- package/dist/runtime/components/navigation/VerticalNavigation.vue.d.ts +37 -0
- package/dist/runtime/components/overlays/ContextMenu.vue +74 -0
- package/dist/runtime/components/overlays/ContextMenu.vue.d.ts +54 -0
- package/dist/runtime/components/overlays/Modal.vue +113 -0
- package/dist/runtime/components/overlays/Modal.vue.d.ts +82 -0
- package/dist/runtime/components/overlays/Notification.vue +197 -0
- package/dist/runtime/components/overlays/Notification.vue.d.ts +126 -0
- package/dist/runtime/components/overlays/Notifications.vue +61 -0
- package/dist/runtime/components/overlays/Notifications.vue.d.ts +41 -0
- package/dist/runtime/components/overlays/Popover.vue +139 -0
- package/dist/runtime/components/overlays/Popover.vue.d.ts +82 -0
- package/dist/runtime/components/overlays/Slideover.vue +103 -0
- package/dist/runtime/components/overlays/Slideover.vue.d.ts +84 -0
- package/dist/runtime/components/overlays/Tooltip.vue +118 -0
- package/dist/runtime/components/overlays/Tooltip.vue.d.ts +82 -0
- package/dist/runtime/composables/defineShortcuts.d.ts +13 -0
- package/dist/runtime/composables/defineShortcuts.mjs +108 -0
- package/dist/runtime/composables/useCopyToClipboard.d.ts +10 -0
- package/dist/runtime/composables/useCopyToClipboard.mjs +26 -0
- package/dist/runtime/composables/useFormGroup.d.ts +6 -0
- package/dist/runtime/composables/useFormGroup.mjs +30 -0
- package/dist/runtime/composables/usePopper.d.ts +232 -0
- package/dist/runtime/composables/usePopper.mjs +78 -0
- package/dist/runtime/composables/useShortcuts.d.ts +12 -0
- package/dist/runtime/composables/useShortcuts.mjs +24 -0
- package/dist/runtime/composables/useTimer.d.ts +8 -0
- package/dist/runtime/composables/useTimer.mjs +51 -0
- package/dist/runtime/composables/useToast.d.ts +18 -0
- package/dist/runtime/composables/useToast.mjs +22 -0
- package/dist/runtime/plugins/colors.d.ts +2 -0
- package/dist/runtime/plugins/colors.mjs +46 -0
- package/dist/runtime/types/accordion.d.ts +9 -0
- package/dist/runtime/types/avatar.d.ts +9 -0
- package/dist/runtime/types/button.d.ts +23 -0
- package/dist/runtime/types/clipboard.d.ts +3 -0
- package/dist/runtime/types/command-palette.d.ts +26 -0
- package/dist/runtime/types/dropdown.d.ts +13 -0
- package/dist/runtime/types/form.d.ts +21 -0
- package/dist/runtime/types/index.d.ts +12 -0
- package/dist/runtime/types/link.d.ts +8 -0
- package/dist/runtime/types/notification.d.ts +22 -0
- package/dist/runtime/types/popper.d.ts +14 -0
- package/dist/runtime/types/tabs.d.ts +6 -0
- package/dist/runtime/types/vertical-navigation.d.ts +11 -0
- package/dist/runtime/ui.css +13 -0
- package/dist/runtime/utils/StateEmitter.d.ts +17 -0
- package/dist/runtime/utils/StateEmitter.mjs +21 -0
- package/dist/runtime/utils/index.d.ts +11 -0
- package/dist/runtime/utils/index.mjs +33 -0
- package/dist/types.d.mts +15 -0
- package/dist/types.d.ts +15 -0
- package/package.json +56 -39
- package/LICENSE +0 -21
- package/dist/assets/styles.css +0 -14
- package/dist/components/NButton.vue +0 -22
- package/dist/components/NCard.vue +0 -5
- package/dist/components/NCheckbox.vue +0 -35
- package/dist/components/NDarkToggle.vue +0 -28
- package/dist/components/NDialog.vue +0 -59
- package/dist/components/NDropdown.vue +0 -31
- package/dist/components/NIcon.vue +0 -9
- package/dist/components/NLink.vue +0 -20
- package/dist/components/NRadio.vue +0 -40
- package/dist/components/NSwitch.vue +0 -37
- package/dist/components/NTextInput.vue +0 -34
- package/dist/components/NTip.vue +0 -16
- package/dist/components/NuxtContentLogo.vue +0 -7
- package/dist/components/NuxtExampleLayout.vue +0 -82
- package/dist/components/NuxtLogo.vue +0 -20
- package/dist/components/nuxt/NDarkToggle.vue +0 -28
- package/dist/nuxt.d.ts +0 -16
- package/dist/nuxt.mjs +0 -36
- package/dist/unocss.d.ts +0 -7
- package/dist/unocss.mjs +0 -127
- package/nuxt.cjs +0 -7
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="wrapperClass" v-bind="attrs">
|
|
3
|
+
<div v-if="notifications.length" :class="ui.container">
|
|
4
|
+
<div v-for="notification of notifications" :key="notification.id">
|
|
5
|
+
<UNotification
|
|
6
|
+
v-bind="notification"
|
|
7
|
+
:class="notification.click && 'cursor-pointer'"
|
|
8
|
+
@click="notification.click && notification.click(notification)"
|
|
9
|
+
@close="toast.remove(notification.id)"
|
|
10
|
+
>
|
|
11
|
+
<template v-for="(_, name) in $slots" #[name]="slotData">
|
|
12
|
+
<slot :name="name" v-bind="slotData" />
|
|
13
|
+
</template>
|
|
14
|
+
</UNotification>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script>
|
|
21
|
+
import { computed, defineComponent } from "vue";
|
|
22
|
+
import { omit } from "lodash-es";
|
|
23
|
+
import { twMerge, twJoin } from "tailwind-merge";
|
|
24
|
+
import UNotification from "./Notification.vue";
|
|
25
|
+
import { useToast } from "../../composables/useToast";
|
|
26
|
+
import { defuTwMerge } from "../../utils";
|
|
27
|
+
import { useState, useAppConfig } from "#imports";
|
|
28
|
+
export default defineComponent({
|
|
29
|
+
components: {
|
|
30
|
+
UNotification
|
|
31
|
+
},
|
|
32
|
+
inheritAttrs: false,
|
|
33
|
+
props: {
|
|
34
|
+
ui: {
|
|
35
|
+
type: Object,
|
|
36
|
+
default: () => ({})
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
setup(props, { attrs }) {
|
|
40
|
+
const appConfig2 = useAppConfig();
|
|
41
|
+
const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.notifications));
|
|
42
|
+
const toast = useToast();
|
|
43
|
+
const notifications = useState("notifications", () => []);
|
|
44
|
+
const wrapperClass = computed(() => {
|
|
45
|
+
return twMerge(twJoin(
|
|
46
|
+
ui.value.wrapper,
|
|
47
|
+
ui.value.position,
|
|
48
|
+
ui.value.width
|
|
49
|
+
), attrs.class);
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
attrs: omit(attrs, ["class"]),
|
|
53
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
54
|
+
ui,
|
|
55
|
+
toast,
|
|
56
|
+
notifications,
|
|
57
|
+
wrapperClass
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
</script>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
import type { PropType } from 'vue';
|
|
3
|
+
import type { Notification } from '../../types/notification';
|
|
4
|
+
declare const _default: import("vue").DefineComponent<{
|
|
5
|
+
ui: {
|
|
6
|
+
type: PropType<any>;
|
|
7
|
+
default: () => {};
|
|
8
|
+
};
|
|
9
|
+
}, {
|
|
10
|
+
attrs: import("lodash").Omit<{
|
|
11
|
+
[x: string]: unknown;
|
|
12
|
+
}, "class">;
|
|
13
|
+
ui: import("vue").ComputedRef<any>;
|
|
14
|
+
toast: {
|
|
15
|
+
add: (notification: Partial<Notification>) => {
|
|
16
|
+
id: string;
|
|
17
|
+
title?: string | undefined;
|
|
18
|
+
description?: string | undefined;
|
|
19
|
+
icon?: string | undefined;
|
|
20
|
+
avatar?: import("../../types/avatar").Avatar | undefined;
|
|
21
|
+
closeButton?: import("../../types/button").Button | undefined;
|
|
22
|
+
timeout?: number | undefined;
|
|
23
|
+
actions?: import("../../types/notification").NotificationAction[] | undefined;
|
|
24
|
+
click?: Function | undefined;
|
|
25
|
+
callback?: Function | undefined;
|
|
26
|
+
color?: string | undefined;
|
|
27
|
+
ui?: any;
|
|
28
|
+
};
|
|
29
|
+
remove: (id: string) => void;
|
|
30
|
+
};
|
|
31
|
+
notifications: any;
|
|
32
|
+
wrapperClass: import("vue").ComputedRef<string>;
|
|
33
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
34
|
+
ui: {
|
|
35
|
+
type: PropType<any>;
|
|
36
|
+
default: () => {};
|
|
37
|
+
};
|
|
38
|
+
}>>, {
|
|
39
|
+
ui: any;
|
|
40
|
+
}, {}>;
|
|
41
|
+
export default _default;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<HPopover ref="popover" v-slot="{ open, close }" :class="wrapperClass" v-bind="attrs" @mouseleave="onMouseLeave">
|
|
3
|
+
<HPopoverButton
|
|
4
|
+
ref="trigger"
|
|
5
|
+
as="div"
|
|
6
|
+
:disabled="disabled"
|
|
7
|
+
class="inline-flex w-full"
|
|
8
|
+
role="button"
|
|
9
|
+
@mouseover="onMouseOver"
|
|
10
|
+
>
|
|
11
|
+
<slot :open="open" :close="close">
|
|
12
|
+
<button :disabled="disabled">
|
|
13
|
+
Open
|
|
14
|
+
</button>
|
|
15
|
+
</slot>
|
|
16
|
+
</HPopoverButton>
|
|
17
|
+
|
|
18
|
+
<div v-if="open" ref="container" :class="[ui.container, ui.width]" :style="containerStyle" @mouseover="onMouseOver">
|
|
19
|
+
<Transition appear v-bind="ui.transition">
|
|
20
|
+
<HPopoverPanel :class="[ui.base, ui.background, ui.ring, ui.rounded, ui.shadow]" static>
|
|
21
|
+
<slot name="panel" :open="open" :close="close" />
|
|
22
|
+
</HPopoverPanel>
|
|
23
|
+
</Transition>
|
|
24
|
+
</div>
|
|
25
|
+
</HPopover>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script>
|
|
29
|
+
import { computed, ref, onMounted, defineComponent } from "vue";
|
|
30
|
+
import { defu } from "defu";
|
|
31
|
+
import { omit } from "lodash-es";
|
|
32
|
+
import { twMerge } from "tailwind-merge";
|
|
33
|
+
import { Popover as HPopover, PopoverButton as HPopoverButton, PopoverPanel as HPopoverPanel } from "@headlessui/vue";
|
|
34
|
+
import { usePopper } from "../../composables/usePopper";
|
|
35
|
+
import { defuTwMerge } from "../../utils";
|
|
36
|
+
import { useAppConfig } from "#imports";
|
|
37
|
+
export default defineComponent({
|
|
38
|
+
components: {
|
|
39
|
+
HPopover,
|
|
40
|
+
HPopoverButton,
|
|
41
|
+
HPopoverPanel
|
|
42
|
+
},
|
|
43
|
+
inheritAttrs: false,
|
|
44
|
+
props: {
|
|
45
|
+
mode: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: "click",
|
|
48
|
+
validator: (value) => ["click", "hover"].includes(value)
|
|
49
|
+
},
|
|
50
|
+
disabled: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: false
|
|
53
|
+
},
|
|
54
|
+
openDelay: {
|
|
55
|
+
type: Number,
|
|
56
|
+
default: 0
|
|
57
|
+
},
|
|
58
|
+
closeDelay: {
|
|
59
|
+
type: Number,
|
|
60
|
+
default: 0
|
|
61
|
+
},
|
|
62
|
+
popper: {
|
|
63
|
+
type: Object,
|
|
64
|
+
default: () => ({})
|
|
65
|
+
},
|
|
66
|
+
ui: {
|
|
67
|
+
type: Object,
|
|
68
|
+
default: () => ({})
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
setup(props, { attrs }) {
|
|
72
|
+
const appConfig2 = useAppConfig();
|
|
73
|
+
const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.popover));
|
|
74
|
+
const popper = computed(() => defu(props.mode === "hover" ? { offsetDistance: 0 } : {}, props.popper, ui.value.popper));
|
|
75
|
+
const [trigger, container] = usePopper(popper.value);
|
|
76
|
+
const popover = ref(null);
|
|
77
|
+
const popoverApi = ref(null);
|
|
78
|
+
let openTimeout = null;
|
|
79
|
+
let closeTimeout = null;
|
|
80
|
+
onMounted(() => {
|
|
81
|
+
const popoverProvides = popover.value?.$.provides;
|
|
82
|
+
if (!popoverProvides) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const popoverProvidesSymbols = Object.getOwnPropertySymbols(popoverProvides);
|
|
86
|
+
popoverApi.value = popoverProvidesSymbols.length && popoverProvides[popoverProvidesSymbols[0]];
|
|
87
|
+
});
|
|
88
|
+
const containerStyle = computed(() => {
|
|
89
|
+
const offsetDistance = props.popper?.offsetDistance || ui.value.popper?.offsetDistance || 8;
|
|
90
|
+
return props.mode === "hover" ? { paddingTop: `${offsetDistance}px`, paddingBottom: `${offsetDistance}px` } : {};
|
|
91
|
+
});
|
|
92
|
+
const wrapperClass = computed(() => twMerge(ui.value.wrapper, attrs.class));
|
|
93
|
+
function onMouseOver() {
|
|
94
|
+
if (props.mode !== "hover" || !popoverApi.value) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (closeTimeout) {
|
|
98
|
+
clearTimeout(closeTimeout);
|
|
99
|
+
closeTimeout = null;
|
|
100
|
+
}
|
|
101
|
+
if (popoverApi.value.popoverState === 0) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
openTimeout = openTimeout || setTimeout(() => {
|
|
105
|
+
popoverApi.value.togglePopover && popoverApi.value.togglePopover();
|
|
106
|
+
openTimeout = null;
|
|
107
|
+
}, props.openDelay);
|
|
108
|
+
}
|
|
109
|
+
function onMouseLeave() {
|
|
110
|
+
if (props.mode !== "hover" || !popoverApi.value) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (openTimeout) {
|
|
114
|
+
clearTimeout(openTimeout);
|
|
115
|
+
openTimeout = null;
|
|
116
|
+
}
|
|
117
|
+
if (popoverApi.value.popoverState === 1) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
closeTimeout = closeTimeout || setTimeout(() => {
|
|
121
|
+
popoverApi.value.closePopover && popoverApi.value.closePopover();
|
|
122
|
+
closeTimeout = null;
|
|
123
|
+
}, props.closeDelay);
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
attrs: omit(attrs, ["class"]),
|
|
127
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
128
|
+
ui,
|
|
129
|
+
popover,
|
|
130
|
+
trigger,
|
|
131
|
+
container,
|
|
132
|
+
containerStyle,
|
|
133
|
+
wrapperClass,
|
|
134
|
+
onMouseOver,
|
|
135
|
+
onMouseLeave
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
</script>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
import type { PropType } from 'vue';
|
|
3
|
+
import type { PopperOptions } from '../../types/popper';
|
|
4
|
+
declare const _default: import("vue").DefineComponent<{
|
|
5
|
+
mode: {
|
|
6
|
+
type: PropType<"click" | "hover">;
|
|
7
|
+
default: string;
|
|
8
|
+
validator: (value: string) => boolean;
|
|
9
|
+
};
|
|
10
|
+
disabled: {
|
|
11
|
+
type: BooleanConstructor;
|
|
12
|
+
default: boolean;
|
|
13
|
+
};
|
|
14
|
+
openDelay: {
|
|
15
|
+
type: NumberConstructor;
|
|
16
|
+
default: number;
|
|
17
|
+
};
|
|
18
|
+
closeDelay: {
|
|
19
|
+
type: NumberConstructor;
|
|
20
|
+
default: number;
|
|
21
|
+
};
|
|
22
|
+
popper: {
|
|
23
|
+
type: PropType<PopperOptions>;
|
|
24
|
+
default: () => {};
|
|
25
|
+
};
|
|
26
|
+
ui: {
|
|
27
|
+
type: PropType<any>;
|
|
28
|
+
default: () => {};
|
|
29
|
+
};
|
|
30
|
+
}, {
|
|
31
|
+
attrs: import("lodash").Omit<{
|
|
32
|
+
[x: string]: unknown;
|
|
33
|
+
}, "class">;
|
|
34
|
+
ui: import("vue").ComputedRef<any>;
|
|
35
|
+
popover: any;
|
|
36
|
+
trigger: import("vue").Ref<import("@vueuse/core").MaybeElement>;
|
|
37
|
+
container: import("vue").Ref<import("@vueuse/core").MaybeElement>;
|
|
38
|
+
containerStyle: import("vue").ComputedRef<{
|
|
39
|
+
paddingTop: string;
|
|
40
|
+
paddingBottom: string;
|
|
41
|
+
} | {
|
|
42
|
+
paddingTop?: undefined;
|
|
43
|
+
paddingBottom?: undefined;
|
|
44
|
+
}>;
|
|
45
|
+
wrapperClass: import("vue").ComputedRef<string>;
|
|
46
|
+
onMouseOver: () => void;
|
|
47
|
+
onMouseLeave: () => void;
|
|
48
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
49
|
+
mode: {
|
|
50
|
+
type: PropType<"click" | "hover">;
|
|
51
|
+
default: string;
|
|
52
|
+
validator: (value: string) => boolean;
|
|
53
|
+
};
|
|
54
|
+
disabled: {
|
|
55
|
+
type: BooleanConstructor;
|
|
56
|
+
default: boolean;
|
|
57
|
+
};
|
|
58
|
+
openDelay: {
|
|
59
|
+
type: NumberConstructor;
|
|
60
|
+
default: number;
|
|
61
|
+
};
|
|
62
|
+
closeDelay: {
|
|
63
|
+
type: NumberConstructor;
|
|
64
|
+
default: number;
|
|
65
|
+
};
|
|
66
|
+
popper: {
|
|
67
|
+
type: PropType<PopperOptions>;
|
|
68
|
+
default: () => {};
|
|
69
|
+
};
|
|
70
|
+
ui: {
|
|
71
|
+
type: PropType<any>;
|
|
72
|
+
default: () => {};
|
|
73
|
+
};
|
|
74
|
+
}>>, {
|
|
75
|
+
ui: any;
|
|
76
|
+
popper: PopperOptions;
|
|
77
|
+
disabled: boolean;
|
|
78
|
+
mode: "click" | "hover";
|
|
79
|
+
openDelay: number;
|
|
80
|
+
closeDelay: number;
|
|
81
|
+
}, {}>;
|
|
82
|
+
export default _default;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<TransitionRoot as="template" :appear="appear" :show="isOpen">
|
|
3
|
+
<HDialog :class="[wrapperClass, { 'justify-end': side === 'right' }]" v-bind="attrs" @close="(e) => !preventClose && close(e)">
|
|
4
|
+
<TransitionChild v-if="overlay" as="template" :appear="appear" v-bind="ui.overlay.transition">
|
|
5
|
+
<div :class="[ui.overlay.base, ui.overlay.background]" />
|
|
6
|
+
</TransitionChild>
|
|
7
|
+
|
|
8
|
+
<TransitionChild as="template" :appear="appear" v-bind="transitionClass">
|
|
9
|
+
<HDialogPanel :class="[ui.base, ui.width, ui.background, ui.ring, ui.padding]">
|
|
10
|
+
<slot />
|
|
11
|
+
</HDialogPanel>
|
|
12
|
+
</TransitionChild>
|
|
13
|
+
</HDialog>
|
|
14
|
+
</TransitionRoot>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script>
|
|
18
|
+
import { computed, defineComponent } from "vue";
|
|
19
|
+
import { Dialog as HDialog, DialogPanel as HDialogPanel, TransitionRoot, TransitionChild } from "@headlessui/vue";
|
|
20
|
+
import { omit } from "lodash-es";
|
|
21
|
+
import { twMerge } from "tailwind-merge";
|
|
22
|
+
import { defuTwMerge } from "../../utils";
|
|
23
|
+
import { useAppConfig } from "#imports";
|
|
24
|
+
export default defineComponent({
|
|
25
|
+
components: {
|
|
26
|
+
HDialog,
|
|
27
|
+
HDialogPanel,
|
|
28
|
+
TransitionRoot,
|
|
29
|
+
TransitionChild
|
|
30
|
+
},
|
|
31
|
+
inheritAttrs: false,
|
|
32
|
+
props: {
|
|
33
|
+
modelValue: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false
|
|
36
|
+
},
|
|
37
|
+
appear: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false
|
|
40
|
+
},
|
|
41
|
+
side: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: "right",
|
|
44
|
+
validator: (value) => ["left", "right"].includes(value)
|
|
45
|
+
},
|
|
46
|
+
overlay: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: true
|
|
49
|
+
},
|
|
50
|
+
transition: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: true
|
|
53
|
+
},
|
|
54
|
+
preventClose: {
|
|
55
|
+
type: Boolean,
|
|
56
|
+
default: false
|
|
57
|
+
},
|
|
58
|
+
ui: {
|
|
59
|
+
type: Object,
|
|
60
|
+
default: () => ({})
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
emits: ["update:modelValue", "close"],
|
|
64
|
+
setup(props, { attrs, emit }) {
|
|
65
|
+
const appConfig2 = useAppConfig();
|
|
66
|
+
const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.slideover));
|
|
67
|
+
const isOpen = computed({
|
|
68
|
+
get() {
|
|
69
|
+
return props.modelValue;
|
|
70
|
+
},
|
|
71
|
+
set(value) {
|
|
72
|
+
emit("update:modelValue", value);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
const wrapperClass = computed(() => twMerge(ui.value.wrapper, attrs.class));
|
|
76
|
+
const transitionClass = computed(() => {
|
|
77
|
+
if (!props.transition) {
|
|
78
|
+
return {};
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
...ui.value.transition,
|
|
82
|
+
enterFrom: props.side === "left" ? "-translate-x-full" : "translate-x-full",
|
|
83
|
+
enterTo: "translate-x-0",
|
|
84
|
+
leaveFrom: "translate-x-0",
|
|
85
|
+
leaveTo: props.side === "left" ? "-translate-x-full" : "translate-x-full"
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
function close(value) {
|
|
89
|
+
isOpen.value = value;
|
|
90
|
+
emit("close");
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
attrs: omit(attrs, ["class"]),
|
|
94
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
95
|
+
ui,
|
|
96
|
+
isOpen,
|
|
97
|
+
wrapperClass,
|
|
98
|
+
transitionClass,
|
|
99
|
+
close
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
</script>
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
import type { WritableComputedRef, PropType } from 'vue';
|
|
3
|
+
declare const _default: import("vue").DefineComponent<{
|
|
4
|
+
modelValue: {
|
|
5
|
+
type: PropType<boolean>;
|
|
6
|
+
default: boolean;
|
|
7
|
+
};
|
|
8
|
+
appear: {
|
|
9
|
+
type: BooleanConstructor;
|
|
10
|
+
default: boolean;
|
|
11
|
+
};
|
|
12
|
+
side: {
|
|
13
|
+
type: PropType<"right" | "left">;
|
|
14
|
+
default: string;
|
|
15
|
+
validator: (value: string) => boolean;
|
|
16
|
+
};
|
|
17
|
+
overlay: {
|
|
18
|
+
type: BooleanConstructor;
|
|
19
|
+
default: boolean;
|
|
20
|
+
};
|
|
21
|
+
transition: {
|
|
22
|
+
type: BooleanConstructor;
|
|
23
|
+
default: boolean;
|
|
24
|
+
};
|
|
25
|
+
preventClose: {
|
|
26
|
+
type: BooleanConstructor;
|
|
27
|
+
default: boolean;
|
|
28
|
+
};
|
|
29
|
+
ui: {
|
|
30
|
+
type: PropType<any>;
|
|
31
|
+
default: () => {};
|
|
32
|
+
};
|
|
33
|
+
}, {
|
|
34
|
+
attrs: import("lodash").Omit<{
|
|
35
|
+
[x: string]: unknown;
|
|
36
|
+
}, "class">;
|
|
37
|
+
ui: import("vue").ComputedRef<any>;
|
|
38
|
+
isOpen: WritableComputedRef<boolean>;
|
|
39
|
+
wrapperClass: import("vue").ComputedRef<string>;
|
|
40
|
+
transitionClass: import("vue").ComputedRef<any>;
|
|
41
|
+
close: (value: boolean) => void;
|
|
42
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("close" | "update:modelValue")[], "close" | "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
43
|
+
modelValue: {
|
|
44
|
+
type: PropType<boolean>;
|
|
45
|
+
default: boolean;
|
|
46
|
+
};
|
|
47
|
+
appear: {
|
|
48
|
+
type: BooleanConstructor;
|
|
49
|
+
default: boolean;
|
|
50
|
+
};
|
|
51
|
+
side: {
|
|
52
|
+
type: PropType<"right" | "left">;
|
|
53
|
+
default: string;
|
|
54
|
+
validator: (value: string) => boolean;
|
|
55
|
+
};
|
|
56
|
+
overlay: {
|
|
57
|
+
type: BooleanConstructor;
|
|
58
|
+
default: boolean;
|
|
59
|
+
};
|
|
60
|
+
transition: {
|
|
61
|
+
type: BooleanConstructor;
|
|
62
|
+
default: boolean;
|
|
63
|
+
};
|
|
64
|
+
preventClose: {
|
|
65
|
+
type: BooleanConstructor;
|
|
66
|
+
default: boolean;
|
|
67
|
+
};
|
|
68
|
+
ui: {
|
|
69
|
+
type: PropType<any>;
|
|
70
|
+
default: () => {};
|
|
71
|
+
};
|
|
72
|
+
}>> & {
|
|
73
|
+
onClose?: ((...args: any[]) => any) | undefined;
|
|
74
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
75
|
+
}, {
|
|
76
|
+
ui: any;
|
|
77
|
+
modelValue: boolean;
|
|
78
|
+
appear: boolean;
|
|
79
|
+
overlay: boolean;
|
|
80
|
+
transition: boolean;
|
|
81
|
+
preventClose: boolean;
|
|
82
|
+
side: "right" | "left";
|
|
83
|
+
}, {}>;
|
|
84
|
+
export default _default;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="trigger" :class="wrapperClass" v-bind="attrs" @mouseover="onMouseOver" @mouseleave="onMouseLeave">
|
|
3
|
+
<slot :open="open">
|
|
4
|
+
Hover
|
|
5
|
+
</slot>
|
|
6
|
+
|
|
7
|
+
<div v-if="open && !prevent" ref="container" :class="[ui.container, ui.width]">
|
|
8
|
+
<Transition appear v-bind="ui.transition">
|
|
9
|
+
<div :class="[ui.base, ui.background, ui.color, ui.rounded, ui.shadow, ui.ring]">
|
|
10
|
+
<slot name="text">
|
|
11
|
+
{{ text }}
|
|
12
|
+
</slot>
|
|
13
|
+
|
|
14
|
+
<span v-if="shortcuts?.length" :class="ui.shortcuts">
|
|
15
|
+
<span class="mx-1 text-gray-700 dark:text-gray-200">·</span>
|
|
16
|
+
<UKbd v-for="shortcut of shortcuts" :key="shortcut" size="xs">
|
|
17
|
+
{{ shortcut }}
|
|
18
|
+
</Ukbd>
|
|
19
|
+
</span>
|
|
20
|
+
</div>
|
|
21
|
+
</Transition>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script>
|
|
27
|
+
import { computed, ref, defineComponent } from "vue";
|
|
28
|
+
import { defu } from "defu";
|
|
29
|
+
import { omit } from "lodash-es";
|
|
30
|
+
import { twMerge } from "tailwind-merge";
|
|
31
|
+
import UKbd from "../elements/Kbd.vue";
|
|
32
|
+
import { usePopper } from "../../composables/usePopper";
|
|
33
|
+
import { defuTwMerge } from "../../utils";
|
|
34
|
+
import { useAppConfig } from "#imports";
|
|
35
|
+
export default defineComponent({
|
|
36
|
+
components: {
|
|
37
|
+
UKbd
|
|
38
|
+
},
|
|
39
|
+
inheritAttrs: false,
|
|
40
|
+
props: {
|
|
41
|
+
text: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: null
|
|
44
|
+
},
|
|
45
|
+
prevent: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
default: false
|
|
48
|
+
},
|
|
49
|
+
shortcuts: {
|
|
50
|
+
type: Array,
|
|
51
|
+
default: () => []
|
|
52
|
+
},
|
|
53
|
+
openDelay: {
|
|
54
|
+
type: Number,
|
|
55
|
+
default: 0
|
|
56
|
+
},
|
|
57
|
+
closeDelay: {
|
|
58
|
+
type: Number,
|
|
59
|
+
default: 0
|
|
60
|
+
},
|
|
61
|
+
popper: {
|
|
62
|
+
type: Object,
|
|
63
|
+
default: () => ({})
|
|
64
|
+
},
|
|
65
|
+
ui: {
|
|
66
|
+
type: Object,
|
|
67
|
+
default: () => ({})
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
setup(props, { attrs }) {
|
|
71
|
+
const appConfig2 = useAppConfig();
|
|
72
|
+
const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.tooltip));
|
|
73
|
+
const popper = computed(() => defu({}, props.popper, ui.value.popper));
|
|
74
|
+
const [trigger, container] = usePopper(popper.value);
|
|
75
|
+
const open = ref(false);
|
|
76
|
+
let openTimeout = null;
|
|
77
|
+
let closeTimeout = null;
|
|
78
|
+
const wrapperClass = computed(() => twMerge(ui.value.wrapper, attrs.class));
|
|
79
|
+
function onMouseOver() {
|
|
80
|
+
if (closeTimeout) {
|
|
81
|
+
clearTimeout(closeTimeout);
|
|
82
|
+
closeTimeout = null;
|
|
83
|
+
}
|
|
84
|
+
if (open.value) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
openTimeout = openTimeout || setTimeout(() => {
|
|
88
|
+
open.value = true;
|
|
89
|
+
openTimeout = null;
|
|
90
|
+
}, props.openDelay);
|
|
91
|
+
}
|
|
92
|
+
function onMouseLeave() {
|
|
93
|
+
if (openTimeout) {
|
|
94
|
+
clearTimeout(openTimeout);
|
|
95
|
+
openTimeout = null;
|
|
96
|
+
}
|
|
97
|
+
if (!open.value) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
closeTimeout = closeTimeout || setTimeout(() => {
|
|
101
|
+
open.value = false;
|
|
102
|
+
closeTimeout = null;
|
|
103
|
+
}, props.closeDelay);
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
attrs: omit(attrs, ["class"]),
|
|
107
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
108
|
+
ui,
|
|
109
|
+
trigger,
|
|
110
|
+
container,
|
|
111
|
+
open,
|
|
112
|
+
wrapperClass,
|
|
113
|
+
onMouseOver,
|
|
114
|
+
onMouseLeave
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
</script>
|