@mdbase-dev/ui 0.1.0-beta.155 → 0.1.0-beta.156

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/README.md +1 -1
  2. package/css/collections.css +5 -100
  3. package/css/controls.css +32 -33
  4. package/css/feedback.css +6 -6
  5. package/css/motion.css +50 -26
  6. package/css/palette.css +22 -54
  7. package/css/toast.css +10 -5
  8. package/css/tokens.css +11 -25
  9. package/dist/AppSwitcher.js +18 -30
  10. package/dist/CommandPalette.d.ts +5 -2
  11. package/dist/CommandPalette.js +157 -152
  12. package/dist/ConfirmDialog.d.ts +14 -0
  13. package/dist/ConfirmDialog.js +65 -0
  14. package/dist/Dialog.d.ts +5 -7
  15. package/dist/Dialog.js +46 -24
  16. package/dist/Feedback.js +24 -56
  17. package/dist/FeedbackMarkup.d.ts +2 -1
  18. package/dist/FeedbackMarkup.js +8 -2
  19. package/dist/Menu.d.ts +10 -0
  20. package/dist/Menu.js +33 -0
  21. package/dist/Select.js +6 -2
  22. package/dist/SelectList.js +2 -1
  23. package/dist/Toaster.js +72 -44
  24. package/dist/brand.js +5 -3
  25. package/dist/collections/CollectionSwitcher.d.ts +2 -3
  26. package/dist/collections/CollectionSwitcher.js +14 -173
  27. package/dist/collections/dialogs.d.ts +9 -4
  28. package/dist/collections/dialogs.js +83 -87
  29. package/dist/collections/parts.d.ts +0 -9
  30. package/dist/collections/parts.js +5 -77
  31. package/dist/locales/de/messages.json +1 -1
  32. package/dist/locales/en/messages.json +1 -1
  33. package/dist/locales/es/messages.json +1 -1
  34. package/dist/locales/fr/messages.json +1 -1
  35. package/dist/locales/it/messages.json +1 -1
  36. package/dist/locales/ja/messages.json +1 -1
  37. package/dist/locales/ko/messages.json +1 -1
  38. package/dist/locales/pt/messages.json +1 -1
  39. package/dist/locales/ru/messages.json +1 -1
  40. package/dist/locales/zh/messages.json +1 -1
  41. package/dist/overlay.d.ts +4 -0
  42. package/dist/overlay.js +23 -0
  43. package/dist/popover.d.ts +2 -1
  44. package/dist/popover.js +6 -13
  45. package/package.json +14 -2
@@ -1,16 +1,15 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useId, useLayoutEffect, useEffect, useRef, useState, useSyncExternalStore } from "react";
3
- import { anchoredPlacement } from "../popover.js";
2
+ import { useId, useRef, useState } from "react";
3
+ import { Dialog } from "../Dialog.js";
4
4
  import { RowDialogs, SignOutDialog } from "./dialogs.js";
5
5
  import { AccountLine, ActionButton, CollectionMark, ItemCopy, ItemMore, NoticeBlock, PrivateMark, RowCopy, RowMore } from "./parts.js";
6
6
  import { useCollectionUi } from "./use-collection-ui.js";
7
7
  /** Collections worth a filter box; fewer fit at a glance. */
8
8
  const FILTER_THRESHOLD = 7;
9
- const NARROW = "(max-width: 639.98px)";
10
9
  /**
11
10
  * The in-app collection switcher: a trigger that opens the approved collections
12
11
  * (one click switches, no Connect window), "Add a collection…", "Manage access"
13
- * and the account. A popover on wide screens, a bottom sheet on narrow ones.
12
+ * and the account in a modal collection chooser.
14
13
  *
15
14
  * Pass `open` and `onOpenChange` to control it. With `variant="none"` it has no
16
15
  * trigger, so an app can open it from its own control and pass that control's
@@ -35,10 +34,8 @@ export function CollectionSwitcher({
35
34
  };
36
35
  const [dialog, setDialog] = useState(null);
37
36
  const trigger = useRef(null);
38
- // The element the panel is placed against and hands focus back to.
39
37
  const anchor = anchorRef ?? trigger;
40
38
  const panelId = useId();
41
- const narrow = useNarrow();
42
39
  const {
43
40
  view,
44
41
  copy,
@@ -61,14 +58,6 @@ export function CollectionSwitcher({
61
58
  setOpen(false);
62
59
  setDialog(next);
63
60
  };
64
- // The popover that held the row is gone: a closed row dialog hands focus to the anchor.
65
- const returnFocus = useRef(false);
66
- useEffect(() => {
67
- if (dialog || !returnFocus.current) return;
68
- returnFocus.current = false;
69
- const active = document.activeElement;
70
- if (!active || active === document.body) anchor.current?.focus();
71
- }, [dialog, anchor]);
72
61
  const content = _jsx(SwitcherContent, {
73
62
  ui: ui,
74
63
  onDone: () => close(false),
@@ -110,24 +99,18 @@ export function CollectionSwitcher({
110
99
  d: "m4 6 4 4 4-4"
111
100
  })
112
101
  })]
113
- }), open && (narrow ? _jsx(SwitcherSheet, {
114
- id: panelId,
115
- ui: ui,
116
- onClose: close,
117
- children: content
118
- }) : _jsx(SwitcherPopover, {
119
- id: panelId,
120
- ui: ui,
121
- anchorRef: anchor,
122
- onClose: close,
102
+ }), _jsx(Dialog, {
103
+ open: open,
104
+ returnFocusRef: anchor,
105
+ title: copy.collectionsLabel,
106
+ onClose: () => close(true),
107
+ className: "mdbase-collections mdbase-collections-switcher-dialog",
123
108
  children: content
124
- })), _jsx(RowDialogs, {
109
+ }), _jsx(RowDialogs, {
125
110
  ui: ui,
126
111
  dialog: dialog,
127
- onClose: () => {
128
- returnFocus.current = true;
129
- setDialog(null);
130
- }
112
+ returnFocusRef: anchor,
113
+ onClose: () => setDialog(null)
131
114
  }), _jsx(SignOutDialog, {
132
115
  ui: ui
133
116
  })]
@@ -266,6 +249,7 @@ export function SwitcherContent({
266
249
  type: "button",
267
250
  role: "radio",
268
251
  "aria-checked": checked,
252
+ "data-autofocus": sdkKey(row) === rovingId || undefined,
269
253
  "aria-disabled": !row.available || undefined,
270
254
  "aria-describedby": detailId,
271
255
  tabIndex: sdkKey(row) === rovingId ? 0 : -1,
@@ -380,6 +364,7 @@ function SwitcherSection({
380
364
  type: "button",
381
365
  role: "radio",
382
366
  "aria-checked": item.current === true,
367
+ "data-autofocus": key(item.id) === roving || undefined,
383
368
  "aria-disabled": item.disabled || undefined,
384
369
  tabIndex: key(item.id) === roving ? 0 : -1,
385
370
  className: "mdbase-collections-row",
@@ -432,9 +417,6 @@ function moveAmongRadios(event) {
432
417
  radios[next]?.focus();
433
418
  }
434
419
  /** Where focus starts in the list: the open collection, else the first group's row. */
435
- function firstRadio(root) {
436
- return root.querySelector('[role="radio"][aria-checked="true"]') ?? root.querySelector('[role="radio"][tabindex="0"]');
437
- }
438
420
  function CheckGlyph() {
439
421
  return _jsx("svg", {
440
422
  className: "mdbase-collections-check",
@@ -445,139 +427,6 @@ function CheckGlyph() {
445
427
  })
446
428
  });
447
429
  }
448
- /**
449
- * Wide screens: a non-modal dialog anchored to the trigger (or the app's
450
- * anchor), in the top layer where supported. Pointer presses and focus on the
451
- * anchor count as inside, so the trigger can toggle it.
452
- */
453
- function SwitcherPopover({
454
- id,
455
- ui,
456
- anchorRef,
457
- onClose,
458
- children
459
- }) {
460
- const ref = useRef(null);
461
- const closeRef = useRef(onClose);
462
- closeRef.current = onClose;
463
- useLayoutEffect(() => {
464
- const panel = ref.current;
465
- const anchor = anchorRef.current;
466
- if (!panel || !anchor) return undefined;
467
- if (typeof panel.showPopover === "function") panel.showPopover();
468
- const box = anchor.getBoundingClientRect();
469
- const width = Math.min(340, window.innerWidth - 16);
470
- panel.style.width = `${width}px`;
471
- const place = anchoredPlacement(box, {
472
- width,
473
- height: panel.scrollHeight
474
- }, {
475
- width: window.innerWidth,
476
- height: window.innerHeight
477
- }, {
478
- gap: 6
479
- });
480
- panel.style.top = `${place.top}px`;
481
- panel.style.left = `${place.left}px`;
482
- panel.style.maxHeight = `${place.maxHeight}px`;
483
- (firstRadio(panel) ?? panel.querySelector("button") ?? panel).focus({
484
- preventScroll: true
485
- });
486
- return () => {
487
- if (typeof panel.hidePopover === "function" && panel.matches(":popover-open")) panel.hidePopover();
488
- };
489
- }, [anchorRef]);
490
- useEffect(() => {
491
- const outside = event => {
492
- const target = event.target;
493
- if (target && !ref.current?.contains(target) && !anchorRef.current?.contains(target)) closeRef.current(false);
494
- };
495
- const resize = () => closeRef.current(false);
496
- document.addEventListener("pointerdown", outside, true);
497
- window.addEventListener("resize", resize);
498
- return () => {
499
- document.removeEventListener("pointerdown", outside, true);
500
- window.removeEventListener("resize", resize);
501
- };
502
- }, [anchorRef]);
503
- return _jsx("div", {
504
- ref: ref,
505
- id: id,
506
- className: "mdbase-collections-popover",
507
- popover: "manual",
508
- role: "dialog",
509
- "aria-label": ui.copy.collectionsLabel,
510
- tabIndex: -1,
511
- onKeyDown: event => {
512
- if (event.key !== "Escape") return;
513
- event.preventDefault();
514
- event.stopPropagation();
515
- onClose(true);
516
- },
517
- onBlur: event => {
518
- const next = event.relatedTarget;
519
- if (next && !ref.current?.contains(next) && !anchorRef.current?.contains(next)) onClose(false);
520
- },
521
- children: children
522
- });
523
- }
524
- /** Narrow screens: a modal bottom sheet on the native <dialog>. */
525
- function SwitcherSheet({
526
- id,
527
- ui,
528
- onClose,
529
- children
530
- }) {
531
- const ref = useRef(null);
532
- useLayoutEffect(() => {
533
- const sheet = ref.current;
534
- if (!sheet) return undefined;
535
- if (!sheet.open) {
536
- if (typeof sheet.showModal === "function") sheet.showModal();else sheet.setAttribute("open", "");
537
- }
538
- firstRadio(sheet)?.focus({
539
- preventScroll: true
540
- });
541
- return () => {
542
- if (sheet.open && typeof sheet.close === "function") sheet.close();
543
- };
544
- }, []);
545
- return _jsx("dialog", {
546
- ref: ref,
547
- id: id,
548
- className: "mdbase-collections mdbase-collections-sheet",
549
- "aria-label": ui.copy.collectionsLabel,
550
- onCancel: event => {
551
- event.preventDefault();
552
- onClose(true);
553
- },
554
- onClick: event => {
555
- if (event.target === event.currentTarget) onClose(true);
556
- },
557
- children: _jsxs("div", {
558
- className: "mdbase-collections-sheet-body",
559
- children: [_jsxs("div", {
560
- className: "mdbase-collections-sheet-header",
561
- children: [_jsx("span", {
562
- className: "mdbase-collections-sheet-title",
563
- children: ui.copy.collectionsLabel
564
- }), _jsx("button", {
565
- type: "button",
566
- className: "mdbase-collections-more",
567
- "aria-label": ui.copy.close,
568
- onClick: () => onClose(true),
569
- children: _jsx("svg", {
570
- viewBox: "0 0 16 16",
571
- "aria-hidden": "true",
572
- children: _jsx("path", {
573
- d: "m4 4 8 8M12 4l-8 8"
574
- })
575
- })
576
- })]
577
- }), children]
578
- })
579
- });
580
- }
581
430
  function CollectionsGlyph() {
582
431
  return _jsx("svg", {
583
432
  className: "mdbase-collections-glyph",
@@ -588,11 +437,3 @@ function CollectionsGlyph() {
588
437
  })
589
438
  });
590
439
  }
591
- function subscribeNarrow(listener) {
592
- const query = typeof window.matchMedia === "function" ? window.matchMedia(NARROW) : null;
593
- query?.addEventListener("change", listener);
594
- return () => query?.removeEventListener("change", listener);
595
- }
596
- function useNarrow() {
597
- return useSyncExternalStore(subscribeNarrow, () => typeof window.matchMedia === "function" && window.matchMedia(NARROW).matches, () => false);
598
- }
@@ -1,16 +1,20 @@
1
- import { type JSX } from "react";
1
+ import { type JSX, type RefObject } from "react";
2
2
  import type { CollectionRow } from "./model.js";
3
3
  import { type RowDialog } from "./parts.js";
4
4
  import type { CollectionUi, DeleteCollectionOutcome } from "./use-collection-ui.js";
5
5
  type Target = Pick<CollectionRow, "id" | "name">;
6
6
  /** Hide a collection on this device. Nothing is deleted and access stays. */
7
- export declare function ForgetCollectionDialog({ ui, collection, onClose }: {
7
+ export declare function ForgetCollectionDialog({ open, ui, collection, onClose, returnFocusRef }: {
8
+ readonly open?: boolean;
9
+ readonly returnFocusRef?: RefObject<HTMLElement | null> | undefined;
8
10
  readonly ui: CollectionUi;
9
11
  readonly collection: Target;
10
12
  readonly onClose: () => void;
11
13
  }): JSX.Element;
12
14
  /** Owner only: type the name to delete a collection for everyone. The SDK and server check both again. */
13
- export declare function DeleteCollectionDialog({ ui, collection, onClose }: {
15
+ export declare function DeleteCollectionDialog({ open, ui, collection, onClose, returnFocusRef }: {
16
+ readonly open?: boolean;
17
+ readonly returnFocusRef?: RefObject<HTMLElement | null> | undefined;
14
18
  readonly ui: CollectionUi;
15
19
  readonly collection: Target;
16
20
  readonly onClose: (outcome: DeleteCollectionOutcome) => void;
@@ -19,9 +23,10 @@ export declare function DeleteCollectionDialog({ ui, collection, onClose }: {
19
23
  export declare function SignOutDialog({ ui }: {
20
24
  readonly ui: CollectionUi;
21
25
  }): JSX.Element | null;
22
- export declare function RowDialogs({ ui, dialog, onClose }: {
26
+ export declare function RowDialogs({ ui, dialog, onClose, returnFocusRef }: {
23
27
  readonly ui: CollectionUi;
24
28
  readonly dialog: RowDialog;
25
29
  readonly onClose: () => void;
30
+ readonly returnFocusRef?: RefObject<HTMLElement | null>;
26
31
  }): JSX.Element | null;
27
32
  export {};
@@ -1,15 +1,23 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { describeError } from "@mdbase-dev/sdk/describe";
3
- import { useId, useState } from "react";
4
- import { ActionButton, CollectionDialog } from "./parts.js";
3
+ import { useEffect, useId, useState } from "react";
4
+ import { ConfirmDialog } from "../ConfirmDialog.js";
5
5
  /** Hide a collection on this device. Nothing is deleted and access stays. */
6
6
  export function ForgetCollectionDialog({
7
+ open = true,
7
8
  ui,
8
9
  collection,
9
- onClose
10
+ onClose,
11
+ returnFocusRef
10
12
  }) {
11
13
  const [busy, setBusy] = useState(false);
12
14
  const [error, setError] = useState(null);
15
+ useEffect(() => {
16
+ if (open) {
17
+ setBusy(false);
18
+ setError(null);
19
+ }
20
+ }, [open]);
13
21
  const forget = () => {
14
22
  setBusy(true);
15
23
  setError(null);
@@ -18,45 +26,46 @@ export function ForgetCollectionDialog({
18
26
  setError(describeError(cause)?.message ?? null);
19
27
  });
20
28
  };
21
- return _jsxs(CollectionDialog, {
29
+ return _jsx(ConfirmDialog, {
30
+ open: open,
31
+ returnFocusRef: returnFocusRef,
22
32
  title: ui.say("forgetTitle", {
23
33
  collection: collection.name
24
34
  }),
35
+ consequence: ui.say("forgetBody"),
36
+ confirmLabel: ui.copy.forgetConfirm,
37
+ pendingLabel: `${ui.copy.forgetConfirm}…`,
25
38
  busy: busy,
26
39
  onClose: onClose,
27
- footer: _jsxs(_Fragment, {
28
- children: [_jsx(ActionButton, {
29
- tone: "quiet",
30
- inert: busy,
31
- onClick: onClose,
32
- children: ui.copy.cancel
33
- }), _jsx(ActionButton, {
34
- tone: "primary",
35
- progress: busy ? ui.copy.forgetConfirm : null,
36
- onClick: forget,
37
- children: ui.copy.forgetConfirm
38
- })]
39
- }),
40
- children: [_jsx("p", {
41
- children: ui.say("forgetBody")
42
- }), error && _jsx("p", {
40
+ onConfirm: forget,
41
+ children: error && _jsx("p", {
43
42
  className: "mdbase-collections-dialog-error",
44
43
  role: "alert",
45
44
  children: error
46
- })]
45
+ })
47
46
  });
48
47
  }
49
48
  /** Owner only: type the name to delete a collection for everyone. The SDK and server check both again. */
50
49
  export function DeleteCollectionDialog({
50
+ open = true,
51
51
  ui,
52
52
  collection,
53
- onClose
53
+ onClose,
54
+ returnFocusRef
54
55
  }) {
55
56
  const id = useId();
56
57
  const [typed, setTyped] = useState("");
57
58
  const [busy, setBusy] = useState(false);
58
59
  const [error, setError] = useState(null);
59
60
  const [failed, setFailed] = useState(false);
61
+ useEffect(() => {
62
+ if (open) {
63
+ setTyped("");
64
+ setBusy(false);
65
+ setError(null);
66
+ setFailed(false);
67
+ }
68
+ }, [open]);
60
69
  const matches = typed.trim() === collection.name.trim();
61
70
  const dismiss = () => onClose(failed ? "failed" : "cancelled");
62
71
  const remove = () => {
@@ -71,50 +80,33 @@ export function DeleteCollectionDialog({
71
80
  setError(describeError(cause)?.message ?? null);
72
81
  });
73
82
  };
74
- return _jsxs(CollectionDialog, {
75
- alert: true,
83
+ return _jsxs(ConfirmDialog, {
84
+ open: open,
85
+ returnFocusRef: returnFocusRef,
76
86
  title: ui.say("deleteTitle", {
77
87
  collection: collection.name
78
88
  }),
89
+ consequence: ui.copy.deleteBody,
90
+ confirmLabel: ui.copy.deleteConfirm,
91
+ pendingLabel: ui.copy.deleting,
79
92
  busy: busy,
93
+ disabled: !matches,
80
94
  onClose: dismiss,
81
- footer: _jsxs(_Fragment, {
82
- children: [_jsx(ActionButton, {
83
- tone: "quiet",
84
- inert: busy,
85
- onClick: dismiss,
86
- children: ui.copy.cancel
87
- }), _jsx(ActionButton, {
88
- tone: "danger",
89
- inert: !matches,
90
- progress: busy ? ui.copy.deleting : null,
91
- onClick: remove,
92
- children: ui.copy.deleteConfirm
93
- })]
94
- }),
95
- children: [_jsx("p", {
96
- children: ui.copy.deleteBody
97
- }), _jsxs("form", {
98
- onSubmit: event => {
99
- event.preventDefault();
100
- remove();
101
- },
102
- children: [_jsx("label", {
103
- className: "mdbase-collections-field-label",
104
- htmlFor: id,
105
- children: ui.say("deleteTypeName", {
106
- collection: collection.name
107
- })
108
- }), _jsx("input", {
109
- id: id,
110
- className: "mdbase-collections-field",
111
- value: typed,
112
- autoComplete: "off",
113
- spellCheck: false,
114
- disabled: busy,
115
- onChange: event => setTyped(event.target.value),
116
- "data-autofocus": true
117
- })]
95
+ onConfirm: remove,
96
+ children: [_jsx("label", {
97
+ className: "mdbase-collections-field-label",
98
+ htmlFor: id,
99
+ children: ui.say("deleteTypeName", {
100
+ collection: collection.name
101
+ })
102
+ }), _jsx("input", {
103
+ id: id,
104
+ className: "mdbase-collections-field",
105
+ value: typed,
106
+ autoComplete: "off",
107
+ spellCheck: false,
108
+ disabled: busy,
109
+ onChange: event => setTyped(event.target.value)
118
110
  }), error && _jsx("p", {
119
111
  className: "mdbase-collections-dialog-error",
120
112
  role: "alert",
@@ -126,44 +118,48 @@ export function DeleteCollectionDialog({
126
118
  export function SignOutDialog({
127
119
  ui
128
120
  }) {
129
- const problem = ui.signOutPrompt;
121
+ const [last, setLast] = useState(ui.signOutPrompt);
122
+ useEffect(() => {
123
+ if (ui.signOutPrompt) setLast(ui.signOutPrompt);
124
+ }, [ui.signOutPrompt]);
125
+ const problem = ui.signOutPrompt ?? last;
130
126
  if (!problem) return null;
131
- return _jsx(CollectionDialog, {
132
- alert: true,
127
+ return _jsx(ConfirmDialog, {
128
+ open: Boolean(ui.signOutPrompt),
133
129
  title: problem.title,
130
+ consequence: problem.message,
131
+ confirmLabel: ui.copy.signOutAnyway,
132
+ pendingLabel: ui.copy.signingOut,
134
133
  onClose: ui.actions.dismissSignOut,
135
- footer: _jsxs(_Fragment, {
136
- children: [_jsx(ActionButton, {
137
- tone: "primary",
138
- onClick: ui.actions.dismissSignOut,
139
- children: problem.actionLabel ?? ui.copy.cancel
140
- }), _jsx(ActionButton, {
141
- tone: "danger",
142
- onClick: ui.actions.confirmSignOut,
143
- children: ui.copy.signOutAnyway
144
- })]
145
- }),
146
- children: _jsx("p", {
147
- children: problem.message
148
- })
134
+ onConfirm: ui.actions.confirmSignOut
149
135
  });
150
136
  }
151
137
  export function RowDialogs({
152
138
  ui,
153
139
  dialog,
154
- onClose
140
+ onClose,
141
+ returnFocusRef
155
142
  }) {
156
- if (!dialog) return null;
157
- return dialog.kind === "forget" ? _jsx(ForgetCollectionDialog, {
143
+ const [last, setLast] = useState(dialog);
144
+ useEffect(() => {
145
+ if (dialog) setLast(dialog);
146
+ }, [dialog]);
147
+ const target = dialog ?? last;
148
+ if (!target) return null;
149
+ return target.kind === "forget" ? _jsx(ForgetCollectionDialog, {
150
+ open: Boolean(dialog),
151
+ returnFocusRef: returnFocusRef,
158
152
  ui: ui,
159
- collection: dialog.row,
153
+ collection: target.row,
160
154
  onClose: onClose
161
- }) : _jsx(DeleteCollectionDialog, {
155
+ }, target.row.id) : _jsx(DeleteCollectionDialog, {
156
+ open: Boolean(dialog),
157
+ returnFocusRef: returnFocusRef,
162
158
  ui: ui,
163
- collection: dialog.row,
159
+ collection: target.row,
164
160
  onClose: outcome => {
165
161
  onClose();
166
- dialog.onClose?.(outcome);
162
+ target.onClose?.(outcome);
167
163
  }
168
- });
164
+ }, target.row.id);
169
165
  }
@@ -73,14 +73,5 @@ export declare function GateFooter({ ui, chooseAnother, extra }: {
73
73
  export declare function AccountLine({ ui }: {
74
74
  readonly ui: CollectionUi;
75
75
  }): JSX.Element;
76
- /** A native modal <dialog>: the browser traps focus and makes the page inert; Escape cancels. */
77
- export declare function CollectionDialog({ title, alert, busy, onClose, children, footer }: {
78
- readonly title: string;
79
- readonly alert?: boolean;
80
- readonly busy?: boolean;
81
- readonly onClose: () => void;
82
- readonly children: ReactNode;
83
- readonly footer: ReactNode;
84
- }): JSX.Element;
85
76
  export declare function initials(name: string): string;
86
77
  export declare function hueOf(id: string): number;
@@ -1,6 +1,6 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useId, useLayoutEffect, useRef, useState } from "react";
3
- import { moveMenuFocus, useMenuPopover } from "../popover.js";
2
+ import { useId, useRef, useState } from "react";
3
+ import { Menu } from "../Menu.js";
4
4
  /**
5
5
  * A text button. While another action runs it stays focusable but inert
6
6
  * (`aria-disabled`), and the running one shows its progress label.
@@ -272,7 +272,9 @@ function RowMenuButton({
272
272
  r: "1.3"
273
273
  })]
274
274
  })
275
- }), open && _jsx(RowMenu, {
275
+ }), _jsx(Menu, {
276
+ open: open,
277
+ className: "mdbase-collections-menu",
276
278
  id: menuId,
277
279
  triggerRef: trigger,
278
280
  onClose: close,
@@ -291,28 +293,6 @@ function RowMenuButton({
291
293
  })]
292
294
  });
293
295
  }
294
- function RowMenu({
295
- id,
296
- triggerRef,
297
- onClose,
298
- children
299
- }) {
300
- const menu = useRef(null);
301
- useMenuPopover(menu, triggerRef, onClose, {
302
- align: "end",
303
- focus: '[role="menuitem"]'
304
- });
305
- return _jsx("div", {
306
- ref: menu,
307
- id: id,
308
- className: "mdbase-collections-menu",
309
- popover: "manual",
310
- role: "menu",
311
- tabIndex: -1,
312
- onKeyDown: event => moveMenuFocus(event, menu.current),
313
- children: children
314
- });
315
- }
316
296
  /** The app's actions, Choose a different collection, Manage access, the account and Sign out: never under an error. */
317
297
  export function GateFooter({
318
298
  ui,
@@ -375,58 +355,6 @@ export function AccountLine({
375
355
  })]
376
356
  });
377
357
  }
378
- /** A native modal <dialog>: the browser traps focus and makes the page inert; Escape cancels. */
379
- export function CollectionDialog({
380
- title,
381
- alert = false,
382
- busy = false,
383
- onClose,
384
- children,
385
- footer
386
- }) {
387
- const ref = useRef(null);
388
- const titleId = useId();
389
- useLayoutEffect(() => {
390
- const dialog = ref.current;
391
- const previous = document.activeElement instanceof HTMLElement ? document.activeElement : null;
392
- if (dialog && !dialog.open) {
393
- if (typeof dialog.showModal === "function") dialog.showModal();else dialog.setAttribute("open", "");
394
- }
395
- (dialog?.querySelector("[data-autofocus]") ?? dialog?.querySelector("button"))?.focus();
396
- return () => {
397
- if (dialog?.open && typeof dialog.close === "function") dialog.close();
398
- if (previous?.isConnected) previous.focus();
399
- };
400
- }, []);
401
- return _jsxs("dialog", {
402
- ref: ref,
403
- className: "mdbase-collections mdbase-collections-dialog",
404
- role: alert ? "alertdialog" : undefined,
405
- "aria-labelledby": titleId,
406
- onKeyDown: event => {
407
- event.stopPropagation();
408
- if (event.key === "Escape") {
409
- event.preventDefault();
410
- if (!busy) onClose();
411
- }
412
- },
413
- onCancel: event => {
414
- event.preventDefault();
415
- if (!busy) onClose();
416
- },
417
- children: [_jsx("h2", {
418
- id: titleId,
419
- className: "mdbase-collections-dialog-title",
420
- children: title
421
- }), _jsx("div", {
422
- className: "mdbase-collections-dialog-body",
423
- children: children
424
- }), _jsx("div", {
425
- className: "mdbase-collections-dialog-actions",
426
- children: footer
427
- })]
428
- });
429
- }
430
358
  export function initials(name) {
431
359
  const words = name.replace(/[^\p{L}\p{N}\s]/gu, " ").trim().split(/\s+/u).filter(Boolean);
432
360
  const letters = words.slice(0, 2).map(word => String.fromCodePoint(word.codePointAt(0) ?? 63));