@mdbase-dev/ui 0.1.0-beta.154 → 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 (47) hide show
  1. package/README.md +9 -1
  2. package/css/collections.css +5 -100
  3. package/css/controls.css +65 -34
  4. package/css/feedback.css +6 -6
  5. package/css/motion.css +50 -26
  6. package/css/palette.css +22 -54
  7. package/css/screens.css +19 -0
  8. package/css/toast.css +11 -0
  9. package/css/tokens.css +11 -25
  10. package/dist/AppSwitcher.js +18 -30
  11. package/dist/CommandPalette.d.ts +5 -2
  12. package/dist/CommandPalette.js +157 -152
  13. package/dist/ConfirmDialog.d.ts +14 -0
  14. package/dist/ConfirmDialog.js +65 -0
  15. package/dist/Dialog.d.ts +5 -7
  16. package/dist/Dialog.js +46 -24
  17. package/dist/Feedback.js +24 -56
  18. package/dist/FeedbackMarkup.d.ts +2 -1
  19. package/dist/FeedbackMarkup.js +8 -2
  20. package/dist/Menu.d.ts +10 -0
  21. package/dist/Menu.js +33 -0
  22. package/dist/Select.js +6 -2
  23. package/dist/SelectList.js +2 -1
  24. package/dist/Toaster.d.ts +2 -0
  25. package/dist/Toaster.js +116 -0
  26. package/dist/brand.js +5 -3
  27. package/dist/collections/CollectionSwitcher.d.ts +2 -3
  28. package/dist/collections/CollectionSwitcher.js +14 -173
  29. package/dist/collections/dialogs.d.ts +9 -4
  30. package/dist/collections/dialogs.js +83 -87
  31. package/dist/collections/parts.d.ts +0 -9
  32. package/dist/collections/parts.js +5 -77
  33. package/dist/locales/de/messages.json +1 -1
  34. package/dist/locales/en/messages.json +1 -1
  35. package/dist/locales/es/messages.json +1 -1
  36. package/dist/locales/fr/messages.json +1 -1
  37. package/dist/locales/it/messages.json +1 -1
  38. package/dist/locales/ja/messages.json +1 -1
  39. package/dist/locales/ko/messages.json +1 -1
  40. package/dist/locales/pt/messages.json +1 -1
  41. package/dist/locales/ru/messages.json +1 -1
  42. package/dist/locales/zh/messages.json +1 -1
  43. package/dist/overlay.d.ts +4 -0
  44. package/dist/overlay.js +23 -0
  45. package/dist/popover.d.ts +2 -1
  46. package/dist/popover.js +6 -13
  47. package/package.json +19 -2
package/dist/Dialog.js CHANGED
@@ -1,50 +1,72 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { i18n as _i18n } from "@lingui/core";
3
- import { useLocaleRevision } from "./i18n.js";
4
3
  import { useLayoutEffect, useRef } from "react";
5
- /**
6
- * A modal dialog on the native <dialog>: the browser keeps focus inside it and the page
7
- * behind it inert. Escape, the close button or a press on the backdrop closes it.
8
- */
4
+ import { createPortal } from "react-dom";
5
+ import { useLocaleRevision } from "./i18n.js";
6
+ import { useOverlay } from "./overlay.js";
9
7
  export function Dialog({
10
8
  open,
11
9
  onClose,
12
10
  title,
11
+ descriptionId,
13
12
  className,
14
13
  closeDisabled = false,
14
+ returnFocusRef,
15
15
  children
16
16
  }) {
17
17
  useLocaleRevision();
18
- const ref = useRef(null);
18
+ const {
19
+ ref,
20
+ present
21
+ } = useOverlay(open);
22
+ const invoker = useRef(null);
19
23
  useLayoutEffect(() => {
20
- const previous = document.activeElement instanceof HTMLElement ? document.activeElement : undefined;
21
- return () => {
22
- ref.current?.close();
23
- previous?.focus();
24
- };
25
- }, []);
26
- // A layout effect, so the dialog is open before fields inside it ask to be focused.
24
+ const dialog = ref.current;
25
+ if (!dialog || !open || dialog.open) return;
26
+ const previous = document.querySelector("dialog[open]");
27
+ if (previous && previous !== dialog) {
28
+ previous.dispatchEvent(new Event("cancel", {
29
+ cancelable: true
30
+ }));
31
+ previous.close();
32
+ }
33
+ invoker.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
34
+ dialog.showModal();
35
+ dialog.querySelector("[data-autofocus]")?.focus();
36
+ }, [open, ref]);
27
37
  useLayoutEffect(() => {
28
38
  const dialog = ref.current;
29
- if (!dialog) return;
30
- if (open && !dialog.open) dialog.showModal();else if (!open && dialog.open) dialog.close();
31
- }, [open]);
32
- return _jsx("dialog", {
39
+ return () => {
40
+ const wasOpen = dialog?.open;
41
+ dialog?.close();
42
+ if (wasOpen && !document.querySelector("dialog[open]")) (returnFocusRef?.current ?? invoker.current)?.focus({
43
+ preventScroll: true
44
+ });
45
+ };
46
+ }, [present, ref, returnFocusRef]);
47
+ if (!present) return null;
48
+ return createPortal(_jsx("dialog", {
33
49
  ref: ref,
34
- className: ["mdbase-dialog", className].filter(Boolean).join(" "),
50
+ className: ["mdbase-dialog mdbase-overlay", className].filter(Boolean).join(" "),
51
+ "data-open": open,
52
+ role: "dialog",
35
53
  "aria-label": title,
36
- onKeyDown: event => event.stopPropagation(),
54
+ "aria-describedby": descriptionId,
55
+ onKeyDown: event => {
56
+ event.stopPropagation();
57
+ if (event.key === "Escape") {
58
+ event.preventDefault();
59
+ if (!closeDisabled) onClose();
60
+ }
61
+ },
37
62
  onCancel: event => {
38
63
  event.preventDefault();
39
64
  if (!closeDisabled) onClose();
40
65
  },
41
- onClose: () => {
42
- if (!closeDisabled) onClose();
43
- },
44
66
  onMouseDown: event => {
45
67
  if (!closeDisabled && event.target === event.currentTarget) onClose();
46
68
  },
47
- children: open && _jsxs("div", {
69
+ children: _jsxs("div", {
48
70
  className: "mdbase-dialog-body",
49
71
  children: [_jsxs("header", {
50
72
  className: "mdbase-dialog-header",
@@ -75,5 +97,5 @@ export function Dialog({
75
97
  })]
76
98
  }), children]
77
99
  })
78
- });
100
+ }), document.body);
79
101
  }
package/dist/Feedback.js CHANGED
@@ -1,7 +1,9 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { flushSync } from "react-dom";
2
3
  import { i18n as _i18n } from "@lingui/core";
3
4
  import { useLocaleRevision } from "./i18n.js";
4
5
  import { createContext, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
6
+ import { Dialog } from "./Dialog.js";
5
7
  import { FeedbackMarkup } from "./FeedbackMarkup.js";
6
8
  import { FeedbackVerification } from "./FeedbackVerification.js";
7
9
  import { FEEDBACK_ERROR_CODES, FEEDBACK_MAX_MESSAGE_LENGTH, captureFeedbackScreenshot, feedbackDiagnostics, feedbackEvents, feedbackTopics, readFeedbackScreenshot, resolveFeedbackEndpoint, screenshotUrl, sendFeedback } from "./feedback-data.js";
@@ -96,12 +98,10 @@ export function FeedbackProvider({
96
98
  }) {
97
99
  useLocaleRevision();
98
100
  const endpoint = resolveFeedbackEndpoint(configuredEndpoint ?? undefined);
99
- const dialog = useRef(null);
100
101
  const content = useRef(null);
101
- const messageField = useRef(null);
102
102
  const successHeading = useRef(null);
103
+ const messageField = useRef(null);
103
104
  const body = useRef(null);
104
- const trigger = useRef(null);
105
105
  const events = useRef([]);
106
106
  const lastWiggle = useRef(-Infinity);
107
107
  const imageOperation = useRef(null);
@@ -125,6 +125,9 @@ export function FeedbackProvider({
125
125
  const [submitError, setSubmitError] = useState("");
126
126
  const [submitting, setSubmitting] = useState(false);
127
127
  const [submitted, setSubmitted] = useState(null);
128
+ useEffect(() => {
129
+ if (submitted) successHeading.current?.focus();
130
+ }, [submitted]);
128
131
  const [turnstileToken, setTurnstileToken] = useState("");
129
132
  const [verificationAttempt, setVerificationAttempt] = useState(0);
130
133
  const [wiggle, setWiggle] = useState(0);
@@ -148,7 +151,6 @@ export function FeedbackProvider({
148
151
  }, [wiggle]);
149
152
  const openFeedback = useCallback(next => {
150
153
  if (!endpoint) return;
151
- trigger.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
152
154
  if (next) setTopic(next);
153
155
  setDiagnostics(feedbackDiagnostics(events.current));
154
156
  setOpen(true);
@@ -175,17 +177,6 @@ export function FeedbackProvider({
175
177
  reportError,
176
178
  wiggle
177
179
  }), [endpoint, openFeedback, reportError, wiggle]);
178
- useLayoutEffect(() => {
179
- if (!dialog.current) return;
180
- if (open && !capturing) {
181
- if (!dialog.current.open) dialog.current.showModal();
182
- if (submitted) successHeading.current?.focus({
183
- preventScroll: true
184
- });else messageField.current?.focus({
185
- preventScroll: true
186
- });
187
- } else if (dialog.current.open) dialog.current.close();
188
- }, [open, capturing, submitted]);
189
180
  function resetDraft() {
190
181
  setTopic("problem");
191
182
  setMessage("");
@@ -211,10 +202,6 @@ export function FeedbackProvider({
211
202
  setTurnstileToken("");
212
203
  setVerificationAttempt(value => value + 1);
213
204
  if (submitted) resetDraft();
214
- dialog.current?.close();
215
- trigger.current?.focus({
216
- preventScroll: true
217
- });
218
205
  }
219
206
  async function capture() {
220
207
  if (imageOperation.current || submitting) return;
@@ -222,11 +209,9 @@ export function FeedbackProvider({
222
209
  imageOperation.current = controller;
223
210
  const scroll = body.current?.scrollTop ?? 0;
224
211
  setImageBusy(true);
225
- setCapturing(true);
212
+ flushSync(() => setCapturing(true));
226
213
  setScreenshotError("");
227
214
  setCaptureStatus("");
228
- // Close synchronously, before either the picker or capture stream sees this native modal.
229
- dialog.current?.close();
230
215
  if (content.current) content.current.inert = true;
231
216
  try {
232
217
  const next = await captureFeedbackScreenshot(controller.signal);
@@ -260,7 +245,6 @@ export function FeedbackProvider({
260
245
  if (!controller.signal.aborted && live.current) {
261
246
  setCapturing(false);
262
247
  setImageBusy(false);
263
- if (dialog.current && !dialog.current.open) dialog.current.showModal();
264
248
  if (body.current) body.current.scrollTop = scroll;
265
249
  }
266
250
  }
@@ -373,38 +357,20 @@ export function FeedbackProvider({
373
357
  id: "7qrUoz",
374
358
  message: "A problem occurred. You can use Send feedback to report it."
375
359
  }) : ""
376
- }), endpoint && _jsxs("dialog", {
377
- ref: dialog,
378
- className: "mdbase-feedback-dialog",
379
- "aria-labelledby": `${id}-title`,
380
- onKeyDown: event => event.stopPropagation(),
381
- onCancel: event => {
382
- event.preventDefault();
383
- close();
360
+ }), endpoint && _jsx(Dialog, {
361
+ open: open && !capturing && !markup,
362
+ title: _i18n._(
363
+ /** i18n */
364
+ {
365
+ id: "RoafuO",
366
+ message: "Send feedback"
367
+ }),
368
+ onClose: () => {
369
+ if (!markup) close();
384
370
  },
385
- children: [_jsxs("header", {
386
- className: "mdbase-feedback-header",
387
- children: [_jsx("h2", {
388
- id: `${id}-title`,
389
- children: _i18n._(
390
- /** i18n */
391
- {
392
- id: "RoafuO",
393
- message: "Send feedback"
394
- })
395
- }), _jsx("button", {
396
- type: "button",
397
- disabled: submitting,
398
- onClick: close,
399
- "aria-label": _i18n._(
400
- /** i18n */
401
- {
402
- id: "lnj9gP",
403
- message: "Close feedback"
404
- }),
405
- children: "\u00D7"
406
- })]
407
- }), submitted ? _jsxs("section", {
371
+ closeDisabled: submitting,
372
+ className: `mdbase-feedback-dialog${capturing ? " is-capturing" : ""}`,
373
+ children: submitted ? _jsxs("section", {
408
374
  className: "mdbase-feedback-success",
409
375
  children: [_jsx("h3", {
410
376
  ref: successHeading,
@@ -460,6 +426,7 @@ export function FeedbackProvider({
460
426
  children: [_jsx("span", {
461
427
  children: config.prompt
462
428
  }), _jsx("textarea", {
429
+ "data-autofocus": true,
463
430
  ref: messageField,
464
431
  required: true,
465
432
  maxLength: FEEDBACK_MAX_MESSAGE_LENGTH,
@@ -750,8 +717,9 @@ export function FeedbackProvider({
750
717
  })
751
718
  })]
752
719
  })]
753
- })]
754
- }), markup && screenshot && _jsx(FeedbackMarkup, {
720
+ })
721
+ }), screenshot && _jsx(FeedbackMarkup, {
722
+ open: markup,
755
723
  screenshot: screenshot,
756
724
  onClose: () => {
757
725
  setMarkup(false);
@@ -10,7 +10,8 @@ export interface FeedbackMark {
10
10
  }
11
11
  /** Redactions render last and replace whole pixels. Export is a flattened raster, never layers. */
12
12
  export declare function paintFeedbackMarks(context: CanvasRenderingContext2D, image: CanvasImageSource, marks: readonly FeedbackMark[]): void;
13
- export declare function FeedbackMarkup({ screenshot, onApply, onClose }: {
13
+ export declare function FeedbackMarkup({ open, screenshot, onApply, onClose }: {
14
+ open: boolean;
14
15
  screenshot: FeedbackScreenshot;
15
16
  onApply(screenshot: FeedbackScreenshot, count: number): void;
16
17
  onClose(): void;
@@ -36,6 +36,7 @@ export function paintFeedbackMarks(context, image, marks) {
36
36
  }
37
37
  }
38
38
  export function FeedbackMarkup({
39
+ open,
39
40
  screenshot,
40
41
  onApply,
41
42
  onClose
@@ -65,6 +66,11 @@ export function FeedbackMarkup({
65
66
  }
66
67
  }
67
68
  useEffect(() => {
69
+ if (!open) return;
70
+ setReady(false);
71
+ setTool("draw");
72
+ setCount(0);
73
+ setError("");
68
74
  let live = true;
69
75
  const decoded = new Image();
70
76
  decoded.src = screenshotUrl(screenshot);
@@ -89,7 +95,7 @@ export function FeedbackMarkup({
89
95
  marks.current = [];
90
96
  current.current = null;
91
97
  };
92
- }, [screenshot]);
98
+ }, [open, screenshot]);
93
99
  function finish() {
94
100
  if (current.current && current.current.points.length > 1 && marks.current.length < 100) marks.current.push(current.current);
95
101
  current.current = null;
@@ -105,7 +111,7 @@ export function FeedbackMarkup({
105
111
  };
106
112
  }
107
113
  return _jsxs(Dialog, {
108
- open: true,
114
+ open: open,
109
115
  onClose: onClose,
110
116
  closeDisabled: busy,
111
117
  title: _i18n._(
package/dist/Menu.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import type { ReactNode, RefObject } from "react";
2
+ export declare function Menu({ open, triggerRef, onClose, id, label, className, children }: {
3
+ readonly open: boolean;
4
+ readonly triggerRef: RefObject<HTMLElement | null>;
5
+ readonly onClose: (refocus: boolean) => void;
6
+ readonly id: string;
7
+ readonly label?: string;
8
+ readonly className?: string;
9
+ readonly children: ReactNode;
10
+ }): import("react").JSX.Element | null;
package/dist/Menu.js ADDED
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { moveMenuFocus, useMenuPopover } from "./popover.js";
3
+ import { useOverlay } from "./overlay.js";
4
+ export function Menu({
5
+ open,
6
+ triggerRef,
7
+ onClose,
8
+ id,
9
+ label,
10
+ className = "mdbase-menu",
11
+ children
12
+ }) {
13
+ const {
14
+ ref,
15
+ present
16
+ } = useOverlay(open);
17
+ useMenuPopover(ref, triggerRef, onClose, {
18
+ align: "end",
19
+ open
20
+ });
21
+ return present ? _jsx("div", {
22
+ ref: ref,
23
+ id: id,
24
+ className: `${className} mdbase-overlay`,
25
+ "data-open": open,
26
+ popover: "manual",
27
+ role: "menu",
28
+ "aria-label": label,
29
+ tabIndex: -1,
30
+ onKeyDown: event => moveMenuFocus(event, ref.current),
31
+ children: children
32
+ }) : null;
33
+ }
package/dist/Select.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useId, useLayoutEffect, useRef, useState } from "react";
3
3
  import { edgeOption, extendTypeahead, flattenOptions, stepOption, typeaheadOption } from "./select-model.js";
4
+ import { useOverlay } from "./overlay.js";
4
5
  import { SelectList } from "./SelectList.js";
5
6
  import { useSelectPopover } from "./popover.js";
6
7
  /**
@@ -27,10 +28,13 @@ export function Select({
27
28
  "aria-labelledby": ariaLabelledBy
28
29
  } = trigger;
29
30
  const triggerRef = useRef(null);
30
- const listRef = useRef(null);
31
31
  const options = flattenOptions(items);
32
32
  const selected = options.findIndex(option => option.value === value);
33
33
  const state = useSelectState(options, selected, value, onChange, disabled, triggerRef);
34
+ const {
35
+ ref: listRef,
36
+ present
37
+ } = useOverlay(state.open);
34
38
  useSelectPopover(state.open, triggerRef, listRef, () => state.close(false));
35
39
  useLayoutEffect(() => {
36
40
  if (state.open && listRef.current) {
@@ -76,7 +80,7 @@ export function Select({
76
80
  d: "m7 10 5 5 5-5"
77
81
  })
78
82
  })]
79
- }), _jsx(SelectList, {
83
+ }), present && _jsx(SelectList, {
80
84
  id: id,
81
85
  listRef: listRef,
82
86
  items: items,
@@ -37,7 +37,8 @@ export function SelectList({
37
37
  return _jsx("div", {
38
38
  ref: listRef,
39
39
  id: `${id}-list`,
40
- className: "mdbase-select-list",
40
+ className: "mdbase-select-list mdbase-overlay",
41
+ "data-open": open,
41
42
  popover: "manual",
42
43
  role: "listbox",
43
44
  tabIndex: -1,
@@ -0,0 +1,2 @@
1
+ export declare function toast(message: string, undo?: () => void): void;
2
+ export declare function Toaster(): import("react").JSX.Element;
@@ -0,0 +1,116 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from "react";
3
+ import { useOverlay } from "./overlay.js";
4
+ import { i18n, useLocaleRevision } from "./i18n.js";
5
+ let queue = [];
6
+ let nextId = 0;
7
+ const listeners = new Set();
8
+ const notify = () => listeners.forEach(listener => listener());
9
+ export function toast(message, undo) {
10
+ const active = queue.filter(item => item.open);
11
+ if (active.length >= 4) active[1].open = false;
12
+ queue.push({
13
+ id: ++nextId,
14
+ message,
15
+ undo,
16
+ open: true
17
+ });
18
+ notify();
19
+ }
20
+ export function Toaster() {
21
+ useLocaleRevision();
22
+ const [items, setItems] = useState(() => [...queue]);
23
+ useEffect(() => {
24
+ const update = () => setItems([...queue]);
25
+ listeners.add(update);
26
+ update();
27
+ return () => {
28
+ listeners.delete(update);
29
+ void Promise.resolve().then(() => {
30
+ if (!listeners.size) queue.length = 0;
31
+ });
32
+ };
33
+ }, []);
34
+ return _jsx("div", {
35
+ className: "mdbase-toaster",
36
+ role: "status",
37
+ "aria-live": "polite",
38
+ "aria-relevant": "additions text",
39
+ children: items.map(item => _jsx(ToastItem, {
40
+ item: item
41
+ }, item.id))
42
+ });
43
+ }
44
+ function ToastItem({
45
+ item
46
+ }) {
47
+ const {
48
+ ref,
49
+ present
50
+ } = useOverlay(item.open);
51
+ const [hovered, setHovered] = useState(false);
52
+ const [focused, setFocused] = useState(false);
53
+ const remaining = useRef(item.undo ? 8_000 : 5_000);
54
+ useEffect(() => {
55
+ if (!present) {
56
+ queue = queue.filter(current => current !== item);
57
+ notify();
58
+ }
59
+ }, [present, item]);
60
+ const dismiss = () => {
61
+ item.open = false;
62
+ notify();
63
+ };
64
+ useEffect(() => {
65
+ if (!item.open || hovered || focused) return;
66
+ const started = Date.now();
67
+ const timeout = setTimeout(dismiss, remaining.current);
68
+ return () => {
69
+ clearTimeout(timeout);
70
+ remaining.current -= Date.now() - started;
71
+ };
72
+ }, [item.open, hovered, focused]);
73
+ if (!present) return null;
74
+ return _jsx("div", {
75
+ ref: ref,
76
+ "data-open": item.open,
77
+ className: "mdbase-toast-slot",
78
+ inert: !item.open,
79
+ onMouseEnter: () => setHovered(true),
80
+ onMouseLeave: () => setHovered(false),
81
+ onFocus: () => setFocused(true),
82
+ onBlur: event => {
83
+ if (!event.currentTarget.contains(event.relatedTarget)) setFocused(false);
84
+ },
85
+ children: _jsx("div", {
86
+ className: "mdbase-toast-clip",
87
+ children: _jsxs("div", {
88
+ className: "mdbase-toast",
89
+ children: [_jsx("span", {
90
+ children: item.message
91
+ }), item.undo && _jsx("button", {
92
+ className: "mdbase-button is-secondary",
93
+ onClick: () => {
94
+ dismiss();
95
+ item.undo?.();
96
+ },
97
+ children: i18n._(
98
+ /** i18n */
99
+ {
100
+ id: "9uI_rE",
101
+ message: "Undo"
102
+ })
103
+ }), _jsx("button", {
104
+ className: "mdbase-button is-tertiary",
105
+ onClick: dismiss,
106
+ children: i18n._(
107
+ /** i18n */
108
+ {
109
+ id: "1QfxQT",
110
+ message: "Dismiss"
111
+ })
112
+ })]
113
+ })
114
+ })
115
+ });
116
+ }
package/dist/brand.js CHANGED
@@ -7,6 +7,7 @@ export const mdbaseMarkEntrances = ["keys-first", "drop", "assemble"];
7
7
  export const mdbaseMarkMotions = [...mdbaseMarkLoops, ...mdbaseMarkEntrances];
8
8
  /** Long enough for each entrance in `motion.css` to finish. */
9
9
  const ENTRANCE_MS = 1300;
10
+ let buildOwner;
10
11
  export function mdbaseMarkMotionClass(motion) {
11
12
  return motion ? ` mdbase-motion-${motion}` : "";
12
13
  }
@@ -148,17 +149,18 @@ export function MdbaseMark({
148
149
  const uid = useId().replaceAll(":", "");
149
150
  // An entrance plays once per mark. Dropping its class afterwards stops it replaying when a signal
150
151
  // remounts the lines, and remembering it stops a replay when a loop or progress hands back to it.
151
- const [entering, setEntering] = useState(isEntrance(motion));
152
+ const [entering, setEntering] = useState(isEntrance(motion) && (motion !== "keys-first" || !buildOwner));
152
153
  const played = useRef(undefined);
153
154
  useEffect(() => {
154
- if (!isEntrance(motion) || played.current === motion) return setEntering(false);
155
+ if (!isEntrance(motion) || played.current === motion || motion === "keys-first" && buildOwner !== undefined && buildOwner !== uid) return setEntering(false);
156
+ if (motion === "keys-first") buildOwner = uid;
155
157
  setEntering(true);
156
158
  const timer = setTimeout(() => {
157
159
  played.current = motion;
158
160
  setEntering(false);
159
161
  }, ENTRANCE_MS);
160
162
  return () => clearTimeout(timer);
161
- }, [motion]);
163
+ }, [motion, uid]);
162
164
  const showsProgress = typeof progress === "number" && Number.isFinite(progress);
163
165
  const active = signal ? undefined : showsProgress ? undefined : isEntrance(motion) ? entering ? motion : undefined : motion;
164
166
  const lines = _jsx(Lines, {
@@ -27,15 +27,14 @@ export type CollectionSwitcherProps = CollectionUiOptions & {
27
27
  readonly variant: "none";
28
28
  /**
29
29
  * The app's element the switcher belongs to, such as the button of the menu
30
- * that offered it. The wide-screen popover is placed against it and focus
31
- * returns to it on close. It must stay mounted while the switcher is open.
30
+ * that offered it. Focus returns to it on close. It must stay mounted while the switcher is open.
32
31
  */
33
32
  readonly anchorRef: RefObject<HTMLElement | null>;
34
33
  });
35
34
  /**
36
35
  * The in-app collection switcher: a trigger that opens the approved collections
37
36
  * (one click switches, no Connect window), "Add a collection…", "Manage access"
38
- * and the account. A popover on wide screens, a bottom sheet on narrow ones.
37
+ * and the account in a modal collection chooser.
39
38
  *
40
39
  * Pass `open` and `onOpenChange` to control it. With `variant="none"` it has no
41
40
  * trigger, so an app can open it from its own control and pass that control's