numori-ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +651 -0
- package/README.md +466 -0
- package/dist/components/Alert.js +137 -0
- package/dist/components/Alert.js.map +1 -0
- package/dist/components/Avatar.js +133 -0
- package/dist/components/Avatar.js.map +1 -0
- package/dist/components/Badge.js +93 -0
- package/dist/components/Badge.js.map +1 -0
- package/dist/components/Button.js +428 -0
- package/dist/components/Button.js.map +1 -0
- package/dist/components/ButtonsGroup.js +153 -0
- package/dist/components/ButtonsGroup.js.map +1 -0
- package/dist/components/Checkbox.js +93 -0
- package/dist/components/Checkbox.js.map +1 -0
- package/dist/components/Divider.js +79 -0
- package/dist/components/Divider.js.map +1 -0
- package/dist/components/Dropdown.js +166 -0
- package/dist/components/Dropdown.js.map +1 -0
- package/dist/components/DropdownItem.js +106 -0
- package/dist/components/DropdownItem.js.map +1 -0
- package/dist/components/DropdownRow.js +41 -0
- package/dist/components/DropdownRow.js.map +1 -0
- package/dist/components/DropdownSubmenu.js +142 -0
- package/dist/components/DropdownSubmenu.js.map +1 -0
- package/dist/components/FileInput.js +122 -0
- package/dist/components/FileInput.js.map +1 -0
- package/dist/components/FormField.js +112 -0
- package/dist/components/FormField.js.map +1 -0
- package/dist/components/Input.js +603 -0
- package/dist/components/Input.js.map +1 -0
- package/dist/components/Kbd.js +35 -0
- package/dist/components/Kbd.js.map +1 -0
- package/dist/components/ListMenu.js +143 -0
- package/dist/components/ListMenu.js.map +1 -0
- package/dist/components/ListMenuItem.js +189 -0
- package/dist/components/ListMenuItem.js.map +1 -0
- package/dist/components/Modal.js +206 -0
- package/dist/components/Modal.js.map +1 -0
- package/dist/components/Numpad.js +123 -0
- package/dist/components/Numpad.js.map +1 -0
- package/dist/components/Popup.js +170 -0
- package/dist/components/Popup.js.map +1 -0
- package/dist/components/ProgressBar.js +118 -0
- package/dist/components/ProgressBar.js.map +1 -0
- package/dist/components/Prompt.js +201 -0
- package/dist/components/Prompt.js.map +1 -0
- package/dist/components/Radio.js +81 -0
- package/dist/components/Radio.js.map +1 -0
- package/dist/components/Select.js +441 -0
- package/dist/components/Select.js.map +1 -0
- package/dist/components/Slider.js +116 -0
- package/dist/components/Slider.js.map +1 -0
- package/dist/components/Stepper.js +65 -0
- package/dist/components/Stepper.js.map +1 -0
- package/dist/components/Toggle.js +133 -0
- package/dist/components/Toggle.js.map +1 -0
- package/dist/components/Tooltip.js +120 -0
- package/dist/components/Tooltip.js.map +1 -0
- package/dist/components/index.js +81 -0
- package/dist/components/index.js.map +1 -0
- package/dist/composables/onClickOutside.js +51 -0
- package/dist/composables/onClickOutside.js.map +1 -0
- package/dist/composables/useBackButton.js +98 -0
- package/dist/composables/useBackButton.js.map +1 -0
- package/dist/composables/useEventListener.js +63 -0
- package/dist/composables/useEventListener.js.map +1 -0
- package/dist/icons/Icon.js +120 -0
- package/dist/icons/Icon.js.map +1 -0
- package/dist/icons/mdi.js +69 -0
- package/dist/icons/mdi.js.map +1 -0
- package/dist/icons/registry.js +63 -0
- package/dist/icons/registry.js.map +1 -0
- package/dist/icons/resolver.js +49 -0
- package/dist/icons/resolver.js.map +1 -0
- package/dist/index.d.ts +108 -0
- package/dist/index.js +157 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.js +89 -0
- package/dist/manifest.js.map +1 -0
- package/dist/numori-ui.css +184 -0
- package/dist/nuxt.d.ts +35 -0
- package/dist/nuxt.mjs +243 -0
- package/dist/nuxt.mjs.map +1 -0
- package/dist/vite.d.ts +29 -0
- package/dist/vite.mjs +187 -0
- package/dist/vite.mjs.map +1 -0
- package/package.json +138 -0
- package/src/components/Alert.vue +127 -0
- package/src/components/Avatar.vue +100 -0
- package/src/components/Badge.vue +77 -0
- package/src/components/Button.vue +419 -0
- package/src/components/ButtonsGroup.vue +140 -0
- package/src/components/Checkbox.vue +81 -0
- package/src/components/Divider.vue +64 -0
- package/src/components/Dropdown.vue +150 -0
- package/src/components/DropdownItem.vue +78 -0
- package/src/components/DropdownRow.vue +37 -0
- package/src/components/DropdownSubmenu.vue +127 -0
- package/src/components/FileInput.vue +107 -0
- package/src/components/FormField.vue +86 -0
- package/src/components/Input.vue +619 -0
- package/src/components/Kbd.vue +30 -0
- package/src/components/ListMenu.vue +127 -0
- package/src/components/ListMenuItem.vue +171 -0
- package/src/components/Modal.vue +209 -0
- package/src/components/Numpad.vue +118 -0
- package/src/components/Popup.vue +156 -0
- package/src/components/ProgressBar.vue +107 -0
- package/src/components/Prompt.vue +161 -0
- package/src/components/Radio.vue +50 -0
- package/src/components/Select.vue +470 -0
- package/src/components/Slider.vue +93 -0
- package/src/components/Stepper.vue +53 -0
- package/src/components/Toggle.vue +125 -0
- package/src/components/Tooltip.vue +113 -0
- package/src/components/index.js +109 -0
- package/src/composables/onClickOutside.js +61 -0
- package/src/composables/useBackButton.js +98 -0
- package/src/composables/useEventListener.js +65 -0
- package/src/icons/Icon.vue +139 -0
- package/src/icons/mdi.js +67 -0
- package/src/icons/registry.js +64 -0
- package/src/icons/resolver.js +48 -0
- package/src/index.js +167 -0
- package/src/manifest.js +86 -0
- package/src/nuxt.js +315 -0
- package/src/style.css +20 -0
- package/src/tailwind.css +18 -0
- package/src/theme.css +172 -0
- package/src/vite.js +235 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
|
+
import { useEventListener } from "../composables/useEventListener.js";
|
|
3
|
+
import { Fragment, createElementBlock, createElementVNode, createVNode, normalizeClass, openBlock, ref, renderList, renderSlot, toDisplayString } from "vue";
|
|
4
|
+
//#region src/components/Numpad.vue
|
|
5
|
+
var _hoisted_1 = ["disabled", "onClick"];
|
|
6
|
+
var _hoisted_2 = ["disabled"];
|
|
7
|
+
var _hoisted_3 = ["disabled"];
|
|
8
|
+
var _sfc_main = {
|
|
9
|
+
__name: "Numpad",
|
|
10
|
+
props: {
|
|
11
|
+
/** Whether the numpad is disabled */
|
|
12
|
+
disabled: {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
default: false
|
|
15
|
+
},
|
|
16
|
+
/** Whether the delete button is enabled */
|
|
17
|
+
canDelete: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: false
|
|
20
|
+
},
|
|
21
|
+
/** Whether the numpad listens for keyboard input globally */
|
|
22
|
+
captureKeyboard: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
default: false
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
emits: ["digit", "delete"],
|
|
28
|
+
setup(__props, { emit: __emit }) {
|
|
29
|
+
/**
|
|
30
|
+
* UiNumpad — A numeric keypad primitive for PIN entry and similar use cases.
|
|
31
|
+
*
|
|
32
|
+
* Emits digit presses and delete actions. Supports physical keyboard input
|
|
33
|
+
* with visual key highlighting. Exposes a bottom-left slot for custom actions
|
|
34
|
+
* (e.g. biometrics button).
|
|
35
|
+
*
|
|
36
|
+
* @example Basic usage
|
|
37
|
+
* <UiNumpad :can-delete="pin.length > 0" @digit="onDigit" @delete="onDelete" />
|
|
38
|
+
*
|
|
39
|
+
* @example With biometrics slot
|
|
40
|
+
* <UiNumpad :can-delete="pin.length > 0" @digit="onDigit" @delete="onDelete">
|
|
41
|
+
* <template #bottom-left>
|
|
42
|
+
* <button @click="useBiometrics">🔒</button>
|
|
43
|
+
* </template>
|
|
44
|
+
* </UiNumpad>
|
|
45
|
+
*/
|
|
46
|
+
const props = __props;
|
|
47
|
+
const emit = __emit;
|
|
48
|
+
const numpadRef = ref(null);
|
|
49
|
+
const pressedKey = ref(null);
|
|
50
|
+
const onDigit = (digit) => {
|
|
51
|
+
if (props.disabled) return;
|
|
52
|
+
emit("digit", digit);
|
|
53
|
+
};
|
|
54
|
+
const handleKeydown = (e) => {
|
|
55
|
+
if (props.disabled) return;
|
|
56
|
+
if (/^[0-9]$/.test(e.key)) {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
const digit = Number(e.key);
|
|
59
|
+
pressedKey.value = digit;
|
|
60
|
+
setTimeout(() => {
|
|
61
|
+
pressedKey.value = null;
|
|
62
|
+
}, 150);
|
|
63
|
+
onDigit(digit);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (e.key === "Backspace") {
|
|
67
|
+
e.preventDefault();
|
|
68
|
+
emit("delete");
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
useEventListener(() => props.captureKeyboard ? globalThis.window : null, "keydown", handleKeydown);
|
|
72
|
+
return (_ctx, _cache) => {
|
|
73
|
+
return openBlock(), createElementBlock("div", {
|
|
74
|
+
ref_key: "numpadRef",
|
|
75
|
+
ref: numpadRef,
|
|
76
|
+
class: "grid grid-cols-3 gap-3 max-w-[264px] mx-auto outline-none"
|
|
77
|
+
}, [
|
|
78
|
+
(openBlock(), createElementBlock(Fragment, null, renderList([
|
|
79
|
+
1,
|
|
80
|
+
2,
|
|
81
|
+
3,
|
|
82
|
+
4,
|
|
83
|
+
5,
|
|
84
|
+
6,
|
|
85
|
+
7,
|
|
86
|
+
8,
|
|
87
|
+
9
|
|
88
|
+
], (n) => {
|
|
89
|
+
return createElementVNode("button", {
|
|
90
|
+
key: n,
|
|
91
|
+
type: "button",
|
|
92
|
+
tabindex: "-1",
|
|
93
|
+
class: normalizeClass(["h-16 w-full text-xl font-medium rounded-2xl transition-all duration-150 text-gray-800 dark:text-gray-100 border shadow-sm active:scale-95", pressedKey.value === n ? "bg-primary-50 dark:bg-primary-900/30 border-primary-300 dark:border-primary-600 scale-95" : "bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-750 active:bg-gray-100 dark:active:bg-gray-700"]),
|
|
94
|
+
disabled: __props.disabled,
|
|
95
|
+
onClick: ($event) => onDigit(n)
|
|
96
|
+
}, toDisplayString(n), 11, _hoisted_1);
|
|
97
|
+
}), 64)),
|
|
98
|
+
renderSlot(_ctx.$slots, "bottom-left", {}, () => [_cache[2] || (_cache[2] = createElementVNode("div", null, null, -1))]),
|
|
99
|
+
createElementVNode("button", {
|
|
100
|
+
type: "button",
|
|
101
|
+
tabindex: "-1",
|
|
102
|
+
class: normalizeClass(["h-16 w-full text-xl font-medium rounded-2xl transition-all duration-150 text-gray-800 dark:text-gray-100 border shadow-sm active:scale-95", pressedKey.value === 0 ? "bg-primary-50 dark:bg-primary-900/30 border-primary-300 dark:border-primary-600 scale-95" : "bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-750 active:bg-gray-100 dark:active:bg-gray-700"]),
|
|
103
|
+
disabled: __props.disabled,
|
|
104
|
+
onClick: _cache[0] || (_cache[0] = ($event) => onDigit(0))
|
|
105
|
+
}, " 0 ", 10, _hoisted_2),
|
|
106
|
+
createElementVNode("button", {
|
|
107
|
+
type: "button",
|
|
108
|
+
tabindex: "-1",
|
|
109
|
+
class: "h-16 w-full rounded-2xl transition-all duration-150 flex items-center justify-center text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 active:scale-95 disabled:opacity-30 disabled:pointer-events-none",
|
|
110
|
+
disabled: !__props.canDelete,
|
|
111
|
+
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("delete"))
|
|
112
|
+
}, [createVNode(_sfc_main$1, {
|
|
113
|
+
name: "mdi:backspace-outline",
|
|
114
|
+
class: "w-6 h-6"
|
|
115
|
+
})], 8, _hoisted_3)
|
|
116
|
+
], 512);
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
//#endregion
|
|
121
|
+
export { _sfc_main as default };
|
|
122
|
+
|
|
123
|
+
//# sourceMappingURL=Numpad.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Numpad.js","names":["$emit"],"sources":["../../src/components/Numpad.vue"],"sourcesContent":["<template>\n <div ref=\"numpadRef\" class=\"grid grid-cols-3 gap-3 max-w-[264px] mx-auto outline-none\">\n <button\n v-for=\"n in [1, 2, 3, 4, 5, 6, 7, 8, 9]\"\n :key=\"n\"\n type=\"button\"\n tabindex=\"-1\"\n class=\"h-16 w-full text-xl font-medium rounded-2xl transition-all duration-150 text-gray-800 dark:text-gray-100 border shadow-sm active:scale-95\"\n :class=\"\n pressedKey === n\n ? 'bg-primary-50 dark:bg-primary-900/30 border-primary-300 dark:border-primary-600 scale-95'\n : 'bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-750 active:bg-gray-100 dark:active:bg-gray-700'\n \"\n :disabled=\"disabled\"\n @click=\"onDigit(n)\"\n >\n {{ n }}\n </button>\n\n <!-- Bottom-left slot (e.g. biometrics button) -->\n <slot name=\"bottom-left\">\n <div />\n </slot>\n\n <button\n type=\"button\"\n tabindex=\"-1\"\n class=\"h-16 w-full text-xl font-medium rounded-2xl transition-all duration-150 text-gray-800 dark:text-gray-100 border shadow-sm active:scale-95\"\n :class=\"\n pressedKey === 0\n ? 'bg-primary-50 dark:bg-primary-900/30 border-primary-300 dark:border-primary-600 scale-95'\n : 'bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-750 active:bg-gray-100 dark:active:bg-gray-700'\n \"\n :disabled=\"disabled\"\n @click=\"onDigit(0)\"\n >\n 0\n </button>\n\n <button\n type=\"button\"\n tabindex=\"-1\"\n class=\"h-16 w-full rounded-2xl transition-all duration-150 flex items-center justify-center text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 active:scale-95 disabled:opacity-30 disabled:pointer-events-none\"\n :disabled=\"!canDelete\"\n @click=\"$emit('delete')\"\n >\n <UiIcon name=\"mdi:backspace-outline\" class=\"w-6 h-6\" />\n </button>\n </div>\n</template>\n\n<script setup>\n/**\n * UiNumpad — A numeric keypad primitive for PIN entry and similar use cases.\n *\n * Emits digit presses and delete actions. Supports physical keyboard input\n * with visual key highlighting. Exposes a bottom-left slot for custom actions\n * (e.g. biometrics button).\n *\n * @example Basic usage\n * <UiNumpad :can-delete=\"pin.length > 0\" @digit=\"onDigit\" @delete=\"onDelete\" />\n *\n * @example With biometrics slot\n * <UiNumpad :can-delete=\"pin.length > 0\" @digit=\"onDigit\" @delete=\"onDelete\">\n * <template #bottom-left>\n * <button @click=\"useBiometrics\">🔒</button>\n * </template>\n * </UiNumpad>\n */\nimport { ref } from 'vue'\nimport UiIcon from '../icons/Icon.vue'\nimport { useEventListener } from '../composables/useEventListener.js'\n\nconst props = defineProps({\n /** Whether the numpad is disabled */\n disabled: { type: Boolean, default: false },\n /** Whether the delete button is enabled */\n canDelete: { type: Boolean, default: false },\n /** Whether the numpad listens for keyboard input globally */\n captureKeyboard: { type: Boolean, default: false },\n})\n\nconst emit = defineEmits(['digit', 'delete'])\n\nconst numpadRef = ref(null)\nconst pressedKey = ref(null)\n\nconst onDigit = (digit) => {\n if (props.disabled) return\n emit('digit', digit)\n}\n\nconst handleKeydown = (e) => {\n if (props.disabled) return\n\n if (/^[0-9]$/.test(e.key)) {\n e.preventDefault()\n const digit = Number(e.key)\n pressedKey.value = digit\n setTimeout(() => {\n pressedKey.value = null\n }, 150)\n onDigit(digit)\n return\n }\n\n if (e.key === 'Backspace') {\n e.preventDefault()\n emit('delete')\n }\n}\n\n// Global keyboard capture, bound only while `captureKeyboard` is set.\n// The target is a getter so it re-evaluates when the prop changes, and is\n// nullish during SSR — useEventListener skips nullish targets and tears the\n// listener down with the component, so no manual cleanup is needed.\nuseEventListener(() => (props.captureKeyboard ? globalThis.window : null), 'keydown', handleKeydown)\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyEA,MAAM,QAAQ;EASd,MAAM,OAAO;EAEb,MAAM,YAAY,IAAI,IAAI;EAC1B,MAAM,aAAa,IAAI,IAAI;EAE3B,MAAM,WAAW,UAAU;GACzB,IAAI,MAAM,UAAU;GACpB,KAAK,SAAS,KAAK;EACrB;EAEA,MAAM,iBAAiB,MAAM;GAC3B,IAAI,MAAM,UAAU;GAEpB,IAAI,UAAU,KAAK,EAAE,GAAG,GAAG;IACzB,EAAE,eAAe;IACjB,MAAM,QAAQ,OAAO,EAAE,GAAG;IAC1B,WAAW,QAAQ;IACnB,iBAAiB;KACf,WAAW,QAAQ;IACrB,GAAG,GAAG;IACN,QAAQ,KAAK;IACb;GACF;GAEA,IAAI,EAAE,QAAQ,aAAa;IACzB,EAAE,eAAe;IACjB,KAAK,QAAQ;GACf;EACF;EAMA,uBAAwB,MAAM,kBAAkB,WAAW,SAAS,MAAO,WAAW,aAAa;;GAnHjG,OAAA,UAAA,GAAA,mBA+CM,OAAA;IA/CG,SAAA;IAAJ,KAAI;IAAY,OAAM;;KACzB,UAAA,GAAA,mBAeS,UAAA,MAAA,WAdK;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;IAAA,IAAL,MAAC;KADV,OAAA,mBAeS,UAAA;MAbN,KAAK;MACN,MAAK;MACL,UAAS;MACT,OAAK,eAAA,CAAC,6IACW,WAAA,UAAe,IAAA,6FAAA,mJAAA,CAAA;MAK/B,UAAU,QAAA;MACV,UAAK,WAAE,QAAQ,CAAC;KAEd,GAAA,gBAAA,CAAC,GAAA,IAAA,UAAA;;IAIN,WAEO,KAAA,QAAA,eAAA,CAAA,SAAA,CADL,OAAA,OAAA,OAAA,KAAA,mBAAO,OAAA,MAAA,MAAA,EAAA,EAAA,CAAA;IAGT,mBAaS,UAAA;KAZP,MAAK;KACL,UAAS;KACT,OAAK,eAAA,CAAC,6IACW,WAAA,UAAU,IAAA,6FAAA,mJAAA,CAAA;KAK1B,UAAU,QAAA;KACV,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,QAAO,CAAA;IAChB,GAAA,OAED,IAAA,UAAA;IAEA,mBAQS,UAAA;KAPP,MAAK;KACL,UAAS;KACT,OAAM;KACL,UAAQ,CAAG,QAAA;KACX,SAAK,OAAA,OAAA,OAAA,MAAA,WAAEA,KAAAA,MAAK,QAAA;IAEb,GAAA,CAAA,YAAuD,aAAA;KAA/C,MAAK;KAAwB,OAAM"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { Transition, computed, createCommentVNode, createElementBlock, createVNode, nextTick, normalizeClass, normalizeStyle, openBlock, ref, renderSlot, watch, withCtx } from "vue";
|
|
2
|
+
//#region src/components/Popup.vue
|
|
3
|
+
var _sfc_main = {
|
|
4
|
+
__name: "Popup",
|
|
5
|
+
props: {
|
|
6
|
+
/**
|
|
7
|
+
* Controls popup visibility.
|
|
8
|
+
* @type {boolean}
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
show: {
|
|
12
|
+
type: Boolean,
|
|
13
|
+
default: false
|
|
14
|
+
},
|
|
15
|
+
/**
|
|
16
|
+
* Horizontal position in pixels relative to the offset parent.
|
|
17
|
+
* @type {number}
|
|
18
|
+
* @default 0
|
|
19
|
+
*/
|
|
20
|
+
x: {
|
|
21
|
+
type: Number,
|
|
22
|
+
default: 0
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* Vertical position in pixels relative to the offset parent.
|
|
26
|
+
* @type {number}
|
|
27
|
+
* @default 0
|
|
28
|
+
*/
|
|
29
|
+
y: {
|
|
30
|
+
type: Number,
|
|
31
|
+
default: 0
|
|
32
|
+
},
|
|
33
|
+
/**
|
|
34
|
+
* Additional vertical offset added to the y position (e.g. to clear a trigger element).
|
|
35
|
+
* @type {number}
|
|
36
|
+
* @default 0
|
|
37
|
+
*/
|
|
38
|
+
offsetY: {
|
|
39
|
+
type: Number,
|
|
40
|
+
default: 0
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* Width class for the popup panel.
|
|
44
|
+
* @type {string}
|
|
45
|
+
* @default 'w-56'
|
|
46
|
+
*/
|
|
47
|
+
width: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: "w-56"
|
|
50
|
+
},
|
|
51
|
+
/**
|
|
52
|
+
* Z-index class for the popup panel.
|
|
53
|
+
* @type {string}
|
|
54
|
+
* @default 'z-50'
|
|
55
|
+
*/
|
|
56
|
+
panelZ: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: "z-50"
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
* Z-index class for the invisible backdrop behind the panel.
|
|
62
|
+
* @type {string}
|
|
63
|
+
* @default 'z-40'
|
|
64
|
+
*/
|
|
65
|
+
backdropZ: {
|
|
66
|
+
type: String,
|
|
67
|
+
default: "z-40"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
emits: ["close"],
|
|
71
|
+
setup(__props) {
|
|
72
|
+
/**
|
|
73
|
+
* UiPopup — Absolutely positioned popup panel with viewport-aware clamping.
|
|
74
|
+
*
|
|
75
|
+
* Renders a floating panel at the given (x, y) coordinates relative to its offset parent.
|
|
76
|
+
* Automatically clamps position to keep the panel within the visible viewport with an 8px margin.
|
|
77
|
+
* Includes an invisible full-screen backdrop that emits 'close' on click.
|
|
78
|
+
*
|
|
79
|
+
* @example Context menu popup
|
|
80
|
+
* <UiPopup :show="showMenu" :x="menuX" :y="menuY" @close="showMenu = false">
|
|
81
|
+
* <UiDropdownItem icon="mdi:pencil" label="Edit" @click="edit" />
|
|
82
|
+
* <UiDropdownItem icon="mdi:trash-can" label="Delete" color="red" @click="del" />
|
|
83
|
+
* </UiPopup>
|
|
84
|
+
*
|
|
85
|
+
* @example Popup with offset and custom width
|
|
86
|
+
* <UiPopup :show="open" :x="posX" :y="posY" :offset-y="8" width="w-64" @close="open = false">
|
|
87
|
+
* <div class="p-3">Custom content</div>
|
|
88
|
+
* </UiPopup>
|
|
89
|
+
*
|
|
90
|
+
* @emits {void} close — Emitted when the backdrop is clicked to dismiss the popup
|
|
91
|
+
*
|
|
92
|
+
* @slot default — Popup content
|
|
93
|
+
*/
|
|
94
|
+
const props = __props;
|
|
95
|
+
const panelRef = ref(null);
|
|
96
|
+
const clampedPos = ref({
|
|
97
|
+
left: 0,
|
|
98
|
+
top: 0
|
|
99
|
+
});
|
|
100
|
+
const positionStyle = computed(() => ({
|
|
101
|
+
left: clampedPos.value.left + "px",
|
|
102
|
+
top: clampedPos.value.top + "px"
|
|
103
|
+
}));
|
|
104
|
+
const updatePosition = () => {
|
|
105
|
+
const left = props.x;
|
|
106
|
+
const top = props.y + props.offsetY;
|
|
107
|
+
nextTick(() => {
|
|
108
|
+
const el = panelRef.value;
|
|
109
|
+
if (!el) return;
|
|
110
|
+
const parentRect = (el.offsetParent || document.body).getBoundingClientRect();
|
|
111
|
+
const panelW = el.offsetWidth;
|
|
112
|
+
const panelH = el.offsetHeight;
|
|
113
|
+
const viewW = window.innerWidth;
|
|
114
|
+
const viewH = window.innerHeight;
|
|
115
|
+
let absLeft = parentRect.left + left;
|
|
116
|
+
let absTop = parentRect.top + top;
|
|
117
|
+
const margin = 8;
|
|
118
|
+
if (absLeft + panelW > viewW - margin) absLeft = viewW - panelW - margin;
|
|
119
|
+
if (absLeft < margin) absLeft = margin;
|
|
120
|
+
if (absTop + panelH > viewH - margin) absTop = viewH - panelH - margin;
|
|
121
|
+
if (absTop < margin) absTop = margin;
|
|
122
|
+
clampedPos.value = {
|
|
123
|
+
left: absLeft - parentRect.left,
|
|
124
|
+
top: absTop - parentRect.top
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
watch(() => [
|
|
129
|
+
props.show,
|
|
130
|
+
props.x,
|
|
131
|
+
props.y,
|
|
132
|
+
props.offsetY
|
|
133
|
+
], () => {
|
|
134
|
+
if (props.show) {
|
|
135
|
+
clampedPos.value = {
|
|
136
|
+
left: props.x,
|
|
137
|
+
top: props.y + props.offsetY
|
|
138
|
+
};
|
|
139
|
+
updatePosition();
|
|
140
|
+
}
|
|
141
|
+
}, { immediate: true });
|
|
142
|
+
return (_ctx, _cache) => {
|
|
143
|
+
return openBlock(), createElementBlock("div", null, [__props.show ? (openBlock(), createElementBlock("div", {
|
|
144
|
+
key: 0,
|
|
145
|
+
class: normalizeClass(["fixed inset-0", __props.backdropZ]),
|
|
146
|
+
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("close"))
|
|
147
|
+
}, null, 2)) : createCommentVNode("", true), createVNode(Transition, {
|
|
148
|
+
"enter-active-class": "transition duration-100 ease-out",
|
|
149
|
+
"enter-from-class": "opacity-0 scale-95",
|
|
150
|
+
"enter-to-class": "opacity-100 scale-100",
|
|
151
|
+
"leave-active-class": "transition duration-75 ease-in",
|
|
152
|
+
"leave-from-class": "opacity-100 scale-100",
|
|
153
|
+
"leave-to-class": "opacity-0 scale-95"
|
|
154
|
+
}, {
|
|
155
|
+
default: withCtx(() => [__props.show ? (openBlock(), createElementBlock("div", {
|
|
156
|
+
key: 0,
|
|
157
|
+
ref_key: "panelRef",
|
|
158
|
+
ref: panelRef,
|
|
159
|
+
class: normalizeClass(["absolute bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1", [__props.width, __props.panelZ]]),
|
|
160
|
+
style: normalizeStyle(positionStyle.value)
|
|
161
|
+
}, [renderSlot(_ctx.$slots, "default")], 6)) : createCommentVNode("", true)]),
|
|
162
|
+
_: 3
|
|
163
|
+
})]);
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
//#endregion
|
|
168
|
+
export { _sfc_main as default };
|
|
169
|
+
|
|
170
|
+
//# sourceMappingURL=Popup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popup.js","names":["$emit"],"sources":["../../src/components/Popup.vue"],"sourcesContent":["<template>\n <div>\n <!-- Invisible full-screen backdrop to capture outside clicks -->\n <div v-if=\"show\" class=\"fixed inset-0\" :class=\"backdropZ\" @click=\"$emit('close')\" />\n <!-- Animated popup panel positioned at (x, y + offsetY) -->\n <Transition\n enter-active-class=\"transition duration-100 ease-out\"\n enter-from-class=\"opacity-0 scale-95\"\n enter-to-class=\"opacity-100 scale-100\"\n leave-active-class=\"transition duration-75 ease-in\"\n leave-from-class=\"opacity-100 scale-100\"\n leave-to-class=\"opacity-0 scale-95\"\n >\n <div\n v-if=\"show\"\n ref=\"panelRef\"\n class=\"absolute bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1\"\n :class=\"[width, panelZ]\"\n :style=\"positionStyle\"\n >\n <slot />\n </div>\n </Transition>\n </div>\n</template>\n\n<script setup>\n/**\n * UiPopup — Absolutely positioned popup panel with viewport-aware clamping.\n *\n * Renders a floating panel at the given (x, y) coordinates relative to its offset parent.\n * Automatically clamps position to keep the panel within the visible viewport with an 8px margin.\n * Includes an invisible full-screen backdrop that emits 'close' on click.\n *\n * @example Context menu popup\n * <UiPopup :show=\"showMenu\" :x=\"menuX\" :y=\"menuY\" @close=\"showMenu = false\">\n * <UiDropdownItem icon=\"mdi:pencil\" label=\"Edit\" @click=\"edit\" />\n * <UiDropdownItem icon=\"mdi:trash-can\" label=\"Delete\" color=\"red\" @click=\"del\" />\n * </UiPopup>\n *\n * @example Popup with offset and custom width\n * <UiPopup :show=\"open\" :x=\"posX\" :y=\"posY\" :offset-y=\"8\" width=\"w-64\" @close=\"open = false\">\n * <div class=\"p-3\">Custom content</div>\n * </UiPopup>\n *\n * @emits {void} close — Emitted when the backdrop is clicked to dismiss the popup\n *\n * @slot default — Popup content\n */\nimport { ref, computed, watch, nextTick } from 'vue'\nconst props = defineProps({\n /**\n * Controls popup visibility.\n * @type {boolean}\n * @default false\n */\n show: { type: Boolean, default: false },\n\n /**\n * Horizontal position in pixels relative to the offset parent.\n * @type {number}\n * @default 0\n */\n x: { type: Number, default: 0 },\n\n /**\n * Vertical position in pixels relative to the offset parent.\n * @type {number}\n * @default 0\n */\n y: { type: Number, default: 0 },\n\n /**\n * Additional vertical offset added to the y position (e.g. to clear a trigger element).\n * @type {number}\n * @default 0\n */\n offsetY: { type: Number, default: 0 },\n\n /**\n * Width class for the popup panel.\n * @type {string}\n * @default 'w-56'\n */\n width: { type: String, default: 'w-56' },\n\n /**\n * Z-index class for the popup panel.\n * @type {string}\n * @default 'z-50'\n */\n panelZ: { type: String, default: 'z-50' },\n\n /**\n * Z-index class for the invisible backdrop behind the panel.\n * @type {string}\n * @default 'z-40'\n */\n backdropZ: { type: String, default: 'z-40' },\n})\n\ndefineEmits(['close'])\n\nconst panelRef = ref(null)\nconst clampedPos = ref({ left: 0, top: 0 })\n\nconst positionStyle = computed(() => ({\n left: clampedPos.value.left + 'px',\n top: clampedPos.value.top + 'px',\n}))\n\n// Clamp the panel position so it stays within the viewport (8px margin)\nconst updatePosition = () => {\n const left = props.x\n const top = props.y + props.offsetY\n\n nextTick(() => {\n const el = panelRef.value\n if (!el) return\n\n const parent = el.offsetParent || document.body\n const parentRect = parent.getBoundingClientRect()\n const panelW = el.offsetWidth\n const panelH = el.offsetHeight\n const viewW = window.innerWidth\n const viewH = window.innerHeight\n\n // Convert to viewport coords, clamp, convert back\n let absLeft = parentRect.left + left\n let absTop = parentRect.top + top\n\n const margin = 8\n if (absLeft + panelW > viewW - margin) absLeft = viewW - panelW - margin\n if (absLeft < margin) absLeft = margin\n if (absTop + panelH > viewH - margin) absTop = viewH - panelH - margin\n if (absTop < margin) absTop = margin\n\n clampedPos.value = {\n left: absLeft - parentRect.left,\n top: absTop - parentRect.top,\n }\n })\n}\n\nwatch(\n () => [props.show, props.x, props.y, props.offsetY],\n () => {\n if (props.show) {\n // Set initial position immediately so the panel renders near the right spot\n clampedPos.value = { left: props.x, top: props.y + props.offsetY }\n updatePosition()\n }\n },\n { immediate: true },\n)\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkDA,MAAM,QAAQ;EAqDd,MAAM,WAAW,IAAI,IAAI;EACzB,MAAM,aAAa,IAAI;GAAE,MAAM;GAAG,KAAK;EAAE,CAAC;EAE1C,MAAM,gBAAgB,gBAAgB;GACpC,MAAM,WAAW,MAAM,OAAO;GAC9B,KAAK,WAAW,MAAM,MAAM;EAC9B,EAAE;EAGF,MAAM,uBAAuB;GAC3B,MAAM,OAAO,MAAM;GACnB,MAAM,MAAM,MAAM,IAAI,MAAM;GAE5B,eAAe;IACb,MAAM,KAAK,SAAS;IACpB,IAAI,CAAC,IAAI;IAGT,MAAM,cADS,GAAG,gBAAgB,SAAS,KAAA,CACjB,sBAAsB;IAChD,MAAM,SAAS,GAAG;IAClB,MAAM,SAAS,GAAG;IAClB,MAAM,QAAQ,OAAO;IACrB,MAAM,QAAQ,OAAO;IAGrB,IAAI,UAAU,WAAW,OAAO;IAChC,IAAI,SAAS,WAAW,MAAM;IAE9B,MAAM,SAAS;IACf,IAAI,UAAU,SAAS,QAAQ,QAAQ,UAAU,QAAQ,SAAS;IAClE,IAAI,UAAU,QAAQ,UAAU;IAChC,IAAI,SAAS,SAAS,QAAQ,QAAQ,SAAS,QAAQ,SAAS;IAChE,IAAI,SAAS,QAAQ,SAAS;IAE9B,WAAW,QAAQ;KACjB,MAAM,UAAU,WAAW;KAC3B,KAAK,SAAS,WAAW;IAC3B;GACF,CAAC;EACH;EAEA,YACQ;GAAC,MAAM;GAAM,MAAM;GAAG,MAAM;GAAG,MAAM;EAAO,SAC5C;GACJ,IAAI,MAAM,MAAM;IAEd,WAAW,QAAQ;KAAE,MAAM,MAAM;KAAG,KAAK,MAAM,IAAI,MAAM;IAAQ;IACjE,eAAe;GACjB;EACF,GACA,EAAE,WAAW,KAAK,CACpB;;GAzJE,OAAA,UAAA,GAAA,mBAsBM,OAAA,MAAA,CApBO,QAAA,QAAX,UAAA,GAAA,mBAAoF,OAAA;;IAAnE,OAAK,eAAA,CAAC,iBAAwB,QAAA,SAAS,CAAA;IAAG,SAAK,OAAA,OAAA,OAAA,MAAA,WAAEA,KAAAA,MAAK,OAAA;GAEvE,GAAA,MAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,GAAA,YAiBa,YAAA;IAhBX,sBAAmB;IACnB,oBAAiB;IACjB,kBAAe;IACf,sBAAmB;IACnB,oBAAiB;IACjB,kBAAe;;IAEf,SAAA,cAQM,CAPE,QAAA,QADR,UAAA,GAAA,mBAQM,OAAA;;KANA,SAAA;KAAJ,KAAI;KACJ,OAAK,eAAA,CAAC,4GAA0G,CACvG,QAAA,OAAO,QAAA,MAAM,CAAA,CAAA;KACrB,OAAK,eAAE,cAAA,KAAa;IAErB,GAAA,CAAA,WAAQ,KAAA,QAAA,SAAA,CAAA,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { computed, createCommentVNode, createElementBlock, createElementVNode, normalizeClass, normalizeStyle, openBlock, toDisplayString } from "vue";
|
|
2
|
+
//#region src/components/ProgressBar.vue
|
|
3
|
+
var _hoisted_1 = { class: "space-y-1" };
|
|
4
|
+
var _hoisted_2 = {
|
|
5
|
+
key: 0,
|
|
6
|
+
class: "flex items-center justify-between text-xs text-gray-500 dark:text-gray-500"
|
|
7
|
+
};
|
|
8
|
+
var _hoisted_3 = { key: 0 };
|
|
9
|
+
var _hoisted_4 = { key: 1 };
|
|
10
|
+
var trackClass = "bg-gray-200 dark:bg-gray-700";
|
|
11
|
+
var _sfc_main = {
|
|
12
|
+
__name: "ProgressBar",
|
|
13
|
+
props: {
|
|
14
|
+
/**
|
|
15
|
+
* Current progress value.
|
|
16
|
+
* @type {number}
|
|
17
|
+
* @default 0
|
|
18
|
+
*/
|
|
19
|
+
current: {
|
|
20
|
+
type: Number,
|
|
21
|
+
default: 0
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* Total/maximum value (denominator for percentage calculation).
|
|
25
|
+
* @type {number}
|
|
26
|
+
* @default 100
|
|
27
|
+
*/
|
|
28
|
+
total: {
|
|
29
|
+
type: Number,
|
|
30
|
+
default: 100
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* Optional label text displayed above the bar on the left.
|
|
34
|
+
* @type {string}
|
|
35
|
+
* @default ''
|
|
36
|
+
*/
|
|
37
|
+
label: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: ""
|
|
40
|
+
},
|
|
41
|
+
/**
|
|
42
|
+
* Show "current / total" text above the bar on the right.
|
|
43
|
+
* @type {boolean}
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
showValue: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: false
|
|
49
|
+
},
|
|
50
|
+
/**
|
|
51
|
+
* Color theme for the fill bar.
|
|
52
|
+
* @type {string}
|
|
53
|
+
* @default 'primary'
|
|
54
|
+
* @values 'primary' | 'green' | 'red' | 'amber'
|
|
55
|
+
*/
|
|
56
|
+
color: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: "primary"
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
* Track height preset.
|
|
62
|
+
* @type {string}
|
|
63
|
+
* @default 'sm'
|
|
64
|
+
* @values 'xs' (h-1) | 'sm' (h-2) | 'md' (h-3)
|
|
65
|
+
*/
|
|
66
|
+
height: {
|
|
67
|
+
type: String,
|
|
68
|
+
default: "sm"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
setup(__props) {
|
|
72
|
+
/**
|
|
73
|
+
* UiProgressBar — Horizontal progress bar with label, value display, and color themes.
|
|
74
|
+
*
|
|
75
|
+
* Renders a rounded track with an animated fill bar representing current/total progress.
|
|
76
|
+
* Supports an optional text label above the bar and a "current / total" value display.
|
|
77
|
+
* The fill percentage is clamped to 0–100% and handles zero-total gracefully.
|
|
78
|
+
*
|
|
79
|
+
* @example Basic progress bar
|
|
80
|
+
* <UiProgressBar :current="45" :total="100" />
|
|
81
|
+
*
|
|
82
|
+
* @example Labeled progress with value
|
|
83
|
+
* <UiProgressBar :current="3" :total="10" label="Steps" show-value />
|
|
84
|
+
*
|
|
85
|
+
* @example Red thin progress bar
|
|
86
|
+
* <UiProgressBar :current="90" :total="100" color="red" height="xs" />
|
|
87
|
+
*/
|
|
88
|
+
const props = __props;
|
|
89
|
+
const percentage = computed(() => props.total > 0 ? Math.min(100, Math.round(props.current / props.total * 100)) : 0);
|
|
90
|
+
const heightClass = computed(() => {
|
|
91
|
+
const map = {
|
|
92
|
+
xs: "h-1",
|
|
93
|
+
sm: "h-2",
|
|
94
|
+
md: "h-3"
|
|
95
|
+
};
|
|
96
|
+
return map[props.height] || map.sm;
|
|
97
|
+
});
|
|
98
|
+
const barClass = computed(() => {
|
|
99
|
+
const map = {
|
|
100
|
+
primary: "bg-primary-600",
|
|
101
|
+
green: "bg-success-600",
|
|
102
|
+
red: "bg-red-600",
|
|
103
|
+
amber: "bg-amber-600"
|
|
104
|
+
};
|
|
105
|
+
return map[props.color] || map.primary;
|
|
106
|
+
});
|
|
107
|
+
return (_ctx, _cache) => {
|
|
108
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [__props.label || __props.showValue ? (openBlock(), createElementBlock("div", _hoisted_2, [__props.label ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(__props.label), 1)) : createCommentVNode("", true), __props.showValue ? (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(__props.current) + " / " + toDisplayString(__props.total), 1)) : createCommentVNode("", true)])) : createCommentVNode("", true), createElementVNode("div", { class: normalizeClass(["w-full rounded-full overflow-hidden", [trackClass, heightClass.value]]) }, [createElementVNode("div", {
|
|
109
|
+
class: normalizeClass(["h-full rounded-full transition-all duration-200", barClass.value]),
|
|
110
|
+
style: normalizeStyle({ width: percentage.value + "%" })
|
|
111
|
+
}, null, 6)], 2)]);
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
//#endregion
|
|
116
|
+
export { _sfc_main as default };
|
|
117
|
+
|
|
118
|
+
//# sourceMappingURL=ProgressBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProgressBar.js","names":[],"sources":["../../src/components/ProgressBar.vue"],"sourcesContent":["<template>\n <div class=\"space-y-1\">\n <!-- Optional label and value display row -->\n <div\n v-if=\"label || showValue\"\n class=\"flex items-center justify-between text-xs text-gray-500 dark:text-gray-500\"\n >\n <span v-if=\"label\">{{ label }}</span>\n <span v-if=\"showValue\">{{ current }} / {{ total }}</span>\n </div>\n <!-- Track background with animated fill bar -->\n <div class=\"w-full rounded-full overflow-hidden\" :class=\"[trackClass, heightClass]\">\n <div\n class=\"h-full rounded-full transition-all duration-200\"\n :class=\"barClass\"\n :style=\"{ width: percentage + '%' }\"\n />\n </div>\n </div>\n</template>\n\n<script setup>\n/**\n * UiProgressBar — Horizontal progress bar with label, value display, and color themes.\n *\n * Renders a rounded track with an animated fill bar representing current/total progress.\n * Supports an optional text label above the bar and a \"current / total\" value display.\n * The fill percentage is clamped to 0–100% and handles zero-total gracefully.\n *\n * @example Basic progress bar\n * <UiProgressBar :current=\"45\" :total=\"100\" />\n *\n * @example Labeled progress with value\n * <UiProgressBar :current=\"3\" :total=\"10\" label=\"Steps\" show-value />\n *\n * @example Red thin progress bar\n * <UiProgressBar :current=\"90\" :total=\"100\" color=\"red\" height=\"xs\" />\n */\nimport { computed } from 'vue'\nconst props = defineProps({\n /**\n * Current progress value.\n * @type {number}\n * @default 0\n */\n current: { type: Number, default: 0 },\n\n /**\n * Total/maximum value (denominator for percentage calculation).\n * @type {number}\n * @default 100\n */\n total: { type: Number, default: 100 },\n\n /**\n * Optional label text displayed above the bar on the left.\n * @type {string}\n * @default ''\n */\n label: { type: String, default: '' },\n\n /**\n * Show \"current / total\" text above the bar on the right.\n * @type {boolean}\n * @default false\n */\n showValue: { type: Boolean, default: false },\n\n /**\n * Color theme for the fill bar.\n * @type {string}\n * @default 'primary'\n * @values 'primary' | 'green' | 'red' | 'amber'\n */\n color: { type: String, default: 'primary' },\n\n /**\n * Track height preset.\n * @type {string}\n * @default 'sm'\n * @values 'xs' (h-1) | 'sm' (h-2) | 'md' (h-3)\n */\n height: { type: String, default: 'sm' },\n})\n\n// Calculate fill percentage, clamped to 0–100, safe against zero total\nconst percentage = computed(() =>\n props.total > 0 ? Math.min(100, Math.round((props.current / props.total) * 100)) : 0,\n)\n\nconst heightClass = computed(() => {\n const map = { xs: 'h-1', sm: 'h-2', md: 'h-3' }\n return map[props.height] || map.sm\n})\n\nconst trackClass = 'bg-gray-200 dark:bg-gray-700'\n\nconst barClass = computed(() => {\n const map = {\n primary: 'bg-primary-600',\n green: 'bg-success-600',\n red: 'bg-red-600',\n amber: 'bg-amber-600',\n }\n return map[props.color] || map.primary\n})\n</script>\n"],"mappings":";;;;;;;;;AA+FA,IAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAxDnB,MAAM,QAAQ;EA+Cd,MAAM,aAAa,eACjB,MAAM,QAAQ,IAAI,KAAK,IAAI,KAAK,KAAK,MAAO,MAAM,UAAU,MAAM,QAAS,GAAG,CAAC,IAAI,CACrF;EAEA,MAAM,cAAc,eAAe;GACjC,MAAM,MAAM;IAAE,IAAI;IAAO,IAAI;IAAO,IAAI;GAAM;GAC9C,OAAO,IAAI,MAAM,WAAW,IAAI;EAClC,CAAC;EAID,MAAM,WAAW,eAAe;GAC9B,MAAM,MAAM;IACV,SAAS;IACT,OAAO;IACP,KAAK;IACL,OAAO;GACT;GACA,OAAO,IAAI,MAAM,UAAU,IAAI;EACjC,CAAC;;GAxGC,OAAA,UAAA,GAAA,mBAiBM,OAjBN,YAiBM,CAdI,QAAA,SAAS,QAAA,aADjB,UAAA,GAAA,mBAMM,OANN,YAMM,CAFQ,QAAA,SAAZ,UAAA,GAAA,mBAAqC,QAAA,YAAA,gBAAf,QAAA,KAAK,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,GACf,QAAA,aAAZ,UAAA,GAAA,mBAAyD,QAAA,YAAA,gBAA/B,QAAA,OAAO,IAAG,QAAG,gBAAG,QAAA,KAAK,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,CAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,GAGjD,mBAMM,OAAA,EAND,OAAK,eAAA,CAAC,uCAAqC,CAAU,YAAY,YAAA,KAAW,CAAA,CAAA,EAAA,GAAA,CAC/E,mBAIE,OAAA;IAHA,OAAK,eAAA,CAAC,mDACE,SAAA,KAAQ,CAAA;IACf,OAAK,eAAA,EAAA,OAAW,WAAA,QAAU,IAAA,CAAA"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
|
+
import _sfc_main$2 from "./Button.js";
|
|
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";
|
|
5
|
+
//#region src/components/Prompt.vue
|
|
6
|
+
var _hoisted_1 = { class: "flex items-center justify-between p-4 pb-0 mb-3 shrink-0" };
|
|
7
|
+
var _hoisted_2 = { class: "flex items-center gap-2" };
|
|
8
|
+
var _hoisted_3 = { class: "text-sm font-semibold text-gray-900 dark:text-gray-200 leading-none" };
|
|
9
|
+
var _hoisted_4 = { class: "flex justify-end gap-2 p-4 pt-0 shrink-0" };
|
|
10
|
+
var _sfc_main = {
|
|
11
|
+
__name: "Prompt",
|
|
12
|
+
props: {
|
|
13
|
+
/** Controls prompt visibility. */
|
|
14
|
+
show: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: false
|
|
17
|
+
},
|
|
18
|
+
/** Prompt heading text. */
|
|
19
|
+
title: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: "Confirm"
|
|
22
|
+
},
|
|
23
|
+
/** Optional icon name displayed before the title. */
|
|
24
|
+
icon: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: null
|
|
27
|
+
},
|
|
28
|
+
/** Plain text body content. Ignored when the default slot is used. */
|
|
29
|
+
body: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: null
|
|
32
|
+
},
|
|
33
|
+
/** Label for the confirm button (default actions only). */
|
|
34
|
+
confirmLabel: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: "Confirm"
|
|
37
|
+
},
|
|
38
|
+
/** Label for the cancel button (default actions only). */
|
|
39
|
+
cancelLabel: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: "Cancel"
|
|
42
|
+
},
|
|
43
|
+
/** Color of the confirm button and icon. */
|
|
44
|
+
confirmColor: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: "primary"
|
|
47
|
+
},
|
|
48
|
+
/** Shows a loading spinner on the confirm button and prevents double-submit. */
|
|
49
|
+
loading: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: false
|
|
52
|
+
},
|
|
53
|
+
/** Whether pressing Enter triggers confirm. Disable for form-based prompts. */
|
|
54
|
+
confirmOnEnter: {
|
|
55
|
+
type: Boolean,
|
|
56
|
+
default: true
|
|
57
|
+
},
|
|
58
|
+
/** Whether the prompt goes fullscreen on mobile viewports. */
|
|
59
|
+
fullscreenMobile: {
|
|
60
|
+
type: Boolean,
|
|
61
|
+
default: false
|
|
62
|
+
},
|
|
63
|
+
/** Additional CSS class(es) applied to the modal panel element. */
|
|
64
|
+
panelClass: {
|
|
65
|
+
type: String,
|
|
66
|
+
default: ""
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
emits: ["close", "confirm"],
|
|
70
|
+
setup(__props, { emit: __emit }) {
|
|
71
|
+
/**
|
|
72
|
+
* UiPrompt — A modal prompt primitive for confirmations, choices, and user decisions.
|
|
73
|
+
*
|
|
74
|
+
* Wraps UiModal with a consistent header (icon + title + close), body content, and
|
|
75
|
+
* action buttons. Handles keyboard (Escape to close, Enter to confirm), auto-focuses
|
|
76
|
+
* the confirm button on open, and prevents double-submit while loading.
|
|
77
|
+
*
|
|
78
|
+
* For simple text prompts, use the `body` prop. For rich content, use the default slot.
|
|
79
|
+
* Override the `#actions` slot for custom button layouts.
|
|
80
|
+
*
|
|
81
|
+
* @example Simple confirmation (props only, no slots needed)
|
|
82
|
+
* <UiPrompt :show="confirming" title="Delete item?" body="This action cannot be undone."
|
|
83
|
+
* icon="mdi:delete" confirm-label="Delete" confirm-color="red"
|
|
84
|
+
* @close="confirming = false" @confirm="doDelete" />
|
|
85
|
+
*
|
|
86
|
+
* @example Rich body content
|
|
87
|
+
* <UiPrompt :show="open" title="Warning" @close="open = false" @confirm="proceed">
|
|
88
|
+
* <p>This will affect <strong>{{ count }}</strong> items.</p>
|
|
89
|
+
* </UiPrompt>
|
|
90
|
+
*
|
|
91
|
+
* @example Custom actions
|
|
92
|
+
* <UiPrompt :show="choosing" title="Export Options" @close="choosing = false">
|
|
93
|
+
* Include results in the export?
|
|
94
|
+
* <template #actions>
|
|
95
|
+
* <UiButton variant="ghost" color="gray" @click="doExport(false)">Without</UiButton>
|
|
96
|
+
* <UiButton @click="doExport(true)">With Results</UiButton>
|
|
97
|
+
* </template>
|
|
98
|
+
* </UiPrompt>
|
|
99
|
+
*
|
|
100
|
+
* @example Form prompt (disable Enter-to-confirm)
|
|
101
|
+
* <UiPrompt :show="open" title="New Group" :confirm-on-enter="false" @close="open = false">
|
|
102
|
+
* <UiInput v-model="name" @keydown.enter="save" />
|
|
103
|
+
* </UiPrompt>
|
|
104
|
+
*/
|
|
105
|
+
const props = __props;
|
|
106
|
+
const emit = __emit;
|
|
107
|
+
const confirmRef = ref(null);
|
|
108
|
+
const hasCustomActions = computed(() => !!useSlots().actions);
|
|
109
|
+
const iconColorClass = computed(() => {
|
|
110
|
+
const map = {
|
|
111
|
+
red: "text-red-600 dark:text-red-400",
|
|
112
|
+
amber: "text-amber-600 dark:text-amber-400",
|
|
113
|
+
primary: "text-primary-600 dark:text-primary-400",
|
|
114
|
+
gray: "text-gray-500 dark:text-gray-400"
|
|
115
|
+
};
|
|
116
|
+
return map[props.confirmColor] || map.primary;
|
|
117
|
+
});
|
|
118
|
+
const handleClose = () => {
|
|
119
|
+
if (!props.loading) emit("close");
|
|
120
|
+
};
|
|
121
|
+
const handleConfirm = () => {
|
|
122
|
+
if (!props.loading) emit("confirm");
|
|
123
|
+
};
|
|
124
|
+
const onKeydown = (e) => {
|
|
125
|
+
if (e.key === "Enter" && props.confirmOnEnter && !hasCustomActions.value && !props.loading) {
|
|
126
|
+
e.preventDefault();
|
|
127
|
+
handleConfirm();
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
watch(() => props.show, (open) => {
|
|
131
|
+
if (open) nextTick(() => {
|
|
132
|
+
const el = confirmRef.value?.$el ?? confirmRef.value;
|
|
133
|
+
if (el instanceof HTMLElement) el.focus();
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
return (_ctx, _cache) => {
|
|
137
|
+
return openBlock(), createBlock(_sfc_main$3, {
|
|
138
|
+
show: __props.show,
|
|
139
|
+
"max-width": "sm",
|
|
140
|
+
"fullscreen-mobile": __props.fullscreenMobile,
|
|
141
|
+
"panel-class": __props.panelClass,
|
|
142
|
+
onClose: handleClose
|
|
143
|
+
}, {
|
|
144
|
+
default: withCtx(() => [createElementVNode("div", {
|
|
145
|
+
ref: "promptRef",
|
|
146
|
+
class: normalizeClass(["flex flex-col max-h-full", __props.panelClass.includes("overflow-visible") ? "overflow-visible" : "overflow-hidden"]),
|
|
147
|
+
onKeydown
|
|
148
|
+
}, [
|
|
149
|
+
createElementVNode("div", _hoisted_1, [createElementVNode("div", _hoisted_2, [__props.icon ? (openBlock(), createBlock(_sfc_main$1, {
|
|
150
|
+
key: 0,
|
|
151
|
+
name: __props.icon,
|
|
152
|
+
class: normalizeClass(["w-5 h-5", iconColorClass.value])
|
|
153
|
+
}, null, 8, ["name", "class"])) : createCommentVNode("", true), createElementVNode("h2", _hoisted_3, toDisplayString(__props.title), 1)]), createVNode(_sfc_main$2, {
|
|
154
|
+
variant: "ghost",
|
|
155
|
+
color: "gray",
|
|
156
|
+
"icon-only": "",
|
|
157
|
+
onClick: handleClose
|
|
158
|
+
}, {
|
|
159
|
+
default: withCtx(() => [createVNode(_sfc_main$1, {
|
|
160
|
+
name: "mdi:close",
|
|
161
|
+
class: "block w-5 h-5"
|
|
162
|
+
})]),
|
|
163
|
+
_: 1
|
|
164
|
+
})]),
|
|
165
|
+
__props.body || _ctx.$slots.default ? (openBlock(), createElementBlock("div", {
|
|
166
|
+
key: 0,
|
|
167
|
+
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
|
+
}, [renderSlot(_ctx.$slots, "default", {}, () => [createTextVNode(toDisplayString(__props.body), 1)])], 2)) : createCommentVNode("", true),
|
|
169
|
+
createElementVNode("div", _hoisted_4, [renderSlot(_ctx.$slots, "actions", {}, () => [createVNode(_sfc_main$2, {
|
|
170
|
+
variant: "ghost",
|
|
171
|
+
color: "gray",
|
|
172
|
+
disabled: __props.loading,
|
|
173
|
+
onClick: handleClose
|
|
174
|
+
}, {
|
|
175
|
+
default: withCtx(() => [createTextVNode(toDisplayString(__props.cancelLabel), 1)]),
|
|
176
|
+
_: 1
|
|
177
|
+
}, 8, ["disabled"]), createVNode(_sfc_main$2, {
|
|
178
|
+
ref_key: "confirmRef",
|
|
179
|
+
ref: confirmRef,
|
|
180
|
+
variant: "solid",
|
|
181
|
+
color: __props.confirmColor,
|
|
182
|
+
loading: __props.loading,
|
|
183
|
+
onClick: handleConfirm
|
|
184
|
+
}, {
|
|
185
|
+
default: withCtx(() => [createTextVNode(toDisplayString(__props.confirmLabel), 1)]),
|
|
186
|
+
_: 1
|
|
187
|
+
}, 8, ["color", "loading"])])])
|
|
188
|
+
], 34)]),
|
|
189
|
+
_: 3
|
|
190
|
+
}, 8, [
|
|
191
|
+
"show",
|
|
192
|
+
"fullscreen-mobile",
|
|
193
|
+
"panel-class"
|
|
194
|
+
]);
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
//#endregion
|
|
199
|
+
export { _sfc_main as default };
|
|
200
|
+
|
|
201
|
+
//# sourceMappingURL=Prompt.js.map
|