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,64 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="direction === 'vertical'" class="shrink-0" :class="[verticalClasses, colorClass]" />
|
|
3
|
+
<div v-else :class="[horizontalClasses, colorClass]" />
|
|
4
|
+
</template>
|
|
5
|
+
|
|
6
|
+
<script setup>
|
|
7
|
+
/**
|
|
8
|
+
* UiDivider — Visual separator line for menus, toolbars, and content sections.
|
|
9
|
+
*
|
|
10
|
+
* Renders a thin line either horizontally (full-width border-top) or vertically
|
|
11
|
+
* (1px-wide column). Supports three color presets matching common usage contexts.
|
|
12
|
+
*
|
|
13
|
+
* @example Horizontal menu divider
|
|
14
|
+
* <UiDivider />
|
|
15
|
+
*
|
|
16
|
+
* @example Vertical toolbar separator
|
|
17
|
+
* <UiDivider direction="vertical" />
|
|
18
|
+
*
|
|
19
|
+
* @example Darker divider
|
|
20
|
+
* <UiDivider color="medium" />
|
|
21
|
+
*/
|
|
22
|
+
import { computed } from 'vue'
|
|
23
|
+
const props = defineProps({
|
|
24
|
+
/**
|
|
25
|
+
* Divider orientation.
|
|
26
|
+
* @type {string}
|
|
27
|
+
* @default 'horizontal'
|
|
28
|
+
* @values 'horizontal' | 'vertical'
|
|
29
|
+
*/
|
|
30
|
+
direction: { type: String, default: 'horizontal' },
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Color intensity preset.
|
|
34
|
+
* - 'light': subtle (gray-100/gray-700) — dropdown menus
|
|
35
|
+
* - 'medium': standard (gray-200/gray-700) — context menus, content sections
|
|
36
|
+
* - 'dark': stronger (gray-300/gray-600) — account menus, prominent separators
|
|
37
|
+
* @type {string}
|
|
38
|
+
* @default 'light'
|
|
39
|
+
* @values 'light' | 'medium' | 'dark'
|
|
40
|
+
*/
|
|
41
|
+
color: { type: String, default: 'light' },
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
const horizontalClasses = 'border-t my-1'
|
|
45
|
+
|
|
46
|
+
const verticalClasses = 'w-px h-5 mx-1'
|
|
47
|
+
|
|
48
|
+
const colorClass = computed(() => {
|
|
49
|
+
if (props.direction === 'vertical') {
|
|
50
|
+
const map = {
|
|
51
|
+
light: 'bg-gray-300/60 dark:bg-gray-700',
|
|
52
|
+
medium: 'bg-gray-300/60 dark:bg-gray-700',
|
|
53
|
+
dark: 'bg-gray-300 dark:bg-gray-600',
|
|
54
|
+
}
|
|
55
|
+
return map[props.color] || map.light
|
|
56
|
+
}
|
|
57
|
+
const map = {
|
|
58
|
+
light: 'border-gray-100 dark:border-gray-700',
|
|
59
|
+
medium: 'border-gray-200 dark:border-gray-700',
|
|
60
|
+
dark: 'border-gray-300 dark:border-gray-600',
|
|
61
|
+
}
|
|
62
|
+
return map[props.color] || map.light
|
|
63
|
+
})
|
|
64
|
+
</script>
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="containerRef" class="relative">
|
|
3
|
+
<!-- Trigger slot: receives { open, toggle } for controlling the dropdown -->
|
|
4
|
+
<slot name="trigger" :open="isOpen" :toggle="toggle" />
|
|
5
|
+
|
|
6
|
+
<!-- Dropdown panel with animated enter/leave transitions -->
|
|
7
|
+
<Transition
|
|
8
|
+
:enter-active-class="transitionClasses.enterActive"
|
|
9
|
+
:enter-from-class="transitionClasses.enterFrom"
|
|
10
|
+
:enter-to-class="transitionClasses.enterTo"
|
|
11
|
+
:leave-active-class="transitionClasses.leaveActive"
|
|
12
|
+
:leave-from-class="transitionClasses.leaveFrom"
|
|
13
|
+
:leave-to-class="transitionClasses.leaveTo"
|
|
14
|
+
>
|
|
15
|
+
<div v-show="isOpen" :class="panelClasses">
|
|
16
|
+
<slot :close="close" />
|
|
17
|
+
</div>
|
|
18
|
+
</Transition>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script setup>
|
|
23
|
+
/**
|
|
24
|
+
* UiDropdown — Headless dropdown menu with configurable alignment, direction, and transitions.
|
|
25
|
+
*
|
|
26
|
+
* Uses a trigger slot that receives `open` state and `toggle` function, and a default
|
|
27
|
+
* slot for menu content that receives a `close` function. Closes on outside click and
|
|
28
|
+
* Escape key. Supports both downward and upward drop directions with matching transitions.
|
|
29
|
+
* Exposes `isOpen`, `toggle()`, and `close()` for programmatic control.
|
|
30
|
+
*
|
|
31
|
+
* @example Basic dropdown with button trigger
|
|
32
|
+
* <UiDropdown>
|
|
33
|
+
* <template #trigger="{ toggle }">
|
|
34
|
+
* <UiButton @click="toggle">Menu</UiButton>
|
|
35
|
+
* </template>
|
|
36
|
+
* <UiDropdownItem icon="mdi:pencil" label="Edit" @click="edit" />
|
|
37
|
+
* <UiDropdownItem icon="mdi:trash-can" label="Delete" color="red" @click="del" />
|
|
38
|
+
* </UiDropdown>
|
|
39
|
+
*
|
|
40
|
+
* @example Right-aligned, drop-up
|
|
41
|
+
* <UiDropdown align="right" drop="up" width="w-48">
|
|
42
|
+
* <template #trigger="{ toggle }">
|
|
43
|
+
* <UiButton variant="ghost" icon-only @click="toggle">
|
|
44
|
+
* <UiIcon name="mdi:dots-vertical" class="w-5 h-5" />
|
|
45
|
+
* </UiButton>
|
|
46
|
+
* </template>
|
|
47
|
+
* <slot />
|
|
48
|
+
* </UiDropdown>
|
|
49
|
+
*
|
|
50
|
+
* @emits {void} open — Emitted when the dropdown opens
|
|
51
|
+
* @emits {void} close — Emitted when the dropdown closes
|
|
52
|
+
*
|
|
53
|
+
* @slot trigger — Trigger element that opens the dropdown. Receives { open: boolean, toggle: Function }
|
|
54
|
+
* @slot default — Dropdown menu content. Receives { close: Function }
|
|
55
|
+
*
|
|
56
|
+
* @see UiDropdownItem — Standard menu item for use inside this dropdown
|
|
57
|
+
* @see UiDropdownSubmenu — Nested submenu for this dropdown
|
|
58
|
+
*/
|
|
59
|
+
import { ref, computed } from 'vue'
|
|
60
|
+
import { onClickOutside } from '../composables/onClickOutside.js'
|
|
61
|
+
import { useEventListener } from '../composables/useEventListener.js'
|
|
62
|
+
const props = defineProps({
|
|
63
|
+
/**
|
|
64
|
+
* Width class applied to the dropdown panel.
|
|
65
|
+
* @type {string}
|
|
66
|
+
* @default 'w-56'
|
|
67
|
+
* @example 'w-48', 'w-64', 'w-72'
|
|
68
|
+
*/
|
|
69
|
+
width: { type: String, default: 'w-56' },
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Horizontal alignment of the panel relative to the trigger.
|
|
73
|
+
* @type {string}
|
|
74
|
+
* @default 'left'
|
|
75
|
+
* @values 'left' | 'right'
|
|
76
|
+
*/
|
|
77
|
+
align: { type: String, default: 'left' },
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Drop direction — 'down' opens below the trigger, 'up' opens above.
|
|
81
|
+
* @type {string}
|
|
82
|
+
* @default 'down'
|
|
83
|
+
* @values 'down' | 'up'
|
|
84
|
+
*/
|
|
85
|
+
drop: { type: String, default: 'down' },
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Override all default panel classes (bg, border, rounded, shadow).
|
|
89
|
+
* When set, the built-in panel styling is completely replaced.
|
|
90
|
+
* @type {string}
|
|
91
|
+
* @default ''
|
|
92
|
+
*/
|
|
93
|
+
panelClass: { type: String, default: '' },
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
const emit = defineEmits(['open', 'close'])
|
|
97
|
+
|
|
98
|
+
const isOpen = ref(false)
|
|
99
|
+
const containerRef = ref(null)
|
|
100
|
+
|
|
101
|
+
// Build panel positioning/styling classes, or use custom override
|
|
102
|
+
const panelClasses = computed(() => {
|
|
103
|
+
if (props.panelClass) return props.panelClass
|
|
104
|
+
const align = props.align === 'right' ? 'right-0' : 'left-0'
|
|
105
|
+
const dropDir = props.drop === 'up' ? 'bottom-full mb-1' : 'mt-1'
|
|
106
|
+
return `absolute z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1 ${props.width} ${align} ${dropDir}`
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
// Use slide-up transition for drop="up", scale transition for drop="down"
|
|
110
|
+
const transitionClasses = computed(() => {
|
|
111
|
+
if (props.drop === 'up') {
|
|
112
|
+
return {
|
|
113
|
+
enterActive: 'transition ease-out duration-150',
|
|
114
|
+
enterFrom: 'opacity-0 translate-y-1',
|
|
115
|
+
enterTo: 'opacity-100 translate-y-0',
|
|
116
|
+
leaveActive: 'transition ease-in duration-100',
|
|
117
|
+
leaveFrom: 'opacity-100 translate-y-0',
|
|
118
|
+
leaveTo: 'opacity-0 translate-y-1',
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
enterActive: 'transition duration-100 ease-out',
|
|
123
|
+
enterFrom: 'opacity-0 scale-95',
|
|
124
|
+
enterTo: 'opacity-100 scale-100',
|
|
125
|
+
leaveActive: 'transition duration-75 ease-in',
|
|
126
|
+
leaveFrom: 'opacity-100 scale-100',
|
|
127
|
+
leaveTo: 'opacity-0 scale-95',
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
const toggle = () => {
|
|
132
|
+
isOpen.value = !isOpen.value
|
|
133
|
+
emit(isOpen.value ? 'open' : 'close')
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const close = () => {
|
|
137
|
+
if (isOpen.value) {
|
|
138
|
+
isOpen.value = false
|
|
139
|
+
emit('close')
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
onClickOutside(containerRef, close)
|
|
144
|
+
|
|
145
|
+
useEventListener(globalThis.document, 'keydown', (e) => {
|
|
146
|
+
if (e.key === 'Escape') close()
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
defineExpose({ isOpen, toggle, close })
|
|
150
|
+
</script>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- Menu item row: icon + label + optional shortcut -->
|
|
3
|
+
<UiButton
|
|
4
|
+
variant="menu-item"
|
|
5
|
+
:color="color"
|
|
6
|
+
:disabled="disabled"
|
|
7
|
+
@click="!disabled && $emit('click')"
|
|
8
|
+
>
|
|
9
|
+
<UiIcon :name="icon" class="w-4 h-4 block shrink-0" />
|
|
10
|
+
<span class="flex-1 text-left">{{ label }}</span>
|
|
11
|
+
<span v-if="shortcut" class="text-xs text-gray-400 dark:text-gray-500">{{ shortcut }}</span>
|
|
12
|
+
</UiButton>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup>
|
|
16
|
+
/**
|
|
17
|
+
* UiDropdownItem — Single menu item row for use inside UiDropdown.
|
|
18
|
+
*
|
|
19
|
+
* Renders a UiButton with `variant="menu-item"` containing an icon, label,
|
|
20
|
+
* and optional keyboard shortcut hint. Supports disabled state and destructive
|
|
21
|
+
* (red) color for dangerous actions like delete.
|
|
22
|
+
*
|
|
23
|
+
* @example Standard menu item
|
|
24
|
+
* <UiDropdownItem icon="mdi:pencil" label="Edit" @click="edit" />
|
|
25
|
+
*
|
|
26
|
+
* @example Destructive item with shortcut
|
|
27
|
+
* <UiDropdownItem icon="mdi:trash-can-outline" label="Delete" color="red" shortcut="⌫" @click="del" />
|
|
28
|
+
*
|
|
29
|
+
* @example Disabled item
|
|
30
|
+
* <UiDropdownItem icon="mdi:lock" label="Locked" disabled />
|
|
31
|
+
*
|
|
32
|
+
* @emits {void} click — Emitted when the item is clicked (unless disabled)
|
|
33
|
+
*
|
|
34
|
+
* @see UiDropdown — Parent dropdown container
|
|
35
|
+
*/
|
|
36
|
+
import UiButton from './Button.vue'
|
|
37
|
+
import UiIcon from '../icons/Icon.vue'
|
|
38
|
+
defineProps({
|
|
39
|
+
/**
|
|
40
|
+
* MDI icon name displayed at the start of the row.
|
|
41
|
+
* @type {string}
|
|
42
|
+
* @required
|
|
43
|
+
*/
|
|
44
|
+
icon: { type: String, required: true },
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Text label for the menu item.
|
|
48
|
+
* @type {string}
|
|
49
|
+
* @required
|
|
50
|
+
*/
|
|
51
|
+
label: { type: String, required: true },
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Optional keyboard shortcut hint displayed on the right side.
|
|
55
|
+
* @type {string}
|
|
56
|
+
* @default ''
|
|
57
|
+
*/
|
|
58
|
+
shortcut: { type: String, default: '' },
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Disabled state — dims the item and prevents click events.
|
|
62
|
+
* @type {boolean}
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
disabled: { type: Boolean, default: false },
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Color theme for the item text and hover background.
|
|
69
|
+
* Use 'red' for destructive actions.
|
|
70
|
+
* @type {string}
|
|
71
|
+
* @default 'gray'
|
|
72
|
+
* @values 'gray' | 'red' | 'green' | 'amber'
|
|
73
|
+
*/
|
|
74
|
+
color: { type: String, default: 'gray' },
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
defineEmits(['click'])
|
|
78
|
+
</script>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- Horizontal row of compact dropdown actions displayed side by side -->
|
|
3
|
+
<div
|
|
4
|
+
class="flex items-center mx-2 my-1 rounded-lg bg-gray-50 dark:bg-gray-700/40 overflow-hidden"
|
|
5
|
+
>
|
|
6
|
+
<slot />
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script setup>
|
|
11
|
+
/**
|
|
12
|
+
* UiDropdownRow — Horizontal container for placing dropdown actions side by side.
|
|
13
|
+
*
|
|
14
|
+
* Wraps child elements in a compact, rounded row with a tinted background.
|
|
15
|
+
* Children should use variant="menu-item" with flex-1 and justify-center
|
|
16
|
+
* for balanced, centered layout. A UiDivider with direction="vertical"
|
|
17
|
+
* works well between items.
|
|
18
|
+
*
|
|
19
|
+
* @example Two actions side by side
|
|
20
|
+
* <UiDropdownRow>
|
|
21
|
+
* <UiButton variant="menu-item" class="flex-1 justify-center" @click="lock">
|
|
22
|
+
* <UiIcon name="mdi:lock" class="w-4 h-4" />
|
|
23
|
+
* Lock
|
|
24
|
+
* </UiButton>
|
|
25
|
+
* <UiDivider direction="vertical" />
|
|
26
|
+
* <UiButton variant="menu-item" color="red" class="flex-1 justify-center" @click="signOut">
|
|
27
|
+
* <UiIcon name="mdi:logout" class="w-4 h-4" />
|
|
28
|
+
* Sign Out
|
|
29
|
+
* </UiButton>
|
|
30
|
+
* </UiDropdownRow>
|
|
31
|
+
*
|
|
32
|
+
* @slot default — Action buttons (and optional dividers) to lay out horizontally
|
|
33
|
+
*
|
|
34
|
+
* @see UiDropdown — Parent dropdown container
|
|
35
|
+
* @see UiDropdownItem — Standard single-row dropdown item
|
|
36
|
+
*/
|
|
37
|
+
</script>
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- Hover-triggered on desktop, click-triggered on mobile -->
|
|
3
|
+
<div
|
|
4
|
+
class="relative"
|
|
5
|
+
@mouseenter="!isMobile && (showSub = true)"
|
|
6
|
+
@mouseleave="!isMobile && (showSub = false)"
|
|
7
|
+
>
|
|
8
|
+
<UiButton variant="menu-item" :disabled="disabled" @click="showSub = !showSub">
|
|
9
|
+
<UiIcon :name="icon" class="w-4 h-4 block shrink-0" />
|
|
10
|
+
<span class="flex-1 text-left">{{ label }}</span>
|
|
11
|
+
<UiIcon
|
|
12
|
+
:name="isMobile ? (showSub ? 'mdi:chevron-up' : 'mdi:chevron-down') : 'mdi:chevron-right'"
|
|
13
|
+
class="w-3.5 h-3.5 block shrink-0 text-gray-400"
|
|
14
|
+
/>
|
|
15
|
+
</UiButton>
|
|
16
|
+
|
|
17
|
+
<!-- Mobile: inline accordion with left border accent -->
|
|
18
|
+
<Transition
|
|
19
|
+
enter-active-class="transition-all duration-100 ease-out"
|
|
20
|
+
enter-from-class="max-h-0 opacity-0"
|
|
21
|
+
enter-to-class="max-h-60 opacity-100"
|
|
22
|
+
leave-active-class="transition-all duration-75 ease-in"
|
|
23
|
+
leave-from-class="max-h-60 opacity-100"
|
|
24
|
+
leave-to-class="max-h-0 opacity-0"
|
|
25
|
+
>
|
|
26
|
+
<div
|
|
27
|
+
v-if="showSub && !disabled && isMobile"
|
|
28
|
+
class="overflow-hidden bg-gray-50 dark:bg-gray-850 border-l-2 border-primary-400 ml-5"
|
|
29
|
+
>
|
|
30
|
+
<slot />
|
|
31
|
+
</div>
|
|
32
|
+
</Transition>
|
|
33
|
+
|
|
34
|
+
<!-- Desktop: flyout panel positioned left or right -->
|
|
35
|
+
<Transition
|
|
36
|
+
enter-active-class="transition duration-100 ease-out"
|
|
37
|
+
enter-from-class="opacity-0 scale-95"
|
|
38
|
+
enter-to-class="opacity-100 scale-100"
|
|
39
|
+
leave-active-class="transition duration-75 ease-in"
|
|
40
|
+
leave-from-class="opacity-100 scale-100"
|
|
41
|
+
leave-to-class="opacity-0 scale-95"
|
|
42
|
+
>
|
|
43
|
+
<div
|
|
44
|
+
v-if="showSub && !disabled && !isMobile"
|
|
45
|
+
class="absolute top-0 w-52 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1 z-50"
|
|
46
|
+
:class="alignLeft ? 'right-full mr-1' : 'left-full ml-1'"
|
|
47
|
+
>
|
|
48
|
+
<slot />
|
|
49
|
+
</div>
|
|
50
|
+
</Transition>
|
|
51
|
+
</div>
|
|
52
|
+
</template>
|
|
53
|
+
|
|
54
|
+
<script setup>
|
|
55
|
+
/**
|
|
56
|
+
* UiDropdownSubmenu — Nested submenu for UiDropdown with responsive behavior.
|
|
57
|
+
*
|
|
58
|
+
* On desktop (≥640px), shows a flyout panel on hover to the left or right.
|
|
59
|
+
* On mobile (<640px), expands inline as an accordion with a left border accent.
|
|
60
|
+
* Automatically detects viewport width on mount and resize.
|
|
61
|
+
*
|
|
62
|
+
* @example Basic submenu
|
|
63
|
+
* <UiDropdownSubmenu icon="mdi:format-text" label="Text Style">
|
|
64
|
+
* <UiDropdownItem icon="mdi:format-bold" label="Bold" @click="bold" />
|
|
65
|
+
* <UiDropdownItem icon="mdi:format-italic" label="Italic" @click="italic" />
|
|
66
|
+
* </UiDropdownSubmenu>
|
|
67
|
+
*
|
|
68
|
+
* @example Left-aligned flyout
|
|
69
|
+
* <UiDropdownSubmenu icon="mdi:share" label="Share" align-left>
|
|
70
|
+
* <UiDropdownItem icon="mdi:email" label="Email" @click="shareEmail" />
|
|
71
|
+
* </UiDropdownSubmenu>
|
|
72
|
+
*
|
|
73
|
+
* @slot default — Submenu items (typically UiDropdownItem components)
|
|
74
|
+
*
|
|
75
|
+
* @see UiDropdown — Parent dropdown container
|
|
76
|
+
* @see UiDropdownItem — Standard menu item for use inside this submenu
|
|
77
|
+
*/
|
|
78
|
+
import { ref, onMounted, onUnmounted } from 'vue'
|
|
79
|
+
import UiButton from './Button.vue'
|
|
80
|
+
import UiIcon from '../icons/Icon.vue'
|
|
81
|
+
defineProps({
|
|
82
|
+
/**
|
|
83
|
+
* MDI icon name displayed at the start of the trigger row.
|
|
84
|
+
* @type {string}
|
|
85
|
+
* @required
|
|
86
|
+
*/
|
|
87
|
+
icon: { type: String, required: true },
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Text label for the submenu trigger.
|
|
91
|
+
* @type {string}
|
|
92
|
+
* @required
|
|
93
|
+
*/
|
|
94
|
+
label: { type: String, required: true },
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Disabled state — prevents opening the submenu.
|
|
98
|
+
* @type {boolean}
|
|
99
|
+
* @default false
|
|
100
|
+
*/
|
|
101
|
+
disabled: { type: Boolean, default: false },
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Align the desktop flyout to the left (right-to-left) instead of the default right.
|
|
105
|
+
* @type {boolean}
|
|
106
|
+
* @default false
|
|
107
|
+
*/
|
|
108
|
+
alignLeft: { type: Boolean, default: false },
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
const showSub = ref(false)
|
|
112
|
+
// Track viewport width to switch between mobile accordion and desktop flyout
|
|
113
|
+
const isMobile = ref(false)
|
|
114
|
+
|
|
115
|
+
const checkMobile = () => {
|
|
116
|
+
isMobile.value = window.innerWidth < 640
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
onMounted(() => {
|
|
120
|
+
checkMobile()
|
|
121
|
+
window.addEventListener('resize', checkMobile)
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
onUnmounted(() => {
|
|
125
|
+
window.removeEventListener('resize', checkMobile)
|
|
126
|
+
})
|
|
127
|
+
</script>
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- Clickable label wrapping a hidden file input — slot content acts as the visible trigger -->
|
|
3
|
+
<label
|
|
4
|
+
class="inline-flex items-center gap-2 cursor-pointer transition-colors"
|
|
5
|
+
:class="disabled ? 'opacity-50 pointer-events-none' : ''"
|
|
6
|
+
>
|
|
7
|
+
<slot />
|
|
8
|
+
<input
|
|
9
|
+
ref="inputRef"
|
|
10
|
+
type="file"
|
|
11
|
+
class="hidden"
|
|
12
|
+
:accept="accept"
|
|
13
|
+
:multiple="multiple"
|
|
14
|
+
:disabled="disabled"
|
|
15
|
+
@change="onChange"
|
|
16
|
+
/>
|
|
17
|
+
</label>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script setup>
|
|
21
|
+
/**
|
|
22
|
+
* UiFileInput — Hidden file input wrapped in a clickable label for custom trigger UI.
|
|
23
|
+
*
|
|
24
|
+
* The default slot provides the visible trigger content (e.g. a button or icon).
|
|
25
|
+
* Clicking anywhere in the label opens the native file picker. Supports file type
|
|
26
|
+
* filtering via `accept`, multi-file selection, and max file size validation.
|
|
27
|
+
* Exposes an `open()` method for programmatic triggering.
|
|
28
|
+
*
|
|
29
|
+
* @example Single image upload
|
|
30
|
+
* <UiFileInput accept="image/*" @select="onFile">
|
|
31
|
+
* <UiButton variant="outline">Upload Image</UiButton>
|
|
32
|
+
* </UiFileInput>
|
|
33
|
+
*
|
|
34
|
+
* @example Multiple files with size limit (5 MB)
|
|
35
|
+
* <UiFileInput multiple :max-size="5 * 1024 * 1024" @select="onFiles" @error="onError">
|
|
36
|
+
* <span>Choose files</span>
|
|
37
|
+
* </UiFileInput>
|
|
38
|
+
*
|
|
39
|
+
* @example Programmatic open via ref
|
|
40
|
+
* <UiFileInput ref="fileInput" @select="onFile"><span>Pick</span></UiFileInput>
|
|
41
|
+
* <!-- In script: fileInput.value.open() -->
|
|
42
|
+
*
|
|
43
|
+
* @emits {File | File[]} select — Emitted with the selected file(s) after validation passes
|
|
44
|
+
* @emits {{ type: string, file: File, message: string }} error — Emitted when a file exceeds the maxSize limit
|
|
45
|
+
*
|
|
46
|
+
* @slot default — Trigger content (e.g. a button or icon) that opens the file picker
|
|
47
|
+
*/
|
|
48
|
+
import { ref } from 'vue'
|
|
49
|
+
const props = defineProps({
|
|
50
|
+
/**
|
|
51
|
+
* Accepted file types (MIME types or extensions), passed to the native `accept` attribute.
|
|
52
|
+
* @type {string}
|
|
53
|
+
* @default undefined
|
|
54
|
+
* @example 'image/*', '.pdf,.doc', 'video/mp4'
|
|
55
|
+
*/
|
|
56
|
+
accept: { type: String, default: undefined },
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Allow selecting multiple files at once.
|
|
60
|
+
* @type {boolean}
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
multiple: { type: Boolean, default: false },
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Disabled state — dims the label and prevents file picker from opening.
|
|
67
|
+
* @type {boolean}
|
|
68
|
+
* @default false
|
|
69
|
+
*/
|
|
70
|
+
disabled: { type: Boolean, default: false },
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Maximum allowed file size in bytes. Set to 0 for no limit.
|
|
74
|
+
* Emits an 'error' event with `{ type: 'maxSize', file, message }` when exceeded.
|
|
75
|
+
* @type {number}
|
|
76
|
+
* @default 0
|
|
77
|
+
*/
|
|
78
|
+
maxSize: { type: Number, default: 0 },
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
const emit = defineEmits(['select', 'error'])
|
|
82
|
+
|
|
83
|
+
const inputRef = ref(null)
|
|
84
|
+
|
|
85
|
+
function onChange(e) {
|
|
86
|
+
const files = Array.from(e.target.files || [])
|
|
87
|
+
if (!files.length) return
|
|
88
|
+
|
|
89
|
+
if (props.maxSize > 0) {
|
|
90
|
+
const oversized = files.find((f) => f.size > props.maxSize)
|
|
91
|
+
if (oversized) {
|
|
92
|
+
const maxMB = (props.maxSize / 1024 / 1024).toFixed(1)
|
|
93
|
+
emit('error', { type: 'maxSize', file: oversized, message: `File exceeds ${maxMB} MB limit` })
|
|
94
|
+
e.target.value = ''
|
|
95
|
+
return
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
emit('select', props.multiple ? files : files[0])
|
|
100
|
+
e.target.value = ''
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
defineExpose({
|
|
104
|
+
open: () => inputRef.value?.click(),
|
|
105
|
+
el: inputRef,
|
|
106
|
+
})
|
|
107
|
+
</script>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<label v-if="label" :class="labelClasses">
|
|
4
|
+
{{ label }}
|
|
5
|
+
<span v-if="optional" class="font-normal text-gray-400 dark:text-gray-600">(optional)</span>
|
|
6
|
+
</label>
|
|
7
|
+
<slot />
|
|
8
|
+
<p v-if="hint" class="text-xs text-gray-500 dark:text-gray-500 mt-1">{{ hint }}</p>
|
|
9
|
+
<p v-if="error" class="text-xs text-red-600 dark:text-red-400 mt-1">{{ error }}</p>
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup>
|
|
14
|
+
/**
|
|
15
|
+
* UiFormField — Label + input wrapper with optional hint and error text.
|
|
16
|
+
*
|
|
17
|
+
* Wraps any form control (UiInput, UiSelect, etc.) with a consistent label,
|
|
18
|
+
* optional "(optional)" suffix, hint text below the input, and error message.
|
|
19
|
+
* Reduces the repeated label + div + hint pattern across all form-heavy modals.
|
|
20
|
+
*
|
|
21
|
+
* @example Basic field
|
|
22
|
+
* <UiFormField label="Email">
|
|
23
|
+
* <UiInput v-model="email" type="email" />
|
|
24
|
+
* </UiFormField>
|
|
25
|
+
*
|
|
26
|
+
* @example Field with hint and optional marker
|
|
27
|
+
* <UiFormField label="Password hint" optional hint="A clue to help remember">
|
|
28
|
+
* <UiInput v-model="hint" />
|
|
29
|
+
* </UiFormField>
|
|
30
|
+
*
|
|
31
|
+
* @example Field with error
|
|
32
|
+
* <UiFormField label="Password" :error="pwError">
|
|
33
|
+
* <UiInput v-model="pw" type="password" />
|
|
34
|
+
* </UiFormField>
|
|
35
|
+
*
|
|
36
|
+
* @example Inline label style (no bottom margin)
|
|
37
|
+
* <UiFormField label="Font Ligatures" inline>
|
|
38
|
+
* <UiToggle v-model="ligatures" />
|
|
39
|
+
* </UiFormField>
|
|
40
|
+
*
|
|
41
|
+
* @slot default — Form control (e.g. UiInput, UiSelect, UiToggle)
|
|
42
|
+
*/
|
|
43
|
+
import { computed } from 'vue'
|
|
44
|
+
const props = defineProps({
|
|
45
|
+
/**
|
|
46
|
+
* Label text displayed above the input.
|
|
47
|
+
* @type {string}
|
|
48
|
+
* @default ''
|
|
49
|
+
*/
|
|
50
|
+
label: { type: String, default: '' },
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Show "(optional)" suffix after the label.
|
|
54
|
+
* @type {boolean}
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
optional: { type: Boolean, default: false },
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Hint text displayed below the input in gray.
|
|
61
|
+
* @type {string}
|
|
62
|
+
* @default ''
|
|
63
|
+
*/
|
|
64
|
+
hint: { type: String, default: '' },
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Error message displayed below the input in red.
|
|
68
|
+
* @type {string}
|
|
69
|
+
* @default ''
|
|
70
|
+
*/
|
|
71
|
+
error: { type: String, default: '' },
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Inline label style — no bottom margin, suitable for toggle rows.
|
|
75
|
+
* @type {boolean}
|
|
76
|
+
* @default false
|
|
77
|
+
*/
|
|
78
|
+
inline: { type: Boolean, default: false },
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
const labelClasses = computed(() =>
|
|
82
|
+
props.inline
|
|
83
|
+
? 'block text-sm font-medium text-gray-700 dark:text-gray-400'
|
|
84
|
+
: 'block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1',
|
|
85
|
+
)
|
|
86
|
+
</script>
|