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,231 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="min-h-dvh bg-gray-50 text-gray-900 dark:bg-gray-950 dark:text-gray-100">
|
|
3
|
+
<!-- Skip link: the first tab stop jumps past the sidebar to the content. -->
|
|
4
|
+
<a
|
|
5
|
+
:href="`#${mainId}`"
|
|
6
|
+
class="sr-only focus:not-sr-only focus:fixed focus:top-3 focus:left-3 focus:z-[60] focus:rounded-lg focus:bg-white focus:px-3 focus:py-2 focus:text-sm focus:font-medium focus:shadow-card dark:focus:bg-gray-900"
|
|
7
|
+
>{{ skipLabel }}</a
|
|
8
|
+
>
|
|
9
|
+
|
|
10
|
+
<!-- Backdrop behind the off-canvas sidebar on small screens -->
|
|
11
|
+
<Transition
|
|
12
|
+
enter-active-class="transition-opacity duration-200 motion-reduce:transition-none"
|
|
13
|
+
enter-from-class="opacity-0"
|
|
14
|
+
leave-active-class="transition-opacity duration-200 motion-reduce:transition-none"
|
|
15
|
+
leave-to-class="opacity-0"
|
|
16
|
+
>
|
|
17
|
+
<div
|
|
18
|
+
v-if="hasSidebar && isOpen"
|
|
19
|
+
class="fixed inset-0 z-40 bg-gray-950/50 backdrop-blur-sm lg:hidden"
|
|
20
|
+
aria-hidden="true"
|
|
21
|
+
@click="close"
|
|
22
|
+
/>
|
|
23
|
+
</Transition>
|
|
24
|
+
|
|
25
|
+
<aside
|
|
26
|
+
v-if="hasSidebar"
|
|
27
|
+
:id="sidebarId"
|
|
28
|
+
class="fixed inset-y-0 left-0 z-50 flex flex-col border-r border-gray-200 bg-white transition-transform duration-200 ease-out motion-reduce:transition-none lg:translate-x-0 dark:border-gray-800 dark:bg-gray-900"
|
|
29
|
+
:class="[widthClass, isOpen ? 'translate-x-0' : '-translate-x-full']"
|
|
30
|
+
:inert="!isDesktop && !isOpen ? true : undefined"
|
|
31
|
+
>
|
|
32
|
+
<slot name="sidebar" :close="close" />
|
|
33
|
+
</aside>
|
|
34
|
+
|
|
35
|
+
<div class="flex min-h-dvh flex-col" :class="hasSidebar ? offsetClass : ''">
|
|
36
|
+
<header
|
|
37
|
+
v-if="$slots.header || hasSidebar"
|
|
38
|
+
class="sticky top-0 z-30 flex h-14 shrink-0 items-center gap-3 border-b border-gray-200 bg-white/80 px-4 backdrop-blur sm:px-6 dark:border-gray-800 dark:bg-gray-900/80"
|
|
39
|
+
>
|
|
40
|
+
<button
|
|
41
|
+
v-if="hasSidebar"
|
|
42
|
+
type="button"
|
|
43
|
+
class="-ml-1 inline-flex size-9 items-center justify-center rounded-lg text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-500 lg:hidden dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-100"
|
|
44
|
+
:aria-label="menuLabel"
|
|
45
|
+
:aria-expanded="isOpen ? 'true' : 'false'"
|
|
46
|
+
:aria-controls="sidebarId"
|
|
47
|
+
@click="toggle"
|
|
48
|
+
>
|
|
49
|
+
<UiIcon name="mdi:menu" class="size-5" />
|
|
50
|
+
</button>
|
|
51
|
+
<div class="flex min-w-0 flex-1 items-center gap-3">
|
|
52
|
+
<slot name="header" :toggle="toggle" :open="isOpen" />
|
|
53
|
+
</div>
|
|
54
|
+
</header>
|
|
55
|
+
|
|
56
|
+
<main :id="mainId" tabindex="-1" class="flex-1 focus:outline-none">
|
|
57
|
+
<div :class="contentClass">
|
|
58
|
+
<slot />
|
|
59
|
+
</div>
|
|
60
|
+
</main>
|
|
61
|
+
|
|
62
|
+
<footer
|
|
63
|
+
v-if="$slots.footer"
|
|
64
|
+
class="border-t border-gray-200 px-4 py-4 text-sm text-gray-500 sm:px-6 dark:border-gray-800 dark:text-gray-400"
|
|
65
|
+
>
|
|
66
|
+
<slot name="footer" />
|
|
67
|
+
</footer>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
</template>
|
|
71
|
+
|
|
72
|
+
<script setup>
|
|
73
|
+
/**
|
|
74
|
+
* UiAppShell — the page frame for an application: a sidebar, a sticky top bar
|
|
75
|
+
* and a scrolling content area.
|
|
76
|
+
*
|
|
77
|
+
* On large screens (`lg` and up) the sidebar is pinned to the left and the
|
|
78
|
+
* content is offset beside it. Below that it becomes an off-canvas drawer,
|
|
79
|
+
* opened by a menu button the shell adds to the top bar, closed by the
|
|
80
|
+
* backdrop, by Escape, or by any `UiSidebarItem` being chosen. While the drawer
|
|
81
|
+
* is closed on a small screen the sidebar is `inert`, so keyboard users don't
|
|
82
|
+
* tab into links they can't see.
|
|
83
|
+
*
|
|
84
|
+
* The shell owns layout only. Put a `UiSidebar` in `#sidebar`, page chrome in
|
|
85
|
+
* `#header`, and the routed page in the default slot. A skip link to the main
|
|
86
|
+
* content is the first tab stop.
|
|
87
|
+
*
|
|
88
|
+
* The drawer state is uncontrolled by default; bind `v-model:open` to drive it
|
|
89
|
+
* yourself (e.g. to close it on route change).
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* <UiAppShell>
|
|
93
|
+
* <template #sidebar>
|
|
94
|
+
* <UiSidebar label="Main">
|
|
95
|
+
* <template #header><strong>Numori CRDT</strong></template>
|
|
96
|
+
* <UiSidebarItem icon="mdi:view-grid" href="/" active>Dashboard</UiSidebarItem>
|
|
97
|
+
* <UiSidebarItem icon="mdi:sync" href="/apps">Apps</UiSidebarItem>
|
|
98
|
+
* </UiSidebar>
|
|
99
|
+
* </template>
|
|
100
|
+
* <template #header>
|
|
101
|
+
* <span class="flex-1" />
|
|
102
|
+
* <UiThemeToggle :is-dark="dark" @toggle="dark = !dark" />
|
|
103
|
+
* </template>
|
|
104
|
+
* <UiPageHeader title="Dashboard" />
|
|
105
|
+
* </UiAppShell>
|
|
106
|
+
*
|
|
107
|
+
* @emits {boolean} update:open — The drawer opened or closed (small screens).
|
|
108
|
+
*
|
|
109
|
+
* @slot sidebar — Sidebar content, usually a `UiSidebar`. Scope: `{ close }`.
|
|
110
|
+
* @slot header — Top bar content beside the menu button. Scope: `{ toggle, open }`.
|
|
111
|
+
* @slot default — Page content.
|
|
112
|
+
* @slot footer — Optional footer below the content.
|
|
113
|
+
*/
|
|
114
|
+
import { computed, onBeforeUnmount, onMounted, provide, ref, useId, useSlots } from 'vue'
|
|
115
|
+
import UiIcon from '../icons/Icon.vue'
|
|
116
|
+
|
|
117
|
+
const props = defineProps({
|
|
118
|
+
/**
|
|
119
|
+
* Drawer state on small screens, for `v-model:open`. Leave unset to let the
|
|
120
|
+
* shell manage it.
|
|
121
|
+
* @type {boolean}
|
|
122
|
+
* @default undefined
|
|
123
|
+
*/
|
|
124
|
+
open: { type: Boolean, default: undefined },
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Sidebar width.
|
|
128
|
+
* @type {string}
|
|
129
|
+
* @default 'md'
|
|
130
|
+
* @values 'sm' | 'md' | 'lg'
|
|
131
|
+
*/
|
|
132
|
+
sidebarWidth: { type: String, default: 'md' },
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Maximum width of the content column. `'none'` lets it fill the space.
|
|
136
|
+
* @type {string}
|
|
137
|
+
* @default '7xl'
|
|
138
|
+
* @values 'none' | '4xl' | '5xl' | '6xl' | '7xl'
|
|
139
|
+
*/
|
|
140
|
+
maxWidth: { type: String, default: '7xl' },
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Pad the content area. Turn off for full-bleed pages that lay out their own
|
|
144
|
+
* spacing.
|
|
145
|
+
* @type {boolean}
|
|
146
|
+
* @default true
|
|
147
|
+
*/
|
|
148
|
+
padded: { type: Boolean, default: true },
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Accessible label for the menu button that opens the drawer.
|
|
152
|
+
* @type {string}
|
|
153
|
+
* @default 'Open navigation'
|
|
154
|
+
*/
|
|
155
|
+
menuLabel: { type: String, default: 'Open navigation' },
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Text of the skip link (visible only when focused).
|
|
159
|
+
* @type {string}
|
|
160
|
+
* @default 'Skip to content'
|
|
161
|
+
*/
|
|
162
|
+
skipLabel: { type: String, default: 'Skip to content' },
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
const emit = defineEmits(['update:open'])
|
|
166
|
+
const slots = useSlots()
|
|
167
|
+
|
|
168
|
+
const baseId = useId()
|
|
169
|
+
const sidebarId = `${baseId}-sidebar`
|
|
170
|
+
const mainId = `${baseId}-main`
|
|
171
|
+
|
|
172
|
+
const hasSidebar = computed(() => !!slots.sidebar)
|
|
173
|
+
|
|
174
|
+
const internalOpen = ref(false)
|
|
175
|
+
const isOpen = computed(() => props.open ?? internalOpen.value)
|
|
176
|
+
|
|
177
|
+
function setOpen(value) {
|
|
178
|
+
internalOpen.value = value
|
|
179
|
+
emit('update:open', value)
|
|
180
|
+
}
|
|
181
|
+
const toggle = () => setOpen(!isOpen.value)
|
|
182
|
+
const close = () => {
|
|
183
|
+
if (isOpen.value) setOpen(false)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// UiSidebarItem closes the drawer when chosen, so navigation on a phone does
|
|
187
|
+
// not leave the drawer covering the page it just opened.
|
|
188
|
+
provide('numori-ui:app-shell', { close })
|
|
189
|
+
|
|
190
|
+
// Assume a desktop layout until mounted, so the server render never marks the
|
|
191
|
+
// sidebar inert on a screen where it is visible.
|
|
192
|
+
const isDesktop = ref(true)
|
|
193
|
+
let media = null
|
|
194
|
+
const onMedia = () => {
|
|
195
|
+
isDesktop.value = media.matches
|
|
196
|
+
if (media.matches) close()
|
|
197
|
+
}
|
|
198
|
+
const onKeydown = (event) => {
|
|
199
|
+
if (event.key === 'Escape' && isOpen.value) close()
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
onMounted(() => {
|
|
203
|
+
media = window.matchMedia('(min-width: 64rem)')
|
|
204
|
+
onMedia()
|
|
205
|
+
media.addEventListener('change', onMedia)
|
|
206
|
+
window.addEventListener('keydown', onKeydown)
|
|
207
|
+
})
|
|
208
|
+
onBeforeUnmount(() => {
|
|
209
|
+
media?.removeEventListener('change', onMedia)
|
|
210
|
+
window.removeEventListener('keydown', onKeydown)
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
const widthClass = computed(
|
|
214
|
+
() => ({ sm: 'w-60', md: 'w-64', lg: 'w-72' })[props.sidebarWidth] ?? 'w-64',
|
|
215
|
+
)
|
|
216
|
+
const offsetClass = computed(
|
|
217
|
+
() => ({ sm: 'lg:pl-60', md: 'lg:pl-64', lg: 'lg:pl-72' })[props.sidebarWidth] ?? 'lg:pl-64',
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
const contentClass = computed(() => {
|
|
221
|
+
const width =
|
|
222
|
+
{
|
|
223
|
+
none: '',
|
|
224
|
+
'4xl': 'mx-auto max-w-4xl',
|
|
225
|
+
'5xl': 'mx-auto max-w-5xl',
|
|
226
|
+
'6xl': 'mx-auto max-w-6xl',
|
|
227
|
+
'7xl': 'mx-auto max-w-7xl',
|
|
228
|
+
}[props.maxWidth] ?? 'mx-auto max-w-7xl'
|
|
229
|
+
return [width, props.padded ? 'px-4 py-6 sm:px-6 lg:px-8 lg:py-8' : ''].filter(Boolean).join(' ')
|
|
230
|
+
})
|
|
231
|
+
</script>
|
|
@@ -7,17 +7,28 @@
|
|
|
7
7
|
leave-from-class="max-h-24 opacity-100"
|
|
8
8
|
leave-to-class="max-h-0 opacity-0"
|
|
9
9
|
>
|
|
10
|
-
<
|
|
11
|
-
:is="clickable ? 'button' : 'div'"
|
|
10
|
+
<div
|
|
12
11
|
v-if="show"
|
|
13
|
-
class="w-full shrink-0 overflow-hidden text-xs font-medium"
|
|
14
|
-
:class="
|
|
12
|
+
class="relative w-full shrink-0 overflow-hidden text-xs font-medium"
|
|
13
|
+
:class="colorClass"
|
|
15
14
|
:style="safeArea ? { paddingTop: 'env(safe-area-inset-top, 0px)' } : undefined"
|
|
16
|
-
:type="clickable ? 'button' : undefined"
|
|
17
15
|
role="status"
|
|
18
|
-
@click="clickable && emit('click')"
|
|
19
16
|
>
|
|
20
|
-
|
|
17
|
+
<!-- Whole-banner click target as a full-cover button that is a *sibling*
|
|
18
|
+
of the dismiss button, never its ancestor. Nesting a <button> inside
|
|
19
|
+
a <button> is invalid HTML: the browser restructures it, so the
|
|
20
|
+
hydrated DOM would no longer match the server markup. -->
|
|
21
|
+
<button
|
|
22
|
+
v-if="clickable"
|
|
23
|
+
type="button"
|
|
24
|
+
class="absolute inset-0 z-0 cursor-pointer"
|
|
25
|
+
:aria-label="message || undefined"
|
|
26
|
+
@click="emit('click')"
|
|
27
|
+
/>
|
|
28
|
+
<div
|
|
29
|
+
class="relative z-10 flex items-center justify-center gap-2 px-4 py-1.5"
|
|
30
|
+
:class="clickable ? 'pointer-events-none' : ''"
|
|
31
|
+
>
|
|
21
32
|
<UiIcon v-if="icon" :name="icon" class="w-3.5 h-3.5 shrink-0" />
|
|
22
33
|
<span
|
|
23
34
|
><slot>{{ message }}</slot></span
|
|
@@ -26,14 +37,14 @@
|
|
|
26
37
|
<button
|
|
27
38
|
v-if="dismissible"
|
|
28
39
|
type="button"
|
|
29
|
-
class="absolute right-3 inline-flex items-center opacity-80 hover:opacity-100"
|
|
40
|
+
class="pointer-events-auto absolute right-3 inline-flex items-center opacity-80 hover:opacity-100"
|
|
30
41
|
:aria-label="dismissLabel"
|
|
31
42
|
@click.stop="emit('dismiss')"
|
|
32
43
|
>
|
|
33
44
|
<UiIcon name="mdi:close" class="w-3.5 h-3.5" />
|
|
34
45
|
</button>
|
|
35
46
|
</div>
|
|
36
|
-
</
|
|
47
|
+
</div>
|
|
37
48
|
</Transition>
|
|
38
49
|
</template>
|
|
39
50
|
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
*
|
|
54
54
|
* @slot default — Button content (label text, icons, or any child elements)
|
|
55
55
|
*/
|
|
56
|
-
import { computed
|
|
56
|
+
import { computed } from 'vue'
|
|
57
57
|
import UiIcon from '../icons/Icon.vue'
|
|
58
|
-
import {
|
|
58
|
+
import { useMergedClasses } from '../composables/useMergedClasses.js'
|
|
59
59
|
const props = defineProps({
|
|
60
60
|
/**
|
|
61
61
|
* HTML element tag to render.
|
|
@@ -105,10 +105,11 @@ const props = defineProps({
|
|
|
105
105
|
size: { type: String, default: 'md' },
|
|
106
106
|
|
|
107
107
|
/**
|
|
108
|
-
* Border-radius shape of the button
|
|
108
|
+
* Border-radius shape of the button, matching `UiSegmented`'s `shape`.
|
|
109
|
+
* For a circular icon button, combine `shape="pill"` with `icon-only`.
|
|
109
110
|
* @type {string}
|
|
110
111
|
* @default 'round'
|
|
111
|
-
* @values 'round' (rounded-lg) | 'pill' (rounded-full) | 'square' (rounded-none)
|
|
112
|
+
* @values 'round' (rounded-lg) | 'pill' (rounded-full) | 'square' (rounded-none)
|
|
112
113
|
*/
|
|
113
114
|
shape: { type: String, default: 'round' },
|
|
114
115
|
|
|
@@ -235,13 +236,14 @@ const sizeClasses = computed(() => {
|
|
|
235
236
|
|
|
236
237
|
// ── Shape classes ─────────────────────────────────────────
|
|
237
238
|
const shapeClasses = computed(() => {
|
|
238
|
-
|
|
239
|
+
// Menu/list rows are full-width, but still round their corners so the hover
|
|
240
|
+
// highlight is a rounded chip rather than a square that pokes past the
|
|
241
|
+
// rounded menu panel around them.
|
|
242
|
+
if (isInlineVariant.value) return 'rounded-lg'
|
|
239
243
|
const map = {
|
|
240
244
|
round: 'rounded-lg',
|
|
241
245
|
pill: 'rounded-full',
|
|
242
246
|
square: 'rounded-none',
|
|
243
|
-
circle: 'rounded-full',
|
|
244
|
-
none: '',
|
|
245
247
|
}
|
|
246
248
|
return map[props.shape] || map.round
|
|
247
249
|
})
|
|
@@ -382,18 +384,9 @@ const stateClasses = computed(() => {
|
|
|
382
384
|
return 'cursor-pointer'
|
|
383
385
|
})
|
|
384
386
|
|
|
385
|
-
// ── Merge
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
const restAttrs = computed(() => {
|
|
389
|
-
const { class: _, ...rest } = attrs
|
|
390
|
-
return rest
|
|
391
|
-
})
|
|
392
|
-
|
|
393
|
-
const mergedClasses = computed(() => {
|
|
394
|
-
const externalClass = attrs.class || ''
|
|
395
|
-
return twMerge(internalClasses.value, externalClass)
|
|
396
|
-
})
|
|
387
|
+
// ── Merge external classes over internals (external wins via twMerge) ──
|
|
388
|
+
// A getter defers reading `internalClasses` until after its declaration below.
|
|
389
|
+
const { mergedClasses, restAttrs } = useMergedClasses(() => internalClasses.value)
|
|
397
390
|
|
|
398
391
|
// ── Assembled internal classes ────────────────────────────
|
|
399
392
|
const internalClasses = computed(() => {
|
package/src/components/Card.vue
CHANGED
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
* @slot header — Optional header, drawn above the body with a divider.
|
|
52
52
|
* @slot footer — Optional footer, drawn below the body with a divider.
|
|
53
53
|
*/
|
|
54
|
-
import { computed
|
|
55
|
-
import {
|
|
54
|
+
import { computed } from 'vue'
|
|
55
|
+
import { useMergedClasses } from '../composables/useMergedClasses.js'
|
|
56
56
|
|
|
57
57
|
const props = defineProps({
|
|
58
58
|
/**
|
|
@@ -125,12 +125,6 @@ const props = defineProps({
|
|
|
125
125
|
|
|
126
126
|
defineOptions({ inheritAttrs: false })
|
|
127
127
|
|
|
128
|
-
const attrs = useAttrs()
|
|
129
|
-
const restAttrs = computed(() => {
|
|
130
|
-
const { class: _class, ...rest } = attrs
|
|
131
|
-
return rest
|
|
132
|
-
})
|
|
133
|
-
|
|
134
128
|
const paddingClass = computed(
|
|
135
129
|
() => ({ none: '', xs: 'p-3', sm: 'p-4', md: 'p-5', lg: 'p-6' })[props.padding] ?? 'p-5',
|
|
136
130
|
)
|
|
@@ -146,8 +140,10 @@ const shadowClass = computed(
|
|
|
146
140
|
'shadow-card',
|
|
147
141
|
)
|
|
148
142
|
|
|
149
|
-
|
|
150
|
-
|
|
143
|
+
// External classes merge last so a caller's `hover:border-primary-300` wins
|
|
144
|
+
// over the neutral hover border rather than doubling up.
|
|
145
|
+
const internalClasses = computed(() =>
|
|
146
|
+
[
|
|
151
147
|
'bg-white dark:bg-gray-900',
|
|
152
148
|
props.focusRing ? 'relative' : '',
|
|
153
149
|
radiusClass.value,
|
|
@@ -163,7 +159,10 @@ const mergedClasses = computed(() =>
|
|
|
163
159
|
? 'focus-within:outline-2 focus-within:outline-offset-2 focus-within:outline-primary-500 dark:focus-within:outline-primary-400'
|
|
164
160
|
: '',
|
|
165
161
|
paddingClass.value,
|
|
166
|
-
|
|
167
|
-
|
|
162
|
+
]
|
|
163
|
+
.filter(Boolean)
|
|
164
|
+
.join(' '),
|
|
168
165
|
)
|
|
166
|
+
|
|
167
|
+
const { mergedClasses, restAttrs } = useMergedClasses(internalClasses)
|
|
169
168
|
</script>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<input
|
|
3
|
+
:id="field?.controlId.value"
|
|
3
4
|
type="checkbox"
|
|
5
|
+
:aria-describedby="field?.describedBy.value"
|
|
4
6
|
:checked="modelValue ?? checked"
|
|
5
7
|
:disabled="disabled"
|
|
6
8
|
class="rounded border-gray-300 dark:border-gray-600 text-primary-600 focus:ring-primary-500"
|
|
@@ -30,6 +32,8 @@
|
|
|
30
32
|
* @emits {Event} change — Emitted with the native change event
|
|
31
33
|
*/
|
|
32
34
|
import { computed } from 'vue'
|
|
35
|
+
import { checkableSizeClass } from '../internal/controlSizes.js'
|
|
36
|
+
import { useFormField } from '../internal/formField.js'
|
|
33
37
|
const props = defineProps({
|
|
34
38
|
/**
|
|
35
39
|
* Controlled checked state (v-model). Takes priority over `checked` when defined.
|
|
@@ -63,16 +67,9 @@ const props = defineProps({
|
|
|
63
67
|
|
|
64
68
|
const emit = defineEmits(['update:modelValue', 'change'])
|
|
65
69
|
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return 'w-3.5 h-3.5'
|
|
70
|
-
case 'lg':
|
|
71
|
-
return 'w-5 h-5'
|
|
72
|
-
default:
|
|
73
|
-
return 'w-4 h-4'
|
|
74
|
-
}
|
|
75
|
-
})
|
|
70
|
+
const field = useFormField()
|
|
71
|
+
|
|
72
|
+
const sizeClass = computed(() => checkableSizeClass(props.size))
|
|
76
73
|
|
|
77
74
|
function onChange(e) {
|
|
78
75
|
emit('update:modelValue', e.target.checked)
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="mergedClasses" v-bind="restAttrs">
|
|
3
|
+
<span
|
|
4
|
+
class="min-w-0 flex-1 px-3 text-gray-800 select-all dark:text-gray-200"
|
|
5
|
+
:class="[
|
|
6
|
+
size === 'sm' ? 'py-1.5 text-xs' : 'py-2 text-sm',
|
|
7
|
+
mono ? 'font-mono' : '',
|
|
8
|
+
wrap ? 'break-all whitespace-pre-wrap' : 'truncate',
|
|
9
|
+
masked ? 'tracking-widest text-gray-500 select-none dark:text-gray-400' : '',
|
|
10
|
+
]"
|
|
11
|
+
:aria-label="masked ? hiddenLabel : undefined"
|
|
12
|
+
>{{ masked ? mask : value }}</span
|
|
13
|
+
>
|
|
14
|
+
|
|
15
|
+
<button
|
|
16
|
+
v-if="secret"
|
|
17
|
+
type="button"
|
|
18
|
+
:class="buttonClass"
|
|
19
|
+
:aria-label="masked ? revealLabel : hideLabel"
|
|
20
|
+
:aria-pressed="masked ? 'false' : 'true'"
|
|
21
|
+
@click="toggleReveal"
|
|
22
|
+
>
|
|
23
|
+
<UiIcon :name="masked ? 'mdi:eye-outline' : 'mdi:eye-off-outline'" class="size-4" />
|
|
24
|
+
</button>
|
|
25
|
+
|
|
26
|
+
<button
|
|
27
|
+
type="button"
|
|
28
|
+
:class="buttonClass"
|
|
29
|
+
:aria-label="copied ? copiedLabel : copyLabel"
|
|
30
|
+
@click="copy"
|
|
31
|
+
>
|
|
32
|
+
<UiIcon
|
|
33
|
+
:name="copied ? 'mdi:check' : 'mdi:content-copy'"
|
|
34
|
+
class="size-4"
|
|
35
|
+
:class="copied ? 'text-success-600 dark:text-success-400' : ''"
|
|
36
|
+
/>
|
|
37
|
+
<span v-if="showCopyText" class="hidden sm:inline">{{
|
|
38
|
+
copied ? copiedLabel : copyLabel
|
|
39
|
+
}}</span>
|
|
40
|
+
</button>
|
|
41
|
+
</div>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script setup>
|
|
45
|
+
/**
|
|
46
|
+
* UiCopyField — a read-only value with a copy button, and optional masking for
|
|
47
|
+
* secrets.
|
|
48
|
+
*
|
|
49
|
+
* For connect URLs, ids, API keys and generated secrets. With `secret`, the
|
|
50
|
+
* value is masked until revealed and the real text is not in the DOM while it
|
|
51
|
+
* is masked, so a screen share or a screenshot does not leak it. Copying works
|
|
52
|
+
* either way.
|
|
53
|
+
*
|
|
54
|
+
* Copy uses the async Clipboard API and fails silently when unavailable (an
|
|
55
|
+
* insecure context or denied permission). Every label is a prop, so nothing
|
|
56
|
+
* is baked into one language.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* <UiFormField label="Connect URL">
|
|
60
|
+
* <UiCopyField value="wss://crdt.numori.app/notes" />
|
|
61
|
+
* </UiFormField>
|
|
62
|
+
*
|
|
63
|
+
* @example A secret shown once
|
|
64
|
+
* <UiCopyField :value="signingKey" secret @copy="markCopied" />
|
|
65
|
+
*
|
|
66
|
+
* @emits {string} copy — The value was copied.
|
|
67
|
+
* @emits {boolean} update:revealed — The secret was revealed or hidden.
|
|
68
|
+
*/
|
|
69
|
+
import { computed, ref, watch } from 'vue'
|
|
70
|
+
import UiIcon from '../icons/Icon.vue'
|
|
71
|
+
import { useMergedClasses } from '../composables/useMergedClasses.js'
|
|
72
|
+
|
|
73
|
+
const props = defineProps({
|
|
74
|
+
/**
|
|
75
|
+
* The text to show and copy.
|
|
76
|
+
* @type {string}
|
|
77
|
+
*/
|
|
78
|
+
value: { type: String, required: true },
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Mask the value until revealed.
|
|
82
|
+
* @type {boolean}
|
|
83
|
+
* @default false
|
|
84
|
+
*/
|
|
85
|
+
secret: { type: Boolean, default: false },
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Revealed state of a secret, for `v-model:revealed`.
|
|
89
|
+
* @type {boolean}
|
|
90
|
+
* @default false
|
|
91
|
+
*/
|
|
92
|
+
revealed: { type: Boolean, default: false },
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Monospace text.
|
|
96
|
+
* @type {boolean}
|
|
97
|
+
* @default true
|
|
98
|
+
*/
|
|
99
|
+
mono: { type: Boolean, default: true },
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Wrap long values onto several lines instead of truncating.
|
|
103
|
+
* @type {boolean}
|
|
104
|
+
* @default false
|
|
105
|
+
*/
|
|
106
|
+
wrap: { type: Boolean, default: false },
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Control size.
|
|
110
|
+
* @type {string}
|
|
111
|
+
* @default 'md'
|
|
112
|
+
* @values 'sm' | 'md'
|
|
113
|
+
*/
|
|
114
|
+
size: { type: String, default: 'md' },
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Show the copy label beside the icon (from `sm` up).
|
|
118
|
+
* @type {boolean}
|
|
119
|
+
* @default false
|
|
120
|
+
*/
|
|
121
|
+
showCopyText: { type: Boolean, default: false },
|
|
122
|
+
|
|
123
|
+
/** @type {string} @default 'Copy' */
|
|
124
|
+
copyLabel: { type: String, default: 'Copy' },
|
|
125
|
+
/** @type {string} @default 'Copied' */
|
|
126
|
+
copiedLabel: { type: String, default: 'Copied' },
|
|
127
|
+
/** @type {string} @default 'Reveal' */
|
|
128
|
+
revealLabel: { type: String, default: 'Reveal' },
|
|
129
|
+
/** @type {string} @default 'Hide' */
|
|
130
|
+
hideLabel: { type: String, default: 'Hide' },
|
|
131
|
+
/** Accessible text read in place of a masked value. @type {string} @default 'Hidden value' */
|
|
132
|
+
hiddenLabel: { type: String, default: 'Hidden value' },
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
const emit = defineEmits(['copy', 'update:revealed'])
|
|
136
|
+
|
|
137
|
+
defineOptions({ inheritAttrs: false })
|
|
138
|
+
|
|
139
|
+
const isRevealed = ref(props.revealed)
|
|
140
|
+
watch(
|
|
141
|
+
() => props.revealed,
|
|
142
|
+
(value) => {
|
|
143
|
+
isRevealed.value = value
|
|
144
|
+
},
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
const masked = computed(() => props.secret && !isRevealed.value)
|
|
148
|
+
const mask = computed(() => '•'.repeat(Math.min(Math.max(props.value.length, 8), 24)))
|
|
149
|
+
|
|
150
|
+
function toggleReveal() {
|
|
151
|
+
isRevealed.value = !isRevealed.value
|
|
152
|
+
emit('update:revealed', isRevealed.value)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const copied = ref(false)
|
|
156
|
+
let timer = null
|
|
157
|
+
|
|
158
|
+
async function copy() {
|
|
159
|
+
try {
|
|
160
|
+
await navigator.clipboard.writeText(props.value)
|
|
161
|
+
copied.value = true
|
|
162
|
+
emit('copy', props.value)
|
|
163
|
+
clearTimeout(timer)
|
|
164
|
+
timer = setTimeout(() => {
|
|
165
|
+
copied.value = false
|
|
166
|
+
}, 1600)
|
|
167
|
+
} catch {
|
|
168
|
+
// Clipboard unavailable; the value is still selectable by hand.
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const buttonClass =
|
|
173
|
+
'inline-flex shrink-0 items-center gap-1.5 border-l border-gray-200 px-3 text-xs font-medium text-gray-600 transition-colors hover:bg-white hover:text-gray-900 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary-500 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100'
|
|
174
|
+
|
|
175
|
+
const { mergedClasses, restAttrs } = useMergedClasses(
|
|
176
|
+
'flex w-full min-w-0 items-stretch overflow-hidden rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-700 dark:bg-gray-800/60',
|
|
177
|
+
)
|
|
178
|
+
</script>
|