numori-ui 0.4.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 +66 -0
- package/README.md +18 -19
- package/dist/components/AppShell.js +234 -0
- package/dist/components/AppShell.js.map +1 -0
- package/dist/components/Checkbox.js +11 -2
- 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/EmptyState.js +123 -0
- package/dist/components/EmptyState.js.map +1 -0
- package/dist/components/FormField.js +43 -13
- package/dist/components/FormField.js.map +1 -1
- package/dist/components/Input.js +15 -1
- package/dist/components/Input.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/Segmented.js +10 -2
- package/dist/components/Segmented.js.map +1 -1
- package/dist/components/Select.js +10 -1
- 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 +182 -50
- package/dist/components/Table.js.map +1 -1
- 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 +97 -80
- package/dist/components/index.js.map +1 -1
- package/dist/icons/mdi.js +10 -0
- package/dist/icons/mdi.js.map +1 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +50 -39
- package/dist/index.js.map +1 -1
- package/dist/internal/formField.js +26 -0
- package/dist/internal/formField.js.map +1 -0
- package/dist/manifest.js +11 -0
- package/dist/manifest.js.map +1 -1
- package/package.json +1 -1
- package/src/components/AppShell.vue +231 -0
- package/src/components/Checkbox.vue +5 -0
- package/src/components/CopyField.vue +178 -0
- package/src/components/DescriptionList.vue +114 -0
- package/src/components/EmptyState.vue +107 -0
- package/src/components/FormField.vue +37 -4
- package/src/components/Input.vue +9 -0
- package/src/components/PageHeader.vue +102 -0
- package/src/components/Pagination.vue +199 -0
- package/src/components/Segmented.vue +5 -0
- package/src/components/Select.vue +5 -0
- 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 +148 -18
- package/src/components/Tabs.vue +217 -0
- package/src/components/Toggle.vue +5 -0
- package/src/components/index.js +33 -5
- package/src/icons/mdi.js +10 -0
- package/src/internal/formField.js +23 -0
- package/src/manifest.js +11 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,70 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
While the library is pre-1.0, minor versions may add components and options; patch
|
|
8
8
|
versions are fixes.
|
|
9
9
|
|
|
10
|
+
## [0.5.0] — 2026-11-30
|
|
11
|
+
|
|
12
|
+
Application and dashboard building blocks. Eleven new components cover the frame
|
|
13
|
+
of an application (shell, sidebar, page header, tabs) and the pieces admin
|
|
14
|
+
screens are made of (stat cards, empty states, description lists, pagination,
|
|
15
|
+
copyable secrets). `UiTable` gains sorting and empty/loading states. Nothing
|
|
16
|
+
existing changes behaviour, so this is a drop-in upgrade from 0.4.0. The library
|
|
17
|
+
is now 49 components (50 registered tags, including `UiIcon`).
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- **`UiAppShell`** — sidebar, sticky top bar and content area. The sidebar is
|
|
22
|
+
pinned from `lg` up and becomes an off-canvas drawer below that (backdrop,
|
|
23
|
+
Escape, and `inert` while closed so hidden links are not tab stops). Includes
|
|
24
|
+
a skip link, `v-model:open`, and `sidebarWidth` / `maxWidth` / `padded`.
|
|
25
|
+
- **`UiSidebar`**, **`UiSidebarGroup`**, **`UiSidebarItem`** — a labelled
|
|
26
|
+
`<nav>` with header and footer regions, labelled groups, and router-agnostic
|
|
27
|
+
items: `to` renders through `RouterLink` (or any `tag`, such as `NuxtLink`),
|
|
28
|
+
`href` an anchor, neither a button. `active` sets `aria-current="page"`; items
|
|
29
|
+
take an icon and a count badge, and close the shell's drawer when chosen.
|
|
30
|
+
- **`UiPageHeader`** — breadcrumb, title (heading `level` 1–3), inline badges,
|
|
31
|
+
description and an actions area that wraps on narrow screens.
|
|
32
|
+
- **`UiTabs`** — the WAI-ARIA tabs pattern: `tablist` / `tab` / `tabpanel`
|
|
33
|
+
roles, a roving `tabindex`, arrow keys, Home and End, skipping disabled tabs.
|
|
34
|
+
`line` and `pill` variants, per-tab icons and badges, and `:panel="false"` for
|
|
35
|
+
tabs that only navigate.
|
|
36
|
+
- **`UiStatCard`** — label, value, tinted icon, trend delta and hint, with a
|
|
37
|
+
same-height loading placeholder. Built on `UiCard`.
|
|
38
|
+
- **`UiEmptyState`** — icon, title, description and actions, with `compact` and
|
|
39
|
+
`bordered` variants.
|
|
40
|
+
- **`UiDescriptionList`** — label/value pairs as a real `<dl>` in `inline`,
|
|
41
|
+
`stacked` or `grid` layouts, with monospace values, hints, explicit empty text
|
|
42
|
+
and a `#value` slot.
|
|
43
|
+
- **`UiPagination`** — first, last and current ± `siblings` pages with gaps, a
|
|
44
|
+
"21–40 of 134" summary, `v-model:page`, and every label configurable.
|
|
45
|
+
- **`UiCopyField`** — a read-only value with a copy button. With `secret` the
|
|
46
|
+
value is masked until revealed, and the real text is not rendered while
|
|
47
|
+
masked.
|
|
48
|
+
- **`UiTable`** — controlled sorting (`sortable` columns, `sort-key`,
|
|
49
|
+
`sort-direction`, a `sort` event, `aria-sort`), `loading` (a spinner, or
|
|
50
|
+
dimmed rows while refreshing), `emptyText` and an `#empty` slot, and
|
|
51
|
+
`clickable-rows` with a `row-click` event that also fires on Enter.
|
|
52
|
+
- Icons `menu`, `arrow-up`, `arrow-down`, `unfold-more-horizontal`,
|
|
53
|
+
`inbox-outline`, `trending-up`, `trending-down` and `trending-neutral` added
|
|
54
|
+
to the bundled set.
|
|
55
|
+
|
|
56
|
+
### Fixed
|
|
57
|
+
|
|
58
|
+
- **`UiFormField` labels now reach the control.** The `<label>` was not
|
|
59
|
+
associated with anything, so clicking it did nothing and screen readers
|
|
60
|
+
announced inputs without their label, hint or error. The field now provides
|
|
61
|
+
an id that `UiInput`, `UiSelect`, `UiToggle`, `UiCheckbox` and `UiSegmented`
|
|
62
|
+
apply to their real control, along with `aria-describedby` (hint and error)
|
|
63
|
+
and `aria-invalid` (when there is an error). For other controls, pass the
|
|
64
|
+
control's id as the new `for` prop.
|
|
65
|
+
|
|
66
|
+
### Changed
|
|
67
|
+
|
|
68
|
+
- The `app.use(NumoriUI)` tree-shaking budget rises from 120 kB to 150 kB to
|
|
69
|
+
cover the new components. Named imports are unaffected, and a new case checks
|
|
70
|
+
that the dashboard components do not pull in forms or overlays.
|
|
71
|
+
- README: Numori UI is now the source of truth for its components. The note
|
|
72
|
+
saying Numori Notes is where they are developed was out of date.
|
|
73
|
+
|
|
10
74
|
## [0.4.0] — 2026-08-31
|
|
11
75
|
|
|
12
76
|
A consolidation-and-polish release. Two components fold into more capable,
|
|
@@ -167,6 +231,8 @@ including `UiIcon`). All additions are backward compatible.
|
|
|
167
231
|
- First published release: 28 components (29 registered tags), consumable as a
|
|
168
232
|
Nuxt module, a Vite plugin or a framework-agnostic Vue plugin.
|
|
169
233
|
|
|
234
|
+
[0.5.0]: https://github.com/Numori-Ecosystem/Numori-UI/releases/tag/v0.5.0
|
|
235
|
+
[0.4.0]: https://github.com/Numori-Ecosystem/Numori-UI/releases/tag/v0.4.0
|
|
170
236
|
[0.3.0]: https://github.com/Numori-Ecosystem/Numori-UI/releases/tag/v0.3.0
|
|
171
237
|
[0.2.0]: https://github.com/Numori-Ecosystem/Numori-UI/releases/tag/v0.2.0
|
|
172
238
|
[0.1.1]: https://github.com/Numori-Ecosystem/Numori-UI/releases/tag/v0.1.1
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Numori UI
|
|
2
2
|
|
|
3
|
-
The Numori design system as a standalone Vue 3 component library.
|
|
3
|
+
The Numori design system as a standalone Vue 3 component library. 49 components, Tailwind CSS v4, no
|
|
4
4
|
TypeScript, consumable as a **Nuxt module** or a **Vite plugin**.
|
|
5
5
|
|
|
6
6
|
Extracted from [Numori Notes](https://github.com/Numori-Ecosystem/Numori-Notes), where these
|
|
@@ -316,6 +316,13 @@ built-in validation), `UiSelect` (searchable, groupable, teleported panel), `UiC
|
|
|
316
316
|
`UiTable` (data table with a built-in comparison mode), `UiCodeBlock` (copyable snippet), `UiListMenu`,
|
|
317
317
|
`UiListMenuItem`, `UiDivider`, `UiAvatar`, `UiKbd`, `UiIcon`
|
|
318
318
|
|
|
319
|
+
**Application & dashboard** — `UiAppShell` (sidebar + sticky top bar + content, off-canvas drawer
|
|
320
|
+
on small screens), `UiSidebar`, `UiSidebarGroup`, `UiSidebarItem` (router-agnostic: `to`, `href` or a
|
|
321
|
+
button), `UiPageHeader` (title, badges, description, actions), `UiTabs` (WAI-ARIA tabs with keyboard
|
|
322
|
+
navigation), `UiStatCard`, `UiEmptyState`, `UiDescriptionList`, `UiPagination`, `UiCopyField`
|
|
323
|
+
(copyable value with masking for secrets). `UiTable` also covers dashboards: sortable columns, empty
|
|
324
|
+
and loading states, clickable rows.
|
|
325
|
+
|
|
319
326
|
External classes always win. `UiButton` merges them with
|
|
320
327
|
[tailwind-merge](https://github.com/dcastil/tailwind-merge), so `class="bg-gray-100"` genuinely
|
|
321
328
|
replaces the variant's background instead of fighting it:
|
|
@@ -445,28 +452,20 @@ npm run lint
|
|
|
445
452
|
|
|
446
453
|
### Syncing from Numori Notes
|
|
447
454
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
```bash
|
|
455
|
-
npm run sync # defaults to ../numori-notes
|
|
456
|
-
npm run sync -- /path/to/numori-notes
|
|
457
|
-
npm run icons && npm run build && npm test
|
|
458
|
-
```
|
|
459
|
-
|
|
460
|
-
It reports anything it could not translate mechanically and exits non-zero, so an upstream change
|
|
461
|
-
that outgrows the codemod fails loudly instead of shipping broken.
|
|
455
|
+
The components were first developed inside Numori Notes and ported here with
|
|
456
|
+
`scripts/sync-from-notes.mjs`. That direction has ended: Numori Notes now installs this package from
|
|
457
|
+
npm and no longer has a `components/ui/` directory, so **this repository is the source of truth**.
|
|
458
|
+
The script is kept as a record of what the port changed (explicit `vue` imports, `<Icon>` to
|
|
459
|
+
`<UiIcon>`, local VueUse-style helpers, Tailwind v3 fixes). Pointed at a tree without that directory,
|
|
460
|
+
it exits with an error before writing anything.
|
|
462
461
|
|
|
463
462
|
## Changelog
|
|
464
463
|
|
|
465
464
|
See [CHANGELOG.md](./CHANGELOG.md) for the release history. The current release is
|
|
466
|
-
**0.
|
|
467
|
-
`
|
|
468
|
-
`
|
|
469
|
-
|
|
465
|
+
**0.5.0**, which adds eleven application and dashboard components (`UiAppShell`, `UiSidebar`,
|
|
466
|
+
`UiSidebarGroup`, `UiSidebarItem`, `UiPageHeader`, `UiTabs`, `UiStatCard`, `UiEmptyState`,
|
|
467
|
+
`UiDescriptionList`, `UiPagination`, `UiCopyField`) and gives `UiTable` sorting plus empty and
|
|
468
|
+
loading states. It is backwards compatible with 0.4.0.
|
|
470
469
|
|
|
471
470
|
## Licence and attribution
|
|
472
471
|
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
|
+
import { Transition, computed, createCommentVNode, createElementBlock, createElementVNode, createVNode, normalizeClass, onBeforeUnmount, onMounted, openBlock, provide, ref, renderSlot, toDisplayString, useId, useSlots, withCtx } from "vue";
|
|
3
|
+
//#region src/components/AppShell.vue
|
|
4
|
+
var _hoisted_1 = { class: "min-h-dvh bg-gray-50 text-gray-900 dark:bg-gray-950 dark:text-gray-100" };
|
|
5
|
+
var _hoisted_2 = ["href"];
|
|
6
|
+
var _hoisted_3 = ["inert"];
|
|
7
|
+
var _hoisted_4 = {
|
|
8
|
+
key: 0,
|
|
9
|
+
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"
|
|
10
|
+
};
|
|
11
|
+
var _hoisted_5 = ["aria-label", "aria-expanded"];
|
|
12
|
+
var _hoisted_6 = { class: "flex min-w-0 flex-1 items-center gap-3" };
|
|
13
|
+
var _hoisted_7 = {
|
|
14
|
+
key: 1,
|
|
15
|
+
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"
|
|
16
|
+
};
|
|
17
|
+
var _sfc_main = {
|
|
18
|
+
__name: "AppShell",
|
|
19
|
+
props: {
|
|
20
|
+
/**
|
|
21
|
+
* Drawer state on small screens, for `v-model:open`. Leave unset to let the
|
|
22
|
+
* shell manage it.
|
|
23
|
+
* @type {boolean}
|
|
24
|
+
* @default undefined
|
|
25
|
+
*/
|
|
26
|
+
open: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: void 0
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* Sidebar width.
|
|
32
|
+
* @type {string}
|
|
33
|
+
* @default 'md'
|
|
34
|
+
* @values 'sm' | 'md' | 'lg'
|
|
35
|
+
*/
|
|
36
|
+
sidebarWidth: {
|
|
37
|
+
type: String,
|
|
38
|
+
default: "md"
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* Maximum width of the content column. `'none'` lets it fill the space.
|
|
42
|
+
* @type {string}
|
|
43
|
+
* @default '7xl'
|
|
44
|
+
* @values 'none' | '4xl' | '5xl' | '6xl' | '7xl'
|
|
45
|
+
*/
|
|
46
|
+
maxWidth: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: "7xl"
|
|
49
|
+
},
|
|
50
|
+
/**
|
|
51
|
+
* Pad the content area. Turn off for full-bleed pages that lay out their own
|
|
52
|
+
* spacing.
|
|
53
|
+
* @type {boolean}
|
|
54
|
+
* @default true
|
|
55
|
+
*/
|
|
56
|
+
padded: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
default: true
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
* Accessible label for the menu button that opens the drawer.
|
|
62
|
+
* @type {string}
|
|
63
|
+
* @default 'Open navigation'
|
|
64
|
+
*/
|
|
65
|
+
menuLabel: {
|
|
66
|
+
type: String,
|
|
67
|
+
default: "Open navigation"
|
|
68
|
+
},
|
|
69
|
+
/**
|
|
70
|
+
* Text of the skip link (visible only when focused).
|
|
71
|
+
* @type {string}
|
|
72
|
+
* @default 'Skip to content'
|
|
73
|
+
*/
|
|
74
|
+
skipLabel: {
|
|
75
|
+
type: String,
|
|
76
|
+
default: "Skip to content"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
emits: ["update:open"],
|
|
80
|
+
setup(__props, { emit: __emit }) {
|
|
81
|
+
/**
|
|
82
|
+
* UiAppShell — the page frame for an application: a sidebar, a sticky top bar
|
|
83
|
+
* and a scrolling content area.
|
|
84
|
+
*
|
|
85
|
+
* On large screens (`lg` and up) the sidebar is pinned to the left and the
|
|
86
|
+
* content is offset beside it. Below that it becomes an off-canvas drawer,
|
|
87
|
+
* opened by a menu button the shell adds to the top bar, closed by the
|
|
88
|
+
* backdrop, by Escape, or by any `UiSidebarItem` being chosen. While the drawer
|
|
89
|
+
* is closed on a small screen the sidebar is `inert`, so keyboard users don't
|
|
90
|
+
* tab into links they can't see.
|
|
91
|
+
*
|
|
92
|
+
* The shell owns layout only. Put a `UiSidebar` in `#sidebar`, page chrome in
|
|
93
|
+
* `#header`, and the routed page in the default slot. A skip link to the main
|
|
94
|
+
* content is the first tab stop.
|
|
95
|
+
*
|
|
96
|
+
* The drawer state is uncontrolled by default; bind `v-model:open` to drive it
|
|
97
|
+
* yourself (e.g. to close it on route change).
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* <UiAppShell>
|
|
101
|
+
* <template #sidebar>
|
|
102
|
+
* <UiSidebar label="Main">
|
|
103
|
+
* <template #header><strong>Numori CRDT</strong></template>
|
|
104
|
+
* <UiSidebarItem icon="mdi:view-grid" href="/" active>Dashboard</UiSidebarItem>
|
|
105
|
+
* <UiSidebarItem icon="mdi:sync" href="/apps">Apps</UiSidebarItem>
|
|
106
|
+
* </UiSidebar>
|
|
107
|
+
* </template>
|
|
108
|
+
* <template #header>
|
|
109
|
+
* <span class="flex-1" />
|
|
110
|
+
* <UiThemeToggle :is-dark="dark" @toggle="dark = !dark" />
|
|
111
|
+
* </template>
|
|
112
|
+
* <UiPageHeader title="Dashboard" />
|
|
113
|
+
* </UiAppShell>
|
|
114
|
+
*
|
|
115
|
+
* @emits {boolean} update:open — The drawer opened or closed (small screens).
|
|
116
|
+
*
|
|
117
|
+
* @slot sidebar — Sidebar content, usually a `UiSidebar`. Scope: `{ close }`.
|
|
118
|
+
* @slot header — Top bar content beside the menu button. Scope: `{ toggle, open }`.
|
|
119
|
+
* @slot default — Page content.
|
|
120
|
+
* @slot footer — Optional footer below the content.
|
|
121
|
+
*/
|
|
122
|
+
const props = __props;
|
|
123
|
+
const emit = __emit;
|
|
124
|
+
const slots = useSlots();
|
|
125
|
+
const baseId = useId();
|
|
126
|
+
const sidebarId = `${baseId}-sidebar`;
|
|
127
|
+
const mainId = `${baseId}-main`;
|
|
128
|
+
const hasSidebar = computed(() => !!slots.sidebar);
|
|
129
|
+
const internalOpen = ref(false);
|
|
130
|
+
const isOpen = computed(() => props.open ?? internalOpen.value);
|
|
131
|
+
function setOpen(value) {
|
|
132
|
+
internalOpen.value = value;
|
|
133
|
+
emit("update:open", value);
|
|
134
|
+
}
|
|
135
|
+
const toggle = () => setOpen(!isOpen.value);
|
|
136
|
+
const close = () => {
|
|
137
|
+
if (isOpen.value) setOpen(false);
|
|
138
|
+
};
|
|
139
|
+
provide("numori-ui:app-shell", { close });
|
|
140
|
+
const isDesktop = ref(true);
|
|
141
|
+
let media = null;
|
|
142
|
+
const onMedia = () => {
|
|
143
|
+
isDesktop.value = media.matches;
|
|
144
|
+
if (media.matches) close();
|
|
145
|
+
};
|
|
146
|
+
const onKeydown = (event) => {
|
|
147
|
+
if (event.key === "Escape" && isOpen.value) close();
|
|
148
|
+
};
|
|
149
|
+
onMounted(() => {
|
|
150
|
+
media = window.matchMedia("(min-width: 64rem)");
|
|
151
|
+
onMedia();
|
|
152
|
+
media.addEventListener("change", onMedia);
|
|
153
|
+
window.addEventListener("keydown", onKeydown);
|
|
154
|
+
});
|
|
155
|
+
onBeforeUnmount(() => {
|
|
156
|
+
media?.removeEventListener("change", onMedia);
|
|
157
|
+
window.removeEventListener("keydown", onKeydown);
|
|
158
|
+
});
|
|
159
|
+
const widthClass = computed(() => ({
|
|
160
|
+
sm: "w-60",
|
|
161
|
+
md: "w-64",
|
|
162
|
+
lg: "w-72"
|
|
163
|
+
})[props.sidebarWidth] ?? "w-64");
|
|
164
|
+
const offsetClass = computed(() => ({
|
|
165
|
+
sm: "lg:pl-60",
|
|
166
|
+
md: "lg:pl-64",
|
|
167
|
+
lg: "lg:pl-72"
|
|
168
|
+
})[props.sidebarWidth] ?? "lg:pl-64");
|
|
169
|
+
const contentClass = computed(() => {
|
|
170
|
+
return [{
|
|
171
|
+
none: "",
|
|
172
|
+
"4xl": "mx-auto max-w-4xl",
|
|
173
|
+
"5xl": "mx-auto max-w-5xl",
|
|
174
|
+
"6xl": "mx-auto max-w-6xl",
|
|
175
|
+
"7xl": "mx-auto max-w-7xl"
|
|
176
|
+
}[props.maxWidth] ?? "mx-auto max-w-7xl", props.padded ? "px-4 py-6 sm:px-6 lg:px-8 lg:py-8" : ""].filter(Boolean).join(" ");
|
|
177
|
+
});
|
|
178
|
+
return (_ctx, _cache) => {
|
|
179
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
180
|
+
createElementVNode("a", {
|
|
181
|
+
href: `#${mainId}`,
|
|
182
|
+
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"
|
|
183
|
+
}, toDisplayString(__props.skipLabel), 9, _hoisted_2),
|
|
184
|
+
createVNode(Transition, {
|
|
185
|
+
"enter-active-class": "transition-opacity duration-200 motion-reduce:transition-none",
|
|
186
|
+
"enter-from-class": "opacity-0",
|
|
187
|
+
"leave-active-class": "transition-opacity duration-200 motion-reduce:transition-none",
|
|
188
|
+
"leave-to-class": "opacity-0"
|
|
189
|
+
}, {
|
|
190
|
+
default: withCtx(() => [hasSidebar.value && isOpen.value ? (openBlock(), createElementBlock("div", {
|
|
191
|
+
key: 0,
|
|
192
|
+
class: "fixed inset-0 z-40 bg-gray-950/50 backdrop-blur-sm lg:hidden",
|
|
193
|
+
"aria-hidden": "true",
|
|
194
|
+
onClick: close
|
|
195
|
+
})) : createCommentVNode("", true)]),
|
|
196
|
+
_: 1
|
|
197
|
+
}),
|
|
198
|
+
hasSidebar.value ? (openBlock(), createElementBlock("aside", {
|
|
199
|
+
key: 0,
|
|
200
|
+
id: sidebarId,
|
|
201
|
+
class: normalizeClass(["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", [widthClass.value, isOpen.value ? "translate-x-0" : "-translate-x-full"]]),
|
|
202
|
+
inert: !isDesktop.value && !isOpen.value ? true : void 0
|
|
203
|
+
}, [renderSlot(_ctx.$slots, "sidebar", { close })], 10, _hoisted_3)) : createCommentVNode("", true),
|
|
204
|
+
createElementVNode("div", { class: normalizeClass(["flex min-h-dvh flex-col", hasSidebar.value ? offsetClass.value : ""]) }, [
|
|
205
|
+
_ctx.$slots.header || hasSidebar.value ? (openBlock(), createElementBlock("header", _hoisted_4, [hasSidebar.value ? (openBlock(), createElementBlock("button", {
|
|
206
|
+
key: 0,
|
|
207
|
+
type: "button",
|
|
208
|
+
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",
|
|
209
|
+
"aria-label": __props.menuLabel,
|
|
210
|
+
"aria-expanded": isOpen.value ? "true" : "false",
|
|
211
|
+
"aria-controls": sidebarId,
|
|
212
|
+
onClick: toggle
|
|
213
|
+
}, [createVNode(_sfc_main$1, {
|
|
214
|
+
name: "mdi:menu",
|
|
215
|
+
class: "size-5"
|
|
216
|
+
})], 8, _hoisted_5)) : createCommentVNode("", true), createElementVNode("div", _hoisted_6, [renderSlot(_ctx.$slots, "header", {
|
|
217
|
+
toggle,
|
|
218
|
+
open: isOpen.value
|
|
219
|
+
})])])) : createCommentVNode("", true),
|
|
220
|
+
createElementVNode("main", {
|
|
221
|
+
id: mainId,
|
|
222
|
+
tabindex: "-1",
|
|
223
|
+
class: "flex-1 focus:outline-none"
|
|
224
|
+
}, [createElementVNode("div", { class: normalizeClass(contentClass.value) }, [renderSlot(_ctx.$slots, "default")], 2)]),
|
|
225
|
+
_ctx.$slots.footer ? (openBlock(), createElementBlock("footer", _hoisted_7, [renderSlot(_ctx.$slots, "footer")])) : createCommentVNode("", true)
|
|
226
|
+
], 2)
|
|
227
|
+
]);
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
//#endregion
|
|
232
|
+
export { _sfc_main as default };
|
|
233
|
+
|
|
234
|
+
//# sourceMappingURL=AppShell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppShell.js","names":["$slots"],"sources":["../../src/components/AppShell.vue"],"sourcesContent":["<template>\n <div class=\"min-h-dvh bg-gray-50 text-gray-900 dark:bg-gray-950 dark:text-gray-100\">\n <!-- Skip link: the first tab stop jumps past the sidebar to the content. -->\n <a\n :href=\"`#${mainId}`\"\n 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\"\n >{{ skipLabel }}</a\n >\n\n <!-- Backdrop behind the off-canvas sidebar on small screens -->\n <Transition\n enter-active-class=\"transition-opacity duration-200 motion-reduce:transition-none\"\n enter-from-class=\"opacity-0\"\n leave-active-class=\"transition-opacity duration-200 motion-reduce:transition-none\"\n leave-to-class=\"opacity-0\"\n >\n <div\n v-if=\"hasSidebar && isOpen\"\n class=\"fixed inset-0 z-40 bg-gray-950/50 backdrop-blur-sm lg:hidden\"\n aria-hidden=\"true\"\n @click=\"close\"\n />\n </Transition>\n\n <aside\n v-if=\"hasSidebar\"\n :id=\"sidebarId\"\n 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\"\n :class=\"[widthClass, isOpen ? 'translate-x-0' : '-translate-x-full']\"\n :inert=\"!isDesktop && !isOpen ? true : undefined\"\n >\n <slot name=\"sidebar\" :close=\"close\" />\n </aside>\n\n <div class=\"flex min-h-dvh flex-col\" :class=\"hasSidebar ? offsetClass : ''\">\n <header\n v-if=\"$slots.header || hasSidebar\"\n 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\"\n >\n <button\n v-if=\"hasSidebar\"\n type=\"button\"\n 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\"\n :aria-label=\"menuLabel\"\n :aria-expanded=\"isOpen ? 'true' : 'false'\"\n :aria-controls=\"sidebarId\"\n @click=\"toggle\"\n >\n <UiIcon name=\"mdi:menu\" class=\"size-5\" />\n </button>\n <div class=\"flex min-w-0 flex-1 items-center gap-3\">\n <slot name=\"header\" :toggle=\"toggle\" :open=\"isOpen\" />\n </div>\n </header>\n\n <main :id=\"mainId\" tabindex=\"-1\" class=\"flex-1 focus:outline-none\">\n <div :class=\"contentClass\">\n <slot />\n </div>\n </main>\n\n <footer\n v-if=\"$slots.footer\"\n 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\"\n >\n <slot name=\"footer\" />\n </footer>\n </div>\n </div>\n</template>\n\n<script setup>\n/**\n * UiAppShell — the page frame for an application: a sidebar, a sticky top bar\n * and a scrolling content area.\n *\n * On large screens (`lg` and up) the sidebar is pinned to the left and the\n * content is offset beside it. Below that it becomes an off-canvas drawer,\n * opened by a menu button the shell adds to the top bar, closed by the\n * backdrop, by Escape, or by any `UiSidebarItem` being chosen. While the drawer\n * is closed on a small screen the sidebar is `inert`, so keyboard users don't\n * tab into links they can't see.\n *\n * The shell owns layout only. Put a `UiSidebar` in `#sidebar`, page chrome in\n * `#header`, and the routed page in the default slot. A skip link to the main\n * content is the first tab stop.\n *\n * The drawer state is uncontrolled by default; bind `v-model:open` to drive it\n * yourself (e.g. to close it on route change).\n *\n * @example\n * <UiAppShell>\n * <template #sidebar>\n * <UiSidebar label=\"Main\">\n * <template #header><strong>Numori CRDT</strong></template>\n * <UiSidebarItem icon=\"mdi:view-grid\" href=\"/\" active>Dashboard</UiSidebarItem>\n * <UiSidebarItem icon=\"mdi:sync\" href=\"/apps\">Apps</UiSidebarItem>\n * </UiSidebar>\n * </template>\n * <template #header>\n * <span class=\"flex-1\" />\n * <UiThemeToggle :is-dark=\"dark\" @toggle=\"dark = !dark\" />\n * </template>\n * <UiPageHeader title=\"Dashboard\" />\n * </UiAppShell>\n *\n * @emits {boolean} update:open — The drawer opened or closed (small screens).\n *\n * @slot sidebar — Sidebar content, usually a `UiSidebar`. Scope: `{ close }`.\n * @slot header — Top bar content beside the menu button. Scope: `{ toggle, open }`.\n * @slot default — Page content.\n * @slot footer — Optional footer below the content.\n */\nimport { computed, onBeforeUnmount, onMounted, provide, ref, useId, useSlots } from 'vue'\nimport UiIcon from '../icons/Icon.vue'\n\nconst props = defineProps({\n /**\n * Drawer state on small screens, for `v-model:open`. Leave unset to let the\n * shell manage it.\n * @type {boolean}\n * @default undefined\n */\n open: { type: Boolean, default: undefined },\n\n /**\n * Sidebar width.\n * @type {string}\n * @default 'md'\n * @values 'sm' | 'md' | 'lg'\n */\n sidebarWidth: { type: String, default: 'md' },\n\n /**\n * Maximum width of the content column. `'none'` lets it fill the space.\n * @type {string}\n * @default '7xl'\n * @values 'none' | '4xl' | '5xl' | '6xl' | '7xl'\n */\n maxWidth: { type: String, default: '7xl' },\n\n /**\n * Pad the content area. Turn off for full-bleed pages that lay out their own\n * spacing.\n * @type {boolean}\n * @default true\n */\n padded: { type: Boolean, default: true },\n\n /**\n * Accessible label for the menu button that opens the drawer.\n * @type {string}\n * @default 'Open navigation'\n */\n menuLabel: { type: String, default: 'Open navigation' },\n\n /**\n * Text of the skip link (visible only when focused).\n * @type {string}\n * @default 'Skip to content'\n */\n skipLabel: { type: String, default: 'Skip to content' },\n})\n\nconst emit = defineEmits(['update:open'])\nconst slots = useSlots()\n\nconst baseId = useId()\nconst sidebarId = `${baseId}-sidebar`\nconst mainId = `${baseId}-main`\n\nconst hasSidebar = computed(() => !!slots.sidebar)\n\nconst internalOpen = ref(false)\nconst isOpen = computed(() => props.open ?? internalOpen.value)\n\nfunction setOpen(value) {\n internalOpen.value = value\n emit('update:open', value)\n}\nconst toggle = () => setOpen(!isOpen.value)\nconst close = () => {\n if (isOpen.value) setOpen(false)\n}\n\n// UiSidebarItem closes the drawer when chosen, so navigation on a phone does\n// not leave the drawer covering the page it just opened.\nprovide('numori-ui:app-shell', { close })\n\n// Assume a desktop layout until mounted, so the server render never marks the\n// sidebar inert on a screen where it is visible.\nconst isDesktop = ref(true)\nlet media = null\nconst onMedia = () => {\n isDesktop.value = media.matches\n if (media.matches) close()\n}\nconst onKeydown = (event) => {\n if (event.key === 'Escape' && isOpen.value) close()\n}\n\nonMounted(() => {\n media = window.matchMedia('(min-width: 64rem)')\n onMedia()\n media.addEventListener('change', onMedia)\n window.addEventListener('keydown', onKeydown)\n})\nonBeforeUnmount(() => {\n media?.removeEventListener('change', onMedia)\n window.removeEventListener('keydown', onKeydown)\n})\n\nconst widthClass = computed(\n () => ({ sm: 'w-60', md: 'w-64', lg: 'w-72' })[props.sidebarWidth] ?? 'w-64',\n)\nconst offsetClass = computed(\n () => ({ sm: 'lg:pl-60', md: 'lg:pl-64', lg: 'lg:pl-72' })[props.sidebarWidth] ?? 'lg:pl-64',\n)\n\nconst contentClass = computed(() => {\n const width =\n {\n none: '',\n '4xl': 'mx-auto max-w-4xl',\n '5xl': 'mx-auto max-w-5xl',\n '6xl': 'mx-auto max-w-6xl',\n '7xl': 'mx-auto max-w-7xl',\n }[props.maxWidth] ?? 'mx-auto max-w-7xl'\n return [width, props.padded ? 'px-4 py-6 sm:px-6 lg:px-8 lg:py-8' : ''].filter(Boolean).join(' ')\n})\n</script>\n"],"mappings":"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"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { checkableSizeClass } from "../internal/controlSizes.js";
|
|
2
|
-
import {
|
|
2
|
+
import { useFormField } from "../internal/formField.js";
|
|
3
|
+
import { computed, createElementBlock, normalizeClass, openBlock, unref } from "vue";
|
|
3
4
|
//#region src/components/Checkbox.vue
|
|
4
|
-
var _hoisted_1 = [
|
|
5
|
+
var _hoisted_1 = [
|
|
6
|
+
"id",
|
|
7
|
+
"aria-describedby",
|
|
8
|
+
"checked",
|
|
9
|
+
"disabled"
|
|
10
|
+
];
|
|
5
11
|
var _sfc_main = {
|
|
6
12
|
__name: "Checkbox",
|
|
7
13
|
props: {
|
|
@@ -66,6 +72,7 @@ var _sfc_main = {
|
|
|
66
72
|
*/
|
|
67
73
|
const props = __props;
|
|
68
74
|
const emit = __emit;
|
|
75
|
+
const field = useFormField();
|
|
69
76
|
const sizeClass = computed(() => checkableSizeClass(props.size));
|
|
70
77
|
function onChange(e) {
|
|
71
78
|
emit("update:modelValue", e.target.checked);
|
|
@@ -73,7 +80,9 @@ var _sfc_main = {
|
|
|
73
80
|
}
|
|
74
81
|
return (_ctx, _cache) => {
|
|
75
82
|
return openBlock(), createElementBlock("input", {
|
|
83
|
+
id: unref(field)?.controlId.value,
|
|
76
84
|
type: "checkbox",
|
|
85
|
+
"aria-describedby": unref(field)?.describedBy.value,
|
|
77
86
|
checked: __props.modelValue ?? __props.checked,
|
|
78
87
|
disabled: __props.disabled,
|
|
79
88
|
class: normalizeClass(["rounded border-gray-300 dark:border-gray-600 text-primary-600 focus:ring-primary-500", sizeClass.value]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","names":[],"sources":["../../src/components/Checkbox.vue"],"sourcesContent":["<template>\n <input\n type=\"checkbox\"\n :checked=\"modelValue ?? checked\"\n :disabled=\"disabled\"\n class=\"rounded border-gray-300 dark:border-gray-600 text-primary-600 focus:ring-primary-500\"\n :class=\"sizeClass\"\n @change=\"onChange\"\n />\n</template>\n\n<script setup>\n/**\n * UiCheckbox — Simple styled checkbox input with configurable size.\n *\n * Wraps a native `<input type=\"checkbox\">` with consistent Tailwind styling,\n * primary color accent, and focus ring. Supports both v-model (`modelValue`)\n * and uncontrolled (`checked`) usage patterns.\n *\n * @example Basic v-model checkbox\n * <UiCheckbox v-model=\"agreed\" />\n *\n * @example Small disabled checkbox\n * <UiCheckbox v-model=\"locked\" size=\"sm\" disabled />\n *\n * @example Uncontrolled with checked prop\n * <UiCheckbox :checked=\"true\" @change=\"handleChange\" />\n *\n * @emits {boolean} update:modelValue — Emitted when the checked state changes (v-model)\n * @emits {Event} change — Emitted with the native change event\n */\nimport { computed } from 'vue'\nimport { checkableSizeClass } from '../internal/controlSizes.js'\nconst props = defineProps({\n /**\n * Controlled checked state (v-model). Takes priority over `checked` when defined.\n * @type {boolean}\n * @default undefined\n */\n modelValue: { type: Boolean, default: undefined },\n\n /**\n * Uncontrolled initial checked state (used when modelValue is undefined).\n * @type {boolean}\n * @default false\n */\n checked: { type: Boolean, default: false },\n\n /**\n * Disabled state — dims the checkbox and prevents interaction.\n * @type {boolean}\n * @default false\n */\n disabled: { type: Boolean, default: false },\n\n /**\n * Checkbox size controlling width and height.\n * @type {string}\n * @default 'md'\n * @values 'sm' (3.5×3.5) | 'md' (4×4) | 'lg' (5×5)\n */\n size: { type: String, default: 'md' },\n})\n\nconst emit = defineEmits(['update:modelValue', 'change'])\n\nconst sizeClass = computed(() => checkableSizeClass(props.size))\n\nfunction onChange(e) {\n emit('update:modelValue', e.target.checked)\n emit('change', e)\n}\n</script>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Checkbox.js","names":[],"sources":["../../src/components/Checkbox.vue"],"sourcesContent":["<template>\n <input\n :id=\"field?.controlId.value\"\n type=\"checkbox\"\n :aria-describedby=\"field?.describedBy.value\"\n :checked=\"modelValue ?? checked\"\n :disabled=\"disabled\"\n class=\"rounded border-gray-300 dark:border-gray-600 text-primary-600 focus:ring-primary-500\"\n :class=\"sizeClass\"\n @change=\"onChange\"\n />\n</template>\n\n<script setup>\n/**\n * UiCheckbox — Simple styled checkbox input with configurable size.\n *\n * Wraps a native `<input type=\"checkbox\">` with consistent Tailwind styling,\n * primary color accent, and focus ring. Supports both v-model (`modelValue`)\n * and uncontrolled (`checked`) usage patterns.\n *\n * @example Basic v-model checkbox\n * <UiCheckbox v-model=\"agreed\" />\n *\n * @example Small disabled checkbox\n * <UiCheckbox v-model=\"locked\" size=\"sm\" disabled />\n *\n * @example Uncontrolled with checked prop\n * <UiCheckbox :checked=\"true\" @change=\"handleChange\" />\n *\n * @emits {boolean} update:modelValue — Emitted when the checked state changes (v-model)\n * @emits {Event} change — Emitted with the native change event\n */\nimport { computed } from 'vue'\nimport { checkableSizeClass } from '../internal/controlSizes.js'\nimport { useFormField } from '../internal/formField.js'\nconst props = defineProps({\n /**\n * Controlled checked state (v-model). Takes priority over `checked` when defined.\n * @type {boolean}\n * @default undefined\n */\n modelValue: { type: Boolean, default: undefined },\n\n /**\n * Uncontrolled initial checked state (used when modelValue is undefined).\n * @type {boolean}\n * @default false\n */\n checked: { type: Boolean, default: false },\n\n /**\n * Disabled state — dims the checkbox and prevents interaction.\n * @type {boolean}\n * @default false\n */\n disabled: { type: Boolean, default: false },\n\n /**\n * Checkbox size controlling width and height.\n * @type {string}\n * @default 'md'\n * @values 'sm' (3.5×3.5) | 'md' (4×4) | 'lg' (5×5)\n */\n size: { type: String, default: 'md' },\n})\n\nconst emit = defineEmits(['update:modelValue', 'change'])\n\nconst field = useFormField()\n\nconst sizeClass = computed(() => checkableSizeClass(props.size))\n\nfunction onChange(e) {\n emit('update:modelValue', e.target.checked)\n emit('change', e)\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoCA,MAAM,QAAQ;EA+Bd,MAAM,OAAO;EAEb,MAAM,QAAQ,aAAa;EAE3B,MAAM,YAAY,eAAe,mBAAmB,MAAM,IAAI,CAAC;EAE/D,SAAS,SAAS,GAAG;GACnB,KAAK,qBAAqB,EAAE,OAAO,OAAO;GAC1C,KAAK,UAAU,CAAC;EAClB;;GA3EE,OAAA,UAAA,GAAA,mBASE,SAAA;IARC,IAAI,MAAA,KAAA,CAAK,EAAE,UAAU;IACtB,MAAK;IACJ,oBAAkB,MAAA,KAAA,CAAK,EAAE,YAAY;IACrC,SAAS,QAAA,cAAc,QAAA;IACvB,UAAU,QAAA;IACX,OAAK,eAAA,CAAC,wFACE,UAAA,KAAS,CAAA;IACR"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
|
+
import { useMergedClasses } from "../composables/useMergedClasses.js";
|
|
3
|
+
import { computed, createCommentVNode, createElementBlock, createElementVNode, createVNode, mergeProps, normalizeClass, openBlock, ref, toDisplayString, unref, watch } from "vue";
|
|
4
|
+
//#region src/components/CopyField.vue
|
|
5
|
+
var _hoisted_1 = ["aria-label"];
|
|
6
|
+
var _hoisted_2 = ["aria-label", "aria-pressed"];
|
|
7
|
+
var _hoisted_3 = ["aria-label"];
|
|
8
|
+
var _hoisted_4 = {
|
|
9
|
+
key: 0,
|
|
10
|
+
class: "hidden sm:inline"
|
|
11
|
+
};
|
|
12
|
+
var buttonClass = "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";
|
|
13
|
+
var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
|
|
14
|
+
__name: "CopyField",
|
|
15
|
+
props: {
|
|
16
|
+
/**
|
|
17
|
+
* The text to show and copy.
|
|
18
|
+
* @type {string}
|
|
19
|
+
*/
|
|
20
|
+
value: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* Mask the value until revealed.
|
|
26
|
+
* @type {boolean}
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
secret: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: false
|
|
32
|
+
},
|
|
33
|
+
/**
|
|
34
|
+
* Revealed state of a secret, for `v-model:revealed`.
|
|
35
|
+
* @type {boolean}
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
revealed: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: false
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* Monospace text.
|
|
44
|
+
* @type {boolean}
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
mono: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: true
|
|
50
|
+
},
|
|
51
|
+
/**
|
|
52
|
+
* Wrap long values onto several lines instead of truncating.
|
|
53
|
+
* @type {boolean}
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
wrap: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
default: false
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
* Control size.
|
|
62
|
+
* @type {string}
|
|
63
|
+
* @default 'md'
|
|
64
|
+
* @values 'sm' | 'md'
|
|
65
|
+
*/
|
|
66
|
+
size: {
|
|
67
|
+
type: String,
|
|
68
|
+
default: "md"
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* Show the copy label beside the icon (from `sm` up).
|
|
72
|
+
* @type {boolean}
|
|
73
|
+
* @default false
|
|
74
|
+
*/
|
|
75
|
+
showCopyText: {
|
|
76
|
+
type: Boolean,
|
|
77
|
+
default: false
|
|
78
|
+
},
|
|
79
|
+
/** @type {string} @default 'Copy' */
|
|
80
|
+
copyLabel: {
|
|
81
|
+
type: String,
|
|
82
|
+
default: "Copy"
|
|
83
|
+
},
|
|
84
|
+
/** @type {string} @default 'Copied' */
|
|
85
|
+
copiedLabel: {
|
|
86
|
+
type: String,
|
|
87
|
+
default: "Copied"
|
|
88
|
+
},
|
|
89
|
+
/** @type {string} @default 'Reveal' */
|
|
90
|
+
revealLabel: {
|
|
91
|
+
type: String,
|
|
92
|
+
default: "Reveal"
|
|
93
|
+
},
|
|
94
|
+
/** @type {string} @default 'Hide' */
|
|
95
|
+
hideLabel: {
|
|
96
|
+
type: String,
|
|
97
|
+
default: "Hide"
|
|
98
|
+
},
|
|
99
|
+
/** Accessible text read in place of a masked value. @type {string} @default 'Hidden value' */
|
|
100
|
+
hiddenLabel: {
|
|
101
|
+
type: String,
|
|
102
|
+
default: "Hidden value"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
emits: ["copy", "update:revealed"],
|
|
106
|
+
setup(__props, { emit: __emit }) {
|
|
107
|
+
/**
|
|
108
|
+
* UiCopyField — a read-only value with a copy button, and optional masking for
|
|
109
|
+
* secrets.
|
|
110
|
+
*
|
|
111
|
+
* For connect URLs, ids, API keys and generated secrets. With `secret`, the
|
|
112
|
+
* value is masked until revealed and the real text is not in the DOM while it
|
|
113
|
+
* is masked, so a screen share or a screenshot does not leak it. Copying works
|
|
114
|
+
* either way.
|
|
115
|
+
*
|
|
116
|
+
* Copy uses the async Clipboard API and fails silently when unavailable (an
|
|
117
|
+
* insecure context or denied permission). Every label is a prop, so nothing
|
|
118
|
+
* is baked into one language.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* <UiFormField label="Connect URL">
|
|
122
|
+
* <UiCopyField value="wss://crdt.numori.app/notes" />
|
|
123
|
+
* </UiFormField>
|
|
124
|
+
*
|
|
125
|
+
* @example A secret shown once
|
|
126
|
+
* <UiCopyField :value="signingKey" secret @copy="markCopied" />
|
|
127
|
+
*
|
|
128
|
+
* @emits {string} copy — The value was copied.
|
|
129
|
+
* @emits {boolean} update:revealed — The secret was revealed or hidden.
|
|
130
|
+
*/
|
|
131
|
+
const props = __props;
|
|
132
|
+
const emit = __emit;
|
|
133
|
+
const isRevealed = ref(props.revealed);
|
|
134
|
+
watch(() => props.revealed, (value) => {
|
|
135
|
+
isRevealed.value = value;
|
|
136
|
+
});
|
|
137
|
+
const masked = computed(() => props.secret && !isRevealed.value);
|
|
138
|
+
const mask = computed(() => "•".repeat(Math.min(Math.max(props.value.length, 8), 24)));
|
|
139
|
+
function toggleReveal() {
|
|
140
|
+
isRevealed.value = !isRevealed.value;
|
|
141
|
+
emit("update:revealed", isRevealed.value);
|
|
142
|
+
}
|
|
143
|
+
const copied = ref(false);
|
|
144
|
+
let timer = null;
|
|
145
|
+
async function copy() {
|
|
146
|
+
try {
|
|
147
|
+
await navigator.clipboard.writeText(props.value);
|
|
148
|
+
copied.value = true;
|
|
149
|
+
emit("copy", props.value);
|
|
150
|
+
clearTimeout(timer);
|
|
151
|
+
timer = setTimeout(() => {
|
|
152
|
+
copied.value = false;
|
|
153
|
+
}, 1600);
|
|
154
|
+
} catch {}
|
|
155
|
+
}
|
|
156
|
+
const { mergedClasses, restAttrs } = useMergedClasses("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");
|
|
157
|
+
return (_ctx, _cache) => {
|
|
158
|
+
return openBlock(), createElementBlock("div", mergeProps({ class: unref(mergedClasses) }, unref(restAttrs)), [
|
|
159
|
+
createElementVNode("span", {
|
|
160
|
+
class: normalizeClass(["min-w-0 flex-1 px-3 text-gray-800 select-all dark:text-gray-200", [
|
|
161
|
+
__props.size === "sm" ? "py-1.5 text-xs" : "py-2 text-sm",
|
|
162
|
+
__props.mono ? "font-mono" : "",
|
|
163
|
+
__props.wrap ? "break-all whitespace-pre-wrap" : "truncate",
|
|
164
|
+
masked.value ? "tracking-widest text-gray-500 select-none dark:text-gray-400" : ""
|
|
165
|
+
]]),
|
|
166
|
+
"aria-label": masked.value ? __props.hiddenLabel : void 0
|
|
167
|
+
}, toDisplayString(masked.value ? mask.value : __props.value), 11, _hoisted_1),
|
|
168
|
+
__props.secret ? (openBlock(), createElementBlock("button", {
|
|
169
|
+
key: 0,
|
|
170
|
+
type: "button",
|
|
171
|
+
class: normalizeClass(buttonClass),
|
|
172
|
+
"aria-label": masked.value ? __props.revealLabel : __props.hideLabel,
|
|
173
|
+
"aria-pressed": masked.value ? "false" : "true",
|
|
174
|
+
onClick: toggleReveal
|
|
175
|
+
}, [createVNode(_sfc_main$1, {
|
|
176
|
+
name: masked.value ? "mdi:eye-outline" : "mdi:eye-off-outline",
|
|
177
|
+
class: "size-4"
|
|
178
|
+
}, null, 8, ["name"])], 8, _hoisted_2)) : createCommentVNode("", true),
|
|
179
|
+
createElementVNode("button", {
|
|
180
|
+
type: "button",
|
|
181
|
+
class: normalizeClass(buttonClass),
|
|
182
|
+
"aria-label": copied.value ? __props.copiedLabel : __props.copyLabel,
|
|
183
|
+
onClick: copy
|
|
184
|
+
}, [createVNode(_sfc_main$1, {
|
|
185
|
+
name: copied.value ? "mdi:check" : "mdi:content-copy",
|
|
186
|
+
class: normalizeClass(["size-4", copied.value ? "text-success-600 dark:text-success-400" : ""])
|
|
187
|
+
}, null, 8, ["name", "class"]), __props.showCopyText ? (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(copied.value ? __props.copiedLabel : __props.copyLabel), 1)) : createCommentVNode("", true)], 8, _hoisted_3)
|
|
188
|
+
], 16);
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
//#endregion
|
|
193
|
+
export { _sfc_main as default };
|
|
194
|
+
|
|
195
|
+
//# sourceMappingURL=CopyField.js.map
|