@namroodinc/liquid-editorial 0.3.2 → 0.3.3
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.
- package/README.md +1562 -177
- package/UPGRADING.md +70 -0
- package/dist/chunks/{ColourField-C2YDshDg.js → ColourField-Bd4twbaG.js} +128 -135
- package/dist/chunks/ColourField-Bd4twbaG.js.map +1 -0
- package/dist/chunks/ColourField-BdAbjgmY.cjs +2 -0
- package/dist/chunks/ColourField-BdAbjgmY.cjs.map +1 -0
- package/dist/chunks/dialogFocus-B9iqKl3I.cjs +2 -0
- package/dist/chunks/dialogFocus-B9iqKl3I.cjs.map +1 -0
- package/dist/chunks/dialogFocus-BFoyeTpA.js +48 -0
- package/dist/chunks/dialogFocus-BFoyeTpA.js.map +1 -0
- package/dist/components/ColourField/focus.d.cts +0 -1
- package/dist/components/ColourField/focus.d.cts.map +1 -1
- package/dist/components/ColourField/focus.d.ts +0 -1
- package/dist/components/ColourField/focus.d.ts.map +1 -1
- package/dist/components/ColourField/index.cjs +1 -1
- package/dist/components/ColourField/index.d.cts.map +1 -1
- package/dist/components/ColourField/index.d.ts.map +1 -1
- package/dist/components/ColourField/index.js +1 -1
- package/dist/components/Drawer/index.cjs +1 -1
- package/dist/components/Drawer/index.cjs.map +1 -1
- package/dist/components/Drawer/index.d.cts.map +1 -1
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +69 -73
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/EditLayout/index.cjs +1 -1
- package/dist/components/EditLayout/index.cjs.map +1 -1
- package/dist/components/EditLayout/index.d.cts.map +1 -1
- package/dist/components/EditLayout/index.d.ts.map +1 -1
- package/dist/components/EditLayout/index.js +68 -55
- package/dist/components/EditLayout/index.js.map +1 -1
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.cjs.map +1 -1
- package/dist/components/Modal/index.d.cts.map +1 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/index.js +40 -48
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Popover/index.cjs +1 -1
- package/dist/components/Popover/index.cjs.map +1 -1
- package/dist/components/Popover/index.d.cts.map +1 -1
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/Popover/index.js +45 -44
- package/dist/components/Popover/index.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/dialogFocus.d.cts +17 -0
- package/dist/internal/dialogFocus.d.cts.map +1 -0
- package/dist/internal/dialogFocus.d.ts +17 -0
- package/dist/internal/dialogFocus.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/chunks/ColourField-C2YDshDg.js.map +0 -1
- package/dist/chunks/ColourField-Dc9533G6.cjs +0 -2
- package/dist/chunks/ColourField-Dc9533G6.cjs.map +0 -1
|
@@ -1,117 +1,113 @@
|
|
|
1
1
|
import { Button as e } from "../Button/index.js";
|
|
2
2
|
import { t } from "../../chunks/mergeRefs-DGM402mE.js";
|
|
3
3
|
import { n, t as r } from "../../chunks/dialogStack-6yv3NXFD.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { n as i, r as a } from "../../chunks/dialogFocus-BFoyeTpA.js";
|
|
5
|
+
import { forwardRef as o, useEffect as s, useId as c, useRef as l, useState as u } from "react";
|
|
6
|
+
import { createPortal as d } from "react-dom";
|
|
7
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
7
8
|
//#region src/components/Drawer/index.tsx
|
|
8
|
-
function
|
|
9
|
-
let [n, r] =
|
|
10
|
-
return n !== e && (r(e),
|
|
9
|
+
function m(e, t) {
|
|
10
|
+
let [n, r] = u(e), [i, a] = u(!1);
|
|
11
|
+
return n !== e && (r(e), a(!e)), s(() => {
|
|
11
12
|
if (!i || e) return;
|
|
12
|
-
let n = getComputedStyle(t.current).transitionDuration.split(","), r = Math.max(0, ...n.map((e) => parseFloat(e) * (e.trim().endsWith("ms") ? 1 : 1e3) || 0)),
|
|
13
|
-
return () => window.clearTimeout(
|
|
13
|
+
let n = getComputedStyle(t.current).transitionDuration.split(","), r = Math.max(0, ...n.map((e) => parseFloat(e) * (e.trim().endsWith("ms") ? 1 : 1e3) || 0)), o = window.setTimeout(() => a(!1), r);
|
|
14
|
+
return () => window.clearTimeout(o);
|
|
14
15
|
}, [
|
|
15
16
|
i,
|
|
16
17
|
e,
|
|
17
18
|
t
|
|
18
|
-
]), [i,
|
|
19
|
+
]), [i, a];
|
|
19
20
|
}
|
|
20
|
-
var
|
|
21
|
-
let
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
}, [
|
|
25
|
-
if (!
|
|
26
|
-
let e = document.activeElement, t = { preventScroll: !0 }
|
|
27
|
-
((
|
|
28
|
-
let
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
var h = o(function({ isOpen: o, onClose: u, title: h, description: g, side: _ = "end", size: v = "md", variant: y = "default", closeLabel: b = "Close", portalContainer: x, footer: S, className: C, children: w, ...T }, E) {
|
|
22
|
+
let D = l(null), O = l(null), k = l(null), A = l(u), j = c(), M = c(), [N, P] = m(o, O);
|
|
23
|
+
return s(() => {
|
|
24
|
+
A.current = u;
|
|
25
|
+
}, [u]), s(() => {
|
|
26
|
+
if (!o) return;
|
|
27
|
+
let e = document.activeElement, t = { preventScroll: !0 };
|
|
28
|
+
((y === "navigation" ? k.current : D.current && i(D.current)[0]) ?? D.current)?.focus(t);
|
|
29
|
+
let s = r(), c = (e) => {
|
|
30
|
+
if (s.isTopmost()) {
|
|
31
|
+
if (e.key === "Escape") {
|
|
32
|
+
if (e.defaultPrevented) return;
|
|
33
|
+
e.preventDefault(), A.current();
|
|
34
|
+
} else a(e, D.current);
|
|
34
35
|
}
|
|
35
|
-
if (e.key !== "Tab") return;
|
|
36
|
-
let t = Array.from(T.current?.querySelectorAll(a) ?? []);
|
|
37
|
-
if (t.length === 0) return;
|
|
38
|
-
let n = t[0], r = t[t.length - 1];
|
|
39
|
-
e.shiftKey && (document.activeElement === n || !T.current?.contains(document.activeElement)) ? (e.preventDefault(), r.focus()) : !e.shiftKey && (document.activeElement === r || !T.current?.contains(document.activeElement)) && (e.preventDefault(), n.focus());
|
|
40
36
|
};
|
|
41
|
-
window.addEventListener("keydown",
|
|
42
|
-
let
|
|
37
|
+
window.addEventListener("keydown", c);
|
|
38
|
+
let l = n();
|
|
43
39
|
return () => {
|
|
44
|
-
window.removeEventListener("keydown",
|
|
40
|
+
window.removeEventListener("keydown", c), s.close(), l(), e?.focus(t);
|
|
45
41
|
};
|
|
46
42
|
}, [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
]), !
|
|
43
|
+
o,
|
|
44
|
+
y,
|
|
45
|
+
x
|
|
46
|
+
]), !o && !N || typeof document > "u" ? null : d(/* @__PURE__ */ f("div", {
|
|
51
47
|
ref: (e) => {
|
|
52
|
-
|
|
48
|
+
O.current = e, e && (e.inert = !o);
|
|
53
49
|
},
|
|
54
50
|
className: "ds-drawer-scrim",
|
|
55
|
-
dir:
|
|
56
|
-
"data-side":
|
|
57
|
-
"data-variant":
|
|
58
|
-
"data-contained":
|
|
59
|
-
"data-state":
|
|
60
|
-
"aria-hidden": !
|
|
51
|
+
dir: T.dir,
|
|
52
|
+
"data-side": _,
|
|
53
|
+
"data-variant": y,
|
|
54
|
+
"data-contained": x ? "" : void 0,
|
|
55
|
+
"data-state": o ? "open" : "closed",
|
|
56
|
+
"aria-hidden": !o || void 0,
|
|
61
57
|
onTransitionEnd: (e) => {
|
|
62
|
-
e.target === e.currentTarget && e.propertyName === "opacity" && !
|
|
58
|
+
e.target === e.currentTarget && e.propertyName === "opacity" && !o && P(!1);
|
|
63
59
|
},
|
|
64
|
-
onMouseDown: (e) =>
|
|
65
|
-
children: /* @__PURE__ */
|
|
66
|
-
...
|
|
67
|
-
ref: t(
|
|
60
|
+
onMouseDown: (e) => o && e.target === e.currentTarget && A.current(),
|
|
61
|
+
children: /* @__PURE__ */ p("div", {
|
|
62
|
+
...T,
|
|
63
|
+
ref: t(D, E),
|
|
68
64
|
role: "dialog",
|
|
69
65
|
"aria-modal": "true",
|
|
70
|
-
"aria-labelledby":
|
|
71
|
-
"aria-describedby":
|
|
66
|
+
"aria-labelledby": T["aria-label"] ? void 0 : T["aria-labelledby"] ?? j,
|
|
67
|
+
"aria-describedby": g ? M : void 0,
|
|
72
68
|
tabIndex: -1,
|
|
73
|
-
"data-side":
|
|
74
|
-
"data-size":
|
|
75
|
-
"data-variant":
|
|
76
|
-
className: ["ds-drawer",
|
|
69
|
+
"data-side": _,
|
|
70
|
+
"data-size": v,
|
|
71
|
+
"data-variant": y,
|
|
72
|
+
className: ["ds-drawer", C].filter(Boolean).join(" "),
|
|
77
73
|
children: [
|
|
78
|
-
/* @__PURE__ */
|
|
74
|
+
/* @__PURE__ */ p("header", {
|
|
79
75
|
className: "ds-drawer__head",
|
|
80
|
-
children: [/* @__PURE__ */
|
|
76
|
+
children: [/* @__PURE__ */ p("div", {
|
|
81
77
|
className: "ds-drawer__titles",
|
|
82
|
-
children: [/* @__PURE__ */
|
|
83
|
-
id:
|
|
78
|
+
children: [/* @__PURE__ */ f("h2", {
|
|
79
|
+
id: j,
|
|
84
80
|
className: "ds-drawer__title",
|
|
85
|
-
children:
|
|
86
|
-
}),
|
|
87
|
-
id:
|
|
81
|
+
children: h
|
|
82
|
+
}), g && /* @__PURE__ */ f("p", {
|
|
83
|
+
id: M,
|
|
88
84
|
className: "ds-drawer__description",
|
|
89
|
-
children:
|
|
85
|
+
children: g
|
|
90
86
|
})]
|
|
91
|
-
}), /* @__PURE__ */
|
|
92
|
-
ref:
|
|
87
|
+
}), /* @__PURE__ */ f(e, {
|
|
88
|
+
ref: k,
|
|
93
89
|
variant: "simple",
|
|
94
|
-
size:
|
|
90
|
+
size: y === "navigation" ? "lg" : "sm",
|
|
95
91
|
isIconOnly: !0,
|
|
96
92
|
iconStart: "x",
|
|
97
|
-
className:
|
|
98
|
-
"aria-label":
|
|
99
|
-
onClick: () =>
|
|
93
|
+
className: y === "navigation" ? "ds-drawer__close" : void 0,
|
|
94
|
+
"aria-label": b,
|
|
95
|
+
onClick: () => A.current()
|
|
100
96
|
})]
|
|
101
97
|
}),
|
|
102
|
-
/* @__PURE__ */
|
|
98
|
+
/* @__PURE__ */ f("div", {
|
|
103
99
|
className: "ds-drawer__body",
|
|
104
|
-
children:
|
|
100
|
+
children: w
|
|
105
101
|
}),
|
|
106
|
-
|
|
102
|
+
S && /* @__PURE__ */ f("footer", {
|
|
107
103
|
className: "ds-drawer__footer",
|
|
108
|
-
children:
|
|
104
|
+
children: S
|
|
109
105
|
})
|
|
110
106
|
]
|
|
111
107
|
})
|
|
112
|
-
}),
|
|
108
|
+
}), x ?? document.body);
|
|
113
109
|
});
|
|
114
110
|
//#endregion
|
|
115
|
-
export {
|
|
111
|
+
export { h as Drawer };
|
|
116
112
|
|
|
117
113
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["openDialog","useDrawerExit","previousOpen","setPreviousOpen","useState","isOpen","exiting","setExiting","useEffect","durations","scrimRef","duration","value","timeout","Drawer","forwardRef","rest","panelRef","useRef","closeRef","onCloseRef","onClose","titleId","useId","descriptionId","previous","focusOptions","selector","variant","dialog","onKeyDown","event","focusable","first","last","unlockScroll","lockBodyScroll","portalContainer","createPortal","node","side","mergeRefs","ref","description","size","className","title","Button","closeLabel","footer"],"sources":["../../../src/components/Drawer/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useEffect,\n useId,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n type RefObject,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Button } from \"../Button\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { lockBodyScroll } from \"../../internal/lockBodyScroll\";\nimport { openDialog } from \"../../internal/dialogStack\";\nimport \"./style.css\";\n\nexport type DrawerSide = \"end\" | \"start\" | \"bottom\";\nexport type DrawerSize = \"md\" | \"wide\";\n\nexport interface DrawerProps extends Omit<HTMLAttributes<HTMLDivElement>, \"title\"> {\n isOpen: boolean;\n /** Escape, the scrim and the close button all call this. */\n onClose: () => void;\n title: ReactNode;\n description?: string;\n /** Which edge the panel is anchored to. */\n side?: DrawerSide;\n size?: DrawerSize;\n /** Navigation uses a compact panel, header and footer. Both variants slide in and out. */\n variant?: \"default\" | \"navigation\";\n /** Accessible name of the dismiss button. */\n closeLabel?: string;\n /**\n * Defaults to document.body, covering the viewport. A navigation drawer\n * portaled into a positioned element, such as an app shell, stays inside it.\n */\n portalContainer?: HTMLElement | null;\n /** Actions, right-aligned. The confirming action goes last. */\n footer?: ReactNode;\n children?: ReactNode;\n}\n\nfunction useDrawerExit(isOpen: boolean, scrimRef: RefObject<HTMLDivElement | null>) {\n const [previousOpen, setPreviousOpen] = useState(isOpen);\n const [exiting, setExiting] = useState(false);\n\n if (previousOpen !== isOpen) {\n setPreviousOpen(isOpen);\n setExiting(!isOpen);\n }\n\n useEffect(() => {\n if (!exiting || isOpen) {\n return;\n }\n // Read the actual transition, including token overrides and reduced motion.\n const durations = getComputedStyle(scrimRef.current!).transitionDuration.split(\",\");\n const duration = Math.max(\n 0,\n ...durations.map(\n (value) => parseFloat(value) * (value.trim().endsWith(\"ms\") ? 1 : 1000) || 0,\n ),\n );\n const timeout = window.setTimeout(() => setExiting(false), duration);\n return () => window.clearTimeout(timeout);\n }, [exiting, isOpen, scrimRef]);\n\n return [exiting, setExiting] as const;\n}\n\n/**\n * A side panel for work that belongs beside the page rather than on top of it\n * — editing one record, a filter set, a revision history. Same frame, rules\n * and footer band as `Modal`, with square corners and a full slide through\n * its anchored edge. Focus is trapped while open.\n */\nexport const Drawer = forwardRef<HTMLDivElement, DrawerProps>(function Drawer(\n {\n isOpen,\n onClose,\n title,\n description,\n side = \"end\",\n size = \"md\",\n variant = \"default\",\n closeLabel = \"Close\",\n portalContainer,\n footer,\n className,\n children,\n ...rest\n },\n ref,\n) {\n const panelRef = useRef<HTMLDivElement | null>(null);\n const scrimRef = useRef<HTMLDivElement | null>(null);\n const closeRef = useRef<HTMLButtonElement | null>(null);\n const onCloseRef = useRef(onClose);\n const titleId = useId();\n const descriptionId = useId();\n const [exiting, setExiting] = useDrawerExit(isOpen, scrimRef);\n\n useEffect(() => {\n onCloseRef.current = onClose;\n }, [onClose]);\n\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n\n const previous = document.activeElement as HTMLElement | null;\n // Panels start off-screen; focusing them must not scroll the page with them.\n const focusOptions = { preventScroll: true };\n const selector =\n \":is(button, [href], input, select, textarea, [tabindex]):not(:disabled):not([tabindex='-1'])\";\n const initialFocus =\n variant === \"navigation\"\n ? closeRef.current\n : panelRef.current?.querySelector<HTMLElement>(selector);\n (initialFocus ?? panelRef.current)?.focus(focusOptions);\n\n const dialog = openDialog();\n const onKeyDown = (event: KeyboardEvent) => {\n // A picker can portal a modal above this drawer. Only the topmost\n // dialog's focus trap handles keys until it closes.\n if (!dialog.isTopmost()) {\n return;\n }\n if (event.key === \"Escape\") {\n // A popup inside the panel (Menu, Select, DateField) claims its Escape.\n if (event.defaultPrevented) {\n return;\n }\n event.preventDefault();\n onCloseRef.current();\n return;\n }\n if (event.key !== \"Tab\") {\n return;\n }\n const focusable = Array.from(panelRef.current?.querySelectorAll<HTMLElement>(selector) ?? []);\n if (focusable.length === 0) {\n return;\n }\n const first = focusable[0]!;\n const last = focusable[focusable.length - 1]!;\n if (\n event.shiftKey &&\n (document.activeElement === first || !panelRef.current?.contains(document.activeElement))\n ) {\n event.preventDefault();\n last.focus();\n } else if (\n !event.shiftKey &&\n (document.activeElement === last || !panelRef.current?.contains(document.activeElement))\n ) {\n event.preventDefault();\n first.focus();\n }\n };\n\n // On window, so document-level popup handlers inside the panel run first.\n window.addEventListener(\"keydown\", onKeyDown);\n const unlockScroll = lockBodyScroll();\n\n return () => {\n window.removeEventListener(\"keydown\", onKeyDown);\n dialog.close();\n unlockScroll();\n previous?.focus(focusOptions);\n };\n }, [isOpen, variant, portalContainer]);\n\n if ((!isOpen && !exiting) || typeof document === \"undefined\") {\n return null;\n }\n\n return createPortal(\n <div\n ref={(node) => {\n scrimRef.current = node;\n if (node) {\n node.inert = !isOpen;\n }\n }}\n className=\"ds-drawer-scrim\"\n dir={rest.dir}\n data-side={side}\n data-variant={variant}\n data-contained={portalContainer ? \"\" : undefined}\n data-state={isOpen ? \"open\" : \"closed\"}\n aria-hidden={!isOpen || undefined}\n onTransitionEnd={(event) => {\n if (event.target === event.currentTarget && event.propertyName === \"opacity\" && !isOpen) {\n setExiting(false);\n }\n }}\n onMouseDown={(event) =>\n isOpen && event.target === event.currentTarget && onCloseRef.current()\n }\n >\n <div\n {...rest}\n ref={mergeRefs(panelRef, ref)}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={rest[\"aria-label\"] ? undefined : (rest[\"aria-labelledby\"] ?? titleId)}\n aria-describedby={description ? descriptionId : undefined}\n tabIndex={-1}\n data-side={side}\n data-size={size}\n data-variant={variant}\n className={[\"ds-drawer\", className].filter(Boolean).join(\" \")}\n >\n <header className=\"ds-drawer__head\">\n <div className=\"ds-drawer__titles\">\n <h2\n id={titleId}\n className=\"ds-drawer__title\"\n >\n {title}\n </h2>\n {description && (\n <p\n id={descriptionId}\n className=\"ds-drawer__description\"\n >\n {description}\n </p>\n )}\n </div>\n <Button\n ref={closeRef}\n variant=\"simple\"\n size={variant === \"navigation\" ? \"lg\" : \"sm\"}\n isIconOnly\n iconStart=\"x\"\n className={variant === \"navigation\" ? \"ds-drawer__close\" : undefined}\n aria-label={closeLabel}\n onClick={() => onCloseRef.current()}\n />\n </header>\n <div className=\"ds-drawer__body\">{children}</div>\n {footer && <footer className=\"ds-drawer__footer\">{footer}</footer>}\n </div>\n </div>,\n portalContainer ?? document.body,\n );\n});\n"],"mappings":";;;;;;;AA2CA,SAASC,EAAc,GAA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AM,iBAAiBA,EAAM,iBAAiB,aAAa,CAAC1B,KAC/EE,EAAW,EAAK;EAEpB;EACA,cAAc,MACZF,KAAU0B,EAAM,WAAWA,EAAM,iBAAiBX,EAAW,QAAQ;EAGvE,UAAA,kBAAC,OAAD;GACE,GAAIJ;GACJ,KAAKyB,EAAUxB,GAAUyB,CAAG;GAC5B,MAAK;GACL,cAAW;GACX,mBAAiB1B,EAAK,gBAAgB,KAAA,IAAaA,EAAK,sBAAsBM;GAC9E,oBAAkBqB,IAAcnB,IAAgB,KAAA;GAChD,UAAU;GACV,aAAWgB;GACX,aAAWI;GACX,gBAAchB;GACd,WAAW,CAAC,aAAaiB,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;GAX9D,UAAA;IAaE,kBAAC,UAAD;KAAQ,WAAU;KAAlB,UAAA,CACE,kBAAC,OAAD;MAAK,WAAU;MAAf,UAAA,CACE,kBAAC,MAAD;OACE,IAAIvB;OACJ,WAAU;OAET,UAAAwB;MACC,CAAA,GACHH,KACC,kBAAC,KAAD;OACE,IAAInB;OACJ,WAAU;OAET,UAAAmB;MACA,CAAA,CAEF;KACL,CAAA,GAAA,kBAACI,GAAD;MACE,KAAK5B;MACL,SAAQ;MACR,MAAMS,MAAY,eAAe,OAAO;MACxC,YAAA;MACA,WAAU;MACV,WAAWA,MAAY,eAAe,qBAAqB,KAAA;MAC3D,cAAYoB;MACZ,eAAe5B,EAAW,QAAQ;KACnC,CAAA,CACK;;IACR,kBAAC,OAAD;KAAK,WAAU;KAAmB;IAAc,CAAA;IAC/C6B,KAAU,kBAAC,UAAD;KAAQ,WAAU;KAAqB,UAAAA;IAAe,CAAA;GAC9D;;CACF,CAAA,GACLZ,KAAmB,SAAS,IAC9B;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["openDialog","tabbableControls","trapTabFocus","useDrawerExit","previousOpen","setPreviousOpen","useState","isOpen","exiting","setExiting","useEffect","durations","scrimRef","duration","value","timeout","Drawer","forwardRef","rest","panelRef","useRef","closeRef","onCloseRef","onClose","titleId","useId","descriptionId","previous","focusOptions","variant","dialog","onKeyDown","event","unlockScroll","lockBodyScroll","portalContainer","createPortal","node","side","mergeRefs","ref","description","size","className","title","Button","closeLabel","footer"],"sources":["../../../src/components/Drawer/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useEffect,\n useId,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n type RefObject,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Button } from \"../Button\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { lockBodyScroll } from \"../../internal/lockBodyScroll\";\nimport { openDialog } from \"../../internal/dialogStack\";\nimport { tabbableControls, trapTabFocus } from \"../../internal/dialogFocus\";\nimport \"./style.css\";\n\nexport type DrawerSide = \"end\" | \"start\" | \"bottom\";\nexport type DrawerSize = \"md\" | \"wide\";\n\nexport interface DrawerProps extends Omit<HTMLAttributes<HTMLDivElement>, \"title\"> {\n isOpen: boolean;\n /** Escape, the scrim and the close button all call this. */\n onClose: () => void;\n title: ReactNode;\n description?: string;\n /** Which edge the panel is anchored to. */\n side?: DrawerSide;\n size?: DrawerSize;\n /** Navigation uses a compact panel, header and footer. Both variants slide in and out. */\n variant?: \"default\" | \"navigation\";\n /** Accessible name of the dismiss button. */\n closeLabel?: string;\n /**\n * Defaults to document.body, covering the viewport. A navigation drawer\n * portaled into a positioned element, such as an app shell, stays inside it.\n */\n portalContainer?: HTMLElement | null;\n /** Actions, right-aligned. The confirming action goes last. */\n footer?: ReactNode;\n children?: ReactNode;\n}\n\nfunction useDrawerExit(isOpen: boolean, scrimRef: RefObject<HTMLDivElement | null>) {\n const [previousOpen, setPreviousOpen] = useState(isOpen);\n const [exiting, setExiting] = useState(false);\n\n if (previousOpen !== isOpen) {\n setPreviousOpen(isOpen);\n setExiting(!isOpen);\n }\n\n useEffect(() => {\n if (!exiting || isOpen) {\n return;\n }\n // Read the actual transition, including token overrides and reduced motion.\n const durations = getComputedStyle(scrimRef.current!).transitionDuration.split(\",\");\n const duration = Math.max(\n 0,\n ...durations.map(\n (value) => parseFloat(value) * (value.trim().endsWith(\"ms\") ? 1 : 1000) || 0,\n ),\n );\n const timeout = window.setTimeout(() => setExiting(false), duration);\n return () => window.clearTimeout(timeout);\n }, [exiting, isOpen, scrimRef]);\n\n return [exiting, setExiting] as const;\n}\n\n/**\n * A side panel for work that belongs beside the page rather than on top of it\n * — editing one record, a filter set, a revision history. Same frame, rules\n * and footer band as `Modal`, with square corners and a full slide through\n * its anchored edge. Focus is trapped while open.\n */\nexport const Drawer = forwardRef<HTMLDivElement, DrawerProps>(function Drawer(\n {\n isOpen,\n onClose,\n title,\n description,\n side = \"end\",\n size = \"md\",\n variant = \"default\",\n closeLabel = \"Close\",\n portalContainer,\n footer,\n className,\n children,\n ...rest\n },\n ref,\n) {\n const panelRef = useRef<HTMLDivElement | null>(null);\n const scrimRef = useRef<HTMLDivElement | null>(null);\n const closeRef = useRef<HTMLButtonElement | null>(null);\n const onCloseRef = useRef(onClose);\n const titleId = useId();\n const descriptionId = useId();\n const [exiting, setExiting] = useDrawerExit(isOpen, scrimRef);\n\n useEffect(() => {\n onCloseRef.current = onClose;\n }, [onClose]);\n\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n\n const previous = document.activeElement as HTMLElement | null;\n // Panels start off-screen; focusing them must not scroll the page with them.\n const focusOptions = { preventScroll: true };\n const initialFocus =\n variant === \"navigation\"\n ? closeRef.current\n : panelRef.current && tabbableControls(panelRef.current)[0];\n (initialFocus ?? panelRef.current)?.focus(focusOptions);\n\n const dialog = openDialog();\n const onKeyDown = (event: KeyboardEvent) => {\n // A picker can portal a modal above this drawer. Only the topmost\n // dialog's focus trap handles keys until it closes.\n if (!dialog.isTopmost()) {\n return;\n }\n if (event.key === \"Escape\") {\n // A popup inside the panel (Menu, Select, DateField) claims its Escape.\n if (event.defaultPrevented) {\n return;\n }\n event.preventDefault();\n onCloseRef.current();\n return;\n }\n trapTabFocus(event, panelRef.current);\n };\n\n // On window, so document-level popup handlers inside the panel run first.\n window.addEventListener(\"keydown\", onKeyDown);\n const unlockScroll = lockBodyScroll();\n\n return () => {\n window.removeEventListener(\"keydown\", onKeyDown);\n dialog.close();\n unlockScroll();\n previous?.focus(focusOptions);\n };\n }, [isOpen, variant, portalContainer]);\n\n if ((!isOpen && !exiting) || typeof document === \"undefined\") {\n return null;\n }\n\n return createPortal(\n <div\n ref={(node) => {\n scrimRef.current = node;\n if (node) {\n node.inert = !isOpen;\n }\n }}\n className=\"ds-drawer-scrim\"\n dir={rest.dir}\n data-side={side}\n data-variant={variant}\n data-contained={portalContainer ? \"\" : undefined}\n data-state={isOpen ? \"open\" : \"closed\"}\n aria-hidden={!isOpen || undefined}\n onTransitionEnd={(event) => {\n if (event.target === event.currentTarget && event.propertyName === \"opacity\" && !isOpen) {\n setExiting(false);\n }\n }}\n onMouseDown={(event) =>\n isOpen && event.target === event.currentTarget && onCloseRef.current()\n }\n >\n <div\n {...rest}\n ref={mergeRefs(panelRef, ref)}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={rest[\"aria-label\"] ? undefined : (rest[\"aria-labelledby\"] ?? titleId)}\n aria-describedby={description ? descriptionId : undefined}\n tabIndex={-1}\n data-side={side}\n data-size={size}\n data-variant={variant}\n className={[\"ds-drawer\", className].filter(Boolean).join(\" \")}\n >\n <header className=\"ds-drawer__head\">\n <div className=\"ds-drawer__titles\">\n <h2\n id={titleId}\n className=\"ds-drawer__title\"\n >\n {title}\n </h2>\n {description && (\n <p\n id={descriptionId}\n className=\"ds-drawer__description\"\n >\n {description}\n </p>\n )}\n </div>\n <Button\n ref={closeRef}\n variant=\"simple\"\n size={variant === \"navigation\" ? \"lg\" : \"sm\"}\n isIconOnly\n iconStart=\"x\"\n className={variant === \"navigation\" ? \"ds-drawer__close\" : undefined}\n aria-label={closeLabel}\n onClick={() => onCloseRef.current()}\n />\n </header>\n <div className=\"ds-drawer__body\">{children}</div>\n {footer && <footer className=\"ds-drawer__footer\">{footer}</footer>}\n </div>\n </div>,\n portalContainer ?? document.body,\n );\n});\n"],"mappings":";;;;;;;;AA4CA,SAASG,EAAc,GAAiB,GAA4C;CAClF,IAAM,CAACC,GAAcC,KAAmBC,EAASC,CAAM,GACjD,CAACC,GAASC,KAAcH,EAAS,EAAK;CAuB5C,OArBIF,MAAiBG,MACnBF,EAAgBE,CAAM,GACtBE,EAAW,CAACF,CAAM,IAGpBG,QAAgB;EACd,IAAI,CAACF,KAAWD,GACd;EAGF,IAAMI,IAAY,iBAAiBC,EAAS,OAAQ,CAAC,CAAC,mBAAmB,MAAM,GAAG,GAC5EC,IAAW,KAAK,IACpB,GACA,GAAGF,EAAU,KACV,MAAU,WAAWG,CAAK,KAAKA,EAAM,KAAK,CAAC,CAAC,SAAS,IAAI,IAAI,IAAI,QAAS,CAC7E,CACF,GACMC,IAAU,OAAO,iBAAiBN,EAAW,EAAK,GAAGI,CAAQ;EACnE,aAAa,OAAO,aAAaE,CAAO;CAC1C,GAAG;EAACP;EAASD;EAAQK;CAAQ,CAAC,GAEvB,CAACJ,GAASC,CAAU;AAC7B;AAQA,IAAaO,IAASC,EAAwC,SAC5D,EACE,WACA,YACA,UACA,gBACA,UAAO,OACP,UAAO,MACP,aAAU,WACV,gBAAa,SACb,oBACA,WACA,cACA,aACA,GAAGC,KAEL,GACA;CACA,IAAMC,IAAWC,EAA8B,IAAI,GAC7CR,IAAWQ,EAA8B,IAAI,GAC7CC,IAAWD,EAAiC,IAAI,GAChDE,IAAaF,EAAOG,CAAO,GAC3BC,IAAUC,EAAM,GAChBC,IAAgBD,EAAM,GACtB,CAACjB,GAASC,KAAcN,EAAcI,GAAQK,CAAQ;CAuD5D,OArDAF,QAAgB;EACd,EAAW,UAAUa;CACvB,GAAG,CAACA,CAAO,CAAC,GAEZb,QAAgB;EACd,IAAI,CAACH,GACH;EAGF,IAAMoB,IAAW,SAAS,eAEpBC,IAAe,EAAE,eAAe,GAAK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GAC9E,oBAAkBiB,IAAcf,IAAgB,KAAA;GAChD,UAAU;GACV,aAAWY;GACX,aAAWI;GACX,gBAAcb;GACd,WAAW,CAAC,aAAac,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;GAX9D,UAAA;IAaE,kBAAC,UAAD;KAAQ,WAAU;KAAlB,UAAA,CACE,kBAAC,OAAD;MAAK,WAAU;MAAf,UAAA,CACE,kBAAC,MAAD;OACE,IAAInB;OACJ,WAAU;OAET,UAAAoB;MACC,CAAA,GACHH,KACC,kBAAC,KAAD;OACE,IAAIf;OACJ,WAAU;OAET,UAAAe;MACA,CAAA,CAEF;KACL,CAAA,GAAA,kBAACI,GAAD;MACE,KAAKxB;MACL,SAAQ;MACR,MAAMQ,MAAY,eAAe,OAAO;MACxC,YAAA;MACA,WAAU;MACV,WAAWA,MAAY,eAAe,qBAAqB,KAAA;MAC3D,cAAYiB;MACZ,eAAexB,EAAW,QAAQ;KACnC,CAAA,CACK;;IACR,kBAAC,OAAD;KAAK,WAAU;KAAmB;IAAc,CAAA;IAC/CyB,KAAU,kBAAC,UAAD;KAAQ,WAAU;KAAqB,UAAAA;IAAe,CAAA;GAC9D;;CACF,CAAA,GACLZ,KAAmB,SAAS,IAC9B;AACF,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-BBoWP_Y6.cjs"),t=require("../Button/index.cjs"),n=require("../../chunks/mergeRefs-Bc3qS0Tt.cjs"),r=require("../Drawer/index.cjs"),i=require("../../chunks/observeElementWidth-BCJM2FAw.cjs");let a=require("react"),o=require("react-dom"),s=require("react/jsx-runtime");var c=360,l=600,u=900;function d(e){return e<c?`tight`:e<l?`compact`:e<u?`narrow`:`wide`}var f={clean:`No changes`,dirty:`Unsaved changes`,saving:`Saving…`,saved:`Saved`,error:`Couldn't save`,offline:`Offline · kept in this tab`},p={clean:void 0,dirty:void 0,saving:`spinner`,saved:`check`,error:`alert-triangle`,offline:`clock`};function m(e){return!e||e===document.body||!e.isConnected||e.closest(`[aria-hidden='true'], [inert]`)!==null}function h(){if(typeof document>`u`)return null;let e=document.createElement(`div`);return e.className=`ds-edit-layout__rail-host`,e}function g({saveState:t,savedAgo:n}){let r=p[t];return(0,s.jsxs)(`div`,{className:`ds-edit-layout__status`,"data-state":t,role:`status`,"aria-live":`polite`,children:[r&&(0,s.jsx)(e.t,{name:r,className:t===`saving`?`ds-icon--spin`:void 0}),t===`dirty`&&(0,s.jsx)(`span`,{className:`ds-edit-layout__dirty`,"aria-hidden":`true`}),(0,s.jsxs)(`span`,{children:[f[t],t===`saved`&&n?(0,s.jsxs)(s.Fragment,{children:[` `,n]}):null]})]})}function _({text:e,bodyRef:n,onKeepEditing:r}){let i=(0,a.useRef)(null),o=(0,a.useRef)(null);return(0,a.useEffect)(()=>{o.current=document.activeElement;let e=requestAnimationFrame(()=>i.current?.focus({preventScroll:!0}));return()=>cancelAnimationFrame(e)},[]),(0,s.jsxs)(`div`,{className:`ds-edit-layout__confirmation`,children:[(0,s.jsx)(`strong`,{children:e}),(0,s.jsx)(t.Button,{ref:i,size:`xs`,onClick:()=>{r?.(),requestAnimationFrame(()=>{(o.current?.isConnected?o.current:n.current?.querySelector(`input, textarea, button, [contenteditable='true']`))?.focus({preventScroll:!0})})},children:`Keep editing`})]})}function v({label:e,detailsId:n,expanded:r,opensSheet:i,sheetOpen:a,toggleRef:o,contentRef:c,collapsed:l,onToggle:u}){return(0,s.jsxs)(`aside`,{className:`ds-edit-layout__rail`,"aria-label":e,children:[(0,s.jsxs)(`header`,{className:`ds-edit-layout__rail-head`,children:[r&&(0,s.jsx)(`span`,{children:e}),(0,s.jsx)(t.Button,{ref:o,variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:r?`chevrons-right`:`chevrons-left`,className:`ds-edit-layout__toggle`,"aria-label":`${r?`Collapse`:`Expand`} ${e}`,"aria-expanded":r||a,"aria-controls":n,"aria-haspopup":i?`dialog`:void 0,onClick:u})]}),r?(0,s.jsx)(`div`,{id:n,ref:c,className:`ds-edit-layout__rail-content`}):(0,s.jsx)(`div`,{className:`ds-edit-layout__rail-icons`,children:l?l(u):(0,s.jsx)(t.Button,{variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`info`,"aria-label":`Show ${e}`,onClick:u})})]})}var
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-BBoWP_Y6.cjs"),t=require("../Button/index.cjs"),n=require("../../chunks/mergeRefs-Bc3qS0Tt.cjs"),r=require("../Drawer/index.cjs"),i=require("../../chunks/observeElementWidth-BCJM2FAw.cjs");let a=require("react"),o=require("react-dom"),s=require("react/jsx-runtime");var c=360,l=600,u=900;function d(e){return e<c?`tight`:e<l?`compact`:e<u?`narrow`:`wide`}var f={clean:`No changes`,dirty:`Unsaved changes`,saving:`Saving…`,saved:`Saved`,error:`Couldn't save`,offline:`Offline · kept in this tab`},p={clean:void 0,dirty:void 0,saving:`spinner`,saved:`check`,error:`alert-triangle`,offline:`clock`};function m(e){return!e||e===document.body||!e.isConnected||e.closest(`[aria-hidden='true'], [inert]`)!==null}function h(){if(typeof document>`u`)return null;let e=document.createElement(`div`);return e.className=`ds-edit-layout__rail-host`,e}function g({saveState:t,savedAgo:n}){let r=p[t];return(0,s.jsxs)(`div`,{className:`ds-edit-layout__status`,"data-state":t,role:`status`,"aria-live":`polite`,children:[r&&(0,s.jsx)(e.t,{name:r,className:t===`saving`?`ds-icon--spin`:void 0}),t===`dirty`&&(0,s.jsx)(`span`,{className:`ds-edit-layout__dirty`,"aria-hidden":`true`}),(0,s.jsxs)(`span`,{children:[f[t],t===`saved`&&n?(0,s.jsxs)(s.Fragment,{children:[` `,n]}):null]})]})}function _({text:e,bodyRef:n,onKeepEditing:r}){let i=(0,a.useRef)(null),o=(0,a.useRef)(null);return(0,a.useEffect)(()=>{o.current=document.activeElement;let e=requestAnimationFrame(()=>i.current?.focus({preventScroll:!0}));return()=>cancelAnimationFrame(e)},[]),(0,s.jsxs)(`div`,{className:`ds-edit-layout__confirmation`,children:[(0,s.jsx)(`strong`,{children:e}),(0,s.jsx)(t.Button,{ref:i,size:`xs`,onClick:()=>{r?.(),requestAnimationFrame(()=>{(o.current?.isConnected?o.current:n.current?.querySelector(`input, textarea, button, [contenteditable='true']`))?.focus({preventScroll:!0})})},children:`Keep editing`})]})}function v({backLabel:e,onBack:n,compact:r,status:i,actions:a,confirmLeave:o,confirmation:c,onLeave:l,detailsToggle:u}){return(0,s.jsxs)(`header`,{className:`ds-edit-layout__bar`,children:[(0,s.jsx)(t.Button,{variant:`simple`,size:`sm`,iconStart:`arrow-left`,isIconOnly:r,"aria-label":`Back to ${e}`,onClick:n,children:e}),o?c:i,(0,s.jsxs)(`div`,{className:`ds-edit-layout__actions`,children:[o?(0,s.jsx)(t.Button,{variant:`danger`,size:`sm`,onClick:l,children:`Leave anyway`}):a,r&&u]})]})}function y({label:e,detailsId:n,expanded:r,opensSheet:i,sheetOpen:a,toggleRef:o,contentRef:c,collapsed:l,onToggle:u}){return(0,s.jsxs)(`aside`,{className:`ds-edit-layout__rail`,"aria-label":e,children:[(0,s.jsxs)(`header`,{className:`ds-edit-layout__rail-head`,children:[r&&(0,s.jsx)(`span`,{children:e}),(0,s.jsx)(t.Button,{ref:o,variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:r?`chevrons-right`:`chevrons-left`,className:`ds-edit-layout__toggle`,"aria-label":`${r?`Collapse`:`Expand`} ${e}`,"aria-expanded":r||a,"aria-controls":n,"aria-haspopup":i?`dialog`:void 0,onClick:u})]}),r?(0,s.jsx)(`div`,{id:n,ref:c,className:`ds-edit-layout__rail-content`}):(0,s.jsx)(`div`,{className:`ds-edit-layout__rail-icons`,children:l?l(u):(0,s.jsx)(t.Button,{variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`info`,"aria-label":`Show ${e}`,onClick:u})})]})}var b=(0,a.forwardRef)(function({backLabel:e,onBack:c,saveState:l=`clean`,savedAgo:u,actions:f,rail:p,railCollapsed:b,railLabel:x=`Details`,railOpen:S,defaultRailOpen:C=!0,onRailToggle:ee,confirmLeave:w=!1,confirmText:T=`Leave without saving?`,onKeepEditing:E,onLeave:D,children:O,className:k,onFocus:A,...j},M){let N=(0,a.useRef)(null),P=(0,a.useMemo)(()=>n.t(N,M),[M]),F=(0,a.useRef)(null),I=(0,a.useRef)(null),L=(0,a.useRef)(null),R=(0,a.useRef)(null),z=(0,a.useRef)(null),[B]=(0,a.useState)(h),[V,H]=(0,a.useState)(`wide`),[U,W]=(0,a.useState)(C),[G,K]=(0,a.useState)(!1),[q,J]=(0,a.useState)(!1),Y=(0,a.useId)(),X=V===`tight`||V===`compact`,Z=V!==`wide`,Q=!Z&&(S??U);G&&(w||!Z)&&K(!1),(0,a.useLayoutEffect)(()=>{let e;return i.t(N.current,t=>{let n=d(t);n!==e&&(e=n,J(!1),H(n))})},[]),(0,a.useLayoutEffect)(()=>{if(!B)return;let e=L.current??R.current;if(!e){B.remove();return}if(B.parentNode===e)return;let t=z.current,n=t instanceof HTMLElement&&B.contains(t)&&m(document.activeElement);e.append(B),n&&t.focus({preventScroll:!0})}),(0,a.useEffect)(()=>{let e=z.current;e&&m(e)&&m(document.activeElement)&&I.current?.focus({preventScroll:!0})},[V,Q,G]);let $=()=>{Z?K(!0):(J(!0),W(!Q),ee?.(!Q))},te=typeof p==`function`?p(()=>(0,o.flushSync)(()=>K(!1))):p;return(0,s.jsxs)(`div`,{...j,ref:P,className:[`ds-edit-layout`,k].filter(Boolean).join(` `),"data-compact":X||void 0,"data-tight":V===`tight`||void 0,"data-expanded":Q||void 0,"data-animate":q||void 0,onFocus:e=>{z.current=e.target,A?.(e)},children:[(0,s.jsxs)(`div`,{className:`ds-edit-layout__main`,children:[(0,s.jsx)(v,{backLabel:e,onBack:c,compact:X,status:(0,s.jsx)(g,{saveState:l,savedAgo:u}),actions:f,confirmLeave:w,confirmation:(0,s.jsx)(_,{text:T,bodyRef:F,onKeepEditing:E}),onLeave:D,detailsToggle:(0,s.jsx)(t.Button,{ref:I,variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`info`,"aria-label":x,"aria-haspopup":`dialog`,"aria-expanded":G,"aria-controls":Y,onClick:$})}),(0,s.jsx)(`div`,{ref:F,className:`ds-edit-layout__body`,children:(0,s.jsx)(`div`,{className:`ds-edit-layout__content`,children:O})})]}),!X&&(0,s.jsx)(y,{label:x,detailsId:Y,expanded:Q,opensSheet:Z,sheetOpen:G,toggleRef:I,contentRef:L,collapsed:b,onToggle:$}),(0,s.jsx)(r.Drawer,{id:Z?Y:void 0,dir:j.dir,isOpen:G,onClose:()=>K(!1),side:`end`,size:`md`,title:x,closeLabel:`Close ${x}`,className:`ds-edit-layout__sheet`,children:Z&&(0,s.jsx)(`div`,{ref:R,className:`ds-edit-layout__rail-content`})}),B&&(0,o.createPortal)(te,B)]})});exports.EditLayout=b;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["Icon","_Fragment","useRef","Button","forwardRef","useMemo","mergeRefs","useState","useId","observeElementWidth","flushSync","Drawer","createPortal","require_Icon","require_components_Button_index","require_mergeRefs","require_components_Drawer_index","require_observeElementWidth","react","react_dom","react_jsx_runtime","TIGHT_WIDTH","COMPACT_WIDTH","WIDE_WIDTH","layoutMode","width","statusLabels","statusIcons","cannotHoldFocus","element","createRailHost","host","SaveStatus","icon","saveState","savedAgo","LeaveConfirmation","keepRef","origin","frame","text","onKeepEditing","bodyRef","DetailsRail","label","expanded","toggleRef","sheetOpen","detailsId","opensSheet","onToggle","contentRef","collapsed","EditLayout","rest","rootRef","mergedRef","ref","railSlotRef","sheetSlotRef","lastFocus","railHost","mode","setMode","localOpen","setLocalOpen","defaultRailOpen","sheet","setSheet","animate","setAnimate","compact","narrow","railOpen","confirmLeave","current","next","slot","focused","refocus","last","toggle","onRailToggle","railContent","rail","className","event","onFocus","backLabel","onBack","confirmText","onLeave","actions","railLabel","railCollapsed"],"sources":["../../../src/components/EditLayout/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n type RefObject,\n} from \"react\";\nimport { createPortal, flushSync } from \"react-dom\";\nimport { Button } from \"../Button\";\nimport { Drawer } from \"../Drawer\";\nimport { Icon } from \"../Icon\";\nimport type { IconName } from \"../Icon/icons\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { observeElementWidth } from \"../../internal/observeElementWidth\";\nimport \"./style.css\";\n\nexport type EditSaveState = \"clean\" | \"dirty\" | \"saving\" | \"saved\" | \"error\" | \"offline\";\n\nexport interface EditLayoutProps extends HTMLAttributes<HTMLDivElement> {\n backLabel: string;\n onBack: () => void;\n saveState?: EditSaveState;\n savedAgo?: ReactNode;\n actions?: ReactNode;\n /** A render slot can close the Details sheet before opening another dialog. */\n rail: ReactNode | ((closeDetails: () => void) => ReactNode);\n /** Custom collapsed controls receive the accessible expand action. */\n railCollapsed?: (expand: () => void) => ReactNode;\n railLabel?: string;\n railOpen?: boolean;\n defaultRailOpen?: boolean;\n onRailToggle?: (open: boolean) => void;\n confirmLeave?: boolean;\n confirmText?: string;\n onKeepEditing?: () => void;\n onLeave?: () => void;\n children?: ReactNode;\n}\n\n/** Below this width, the action bar's gaps and padding contract. */\nconst TIGHT_WIDTH = 360;\n/** Below this width, Details opens from the action bar. */\nconst COMPACT_WIDTH = 600;\n/** From this width, the rail follows the open/closed preference. */\nconst WIDE_WIDTH = 900;\n\ntype LayoutMode = \"tight\" | \"compact\" | \"narrow\" | \"wide\";\n\nfunction layoutMode(width: number): LayoutMode {\n if (width < TIGHT_WIDTH) {\n return \"tight\";\n }\n if (width < COMPACT_WIDTH) {\n return \"compact\";\n }\n if (width < WIDE_WIDTH) {\n return \"narrow\";\n }\n return \"wide\";\n}\n\nconst statusLabels: Record<EditSaveState, string> = {\n clean: \"No changes\",\n dirty: \"Unsaved changes\",\n saving: \"Saving…\",\n saved: \"Saved\",\n error: \"Couldn't save\",\n offline: \"Offline · kept in this tab\",\n};\n\nconst statusIcons: Record<EditSaveState, IconName | undefined> = {\n clean: undefined,\n dirty: undefined,\n saving: \"spinner\",\n saved: \"check\",\n error: \"alert-triangle\",\n offline: \"clock\",\n};\n\n/** Removed, hidden and inert elements can't keep focus, and neither can the page. */\nfunction cannotHoldFocus(element: Element | null) {\n return (\n !element ||\n element === document.body ||\n !element.isConnected ||\n element.closest(\"[aria-hidden='true'], [inert]\") !== null\n );\n}\n\nfunction createRailHost() {\n if (typeof document === \"undefined\") {\n return null;\n }\n const host = document.createElement(\"div\");\n host.className = \"ds-edit-layout__rail-host\";\n return host;\n}\n\ninterface SaveStatusProps {\n saveState: EditSaveState;\n savedAgo?: ReactNode;\n}\n\nfunction SaveStatus({ saveState, savedAgo }: SaveStatusProps) {\n const icon = statusIcons[saveState];\n return (\n <div\n className=\"ds-edit-layout__status\"\n data-state={saveState}\n role=\"status\"\n aria-live=\"polite\"\n >\n {icon && (\n <Icon\n name={icon}\n className={saveState === \"saving\" ? \"ds-icon--spin\" : undefined}\n />\n )}\n {saveState === \"dirty\" && (\n <span\n className=\"ds-edit-layout__dirty\"\n aria-hidden=\"true\"\n />\n )}\n <span>\n {statusLabels[saveState]}\n {saveState === \"saved\" && savedAgo ? <> {savedAgo}</> : null}\n </span>\n </div>\n );\n}\n\ninterface LeaveConfirmationProps {\n text: string;\n /** Keep editing falls back to the first control here when its origin is gone. */\n bodyRef: RefObject<HTMLDivElement | null>;\n onKeepEditing?: () => void;\n}\n\n/** Takes focus while shown; Keep editing returns it to where the user was. */\nfunction LeaveConfirmation({ text, bodyRef, onKeepEditing }: LeaveConfirmationProps) {\n const keepRef = useRef<HTMLButtonElement>(null);\n const origin = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n origin.current = document.activeElement as HTMLElement | null;\n const frame = requestAnimationFrame(() => keepRef.current?.focus({ preventScroll: true }));\n return () => cancelAnimationFrame(frame);\n }, []);\n\n const keepEditing = () => {\n onKeepEditing?.();\n requestAnimationFrame(() => {\n const destination = origin.current?.isConnected\n ? origin.current\n : bodyRef.current?.querySelector<HTMLElement>(\n \"input, textarea, button, [contenteditable='true']\",\n );\n destination?.focus({ preventScroll: true });\n });\n };\n\n return (\n <div className=\"ds-edit-layout__confirmation\">\n <strong>{text}</strong>\n <Button\n ref={keepRef}\n size=\"xs\"\n onClick={keepEditing}\n >\n Keep editing\n </Button>\n </div>\n );\n}\n\ninterface DetailsRailProps {\n label: string;\n detailsId: string;\n expanded: boolean;\n /** Below the wide breakpoint, the toggle opens the Details sheet instead. */\n opensSheet: boolean;\n sheetOpen: boolean;\n toggleRef: RefObject<HTMLButtonElement | null>;\n /** Receives the rail content while the rail is expanded. */\n contentRef: RefObject<HTMLDivElement | null>;\n collapsed?: (expand: () => void) => ReactNode;\n onToggle: () => void;\n}\n\nfunction DetailsRail({\n label,\n detailsId,\n expanded,\n opensSheet,\n sheetOpen,\n toggleRef,\n contentRef,\n collapsed,\n onToggle,\n}: DetailsRailProps) {\n return (\n <aside\n className=\"ds-edit-layout__rail\"\n aria-label={label}\n >\n <header className=\"ds-edit-layout__rail-head\">\n {expanded && <span>{label}</span>}\n <Button\n ref={toggleRef}\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart={expanded ? \"chevrons-right\" : \"chevrons-left\"}\n className=\"ds-edit-layout__toggle\"\n aria-label={`${expanded ? \"Collapse\" : \"Expand\"} ${label}`}\n aria-expanded={expanded || sheetOpen}\n aria-controls={detailsId}\n aria-haspopup={opensSheet ? \"dialog\" : undefined}\n onClick={onToggle}\n />\n </header>\n {expanded ? (\n <div\n id={detailsId}\n ref={contentRef}\n className=\"ds-edit-layout__rail-content\"\n />\n ) : (\n <div className=\"ds-edit-layout__rail-icons\">\n {collapsed ? (\n collapsed(onToggle)\n ) : (\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"info\"\n aria-label={`Show ${label}`}\n onClick={onToggle}\n />\n )}\n </div>\n )}\n </aside>\n );\n}\n\n/** Presentation only: the consumer owns saving, routing and persisted preferences. */\nexport const EditLayout = forwardRef<HTMLDivElement, EditLayoutProps>(function EditLayout(\n {\n backLabel,\n onBack,\n saveState = \"clean\",\n savedAgo,\n actions,\n rail,\n railCollapsed,\n railLabel = \"Details\",\n railOpen,\n defaultRailOpen = true,\n onRailToggle,\n confirmLeave = false,\n confirmText = \"Leave without saving?\",\n onKeepEditing,\n onLeave,\n children,\n className,\n onFocus,\n ...rest\n },\n ref,\n) {\n const rootRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMemo(() => mergeRefs(rootRef, ref), [ref]);\n const bodyRef = useRef<HTMLDivElement>(null);\n const toggleRef = useRef<HTMLButtonElement>(null);\n const railSlotRef = useRef<HTMLDivElement>(null);\n const sheetSlotRef = useRef<HTMLDivElement>(null);\n const lastFocus = useRef<Element | null>(null);\n // Rail content renders once, into a node that moves between the rail and\n // the sheet, so uncontrolled fields keep their values across modes.\n const [railHost] = useState(createRailHost);\n const [mode, setMode] = useState<LayoutMode>(\"wide\");\n const [localOpen, setLocalOpen] = useState(defaultRailOpen);\n const [sheet, setSheet] = useState(false);\n const [animate, setAnimate] = useState(false);\n const detailsId = useId();\n const compact = mode === \"tight\" || mode === \"compact\";\n const narrow = mode !== \"wide\";\n const expanded = !narrow && (railOpen ?? localOpen);\n\n // Leave confirmation and the wide rail both replace the Details sheet.\n if (sheet && (confirmLeave || !narrow)) {\n setSheet(false);\n }\n\n // Measure before the first paint, then re-render only when a breakpoint is crossed.\n useLayoutEffect(() => {\n let current: LayoutMode | undefined;\n return observeElementWidth(rootRef.current!, (width) => {\n const next = layoutMode(width);\n if (next === current) {\n return;\n }\n current = next;\n // Crossing a breakpoint is not a deliberate toggle, so it doesn't animate.\n setAnimate(false);\n setMode(next);\n });\n }, []);\n\n useLayoutEffect(() => {\n if (!railHost) {\n return;\n }\n const slot = railSlotRef.current ?? sheetSlotRef.current;\n if (!slot) {\n railHost.remove();\n return;\n }\n if (railHost.parentNode === slot) {\n return;\n }\n // Moving a node drops its focus; keep the user in the field they were in.\n const focused = lastFocus.current;\n const refocus =\n focused instanceof HTMLElement &&\n railHost.contains(focused) &&\n cannotHoldFocus(document.activeElement);\n slot.append(railHost);\n if (refocus) {\n focused.focus({ preventScroll: true });\n }\n });\n\n // A breakpoint, a collapse or a closing sheet can remove the focused control.\n // Hand focus to the Details toggle that replaced it.\n useEffect(() => {\n const last = lastFocus.current;\n if (last && cannotHoldFocus(last) && cannotHoldFocus(document.activeElement)) {\n toggleRef.current?.focus({ preventScroll: true });\n }\n }, [mode, expanded, sheet]);\n\n const toggle = () => {\n if (narrow) {\n setSheet(true);\n return;\n }\n setAnimate(true);\n setLocalOpen(!expanded);\n onRailToggle?.(!expanded);\n };\n const closeDetails = () => flushSync(() => setSheet(false));\n const railContent = typeof rail === \"function\" ? rail(closeDetails) : rail;\n\n return (\n <div\n {...rest}\n ref={mergedRef}\n className={[\"ds-edit-layout\", className].filter(Boolean).join(\" \")}\n data-compact={compact || undefined}\n data-tight={mode === \"tight\" || undefined}\n data-expanded={expanded || undefined}\n data-animate={animate || undefined}\n onFocus={(event) => {\n lastFocus.current = event.target;\n onFocus?.(event);\n }}\n >\n <div className=\"ds-edit-layout__main\">\n <header className=\"ds-edit-layout__bar\">\n <Button\n variant=\"simple\"\n size=\"sm\"\n iconStart=\"arrow-left\"\n isIconOnly={compact}\n aria-label={`Back to ${backLabel}`}\n onClick={onBack}\n >\n {backLabel}\n </Button>\n {confirmLeave ? (\n <LeaveConfirmation\n text={confirmText}\n bodyRef={bodyRef}\n onKeepEditing={onKeepEditing}\n />\n ) : (\n <SaveStatus\n saveState={saveState}\n savedAgo={savedAgo}\n />\n )}\n <div className=\"ds-edit-layout__actions\">\n {confirmLeave ? (\n <Button\n variant=\"danger\"\n size=\"sm\"\n onClick={onLeave}\n >\n Leave anyway\n </Button>\n ) : (\n actions\n )}\n {compact && (\n <Button\n ref={toggleRef}\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"info\"\n aria-label={railLabel}\n aria-haspopup=\"dialog\"\n aria-expanded={sheet}\n aria-controls={detailsId}\n onClick={toggle}\n />\n )}\n </div>\n </header>\n <div\n ref={bodyRef}\n className=\"ds-edit-layout__body\"\n >\n <div className=\"ds-edit-layout__content\">{children}</div>\n </div>\n </div>\n {!compact && (\n <DetailsRail\n label={railLabel}\n detailsId={detailsId}\n expanded={expanded}\n opensSheet={narrow}\n sheetOpen={sheet}\n toggleRef={toggleRef}\n contentRef={railSlotRef}\n collapsed={railCollapsed}\n onToggle={toggle}\n />\n )}\n <Drawer\n id={narrow ? detailsId : undefined}\n dir={rest.dir}\n isOpen={sheet}\n onClose={() => setSheet(false)}\n side=\"end\"\n size=\"md\"\n title={railLabel}\n closeLabel={`Close ${railLabel}`}\n className=\"ds-edit-layout__sheet\"\n >\n {narrow && (\n <div\n ref={sheetSlotRef}\n className=\"ds-edit-layout__rail-content\"\n />\n )}\n </Drawer>\n {railHost && createPortal(railContent, railHost)}\n </div>\n );\n});\n"],"mappings":"A,gXA6CA,IAAMqB,EAAc,IAEdC,EAAgB,IAEhBC,EAAa,IAInB,SAASC,EAAW,EAA2B,CAU7C,OATIC,EAAQJ,EACH,QAELI,EAAQH,EACH,UAELG,EAAQF,EACH,SAEF,MACT,CAEA,IAAMG,EAA8C,CAClD,MAAO,aACP,MAAO,kBACP,OAAQ,UACR,MAAO,QACP,MAAO,gBACP,QAAS,4BACX,EAEMC,EAA2D,CAC/D,MAAO,IAAA,GACP,MAAO,IAAA,GACP,OAAQ,UACR,MAAO,QACP,MAAO,iBACP,QAAS,OACX,EAGA,SAASC,EAAgB,EAAyB,CAChD,MACE,CAACC,GACDA,IAAY,SAAS,MACrB,CAACA,EAAQ,aACTA,EAAQ,QAAQ,+BAA+B,IAAM,IAEzD,CAEA,SAAS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ACL,MAAOyB,EACP,WAAY,SAASA,IACrB,UAAU,wBAET,SAAArB,IACC,EAAApD,EAAA,IAAA,CAAC,MAAD,CACE,IAAKuC,EACL,UAAU,8BACX,CAAA,CAEG,CAAA,EACPE,IAAA,EAAYjD,EAAAA,aAAAA,CAAauE,GAAatB,CAAQ,CAC5C,C,EAET,CAAC,E"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["Icon","_Fragment","useRef","Button","forwardRef","useMemo","mergeRefs","useState","useId","observeElementWidth","flushSync","Drawer","createPortal","require_Icon","require_components_Button_index","require_mergeRefs","require_components_Drawer_index","require_observeElementWidth","react","react_dom","react_jsx_runtime","TIGHT_WIDTH","COMPACT_WIDTH","WIDE_WIDTH","layoutMode","width","statusLabels","statusIcons","cannotHoldFocus","element","createRailHost","host","SaveStatus","icon","saveState","savedAgo","LeaveConfirmation","keepRef","origin","frame","text","onKeepEditing","bodyRef","EditActionBar","compact","backLabel","onBack","confirmLeave","confirmation","status","onLeave","actions","detailsToggle","DetailsRail","label","expanded","toggleRef","sheetOpen","detailsId","opensSheet","onToggle","contentRef","collapsed","EditLayout","rest","rootRef","mergedRef","ref","railSlotRef","sheetSlotRef","lastFocus","railHost","mode","setMode","localOpen","setLocalOpen","defaultRailOpen","sheet","setSheet","animate","setAnimate","narrow","railOpen","current","next","slot","focused","refocus","last","toggle","onRailToggle","railContent","rail","className","event","onFocus","confirmText","railLabel","railCollapsed"],"sources":["../../../src/components/EditLayout/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n type RefObject,\n} from \"react\";\nimport { createPortal, flushSync } from \"react-dom\";\nimport { Button } from \"../Button\";\nimport { Drawer } from \"../Drawer\";\nimport { Icon } from \"../Icon\";\nimport type { IconName } from \"../Icon/icons\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { observeElementWidth } from \"../../internal/observeElementWidth\";\nimport \"./style.css\";\n\nexport type EditSaveState = \"clean\" | \"dirty\" | \"saving\" | \"saved\" | \"error\" | \"offline\";\n\nexport interface EditLayoutProps extends HTMLAttributes<HTMLDivElement> {\n backLabel: string;\n onBack: () => void;\n saveState?: EditSaveState;\n savedAgo?: ReactNode;\n actions?: ReactNode;\n /** A render slot can close the Details sheet before opening another dialog. */\n rail: ReactNode | ((closeDetails: () => void) => ReactNode);\n /** Custom collapsed controls receive the accessible expand action. */\n railCollapsed?: (expand: () => void) => ReactNode;\n railLabel?: string;\n railOpen?: boolean;\n defaultRailOpen?: boolean;\n onRailToggle?: (open: boolean) => void;\n confirmLeave?: boolean;\n confirmText?: string;\n onKeepEditing?: () => void;\n onLeave?: () => void;\n children?: ReactNode;\n}\n\n/** Below this width, the action bar's gaps and padding contract. */\nconst TIGHT_WIDTH = 360;\n/** Below this width, Details opens from the action bar. */\nconst COMPACT_WIDTH = 600;\n/** From this width, the rail follows the open/closed preference. */\nconst WIDE_WIDTH = 900;\n\ntype LayoutMode = \"tight\" | \"compact\" | \"narrow\" | \"wide\";\n\nfunction layoutMode(width: number): LayoutMode {\n if (width < TIGHT_WIDTH) {\n return \"tight\";\n }\n if (width < COMPACT_WIDTH) {\n return \"compact\";\n }\n if (width < WIDE_WIDTH) {\n return \"narrow\";\n }\n return \"wide\";\n}\n\nconst statusLabels: Record<EditSaveState, string> = {\n clean: \"No changes\",\n dirty: \"Unsaved changes\",\n saving: \"Saving…\",\n saved: \"Saved\",\n error: \"Couldn't save\",\n offline: \"Offline · kept in this tab\",\n};\n\nconst statusIcons: Record<EditSaveState, IconName | undefined> = {\n clean: undefined,\n dirty: undefined,\n saving: \"spinner\",\n saved: \"check\",\n error: \"alert-triangle\",\n offline: \"clock\",\n};\n\n/** Removed, hidden and inert elements can't keep focus, and neither can the page. */\nfunction cannotHoldFocus(element: Element | null) {\n return (\n !element ||\n element === document.body ||\n !element.isConnected ||\n element.closest(\"[aria-hidden='true'], [inert]\") !== null\n );\n}\n\nfunction createRailHost() {\n if (typeof document === \"undefined\") {\n return null;\n }\n const host = document.createElement(\"div\");\n host.className = \"ds-edit-layout__rail-host\";\n return host;\n}\n\ninterface SaveStatusProps {\n saveState: EditSaveState;\n savedAgo?: ReactNode;\n}\n\nfunction SaveStatus({ saveState, savedAgo }: SaveStatusProps) {\n const icon = statusIcons[saveState];\n return (\n <div\n className=\"ds-edit-layout__status\"\n data-state={saveState}\n role=\"status\"\n aria-live=\"polite\"\n >\n {icon && (\n <Icon\n name={icon}\n className={saveState === \"saving\" ? \"ds-icon--spin\" : undefined}\n />\n )}\n {saveState === \"dirty\" && (\n <span\n className=\"ds-edit-layout__dirty\"\n aria-hidden=\"true\"\n />\n )}\n <span>\n {statusLabels[saveState]}\n {saveState === \"saved\" && savedAgo ? <> {savedAgo}</> : null}\n </span>\n </div>\n );\n}\n\ninterface LeaveConfirmationProps {\n text: string;\n /** Keep editing falls back to the first control here when its origin is gone. */\n bodyRef: RefObject<HTMLDivElement | null>;\n onKeepEditing?: () => void;\n}\n\n/** Takes focus while shown; Keep editing returns it to where the user was. */\nfunction LeaveConfirmation({ text, bodyRef, onKeepEditing }: LeaveConfirmationProps) {\n const keepRef = useRef<HTMLButtonElement>(null);\n const origin = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n origin.current = document.activeElement as HTMLElement | null;\n const frame = requestAnimationFrame(() => keepRef.current?.focus({ preventScroll: true }));\n return () => cancelAnimationFrame(frame);\n }, []);\n\n const keepEditing = () => {\n onKeepEditing?.();\n requestAnimationFrame(() => {\n const destination = origin.current?.isConnected\n ? origin.current\n : bodyRef.current?.querySelector<HTMLElement>(\n \"input, textarea, button, [contenteditable='true']\",\n );\n destination?.focus({ preventScroll: true });\n });\n };\n\n return (\n <div className=\"ds-edit-layout__confirmation\">\n <strong>{text}</strong>\n <Button\n ref={keepRef}\n size=\"xs\"\n onClick={keepEditing}\n >\n Keep editing\n </Button>\n </div>\n );\n}\n\ninterface EditActionBarProps {\n backLabel: string;\n onBack: () => void;\n compact: boolean;\n status: ReactNode;\n actions?: ReactNode;\n /** Replaces the status and actions while set. */\n confirmLeave: boolean;\n confirmation: ReactNode;\n onLeave?: () => void;\n /** Shown only in compact layouts, where Details opens as a sheet. */\n detailsToggle: ReactNode;\n}\n\nfunction EditActionBar({\n backLabel,\n onBack,\n compact,\n status,\n actions,\n confirmLeave,\n confirmation,\n onLeave,\n detailsToggle,\n}: EditActionBarProps) {\n return (\n <header className=\"ds-edit-layout__bar\">\n <Button\n variant=\"simple\"\n size=\"sm\"\n iconStart=\"arrow-left\"\n isIconOnly={compact}\n aria-label={`Back to ${backLabel}`}\n onClick={onBack}\n >\n {backLabel}\n </Button>\n {confirmLeave ? confirmation : status}\n <div className=\"ds-edit-layout__actions\">\n {confirmLeave ? (\n <Button\n variant=\"danger\"\n size=\"sm\"\n onClick={onLeave}\n >\n Leave anyway\n </Button>\n ) : (\n actions\n )}\n {compact && detailsToggle}\n </div>\n </header>\n );\n}\n\ninterface DetailsRailProps {\n label: string;\n detailsId: string;\n expanded: boolean;\n /** Below the wide breakpoint, the toggle opens the Details sheet instead. */\n opensSheet: boolean;\n sheetOpen: boolean;\n toggleRef: RefObject<HTMLButtonElement | null>;\n /** Receives the rail content while the rail is expanded. */\n contentRef: RefObject<HTMLDivElement | null>;\n collapsed?: (expand: () => void) => ReactNode;\n onToggle: () => void;\n}\n\nfunction DetailsRail({\n label,\n detailsId,\n expanded,\n opensSheet,\n sheetOpen,\n toggleRef,\n contentRef,\n collapsed,\n onToggle,\n}: DetailsRailProps) {\n return (\n <aside\n className=\"ds-edit-layout__rail\"\n aria-label={label}\n >\n <header className=\"ds-edit-layout__rail-head\">\n {expanded && <span>{label}</span>}\n <Button\n ref={toggleRef}\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart={expanded ? \"chevrons-right\" : \"chevrons-left\"}\n className=\"ds-edit-layout__toggle\"\n aria-label={`${expanded ? \"Collapse\" : \"Expand\"} ${label}`}\n aria-expanded={expanded || sheetOpen}\n aria-controls={detailsId}\n aria-haspopup={opensSheet ? \"dialog\" : undefined}\n onClick={onToggle}\n />\n </header>\n {expanded ? (\n <div\n id={detailsId}\n ref={contentRef}\n className=\"ds-edit-layout__rail-content\"\n />\n ) : (\n <div className=\"ds-edit-layout__rail-icons\">\n {collapsed ? (\n collapsed(onToggle)\n ) : (\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"info\"\n aria-label={`Show ${label}`}\n onClick={onToggle}\n />\n )}\n </div>\n )}\n </aside>\n );\n}\n\n/** Presentation only: the consumer owns saving, routing and persisted preferences. */\nexport const EditLayout = forwardRef<HTMLDivElement, EditLayoutProps>(function EditLayout(\n {\n backLabel,\n onBack,\n saveState = \"clean\",\n savedAgo,\n actions,\n rail,\n railCollapsed,\n railLabel = \"Details\",\n railOpen,\n defaultRailOpen = true,\n onRailToggle,\n confirmLeave = false,\n confirmText = \"Leave without saving?\",\n onKeepEditing,\n onLeave,\n children,\n className,\n onFocus,\n ...rest\n },\n ref,\n) {\n const rootRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMemo(() => mergeRefs(rootRef, ref), [ref]);\n const bodyRef = useRef<HTMLDivElement>(null);\n const toggleRef = useRef<HTMLButtonElement>(null);\n const railSlotRef = useRef<HTMLDivElement>(null);\n const sheetSlotRef = useRef<HTMLDivElement>(null);\n const lastFocus = useRef<Element | null>(null);\n // Rail content renders once, into a node that moves between the rail and\n // the sheet, so uncontrolled fields keep their values across modes.\n const [railHost] = useState(createRailHost);\n const [mode, setMode] = useState<LayoutMode>(\"wide\");\n const [localOpen, setLocalOpen] = useState(defaultRailOpen);\n const [sheet, setSheet] = useState(false);\n const [animate, setAnimate] = useState(false);\n const detailsId = useId();\n const compact = mode === \"tight\" || mode === \"compact\";\n const narrow = mode !== \"wide\";\n const expanded = !narrow && (railOpen ?? localOpen);\n\n // Leave confirmation and the wide rail both replace the Details sheet.\n if (sheet && (confirmLeave || !narrow)) {\n setSheet(false);\n }\n\n // Measure before the first paint, then re-render only when a breakpoint is crossed.\n useLayoutEffect(() => {\n let current: LayoutMode | undefined;\n return observeElementWidth(rootRef.current!, (width) => {\n const next = layoutMode(width);\n if (next === current) {\n return;\n }\n current = next;\n // Crossing a breakpoint is not a deliberate toggle, so it doesn't animate.\n setAnimate(false);\n setMode(next);\n });\n }, []);\n\n useLayoutEffect(() => {\n if (!railHost) {\n return;\n }\n const slot = railSlotRef.current ?? sheetSlotRef.current;\n if (!slot) {\n railHost.remove();\n return;\n }\n if (railHost.parentNode === slot) {\n return;\n }\n // Moving a node drops its focus; keep the user in the field they were in.\n const focused = lastFocus.current;\n const refocus =\n focused instanceof HTMLElement &&\n railHost.contains(focused) &&\n cannotHoldFocus(document.activeElement);\n slot.append(railHost);\n if (refocus) {\n focused.focus({ preventScroll: true });\n }\n });\n\n // A breakpoint, a collapse or a closing sheet can remove the focused control.\n // Hand focus to the Details toggle that replaced it.\n useEffect(() => {\n const last = lastFocus.current;\n if (last && cannotHoldFocus(last) && cannotHoldFocus(document.activeElement)) {\n toggleRef.current?.focus({ preventScroll: true });\n }\n }, [mode, expanded, sheet]);\n\n const toggle = () => {\n if (narrow) {\n setSheet(true);\n return;\n }\n setAnimate(true);\n setLocalOpen(!expanded);\n onRailToggle?.(!expanded);\n };\n const closeDetails = () => flushSync(() => setSheet(false));\n const railContent = typeof rail === \"function\" ? rail(closeDetails) : rail;\n\n return (\n <div\n {...rest}\n ref={mergedRef}\n className={[\"ds-edit-layout\", className].filter(Boolean).join(\" \")}\n data-compact={compact || undefined}\n data-tight={mode === \"tight\" || undefined}\n data-expanded={expanded || undefined}\n data-animate={animate || undefined}\n onFocus={(event) => {\n lastFocus.current = event.target;\n onFocus?.(event);\n }}\n >\n <div className=\"ds-edit-layout__main\">\n <EditActionBar\n backLabel={backLabel}\n onBack={onBack}\n compact={compact}\n status={\n <SaveStatus\n saveState={saveState}\n savedAgo={savedAgo}\n />\n }\n actions={actions}\n confirmLeave={confirmLeave}\n confirmation={\n <LeaveConfirmation\n text={confirmText}\n bodyRef={bodyRef}\n onKeepEditing={onKeepEditing}\n />\n }\n onLeave={onLeave}\n detailsToggle={\n <Button\n ref={toggleRef}\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"info\"\n aria-label={railLabel}\n aria-haspopup=\"dialog\"\n aria-expanded={sheet}\n aria-controls={detailsId}\n onClick={toggle}\n />\n }\n />\n <div\n ref={bodyRef}\n className=\"ds-edit-layout__body\"\n >\n <div className=\"ds-edit-layout__content\">{children}</div>\n </div>\n </div>\n {!compact && (\n <DetailsRail\n label={railLabel}\n detailsId={detailsId}\n expanded={expanded}\n opensSheet={narrow}\n sheetOpen={sheet}\n toggleRef={toggleRef}\n contentRef={railSlotRef}\n collapsed={railCollapsed}\n onToggle={toggle}\n />\n )}\n <Drawer\n id={narrow ? detailsId : undefined}\n dir={rest.dir}\n isOpen={sheet}\n onClose={() => setSheet(false)}\n side=\"end\"\n size=\"md\"\n title={railLabel}\n closeLabel={`Close ${railLabel}`}\n className=\"ds-edit-layout__sheet\"\n >\n {narrow && (\n <div\n ref={sheetSlotRef}\n className=\"ds-edit-layout__rail-content\"\n />\n )}\n </Drawer>\n {railHost && createPortal(railContent, railHost)}\n </div>\n );\n});\n"],"mappings":"A,gXA6CA,IAAMqB,EAAc,IAEdC,EAAgB,IAEhBC,EAAa,IAInB,SAASC,EAAW,EAA2B,CAU7C,OATIC,EAAQJ,EACH,QAELI,EAAQH,EACH,UAELG,EAAQF,EACH,SAEF,MACT,CAEA,IAAMG,EAA8C,CAClD,MAAO,aACP,MAAO,kBACP,OAAQ,UACR,MAAO,QACP,MAAO,gBACP,QAAS,4BACX,EAEMC,EAA2D,CAC/D,MAAO,IAAA,GACP,MAAO,IAAA,GACP,OAAQ,UACR,MAAO,QACP,MAAO,iBACP,QAAS,OACX,EAGA,SAASC,EAAgB,EAAyB,CAChD,MACE,CAACC,GACDA,IAAY,SAAS,MACrB,CAACA,EAAQ,aACTA,EAAQ,QAAQ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ACtF,eAAO,MAAM,UAAU,4GAuMrB,CAAC"}
|
|
@@ -74,7 +74,33 @@ function ne({ text: e, bodyRef: n, onKeepEditing: r }) {
|
|
|
74
74
|
})]
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
|
-
function re({
|
|
77
|
+
function re({ backLabel: e, onBack: n, compact: r, status: i, actions: a, confirmLeave: o, confirmation: s, onLeave: c, detailsToggle: l }) {
|
|
78
|
+
return /* @__PURE__ */ h("header", {
|
|
79
|
+
className: "ds-edit-layout__bar",
|
|
80
|
+
children: [
|
|
81
|
+
/* @__PURE__ */ m(t, {
|
|
82
|
+
variant: "simple",
|
|
83
|
+
size: "sm",
|
|
84
|
+
iconStart: "arrow-left",
|
|
85
|
+
isIconOnly: r,
|
|
86
|
+
"aria-label": `Back to ${e}`,
|
|
87
|
+
onClick: n,
|
|
88
|
+
children: e
|
|
89
|
+
}),
|
|
90
|
+
o ? s : i,
|
|
91
|
+
/* @__PURE__ */ h("div", {
|
|
92
|
+
className: "ds-edit-layout__actions",
|
|
93
|
+
children: [o ? /* @__PURE__ */ m(t, {
|
|
94
|
+
variant: "danger",
|
|
95
|
+
size: "sm",
|
|
96
|
+
onClick: c,
|
|
97
|
+
children: "Leave anyway"
|
|
98
|
+
}) : a, r && l]
|
|
99
|
+
})
|
|
100
|
+
]
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function ie({ label: e, detailsId: n, expanded: r, opensSheet: i, sheetOpen: a, toggleRef: o, contentRef: s, collapsed: c, onToggle: l }) {
|
|
78
104
|
return /* @__PURE__ */ h("aside", {
|
|
79
105
|
className: "ds-edit-layout__rail",
|
|
80
106
|
"aria-label": e,
|
|
@@ -110,11 +136,11 @@ function re({ label: e, detailsId: n, expanded: r, opensSheet: i, sheetOpen: a,
|
|
|
110
136
|
})]
|
|
111
137
|
});
|
|
112
138
|
}
|
|
113
|
-
var w = a(function({ backLabel: e, onBack: a, saveState: p = "clean", savedAgo: g, actions: _, rail: v, railCollapsed: b, railLabel: x = "Details", railOpen: w, defaultRailOpen: T = !0, onRailToggle:
|
|
114
|
-
let
|
|
115
|
-
K && (
|
|
139
|
+
var w = a(function({ backLabel: e, onBack: a, saveState: p = "clean", savedAgo: g, actions: _, rail: v, railCollapsed: b, railLabel: x = "Details", railOpen: w, defaultRailOpen: T = !0, onRailToggle: ae, confirmLeave: E = !1, confirmText: D = "Leave without saving?", onKeepEditing: O, onLeave: k, children: A, className: j, onFocus: oe, ...M }, N) {
|
|
140
|
+
let P = u(null), F = l(() => n(P, N), [N]), I = u(null), L = u(null), R = u(null), z = u(null), B = u(null), [V] = d(C), [H, U] = d("wide"), [W, G] = d(T), [K, q] = d(!1), [se, J] = d(!1), Y = s(), X = H === "tight" || H === "compact", Z = H !== "wide", Q = !Z && (w ?? W);
|
|
141
|
+
K && (E || !Z) && q(!1), c(() => {
|
|
116
142
|
let e;
|
|
117
|
-
return i(
|
|
143
|
+
return i(P.current, (t) => {
|
|
118
144
|
let n = y(t);
|
|
119
145
|
n !== e && (e = n, J(!1), U(n));
|
|
120
146
|
});
|
|
@@ -137,63 +163,50 @@ var w = a(function({ backLabel: e, onBack: a, saveState: p = "clean", savedAgo:
|
|
|
137
163
|
K
|
|
138
164
|
]);
|
|
139
165
|
let $ = () => {
|
|
140
|
-
Z ? q(!0) : (J(!0), G(!Q),
|
|
141
|
-
},
|
|
166
|
+
Z ? q(!0) : (J(!0), G(!Q), ae?.(!Q));
|
|
167
|
+
}, ce = typeof v == "function" ? v(() => f(() => q(!1))) : v;
|
|
142
168
|
return /* @__PURE__ */ h("div", {
|
|
143
|
-
...
|
|
144
|
-
ref:
|
|
169
|
+
...M,
|
|
170
|
+
ref: F,
|
|
145
171
|
className: ["ds-edit-layout", j].filter(Boolean).join(" "),
|
|
146
172
|
"data-compact": X || void 0,
|
|
147
173
|
"data-tight": H === "tight" || void 0,
|
|
148
174
|
"data-expanded": Q || void 0,
|
|
149
|
-
"data-animate":
|
|
175
|
+
"data-animate": se || void 0,
|
|
150
176
|
onFocus: (e) => {
|
|
151
|
-
B.current = e.target,
|
|
177
|
+
B.current = e.target, oe?.(e);
|
|
152
178
|
},
|
|
153
179
|
children: [
|
|
154
180
|
/* @__PURE__ */ h("div", {
|
|
155
181
|
className: "ds-edit-layout__main",
|
|
156
|
-
children: [/* @__PURE__ */
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
ref: L,
|
|
185
|
-
variant: "simple",
|
|
186
|
-
size: "sm",
|
|
187
|
-
isIconOnly: !0,
|
|
188
|
-
iconStart: "info",
|
|
189
|
-
"aria-label": x,
|
|
190
|
-
"aria-haspopup": "dialog",
|
|
191
|
-
"aria-expanded": K,
|
|
192
|
-
"aria-controls": Y,
|
|
193
|
-
onClick: $
|
|
194
|
-
})]
|
|
195
|
-
})
|
|
196
|
-
]
|
|
182
|
+
children: [/* @__PURE__ */ m(re, {
|
|
183
|
+
backLabel: e,
|
|
184
|
+
onBack: a,
|
|
185
|
+
compact: X,
|
|
186
|
+
status: /* @__PURE__ */ m(te, {
|
|
187
|
+
saveState: p,
|
|
188
|
+
savedAgo: g
|
|
189
|
+
}),
|
|
190
|
+
actions: _,
|
|
191
|
+
confirmLeave: E,
|
|
192
|
+
confirmation: /* @__PURE__ */ m(ne, {
|
|
193
|
+
text: D,
|
|
194
|
+
bodyRef: I,
|
|
195
|
+
onKeepEditing: O
|
|
196
|
+
}),
|
|
197
|
+
onLeave: k,
|
|
198
|
+
detailsToggle: /* @__PURE__ */ m(t, {
|
|
199
|
+
ref: L,
|
|
200
|
+
variant: "simple",
|
|
201
|
+
size: "sm",
|
|
202
|
+
isIconOnly: !0,
|
|
203
|
+
iconStart: "info",
|
|
204
|
+
"aria-label": x,
|
|
205
|
+
"aria-haspopup": "dialog",
|
|
206
|
+
"aria-expanded": K,
|
|
207
|
+
"aria-controls": Y,
|
|
208
|
+
onClick: $
|
|
209
|
+
})
|
|
197
210
|
}), /* @__PURE__ */ m("div", {
|
|
198
211
|
ref: I,
|
|
199
212
|
className: "ds-edit-layout__body",
|
|
@@ -203,7 +216,7 @@ var w = a(function({ backLabel: e, onBack: a, saveState: p = "clean", savedAgo:
|
|
|
203
216
|
})
|
|
204
217
|
})]
|
|
205
218
|
}),
|
|
206
|
-
!X && /* @__PURE__ */ m(
|
|
219
|
+
!X && /* @__PURE__ */ m(ie, {
|
|
207
220
|
label: x,
|
|
208
221
|
detailsId: Y,
|
|
209
222
|
expanded: Q,
|
|
@@ -216,7 +229,7 @@ var w = a(function({ backLabel: e, onBack: a, saveState: p = "clean", savedAgo:
|
|
|
216
229
|
}),
|
|
217
230
|
/* @__PURE__ */ m(r, {
|
|
218
231
|
id: Z ? Y : void 0,
|
|
219
|
-
dir:
|
|
232
|
+
dir: M.dir,
|
|
220
233
|
isOpen: K,
|
|
221
234
|
onClose: () => q(!1),
|
|
222
235
|
side: "end",
|
|
@@ -229,7 +242,7 @@ var w = a(function({ backLabel: e, onBack: a, saveState: p = "clean", savedAgo:
|
|
|
229
242
|
className: "ds-edit-layout__rail-content"
|
|
230
243
|
})
|
|
231
244
|
}),
|
|
232
|
-
V && ee(
|
|
245
|
+
V && ee(ce, V)
|
|
233
246
|
]
|
|
234
247
|
});
|
|
235
248
|
});
|