numori-ui 0.5.0 → 0.7.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/CHANGELOG.md +85 -0
- package/README.md +11 -3
- package/dist/components/Avatar.js +71 -19
- package/dist/components/Avatar.js.map +1 -1
- package/dist/components/ChipsInput.js +423 -0
- package/dist/components/ChipsInput.js.map +1 -0
- package/dist/components/Drawer.js +236 -0
- package/dist/components/Drawer.js.map +1 -0
- package/dist/components/Dropdown.js +4 -2
- package/dist/components/Dropdown.js.map +1 -1
- package/dist/components/Modal.js +61 -4
- package/dist/components/Modal.js.map +1 -1
- package/dist/components/Prompt.js +11 -6
- package/dist/components/Prompt.js.map +1 -1
- package/dist/components/Select.js +1 -1
- package/dist/components/Select.js.map +1 -1
- package/dist/components/Skeleton.js +122 -0
- package/dist/components/Skeleton.js.map +1 -0
- package/dist/components/SplitPane.js +264 -0
- package/dist/components/SplitPane.js.map +1 -0
- package/dist/components/Toast.js +62 -16
- package/dist/components/Toast.js.map +1 -1
- package/dist/components/Tree.js +417 -0
- package/dist/components/Tree.js.map +1 -0
- package/dist/components/VirtualList.js +292 -0
- package/dist/components/VirtualList.js.map +1 -0
- package/dist/components/index.js +93 -82
- package/dist/components/index.js.map +1 -1
- package/dist/icons/mdi.js +3 -0
- package/dist/icons/mdi.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +49 -43
- package/dist/index.js.map +1 -1
- package/dist/internal/focusTrap.js +163 -0
- package/dist/internal/focusTrap.js.map +1 -0
- package/dist/manifest.js +7 -1
- package/dist/manifest.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Avatar.vue +69 -18
- package/src/components/ChipsInput.vue +387 -0
- package/src/components/Drawer.vue +213 -0
- package/src/components/Dropdown.vue +4 -1
- package/src/components/Modal.vue +51 -3
- package/src/components/Prompt.vue +14 -3
- package/src/components/Select.vue +1 -1
- package/src/components/Skeleton.vue +91 -0
- package/src/components/SplitPane.vue +264 -0
- package/src/components/Toast.vue +57 -13
- package/src/components/Tree.vue +428 -0
- package/src/components/VirtualList.vue +250 -0
- package/src/components/index.js +18 -1
- package/src/icons/mdi.js +3 -0
- package/src/internal/focusTrap.js +185 -0
- package/src/manifest.js +6 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { useBackButton } from "../composables/useBackButton.js";
|
|
2
|
+
import { useFocusTrap } from "../internal/focusTrap.js";
|
|
3
|
+
import { Teleport, Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, normalizeClass, normalizeStyle, onBeforeUnmount, openBlock, ref, renderSlot, watch, withCtx } from "vue";
|
|
4
|
+
//#region src/components/Drawer.vue
|
|
5
|
+
var _hoisted_1 = ["aria-label", "aria-labelledby"];
|
|
6
|
+
var _hoisted_2 = {
|
|
7
|
+
key: 0,
|
|
8
|
+
class: "flex shrink-0 justify-center pt-2 pb-1",
|
|
9
|
+
"aria-hidden": "true"
|
|
10
|
+
};
|
|
11
|
+
var _sfc_main = {
|
|
12
|
+
__name: "Drawer",
|
|
13
|
+
props: {
|
|
14
|
+
/**
|
|
15
|
+
* Whether the drawer is open.
|
|
16
|
+
* @type {boolean}
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
show: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: false
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* The edge it slides in from.
|
|
25
|
+
* @type {string}
|
|
26
|
+
* @default 'bottom'
|
|
27
|
+
* @values 'bottom' | 'left' | 'right'
|
|
28
|
+
*/
|
|
29
|
+
side: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: "bottom"
|
|
32
|
+
},
|
|
33
|
+
/**
|
|
34
|
+
* How far it reaches: the height of a bottom sheet, the width of a side panel.
|
|
35
|
+
* @type {string}
|
|
36
|
+
* @default 'md'
|
|
37
|
+
* @values 'sm' | 'md' | 'lg' | 'full'
|
|
38
|
+
*/
|
|
39
|
+
size: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: "md"
|
|
42
|
+
},
|
|
43
|
+
/**
|
|
44
|
+
* Ignore the backdrop, Escape and the back button.
|
|
45
|
+
* @type {boolean}
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
persistent: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: false
|
|
51
|
+
},
|
|
52
|
+
/**
|
|
53
|
+
* Show a grab handle at the top of a bottom sheet.
|
|
54
|
+
* @type {boolean}
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
handle: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
default: true
|
|
60
|
+
},
|
|
61
|
+
/**
|
|
62
|
+
* Accessible name. Prefer `labelledby` when there is a visible heading.
|
|
63
|
+
* @type {string}
|
|
64
|
+
* @default ''
|
|
65
|
+
*/
|
|
66
|
+
label: {
|
|
67
|
+
type: String,
|
|
68
|
+
default: ""
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* Id of the element that names the drawer.
|
|
72
|
+
* @type {string}
|
|
73
|
+
* @default ''
|
|
74
|
+
*/
|
|
75
|
+
labelledby: {
|
|
76
|
+
type: String,
|
|
77
|
+
default: ""
|
|
78
|
+
},
|
|
79
|
+
/**
|
|
80
|
+
* Extra classes for the panel.
|
|
81
|
+
* @type {string}
|
|
82
|
+
* @default ''
|
|
83
|
+
*/
|
|
84
|
+
panelClass: {
|
|
85
|
+
type: String,
|
|
86
|
+
default: ""
|
|
87
|
+
},
|
|
88
|
+
/**
|
|
89
|
+
* Z-index class for the backdrop and panel.
|
|
90
|
+
* @type {string}
|
|
91
|
+
* @default 'z-50'
|
|
92
|
+
*/
|
|
93
|
+
z: {
|
|
94
|
+
type: String,
|
|
95
|
+
default: "z-50"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
emits: ["close"],
|
|
99
|
+
setup(__props, { emit: __emit }) {
|
|
100
|
+
/**
|
|
101
|
+
* UiDrawer — a panel that slides in from an edge of the screen: a bottom
|
|
102
|
+
* sheet on phones, a side panel on larger screens.
|
|
103
|
+
*
|
|
104
|
+
* It is a modal dialog in every respect but its position: `role="dialog"`
|
|
105
|
+
* with `aria-modal`, named by `label` or `labelledby`; focus moves inside when
|
|
106
|
+
* it opens, Tab stays inside, Escape and the backdrop close it (unless
|
|
107
|
+
* `persistent`), and focus returns to whatever opened it. On Android the
|
|
108
|
+
* system back button closes it too. Stacked with modals, only the top one
|
|
109
|
+
* responds.
|
|
110
|
+
*
|
|
111
|
+
* The panel respects the device's safe areas: a bottom sheet keeps clear of
|
|
112
|
+
* the home indicator, a side panel of notches and rounded corners.
|
|
113
|
+
*
|
|
114
|
+
* Content and scrolling are the caller's: put a header in the slot and give
|
|
115
|
+
* the body `overflow-y-auto` and `min-h-0`.
|
|
116
|
+
*
|
|
117
|
+
* @example A compose sheet on mobile
|
|
118
|
+
* <UiDrawer :show="composing" side="bottom" size="full" labelledby="compose-title" @close="composing = false">
|
|
119
|
+
* <h2 id="compose-title" class="p-4 font-semibold">New message</h2>
|
|
120
|
+
* <div class="min-h-0 flex-1 overflow-y-auto p-4">…</div>
|
|
121
|
+
* </UiDrawer>
|
|
122
|
+
*
|
|
123
|
+
* @example A side panel
|
|
124
|
+
* <UiDrawer :show="open" side="right" size="md" label="Filters" @close="open = false">
|
|
125
|
+
* <div class="p-6">…</div>
|
|
126
|
+
* </UiDrawer>
|
|
127
|
+
*
|
|
128
|
+
* @emits {void} close — The drawer should close (backdrop, Escape, back button).
|
|
129
|
+
*
|
|
130
|
+
* @slot default — Drawer content. Scope: `{ close }`.
|
|
131
|
+
*/
|
|
132
|
+
const props = __props;
|
|
133
|
+
const emit = __emit;
|
|
134
|
+
const panelRef = ref(null);
|
|
135
|
+
useFocusTrap(() => panelRef.value, {
|
|
136
|
+
active: () => props.show,
|
|
137
|
+
escape: () => !props.persistent,
|
|
138
|
+
onEscape: () => emit("close")
|
|
139
|
+
});
|
|
140
|
+
const { register, unregister } = useBackButton();
|
|
141
|
+
let backId = null;
|
|
142
|
+
watch(() => props.show, (open) => {
|
|
143
|
+
if (open && backId === null) backId = register(() => {
|
|
144
|
+
if (props.persistent) return false;
|
|
145
|
+
emit("close");
|
|
146
|
+
return true;
|
|
147
|
+
});
|
|
148
|
+
else if (!open && backId !== null) {
|
|
149
|
+
unregister(backId);
|
|
150
|
+
backId = null;
|
|
151
|
+
}
|
|
152
|
+
}, { immediate: true });
|
|
153
|
+
onBeforeUnmount(() => {
|
|
154
|
+
if (backId !== null) unregister(backId);
|
|
155
|
+
});
|
|
156
|
+
const SIZES = {
|
|
157
|
+
bottom: {
|
|
158
|
+
sm: "max-h-[40dvh]",
|
|
159
|
+
md: "max-h-[65dvh]",
|
|
160
|
+
lg: "max-h-[85dvh]",
|
|
161
|
+
full: "h-[calc(100dvh-env(safe-area-inset-top)-0.5rem)]"
|
|
162
|
+
},
|
|
163
|
+
side: {
|
|
164
|
+
sm: "w-72",
|
|
165
|
+
md: "w-96",
|
|
166
|
+
lg: "w-[32rem]",
|
|
167
|
+
full: "w-full"
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const placementClass = computed(() => {
|
|
171
|
+
if (props.side === "left") return `inset-y-0 left-0 max-w-full ${SIZES.side[props.size] ?? SIZES.side.md}`;
|
|
172
|
+
if (props.side === "right") return `inset-y-0 right-0 max-w-full ${SIZES.side[props.size] ?? SIZES.side.md}`;
|
|
173
|
+
return `inset-x-0 bottom-0 rounded-t-2xl ${SIZES.bottom[props.size] ?? SIZES.bottom.md}`;
|
|
174
|
+
});
|
|
175
|
+
const offscreenClass = computed(() => ({
|
|
176
|
+
left: "-translate-x-full",
|
|
177
|
+
right: "translate-x-full"
|
|
178
|
+
})[props.side] ?? "translate-y-full");
|
|
179
|
+
const safeAreaStyle = computed(() => {
|
|
180
|
+
if (props.side === "bottom") return { paddingBottom: "env(safe-area-inset-bottom)" };
|
|
181
|
+
if (props.side === "left") return {
|
|
182
|
+
paddingLeft: "env(safe-area-inset-left)",
|
|
183
|
+
paddingTop: "env(safe-area-inset-top)",
|
|
184
|
+
paddingBottom: "env(safe-area-inset-bottom)"
|
|
185
|
+
};
|
|
186
|
+
return {
|
|
187
|
+
paddingRight: "env(safe-area-inset-right)",
|
|
188
|
+
paddingTop: "env(safe-area-inset-top)",
|
|
189
|
+
paddingBottom: "env(safe-area-inset-bottom)"
|
|
190
|
+
};
|
|
191
|
+
});
|
|
192
|
+
return (_ctx, _cache) => {
|
|
193
|
+
return openBlock(), createBlock(Teleport, { to: "body" }, [createVNode(Transition, {
|
|
194
|
+
"enter-active-class": "transition-opacity duration-200 motion-reduce:transition-none",
|
|
195
|
+
"enter-from-class": "opacity-0",
|
|
196
|
+
"leave-active-class": "transition-opacity duration-150 motion-reduce:transition-none",
|
|
197
|
+
"leave-to-class": "opacity-0"
|
|
198
|
+
}, {
|
|
199
|
+
default: withCtx(() => [__props.show ? (openBlock(), createElementBlock("div", {
|
|
200
|
+
key: 0,
|
|
201
|
+
class: normalizeClass(["fixed inset-0 bg-gray-950/50 backdrop-blur-sm", __props.z]),
|
|
202
|
+
"aria-hidden": "true",
|
|
203
|
+
onClick: _cache[0] || (_cache[0] = ($event) => !__props.persistent && _ctx.$emit("close"))
|
|
204
|
+
}, null, 2)) : createCommentVNode("", true)]),
|
|
205
|
+
_: 1
|
|
206
|
+
}), createVNode(Transition, {
|
|
207
|
+
"enter-active-class": "transition-transform duration-250 ease-out motion-reduce:transition-none",
|
|
208
|
+
"enter-from-class": offscreenClass.value,
|
|
209
|
+
"leave-active-class": "transition-transform duration-200 ease-in motion-reduce:transition-none",
|
|
210
|
+
"leave-to-class": offscreenClass.value
|
|
211
|
+
}, {
|
|
212
|
+
default: withCtx(() => [__props.show ? (openBlock(), createElementBlock("div", {
|
|
213
|
+
key: 0,
|
|
214
|
+
ref_key: "panelRef",
|
|
215
|
+
ref: panelRef,
|
|
216
|
+
role: "dialog",
|
|
217
|
+
"aria-modal": "true",
|
|
218
|
+
"aria-label": __props.labelledby ? void 0 : __props.label || void 0,
|
|
219
|
+
"aria-labelledby": __props.labelledby || void 0,
|
|
220
|
+
tabindex: "-1",
|
|
221
|
+
class: normalizeClass(["fixed flex flex-col bg-white text-gray-900 shadow-modal focus:outline-none dark:bg-gray-925 dark:text-gray-100", [
|
|
222
|
+
__props.z,
|
|
223
|
+
placementClass.value,
|
|
224
|
+
__props.panelClass
|
|
225
|
+
]]),
|
|
226
|
+
style: normalizeStyle(safeAreaStyle.value)
|
|
227
|
+
}, [__props.side === "bottom" && __props.handle ? (openBlock(), createElementBlock("div", _hoisted_2, [..._cache[1] || (_cache[1] = [createElementVNode("span", { class: "h-1 w-10 rounded-full bg-gray-300 dark:bg-gray-600" }, null, -1)])])) : createCommentVNode("", true), renderSlot(_ctx.$slots, "default", { close: () => _ctx.$emit("close") })], 14, _hoisted_1)) : createCommentVNode("", true)]),
|
|
228
|
+
_: 3
|
|
229
|
+
}, 8, ["enter-from-class", "leave-to-class"])]);
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
//#endregion
|
|
234
|
+
export { _sfc_main as default };
|
|
235
|
+
|
|
236
|
+
//# sourceMappingURL=Drawer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.js","names":["$emit"],"sources":["../../src/components/Drawer.vue"],"sourcesContent":["<template>\n <Teleport to=\"body\">\n <Transition\n enter-active-class=\"transition-opacity duration-200 motion-reduce:transition-none\"\n enter-from-class=\"opacity-0\"\n leave-active-class=\"transition-opacity duration-150 motion-reduce:transition-none\"\n leave-to-class=\"opacity-0\"\n >\n <div\n v-if=\"show\"\n class=\"fixed inset-0 bg-gray-950/50 backdrop-blur-sm\"\n :class=\"z\"\n aria-hidden=\"true\"\n @click=\"!persistent && $emit('close')\"\n />\n </Transition>\n <Transition\n enter-active-class=\"transition-transform duration-250 ease-out motion-reduce:transition-none\"\n :enter-from-class=\"offscreenClass\"\n leave-active-class=\"transition-transform duration-200 ease-in motion-reduce:transition-none\"\n :leave-to-class=\"offscreenClass\"\n >\n <div\n v-if=\"show\"\n ref=\"panelRef\"\n role=\"dialog\"\n aria-modal=\"true\"\n :aria-label=\"labelledby ? undefined : label || undefined\"\n :aria-labelledby=\"labelledby || undefined\"\n tabindex=\"-1\"\n class=\"fixed flex flex-col bg-white text-gray-900 shadow-modal focus:outline-none dark:bg-gray-925 dark:text-gray-100\"\n :class=\"[z, placementClass, panelClass]\"\n :style=\"safeAreaStyle\"\n >\n <div\n v-if=\"side === 'bottom' && handle\"\n class=\"flex shrink-0 justify-center pt-2 pb-1\"\n aria-hidden=\"true\"\n >\n <span class=\"h-1 w-10 rounded-full bg-gray-300 dark:bg-gray-600\" />\n </div>\n <slot :close=\"() => $emit('close')\" />\n </div>\n </Transition>\n </Teleport>\n</template>\n\n<script setup>\n/**\n * UiDrawer — a panel that slides in from an edge of the screen: a bottom\n * sheet on phones, a side panel on larger screens.\n *\n * It is a modal dialog in every respect but its position: `role=\"dialog\"`\n * with `aria-modal`, named by `label` or `labelledby`; focus moves inside when\n * it opens, Tab stays inside, Escape and the backdrop close it (unless\n * `persistent`), and focus returns to whatever opened it. On Android the\n * system back button closes it too. Stacked with modals, only the top one\n * responds.\n *\n * The panel respects the device's safe areas: a bottom sheet keeps clear of\n * the home indicator, a side panel of notches and rounded corners.\n *\n * Content and scrolling are the caller's: put a header in the slot and give\n * the body `overflow-y-auto` and `min-h-0`.\n *\n * @example A compose sheet on mobile\n * <UiDrawer :show=\"composing\" side=\"bottom\" size=\"full\" labelledby=\"compose-title\" @close=\"composing = false\">\n * <h2 id=\"compose-title\" class=\"p-4 font-semibold\">New message</h2>\n * <div class=\"min-h-0 flex-1 overflow-y-auto p-4\">…</div>\n * </UiDrawer>\n *\n * @example A side panel\n * <UiDrawer :show=\"open\" side=\"right\" size=\"md\" label=\"Filters\" @close=\"open = false\">\n * <div class=\"p-6\">…</div>\n * </UiDrawer>\n *\n * @emits {void} close — The drawer should close (backdrop, Escape, back button).\n *\n * @slot default — Drawer content. Scope: `{ close }`.\n */\nimport { computed, onBeforeUnmount, ref, watch } from 'vue'\nimport { useBackButton } from '../composables/useBackButton.js'\nimport { useFocusTrap } from '../internal/focusTrap.js'\n\nconst props = defineProps({\n /**\n * Whether the drawer is open.\n * @type {boolean}\n * @default false\n */\n show: { type: Boolean, default: false },\n /**\n * The edge it slides in from.\n * @type {string}\n * @default 'bottom'\n * @values 'bottom' | 'left' | 'right'\n */\n side: { type: String, default: 'bottom' },\n /**\n * How far it reaches: the height of a bottom sheet, the width of a side panel.\n * @type {string}\n * @default 'md'\n * @values 'sm' | 'md' | 'lg' | 'full'\n */\n size: { type: String, default: 'md' },\n /**\n * Ignore the backdrop, Escape and the back button.\n * @type {boolean}\n * @default false\n */\n persistent: { type: Boolean, default: false },\n /**\n * Show a grab handle at the top of a bottom sheet.\n * @type {boolean}\n * @default true\n */\n handle: { type: Boolean, default: true },\n /**\n * Accessible name. Prefer `labelledby` when there is a visible heading.\n * @type {string}\n * @default ''\n */\n label: { type: String, default: '' },\n /**\n * Id of the element that names the drawer.\n * @type {string}\n * @default ''\n */\n labelledby: { type: String, default: '' },\n /**\n * Extra classes for the panel.\n * @type {string}\n * @default ''\n */\n panelClass: { type: String, default: '' },\n /**\n * Z-index class for the backdrop and panel.\n * @type {string}\n * @default 'z-50'\n */\n z: { type: String, default: 'z-50' },\n})\n\nconst emit = defineEmits(['close'])\n\nconst panelRef = ref(null)\nuseFocusTrap(() => panelRef.value, {\n active: () => props.show,\n escape: () => !props.persistent,\n onEscape: () => emit('close'),\n})\n\n// ── Back button (Capacitor) ──\nconst { register, unregister } = useBackButton()\nlet backId = null\nwatch(\n () => props.show,\n (open) => {\n if (open && backId === null) {\n backId = register(() => {\n if (props.persistent) return false\n emit('close')\n return true\n })\n } else if (!open && backId !== null) {\n unregister(backId)\n backId = null\n }\n },\n { immediate: true },\n)\nonBeforeUnmount(() => {\n if (backId !== null) unregister(backId)\n})\n\nconst SIZES = {\n bottom: {\n sm: 'max-h-[40dvh]',\n md: 'max-h-[65dvh]',\n lg: 'max-h-[85dvh]',\n full: 'h-[calc(100dvh-env(safe-area-inset-top)-0.5rem)]',\n },\n side: { sm: 'w-72', md: 'w-96', lg: 'w-[32rem]', full: 'w-full' },\n}\n\nconst placementClass = computed(() => {\n if (props.side === 'left')\n return `inset-y-0 left-0 max-w-full ${SIZES.side[props.size] ?? SIZES.side.md}`\n if (props.side === 'right')\n return `inset-y-0 right-0 max-w-full ${SIZES.side[props.size] ?? SIZES.side.md}`\n return `inset-x-0 bottom-0 rounded-t-2xl ${SIZES.bottom[props.size] ?? SIZES.bottom.md}`\n})\n\nconst offscreenClass = computed(\n () =>\n ({ left: '-translate-x-full', right: 'translate-x-full' })[props.side] ?? 'translate-y-full',\n)\n\nconst safeAreaStyle = computed(() => {\n if (props.side === 'bottom') return { paddingBottom: 'env(safe-area-inset-bottom)' }\n if (props.side === 'left')\n return {\n paddingLeft: 'env(safe-area-inset-left)',\n paddingTop: 'env(safe-area-inset-top)',\n paddingBottom: 'env(safe-area-inset-bottom)',\n }\n return {\n paddingRight: 'env(safe-area-inset-right)',\n paddingTop: 'env(safe-area-inset-top)',\n paddingBottom: 'env(safe-area-inset-bottom)',\n }\n})\n</script>\n"],"mappings":"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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { MENU_PANEL_CLASS } from "../internal/menu.js";
|
|
1
2
|
import { useEventListener } from "../composables/useEventListener.js";
|
|
2
3
|
import { onClickOutside } from "../composables/onClickOutside.js";
|
|
3
|
-
import { MENU_PANEL_CLASS } from "../internal/menu.js";
|
|
4
4
|
import { Transition, computed, createElementBlock, createElementVNode, createVNode, normalizeClass, normalizeStyle, openBlock, ref, renderSlot, vShow, withCtx, withDirectives } from "vue";
|
|
5
5
|
//#region src/components/Dropdown.vue
|
|
6
6
|
var _sfc_main = {
|
|
@@ -128,7 +128,9 @@ var _sfc_main = {
|
|
|
128
128
|
};
|
|
129
129
|
onClickOutside(containerRef, close);
|
|
130
130
|
useEventListener(globalThis.document, "keydown", (e) => {
|
|
131
|
-
if (e.key
|
|
131
|
+
if (e.key !== "Escape" || !isOpen.value) return;
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
close();
|
|
132
134
|
});
|
|
133
135
|
__expose({
|
|
134
136
|
isOpen,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.js","names":[],"sources":["../../src/components/Dropdown.vue"],"sourcesContent":["<template>\n <div ref=\"containerRef\" class=\"relative\">\n <!-- Trigger slot: receives { open, toggle } for controlling the dropdown -->\n <slot name=\"trigger\" :open=\"isOpen\" :toggle=\"toggle\" />\n\n <!-- Dropdown panel with animated enter/leave transitions -->\n <Transition\n :enter-active-class=\"transitionClasses.enterActive\"\n :enter-from-class=\"transitionClasses.enterFrom\"\n :enter-to-class=\"transitionClasses.enterTo\"\n :leave-active-class=\"transitionClasses.leaveActive\"\n :leave-from-class=\"transitionClasses.leaveFrom\"\n :leave-to-class=\"transitionClasses.leaveTo\"\n >\n <div v-show=\"isOpen\" :class=\"panelClasses\" :style=\"{ transformOrigin: panelOrigin }\">\n <slot :close=\"close\" />\n </div>\n </Transition>\n </div>\n</template>\n\n<script setup>\n/**\n * UiDropdown — Headless dropdown menu with configurable alignment, direction, and transitions.\n *\n * Uses a trigger slot that receives `open` state and `toggle` function, and a default\n * slot for menu content that receives a `close` function. Closes on outside click and\n * Escape key. Supports both downward and upward drop directions with matching transitions.\n * Exposes `isOpen`, `toggle()`, and `close()` for programmatic control.\n *\n * @example Basic dropdown with button trigger\n * <UiDropdown>\n * <template #trigger=\"{ toggle }\">\n * <UiButton @click=\"toggle\">Menu</UiButton>\n * </template>\n * <UiDropdownItem icon=\"mdi:pencil\" label=\"Edit\" @click=\"edit\" />\n * <UiDropdownItem icon=\"mdi:trash-can\" label=\"Delete\" color=\"red\" @click=\"del\" />\n * </UiDropdown>\n *\n * @example Right-aligned, drop-up\n * <UiDropdown align=\"right\" drop=\"up\" width=\"w-48\">\n * <template #trigger=\"{ toggle }\">\n * <UiButton variant=\"ghost\" icon-only @click=\"toggle\">\n * <UiIcon name=\"mdi:dots-vertical\" class=\"w-5 h-5\" />\n * </UiButton>\n * </template>\n * <slot />\n * </UiDropdown>\n *\n * @emits {void} open — Emitted when the dropdown opens\n * @emits {void} close — Emitted when the dropdown closes\n *\n * @slot trigger — Trigger element that opens the dropdown. Receives { open: boolean, toggle: Function }\n * @slot default — Dropdown menu content. Receives { close: Function }\n *\n * @see UiDropdownItem — Standard menu item for use inside this dropdown\n * @see UiDropdownSubmenu — Nested submenu for this dropdown\n */\nimport { ref, computed } from 'vue'\nimport { onClickOutside } from '../composables/onClickOutside.js'\nimport { useEventListener } from '../composables/useEventListener.js'\nimport { MENU_PANEL_CLASS } from '../internal/menu.js'\nconst props = defineProps({\n /**\n * Width class applied to the dropdown panel.\n * @type {string}\n * @default 'w-56'\n * @example 'w-48', 'w-64', 'w-72'\n */\n width: { type: String, default: 'w-56' },\n\n /**\n * Horizontal alignment of the panel relative to the trigger.\n * @type {string}\n * @default 'left'\n * @values 'left' | 'right'\n */\n align: { type: String, default: 'left' },\n\n /**\n * Drop direction — 'down' opens below the trigger, 'up' opens above.\n * @type {string}\n * @default 'down'\n * @values 'down' | 'up'\n */\n drop: { type: String, default: 'down' },\n\n /**\n * Override all default panel classes (bg, border, rounded, shadow).\n * When set, the built-in panel styling is completely replaced.\n * @type {string}\n * @default ''\n */\n panelClass: { type: String, default: '' },\n})\n\nconst emit = defineEmits(['open', 'close'])\n\nconst isOpen = ref(false)\nconst containerRef = ref(null)\n\n// Build panel positioning/styling classes, or use custom override\nconst panelClasses = computed(() => {\n if (props.panelClass) return props.panelClass\n const align = props.align === 'right' ? 'right-0' : 'left-0'\n const dropDir = props.drop === 'up' ? 'bottom-full mb-1' : 'mt-1'\n // `p-1` (not just `py-1`) insets the rows so their rounded hover highlight\n // reads as a chip with breathing room from the panel edge.\n return `absolute z-50 ${MENU_PANEL_CLASS} p-1 ${props.width} ${align} ${dropDir}`\n})\n\n// Inline transform-origin (not a Tailwind class, so it needs no build step to\n// take effect): the panel scales in from the corner nearest the trigger rather\n// than drifting in from its centre.\nconst panelOrigin = computed(() => {\n const y = props.drop === 'up' ? 'bottom' : 'top'\n const x = props.align === 'right' ? 'right' : 'left'\n return `${y} ${x}`\n})\n\n// Use slide-up transition for drop=\"up\", scale transition for drop=\"down\"\nconst transitionClasses = computed(() => {\n if (props.drop === 'up') {\n return {\n enterActive: 'transition ease-out duration-150',\n enterFrom: 'opacity-0 translate-y-1',\n enterTo: 'opacity-100 translate-y-0',\n leaveActive: 'transition ease-in duration-100',\n leaveFrom: 'opacity-100 translate-y-0',\n leaveTo: 'opacity-0 translate-y-1',\n }\n }\n return {\n enterActive: 'transition duration-100 ease-out',\n enterFrom: 'opacity-0 scale-95',\n enterTo: 'opacity-100 scale-100',\n leaveActive: 'transition duration-75 ease-in',\n leaveFrom: 'opacity-100 scale-100',\n leaveTo: 'opacity-0 scale-95',\n }\n})\n\nconst toggle = () => {\n isOpen.value = !isOpen.value\n emit(isOpen.value ? 'open' : 'close')\n}\n\nconst close = () => {\n if (isOpen.value) {\n isOpen.value = false\n emit('close')\n }\n}\n\nonClickOutside(containerRef, close)\n\nuseEventListener(globalThis.document, 'keydown', (e) => {\n if (e.key
|
|
1
|
+
{"version":3,"file":"Dropdown.js","names":[],"sources":["../../src/components/Dropdown.vue"],"sourcesContent":["<template>\n <div ref=\"containerRef\" class=\"relative\">\n <!-- Trigger slot: receives { open, toggle } for controlling the dropdown -->\n <slot name=\"trigger\" :open=\"isOpen\" :toggle=\"toggle\" />\n\n <!-- Dropdown panel with animated enter/leave transitions -->\n <Transition\n :enter-active-class=\"transitionClasses.enterActive\"\n :enter-from-class=\"transitionClasses.enterFrom\"\n :enter-to-class=\"transitionClasses.enterTo\"\n :leave-active-class=\"transitionClasses.leaveActive\"\n :leave-from-class=\"transitionClasses.leaveFrom\"\n :leave-to-class=\"transitionClasses.leaveTo\"\n >\n <div v-show=\"isOpen\" :class=\"panelClasses\" :style=\"{ transformOrigin: panelOrigin }\">\n <slot :close=\"close\" />\n </div>\n </Transition>\n </div>\n</template>\n\n<script setup>\n/**\n * UiDropdown — Headless dropdown menu with configurable alignment, direction, and transitions.\n *\n * Uses a trigger slot that receives `open` state and `toggle` function, and a default\n * slot for menu content that receives a `close` function. Closes on outside click and\n * Escape key. Supports both downward and upward drop directions with matching transitions.\n * Exposes `isOpen`, `toggle()`, and `close()` for programmatic control.\n *\n * @example Basic dropdown with button trigger\n * <UiDropdown>\n * <template #trigger=\"{ toggle }\">\n * <UiButton @click=\"toggle\">Menu</UiButton>\n * </template>\n * <UiDropdownItem icon=\"mdi:pencil\" label=\"Edit\" @click=\"edit\" />\n * <UiDropdownItem icon=\"mdi:trash-can\" label=\"Delete\" color=\"red\" @click=\"del\" />\n * </UiDropdown>\n *\n * @example Right-aligned, drop-up\n * <UiDropdown align=\"right\" drop=\"up\" width=\"w-48\">\n * <template #trigger=\"{ toggle }\">\n * <UiButton variant=\"ghost\" icon-only @click=\"toggle\">\n * <UiIcon name=\"mdi:dots-vertical\" class=\"w-5 h-5\" />\n * </UiButton>\n * </template>\n * <slot />\n * </UiDropdown>\n *\n * @emits {void} open — Emitted when the dropdown opens\n * @emits {void} close — Emitted when the dropdown closes\n *\n * @slot trigger — Trigger element that opens the dropdown. Receives { open: boolean, toggle: Function }\n * @slot default — Dropdown menu content. Receives { close: Function }\n *\n * @see UiDropdownItem — Standard menu item for use inside this dropdown\n * @see UiDropdownSubmenu — Nested submenu for this dropdown\n */\nimport { ref, computed } from 'vue'\nimport { onClickOutside } from '../composables/onClickOutside.js'\nimport { useEventListener } from '../composables/useEventListener.js'\nimport { MENU_PANEL_CLASS } from '../internal/menu.js'\nconst props = defineProps({\n /**\n * Width class applied to the dropdown panel.\n * @type {string}\n * @default 'w-56'\n * @example 'w-48', 'w-64', 'w-72'\n */\n width: { type: String, default: 'w-56' },\n\n /**\n * Horizontal alignment of the panel relative to the trigger.\n * @type {string}\n * @default 'left'\n * @values 'left' | 'right'\n */\n align: { type: String, default: 'left' },\n\n /**\n * Drop direction — 'down' opens below the trigger, 'up' opens above.\n * @type {string}\n * @default 'down'\n * @values 'down' | 'up'\n */\n drop: { type: String, default: 'down' },\n\n /**\n * Override all default panel classes (bg, border, rounded, shadow).\n * When set, the built-in panel styling is completely replaced.\n * @type {string}\n * @default ''\n */\n panelClass: { type: String, default: '' },\n})\n\nconst emit = defineEmits(['open', 'close'])\n\nconst isOpen = ref(false)\nconst containerRef = ref(null)\n\n// Build panel positioning/styling classes, or use custom override\nconst panelClasses = computed(() => {\n if (props.panelClass) return props.panelClass\n const align = props.align === 'right' ? 'right-0' : 'left-0'\n const dropDir = props.drop === 'up' ? 'bottom-full mb-1' : 'mt-1'\n // `p-1` (not just `py-1`) insets the rows so their rounded hover highlight\n // reads as a chip with breathing room from the panel edge.\n return `absolute z-50 ${MENU_PANEL_CLASS} p-1 ${props.width} ${align} ${dropDir}`\n})\n\n// Inline transform-origin (not a Tailwind class, so it needs no build step to\n// take effect): the panel scales in from the corner nearest the trigger rather\n// than drifting in from its centre.\nconst panelOrigin = computed(() => {\n const y = props.drop === 'up' ? 'bottom' : 'top'\n const x = props.align === 'right' ? 'right' : 'left'\n return `${y} ${x}`\n})\n\n// Use slide-up transition for drop=\"up\", scale transition for drop=\"down\"\nconst transitionClasses = computed(() => {\n if (props.drop === 'up') {\n return {\n enterActive: 'transition ease-out duration-150',\n enterFrom: 'opacity-0 translate-y-1',\n enterTo: 'opacity-100 translate-y-0',\n leaveActive: 'transition ease-in duration-100',\n leaveFrom: 'opacity-100 translate-y-0',\n leaveTo: 'opacity-0 translate-y-1',\n }\n }\n return {\n enterActive: 'transition duration-100 ease-out',\n enterFrom: 'opacity-0 scale-95',\n enterTo: 'opacity-100 scale-100',\n leaveActive: 'transition duration-75 ease-in',\n leaveFrom: 'opacity-100 scale-100',\n leaveTo: 'opacity-0 scale-95',\n }\n})\n\nconst toggle = () => {\n isOpen.value = !isOpen.value\n emit(isOpen.value ? 'open' : 'close')\n}\n\nconst close = () => {\n if (isOpen.value) {\n isOpen.value = false\n emit('close')\n }\n}\n\nonClickOutside(containerRef, close)\n\nuseEventListener(globalThis.document, 'keydown', (e) => {\n if (e.key !== 'Escape' || !isOpen.value) return\n // Claim the key so an enclosing UiModal does not close too.\n e.preventDefault()\n close()\n})\n\ndefineExpose({ isOpen, toggle, close })\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8DA,MAAM,QAAQ;EAkCd,MAAM,OAAO;EAEb,MAAM,SAAS,IAAI,KAAK;EACxB,MAAM,eAAe,IAAI,IAAI;EAG7B,MAAM,eAAe,eAAe;GAClC,IAAI,MAAM,YAAY,OAAO,MAAM;GACnC,MAAM,QAAQ,MAAM,UAAU,UAAU,YAAY;GACpD,MAAM,UAAU,MAAM,SAAS,OAAO,qBAAqB;GAG3D,OAAO,iBAAiB,iBAAiB,OAAO,MAAM,MAAM,GAAG,MAAM,GAAG;EAC1E,CAAC;EAKD,MAAM,cAAc,eAAe;GAGjC,OAAO,GAFG,MAAM,SAAS,OAAO,WAAW,MAE/B,GADF,MAAM,UAAU,UAAU,UAAU;EAEhD,CAAC;EAGD,MAAM,oBAAoB,eAAe;GACvC,IAAI,MAAM,SAAS,MACjB,OAAO;IACL,aAAa;IACb,WAAW;IACX,SAAS;IACT,aAAa;IACb,WAAW;IACX,SAAS;GACX;GAEF,OAAO;IACL,aAAa;IACb,WAAW;IACX,SAAS;IACT,aAAa;IACb,WAAW;IACX,SAAS;GACX;EACF,CAAC;EAED,MAAM,eAAe;GACnB,OAAO,QAAQ,CAAC,OAAO;GACvB,KAAK,OAAO,QAAQ,SAAS,OAAO;EACtC;EAEA,MAAM,cAAc;GAClB,IAAI,OAAO,OAAO;IAChB,OAAO,QAAQ;IACf,KAAK,OAAO;GACd;EACF;EAEA,eAAe,cAAc,KAAK;EAElC,iBAAiB,WAAW,UAAU,YAAY,MAAM;GACtD,IAAI,EAAE,QAAQ,YAAY,CAAC,OAAO,OAAO;GAEzC,EAAE,eAAe;GACjB,MAAM;EACR,CAAC;EAED,SAAa;GAAE;GAAQ;GAAQ;EAAM,CAAC;;GAlKpC,OAAA,UAAA,GAAA,mBAiBM,OAAA;IAjBG,SAAA;IAAJ,KAAI;IAAe,OAAM;GAE5B,GAAA,CAAA,WAAuD,KAAA,QAAA,WAAA;IAAjC,MAAM,OAAA;IAAiB;GAG7C,CAAA,GAAA,YAWa,YAAA;IAVV,sBAAoB,kBAAA,MAAkB;IACtC,oBAAkB,kBAAA,MAAkB;IACpC,kBAAgB,kBAAA,MAAkB;IAClC,sBAAoB,kBAAA,MAAkB;IACtC,oBAAkB,kBAAA,MAAkB;IACpC,kBAAgB,kBAAA,MAAkB;;IAEnC,SAAA,cAEM,CAFN,eAAA,mBAEM,OAAA;KAFgB,OAAK,eAAE,aAAA,KAAY;KAAG,OAAK,eAAA,EAAA,iBAAqB,YAAA,MAAW,CAAA;IAC/E,GAAA,CAAA,WAAuB,KAAA,QAAA,WAAA,EAAT,MAAK,CAAA,CAAA,GAAA,CAAA,GAAA,CADR,CAAA,OAAA,OAAA,KAAM,CAAA,CAAA,CAAA,CAAA"}
|
package/dist/components/Modal.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { useBackButton } from "../composables/useBackButton.js";
|
|
2
|
-
import {
|
|
2
|
+
import { useFocusTrap } from "../internal/focusTrap.js";
|
|
3
|
+
import { Teleport, Transition, computed, createBlock, createCommentVNode, createElementBlock, createVNode, normalizeClass, onBeforeUnmount, openBlock, ref, renderSlot, watch, withCtx, withModifiers } from "vue";
|
|
3
4
|
//#region src/components/Modal.vue
|
|
5
|
+
var _hoisted_1 = ["aria-label", "aria-labelledby"];
|
|
4
6
|
var _sfc_main = {
|
|
5
7
|
__name: "Modal",
|
|
6
8
|
props: {
|
|
@@ -68,6 +70,35 @@ var _sfc_main = {
|
|
|
68
70
|
padding: {
|
|
69
71
|
type: String,
|
|
70
72
|
default: "md:p-4"
|
|
73
|
+
},
|
|
74
|
+
/**
|
|
75
|
+
* Accessible name for the dialog. Prefer `labelledby` when the content has a
|
|
76
|
+
* visible heading.
|
|
77
|
+
* @type {string}
|
|
78
|
+
* @default ''
|
|
79
|
+
*/
|
|
80
|
+
label: {
|
|
81
|
+
type: String,
|
|
82
|
+
default: ""
|
|
83
|
+
},
|
|
84
|
+
/**
|
|
85
|
+
* Id of the element that names the dialog, usually its heading.
|
|
86
|
+
* @type {string}
|
|
87
|
+
* @default ''
|
|
88
|
+
*/
|
|
89
|
+
labelledby: {
|
|
90
|
+
type: String,
|
|
91
|
+
default: ""
|
|
92
|
+
},
|
|
93
|
+
/**
|
|
94
|
+
* Whether Escape closes the modal. Ignored (treated as false) when
|
|
95
|
+
* `persistent` is set.
|
|
96
|
+
* @type {boolean}
|
|
97
|
+
* @default true
|
|
98
|
+
*/
|
|
99
|
+
closeOnEscape: {
|
|
100
|
+
type: Boolean,
|
|
101
|
+
default: true
|
|
71
102
|
}
|
|
72
103
|
},
|
|
73
104
|
emits: ["close"],
|
|
@@ -79,6 +110,13 @@ var _sfc_main = {
|
|
|
79
110
|
* (xs through 5xl and full-screen), persistent mode to prevent backdrop-click dismissal,
|
|
80
111
|
* and customizable z-index and padding. The panel uses a scale+fade transition on enter/leave.
|
|
81
112
|
*
|
|
113
|
+
* The panel is a real dialog: `role="dialog"` and `aria-modal="true"`, named by
|
|
114
|
+
* `label` or `labelledby`. While open, focus moves into the panel (unless
|
|
115
|
+
* something inside already has it), Tab and Shift+Tab wrap within it, Escape
|
|
116
|
+
* closes it (unless `persistent` or `close-on-escape` is false), and focus
|
|
117
|
+
* returns to whatever opened it. Stacked modals behave: only the top one
|
|
118
|
+
* responds to Tab and Escape.
|
|
119
|
+
*
|
|
82
120
|
* @example Basic modal
|
|
83
121
|
* <UiModal :show="isOpen" @close="isOpen = false">
|
|
84
122
|
* <div class="p-6">Hello!</div>
|
|
@@ -100,12 +138,24 @@ var _sfc_main = {
|
|
|
100
138
|
* <div class="p-6">Centered on all screens</div>
|
|
101
139
|
* </UiModal>
|
|
102
140
|
*
|
|
103
|
-
* @
|
|
141
|
+
* @example Named by its heading
|
|
142
|
+
* <UiModal :show="isOpen" labelledby="settings-title" @close="isOpen = false">
|
|
143
|
+
* <h2 id="settings-title">Settings</h2>
|
|
144
|
+
* </UiModal>
|
|
145
|
+
*
|
|
146
|
+
* @emits {void} close — Emitted when the modal should close (backdrop click, Escape,
|
|
147
|
+
* the Android back button, or programmatic)
|
|
104
148
|
*
|
|
105
149
|
* @slot default — Modal content
|
|
106
150
|
*/
|
|
107
151
|
const props = __props;
|
|
108
152
|
const emit = __emit;
|
|
153
|
+
const panelRef = ref(null);
|
|
154
|
+
useFocusTrap(() => panelRef.value, {
|
|
155
|
+
active: () => props.show,
|
|
156
|
+
escape: () => props.closeOnEscape && !props.persistent,
|
|
157
|
+
onEscape: () => emit("close")
|
|
158
|
+
});
|
|
109
159
|
const { register: registerBack, unregister: unregisterBack } = useBackButton();
|
|
110
160
|
let backHandlerId = null;
|
|
111
161
|
watch(() => props.show, (visible) => {
|
|
@@ -185,14 +235,21 @@ var _sfc_main = {
|
|
|
185
235
|
}, {
|
|
186
236
|
default: withCtx(() => [__props.show ? (openBlock(), createElementBlock("div", {
|
|
187
237
|
key: 0,
|
|
188
|
-
|
|
238
|
+
ref_key: "panelRef",
|
|
239
|
+
ref: panelRef,
|
|
240
|
+
role: "dialog",
|
|
241
|
+
"aria-modal": "true",
|
|
242
|
+
"aria-label": __props.labelledby ? void 0 : __props.label || void 0,
|
|
243
|
+
"aria-labelledby": __props.labelledby || void 0,
|
|
244
|
+
tabindex: "-1",
|
|
245
|
+
class: normalizeClass(["modal-panel bg-white dark:bg-gray-925 overflow-hidden flex flex-col focus:outline-none", [
|
|
189
246
|
__props.panelClass,
|
|
190
247
|
maxWidthClass.value,
|
|
191
248
|
roundedClass.value,
|
|
192
249
|
mobileLayoutClass.value
|
|
193
250
|
]]),
|
|
194
251
|
onClick: _cache[0] || (_cache[0] = withModifiers(() => {}, ["stop"]))
|
|
195
|
-
}, [renderSlot(_ctx.$slots, "default")],
|
|
252
|
+
}, [renderSlot(_ctx.$slots, "default")], 10, _hoisted_1)) : createCommentVNode("", true)]),
|
|
196
253
|
_: 3
|
|
197
254
|
})], 2)) : createCommentVNode("", true)]),
|
|
198
255
|
_: 3
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","names":["$emit"],"sources":["../../src/components/Modal.vue"],"sourcesContent":["<template>\n <!-- Teleported to body to avoid z-index stacking context issues -->\n <Teleport to=\"body\">\n <!-- Backdrop overlay with fade transition -->\n <Transition\n enter-active-class=\"transition ease-out duration-200\"\n enter-from-class=\"opacity-0\"\n enter-to-class=\"opacity-100\"\n leave-active-class=\"transition ease-in duration-150\"\n leave-from-class=\"opacity-100\"\n leave-to-class=\"opacity-0\"\n >\n <div\n v-if=\"show\"\n class=\"fixed inset-0 flex items-center justify-center\"\n :class=\"[zClass, paddingClass, backdropClass]\"\n @click.self=\"!persistent && $emit('close')\"\n >\n <Transition\n enter-active-class=\"transition ease-out duration-300\"\n enter-from-class=\"opacity-0 scale-95\"\n enter-to-class=\"opacity-100 scale-100\"\n leave-active-class=\"transition ease-in duration-200\"\n leave-from-class=\"opacity-100 scale-100\"\n leave-to-class=\"opacity-0 scale-95\"\n appear\n >\n <div\n v-if=\"show\"\n class=\"modal-panel bg-white dark:bg-gray-925 overflow-hidden flex flex-col\"\n :class=\"[panelClass, maxWidthClass, roundedClass, mobileLayoutClass]\"\n @click.stop\n >\n <slot />\n </div>\n </Transition>\n </div>\n </Transition>\n </Teleport>\n</template>\n\n<script setup>\n/**\n * UiModal — Teleported modal dialog with backdrop, configurable max-width, and enter/leave transitions.\n *\n * Renders a centered overlay panel teleported to `<body>`. Supports ten max-width presets\n * (xs through 5xl and full-screen), persistent mode to prevent backdrop-click dismissal,\n * and customizable z-index and padding. The panel uses a scale+fade transition on enter/leave.\n *\n * @example Basic modal\n * <UiModal :show=\"isOpen\" @close=\"isOpen = false\">\n * <div class=\"p-6\">Hello!</div>\n * </UiModal>\n *\n * @example Large persistent modal\n * <UiModal :show=\"showEditor\" max-width=\"3xl\" persistent>\n * <ModalHeader @close=\"showEditor = false\" />\n * <div class=\"p-6\">Editor content</div>\n * </UiModal>\n *\n * @example Full-screen modal\n * <UiModal :show=\"showFull\" max-width=\"full\">\n * <div class=\"h-full\">Full screen content</div>\n * </UiModal>\n *\n * @example Non-fullscreen on mobile\n * <UiModal :show=\"isOpen\" :fullscreen-mobile=\"false\" @close=\"isOpen = false\">\n * <div class=\"p-6\">Centered on all screens</div>\n * </UiModal>\n *\n * @emits {void} close — Emitted when the modal should close (backdrop click or programmatic)\n *\n * @slot default — Modal content\n */\nimport { computed, watch, onBeforeUnmount } from 'vue'\nimport { useBackButton } from '../composables/useBackButton.js'\nconst props = defineProps({\n /**\n * Controls modal visibility. Use with v-model or :show + @close.\n * @type {boolean}\n * @default false\n */\n show: { type: Boolean, default: false },\n\n /**\n * Maximum width preset for the modal panel.\n * @type {string}\n * @default 'sm'\n * @values 'xs' (20rem) | 'sm' (24rem) | 'md' (28rem) | 'lg' (32rem) | 'xl' (36rem) | '2xl' (42rem) | '3xl' (48rem) | '4xl' (56rem) | '5xl' (64rem) | 'full'\n */\n maxWidth: { type: String, default: 'sm' },\n\n /**\n * Whether the modal goes fullscreen on mobile viewports.\n * When true, the panel fills the screen on mobile and respects safe area insets.\n * @type {boolean}\n * @default true\n */\n fullscreenMobile: { type: Boolean, default: true },\n\n /**\n * Persistent mode — prevents closing when clicking the backdrop overlay.\n * @type {boolean}\n * @default false\n */\n persistent: { type: Boolean, default: false },\n\n /**\n * Additional CSS classes applied to the modal panel element.\n * @type {string}\n * @default ''\n */\n panelClass: { type: String, default: '' },\n\n /**\n * Z-index class for the backdrop and modal layers.\n * @type {string}\n * @default 'z-50'\n */\n z: { type: String, default: 'z-50' },\n\n /**\n * Padding class around the modal panel (applied to the backdrop container).\n * @type {string}\n * @default 'md:p-4'\n */\n padding: { type: String, default: 'md:p-4' },\n})\n\nconst emit = defineEmits(['close'])\n\n// ── Back-button interception (Capacitor) ──\nconst { register: registerBack, unregister: unregisterBack } = useBackButton()\nlet backHandlerId = null\n\nwatch(\n () => props.show,\n (visible) => {\n if (visible) {\n backHandlerId = registerBack(() => {\n if (props.persistent) return false\n emit('close')\n return true\n })\n } else if (backHandlerId !== null) {\n unregisterBack(backHandlerId)\n backHandlerId = null\n }\n },\n { immediate: true },\n)\n\nonBeforeUnmount(() => {\n if (backHandlerId !== null) {\n unregisterBack(backHandlerId)\n backHandlerId = null\n }\n})\n\nconst zClass = computed(() => props.z)\nconst paddingClass = computed(() => props.padding)\n\nconst backdropClass = computed(() => {\n if (props.fullscreenMobile) {\n return 'bg-transparent md:bg-black/50'\n }\n return 'bg-black/50 p-4'\n})\n\nconst mobileLayoutClass = computed(() => {\n if (props.maxWidth === 'full') return 'fixed inset-0'\n\n if (props.fullscreenMobile) {\n return 'fixed inset-0 modal-panel--safe-area md:static md:inset-auto'\n }\n // Non-fullscreen on mobile: centered dialog with max-height\n return 'relative max-h-[calc(100vh-2rem)] md:static'\n})\n\nconst maxWidthClass = computed(() => {\n if (props.maxWidth === 'full') return 'w-full h-full'\n\n const map = {\n xs: 'md:max-w-xs',\n sm: 'md:max-w-sm',\n md: 'md:max-w-md',\n lg: 'md:max-w-lg',\n xl: 'md:max-w-xl',\n '2xl': 'md:max-w-2xl',\n '3xl': 'md:max-w-3xl',\n '4xl': 'md:max-w-4xl',\n '5xl': 'md:max-w-5xl',\n }\n\n if (props.fullscreenMobile) {\n return `md:w-full ${map[props.maxWidth] || map.sm}`\n }\n return `w-full ${map[props.maxWidth] || map.sm}`\n})\n\nconst roundedClass = computed(() => {\n if (props.maxWidth === 'full') return 'rounded-none'\n\n if (props.fullscreenMobile) {\n return 'rounded-none md:rounded-lg'\n }\n return 'rounded-lg'\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4EA,MAAM,QAAQ;EAqDd,MAAM,OAAO;EAGb,MAAM,EAAE,UAAU,cAAc,YAAY,mBAAmB,cAAc;EAC7E,IAAI,gBAAgB;EAEpB,YACQ,MAAM,OACX,YAAY;GACX,IAAI,SACF,gBAAgB,mBAAmB;IACjC,IAAI,MAAM,YAAY,OAAO;IAC7B,KAAK,OAAO;IACZ,OAAO;GACT,CAAC;QACI,IAAI,kBAAkB,MAAM;IACjC,eAAe,aAAa;IAC5B,gBAAgB;GAClB;EACF,GACA,EAAE,WAAW,KAAK,CACpB;EAEA,sBAAsB;GACpB,IAAI,kBAAkB,MAAM;IAC1B,eAAe,aAAa;IAC5B,gBAAgB;GAClB;EACF,CAAC;EAED,MAAM,SAAS,eAAe,MAAM,CAAC;EACrC,MAAM,eAAe,eAAe,MAAM,OAAO;EAEjD,MAAM,gBAAgB,eAAe;GACnC,IAAI,MAAM,kBACR,OAAO;GAET,OAAO;EACT,CAAC;EAED,MAAM,oBAAoB,eAAe;GACvC,IAAI,MAAM,aAAa,QAAQ,OAAO;GAEtC,IAAI,MAAM,kBACR,OAAO;GAGT,OAAO;EACT,CAAC;EAED,MAAM,gBAAgB,eAAe;GACnC,IAAI,MAAM,aAAa,QAAQ,OAAO;GAEtC,MAAM,MAAM;IACV,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;GACT;GAEA,IAAI,MAAM,kBACR,OAAO,aAAa,IAAI,MAAM,aAAa,IAAI;GAEjD,OAAO,UAAU,IAAI,MAAM,aAAa,IAAI;EAC9C,CAAC;EAED,MAAM,eAAe,eAAe;GAClC,IAAI,MAAM,aAAa,QAAQ,OAAO;GAEtC,IAAI,MAAM,kBACR,OAAO;GAET,OAAO;EACT,CAAC;;GA7MC,OAAA,UAAA,GAAA,YAoCW,UAAA,EApCD,IAAG,OAAM,GAAA,CAEjB,YAiCa,YAAA;IAhCX,sBAAmB;IACnB,oBAAiB;IACjB,kBAAe;IACf,sBAAmB;IACnB,oBAAiB;IACjB,kBAAe;;IAEf,SAAA,cAwBM,CAvBE,QAAA,QADR,UAAA,GAAA,mBAwBM,OAAA;;KAtBJ,OAAK,eAAA,CAAC,kDAAgD;MAC7C,OAAA;MAAQ,aAAA;MAAc,cAAA;KAAa,CAAA,CAAA;KAC3C,SAAK,OAAA,OAAA,OAAA,KAAA,eAAA,WAAA,CAAQ,QAAA,cAAcA,KAAAA,MAAK,OAAA,GAAA,CAAA,MAAA,CAAA;IAEjC,GAAA,CAAA,YAiBa,YAAA;KAhBX,sBAAmB;KACnB,oBAAiB;KACjB,kBAAe;KACf,sBAAmB;KACnB,oBAAiB;KACjB,kBAAe;KACf,QAAA;;KAEA,SAAA,cAOM,CANE,QAAA,QADR,UAAA,GAAA,mBAOM,OAAA;;MALJ,OAAK,eAAA,CAAC,uEAAqE;OAClE,QAAA;OAAY,cAAA;OAAe,aAAA;OAAc,kBAAA;MAAiB,CAAA,CAAA;MAClE,SAAK,OAAA,OAAA,OAAA,KAAA,oBAAN,CAAA,GAAW,CAAA,MAAA,CAAA;KAEX,GAAA,CAAA,WAAQ,KAAA,QAAA,SAAA,CAAA,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"Modal.js","names":["$emit"],"sources":["../../src/components/Modal.vue"],"sourcesContent":["<template>\n <!-- Teleported to body to avoid z-index stacking context issues -->\n <Teleport to=\"body\">\n <!-- Backdrop overlay with fade transition -->\n <Transition\n enter-active-class=\"transition ease-out duration-200\"\n enter-from-class=\"opacity-0\"\n enter-to-class=\"opacity-100\"\n leave-active-class=\"transition ease-in duration-150\"\n leave-from-class=\"opacity-100\"\n leave-to-class=\"opacity-0\"\n >\n <div\n v-if=\"show\"\n class=\"fixed inset-0 flex items-center justify-center\"\n :class=\"[zClass, paddingClass, backdropClass]\"\n @click.self=\"!persistent && $emit('close')\"\n >\n <Transition\n enter-active-class=\"transition ease-out duration-300\"\n enter-from-class=\"opacity-0 scale-95\"\n enter-to-class=\"opacity-100 scale-100\"\n leave-active-class=\"transition ease-in duration-200\"\n leave-from-class=\"opacity-100 scale-100\"\n leave-to-class=\"opacity-0 scale-95\"\n appear\n >\n <div\n v-if=\"show\"\n ref=\"panelRef\"\n role=\"dialog\"\n aria-modal=\"true\"\n :aria-label=\"labelledby ? undefined : label || undefined\"\n :aria-labelledby=\"labelledby || undefined\"\n tabindex=\"-1\"\n class=\"modal-panel bg-white dark:bg-gray-925 overflow-hidden flex flex-col focus:outline-none\"\n :class=\"[panelClass, maxWidthClass, roundedClass, mobileLayoutClass]\"\n @click.stop\n >\n <slot />\n </div>\n </Transition>\n </div>\n </Transition>\n </Teleport>\n</template>\n\n<script setup>\n/**\n * UiModal — Teleported modal dialog with backdrop, configurable max-width, and enter/leave transitions.\n *\n * Renders a centered overlay panel teleported to `<body>`. Supports ten max-width presets\n * (xs through 5xl and full-screen), persistent mode to prevent backdrop-click dismissal,\n * and customizable z-index and padding. The panel uses a scale+fade transition on enter/leave.\n *\n * The panel is a real dialog: `role=\"dialog\"` and `aria-modal=\"true\"`, named by\n * `label` or `labelledby`. While open, focus moves into the panel (unless\n * something inside already has it), Tab and Shift+Tab wrap within it, Escape\n * closes it (unless `persistent` or `close-on-escape` is false), and focus\n * returns to whatever opened it. Stacked modals behave: only the top one\n * responds to Tab and Escape.\n *\n * @example Basic modal\n * <UiModal :show=\"isOpen\" @close=\"isOpen = false\">\n * <div class=\"p-6\">Hello!</div>\n * </UiModal>\n *\n * @example Large persistent modal\n * <UiModal :show=\"showEditor\" max-width=\"3xl\" persistent>\n * <ModalHeader @close=\"showEditor = false\" />\n * <div class=\"p-6\">Editor content</div>\n * </UiModal>\n *\n * @example Full-screen modal\n * <UiModal :show=\"showFull\" max-width=\"full\">\n * <div class=\"h-full\">Full screen content</div>\n * </UiModal>\n *\n * @example Non-fullscreen on mobile\n * <UiModal :show=\"isOpen\" :fullscreen-mobile=\"false\" @close=\"isOpen = false\">\n * <div class=\"p-6\">Centered on all screens</div>\n * </UiModal>\n *\n * @example Named by its heading\n * <UiModal :show=\"isOpen\" labelledby=\"settings-title\" @close=\"isOpen = false\">\n * <h2 id=\"settings-title\">Settings</h2>\n * </UiModal>\n *\n * @emits {void} close — Emitted when the modal should close (backdrop click, Escape,\n * the Android back button, or programmatic)\n *\n * @slot default — Modal content\n */\nimport { computed, ref, watch, onBeforeUnmount } from 'vue'\nimport { useBackButton } from '../composables/useBackButton.js'\nimport { useFocusTrap } from '../internal/focusTrap.js'\nconst props = defineProps({\n /**\n * Controls modal visibility. Use with v-model or :show + @close.\n * @type {boolean}\n * @default false\n */\n show: { type: Boolean, default: false },\n\n /**\n * Maximum width preset for the modal panel.\n * @type {string}\n * @default 'sm'\n * @values 'xs' (20rem) | 'sm' (24rem) | 'md' (28rem) | 'lg' (32rem) | 'xl' (36rem) | '2xl' (42rem) | '3xl' (48rem) | '4xl' (56rem) | '5xl' (64rem) | 'full'\n */\n maxWidth: { type: String, default: 'sm' },\n\n /**\n * Whether the modal goes fullscreen on mobile viewports.\n * When true, the panel fills the screen on mobile and respects safe area insets.\n * @type {boolean}\n * @default true\n */\n fullscreenMobile: { type: Boolean, default: true },\n\n /**\n * Persistent mode — prevents closing when clicking the backdrop overlay.\n * @type {boolean}\n * @default false\n */\n persistent: { type: Boolean, default: false },\n\n /**\n * Additional CSS classes applied to the modal panel element.\n * @type {string}\n * @default ''\n */\n panelClass: { type: String, default: '' },\n\n /**\n * Z-index class for the backdrop and modal layers.\n * @type {string}\n * @default 'z-50'\n */\n z: { type: String, default: 'z-50' },\n\n /**\n * Padding class around the modal panel (applied to the backdrop container).\n * @type {string}\n * @default 'md:p-4'\n */\n padding: { type: String, default: 'md:p-4' },\n /**\n * Accessible name for the dialog. Prefer `labelledby` when the content has a\n * visible heading.\n * @type {string}\n * @default ''\n */\n label: { type: String, default: '' },\n /**\n * Id of the element that names the dialog, usually its heading.\n * @type {string}\n * @default ''\n */\n labelledby: { type: String, default: '' },\n /**\n * Whether Escape closes the modal. Ignored (treated as false) when\n * `persistent` is set.\n * @type {boolean}\n * @default true\n */\n closeOnEscape: { type: Boolean, default: true },\n})\n\nconst emit = defineEmits(['close'])\n\n// ── Focus: move in, keep in, put back ──\nconst panelRef = ref(null)\nuseFocusTrap(() => panelRef.value, {\n active: () => props.show,\n escape: () => props.closeOnEscape && !props.persistent,\n onEscape: () => emit('close'),\n})\n\n// ── Back-button interception (Capacitor) ──\nconst { register: registerBack, unregister: unregisterBack } = useBackButton()\nlet backHandlerId = null\n\nwatch(\n () => props.show,\n (visible) => {\n if (visible) {\n backHandlerId = registerBack(() => {\n if (props.persistent) return false\n emit('close')\n return true\n })\n } else if (backHandlerId !== null) {\n unregisterBack(backHandlerId)\n backHandlerId = null\n }\n },\n { immediate: true },\n)\n\nonBeforeUnmount(() => {\n if (backHandlerId !== null) {\n unregisterBack(backHandlerId)\n backHandlerId = null\n }\n})\n\nconst zClass = computed(() => props.z)\nconst paddingClass = computed(() => props.padding)\n\nconst backdropClass = computed(() => {\n if (props.fullscreenMobile) {\n return 'bg-transparent md:bg-black/50'\n }\n return 'bg-black/50 p-4'\n})\n\nconst mobileLayoutClass = computed(() => {\n if (props.maxWidth === 'full') return 'fixed inset-0'\n\n if (props.fullscreenMobile) {\n return 'fixed inset-0 modal-panel--safe-area md:static md:inset-auto'\n }\n // Non-fullscreen on mobile: centered dialog with max-height\n return 'relative max-h-[calc(100vh-2rem)] md:static'\n})\n\nconst maxWidthClass = computed(() => {\n if (props.maxWidth === 'full') return 'w-full h-full'\n\n const map = {\n xs: 'md:max-w-xs',\n sm: 'md:max-w-sm',\n md: 'md:max-w-md',\n lg: 'md:max-w-lg',\n xl: 'md:max-w-xl',\n '2xl': 'md:max-w-2xl',\n '3xl': 'md:max-w-3xl',\n '4xl': 'md:max-w-4xl',\n '5xl': 'md:max-w-5xl',\n }\n\n if (props.fullscreenMobile) {\n return `md:w-full ${map[props.maxWidth] || map.sm}`\n }\n return `w-full ${map[props.maxWidth] || map.sm}`\n})\n\nconst roundedClass = computed(() => {\n if (props.maxWidth === 'full') return 'rounded-none'\n\n if (props.fullscreenMobile) {\n return 'rounded-none md:rounded-lg'\n }\n return 'rounded-lg'\n})\n</script>\n"],"mappings":"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"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
2
|
import _sfc_main$2 from "./Button.js";
|
|
3
3
|
import _sfc_main$3 from "./Modal.js";
|
|
4
|
-
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, nextTick, normalizeClass, openBlock, ref, renderSlot, toDisplayString, useSlots, watch, withCtx } from "vue";
|
|
4
|
+
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, nextTick, normalizeClass, openBlock, ref, renderSlot, toDisplayString, useId, useSlots, watch, withCtx } from "vue";
|
|
5
5
|
//#region src/components/Prompt.vue
|
|
6
6
|
var _hoisted_1 = { class: "flex items-center justify-between p-4 pb-0 mb-3 shrink-0" };
|
|
7
7
|
var _hoisted_2 = { class: "flex items-center gap-2" };
|
|
8
|
-
var _hoisted_3 = { class: "
|
|
9
|
-
var _hoisted_4 = { class: "flex justify-end gap-2 p-4 pt-0 shrink-0" };
|
|
8
|
+
var _hoisted_3 = { class: "flex justify-end gap-2 p-4 pt-0 shrink-0" };
|
|
10
9
|
var _sfc_main = {
|
|
11
10
|
__name: "Prompt",
|
|
12
11
|
props: {
|
|
@@ -105,6 +104,7 @@ var _sfc_main = {
|
|
|
105
104
|
const props = __props;
|
|
106
105
|
const emit = __emit;
|
|
107
106
|
const confirmRef = ref(null);
|
|
107
|
+
const titleId = `${useId()}-title`;
|
|
108
108
|
const hasCustomActions = computed(() => !!useSlots().actions);
|
|
109
109
|
const iconColorClass = computed(() => {
|
|
110
110
|
const map = {
|
|
@@ -139,6 +139,7 @@ var _sfc_main = {
|
|
|
139
139
|
"max-width": "sm",
|
|
140
140
|
"fullscreen-mobile": __props.fullscreenMobile,
|
|
141
141
|
"panel-class": __props.panelClass,
|
|
142
|
+
labelledby: titleId,
|
|
142
143
|
onClose: handleClose
|
|
143
144
|
}, {
|
|
144
145
|
default: withCtx(() => [createElementVNode("div", {
|
|
@@ -150,10 +151,14 @@ var _sfc_main = {
|
|
|
150
151
|
key: 0,
|
|
151
152
|
name: __props.icon,
|
|
152
153
|
class: normalizeClass(["w-5 h-5", iconColorClass.value])
|
|
153
|
-
}, null, 8, ["name", "class"])) : createCommentVNode("", true), createElementVNode("h2",
|
|
154
|
+
}, null, 8, ["name", "class"])) : createCommentVNode("", true), createElementVNode("h2", {
|
|
155
|
+
id: titleId,
|
|
156
|
+
class: "text-sm font-semibold text-gray-900 dark:text-gray-200 leading-none"
|
|
157
|
+
}, toDisplayString(__props.title), 1)]), createVNode(_sfc_main$2, {
|
|
154
158
|
variant: "ghost",
|
|
155
159
|
color: "gray",
|
|
156
160
|
"icon-only": "",
|
|
161
|
+
"aria-label": __props.cancelLabel,
|
|
157
162
|
onClick: handleClose
|
|
158
163
|
}, {
|
|
159
164
|
default: withCtx(() => [createVNode(_sfc_main$1, {
|
|
@@ -161,12 +166,12 @@ var _sfc_main = {
|
|
|
161
166
|
class: "block w-5 h-5"
|
|
162
167
|
})]),
|
|
163
168
|
_: 1
|
|
164
|
-
})]),
|
|
169
|
+
}, 8, ["aria-label"])]),
|
|
165
170
|
__props.body || _ctx.$slots.default ? (openBlock(), createElementBlock("div", {
|
|
166
171
|
key: 0,
|
|
167
172
|
class: normalizeClass(["text-sm text-gray-600 dark:text-gray-400 mb-4 leading-relaxed px-4 min-h-0", __props.panelClass.includes("overflow-visible") ? "overflow-visible" : "overflow-y-auto"])
|
|
168
173
|
}, [renderSlot(_ctx.$slots, "default", {}, () => [createTextVNode(toDisplayString(__props.body), 1)])], 2)) : createCommentVNode("", true),
|
|
169
|
-
createElementVNode("div",
|
|
174
|
+
createElementVNode("div", _hoisted_3, [renderSlot(_ctx.$slots, "actions", {}, () => [createVNode(_sfc_main$2, {
|
|
170
175
|
variant: "ghost",
|
|
171
176
|
color: "gray",
|
|
172
177
|
disabled: __props.loading,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Prompt.js","names":["$slots"],"sources":["../../src/components/Prompt.vue"],"sourcesContent":["<template>\n <UiModal\n :show=\"show\"\n max-width=\"sm\"\n :fullscreen-mobile=\"fullscreenMobile\"\n :panel-class=\"panelClass\"\n @close=\"handleClose\"\n >\n <div\n ref=\"promptRef\"\n class=\"flex flex-col max-h-full\"\n :class=\"panelClass.includes('overflow-visible') ? 'overflow-visible' : 'overflow-hidden'\"\n @keydown=\"onKeydown\"\n >\n <div class=\"flex items-center justify-between p-4 pb-0 mb-3 shrink-0\">\n <div class=\"flex items-center gap-2\">\n <UiIcon v-if=\"icon\" :name=\"icon\" class=\"w-5 h-5\" :class=\"iconColorClass\" />\n <h2
|
|
1
|
+
{"version":3,"file":"Prompt.js","names":["$slots"],"sources":["../../src/components/Prompt.vue"],"sourcesContent":["<template>\n <UiModal\n :show=\"show\"\n max-width=\"sm\"\n :fullscreen-mobile=\"fullscreenMobile\"\n :panel-class=\"panelClass\"\n :labelledby=\"titleId\"\n @close=\"handleClose\"\n >\n <div\n ref=\"promptRef\"\n class=\"flex flex-col max-h-full\"\n :class=\"panelClass.includes('overflow-visible') ? 'overflow-visible' : 'overflow-hidden'\"\n @keydown=\"onKeydown\"\n >\n <div class=\"flex items-center justify-between p-4 pb-0 mb-3 shrink-0\">\n <div class=\"flex items-center gap-2\">\n <UiIcon v-if=\"icon\" :name=\"icon\" class=\"w-5 h-5\" :class=\"iconColorClass\" />\n <h2\n :id=\"titleId\"\n class=\"text-sm font-semibold text-gray-900 dark:text-gray-200 leading-none\"\n >\n {{ title }}\n </h2>\n </div>\n <UiButton\n variant=\"ghost\"\n color=\"gray\"\n icon-only\n :aria-label=\"cancelLabel\"\n @click=\"handleClose\"\n >\n <UiIcon name=\"mdi:close\" class=\"block w-5 h-5\" />\n </UiButton>\n </div>\n\n <div\n v-if=\"body || $slots.default\"\n class=\"text-sm text-gray-600 dark:text-gray-400 mb-4 leading-relaxed px-4 min-h-0\"\n :class=\"panelClass.includes('overflow-visible') ? 'overflow-visible' : 'overflow-y-auto'\"\n >\n <slot>{{ body }}</slot>\n </div>\n\n <div class=\"flex justify-end gap-2 p-4 pt-0 shrink-0\">\n <slot name=\"actions\">\n <UiButton variant=\"ghost\" color=\"gray\" :disabled=\"loading\" @click=\"handleClose\">\n {{ cancelLabel }}\n </UiButton>\n <UiButton\n ref=\"confirmRef\"\n variant=\"solid\"\n :color=\"confirmColor\"\n :loading=\"loading\"\n @click=\"handleConfirm\"\n >\n {{ confirmLabel }}\n </UiButton>\n </slot>\n </div>\n </div>\n </UiModal>\n</template>\n\n<script setup>\n/**\n * UiPrompt — A modal prompt primitive for confirmations, choices, and user decisions.\n *\n * Wraps UiModal with a consistent header (icon + title + close), body content, and\n * action buttons. Handles keyboard (Escape to close, Enter to confirm), auto-focuses\n * the confirm button on open, and prevents double-submit while loading.\n *\n * For simple text prompts, use the `body` prop. For rich content, use the default slot.\n * Override the `#actions` slot for custom button layouts.\n *\n * @example Simple confirmation (props only, no slots needed)\n * <UiPrompt :show=\"confirming\" title=\"Delete item?\" body=\"This action cannot be undone.\"\n * icon=\"mdi:delete\" confirm-label=\"Delete\" confirm-color=\"red\"\n * @close=\"confirming = false\" @confirm=\"doDelete\" />\n *\n * @example Rich body content\n * <UiPrompt :show=\"open\" title=\"Warning\" @close=\"open = false\" @confirm=\"proceed\">\n * <p>This will affect <strong>{{ count }}</strong> items.</p>\n * </UiPrompt>\n *\n * @example Custom actions\n * <UiPrompt :show=\"choosing\" title=\"Export Options\" @close=\"choosing = false\">\n * Include results in the export?\n * <template #actions>\n * <UiButton variant=\"ghost\" color=\"gray\" @click=\"doExport(false)\">Without</UiButton>\n * <UiButton @click=\"doExport(true)\">With Results</UiButton>\n * </template>\n * </UiPrompt>\n *\n * @example Form prompt (disable Enter-to-confirm)\n * <UiPrompt :show=\"open\" title=\"New Group\" :confirm-on-enter=\"false\" @close=\"open = false\">\n * <UiInput v-model=\"name\" @keydown.enter=\"save\" />\n * </UiPrompt>\n */\nimport { ref, computed, watch, nextTick, useSlots, useId } from 'vue'\nimport UiButton from './Button.vue'\nimport UiModal from './Modal.vue'\nimport UiIcon from '../icons/Icon.vue'\nconst props = defineProps({\n /** Controls prompt visibility. */\n show: { type: Boolean, default: false },\n /** Prompt heading text. */\n title: { type: String, default: 'Confirm' },\n /** Optional icon name displayed before the title. */\n icon: { type: String, default: null },\n /** Plain text body content. Ignored when the default slot is used. */\n body: { type: String, default: null },\n /** Label for the confirm button (default actions only). */\n confirmLabel: { type: String, default: 'Confirm' },\n /** Label for the cancel button (default actions only). */\n cancelLabel: { type: String, default: 'Cancel' },\n /** Color of the confirm button and icon. */\n confirmColor: { type: String, default: 'primary' },\n /** Shows a loading spinner on the confirm button and prevents double-submit. */\n loading: { type: Boolean, default: false },\n /** Whether pressing Enter triggers confirm. Disable for form-based prompts. */\n confirmOnEnter: { type: Boolean, default: true },\n /** Whether the prompt goes fullscreen on mobile viewports. */\n fullscreenMobile: { type: Boolean, default: false },\n /** Additional CSS class(es) applied to the modal panel element. */\n panelClass: { type: String, default: '' },\n})\n\nconst emit = defineEmits(['close', 'confirm'])\n\nconst confirmRef = ref(null)\nconst titleId = `${useId()}-title`\nconst hasCustomActions = computed(() => !!useSlots().actions)\n\nconst iconColorClass = computed(() => {\n const map = {\n red: 'text-red-600 dark:text-red-400',\n amber: 'text-amber-600 dark:text-amber-400',\n primary: 'text-primary-600 dark:text-primary-400',\n gray: 'text-gray-500 dark:text-gray-400',\n }\n return map[props.confirmColor] || map.primary\n})\n\nconst handleClose = () => {\n if (!props.loading) emit('close')\n}\n\nconst handleConfirm = () => {\n if (!props.loading) emit('confirm')\n}\n\nconst onKeydown = (e) => {\n if (e.key === 'Enter' && props.confirmOnEnter && !hasCustomActions.value && !props.loading) {\n e.preventDefault()\n handleConfirm()\n }\n}\n\n// Auto-focus confirm button when prompt opens\nwatch(\n () => props.show,\n (open) => {\n if (open) {\n nextTick(() => {\n const el = confirmRef.value?.$el ?? confirmRef.value\n if (el instanceof HTMLElement) el.focus()\n })\n }\n },\n)\n</script>\n"],"mappings":"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"}
|
|
@@ -416,7 +416,7 @@ var _sfc_main = {
|
|
|
416
416
|
type: "text",
|
|
417
417
|
placeholder: "Search...",
|
|
418
418
|
class: "w-full px-2.5 py-1.5 text-sm border border-gray-200 dark:border-gray-700 rounded-md bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-gray-300 outline-none focus:ring-1 focus:ring-primary-500 placeholder-gray-400",
|
|
419
|
-
onKeydown: [withKeys(close, ["escape"]), withKeys(withModifiers(selectFirst, ["prevent"]), ["enter"])]
|
|
419
|
+
onKeydown: [withKeys(withModifiers(close, ["prevent"]), ["escape"]), withKeys(withModifiers(selectFirst, ["prevent"]), ["enter"])]
|
|
420
420
|
}, null, 40, _hoisted_6), [[vModelText, searchQuery.value]])])) : createCommentVNode("", true), createElementVNode("ul", _hoisted_7, [filteredOptions.value.length === 0 && filteredGroups.value.length === 0 ? (openBlock(), createElementBlock("li", _hoisted_8, " No results ")) : createCommentVNode("", true), filteredGroups.value.length === 0 ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(filteredOptions.value, (opt) => {
|
|
421
421
|
return openBlock(), createElementBlock("li", {
|
|
422
422
|
key: opt.value,
|