numori-ui 0.5.0 → 0.7.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/README.md +11 -3
  3. package/dist/components/Avatar.js +71 -19
  4. package/dist/components/Avatar.js.map +1 -1
  5. package/dist/components/ChipsInput.js +423 -0
  6. package/dist/components/ChipsInput.js.map +1 -0
  7. package/dist/components/Drawer.js +236 -0
  8. package/dist/components/Drawer.js.map +1 -0
  9. package/dist/components/Dropdown.js +4 -2
  10. package/dist/components/Dropdown.js.map +1 -1
  11. package/dist/components/Modal.js +61 -4
  12. package/dist/components/Modal.js.map +1 -1
  13. package/dist/components/Prompt.js +11 -6
  14. package/dist/components/Prompt.js.map +1 -1
  15. package/dist/components/Select.js +1 -1
  16. package/dist/components/Select.js.map +1 -1
  17. package/dist/components/Skeleton.js +122 -0
  18. package/dist/components/Skeleton.js.map +1 -0
  19. package/dist/components/SplitPane.js +264 -0
  20. package/dist/components/SplitPane.js.map +1 -0
  21. package/dist/components/Toast.js +62 -16
  22. package/dist/components/Toast.js.map +1 -1
  23. package/dist/components/Tree.js +417 -0
  24. package/dist/components/Tree.js.map +1 -0
  25. package/dist/components/VirtualList.js +292 -0
  26. package/dist/components/VirtualList.js.map +1 -0
  27. package/dist/components/index.js +93 -82
  28. package/dist/components/index.js.map +1 -1
  29. package/dist/icons/mdi.js +3 -0
  30. package/dist/icons/mdi.js.map +1 -1
  31. package/dist/index.d.ts +6 -0
  32. package/dist/index.js +49 -43
  33. package/dist/index.js.map +1 -1
  34. package/dist/internal/focusTrap.js +163 -0
  35. package/dist/internal/focusTrap.js.map +1 -0
  36. package/dist/manifest.js +7 -1
  37. package/dist/manifest.js.map +1 -1
  38. package/package.json +2 -2
  39. package/src/components/Avatar.vue +69 -18
  40. package/src/components/ChipsInput.vue +387 -0
  41. package/src/components/Drawer.vue +213 -0
  42. package/src/components/Dropdown.vue +4 -1
  43. package/src/components/Modal.vue +51 -3
  44. package/src/components/Prompt.vue +14 -3
  45. package/src/components/Select.vue +1 -1
  46. package/src/components/Skeleton.vue +91 -0
  47. package/src/components/SplitPane.vue +264 -0
  48. package/src/components/Toast.vue +57 -13
  49. package/src/components/Tree.vue +428 -0
  50. package/src/components/VirtualList.vue +250 -0
  51. package/src/components/index.js +18 -1
  52. package/src/icons/mdi.js +3 -0
  53. package/src/internal/focusTrap.js +185 -0
  54. package/src/manifest.js +6 -0
package/CHANGELOG.md CHANGED
@@ -7,6 +7,91 @@ 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.7.0] — 2026-11-30
11
+
12
+ Compose and mobile building blocks: a chips field for recipients and tags, a
13
+ drawer for bottom sheets and side panels, and actions on toasts so an "Undo"
14
+ can sit where the confirmation does. Drop-in from 0.6.0. The library is now 55
15
+ components (56 registered tags, including `UiIcon`).
16
+
17
+ ### Added
18
+
19
+ - **`UiChipsInput`** — a field that turns typed text into chips. A comma,
20
+ semicolon, Enter or Tab finishes a chip, as does leaving the field; pasting
21
+ a list makes one chip per entry without splitting `"Smith, Ana" <ana@…>`;
22
+ Backspace in an empty field removes the last chip; duplicates are ignored.
23
+ Chips failing `validate` stay, visibly marked and announced as invalid.
24
+ Suggestions follow the WAI-ARIA combobox pattern (`aria-activedescendant`,
25
+ Up/Down, Enter/Tab to pick, Escape to close) and come from an async
26
+ `suggest` function whose stale results are discarded. Chips may be strings
27
+ or objects (`parse`, `chipLabel`, `chipDetail`, `chipKey`).
28
+ - **`UiDrawer`** — a panel from the bottom (with a grab handle), left or right,
29
+ in four sizes. It is a full modal dialog: named, focus moved in and kept
30
+ in, closed by Escape, the backdrop or the Android back button (unless
31
+ `persistent`), focus returned on close, and stacked correctly with
32
+ `UiModal`. Respects safe-area insets.
33
+ - **`UiToast` actions** — an entry's `action` label adds a button that emits
34
+ `action`; `dismissible` adds a close button that emits `dismiss`
35
+ (`dismiss-label` names it). Bottom-anchored stacks clear the home indicator.
36
+
37
+ ### Changed
38
+
39
+ - `UiToast` transitions stop under `prefers-reduced-motion`.
40
+
41
+ ## [0.6.0] — 2026-11-30
42
+
43
+ Layout and list primitives for dense, keyboard-driven applications — built for
44
+ Numori Mail's three-pane layout, and general enough for anything with a sidebar,
45
+ a long list and a detail view. `UiModal` becomes an accessible dialog. Nothing is
46
+ removed and no prop changes meaning, so this is a drop-in upgrade from 0.5.0; see
47
+ **Changed** for the two behaviours that are new. The library is now 53 components
48
+ (54 registered tags, including `UiIcon`).
49
+
50
+ ### Added
51
+
52
+ - **`UiSplitPane`** — two panes and a draggable splitter, following the WAI-ARIA
53
+ window splitter pattern: a focusable `role="separator"` with
54
+ `aria-valuenow`/`min`/`max` and `aria-controls`. Arrow keys resize (Shift for
55
+ five steps), Home and End go to the limits, Enter collapses to `min` and back,
56
+ double-click resets to `default-size`. Horizontal or vertical, nestable, and
57
+ `v-model` for the size, with `resize-end` firing once per gesture for
58
+ persisting. `end-min` stops the other pane being squeezed away.
59
+ - **`UiVirtualList`** — renders only the rows near the viewport (fixed
60
+ `item-height`), so 10,000 rows put about thirty in the DOM. Each rendered row
61
+ carries `aria-setsize` and `aria-posinset`; container and row roles are
62
+ configurable for listbox use. Emits `range` for prefetching and `end-reached`
63
+ for paging, and exposes `scrollToIndex(index, align)`.
64
+ - **`UiTree`** — the WAI-ARIA tree view: one tab stop with a roving tabindex;
65
+ Up/Down, Left/Right (collapse, or move to the parent / expand, or move to the
66
+ first child), Home/End, Enter/Space, `*` to expand siblings, and type-ahead.
67
+ `v-model` selection, `v-model:expanded` or `default-expanded`, badges, icons,
68
+ disabled nodes and an `#item` slot. Opt-in drag and drop: `draggable` rows, and
69
+ `droppable` (or a predicate) rows that accept drops from the tree or from
70
+ elsewhere, opening a collapsed branch on hover. Emits `drop` and `contextmenu`.
71
+ - **`UiSkeleton`** — `text` (multi-line), `rect` and `circle` placeholders. The
72
+ pulse stops under `prefers-reduced-motion`; decorative by default, or a polite
73
+ status message when given a `label`.
74
+ - **`UiAvatar`** gains `initials`, shown when there is no image.
75
+ - **`UiModal`** gains `label`, `labelledby` and `close-on-escape`.
76
+ - Icons `inbox` and `folder-outline` added to the bundled set, so `UiTree`'s
77
+ documented folder example renders without a host icon component.
78
+
79
+ ### Changed
80
+
81
+ - **`UiModal` is now an accessible dialog.** The panel has `role="dialog"` and
82
+ `aria-modal="true"`. Opening it moves focus inside (unless something inside
83
+ already has it), Tab and Shift+Tab wrap within it, **Escape closes it** (unless
84
+ `persistent` or `:close-on-escape="false"`), and focus returns to the element
85
+ that opened it. With stacked modals only the top one responds. Controls inside
86
+ that handle Escape themselves — an open `UiDropdown`, `UiSelect`'s search
87
+ field — now claim the key, so one Escape closes one thing.
88
+ - **`UiPrompt`** names its dialog by its title, gives its close button an
89
+ accessible name, and now actually closes on Escape, as its documentation
90
+ always said it did.
91
+ - **`UiAvatar`** without an image is exposed as `role="img"` named by `alt`, and
92
+ falls back to initials or the icon when its image fails to load — including a
93
+ failure that happened before hydration.
94
+
10
95
  ## [0.5.0] — 2026-11-30
11
96
 
12
97
  Application and dashboard building blocks. Eleven new components cover the frame
package/README.md CHANGED
@@ -301,15 +301,16 @@ slots and worked examples. Prefixes below assume the default `Ui`.
301
301
  `UiSegmented` (single-select segmented control with an animated sliding indicator; `solid`/`outline`/`ghost`
302
302
  variants matching `UiButton`; `pill`/`round`/`square` shapes), `UiThemeToggle` (stateless light/dark button)
303
303
 
304
- **Forms** — `UiInput` (text, number with steppers, password with toggle, email, phone, textarea,
304
+ **Forms** — `UiChipsInput` (recipients and tags as chips, with combobox suggestions), `UiInput` (text, number with steppers, password with toggle, email, phone, textarea,
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), `UiPrompt`,
308
+ **Overlays** — `UiDrawer` (bottom sheet or side panel, a full modal dialog), `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),
312
- `UiToast` (transient message stack), `UiBanner` (full-width status strip)
313
+ `UiToast` (transient message stack, with optional action and close buttons), `UiBanner` (full-width status strip)
313
314
 
314
315
  **Layout & display** — `UiCard` (the surface primitive, with interactive and highlighted states),
315
316
  `UiSectionHeading` (eyebrow / heading / standfirst), `UiBreadcrumb`, `UiIconTile` (tinted icon tile),
@@ -323,6 +324,13 @@ navigation), `UiStatCard`, `UiEmptyState`, `UiDescriptionList`, `UiPagination`,
323
324
  (copyable value with masking for secrets). `UiTable` also covers dashboards: sortable columns, empty
324
325
  and loading states, clickable rows.
325
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
+
326
334
  External classes always win. `UiButton` merges them with
327
335
  [tailwind-merge](https://github.com/dcastil/tailwind-merge), so `class="bg-gray-100"` genuinely
328
336
  replaces the variant's background instead of fighting it:
@@ -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 = ["src", "alt"];
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, the fallback icon is shown.
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 no image src is provided.
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. Otherwise, displays
70
- * a configurable fallback icon on a colored background. Supports five sizes,
71
- * two color themes for the fallback state, and an optional ring border.
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 (props.src) return "";
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", { class: normalizeClass(["rounded-full flex items-center justify-center overflow-hidden shrink-0", [
114
- sizeClass.value,
115
- bgClass.value,
116
- ringClass.value
117
- ]]) }, [__props.src ? (openBlock(), createElementBlock("img", {
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
- }, null, 8, _hoisted_1)) : (openBlock(), createBlock(_sfc_main$1, {
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
- }, null, 8, ["name", "class"]))], 2);
176
+ class: normalizeClass(iconSizeClass.value),
177
+ "aria-hidden": "true"
178
+ }, null, 8, ["name", "class"]))], 10, _hoisted_1);
127
179
  };
128
180
  }
129
181
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Avatar.js","names":[],"sources":["../../src/components/Avatar.vue"],"sourcesContent":["<template>\n <!-- Circular avatar container with image or fallback icon -->\n <div\n class=\"rounded-full flex items-center justify-center overflow-hidden shrink-0\"\n :class=\"[sizeClass, bgClass, ringClass]\"\n >\n <img v-if=\"src\" :src=\"src\" :alt=\"alt\" class=\"w-full h-full object-cover\" />\n <UiIcon v-else :name=\"fallbackIcon\" :class=\"iconSizeClass\" />\n </div>\n</template>\n\n<script setup>\n/**\n * UiAvatar — Circular avatar component displaying an image or a fallback icon.\n *\n * When a `src` URL is provided, renders a cover-fit image. Otherwise, displays\n * a configurable fallback icon on a colored background. Supports five sizes,\n * two color themes for the fallback state, and an optional ring border.\n *\n * @example Image avatar\n * <UiAvatar src=\"/img/user.jpg\" alt=\"Jane Doe\" size=\"lg\" />\n *\n * @example Fallback icon avatar with ring\n * <UiAvatar size=\"md\" color=\"primary\" ring />\n *\n * @example Small gray avatar with custom icon\n * <UiAvatar size=\"sm\" color=\"gray\" fallback-icon=\"mdi:account-group\" />\n */\nimport { computed } from 'vue'\nimport UiIcon from '../icons/Icon.vue'\nconst props = defineProps({\n /**\n * Image source URL. When empty, the fallback icon is shown.\n * @type {string}\n * @default ''\n */\n src: { type: String, default: '' },\n\n /**\n * Alt text for the avatar image (accessibility).\n * @type {string}\n * @default 'Avatar'\n */\n alt: { type: String, default: 'Avatar' },\n\n /**\n * Avatar size controlling width, height, and icon dimensions.\n * @type {string}\n * @default 'md'\n * @values 'xs' (24px) | 'sm' (32px) | 'md' (36px) | 'lg' (48px) | 'xl' (64px)\n */\n size: { type: String, default: 'md' },\n\n /**\n * MDI icon name used when no image src is provided.\n * @type {string}\n * @default 'mdi:account'\n */\n fallbackIcon: { type: String, default: 'mdi:account' },\n\n /**\n * Background color theme for the fallback icon state.\n * @type {string}\n * @default 'primary'\n * @values 'primary' | 'gray'\n */\n color: { type: String, default: 'primary' },\n\n /**\n * Show a ring border around the avatar for emphasis.\n * @type {boolean}\n * @default false\n */\n ring: { type: Boolean, default: false },\n})\n\nconst sizeClass = computed(() => {\n const map = { xs: 'w-6 h-6', sm: 'w-8 h-8', md: 'w-9 h-9', lg: 'w-12 h-12', xl: 'w-16 h-16' }\n return map[props.size] || map.md\n})\n\nconst iconSizeClass = computed(() => {\n const map = { xs: 'w-3 h-3', sm: 'w-4 h-4', md: 'w-5 h-5', lg: 'w-6 h-6', xl: 'w-8 h-8' }\n return map[props.size] || map.md\n})\n\n// Only apply background color when showing the fallback icon (not when an image is loaded)\nconst bgClass = computed(() => {\n if (props.src) return ''\n const map = {\n primary: 'bg-primary-100 dark:bg-primary-900/30 text-primary-600 dark:text-primary-400',\n gray: 'bg-gray-200 dark:bg-gray-700 text-gray-500 dark:text-gray-400',\n }\n return map[props.color] || map.primary\n})\n\nconst ringClass = computed(() =>\n props.ring ? 'ring-2 ring-primary-200 dark:ring-primary-800 shadow-sm' : '',\n)\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8BA,MAAM,QAAQ;EA8Cd,MAAM,YAAY,eAAe;GAC/B,MAAM,MAAM;IAAE,IAAI;IAAW,IAAI;IAAW,IAAI;IAAW,IAAI;IAAa,IAAI;GAAY;GAC5F,OAAO,IAAI,MAAM,SAAS,IAAI;EAChC,CAAC;EAED,MAAM,gBAAgB,eAAe;GACnC,MAAM,MAAM;IAAE,IAAI;IAAW,IAAI;IAAW,IAAI;IAAW,IAAI;IAAW,IAAI;GAAU;GACxF,OAAO,IAAI,MAAM,SAAS,IAAI;EAChC,CAAC;EAGD,MAAM,UAAU,eAAe;GAC7B,IAAI,MAAM,KAAK,OAAO;GACtB,MAAM,MAAM;IACV,SAAS;IACT,MAAM;GACR;GACA,OAAO,IAAI,MAAM,UAAU,IAAI;EACjC,CAAC;EAED,MAAM,YAAY,eAChB,MAAM,OAAO,4DAA4D,EAC3E;;GAhGE,OAAA,UAAA,GAAA,mBAMM,OAAA,EALJ,OAAK,eAAA,CAAC,0EAAwE;IACrE,UAAA;IAAW,QAAA;IAAS,UAAA;GAAS,CAAA,CAAA,EAAA,GAAA,CAE3B,QAAA,OAAX,UAAA,GAAA,mBAA2E,OAAA;;IAA1D,KAAK,QAAA;IAAM,KAAK,QAAA;IAAK,OAAM;GAC5C,GAAA,MAAA,GAAA,UAAA,MAAA,UAAA,GAAA,YAA6D,aAAA;;IAA7C,MAAM,QAAA;IAAe,OAAK,eAAE,cAAA,KAAa"}
1
+ {"version":3,"file":"Avatar.js","names":[],"sources":["../../src/components/Avatar.vue"],"sourcesContent":["<template>\n <!-- Circular avatar container with an image, initials or a fallback icon -->\n <div\n class=\"rounded-full flex items-center justify-center overflow-hidden shrink-0\"\n :class=\"[sizeClass, bgClass, ringClass]\"\n :role=\"showImage ? undefined : 'img'\"\n :aria-label=\"showImage ? undefined : alt\"\n >\n <img\n v-if=\"showImage\"\n ref=\"imgRef\"\n :src=\"src\"\n :alt=\"alt\"\n class=\"w-full h-full object-cover\"\n @error=\"failed = true\"\n />\n <span\n v-else-if=\"shownInitials\"\n class=\"font-semibold leading-none tracking-tight select-none\"\n :class=\"textSizeClass\"\n aria-hidden=\"true\"\n >{{ shownInitials }}</span\n >\n <UiIcon v-else :name=\"fallbackIcon\" :class=\"iconSizeClass\" aria-hidden=\"true\" />\n </div>\n</template>\n\n<script setup>\n/**\n * UiAvatar — Circular avatar component displaying an image, initials or a fallback icon.\n *\n * When a `src` URL is provided, renders a cover-fit image; if the image fails\n * to load, it falls back rather than showing a broken-image glyph. Without an\n * image it shows `initials` (at most two characters, upper-cased), and without\n * those a configurable fallback icon, on a colored background. Supports five\n * sizes, two color themes for the fallback state, and an optional ring border.\n *\n * Without an image the avatar is exposed as `role=\"img\"` named by `alt`, so\n * pass the person's name there rather than the default.\n *\n * @example Image avatar\n * <UiAvatar src=\"/img/user.jpg\" alt=\"Jane Doe\" size=\"lg\" />\n *\n * @example Initials\n * <UiAvatar initials=\"JD\" alt=\"Jane Doe\" />\n *\n * @example Fallback icon avatar with ring\n * <UiAvatar size=\"md\" color=\"primary\" ring />\n *\n * @example Small gray avatar with custom icon\n * <UiAvatar size=\"sm\" color=\"gray\" fallback-icon=\"mdi:account-group\" />\n */\nimport { computed, onMounted, ref, watch } from 'vue'\nimport UiIcon from '../icons/Icon.vue'\n\nconst props = defineProps({\n /**\n * Image source URL. When empty (or it fails to load), initials or the\n * fallback icon are shown.\n * @type {string}\n * @default ''\n */\n src: { type: String, default: '' },\n /**\n * Alt text for the avatar image (accessibility), and the accessible name\n * when initials or the icon are shown.\n * @type {string}\n * @default 'Avatar'\n */\n alt: { type: String, default: 'Avatar' },\n /**\n * Initials shown when there is no image. Trimmed to two characters and\n * upper-cased.\n * @type {string}\n * @default ''\n */\n initials: { type: String, default: '' },\n /**\n * Avatar size controlling width, height, and icon dimensions.\n * @type {string}\n * @default 'md'\n * @values 'xs' (24px) | 'sm' (32px) | 'md' (36px) | 'lg' (48px) | 'xl' (64px)\n */\n size: { type: String, default: 'md' },\n /**\n * MDI icon name used when there is neither an image nor initials.\n * @type {string}\n * @default 'mdi:account'\n */\n fallbackIcon: { type: String, default: 'mdi:account' },\n /**\n * Background color theme for the fallback icon state.\n * @type {string}\n * @default 'primary'\n * @values 'primary' | 'gray'\n */\n color: { type: String, default: 'primary' },\n /**\n * Show a ring border around the avatar for emphasis.\n * @type {boolean}\n * @default false\n */\n ring: { type: Boolean, default: false },\n})\n\n// A failed load falls back to initials or the icon; a new src retries.\nconst failed = ref(false)\nconst imgRef = ref(null)\nwatch(\n () => props.src,\n () => (failed.value = false),\n)\n// Server-rendered images can fail before hydration attaches `@error`, so the\n// event is never seen. Check once on mount for an image that already failed.\nonMounted(() => {\n const img = imgRef.value\n if (img && img.complete && img.naturalWidth === 0) failed.value = true\n})\nconst showImage = computed(() => !!props.src && !failed.value)\n\nconst shownInitials = computed(() => [...props.initials.trim()].slice(0, 2).join('').toUpperCase())\n\nconst sizeClass = computed(() => {\n const map = { xs: 'w-6 h-6', sm: 'w-8 h-8', md: 'w-9 h-9', lg: 'w-12 h-12', xl: 'w-16 h-16' }\n return map[props.size] || map.md\n})\n\nconst iconSizeClass = computed(() => {\n const map = { xs: 'w-3 h-3', sm: 'w-4 h-4', md: 'w-5 h-5', lg: 'w-6 h-6', xl: 'w-8 h-8' }\n return map[props.size] || map.md\n})\n\nconst textSizeClass = computed(() => {\n const map = { xs: 'text-[10px]', sm: 'text-xs', md: 'text-sm', lg: 'text-base', xl: 'text-xl' }\n return map[props.size] || map.md\n})\n\n// Only apply background color when not showing an image\nconst bgClass = computed(() => {\n if (showImage.value) return ''\n const map = {\n primary: 'bg-primary-100 dark:bg-primary-900/30 text-primary-600 dark:text-primary-400',\n gray: 'bg-gray-200 dark:bg-gray-700 text-gray-500 dark:text-gray-400',\n }\n return map[props.color] || map.primary\n})\n\nconst ringClass = computed(() =>\n props.ring ? 'ring-2 ring-primary-200 dark:ring-primary-800 shadow-sm' : '',\n)\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuDA,MAAM,QAAQ;EAmDd,MAAM,SAAS,IAAI,KAAK;EACxB,MAAM,SAAS,IAAI,IAAI;EACvB,YACQ,MAAM,WACL,OAAO,QAAQ,KACxB;EAGA,gBAAgB;GACd,MAAM,MAAM,OAAO;GACnB,IAAI,OAAO,IAAI,YAAY,IAAI,iBAAiB,GAAG,OAAO,QAAQ;EACpE,CAAC;EACD,MAAM,YAAY,eAAe,CAAC,CAAC,MAAM,OAAO,CAAC,OAAO,KAAK;EAE7D,MAAM,gBAAgB,eAAe,CAAC,GAAG,MAAM,SAAS,KAAK,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,YAAY,CAAC;EAElG,MAAM,YAAY,eAAe;GAC/B,MAAM,MAAM;IAAE,IAAI;IAAW,IAAI;IAAW,IAAI;IAAW,IAAI;IAAa,IAAI;GAAY;GAC5F,OAAO,IAAI,MAAM,SAAS,IAAI;EAChC,CAAC;EAED,MAAM,gBAAgB,eAAe;GACnC,MAAM,MAAM;IAAE,IAAI;IAAW,IAAI;IAAW,IAAI;IAAW,IAAI;IAAW,IAAI;GAAU;GACxF,OAAO,IAAI,MAAM,SAAS,IAAI;EAChC,CAAC;EAED,MAAM,gBAAgB,eAAe;GACnC,MAAM,MAAM;IAAE,IAAI;IAAe,IAAI;IAAW,IAAI;IAAW,IAAI;IAAa,IAAI;GAAU;GAC9F,OAAO,IAAI,MAAM,SAAS,IAAI;EAChC,CAAC;EAGD,MAAM,UAAU,eAAe;GAC7B,IAAI,UAAU,OAAO,OAAO;GAC5B,MAAM,MAAM;IACV,SAAS;IACT,MAAM;GACR;GACA,OAAO,IAAI,MAAM,UAAU,IAAI;EACjC,CAAC;EAED,MAAM,YAAY,eAChB,MAAM,OAAO,4DAA4D,EAC3E;;GAnJE,OAAA,UAAA,GAAA,mBAsBM,OAAA;IArBJ,OAAK,eAAA,CAAC,0EAAwE;KACrE,UAAA;KAAW,QAAA;KAAS,UAAA;IAAS,CAAA,CAAA;IACrC,MAAM,UAAA,QAAY,KAAA,IAAS;IAC3B,cAAY,UAAA,QAAY,KAAA,IAAY,QAAA;GAG7B,GAAA,CAAA,UAAA,SADR,UAAA,GAAA,mBAOE,OAAA;;IALI,SAAA;IAAJ,KAAI;IACH,KAAK,QAAA;IACL,KAAK,QAAA;IACN,OAAM;IACL,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,OAAA,QAAM;GAGH,GAAA,MAAA,IAAA,UAAA,KAAA,cAAA,SADb,UAAA,GAAA,mBAMC,QAAA;;IAJC,OAAK,eAAA,CAAC,yDACE,cAAA,KAAa,CAAA;IACrB,eAAY;GACR,GAAA,gBAAA,cAAA,KAAa,GAAA,CAAA,MAEnB,UAAA,GAAA,YAAgF,aAAA;;IAAhE,MAAM,QAAA;IAAe,OAAK,eAAE,cAAA,KAAa;IAAE,eAAY"}