numori-ui 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +148 -0
- package/README.md +36 -34
- package/dist/components/AppShell.js +234 -0
- package/dist/components/AppShell.js.map +1 -0
- package/dist/components/Banner.js +29 -32
- package/dist/components/Banner.js.map +1 -1
- package/dist/components/Button.js +10 -19
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Card.js +15 -9
- package/dist/components/Card.js.map +1 -1
- package/dist/components/Checkbox.js +13 -9
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/CopyField.js +195 -0
- package/dist/components/CopyField.js.map +1 -0
- package/dist/components/DescriptionList.js +116 -0
- package/dist/components/DescriptionList.js.map +1 -0
- package/dist/components/Dropdown.js +10 -3
- package/dist/components/Dropdown.js.map +1 -1
- package/dist/components/DropdownSubmenu.js +5 -3
- package/dist/components/DropdownSubmenu.js.map +1 -1
- package/dist/components/EmptyState.js +123 -0
- package/dist/components/EmptyState.js.map +1 -0
- package/dist/components/FileInput.js +12 -4
- package/dist/components/FileInput.js.map +1 -1
- package/dist/components/FormField.js +43 -13
- package/dist/components/FormField.js.map +1 -1
- package/dist/components/IconTile.js +5 -9
- package/dist/components/IconTile.js.map +1 -1
- package/dist/components/Input.js +21 -7
- package/dist/components/Input.js.map +1 -1
- package/dist/components/ListMenuItem.js +38 -31
- package/dist/components/ListMenuItem.js.map +1 -1
- package/dist/components/Numpad.js +4 -4
- package/dist/components/Numpad.js.map +1 -1
- package/dist/components/PageHeader.js +106 -0
- package/dist/components/PageHeader.js.map +1 -0
- package/dist/components/Pagination.js +236 -0
- package/dist/components/Pagination.js.map +1 -0
- package/dist/components/Popup.js +9 -3
- package/dist/components/Popup.js.map +1 -1
- package/dist/components/Radio.js +2 -7
- package/dist/components/Radio.js.map +1 -1
- package/dist/components/Segmented.js +109 -27
- package/dist/components/Segmented.js.map +1 -1
- package/dist/components/Select.js +16 -5
- package/dist/components/Select.js.map +1 -1
- package/dist/components/Sidebar.js +69 -0
- package/dist/components/Sidebar.js.map +1 -0
- package/dist/components/SidebarGroup.js +50 -0
- package/dist/components/SidebarGroup.js.map +1 -0
- package/dist/components/SidebarItem.js +167 -0
- package/dist/components/SidebarItem.js.map +1 -0
- package/dist/components/StatCard.js +185 -0
- package/dist/components/StatCard.js.map +1 -0
- package/dist/components/Table.js +306 -0
- package/dist/components/Table.js.map +1 -0
- package/dist/components/Tabs.js +216 -0
- package/dist/components/Tabs.js.map +1 -0
- package/dist/components/Toggle.js +11 -2
- package/dist/components/Toggle.js.map +1 -1
- package/dist/components/index.js +91 -76
- package/dist/components/index.js.map +1 -1
- package/dist/composables/useMergedClasses.js +52 -0
- package/dist/composables/useMergedClasses.js.map +1 -0
- package/dist/icons/mdi.js +11 -0
- package/dist/icons/mdi.js.map +1 -1
- package/dist/index.d.ts +13 -3
- package/dist/index.js +47 -37
- package/dist/index.js.map +1 -1
- package/dist/internal/controlSizes.js +21 -0
- package/dist/internal/controlSizes.js.map +1 -0
- package/dist/internal/formField.js +26 -0
- package/dist/internal/formField.js.map +1 -0
- package/dist/internal/menu.js +20 -0
- package/dist/internal/menu.js.map +1 -0
- package/dist/manifest.js +12 -2
- package/dist/manifest.js.map +1 -1
- package/package.json +2 -1
- package/src/components/AppShell.vue +231 -0
- package/src/components/Banner.vue +20 -9
- package/src/components/Button.vue +12 -19
- package/src/components/Card.vue +11 -12
- package/src/components/Checkbox.vue +7 -10
- package/src/components/CopyField.vue +178 -0
- package/src/components/DescriptionList.vue +114 -0
- package/src/components/Dropdown.vue +14 -2
- package/src/components/DropdownSubmenu.vue +4 -2
- package/src/components/EmptyState.vue +107 -0
- package/src/components/FileInput.vue +19 -4
- package/src/components/FormField.vue +37 -4
- package/src/components/IconTile.vue +4 -9
- package/src/components/Input.vue +15 -6
- package/src/components/ListMenuItem.vue +21 -5
- package/src/components/Numpad.vue +7 -4
- package/src/components/PageHeader.vue +102 -0
- package/src/components/Pagination.vue +199 -0
- package/src/components/Popup.vue +6 -2
- package/src/components/Radio.vue +2 -10
- package/src/components/Segmented.vue +113 -38
- package/src/components/Select.vue +16 -2
- package/src/components/Sidebar.vue +61 -0
- package/src/components/SidebarGroup.vue +43 -0
- package/src/components/SidebarItem.vue +159 -0
- package/src/components/StatCard.vue +165 -0
- package/src/components/Table.vue +323 -0
- package/src/components/Tabs.vue +217 -0
- package/src/components/Toggle.vue +5 -0
- package/src/components/index.js +36 -11
- package/src/composables/useMergedClasses.js +49 -0
- package/src/icons/mdi.js +11 -0
- package/src/internal/controlSizes.js +17 -0
- package/src/internal/formField.js +23 -0
- package/src/internal/menu.js +16 -0
- package/src/manifest.js +12 -2
- package/dist/components/ButtonsGroup.js +0 -153
- package/dist/components/ButtonsGroup.js.map +0 -1
- package/dist/components/ComparisonTable.js +0 -152
- package/dist/components/ComparisonTable.js.map +0 -1
- package/src/components/ButtonsGroup.vue +0 -140
- package/src/components/ComparisonTable.vue +0 -141
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<dl :class="mergedClasses" v-bind="restAttrs">
|
|
3
|
+
<div v-for="(item, index) in items" :key="item.key ?? item.label ?? index" :class="rowClass">
|
|
4
|
+
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">
|
|
5
|
+
{{ item.label }}
|
|
6
|
+
<span
|
|
7
|
+
v-if="item.hint"
|
|
8
|
+
class="mt-0.5 block text-xs font-normal text-gray-400 dark:text-gray-500"
|
|
9
|
+
>{{ item.hint }}</span
|
|
10
|
+
>
|
|
11
|
+
</dt>
|
|
12
|
+
<dd
|
|
13
|
+
class="min-w-0 text-sm text-gray-900 dark:text-gray-100"
|
|
14
|
+
:class="[
|
|
15
|
+
item.mono ? 'font-mono text-[13px] break-all' : 'break-words',
|
|
16
|
+
layout === 'inline' ? 'mt-1 sm:col-span-2 sm:mt-0' : 'mt-1',
|
|
17
|
+
]"
|
|
18
|
+
>
|
|
19
|
+
<slot name="value" :item="item" :value="item.value">
|
|
20
|
+
<span v-if="isEmpty(item.value)" class="text-gray-400 dark:text-gray-500">{{
|
|
21
|
+
emptyText
|
|
22
|
+
}}</span>
|
|
23
|
+
<template v-else>{{ item.value }}</template>
|
|
24
|
+
</slot>
|
|
25
|
+
</dd>
|
|
26
|
+
</div>
|
|
27
|
+
</dl>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script setup>
|
|
31
|
+
/**
|
|
32
|
+
* UiDescriptionList — label / value pairs, such as a record's details or a
|
|
33
|
+
* service's settings, rendered as a real `<dl>`.
|
|
34
|
+
*
|
|
35
|
+
* Three layouts:
|
|
36
|
+
* - `inline` (default): label in a narrow left column, value beside it, one
|
|
37
|
+
* pair per row with dividers. Stacks on narrow screens.
|
|
38
|
+
* - `stacked`: label above value, one pair per row.
|
|
39
|
+
* - `grid`: label above value, pairs flowing into two columns.
|
|
40
|
+
*
|
|
41
|
+
* Empty values (`null`, `undefined`, `''`) render `emptyText` so a missing
|
|
42
|
+
* setting reads as deliberate rather than as a rendering bug. Use the `#value`
|
|
43
|
+
* slot to render badges, links or copy fields.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* <UiDescriptionList
|
|
47
|
+
* :items="[
|
|
48
|
+
* { label: 'App id', value: 'notes', mono: true },
|
|
49
|
+
* { label: 'Storage', value: 'postgres' },
|
|
50
|
+
* { label: 'Audience', value: null, hint: 'Optional app/aud claim' },
|
|
51
|
+
* ]"
|
|
52
|
+
* />
|
|
53
|
+
*
|
|
54
|
+
* @example Custom value rendering
|
|
55
|
+
* <UiDescriptionList :items="items">
|
|
56
|
+
* <template #value="{ item, value }">
|
|
57
|
+
* <UiBadge v-if="item.key === 'status'" color="green">{{ value }}</UiBadge>
|
|
58
|
+
* <template v-else>{{ value }}</template>
|
|
59
|
+
* </template>
|
|
60
|
+
* </UiDescriptionList>
|
|
61
|
+
*
|
|
62
|
+
* @slot value — Custom value content. Scope: `{ item, value }`.
|
|
63
|
+
*/
|
|
64
|
+
import { computed } from 'vue'
|
|
65
|
+
import { useMergedClasses } from '../composables/useMergedClasses.js'
|
|
66
|
+
|
|
67
|
+
const props = defineProps({
|
|
68
|
+
/**
|
|
69
|
+
* Pairs to show. Each is `{ label, value, key?, hint?, mono? }`; `mono`
|
|
70
|
+
* renders the value in a monospace font that breaks anywhere (ids, keys).
|
|
71
|
+
* @type {Array<{ label: string, value?: unknown, key?: string, hint?: string, mono?: boolean }>}
|
|
72
|
+
*/
|
|
73
|
+
items: { type: Array, required: true },
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Arrangement of each pair.
|
|
77
|
+
* @type {string}
|
|
78
|
+
* @default 'inline'
|
|
79
|
+
* @values 'inline' | 'stacked' | 'grid'
|
|
80
|
+
*/
|
|
81
|
+
layout: { type: String, default: 'inline' },
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Dividers between rows (ignored by `grid`).
|
|
85
|
+
* @type {boolean}
|
|
86
|
+
* @default true
|
|
87
|
+
*/
|
|
88
|
+
divided: { type: Boolean, default: true },
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Shown in place of an empty value.
|
|
92
|
+
* @type {string}
|
|
93
|
+
* @default '—'
|
|
94
|
+
*/
|
|
95
|
+
emptyText: { type: String, default: '—' },
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
defineOptions({ inheritAttrs: false })
|
|
99
|
+
|
|
100
|
+
const isEmpty = (value) => value === null || value === undefined || value === ''
|
|
101
|
+
|
|
102
|
+
const rowClass = computed(() => {
|
|
103
|
+
if (props.layout === 'grid') return ''
|
|
104
|
+
if (props.layout === 'stacked') return 'py-3 first:pt-0 last:pb-0'
|
|
105
|
+
return 'py-3 first:pt-0 last:pb-0 sm:grid sm:grid-cols-3 sm:gap-4'
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
const internalClasses = computed(() => {
|
|
109
|
+
if (props.layout === 'grid') return 'grid gap-x-6 gap-y-4 sm:grid-cols-2'
|
|
110
|
+
return props.divided ? 'divide-y divide-gray-100 dark:divide-gray-800' : ''
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
const { mergedClasses, restAttrs } = useMergedClasses(() => internalClasses.value)
|
|
114
|
+
</script>
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
:leave-from-class="transitionClasses.leaveFrom"
|
|
13
13
|
:leave-to-class="transitionClasses.leaveTo"
|
|
14
14
|
>
|
|
15
|
-
<div v-show="isOpen" :class="panelClasses">
|
|
15
|
+
<div v-show="isOpen" :class="panelClasses" :style="{ transformOrigin: panelOrigin }">
|
|
16
16
|
<slot :close="close" />
|
|
17
17
|
</div>
|
|
18
18
|
</Transition>
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
import { ref, computed } from 'vue'
|
|
60
60
|
import { onClickOutside } from '../composables/onClickOutside.js'
|
|
61
61
|
import { useEventListener } from '../composables/useEventListener.js'
|
|
62
|
+
import { MENU_PANEL_CLASS } from '../internal/menu.js'
|
|
62
63
|
const props = defineProps({
|
|
63
64
|
/**
|
|
64
65
|
* Width class applied to the dropdown panel.
|
|
@@ -103,7 +104,18 @@ const panelClasses = computed(() => {
|
|
|
103
104
|
if (props.panelClass) return props.panelClass
|
|
104
105
|
const align = props.align === 'right' ? 'right-0' : 'left-0'
|
|
105
106
|
const dropDir = props.drop === 'up' ? 'bottom-full mb-1' : 'mt-1'
|
|
106
|
-
|
|
107
|
+
// `p-1` (not just `py-1`) insets the rows so their rounded hover highlight
|
|
108
|
+
// reads as a chip with breathing room from the panel edge.
|
|
109
|
+
return `absolute z-50 ${MENU_PANEL_CLASS} p-1 ${props.width} ${align} ${dropDir}`
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
// Inline transform-origin (not a Tailwind class, so it needs no build step to
|
|
113
|
+
// take effect): the panel scales in from the corner nearest the trigger rather
|
|
114
|
+
// than drifting in from its centre.
|
|
115
|
+
const panelOrigin = computed(() => {
|
|
116
|
+
const y = props.drop === 'up' ? 'bottom' : 'top'
|
|
117
|
+
const x = props.align === 'right' ? 'right' : 'left'
|
|
118
|
+
return `${y} ${x}`
|
|
107
119
|
})
|
|
108
120
|
|
|
109
121
|
// Use slide-up transition for drop="up", scale transition for drop="down"
|
|
@@ -42,8 +42,9 @@
|
|
|
42
42
|
>
|
|
43
43
|
<div
|
|
44
44
|
v-if="showSub && !disabled && !isMobile"
|
|
45
|
-
class="absolute top-0 w-52
|
|
46
|
-
:class="alignLeft ? 'right-full mr-1' : 'left-full ml-1'"
|
|
45
|
+
class="absolute top-0 w-52 py-1 z-50"
|
|
46
|
+
:class="[MENU_PANEL_CLASS, alignLeft ? 'right-full mr-1' : 'left-full ml-1']"
|
|
47
|
+
:style="{ transformOrigin: alignLeft ? 'top right' : 'top left' }"
|
|
47
48
|
>
|
|
48
49
|
<slot />
|
|
49
50
|
</div>
|
|
@@ -78,6 +79,7 @@
|
|
|
78
79
|
import { ref, onMounted, onUnmounted } from 'vue'
|
|
79
80
|
import UiButton from './Button.vue'
|
|
80
81
|
import UiIcon from '../icons/Icon.vue'
|
|
82
|
+
import { MENU_PANEL_CLASS } from '../internal/menu.js'
|
|
81
83
|
defineProps({
|
|
82
84
|
/**
|
|
83
85
|
* MDI icon name displayed at the start of the trigger row.
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="mergedClasses" v-bind="restAttrs">
|
|
3
|
+
<div
|
|
4
|
+
class="mx-auto flex size-12 items-center justify-center rounded-2xl bg-gray-100 text-gray-400 dark:bg-gray-800 dark:text-gray-500"
|
|
5
|
+
aria-hidden="true"
|
|
6
|
+
>
|
|
7
|
+
<slot name="icon"><UiIcon :name="icon" class="size-6" /></slot>
|
|
8
|
+
</div>
|
|
9
|
+
<component :is="headingTag" class="mt-4 text-sm font-semibold text-gray-900 dark:text-gray-100">
|
|
10
|
+
{{ title }}
|
|
11
|
+
</component>
|
|
12
|
+
<p
|
|
13
|
+
v-if="description || $slots.description"
|
|
14
|
+
class="mx-auto mt-1 max-w-sm text-sm text-gray-500 dark:text-gray-400"
|
|
15
|
+
>
|
|
16
|
+
<slot name="description">{{ description }}</slot>
|
|
17
|
+
</p>
|
|
18
|
+
<div v-if="$slots.default" class="mt-5 flex flex-wrap justify-center gap-2">
|
|
19
|
+
<slot />
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script setup>
|
|
25
|
+
/**
|
|
26
|
+
* UiEmptyState — what a list, table or page shows when there is nothing in it
|
|
27
|
+
* yet: an icon, a short title, one line of explanation and the action that
|
|
28
|
+
* fixes it.
|
|
29
|
+
*
|
|
30
|
+
* Say why it is empty and what to do next, rather than only that it is empty.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* <UiEmptyState
|
|
34
|
+
* icon="mdi:sync"
|
|
35
|
+
* title="No apps yet"
|
|
36
|
+
* description="Register an app to give its clients a place to sync."
|
|
37
|
+
* >
|
|
38
|
+
* <UiButton><UiIcon name="mdi:plus" class="size-4" />New app</UiButton>
|
|
39
|
+
* </UiEmptyState>
|
|
40
|
+
*
|
|
41
|
+
* @slot default — Actions.
|
|
42
|
+
* @slot icon — Custom icon content.
|
|
43
|
+
* @slot description — Rich description (overrides `description`).
|
|
44
|
+
*/
|
|
45
|
+
import { computed } from 'vue'
|
|
46
|
+
import UiIcon from '../icons/Icon.vue'
|
|
47
|
+
import { useMergedClasses } from '../composables/useMergedClasses.js'
|
|
48
|
+
|
|
49
|
+
const props = defineProps({
|
|
50
|
+
/**
|
|
51
|
+
* Short statement of the state, e.g. "No apps yet".
|
|
52
|
+
* @type {string}
|
|
53
|
+
* @default ''
|
|
54
|
+
*/
|
|
55
|
+
title: { type: String, default: '' },
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* One line explaining why, or what to do.
|
|
59
|
+
* @type {string}
|
|
60
|
+
* @default ''
|
|
61
|
+
*/
|
|
62
|
+
description: { type: String, default: '' },
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* MDI icon.
|
|
66
|
+
* @type {string}
|
|
67
|
+
* @default 'mdi:inbox-outline'
|
|
68
|
+
*/
|
|
69
|
+
icon: { type: String, default: 'mdi:inbox-outline' },
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Tighter vertical padding, for use inside cards and tables.
|
|
73
|
+
* @type {boolean}
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
76
|
+
compact: { type: Boolean, default: false },
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Dashed outline around the state, for standalone use on a page.
|
|
80
|
+
* @type {boolean}
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
bordered: { type: Boolean, default: false },
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Element used for the title.
|
|
87
|
+
* @type {string}
|
|
88
|
+
* @default 'h3'
|
|
89
|
+
* @values 'h2' | 'h3' | 'h4' | 'p'
|
|
90
|
+
*/
|
|
91
|
+
headingTag: { type: String, default: 'h3' },
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
defineOptions({ inheritAttrs: false })
|
|
95
|
+
|
|
96
|
+
const internalClasses = computed(() =>
|
|
97
|
+
[
|
|
98
|
+
'text-center',
|
|
99
|
+
props.compact ? 'px-4 py-6' : 'px-6 py-12',
|
|
100
|
+
props.bordered ? 'rounded-2xl border-2 border-dashed border-gray-200 dark:border-gray-700' : '',
|
|
101
|
+
]
|
|
102
|
+
.filter(Boolean)
|
|
103
|
+
.join(' '),
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
const { mergedClasses, restAttrs } = useMergedClasses(() => internalClasses.value)
|
|
107
|
+
</script>
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<!-- Clickable
|
|
3
|
-
|
|
2
|
+
<!-- Clickable wrapper around a hidden file input — slot content is the visible trigger.
|
|
3
|
+
A plain <label> would not work when the slot is a <button> (or any interactive
|
|
4
|
+
element): the browser skips label→control forwarding when the click lands on an
|
|
5
|
+
interactive descendant, so the picker never opened. Handling the click ourselves
|
|
6
|
+
makes any trigger content work. -->
|
|
7
|
+
<span
|
|
4
8
|
class="inline-flex items-center gap-2 cursor-pointer transition-colors"
|
|
5
9
|
:class="disabled ? 'opacity-50 pointer-events-none' : ''"
|
|
10
|
+
@click="onTriggerClick"
|
|
6
11
|
>
|
|
7
12
|
<slot />
|
|
8
13
|
<input
|
|
@@ -13,8 +18,9 @@
|
|
|
13
18
|
:multiple="multiple"
|
|
14
19
|
:disabled="disabled"
|
|
15
20
|
@change="onChange"
|
|
21
|
+
@click.stop
|
|
16
22
|
/>
|
|
17
|
-
</
|
|
23
|
+
</span>
|
|
18
24
|
</template>
|
|
19
25
|
|
|
20
26
|
<script setup>
|
|
@@ -100,8 +106,17 @@ function onChange(e) {
|
|
|
100
106
|
e.target.value = ''
|
|
101
107
|
}
|
|
102
108
|
|
|
109
|
+
const open = () => inputRef.value?.click()
|
|
110
|
+
|
|
111
|
+
// A click anywhere in the wrapper opens the picker. The hidden input's own
|
|
112
|
+
// (programmatic) click is stopped from bubbling via `@click.stop` in the
|
|
113
|
+
// template, so this never re-enters itself.
|
|
114
|
+
const onTriggerClick = () => {
|
|
115
|
+
if (!props.disabled) open()
|
|
116
|
+
}
|
|
117
|
+
|
|
103
118
|
defineExpose({
|
|
104
|
-
open
|
|
119
|
+
open,
|
|
105
120
|
el: inputRef,
|
|
106
121
|
})
|
|
107
122
|
</script>
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<label v-if="label" :class="labelClasses">
|
|
3
|
+
<label v-if="label" :id="labelId" :for="controlId" :class="labelClasses">
|
|
4
4
|
{{ label }}
|
|
5
5
|
<span v-if="optional" class="font-normal text-gray-400 dark:text-gray-600">(optional)</span>
|
|
6
6
|
</label>
|
|
7
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">
|
|
8
|
+
<p v-if="hint" :id="hintId" class="text-xs text-gray-500 dark:text-gray-500 mt-1">{{ hint }}</p>
|
|
9
|
+
<p v-if="error" :id="errorId" class="text-xs text-red-600 dark:text-red-400 mt-1">
|
|
10
|
+
{{ error }}
|
|
11
|
+
</p>
|
|
10
12
|
</div>
|
|
11
13
|
</template>
|
|
12
14
|
|
|
@@ -38,9 +40,15 @@
|
|
|
38
40
|
* <UiToggle v-model="ligatures" />
|
|
39
41
|
* </UiFormField>
|
|
40
42
|
*
|
|
43
|
+
* The label is associated with the control: UiInput, UiSelect, UiToggle,
|
|
44
|
+
* UiCheckbox and UiSegmented pick up the field's id, so the label, hint and
|
|
45
|
+
* error are announced by screen readers and clicking the label focuses the
|
|
46
|
+
* control. For any other control, give it the id passed as `for`.
|
|
47
|
+
*
|
|
41
48
|
* @slot default — Form control (e.g. UiInput, UiSelect, UiToggle)
|
|
42
49
|
*/
|
|
43
|
-
import { computed } from 'vue'
|
|
50
|
+
import { computed, provide, useId } from 'vue'
|
|
51
|
+
import { FORM_FIELD_KEY } from '../internal/formField.js'
|
|
44
52
|
const props = defineProps({
|
|
45
53
|
/**
|
|
46
54
|
* Label text displayed above the input.
|
|
@@ -76,6 +84,31 @@ const props = defineProps({
|
|
|
76
84
|
* @default false
|
|
77
85
|
*/
|
|
78
86
|
inline: { type: Boolean, default: false },
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Id of the control the label points at. Generated when omitted; set it
|
|
90
|
+
* when the control is not a Numori UI form component.
|
|
91
|
+
* @type {string}
|
|
92
|
+
* @default ''
|
|
93
|
+
*/
|
|
94
|
+
for: { type: String, default: '' },
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
const uid = useId()
|
|
98
|
+
const controlId = computed(() => props.for || `${uid}-control`)
|
|
99
|
+
const labelId = `${uid}-label`
|
|
100
|
+
const hintId = `${uid}-hint`
|
|
101
|
+
const errorId = `${uid}-error`
|
|
102
|
+
|
|
103
|
+
provide(FORM_FIELD_KEY, {
|
|
104
|
+
controlId,
|
|
105
|
+
labelId,
|
|
106
|
+
describedBy: computed(
|
|
107
|
+
() =>
|
|
108
|
+
[props.hint ? hintId : null, props.error ? errorId : null].filter(Boolean).join(' ') ||
|
|
109
|
+
undefined,
|
|
110
|
+
),
|
|
111
|
+
invalid: computed(() => !!props.error),
|
|
79
112
|
})
|
|
80
113
|
|
|
81
114
|
const labelClasses = computed(() =>
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
* @example Success tile
|
|
25
25
|
* <UiIconTile icon="mdi:check" color="success" size="sm" />
|
|
26
26
|
*/
|
|
27
|
-
import { computed
|
|
28
|
-
import {
|
|
27
|
+
import { computed } from 'vue'
|
|
28
|
+
import { useMergedClasses } from '../composables/useMergedClasses.js'
|
|
29
29
|
import UiIcon from '../icons/Icon.vue'
|
|
30
30
|
|
|
31
31
|
const props = defineProps({
|
|
@@ -87,14 +87,9 @@ const colorClass = computed(
|
|
|
87
87
|
|
|
88
88
|
defineOptions({ inheritAttrs: false })
|
|
89
89
|
|
|
90
|
-
const attrs = useAttrs()
|
|
91
|
-
const restAttrs = computed(() => {
|
|
92
|
-
const { class: _class, ...rest } = attrs
|
|
93
|
-
return rest
|
|
94
|
-
})
|
|
95
|
-
|
|
96
90
|
// External classes merge last so a caller's `bg-*`/`text-*` (e.g. a Tailwind
|
|
97
91
|
// palette outside the semantic set) overrides the built-in tint rather than
|
|
98
92
|
// colliding with it.
|
|
99
|
-
const
|
|
93
|
+
const internalClasses = computed(() => `${sizeClass.value} ${colorClass.value}`)
|
|
94
|
+
const { mergedClasses, restAttrs } = useMergedClasses(internalClasses)
|
|
100
95
|
</script>
|
package/src/components/Input.vue
CHANGED
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
<!-- Number stepper: stacked up/down buttons on left -->
|
|
18
18
|
<div
|
|
19
19
|
v-if="isNumber && stepperLayout === 'stacked-left'"
|
|
20
|
-
class="flex flex-col w-
|
|
20
|
+
class="flex flex-col w-7 border border-r-0 border-gray-300 dark:border-gray-600 rounded-l-lg overflow-hidden"
|
|
21
21
|
:class="{ 'opacity-50 pointer-events-none': disabled }"
|
|
22
22
|
>
|
|
23
23
|
<button
|
|
24
24
|
type="button"
|
|
25
25
|
tabindex="-1"
|
|
26
|
-
class="grid place-items-center w-
|
|
26
|
+
class="grid place-items-center w-full flex-1 bg-gray-50 dark:bg-gray-800 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors select-none border-b border-gray-300 dark:border-gray-600"
|
|
27
27
|
aria-label="Increase value"
|
|
28
28
|
@click="stepUp"
|
|
29
29
|
>
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
<button
|
|
33
33
|
type="button"
|
|
34
34
|
tabindex="-1"
|
|
35
|
-
class="grid place-items-center w-
|
|
35
|
+
class="grid place-items-center w-full flex-1 bg-gray-50 dark:bg-gray-800 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors select-none"
|
|
36
36
|
aria-label="Decrease value"
|
|
37
37
|
@click="stepDown"
|
|
38
38
|
>
|
|
@@ -43,7 +43,10 @@
|
|
|
43
43
|
<!-- Textarea mode: multi-line text input with custom scrollbar styling -->
|
|
44
44
|
<textarea
|
|
45
45
|
v-if="isTextarea"
|
|
46
|
+
:id="field?.controlId.value"
|
|
46
47
|
ref="inputRef"
|
|
48
|
+
:aria-describedby="field?.describedBy.value"
|
|
49
|
+
:aria-invalid="field?.invalid.value ? 'true' : undefined"
|
|
47
50
|
:value="modelValue"
|
|
48
51
|
:placeholder="placeholder"
|
|
49
52
|
:required="required"
|
|
@@ -71,7 +74,10 @@
|
|
|
71
74
|
|
|
72
75
|
<input
|
|
73
76
|
v-if="!isTextarea"
|
|
77
|
+
:id="field?.controlId.value"
|
|
74
78
|
ref="inputRef"
|
|
79
|
+
:aria-describedby="field?.describedBy.value"
|
|
80
|
+
:aria-invalid="field?.invalid.value ? 'true' : undefined"
|
|
75
81
|
:type="computedType"
|
|
76
82
|
:value="modelValue"
|
|
77
83
|
:placeholder="placeholder"
|
|
@@ -140,13 +146,13 @@
|
|
|
140
146
|
<!-- Number stepper: stacked up/down buttons on right -->
|
|
141
147
|
<div
|
|
142
148
|
v-if="isNumber && stepperLayout === 'stacked-right'"
|
|
143
|
-
class="flex flex-col w-
|
|
149
|
+
class="flex flex-col w-7 border border-l-0 border-gray-300 dark:border-gray-600 rounded-r-lg overflow-hidden"
|
|
144
150
|
:class="{ 'opacity-50 pointer-events-none': disabled }"
|
|
145
151
|
>
|
|
146
152
|
<button
|
|
147
153
|
type="button"
|
|
148
154
|
tabindex="-1"
|
|
149
|
-
class="grid place-items-center w-
|
|
155
|
+
class="grid place-items-center w-full flex-1 bg-gray-50 dark:bg-gray-800 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors select-none border-b border-gray-300 dark:border-gray-600"
|
|
150
156
|
aria-label="Increase value"
|
|
151
157
|
@click="stepUp"
|
|
152
158
|
>
|
|
@@ -155,7 +161,7 @@
|
|
|
155
161
|
<button
|
|
156
162
|
type="button"
|
|
157
163
|
tabindex="-1"
|
|
158
|
-
class="grid place-items-center w-
|
|
164
|
+
class="grid place-items-center w-full flex-1 bg-gray-50 dark:bg-gray-800 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors select-none"
|
|
159
165
|
aria-label="Decrease value"
|
|
160
166
|
@click="stepDown"
|
|
161
167
|
>
|
|
@@ -217,6 +223,7 @@
|
|
|
217
223
|
*/
|
|
218
224
|
import { ref, computed, watch, useSlots } from 'vue'
|
|
219
225
|
import UiIcon from '../icons/Icon.vue'
|
|
226
|
+
import { useFormField } from '../internal/formField.js'
|
|
220
227
|
const props = defineProps({
|
|
221
228
|
/**
|
|
222
229
|
* Bound value (v-model).
|
|
@@ -421,6 +428,8 @@ const props = defineProps({
|
|
|
421
428
|
|
|
422
429
|
const emit = defineEmits(['update:modelValue', 'validation'])
|
|
423
430
|
|
|
431
|
+
const field = useFormField()
|
|
432
|
+
|
|
424
433
|
const inputRef = ref(null)
|
|
425
434
|
const passwordVisible = ref(false)
|
|
426
435
|
const touched = ref(false)
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
<!-- A <div role="button"> rather than a real <button> when interactive: the
|
|
3
|
+
suffix slot commonly holds interactive controls (UiToggle, UiSelect —
|
|
4
|
+
both <button>s), and nesting a <button> inside a <button> is invalid HTML
|
|
5
|
+
the browser restructures, which breaks SSR hydration. A <div> can legally
|
|
6
|
+
contain those controls. -->
|
|
7
|
+
<div
|
|
5
8
|
class="w-full flex items-center gap-3 text-sm text-left transition-colors"
|
|
6
9
|
:class="[sizeClass, colorClass]"
|
|
7
|
-
:
|
|
10
|
+
:role="isInteractive ? 'button' : undefined"
|
|
11
|
+
:tabindex="isInteractive && !disabled ? 0 : undefined"
|
|
12
|
+
:aria-disabled="isInteractive && disabled ? 'true' : undefined"
|
|
8
13
|
@click="handleClick"
|
|
14
|
+
@keydown="onKeydown"
|
|
9
15
|
>
|
|
10
16
|
<UiIcon
|
|
11
17
|
v-if="icon"
|
|
@@ -29,7 +35,7 @@
|
|
|
29
35
|
/>
|
|
30
36
|
</slot>
|
|
31
37
|
</div>
|
|
32
|
-
</
|
|
38
|
+
</div>
|
|
33
39
|
</template>
|
|
34
40
|
|
|
35
41
|
<script setup>
|
|
@@ -125,6 +131,16 @@ const handleClick = () => {
|
|
|
125
131
|
}
|
|
126
132
|
}
|
|
127
133
|
|
|
134
|
+
// Keep the row keyboard-operable now that it is a div[role=button] rather than
|
|
135
|
+
// a native button.
|
|
136
|
+
const onKeydown = (e) => {
|
|
137
|
+
if (!isInteractive.value || props.disabled) return
|
|
138
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
139
|
+
e.preventDefault()
|
|
140
|
+
handleClick()
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
128
144
|
const handleSuffixClick = (e) => {
|
|
129
145
|
// For toggle rows, clicking the suffix (the toggle itself) should also toggle
|
|
130
146
|
if (isToggle.value && !props.disabled) {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
2
|
+
<div
|
|
3
|
+
ref="numpadRef"
|
|
4
|
+
class="grid grid-cols-3 gap-3 min-w-[264px] max-w-[264px] mx-auto outline-none"
|
|
5
|
+
>
|
|
3
6
|
<button
|
|
4
7
|
v-for="n in [1, 2, 3, 4, 5, 6, 7, 8, 9]"
|
|
5
8
|
:key="n"
|
|
@@ -9,7 +12,7 @@
|
|
|
9
12
|
:class="
|
|
10
13
|
pressedKey === n
|
|
11
14
|
? '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-
|
|
15
|
+
: 'bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700 hover:bg-gray-100 dark:hover:bg-gray-700 active:bg-gray-200 dark:active:bg-gray-600'
|
|
13
16
|
"
|
|
14
17
|
:disabled="disabled"
|
|
15
18
|
@click="onDigit(n)"
|
|
@@ -29,7 +32,7 @@
|
|
|
29
32
|
:class="
|
|
30
33
|
pressedKey === 0
|
|
31
34
|
? '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-
|
|
35
|
+
: 'bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700 hover:bg-gray-100 dark:hover:bg-gray-700 active:bg-gray-200 dark:active:bg-gray-600'
|
|
33
36
|
"
|
|
34
37
|
:disabled="disabled"
|
|
35
38
|
@click="onDigit(0)"
|
|
@@ -40,7 +43,7 @@
|
|
|
40
43
|
<button
|
|
41
44
|
type="button"
|
|
42
45
|
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-
|
|
46
|
+
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-700 active:bg-gray-200 dark:active:bg-gray-600 active:scale-95 disabled:opacity-30 disabled:pointer-events-none"
|
|
44
47
|
:disabled="!canDelete"
|
|
45
48
|
@click="$emit('delete')"
|
|
46
49
|
>
|