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,156 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<!-- Invisible full-screen backdrop to capture outside clicks -->
|
|
4
|
+
<div v-if="show" class="fixed inset-0" :class="backdropZ" @click="$emit('close')" />
|
|
5
|
+
<!-- Animated popup panel positioned at (x, y + offsetY) -->
|
|
6
|
+
<Transition
|
|
7
|
+
enter-active-class="transition duration-100 ease-out"
|
|
8
|
+
enter-from-class="opacity-0 scale-95"
|
|
9
|
+
enter-to-class="opacity-100 scale-100"
|
|
10
|
+
leave-active-class="transition duration-75 ease-in"
|
|
11
|
+
leave-from-class="opacity-100 scale-100"
|
|
12
|
+
leave-to-class="opacity-0 scale-95"
|
|
13
|
+
>
|
|
14
|
+
<div
|
|
15
|
+
v-if="show"
|
|
16
|
+
ref="panelRef"
|
|
17
|
+
class="absolute bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1"
|
|
18
|
+
:class="[width, panelZ]"
|
|
19
|
+
:style="positionStyle"
|
|
20
|
+
>
|
|
21
|
+
<slot />
|
|
22
|
+
</div>
|
|
23
|
+
</Transition>
|
|
24
|
+
</div>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<script setup>
|
|
28
|
+
/**
|
|
29
|
+
* UiPopup — Absolutely positioned popup panel with viewport-aware clamping.
|
|
30
|
+
*
|
|
31
|
+
* Renders a floating panel at the given (x, y) coordinates relative to its offset parent.
|
|
32
|
+
* Automatically clamps position to keep the panel within the visible viewport with an 8px margin.
|
|
33
|
+
* Includes an invisible full-screen backdrop that emits 'close' on click.
|
|
34
|
+
*
|
|
35
|
+
* @example Context menu popup
|
|
36
|
+
* <UiPopup :show="showMenu" :x="menuX" :y="menuY" @close="showMenu = false">
|
|
37
|
+
* <UiDropdownItem icon="mdi:pencil" label="Edit" @click="edit" />
|
|
38
|
+
* <UiDropdownItem icon="mdi:trash-can" label="Delete" color="red" @click="del" />
|
|
39
|
+
* </UiPopup>
|
|
40
|
+
*
|
|
41
|
+
* @example Popup with offset and custom width
|
|
42
|
+
* <UiPopup :show="open" :x="posX" :y="posY" :offset-y="8" width="w-64" @close="open = false">
|
|
43
|
+
* <div class="p-3">Custom content</div>
|
|
44
|
+
* </UiPopup>
|
|
45
|
+
*
|
|
46
|
+
* @emits {void} close — Emitted when the backdrop is clicked to dismiss the popup
|
|
47
|
+
*
|
|
48
|
+
* @slot default — Popup content
|
|
49
|
+
*/
|
|
50
|
+
import { ref, computed, watch, nextTick } from 'vue'
|
|
51
|
+
const props = defineProps({
|
|
52
|
+
/**
|
|
53
|
+
* Controls popup visibility.
|
|
54
|
+
* @type {boolean}
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
show: { type: Boolean, default: false },
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Horizontal position in pixels relative to the offset parent.
|
|
61
|
+
* @type {number}
|
|
62
|
+
* @default 0
|
|
63
|
+
*/
|
|
64
|
+
x: { type: Number, default: 0 },
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Vertical position in pixels relative to the offset parent.
|
|
68
|
+
* @type {number}
|
|
69
|
+
* @default 0
|
|
70
|
+
*/
|
|
71
|
+
y: { type: Number, default: 0 },
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Additional vertical offset added to the y position (e.g. to clear a trigger element).
|
|
75
|
+
* @type {number}
|
|
76
|
+
* @default 0
|
|
77
|
+
*/
|
|
78
|
+
offsetY: { type: Number, default: 0 },
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Width class for the popup panel.
|
|
82
|
+
* @type {string}
|
|
83
|
+
* @default 'w-56'
|
|
84
|
+
*/
|
|
85
|
+
width: { type: String, default: 'w-56' },
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Z-index class for the popup panel.
|
|
89
|
+
* @type {string}
|
|
90
|
+
* @default 'z-50'
|
|
91
|
+
*/
|
|
92
|
+
panelZ: { type: String, default: 'z-50' },
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Z-index class for the invisible backdrop behind the panel.
|
|
96
|
+
* @type {string}
|
|
97
|
+
* @default 'z-40'
|
|
98
|
+
*/
|
|
99
|
+
backdropZ: { type: String, default: 'z-40' },
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
defineEmits(['close'])
|
|
103
|
+
|
|
104
|
+
const panelRef = ref(null)
|
|
105
|
+
const clampedPos = ref({ left: 0, top: 0 })
|
|
106
|
+
|
|
107
|
+
const positionStyle = computed(() => ({
|
|
108
|
+
left: clampedPos.value.left + 'px',
|
|
109
|
+
top: clampedPos.value.top + 'px',
|
|
110
|
+
}))
|
|
111
|
+
|
|
112
|
+
// Clamp the panel position so it stays within the viewport (8px margin)
|
|
113
|
+
const updatePosition = () => {
|
|
114
|
+
const left = props.x
|
|
115
|
+
const top = props.y + props.offsetY
|
|
116
|
+
|
|
117
|
+
nextTick(() => {
|
|
118
|
+
const el = panelRef.value
|
|
119
|
+
if (!el) return
|
|
120
|
+
|
|
121
|
+
const parent = el.offsetParent || document.body
|
|
122
|
+
const parentRect = parent.getBoundingClientRect()
|
|
123
|
+
const panelW = el.offsetWidth
|
|
124
|
+
const panelH = el.offsetHeight
|
|
125
|
+
const viewW = window.innerWidth
|
|
126
|
+
const viewH = window.innerHeight
|
|
127
|
+
|
|
128
|
+
// Convert to viewport coords, clamp, convert back
|
|
129
|
+
let absLeft = parentRect.left + left
|
|
130
|
+
let absTop = parentRect.top + top
|
|
131
|
+
|
|
132
|
+
const margin = 8
|
|
133
|
+
if (absLeft + panelW > viewW - margin) absLeft = viewW - panelW - margin
|
|
134
|
+
if (absLeft < margin) absLeft = margin
|
|
135
|
+
if (absTop + panelH > viewH - margin) absTop = viewH - panelH - margin
|
|
136
|
+
if (absTop < margin) absTop = margin
|
|
137
|
+
|
|
138
|
+
clampedPos.value = {
|
|
139
|
+
left: absLeft - parentRect.left,
|
|
140
|
+
top: absTop - parentRect.top,
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
watch(
|
|
146
|
+
() => [props.show, props.x, props.y, props.offsetY],
|
|
147
|
+
() => {
|
|
148
|
+
if (props.show) {
|
|
149
|
+
// Set initial position immediately so the panel renders near the right spot
|
|
150
|
+
clampedPos.value = { left: props.x, top: props.y + props.offsetY }
|
|
151
|
+
updatePosition()
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{ immediate: true },
|
|
155
|
+
)
|
|
156
|
+
</script>
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="space-y-1">
|
|
3
|
+
<!-- Optional label and value display row -->
|
|
4
|
+
<div
|
|
5
|
+
v-if="label || showValue"
|
|
6
|
+
class="flex items-center justify-between text-xs text-gray-500 dark:text-gray-500"
|
|
7
|
+
>
|
|
8
|
+
<span v-if="label">{{ label }}</span>
|
|
9
|
+
<span v-if="showValue">{{ current }} / {{ total }}</span>
|
|
10
|
+
</div>
|
|
11
|
+
<!-- Track background with animated fill bar -->
|
|
12
|
+
<div class="w-full rounded-full overflow-hidden" :class="[trackClass, heightClass]">
|
|
13
|
+
<div
|
|
14
|
+
class="h-full rounded-full transition-all duration-200"
|
|
15
|
+
:class="barClass"
|
|
16
|
+
:style="{ width: percentage + '%' }"
|
|
17
|
+
/>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script setup>
|
|
23
|
+
/**
|
|
24
|
+
* UiProgressBar — Horizontal progress bar with label, value display, and color themes.
|
|
25
|
+
*
|
|
26
|
+
* Renders a rounded track with an animated fill bar representing current/total progress.
|
|
27
|
+
* Supports an optional text label above the bar and a "current / total" value display.
|
|
28
|
+
* The fill percentage is clamped to 0–100% and handles zero-total gracefully.
|
|
29
|
+
*
|
|
30
|
+
* @example Basic progress bar
|
|
31
|
+
* <UiProgressBar :current="45" :total="100" />
|
|
32
|
+
*
|
|
33
|
+
* @example Labeled progress with value
|
|
34
|
+
* <UiProgressBar :current="3" :total="10" label="Steps" show-value />
|
|
35
|
+
*
|
|
36
|
+
* @example Red thin progress bar
|
|
37
|
+
* <UiProgressBar :current="90" :total="100" color="red" height="xs" />
|
|
38
|
+
*/
|
|
39
|
+
import { computed } from 'vue'
|
|
40
|
+
const props = defineProps({
|
|
41
|
+
/**
|
|
42
|
+
* Current progress value.
|
|
43
|
+
* @type {number}
|
|
44
|
+
* @default 0
|
|
45
|
+
*/
|
|
46
|
+
current: { type: Number, default: 0 },
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Total/maximum value (denominator for percentage calculation).
|
|
50
|
+
* @type {number}
|
|
51
|
+
* @default 100
|
|
52
|
+
*/
|
|
53
|
+
total: { type: Number, default: 100 },
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Optional label text displayed above the bar on the left.
|
|
57
|
+
* @type {string}
|
|
58
|
+
* @default ''
|
|
59
|
+
*/
|
|
60
|
+
label: { type: String, default: '' },
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Show "current / total" text above the bar on the right.
|
|
64
|
+
* @type {boolean}
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
67
|
+
showValue: { type: Boolean, default: false },
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Color theme for the fill bar.
|
|
71
|
+
* @type {string}
|
|
72
|
+
* @default 'primary'
|
|
73
|
+
* @values 'primary' | 'green' | 'red' | 'amber'
|
|
74
|
+
*/
|
|
75
|
+
color: { type: String, default: 'primary' },
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Track height preset.
|
|
79
|
+
* @type {string}
|
|
80
|
+
* @default 'sm'
|
|
81
|
+
* @values 'xs' (h-1) | 'sm' (h-2) | 'md' (h-3)
|
|
82
|
+
*/
|
|
83
|
+
height: { type: String, default: 'sm' },
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
// Calculate fill percentage, clamped to 0–100, safe against zero total
|
|
87
|
+
const percentage = computed(() =>
|
|
88
|
+
props.total > 0 ? Math.min(100, Math.round((props.current / props.total) * 100)) : 0,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
const heightClass = computed(() => {
|
|
92
|
+
const map = { xs: 'h-1', sm: 'h-2', md: 'h-3' }
|
|
93
|
+
return map[props.height] || map.sm
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
const trackClass = 'bg-gray-200 dark:bg-gray-700'
|
|
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
|
+
</script>
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<UiModal
|
|
3
|
+
:show="show"
|
|
4
|
+
max-width="sm"
|
|
5
|
+
:fullscreen-mobile="fullscreenMobile"
|
|
6
|
+
:panel-class="panelClass"
|
|
7
|
+
@close="handleClose"
|
|
8
|
+
>
|
|
9
|
+
<div
|
|
10
|
+
ref="promptRef"
|
|
11
|
+
class="flex flex-col max-h-full"
|
|
12
|
+
:class="panelClass.includes('overflow-visible') ? 'overflow-visible' : 'overflow-hidden'"
|
|
13
|
+
@keydown="onKeydown"
|
|
14
|
+
>
|
|
15
|
+
<div class="flex items-center justify-between p-4 pb-0 mb-3 shrink-0">
|
|
16
|
+
<div class="flex items-center gap-2">
|
|
17
|
+
<UiIcon v-if="icon" :name="icon" class="w-5 h-5" :class="iconColorClass" />
|
|
18
|
+
<h2 class="text-sm font-semibold text-gray-900 dark:text-gray-200 leading-none">
|
|
19
|
+
{{ title }}
|
|
20
|
+
</h2>
|
|
21
|
+
</div>
|
|
22
|
+
<UiButton variant="ghost" color="gray" icon-only @click="handleClose">
|
|
23
|
+
<UiIcon name="mdi:close" class="block w-5 h-5" />
|
|
24
|
+
</UiButton>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<div
|
|
28
|
+
v-if="body || $slots.default"
|
|
29
|
+
class="text-sm text-gray-600 dark:text-gray-400 mb-4 leading-relaxed px-4 min-h-0"
|
|
30
|
+
:class="panelClass.includes('overflow-visible') ? 'overflow-visible' : 'overflow-y-auto'"
|
|
31
|
+
>
|
|
32
|
+
<slot>{{ body }}</slot>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<div class="flex justify-end gap-2 p-4 pt-0 shrink-0">
|
|
36
|
+
<slot name="actions">
|
|
37
|
+
<UiButton variant="ghost" color="gray" :disabled="loading" @click="handleClose">
|
|
38
|
+
{{ cancelLabel }}
|
|
39
|
+
</UiButton>
|
|
40
|
+
<UiButton
|
|
41
|
+
ref="confirmRef"
|
|
42
|
+
variant="solid"
|
|
43
|
+
:color="confirmColor"
|
|
44
|
+
:loading="loading"
|
|
45
|
+
@click="handleConfirm"
|
|
46
|
+
>
|
|
47
|
+
{{ confirmLabel }}
|
|
48
|
+
</UiButton>
|
|
49
|
+
</slot>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</UiModal>
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<script setup>
|
|
56
|
+
/**
|
|
57
|
+
* UiPrompt — A modal prompt primitive for confirmations, choices, and user decisions.
|
|
58
|
+
*
|
|
59
|
+
* Wraps UiModal with a consistent header (icon + title + close), body content, and
|
|
60
|
+
* action buttons. Handles keyboard (Escape to close, Enter to confirm), auto-focuses
|
|
61
|
+
* the confirm button on open, and prevents double-submit while loading.
|
|
62
|
+
*
|
|
63
|
+
* For simple text prompts, use the `body` prop. For rich content, use the default slot.
|
|
64
|
+
* Override the `#actions` slot for custom button layouts.
|
|
65
|
+
*
|
|
66
|
+
* @example Simple confirmation (props only, no slots needed)
|
|
67
|
+
* <UiPrompt :show="confirming" title="Delete item?" body="This action cannot be undone."
|
|
68
|
+
* icon="mdi:delete" confirm-label="Delete" confirm-color="red"
|
|
69
|
+
* @close="confirming = false" @confirm="doDelete" />
|
|
70
|
+
*
|
|
71
|
+
* @example Rich body content
|
|
72
|
+
* <UiPrompt :show="open" title="Warning" @close="open = false" @confirm="proceed">
|
|
73
|
+
* <p>This will affect <strong>{{ count }}</strong> items.</p>
|
|
74
|
+
* </UiPrompt>
|
|
75
|
+
*
|
|
76
|
+
* @example Custom actions
|
|
77
|
+
* <UiPrompt :show="choosing" title="Export Options" @close="choosing = false">
|
|
78
|
+
* Include results in the export?
|
|
79
|
+
* <template #actions>
|
|
80
|
+
* <UiButton variant="ghost" color="gray" @click="doExport(false)">Without</UiButton>
|
|
81
|
+
* <UiButton @click="doExport(true)">With Results</UiButton>
|
|
82
|
+
* </template>
|
|
83
|
+
* </UiPrompt>
|
|
84
|
+
*
|
|
85
|
+
* @example Form prompt (disable Enter-to-confirm)
|
|
86
|
+
* <UiPrompt :show="open" title="New Group" :confirm-on-enter="false" @close="open = false">
|
|
87
|
+
* <UiInput v-model="name" @keydown.enter="save" />
|
|
88
|
+
* </UiPrompt>
|
|
89
|
+
*/
|
|
90
|
+
import { ref, computed, watch, nextTick, useSlots } from 'vue'
|
|
91
|
+
import UiButton from './Button.vue'
|
|
92
|
+
import UiModal from './Modal.vue'
|
|
93
|
+
import UiIcon from '../icons/Icon.vue'
|
|
94
|
+
const props = defineProps({
|
|
95
|
+
/** Controls prompt visibility. */
|
|
96
|
+
show: { type: Boolean, default: false },
|
|
97
|
+
/** Prompt heading text. */
|
|
98
|
+
title: { type: String, default: 'Confirm' },
|
|
99
|
+
/** Optional icon name displayed before the title. */
|
|
100
|
+
icon: { type: String, default: null },
|
|
101
|
+
/** Plain text body content. Ignored when the default slot is used. */
|
|
102
|
+
body: { type: String, default: null },
|
|
103
|
+
/** Label for the confirm button (default actions only). */
|
|
104
|
+
confirmLabel: { type: String, default: 'Confirm' },
|
|
105
|
+
/** Label for the cancel button (default actions only). */
|
|
106
|
+
cancelLabel: { type: String, default: 'Cancel' },
|
|
107
|
+
/** Color of the confirm button and icon. */
|
|
108
|
+
confirmColor: { type: String, default: 'primary' },
|
|
109
|
+
/** Shows a loading spinner on the confirm button and prevents double-submit. */
|
|
110
|
+
loading: { type: Boolean, default: false },
|
|
111
|
+
/** Whether pressing Enter triggers confirm. Disable for form-based prompts. */
|
|
112
|
+
confirmOnEnter: { type: Boolean, default: true },
|
|
113
|
+
/** Whether the prompt goes fullscreen on mobile viewports. */
|
|
114
|
+
fullscreenMobile: { type: Boolean, default: false },
|
|
115
|
+
/** Additional CSS class(es) applied to the modal panel element. */
|
|
116
|
+
panelClass: { type: String, default: '' },
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
const emit = defineEmits(['close', 'confirm'])
|
|
120
|
+
|
|
121
|
+
const confirmRef = ref(null)
|
|
122
|
+
const hasCustomActions = computed(() => !!useSlots().actions)
|
|
123
|
+
|
|
124
|
+
const iconColorClass = computed(() => {
|
|
125
|
+
const map = {
|
|
126
|
+
red: 'text-red-600 dark:text-red-400',
|
|
127
|
+
amber: 'text-amber-600 dark:text-amber-400',
|
|
128
|
+
primary: 'text-primary-600 dark:text-primary-400',
|
|
129
|
+
gray: 'text-gray-500 dark:text-gray-400',
|
|
130
|
+
}
|
|
131
|
+
return map[props.confirmColor] || map.primary
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
const handleClose = () => {
|
|
135
|
+
if (!props.loading) emit('close')
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const handleConfirm = () => {
|
|
139
|
+
if (!props.loading) emit('confirm')
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const onKeydown = (e) => {
|
|
143
|
+
if (e.key === 'Enter' && props.confirmOnEnter && !hasCustomActions.value && !props.loading) {
|
|
144
|
+
e.preventDefault()
|
|
145
|
+
handleConfirm()
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Auto-focus confirm button when prompt opens
|
|
150
|
+
watch(
|
|
151
|
+
() => props.show,
|
|
152
|
+
(open) => {
|
|
153
|
+
if (open) {
|
|
154
|
+
nextTick(() => {
|
|
155
|
+
const el = confirmRef.value?.$el ?? confirmRef.value
|
|
156
|
+
if (el instanceof HTMLElement) el.focus()
|
|
157
|
+
})
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
)
|
|
161
|
+
</script>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<input
|
|
3
|
+
type="radio"
|
|
4
|
+
:checked="modelValue === value"
|
|
5
|
+
:disabled="disabled"
|
|
6
|
+
:name="name"
|
|
7
|
+
:value="value"
|
|
8
|
+
class="rounded-full border-gray-300 dark:border-gray-600 text-primary-600 focus:ring-primary-500"
|
|
9
|
+
:class="sizeClass"
|
|
10
|
+
@change="onChange"
|
|
11
|
+
/>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script setup>
|
|
15
|
+
/**
|
|
16
|
+
* UiRadio — Simple styled radio input with configurable size.
|
|
17
|
+
*
|
|
18
|
+
* Wraps a native `<input type="radio">` with consistent Tailwind styling,
|
|
19
|
+
* primary color accent, and focus ring. Use with v-model for group selection.
|
|
20
|
+
*
|
|
21
|
+
* @example Radio group
|
|
22
|
+
* <UiRadio v-model="selected" value="a" name="choice" />
|
|
23
|
+
* <UiRadio v-model="selected" value="b" name="choice" />
|
|
24
|
+
*/
|
|
25
|
+
import { computed } from 'vue'
|
|
26
|
+
const props = defineProps({
|
|
27
|
+
modelValue: { type: [String, Number, Boolean], default: null },
|
|
28
|
+
value: { type: [String, Number, Boolean], required: true },
|
|
29
|
+
name: { type: String, default: undefined },
|
|
30
|
+
disabled: { type: Boolean, default: false },
|
|
31
|
+
size: { type: String, default: 'md' },
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const emit = defineEmits(['update:modelValue'])
|
|
35
|
+
|
|
36
|
+
const sizeClass = computed(() => {
|
|
37
|
+
switch (props.size) {
|
|
38
|
+
case 'sm':
|
|
39
|
+
return 'w-3.5 h-3.5'
|
|
40
|
+
case 'lg':
|
|
41
|
+
return 'w-5 h-5'
|
|
42
|
+
default:
|
|
43
|
+
return 'w-4 h-4'
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
function onChange() {
|
|
48
|
+
emit('update:modelValue', props.value)
|
|
49
|
+
}
|
|
50
|
+
</script>
|