@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.
Files changed (192) hide show
  1. package/README.md +17 -7
  2. package/UPGRADING.md +217 -0
  3. package/dist/chunks/{Board-BaQ04nWg.cjs → Board-BPA6mVhf.cjs} +2 -2
  4. package/dist/chunks/{Board-BaQ04nWg.cjs.map → Board-BPA6mVhf.cjs.map} +1 -1
  5. package/dist/chunks/{Board-CUhF8pTX.js → Board-CcIF7jS0.js} +2 -2
  6. package/dist/chunks/{Board-CUhF8pTX.js.map → Board-CcIF7jS0.js.map} +1 -1
  7. package/dist/chunks/{ColourField-CJicr3OT.cjs → ColourField-BQ4a5tAV.cjs} +2 -2
  8. package/dist/chunks/{ColourField-CJicr3OT.cjs.map → ColourField-BQ4a5tAV.cjs.map} +1 -1
  9. package/dist/chunks/{ColourField-DjHRiFDU.js → ColourField-Doew1hLw.js} +3 -3
  10. package/dist/chunks/{ColourField-DjHRiFDU.js.map → ColourField-Doew1hLw.js.map} +1 -1
  11. package/dist/chunks/{DatePicker-aSlYLjtW.cjs → DatePicker-C0-609Zx.cjs} +2 -2
  12. package/dist/chunks/{DatePicker-aSlYLjtW.cjs.map → DatePicker-C0-609Zx.cjs.map} +1 -1
  13. package/dist/chunks/{DatePicker-D_6CQpUd.js → DatePicker-DmeWUsOS.js} +2 -2
  14. package/dist/chunks/{DatePicker-D_6CQpUd.js.map → DatePicker-DmeWUsOS.js.map} +1 -1
  15. package/dist/chunks/{FormEditor-CaskinQ1.js → FormEditor-DTnFO4oS.js} +170 -154
  16. package/dist/chunks/FormEditor-DTnFO4oS.js.map +1 -0
  17. package/dist/chunks/FormEditor-DfQLJnsO.cjs +2 -0
  18. package/dist/chunks/FormEditor-DfQLJnsO.cjs.map +1 -0
  19. package/dist/chunks/Icon-D1kx7-1c.js +81 -0
  20. package/dist/chunks/Icon-D1kx7-1c.js.map +1 -0
  21. package/dist/chunks/Icon-D38lQXNe.cjs +2 -0
  22. package/dist/chunks/Icon-D38lQXNe.cjs.map +1 -0
  23. package/dist/chunks/RichTextEditor-DEJ-u-ZR.js +483 -0
  24. package/dist/chunks/RichTextEditor-DEJ-u-ZR.js.map +1 -0
  25. package/dist/chunks/RichTextEditor-Ddk7qaqg.cjs +2 -0
  26. package/dist/chunks/RichTextEditor-Ddk7qaqg.cjs.map +1 -0
  27. package/dist/chunks/movableHost-CajG9_5Z.cjs +2 -0
  28. package/dist/chunks/movableHost-CajG9_5Z.cjs.map +1 -0
  29. package/dist/chunks/movableHost-NJj_FsAu.js +23 -0
  30. package/dist/chunks/movableHost-NJj_FsAu.js.map +1 -0
  31. package/dist/chunks/portalScope-AzzPM54i.js +105 -0
  32. package/dist/chunks/portalScope-AzzPM54i.js.map +1 -0
  33. package/dist/chunks/portalScope-BVA1-Ypu.cjs +2 -0
  34. package/dist/chunks/portalScope-BVA1-Ypu.cjs.map +1 -0
  35. package/dist/chunks/useModalDialog-BVaG--b3.js +87 -0
  36. package/dist/chunks/useModalDialog-BVaG--b3.js.map +1 -0
  37. package/dist/chunks/useModalDialog-Ctu270Dp.cjs +2 -0
  38. package/dist/chunks/useModalDialog-Ctu270Dp.cjs.map +1 -0
  39. package/dist/components/AssetCard/index.cjs +1 -1
  40. package/dist/components/AssetCard/index.js +1 -1
  41. package/dist/components/AssetGrid/index.cjs +1 -1
  42. package/dist/components/AssetGrid/index.js +1 -1
  43. package/dist/components/Board/index.cjs +1 -1
  44. package/dist/components/Board/index.js +1 -1
  45. package/dist/components/Button/index.cjs +1 -1
  46. package/dist/components/Button/index.cjs.map +1 -1
  47. package/dist/components/Button/index.d.cts +5 -0
  48. package/dist/components/Button/index.d.cts.map +1 -1
  49. package/dist/components/Button/index.d.ts +5 -0
  50. package/dist/components/Button/index.d.ts.map +1 -1
  51. package/dist/components/Button/index.js +14 -12
  52. package/dist/components/Button/index.js.map +1 -1
  53. package/dist/components/Button/style.css +43 -11
  54. package/dist/components/ColourField/index.cjs +1 -1
  55. package/dist/components/ColourField/index.js +1 -1
  56. package/dist/components/DatePicker/index.cjs +1 -1
  57. package/dist/components/DatePicker/index.js +1 -1
  58. package/dist/components/Drawer/index.cjs +1 -1
  59. package/dist/components/Drawer/index.cjs.map +1 -1
  60. package/dist/components/Drawer/index.d.cts.map +1 -1
  61. package/dist/components/Drawer/index.d.ts.map +1 -1
  62. package/dist/components/Drawer/index.js +59 -75
  63. package/dist/components/Drawer/index.js.map +1 -1
  64. package/dist/components/Drawer/style.css +3 -0
  65. package/dist/components/EditLayout/index.cjs +1 -1
  66. package/dist/components/EditLayout/index.cjs.map +1 -1
  67. package/dist/components/EditLayout/index.d.cts.map +1 -1
  68. package/dist/components/EditLayout/index.d.ts.map +1 -1
  69. package/dist/components/EditLayout/index.js +107 -121
  70. package/dist/components/EditLayout/index.js.map +1 -1
  71. package/dist/components/EntryPicker/index.cjs +1 -1
  72. package/dist/components/EntryPicker/index.cjs.map +1 -1
  73. package/dist/components/EntryPicker/index.d.cts.map +1 -1
  74. package/dist/components/EntryPicker/index.d.ts.map +1 -1
  75. package/dist/components/EntryPicker/index.js +3 -9
  76. package/dist/components/EntryPicker/index.js.map +1 -1
  77. package/dist/components/FormEditor/README.md +79 -3
  78. package/dist/components/FormEditor/control.d.cts.map +1 -1
  79. package/dist/components/FormEditor/control.d.ts.map +1 -1
  80. package/dist/components/FormEditor/index.cjs +1 -1
  81. package/dist/components/FormEditor/index.d.cts.map +1 -1
  82. package/dist/components/FormEditor/index.d.ts.map +1 -1
  83. package/dist/components/FormEditor/index.js +2 -1
  84. package/dist/components/FormEditor/model.d.cts +6 -0
  85. package/dist/components/FormEditor/model.d.cts.map +1 -1
  86. package/dist/components/FormEditor/model.d.ts +6 -0
  87. package/dist/components/FormEditor/model.d.ts.map +1 -1
  88. package/dist/components/FormEditor/style.css +7 -0
  89. package/dist/components/Icon/icons.d.cts +2 -0
  90. package/dist/components/Icon/icons.d.cts.map +1 -1
  91. package/dist/components/Icon/icons.d.ts +2 -0
  92. package/dist/components/Icon/icons.d.ts.map +1 -1
  93. package/dist/components/Icon/index.cjs +1 -1
  94. package/dist/components/Icon/index.js +1 -1
  95. package/dist/components/Modal/index.cjs +1 -1
  96. package/dist/components/Modal/index.cjs.map +1 -1
  97. package/dist/components/Modal/index.d.cts +9 -1
  98. package/dist/components/Modal/index.d.cts.map +1 -1
  99. package/dist/components/Modal/index.d.ts +9 -1
  100. package/dist/components/Modal/index.d.ts.map +1 -1
  101. package/dist/components/Modal/index.js +37 -45
  102. package/dist/components/Modal/index.js.map +1 -1
  103. package/dist/components/Modal/style.css +8 -1
  104. package/dist/components/Popover/index.cjs +1 -1
  105. package/dist/components/Popover/index.cjs.map +1 -1
  106. package/dist/components/Popover/index.d.cts.map +1 -1
  107. package/dist/components/Popover/index.d.ts.map +1 -1
  108. package/dist/components/Popover/index.js +44 -37
  109. package/dist/components/Popover/index.js.map +1 -1
  110. package/dist/components/Popover/style.css +3 -0
  111. package/dist/components/RichTextEditor/expanded-width.d.cts +4 -0
  112. package/dist/components/RichTextEditor/expanded-width.d.cts.map +1 -0
  113. package/dist/components/RichTextEditor/expanded-width.d.ts +4 -0
  114. package/dist/components/RichTextEditor/expanded-width.d.ts.map +1 -0
  115. package/dist/components/RichTextEditor/expansion.d.cts +28 -0
  116. package/dist/components/RichTextEditor/expansion.d.cts.map +1 -0
  117. package/dist/components/RichTextEditor/expansion.d.ts +28 -0
  118. package/dist/components/RichTextEditor/expansion.d.ts.map +1 -0
  119. package/dist/components/RichTextEditor/index.cjs +1 -1
  120. package/dist/components/RichTextEditor/index.d.cts +4 -4
  121. package/dist/components/RichTextEditor/index.d.cts.map +1 -1
  122. package/dist/components/RichTextEditor/index.d.ts +4 -4
  123. package/dist/components/RichTextEditor/index.d.ts.map +1 -1
  124. package/dist/components/RichTextEditor/index.js +1 -1
  125. package/dist/components/RichTextEditor/style.css +85 -4
  126. package/dist/components/SearchField/index.cjs +1 -1
  127. package/dist/components/SearchField/index.js +1 -1
  128. package/dist/components/Select/index.cjs +1 -1
  129. package/dist/components/Select/index.js +1 -1
  130. package/dist/components/SideNav/index.cjs +1 -1
  131. package/dist/components/SideNav/index.js +1 -1
  132. package/dist/components/SortableList/index.cjs +1 -1
  133. package/dist/components/SortableList/index.cjs.map +1 -1
  134. package/dist/components/SortableList/index.d.cts +12 -2
  135. package/dist/components/SortableList/index.d.cts.map +1 -1
  136. package/dist/components/SortableList/index.d.ts +12 -2
  137. package/dist/components/SortableList/index.d.ts.map +1 -1
  138. package/dist/components/SortableList/index.js +126 -66
  139. package/dist/components/SortableList/index.js.map +1 -1
  140. package/dist/components/SortableList/style.css +19 -5
  141. package/dist/components/Stepper/index.cjs +1 -1
  142. package/dist/components/Stepper/index.js +1 -1
  143. package/dist/components/SubNav/index.cjs +1 -1
  144. package/dist/components/SubNav/index.js +1 -1
  145. package/dist/components/Table/index.cjs +1 -1
  146. package/dist/components/Table/index.js +1 -1
  147. package/dist/components/Toast/index.cjs +1 -1
  148. package/dist/components/Toast/index.js +1 -1
  149. package/dist/components/TopNav/index.cjs +1 -1
  150. package/dist/components/TopNav/index.js +1 -1
  151. package/dist/index.cjs +1 -1
  152. package/dist/index.d.cts +1 -1
  153. package/dist/index.d.cts.map +1 -1
  154. package/dist/index.d.ts +1 -1
  155. package/dist/index.d.ts.map +1 -1
  156. package/dist/index.js +30 -30
  157. package/dist/internal/dialogFocus.d.cts +8 -0
  158. package/dist/internal/dialogFocus.d.cts.map +1 -1
  159. package/dist/internal/dialogFocus.d.ts +8 -0
  160. package/dist/internal/dialogFocus.d.ts.map +1 -1
  161. package/dist/internal/movableHost.d.cts +20 -0
  162. package/dist/internal/movableHost.d.cts.map +1 -0
  163. package/dist/internal/movableHost.d.ts +20 -0
  164. package/dist/internal/movableHost.d.ts.map +1 -0
  165. package/dist/internal/portalScope.d.cts +23 -0
  166. package/dist/internal/portalScope.d.cts.map +1 -0
  167. package/dist/internal/portalScope.d.ts +23 -0
  168. package/dist/internal/portalScope.d.ts.map +1 -0
  169. package/dist/internal/useModalDialog.d.cts +22 -0
  170. package/dist/internal/useModalDialog.d.cts.map +1 -0
  171. package/dist/internal/useModalDialog.d.ts +22 -0
  172. package/dist/internal/useModalDialog.d.ts.map +1 -0
  173. package/package.json +1 -1
  174. package/dist/chunks/FormEditor-CaskinQ1.js.map +0 -1
  175. package/dist/chunks/FormEditor-DDylpJ9O.cjs +0 -2
  176. package/dist/chunks/FormEditor-DDylpJ9O.cjs.map +0 -1
  177. package/dist/chunks/Icon-BBoWP_Y6.cjs +0 -2
  178. package/dist/chunks/Icon-BBoWP_Y6.cjs.map +0 -1
  179. package/dist/chunks/Icon-XNismJDm.js +0 -79
  180. package/dist/chunks/Icon-XNismJDm.js.map +0 -1
  181. package/dist/chunks/RichTextEditor-C7nMfDmE.cjs +0 -2
  182. package/dist/chunks/RichTextEditor-C7nMfDmE.cjs.map +0 -1
  183. package/dist/chunks/RichTextEditor-DjR10XJ-.js +0 -370
  184. package/dist/chunks/RichTextEditor-DjR10XJ-.js.map +0 -1
  185. package/dist/chunks/dialogFocus-B9iqKl3I.cjs +0 -2
  186. package/dist/chunks/dialogFocus-B9iqKl3I.cjs.map +0 -1
  187. package/dist/chunks/dialogFocus-BFoyeTpA.js +0 -48
  188. package/dist/chunks/dialogFocus-BFoyeTpA.js.map +0 -1
  189. package/dist/chunks/dialogStack-6yv3NXFD.js +0 -43
  190. package/dist/chunks/dialogStack-6yv3NXFD.js.map +0 -1
  191. package/dist/chunks/dialogStack-C9SLVu6Q.cjs +0 -2
  192. 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;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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-XNismJDm.js";
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, className: u, children: d, type: f = "button", ...p }, m) {
6
- let h = i === "lg" ? 20 : 16;
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: m,
9
- type: f,
10
- disabled: c || l,
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", u].filter(Boolean).join(" "),
16
- ...p,
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: h,
22
+ size: _,
21
23
  className: "ds-button__spinner ds-icon--spin"
22
24
  }) : a && /* @__PURE__ */ n(e, {
23
25
  name: a,
24
- size: h
26
+ size: _
25
27
  }),
26
- (!s || !a && !l) && d,
28
+ (!s || !a && !l) && f,
27
29
  o && !s && /* @__PURE__ */ n(e, {
28
30
  name: o,
29
- size: h
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={isDisabled || isPending}\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 >\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":";;;;AA0BA,IAAaC,IAASC,EAA2C,SAC/D,EACE,aAAU,WACV,UAAO,MACP,cACA,YACA,gBAAa,IACb,gBAAa,IACb,eAAY,IACZ,cACA,aACA,UAAO,UACP,GAAGC,KAEL,GACA;CACA,IAAMC,IAAQC,MAAS,OAAO,KAAK;CACnC,OACE,kBAAC,UAAD;EACO;EACC;EACN,UAAUC,KAAcC;EACxB,gBAAcC;EACd,aAAWH;EACX,kBAAgBI,KAAc,KAAA;EAC9B,gBAAcF,KAAa,KAAA;EAC3B,WAAW,CAAC,aAAaG,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;EAC5D,GAAIP;EATN,UAAA;GAWGI,IACC,kBAACP,GAAD;IACE,MAAK;IACL,MAAMI;IACN,WAAU;GACX,CAAA,IAEDO,KACE,kBAACX,GAAD;IACE,MAAMW;IACN,MAAMP;GACP,CAAA;IAGH,CAACK,KAAe,CAACE,KAAa,CAACJ,MAAeK;GAC/CC,KAAW,CAACJ,KACX,kBAACT,GAAD;IACE,MAAMa;IACN,MAAMT;GACP,CAAA;EAEG;;AAEZ,CAAC"}
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(:disabled) {
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(:disabled) {
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(:disabled) {
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(:disabled) {
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(:disabled) {
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(:disabled) {
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(:disabled) {
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(:disabled) {
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(:disabled) {
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(:disabled) {
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
- .ds-button:disabled {
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-CJicr3OT.cjs");exports.ColourField=e.t,exports.ColourPanel=e.n;
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-DjHRiFDU.js";
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-aSlYLjtW.cjs");exports.Calendar=e.t,exports.DateField=e.n,exports.DateRangeField=e.r,exports.formatIsoDate=e.i;
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-D_6CQpUd.js";
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/dialogStack-C9SLVu6Q.cjs"),r=require("../../chunks/dialogFocus-B9iqKl3I.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.useRef)(l),E=(0,i.useId)(),D=(0,i.useId)(),[O,k]=s(c,C);return(0,i.useEffect)(()=>{T.current=l},[l]),(0,i.useEffect)(()=>{if(!c)return;let e=document.activeElement,t={preventScroll:!0};((m===`navigation`?w.current:S.current&&r.n(S.current)[0])??S.current)?.focus(t);let i=n.t(),a=e=>{if(i.isTopmost()){if(e.key===`Escape`){if(e.defaultPrevented)return;e.preventDefault(),T.current()}else r.r(e,S.current)}};window.addEventListener(`keydown`,a);let o=n.n();return()=>{window.removeEventListener(`keydown`,a),i.close(),o(),e?.focus(t)}},[c,m,g]),!c&&!O||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&&k(!1)},onMouseDown:e=>c&&e.target===e.currentTarget&&T.current(),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`]??E,"aria-describedby":d?D: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:E,className:`ds-drawer__title`,children:u}),d&&(0,o.jsx)(`p`,{id:D,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:()=>T.current()})]}),(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;
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,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SAAA,EAaE,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,EA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":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 { n, t as r } from "../../chunks/dialogStack-6yv3NXFD.js";
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";
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 m(e, t) {
10
- let [n, r] = u(e), [i, a] = u(!1);
11
- return n !== e && (r(e), a(!e)), s(() => {
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)), o = window.setTimeout(() => a(!1), r);
14
- return () => window.clearTimeout(o);
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, a];
19
+ ]), [i, o];
20
20
  }
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);
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
- O.current = e, e && (e.inert = !o);
32
+ T.current = e, e && (e.inert = !i);
49
33
  },
50
34
  className: "ds-drawer-scrim",
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,
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" && !o && P(!1);
42
+ e.target === e.currentTarget && e.propertyName === "opacity" && !i && A(!1);
59
43
  },
60
- onMouseDown: (e) => o && e.target === e.currentTarget && A.current(),
61
- children: /* @__PURE__ */ p("div", {
62
- ...T,
63
- ref: t(D, E),
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": T["aria-label"] ? void 0 : T["aria-labelledby"] ?? j,
67
- "aria-describedby": g ? M : void 0,
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": v,
71
- "data-variant": y,
72
- className: ["ds-drawer", C].filter(Boolean).join(" "),
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__ */ p("header", {
58
+ /* @__PURE__ */ d("header", {
75
59
  className: "ds-drawer__head",
76
- children: [/* @__PURE__ */ p("div", {
60
+ children: [/* @__PURE__ */ d("div", {
77
61
  className: "ds-drawer__titles",
78
- children: [/* @__PURE__ */ f("h2", {
79
- id: j,
62
+ children: [/* @__PURE__ */ u("h2", {
63
+ id: D,
80
64
  className: "ds-drawer__title",
81
- children: h
82
- }), g && /* @__PURE__ */ f("p", {
83
- id: M,
65
+ children: c
66
+ }), p && /* @__PURE__ */ u("p", {
67
+ id: O,
84
68
  className: "ds-drawer__description",
85
- children: g
69
+ children: p
86
70
  })]
87
- }), /* @__PURE__ */ f(e, {
88
- ref: k,
71
+ }), /* @__PURE__ */ u(e, {
72
+ ref: E,
89
73
  variant: "simple",
90
- size: y === "navigation" ? "lg" : "sm",
74
+ size: g === "navigation" ? "lg" : "sm",
91
75
  isIconOnly: !0,
92
76
  iconStart: "x",
93
- className: y === "navigation" ? "ds-drawer__close" : void 0,
94
- "aria-label": b,
95
- onClick: () => A.current()
77
+ className: g === "navigation" ? "ds-drawer__close" : void 0,
78
+ "aria-label": _,
79
+ onClick: a
96
80
  })]
97
81
  }),
98
- /* @__PURE__ */ f("div", {
82
+ /* @__PURE__ */ u("div", {
99
83
  className: "ds-drawer__body",
100
- children: w
84
+ children: x
101
85
  }),
102
- S && /* @__PURE__ */ f("footer", {
86
+ y && /* @__PURE__ */ u("footer", {
103
87
  className: "ds-drawer__footer",
104
- children: S
88
+ children: y
105
89
  })
106
90
  ]
107
91
  })
108
- }), x ?? document.body);
92
+ }), v ?? document.body);
109
93
  });
110
94
  //#endregion
111
- export { h as Drawer };
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,aACA,GAAGC,KAEL,GACA;CACA,IAAMC,IAAWC,EAA8B,IAAI,GAC7CR,IAAWQ,EAA8B,IAAI,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,EAAM,WAAWA,EAAM,iBAAiBA,EAAM,iBAAiB,aAAa,CAACzB,KAC/EE,EAAW,EAAK;EAEpB;EACA,cAAc,MACZF,KAAUyB,EAAM,WAAWA,EAAM,iBAAiBV,EAAW,QAAQ;EAGvE,UAAA,kBAAC,OAAD;GACE,GAAIJ;GACJ,KAAKqB,EAAUpB,GAAUqB,CAAG;GAC5B,MAAK;GACL,cAAW;GACX,mBAAiBtB,EAAK,gBAAgB,KAAA,IAAaA,EAAK,sBAAsBM;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
+ {"version":3,"file":"index.js","names":["useModalDialog","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,EAAW,EAAK,GAAGI,CAAQ;EACnE,aAAa,OAAO,aAAaE,CAAO;CAC1C,GAAG;EAACP;EAASD;EAAQK;CAA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ACX,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-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;
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