numori-ui 0.4.0 → 0.6.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 +120 -0
- package/README.md +27 -20
- package/dist/components/AppShell.js +234 -0
- package/dist/components/AppShell.js.map +1 -0
- package/dist/components/Avatar.js +71 -19
- package/dist/components/Avatar.js.map +1 -1
- 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/Dropdown.js +3 -1
- package/dist/components/Dropdown.js.map +1 -1
- 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/Modal.js +61 -4
- package/dist/components/Modal.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/Prompt.js +11 -6
- package/dist/components/Prompt.js.map +1 -1
- package/dist/components/Segmented.js +10 -2
- package/dist/components/Segmented.js.map +1 -1
- package/dist/components/Select.js +11 -2
- 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/Skeleton.js +122 -0
- package/dist/components/Skeleton.js.map +1 -0
- package/dist/components/SplitPane.js +264 -0
- package/dist/components/SplitPane.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/Tree.js +417 -0
- package/dist/components/Tree.js.map +1 -0
- package/dist/components/VirtualList.js +292 -0
- package/dist/components/VirtualList.js.map +1 -0
- package/dist/components/index.js +105 -81
- package/dist/components/index.js.map +1 -1
- package/dist/icons/mdi.js +12 -0
- package/dist/icons/mdi.js.map +1 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +54 -39
- package/dist/index.js.map +1 -1
- package/dist/internal/focusTrap.js +163 -0
- package/dist/internal/focusTrap.js.map +1 -0
- package/dist/internal/formField.js +26 -0
- package/dist/internal/formField.js.map +1 -0
- package/dist/manifest.js +16 -1
- package/dist/manifest.js.map +1 -1
- package/package.json +1 -1
- package/src/components/AppShell.vue +231 -0
- package/src/components/Avatar.vue +69 -18
- package/src/components/Checkbox.vue +5 -0
- package/src/components/CopyField.vue +178 -0
- package/src/components/DescriptionList.vue +114 -0
- package/src/components/Dropdown.vue +4 -1
- package/src/components/EmptyState.vue +107 -0
- package/src/components/FormField.vue +37 -4
- package/src/components/Input.vue +9 -0
- package/src/components/Modal.vue +51 -3
- package/src/components/PageHeader.vue +102 -0
- package/src/components/Pagination.vue +199 -0
- package/src/components/Prompt.vue +14 -3
- package/src/components/Segmented.vue +5 -0
- package/src/components/Select.vue +6 -1
- package/src/components/Sidebar.vue +61 -0
- package/src/components/SidebarGroup.vue +43 -0
- package/src/components/SidebarItem.vue +159 -0
- package/src/components/Skeleton.vue +91 -0
- package/src/components/SplitPane.vue +264 -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/Tree.vue +428 -0
- package/src/components/VirtualList.vue +250 -0
- package/src/components/index.js +45 -6
- package/src/icons/mdi.js +12 -0
- package/src/internal/focusTrap.js +185 -0
- package/src/internal/formField.js +23 -0
- package/src/manifest.js +15 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,124 @@ 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.6.0] — 2026-11-30
|
|
11
|
+
|
|
12
|
+
Layout and list primitives for dense, keyboard-driven applications — built for
|
|
13
|
+
Numori Mail's three-pane layout, and general enough for anything with a sidebar,
|
|
14
|
+
a long list and a detail view. `UiModal` becomes an accessible dialog. Nothing is
|
|
15
|
+
removed and no prop changes meaning, so this is a drop-in upgrade from 0.5.0; see
|
|
16
|
+
**Changed** for the two behaviours that are new. The library is now 53 components
|
|
17
|
+
(54 registered tags, including `UiIcon`).
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- **`UiSplitPane`** — two panes and a draggable splitter, following the WAI-ARIA
|
|
22
|
+
window splitter pattern: a focusable `role="separator"` with
|
|
23
|
+
`aria-valuenow`/`min`/`max` and `aria-controls`. Arrow keys resize (Shift for
|
|
24
|
+
five steps), Home and End go to the limits, Enter collapses to `min` and back,
|
|
25
|
+
double-click resets to `default-size`. Horizontal or vertical, nestable, and
|
|
26
|
+
`v-model` for the size, with `resize-end` firing once per gesture for
|
|
27
|
+
persisting. `end-min` stops the other pane being squeezed away.
|
|
28
|
+
- **`UiVirtualList`** — renders only the rows near the viewport (fixed
|
|
29
|
+
`item-height`), so 10,000 rows put about thirty in the DOM. Each rendered row
|
|
30
|
+
carries `aria-setsize` and `aria-posinset`; container and row roles are
|
|
31
|
+
configurable for listbox use. Emits `range` for prefetching and `end-reached`
|
|
32
|
+
for paging, and exposes `scrollToIndex(index, align)`.
|
|
33
|
+
- **`UiTree`** — the WAI-ARIA tree view: one tab stop with a roving tabindex;
|
|
34
|
+
Up/Down, Left/Right (collapse, or move to the parent / expand, or move to the
|
|
35
|
+
first child), Home/End, Enter/Space, `*` to expand siblings, and type-ahead.
|
|
36
|
+
`v-model` selection, `v-model:expanded` or `default-expanded`, badges, icons,
|
|
37
|
+
disabled nodes and an `#item` slot. Opt-in drag and drop: `draggable` rows, and
|
|
38
|
+
`droppable` (or a predicate) rows that accept drops from the tree or from
|
|
39
|
+
elsewhere, opening a collapsed branch on hover. Emits `drop` and `contextmenu`.
|
|
40
|
+
- **`UiSkeleton`** — `text` (multi-line), `rect` and `circle` placeholders. The
|
|
41
|
+
pulse stops under `prefers-reduced-motion`; decorative by default, or a polite
|
|
42
|
+
status message when given a `label`.
|
|
43
|
+
- **`UiAvatar`** gains `initials`, shown when there is no image.
|
|
44
|
+
- **`UiModal`** gains `label`, `labelledby` and `close-on-escape`.
|
|
45
|
+
- Icons `inbox` and `folder-outline` added to the bundled set, so `UiTree`'s
|
|
46
|
+
documented folder example renders without a host icon component.
|
|
47
|
+
|
|
48
|
+
### Changed
|
|
49
|
+
|
|
50
|
+
- **`UiModal` is now an accessible dialog.** The panel has `role="dialog"` and
|
|
51
|
+
`aria-modal="true"`. Opening it moves focus inside (unless something inside
|
|
52
|
+
already has it), Tab and Shift+Tab wrap within it, **Escape closes it** (unless
|
|
53
|
+
`persistent` or `:close-on-escape="false"`), and focus returns to the element
|
|
54
|
+
that opened it. With stacked modals only the top one responds. Controls inside
|
|
55
|
+
that handle Escape themselves — an open `UiDropdown`, `UiSelect`'s search
|
|
56
|
+
field — now claim the key, so one Escape closes one thing.
|
|
57
|
+
- **`UiPrompt`** names its dialog by its title, gives its close button an
|
|
58
|
+
accessible name, and now actually closes on Escape, as its documentation
|
|
59
|
+
always said it did.
|
|
60
|
+
- **`UiAvatar`** without an image is exposed as `role="img"` named by `alt`, and
|
|
61
|
+
falls back to initials or the icon when its image fails to load — including a
|
|
62
|
+
failure that happened before hydration.
|
|
63
|
+
|
|
64
|
+
## [0.5.0] — 2026-11-30
|
|
65
|
+
|
|
66
|
+
Application and dashboard building blocks. Eleven new components cover the frame
|
|
67
|
+
of an application (shell, sidebar, page header, tabs) and the pieces admin
|
|
68
|
+
screens are made of (stat cards, empty states, description lists, pagination,
|
|
69
|
+
copyable secrets). `UiTable` gains sorting and empty/loading states. Nothing
|
|
70
|
+
existing changes behaviour, so this is a drop-in upgrade from 0.4.0. The library
|
|
71
|
+
is now 49 components (50 registered tags, including `UiIcon`).
|
|
72
|
+
|
|
73
|
+
### Added
|
|
74
|
+
|
|
75
|
+
- **`UiAppShell`** — sidebar, sticky top bar and content area. The sidebar is
|
|
76
|
+
pinned from `lg` up and becomes an off-canvas drawer below that (backdrop,
|
|
77
|
+
Escape, and `inert` while closed so hidden links are not tab stops). Includes
|
|
78
|
+
a skip link, `v-model:open`, and `sidebarWidth` / `maxWidth` / `padded`.
|
|
79
|
+
- **`UiSidebar`**, **`UiSidebarGroup`**, **`UiSidebarItem`** — a labelled
|
|
80
|
+
`<nav>` with header and footer regions, labelled groups, and router-agnostic
|
|
81
|
+
items: `to` renders through `RouterLink` (or any `tag`, such as `NuxtLink`),
|
|
82
|
+
`href` an anchor, neither a button. `active` sets `aria-current="page"`; items
|
|
83
|
+
take an icon and a count badge, and close the shell's drawer when chosen.
|
|
84
|
+
- **`UiPageHeader`** — breadcrumb, title (heading `level` 1–3), inline badges,
|
|
85
|
+
description and an actions area that wraps on narrow screens.
|
|
86
|
+
- **`UiTabs`** — the WAI-ARIA tabs pattern: `tablist` / `tab` / `tabpanel`
|
|
87
|
+
roles, a roving `tabindex`, arrow keys, Home and End, skipping disabled tabs.
|
|
88
|
+
`line` and `pill` variants, per-tab icons and badges, and `:panel="false"` for
|
|
89
|
+
tabs that only navigate.
|
|
90
|
+
- **`UiStatCard`** — label, value, tinted icon, trend delta and hint, with a
|
|
91
|
+
same-height loading placeholder. Built on `UiCard`.
|
|
92
|
+
- **`UiEmptyState`** — icon, title, description and actions, with `compact` and
|
|
93
|
+
`bordered` variants.
|
|
94
|
+
- **`UiDescriptionList`** — label/value pairs as a real `<dl>` in `inline`,
|
|
95
|
+
`stacked` or `grid` layouts, with monospace values, hints, explicit empty text
|
|
96
|
+
and a `#value` slot.
|
|
97
|
+
- **`UiPagination`** — first, last and current ± `siblings` pages with gaps, a
|
|
98
|
+
"21–40 of 134" summary, `v-model:page`, and every label configurable.
|
|
99
|
+
- **`UiCopyField`** — a read-only value with a copy button. With `secret` the
|
|
100
|
+
value is masked until revealed, and the real text is not rendered while
|
|
101
|
+
masked.
|
|
102
|
+
- **`UiTable`** — controlled sorting (`sortable` columns, `sort-key`,
|
|
103
|
+
`sort-direction`, a `sort` event, `aria-sort`), `loading` (a spinner, or
|
|
104
|
+
dimmed rows while refreshing), `emptyText` and an `#empty` slot, and
|
|
105
|
+
`clickable-rows` with a `row-click` event that also fires on Enter.
|
|
106
|
+
- Icons `menu`, `arrow-up`, `arrow-down`, `unfold-more-horizontal`,
|
|
107
|
+
`inbox-outline`, `trending-up`, `trending-down` and `trending-neutral` added
|
|
108
|
+
to the bundled set.
|
|
109
|
+
|
|
110
|
+
### Fixed
|
|
111
|
+
|
|
112
|
+
- **`UiFormField` labels now reach the control.** The `<label>` was not
|
|
113
|
+
associated with anything, so clicking it did nothing and screen readers
|
|
114
|
+
announced inputs without their label, hint or error. The field now provides
|
|
115
|
+
an id that `UiInput`, `UiSelect`, `UiToggle`, `UiCheckbox` and `UiSegmented`
|
|
116
|
+
apply to their real control, along with `aria-describedby` (hint and error)
|
|
117
|
+
and `aria-invalid` (when there is an error). For other controls, pass the
|
|
118
|
+
control's id as the new `for` prop.
|
|
119
|
+
|
|
120
|
+
### Changed
|
|
121
|
+
|
|
122
|
+
- The `app.use(NumoriUI)` tree-shaking budget rises from 120 kB to 150 kB to
|
|
123
|
+
cover the new components. Named imports are unaffected, and a new case checks
|
|
124
|
+
that the dashboard components do not pull in forms or overlays.
|
|
125
|
+
- README: Numori UI is now the source of truth for its components. The note
|
|
126
|
+
saying Numori Notes is where they are developed was out of date.
|
|
127
|
+
|
|
10
128
|
## [0.4.0] — 2026-08-31
|
|
11
129
|
|
|
12
130
|
A consolidation-and-polish release. Two components fold into more capable,
|
|
@@ -167,6 +285,8 @@ including `UiIcon`). All additions are backward compatible.
|
|
|
167
285
|
- First published release: 28 components (29 registered tags), consumable as a
|
|
168
286
|
Nuxt module, a Vite plugin or a framework-agnostic Vue plugin.
|
|
169
287
|
|
|
288
|
+
[0.5.0]: https://github.com/Numori-Ecosystem/Numori-UI/releases/tag/v0.5.0
|
|
289
|
+
[0.4.0]: https://github.com/Numori-Ecosystem/Numori-UI/releases/tag/v0.4.0
|
|
170
290
|
[0.3.0]: https://github.com/Numori-Ecosystem/Numori-UI/releases/tag/v0.3.0
|
|
171
291
|
[0.2.0]: https://github.com/Numori-Ecosystem/Numori-UI/releases/tag/v0.2.0
|
|
172
292
|
[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
|
|
@@ -305,7 +305,8 @@ variants matching `UiButton`; `pill`/`round`/`square` shapes), `UiThemeToggle` (
|
|
|
305
305
|
built-in validation), `UiSelect` (searchable, groupable, teleported panel), `UiCheckbox`, `UiRadio`,
|
|
306
306
|
`UiToggle`, `UiSlider`, `UiFileInput`, `UiFormField`, `UiNumpad`, `UiStepper`
|
|
307
307
|
|
|
308
|
-
**Overlays** — `UiModal` (teleported, fullscreen-on-mobile, safe-area aware
|
|
308
|
+
**Overlays** — `UiModal` (teleported, fullscreen-on-mobile, safe-area aware; a real `role="dialog"` that
|
|
309
|
+
traps focus, closes on Escape and returns focus to its opener), `UiPrompt`,
|
|
309
310
|
`UiDropdown`, `UiDropdownItem`, `UiDropdownRow`, `UiDropdownSubmenu`, `UiPopup`, `UiTooltip`
|
|
310
311
|
|
|
311
312
|
**Feedback** — `UiAlert`, `UiBadge`, `UiProgressBar`, `UiSpinner` (loading glyph),
|
|
@@ -316,6 +317,20 @@ built-in validation), `UiSelect` (searchable, groupable, teleported panel), `UiC
|
|
|
316
317
|
`UiTable` (data table with a built-in comparison mode), `UiCodeBlock` (copyable snippet), `UiListMenu`,
|
|
317
318
|
`UiListMenuItem`, `UiDivider`, `UiAvatar`, `UiKbd`, `UiIcon`
|
|
318
319
|
|
|
320
|
+
**Application & dashboard** — `UiAppShell` (sidebar + sticky top bar + content, off-canvas drawer
|
|
321
|
+
on small screens), `UiSidebar`, `UiSidebarGroup`, `UiSidebarItem` (router-agnostic: `to`, `href` or a
|
|
322
|
+
button), `UiPageHeader` (title, badges, description, actions), `UiTabs` (WAI-ARIA tabs with keyboard
|
|
323
|
+
navigation), `UiStatCard`, `UiEmptyState`, `UiDescriptionList`, `UiPagination`, `UiCopyField`
|
|
324
|
+
(copyable value with masking for secrets). `UiTable` also covers dashboards: sortable columns, empty
|
|
325
|
+
and loading states, clickable rows.
|
|
326
|
+
|
|
327
|
+
**Layout & lists** — `UiSplitPane` (resizable two-pane split, WAI-ARIA window splitter, keyboard
|
|
328
|
+
operable, nestable, `v-model` size), `UiVirtualList` (fixed-row-height windowed list for tens of
|
|
329
|
+
thousands of rows, with `aria-setsize`/`aria-posinset` and `scrollToIndex`), `UiTree` (WAI-ARIA tree
|
|
330
|
+
with roving focus, type-ahead, controlled or uncontrolled expansion, and opt-in drag and drop),
|
|
331
|
+
`UiSkeleton` (loading placeholders that respect reduced motion). `UiAvatar` also shows initials and
|
|
332
|
+
falls back when an image fails to load.
|
|
333
|
+
|
|
319
334
|
External classes always win. `UiButton` merges them with
|
|
320
335
|
[tailwind-merge](https://github.com/dcastil/tailwind-merge), so `class="bg-gray-100"` genuinely
|
|
321
336
|
replaces the variant's background instead of fighting it:
|
|
@@ -445,28 +460,20 @@ npm run lint
|
|
|
445
460
|
|
|
446
461
|
### Syncing from Numori Notes
|
|
447
462
|
|
|
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.
|
|
463
|
+
The components were first developed inside Numori Notes and ported here with
|
|
464
|
+
`scripts/sync-from-notes.mjs`. That direction has ended: Numori Notes now installs this package from
|
|
465
|
+
npm and no longer has a `components/ui/` directory, so **this repository is the source of truth**.
|
|
466
|
+
The script is kept as a record of what the port changed (explicit `vue` imports, `<Icon>` to
|
|
467
|
+
`<UiIcon>`, local VueUse-style helpers, Tailwind v3 fixes). Pointed at a tree without that directory,
|
|
468
|
+
it exits with an error before writing anything.
|
|
462
469
|
|
|
463
470
|
## Changelog
|
|
464
471
|
|
|
465
472
|
See [CHANGELOG.md](./CHANGELOG.md) for the release history. The current release is
|
|
466
|
-
**0.
|
|
467
|
-
`
|
|
468
|
-
`
|
|
469
|
-
|
|
473
|
+
**0.5.0**, which adds eleven application and dashboard components (`UiAppShell`, `UiSidebar`,
|
|
474
|
+
`UiSidebarGroup`, `UiSidebarItem`, `UiPageHeader`, `UiTabs`, `UiStatCard`, `UiEmptyState`,
|
|
475
|
+
`UiDescriptionList`, `UiPagination`, `UiCopyField`) and gives `UiTable` sorting plus empty and
|
|
476
|
+
loading states. It is backwards compatible with 0.4.0.
|
|
470
477
|
|
|
471
478
|
## Licence and attribution
|
|
472
479
|
|
|
@@ -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,12 +1,14 @@
|
|
|
1
1
|
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
|
-
import { computed, createBlock, createElementBlock, normalizeClass, openBlock } from "vue";
|
|
2
|
+
import { computed, createBlock, createElementBlock, normalizeClass, onMounted, openBlock, ref, toDisplayString, watch } from "vue";
|
|
3
3
|
//#region src/components/Avatar.vue
|
|
4
|
-
var _hoisted_1 = ["
|
|
4
|
+
var _hoisted_1 = ["role", "aria-label"];
|
|
5
|
+
var _hoisted_2 = ["src", "alt"];
|
|
5
6
|
var _sfc_main = {
|
|
6
7
|
__name: "Avatar",
|
|
7
8
|
props: {
|
|
8
9
|
/**
|
|
9
|
-
* Image source URL. When empty
|
|
10
|
+
* Image source URL. When empty (or it fails to load), initials or the
|
|
11
|
+
* fallback icon are shown.
|
|
10
12
|
* @type {string}
|
|
11
13
|
* @default ''
|
|
12
14
|
*/
|
|
@@ -15,7 +17,8 @@ var _sfc_main = {
|
|
|
15
17
|
default: ""
|
|
16
18
|
},
|
|
17
19
|
/**
|
|
18
|
-
* Alt text for the avatar image (accessibility)
|
|
20
|
+
* Alt text for the avatar image (accessibility), and the accessible name
|
|
21
|
+
* when initials or the icon are shown.
|
|
19
22
|
* @type {string}
|
|
20
23
|
* @default 'Avatar'
|
|
21
24
|
*/
|
|
@@ -24,6 +27,16 @@ var _sfc_main = {
|
|
|
24
27
|
default: "Avatar"
|
|
25
28
|
},
|
|
26
29
|
/**
|
|
30
|
+
* Initials shown when there is no image. Trimmed to two characters and
|
|
31
|
+
* upper-cased.
|
|
32
|
+
* @type {string}
|
|
33
|
+
* @default ''
|
|
34
|
+
*/
|
|
35
|
+
initials: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: ""
|
|
38
|
+
},
|
|
39
|
+
/**
|
|
27
40
|
* Avatar size controlling width, height, and icon dimensions.
|
|
28
41
|
* @type {string}
|
|
29
42
|
* @default 'md'
|
|
@@ -34,7 +47,7 @@ var _sfc_main = {
|
|
|
34
47
|
default: "md"
|
|
35
48
|
},
|
|
36
49
|
/**
|
|
37
|
-
* MDI icon name used when
|
|
50
|
+
* MDI icon name used when there is neither an image nor initials.
|
|
38
51
|
* @type {string}
|
|
39
52
|
* @default 'mdi:account'
|
|
40
53
|
*/
|
|
@@ -64,15 +77,23 @@ var _sfc_main = {
|
|
|
64
77
|
},
|
|
65
78
|
setup(__props) {
|
|
66
79
|
/**
|
|
67
|
-
* UiAvatar — Circular avatar component displaying an image or a fallback icon.
|
|
80
|
+
* UiAvatar — Circular avatar component displaying an image, initials or a fallback icon.
|
|
68
81
|
*
|
|
69
|
-
* When a `src` URL is provided, renders a cover-fit image
|
|
70
|
-
*
|
|
71
|
-
*
|
|
82
|
+
* When a `src` URL is provided, renders a cover-fit image; if the image fails
|
|
83
|
+
* to load, it falls back rather than showing a broken-image glyph. Without an
|
|
84
|
+
* image it shows `initials` (at most two characters, upper-cased), and without
|
|
85
|
+
* those a configurable fallback icon, on a colored background. Supports five
|
|
86
|
+
* sizes, two color themes for the fallback state, and an optional ring border.
|
|
87
|
+
*
|
|
88
|
+
* Without an image the avatar is exposed as `role="img"` named by `alt`, so
|
|
89
|
+
* pass the person's name there rather than the default.
|
|
72
90
|
*
|
|
73
91
|
* @example Image avatar
|
|
74
92
|
* <UiAvatar src="/img/user.jpg" alt="Jane Doe" size="lg" />
|
|
75
93
|
*
|
|
94
|
+
* @example Initials
|
|
95
|
+
* <UiAvatar initials="JD" alt="Jane Doe" />
|
|
96
|
+
*
|
|
76
97
|
* @example Fallback icon avatar with ring
|
|
77
98
|
* <UiAvatar size="md" color="primary" ring />
|
|
78
99
|
*
|
|
@@ -80,6 +101,15 @@ var _sfc_main = {
|
|
|
80
101
|
* <UiAvatar size="sm" color="gray" fallback-icon="mdi:account-group" />
|
|
81
102
|
*/
|
|
82
103
|
const props = __props;
|
|
104
|
+
const failed = ref(false);
|
|
105
|
+
const imgRef = ref(null);
|
|
106
|
+
watch(() => props.src, () => failed.value = false);
|
|
107
|
+
onMounted(() => {
|
|
108
|
+
const img = imgRef.value;
|
|
109
|
+
if (img && img.complete && img.naturalWidth === 0) failed.value = true;
|
|
110
|
+
});
|
|
111
|
+
const showImage = computed(() => !!props.src && !failed.value);
|
|
112
|
+
const shownInitials = computed(() => [...props.initials.trim()].slice(0, 2).join("").toUpperCase());
|
|
83
113
|
const sizeClass = computed(() => {
|
|
84
114
|
const map = {
|
|
85
115
|
xs: "w-6 h-6",
|
|
@@ -100,8 +130,18 @@ var _sfc_main = {
|
|
|
100
130
|
};
|
|
101
131
|
return map[props.size] || map.md;
|
|
102
132
|
});
|
|
133
|
+
const textSizeClass = computed(() => {
|
|
134
|
+
const map = {
|
|
135
|
+
xs: "text-[10px]",
|
|
136
|
+
sm: "text-xs",
|
|
137
|
+
md: "text-sm",
|
|
138
|
+
lg: "text-base",
|
|
139
|
+
xl: "text-xl"
|
|
140
|
+
};
|
|
141
|
+
return map[props.size] || map.md;
|
|
142
|
+
});
|
|
103
143
|
const bgClass = computed(() => {
|
|
104
|
-
if (
|
|
144
|
+
if (showImage.value) return "";
|
|
105
145
|
const map = {
|
|
106
146
|
primary: "bg-primary-100 dark:bg-primary-900/30 text-primary-600 dark:text-primary-400",
|
|
107
147
|
gray: "bg-gray-200 dark:bg-gray-700 text-gray-500 dark:text-gray-400"
|
|
@@ -110,20 +150,32 @@ var _sfc_main = {
|
|
|
110
150
|
});
|
|
111
151
|
const ringClass = computed(() => props.ring ? "ring-2 ring-primary-200 dark:ring-primary-800 shadow-sm" : "");
|
|
112
152
|
return (_ctx, _cache) => {
|
|
113
|
-
return openBlock(), createElementBlock("div", {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
153
|
+
return openBlock(), createElementBlock("div", {
|
|
154
|
+
class: normalizeClass(["rounded-full flex items-center justify-center overflow-hidden shrink-0", [
|
|
155
|
+
sizeClass.value,
|
|
156
|
+
bgClass.value,
|
|
157
|
+
ringClass.value
|
|
158
|
+
]]),
|
|
159
|
+
role: showImage.value ? void 0 : "img",
|
|
160
|
+
"aria-label": showImage.value ? void 0 : __props.alt
|
|
161
|
+
}, [showImage.value ? (openBlock(), createElementBlock("img", {
|
|
118
162
|
key: 0,
|
|
163
|
+
ref_key: "imgRef",
|
|
164
|
+
ref: imgRef,
|
|
119
165
|
src: __props.src,
|
|
120
166
|
alt: __props.alt,
|
|
121
|
-
class: "w-full h-full object-cover"
|
|
122
|
-
|
|
167
|
+
class: "w-full h-full object-cover",
|
|
168
|
+
onError: _cache[0] || (_cache[0] = ($event) => failed.value = true)
|
|
169
|
+
}, null, 40, _hoisted_2)) : shownInitials.value ? (openBlock(), createElementBlock("span", {
|
|
123
170
|
key: 1,
|
|
171
|
+
class: normalizeClass(["font-semibold leading-none tracking-tight select-none", textSizeClass.value]),
|
|
172
|
+
"aria-hidden": "true"
|
|
173
|
+
}, toDisplayString(shownInitials.value), 3)) : (openBlock(), createBlock(_sfc_main$1, {
|
|
174
|
+
key: 2,
|
|
124
175
|
name: __props.fallbackIcon,
|
|
125
|
-
class: normalizeClass(iconSizeClass.value)
|
|
126
|
-
|
|
176
|
+
class: normalizeClass(iconSizeClass.value),
|
|
177
|
+
"aria-hidden": "true"
|
|
178
|
+
}, null, 8, ["name", "class"]))], 10, _hoisted_1);
|
|
127
179
|
};
|
|
128
180
|
}
|
|
129
181
|
};
|