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,127 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<!-- Optional section label above the list -->
|
|
4
|
+
<p
|
|
5
|
+
v-if="label"
|
|
6
|
+
class="font-medium uppercase tracking-wider mb-1.5"
|
|
7
|
+
:class="[labelSizeClass, labelColorClass, labelPaddingClass]"
|
|
8
|
+
>
|
|
9
|
+
{{ label }}
|
|
10
|
+
</p>
|
|
11
|
+
<div class="divide-y" :class="[shapeClass, containerClass, childRadiusClass]">
|
|
12
|
+
<slot />
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup>
|
|
18
|
+
/**
|
|
19
|
+
* UiListMenu — Grouped list container for UiListMenuItem rows.
|
|
20
|
+
*
|
|
21
|
+
* A versatile container for grouped rows of any kind: clickable actions,
|
|
22
|
+
* settings with toggles/selects, informational rows, or mixed content.
|
|
23
|
+
* Supports an optional uppercase section label, a danger (red) color scheme,
|
|
24
|
+
* and visual presets for different contexts.
|
|
25
|
+
*
|
|
26
|
+
* @example Action list
|
|
27
|
+
* <UiListMenu label="Account">
|
|
28
|
+
* <UiListMenuItem icon="mdi:account" clickable>Profile</UiListMenuItem>
|
|
29
|
+
* <UiListMenuItem icon="mdi:lock" clickable>Security</UiListMenuItem>
|
|
30
|
+
* </UiListMenu>
|
|
31
|
+
*
|
|
32
|
+
* @example Settings panel preset with mixed content
|
|
33
|
+
* <UiListMenu label="Display" preset="settings">
|
|
34
|
+
* <UiListMenuItem icon="mdi:translate" label="Language">
|
|
35
|
+
* <template #suffix><UiSelect ... /></template>
|
|
36
|
+
* </UiListMenuItem>
|
|
37
|
+
* <UiListMenuItem icon="mdi:wrap" label="Word Wrap">
|
|
38
|
+
* <template #suffix><UiToggle ... /></template>
|
|
39
|
+
* </UiListMenuItem>
|
|
40
|
+
* </UiListMenu>
|
|
41
|
+
*
|
|
42
|
+
* @example Danger zone
|
|
43
|
+
* <UiListMenu label="Danger Zone" danger>
|
|
44
|
+
* <UiListMenuItem icon="mdi:trash-can" danger clickable>Delete Account</UiListMenuItem>
|
|
45
|
+
* </UiListMenu>
|
|
46
|
+
*
|
|
47
|
+
* @slot default — List items (typically UiListMenuItem components)
|
|
48
|
+
*
|
|
49
|
+
* @see UiListMenuItem — Row item designed for use inside this list
|
|
50
|
+
*/
|
|
51
|
+
import { computed } from 'vue'
|
|
52
|
+
const props = defineProps({
|
|
53
|
+
/**
|
|
54
|
+
* Section label displayed above the list in uppercase.
|
|
55
|
+
* @type {string}
|
|
56
|
+
* @default ''
|
|
57
|
+
*/
|
|
58
|
+
label: { type: String, default: '' },
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Use danger/red styling for the container border, background, and label.
|
|
62
|
+
* @type {boolean}
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
danger: { type: Boolean, default: false },
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Border radius preset for the container.
|
|
69
|
+
* @type {string}
|
|
70
|
+
* @default 'xl'
|
|
71
|
+
* @values 'xl' | 'lg' | 'none'
|
|
72
|
+
*/
|
|
73
|
+
rounded: { type: String, default: 'xl' },
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Visual preset that adjusts container styling for different contexts.
|
|
77
|
+
* - 'default' — Standard bordered list with gray background
|
|
78
|
+
* - 'settings' — White bg, subtle border, inset label — ideal for settings panels
|
|
79
|
+
* @type {string}
|
|
80
|
+
* @default 'default'
|
|
81
|
+
* @values 'default' | 'settings'
|
|
82
|
+
*/
|
|
83
|
+
preset: { type: String, default: 'default' },
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
const shapeClass = computed(() => {
|
|
87
|
+
const map = { xl: 'rounded-xl', lg: 'rounded-lg', none: '' }
|
|
88
|
+
return map[props.rounded] ?? map.xl
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
const childRadiusClass = computed(() => {
|
|
92
|
+
const map = {
|
|
93
|
+
xl: '[&>*:first-child]:rounded-t-xl [&>*:last-child]:rounded-b-xl',
|
|
94
|
+
lg: '[&>*:first-child]:rounded-t-lg [&>*:last-child]:rounded-b-lg',
|
|
95
|
+
none: '',
|
|
96
|
+
}
|
|
97
|
+
return map[props.rounded] ?? map.xl
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
const containerClass = computed(() => {
|
|
101
|
+
if (props.danger) {
|
|
102
|
+
return 'bg-red-50/50 dark:bg-red-900/10 border border-red-100 dark:border-red-900/30 divide-red-100 dark:divide-red-900/30'
|
|
103
|
+
}
|
|
104
|
+
const presetMap = {
|
|
105
|
+
default:
|
|
106
|
+
'bg-gray-50 dark:bg-gray-900 border border-gray-100 dark:border-gray-800 divide-gray-100 dark:divide-gray-800',
|
|
107
|
+
settings:
|
|
108
|
+
'bg-white dark:bg-gray-800/40 border border-gray-200/80 dark:border-gray-700/50 divide-gray-100 dark:divide-gray-700/40',
|
|
109
|
+
}
|
|
110
|
+
return presetMap[props.preset] ?? presetMap.default
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
const labelSizeClass = computed(() => {
|
|
114
|
+
const map = { default: 'text-[10px]', settings: 'text-[11px]' }
|
|
115
|
+
return map[props.preset] ?? map.default
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
const labelPaddingClass = computed(() => {
|
|
119
|
+
const map = { default: 'px-1', settings: 'px-1' }
|
|
120
|
+
return map[props.preset] ?? map.default
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
const labelColorClass = computed(() => {
|
|
124
|
+
if (props.danger) return 'text-red-400 dark:text-red-600'
|
|
125
|
+
return 'text-gray-400 dark:text-gray-500'
|
|
126
|
+
})
|
|
127
|
+
</script>
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component
|
|
3
|
+
:is="isInteractive ? 'button' : 'div'"
|
|
4
|
+
:type="isInteractive ? 'button' : undefined"
|
|
5
|
+
class="w-full flex items-center gap-3 text-sm text-left transition-colors"
|
|
6
|
+
:class="[sizeClass, colorClass]"
|
|
7
|
+
:disabled="isInteractive ? disabled : undefined"
|
|
8
|
+
@click="handleClick"
|
|
9
|
+
>
|
|
10
|
+
<UiIcon
|
|
11
|
+
v-if="icon"
|
|
12
|
+
:name="icon"
|
|
13
|
+
class="shrink-0"
|
|
14
|
+
:class="[iconSizeClass, iconClass || defaultIconColorClass]"
|
|
15
|
+
/>
|
|
16
|
+
<span class="flex-1 min-w-0">
|
|
17
|
+
<span class="block truncate"><slot /></span>
|
|
18
|
+
<span v-if="hint" class="block text-xs text-gray-400 dark:text-gray-500 truncate mt-0.5">{{
|
|
19
|
+
hint
|
|
20
|
+
}}</span>
|
|
21
|
+
</span>
|
|
22
|
+
<div class="shrink-0 flex items-center" @click.stop="handleSuffixClick">
|
|
23
|
+
<slot name="suffix">
|
|
24
|
+
<UiIcon
|
|
25
|
+
v-if="clickable && chevron"
|
|
26
|
+
name="mdi:chevron-right"
|
|
27
|
+
class="w-4 h-4"
|
|
28
|
+
:class="danger ? 'text-red-300 dark:text-red-800' : 'text-gray-300 dark:text-gray-600'"
|
|
29
|
+
/>
|
|
30
|
+
</slot>
|
|
31
|
+
</div>
|
|
32
|
+
</component>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script setup>
|
|
36
|
+
/**
|
|
37
|
+
* UiListMenuItem — Single row item for use inside UiListMenu.
|
|
38
|
+
*
|
|
39
|
+
* A versatile row component that can serve as:
|
|
40
|
+
* - A clickable action row (set `clickable`)
|
|
41
|
+
* - A toggle row where tapping anywhere toggles (set `toggle`)
|
|
42
|
+
* - A select row where tapping anywhere opens the select (set `selectRef`)
|
|
43
|
+
* - A static row hosting suffix controls (default)
|
|
44
|
+
*
|
|
45
|
+
* @example Clickable action row
|
|
46
|
+
* <UiListMenuItem icon="mdi:account" clickable @click="goProfile">Profile</UiListMenuItem>
|
|
47
|
+
*
|
|
48
|
+
* @example Toggle row (whole row is tappable)
|
|
49
|
+
* <UiListMenuItem icon="mdi:wrap" :toggle="wordWrap" @update:toggle="wordWrap = $event">
|
|
50
|
+
* Word Wrap
|
|
51
|
+
* <template #suffix><UiToggle :model-value="wordWrap" readonly /></template>
|
|
52
|
+
* </UiListMenuItem>
|
|
53
|
+
*
|
|
54
|
+
* @example Select row (whole row opens the select)
|
|
55
|
+
* <UiListMenuItem icon="mdi:translate" :select-ref="langRef">
|
|
56
|
+
* Language
|
|
57
|
+
* <template #suffix><UiSelect ref="langRef" ... /></template>
|
|
58
|
+
* </UiListMenuItem>
|
|
59
|
+
*
|
|
60
|
+
* @emits {void} click — Emitted when a clickable item is clicked
|
|
61
|
+
* @emits {boolean} update:toggle — Emitted with the new value when a toggle row is tapped
|
|
62
|
+
*
|
|
63
|
+
* @slot default — Label text
|
|
64
|
+
* @slot suffix — Trailing content (toggle, select, badge, etc.)
|
|
65
|
+
*
|
|
66
|
+
* @see UiListMenu — Parent container for grouping list items
|
|
67
|
+
*/
|
|
68
|
+
import { computed } from 'vue'
|
|
69
|
+
import UiIcon from '../icons/Icon.vue'
|
|
70
|
+
const props = defineProps({
|
|
71
|
+
/** MDI icon name displayed at the start of the row. */
|
|
72
|
+
icon: { type: String, default: '' },
|
|
73
|
+
|
|
74
|
+
/** Custom CSS class override for the icon element. */
|
|
75
|
+
iconClass: { type: String, default: '' },
|
|
76
|
+
|
|
77
|
+
/** Whether this item is a clickable action (renders as button with hover states + chevron). */
|
|
78
|
+
clickable: { type: Boolean, default: false },
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Toggle state. When set to a boolean, the row becomes a tappable toggle.
|
|
82
|
+
* Clicking anywhere emits `update:toggle` with the inverted value.
|
|
83
|
+
*/
|
|
84
|
+
toggle: { type: Boolean, default: undefined },
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Reference to a UiSelect component instance. When provided, the row becomes
|
|
88
|
+
* tappable and clicking anywhere opens the select dropdown.
|
|
89
|
+
*/
|
|
90
|
+
selectRef: { type: Object, default: undefined },
|
|
91
|
+
|
|
92
|
+
/** Show a chevron-right icon as the trailing suffix (only when clickable). */
|
|
93
|
+
chevron: { type: Boolean, default: true },
|
|
94
|
+
|
|
95
|
+
/** Danger/red styling for destructive actions. */
|
|
96
|
+
danger: { type: Boolean, default: false },
|
|
97
|
+
|
|
98
|
+
/** Disabled state — dims the item and prevents interaction. */
|
|
99
|
+
disabled: { type: Boolean, default: false },
|
|
100
|
+
|
|
101
|
+
/** Optional hint text displayed below the label. */
|
|
102
|
+
hint: { type: String, default: '' },
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Size preset for padding and icon dimensions.
|
|
106
|
+
* @values 'md' | 'sm'
|
|
107
|
+
*/
|
|
108
|
+
size: { type: String, default: 'md' },
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
const emit = defineEmits(['click', 'update:toggle'])
|
|
112
|
+
|
|
113
|
+
const isToggle = computed(() => props.toggle !== undefined)
|
|
114
|
+
const isSelect = computed(() => props.selectRef !== undefined)
|
|
115
|
+
const isInteractive = computed(() => props.clickable || isToggle.value || isSelect.value)
|
|
116
|
+
|
|
117
|
+
const handleClick = () => {
|
|
118
|
+
if (props.disabled) return
|
|
119
|
+
if (isToggle.value) {
|
|
120
|
+
emit('update:toggle', !props.toggle)
|
|
121
|
+
} else if (isSelect.value) {
|
|
122
|
+
props.selectRef?.toggle?.()
|
|
123
|
+
} else if (props.clickable) {
|
|
124
|
+
emit('click')
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const handleSuffixClick = (e) => {
|
|
129
|
+
// For toggle rows, clicking the suffix (the toggle itself) should also toggle
|
|
130
|
+
if (isToggle.value && !props.disabled) {
|
|
131
|
+
e.stopPropagation()
|
|
132
|
+
emit('update:toggle', !props.toggle)
|
|
133
|
+
return
|
|
134
|
+
}
|
|
135
|
+
// For select rows, let the select handle its own click (it calls toggleOpen)
|
|
136
|
+
// but stop propagation so the row doesn't double-open
|
|
137
|
+
if (isSelect.value) {
|
|
138
|
+
e.stopPropagation()
|
|
139
|
+
return
|
|
140
|
+
}
|
|
141
|
+
// For clickable rows, stop propagation so suffix controls work independently
|
|
142
|
+
if (props.clickable) {
|
|
143
|
+
e.stopPropagation()
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const sizeClass = computed(() => {
|
|
148
|
+
const map = { md: 'px-4 py-3', sm: 'px-3 py-2.5' }
|
|
149
|
+
return map[props.size] ?? map.md
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
const iconSizeClass = computed(() => {
|
|
153
|
+
const map = { md: 'w-[18px] h-[18px]', sm: 'w-4 h-4' }
|
|
154
|
+
return map[props.size] ?? map.md
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
const defaultIconColorClass = computed(() => {
|
|
158
|
+
if (props.danger) return 'text-red-500 dark:text-red-400'
|
|
159
|
+
return 'text-gray-400 dark:text-gray-500'
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
const colorClass = computed(() => {
|
|
163
|
+
if (props.disabled) return 'opacity-40 cursor-not-allowed'
|
|
164
|
+
if (!isInteractive.value) {
|
|
165
|
+
return props.danger ? 'text-red-600 dark:text-red-400' : 'text-gray-700 dark:text-gray-300'
|
|
166
|
+
}
|
|
167
|
+
if (props.danger)
|
|
168
|
+
return 'text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 active:bg-red-100 dark:active:bg-red-900/30 cursor-pointer'
|
|
169
|
+
return 'text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700/40 active:bg-gray-100 dark:active:bg-gray-700/60 cursor-pointer'
|
|
170
|
+
})
|
|
171
|
+
</script>
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- Teleported to body to avoid z-index stacking context issues -->
|
|
3
|
+
<Teleport to="body">
|
|
4
|
+
<!-- Backdrop overlay with fade transition -->
|
|
5
|
+
<Transition
|
|
6
|
+
enter-active-class="transition ease-out duration-200"
|
|
7
|
+
enter-from-class="opacity-0"
|
|
8
|
+
enter-to-class="opacity-100"
|
|
9
|
+
leave-active-class="transition ease-in duration-150"
|
|
10
|
+
leave-from-class="opacity-100"
|
|
11
|
+
leave-to-class="opacity-0"
|
|
12
|
+
>
|
|
13
|
+
<div
|
|
14
|
+
v-if="show"
|
|
15
|
+
class="fixed inset-0 flex items-center justify-center"
|
|
16
|
+
:class="[zClass, paddingClass, backdropClass]"
|
|
17
|
+
@click.self="!persistent && $emit('close')"
|
|
18
|
+
>
|
|
19
|
+
<Transition
|
|
20
|
+
enter-active-class="transition ease-out duration-300"
|
|
21
|
+
enter-from-class="opacity-0 scale-95"
|
|
22
|
+
enter-to-class="opacity-100 scale-100"
|
|
23
|
+
leave-active-class="transition ease-in duration-200"
|
|
24
|
+
leave-from-class="opacity-100 scale-100"
|
|
25
|
+
leave-to-class="opacity-0 scale-95"
|
|
26
|
+
appear
|
|
27
|
+
>
|
|
28
|
+
<div
|
|
29
|
+
v-if="show"
|
|
30
|
+
class="modal-panel bg-white dark:bg-gray-925 overflow-hidden flex flex-col"
|
|
31
|
+
:class="[panelClass, maxWidthClass, roundedClass, mobileLayoutClass]"
|
|
32
|
+
@click.stop
|
|
33
|
+
>
|
|
34
|
+
<slot />
|
|
35
|
+
</div>
|
|
36
|
+
</Transition>
|
|
37
|
+
</div>
|
|
38
|
+
</Transition>
|
|
39
|
+
</Teleport>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<script setup>
|
|
43
|
+
/**
|
|
44
|
+
* UiModal — Teleported modal dialog with backdrop, configurable max-width, and enter/leave transitions.
|
|
45
|
+
*
|
|
46
|
+
* Renders a centered overlay panel teleported to `<body>`. Supports ten max-width presets
|
|
47
|
+
* (xs through 5xl and full-screen), persistent mode to prevent backdrop-click dismissal,
|
|
48
|
+
* and customizable z-index and padding. The panel uses a scale+fade transition on enter/leave.
|
|
49
|
+
*
|
|
50
|
+
* @example Basic modal
|
|
51
|
+
* <UiModal :show="isOpen" @close="isOpen = false">
|
|
52
|
+
* <div class="p-6">Hello!</div>
|
|
53
|
+
* </UiModal>
|
|
54
|
+
*
|
|
55
|
+
* @example Large persistent modal
|
|
56
|
+
* <UiModal :show="showEditor" max-width="3xl" persistent>
|
|
57
|
+
* <ModalHeader @close="showEditor = false" />
|
|
58
|
+
* <div class="p-6">Editor content</div>
|
|
59
|
+
* </UiModal>
|
|
60
|
+
*
|
|
61
|
+
* @example Full-screen modal
|
|
62
|
+
* <UiModal :show="showFull" max-width="full">
|
|
63
|
+
* <div class="h-full">Full screen content</div>
|
|
64
|
+
* </UiModal>
|
|
65
|
+
*
|
|
66
|
+
* @example Non-fullscreen on mobile
|
|
67
|
+
* <UiModal :show="isOpen" :fullscreen-mobile="false" @close="isOpen = false">
|
|
68
|
+
* <div class="p-6">Centered on all screens</div>
|
|
69
|
+
* </UiModal>
|
|
70
|
+
*
|
|
71
|
+
* @emits {void} close — Emitted when the modal should close (backdrop click or programmatic)
|
|
72
|
+
*
|
|
73
|
+
* @slot default — Modal content
|
|
74
|
+
*/
|
|
75
|
+
import { computed, watch, onBeforeUnmount } from 'vue'
|
|
76
|
+
import { useBackButton } from '../composables/useBackButton.js'
|
|
77
|
+
const props = defineProps({
|
|
78
|
+
/**
|
|
79
|
+
* Controls modal visibility. Use with v-model or :show + @close.
|
|
80
|
+
* @type {boolean}
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
show: { type: Boolean, default: false },
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Maximum width preset for the modal panel.
|
|
87
|
+
* @type {string}
|
|
88
|
+
* @default 'sm'
|
|
89
|
+
* @values 'xs' (20rem) | 'sm' (24rem) | 'md' (28rem) | 'lg' (32rem) | 'xl' (36rem) | '2xl' (42rem) | '3xl' (48rem) | '4xl' (56rem) | '5xl' (64rem) | 'full'
|
|
90
|
+
*/
|
|
91
|
+
maxWidth: { type: String, default: 'sm' },
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Whether the modal goes fullscreen on mobile viewports.
|
|
95
|
+
* When true, the panel fills the screen on mobile and respects safe area insets.
|
|
96
|
+
* @type {boolean}
|
|
97
|
+
* @default true
|
|
98
|
+
*/
|
|
99
|
+
fullscreenMobile: { type: Boolean, default: true },
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Persistent mode — prevents closing when clicking the backdrop overlay.
|
|
103
|
+
* @type {boolean}
|
|
104
|
+
* @default false
|
|
105
|
+
*/
|
|
106
|
+
persistent: { type: Boolean, default: false },
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Additional CSS classes applied to the modal panel element.
|
|
110
|
+
* @type {string}
|
|
111
|
+
* @default ''
|
|
112
|
+
*/
|
|
113
|
+
panelClass: { type: String, default: '' },
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Z-index class for the backdrop and modal layers.
|
|
117
|
+
* @type {string}
|
|
118
|
+
* @default 'z-50'
|
|
119
|
+
*/
|
|
120
|
+
z: { type: String, default: 'z-50' },
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Padding class around the modal panel (applied to the backdrop container).
|
|
124
|
+
* @type {string}
|
|
125
|
+
* @default 'md:p-4'
|
|
126
|
+
*/
|
|
127
|
+
padding: { type: String, default: 'md:p-4' },
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
const emit = defineEmits(['close'])
|
|
131
|
+
|
|
132
|
+
// ── Back-button interception (Capacitor) ──
|
|
133
|
+
const { register: registerBack, unregister: unregisterBack } = useBackButton()
|
|
134
|
+
let backHandlerId = null
|
|
135
|
+
|
|
136
|
+
watch(
|
|
137
|
+
() => props.show,
|
|
138
|
+
(visible) => {
|
|
139
|
+
if (visible) {
|
|
140
|
+
backHandlerId = registerBack(() => {
|
|
141
|
+
if (props.persistent) return false
|
|
142
|
+
emit('close')
|
|
143
|
+
return true
|
|
144
|
+
})
|
|
145
|
+
} else if (backHandlerId !== null) {
|
|
146
|
+
unregisterBack(backHandlerId)
|
|
147
|
+
backHandlerId = null
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
{ immediate: true },
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
onBeforeUnmount(() => {
|
|
154
|
+
if (backHandlerId !== null) {
|
|
155
|
+
unregisterBack(backHandlerId)
|
|
156
|
+
backHandlerId = null
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
const zClass = computed(() => props.z)
|
|
161
|
+
const paddingClass = computed(() => props.padding)
|
|
162
|
+
|
|
163
|
+
const backdropClass = computed(() => {
|
|
164
|
+
if (props.fullscreenMobile) {
|
|
165
|
+
return 'bg-transparent md:bg-black/50'
|
|
166
|
+
}
|
|
167
|
+
return 'bg-black/50 p-4'
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
const mobileLayoutClass = computed(() => {
|
|
171
|
+
if (props.maxWidth === 'full') return 'fixed inset-0'
|
|
172
|
+
|
|
173
|
+
if (props.fullscreenMobile) {
|
|
174
|
+
return 'fixed inset-0 modal-panel--safe-area md:static md:inset-auto'
|
|
175
|
+
}
|
|
176
|
+
// Non-fullscreen on mobile: centered dialog with max-height
|
|
177
|
+
return 'relative max-h-[calc(100vh-2rem)] md:static'
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
const maxWidthClass = computed(() => {
|
|
181
|
+
if (props.maxWidth === 'full') return 'w-full h-full'
|
|
182
|
+
|
|
183
|
+
const map = {
|
|
184
|
+
xs: 'md:max-w-xs',
|
|
185
|
+
sm: 'md:max-w-sm',
|
|
186
|
+
md: 'md:max-w-md',
|
|
187
|
+
lg: 'md:max-w-lg',
|
|
188
|
+
xl: 'md:max-w-xl',
|
|
189
|
+
'2xl': 'md:max-w-2xl',
|
|
190
|
+
'3xl': 'md:max-w-3xl',
|
|
191
|
+
'4xl': 'md:max-w-4xl',
|
|
192
|
+
'5xl': 'md:max-w-5xl',
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (props.fullscreenMobile) {
|
|
196
|
+
return `md:w-full ${map[props.maxWidth] || map.sm}`
|
|
197
|
+
}
|
|
198
|
+
return `w-full ${map[props.maxWidth] || map.sm}`
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
const roundedClass = computed(() => {
|
|
202
|
+
if (props.maxWidth === 'full') return 'rounded-none'
|
|
203
|
+
|
|
204
|
+
if (props.fullscreenMobile) {
|
|
205
|
+
return 'rounded-none md:rounded-lg'
|
|
206
|
+
}
|
|
207
|
+
return 'rounded-lg'
|
|
208
|
+
})
|
|
209
|
+
</script>
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="numpadRef" class="grid grid-cols-3 gap-3 max-w-[264px] mx-auto outline-none">
|
|
3
|
+
<button
|
|
4
|
+
v-for="n in [1, 2, 3, 4, 5, 6, 7, 8, 9]"
|
|
5
|
+
:key="n"
|
|
6
|
+
type="button"
|
|
7
|
+
tabindex="-1"
|
|
8
|
+
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"
|
|
9
|
+
:class="
|
|
10
|
+
pressedKey === n
|
|
11
|
+
? 'bg-primary-50 dark:bg-primary-900/30 border-primary-300 dark:border-primary-600 scale-95'
|
|
12
|
+
: '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'
|
|
13
|
+
"
|
|
14
|
+
:disabled="disabled"
|
|
15
|
+
@click="onDigit(n)"
|
|
16
|
+
>
|
|
17
|
+
{{ n }}
|
|
18
|
+
</button>
|
|
19
|
+
|
|
20
|
+
<!-- Bottom-left slot (e.g. biometrics button) -->
|
|
21
|
+
<slot name="bottom-left">
|
|
22
|
+
<div />
|
|
23
|
+
</slot>
|
|
24
|
+
|
|
25
|
+
<button
|
|
26
|
+
type="button"
|
|
27
|
+
tabindex="-1"
|
|
28
|
+
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"
|
|
29
|
+
:class="
|
|
30
|
+
pressedKey === 0
|
|
31
|
+
? 'bg-primary-50 dark:bg-primary-900/30 border-primary-300 dark:border-primary-600 scale-95'
|
|
32
|
+
: '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'
|
|
33
|
+
"
|
|
34
|
+
:disabled="disabled"
|
|
35
|
+
@click="onDigit(0)"
|
|
36
|
+
>
|
|
37
|
+
0
|
|
38
|
+
</button>
|
|
39
|
+
|
|
40
|
+
<button
|
|
41
|
+
type="button"
|
|
42
|
+
tabindex="-1"
|
|
43
|
+
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"
|
|
44
|
+
:disabled="!canDelete"
|
|
45
|
+
@click="$emit('delete')"
|
|
46
|
+
>
|
|
47
|
+
<UiIcon name="mdi:backspace-outline" class="w-6 h-6" />
|
|
48
|
+
</button>
|
|
49
|
+
</div>
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<script setup>
|
|
53
|
+
/**
|
|
54
|
+
* UiNumpad — A numeric keypad primitive for PIN entry and similar use cases.
|
|
55
|
+
*
|
|
56
|
+
* Emits digit presses and delete actions. Supports physical keyboard input
|
|
57
|
+
* with visual key highlighting. Exposes a bottom-left slot for custom actions
|
|
58
|
+
* (e.g. biometrics button).
|
|
59
|
+
*
|
|
60
|
+
* @example Basic usage
|
|
61
|
+
* <UiNumpad :can-delete="pin.length > 0" @digit="onDigit" @delete="onDelete" />
|
|
62
|
+
*
|
|
63
|
+
* @example With biometrics slot
|
|
64
|
+
* <UiNumpad :can-delete="pin.length > 0" @digit="onDigit" @delete="onDelete">
|
|
65
|
+
* <template #bottom-left>
|
|
66
|
+
* <button @click="useBiometrics">🔒</button>
|
|
67
|
+
* </template>
|
|
68
|
+
* </UiNumpad>
|
|
69
|
+
*/
|
|
70
|
+
import { ref } from 'vue'
|
|
71
|
+
import UiIcon from '../icons/Icon.vue'
|
|
72
|
+
import { useEventListener } from '../composables/useEventListener.js'
|
|
73
|
+
|
|
74
|
+
const props = defineProps({
|
|
75
|
+
/** Whether the numpad is disabled */
|
|
76
|
+
disabled: { type: Boolean, default: false },
|
|
77
|
+
/** Whether the delete button is enabled */
|
|
78
|
+
canDelete: { type: Boolean, default: false },
|
|
79
|
+
/** Whether the numpad listens for keyboard input globally */
|
|
80
|
+
captureKeyboard: { type: Boolean, default: false },
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
const emit = defineEmits(['digit', 'delete'])
|
|
84
|
+
|
|
85
|
+
const numpadRef = ref(null)
|
|
86
|
+
const pressedKey = ref(null)
|
|
87
|
+
|
|
88
|
+
const onDigit = (digit) => {
|
|
89
|
+
if (props.disabled) return
|
|
90
|
+
emit('digit', digit)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const handleKeydown = (e) => {
|
|
94
|
+
if (props.disabled) return
|
|
95
|
+
|
|
96
|
+
if (/^[0-9]$/.test(e.key)) {
|
|
97
|
+
e.preventDefault()
|
|
98
|
+
const digit = Number(e.key)
|
|
99
|
+
pressedKey.value = digit
|
|
100
|
+
setTimeout(() => {
|
|
101
|
+
pressedKey.value = null
|
|
102
|
+
}, 150)
|
|
103
|
+
onDigit(digit)
|
|
104
|
+
return
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (e.key === 'Backspace') {
|
|
108
|
+
e.preventDefault()
|
|
109
|
+
emit('delete')
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Global keyboard capture, bound only while `captureKeyboard` is set.
|
|
114
|
+
// The target is a getter so it re-evaluates when the prop changes, and is
|
|
115
|
+
// nullish during SSR — useEventListener skips nullish targets and tears the
|
|
116
|
+
// listener down with the component, so no manual cleanup is needed.
|
|
117
|
+
useEventListener(() => (props.captureKeyboard ? globalThis.window : null), 'keydown', handleKeydown)
|
|
118
|
+
</script>
|