@lablup/ui-common 0.2.0-alpha.17 → 0.2.0-alpha.19

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 (173) hide show
  1. package/README.md +3 -2
  2. package/astryx/components/Board.doc.mjs +122 -0
  3. package/astryx/components/Board.tsx +3 -0
  4. package/astryx/components/Form.doc.mjs +1 -1
  5. package/astryx/docs/ui-common.doc.mjs +1 -1
  6. package/dist/assets/components/Board/Board.css +2 -0
  7. package/dist/assets/components/Form/FormItemVisual.css +1 -1
  8. package/dist/astryx/DateInput/tokens.stylex.d.ts +1 -0
  9. package/dist/astryx/DateInput/tokens.stylex.js +1 -0
  10. package/dist/astryx/Icon/IconSize.stylex.d.ts +1 -0
  11. package/dist/astryx/Icon/IconSize.stylex.js +1 -0
  12. package/dist/astryx/Indicator/indicator.markers.stylex.d.ts +1 -0
  13. package/dist/astryx/Indicator/indicator.markers.stylex.js +1 -0
  14. package/dist/astryx/Layer/layerAnimations.stylex.d.ts +1 -0
  15. package/dist/astryx/Layer/layerAnimations.stylex.js +1 -0
  16. package/dist/astryx/Layer/layerTextReset.stylex.d.ts +1 -0
  17. package/dist/astryx/Layer/layerTextReset.stylex.js +1 -0
  18. package/dist/astryx/Layer/layerViewportInset.stylex.d.ts +1 -0
  19. package/dist/astryx/Layer/layerViewportInset.stylex.js +1 -0
  20. package/dist/astryx/Layout/container.stylex.d.ts +1 -0
  21. package/dist/astryx/Layout/container.stylex.js +1 -0
  22. package/dist/astryx/Layout/edgeCompensation.stylex.d.ts +1 -0
  23. package/dist/astryx/Layout/edgeCompensation.stylex.js +1 -0
  24. package/dist/astryx/Layout/padding.stylex.d.ts +1 -0
  25. package/dist/astryx/Layout/padding.stylex.js +1 -0
  26. package/dist/astryx/Markdown/plugin-renderer.d.ts +1 -0
  27. package/dist/astryx/Markdown/plugin-renderer.js +1 -0
  28. package/dist/astryx/NavItem/navItemStyles.stylex.d.ts +1 -0
  29. package/dist/astryx/NavItem/navItemStyles.stylex.js +1 -0
  30. package/dist/astryx/Selector/selectorPresentation.stylex.d.ts +1 -0
  31. package/dist/astryx/Selector/selectorPresentation.stylex.js +1 -0
  32. package/dist/astryx/Stack/stack.stylex.d.ts +1 -0
  33. package/dist/astryx/Stack/stack.stylex.js +1 -0
  34. package/dist/astryx/Stack/stackItem.stylex.d.ts +1 -0
  35. package/dist/astryx/Stack/stackItem.stylex.js +1 -0
  36. package/dist/astryx/Text/text.stylex.d.ts +1 -0
  37. package/dist/astryx/Text/text.stylex.js +1 -0
  38. package/dist/astryx/theme/dataTokens.stylex.d.ts +1 -0
  39. package/dist/astryx/theme/dataTokens.stylex.js +1 -0
  40. package/dist/astryx/theme/neutral/fonts.css +3 -0
  41. package/dist/astryx/utils/focusOutline.stylex.d.ts +1 -0
  42. package/dist/astryx/utils/focusOutline.stylex.js +1 -0
  43. package/dist/astryx/utils/interactionOverlay.stylex.d.ts +1 -0
  44. package/dist/astryx/utils/interactionOverlay.stylex.js +1 -0
  45. package/dist/components/Board/Board.d.ts +102 -0
  46. package/dist/components/Board/Board.messages.d.ts +62 -0
  47. package/dist/components/Board/Board.messages.js +68 -0
  48. package/dist/components/Board/Board.messages.js.map +1 -0
  49. package/dist/components/Board/Board2.js +607 -0
  50. package/dist/components/Board/Board2.js.map +1 -0
  51. package/dist/components/Board/engine.d.ts +60 -0
  52. package/dist/components/Board/engine.js +397 -0
  53. package/dist/components/Board/engine.js.map +1 -0
  54. package/dist/components/Board/index.d.ts +4 -0
  55. package/dist/components/Board/index.js +3 -0
  56. package/dist/components/Board/layout.d.ts +81 -0
  57. package/dist/components/Board/layout.js +67 -0
  58. package/dist/components/Board/layout.js.map +1 -0
  59. package/dist/components/Board/scroll.d.ts +38 -0
  60. package/dist/components/Board/scroll.js +42 -0
  61. package/dist/components/Board/scroll.js.map +1 -0
  62. package/dist/components/DataGrid/DataGrid2.js +128 -128
  63. package/dist/components/DataGrid/DataGrid2.js.map +1 -1
  64. package/dist/components/Form/FormItem.d.ts +6 -1
  65. package/dist/components/Form/FormItem.js +68 -67
  66. package/dist/components/Form/FormItem.js.map +1 -1
  67. package/dist/components/Form/FormItemVisual.d.ts +7 -0
  68. package/dist/components/Form/FormItemVisual2.js +60 -55
  69. package/dist/components/Form/FormItemVisual2.js.map +1 -1
  70. package/dist/components/NotificationStack/NotificationStack2.js +1 -0
  71. package/dist/components/NotificationStack/NotificationStack2.js.map +1 -1
  72. package/dist/components/PageHeader/PageHeader2.js +4 -4
  73. package/dist/components/PagedSelector/PagedSelector.d.ts +1 -1
  74. package/dist/components/PagedSelector/PagedSelector2.js +37 -37
  75. package/dist/components/PagedSelector/PagedSelector2.js.map +1 -1
  76. package/dist/components/SelectionLabel/SelectionLabel.js +4 -4
  77. package/dist/forks/ComplexSelector/ComplexSelector.d.ts +82 -6
  78. package/dist/forks/ComplexSelector/ComplexSelector.js +170 -114
  79. package/dist/forks/ComplexSelector/ComplexSelector.js.map +1 -1
  80. package/dist/forks/ComplexSelector/ComplexSelector.styles.d.ts +40 -0
  81. package/dist/forks/ComplexSelector/ComplexSelector.styles.js +46 -6
  82. package/dist/forks/ComplexSelector/ComplexSelector.styles.js.map +1 -1
  83. package/dist/forks/ComplexSelector/index.d.ts +1 -1
  84. package/dist/forks/Drawer/Drawer.d.ts +21 -3
  85. package/dist/forks/Drawer/Drawer.js +70 -65
  86. package/dist/forks/Drawer/Drawer.js.map +1 -1
  87. package/dist/forks/Drawer/Drawer.styles.d.ts +16 -0
  88. package/dist/forks/Drawer/Drawer.styles.js +16 -0
  89. package/dist/forks/Drawer/Drawer.styles.js.map +1 -1
  90. package/dist/forks/Drawer/useDrawerDialogPresence.js.map +1 -1
  91. package/dist/forks/Tour/Tour.js +38 -40
  92. package/dist/forks/Tour/Tour.js.map +1 -1
  93. package/dist/forks/Tour/TourContext.js.map +1 -1
  94. package/dist/forks/Tour/TourStep.js.map +1 -1
  95. package/dist/forks/Tour/TourStep.styles.js.map +1 -1
  96. package/dist/forks/Tour/useTour.js.map +1 -1
  97. package/dist/i18n/catalog.js +27 -25
  98. package/dist/i18n/catalog.js.map +1 -1
  99. package/dist/i18n/locales/de-DE.js +60 -0
  100. package/dist/i18n/locales/de-DE.js.map +1 -1
  101. package/dist/i18n/locales/el-GR.js +60 -0
  102. package/dist/i18n/locales/el-GR.js.map +1 -1
  103. package/dist/i18n/locales/es-ES.js +60 -0
  104. package/dist/i18n/locales/es-ES.js.map +1 -1
  105. package/dist/i18n/locales/fi-FI.js +60 -0
  106. package/dist/i18n/locales/fi-FI.js.map +1 -1
  107. package/dist/i18n/locales/fr-FR.js +60 -0
  108. package/dist/i18n/locales/fr-FR.js.map +1 -1
  109. package/dist/i18n/locales/id-ID.js +60 -0
  110. package/dist/i18n/locales/id-ID.js.map +1 -1
  111. package/dist/i18n/locales/it-IT.js +60 -0
  112. package/dist/i18n/locales/it-IT.js.map +1 -1
  113. package/dist/i18n/locales/ja-JP.js +60 -0
  114. package/dist/i18n/locales/ja-JP.js.map +1 -1
  115. package/dist/i18n/locales/ko-KR.js +60 -0
  116. package/dist/i18n/locales/ko-KR.js.map +1 -1
  117. package/dist/i18n/locales/mn-MN.js +60 -0
  118. package/dist/i18n/locales/mn-MN.js.map +1 -1
  119. package/dist/i18n/locales/ms-MY.js +60 -0
  120. package/dist/i18n/locales/ms-MY.js.map +1 -1
  121. package/dist/i18n/locales/pl-PL.js +60 -0
  122. package/dist/i18n/locales/pl-PL.js.map +1 -1
  123. package/dist/i18n/locales/pt-BR.js +60 -0
  124. package/dist/i18n/locales/pt-BR.js.map +1 -1
  125. package/dist/i18n/locales/pt-PT.js +60 -0
  126. package/dist/i18n/locales/pt-PT.js.map +1 -1
  127. package/dist/i18n/locales/ru-RU.js +60 -0
  128. package/dist/i18n/locales/ru-RU.js.map +1 -1
  129. package/dist/i18n/locales/th-TH.js +60 -0
  130. package/dist/i18n/locales/th-TH.js.map +1 -1
  131. package/dist/i18n/locales/tr-TR.js +60 -0
  132. package/dist/i18n/locales/tr-TR.js.map +1 -1
  133. package/dist/i18n/locales/vi-VN.js +60 -0
  134. package/dist/i18n/locales/vi-VN.js.map +1 -1
  135. package/dist/i18n/locales/zh-CN.js +60 -0
  136. package/dist/i18n/locales/zh-CN.js.map +1 -1
  137. package/dist/i18n/locales/zh-TW.js +60 -0
  138. package/dist/i18n/locales/zh-TW.js.map +1 -1
  139. package/dist/index.d.ts +7 -5
  140. package/dist/index.js +61 -59
  141. package/dist/instance.js +2 -2
  142. package/dist/locales/en.generated.js +34 -0
  143. package/dist/locales/en.json +136 -0
  144. package/dist/locales/pseudo.generated.js +34 -0
  145. package/dist/locales/pseudo.json +102 -0
  146. package/dist/theme/lablup/built/lablup.d.ts +3 -3
  147. package/dist/theme/lablup/built/lablup.js +24 -5
  148. package/dist/theme/lablup/built/lablup.variants.d.ts +2 -2
  149. package/dist/theme/lablup/built/theme.css +70 -63
  150. package/dist/theme/lablup/built/theme.css.d.ts +9 -0
  151. package/dist/ui-common-locales/de-DE.json +60 -0
  152. package/dist/ui-common-locales/el-GR.json +60 -0
  153. package/dist/ui-common-locales/en.json +60 -0
  154. package/dist/ui-common-locales/es-ES.json +60 -0
  155. package/dist/ui-common-locales/fi-FI.json +60 -0
  156. package/dist/ui-common-locales/fr-FR.json +60 -0
  157. package/dist/ui-common-locales/id-ID.json +60 -0
  158. package/dist/ui-common-locales/it-IT.json +60 -0
  159. package/dist/ui-common-locales/ja-JP.json +60 -0
  160. package/dist/ui-common-locales/ko-KR.json +60 -0
  161. package/dist/ui-common-locales/mn-MN.json +60 -0
  162. package/dist/ui-common-locales/ms-MY.json +60 -0
  163. package/dist/ui-common-locales/pl-PL.json +60 -0
  164. package/dist/ui-common-locales/pt-BR.json +60 -0
  165. package/dist/ui-common-locales/pt-PT.json +60 -0
  166. package/dist/ui-common-locales/ru-RU.json +60 -0
  167. package/dist/ui-common-locales/th-TH.json +60 -0
  168. package/dist/ui-common-locales/tr-TR.json +60 -0
  169. package/dist/ui-common-locales/vi-VN.json +60 -0
  170. package/dist/ui-common-locales/zh-CN.json +60 -0
  171. package/dist/ui-common-locales/zh-TW.json +60 -0
  172. package/exports.customs.json +1 -0
  173. package/package.json +86 -6
@@ -4,4 +4,4 @@
4
4
  * (facebook/astryx#6362). Astryx's is excluded (exports.exclude.json).
5
5
  */
6
6
  export { ComplexSelector } from './ComplexSelector';
7
- export type { ComplexSelectorHandle, ComplexSelectorProps, ComplexSelectorRenderState, ComplexSelectorSize, ComplexSelectorStatus, ComplexSelectorVariant, } from './ComplexSelector';
7
+ export type { ComplexSelectorHandle, ComplexSelectorProps, ComplexSelectorRenderState, ComplexSelectorRenderTriggerProps, ComplexSelectorSize, ComplexSelectorStatus, ComplexSelectorVariant, } from './ComplexSelector';
@@ -1,6 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { BaseProps } from '@astryxdesign/core';
3
3
  import { DialogPurpose } from '@astryxdesign/core/Dialog';
4
+ import { SpacingStep } from '@astryxdesign/core/Layout';
4
5
  export interface DrawerProps extends BaseProps<HTMLDialogElement> {
5
6
  /** Ref forwarded to the root <dialog> element */
6
7
  ref?: React.Ref<HTMLDialogElement>;
@@ -64,6 +65,16 @@ export interface DrawerProps extends BaseProps<HTMLDialogElement> {
64
65
  * @default 'info'
65
66
  */
66
67
  purpose?: DialogPurpose;
68
+ /**
69
+ * Internal padding of the drawer content using the spacing scale, matching
70
+ * Dialog. Accepts numeric spacing steps: 0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8,
71
+ * 10. When omitted, uses the theme default for drawers (`--spacing-4`, 16px,
72
+ * unless the theme sets `padding` on `drawer`), as Dialog does. Pass `0` for
73
+ * a full-bleed content area. The content area is a container: a Section that
74
+ * is its only child escapes the padding, bleed children such as Table and
75
+ * Divider compensate against it, and a Layout picks it up for its regions.
76
+ */
77
+ padding?: SpacingStep;
67
78
  /**
68
79
  * Drawer content. Rendered inside a full-height scrollable area.
69
80
  * Focus the element with `data-autofocus` on open, if present.
@@ -90,6 +101,11 @@ export interface DrawerProps extends BaseProps<HTMLDialogElement> {
90
101
  * close the drawer, and `DrawerHeader` renders a close button when given
91
102
  * `onOpenChange`.
92
103
  *
104
+ * Like Dialog, the drawer is a container: `padding` (or a theme's `padding`
105
+ * on `drawer`) insets the content area, a lone Section child escapes that
106
+ * inset, and a Layout inside picks it up for its header, content, and footer
107
+ * regions. The default inset is `--spacing-4`, matching Dialog.
108
+ *
93
109
  * @example
94
110
  * ```
95
111
  * const [selected, setSelected] = useState(null);
@@ -98,12 +114,14 @@ export interface DrawerProps extends BaseProps<HTMLDialogElement> {
98
114
  * isOpen={selected != null}
99
115
  * onOpenChange={handleOpenChange}
100
116
  * label={`Details: ${selected?.name}`}>
101
- * <DrawerHeader title={selected?.name} onOpenChange={handleOpenChange} />
102
- * <HostDetails host={selected} />
117
+ * <Layout
118
+ * header={<DrawerHeader title={selected?.name} onOpenChange={handleOpenChange} />}
119
+ * content={<LayoutContent><HostDetails host={selected} /></LayoutContent>}
120
+ * />
103
121
  * </Drawer>
104
122
  * ```
105
123
  */
106
- export declare function Drawer({ isOpen, onOpenChange, side, width, isFullWidthOnMobile, label, hasScrim, purpose, children, xstyle, className, style, onClick: onClickProp, onKeyDown: onKeyDownProp, ref, ...props }: DrawerProps): import("react").JSX.Element;
124
+ export declare function Drawer({ isOpen, onOpenChange, side, width, isFullWidthOnMobile, label, hasScrim, purpose, padding, children, xstyle, className, style, onClick: onClickProp, onKeyDown: onKeyDownProp, ref, ...props }: DrawerProps): import("react").JSX.Element;
107
125
  export declare namespace Drawer {
108
126
  var displayName: string;
109
127
  }
@@ -3,92 +3,97 @@ import { ModalPortalContext as e, modalZIndexBase as t } from "../../components/
3
3
  import { compiledStyles as n } from "../compiled.js";
4
4
  import { dynamicStyles as r, styles as i } from "./Drawer.styles.js";
5
5
  import { useDrawerDialogPresence as a } from "./useDrawerDialogPresence.js";
6
- import { useCallback as o, useEffect as s, useId as ee, useRef as c, useState as l } from "react";
7
- import { overlayPaddingReset as te } from "@astryxdesign/core/Layout";
8
- import { useFocusTrap as u, useMergedRefs as d, useScrollLock as f } from "@astryxdesign/core/hooks";
9
- import { LayerDepthProvider as p, useLayerDismissal as m } from "@astryxdesign/core/Layer";
10
- import { composeEventHandlers as ne, mergeProps as h, themeProps as g } from "@astryxdesign/core/utils";
11
- import { jsx as _ } from "react/jsx-runtime";
12
- import * as v from "@stylexjs/stylex";
6
+ import { useCallback as o, useEffect as s, useId as c, useRef as l, useState as u } from "react";
7
+ import { container as ee, overlayPaddingReset as te } from "@astryxdesign/core/Layout";
8
+ import { useFocusTrap as ne, useMergedRefs as re, useScrollLock as d } from "@astryxdesign/core/hooks";
9
+ import { LayerDepthProvider as f, useLayerDismissal as ie } from "@astryxdesign/core/Layer";
10
+ import { composeEventHandlers as p, mergeProps as m, themeProps as h } from "@astryxdesign/core/utils";
11
+ import { jsx as g } from "react/jsx-runtime";
12
+ import * as _ from "@stylexjs/stylex";
13
+ import { containerPaddingBlockEndVarStyles as ae, containerPaddingBlockStartVarStyles as v, containerPaddingInlineVarStyles as oe, paddingStyles as y, spacingStepToToken as b } from "@astryxdesign/core/Layout/padding.stylex";
13
14
  //#region src/forks/Drawer/Drawer.tsx
14
- var y = 56, re = "100dvw", b = n(i), ie = r, ae = 1e3, x = /* @__PURE__ */ new Map();
15
- function oe(e) {
16
- let n = Math.max(999, ...x.values()), r = Math.min(n + 1, t() - 1);
17
- return x.set(e, r), r;
15
+ var x = 56, se = "100dvw", S = n(i), ce = r, le = 1e3, C = /* @__PURE__ */ new Map();
16
+ function ue(e) {
17
+ let n = Math.max(999, ...C.values()), r = Math.min(n + 1, t() - 1);
18
+ return C.set(e, r), r;
18
19
  }
19
- function S(e) {
20
- x.delete(e);
20
+ function w(e) {
21
+ C.delete(e);
21
22
  }
22
- var C = "x1iyjqo2 x2lwn1j xh8yej3 x1odjw0f x6ikm8r xish69e xx69xxh x1a148e8 x1a2a7pz";
23
- function w({ isOpen: t, onOpenChange: n, side: r = "end", width: i = 400, isFullWidthOnMobile: x = !1, label: w, hasScrim: T = !0, purpose: E = "info", children: D, xstyle: O, className: k, style: A, onClick: j, onKeyDown: M, ref: N, ...P }) {
24
- let F = c(null), { containerRef: I } = u({ isActive: t && T }), L = d(N, F, I), R = E !== "required", z = E === "info", [B, V] = l(t);
25
- t && !B && V(!0), a({
26
- dialogRef: F,
23
+ function T({ isOpen: t, onOpenChange: n, side: r = "end", width: i = 400, isFullWidthOnMobile: C = !1, label: T, hasScrim: E = !0, purpose: D = "info", padding: O, children: k, xstyle: A, className: j, style: M, onClick: N, onKeyDown: P, ref: F, ...I }) {
24
+ let L = l(null), { containerRef: R } = ne({ isActive: t && E }), z = re(F, L, R), B = D !== "required", V = D === "info", H = O == null, U = O ?? 4, W = b[U], [G, K] = u(t);
25
+ t && !G && K(!0), a({
26
+ dialogRef: L,
27
27
  isOpen: t,
28
- isModal: T,
29
- setIsRendered: V
28
+ isModal: E,
29
+ setIsRendered: K
30
30
  });
31
- let [H, U] = l(null);
31
+ let [de, fe] = u(null);
32
32
  s(() => {
33
- U(t && T ? F.current : null);
34
- }, [t, T]);
35
- let W = ee(), [G, K] = l(ae);
33
+ fe(t && E ? L.current : null);
34
+ }, [t, E]);
35
+ let q = c(), [pe, me] = u(le);
36
36
  s(() => {
37
- if (!(!B || T)) return K(oe(W)), () => S(W);
37
+ if (!(!G || E)) return me(ue(q)), () => w(q);
38
38
  }, [
39
- B,
40
- T,
41
- W
39
+ G,
40
+ E,
41
+ q
42
42
  ]);
43
- let q = o(() => {
43
+ let J = o(() => {
44
44
  n(!1);
45
- }, [n]), { shouldDismissOnCloseRequest: J } = m({
46
- isActive: B,
47
- escapeBehavior: R ? "close" : "block",
48
- onDismiss: q,
49
- getContainer: () => F.current
45
+ }, [n]), { shouldDismissOnCloseRequest: Y } = ie({
46
+ isActive: G,
47
+ escapeBehavior: B ? "close" : "block",
48
+ onDismiss: J,
49
+ getContainer: () => L.current
50
50
  });
51
- f(t && T);
52
- let se = o((e) => {
53
- e.preventDefault(), J() && R && q();
51
+ d(t && E);
52
+ let he = o((e) => {
53
+ e.preventDefault(), Y() && B && J();
54
54
  }, [
55
- R,
56
- q,
57
- J
58
- ]), ce = o((e) => {
59
- e.target === e.currentTarget && T && z && n(!1);
55
+ B,
56
+ J,
57
+ Y
58
+ ]), ge = o((e) => {
59
+ e.target === e.currentTarget && E && V && n(!1);
60
60
  }, [
61
- z,
62
- T,
61
+ V,
62
+ E,
63
63
  n
64
- ]), Y = typeof i == "number" ? `${i}px` : i, le = x ? re : `min(${Y}, calc(100dvw - ${y}px))`, X = c(r);
65
- t && (X.current = r);
66
- let Z = t ? r : X.current, ue = Z === "start" ? b.start : b.end, Q = Z === "start" ? b.startOpen : b.endOpen, { open: de, ...$ } = P;
67
- return /* @__PURE__ */ _("dialog", {
68
- ref: L,
69
- ...h(g("drawer", { side: Z }), v.props(b.dialog, te.reset, ue, ie.inlineSize(Y, le), B && b.rendered, t && Q, T && b.scrim, T && t && b.scrimOpen, O), k, T ? A : {
70
- zIndex: G,
71
- ...A
64
+ ]), X = typeof i == "number" ? `${i}px` : i, _e = C ? se : `min(${X}, calc(100dvw - ${x}px))`, Z = l(r);
65
+ t && (Z.current = r);
66
+ let Q = t ? r : Z.current, ve = Q === "start" ? S.start : S.end, ye = Q === "start" ? S.startOpen : S.endOpen, { open: be, ...$ } = I;
67
+ return /* @__PURE__ */ g("dialog", {
68
+ ref: z,
69
+ ...m(h("drawer", { side: Q }), _.props(S.dialog, te.reset, ve, ce.inlineSize(X, _e), G && S.rendered, t && ye, E && S.scrim, E && t && S.scrimOpen, A), j, E ? M : {
70
+ zIndex: pe,
71
+ ...M
72
72
  }),
73
73
  ...$,
74
- "aria-label": w,
75
- "aria-modal": $["aria-modal"] ?? (T ? "true" : void 0),
76
- ...E === "required" && T ? { role: "alertdialog" } : void 0,
77
- onClick: ne(j, ce),
78
- onKeyDown: M,
79
- onCancel: se,
80
- children: /* @__PURE__ */ _(p, { children: /* @__PURE__ */ _("div", {
74
+ "aria-label": T,
75
+ "aria-modal": $["aria-modal"] ?? (E ? "true" : void 0),
76
+ ...D === "required" && E ? { role: "alertdialog" } : void 0,
77
+ onClick: p(N, ge),
78
+ onKeyDown: P,
79
+ onCancel: he,
80
+ children: /* @__PURE__ */ g(f, { children: /* @__PURE__ */ g("div", {
81
81
  tabIndex: -1,
82
- className: C,
83
- children: /* @__PURE__ */ _(e, {
84
- value: H,
85
- children: D
82
+ ..._.props(S.content, ...ee(H ? { useThemeDefault: "drawer" } : {
83
+ paddingInnerX: W,
84
+ paddingInnerY: W,
85
+ paddingOuterX: W,
86
+ paddingOuterY: W
87
+ }), !H && U !== 4 && y[U], !H && U !== 4 && oe[U], !H && U !== 4 && v[U], !H && U !== 4 && ae[U], S.contentSafeArea),
88
+ children: /* @__PURE__ */ g(e, {
89
+ value: de,
90
+ children: k
86
91
  })
87
92
  }) })
88
93
  });
89
94
  }
90
- w.displayName = "Drawer";
95
+ T.displayName = "Drawer";
91
96
  //#endregion
92
- export { w as Drawer };
97
+ export { T as Drawer };
93
98
 
94
99
  //# sourceMappingURL=Drawer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Drawer.js","names":[],"sources":["../../../src/forks/Drawer/Drawer.tsx"],"sourcesContent":["// Copyright (c) Meta Platforms, Inc. and affiliates.\n// Modifications copyright (c) Lablup Inc.\n//\n// Forked from @astryxdesign/lab 0.6.5-canary.8701623, src/Drawer/Drawer.tsx\n// (MIT; see NOTICE). Provenance and the drift guard: src/forks/provenance.json.\n\n\"use client\";\n\n/**\n * Drawer, ui-common's copy of Astryx lab's, with three changes (not upstream):\n *\n * - **A scrimless drawer stays out of the top layer.** lab 0.6.5 opens it as\n * a manual popover; this copy keeps the `show()` + z-index it had before\n * (base 1000, later drawers above), because ui-common's `Modal` and\n * notification stack are z-index surfaces: a top-layer drawer painted over\n * a confirm or a notification opened while it was up, and the modal stack\n * then inerted the drawer it could not cover.\n * - **`aria-modal` passes through.** A scrimless drawer is non-modal, but a\n * consumer that restores modality by hand (its own mask and focus trap) can\n * now say so; the default is unchanged.\n * - **ui-common's `Modal` opens above a scrimmed drawer.** That drawer is a\n * modal `<dialog>`, top layer and inerting everything outside it, so a\n * `Modal` portalled to the body sat behind it, unreachable. The drawer\n * provides its dialog through `ModalPortalContext` while it is open and\n * modal, and a `Modal` inside renders there and enters the top layer\n * after it (modalStack.ts).\n *\n * Escape routing is upstream's since lab 0.6.5: the drawer registers with\n * core's layer-dismissal stack, so a popover, selector or modal opened inside\n * it closes first and nested drawers close top-first. Everything else is\n * upstream's too. Its style namespaces are Astryx's compiled output\n * (src/forks/compiled.ts).\n *\n * Delete this fork, and its exports.exclude.json entry, once ui-common's\n * `Modal` and notification stack are top layer themselves and lab passes\n * `aria-modal` through (CONTRIBUTING, \"Forks of Astryx components\").\n */\n\n/*\n * Upstream's file notes, kept:\n *\n * Overlay panel for inspectors and detail views — the \"click a table row,\n * see its details\" pattern. Slides in from the inline start or end edge and\n * floats above the page content: unlike a docked panel it never reflows the\n * layout underneath, it overlays it (with or without a scrim).\n *\n * Inline axis only (start/end). Block-axis sheets are BottomSheet's job;\n * a drawer is always a full-height side panel.\n *\n * Sizing is viewport-aware: `width` is the desktop budget, and below\n * the mobile breakpoint it preserves a 56px reveal of the page behind, capped\n * by the requested width (or fills the viewport with `isFullWidthOnMobile`).\n *\n * Uses the native `<dialog>` element (same precedent as Dialog/MobileNav):\n * - `showModal()` when `hasScrim` (default) — top-layer rendering, focus\n * trapping, `::backdrop`, no z-index management.\n * - `showPopover()` when `hasScrim={false}` — non-modal top-layer overlay;\n * the page behind stays interactive (e.g. master-detail inspectors).\n * (ui-common: `show()` and a z-index instead; see the header above.)\n *\n * Entry animation uses `@starting-style`; exit slides out before the active\n * modal-dialog or manual-popover host releases the top layer and focus returns\n * to the element that opened the drawer. React owns `display` for both legs\n * rather than a discrete `display` transition, so the panel stops painting in\n * the same commit as the host closes — see the `rendered` style for why.\n *\n * Sibling drawers use the shared layer dismissal stack for topmost-only Escape\n * handling and the browser top layer's chronological paint order.\n *\n * Dismissal follows Dialog: `purpose` decides whether Escape and a scrim click\n * request close, and Drawer renders no close button of its own. Compose\n * `DrawerHeader` with `onOpenChange` for a visible close action, as with\n * `DialogHeader`.\n *\n */\n\nimport { useCallback, useEffect, useId, useRef, useState, type ReactNode } from \"react\";\nimport * as stylex from \"@stylexjs/stylex\";\nimport type { StyleXStyles } from \"@stylexjs/stylex\";\nimport type { BaseProps } from \"@astryxdesign/core\";\nimport type { DialogPurpose } from \"@astryxdesign/core/Dialog\";\nimport { useFocusTrap, useMergedRefs, useScrollLock } from \"@astryxdesign/core/hooks\";\nimport { LayerDepthProvider, useLayerDismissal } from \"@astryxdesign/core/Layer\";\nimport { composeEventHandlers, mergeProps, themeProps } from \"@astryxdesign/core/utils\";\nimport { overlayPaddingReset } from \"@astryxdesign/core/Layout\";\n\nimport { compiledStyles } from \"../compiled\";\nimport * as compiled from \"./Drawer.styles\";\nimport { ModalPortalContext, modalZIndexBase } from \"../../components/Modal/modalStack\";\nimport { useDrawerDialogPresence } from \"./useDrawerDialogPresence\";\n\n// =============================================================================\n// Styles\n// =============================================================================\n\n// Material's established mobile drawer pattern leaves a 56dp reveal. Using\n// the same value in CSS pixels gives the overlay a stable visual relationship\n// to the page behind while the requested width remains an upper bound.\nconst MOBILE_PAGE_REVEAL = 56;\nconst MOBILE_WIDTH_FULL = \"100dvw\";\n\n// @astryxdesign/lab dist/Drawer/Drawer.js `styles` and `dynamicStyles`.\nconst styles = compiledStyles(compiled.styles);\nconst dynamicStyles = compiled.dynamicStyles as {\n inlineSize: (desktopWidth: string, mobileWidth: string) => StyleXStyles;\n};\n\n// ui-common: stacking for scrimless drawers, which open with `show()` and so\n// need a z-index; modal drawers rely on the top layer's chronological order.\n// Module-level; only mutated inside effects (SSR-safe). 1000 is the app-level\n// drawer convention lab used before 0.6.5. A new drawer goes one above the\n// highest OPEN one, so the value is bounded by how many are open at once, and\n// it stays below the modal band so a Modal always paints over a drawer.\nconst NON_MODAL_BASE_Z = 1000;\nconst openNonModalDrawers = new Map<string, number>();\n\nfunction registerNonModalDrawer(id: string): number {\n const highest = Math.max(NON_MODAL_BASE_Z - 1, ...openNonModalDrawers.values());\n const z = Math.min(highest + 1, modalZIndexBase() - 1);\n openNonModalDrawers.set(id, z);\n return z;\n}\n\nfunction unregisterNonModalDrawer(id: string): void {\n openNonModalDrawers.delete(id);\n}\n\n// Upstream's `content` style, which its compiler folded into this class list\n// (dist/Drawer/Drawer.js).\nconst CONTENT_CLASS_NAME =\n \"x1iyjqo2 x2lwn1j xh8yej3 x1odjw0f x6ikm8r xish69e xx69xxh x1a148e8 x1a2a7pz\";\n\n// =============================================================================\n// Types\n// =============================================================================\n\nexport interface DrawerProps extends BaseProps<HTMLDialogElement> {\n /** Ref forwarded to the root <dialog> element */\n ref?: React.Ref<HTMLDialogElement>;\n\n /**\n * Whether the drawer is open. Fully controlled — pair with `onOpenChange`.\n */\n isOpen: boolean;\n\n /**\n * Called when the drawer requests an open-state change. Escape and a scrim\n * click call it with `false` as `purpose` allows; a `DrawerHeader` close\n * button calls it when you pass the same callback to the header. The caller\n * owns the open state. When sibling drawers are open, Escape only closes the\n * top (last-opened) drawer.\n */\n onOpenChange: (isOpen: boolean) => void;\n\n /**\n * Which edge the drawer slides from.\n * - `'end'` — inline-end edge (right in LTR) — the inspector convention\n * - `'start'` — inline-start edge (left in LTR)\n * @default 'end'\n */\n side?: \"start\" | \"end\";\n\n /**\n * Desktop width budget. A number is pixels; a string is any CSS length\n * (`'50%'`, `'32rem'`). Below the mobile breakpoint (640px), this\n * remains the maximum while the drawer preserves a 56px reveal of the page\n * behind — see `isFullWidthOnMobile`.\n * @default 400\n */\n width?: number | string;\n\n /**\n * Whether the drawer covers the full viewport width on mobile\n * (below 640px) instead of preserving the default 56px reveal of the page\n * behind. The reveal makes the drawer read as an overlay rather than a\n * navigation.\n * @default false\n */\n isFullWidthOnMobile?: boolean;\n\n /**\n * Accessible label for the drawer (required — the drawer has no\n * built-in heading to derive a name from).\n */\n label: string;\n\n /**\n * Whether to render a modal scrim behind the drawer.\n * - `true` (default) — `showModal()`: top layer, focus trap, body scroll\n * lock, click-outside-to-close.\n * - `false` — `showPopover()`: non-modal top-layer overlay; the page behind\n * stays interactive. Escape still closes through the shared layer stack.\n * @default true\n */\n hasScrim?: boolean;\n\n /**\n * Configures how the drawer enables dismissals, matching Dialog.\n * - required: Disables Escape and scrim click (for mandatory flows); a\n * modal required drawer is exposed as an `alertdialog`\n * - form: Prevents scrim click, allows the Escape key\n * - info: Allows Escape and scrim click\n *\n * A non-modal drawer has no scrim, so `form` and `info` behave the same.\n * @default 'info'\n */\n purpose?: DialogPurpose;\n\n /**\n * Drawer content. Rendered inside a full-height scrollable area.\n * Focus the element with `data-autofocus` on open, if present.\n */\n children: ReactNode;\n\n /**\n * Test ID for the root element.\n */\n \"data-testid\"?: string;\n}\n\n// =============================================================================\n// Component\n// =============================================================================\n\n/**\n * An overlay panel for inspectors and detail views.\n *\n * Slides in from the logical start or end edge and floats above the page\n * using the native `<dialog>` element: modal with a scrim by default, or a\n * non-modal overlay with `hasScrim={false}` that leaves the page behind\n * interactive. `width` is the desktop budget; below 640px the panel preserves\n * a 56px page reveal without exceeding that budget (or fills the viewport\n * with `isFullWidthOnMobile`). Escape\n * closes the top-most open drawer; focus returns to the element that\n * opened it.\n *\n * Dismissal matches Dialog: `purpose` decides whether Escape and a scrim click\n * close the drawer, and `DrawerHeader` renders a close button when given\n * `onOpenChange`.\n *\n * @example\n * ```\n * const [selected, setSelected] = useState(null);\n * const handleOpenChange = isOpen => !isOpen && setSelected(null);\n * <Drawer\n * isOpen={selected != null}\n * onOpenChange={handleOpenChange}\n * label={`Details: ${selected?.name}`}>\n * <DrawerHeader title={selected?.name} onOpenChange={handleOpenChange} />\n * <HostDetails host={selected} />\n * </Drawer>\n * ```\n */\nexport function Drawer({\n isOpen,\n onOpenChange,\n side = \"end\",\n width = 400,\n isFullWidthOnMobile = false,\n label,\n hasScrim = true,\n purpose = \"info\",\n children,\n xstyle,\n className,\n style,\n onClick: onClickProp,\n onKeyDown: onKeyDownProp,\n ref,\n ...props\n}: DrawerProps) {\n const dialogRef = useRef<HTMLDialogElement>(null);\n const { containerRef: focusTrapRef } = useFocusTrap<HTMLDialogElement>({\n isActive: isOpen && hasScrim,\n });\n const mergedDialogRef = useMergedRefs(ref, dialogRef, focusTrapRef);\n // Derive dismissal behavior from purpose, as Dialog does.\n const allowEscape = purpose !== \"required\";\n const allowScrimClick = purpose === \"info\";\n // Whether the panel paints: true while open and for the whole slide-out.\n const [isRendered, setIsRendered] = useState(isOpen);\n\n // Adjusted during render, not in an effect: the panel has to be rendered in\n // the same commit that targets the open transform, or @starting-style has\n // nothing to animate from.\n if (isOpen && !isRendered) {\n setIsRendered(true);\n }\n\n useDrawerDialogPresence({\n dialogRef,\n isOpen,\n isModal: hasScrim,\n setIsRendered,\n });\n\n // ui-common: the dialog a Modal inside renders into, set only once\n // showModal() has run (the effect above), so the Modal's popover enters the\n // top layer after the dialog and paints above it. A scrimless drawer is not\n // top layer (`show()`), so a body-portalled Modal already stacks above it.\n const [modalHost, setModalHost] = useState<HTMLDialogElement | null>(null);\n useEffect(() => {\n setModalHost(isOpen && hasScrim ? dialogRef.current : null);\n }, [isOpen, hasScrim]);\n\n // ui-common: a scrimless drawer's z-index, last opened on top.\n const drawerId = useId();\n const [stackZ, setStackZ] = useState(NON_MODAL_BASE_Z);\n // Held while the panel paints, slide-out included, so a drawer opened during\n // another's exit goes above it rather than taking the same value.\n useEffect(() => {\n if (!isRendered || hasScrim) return;\n setStackZ(registerNonModalDrawer(drawerId));\n return () => unregisterNonModalDrawer(drawerId);\n }, [isRendered, hasScrim, drawerId]);\n\n const handleDismiss = useCallback(() => {\n onOpenChange(false);\n }, [onOpenChange]);\n\n // The shared stack owns Escape delivery across every overlay family. The\n // provider below gives layers opened from Drawer content a greater logical\n // depth even when they render elsewhere in the DOM or browser top layer.\n const { shouldDismissOnCloseRequest } = useLayerDismissal({\n // The native host stays present through the slide-out. Keep this entry on\n // the stack until the same commit that hides the host, so a second Escape\n // cannot fall through to a lower layer during the exit animation.\n isActive: isRendered,\n // A `required` drawer consumes Escape without closing, so the press cannot\n // fall through and dismiss a layer behind it either.\n escapeBehavior: allowEscape ? \"close\" : \"block\",\n onDismiss: handleDismiss,\n getContainer: () => dialogRef.current,\n });\n\n // Lock body scroll while a modal drawer is open (iOS Safari workaround).\n useScrollLock(isOpen && hasScrim);\n\n // A modal dialog's native cancel event is a platform close request (for\n // example Android Back). Keep controlled state authoritative and apply the\n // same top-most/IME rules as the shared Escape listener.\n const handleCancel = useCallback(\n (event: React.SyntheticEvent<HTMLDialogElement>) => {\n event.preventDefault();\n if (shouldDismissOnCloseRequest() && allowEscape) {\n handleDismiss();\n }\n },\n [allowEscape, handleDismiss, shouldDismissOnCloseRequest],\n );\n\n // Clicks on the ::backdrop target the <dialog> element itself; clicks on\n // drawer content always target a child (the content area fills the panel).\n const handleClick = useCallback(\n (event: React.MouseEvent<HTMLDialogElement>) => {\n if (event.target === event.currentTarget && hasScrim && allowScrimClick) {\n onOpenChange(false);\n }\n },\n [allowScrimClick, hasScrim, onOpenChange],\n );\n\n const widthValue = typeof width === \"number\" ? `${width}px` : width;\n const mobileWidth = isFullWidthOnMobile\n ? MOBILE_WIDTH_FULL\n : `min(${widthValue}, calc(100dvw - ${MOBILE_PAGE_REVEAL}px))`;\n\n // The side the panel is ANCHORED to, which is the side it must slide back\n // out to. Latched at open, because a consumer commonly derives `side` from\n // the same state that drives `isOpen` (`side={selected?.side ?? 'end'}`):\n // that state clears on close, so the live prop flips mid-exit and the panel\n // teleports to the other edge and slides out the wrong way. Children stay\n // mounted for the exit for the same reason; so does the anchor.\n const exitSideRef = useRef(side);\n if (isOpen) {\n exitSideRef.current = side;\n }\n const anchoredSide = isOpen ? side : exitSideRef.current;\n\n const sideStyle = anchoredSide === \"start\" ? styles.start : styles.end;\n const sideOpenStyle = anchoredSide === \"start\" ? styles.startOpen : styles.endOpen;\n\n // Filter out native `open` to prevent InvalidStateError when passed\n const { open: _open, ...safeProps } = props as Record<string, unknown>;\n\n return (\n <dialog\n ref={mergedDialogRef}\n {...mergeProps(\n themeProps(\"drawer\", { side: anchoredSide }),\n stylex.props(\n styles.dialog,\n overlayPaddingReset.reset,\n sideStyle,\n dynamicStyles.inlineSize(widthValue, mobileWidth),\n isRendered && styles.rendered,\n isOpen && sideOpenStyle,\n hasScrim && styles.scrim,\n hasScrim && isOpen && styles.scrimOpen,\n xstyle,\n ),\n className,\n // ui-common: the consumer's style may still override the stack.\n hasScrim ? style : { zIndex: stackZ, ...style },\n )}\n {...safeProps}\n aria-label={label}\n // ui-common: scrimless by itself is non-modal, but a consumer that\n // restores the modality by hand (a portal supplying its own mask and\n // focus trap) must be able to say so.\n aria-modal={\n (safeProps[\"aria-modal\"] as React.AriaAttributes[\"aria-modal\"]) ??\n (hasScrim ? \"true\" : undefined)\n }\n {...(purpose === \"required\" && hasScrim ? { role: \"alertdialog\" } : undefined)}\n onClick={composeEventHandlers(onClickProp, handleClick)}\n onKeyDown={onKeyDownProp}\n onCancel={handleCancel}\n >\n <LayerDepthProvider>\n {/* Scrollable content area — tabIndex so the dialog's focusing steps\n land on the panel body rather than the first button inside. */}\n <div tabIndex={-1} className={CONTENT_CLASS_NAME}>\n <ModalPortalContext value={modalHost}>{children}</ModalPortalContext>\n </div>\n </LayerDepthProvider>\n </dialog>\n );\n}\n\nDrawer.displayName = \"Drawer\";\n"],"mappings":"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"}
1
+ {"version":3,"file":"Drawer.js","names":[],"sources":["../../../src/forks/Drawer/Drawer.tsx"],"sourcesContent":["// Copyright (c) Meta Platforms, Inc. and affiliates.\n// Modifications copyright (c) Lablup Inc.\n//\n// Forked from @astryxdesign/lab 0.7.0-canary.97a0d31, src/Drawer/Drawer.tsx\n// (MIT; see NOTICE). Provenance and the drift guard: src/forks/provenance.json.\n\n\"use client\";\n\n/**\n * Drawer, ui-common's copy of Astryx lab's, with three changes (not upstream):\n *\n * - **A scrimless drawer stays out of the top layer.** lab 0.6.5 opens it as\n * a manual popover; this copy keeps the `show()` + z-index it had before\n * (base 1000, later drawers above), because ui-common's `Modal` and\n * notification stack are z-index surfaces: a top-layer drawer painted over\n * a confirm or a notification opened while it was up, and the modal stack\n * then inerted the drawer it could not cover.\n * - **`aria-modal` passes through.** A scrimless drawer is non-modal, but a\n * consumer that restores modality by hand (its own mask and focus trap) can\n * now say so; the default is unchanged.\n * - **ui-common's `Modal` opens above a scrimmed drawer.** That drawer is a\n * modal `<dialog>`, top layer and inerting everything outside it, so a\n * `Modal` portalled to the body sat behind it, unreachable. The drawer\n * provides its dialog through `ModalPortalContext` while it is open and\n * modal, and a `Modal` inside renders there and enters the top layer\n * after it (modalStack.ts).\n *\n * Escape routing is upstream's since lab 0.6.5: the drawer registers with\n * core's layer-dismissal stack, so a popover, selector or modal opened inside\n * it closes first and nested drawers close top-first. Everything else is\n * upstream's too. Its style namespaces are Astryx's compiled output\n * (src/forks/compiled.ts).\n *\n * Delete this fork, and its exports.exclude.json entry, once ui-common's\n * `Modal` and notification stack are top layer themselves and lab passes\n * `aria-modal` through (CONTRIBUTING, \"Forks of Astryx components\").\n */\n\n/*\n * Upstream's file notes, kept:\n *\n * Overlay panel for inspectors and detail views — the \"click a table row,\n * see its details\" pattern. Slides in from the inline start or end edge and\n * floats above the page content: unlike a docked panel it never reflows the\n * layout underneath, it overlays it (with or without a scrim).\n *\n * Inline axis only (start/end). Block-axis sheets are BottomSheet's job;\n * a drawer is always a full-height side panel.\n *\n * Sizing is viewport-aware: `width` is the desktop budget, and below\n * the mobile breakpoint it preserves a 56px reveal of the page behind, capped\n * by the requested width (or fills the viewport with `isFullWidthOnMobile`).\n *\n * Uses the native `<dialog>` element (same precedent as Dialog/MobileNav):\n * - `showModal()` when `hasScrim` (default) — top-layer rendering, focus\n * trapping, `::backdrop`, no z-index management.\n * - `showPopover()` when `hasScrim={false}` — non-modal top-layer overlay;\n * the page behind stays interactive (e.g. master-detail inspectors).\n * (ui-common: `show()` and a z-index instead; see the header above.)\n *\n * Entry animation uses `@starting-style`; exit slides out before the active\n * modal-dialog or manual-popover host releases the top layer and focus returns\n * to the element that opened the drawer. React owns `display` for both legs\n * rather than a discrete `display` transition, so the panel stops painting in\n * the same commit as the host closes — see the `rendered` style for why.\n *\n * Sibling drawers use the shared layer dismissal stack for topmost-only Escape\n * handling and the browser top layer's chronological paint order.\n *\n * Dismissal follows Dialog: `purpose` decides whether Escape and a scrim click\n * request close, and Drawer renders no close button of its own. Compose\n * `DrawerHeader` with `onOpenChange` for a visible close action, as with\n * `DialogHeader`.\n *\n * The scrolling content area is the drawer's container, like Dialog's inner\n * box: the `padding` prop, else the theme's `padding` on `drawer`, insets it\n * through container tokens, defaulting to `--spacing-4` like Dialog, and the\n * applied inset is published so a lone Section child escapes it and a Layout\n * redistributes it to its regions. Compose `DrawerHeader` inside a `Layout`, as\n * `DialogHeader` is composed in Dialog, so the header is not padded twice. The\n * root dialog stays the overlay boundary (`overlayPaddingReset`).\n *\n * SYNC: When modified, update these files to stay in sync:\n * - /packages/lab/src/Drawer/Drawer.doc.mjs (props table, features, usage)\n * - /packages/lab/src/Drawer/Drawer.test.tsx (tests for new/changed behavior)\n * - /packages/lab/src/Drawer/Drawer.spec.md (component contract)\n * - /packages/lab/src/Drawer/index.ts (exports if types change)\n * - /apps/storybook/stories/Drawer.stories.tsx (examples and visual coverage)\n */\n\nimport { useCallback, useEffect, useId, useRef, useState, type ReactNode } from \"react\";\nimport * as stylex from \"@stylexjs/stylex\";\nimport type { StyleXStyles } from \"@stylexjs/stylex\";\nimport type { BaseProps } from \"@astryxdesign/core\";\nimport type { DialogPurpose } from \"@astryxdesign/core/Dialog\";\nimport { useFocusTrap, useMergedRefs, useScrollLock } from \"@astryxdesign/core/hooks\";\nimport { LayerDepthProvider, useLayerDismissal } from \"@astryxdesign/core/Layer\";\nimport { composeEventHandlers, mergeProps, themeProps } from \"@astryxdesign/core/utils\";\nimport { container, overlayPaddingReset } from \"@astryxdesign/core/Layout\";\nimport {\n containerPaddingBlockEndVarStyles,\n containerPaddingBlockStartVarStyles,\n containerPaddingInlineVarStyles,\n paddingStyles,\n spacingStepToToken,\n} from \"@astryxdesign/core/Layout/padding.stylex\";\nimport type { SpacingStep, SpacingToken } from \"@astryxdesign/core/Layout\";\n\nimport { compiledStyles } from \"../compiled\";\nimport * as compiled from \"./Drawer.styles\";\nimport { ModalPortalContext, modalZIndexBase } from \"../../components/Modal/modalStack\";\nimport { useDrawerDialogPresence } from \"./useDrawerDialogPresence\";\n\n// =============================================================================\n// Styles\n// =============================================================================\n\n// Material's established mobile drawer pattern leaves a 56dp reveal. Using\n// the same value in CSS pixels gives the overlay a stable visual relationship\n// to the page behind while the requested width remains an upper bound.\nconst MOBILE_PAGE_REVEAL = 56;\nconst MOBILE_WIDTH_FULL = \"100dvw\";\n\n// @astryxdesign/lab dist/Drawer/Drawer.js `styles` and `dynamicStyles`.\nconst styles = compiledStyles(compiled.styles);\nconst dynamicStyles = compiled.dynamicStyles as {\n inlineSize: (desktopWidth: string, mobileWidth: string) => StyleXStyles;\n};\n\n// ui-common: stacking for scrimless drawers, which open with `show()` and so\n// need a z-index; modal drawers rely on the top layer's chronological order.\n// Module-level; only mutated inside effects (SSR-safe). 1000 is the app-level\n// drawer convention lab used before 0.6.5. A new drawer goes one above the\n// highest OPEN one, so the value is bounded by how many are open at once, and\n// it stays below the modal band so a Modal always paints over a drawer.\nconst NON_MODAL_BASE_Z = 1000;\nconst openNonModalDrawers = new Map<string, number>();\n\nfunction registerNonModalDrawer(id: string): number {\n const highest = Math.max(NON_MODAL_BASE_Z - 1, ...openNonModalDrawers.values());\n const z = Math.min(highest + 1, modalZIndexBase() - 1);\n openNonModalDrawers.set(id, z);\n return z;\n}\n\nfunction unregisterNonModalDrawer(id: string): void {\n openNonModalDrawers.delete(id);\n}\n\n// =============================================================================\n// Types\n// =============================================================================\n\nexport interface DrawerProps extends BaseProps<HTMLDialogElement> {\n /** Ref forwarded to the root <dialog> element */\n ref?: React.Ref<HTMLDialogElement>;\n\n /**\n * Whether the drawer is open. Fully controlled — pair with `onOpenChange`.\n */\n isOpen: boolean;\n\n /**\n * Called when the drawer requests an open-state change. Escape and a scrim\n * click call it with `false` as `purpose` allows; a `DrawerHeader` close\n * button calls it when you pass the same callback to the header. The caller\n * owns the open state. When sibling drawers are open, Escape only closes the\n * top (last-opened) drawer.\n */\n onOpenChange: (isOpen: boolean) => void;\n\n /**\n * Which edge the drawer slides from.\n * - `'end'` — inline-end edge (right in LTR) — the inspector convention\n * - `'start'` — inline-start edge (left in LTR)\n * @default 'end'\n */\n side?: \"start\" | \"end\";\n\n /**\n * Desktop width budget. A number is pixels; a string is any CSS length\n * (`'50%'`, `'32rem'`). Below the mobile breakpoint (640px), this\n * remains the maximum while the drawer preserves a 56px reveal of the page\n * behind — see `isFullWidthOnMobile`.\n * @default 400\n */\n width?: number | string;\n\n /**\n * Whether the drawer covers the full viewport width on mobile\n * (below 640px) instead of preserving the default 56px reveal of the page\n * behind. The reveal makes the drawer read as an overlay rather than a\n * navigation.\n * @default false\n */\n isFullWidthOnMobile?: boolean;\n\n /**\n * Accessible label for the drawer (required — the drawer has no\n * built-in heading to derive a name from).\n */\n label: string;\n\n /**\n * Whether to render a modal scrim behind the drawer.\n * - `true` (default) — `showModal()`: top layer, focus trap, body scroll\n * lock, click-outside-to-close.\n * - `false` — `showPopover()`: non-modal top-layer overlay; the page behind\n * stays interactive. Escape still closes through the shared layer stack.\n * @default true\n */\n hasScrim?: boolean;\n\n /**\n * Configures how the drawer enables dismissals, matching Dialog.\n * - required: Disables Escape and scrim click (for mandatory flows); a\n * modal required drawer is exposed as an `alertdialog`\n * - form: Prevents scrim click, allows the Escape key\n * - info: Allows Escape and scrim click\n *\n * A non-modal drawer has no scrim, so `form` and `info` behave the same.\n * @default 'info'\n */\n purpose?: DialogPurpose;\n\n /**\n * Internal padding of the drawer content using the spacing scale, matching\n * Dialog. Accepts numeric spacing steps: 0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8,\n * 10. When omitted, uses the theme default for drawers (`--spacing-4`, 16px,\n * unless the theme sets `padding` on `drawer`), as Dialog does. Pass `0` for\n * a full-bleed content area. The content area is a container: a Section that\n * is its only child escapes the padding, bleed children such as Table and\n * Divider compensate against it, and a Layout picks it up for its regions.\n */\n padding?: SpacingStep;\n\n /**\n * Drawer content. Rendered inside a full-height scrollable area.\n * Focus the element with `data-autofocus` on open, if present.\n */\n children: ReactNode;\n\n /**\n * Test ID for the root element.\n */\n \"data-testid\"?: string;\n}\n\n// =============================================================================\n// Component\n// =============================================================================\n\n/**\n * An overlay panel for inspectors and detail views.\n *\n * Slides in from the logical start or end edge and floats above the page\n * using the native `<dialog>` element: modal with a scrim by default, or a\n * non-modal overlay with `hasScrim={false}` that leaves the page behind\n * interactive. `width` is the desktop budget; below 640px the panel preserves\n * a 56px page reveal without exceeding that budget (or fills the viewport\n * with `isFullWidthOnMobile`). Escape\n * closes the top-most open drawer; focus returns to the element that\n * opened it.\n *\n * Dismissal matches Dialog: `purpose` decides whether Escape and a scrim click\n * close the drawer, and `DrawerHeader` renders a close button when given\n * `onOpenChange`.\n *\n * Like Dialog, the drawer is a container: `padding` (or a theme's `padding`\n * on `drawer`) insets the content area, a lone Section child escapes that\n * inset, and a Layout inside picks it up for its header, content, and footer\n * regions. The default inset is `--spacing-4`, matching Dialog.\n *\n * @example\n * ```\n * const [selected, setSelected] = useState(null);\n * const handleOpenChange = isOpen => !isOpen && setSelected(null);\n * <Drawer\n * isOpen={selected != null}\n * onOpenChange={handleOpenChange}\n * label={`Details: ${selected?.name}`}>\n * <Layout\n * header={<DrawerHeader title={selected?.name} onOpenChange={handleOpenChange} />}\n * content={<LayoutContent><HostDetails host={selected} /></LayoutContent>}\n * />\n * </Drawer>\n * ```\n */\nexport function Drawer({\n isOpen,\n onOpenChange,\n side = \"end\",\n width = 400,\n isFullWidthOnMobile = false,\n label,\n hasScrim = true,\n purpose = \"info\",\n padding,\n children,\n xstyle,\n className,\n style,\n onClick: onClickProp,\n onKeyDown: onKeyDownProp,\n ref,\n ...props\n}: DrawerProps) {\n const dialogRef = useRef<HTMLDialogElement>(null);\n const { containerRef: focusTrapRef } = useFocusTrap<HTMLDialogElement>({\n isActive: isOpen && hasScrim,\n });\n const mergedDialogRef = useMergedRefs(ref, dialogRef, focusTrapRef);\n // Derive dismissal behavior from purpose, as Dialog does.\n const allowEscape = purpose !== \"required\";\n const allowScrimClick = purpose === \"info\";\n // Same lowering as Dialog: with no padding prop the content area reads the\n // theme's --astryx-drawer-padding chain (--spacing-4 when unset), else the\n // explicit step.\n const usesThemePadding = padding == null;\n const effectivePadding = padding ?? 4;\n const paddingToken = spacingStepToToken[effectivePadding] as SpacingToken;\n // Whether the panel paints: true while open and for the whole slide-out.\n const [isRendered, setIsRendered] = useState(isOpen);\n\n // Adjusted during render, not in an effect: the panel has to be rendered in\n // the same commit that targets the open transform, or @starting-style has\n // nothing to animate from.\n if (isOpen && !isRendered) {\n setIsRendered(true);\n }\n\n useDrawerDialogPresence({\n dialogRef,\n isOpen,\n isModal: hasScrim,\n setIsRendered,\n });\n\n // ui-common: the dialog a Modal inside renders into, set only once\n // showModal() has run (the effect above), so the Modal's popover enters the\n // top layer after the dialog and paints above it. A scrimless drawer is not\n // top layer (`show()`), so a body-portalled Modal already stacks above it.\n const [modalHost, setModalHost] = useState<HTMLDialogElement | null>(null);\n useEffect(() => {\n setModalHost(isOpen && hasScrim ? dialogRef.current : null);\n }, [isOpen, hasScrim]);\n\n // ui-common: a scrimless drawer's z-index, last opened on top.\n const drawerId = useId();\n const [stackZ, setStackZ] = useState(NON_MODAL_BASE_Z);\n // Held while the panel paints, slide-out included, so a drawer opened during\n // another's exit goes above it rather than taking the same value.\n useEffect(() => {\n if (!isRendered || hasScrim) return;\n setStackZ(registerNonModalDrawer(drawerId));\n return () => unregisterNonModalDrawer(drawerId);\n }, [isRendered, hasScrim, drawerId]);\n\n const handleDismiss = useCallback(() => {\n onOpenChange(false);\n }, [onOpenChange]);\n\n // The shared stack owns Escape delivery across every overlay family. The\n // provider below gives layers opened from Drawer content a greater logical\n // depth even when they render elsewhere in the DOM or browser top layer.\n const { shouldDismissOnCloseRequest } = useLayerDismissal({\n // The native host stays present through the slide-out. Keep this entry on\n // the stack until the same commit that hides the host, so a second Escape\n // cannot fall through to a lower layer during the exit animation.\n isActive: isRendered,\n // A `required` drawer consumes Escape without closing, so the press cannot\n // fall through and dismiss a layer behind it either.\n escapeBehavior: allowEscape ? \"close\" : \"block\",\n onDismiss: handleDismiss,\n getContainer: () => dialogRef.current,\n });\n\n // Lock body scroll while a modal drawer is open (iOS Safari workaround).\n useScrollLock(isOpen && hasScrim);\n\n // A modal dialog's native cancel event is a platform close request (for\n // example Android Back). Keep controlled state authoritative and apply the\n // same top-most/IME rules as the shared Escape listener.\n const handleCancel = useCallback(\n (event: React.SyntheticEvent<HTMLDialogElement>) => {\n event.preventDefault();\n if (shouldDismissOnCloseRequest() && allowEscape) {\n handleDismiss();\n }\n },\n [allowEscape, handleDismiss, shouldDismissOnCloseRequest],\n );\n\n // Clicks on the ::backdrop target the <dialog> element itself; clicks on\n // drawer content always target a child (the content area fills the panel).\n const handleClick = useCallback(\n (event: React.MouseEvent<HTMLDialogElement>) => {\n if (event.target === event.currentTarget && hasScrim && allowScrimClick) {\n onOpenChange(false);\n }\n },\n [allowScrimClick, hasScrim, onOpenChange],\n );\n\n const widthValue = typeof width === \"number\" ? `${width}px` : width;\n const mobileWidth = isFullWidthOnMobile\n ? MOBILE_WIDTH_FULL\n : `min(${widthValue}, calc(100dvw - ${MOBILE_PAGE_REVEAL}px))`;\n\n // The side the panel is ANCHORED to, which is the side it must slide back\n // out to. Latched at open, because a consumer commonly derives `side` from\n // the same state that drives `isOpen` (`side={selected?.side ?? 'end'}`):\n // that state clears on close, so the live prop flips mid-exit and the panel\n // teleports to the other edge and slides out the wrong way. Children stay\n // mounted for the exit for the same reason; so does the anchor.\n const exitSideRef = useRef(side);\n if (isOpen) {\n exitSideRef.current = side;\n }\n const anchoredSide = isOpen ? side : exitSideRef.current;\n\n const sideStyle = anchoredSide === \"start\" ? styles.start : styles.end;\n const sideOpenStyle = anchoredSide === \"start\" ? styles.startOpen : styles.endOpen;\n\n // Filter out native `open` to prevent InvalidStateError when passed\n const { open: _open, ...safeProps } = props as Record<string, unknown>;\n\n return (\n <dialog\n ref={mergedDialogRef}\n {...mergeProps(\n themeProps(\"drawer\", { side: anchoredSide }),\n stylex.props(\n styles.dialog,\n overlayPaddingReset.reset,\n sideStyle,\n dynamicStyles.inlineSize(widthValue, mobileWidth),\n isRendered && styles.rendered,\n isOpen && sideOpenStyle,\n hasScrim && styles.scrim,\n hasScrim && isOpen && styles.scrimOpen,\n xstyle,\n ),\n className,\n // ui-common: the consumer's style may still override the stack.\n hasScrim ? style : { zIndex: stackZ, ...style },\n )}\n {...safeProps}\n aria-label={label}\n // ui-common: scrimless by itself is non-modal, but a consumer that\n // restores the modality by hand (a portal supplying its own mask and\n // focus trap) must be able to say so.\n aria-modal={\n (safeProps[\"aria-modal\"] as React.AriaAttributes[\"aria-modal\"]) ??\n (hasScrim ? \"true\" : undefined)\n }\n {...(purpose === \"required\" && hasScrim ? { role: \"alertdialog\" } : undefined)}\n onClick={composeEventHandlers(onClickProp, handleClick)}\n onKeyDown={onKeyDownProp}\n onCancel={handleCancel}\n >\n <LayerDepthProvider>\n {/* Scrollable content area — tabIndex so the dialog's focusing steps\n land on the panel body rather than the first button inside. */}\n <div\n tabIndex={-1}\n {...stylex.props(\n styles.content,\n ...container(\n usesThemePadding\n ? { useThemeDefault: \"drawer\" }\n : {\n paddingInnerX: paddingToken,\n paddingInnerY: paddingToken,\n paddingOuterX: paddingToken,\n paddingOuterY: paddingToken,\n },\n ),\n !usesThemePadding &&\n effectivePadding !== 4 &&\n paddingStyles[effectivePadding],\n !usesThemePadding &&\n effectivePadding !== 4 &&\n containerPaddingInlineVarStyles[effectivePadding],\n !usesThemePadding &&\n effectivePadding !== 4 &&\n containerPaddingBlockStartVarStyles[effectivePadding],\n !usesThemePadding &&\n effectivePadding !== 4 &&\n containerPaddingBlockEndVarStyles[effectivePadding],\n styles.contentSafeArea,\n )}\n >\n <ModalPortalContext value={modalHost}>{children}</ModalPortalContext>\n </div>\n </LayerDepthProvider>\n </dialog>\n );\n}\n\nDrawer.displayName = \"Drawer\";\n"],"mappings":"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"}
@@ -83,6 +83,22 @@ export declare const styles: {
83
83
  k5sjJv: string;
84
84
  $$css: boolean;
85
85
  };
86
+ content: {
87
+ kzQI83: string;
88
+ kAzted: string;
89
+ kzqmXN: string;
90
+ kORKVm: string;
91
+ kXHlph: string;
92
+ kZeWKH: string;
93
+ kFalU9: string;
94
+ kI3sdo: string;
95
+ kWkggS: string;
96
+ $$css: boolean;
97
+ };
98
+ contentSafeArea: {
99
+ kGO01o: string;
100
+ $$css: boolean;
101
+ };
86
102
  };
87
103
  export declare const _temp: {
88
104
  ks0D6T: string;
@@ -83,6 +83,22 @@ var e = {
83
83
  scrimOpen: {
84
84
  k5sjJv: "xb3n6bw xxiuuzi",
85
85
  $$css: !0
86
+ },
87
+ content: {
88
+ kzQI83: "x1iyjqo2",
89
+ kAzted: "x2lwn1j",
90
+ kzqmXN: "xh8yej3",
91
+ kORKVm: "x1odjw0f",
92
+ kXHlph: "x6ikm8r",
93
+ kZeWKH: "xish69e",
94
+ kFalU9: "xx69xxh",
95
+ kI3sdo: "x1a2a7pz",
96
+ kWkggS: "x10xzikg",
97
+ $$css: !0
98
+ },
99
+ contentSafeArea: {
100
+ kGO01o: "xvmia7e",
101
+ $$css: !0
86
102
  }
87
103
  }, t = {
88
104
  ks0D6T: "xlbgzzq",
@@ -1 +1 @@
1
- {"version":3,"file":"Drawer.styles.js","names":[],"sources":["../../../src/forks/Drawer/Drawer.styles.ts"],"sourcesContent":["/* eslint-disable */\n// @ts-nocheck\n// @generated by scripts/sync-forks.mjs. Do not edit.\n//\n// Compiled StyleX from @astryxdesign/lab 0.6.5-canary.8701623, reused by the\n// Drawer fork so it renders with upstream's own class names\n// (src/forks/compiled.ts). Copyright (c) Meta Platforms, Inc. and\n// affiliates; MIT, see NOTICE.\n\n// dist/Drawer/Drawer.js\nexport const styles = {\n dialog: {\n kMv6JI: \"x9ynric\",\n kGuDYH: \"xjm74w1\",\n k63SB2: \"xxovm9e\",\n kLWn49: \"xw6l6zx\",\n kKX8nH: \"x1j61x8r\",\n k9WMMc: \"x1yc453h\",\n kJI5tL: \"x7ssn7h\",\n kTHuQy: \"xzugeeo\",\n kP9fke: \"x6mezaz\",\n kb6lSQ: \"x1i21sxh\",\n k4JVr9: \"xp3md9m\",\n kKMj4B: \"x19pm5ym\",\n khDVqt: \"xeaf4i8\",\n kTgw9: \"x1lldw8n\",\n kHjlTd: \"x1h4wwuj\",\n kE4Cay: \"xxydokm\",\n kVAEAm: \"xixxii4\",\n kogj98: \"x1ghz6dp\",\n kmVPX3: \"x1717udv\",\n kaIpWk: \"x2u8bby\",\n ks0D6T: \"x1x1rfll\",\n kskxy: \"x7ab17h\",\n kB7OPa: \"x9f619\",\n kXwgrk: \"xdt5ytf\",\n kWkggS: \"x10xzikg\",\n kGVxlE: \"x1kcpxr7\",\n kVQacm: \"xb3r6kr\",\n kZeWKH: \"xish69e\",\n kI3sdo: \"x1a2a7pz\",\n k87sOh: \"x13vifvy\",\n krVfgx: \"x1ey2m1c\",\n kZKoxP: \"xtdtrs8\",\n k1xSpc: \"x1s85apg\",\n k1ekBW: \"x11xpdln\",\n kIyJzY: \"x80gvsz\",\n kAMwcw: \"xlr8y92\",\n k6CgDc: \"xzg1mie\",\n $$css: true,\n },\n rendered: {\n k1xSpc: \"x78zum5\",\n $$css: true,\n },\n end: {\n kt4wiu: \"xtijo5x\",\n kLqNvP: \"xhi6v0a\",\n k2ei4v: \"xgbv0en\",\n kVhnKS: \"x1t7ytsu\",\n kGJrpR: \"x1j92z86\",\n k3aq6I: \"xumwmo6 x1df3fe5\",\n $$css: true,\n },\n endOpen: {\n k3aq6I: \"xbryuvx x1yqmsfc x1lymnkk\",\n $$css: true,\n },\n start: {\n kLqNvP: \"x1o0tod\",\n kt4wiu: \"x1woyocn\",\n ke9TFa: \"xw8tdv1\",\n k8ry5P: \"x18b5jzi\",\n kBCPoo: \"x1gejf6u\",\n k3aq6I: \"x5i6ehr xttggg\",\n $$css: true,\n },\n startOpen: {\n k3aq6I: \"xbryuvx x6mt36l x14gflnl\",\n $$css: true,\n },\n scrim: {\n kGyWv1: \"xnixb3f\",\n kba3nw: \"x1abwkk1\",\n k5sjJv: \"xph5o2a\",\n kND0Po: \"x167zut7\",\n k9an0g: \"xft5bk6\",\n kb4ib: \"x15h3t91\",\n kA5Tbj: \"x1viac0w\",\n $$css: true,\n },\n scrimOpen: {\n k5sjJv: \"xb3n6bw xxiuuzi\",\n $$css: true,\n },\n};\nexport const _temp = {\n ks0D6T: \"xlbgzzq\",\n $$css: true,\n};\nexport const dynamicStyles = {\n inlineSize: (desktopWidth, mobileWidth) => [\n _temp,\n {\n kzqmXN:\n (desktopWidth != null ? \"x11ymkkh \" : desktopWidth) +\n (mobileWidth != null ? \"xci7e5a\" : mobileWidth),\n $$css: true,\n },\n {\n \"--x-1xmrurk\": ((val) =>\n typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(\n desktopWidth,\n ),\n \"--x-fqzwsx\": ((val) =>\n typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(\n mobileWidth,\n ),\n },\n ],\n};\n"],"mappings":";AAUA,IAAa,IAAS;CACpB,QAAQ;EACN,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,UAAU;EACR,QAAQ;EACR,OAAO;CACT;CACA,KAAK;EACH,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,SAAS;EACP,QAAQ;EACR,OAAO;CACT;CACA,OAAO;EACL,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,WAAW;EACT,QAAQ;EACR,OAAO;CACT;CACA,OAAO;EACL,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,OAAO;CACT;CACA,WAAW;EACT,QAAQ;EACR,OAAO;CACT;AACF,GACa,IAAQ;CACnB,QAAQ;CACR,OAAO;AACT,GACa,IAAgB,EAC3B,aAAa,GAAc,MAAgB;CACzC;CACA;EACE,SACG,KAAgB,OAAqB,IAAd,gBACvB,KAAe,OAAmB,IAAZ;EACzB,OAAO;CACT;CACA;EACE,iBAAiB,MACf,OAAO,KAAQ,WAAW,IAAM,OAAO,KAAoB,KAAA,EAAA,CAC3D,CACF;EACA,gBAAgB,MACd,OAAO,KAAQ,WAAW,IAAM,OAAO,KAAoB,KAAA,EAAA,CAC3D,CACF;CACF;AACF,EACF"}
1
+ {"version":3,"file":"Drawer.styles.js","names":[],"sources":["../../../src/forks/Drawer/Drawer.styles.ts"],"sourcesContent":["/* eslint-disable */\n// @ts-nocheck\n// @generated by scripts/sync-forks.mjs. Do not edit.\n//\n// Compiled StyleX from @astryxdesign/lab 0.7.0-canary.97a0d31, reused by the\n// Drawer fork so it renders with upstream's own class names\n// (src/forks/compiled.ts). Copyright (c) Meta Platforms, Inc. and\n// affiliates; MIT, see NOTICE.\n\n// dist/Drawer/Drawer.js\nexport const styles = {\n dialog: {\n kMv6JI: \"x9ynric\",\n kGuDYH: \"xjm74w1\",\n k63SB2: \"xxovm9e\",\n kLWn49: \"xw6l6zx\",\n kKX8nH: \"x1j61x8r\",\n k9WMMc: \"x1yc453h\",\n kJI5tL: \"x7ssn7h\",\n kTHuQy: \"xzugeeo\",\n kP9fke: \"x6mezaz\",\n kb6lSQ: \"x1i21sxh\",\n k4JVr9: \"xp3md9m\",\n kKMj4B: \"x19pm5ym\",\n khDVqt: \"xeaf4i8\",\n kTgw9: \"x1lldw8n\",\n kHjlTd: \"x1h4wwuj\",\n kE4Cay: \"xxydokm\",\n kVAEAm: \"xixxii4\",\n kogj98: \"x1ghz6dp\",\n kmVPX3: \"x1717udv\",\n kaIpWk: \"x2u8bby\",\n ks0D6T: \"x1x1rfll\",\n kskxy: \"x7ab17h\",\n kB7OPa: \"x9f619\",\n kXwgrk: \"xdt5ytf\",\n kWkggS: \"x10xzikg\",\n kGVxlE: \"x1kcpxr7\",\n kVQacm: \"xb3r6kr\",\n kZeWKH: \"xish69e\",\n kI3sdo: \"x1a2a7pz\",\n k87sOh: \"x13vifvy\",\n krVfgx: \"x1ey2m1c\",\n kZKoxP: \"xtdtrs8\",\n k1xSpc: \"x1s85apg\",\n k1ekBW: \"x11xpdln\",\n kIyJzY: \"x80gvsz\",\n kAMwcw: \"xlr8y92\",\n k6CgDc: \"xzg1mie\",\n $$css: true,\n },\n rendered: {\n k1xSpc: \"x78zum5\",\n $$css: true,\n },\n end: {\n kt4wiu: \"xtijo5x\",\n kLqNvP: \"xhi6v0a\",\n k2ei4v: \"xgbv0en\",\n kVhnKS: \"x1t7ytsu\",\n kGJrpR: \"x1j92z86\",\n k3aq6I: \"xumwmo6 x1df3fe5\",\n $$css: true,\n },\n endOpen: {\n k3aq6I: \"xbryuvx x1yqmsfc x1lymnkk\",\n $$css: true,\n },\n start: {\n kLqNvP: \"x1o0tod\",\n kt4wiu: \"x1woyocn\",\n ke9TFa: \"xw8tdv1\",\n k8ry5P: \"x18b5jzi\",\n kBCPoo: \"x1gejf6u\",\n k3aq6I: \"x5i6ehr xttggg\",\n $$css: true,\n },\n startOpen: {\n k3aq6I: \"xbryuvx x6mt36l x14gflnl\",\n $$css: true,\n },\n scrim: {\n kGyWv1: \"xnixb3f\",\n kba3nw: \"x1abwkk1\",\n k5sjJv: \"xph5o2a\",\n kND0Po: \"x167zut7\",\n k9an0g: \"xft5bk6\",\n kb4ib: \"x15h3t91\",\n kA5Tbj: \"x1viac0w\",\n $$css: true,\n },\n scrimOpen: {\n k5sjJv: \"xb3n6bw xxiuuzi\",\n $$css: true,\n },\n content: {\n kzQI83: \"x1iyjqo2\",\n kAzted: \"x2lwn1j\",\n kzqmXN: \"xh8yej3\",\n kORKVm: \"x1odjw0f\",\n kXHlph: \"x6ikm8r\",\n kZeWKH: \"xish69e\",\n kFalU9: \"xx69xxh\",\n kI3sdo: \"x1a2a7pz\",\n kWkggS: \"x10xzikg\",\n $$css: true,\n },\n contentSafeArea: {\n kGO01o: \"xvmia7e\",\n $$css: true,\n },\n};\nexport const _temp = {\n ks0D6T: \"xlbgzzq\",\n $$css: true,\n};\nexport const dynamicStyles = {\n inlineSize: (desktopWidth, mobileWidth) => [\n _temp,\n {\n kzqmXN:\n (desktopWidth != null ? \"x11ymkkh \" : desktopWidth) +\n (mobileWidth != null ? \"xci7e5a\" : mobileWidth),\n $$css: true,\n },\n {\n \"--x-1xmrurk\": ((val) =>\n typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(\n desktopWidth,\n ),\n \"--x-fqzwsx\": ((val) =>\n typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(\n mobileWidth,\n ),\n },\n ],\n};\n"],"mappings":";AAUA,IAAa,IAAS;CACpB,QAAQ;EACN,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,UAAU;EACR,QAAQ;EACR,OAAO;CACT;CACA,KAAK;EACH,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,SAAS;EACP,QAAQ;EACR,OAAO;CACT;CACA,OAAO;EACL,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,WAAW;EACT,QAAQ;EACR,OAAO;CACT;CACA,OAAO;EACL,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,OAAO;CACT;CACA,WAAW;EACT,QAAQ;EACR,OAAO;CACT;CACA,SAAS;EACP,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,iBAAiB;EACf,QAAQ;EACR,OAAO;CACT;AACF,GACa,IAAQ;CACnB,QAAQ;CACR,OAAO;AACT,GACa,IAAgB,EAC3B,aAAa,GAAc,MAAgB;CACzC;CACA;EACE,SACG,KAAgB,OAAqB,IAAd,gBACvB,KAAe,OAAmB,IAAZ;EACzB,OAAO;CACT;CACA;EACE,iBAAiB,MACf,OAAO,KAAQ,WAAW,IAAM,OAAO,KAAoB,KAAA,EAAA,CAC3D,CACF;EACA,gBAAgB,MACd,OAAO,KAAQ,WAAW,IAAM,OAAO,KAAoB,KAAA,EAAA,CAC3D,CACF;CACF;AACF,EACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDrawerDialogPresence.js","names":[],"sources":["../../../src/forks/Drawer/useDrawerDialogPresence.ts"],"sourcesContent":["// Copyright (c) Meta Platforms, Inc. and affiliates.\n//\n// Forked from @astryxdesign/lab 0.6.5-canary.8701623, src/Drawer/useDrawerDialogPresence.ts\n// (MIT; see NOTICE). Changed (marked `ui-common:`): a non-modal drawer opens\n// with `show()`, not `showPopover()`, so it stays out of the top layer (Drawer.tsx).\n// Provenance and the drift guard: src/forks/provenance.json.\n\n\"use client\";\n\n/**\n * @file useDrawerDialogPresence.ts\n * @input Controlled open state, modal mode, dialog ref, and rendered-state setter\n * @output Coordinates native dialog presence, exit timing, focus restoration, and unmount cleanup\n * @position Drawer-internal hook; consumed only by Drawer.tsx\n *\n * The drawer has two independent notions of presence:\n * - React's rendered state keeps the panel visible for its CSS exit.\n * - The native dialog's `open` state: `showModal()` (top layer) with a scrim,\n * `show()` (in the page, by z-index) without (ui-common; lab uses\n * `showPopover()`).\n *\n * Their close ordering is a browser-visible invariant: the panel must finish\n * its exit, then leave the active native host and hide in the same task. If the\n * hide lands a frame later, a transformed ancestor becomes the containing block\n * for the now-non-top-layer `position: fixed` panel and it paints back inside\n * the page for one frame.\n *\n * SYNC: When modified, update:\n * - /packages/lab/src/Drawer/Drawer.test.tsx\n * - /.github/scripts/modal-close-visibility.js\n */\n\nimport {\n useEffect,\n useRef,\n type Dispatch,\n type RefObject,\n type SetStateAction,\n} from \"react\";\nimport { flushSync } from \"react-dom\";\n\n/** Slack past the computed transition before the backstop gives up waiting. */\nconst EXIT_BACKSTOP_BUFFER_MS = 50;\n\n/**\n * Hold used when the transition duration cannot be read — an unresolved\n * `var()` outside a real browser. Picking a fixed number would otherwise make\n * an assumption about the consumer's theme.\n */\nconst EXIT_FALLBACK_MS = 250;\n\ntype UseDrawerDialogPresenceOptions = {\n dialogRef: RefObject<HTMLDialogElement | null>;\n isOpen: boolean;\n isModal: boolean;\n setIsRendered: Dispatch<SetStateAction<boolean>>;\n};\n\n// ui-common: a non-modal drawer opens with `show()` and stacks by z-index, as\n// it did before lab 0.6.5 moved it into the top layer as a manual popover.\n// ui-common's `Modal` and notification stack are z-index surfaces too, so a\n// top-layer drawer would paint over every one of them (Drawer.tsx).\nfunction isDrawerHostOpen(dialog: HTMLDialogElement): boolean {\n return dialog.open;\n}\n\nfunction showDrawerHost(dialog: HTMLDialogElement, isModal: boolean): void {\n if (isModal) {\n dialog.showModal();\n } else {\n dialog.show();\n }\n}\n\n/** Leaves the native host; `close()` fires the native `close` event itself. */\nfunction hideDrawerHost(dialog: HTMLDialogElement): void {\n if (dialog.open) {\n dialog.close();\n }\n}\n\n/**\n * Coordinates the native dialog and React-rendered presence for Drawer.\n *\n * Opening captures the trigger, opens the dialog (`showModal()` or `show()`),\n * and honours the component's `data-autofocus` contract. Closing waits for the\n * actual transform transition (with a computed-duration backstop), then calls\n * `close()` (which fires the native `close` event) and synchronously hides the\n * panel before the browser can paint it outside the top layer, then restores\n * focus to the captured trigger. Unmount cleanup closes a dialog left open by\n * React Activity or a removed subtree.\n */\nexport function useDrawerDialogPresence({\n dialogRef,\n isOpen,\n isModal,\n setIsRendered,\n}: UseDrawerDialogPresenceOptions): void {\n // Element focused when the drawer opened — restored on close.\n const triggerElementRef = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n const dialog = dialogRef.current;\n if (!dialog) {\n return;\n }\n\n if (isOpen) {\n if (!isDrawerHostOpen(dialog)) {\n triggerElementRef.current = document.activeElement as HTMLElement | null;\n showDrawerHost(dialog, isModal);\n // React's autoFocus calls .focus() during commit, before the native host\n // is visible, so it silently fails — honour data-autofocus instead (same\n // contract as Dialog).\n dialog.querySelector<HTMLElement>(\"[data-autofocus]\")?.focus();\n }\n return;\n }\n\n if (!isDrawerHostOpen(dialog)) {\n return;\n }\n\n return waitForDrawerExit(dialog, () => {\n hideDrawerHost(dialog);\n // flushSync, not a plain setState: React's default scheduling can land\n // the commit after the next paint, and that one frame is exactly the\n // bug — the panel paints outside the top layer. Both happen in this\n // task, so the browser never gets to paint between them.\n flushSync(() => {\n setIsRendered(false);\n });\n // Return focus after leaving the native host: a modal dialog makes the\n // rest of the document inert, so focusing earlier silently fails.\n triggerElementRef.current?.focus();\n triggerElementRef.current = null;\n });\n }, [dialogRef, isModal, isOpen, setIsRendered]);\n\n // Leave the active native host on unmount. When the drawer is mounted inside\n // an <Activity> that flips to mode=\"hidden\", React runs effect cleanups (with\n // stale isOpen) instead of re-running the effect with isOpen=false. Leaving\n // the host active would strand the top-layer surface and skip the next open.\n // This is deliberately separate from the open/close effect: putting it in\n // that cleanup would cut off every delayed slide-out.\n useEffect(() => {\n const dialog = dialogRef.current;\n return () => {\n if (dialog && isDrawerHostOpen(dialog)) {\n hideDrawerHost(dialog);\n }\n };\n }, [dialogRef]);\n}\n\n/**\n * Wait for the panel's transform transition, with a computed-duration\n * backstop. Mirrors BottomSheetPanel.waitForTransition: the native event is\n * authoritative, and the timeout only prevents a lost event from stranding an\n * open dialog.\n */\nfunction waitForDrawerExit(\n element: HTMLDialogElement,\n complete: () => void,\n): () => void {\n let done = false;\n let timer: ReturnType<typeof setTimeout> | null = null;\n\n const finish = () => {\n if (done) {\n return;\n }\n done = true;\n if (timer != null) {\n clearTimeout(timer);\n }\n element.removeEventListener(\"transitionend\", handleTransitionEnd);\n element.removeEventListener(\"transitioncancel\", handleTransitionEnd);\n complete();\n };\n\n const handleTransitionEnd = (event: TransitionEvent) => {\n if (event.target === element && event.propertyName === \"transform\") {\n finish();\n }\n };\n\n element.addEventListener(\"transitionend\", handleTransitionEnd);\n element.addEventListener(\"transitioncancel\", handleTransitionEnd);\n\n const transitionMs = readTransformTransitionMs(element);\n timer = setTimeout(\n finish,\n (transitionMs ?? EXIT_FALLBACK_MS) + EXIT_BACKSTOP_BUFFER_MS,\n );\n\n return () => {\n done = true;\n if (timer != null) {\n clearTimeout(timer);\n }\n element.removeEventListener(\"transitionend\", handleTransitionEnd);\n element.removeEventListener(\"transitioncancel\", handleTransitionEnd);\n };\n}\n\n/** Read the transform transition's duration + delay from computed CSS. */\nfunction readTransformTransitionMs(element: HTMLElement): number | null {\n const computed = window.getComputedStyle(element);\n const properties = computed.transitionProperty\n .split(\",\")\n .map((value) => value.trim());\n const durations = parseTimes(computed.transitionDuration);\n const delays = parseTimes(computed.transitionDelay);\n\n if (\n properties.length === 0 ||\n durations.length === 0 ||\n delays.length === 0 ||\n durations.includes(null) ||\n delays.includes(null)\n ) {\n return null;\n }\n\n return properties.reduce((longest, property, index) => {\n if (property !== \"transform\" && property !== \"all\") {\n return longest;\n }\n const duration = durations[index % durations.length];\n const delay = delays[index % delays.length];\n return Math.max(longest, (duration ?? 0) + (delay ?? 0));\n }, 0);\n}\n\nfunction parseTimes(value: string): (number | null)[] {\n return value.split(\",\").map((part) => {\n const trimmed = part.trim();\n const time = Number.parseFloat(trimmed);\n if (!Number.isFinite(time)) {\n return null;\n }\n if (trimmed.endsWith(\"ms\")) {\n return time;\n }\n return trimmed.endsWith(\"s\") ? time * 1000 : null;\n });\n}\n"],"mappings":";;;;AA0CA,IAAM,IAA0B,IAO1B,IAAmB;AAazB,SAAS,EAAiB,GAAoC;CAC5D,OAAO,EAAO;AAChB;AAEA,SAAS,EAAe,GAA2B,GAAwB;CACzE,AAAI,IACF,EAAO,UAAU,IAEjB,EAAO,KAAK;AAEhB;AAGA,SAAS,EAAe,GAAiC;CACvD,AAAI,EAAO,QACT,EAAO,MAAM;AAEjB;AAaA,SAAgB,EAAwB,EACtC,cACA,WACA,YACA,oBACuC;CAEvC,IAAM,IAAoB,EAA2B,IAAI;CA8CzD,AA5CA,QAAgB;EACd,IAAM,IAAS,EAAU;EACpB,OAIL;OAAI,GAAQ;IACV,AAAK,EAAiB,CAAM,MAC1B,EAAkB,UAAU,SAAS,eACrC,EAAe,GAAQ,CAAO,GAI9B,EAAO,cAA2B,kBAAkB,CAAC,EAAE,MAAM;IAE/D;GACF;GAEK,MAAiB,CAAM,GAI5B,OAAO,EAAkB,SAAc;IAYrC,AAXA,EAAe,CAAM,GAKrB,QAAgB;KACd,EAAc,EAAK;IACrB,CAAC,GAGD,EAAkB,SAAS,MAAM,GACjC,EAAkB,UAAU;GAC9B,CAAC;EAnBD;CAoBF,GAAG;EAAC;EAAW;EAAS;EAAQ;CAAa,CAAC,GAQ9C,QAAgB;EACd,IAAM,IAAS,EAAU;EACzB,aAAa;GACX,AAAI,KAAU,EAAiB,CAAM,KACnC,EAAe,CAAM;EAEzB;CACF,GAAG,CAAC,CAAS,CAAC;AAChB;AAQA,SAAS,EACP,GACA,GACY;CACZ,IAAI,IAAO,IACP,IAA8C,MAE5C,UAAe;EACf,MAGJ,IAAO,IACH,KAAS,QACX,aAAa,CAAK,GAEpB,EAAQ,oBAAoB,iBAAiB,CAAmB,GAChE,EAAQ,oBAAoB,oBAAoB,CAAmB,GACnE,EAAS;CACX,GAEM,KAAuB,MAA2B;EACtD,AAAI,EAAM,WAAW,KAAW,EAAM,iBAAiB,eACrD,EAAO;CAEX;CAGA,AADA,EAAQ,iBAAiB,iBAAiB,CAAmB,GAC7D,EAAQ,iBAAiB,oBAAoB,CAAmB;CAEhE,IAAM,IAAe,EAA0B,CAAO;CAMtD,OALA,IAAQ,WACN,IACC,KAAgB,KAAoB,CACvC,SAEa;EAMX,AALA,IAAO,IACH,KAAS,QACX,aAAa,CAAK,GAEpB,EAAQ,oBAAoB,iBAAiB,CAAmB,GAChE,EAAQ,oBAAoB,oBAAoB,CAAmB;CACrE;AACF;AAGA,SAAS,EAA0B,GAAqC;CACtE,IAAM,IAAW,OAAO,iBAAiB,CAAO,GAC1C,IAAa,EAAS,mBACzB,MAAM,GAAG,CAAC,CACV,KAAK,MAAU,EAAM,KAAK,CAAC,GACxB,IAAY,EAAW,EAAS,kBAAkB,GAClD,IAAS,EAAW,EAAS,eAAe;CAYlD,OATE,EAAW,WAAW,KACtB,EAAU,WAAW,KACrB,EAAO,WAAW,KAClB,EAAU,SAAS,IAAI,KACvB,EAAO,SAAS,IAAI,IAEb,OAGF,EAAW,QAAQ,GAAS,GAAU,MAAU;EACrD,IAAI,MAAa,eAAe,MAAa,OAC3C,OAAO;EAET,IAAM,IAAW,EAAU,IAAQ,EAAU,SACvC,IAAQ,EAAO,IAAQ,EAAO;EACpC,OAAO,KAAK,IAAI,IAAU,KAAY,MAAM,KAAS,EAAE;CACzD,GAAG,CAAC;AACN;AAEA,SAAS,EAAW,GAAkC;CACpD,OAAO,EAAM,MAAM,GAAG,CAAC,CAAC,KAAK,MAAS;EACpC,IAAM,IAAU,EAAK,KAAK,GACpB,IAAO,OAAO,WAAW,CAAO;EAOtC,OANK,OAAO,SAAS,CAAI,IAGrB,EAAQ,SAAS,IAAI,IAChB,IAEF,EAAQ,SAAS,GAAG,IAAI,IAAO,MAAO,OALpC;CAMX,CAAC;AACH"}
1
+ {"version":3,"file":"useDrawerDialogPresence.js","names":[],"sources":["../../../src/forks/Drawer/useDrawerDialogPresence.ts"],"sourcesContent":["// Copyright (c) Meta Platforms, Inc. and affiliates.\n//\n// Forked from @astryxdesign/lab 0.7.0-canary.97a0d31, src/Drawer/useDrawerDialogPresence.ts\n// (MIT; see NOTICE). Changed (marked `ui-common:`): a non-modal drawer opens\n// with `show()`, not `showPopover()`, so it stays out of the top layer (Drawer.tsx).\n// Provenance and the drift guard: src/forks/provenance.json.\n\n\"use client\";\n\n/**\n * @file useDrawerDialogPresence.ts\n * @input Controlled open state, modal mode, dialog ref, and rendered-state setter\n * @output Coordinates native dialog presence, exit timing, focus restoration, and unmount cleanup\n * @position Drawer-internal hook; consumed only by Drawer.tsx\n *\n * The drawer has two independent notions of presence:\n * - React's rendered state keeps the panel visible for its CSS exit.\n * - The native dialog's `open` state: `showModal()` (top layer) with a scrim,\n * `show()` (in the page, by z-index) without (ui-common; lab uses\n * `showPopover()`).\n *\n * Their close ordering is a browser-visible invariant: the panel must finish\n * its exit, then leave the active native host and hide in the same task. If the\n * hide lands a frame later, a transformed ancestor becomes the containing block\n * for the now-non-top-layer `position: fixed` panel and it paints back inside\n * the page for one frame.\n *\n * SYNC: When modified, update:\n * - /packages/lab/src/Drawer/Drawer.test.tsx\n * - /.github/scripts/modal-close-visibility.js\n */\n\nimport {\n useEffect,\n useRef,\n type Dispatch,\n type RefObject,\n type SetStateAction,\n} from \"react\";\nimport { flushSync } from \"react-dom\";\n\n/** Slack past the computed transition before the backstop gives up waiting. */\nconst EXIT_BACKSTOP_BUFFER_MS = 50;\n\n/**\n * Hold used when the transition duration cannot be read — an unresolved\n * `var()` outside a real browser. Picking a fixed number would otherwise make\n * an assumption about the consumer's theme.\n */\nconst EXIT_FALLBACK_MS = 250;\n\ntype UseDrawerDialogPresenceOptions = {\n dialogRef: RefObject<HTMLDialogElement | null>;\n isOpen: boolean;\n isModal: boolean;\n setIsRendered: Dispatch<SetStateAction<boolean>>;\n};\n\n// ui-common: a non-modal drawer opens with `show()` and stacks by z-index, as\n// it did before lab 0.6.5 moved it into the top layer as a manual popover.\n// ui-common's `Modal` and notification stack are z-index surfaces too, so a\n// top-layer drawer would paint over every one of them (Drawer.tsx).\nfunction isDrawerHostOpen(dialog: HTMLDialogElement): boolean {\n return dialog.open;\n}\n\nfunction showDrawerHost(dialog: HTMLDialogElement, isModal: boolean): void {\n if (isModal) {\n dialog.showModal();\n } else {\n dialog.show();\n }\n}\n\n/** Leaves the native host; `close()` fires the native `close` event itself. */\nfunction hideDrawerHost(dialog: HTMLDialogElement): void {\n if (dialog.open) {\n dialog.close();\n }\n}\n\n/**\n * Coordinates the native dialog and React-rendered presence for Drawer.\n *\n * Opening captures the trigger, opens the dialog (`showModal()` or `show()`),\n * and honours the component's `data-autofocus` contract. Closing waits for the\n * actual transform transition (with a computed-duration backstop), then calls\n * `close()` (which fires the native `close` event) and synchronously hides the\n * panel before the browser can paint it outside the top layer, then restores\n * focus to the captured trigger. Unmount cleanup closes a dialog left open by\n * React Activity or a removed subtree.\n */\nexport function useDrawerDialogPresence({\n dialogRef,\n isOpen,\n isModal,\n setIsRendered,\n}: UseDrawerDialogPresenceOptions): void {\n // Element focused when the drawer opened — restored on close.\n const triggerElementRef = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n const dialog = dialogRef.current;\n if (!dialog) {\n return;\n }\n\n if (isOpen) {\n if (!isDrawerHostOpen(dialog)) {\n triggerElementRef.current = document.activeElement as HTMLElement | null;\n showDrawerHost(dialog, isModal);\n // React's autoFocus calls .focus() during commit, before the native host\n // is visible, so it silently fails — honour data-autofocus instead (same\n // contract as Dialog).\n dialog.querySelector<HTMLElement>(\"[data-autofocus]\")?.focus();\n }\n return;\n }\n\n if (!isDrawerHostOpen(dialog)) {\n return;\n }\n\n return waitForDrawerExit(dialog, () => {\n hideDrawerHost(dialog);\n // flushSync, not a plain setState: React's default scheduling can land\n // the commit after the next paint, and that one frame is exactly the\n // bug — the panel paints outside the top layer. Both happen in this\n // task, so the browser never gets to paint between them.\n flushSync(() => {\n setIsRendered(false);\n });\n // Return focus after leaving the native host: a modal dialog makes the\n // rest of the document inert, so focusing earlier silently fails.\n triggerElementRef.current?.focus();\n triggerElementRef.current = null;\n });\n }, [dialogRef, isModal, isOpen, setIsRendered]);\n\n // Leave the active native host on unmount. When the drawer is mounted inside\n // an <Activity> that flips to mode=\"hidden\", React runs effect cleanups (with\n // stale isOpen) instead of re-running the effect with isOpen=false. Leaving\n // the host active would strand the top-layer surface and skip the next open.\n // This is deliberately separate from the open/close effect: putting it in\n // that cleanup would cut off every delayed slide-out.\n useEffect(() => {\n const dialog = dialogRef.current;\n return () => {\n if (dialog && isDrawerHostOpen(dialog)) {\n hideDrawerHost(dialog);\n }\n };\n }, [dialogRef]);\n}\n\n/**\n * Wait for the panel's transform transition, with a computed-duration\n * backstop. Mirrors BottomSheetPanel.waitForTransition: the native event is\n * authoritative, and the timeout only prevents a lost event from stranding an\n * open dialog.\n */\nfunction waitForDrawerExit(\n element: HTMLDialogElement,\n complete: () => void,\n): () => void {\n let done = false;\n let timer: ReturnType<typeof setTimeout> | null = null;\n\n const finish = () => {\n if (done) {\n return;\n }\n done = true;\n if (timer != null) {\n clearTimeout(timer);\n }\n element.removeEventListener(\"transitionend\", handleTransitionEnd);\n element.removeEventListener(\"transitioncancel\", handleTransitionEnd);\n complete();\n };\n\n const handleTransitionEnd = (event: TransitionEvent) => {\n if (event.target === element && event.propertyName === \"transform\") {\n finish();\n }\n };\n\n element.addEventListener(\"transitionend\", handleTransitionEnd);\n element.addEventListener(\"transitioncancel\", handleTransitionEnd);\n\n const transitionMs = readTransformTransitionMs(element);\n timer = setTimeout(\n finish,\n (transitionMs ?? EXIT_FALLBACK_MS) + EXIT_BACKSTOP_BUFFER_MS,\n );\n\n return () => {\n done = true;\n if (timer != null) {\n clearTimeout(timer);\n }\n element.removeEventListener(\"transitionend\", handleTransitionEnd);\n element.removeEventListener(\"transitioncancel\", handleTransitionEnd);\n };\n}\n\n/** Read the transform transition's duration + delay from computed CSS. */\nfunction readTransformTransitionMs(element: HTMLElement): number | null {\n const computed = window.getComputedStyle(element);\n const properties = computed.transitionProperty\n .split(\",\")\n .map((value) => value.trim());\n const durations = parseTimes(computed.transitionDuration);\n const delays = parseTimes(computed.transitionDelay);\n\n if (\n properties.length === 0 ||\n durations.length === 0 ||\n delays.length === 0 ||\n durations.includes(null) ||\n delays.includes(null)\n ) {\n return null;\n }\n\n return properties.reduce((longest, property, index) => {\n if (property !== \"transform\" && property !== \"all\") {\n return longest;\n }\n const duration = durations[index % durations.length];\n const delay = delays[index % delays.length];\n return Math.max(longest, (duration ?? 0) + (delay ?? 0));\n }, 0);\n}\n\nfunction parseTimes(value: string): (number | null)[] {\n return value.split(\",\").map((part) => {\n const trimmed = part.trim();\n const time = Number.parseFloat(trimmed);\n if (!Number.isFinite(time)) {\n return null;\n }\n if (trimmed.endsWith(\"ms\")) {\n return time;\n }\n return trimmed.endsWith(\"s\") ? time * 1000 : null;\n });\n}\n"],"mappings":";;;;AA0CA,IAAM,IAA0B,IAO1B,IAAmB;AAazB,SAAS,EAAiB,GAAoC;CAC5D,OAAO,EAAO;AAChB;AAEA,SAAS,EAAe,GAA2B,GAAwB;CACzE,AAAI,IACF,EAAO,UAAU,IAEjB,EAAO,KAAK;AAEhB;AAGA,SAAS,EAAe,GAAiC;CACvD,AAAI,EAAO,QACT,EAAO,MAAM;AAEjB;AAaA,SAAgB,EAAwB,EACtC,cACA,WACA,YACA,oBACuC;CAEvC,IAAM,IAAoB,EAA2B,IAAI;CA8CzD,AA5CA,QAAgB;EACd,IAAM,IAAS,EAAU;EACpB,OAIL;OAAI,GAAQ;IACV,AAAK,EAAiB,CAAM,MAC1B,EAAkB,UAAU,SAAS,eACrC,EAAe,GAAQ,CAAO,GAI9B,EAAO,cAA2B,kBAAkB,CAAC,EAAE,MAAM;IAE/D;GACF;GAEK,MAAiB,CAAM,GAI5B,OAAO,EAAkB,SAAc;IAYrC,AAXA,EAAe,CAAM,GAKrB,QAAgB;KACd,EAAc,EAAK;IACrB,CAAC,GAGD,EAAkB,SAAS,MAAM,GACjC,EAAkB,UAAU;GAC9B,CAAC;EAnBD;CAoBF,GAAG;EAAC;EAAW;EAAS;EAAQ;CAAa,CAAC,GAQ9C,QAAgB;EACd,IAAM,IAAS,EAAU;EACzB,aAAa;GACX,AAAI,KAAU,EAAiB,CAAM,KACnC,EAAe,CAAM;EAEzB;CACF,GAAG,CAAC,CAAS,CAAC;AAChB;AAQA,SAAS,EACP,GACA,GACY;CACZ,IAAI,IAAO,IACP,IAA8C,MAE5C,UAAe;EACf,MAGJ,IAAO,IACH,KAAS,QACX,aAAa,CAAK,GAEpB,EAAQ,oBAAoB,iBAAiB,CAAmB,GAChE,EAAQ,oBAAoB,oBAAoB,CAAmB,GACnE,EAAS;CACX,GAEM,KAAuB,MAA2B;EACtD,AAAI,EAAM,WAAW,KAAW,EAAM,iBAAiB,eACrD,EAAO;CAEX;CAGA,AADA,EAAQ,iBAAiB,iBAAiB,CAAmB,GAC7D,EAAQ,iBAAiB,oBAAoB,CAAmB;CAEhE,IAAM,IAAe,EAA0B,CAAO;CAMtD,OALA,IAAQ,WACN,IACC,KAAgB,KAAoB,CACvC,SAEa;EAMX,AALA,IAAO,IACH,KAAS,QACX,aAAa,CAAK,GAEpB,EAAQ,oBAAoB,iBAAiB,CAAmB,GAChE,EAAQ,oBAAoB,oBAAoB,CAAmB;CACrE;AACF;AAGA,SAAS,EAA0B,GAAqC;CACtE,IAAM,IAAW,OAAO,iBAAiB,CAAO,GAC1C,IAAa,EAAS,mBACzB,MAAM,GAAG,CAAC,CACV,KAAK,MAAU,EAAM,KAAK,CAAC,GACxB,IAAY,EAAW,EAAS,kBAAkB,GAClD,IAAS,EAAW,EAAS,eAAe;CAYlD,OATE,EAAW,WAAW,KACtB,EAAU,WAAW,KACrB,EAAO,WAAW,KAClB,EAAU,SAAS,IAAI,KACvB,EAAO,SAAS,IAAI,IAEb,OAGF,EAAW,QAAQ,GAAS,GAAU,MAAU;EACrD,IAAI,MAAa,eAAe,MAAa,OAC3C,OAAO;EAET,IAAM,IAAW,EAAU,IAAQ,EAAU,SACvC,IAAQ,EAAO,IAAQ,EAAO;EACpC,OAAO,KAAK,IAAI,IAAU,KAAY,MAAM,KAAS,EAAE;CACzD,GAAG,CAAC;AACN;AAEA,SAAS,EAAW,GAAkC;CACpD,OAAO,EAAM,MAAM,GAAG,CAAC,CAAC,KAAK,MAAS;EACpC,IAAM,IAAU,EAAK,KAAK,GACpB,IAAO,OAAO,WAAW,CAAO;EAOtC,OANK,OAAO,SAAS,CAAI,IAGrB,EAAQ,SAAS,IAAI,IAChB,IAEF,EAAQ,SAAS,GAAG,IAAI,IAAO,MAAO,OALpC;CAMX,CAAC;AACH"}
@@ -1,55 +1,53 @@
1
1
  "use client";
2
2
  import { TourContext as e } from "./TourContext.js";
3
- import { useCallback as t, useEffect as n, useMemo as r, useState as i } from "react";
4
- import { jsx as a } from "react/jsx-runtime";
3
+ import { useCallback as t, useMemo as n, useState as r } from "react";
4
+ import { jsx as i } from "react/jsx-runtime";
5
5
  //#region src/forks/Tour/Tour.tsx
6
- function o({ isActive: o, children: s, onDismiss: c, hasBackdrop: l = !1, isStepCountShown: u = !1 }) {
7
- let [d, f] = i([]), [p, m] = i(0), h = t((e) => (f((t) => t.includes(e) ? t : [...t, e]), () => {
8
- f((t) => t.filter((t) => t !== e));
9
- }), []);
10
- n(() => {
11
- o || m(0);
12
- }, [o]);
13
- let g = d.length, _ = t(() => {
14
- if (p < g - 1) {
15
- m(p + 1);
6
+ function a({ isActive: a, children: o, onDismiss: s, hasBackdrop: c = !1, isStepCountShown: l = !1 }) {
7
+ let [u, d] = r([]), [f, p] = r(0), m = t((e) => (d((t) => t.includes(e) ? t : [...t, e]), () => {
8
+ d((t) => t.filter((t) => t !== e));
9
+ }), []), [h, g] = r(a);
10
+ Object.is(h, a) || (g(a), a || p(0));
11
+ let _ = u.length, v = t(() => {
12
+ if (f < _ - 1) {
13
+ p(f + 1);
16
14
  return;
17
15
  }
18
- c("complete");
16
+ s("complete");
19
17
  }, [
20
- p,
21
- g,
22
- c
23
- ]), v = t(() => {
24
- m((e) => e > 0 ? e - 1 : e);
25
- }, []), y = o ? d[p] ?? null : null, b = r(() => ({
26
- registerStep: h,
27
- activeStepId: y,
28
- activeStepIndex: p,
29
- stepCount: g,
30
- isStepCountShown: u,
31
- hasBackdrop: l,
32
- onNext: _,
33
- onPrevious: v,
34
- onDismiss: c
18
+ f,
19
+ _,
20
+ s
21
+ ]), y = t(() => {
22
+ p((e) => e > 0 ? e - 1 : e);
23
+ }, []), b = a ? u[f] ?? null : null, x = n(() => ({
24
+ registerStep: m,
25
+ activeStepId: b,
26
+ activeStepIndex: f,
27
+ stepCount: _,
28
+ isStepCountShown: l,
29
+ hasBackdrop: c,
30
+ onNext: v,
31
+ onPrevious: y,
32
+ onDismiss: s
35
33
  }), [
36
- h,
37
- y,
38
- p,
39
- g,
40
- u,
41
- l,
34
+ m,
35
+ b,
36
+ f,
42
37
  _,
38
+ l,
39
+ c,
43
40
  v,
44
- c
41
+ y,
42
+ s
45
43
  ]);
46
- return /* @__PURE__ */ a(e.Provider, {
47
- value: b,
48
- children: s
44
+ return /* @__PURE__ */ i(e.Provider, {
45
+ value: x,
46
+ children: o
49
47
  });
50
48
  }
51
- o.displayName = "Tour";
49
+ a.displayName = "Tour";
52
50
  //#endregion
53
- export { o as Tour };
51
+ export { a as Tour };
54
52
 
55
53
  //# sourceMappingURL=Tour.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tour.js","names":[],"sources":["../../../src/forks/Tour/Tour.tsx"],"sourcesContent":["// Copyright (c) Meta Platforms, Inc. and affiliates.\n//\n// Forked from @astryxdesign/lab 0.6.5-canary.8701623, src/Tour/Tour.tsx\n// (MIT; see NOTICE). Unchanged: forked with TourStep, whose context it provides.\n// Provenance and the drift guard: src/forks/provenance.json.\n\n\"use client\";\n\n/**\n * @file Tour.tsx\n * @input Uses React state/refs, TourContext\n * @output Exports Tour controller component and TourProps\n * @position Lab experiment (facebook/astryx#4239); controller consumed by index.ts\n *\n * Tour is the controller for a product-tour / NUX walkthrough. It renders no\n * visible chrome of its own — it owns the tour state (active step, advance /\n * retreat / complete / dismiss) and shares it with declaratively-nested\n * `<TourStep>` children through context. Steps register on mount, so the step\n * ORDER is taken from the children in document order (no step array to keep in\n * sync with the markup).\n *\n * The behavior (a controller plus spotlight feature steps, an `isActive`\n * switch, dismiss-with-reason, and step progress) is composed from Astryx\n * primitives. Each step anchors its callout via Popover and draws its own\n * highlight/backdrop (see TourStep) — the controller owns no chrome.\n *\n * SYNC: When modified, update these files to stay in sync:\n * - /packages/lab/src/Tour/TourStep.tsx\n * - /packages/lab/src/Tour/TourContext.ts\n * - /packages/lab/src/Tour/useTour.ts\n * - /packages/lab/src/Tour/Tour.doc.mjs (props table, features)\n * - /packages/lab/src/Tour/Tour.test.tsx (tests for new/changed behavior)\n * - /packages/lab/src/Tour/index.ts (exports if types change)\n */\n\nimport { useCallback, useEffect, useMemo, useState, type ReactNode } from \"react\";\nimport {\n TourContext,\n type TourDismissSource,\n type TourContextValue,\n} from \"./TourContext\";\n\nexport interface TourProps {\n /**\n * Whether the tour is running. When false, nothing renders and step state\n * resets — the tour restarts from the first step next time it becomes active.\n * (Controlled: the consumer owns \"has this user seen the tour?\".)\n */\n isActive: boolean;\n /**\n * The tour's steps — `<TourStep>` elements. Step order is taken from their\n * order here; only the active step renders its callout.\n */\n children?: ReactNode;\n /**\n * Called when the tour is dismissed, with the reason. Fires for every exit,\n * including completing the last step (`source === 'complete'`). The consumer\n * flips `isActive` to false in response, and can branch on the source to tell\n * a successful finish apart from an early skip/backdrop/escape.\n */\n onDismiss: (source: TourDismissSource) => void;\n /**\n * Dim the page around the active step's target (a spotlight cutout — the\n * target stays lit, everything else darkens). Use for modal-style steps that\n * demand focus; leave off for a lightweight coachmark that only rings the\n * target.\n * @default false\n */\n hasBackdrop?: boolean;\n /**\n * Show the step count (\"2 of 5\") in each step.\n * @default false\n */\n isStepCountShown?: boolean;\n}\n\n/**\n * Controller for a guided product tour. Renders no chrome; coordinates the\n * active step among its `<TourStep>` children.\n *\n * @example\n * ```\n * const [isActive, setIsActive] = useState(true);\n * const saveRef = useRef(null);\n * const shareRef = useRef(null);\n * <Tour isActive={isActive} hasBackdrop isStepCountShown onDismiss={() => setIsActive(false)}>\n * <TourStep targetRef={saveRef} heading=\"Save your work\">\n * Changes save automatically to the cloud.\n * </TourStep>\n * <TourStep targetRef={shareRef} heading=\"Share it\">\n * Invite teammates from here.\n * </TourStep>\n * </Tour>\n * ```\n */\nexport function Tour({\n isActive,\n children,\n onDismiss,\n hasBackdrop = false,\n isStepCountShown = false,\n}: TourProps) {\n // Steps register on mount; insertion order (document order) defines the\n // sequence. A plain array keeps registration order deterministic.\n const [stepIds, setStepIds] = useState<string[]>([]);\n const [activeStepIndex, setActiveStepIndex] = useState(0);\n\n const registerStep = useCallback((id: string) => {\n setStepIds((prev) => (prev.includes(id) ? prev : [...prev, id]));\n return () => {\n setStepIds((prev) => prev.filter((stepId) => stepId !== id));\n };\n }, []);\n\n // Reset to the first step whenever the tour is (re)started, so a dismissed\n // tour begins from the top next time isActive flips back on.\n useEffect(() => {\n if (!isActive) {\n setActiveStepIndex(0);\n }\n }, [isActive]);\n\n const stepCount = stepIds.length;\n\n const onNext = useCallback(() => {\n // Runs from a click/imperative call (never during render), so branch on the\n // current index directly rather than inside a state updater — calling\n // onDismiss from within setState triggers a \"setState while rendering\"\n // warning.\n if (activeStepIndex < stepCount - 1) {\n setActiveStepIndex(activeStepIndex + 1);\n return;\n }\n // Past the last step → complete. onDismiss carries the reason so a\n // consumer can branch on 'complete' vs an early exit.\n onDismiss(\"complete\");\n }, [activeStepIndex, stepCount, onDismiss]);\n\n const onPrevious = useCallback(() => {\n setActiveStepIndex((prev) => (prev > 0 ? prev - 1 : prev));\n }, []);\n\n const activeStepId = isActive ? (stepIds[activeStepIndex] ?? null) : null;\n\n const contextValue = useMemo<TourContextValue>(\n () => ({\n registerStep,\n activeStepId,\n activeStepIndex,\n stepCount,\n isStepCountShown,\n hasBackdrop,\n onNext,\n onPrevious,\n onDismiss,\n }),\n [\n registerStep,\n activeStepId,\n activeStepIndex,\n stepCount,\n isStepCountShown,\n hasBackdrop,\n onNext,\n onPrevious,\n onDismiss,\n ],\n );\n\n return <TourContext.Provider value={contextValue}>{children}</TourContext.Provider>;\n}\n\nTour.displayName = \"Tour\";\n"],"mappings":";;;;;AA+FA,SAAgB,EAAK,EACnB,aACA,aACA,cACA,iBAAc,IACd,sBAAmB,MACP;CAGZ,IAAM,CAAC,GAAS,KAAc,EAAmB,CAAC,CAAC,GAC7C,CAAC,GAAiB,KAAsB,EAAS,CAAC,GAElD,IAAe,GAAa,OAChC,GAAY,MAAU,EAAK,SAAS,CAAE,IAAI,IAAO,CAAC,GAAG,GAAM,CAAE,CAAE,SAClD;EACX,GAAY,MAAS,EAAK,QAAQ,MAAW,MAAW,CAAE,CAAC;CAC7D,IACC,CAAC,CAAC;CAIL,QAAgB;EACd,AAAK,KACH,EAAmB,CAAC;CAExB,GAAG,CAAC,CAAQ,CAAC;CAEb,IAAM,IAAY,EAAQ,QAEpB,IAAS,QAAkB;EAK/B,IAAI,IAAkB,IAAY,GAAG;GACnC,EAAmB,IAAkB,CAAC;GACtC;EACF;EAGA,EAAU,UAAU;CACtB,GAAG;EAAC;EAAiB;EAAW;CAAS,CAAC,GAEpC,IAAa,QAAkB;EACnC,GAAoB,MAAU,IAAO,IAAI,IAAO,IAAI,CAAK;CAC3D,GAAG,CAAC,CAAC,GAEC,IAAe,IAAY,EAAQ,MAAoB,OAAQ,MAE/D,IAAe,SACZ;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,OAAO,kBAAC,EAAY,UAAb;EAAsB,OAAO;EAAe;CAA+B,CAAA;AACpF;AAEA,EAAK,cAAc"}
1
+ {"version":3,"file":"Tour.js","names":[],"sources":["../../../src/forks/Tour/Tour.tsx"],"sourcesContent":["// Copyright (c) Meta Platforms, Inc. and affiliates.\n//\n// Forked from @astryxdesign/lab 0.7.0-canary.97a0d31, src/Tour/Tour.tsx\n// (MIT; see NOTICE). Unchanged: forked with TourStep, whose context it provides.\n// Provenance and the drift guard: src/forks/provenance.json.\n\n\"use client\";\n\n/**\n * @file Tour.tsx\n * @input Uses React state/refs, TourContext\n * @output Exports Tour controller component and TourProps\n * @position Lab experiment (facebook/astryx#4239); controller consumed by index.ts\n *\n * Tour is the controller for a product-tour / NUX walkthrough. It renders no\n * visible chrome of its own — it owns the tour state (active step, advance /\n * retreat / complete / dismiss) and shares it with declaratively-nested\n * `<TourStep>` children through context. Steps register on mount, so the step\n * ORDER is taken from the children in document order (no step array to keep in\n * sync with the markup).\n *\n * The behavior (a controller plus spotlight feature steps, an `isActive`\n * switch, dismiss-with-reason, and step progress) is composed from Astryx\n * primitives. Each step anchors its callout via Popover and draws its own\n * highlight/backdrop (see TourStep) — the controller owns no chrome.\n *\n * SYNC: When modified, update these files to stay in sync:\n * - /packages/lab/src/Tour/TourStep.tsx\n * - /packages/lab/src/Tour/TourContext.ts\n * - /packages/lab/src/Tour/useTour.ts\n * - /packages/lab/src/Tour/Tour.doc.mjs (props table, features)\n * - /packages/lab/src/Tour/Tour.test.tsx (tests for new/changed behavior)\n * - /packages/lab/src/Tour/index.ts (exports if types change)\n */\n\nimport { useCallback, useMemo, useState, type ReactNode } from \"react\";\nimport {\n TourContext,\n type TourDismissSource,\n type TourContextValue,\n} from \"./TourContext\";\n\nexport interface TourProps {\n /**\n * Whether the tour is running. When false, nothing renders and step state\n * resets — the tour restarts from the first step next time it becomes active.\n * (Controlled: the consumer owns \"has this user seen the tour?\".)\n */\n isActive: boolean;\n /**\n * The tour's steps — `<TourStep>` elements. Step order is taken from their\n * order here; only the active step renders its callout.\n */\n children?: ReactNode;\n /**\n * Called when the tour is dismissed, with the reason. Fires for every exit,\n * including completing the last step (`source === 'complete'`). The consumer\n * flips `isActive` to false in response, and can branch on the source to tell\n * a successful finish apart from an early skip/backdrop/escape.\n */\n onDismiss: (source: TourDismissSource) => void;\n /**\n * Dim the page around the active step's target (a spotlight cutout — the\n * target stays lit, everything else darkens). Use for modal-style steps that\n * demand focus; leave off for a lightweight coachmark that only rings the\n * target.\n * @default false\n */\n hasBackdrop?: boolean;\n /**\n * Show the step count (\"2 of 5\") in each step.\n * @default false\n */\n isStepCountShown?: boolean;\n}\n\n/**\n * Controller for a guided product tour. Renders no chrome; coordinates the\n * active step among its `<TourStep>` children.\n *\n * @example\n * ```\n * const [isActive, setIsActive] = useState(true);\n * const saveRef = useRef(null);\n * const shareRef = useRef(null);\n * <Tour isActive={isActive} hasBackdrop isStepCountShown onDismiss={() => setIsActive(false)}>\n * <TourStep targetRef={saveRef} heading=\"Save your work\">\n * Changes save automatically to the cloud.\n * </TourStep>\n * <TourStep targetRef={shareRef} heading=\"Share it\">\n * Invite teammates from here.\n * </TourStep>\n * </Tour>\n * ```\n */\nexport function Tour({\n isActive,\n children,\n onDismiss,\n hasBackdrop = false,\n isStepCountShown = false,\n}: TourProps) {\n // Steps register on mount; insertion order (document order) defines the\n // sequence. A plain array keeps registration order deterministic.\n const [stepIds, setStepIds] = useState<string[]>([]);\n const [activeStepIndex, setActiveStepIndex] = useState(0);\n\n const registerStep = useCallback((id: string) => {\n setStepIds((prev) => (prev.includes(id) ? prev : [...prev, id]));\n return () => {\n setStepIds((prev) => prev.filter((stepId) => stepId !== id));\n };\n }, []);\n\n // Reset to the first step when the tour is deactivated, so a dismissed tour\n // begins from the top next time isActive flips back on. Adjusted during\n // render, so no commit carries the old step past deactivation.\n const [wasActive, setWasActive] = useState(isActive);\n if (!Object.is(wasActive, isActive)) {\n setWasActive(isActive);\n if (!isActive) {\n setActiveStepIndex(0);\n }\n }\n\n const stepCount = stepIds.length;\n\n const onNext = useCallback(() => {\n // Runs from a click/imperative call (never during render), so branch on the\n // current index directly rather than inside a state updater — calling\n // onDismiss from within setState triggers a \"setState while rendering\"\n // warning.\n if (activeStepIndex < stepCount - 1) {\n setActiveStepIndex(activeStepIndex + 1);\n return;\n }\n // Past the last step → complete. onDismiss carries the reason so a\n // consumer can branch on 'complete' vs an early exit.\n onDismiss(\"complete\");\n }, [activeStepIndex, stepCount, onDismiss]);\n\n const onPrevious = useCallback(() => {\n setActiveStepIndex((prev) => (prev > 0 ? prev - 1 : prev));\n }, []);\n\n const activeStepId = isActive ? (stepIds[activeStepIndex] ?? null) : null;\n\n const contextValue = useMemo<TourContextValue>(\n () => ({\n registerStep,\n activeStepId,\n activeStepIndex,\n stepCount,\n isStepCountShown,\n hasBackdrop,\n onNext,\n onPrevious,\n onDismiss,\n }),\n [\n registerStep,\n activeStepId,\n activeStepIndex,\n stepCount,\n isStepCountShown,\n hasBackdrop,\n onNext,\n onPrevious,\n onDismiss,\n ],\n );\n\n return <TourContext.Provider value={contextValue}>{children}</TourContext.Provider>;\n}\n\nTour.displayName = \"Tour\";\n"],"mappings":";;;;;AA+FA,SAAgB,EAAK,EACnB,aACA,aACA,cACA,iBAAc,IACd,sBAAmB,MACP;CAGZ,IAAM,CAAC,GAAS,KAAc,EAAmB,CAAC,CAAC,GAC7C,CAAC,GAAiB,KAAsB,EAAS,CAAC,GAElD,IAAe,GAAa,OAChC,GAAY,MAAU,EAAK,SAAS,CAAE,IAAI,IAAO,CAAC,GAAG,GAAM,CAAE,CAAE,SAClD;EACX,GAAY,MAAS,EAAK,QAAQ,MAAW,MAAW,CAAE,CAAC;CAC7D,IACC,CAAC,CAAC,GAKC,CAAC,GAAW,KAAgB,EAAS,CAAQ;CACnD,AAAK,OAAO,GAAG,GAAW,CAAQ,MAChC,EAAa,CAAQ,GAChB,KACH,EAAmB,CAAC;CAIxB,IAAM,IAAY,EAAQ,QAEpB,IAAS,QAAkB;EAK/B,IAAI,IAAkB,IAAY,GAAG;GACnC,EAAmB,IAAkB,CAAC;GACtC;EACF;EAGA,EAAU,UAAU;CACtB,GAAG;EAAC;EAAiB;EAAW;CAAS,CAAC,GAEpC,IAAa,QAAkB;EACnC,GAAoB,MAAU,IAAO,IAAI,IAAO,IAAI,CAAK;CAC3D,GAAG,CAAC,CAAC,GAEC,IAAe,IAAY,EAAQ,MAAoB,OAAQ,MAE/D,IAAe,SACZ;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,OAAO,kBAAC,EAAY,UAAb;EAAsB,OAAO;EAAe;CAA+B,CAAA;AACpF;AAEA,EAAK,cAAc"}