@namroodinc/liquid-editorial 0.4.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -7
- package/UPGRADING.md +217 -0
- package/dist/chunks/{Board-BaQ04nWg.cjs → Board-BPA6mVhf.cjs} +2 -2
- package/dist/chunks/{Board-BaQ04nWg.cjs.map → Board-BPA6mVhf.cjs.map} +1 -1
- package/dist/chunks/{Board-CUhF8pTX.js → Board-CcIF7jS0.js} +2 -2
- package/dist/chunks/{Board-CUhF8pTX.js.map → Board-CcIF7jS0.js.map} +1 -1
- package/dist/chunks/{ColourField-CJicr3OT.cjs → ColourField-BQ4a5tAV.cjs} +2 -2
- package/dist/chunks/{ColourField-CJicr3OT.cjs.map → ColourField-BQ4a5tAV.cjs.map} +1 -1
- package/dist/chunks/{ColourField-DjHRiFDU.js → ColourField-Doew1hLw.js} +3 -3
- package/dist/chunks/{ColourField-DjHRiFDU.js.map → ColourField-Doew1hLw.js.map} +1 -1
- package/dist/chunks/{DatePicker-aSlYLjtW.cjs → DatePicker-C0-609Zx.cjs} +2 -2
- package/dist/chunks/{DatePicker-aSlYLjtW.cjs.map → DatePicker-C0-609Zx.cjs.map} +1 -1
- package/dist/chunks/{DatePicker-D_6CQpUd.js → DatePicker-DmeWUsOS.js} +2 -2
- package/dist/chunks/{DatePicker-D_6CQpUd.js.map → DatePicker-DmeWUsOS.js.map} +1 -1
- package/dist/chunks/{FormEditor-CaskinQ1.js → FormEditor-DTnFO4oS.js} +170 -154
- package/dist/chunks/FormEditor-DTnFO4oS.js.map +1 -0
- package/dist/chunks/FormEditor-DfQLJnsO.cjs +2 -0
- package/dist/chunks/FormEditor-DfQLJnsO.cjs.map +1 -0
- package/dist/chunks/Icon-D1kx7-1c.js +81 -0
- package/dist/chunks/Icon-D1kx7-1c.js.map +1 -0
- package/dist/chunks/Icon-D38lQXNe.cjs +2 -0
- package/dist/chunks/Icon-D38lQXNe.cjs.map +1 -0
- package/dist/chunks/RichTextEditor-DEJ-u-ZR.js +483 -0
- package/dist/chunks/RichTextEditor-DEJ-u-ZR.js.map +1 -0
- package/dist/chunks/RichTextEditor-Ddk7qaqg.cjs +2 -0
- package/dist/chunks/RichTextEditor-Ddk7qaqg.cjs.map +1 -0
- package/dist/chunks/movableHost-CajG9_5Z.cjs +2 -0
- package/dist/chunks/movableHost-CajG9_5Z.cjs.map +1 -0
- package/dist/chunks/movableHost-NJj_FsAu.js +23 -0
- package/dist/chunks/movableHost-NJj_FsAu.js.map +1 -0
- package/dist/chunks/portalScope-AzzPM54i.js +105 -0
- package/dist/chunks/portalScope-AzzPM54i.js.map +1 -0
- package/dist/chunks/portalScope-BVA1-Ypu.cjs +2 -0
- package/dist/chunks/portalScope-BVA1-Ypu.cjs.map +1 -0
- package/dist/chunks/useModalDialog-BVaG--b3.js +87 -0
- package/dist/chunks/useModalDialog-BVaG--b3.js.map +1 -0
- package/dist/chunks/useModalDialog-Ctu270Dp.cjs +2 -0
- package/dist/chunks/useModalDialog-Ctu270Dp.cjs.map +1 -0
- package/dist/components/AssetCard/index.cjs +1 -1
- package/dist/components/AssetCard/index.js +1 -1
- package/dist/components/AssetGrid/index.cjs +1 -1
- package/dist/components/AssetGrid/index.js +1 -1
- package/dist/components/Board/index.cjs +1 -1
- package/dist/components/Board/index.js +1 -1
- package/dist/components/Button/index.cjs +1 -1
- package/dist/components/Button/index.cjs.map +1 -1
- package/dist/components/Button/index.d.cts +5 -0
- package/dist/components/Button/index.d.cts.map +1 -1
- package/dist/components/Button/index.d.ts +5 -0
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +14 -12
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Button/style.css +43 -11
- package/dist/components/ColourField/index.cjs +1 -1
- package/dist/components/ColourField/index.js +1 -1
- package/dist/components/DatePicker/index.cjs +1 -1
- package/dist/components/DatePicker/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 +59 -75
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/Drawer/style.css +3 -0
- 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 +107 -121
- package/dist/components/EditLayout/index.js.map +1 -1
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.cjs.map +1 -1
- package/dist/components/EntryPicker/index.d.cts.map +1 -1
- package/dist/components/EntryPicker/index.d.ts.map +1 -1
- package/dist/components/EntryPicker/index.js +3 -9
- package/dist/components/EntryPicker/index.js.map +1 -1
- package/dist/components/FormEditor/README.md +79 -3
- package/dist/components/FormEditor/control.d.cts.map +1 -1
- package/dist/components/FormEditor/control.d.ts.map +1 -1
- package/dist/components/FormEditor/index.cjs +1 -1
- package/dist/components/FormEditor/index.d.cts.map +1 -1
- package/dist/components/FormEditor/index.d.ts.map +1 -1
- package/dist/components/FormEditor/index.js +2 -1
- package/dist/components/FormEditor/model.d.cts +6 -0
- package/dist/components/FormEditor/model.d.cts.map +1 -1
- package/dist/components/FormEditor/model.d.ts +6 -0
- package/dist/components/FormEditor/model.d.ts.map +1 -1
- package/dist/components/FormEditor/style.css +7 -0
- package/dist/components/Icon/icons.d.cts +2 -0
- package/dist/components/Icon/icons.d.cts.map +1 -1
- package/dist/components/Icon/icons.d.ts +2 -0
- package/dist/components/Icon/icons.d.ts.map +1 -1
- package/dist/components/Icon/index.cjs +1 -1
- package/dist/components/Icon/index.js +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 +9 -1
- package/dist/components/Modal/index.d.cts.map +1 -1
- package/dist/components/Modal/index.d.ts +9 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/index.js +37 -45
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/style.css +8 -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 +44 -37
- package/dist/components/Popover/index.js.map +1 -1
- package/dist/components/Popover/style.css +3 -0
- package/dist/components/RichTextEditor/expanded-width.d.cts +4 -0
- package/dist/components/RichTextEditor/expanded-width.d.cts.map +1 -0
- package/dist/components/RichTextEditor/expanded-width.d.ts +4 -0
- package/dist/components/RichTextEditor/expanded-width.d.ts.map +1 -0
- package/dist/components/RichTextEditor/expansion.d.cts +28 -0
- package/dist/components/RichTextEditor/expansion.d.cts.map +1 -0
- package/dist/components/RichTextEditor/expansion.d.ts +28 -0
- package/dist/components/RichTextEditor/expansion.d.ts.map +1 -0
- package/dist/components/RichTextEditor/index.cjs +1 -1
- package/dist/components/RichTextEditor/index.d.cts +4 -4
- package/dist/components/RichTextEditor/index.d.cts.map +1 -1
- package/dist/components/RichTextEditor/index.d.ts +4 -4
- package/dist/components/RichTextEditor/index.d.ts.map +1 -1
- package/dist/components/RichTextEditor/index.js +1 -1
- package/dist/components/RichTextEditor/style.css +85 -4
- package/dist/components/SearchField/index.cjs +1 -1
- package/dist/components/SearchField/index.js +1 -1
- package/dist/components/Select/index.cjs +1 -1
- package/dist/components/Select/index.js +1 -1
- package/dist/components/SideNav/index.cjs +1 -1
- package/dist/components/SideNav/index.js +1 -1
- package/dist/components/SortableList/index.cjs +1 -1
- package/dist/components/SortableList/index.cjs.map +1 -1
- package/dist/components/SortableList/index.d.cts +12 -2
- package/dist/components/SortableList/index.d.cts.map +1 -1
- package/dist/components/SortableList/index.d.ts +12 -2
- package/dist/components/SortableList/index.d.ts.map +1 -1
- package/dist/components/SortableList/index.js +126 -66
- package/dist/components/SortableList/index.js.map +1 -1
- package/dist/components/SortableList/style.css +19 -5
- package/dist/components/Stepper/index.cjs +1 -1
- package/dist/components/Stepper/index.js +1 -1
- package/dist/components/SubNav/index.cjs +1 -1
- package/dist/components/SubNav/index.js +1 -1
- package/dist/components/Table/index.cjs +1 -1
- package/dist/components/Table/index.js +1 -1
- package/dist/components/Toast/index.cjs +1 -1
- package/dist/components/Toast/index.js +1 -1
- package/dist/components/TopNav/index.cjs +1 -1
- package/dist/components/TopNav/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -30
- package/dist/internal/dialogFocus.d.cts +8 -0
- package/dist/internal/dialogFocus.d.cts.map +1 -1
- package/dist/internal/dialogFocus.d.ts +8 -0
- package/dist/internal/dialogFocus.d.ts.map +1 -1
- package/dist/internal/movableHost.d.cts +20 -0
- package/dist/internal/movableHost.d.cts.map +1 -0
- package/dist/internal/movableHost.d.ts +20 -0
- package/dist/internal/movableHost.d.ts.map +1 -0
- package/dist/internal/portalScope.d.cts +23 -0
- package/dist/internal/portalScope.d.cts.map +1 -0
- package/dist/internal/portalScope.d.ts +23 -0
- package/dist/internal/portalScope.d.ts.map +1 -0
- package/dist/internal/useModalDialog.d.cts +22 -0
- package/dist/internal/useModalDialog.d.cts.map +1 -0
- package/dist/internal/useModalDialog.d.ts +22 -0
- package/dist/internal/useModalDialog.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/chunks/FormEditor-CaskinQ1.js.map +0 -1
- package/dist/chunks/FormEditor-DDylpJ9O.cjs +0 -2
- package/dist/chunks/FormEditor-DDylpJ9O.cjs.map +0 -1
- package/dist/chunks/Icon-BBoWP_Y6.cjs +0 -2
- package/dist/chunks/Icon-BBoWP_Y6.cjs.map +0 -1
- package/dist/chunks/Icon-XNismJDm.js +0 -79
- package/dist/chunks/Icon-XNismJDm.js.map +0 -1
- package/dist/chunks/RichTextEditor-C7nMfDmE.cjs +0 -2
- package/dist/chunks/RichTextEditor-C7nMfDmE.cjs.map +0 -1
- package/dist/chunks/RichTextEditor-DjR10XJ-.js +0 -370
- package/dist/chunks/RichTextEditor-DjR10XJ-.js.map +0 -1
- package/dist/chunks/dialogFocus-B9iqKl3I.cjs +0 -2
- package/dist/chunks/dialogFocus-B9iqKl3I.cjs.map +0 -1
- package/dist/chunks/dialogFocus-BFoyeTpA.js +0 -48
- package/dist/chunks/dialogFocus-BFoyeTpA.js.map +0 -1
- package/dist/chunks/dialogStack-6yv3NXFD.js +0 -43
- package/dist/chunks/dialogStack-6yv3NXFD.js.map +0 -1
- package/dist/chunks/dialogStack-C9SLVu6Q.cjs +0 -2
- package/dist/chunks/dialogStack-C9SLVu6Q.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Button/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,oBAAoB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,aAAa,CAAC;AAErB,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACnF,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEnD,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,CAAC;IAC5F,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,oFAAoF;IACpF,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,SAAS,CAAC,EAAE,QAAQ,CAAC;IACrB,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,gGAAgG;IAChG,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,mEAAmE;IACnE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Button/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,oBAAoB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,aAAa,CAAC;AAErB,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACnF,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEnD,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,CAAC;IAC5F,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,oFAAoF;IACpF,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,SAAS,CAAC,EAAE,QAAQ,CAAC;IACrB,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,gGAAgG;IAChG,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,mEAAmE;IACnE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,MAAM,2GA2DjB,CAAC"}
|
|
@@ -1,32 +1,34 @@
|
|
|
1
|
-
import { t as e } from "../../chunks/Icon-
|
|
1
|
+
import { t as e } from "../../chunks/Icon-D1kx7-1c.js";
|
|
2
2
|
import { forwardRef as t } from "react";
|
|
3
3
|
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
4
|
//#region src/components/Button/index.tsx
|
|
5
|
-
var i = t(function({ variant: t = "neutral", size: i = "md", iconStart: a, iconEnd: o, isIconOnly: s = !1, isDisabled: c = !1, isPending: l = !1,
|
|
6
|
-
let
|
|
5
|
+
var i = t(function({ variant: t = "neutral", size: i = "md", iconStart: a, iconEnd: o, isIconOnly: s = !1, isDisabled: c = !1, isPending: l = !1, isFocusableWhenDisabled: u = !1, className: d, children: f, type: p = "button", onClick: m, ...h }, g) {
|
|
6
|
+
let _ = i === "lg" ? 20 : 16, v = c || l, y = v && u;
|
|
7
7
|
return /* @__PURE__ */ r("button", {
|
|
8
|
-
ref:
|
|
9
|
-
type:
|
|
10
|
-
disabled:
|
|
8
|
+
ref: g,
|
|
9
|
+
type: p,
|
|
10
|
+
disabled: v && !u,
|
|
11
|
+
"aria-disabled": y || void 0,
|
|
11
12
|
"data-variant": t,
|
|
12
13
|
"data-size": i,
|
|
13
14
|
"data-icon-only": s || void 0,
|
|
14
15
|
"data-pending": l || void 0,
|
|
15
|
-
className: ["ds-button",
|
|
16
|
-
...
|
|
16
|
+
className: ["ds-button", d].filter(Boolean).join(" "),
|
|
17
|
+
...h,
|
|
18
|
+
onClick: y ? (e) => e.preventDefault() : m,
|
|
17
19
|
children: [
|
|
18
20
|
l ? /* @__PURE__ */ n(e, {
|
|
19
21
|
name: "spinner",
|
|
20
|
-
size:
|
|
22
|
+
size: _,
|
|
21
23
|
className: "ds-button__spinner ds-icon--spin"
|
|
22
24
|
}) : a && /* @__PURE__ */ n(e, {
|
|
23
25
|
name: a,
|
|
24
|
-
size:
|
|
26
|
+
size: _
|
|
25
27
|
}),
|
|
26
|
-
(!s || !a && !l) &&
|
|
28
|
+
(!s || !a && !l) && f,
|
|
27
29
|
o && !s && /* @__PURE__ */ n(e, {
|
|
28
30
|
name: o,
|
|
29
|
-
size:
|
|
31
|
+
size: _
|
|
30
32
|
})
|
|
31
33
|
]
|
|
32
34
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Icon","Button","forwardRef","rest","glyph","size","isDisabled","isPending","variant","isIconOnly","className","iconStart","children","iconEnd"],"sources":["../../../src/components/Button/index.tsx"],"sourcesContent":["import { forwardRef, type ButtonHTMLAttributes, type ReactNode } from \"react\";\nimport { Icon } from \"../Icon\";\nimport type { IconName } from \"../Icon/icons\";\nimport \"./style.css\";\n\nexport type ButtonVariant = \"primary\" | \"neutral\" | \"danger\" | \"active\" | \"simple\";\nexport type ButtonSize = \"xs\" | \"sm\" | \"md\" | \"lg\";\n\nexport interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"disabled\"> {\n variant?: ButtonVariant;\n /** `xs` is for compact actions inside a field or chip, such as clear and remove. */\n size?: ButtonSize;\n iconStart?: IconName;\n iconEnd?: IconName;\n /** Square button. Label with aria-label/aria-labelledby. Children can supply a custom glyph. */\n isIconOnly?: boolean;\n isDisabled?: boolean;\n /** Label stays, spinner replaces `iconStart`, press is blocked. */\n isPending?: boolean;\n children?: ReactNode;\n}\n\n/**\n * Every action the user can take. One primary per view; a sixth variant is a\n * conversation, not a prop.\n */\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n variant = \"neutral\",\n size = \"md\",\n iconStart,\n iconEnd,\n isIconOnly = false,\n isDisabled = false,\n isPending = false,\n className,\n children,\n type = \"button\",\n ...rest\n },\n ref,\n) {\n const glyph = size === \"lg\" ? 20 : 16;\n return (\n <button\n ref={ref}\n type={type}\n disabled={
|
|
1
|
+
{"version":3,"file":"index.js","names":["Icon","Button","forwardRef","rest","glyph","size","isBlocked","isDisabled","isPending","keepsFocus","isFocusableWhenDisabled","variant","isIconOnly","className","event","onClick","iconStart","children","iconEnd"],"sources":["../../../src/components/Button/index.tsx"],"sourcesContent":["import { forwardRef, type ButtonHTMLAttributes, type ReactNode } from \"react\";\nimport { Icon } from \"../Icon\";\nimport type { IconName } from \"../Icon/icons\";\nimport \"./style.css\";\n\nexport type ButtonVariant = \"primary\" | \"neutral\" | \"danger\" | \"active\" | \"simple\";\nexport type ButtonSize = \"xs\" | \"sm\" | \"md\" | \"lg\";\n\nexport interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"disabled\"> {\n variant?: ButtonVariant;\n /** `xs` is for compact actions inside a field or chip, such as clear and remove. */\n size?: ButtonSize;\n iconStart?: IconName;\n iconEnd?: IconName;\n /** Square button. Label with aria-label/aria-labelledby. Children can supply a custom glyph. */\n isIconOnly?: boolean;\n isDisabled?: boolean;\n /** Label stays, spinner replaces `iconStart`, press is blocked. */\n isPending?: boolean;\n /**\n * While `isDisabled` or `isPending` blocks presses, keep the button focusable and\n * mark it `aria-disabled` instead of native `disabled`, so focus is not lost.\n */\n isFocusableWhenDisabled?: boolean;\n children?: ReactNode;\n}\n\n/**\n * Every action the user can take. One primary per view; a sixth variant is a\n * conversation, not a prop.\n */\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n variant = \"neutral\",\n size = \"md\",\n iconStart,\n iconEnd,\n isIconOnly = false,\n isDisabled = false,\n isPending = false,\n isFocusableWhenDisabled = false,\n className,\n children,\n type = \"button\",\n onClick,\n ...rest\n },\n ref,\n) {\n const glyph = size === \"lg\" ? 20 : 16;\n const isBlocked = isDisabled || isPending;\n const keepsFocus = isBlocked && isFocusableWhenDisabled;\n return (\n <button\n ref={ref}\n type={type}\n disabled={isBlocked && !isFocusableWhenDisabled}\n aria-disabled={keepsFocus || undefined}\n data-variant={variant}\n data-size={size}\n data-icon-only={isIconOnly || undefined}\n data-pending={isPending || undefined}\n className={[\"ds-button\", className].filter(Boolean).join(\" \")}\n {...rest}\n // A focusable blocked button still receives clicks; stop them, including form submission.\n onClick={keepsFocus ? (event) => event.preventDefault() : onClick}\n >\n {isPending ? (\n <Icon\n name=\"spinner\"\n size={glyph}\n className=\"ds-button__spinner ds-icon--spin\"\n />\n ) : (\n iconStart && (\n <Icon\n name={iconStart}\n size={glyph}\n />\n )\n )}\n {(!isIconOnly || (!iconStart && !isPending)) && children}\n {iconEnd && !isIconOnly && (\n <Icon\n name={iconEnd}\n size={glyph}\n />\n )}\n </button>\n );\n});\n"],"mappings":";;;;AA+BA,IAAaC,IAASC,EAA2C,SAC/D,EACE,aAAU,WACV,UAAO,MACP,cACA,YACA,gBAAa,IACb,gBAAa,IACb,eAAY,IACZ,6BAA0B,IAC1B,cACA,aACA,UAAO,UACP,YACA,GAAGC,KAEL,GACA;CACA,IAAMC,IAAQC,MAAS,OAAO,KAAK,IAC7BC,IAAYC,KAAcC,GAC1BC,IAAaH,KAAaI;CAChC,OACE,kBAAC,UAAD;EACO;EACC;EACN,UAAUJ,KAAa,CAACI;EACxB,iBAAeD,KAAc,KAAA;EAC7B,gBAAcE;EACd,aAAWN;EACX,kBAAgBO,KAAc,KAAA;EAC9B,gBAAcJ,KAAa,KAAA;EAC3B,WAAW,CAAC,aAAaK,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;EAC5D,GAAIV;EAEJ,SAASM,KAAc,MAAUK,EAAM,eAAe,IAAIC;EAZ5D,UAAA;GAcGP,IACC,kBAACR,GAAD;IACE,MAAK;IACL,MAAMI;IACN,WAAU;GACX,CAAA,IAEDY,KACE,kBAAChB,GAAD;IACE,MAAMgB;IACN,MAAMZ;GACP,CAAA;IAGH,CAACQ,KAAe,CAACI,KAAa,CAACR,MAAeS;GAC/CC,KAAW,CAACN,KACX,kBAACZ,GAAD;IACE,MAAMkB;IACN,MAAMd;GACP,CAAA;EAEG;;AAEZ,CAAC"}
|
|
@@ -50,11 +50,17 @@
|
|
|
50
50
|
color: var(--color-text-on-solid);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
.ds-button:where(:not(.ds-field-skin))[data-variant="primary"]:hover:not(
|
|
53
|
+
.ds-button:where(:not(.ds-field-skin))[data-variant="primary"]:hover:not(
|
|
54
|
+
:disabled,
|
|
55
|
+
[aria-disabled="true"]
|
|
56
|
+
) {
|
|
54
57
|
background: var(--color-primary-hover);
|
|
55
58
|
}
|
|
56
59
|
|
|
57
|
-
.ds-button:where(:not(.ds-field-skin))[data-variant="primary"]:active:not(
|
|
60
|
+
.ds-button:where(:not(.ds-field-skin))[data-variant="primary"]:active:not(
|
|
61
|
+
:disabled,
|
|
62
|
+
[aria-disabled="true"]
|
|
63
|
+
) {
|
|
58
64
|
background: var(--color-primary-pressed);
|
|
59
65
|
}
|
|
60
66
|
|
|
@@ -63,11 +69,17 @@
|
|
|
63
69
|
color: var(--color-text);
|
|
64
70
|
}
|
|
65
71
|
|
|
66
|
-
.ds-button:where(:not(.ds-field-skin))[data-variant="neutral"]:hover:not(
|
|
72
|
+
.ds-button:where(:not(.ds-field-skin))[data-variant="neutral"]:hover:not(
|
|
73
|
+
:disabled,
|
|
74
|
+
[aria-disabled="true"]
|
|
75
|
+
) {
|
|
67
76
|
background: var(--field-hover);
|
|
68
77
|
}
|
|
69
78
|
|
|
70
|
-
.ds-button:where(:not(.ds-field-skin))[data-variant="neutral"]:active:not(
|
|
79
|
+
.ds-button:where(:not(.ds-field-skin))[data-variant="neutral"]:active:not(
|
|
80
|
+
:disabled,
|
|
81
|
+
[aria-disabled="true"]
|
|
82
|
+
) {
|
|
71
83
|
background: var(--field-pressed);
|
|
72
84
|
}
|
|
73
85
|
|
|
@@ -76,11 +88,17 @@
|
|
|
76
88
|
color: var(--color-text-on-solid);
|
|
77
89
|
}
|
|
78
90
|
|
|
79
|
-
.ds-button:where(:not(.ds-field-skin))[data-variant="danger"]:hover:not(
|
|
91
|
+
.ds-button:where(:not(.ds-field-skin))[data-variant="danger"]:hover:not(
|
|
92
|
+
:disabled,
|
|
93
|
+
[aria-disabled="true"]
|
|
94
|
+
) {
|
|
80
95
|
background: var(--color-danger-hover, var(--color-danger));
|
|
81
96
|
}
|
|
82
97
|
|
|
83
|
-
.ds-button:where(:not(.ds-field-skin))[data-variant="danger"]:active:not(
|
|
98
|
+
.ds-button:where(:not(.ds-field-skin))[data-variant="danger"]:active:not(
|
|
99
|
+
:disabled,
|
|
100
|
+
[aria-disabled="true"]
|
|
101
|
+
) {
|
|
84
102
|
background: var(--color-danger-pressed, var(--color-danger));
|
|
85
103
|
}
|
|
86
104
|
|
|
@@ -90,11 +108,17 @@
|
|
|
90
108
|
border-color: var(--color-primary);
|
|
91
109
|
}
|
|
92
110
|
|
|
93
|
-
.ds-button:where(:not(.ds-field-skin))[data-variant="active"]:hover:not(
|
|
111
|
+
.ds-button:where(:not(.ds-field-skin))[data-variant="active"]:hover:not(
|
|
112
|
+
:disabled,
|
|
113
|
+
[aria-disabled="true"]
|
|
114
|
+
) {
|
|
94
115
|
background: var(--color-primary-soft-hover);
|
|
95
116
|
}
|
|
96
117
|
|
|
97
|
-
.ds-button:where(:not(.ds-field-skin))[data-variant="active"]:active:not(
|
|
118
|
+
.ds-button:where(:not(.ds-field-skin))[data-variant="active"]:active:not(
|
|
119
|
+
:disabled,
|
|
120
|
+
[aria-disabled="true"]
|
|
121
|
+
) {
|
|
98
122
|
background: var(--color-primary-soft-pressed);
|
|
99
123
|
}
|
|
100
124
|
|
|
@@ -105,11 +129,17 @@
|
|
|
105
129
|
font-weight: var(--font-weight-regular);
|
|
106
130
|
}
|
|
107
131
|
|
|
108
|
-
.ds-button:where(:not(.ds-field-skin))[data-variant="simple"]:hover:not(
|
|
132
|
+
.ds-button:where(:not(.ds-field-skin))[data-variant="simple"]:hover:not(
|
|
133
|
+
:disabled,
|
|
134
|
+
[aria-disabled="true"]
|
|
135
|
+
) {
|
|
109
136
|
background: var(--field-hover);
|
|
110
137
|
}
|
|
111
138
|
|
|
112
|
-
.ds-button:where(:not(.ds-field-skin))[data-variant="simple"]:active:not(
|
|
139
|
+
.ds-button:where(:not(.ds-field-skin))[data-variant="simple"]:active:not(
|
|
140
|
+
:disabled,
|
|
141
|
+
[aria-disabled="true"]
|
|
142
|
+
) {
|
|
113
143
|
background: var(--field-pressed);
|
|
114
144
|
}
|
|
115
145
|
|
|
@@ -118,7 +148,9 @@
|
|
|
118
148
|
outline-offset: 2px;
|
|
119
149
|
}
|
|
120
150
|
|
|
121
|
-
|
|
151
|
+
/* `aria-disabled` is the focusable disabled state (isFocusableWhenDisabled). */
|
|
152
|
+
.ds-button:disabled,
|
|
153
|
+
.ds-button[aria-disabled="true"] {
|
|
122
154
|
opacity: 0.45;
|
|
123
155
|
cursor: not-allowed;
|
|
124
156
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/ColourField-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/ColourField-BQ4a5tAV.cjs");exports.ColourField=e.t,exports.ColourPanel=e.n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as ColourField, n as ColourPanel } from "../../chunks/ColourField-
|
|
1
|
+
export { t as ColourField, n as ColourPanel } from "../../chunks/ColourField-Doew1hLw.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/DatePicker-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/DatePicker-C0-609Zx.cjs");exports.Calendar=e.t,exports.DateField=e.n,exports.DateRangeField=e.r,exports.formatIsoDate=e.i;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as Calendar, n as DateField, r as DateRangeField, i as formatIsoDate } from "../../chunks/DatePicker-
|
|
1
|
+
export { t as Calendar, n as DateField, r as DateRangeField, i as formatIsoDate } from "../../chunks/DatePicker-DmeWUsOS.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../Button/index.cjs"),t=require("../../chunks/mergeRefs-Bc3qS0Tt.cjs"),n=require("../../chunks/
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../Button/index.cjs"),t=require("../../chunks/mergeRefs-Bc3qS0Tt.cjs"),n=require("../../chunks/useModalDialog-Ctu270Dp.cjs"),r=require("../../chunks/portalScope-BVA1-Ypu.cjs");let i=require("react"),a=require("react-dom"),o=require("react/jsx-runtime");function s(e,t){let[n,r]=(0,i.useState)(e),[a,o]=(0,i.useState)(!1);return n!==e&&(r(e),o(!e)),(0,i.useEffect)(()=>{if(!a||e)return;let n=getComputedStyle(t.current).transitionDuration.split(`,`),r=Math.max(0,...n.map(e=>parseFloat(e)*(e.trim().endsWith(`ms`)?1:1e3)||0)),i=window.setTimeout(()=>o(!1),r);return()=>window.clearTimeout(i)},[a,e,t]),[a,o]}var c=(0,i.forwardRef)(function({isOpen:c,onClose:l,title:u,description:d,side:f=`end`,size:p=`md`,variant:m=`default`,closeLabel:h=`Close`,portalContainer:g,footer:_,className:v,children:y,...b},x){let S=(0,i.useRef)(null),C=(0,i.useRef)(null),w=(0,i.useRef)(null),T=(0,i.useId)(),E=(0,i.useId)(),[D,O]=s(c,C),{onScrimMouseDown:k}=n.t({isOpen:c,panelRef:S,onClose:l,initialFocus:m===`navigation`?()=>w.current:void 0,preventScroll:!0,container:g});return r.n(C,c,{keepDir:b.dir!==void 0}),!c&&!D||typeof document>`u`?null:(0,a.createPortal)((0,o.jsx)(`div`,{ref:e=>{C.current=e,e&&(e.inert=!c)},className:`ds-drawer-scrim`,dir:b.dir,"data-side":f,"data-variant":m,"data-contained":g?``:void 0,"data-state":c?`open`:`closed`,"aria-hidden":!c||void 0,onTransitionEnd:e=>{e.target===e.currentTarget&&e.propertyName===`opacity`&&!c&&O(!1)},onMouseDown:k,children:(0,o.jsxs)(`div`,{...b,ref:t.t(S,x),role:`dialog`,"aria-modal":`true`,"aria-labelledby":b[`aria-label`]?void 0:b[`aria-labelledby`]??T,"aria-describedby":d?E:void 0,tabIndex:-1,"data-side":f,"data-size":p,"data-variant":m,className:[`ds-drawer`,v].filter(Boolean).join(` `),children:[(0,o.jsxs)(`header`,{className:`ds-drawer__head`,children:[(0,o.jsxs)(`div`,{className:`ds-drawer__titles`,children:[(0,o.jsx)(`h2`,{id:T,className:`ds-drawer__title`,children:u}),d&&(0,o.jsx)(`p`,{id:E,className:`ds-drawer__description`,children:d})]}),(0,o.jsx)(e.Button,{ref:w,variant:`simple`,size:m===`navigation`?`lg`:`sm`,isIconOnly:!0,iconStart:`x`,className:m===`navigation`?`ds-drawer__close`:void 0,"aria-label":h,onClick:l})]}),(0,o.jsx)(`div`,{className:`ds-drawer__body`,children:y}),_&&(0,o.jsx)(`footer`,{className:`ds-drawer__footer`,children:_})]})}),g??document.body)});exports.Drawer=c;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["useState","forwardRef","useRef","useId","tabbableControls","openDialog","lockBodyScroll","createPortal","mergeRefs","Button","require_components_Button_index","require_mergeRefs","require_dialogStack","require_dialogFocus","react","react_dom","react_jsx_runtime","useDrawerExit","previousOpen","setPreviousOpen","isOpen","exiting","setExiting","durations","scrimRef","duration","value","timeout","Drawer","rest","panelRef","closeRef","onCloseRef","onClose","titleId","descriptionId","previous","focusOptions","variant","dialog","onKeyDown","event","unlockScroll","portalContainer","node","side","ref","description","size","className","title","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":"A,8UA4CA,SAASiB,EAAc,EAAiB,EAA4C,CAClF,GAAM,CAACC,EAAcC,IAAA,EAAmBnB,EAAAA,SAAAA,CAASoB,CAAM,EACjD,CAACC,EAASC,IAAA,EAActB,EAAAA,SAAAA,CAAS,EAAK,EAuB5C,OArBIkB,IAAiBE,IACnBD,EAAgBC,CAAM,EACtBE,EAAW,CAACF,CAAM,IAGpB,EAAAN,EAAA,UAAA,KAAgB,CACd,GAAI,CAACO,GAAWD,EACd,OAGF,IAAMG,EAAY,iBAAiBC,EAAS,OAAQ,CAAC,CAAC,mBAAmB,MAAM,GAAG,EAC5EC,EAAW,KAAK,IACp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E,EAAAjC,EAAA,KAAA,CAAC,SAAD,CAAQ,UAAU,kBAAlB,SAAA,EACE,EAAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,oBAAf,SAAA,EACE,EAAAA,EAAA,IAAA,CAAC,KAAD,CACE,GAAIkB,EACJ,UAAU,mBAET,SAAAgB,CACC,CAAA,EACHH,IACC,EAAA/B,EAAA,IAAA,CAAC,IAAD,CACE,GAAImB,EACJ,UAAU,yBAET,SAAAY,CACA,CAAA,CAEF,CACL,CAAA,GAAA,EAAA/B,EAAA,IAAA,CAACP,EAAAA,OAAD,CACE,IAAKsB,EACL,QAAQ,SACR,KAAMO,IAAY,aAAe,KAAO,KACxC,WAAA,GACA,UAAU,IACV,UAAWA,IAAY,aAAe,mBAAqB,IAAA,GAC3D,aAAYa,EACZ,YAAenB,EAAW,QAAQ,CACnC,CAAA,CACK,C,IACR,EAAAhB,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,kBAAmB,UAAc,CAAA,EAC/CoC,IAAU,EAAApC,EAAA,IAAA,CAAC,SAAD,CAAQ,UAAU,oBAAqB,SAAAoC,CAAe,CAAA,CAC9D,C,EACF,CAAA,EACLT,GAAmB,SAAS,IAC9B,CACF,CAAC,E"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useState","forwardRef","useRef","useId","useModalDialog","createPortal","mergeRefs","Button","require_components_Button_index","require_mergeRefs","require_useModalDialog","require_portalScope","react","react_dom","react_jsx_runtime","useDrawerExit","previousOpen","setPreviousOpen","isOpen","exiting","setExiting","durations","scrimRef","duration","value","timeout","Drawer","rest","panelRef","closeRef","titleId","descriptionId","variant","portalContainer","node","side","event","onScrimMouseDown","ref","description","size","className","title","closeLabel","onClose","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 { useModalDialog } from \"../../internal/useModalDialog\";\nimport { useInheritedPortalScope } from \"../../internal/portalScope\";\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 titleId = useId();\n const descriptionId = useId();\n const [exiting, setExiting] = useDrawerExit(isOpen, scrimRef);\n const { onScrimMouseDown } = useModalDialog({\n isOpen,\n panelRef,\n onClose,\n initialFocus: variant === \"navigation\" ? () => closeRef.current : undefined,\n // Panels start off-screen; focusing them must not scroll the page with them.\n preventScroll: true,\n container: portalContainer,\n });\n useInheritedPortalScope(scrimRef, isOpen, { keepDir: rest.dir !== undefined });\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={onScrimMouseDown}\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={onClose}\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":"A,iVA2CA,SAASe,EAAc,EAAiB,EAA4C,CAClF,GAAM,CAACC,EAAcC,IAAA,EAAmBjB,EAAAA,SAAAA,CAASkB,CAAM,EACjD,CAACC,EAASC,IAAA,EAAcpB,EAAAA,SAAAA,CAAS,EAAK,EAuB5C,OArBIgB,IAAiBE,IACnBD,EAAgBC,CAAM,EACtBE,EAAW,CAACF,CAAM,IAGpB,EAAAN,EAAA,UAAA,KAAgB,CACd,GAAI,CAACO,GAAWD,EACd,OAGF,IAAMG,EAAY,iBAAiBC,EAAS,OAAQ,CAAC,CAAC,mBAAmB,MAAM,GAAG,EAC5EC,EAAW,KAAK,IACpB,EACA,GAAGF,EAAU,IACV,GAAU,WAAWG,CAAK,GAAKA,EAAM,KAAK,CAAC,CAAC,SAAS,IAAI,EAAI,EAAI,MAAS,CAC7E,CACF,EACMC,EAAU,OAAO,eAAiBL,EAAW,EAAK,EAAGG,CAAQ,EACnE,UAAa,OAAO,aAAaE,CAAO,CAC1C,EAAG,CAACN,EAASD,EAAQI,CAAQ,CAAC,EAEvB,CAACH,EAASC,CAAU,CAC7B,CAQA,IAAaM,GAAA,EAASzB,EAAAA,WAAAA,CAAwC,SAC5D,CACE,SACA,UACA,QACA,cACA,OAAO,MACP,OAAO,KACP,UAAU,UACV,aAAa,QACb,kBACA,SACA,YACA,WACA,GAAG0B,GAEL,EACA,CACA,IAAMC,GAAA,EAAW1B,EAAA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S,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,EAX9D,SAAA,EAaE,EAAA3B,EAAA,KAAA,CAAC,SAAD,CAAQ,UAAU,kBAAlB,SAAA,EACE,EAAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,oBAAf,SAAA,EACE,EAAAA,EAAA,IAAA,CAAC,KAAD,CACE,GAAIgB,EACJ,UAAU,mBAET,SAAAY,CACC,CAAA,EACHH,IACC,EAAAzB,EAAA,IAAA,CAAC,IAAD,CACE,GAAIiB,EACJ,UAAU,yBAET,SAAAQ,CACA,CAAA,CAEF,CACL,CAAA,GAAA,EAAAzB,EAAA,IAAA,CAACP,EAAAA,OAAD,CACE,IAAKsB,EACL,QAAQ,SACR,KAAMG,IAAY,aAAe,KAAO,KACxC,WAAA,GACA,UAAU,IACV,UAAWA,IAAY,aAAe,mBAAqB,IAAA,GAC3D,aAAYW,EACZ,QAASC,CACV,CAAA,CACK,C,IACR,EAAA9B,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,kBAAmB,UAAc,CAAA,EAC/C+B,IAAU,EAAA/B,EAAA,IAAA,CAAC,SAAD,CAAQ,UAAU,oBAAqB,SAAA+B,CAAe,CAAA,CAC9D,C,EACF,CAAA,EACLZ,GAAmB,SAAS,IAC9B,CACF,CAAC,E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/Drawer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,cAAc,EACnB,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/Drawer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,cAAc,EACnB,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AAMf,OAAO,aAAa,CAAC;AAErB,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AACpD,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,MAAM,CAAC;AAEvC,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAChF,MAAM,EAAE,OAAO,CAAC;IAChB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,EAAE,SAAS,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,0FAA0F;IAC1F,OAAO,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC;IACnC,6CAA6C;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,eAAe,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACrC,+DAA+D;IAC/D,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AA8BD;;;;;GAKG;AACH,eAAO,MAAM,MAAM,wGA4GjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Drawer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,cAAc,EACnB,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Drawer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,cAAc,EACnB,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AAMf,OAAO,aAAa,CAAC;AAErB,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AACpD,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,MAAM,CAAC;AAEvC,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAChF,MAAM,EAAE,OAAO,CAAC;IAChB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,EAAE,SAAS,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,0FAA0F;IAC1F,OAAO,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC;IACnC,6CAA6C;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,eAAe,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACrC,+DAA+D;IAC/D,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AA8BD;;;;;GAKG;AACH,eAAO,MAAM,MAAM,wGA4GjB,CAAC"}
|
|
@@ -1,113 +1,97 @@
|
|
|
1
1
|
import { Button as e } from "../Button/index.js";
|
|
2
2
|
import { t } from "../../chunks/mergeRefs-DGM402mE.js";
|
|
3
|
-
import {
|
|
4
|
-
import { n as
|
|
5
|
-
import { forwardRef as
|
|
6
|
-
import { createPortal as
|
|
7
|
-
import { jsx as
|
|
3
|
+
import { t as n } from "../../chunks/useModalDialog-BVaG--b3.js";
|
|
4
|
+
import { n as r } from "../../chunks/portalScope-AzzPM54i.js";
|
|
5
|
+
import { forwardRef as i, useEffect as a, useId as o, useRef as s, useState as c } from "react";
|
|
6
|
+
import { createPortal as l } from "react-dom";
|
|
7
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
8
8
|
//#region src/components/Drawer/index.tsx
|
|
9
|
-
function
|
|
10
|
-
let [n, r] =
|
|
11
|
-
return n !== e && (r(e),
|
|
9
|
+
function f(e, t) {
|
|
10
|
+
let [n, r] = c(e), [i, o] = c(!1);
|
|
11
|
+
return n !== e && (r(e), o(!e)), a(() => {
|
|
12
12
|
if (!i || e) return;
|
|
13
|
-
let n = getComputedStyle(t.current).transitionDuration.split(","), r = Math.max(0, ...n.map((e) => parseFloat(e) * (e.trim().endsWith("ms") ? 1 : 1e3) || 0)),
|
|
14
|
-
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)), a = window.setTimeout(() => o(!1), r);
|
|
14
|
+
return () => window.clearTimeout(a);
|
|
15
15
|
}, [
|
|
16
16
|
i,
|
|
17
17
|
e,
|
|
18
18
|
t
|
|
19
|
-
]), [i,
|
|
19
|
+
]), [i, o];
|
|
20
20
|
}
|
|
21
|
-
var
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (e.key === "Escape") {
|
|
32
|
-
if (e.defaultPrevented) return;
|
|
33
|
-
e.preventDefault(), A.current();
|
|
34
|
-
} else a(e, D.current);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
window.addEventListener("keydown", c);
|
|
38
|
-
let l = n();
|
|
39
|
-
return () => {
|
|
40
|
-
window.removeEventListener("keydown", c), s.close(), l(), e?.focus(t);
|
|
41
|
-
};
|
|
42
|
-
}, [
|
|
43
|
-
o,
|
|
44
|
-
y,
|
|
45
|
-
x
|
|
46
|
-
]), !o && !N || typeof document > "u" ? null : d(/* @__PURE__ */ f("div", {
|
|
21
|
+
var p = i(function({ isOpen: i, onClose: a, title: c, description: p, side: m = "end", size: h = "md", variant: g = "default", closeLabel: _ = "Close", portalContainer: v, footer: y, className: b, children: x, ...S }, C) {
|
|
22
|
+
let w = s(null), T = s(null), E = s(null), D = o(), O = o(), [k, A] = f(i, T), { onScrimMouseDown: j } = n({
|
|
23
|
+
isOpen: i,
|
|
24
|
+
panelRef: w,
|
|
25
|
+
onClose: a,
|
|
26
|
+
initialFocus: g === "navigation" ? () => E.current : void 0,
|
|
27
|
+
preventScroll: !0,
|
|
28
|
+
container: v
|
|
29
|
+
});
|
|
30
|
+
return r(T, i, { keepDir: S.dir !== void 0 }), !i && !k || typeof document > "u" ? null : l(/* @__PURE__ */ u("div", {
|
|
47
31
|
ref: (e) => {
|
|
48
|
-
|
|
32
|
+
T.current = e, e && (e.inert = !i);
|
|
49
33
|
},
|
|
50
34
|
className: "ds-drawer-scrim",
|
|
51
|
-
dir:
|
|
52
|
-
"data-side":
|
|
53
|
-
"data-variant":
|
|
54
|
-
"data-contained":
|
|
55
|
-
"data-state":
|
|
56
|
-
"aria-hidden": !
|
|
35
|
+
dir: S.dir,
|
|
36
|
+
"data-side": m,
|
|
37
|
+
"data-variant": g,
|
|
38
|
+
"data-contained": v ? "" : void 0,
|
|
39
|
+
"data-state": i ? "open" : "closed",
|
|
40
|
+
"aria-hidden": !i || void 0,
|
|
57
41
|
onTransitionEnd: (e) => {
|
|
58
|
-
e.target === e.currentTarget && e.propertyName === "opacity" && !
|
|
42
|
+
e.target === e.currentTarget && e.propertyName === "opacity" && !i && A(!1);
|
|
59
43
|
},
|
|
60
|
-
onMouseDown:
|
|
61
|
-
children: /* @__PURE__ */
|
|
62
|
-
...
|
|
63
|
-
ref: t(
|
|
44
|
+
onMouseDown: j,
|
|
45
|
+
children: /* @__PURE__ */ d("div", {
|
|
46
|
+
...S,
|
|
47
|
+
ref: t(w, C),
|
|
64
48
|
role: "dialog",
|
|
65
49
|
"aria-modal": "true",
|
|
66
|
-
"aria-labelledby":
|
|
67
|
-
"aria-describedby":
|
|
50
|
+
"aria-labelledby": S["aria-label"] ? void 0 : S["aria-labelledby"] ?? D,
|
|
51
|
+
"aria-describedby": p ? O : void 0,
|
|
68
52
|
tabIndex: -1,
|
|
69
|
-
"data-side":
|
|
70
|
-
"data-size":
|
|
71
|
-
"data-variant":
|
|
72
|
-
className: ["ds-drawer",
|
|
53
|
+
"data-side": m,
|
|
54
|
+
"data-size": h,
|
|
55
|
+
"data-variant": g,
|
|
56
|
+
className: ["ds-drawer", b].filter(Boolean).join(" "),
|
|
73
57
|
children: [
|
|
74
|
-
/* @__PURE__ */
|
|
58
|
+
/* @__PURE__ */ d("header", {
|
|
75
59
|
className: "ds-drawer__head",
|
|
76
|
-
children: [/* @__PURE__ */
|
|
60
|
+
children: [/* @__PURE__ */ d("div", {
|
|
77
61
|
className: "ds-drawer__titles",
|
|
78
|
-
children: [/* @__PURE__ */
|
|
79
|
-
id:
|
|
62
|
+
children: [/* @__PURE__ */ u("h2", {
|
|
63
|
+
id: D,
|
|
80
64
|
className: "ds-drawer__title",
|
|
81
|
-
children:
|
|
82
|
-
}),
|
|
83
|
-
id:
|
|
65
|
+
children: c
|
|
66
|
+
}), p && /* @__PURE__ */ u("p", {
|
|
67
|
+
id: O,
|
|
84
68
|
className: "ds-drawer__description",
|
|
85
|
-
children:
|
|
69
|
+
children: p
|
|
86
70
|
})]
|
|
87
|
-
}), /* @__PURE__ */
|
|
88
|
-
ref:
|
|
71
|
+
}), /* @__PURE__ */ u(e, {
|
|
72
|
+
ref: E,
|
|
89
73
|
variant: "simple",
|
|
90
|
-
size:
|
|
74
|
+
size: g === "navigation" ? "lg" : "sm",
|
|
91
75
|
isIconOnly: !0,
|
|
92
76
|
iconStart: "x",
|
|
93
|
-
className:
|
|
94
|
-
"aria-label":
|
|
95
|
-
onClick:
|
|
77
|
+
className: g === "navigation" ? "ds-drawer__close" : void 0,
|
|
78
|
+
"aria-label": _,
|
|
79
|
+
onClick: a
|
|
96
80
|
})]
|
|
97
81
|
}),
|
|
98
|
-
/* @__PURE__ */
|
|
82
|
+
/* @__PURE__ */ u("div", {
|
|
99
83
|
className: "ds-drawer__body",
|
|
100
|
-
children:
|
|
84
|
+
children: x
|
|
101
85
|
}),
|
|
102
|
-
|
|
86
|
+
y && /* @__PURE__ */ u("footer", {
|
|
103
87
|
className: "ds-drawer__footer",
|
|
104
|
-
children:
|
|
88
|
+
children: y
|
|
105
89
|
})
|
|
106
90
|
]
|
|
107
91
|
})
|
|
108
|
-
}),
|
|
92
|
+
}), v ?? document.body);
|
|
109
93
|
});
|
|
110
94
|
//#endregion
|
|
111
|
-
export {
|
|
95
|
+
export { p as Drawer };
|
|
112
96
|
|
|
113
97
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
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,aAC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useInheritedPortalScope","useDrawerExit","previousOpen","setPreviousOpen","useState","isOpen","exiting","setExiting","useEffect","durations","scrimRef","duration","value","timeout","Drawer","forwardRef","rest","panelRef","useRef","closeRef","titleId","useId","descriptionId","variant","portalContainer","createPortal","node","side","event","onScrimMouseDown","mergeRefs","ref","description","size","className","title","Button","closeLabel","onClose","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 { useModalDialog } from \"../../internal/useModalDialog\";\nimport { useInheritedPortalScope } from \"../../internal/portalScope\";\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 titleId = useId();\n const descriptionId = useId();\n const [exiting, setExiting] = useDrawerExit(isOpen, scrimRef);\n const { onScrimMouseDown } = useModalDialog({\n isOpen,\n panelRef,\n onClose,\n initialFocus: variant === \"navigation\" ? () => closeRef.current : undefined,\n // Panels start off-screen; focusing them must not scroll the page with them.\n preventScroll: true,\n container: portalContainer,\n });\n useInheritedPortalScope(scrimRef, isOpen, { keepDir: rest.dir !== undefined });\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={onScrimMouseDown}\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={onClose}\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,SAASE,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,EAA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EAAK,sBAAsBI;GAC9E,oBAAkBY,IAAcV,IAAgB,KAAA;GAChD,UAAU;GACV,aAAWK;GACX,aAAWM;GACX,gBAAcV;GACd,WAAW,CAAC,aAAaW,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,IAAId;OACJ,WAAU;OAET,UAAAe;MACC,CAAA,GACHH,KACC,kBAAC,KAAD;OACE,IAAIV;OACJ,WAAU;OAET,UAAAU;MACA,CAAA,CAEF;KACL,CAAA,GAAA,kBAACI,GAAD;MACE,KAAKjB;MACL,SAAQ;MACR,MAAMI,MAAY,eAAe,OAAO;MACxC,YAAA;MACA,WAAU;MACV,WAAWA,MAAY,eAAe,qBAAqB,KAAA;MAC3D,cAAYc;MACZ,SAASC;KACV,CAAA,CACK;;IACR,kBAAC,OAAD;KAAK,WAAU;KAAmB;IAAc,CAAA;IAC/CC,KAAU,kBAAC,UAAD;KAAQ,WAAU;KAAqB,UAAAA;IAAe,CAAA;GAC9D;;CACF,CAAA,GACLf,KAAmB,SAAS,IAC9B;AACF,CAAC"}
|
|
@@ -31,6 +31,9 @@
|
|
|
31
31
|
flex-direction: column;
|
|
32
32
|
min-block-size: 0;
|
|
33
33
|
background: var(--color-surface);
|
|
34
|
+
|
|
35
|
+
/* Set here, not inherited, so a panel carrying a scoped theme matches it. */
|
|
36
|
+
color: var(--color-text);
|
|
34
37
|
border: var(--frame-width) solid var(--frame-color);
|
|
35
38
|
border-radius: 0;
|
|
36
39
|
box-shadow: var(--shadow-lg);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-D38lQXNe.cjs"),t=require("../Button/index.cjs"),n=require("../../chunks/mergeRefs-Bc3qS0Tt.cjs"),r=require("../../chunks/portalScope-BVA1-Ypu.cjs"),i=require("../Drawer/index.cjs"),a=require("../../chunks/observeElementWidth-BCJM2FAw.cjs"),o=require("../../chunks/movableHost-CajG9_5Z.cjs");let s=require("react"),c=require("react-dom"),l=require("react/jsx-runtime");var u=360,d=600,f=900;function p(e){return e<u?`tight`:e<d?`compact`:e<f?`narrow`:`wide`}var m={clean:`No changes`,dirty:`Unsaved changes`,saving:`Saving…`,saved:`Saved`,error:`Couldn't save`,offline:`Offline · kept in this tab`},h={clean:void 0,dirty:void 0,saving:`spinner`,saved:`check`,error:`alert-triangle`,offline:`clock`};function g({saveState:t,savedAgo:n}){let r=h[t];return(0,l.jsxs)(`div`,{className:`ds-edit-layout__status`,"data-state":t,role:`status`,"aria-live":`polite`,children:[r&&(0,l.jsx)(e.t,{name:r,className:t===`saving`?`ds-icon--spin`:void 0}),t===`dirty`&&(0,l.jsx)(`span`,{className:`ds-edit-layout__dirty`,"aria-hidden":`true`}),(0,l.jsxs)(`span`,{children:[m[t],t===`saved`&&n?(0,l.jsxs)(l.Fragment,{children:[` `,n]}):null]})]})}function _({text:e,bodyRef:n,onKeepEditing:r}){let i=(0,s.useRef)(null),a=(0,s.useRef)(null);return(0,s.useEffect)(()=>{a.current=document.activeElement;let e=requestAnimationFrame(()=>i.current?.focus({preventScroll:!0}));return()=>cancelAnimationFrame(e)},[]),(0,l.jsxs)(`div`,{className:`ds-edit-layout__confirmation`,children:[(0,l.jsx)(`strong`,{children:e}),(0,l.jsx)(t.Button,{ref:i,size:`xs`,onClick:()=>{r?.(),requestAnimationFrame(()=>{(a.current?.isConnected?a.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:s,onLeave:c,detailsToggle:u}){return(0,l.jsxs)(`header`,{className:`ds-edit-layout__bar`,children:[(0,l.jsx)(t.Button,{variant:`simple`,size:`sm`,iconStart:`arrow-left`,isIconOnly:r,"aria-label":`Back to ${e}`,onClick:n,children:e}),o?s:i,(0,l.jsxs)(`div`,{className:`ds-edit-layout__actions`,children:[o?(0,l.jsx)(t.Button,{variant:`danger`,size:`sm`,onClick:c,children:`Leave anyway`}):a,r&&u]})]})}function y({label:e,detailsId:n,expanded:r,opensSheet:i,sheetOpen:a,toggleRef:o,contentRef:s,collapsed:c,onToggle:u}){return(0,l.jsxs)(`aside`,{className:`ds-edit-layout__rail`,"aria-label":e,children:[(0,l.jsxs)(`header`,{className:`ds-edit-layout__rail-head`,children:[r&&(0,l.jsx)(`span`,{children:e}),(0,l.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,l.jsx)(`div`,{id:n,ref:s,className:`ds-edit-layout__rail-content`}):(0,l.jsx)(`div`,{className:`ds-edit-layout__rail-icons`,children:c?c(u):(0,l.jsx)(t.Button,{variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`info`,"aria-label":`Show ${e}`,onClick:u})})]})}var b=(0,s.forwardRef)(function({backLabel:e,onBack:u,saveState:d=`clean`,savedAgo:f,actions:m,rail:h,railCollapsed:b,railLabel:x=`Details`,railOpen:S,defaultRailOpen:ee=!0,onRailToggle:C,confirmLeave:w=!1,confirmText:T=`Leave without saving?`,onKeepEditing:E,onLeave:D,children:O,className:k,onFocus:A,...j},M){let N=(0,s.useRef)(null),P=(0,s.useMemo)(()=>n.t(N,M),[M]),F=(0,s.useRef)(null),I=(0,s.useRef)(null),L=(0,s.useRef)(null),R=(0,s.useRef)(null),z=(0,s.useRef)(null),[B]=(0,s.useState)(()=>o.t(`ds-edit-layout__rail-host`)),[V,H]=(0,s.useState)(`wide`),[U,W]=(0,s.useState)(ee),[G,K]=(0,s.useState)(!1),[q,J]=(0,s.useState)(!1),Y=(0,s.useId)(),X=V===`tight`||V===`compact`,Z=V!==`wide`,Q=!Z&&(S??U);G&&(w||!Z)&&K(!1),(0,s.useLayoutEffect)(()=>{let e;return a.t(N.current,t=>{let n=p(t);n!==e&&(e=n,J(!1),H(n))})},[]),(0,s.useLayoutEffect)(()=>{B&&o.n(B,L.current??R.current,z.current)}),(0,s.useEffect)(()=>{let e=z.current;e&&r.i(e)&&r.i(document.activeElement)&&I.current?.focus({preventScroll:!0})},[V,Q,G]);let $=()=>{Z?K(!0):(J(!0),W(!Q),C?.(!Q))},te=typeof h==`function`?h(()=>(0,c.flushSync)(()=>K(!1))):h;return(0,l.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,l.jsxs)(`div`,{className:`ds-edit-layout__main`,children:[(0,l.jsx)(v,{backLabel:e,onBack:u,compact:X,status:(0,l.jsx)(g,{saveState:d,savedAgo:f}),actions:m,confirmLeave:w,confirmation:(0,l.jsx)(_,{text:T,bodyRef:F,onKeepEditing:E}),onLeave:D,detailsToggle:(0,l.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,l.jsx)(`div`,{ref:F,className:`ds-edit-layout__body`,children:(0,l.jsx)(`div`,{className:`ds-edit-layout__content`,children:O})})]}),!X&&(0,l.jsx)(y,{label:x,detailsId:Y,expanded:Q,opensSheet:Z,sheetOpen:G,toggleRef:I,contentRef:L,collapsed:b,onToggle:$}),(0,l.jsx)(i.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,l.jsx)(`div`,{ref:R,className:`ds-edit-layout__rail-content`})}),B&&(0,c.createPortal)(te,B)]})});exports.EditLayout=b;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|