numori-ui 0.5.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/README.md +9 -1
  3. package/dist/components/Avatar.js +71 -19
  4. package/dist/components/Avatar.js.map +1 -1
  5. package/dist/components/Dropdown.js +3 -1
  6. package/dist/components/Dropdown.js.map +1 -1
  7. package/dist/components/Modal.js +61 -4
  8. package/dist/components/Modal.js.map +1 -1
  9. package/dist/components/Prompt.js +11 -6
  10. package/dist/components/Prompt.js.map +1 -1
  11. package/dist/components/Select.js +1 -1
  12. package/dist/components/Select.js.map +1 -1
  13. package/dist/components/Skeleton.js +122 -0
  14. package/dist/components/Skeleton.js.map +1 -0
  15. package/dist/components/SplitPane.js +264 -0
  16. package/dist/components/SplitPane.js.map +1 -0
  17. package/dist/components/Tree.js +417 -0
  18. package/dist/components/Tree.js.map +1 -0
  19. package/dist/components/VirtualList.js +292 -0
  20. package/dist/components/VirtualList.js.map +1 -0
  21. package/dist/components/index.js +29 -22
  22. package/dist/components/index.js.map +1 -1
  23. package/dist/icons/mdi.js +2 -0
  24. package/dist/icons/mdi.js.map +1 -1
  25. package/dist/index.d.ts +4 -0
  26. package/dist/index.js +15 -11
  27. package/dist/index.js.map +1 -1
  28. package/dist/internal/focusTrap.js +163 -0
  29. package/dist/internal/focusTrap.js.map +1 -0
  30. package/dist/manifest.js +5 -1
  31. package/dist/manifest.js.map +1 -1
  32. package/package.json +1 -1
  33. package/src/components/Avatar.vue +69 -18
  34. package/src/components/Dropdown.vue +4 -1
  35. package/src/components/Modal.vue +51 -3
  36. package/src/components/Prompt.vue +14 -3
  37. package/src/components/Select.vue +1 -1
  38. package/src/components/Skeleton.vue +91 -0
  39. package/src/components/SplitPane.vue +264 -0
  40. package/src/components/Tree.vue +428 -0
  41. package/src/components/VirtualList.vue +250 -0
  42. package/src/components/index.js +12 -1
  43. package/src/icons/mdi.js +2 -0
  44. package/src/internal/focusTrap.js +185 -0
  45. package/src/manifest.js +4 -0
package/CHANGELOG.md CHANGED
@@ -7,6 +7,60 @@ 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
+
10
64
  ## [0.5.0] — 2026-11-30
11
65
 
12
66
  Application and dashboard building blocks. Eleven new components cover the frame
package/README.md CHANGED
@@ -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), `UiPrompt`,
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),
@@ -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"}
@@ -128,7 +128,9 @@ var _sfc_main = {
128
128
  };
129
129
  onClickOutside(containerRef, close);
130
130
  useEventListener(globalThis.document, "keydown", (e) => {
131
- if (e.key === "Escape") close();
131
+ if (e.key !== "Escape" || !isOpen.value) return;
132
+ e.preventDefault();
133
+ close();
132
134
  });
133
135
  __expose({
134
136
  isOpen,
@@ -1 +1 @@
1
- {"version":3,"file":"Dropdown.js","names":[],"sources":["../../src/components/Dropdown.vue"],"sourcesContent":["<template>\n <div ref=\"containerRef\" class=\"relative\">\n <!-- Trigger slot: receives { open, toggle } for controlling the dropdown -->\n <slot name=\"trigger\" :open=\"isOpen\" :toggle=\"toggle\" />\n\n <!-- Dropdown panel with animated enter/leave transitions -->\n <Transition\n :enter-active-class=\"transitionClasses.enterActive\"\n :enter-from-class=\"transitionClasses.enterFrom\"\n :enter-to-class=\"transitionClasses.enterTo\"\n :leave-active-class=\"transitionClasses.leaveActive\"\n :leave-from-class=\"transitionClasses.leaveFrom\"\n :leave-to-class=\"transitionClasses.leaveTo\"\n >\n <div v-show=\"isOpen\" :class=\"panelClasses\" :style=\"{ transformOrigin: panelOrigin }\">\n <slot :close=\"close\" />\n </div>\n </Transition>\n </div>\n</template>\n\n<script setup>\n/**\n * UiDropdown — Headless dropdown menu with configurable alignment, direction, and transitions.\n *\n * Uses a trigger slot that receives `open` state and `toggle` function, and a default\n * slot for menu content that receives a `close` function. Closes on outside click and\n * Escape key. Supports both downward and upward drop directions with matching transitions.\n * Exposes `isOpen`, `toggle()`, and `close()` for programmatic control.\n *\n * @example Basic dropdown with button trigger\n * <UiDropdown>\n * <template #trigger=\"{ toggle }\">\n * <UiButton @click=\"toggle\">Menu</UiButton>\n * </template>\n * <UiDropdownItem icon=\"mdi:pencil\" label=\"Edit\" @click=\"edit\" />\n * <UiDropdownItem icon=\"mdi:trash-can\" label=\"Delete\" color=\"red\" @click=\"del\" />\n * </UiDropdown>\n *\n * @example Right-aligned, drop-up\n * <UiDropdown align=\"right\" drop=\"up\" width=\"w-48\">\n * <template #trigger=\"{ toggle }\">\n * <UiButton variant=\"ghost\" icon-only @click=\"toggle\">\n * <UiIcon name=\"mdi:dots-vertical\" class=\"w-5 h-5\" />\n * </UiButton>\n * </template>\n * <slot />\n * </UiDropdown>\n *\n * @emits {void} open — Emitted when the dropdown opens\n * @emits {void} close — Emitted when the dropdown closes\n *\n * @slot trigger — Trigger element that opens the dropdown. Receives { open: boolean, toggle: Function }\n * @slot default — Dropdown menu content. Receives { close: Function }\n *\n * @see UiDropdownItem — Standard menu item for use inside this dropdown\n * @see UiDropdownSubmenu — Nested submenu for this dropdown\n */\nimport { ref, computed } from 'vue'\nimport { onClickOutside } from '../composables/onClickOutside.js'\nimport { useEventListener } from '../composables/useEventListener.js'\nimport { MENU_PANEL_CLASS } from '../internal/menu.js'\nconst props = defineProps({\n /**\n * Width class applied to the dropdown panel.\n * @type {string}\n * @default 'w-56'\n * @example 'w-48', 'w-64', 'w-72'\n */\n width: { type: String, default: 'w-56' },\n\n /**\n * Horizontal alignment of the panel relative to the trigger.\n * @type {string}\n * @default 'left'\n * @values 'left' | 'right'\n */\n align: { type: String, default: 'left' },\n\n /**\n * Drop direction — 'down' opens below the trigger, 'up' opens above.\n * @type {string}\n * @default 'down'\n * @values 'down' | 'up'\n */\n drop: { type: String, default: 'down' },\n\n /**\n * Override all default panel classes (bg, border, rounded, shadow).\n * When set, the built-in panel styling is completely replaced.\n * @type {string}\n * @default ''\n */\n panelClass: { type: String, default: '' },\n})\n\nconst emit = defineEmits(['open', 'close'])\n\nconst isOpen = ref(false)\nconst containerRef = ref(null)\n\n// Build panel positioning/styling classes, or use custom override\nconst panelClasses = computed(() => {\n if (props.panelClass) return props.panelClass\n const align = props.align === 'right' ? 'right-0' : 'left-0'\n const dropDir = props.drop === 'up' ? 'bottom-full mb-1' : 'mt-1'\n // `p-1` (not just `py-1`) insets the rows so their rounded hover highlight\n // reads as a chip with breathing room from the panel edge.\n return `absolute z-50 ${MENU_PANEL_CLASS} p-1 ${props.width} ${align} ${dropDir}`\n})\n\n// Inline transform-origin (not a Tailwind class, so it needs no build step to\n// take effect): the panel scales in from the corner nearest the trigger rather\n// than drifting in from its centre.\nconst panelOrigin = computed(() => {\n const y = props.drop === 'up' ? 'bottom' : 'top'\n const x = props.align === 'right' ? 'right' : 'left'\n return `${y} ${x}`\n})\n\n// Use slide-up transition for drop=\"up\", scale transition for drop=\"down\"\nconst transitionClasses = computed(() => {\n if (props.drop === 'up') {\n return {\n enterActive: 'transition ease-out duration-150',\n enterFrom: 'opacity-0 translate-y-1',\n enterTo: 'opacity-100 translate-y-0',\n leaveActive: 'transition ease-in duration-100',\n leaveFrom: 'opacity-100 translate-y-0',\n leaveTo: 'opacity-0 translate-y-1',\n }\n }\n return {\n enterActive: 'transition duration-100 ease-out',\n enterFrom: 'opacity-0 scale-95',\n enterTo: 'opacity-100 scale-100',\n leaveActive: 'transition duration-75 ease-in',\n leaveFrom: 'opacity-100 scale-100',\n leaveTo: 'opacity-0 scale-95',\n }\n})\n\nconst toggle = () => {\n isOpen.value = !isOpen.value\n emit(isOpen.value ? 'open' : 'close')\n}\n\nconst close = () => {\n if (isOpen.value) {\n isOpen.value = false\n emit('close')\n }\n}\n\nonClickOutside(containerRef, close)\n\nuseEventListener(globalThis.document, 'keydown', (e) => {\n if (e.key === 'Escape') close()\n})\n\ndefineExpose({ isOpen, toggle, close })\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8DA,MAAM,QAAQ;EAkCd,MAAM,OAAO;EAEb,MAAM,SAAS,IAAI,KAAK;EACxB,MAAM,eAAe,IAAI,IAAI;EAG7B,MAAM,eAAe,eAAe;GAClC,IAAI,MAAM,YAAY,OAAO,MAAM;GACnC,MAAM,QAAQ,MAAM,UAAU,UAAU,YAAY;GACpD,MAAM,UAAU,MAAM,SAAS,OAAO,qBAAqB;GAG3D,OAAO,iBAAiB,iBAAiB,OAAO,MAAM,MAAM,GAAG,MAAM,GAAG;EAC1E,CAAC;EAKD,MAAM,cAAc,eAAe;GAGjC,OAAO,GAFG,MAAM,SAAS,OAAO,WAAW,MAE/B,GADF,MAAM,UAAU,UAAU,UAAU;EAEhD,CAAC;EAGD,MAAM,oBAAoB,eAAe;GACvC,IAAI,MAAM,SAAS,MACjB,OAAO;IACL,aAAa;IACb,WAAW;IACX,SAAS;IACT,aAAa;IACb,WAAW;IACX,SAAS;GACX;GAEF,OAAO;IACL,aAAa;IACb,WAAW;IACX,SAAS;IACT,aAAa;IACb,WAAW;IACX,SAAS;GACX;EACF,CAAC;EAED,MAAM,eAAe;GACnB,OAAO,QAAQ,CAAC,OAAO;GACvB,KAAK,OAAO,QAAQ,SAAS,OAAO;EACtC;EAEA,MAAM,cAAc;GAClB,IAAI,OAAO,OAAO;IAChB,OAAO,QAAQ;IACf,KAAK,OAAO;GACd;EACF;EAEA,eAAe,cAAc,KAAK;EAElC,iBAAiB,WAAW,UAAU,YAAY,MAAM;GACtD,IAAI,EAAE,QAAQ,UAAU,MAAM;EAChC,CAAC;EAED,SAAa;GAAE;GAAQ;GAAQ;EAAM,CAAC;;GA/JpC,OAAA,UAAA,GAAA,mBAiBM,OAAA;IAjBG,SAAA;IAAJ,KAAI;IAAe,OAAM;GAE5B,GAAA,CAAA,WAAuD,KAAA,QAAA,WAAA;IAAjC,MAAM,OAAA;IAAiB;GAG7C,CAAA,GAAA,YAWa,YAAA;IAVV,sBAAoB,kBAAA,MAAkB;IACtC,oBAAkB,kBAAA,MAAkB;IACpC,kBAAgB,kBAAA,MAAkB;IAClC,sBAAoB,kBAAA,MAAkB;IACtC,oBAAkB,kBAAA,MAAkB;IACpC,kBAAgB,kBAAA,MAAkB;;IAEnC,SAAA,cAEM,CAFN,eAAA,mBAEM,OAAA;KAFgB,OAAK,eAAE,aAAA,KAAY;KAAG,OAAK,eAAA,EAAA,iBAAqB,YAAA,MAAW,CAAA;IAC/E,GAAA,CAAA,WAAuB,KAAA,QAAA,WAAA,EAAT,MAAK,CAAA,CAAA,GAAA,CAAA,GAAA,CADR,CAAA,OAAA,OAAA,KAAM,CAAA,CAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"Dropdown.js","names":[],"sources":["../../src/components/Dropdown.vue"],"sourcesContent":["<template>\n <div ref=\"containerRef\" class=\"relative\">\n <!-- Trigger slot: receives { open, toggle } for controlling the dropdown -->\n <slot name=\"trigger\" :open=\"isOpen\" :toggle=\"toggle\" />\n\n <!-- Dropdown panel with animated enter/leave transitions -->\n <Transition\n :enter-active-class=\"transitionClasses.enterActive\"\n :enter-from-class=\"transitionClasses.enterFrom\"\n :enter-to-class=\"transitionClasses.enterTo\"\n :leave-active-class=\"transitionClasses.leaveActive\"\n :leave-from-class=\"transitionClasses.leaveFrom\"\n :leave-to-class=\"transitionClasses.leaveTo\"\n >\n <div v-show=\"isOpen\" :class=\"panelClasses\" :style=\"{ transformOrigin: panelOrigin }\">\n <slot :close=\"close\" />\n </div>\n </Transition>\n </div>\n</template>\n\n<script setup>\n/**\n * UiDropdown — Headless dropdown menu with configurable alignment, direction, and transitions.\n *\n * Uses a trigger slot that receives `open` state and `toggle` function, and a default\n * slot for menu content that receives a `close` function. Closes on outside click and\n * Escape key. Supports both downward and upward drop directions with matching transitions.\n * Exposes `isOpen`, `toggle()`, and `close()` for programmatic control.\n *\n * @example Basic dropdown with button trigger\n * <UiDropdown>\n * <template #trigger=\"{ toggle }\">\n * <UiButton @click=\"toggle\">Menu</UiButton>\n * </template>\n * <UiDropdownItem icon=\"mdi:pencil\" label=\"Edit\" @click=\"edit\" />\n * <UiDropdownItem icon=\"mdi:trash-can\" label=\"Delete\" color=\"red\" @click=\"del\" />\n * </UiDropdown>\n *\n * @example Right-aligned, drop-up\n * <UiDropdown align=\"right\" drop=\"up\" width=\"w-48\">\n * <template #trigger=\"{ toggle }\">\n * <UiButton variant=\"ghost\" icon-only @click=\"toggle\">\n * <UiIcon name=\"mdi:dots-vertical\" class=\"w-5 h-5\" />\n * </UiButton>\n * </template>\n * <slot />\n * </UiDropdown>\n *\n * @emits {void} open — Emitted when the dropdown opens\n * @emits {void} close — Emitted when the dropdown closes\n *\n * @slot trigger — Trigger element that opens the dropdown. Receives { open: boolean, toggle: Function }\n * @slot default — Dropdown menu content. Receives { close: Function }\n *\n * @see UiDropdownItem — Standard menu item for use inside this dropdown\n * @see UiDropdownSubmenu — Nested submenu for this dropdown\n */\nimport { ref, computed } from 'vue'\nimport { onClickOutside } from '../composables/onClickOutside.js'\nimport { useEventListener } from '../composables/useEventListener.js'\nimport { MENU_PANEL_CLASS } from '../internal/menu.js'\nconst props = defineProps({\n /**\n * Width class applied to the dropdown panel.\n * @type {string}\n * @default 'w-56'\n * @example 'w-48', 'w-64', 'w-72'\n */\n width: { type: String, default: 'w-56' },\n\n /**\n * Horizontal alignment of the panel relative to the trigger.\n * @type {string}\n * @default 'left'\n * @values 'left' | 'right'\n */\n align: { type: String, default: 'left' },\n\n /**\n * Drop direction — 'down' opens below the trigger, 'up' opens above.\n * @type {string}\n * @default 'down'\n * @values 'down' | 'up'\n */\n drop: { type: String, default: 'down' },\n\n /**\n * Override all default panel classes (bg, border, rounded, shadow).\n * When set, the built-in panel styling is completely replaced.\n * @type {string}\n * @default ''\n */\n panelClass: { type: String, default: '' },\n})\n\nconst emit = defineEmits(['open', 'close'])\n\nconst isOpen = ref(false)\nconst containerRef = ref(null)\n\n// Build panel positioning/styling classes, or use custom override\nconst panelClasses = computed(() => {\n if (props.panelClass) return props.panelClass\n const align = props.align === 'right' ? 'right-0' : 'left-0'\n const dropDir = props.drop === 'up' ? 'bottom-full mb-1' : 'mt-1'\n // `p-1` (not just `py-1`) insets the rows so their rounded hover highlight\n // reads as a chip with breathing room from the panel edge.\n return `absolute z-50 ${MENU_PANEL_CLASS} p-1 ${props.width} ${align} ${dropDir}`\n})\n\n// Inline transform-origin (not a Tailwind class, so it needs no build step to\n// take effect): the panel scales in from the corner nearest the trigger rather\n// than drifting in from its centre.\nconst panelOrigin = computed(() => {\n const y = props.drop === 'up' ? 'bottom' : 'top'\n const x = props.align === 'right' ? 'right' : 'left'\n return `${y} ${x}`\n})\n\n// Use slide-up transition for drop=\"up\", scale transition for drop=\"down\"\nconst transitionClasses = computed(() => {\n if (props.drop === 'up') {\n return {\n enterActive: 'transition ease-out duration-150',\n enterFrom: 'opacity-0 translate-y-1',\n enterTo: 'opacity-100 translate-y-0',\n leaveActive: 'transition ease-in duration-100',\n leaveFrom: 'opacity-100 translate-y-0',\n leaveTo: 'opacity-0 translate-y-1',\n }\n }\n return {\n enterActive: 'transition duration-100 ease-out',\n enterFrom: 'opacity-0 scale-95',\n enterTo: 'opacity-100 scale-100',\n leaveActive: 'transition duration-75 ease-in',\n leaveFrom: 'opacity-100 scale-100',\n leaveTo: 'opacity-0 scale-95',\n }\n})\n\nconst toggle = () => {\n isOpen.value = !isOpen.value\n emit(isOpen.value ? 'open' : 'close')\n}\n\nconst close = () => {\n if (isOpen.value) {\n isOpen.value = false\n emit('close')\n }\n}\n\nonClickOutside(containerRef, close)\n\nuseEventListener(globalThis.document, 'keydown', (e) => {\n if (e.key !== 'Escape' || !isOpen.value) return\n // Claim the key so an enclosing UiModal does not close too.\n e.preventDefault()\n close()\n})\n\ndefineExpose({ isOpen, toggle, close })\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8DA,MAAM,QAAQ;EAkCd,MAAM,OAAO;EAEb,MAAM,SAAS,IAAI,KAAK;EACxB,MAAM,eAAe,IAAI,IAAI;EAG7B,MAAM,eAAe,eAAe;GAClC,IAAI,MAAM,YAAY,OAAO,MAAM;GACnC,MAAM,QAAQ,MAAM,UAAU,UAAU,YAAY;GACpD,MAAM,UAAU,MAAM,SAAS,OAAO,qBAAqB;GAG3D,OAAO,iBAAiB,iBAAiB,OAAO,MAAM,MAAM,GAAG,MAAM,GAAG;EAC1E,CAAC;EAKD,MAAM,cAAc,eAAe;GAGjC,OAAO,GAFG,MAAM,SAAS,OAAO,WAAW,MAE/B,GADF,MAAM,UAAU,UAAU,UAAU;EAEhD,CAAC;EAGD,MAAM,oBAAoB,eAAe;GACvC,IAAI,MAAM,SAAS,MACjB,OAAO;IACL,aAAa;IACb,WAAW;IACX,SAAS;IACT,aAAa;IACb,WAAW;IACX,SAAS;GACX;GAEF,OAAO;IACL,aAAa;IACb,WAAW;IACX,SAAS;IACT,aAAa;IACb,WAAW;IACX,SAAS;GACX;EACF,CAAC;EAED,MAAM,eAAe;GACnB,OAAO,QAAQ,CAAC,OAAO;GACvB,KAAK,OAAO,QAAQ,SAAS,OAAO;EACtC;EAEA,MAAM,cAAc;GAClB,IAAI,OAAO,OAAO;IAChB,OAAO,QAAQ;IACf,KAAK,OAAO;GACd;EACF;EAEA,eAAe,cAAc,KAAK;EAElC,iBAAiB,WAAW,UAAU,YAAY,MAAM;GACtD,IAAI,EAAE,QAAQ,YAAY,CAAC,OAAO,OAAO;GAEzC,EAAE,eAAe;GACjB,MAAM;EACR,CAAC;EAED,SAAa;GAAE;GAAQ;GAAQ;EAAM,CAAC;;GAlKpC,OAAA,UAAA,GAAA,mBAiBM,OAAA;IAjBG,SAAA;IAAJ,KAAI;IAAe,OAAM;GAE5B,GAAA,CAAA,WAAuD,KAAA,QAAA,WAAA;IAAjC,MAAM,OAAA;IAAiB;GAG7C,CAAA,GAAA,YAWa,YAAA;IAVV,sBAAoB,kBAAA,MAAkB;IACtC,oBAAkB,kBAAA,MAAkB;IACpC,kBAAgB,kBAAA,MAAkB;IAClC,sBAAoB,kBAAA,MAAkB;IACtC,oBAAkB,kBAAA,MAAkB;IACpC,kBAAgB,kBAAA,MAAkB;;IAEnC,SAAA,cAEM,CAFN,eAAA,mBAEM,OAAA;KAFgB,OAAK,eAAE,aAAA,KAAY;KAAG,OAAK,eAAA,EAAA,iBAAqB,YAAA,MAAW,CAAA;IAC/E,GAAA,CAAA,WAAuB,KAAA,QAAA,WAAA,EAAT,MAAK,CAAA,CAAA,GAAA,CAAA,GAAA,CADR,CAAA,OAAA,OAAA,KAAM,CAAA,CAAA,CAAA,CAAA"}
@@ -1,6 +1,8 @@
1
1
  import { useBackButton } from "../composables/useBackButton.js";
2
- import { Teleport, Transition, computed, createBlock, createCommentVNode, createElementBlock, createVNode, normalizeClass, onBeforeUnmount, openBlock, renderSlot, watch, withCtx, withModifiers } from "vue";
2
+ import { useFocusTrap } from "../internal/focusTrap.js";
3
+ import { Teleport, Transition, computed, createBlock, createCommentVNode, createElementBlock, createVNode, normalizeClass, onBeforeUnmount, openBlock, ref, renderSlot, watch, withCtx, withModifiers } from "vue";
3
4
  //#region src/components/Modal.vue
5
+ var _hoisted_1 = ["aria-label", "aria-labelledby"];
4
6
  var _sfc_main = {
5
7
  __name: "Modal",
6
8
  props: {
@@ -68,6 +70,35 @@ var _sfc_main = {
68
70
  padding: {
69
71
  type: String,
70
72
  default: "md:p-4"
73
+ },
74
+ /**
75
+ * Accessible name for the dialog. Prefer `labelledby` when the content has a
76
+ * visible heading.
77
+ * @type {string}
78
+ * @default ''
79
+ */
80
+ label: {
81
+ type: String,
82
+ default: ""
83
+ },
84
+ /**
85
+ * Id of the element that names the dialog, usually its heading.
86
+ * @type {string}
87
+ * @default ''
88
+ */
89
+ labelledby: {
90
+ type: String,
91
+ default: ""
92
+ },
93
+ /**
94
+ * Whether Escape closes the modal. Ignored (treated as false) when
95
+ * `persistent` is set.
96
+ * @type {boolean}
97
+ * @default true
98
+ */
99
+ closeOnEscape: {
100
+ type: Boolean,
101
+ default: true
71
102
  }
72
103
  },
73
104
  emits: ["close"],
@@ -79,6 +110,13 @@ var _sfc_main = {
79
110
  * (xs through 5xl and full-screen), persistent mode to prevent backdrop-click dismissal,
80
111
  * and customizable z-index and padding. The panel uses a scale+fade transition on enter/leave.
81
112
  *
113
+ * The panel is a real dialog: `role="dialog"` and `aria-modal="true"`, named by
114
+ * `label` or `labelledby`. While open, focus moves into the panel (unless
115
+ * something inside already has it), Tab and Shift+Tab wrap within it, Escape
116
+ * closes it (unless `persistent` or `close-on-escape` is false), and focus
117
+ * returns to whatever opened it. Stacked modals behave: only the top one
118
+ * responds to Tab and Escape.
119
+ *
82
120
  * @example Basic modal
83
121
  * <UiModal :show="isOpen" @close="isOpen = false">
84
122
  * <div class="p-6">Hello!</div>
@@ -100,12 +138,24 @@ var _sfc_main = {
100
138
  * <div class="p-6">Centered on all screens</div>
101
139
  * </UiModal>
102
140
  *
103
- * @emits {void} close — Emitted when the modal should close (backdrop click or programmatic)
141
+ * @example Named by its heading
142
+ * <UiModal :show="isOpen" labelledby="settings-title" @close="isOpen = false">
143
+ * <h2 id="settings-title">Settings</h2>
144
+ * </UiModal>
145
+ *
146
+ * @emits {void} close — Emitted when the modal should close (backdrop click, Escape,
147
+ * the Android back button, or programmatic)
104
148
  *
105
149
  * @slot default — Modal content
106
150
  */
107
151
  const props = __props;
108
152
  const emit = __emit;
153
+ const panelRef = ref(null);
154
+ useFocusTrap(() => panelRef.value, {
155
+ active: () => props.show,
156
+ escape: () => props.closeOnEscape && !props.persistent,
157
+ onEscape: () => emit("close")
158
+ });
109
159
  const { register: registerBack, unregister: unregisterBack } = useBackButton();
110
160
  let backHandlerId = null;
111
161
  watch(() => props.show, (visible) => {
@@ -185,14 +235,21 @@ var _sfc_main = {
185
235
  }, {
186
236
  default: withCtx(() => [__props.show ? (openBlock(), createElementBlock("div", {
187
237
  key: 0,
188
- class: normalizeClass(["modal-panel bg-white dark:bg-gray-925 overflow-hidden flex flex-col", [
238
+ ref_key: "panelRef",
239
+ ref: panelRef,
240
+ role: "dialog",
241
+ "aria-modal": "true",
242
+ "aria-label": __props.labelledby ? void 0 : __props.label || void 0,
243
+ "aria-labelledby": __props.labelledby || void 0,
244
+ tabindex: "-1",
245
+ class: normalizeClass(["modal-panel bg-white dark:bg-gray-925 overflow-hidden flex flex-col focus:outline-none", [
189
246
  __props.panelClass,
190
247
  maxWidthClass.value,
191
248
  roundedClass.value,
192
249
  mobileLayoutClass.value
193
250
  ]]),
194
251
  onClick: _cache[0] || (_cache[0] = withModifiers(() => {}, ["stop"]))
195
- }, [renderSlot(_ctx.$slots, "default")], 2)) : createCommentVNode("", true)]),
252
+ }, [renderSlot(_ctx.$slots, "default")], 10, _hoisted_1)) : createCommentVNode("", true)]),
196
253
  _: 3
197
254
  })], 2)) : createCommentVNode("", true)]),
198
255
  _: 3
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.js","names":["$emit"],"sources":["../../src/components/Modal.vue"],"sourcesContent":["<template>\n <!-- Teleported to body to avoid z-index stacking context issues -->\n <Teleport to=\"body\">\n <!-- Backdrop overlay with fade transition -->\n <Transition\n enter-active-class=\"transition ease-out duration-200\"\n enter-from-class=\"opacity-0\"\n enter-to-class=\"opacity-100\"\n leave-active-class=\"transition ease-in duration-150\"\n leave-from-class=\"opacity-100\"\n leave-to-class=\"opacity-0\"\n >\n <div\n v-if=\"show\"\n class=\"fixed inset-0 flex items-center justify-center\"\n :class=\"[zClass, paddingClass, backdropClass]\"\n @click.self=\"!persistent && $emit('close')\"\n >\n <Transition\n enter-active-class=\"transition ease-out duration-300\"\n enter-from-class=\"opacity-0 scale-95\"\n enter-to-class=\"opacity-100 scale-100\"\n leave-active-class=\"transition ease-in duration-200\"\n leave-from-class=\"opacity-100 scale-100\"\n leave-to-class=\"opacity-0 scale-95\"\n appear\n >\n <div\n v-if=\"show\"\n class=\"modal-panel bg-white dark:bg-gray-925 overflow-hidden flex flex-col\"\n :class=\"[panelClass, maxWidthClass, roundedClass, mobileLayoutClass]\"\n @click.stop\n >\n <slot />\n </div>\n </Transition>\n </div>\n </Transition>\n </Teleport>\n</template>\n\n<script setup>\n/**\n * UiModal — Teleported modal dialog with backdrop, configurable max-width, and enter/leave transitions.\n *\n * Renders a centered overlay panel teleported to `<body>`. Supports ten max-width presets\n * (xs through 5xl and full-screen), persistent mode to prevent backdrop-click dismissal,\n * and customizable z-index and padding. The panel uses a scale+fade transition on enter/leave.\n *\n * @example Basic modal\n * <UiModal :show=\"isOpen\" @close=\"isOpen = false\">\n * <div class=\"p-6\">Hello!</div>\n * </UiModal>\n *\n * @example Large persistent modal\n * <UiModal :show=\"showEditor\" max-width=\"3xl\" persistent>\n * <ModalHeader @close=\"showEditor = false\" />\n * <div class=\"p-6\">Editor content</div>\n * </UiModal>\n *\n * @example Full-screen modal\n * <UiModal :show=\"showFull\" max-width=\"full\">\n * <div class=\"h-full\">Full screen content</div>\n * </UiModal>\n *\n * @example Non-fullscreen on mobile\n * <UiModal :show=\"isOpen\" :fullscreen-mobile=\"false\" @close=\"isOpen = false\">\n * <div class=\"p-6\">Centered on all screens</div>\n * </UiModal>\n *\n * @emits {void} close — Emitted when the modal should close (backdrop click or programmatic)\n *\n * @slot default — Modal content\n */\nimport { computed, watch, onBeforeUnmount } from 'vue'\nimport { useBackButton } from '../composables/useBackButton.js'\nconst props = defineProps({\n /**\n * Controls modal visibility. Use with v-model or :show + @close.\n * @type {boolean}\n * @default false\n */\n show: { type: Boolean, default: false },\n\n /**\n * Maximum width preset for the modal panel.\n * @type {string}\n * @default 'sm'\n * @values 'xs' (20rem) | 'sm' (24rem) | 'md' (28rem) | 'lg' (32rem) | 'xl' (36rem) | '2xl' (42rem) | '3xl' (48rem) | '4xl' (56rem) | '5xl' (64rem) | 'full'\n */\n maxWidth: { type: String, default: 'sm' },\n\n /**\n * Whether the modal goes fullscreen on mobile viewports.\n * When true, the panel fills the screen on mobile and respects safe area insets.\n * @type {boolean}\n * @default true\n */\n fullscreenMobile: { type: Boolean, default: true },\n\n /**\n * Persistent mode — prevents closing when clicking the backdrop overlay.\n * @type {boolean}\n * @default false\n */\n persistent: { type: Boolean, default: false },\n\n /**\n * Additional CSS classes applied to the modal panel element.\n * @type {string}\n * @default ''\n */\n panelClass: { type: String, default: '' },\n\n /**\n * Z-index class for the backdrop and modal layers.\n * @type {string}\n * @default 'z-50'\n */\n z: { type: String, default: 'z-50' },\n\n /**\n * Padding class around the modal panel (applied to the backdrop container).\n * @type {string}\n * @default 'md:p-4'\n */\n padding: { type: String, default: 'md:p-4' },\n})\n\nconst emit = defineEmits(['close'])\n\n// ── Back-button interception (Capacitor) ──\nconst { register: registerBack, unregister: unregisterBack } = useBackButton()\nlet backHandlerId = null\n\nwatch(\n () => props.show,\n (visible) => {\n if (visible) {\n backHandlerId = registerBack(() => {\n if (props.persistent) return false\n emit('close')\n return true\n })\n } else if (backHandlerId !== null) {\n unregisterBack(backHandlerId)\n backHandlerId = null\n }\n },\n { immediate: true },\n)\n\nonBeforeUnmount(() => {\n if (backHandlerId !== null) {\n unregisterBack(backHandlerId)\n backHandlerId = null\n }\n})\n\nconst zClass = computed(() => props.z)\nconst paddingClass = computed(() => props.padding)\n\nconst backdropClass = computed(() => {\n if (props.fullscreenMobile) {\n return 'bg-transparent md:bg-black/50'\n }\n return 'bg-black/50 p-4'\n})\n\nconst mobileLayoutClass = computed(() => {\n if (props.maxWidth === 'full') return 'fixed inset-0'\n\n if (props.fullscreenMobile) {\n return 'fixed inset-0 modal-panel--safe-area md:static md:inset-auto'\n }\n // Non-fullscreen on mobile: centered dialog with max-height\n return 'relative max-h-[calc(100vh-2rem)] md:static'\n})\n\nconst maxWidthClass = computed(() => {\n if (props.maxWidth === 'full') return 'w-full h-full'\n\n const map = {\n xs: 'md:max-w-xs',\n sm: 'md:max-w-sm',\n md: 'md:max-w-md',\n lg: 'md:max-w-lg',\n xl: 'md:max-w-xl',\n '2xl': 'md:max-w-2xl',\n '3xl': 'md:max-w-3xl',\n '4xl': 'md:max-w-4xl',\n '5xl': 'md:max-w-5xl',\n }\n\n if (props.fullscreenMobile) {\n return `md:w-full ${map[props.maxWidth] || map.sm}`\n }\n return `w-full ${map[props.maxWidth] || map.sm}`\n})\n\nconst roundedClass = computed(() => {\n if (props.maxWidth === 'full') return 'rounded-none'\n\n if (props.fullscreenMobile) {\n return 'rounded-none md:rounded-lg'\n }\n return 'rounded-lg'\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4EA,MAAM,QAAQ;EAqDd,MAAM,OAAO;EAGb,MAAM,EAAE,UAAU,cAAc,YAAY,mBAAmB,cAAc;EAC7E,IAAI,gBAAgB;EAEpB,YACQ,MAAM,OACX,YAAY;GACX,IAAI,SACF,gBAAgB,mBAAmB;IACjC,IAAI,MAAM,YAAY,OAAO;IAC7B,KAAK,OAAO;IACZ,OAAO;GACT,CAAC;QACI,IAAI,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AAA,WAAA,CAAQ,QAAA,cAAcA,KAAAA,MAAK,OAAA,GAAA,CAAA,MAAA,CAAA;IAEjC,GAAA,CAAA,YAiBa,YAAA;KAhBX,sBAAmB;KACnB,oBAAiB;KACjB,kBAAe;KACf,sBAAmB;KACnB,oBAAiB;KACjB,kBAAe;KACf,QAAA;;KAEA,SAAA,cAOM,CANE,QAAA,QADR,UAAA,GAAA,mBAOM,OAAA;;MALJ,OAAK,eAAA,CAAC,uEAAqE;OAClE,QAAA;OAAY,cAAA;OAAe,aAAA;OAAc,kBAAA;MAAiB,CAAA,CAAA;MAClE,SAAK,OAAA,OAAA,OAAA,KAAA,oBAAN,CAAA,GAAW,CAAA,MAAA,CAAA;KAEX,GAAA,CAAA,WAAQ,KAAA,QAAA,SAAA,CAAA,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"Modal.js","names":["$emit"],"sources":["../../src/components/Modal.vue"],"sourcesContent":["<template>\n <!-- Teleported to body to avoid z-index stacking context issues -->\n <Teleport to=\"body\">\n <!-- Backdrop overlay with fade transition -->\n <Transition\n enter-active-class=\"transition ease-out duration-200\"\n enter-from-class=\"opacity-0\"\n enter-to-class=\"opacity-100\"\n leave-active-class=\"transition ease-in duration-150\"\n leave-from-class=\"opacity-100\"\n leave-to-class=\"opacity-0\"\n >\n <div\n v-if=\"show\"\n class=\"fixed inset-0 flex items-center justify-center\"\n :class=\"[zClass, paddingClass, backdropClass]\"\n @click.self=\"!persistent && $emit('close')\"\n >\n <Transition\n enter-active-class=\"transition ease-out duration-300\"\n enter-from-class=\"opacity-0 scale-95\"\n enter-to-class=\"opacity-100 scale-100\"\n leave-active-class=\"transition ease-in duration-200\"\n leave-from-class=\"opacity-100 scale-100\"\n leave-to-class=\"opacity-0 scale-95\"\n appear\n >\n <div\n v-if=\"show\"\n ref=\"panelRef\"\n role=\"dialog\"\n aria-modal=\"true\"\n :aria-label=\"labelledby ? undefined : label || undefined\"\n :aria-labelledby=\"labelledby || undefined\"\n tabindex=\"-1\"\n class=\"modal-panel bg-white dark:bg-gray-925 overflow-hidden flex flex-col focus:outline-none\"\n :class=\"[panelClass, maxWidthClass, roundedClass, mobileLayoutClass]\"\n @click.stop\n >\n <slot />\n </div>\n </Transition>\n </div>\n </Transition>\n </Teleport>\n</template>\n\n<script setup>\n/**\n * UiModal — Teleported modal dialog with backdrop, configurable max-width, and enter/leave transitions.\n *\n * Renders a centered overlay panel teleported to `<body>`. Supports ten max-width presets\n * (xs through 5xl and full-screen), persistent mode to prevent backdrop-click dismissal,\n * and customizable z-index and padding. The panel uses a scale+fade transition on enter/leave.\n *\n * The panel is a real dialog: `role=\"dialog\"` and `aria-modal=\"true\"`, named by\n * `label` or `labelledby`. While open, focus moves into the panel (unless\n * something inside already has it), Tab and Shift+Tab wrap within it, Escape\n * closes it (unless `persistent` or `close-on-escape` is false), and focus\n * returns to whatever opened it. Stacked modals behave: only the top one\n * responds to Tab and Escape.\n *\n * @example Basic modal\n * <UiModal :show=\"isOpen\" @close=\"isOpen = false\">\n * <div class=\"p-6\">Hello!</div>\n * </UiModal>\n *\n * @example Large persistent modal\n * <UiModal :show=\"showEditor\" max-width=\"3xl\" persistent>\n * <ModalHeader @close=\"showEditor = false\" />\n * <div class=\"p-6\">Editor content</div>\n * </UiModal>\n *\n * @example Full-screen modal\n * <UiModal :show=\"showFull\" max-width=\"full\">\n * <div class=\"h-full\">Full screen content</div>\n * </UiModal>\n *\n * @example Non-fullscreen on mobile\n * <UiModal :show=\"isOpen\" :fullscreen-mobile=\"false\" @close=\"isOpen = false\">\n * <div class=\"p-6\">Centered on all screens</div>\n * </UiModal>\n *\n * @example Named by its heading\n * <UiModal :show=\"isOpen\" labelledby=\"settings-title\" @close=\"isOpen = false\">\n * <h2 id=\"settings-title\">Settings</h2>\n * </UiModal>\n *\n * @emits {void} close — Emitted when the modal should close (backdrop click, Escape,\n * the Android back button, or programmatic)\n *\n * @slot default — Modal content\n */\nimport { computed, ref, watch, onBeforeUnmount } from 'vue'\nimport { useBackButton } from '../composables/useBackButton.js'\nimport { useFocusTrap } from '../internal/focusTrap.js'\nconst props = defineProps({\n /**\n * Controls modal visibility. Use with v-model or :show + @close.\n * @type {boolean}\n * @default false\n */\n show: { type: Boolean, default: false },\n\n /**\n * Maximum width preset for the modal panel.\n * @type {string}\n * @default 'sm'\n * @values 'xs' (20rem) | 'sm' (24rem) | 'md' (28rem) | 'lg' (32rem) | 'xl' (36rem) | '2xl' (42rem) | '3xl' (48rem) | '4xl' (56rem) | '5xl' (64rem) | 'full'\n */\n maxWidth: { type: String, default: 'sm' },\n\n /**\n * Whether the modal goes fullscreen on mobile viewports.\n * When true, the panel fills the screen on mobile and respects safe area insets.\n * @type {boolean}\n * @default true\n */\n fullscreenMobile: { type: Boolean, default: true },\n\n /**\n * Persistent mode — prevents closing when clicking the backdrop overlay.\n * @type {boolean}\n * @default false\n */\n persistent: { type: Boolean, default: false },\n\n /**\n * Additional CSS classes applied to the modal panel element.\n * @type {string}\n * @default ''\n */\n panelClass: { type: String, default: '' },\n\n /**\n * Z-index class for the backdrop and modal layers.\n * @type {string}\n * @default 'z-50'\n */\n z: { type: String, default: 'z-50' },\n\n /**\n * Padding class around the modal panel (applied to the backdrop container).\n * @type {string}\n * @default 'md:p-4'\n */\n padding: { type: String, default: 'md:p-4' },\n /**\n * Accessible name for the dialog. Prefer `labelledby` when the content has a\n * visible heading.\n * @type {string}\n * @default ''\n */\n label: { type: String, default: '' },\n /**\n * Id of the element that names the dialog, usually its heading.\n * @type {string}\n * @default ''\n */\n labelledby: { type: String, default: '' },\n /**\n * Whether Escape closes the modal. Ignored (treated as false) when\n * `persistent` is set.\n * @type {boolean}\n * @default true\n */\n closeOnEscape: { type: Boolean, default: true },\n})\n\nconst emit = defineEmits(['close'])\n\n// ── Focus: move in, keep in, put back ──\nconst panelRef = ref(null)\nuseFocusTrap(() => panelRef.value, {\n active: () => props.show,\n escape: () => props.closeOnEscape && !props.persistent,\n onEscape: () => emit('close'),\n})\n\n// ── Back-button interception (Capacitor) ──\nconst { register: registerBack, unregister: unregisterBack } = useBackButton()\nlet backHandlerId = null\n\nwatch(\n () => props.show,\n (visible) => {\n if (visible) {\n backHandlerId = registerBack(() => {\n if (props.persistent) return false\n emit('close')\n return true\n })\n } else if (backHandlerId !== null) {\n unregisterBack(backHandlerId)\n backHandlerId = null\n }\n },\n { immediate: true },\n)\n\nonBeforeUnmount(() => {\n if (backHandlerId !== null) {\n unregisterBack(backHandlerId)\n backHandlerId = null\n }\n})\n\nconst zClass = computed(() => props.z)\nconst paddingClass = computed(() => props.padding)\n\nconst backdropClass = computed(() => {\n if (props.fullscreenMobile) {\n return 'bg-transparent md:bg-black/50'\n }\n return 'bg-black/50 p-4'\n})\n\nconst mobileLayoutClass = computed(() => {\n if (props.maxWidth === 'full') return 'fixed inset-0'\n\n if (props.fullscreenMobile) {\n return 'fixed inset-0 modal-panel--safe-area md:static md:inset-auto'\n }\n // Non-fullscreen on mobile: centered dialog with max-height\n return 'relative max-h-[calc(100vh-2rem)] md:static'\n})\n\nconst maxWidthClass = computed(() => {\n if (props.maxWidth === 'full') return 'w-full h-full'\n\n const map = {\n xs: 'md:max-w-xs',\n sm: 'md:max-w-sm',\n md: 'md:max-w-md',\n lg: 'md:max-w-lg',\n xl: 'md:max-w-xl',\n '2xl': 'md:max-w-2xl',\n '3xl': 'md:max-w-3xl',\n '4xl': 'md:max-w-4xl',\n '5xl': 'md:max-w-5xl',\n }\n\n if (props.fullscreenMobile) {\n return `md:w-full ${map[props.maxWidth] || map.sm}`\n }\n return `w-full ${map[props.maxWidth] || map.sm}`\n})\n\nconst roundedClass = computed(() => {\n if (props.maxWidth === 'full') return 'rounded-none'\n\n if (props.fullscreenMobile) {\n return 'rounded-none md:rounded-lg'\n }\n return 'rounded-lg'\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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main$1 from "../icons/Icon.js";
2
2
  import _sfc_main$2 from "./Button.js";
3
3
  import _sfc_main$3 from "./Modal.js";
4
- import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, nextTick, normalizeClass, openBlock, ref, renderSlot, toDisplayString, useSlots, watch, withCtx } from "vue";
4
+ import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, nextTick, normalizeClass, openBlock, ref, renderSlot, toDisplayString, useId, useSlots, watch, withCtx } from "vue";
5
5
  //#region src/components/Prompt.vue
6
6
  var _hoisted_1 = { class: "flex items-center justify-between p-4 pb-0 mb-3 shrink-0" };
7
7
  var _hoisted_2 = { class: "flex items-center gap-2" };
8
- var _hoisted_3 = { class: "text-sm font-semibold text-gray-900 dark:text-gray-200 leading-none" };
9
- var _hoisted_4 = { class: "flex justify-end gap-2 p-4 pt-0 shrink-0" };
8
+ var _hoisted_3 = { class: "flex justify-end gap-2 p-4 pt-0 shrink-0" };
10
9
  var _sfc_main = {
11
10
  __name: "Prompt",
12
11
  props: {
@@ -105,6 +104,7 @@ var _sfc_main = {
105
104
  const props = __props;
106
105
  const emit = __emit;
107
106
  const confirmRef = ref(null);
107
+ const titleId = `${useId()}-title`;
108
108
  const hasCustomActions = computed(() => !!useSlots().actions);
109
109
  const iconColorClass = computed(() => {
110
110
  const map = {
@@ -139,6 +139,7 @@ var _sfc_main = {
139
139
  "max-width": "sm",
140
140
  "fullscreen-mobile": __props.fullscreenMobile,
141
141
  "panel-class": __props.panelClass,
142
+ labelledby: titleId,
142
143
  onClose: handleClose
143
144
  }, {
144
145
  default: withCtx(() => [createElementVNode("div", {
@@ -150,10 +151,14 @@ var _sfc_main = {
150
151
  key: 0,
151
152
  name: __props.icon,
152
153
  class: normalizeClass(["w-5 h-5", iconColorClass.value])
153
- }, null, 8, ["name", "class"])) : createCommentVNode("", true), createElementVNode("h2", _hoisted_3, toDisplayString(__props.title), 1)]), createVNode(_sfc_main$2, {
154
+ }, null, 8, ["name", "class"])) : createCommentVNode("", true), createElementVNode("h2", {
155
+ id: titleId,
156
+ class: "text-sm font-semibold text-gray-900 dark:text-gray-200 leading-none"
157
+ }, toDisplayString(__props.title), 1)]), createVNode(_sfc_main$2, {
154
158
  variant: "ghost",
155
159
  color: "gray",
156
160
  "icon-only": "",
161
+ "aria-label": __props.cancelLabel,
157
162
  onClick: handleClose
158
163
  }, {
159
164
  default: withCtx(() => [createVNode(_sfc_main$1, {
@@ -161,12 +166,12 @@ var _sfc_main = {
161
166
  class: "block w-5 h-5"
162
167
  })]),
163
168
  _: 1
164
- })]),
169
+ }, 8, ["aria-label"])]),
165
170
  __props.body || _ctx.$slots.default ? (openBlock(), createElementBlock("div", {
166
171
  key: 0,
167
172
  class: normalizeClass(["text-sm text-gray-600 dark:text-gray-400 mb-4 leading-relaxed px-4 min-h-0", __props.panelClass.includes("overflow-visible") ? "overflow-visible" : "overflow-y-auto"])
168
173
  }, [renderSlot(_ctx.$slots, "default", {}, () => [createTextVNode(toDisplayString(__props.body), 1)])], 2)) : createCommentVNode("", true),
169
- createElementVNode("div", _hoisted_4, [renderSlot(_ctx.$slots, "actions", {}, () => [createVNode(_sfc_main$2, {
174
+ createElementVNode("div", _hoisted_3, [renderSlot(_ctx.$slots, "actions", {}, () => [createVNode(_sfc_main$2, {
170
175
  variant: "ghost",
171
176
  color: "gray",
172
177
  disabled: __props.loading,
@@ -1 +1 @@
1
- {"version":3,"file":"Prompt.js","names":["$slots"],"sources":["../../src/components/Prompt.vue"],"sourcesContent":["<template>\n <UiModal\n :show=\"show\"\n max-width=\"sm\"\n :fullscreen-mobile=\"fullscreenMobile\"\n :panel-class=\"panelClass\"\n @close=\"handleClose\"\n >\n <div\n ref=\"promptRef\"\n class=\"flex flex-col max-h-full\"\n :class=\"panelClass.includes('overflow-visible') ? 'overflow-visible' : 'overflow-hidden'\"\n @keydown=\"onKeydown\"\n >\n <div class=\"flex items-center justify-between p-4 pb-0 mb-3 shrink-0\">\n <div class=\"flex items-center gap-2\">\n <UiIcon v-if=\"icon\" :name=\"icon\" class=\"w-5 h-5\" :class=\"iconColorClass\" />\n <h2 class=\"text-sm font-semibold text-gray-900 dark:text-gray-200 leading-none\">\n {{ title }}\n </h2>\n </div>\n <UiButton variant=\"ghost\" color=\"gray\" icon-only @click=\"handleClose\">\n <UiIcon name=\"mdi:close\" class=\"block w-5 h-5\" />\n </UiButton>\n </div>\n\n <div\n v-if=\"body || $slots.default\"\n class=\"text-sm text-gray-600 dark:text-gray-400 mb-4 leading-relaxed px-4 min-h-0\"\n :class=\"panelClass.includes('overflow-visible') ? 'overflow-visible' : 'overflow-y-auto'\"\n >\n <slot>{{ body }}</slot>\n </div>\n\n <div class=\"flex justify-end gap-2 p-4 pt-0 shrink-0\">\n <slot name=\"actions\">\n <UiButton variant=\"ghost\" color=\"gray\" :disabled=\"loading\" @click=\"handleClose\">\n {{ cancelLabel }}\n </UiButton>\n <UiButton\n ref=\"confirmRef\"\n variant=\"solid\"\n :color=\"confirmColor\"\n :loading=\"loading\"\n @click=\"handleConfirm\"\n >\n {{ confirmLabel }}\n </UiButton>\n </slot>\n </div>\n </div>\n </UiModal>\n</template>\n\n<script setup>\n/**\n * UiPrompt — A modal prompt primitive for confirmations, choices, and user decisions.\n *\n * Wraps UiModal with a consistent header (icon + title + close), body content, and\n * action buttons. Handles keyboard (Escape to close, Enter to confirm), auto-focuses\n * the confirm button on open, and prevents double-submit while loading.\n *\n * For simple text prompts, use the `body` prop. For rich content, use the default slot.\n * Override the `#actions` slot for custom button layouts.\n *\n * @example Simple confirmation (props only, no slots needed)\n * <UiPrompt :show=\"confirming\" title=\"Delete item?\" body=\"This action cannot be undone.\"\n * icon=\"mdi:delete\" confirm-label=\"Delete\" confirm-color=\"red\"\n * @close=\"confirming = false\" @confirm=\"doDelete\" />\n *\n * @example Rich body content\n * <UiPrompt :show=\"open\" title=\"Warning\" @close=\"open = false\" @confirm=\"proceed\">\n * <p>This will affect <strong>{{ count }}</strong> items.</p>\n * </UiPrompt>\n *\n * @example Custom actions\n * <UiPrompt :show=\"choosing\" title=\"Export Options\" @close=\"choosing = false\">\n * Include results in the export?\n * <template #actions>\n * <UiButton variant=\"ghost\" color=\"gray\" @click=\"doExport(false)\">Without</UiButton>\n * <UiButton @click=\"doExport(true)\">With Results</UiButton>\n * </template>\n * </UiPrompt>\n *\n * @example Form prompt (disable Enter-to-confirm)\n * <UiPrompt :show=\"open\" title=\"New Group\" :confirm-on-enter=\"false\" @close=\"open = false\">\n * <UiInput v-model=\"name\" @keydown.enter=\"save\" />\n * </UiPrompt>\n */\nimport { ref, computed, watch, nextTick, useSlots } from 'vue'\nimport UiButton from './Button.vue'\nimport UiModal from './Modal.vue'\nimport UiIcon from '../icons/Icon.vue'\nconst props = defineProps({\n /** Controls prompt visibility. */\n show: { type: Boolean, default: false },\n /** Prompt heading text. */\n title: { type: String, default: 'Confirm' },\n /** Optional icon name displayed before the title. */\n icon: { type: String, default: null },\n /** Plain text body content. Ignored when the default slot is used. */\n body: { type: String, default: null },\n /** Label for the confirm button (default actions only). */\n confirmLabel: { type: String, default: 'Confirm' },\n /** Label for the cancel button (default actions only). */\n cancelLabel: { type: String, default: 'Cancel' },\n /** Color of the confirm button and icon. */\n confirmColor: { type: String, default: 'primary' },\n /** Shows a loading spinner on the confirm button and prevents double-submit. */\n loading: { type: Boolean, default: false },\n /** Whether pressing Enter triggers confirm. Disable for form-based prompts. */\n confirmOnEnter: { type: Boolean, default: true },\n /** Whether the prompt goes fullscreen on mobile viewports. */\n fullscreenMobile: { type: Boolean, default: false },\n /** Additional CSS class(es) applied to the modal panel element. */\n panelClass: { type: String, default: '' },\n})\n\nconst emit = defineEmits(['close', 'confirm'])\n\nconst confirmRef = ref(null)\nconst hasCustomActions = computed(() => !!useSlots().actions)\n\nconst iconColorClass = computed(() => {\n const map = {\n red: 'text-red-600 dark:text-red-400',\n amber: 'text-amber-600 dark:text-amber-400',\n primary: 'text-primary-600 dark:text-primary-400',\n gray: 'text-gray-500 dark:text-gray-400',\n }\n return map[props.confirmColor] || map.primary\n})\n\nconst handleClose = () => {\n if (!props.loading) emit('close')\n}\n\nconst handleConfirm = () => {\n if (!props.loading) emit('confirm')\n}\n\nconst onKeydown = (e) => {\n if (e.key === 'Enter' && props.confirmOnEnter && !hasCustomActions.value && !props.loading) {\n e.preventDefault()\n handleConfirm()\n }\n}\n\n// Auto-focus confirm button when prompt opens\nwatch(\n () => props.show,\n (open) => {\n if (open) {\n nextTick(() => {\n const el = confirmRef.value?.$el ?? confirmRef.value\n if (el instanceof HTMLElement) el.focus()\n })\n }\n },\n)\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6FA,MAAM,QAAQ;EAyBd,MAAM,OAAO;EAEb,MAAM,aAAa,IAAI,IAAI;EAC3B,MAAM,mBAAmB,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO;EAE5D,MAAM,iBAAiB,eAAe;GACpC,MAAM,MAAM;IACV,KAAK;IACL,OAAO;IACP,SAAS;IACT,MAAM;GACR;GACA,OAAO,IAAI,MAAM,iBAAiB,IAAI;EACxC,CAAC;EAED,MAAM,oBAAoB;GACxB,IAAI,CAAC,MAAM,SAAS,KAAK,OAAO;EAClC;EAEA,MAAM,sBAAsB;GAC1B,IAAI,CAAC,MAAM,SAAS,KAAK,SAAS;EACpC;EAEA,MAAM,aAAa,MAAM;GACvB,IAAI,EAAE,QAAQ,WAAW,MAAM,kBAAkB,CAAC,iBAAiB,SAAS,CAAC,MAAM,SAAS;IAC1F,EAAE,eAAe;IACjB,cAAc;GAChB;EACF;EAGA,YACQ,MAAM,OACX,SAAS;GACR,IAAI,MACF,eAAe;IACb,MAAM,KAAK,WAAW,OAAO,OAAO,WAAW;IAC/C,IAAI,cAAc,aAAa,GAAG,MAAM;GAC1C,CAAC;EAEL,CAC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AAA;;KAEhB,GAAA,GAAA,CAAA,UAAA,CAAA,GAAA,YAQW,aAAA;MAPL,SAAA;MAAJ,KAAI;MACJ,SAAQ;MACP,OAAO,QAAA;MACP,SAAS,QAAA;MACT,SAAO;;MAER,SAAA,cAAkB,CAAf,gBAAA,gBAAA,QAAA,YAAY,GAAA,CAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"Prompt.js","names":["$slots"],"sources":["../../src/components/Prompt.vue"],"sourcesContent":["<template>\n <UiModal\n :show=\"show\"\n max-width=\"sm\"\n :fullscreen-mobile=\"fullscreenMobile\"\n :panel-class=\"panelClass\"\n :labelledby=\"titleId\"\n @close=\"handleClose\"\n >\n <div\n ref=\"promptRef\"\n class=\"flex flex-col max-h-full\"\n :class=\"panelClass.includes('overflow-visible') ? 'overflow-visible' : 'overflow-hidden'\"\n @keydown=\"onKeydown\"\n >\n <div class=\"flex items-center justify-between p-4 pb-0 mb-3 shrink-0\">\n <div class=\"flex items-center gap-2\">\n <UiIcon v-if=\"icon\" :name=\"icon\" class=\"w-5 h-5\" :class=\"iconColorClass\" />\n <h2\n :id=\"titleId\"\n class=\"text-sm font-semibold text-gray-900 dark:text-gray-200 leading-none\"\n >\n {{ title }}\n </h2>\n </div>\n <UiButton\n variant=\"ghost\"\n color=\"gray\"\n icon-only\n :aria-label=\"cancelLabel\"\n @click=\"handleClose\"\n >\n <UiIcon name=\"mdi:close\" class=\"block w-5 h-5\" />\n </UiButton>\n </div>\n\n <div\n v-if=\"body || $slots.default\"\n class=\"text-sm text-gray-600 dark:text-gray-400 mb-4 leading-relaxed px-4 min-h-0\"\n :class=\"panelClass.includes('overflow-visible') ? 'overflow-visible' : 'overflow-y-auto'\"\n >\n <slot>{{ body }}</slot>\n </div>\n\n <div class=\"flex justify-end gap-2 p-4 pt-0 shrink-0\">\n <slot name=\"actions\">\n <UiButton variant=\"ghost\" color=\"gray\" :disabled=\"loading\" @click=\"handleClose\">\n {{ cancelLabel }}\n </UiButton>\n <UiButton\n ref=\"confirmRef\"\n variant=\"solid\"\n :color=\"confirmColor\"\n :loading=\"loading\"\n @click=\"handleConfirm\"\n >\n {{ confirmLabel }}\n </UiButton>\n </slot>\n </div>\n </div>\n </UiModal>\n</template>\n\n<script setup>\n/**\n * UiPrompt — A modal prompt primitive for confirmations, choices, and user decisions.\n *\n * Wraps UiModal with a consistent header (icon + title + close), body content, and\n * action buttons. Handles keyboard (Escape to close, Enter to confirm), auto-focuses\n * the confirm button on open, and prevents double-submit while loading.\n *\n * For simple text prompts, use the `body` prop. For rich content, use the default slot.\n * Override the `#actions` slot for custom button layouts.\n *\n * @example Simple confirmation (props only, no slots needed)\n * <UiPrompt :show=\"confirming\" title=\"Delete item?\" body=\"This action cannot be undone.\"\n * icon=\"mdi:delete\" confirm-label=\"Delete\" confirm-color=\"red\"\n * @close=\"confirming = false\" @confirm=\"doDelete\" />\n *\n * @example Rich body content\n * <UiPrompt :show=\"open\" title=\"Warning\" @close=\"open = false\" @confirm=\"proceed\">\n * <p>This will affect <strong>{{ count }}</strong> items.</p>\n * </UiPrompt>\n *\n * @example Custom actions\n * <UiPrompt :show=\"choosing\" title=\"Export Options\" @close=\"choosing = false\">\n * Include results in the export?\n * <template #actions>\n * <UiButton variant=\"ghost\" color=\"gray\" @click=\"doExport(false)\">Without</UiButton>\n * <UiButton @click=\"doExport(true)\">With Results</UiButton>\n * </template>\n * </UiPrompt>\n *\n * @example Form prompt (disable Enter-to-confirm)\n * <UiPrompt :show=\"open\" title=\"New Group\" :confirm-on-enter=\"false\" @close=\"open = false\">\n * <UiInput v-model=\"name\" @keydown.enter=\"save\" />\n * </UiPrompt>\n */\nimport { ref, computed, watch, nextTick, useSlots, useId } from 'vue'\nimport UiButton from './Button.vue'\nimport UiModal from './Modal.vue'\nimport UiIcon from '../icons/Icon.vue'\nconst props = defineProps({\n /** Controls prompt visibility. */\n show: { type: Boolean, default: false },\n /** Prompt heading text. */\n title: { type: String, default: 'Confirm' },\n /** Optional icon name displayed before the title. */\n icon: { type: String, default: null },\n /** Plain text body content. Ignored when the default slot is used. */\n body: { type: String, default: null },\n /** Label for the confirm button (default actions only). */\n confirmLabel: { type: String, default: 'Confirm' },\n /** Label for the cancel button (default actions only). */\n cancelLabel: { type: String, default: 'Cancel' },\n /** Color of the confirm button and icon. */\n confirmColor: { type: String, default: 'primary' },\n /** Shows a loading spinner on the confirm button and prevents double-submit. */\n loading: { type: Boolean, default: false },\n /** Whether pressing Enter triggers confirm. Disable for form-based prompts. */\n confirmOnEnter: { type: Boolean, default: true },\n /** Whether the prompt goes fullscreen on mobile viewports. */\n fullscreenMobile: { type: Boolean, default: false },\n /** Additional CSS class(es) applied to the modal panel element. */\n panelClass: { type: String, default: '' },\n})\n\nconst emit = defineEmits(['close', 'confirm'])\n\nconst confirmRef = ref(null)\nconst titleId = `${useId()}-title`\nconst hasCustomActions = computed(() => !!useSlots().actions)\n\nconst iconColorClass = computed(() => {\n const map = {\n red: 'text-red-600 dark:text-red-400',\n amber: 'text-amber-600 dark:text-amber-400',\n primary: 'text-primary-600 dark:text-primary-400',\n gray: 'text-gray-500 dark:text-gray-400',\n }\n return map[props.confirmColor] || map.primary\n})\n\nconst handleClose = () => {\n if (!props.loading) emit('close')\n}\n\nconst handleConfirm = () => {\n if (!props.loading) emit('confirm')\n}\n\nconst onKeydown = (e) => {\n if (e.key === 'Enter' && props.confirmOnEnter && !hasCustomActions.value && !props.loading) {\n e.preventDefault()\n handleConfirm()\n }\n}\n\n// Auto-focus confirm button when prompt opens\nwatch(\n () => props.show,\n (open) => {\n if (open) {\n nextTick(() => {\n const el = confirmRef.value?.$el ?? confirmRef.value\n if (el instanceof HTMLElement) el.focus()\n })\n }\n },\n)\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuGA,MAAM,QAAQ;EAyBd,MAAM,OAAO;EAEb,M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BAKK,MAAA;MAJF,IAAI;MACL,OAAM;KAEH,GAAA,gBAAA,QAAA,KAAK,GAAA,CAAA,CAAA,CAAA,GAGZ,YAQW,aAAA;MAPT,SAAQ;MACR,OAAM;MACN,aAAA;MACC,cAAY,QAAA;MACZ,SAAO;;MAER,SAAA,cAAiD,CAAjD,YAAiD,aAAA;OAAzC,MAAK;OAAY,OAAM;;;;KAK3B,QAAA,QAAQA,KAAAA,OAAO,WADvB,UAAA,GAAA,mBAMM,OAAA;;MAJJ,OAAK,eAAA,CAAC,8EACE,QAAA,WAAW,SAAQ,kBAAA,IAAA,qBAAA,iBAAA,CAAA;KAE3B,GAAA,CAAA,WAAuB,KAAA,QAAA,WAAA,CAAA,SAAA,CAAd,gBAAA,gBAAA,QAAA,IAAI,GAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA;KAGf,mBAeM,OAfN,YAeM,CAdJ,WAaO,KAAA,QAAA,WAAA,CAAA,SAAA,CAZL,YAEW,aAAA;MAFD,SAAQ;MAAQ,OAAM;MAAQ,UAAU,QAAA;MAAU,SAAO;;MACjE,SAAA,cAAiB,CAAd,gBAAA,gBAAA,QAAA,WAAW,GAAA,CAAA,CAAA,CAAA;;KAEhB,GAAA,GAAA,CAAA,UAAA,CAAA,GAAA,YAQW,aAAA;MAPL,SAAA;MAAJ,KAAI;MACJ,SAAQ;MACP,OAAO,QAAA;MACP,SAAS,QAAA;MACT,SAAO;;MAER,SAAA,cAAkB,CAAf,gBAAA,gBAAA,QAAA,YAAY,GAAA,CAAA,CAAA,CAAA"}
@@ -416,7 +416,7 @@ var _sfc_main = {
416
416
  type: "text",
417
417
  placeholder: "Search...",
418
418
  class: "w-full px-2.5 py-1.5 text-sm border border-gray-200 dark:border-gray-700 rounded-md bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-gray-300 outline-none focus:ring-1 focus:ring-primary-500 placeholder-gray-400",
419
- onKeydown: [withKeys(close, ["escape"]), withKeys(withModifiers(selectFirst, ["prevent"]), ["enter"])]
419
+ onKeydown: [withKeys(withModifiers(close, ["prevent"]), ["escape"]), withKeys(withModifiers(selectFirst, ["prevent"]), ["enter"])]
420
420
  }, null, 40, _hoisted_6), [[vModelText, searchQuery.value]])])) : createCommentVNode("", true), createElementVNode("ul", _hoisted_7, [filteredOptions.value.length === 0 && filteredGroups.value.length === 0 ? (openBlock(), createElementBlock("li", _hoisted_8, " No results ")) : createCommentVNode("", true), filteredGroups.value.length === 0 ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(filteredOptions.value, (opt) => {
421
421
  return openBlock(), createElementBlock("li", {
422
422
  key: opt.value,