@protonradio/proton-ui 0.11.18-beta.6 → 0.11.18-beta.8

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 (45) hide show
  1. package/dist/components/Input/CopyInput/CopyInput.cjs.js +1 -1
  2. package/dist/components/Input/CopyInput/CopyInput.cjs.js.map +1 -1
  3. package/dist/components/Input/CopyInput/CopyInput.es.js +3 -1
  4. package/dist/components/Input/CopyInput/CopyInput.es.js.map +1 -1
  5. package/dist/components/Modal/Modal.cjs.js +1 -1
  6. package/dist/components/Modal/Modal.cjs.js.map +1 -1
  7. package/dist/components/Modal/Modal.es.js +59 -79
  8. package/dist/components/Modal/Modal.es.js.map +1 -1
  9. package/dist/node_modules/@react-aria/focus/dist/FocusScope.cjs.js +1 -1
  10. package/dist/node_modules/@react-aria/focus/dist/FocusScope.cjs.js.map +1 -1
  11. package/dist/node_modules/@react-aria/focus/dist/FocusScope.es.js +50 -399
  12. package/dist/node_modules/@react-aria/focus/dist/FocusScope.es.js.map +1 -1
  13. package/dist/utils/copy.cjs.js +1 -1
  14. package/dist/utils/copy.cjs.js.map +1 -1
  15. package/dist/utils/copy.es.js +18 -27
  16. package/dist/utils/copy.es.js.map +1 -1
  17. package/package.json +1 -1
  18. package/dist/node_modules/@react-aria/button/dist/useButton.cjs.js +0 -2
  19. package/dist/node_modules/@react-aria/button/dist/useButton.cjs.js.map +0 -1
  20. package/dist/node_modules/@react-aria/button/dist/useButton.es.js +0 -55
  21. package/dist/node_modules/@react-aria/button/dist/useButton.es.js.map +0 -1
  22. package/dist/node_modules/@react-aria/interactions/dist/useInteractOutside.cjs.js +0 -2
  23. package/dist/node_modules/@react-aria/interactions/dist/useInteractOutside.cjs.js.map +0 -1
  24. package/dist/node_modules/@react-aria/interactions/dist/useInteractOutside.es.js +0 -51
  25. package/dist/node_modules/@react-aria/interactions/dist/useInteractOutside.es.js.map +0 -1
  26. package/dist/node_modules/@react-aria/overlays/dist/ariaHideOutside.cjs.js +0 -2
  27. package/dist/node_modules/@react-aria/overlays/dist/ariaHideOutside.cjs.js.map +0 -1
  28. package/dist/node_modules/@react-aria/overlays/dist/ariaHideOutside.es.js +0 -70
  29. package/dist/node_modules/@react-aria/overlays/dist/ariaHideOutside.es.js.map +0 -1
  30. package/dist/node_modules/@react-aria/overlays/dist/useModalOverlay.cjs.js +0 -2
  31. package/dist/node_modules/@react-aria/overlays/dist/useModalOverlay.cjs.js.map +0 -1
  32. package/dist/node_modules/@react-aria/overlays/dist/useModalOverlay.es.js +0 -32
  33. package/dist/node_modules/@react-aria/overlays/dist/useModalOverlay.es.js.map +0 -1
  34. package/dist/node_modules/@react-aria/overlays/dist/useOverlay.cjs.js +0 -2
  35. package/dist/node_modules/@react-aria/overlays/dist/useOverlay.cjs.js.map +0 -1
  36. package/dist/node_modules/@react-aria/overlays/dist/useOverlay.es.js +0 -53
  37. package/dist/node_modules/@react-aria/overlays/dist/useOverlay.es.js.map +0 -1
  38. package/dist/node_modules/@react-aria/overlays/dist/usePreventScroll.cjs.js +0 -2
  39. package/dist/node_modules/@react-aria/overlays/dist/usePreventScroll.cjs.js.map +0 -1
  40. package/dist/node_modules/@react-aria/overlays/dist/usePreventScroll.es.js +0 -100
  41. package/dist/node_modules/@react-aria/overlays/dist/usePreventScroll.es.js.map +0 -1
  42. package/dist/node_modules/@react-stately/overlays/dist/useOverlayTriggerState.cjs.js +0 -2
  43. package/dist/node_modules/@react-stately/overlays/dist/useOverlayTriggerState.cjs.js.map +0 -1
  44. package/dist/node_modules/@react-stately/overlays/dist/useOverlayTriggerState.es.js +0 -30
  45. package/dist/node_modules/@react-stately/overlays/dist/useOverlayTriggerState.es.js.map +0 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../../node_modules/react/jsx-runtime.cjs.js"),x=require("react"),a=require("../../../utils/copy.cjs.js"),c=require("../BaseInput/Input.cjs.js");;/* empty css */const r=require("../../../utils/string.cjs.js");function l({name:o,value:e,isDisabled:p,onError:u,onSuccess:n}){const[i,s]=x.useState(!1);return t.jsxRuntimeExports.jsx(c.Input,{name:o,value:e,isDisabled:p,suffix:t.jsxRuntimeExports.jsx(j,{isCopied:i,onClick:async()=>{await a.copyTextToClipboard(e,u)&&(s(!0),n==null||n(),setTimeout(()=>s(!1),5e3))}})})}const j=({isCopied:o,onClick:e})=>t.jsxRuntimeExports.jsx("div",{className:"proton-CopyInput-button-container",onClick:e,children:t.jsxRuntimeExports.jsxs("button",{"data-testid":"COPY_BUTTON",className:r.csx("proton-CopyInput-button",o&&"proton-CopyInput-button--copied"),children:[t.jsxRuntimeExports.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 512 512",children:[t.jsxRuntimeExports.jsx("path",{fill:"currentColor",d:"M408 480H184a72 72 0 0 1-72-72V184a72 72 0 0 1 72-72h224a72 72 0 0 1 72 72v224a72 72 0 0 1-72 72"}),t.jsxRuntimeExports.jsx("path",{fill:"currentColor",d:"M160 80h235.88A72.12 72.12 0 0 0 328 32H104a72 72 0 0 0-72 72v224a72.12 72.12 0 0 0 48 67.88V160a80 80 0 0 1 80-80"})]}),t.jsxRuntimeExports.jsx("span",{className:r.csx("proton-CopyInput-button-text",o&&"proton-CopyInput-button-text--copied"),children:o?"Copied!":"Copy"})]})});exports.CopyInput=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../../node_modules/react/jsx-runtime.cjs.js"),x=require("react"),a=require("../../../utils/copy.cjs.js"),c=require("../BaseInput/Input.cjs.js");;/* empty css */const r=require("../../../utils/string.cjs.js");function l({name:o,value:e,isDisabled:p,onError:u,onSuccess:n}){const[i,s]=x.useState(!1);return t.jsxRuntimeExports.jsx(c.Input,{name:o,value:e,isDisabled:p,suffix:t.jsxRuntimeExports.jsx(j,{isCopied:i,onClick:async()=>{await a.copyTextToClipboard(e,u)&&(s(!0),n==null||n(),setTimeout(()=>s(!1),5e3))}})})}const j=({isCopied:o,onClick:e})=>t.jsxRuntimeExports.jsx("div",{className:"proton-CopyInput-button-container",children:t.jsxRuntimeExports.jsxs("button",{"data-testid":"COPY_BUTTON",className:r.csx("proton-CopyInput-button",o&&"proton-CopyInput-button--copied"),onClick:e,type:"button",children:[t.jsxRuntimeExports.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 512 512",children:[t.jsxRuntimeExports.jsx("path",{fill:"currentColor",d:"M408 480H184a72 72 0 0 1-72-72V184a72 72 0 0 1 72-72h224a72 72 0 0 1 72 72v224a72 72 0 0 1-72 72"}),t.jsxRuntimeExports.jsx("path",{fill:"currentColor",d:"M160 80h235.88A72.12 72.12 0 0 0 328 32H104a72 72 0 0 0-72 72v224a72.12 72.12 0 0 0 48 67.88V160a80 80 0 0 1 80-80"})]}),t.jsxRuntimeExports.jsx("span",{className:r.csx("proton-CopyInput-button-text",o&&"proton-CopyInput-button-text--copied"),children:o?"Copied!":"Copy"})]})});exports.CopyInput=l;
2
2
  //# sourceMappingURL=CopyInput.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CopyInput.cjs.js","sources":["../../../../src/components/Input/CopyInput/CopyInput.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { csx } from \"../../../utils\";\nimport { copyTextToClipboard } from \"../../../utils/copy\";\nimport { Input } from \"../BaseInput/Input\";\nimport \"./CopyInput.css\";\n\nexport interface CopyInputProps {\n /** The name of the input field */\n name: string;\n\n /** The value to display in the input and copy to clipboard */\n value: string;\n\n /** Whether the input is disabled */\n isDisabled?: boolean;\n\n /** Optional callback when copy fails, receives the error object */\n onError?: (error: Error) => void;\n\n /** Optional callback when copy succeeds */\n onSuccess?: () => void;\n}\n\n/**\n * Input with a button to copy value to the clipboard.\n *\n * API:\n * - {@link CopyInputProps}\n */\nexport function CopyInput({\n name,\n value,\n isDisabled,\n onError,\n onSuccess,\n}: CopyInputProps) {\n const [isCopied, setCopied] = useState(false);\n\n return (\n <Input\n name={name}\n value={value}\n isDisabled={isDisabled}\n suffix={\n <CopyButton\n isCopied={isCopied}\n onClick={async () => {\n const copySuccess = await copyTextToClipboard(value, onError);\n if (!copySuccess) return;\n\n setCopied(true);\n onSuccess?.();\n setTimeout(() => setCopied(false), 5000);\n }}\n />\n }\n />\n );\n}\n\nconst CopyButton = ({ isCopied, onClick }) => {\n return (\n <div className=\"proton-CopyInput-button-container\" onClick={onClick}>\n <button\n data-testid=\"COPY_BUTTON\"\n className={csx(\n \"proton-CopyInput-button\",\n isCopied && \"proton-CopyInput-button--copied\"\n )}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 512 512\"\n >\n <path\n fill=\"currentColor\"\n d=\"M408 480H184a72 72 0 0 1-72-72V184a72 72 0 0 1 72-72h224a72 72 0 0 1 72 72v224a72 72 0 0 1-72 72\"\n />\n <path\n fill=\"currentColor\"\n d=\"M160 80h235.88A72.12 72.12 0 0 0 328 32H104a72 72 0 0 0-72 72v224a72.12 72.12 0 0 0 48 67.88V160a80 80 0 0 1 80-80\"\n />\n </svg>\n <span\n className={csx(\n \"proton-CopyInput-button-text\",\n isCopied && \"proton-CopyInput-button-text--copied\"\n )}\n >\n {isCopied ? \"Copied!\" : \"Copy\"}\n </span>\n </button>\n </div>\n );\n};\n"],"names":["CopyInput","name","value","isDisabled","onError","onSuccess","isCopied","setCopied","useState","jsx","Input","CopyButton","copyTextToClipboard","onClick","jsxs","csx"],"mappings":"sUA6BO,SAASA,EAAU,CACxB,KAAAC,EACA,MAAAC,EACA,WAAAC,EACA,QAAAC,EACA,UAAAC,CACF,EAAmB,CACjB,KAAM,CAACC,EAAUC,CAAS,EAAIC,WAAS,EAAK,EAG1C,OAAAC,EAAA,kBAAA,IAACC,EAAA,MAAA,CACC,KAAAT,EACA,MAAAC,EACA,WAAAC,EACA,OACEM,EAAA,kBAAA,IAACE,EAAA,CACC,SAAAL,EACA,QAAS,SAAY,CACC,MAAMM,EAAAA,oBAAoBV,EAAOE,CAAO,IAG5DG,EAAU,EAAI,EACFF,GAAA,MAAAA,IACZ,WAAW,IAAME,EAAU,EAAK,EAAG,GAAI,EACzC,CAAA,CACF,CAAA,CAAA,CAIR,CAEA,MAAMI,EAAa,CAAC,CAAE,SAAAL,EAAU,QAAAO,KAE3BJ,EAAAA,kBAAAA,IAAA,MAAA,CAAI,UAAU,oCAAoC,QAAAI,EACjD,SAAAC,EAAA,kBAAA,KAAC,SAAA,CACC,cAAY,cACZ,UAAWC,EAAA,IACT,0BACAT,GAAY,iCACd,EAEA,SAAA,CAAAQ,EAAA,kBAAA,KAAC,MAAA,CACC,MAAM,6BACN,MAAM,KACN,OAAO,KACP,QAAQ,cAER,SAAA,CAAAL,EAAA,kBAAA,IAAC,OAAA,CACC,KAAK,eACL,EAAE,kGAAA,CACJ,EACAA,EAAA,kBAAA,IAAC,OAAA,CACC,KAAK,eACL,EAAE,oHAAA,CACJ,CAAA,CAAA,CACF,EACAA,EAAA,kBAAA,IAAC,OAAA,CACC,UAAWM,EAAA,IACT,+BACAT,GAAY,sCACd,EAEC,WAAW,UAAY,MAAA,CAC1B,CAAA,CAAA,CAEJ,CAAA,CAAA"}
1
+ {"version":3,"file":"CopyInput.cjs.js","sources":["../../../../src/components/Input/CopyInput/CopyInput.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { csx } from \"../../../utils\";\nimport { copyTextToClipboard } from \"../../../utils/copy\";\nimport { Input } from \"../BaseInput/Input\";\nimport \"./CopyInput.css\";\n\nexport interface CopyInputProps {\n /** The name of the input field */\n name: string;\n\n /** The value to display in the input and copy to clipboard */\n value: string;\n\n /** Whether the input is disabled */\n isDisabled?: boolean;\n\n /** Optional callback when copy fails, receives the error object */\n onError?: (error: Error) => void;\n\n /** Optional callback when copy succeeds */\n onSuccess?: () => void;\n}\n\n/**\n * Input with a button to copy value to the clipboard.\n *\n * API:\n * - {@link CopyInputProps}\n */\nexport function CopyInput({\n name,\n value,\n isDisabled,\n onError,\n onSuccess,\n}: CopyInputProps) {\n const [isCopied, setCopied] = useState(false);\n\n return (\n <Input\n name={name}\n value={value}\n isDisabled={isDisabled}\n suffix={\n <CopyButton\n isCopied={isCopied}\n onClick={async () => {\n const copySuccess = await copyTextToClipboard(value, onError);\n if (!copySuccess) return;\n\n setCopied(true);\n onSuccess?.();\n setTimeout(() => setCopied(false), 5000);\n }}\n />\n }\n />\n );\n}\n\nconst CopyButton = ({ isCopied, onClick }) => {\n return (\n <div className=\"proton-CopyInput-button-container\">\n <button\n data-testid=\"COPY_BUTTON\"\n className={csx(\n \"proton-CopyInput-button\",\n isCopied && \"proton-CopyInput-button--copied\"\n )}\n onClick={onClick}\n type=\"button\"\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 512 512\"\n >\n <path\n fill=\"currentColor\"\n d=\"M408 480H184a72 72 0 0 1-72-72V184a72 72 0 0 1 72-72h224a72 72 0 0 1 72 72v224a72 72 0 0 1-72 72\"\n />\n <path\n fill=\"currentColor\"\n d=\"M160 80h235.88A72.12 72.12 0 0 0 328 32H104a72 72 0 0 0-72 72v224a72.12 72.12 0 0 0 48 67.88V160a80 80 0 0 1 80-80\"\n />\n </svg>\n <span\n className={csx(\n \"proton-CopyInput-button-text\",\n isCopied && \"proton-CopyInput-button-text--copied\"\n )}\n >\n {isCopied ? \"Copied!\" : \"Copy\"}\n </span>\n </button>\n </div>\n );\n};\n"],"names":["CopyInput","name","value","isDisabled","onError","onSuccess","isCopied","setCopied","useState","jsx","Input","CopyButton","copyTextToClipboard","onClick","jsxs","csx"],"mappings":"sUA6BO,SAASA,EAAU,CACxB,KAAAC,EACA,MAAAC,EACA,WAAAC,EACA,QAAAC,EACA,UAAAC,CACF,EAAmB,CACjB,KAAM,CAACC,EAAUC,CAAS,EAAIC,WAAS,EAAK,EAG1C,OAAAC,EAAA,kBAAA,IAACC,EAAA,MAAA,CACC,KAAAT,EACA,MAAAC,EACA,WAAAC,EACA,OACEM,EAAA,kBAAA,IAACE,EAAA,CACC,SAAAL,EACA,QAAS,SAAY,CACC,MAAMM,EAAAA,oBAAoBV,EAAOE,CAAO,IAG5DG,EAAU,EAAI,EACFF,GAAA,MAAAA,IACZ,WAAW,IAAME,EAAU,EAAK,EAAG,GAAI,EACzC,CAAA,CACF,CAAA,CAAA,CAIR,CAEA,MAAMI,EAAa,CAAC,CAAE,SAAAL,EAAU,QAAAO,KAE5BJ,EAAAA,kBAAAA,IAAC,MAAI,CAAA,UAAU,oCACb,SAAAK,EAAA,kBAAA,KAAC,SAAA,CACC,cAAY,cACZ,UAAWC,EAAA,IACT,0BACAT,GAAY,iCACd,EACA,QAAAO,EACA,KAAK,SAEL,SAAA,CAAAC,EAAA,kBAAA,KAAC,MAAA,CACC,MAAM,6BACN,MAAM,KACN,OAAO,KACP,QAAQ,cAER,SAAA,CAAAL,EAAA,kBAAA,IAAC,OAAA,CACC,KAAK,eACL,EAAE,kGAAA,CACJ,EACAA,EAAA,kBAAA,IAAC,OAAA,CACC,KAAK,eACL,EAAE,oHAAA,CACJ,CAAA,CAAA,CACF,EACAA,EAAA,kBAAA,IAAC,OAAA,CACC,UAAWM,EAAA,IACT,+BACAT,GAAY,sCACd,EAEC,WAAW,UAAY,MAAA,CAC1B,CAAA,CAAA,CAEJ,CAAA,CAAA"}
@@ -30,7 +30,7 @@ function b({
30
30
  }
31
31
  );
32
32
  }
33
- const l = ({ isCopied: o, onClick: p }) => /* @__PURE__ */ t.jsx("div", { className: "proton-CopyInput-button-container", onClick: p, children: /* @__PURE__ */ t.jsxs(
33
+ const l = ({ isCopied: o, onClick: p }) => /* @__PURE__ */ t.jsx("div", { className: "proton-CopyInput-button-container", children: /* @__PURE__ */ t.jsxs(
34
34
  "button",
35
35
  {
36
36
  "data-testid": "COPY_BUTTON",
@@ -38,6 +38,8 @@ const l = ({ isCopied: o, onClick: p }) => /* @__PURE__ */ t.jsx("div", { classN
38
38
  "proton-CopyInput-button",
39
39
  o && "proton-CopyInput-button--copied"
40
40
  ),
41
+ onClick: p,
42
+ type: "button",
41
43
  children: [
42
44
  /* @__PURE__ */ t.jsxs(
43
45
  "svg",
@@ -1 +1 @@
1
- {"version":3,"file":"CopyInput.es.js","sources":["../../../../src/components/Input/CopyInput/CopyInput.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { csx } from \"../../../utils\";\nimport { copyTextToClipboard } from \"../../../utils/copy\";\nimport { Input } from \"../BaseInput/Input\";\nimport \"./CopyInput.css\";\n\nexport interface CopyInputProps {\n /** The name of the input field */\n name: string;\n\n /** The value to display in the input and copy to clipboard */\n value: string;\n\n /** Whether the input is disabled */\n isDisabled?: boolean;\n\n /** Optional callback when copy fails, receives the error object */\n onError?: (error: Error) => void;\n\n /** Optional callback when copy succeeds */\n onSuccess?: () => void;\n}\n\n/**\n * Input with a button to copy value to the clipboard.\n *\n * API:\n * - {@link CopyInputProps}\n */\nexport function CopyInput({\n name,\n value,\n isDisabled,\n onError,\n onSuccess,\n}: CopyInputProps) {\n const [isCopied, setCopied] = useState(false);\n\n return (\n <Input\n name={name}\n value={value}\n isDisabled={isDisabled}\n suffix={\n <CopyButton\n isCopied={isCopied}\n onClick={async () => {\n const copySuccess = await copyTextToClipboard(value, onError);\n if (!copySuccess) return;\n\n setCopied(true);\n onSuccess?.();\n setTimeout(() => setCopied(false), 5000);\n }}\n />\n }\n />\n );\n}\n\nconst CopyButton = ({ isCopied, onClick }) => {\n return (\n <div className=\"proton-CopyInput-button-container\" onClick={onClick}>\n <button\n data-testid=\"COPY_BUTTON\"\n className={csx(\n \"proton-CopyInput-button\",\n isCopied && \"proton-CopyInput-button--copied\"\n )}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 512 512\"\n >\n <path\n fill=\"currentColor\"\n d=\"M408 480H184a72 72 0 0 1-72-72V184a72 72 0 0 1 72-72h224a72 72 0 0 1 72 72v224a72 72 0 0 1-72 72\"\n />\n <path\n fill=\"currentColor\"\n d=\"M160 80h235.88A72.12 72.12 0 0 0 328 32H104a72 72 0 0 0-72 72v224a72.12 72.12 0 0 0 48 67.88V160a80 80 0 0 1 80-80\"\n />\n </svg>\n <span\n className={csx(\n \"proton-CopyInput-button-text\",\n isCopied && \"proton-CopyInput-button-text--copied\"\n )}\n >\n {isCopied ? \"Copied!\" : \"Copy\"}\n </span>\n </button>\n </div>\n );\n};\n"],"names":["CopyInput","name","value","isDisabled","onError","onSuccess","isCopied","setCopied","useState","jsx","Input","CopyButton","copyTextToClipboard","onClick","jsxs","csx"],"mappings":";;;;;;AA6BO,SAASA,EAAU;AAAA,EACxB,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,SAAAC;AAAA,EACA,WAAAC;AACF,GAAmB;AACjB,QAAM,CAACC,GAAUC,CAAS,IAAIC,EAAS,EAAK;AAG1C,SAAAC,gBAAAA,EAAA;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,MAAAT;AAAA,MACA,OAAAC;AAAA,MACA,YAAAC;AAAA,MACA,QACEM,gBAAAA,EAAA;AAAA,QAACE;AAAA,QAAA;AAAA,UACC,UAAAL;AAAA,UACA,SAAS,YAAY;AAEnB,YADoB,MAAMM,EAAoBV,GAAOE,CAAO,MAG5DG,EAAU,EAAI,GACFF,KAAA,QAAAA,KACZ,WAAW,MAAME,EAAU,EAAK,GAAG,GAAI;AAAA,UACzC;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAIR;AAEA,MAAMI,IAAa,CAAC,EAAE,UAAAL,GAAU,SAAAO,QAE3BJ,gBAAAA,EAAAA,IAAA,OAAA,EAAI,WAAU,qCAAoC,SAAAI,GACjD,UAAAC,gBAAAA,EAAA;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,eAAY;AAAA,IACZ,WAAWC;AAAA,MACT;AAAA,MACAT,KAAY;AAAA,IACd;AAAA,IAEA,UAAA;AAAA,MAAAQ,gBAAAA,EAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,OAAM;AAAA,UACN,OAAM;AAAA,UACN,QAAO;AAAA,UACP,SAAQ;AAAA,UAER,UAAA;AAAA,YAAAL,gBAAAA,EAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,MAAK;AAAA,gBACL,GAAE;AAAA,cAAA;AAAA,YACJ;AAAA,YACAA,gBAAAA,EAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,MAAK;AAAA,gBACL,GAAE;AAAA,cAAA;AAAA,YACJ;AAAA,UAAA;AAAA,QAAA;AAAA,MACF;AAAA,MACAA,gBAAAA,EAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAWM;AAAA,YACT;AAAA,YACAT,KAAY;AAAA,UACd;AAAA,UAEC,cAAW,YAAY;AAAA,QAAA;AAAA,MAC1B;AAAA,IAAA;AAAA,EAAA;AAEJ,EAAA,CAAA;"}
1
+ {"version":3,"file":"CopyInput.es.js","sources":["../../../../src/components/Input/CopyInput/CopyInput.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { csx } from \"../../../utils\";\nimport { copyTextToClipboard } from \"../../../utils/copy\";\nimport { Input } from \"../BaseInput/Input\";\nimport \"./CopyInput.css\";\n\nexport interface CopyInputProps {\n /** The name of the input field */\n name: string;\n\n /** The value to display in the input and copy to clipboard */\n value: string;\n\n /** Whether the input is disabled */\n isDisabled?: boolean;\n\n /** Optional callback when copy fails, receives the error object */\n onError?: (error: Error) => void;\n\n /** Optional callback when copy succeeds */\n onSuccess?: () => void;\n}\n\n/**\n * Input with a button to copy value to the clipboard.\n *\n * API:\n * - {@link CopyInputProps}\n */\nexport function CopyInput({\n name,\n value,\n isDisabled,\n onError,\n onSuccess,\n}: CopyInputProps) {\n const [isCopied, setCopied] = useState(false);\n\n return (\n <Input\n name={name}\n value={value}\n isDisabled={isDisabled}\n suffix={\n <CopyButton\n isCopied={isCopied}\n onClick={async () => {\n const copySuccess = await copyTextToClipboard(value, onError);\n if (!copySuccess) return;\n\n setCopied(true);\n onSuccess?.();\n setTimeout(() => setCopied(false), 5000);\n }}\n />\n }\n />\n );\n}\n\nconst CopyButton = ({ isCopied, onClick }) => {\n return (\n <div className=\"proton-CopyInput-button-container\">\n <button\n data-testid=\"COPY_BUTTON\"\n className={csx(\n \"proton-CopyInput-button\",\n isCopied && \"proton-CopyInput-button--copied\"\n )}\n onClick={onClick}\n type=\"button\"\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 512 512\"\n >\n <path\n fill=\"currentColor\"\n d=\"M408 480H184a72 72 0 0 1-72-72V184a72 72 0 0 1 72-72h224a72 72 0 0 1 72 72v224a72 72 0 0 1-72 72\"\n />\n <path\n fill=\"currentColor\"\n d=\"M160 80h235.88A72.12 72.12 0 0 0 328 32H104a72 72 0 0 0-72 72v224a72.12 72.12 0 0 0 48 67.88V160a80 80 0 0 1 80-80\"\n />\n </svg>\n <span\n className={csx(\n \"proton-CopyInput-button-text\",\n isCopied && \"proton-CopyInput-button-text--copied\"\n )}\n >\n {isCopied ? \"Copied!\" : \"Copy\"}\n </span>\n </button>\n </div>\n );\n};\n"],"names":["CopyInput","name","value","isDisabled","onError","onSuccess","isCopied","setCopied","useState","jsx","Input","CopyButton","copyTextToClipboard","onClick","jsxs","csx"],"mappings":";;;;;;AA6BO,SAASA,EAAU;AAAA,EACxB,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,SAAAC;AAAA,EACA,WAAAC;AACF,GAAmB;AACjB,QAAM,CAACC,GAAUC,CAAS,IAAIC,EAAS,EAAK;AAG1C,SAAAC,gBAAAA,EAAA;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,MAAAT;AAAA,MACA,OAAAC;AAAA,MACA,YAAAC;AAAA,MACA,QACEM,gBAAAA,EAAA;AAAA,QAACE;AAAA,QAAA;AAAA,UACC,UAAAL;AAAA,UACA,SAAS,YAAY;AAEnB,YADoB,MAAMM,EAAoBV,GAAOE,CAAO,MAG5DG,EAAU,EAAI,GACFF,KAAA,QAAAA,KACZ,WAAW,MAAME,EAAU,EAAK,GAAG,GAAI;AAAA,UACzC;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAIR;AAEA,MAAMI,IAAa,CAAC,EAAE,UAAAL,GAAU,SAAAO,QAE5BJ,gBAAAA,EAAAA,IAAC,OAAI,EAAA,WAAU,qCACb,UAAAK,gBAAAA,EAAA;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,eAAY;AAAA,IACZ,WAAWC;AAAA,MACT;AAAA,MACAT,KAAY;AAAA,IACd;AAAA,IACA,SAAAO;AAAA,IACA,MAAK;AAAA,IAEL,UAAA;AAAA,MAAAC,gBAAAA,EAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,OAAM;AAAA,UACN,OAAM;AAAA,UACN,QAAO;AAAA,UACP,SAAQ;AAAA,UAER,UAAA;AAAA,YAAAL,gBAAAA,EAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,MAAK;AAAA,gBACL,GAAE;AAAA,cAAA;AAAA,YACJ;AAAA,YACAA,gBAAAA,EAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,MAAK;AAAA,gBACL,GAAE;AAAA,cAAA;AAAA,YACJ;AAAA,UAAA;AAAA,QAAA;AAAA,MACF;AAAA,MACAA,gBAAAA,EAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAWM;AAAA,YACT;AAAA,YACAT,KAAY;AAAA,UACd;AAAA,UAEC,cAAW,YAAY;AAAA,QAAA;AAAA,MAC1B;AAAA,IAAA;AAAA,EAAA;AAEJ,EAAA,CAAA;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../node_modules/react/jsx-runtime.cjs.js"),E=require("../../node_modules/@react-aria/button/dist/useButton.cjs.js"),q=require("../../node_modules/@react-aria/dialog/dist/useDialog.cjs.js"),m=require("../../node_modules/@react-aria/focus/dist/FocusScope.cjs.js"),v=require("@react-aria/utils"),S=require("../../node_modules/@react-aria/overlays/dist/usePreventScroll.cjs.js"),_=require("../../node_modules/@react-aria/overlays/dist/useModalOverlay.cjs.js"),j=require("react"),h=require("../../node_modules/@react-stately/overlays/dist/useOverlayTriggerState.cjs.js"),b=require("../../hooks/useIsClosing.cjs.js"),f=require("../Button/Button.cjs.js");;/* empty css */const B=require("../ScreenOverlay/ScreenOverlay.cjs.js"),y=require("../../hooks/useBreakpoint.cjs.js"),C=require("../../constants/breakpoint.cjs.js"),O=require("../../utils/string.cjs.js"),M=({children:s})=>e.jsxRuntimeExports.jsx("h2",{className:"proton-Modal__title",children:s}),R=({children:s})=>e.jsxRuntimeExports.jsx("h3",{className:"proton-Modal__subtitle",children:s}),g=({children:s})=>e.jsxRuntimeExports.jsx("div",{className:"proton-Modal__body",children:s}),P=s=>e.jsxRuntimeExports.jsx("div",{className:"proton-Modal__action",children:e.jsxRuntimeExports.jsx(f.Button,{...s})}),N=({children:s})=>e.jsxRuntimeExports.jsx(m.FocusScope,{autoFocus:!0,children:e.jsxRuntimeExports.jsx("div",{className:"proton-Modal__actions",children:s})}),F=({title:s,subtitle:o,body:r,onClose:n,children:c,isClosing:d,"data-testid":x})=>{const t=j.useRef(null),u=h.useOverlayTriggerState({isOpen:!0,onOpenChange:n}),{modalProps:p}=_.useModalOverlay({isDismissable:!1},u,t),{dialogProps:i}=q.useDialog({role:"dialog"},t);S.usePreventScroll();const l=j.useRef(null),{buttonProps:a}=E.useButton({onPress:n,"aria-label":"Close"},l);return e.jsxRuntimeExports.jsx(m.FocusScope,{contain:!0,restoreFocus:!0,autoFocus:!0,children:e.jsxRuntimeExports.jsxs("div",{"data-testid":x,className:O.csx("proton-Modal",d&&"proton-Modal--closing"),...v.mergeProps(p,i),ref:t,children:[e.jsxRuntimeExports.jsx("button",{name:"Close",className:"proton-Modal__close-button",...a,ref:l,children:"×"}),s&&e.jsxRuntimeExports.jsx(M,{children:s}),o&&e.jsxRuntimeExports.jsx(R,{children:o}),r&&e.jsxRuntimeExports.jsx(g,{children:r}),e.jsxRuntimeExports.jsx("div",{className:"proton-Modal__content",children:c})]})})},T=({isOpen:s,onClose:o,title:r,subtitle:n,body:c,children:d,isOverlay:x=!0,"data-testid":t})=>{const u=j.useRef(null),{isClosing:p,handleClose:i}=b.useIsClosing({onClose:o,overlayRef:u}),l=y.useBreakpoint(C.BREAKPOINTS.MEDIUM);if(!s)return null;const a=e.jsxRuntimeExports.jsx(F,{isOpen:s,title:r,subtitle:n,body:c,onClose:i,isClosing:p,"data-testid":t,children:d});return x||l?e.jsxRuntimeExports.jsx(B.ScreenOverlay,{fadeIn:!0,ref:u,onClose:i,children:a}):a},A=Object.assign(T,{Title:M,Subtitle:R,Body:g,Action:P,Actions:N});exports.Modal=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../node_modules/react/jsx-runtime.cjs.js"),u=require("react"),E=require("../../hooks/useIsClosing.cjs.js"),_=require("../Button/Button.cjs.js");;/* empty css */const b=require("../ScreenOverlay/ScreenOverlay.cjs.js"),f=require("../../hooks/useBreakpoint.cjs.js"),C=require("../../constants/breakpoint.cjs.js"),g=require("../../utils/string.cjs.js"),j=({children:t})=>e.jsxRuntimeExports.jsx("h2",{className:"proton-Modal__title",children:t}),p=({children:t})=>e.jsxRuntimeExports.jsx("h3",{className:"proton-Modal__subtitle",children:t}),m=({children:t})=>e.jsxRuntimeExports.jsx("div",{className:"proton-Modal__body",children:t}),h=t=>e.jsxRuntimeExports.jsx("div",{className:"proton-Modal__action",children:e.jsxRuntimeExports.jsx(_.Button,{...t})}),q=({children:t})=>e.jsxRuntimeExports.jsx("div",{className:"proton-Modal__actions",children:t}),v=({title:t,subtitle:s,body:o,onClose:r,children:l,isClosing:i,"data-testid":a})=>{const c=u.useRef(null),n=u.useRef(null);return e.jsxRuntimeExports.jsxs("div",{"data-testid":a,className:g.csx("proton-Modal",i&&"proton-Modal--closing"),role:"dialog",tabIndex:-1,ref:c,children:[e.jsxRuntimeExports.jsx("button",{name:"Close",className:"proton-Modal__close-button",onClick:r,"aria-label":"Close",ref:n,children:"×"}),t&&e.jsxRuntimeExports.jsx(j,{children:t}),s&&e.jsxRuntimeExports.jsx(p,{children:s}),o&&e.jsxRuntimeExports.jsx(m,{children:o}),e.jsxRuntimeExports.jsx("div",{className:"proton-Modal__content",children:l})]})},B=({isOpen:t,onClose:s,title:o,subtitle:r,body:l,children:i,isOverlay:a=!0,"data-testid":c})=>{const n=u.useRef(null),{isClosing:M,handleClose:d}=E.useIsClosing({onClose:s,overlayRef:n}),R=f.useBreakpoint(C.BREAKPOINTS.MEDIUM);if(!t)return null;const x=e.jsxRuntimeExports.jsx(v,{isOpen:t,title:o,subtitle:r,body:l,onClose:d,isClosing:M,"data-testid":c,children:i});return a||R?e.jsxRuntimeExports.jsx(b.ScreenOverlay,{fadeIn:!0,ref:n,onClose:d,children:x}):x},N=Object.assign(B,{Title:j,Subtitle:p,Body:m,Action:h,Actions:q});exports.Modal=N;
2
2
  //# sourceMappingURL=Modal.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.cjs.js","sources":["../../../src/components/Modal/Modal.tsx"],"sourcesContent":["\"use client\";\n\nimport { useButton } from \"@react-aria/button\";\nimport { useDialog } from \"@react-aria/dialog\";\nimport { FocusScope } from \"@react-aria/focus\";\nimport { useModalOverlay, usePreventScroll } from \"@react-aria/overlays\";\nimport { mergeProps } from \"@react-aria/utils\";\nimport { useRef } from \"react\";\nimport { useOverlayTriggerState } from \"@react-stately/overlays\";\nimport { BREAKPOINTS } from \"../../constants\";\nimport { useBreakpoint } from \"../../hooks\";\nimport { useIsClosing } from \"../../hooks/useIsClosing\";\nimport { csx } from \"../../utils\";\nimport { Button, ButtonProps } from \"../Button/Button\";\nimport \"./Modal.css\";\nimport { ScreenOverlay } from \"../ScreenOverlay/ScreenOverlay\";\n\nconst ModalTitle = ({ children }: { children: React.ReactNode }) => {\n return <h2 className=\"proton-Modal__title\">{children}</h2>;\n};\n\nconst ModalSubtitle = ({ children }: { children: React.ReactNode }) => {\n return <h3 className=\"proton-Modal__subtitle\">{children}</h3>;\n};\n\nconst ModalBody = ({ children }: { children: React.ReactNode }) => {\n return <div className=\"proton-Modal__body\">{children}</div>;\n};\n\nconst ModalAction = (buttonProps: ButtonProps) => {\n return (\n <div className=\"proton-Modal__action\">\n <Button {...buttonProps} />\n </div>\n );\n};\n\nconst ModalActions = ({ children }: { children: React.ReactNode }) => {\n return (\n <FocusScope autoFocus>\n <div className=\"proton-Modal__actions\">{children}</div>\n </FocusScope>\n );\n};\n\nconst ModalContent = ({\n title,\n subtitle,\n body,\n onClose,\n children,\n isClosing,\n \"data-testid\": dataTestId,\n}: ModalProps & {\n isClosing: boolean;\n}) => {\n const ref = useRef<HTMLDivElement>(null);\n const state = useOverlayTriggerState({ isOpen: true, onOpenChange: onClose });\n const { modalProps } = useModalOverlay(\n {\n isDismissable: false, //handle dismiss behavior in useIsClosing\n },\n state,\n ref\n );\n\n const { dialogProps } = useDialog({ role: \"dialog\" }, ref);\n usePreventScroll();\n\n const closeButtonRef = useRef<HTMLButtonElement>(null);\n const { buttonProps: closeButtonProps } = useButton(\n {\n onPress: onClose,\n \"aria-label\": \"Close\",\n },\n closeButtonRef\n );\n\n return (\n <FocusScope contain restoreFocus autoFocus>\n <div\n data-testid={dataTestId}\n className={csx(\"proton-Modal\", isClosing && \"proton-Modal--closing\")}\n {...mergeProps(modalProps, dialogProps)}\n ref={ref}\n >\n <button\n name=\"Close\"\n className=\"proton-Modal__close-button\"\n {...closeButtonProps}\n ref={closeButtonRef}\n >\n ×\n </button>\n {title && <ModalTitle>{title}</ModalTitle>}\n {subtitle && <ModalSubtitle>{subtitle}</ModalSubtitle>}\n {body && <ModalBody>{body}</ModalBody>}\n <div className=\"proton-Modal__content\">{children}</div>\n </div>\n </FocusScope>\n );\n};\n\nexport interface ModalProps {\n /**\n * Optional body text content for the modal\n * */\n body?: string;\n /**\n * Content to render inside the modal\n * */\n children: React.ReactNode;\n /**\n * data-testid for the modal\n * */\n \"data-testid\"?: string;\n /**\n * Controls the visibility of the modal\n * */\n isOpen: boolean;\n /**\n * Whether to show the modal with an overlay background.\n * @default true\n * */\n isOverlay?: boolean;\n /**\n * Callback function when modal is closed\n * */\n onClose?: () => void;\n /**\n * Optional subtitle text below the modal title\n * */\n subtitle?: string;\n /**\n * Optional title text for the modal header\n * */\n title?: string;\n}\n\n/**\n * Modal component with overlay support and responsive behavior.\n *\n * API:\n * - {@link ModalProps}\n */\nconst ModalWrapper = ({\n isOpen,\n onClose,\n title,\n subtitle,\n body,\n children,\n isOverlay = true,\n \"data-testid\": dataTestId,\n}: ModalProps) => {\n const overlayRef = useRef<HTMLDivElement>(null);\n const { isClosing, handleClose } = useIsClosing({\n onClose,\n overlayRef,\n });\n const isMobile = useBreakpoint(BREAKPOINTS.MEDIUM);\n\n if (!isOpen) return null;\n\n const modalContent = (\n <ModalContent\n isOpen={isOpen}\n title={title}\n subtitle={subtitle}\n body={body}\n onClose={handleClose}\n isClosing={isClosing}\n data-testid={dataTestId}\n >\n {children}\n </ModalContent>\n );\n\n return isOverlay || isMobile ? (\n <ScreenOverlay fadeIn ref={overlayRef} onClose={handleClose}>\n {modalContent}\n </ScreenOverlay>\n ) : (\n modalContent\n );\n};\n\nexport const Modal = Object.assign(ModalWrapper, {\n /**\n * Renders a h2 styled title\n * */\n Title: ModalTitle,\n /**\n * Renders a h3 styled subtitle\n * */\n Subtitle: ModalSubtitle,\n /**\n * Renders a div styled body\n * */\n Body: ModalBody,\n /**\n * Renders a Proton Button action\n * - @prop buttonProps {@link ButtonProps}\n * */\n Action: ModalAction,\n /**\n * Renders a group of Proton Buttons\n * */\n Actions: ModalActions,\n});\n"],"names":["ModalTitle","children","jsx","ModalSubtitle","ModalBody","ModalAction","buttonProps","Button","ModalActions","FocusScope","ModalContent","title","subtitle","body","onClose","isClosing","dataTestId","ref","useRef","state","useOverlayTriggerState","modalProps","useModalOverlay","dialogProps","useDialog","usePreventScroll","closeButtonRef","closeButtonProps","useButton","jsxs","csx","mergeProps","ModalWrapper","isOpen","isOverlay","overlayRef","handleClose","useIsClosing","isMobile","useBreakpoint","BREAKPOINTS","modalContent","ScreenOverlay","Modal"],"mappings":"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"}
1
+ {"version":3,"file":"Modal.cjs.js","sources":["../../../src/components/Modal/Modal.tsx"],"sourcesContent":["\"use client\";\n\nimport { useRef } from \"react\";\nimport { BREAKPOINTS } from \"../../constants\";\nimport { useBreakpoint } from \"../../hooks\";\nimport { useIsClosing } from \"../../hooks/useIsClosing\";\nimport { csx } from \"../../utils\";\nimport { Button, ButtonProps } from \"../Button/Button\";\nimport \"./Modal.css\";\nimport { ScreenOverlay } from \"../ScreenOverlay/ScreenOverlay\";\n\nconst ModalTitle = ({ children }: { children: React.ReactNode }) => {\n return <h2 className=\"proton-Modal__title\">{children}</h2>;\n};\n\nconst ModalSubtitle = ({ children }: { children: React.ReactNode }) => {\n return <h3 className=\"proton-Modal__subtitle\">{children}</h3>;\n};\n\nconst ModalBody = ({ children }: { children: React.ReactNode }) => {\n return <div className=\"proton-Modal__body\">{children}</div>;\n};\n\nconst ModalAction = (buttonProps: ButtonProps) => {\n return (\n <div className=\"proton-Modal__action\">\n <Button {...buttonProps} />\n </div>\n );\n};\n\nconst ModalActions = ({ children }: { children: React.ReactNode }) => {\n return <div className=\"proton-Modal__actions\">{children}</div>;\n};\n\nconst ModalContent = ({\n title,\n subtitle,\n body,\n onClose,\n children,\n isClosing,\n \"data-testid\": dataTestId,\n}: ModalProps & {\n isClosing: boolean;\n}) => {\n const ref = useRef<HTMLDivElement>(null);\n const closeButtonRef = useRef<HTMLButtonElement>(null);\n\n return (\n <div\n data-testid={dataTestId}\n className={csx(\"proton-Modal\", isClosing && \"proton-Modal--closing\")}\n role=\"dialog\"\n tabIndex={-1}\n ref={ref}\n >\n <button\n name=\"Close\"\n className=\"proton-Modal__close-button\"\n onClick={onClose}\n aria-label=\"Close\"\n ref={closeButtonRef}\n >\n ×\n </button>\n {title && <ModalTitle>{title}</ModalTitle>}\n {subtitle && <ModalSubtitle>{subtitle}</ModalSubtitle>}\n {body && <ModalBody>{body}</ModalBody>}\n <div className=\"proton-Modal__content\">{children}</div>\n </div>\n );\n};\n\nexport interface ModalProps {\n /**\n * Optional body text content for the modal\n * */\n body?: string;\n /**\n * Content to render inside the modal\n * */\n children: React.ReactNode;\n /**\n * data-testid for the modal\n * */\n \"data-testid\"?: string;\n /**\n * Controls the visibility of the modal\n * */\n isOpen: boolean;\n /**\n * Whether to show the modal with an overlay background.\n * @default true\n * */\n isOverlay?: boolean;\n /**\n * Callback function when modal is closed\n * */\n onClose?: () => void;\n /**\n * Optional subtitle text below the modal title\n * */\n subtitle?: string;\n /**\n * Optional title text for the modal header\n * */\n title?: string;\n}\n\n/**\n * Modal component with overlay support and responsive behavior.\n *\n * API:\n * - {@link ModalProps}\n */\nconst ModalWrapper = ({\n isOpen,\n onClose,\n title,\n subtitle,\n body,\n children,\n isOverlay = true,\n \"data-testid\": dataTestId,\n}: ModalProps) => {\n const overlayRef = useRef<HTMLDivElement>(null);\n const { isClosing, handleClose } = useIsClosing({\n onClose,\n overlayRef,\n });\n const isMobile = useBreakpoint(BREAKPOINTS.MEDIUM);\n\n if (!isOpen) return null;\n\n const modalContent = (\n <ModalContent\n isOpen={isOpen}\n title={title}\n subtitle={subtitle}\n body={body}\n onClose={handleClose}\n isClosing={isClosing}\n data-testid={dataTestId}\n >\n {children}\n </ModalContent>\n );\n\n return isOverlay || isMobile ? (\n <ScreenOverlay fadeIn ref={overlayRef} onClose={handleClose}>\n {modalContent}\n </ScreenOverlay>\n ) : (\n modalContent\n );\n};\n\nexport const Modal = Object.assign(ModalWrapper, {\n /**\n * Renders a h2 styled title\n * */\n Title: ModalTitle,\n /**\n * Renders a h3 styled subtitle\n * */\n Subtitle: ModalSubtitle,\n /**\n * Renders a div styled body\n * */\n Body: ModalBody,\n /**\n * Renders a Proton Button action\n * - @prop buttonProps {@link ButtonProps}\n * */\n Action: ModalAction,\n /**\n * Renders a group of Proton Buttons\n * */\n Actions: ModalActions,\n});\n"],"names":["ModalTitle","children","jsx","ModalSubtitle","ModalBody","ModalAction","buttonProps","Button","ModalActions","ModalContent","title","subtitle","body","onClose","isClosing","dataTestId","ref","useRef","closeButtonRef","jsxs","csx","ModalWrapper","isOpen","isOverlay","overlayRef","handleClose","useIsClosing","isMobile","useBreakpoint","BREAKPOINTS","modalContent","ScreenOverlay","Modal"],"mappings":"+cAWMA,EAAa,CAAC,CAAE,SAAAC,KACZC,EAAAA,kBAAAA,IAAA,KAAA,CAAG,UAAU,sBAAuB,SAAAD,CAAS,CAAA,EAGjDE,EAAgB,CAAC,CAAE,SAAAF,KACfC,EAAAA,kBAAAA,IAAA,KAAA,CAAG,UAAU,yBAA0B,SAAAD,CAAS,CAAA,EAGpDG,EAAY,CAAC,CAAE,SAAAH,KACXC,EAAAA,kBAAAA,IAAA,MAAA,CAAI,UAAU,qBAAsB,SAAAD,CAAS,CAAA,EAGjDI,EAAeC,GAEjBJ,wBAAC,OAAI,UAAU,uBACb,iCAACK,EAAQ,OAAA,CAAA,GAAGD,CAAa,CAAA,CAC3B,CAAA,EAIEE,EAAe,CAAC,CAAE,SAAAP,KACdC,EAAAA,kBAAAA,IAAA,MAAA,CAAI,UAAU,wBAAyB,SAAAD,CAAS,CAAA,EAGpDQ,EAAe,CAAC,CACpB,MAAAC,EACA,SAAAC,EACA,KAAAC,EACA,QAAAC,EACA,SAAAZ,EACA,UAAAa,EACA,cAAeC,CACjB,IAEM,CACE,MAAAC,EAAMC,SAAuB,IAAI,EACjCC,EAAiBD,SAA0B,IAAI,EAGnD,OAAAE,EAAA,kBAAA,KAAC,MAAA,CACC,cAAaJ,EACb,UAAWK,EAAA,IAAI,eAAgBN,GAAa,uBAAuB,EACnE,KAAK,SACL,SAAU,GACV,IAAAE,EAEA,SAAA,CAAAd,EAAA,kBAAA,IAAC,SAAA,CACC,KAAK,QACL,UAAU,6BACV,QAASW,EACT,aAAW,QACX,IAAKK,EACN,SAAA,GAAA,CAED,EACCR,GAAUR,EAAAA,kBAAAA,IAAAF,EAAA,CAAY,SAAMU,CAAA,CAAA,EAC5BC,GAAaT,EAAAA,kBAAAA,IAAAC,EAAA,CAAe,SAASQ,CAAA,CAAA,EACrCC,GAASV,EAAAA,kBAAAA,IAAAE,EAAA,CAAW,SAAKQ,CAAA,CAAA,EACzBV,EAAAA,kBAAAA,IAAA,MAAA,CAAI,UAAU,wBAAyB,SAAAD,CAAS,CAAA,CAAA,CAAA,CAAA,CAGvD,EA4CMoB,EAAe,CAAC,CACpB,OAAAC,EACA,QAAAT,EACA,MAAAH,EACA,SAAAC,EACA,KAAAC,EACA,SAAAX,EACA,UAAAsB,EAAY,GACZ,cAAeR,CACjB,IAAkB,CACV,MAAAS,EAAaP,SAAuB,IAAI,EACxC,CAAE,UAAAH,EAAW,YAAAW,CAAY,EAAIC,eAAa,CAC9C,QAAAb,EACA,WAAAW,CAAA,CACD,EACKG,EAAWC,EAAAA,cAAcC,EAAA,YAAY,MAAM,EAE7C,GAAA,CAACP,EAAe,OAAA,KAEpB,MAAMQ,EACJ5B,EAAA,kBAAA,IAACO,EAAA,CACC,OAAAa,EACA,MAAAZ,EACA,SAAAC,EACA,KAAAC,EACA,QAASa,EACT,UAAAX,EACA,cAAaC,EAEZ,SAAAd,CAAA,CAAA,EAIE,OAAAsB,GAAaI,EAClBzB,EAAAA,kBAAAA,IAAC6B,EAAAA,cAAc,CAAA,OAAM,GAAC,IAAKP,EAAY,QAASC,EAC7C,SAAAK,CAAA,CACH,EAEAA,CAEJ,EAEaE,EAAQ,OAAO,OAAOX,EAAc,CAI/C,MAAOrB,EAIP,SAAUG,EAIV,KAAMC,EAKN,OAAQC,EAIR,QAASG,CACX,CAAC"}
@@ -1,103 +1,83 @@
1
- import { j as o } from "../../node_modules/react/jsx-runtime.es.js";
2
- import { useButton as $ } from "../../node_modules/@react-aria/button/dist/useButton.es.js";
3
- import { useDialog as _ } from "../../node_modules/@react-aria/dialog/dist/useDialog.es.js";
4
- import { FocusScope as x } from "../../node_modules/@react-aria/focus/dist/FocusScope.es.js";
5
- import { mergeProps as h } from "@react-aria/utils";
6
- import { usePreventScroll as g } from "../../node_modules/@react-aria/overlays/dist/usePreventScroll.es.js";
7
- import { useModalOverlay as v } from "../../node_modules/@react-aria/overlays/dist/useModalOverlay.es.js";
8
- import { useRef as f } from "react";
9
- import { useOverlayTriggerState as C } from "../../node_modules/@react-stately/overlays/dist/useOverlayTriggerState.es.js";
10
- import { useIsClosing as N } from "../../hooks/useIsClosing.es.js";
11
- import { Button as B } from "../Button/Button.es.js";
1
+ import { j as t } from "../../node_modules/react/jsx-runtime.es.js";
2
+ import { useRef as c } from "react";
3
+ import { useIsClosing as _ } from "../../hooks/useIsClosing.es.js";
4
+ import { Button as h } from "../Button/Button.es.js";
12
5
  /* empty css */
13
- import { ScreenOverlay as P } from "../ScreenOverlay/ScreenOverlay.es.js";
14
- import { useBreakpoint as S } from "../../hooks/useBreakpoint.es.js";
15
- import { BREAKPOINTS as y } from "../../constants/breakpoint.es.js";
16
- import { csx as O } from "../../utils/string.es.js";
17
- const b = ({ children: t }) => /* @__PURE__ */ o.jsx("h2", { className: "proton-Modal__title", children: t }), M = ({ children: t }) => /* @__PURE__ */ o.jsx("h3", { className: "proton-Modal__subtitle", children: t }), j = ({ children: t }) => /* @__PURE__ */ o.jsx("div", { className: "proton-Modal__body", children: t }), A = (t) => /* @__PURE__ */ o.jsx("div", { className: "proton-Modal__action", children: /* @__PURE__ */ o.jsx(B, { ...t }) }), R = ({ children: t }) => /* @__PURE__ */ o.jsx(x, { autoFocus: !0, children: /* @__PURE__ */ o.jsx("div", { className: "proton-Modal__actions", children: t }) }), F = ({
18
- title: t,
6
+ import { ScreenOverlay as C } from "../ScreenOverlay/ScreenOverlay.es.js";
7
+ import { useBreakpoint as N } from "../../hooks/useBreakpoint.es.js";
8
+ import { BREAKPOINTS as b } from "../../constants/breakpoint.es.js";
9
+ import { csx as v } from "../../utils/string.es.js";
10
+ const p = ({ children: o }) => /* @__PURE__ */ t.jsx("h2", { className: "proton-Modal__title", children: o }), M = ({ children: o }) => /* @__PURE__ */ t.jsx("h3", { className: "proton-Modal__subtitle", children: o }), x = ({ children: o }) => /* @__PURE__ */ t.jsx("div", { className: "proton-Modal__body", children: o }), B = (o) => /* @__PURE__ */ t.jsx("div", { className: "proton-Modal__action", children: /* @__PURE__ */ t.jsx(h, { ...o }) }), g = ({ children: o }) => /* @__PURE__ */ t.jsx("div", { className: "proton-Modal__actions", children: o }), A = ({
11
+ title: o,
19
12
  subtitle: s,
20
- body: r,
21
- onClose: a,
22
- children: d,
23
- isClosing: m,
24
- "data-testid": p
13
+ body: n,
14
+ onClose: l,
15
+ children: r,
16
+ isClosing: a,
17
+ "data-testid": i
25
18
  }) => {
26
- const e = f(null), n = C({ isOpen: !0, onOpenChange: a }), { modalProps: u } = v(
27
- {
28
- isDismissable: !1
29
- //handle dismiss behavior in useIsClosing
30
- },
31
- n,
32
- e
33
- ), { dialogProps: l } = _({ role: "dialog" }, e);
34
- g();
35
- const c = f(null), { buttonProps: i } = $(
36
- {
37
- onPress: a,
38
- "aria-label": "Close"
39
- },
40
- c
41
- );
42
- return /* @__PURE__ */ o.jsx(x, { contain: !0, restoreFocus: !0, autoFocus: !0, children: /* @__PURE__ */ o.jsxs(
19
+ const d = c(null), e = c(null);
20
+ return /* @__PURE__ */ t.jsxs(
43
21
  "div",
44
22
  {
45
- "data-testid": p,
46
- className: O("proton-Modal", m && "proton-Modal--closing"),
47
- ...h(u, l),
48
- ref: e,
23
+ "data-testid": i,
24
+ className: v("proton-Modal", a && "proton-Modal--closing"),
25
+ role: "dialog",
26
+ tabIndex: -1,
27
+ ref: d,
49
28
  children: [
50
- /* @__PURE__ */ o.jsx(
29
+ /* @__PURE__ */ t.jsx(
51
30
  "button",
52
31
  {
53
32
  name: "Close",
54
33
  className: "proton-Modal__close-button",
55
- ...i,
56
- ref: c,
34
+ onClick: l,
35
+ "aria-label": "Close",
36
+ ref: e,
57
37
  children: "×"
58
38
  }
59
39
  ),
60
- t && /* @__PURE__ */ o.jsx(b, { children: t }),
61
- s && /* @__PURE__ */ o.jsx(M, { children: s }),
62
- r && /* @__PURE__ */ o.jsx(j, { children: r }),
63
- /* @__PURE__ */ o.jsx("div", { className: "proton-Modal__content", children: d })
40
+ o && /* @__PURE__ */ t.jsx(p, { children: o }),
41
+ s && /* @__PURE__ */ t.jsx(M, { children: s }),
42
+ n && /* @__PURE__ */ t.jsx(x, { children: n }),
43
+ /* @__PURE__ */ t.jsx("div", { className: "proton-Modal__content", children: r })
64
44
  ]
65
45
  }
66
- ) });
46
+ );
67
47
  }, I = ({
68
- isOpen: t,
48
+ isOpen: o,
69
49
  onClose: s,
70
- title: r,
71
- subtitle: a,
72
- body: d,
73
- children: m,
74
- isOverlay: p = !0,
75
- "data-testid": e
50
+ title: n,
51
+ subtitle: l,
52
+ body: r,
53
+ children: a,
54
+ isOverlay: i = !0,
55
+ "data-testid": d
76
56
  }) => {
77
- const n = f(null), { isClosing: u, handleClose: l } = N({
57
+ const e = c(null), { isClosing: j, handleClose: m } = _({
78
58
  onClose: s,
79
- overlayRef: n
80
- }), c = S(y.MEDIUM);
81
- if (!t) return null;
82
- const i = /* @__PURE__ */ o.jsx(
83
- F,
59
+ overlayRef: e
60
+ }), f = N(b.MEDIUM);
61
+ if (!o) return null;
62
+ const u = /* @__PURE__ */ t.jsx(
63
+ A,
84
64
  {
85
- isOpen: t,
86
- title: r,
87
- subtitle: a,
88
- body: d,
89
- onClose: l,
90
- isClosing: u,
91
- "data-testid": e,
92
- children: m
65
+ isOpen: o,
66
+ title: n,
67
+ subtitle: l,
68
+ body: r,
69
+ onClose: m,
70
+ isClosing: j,
71
+ "data-testid": d,
72
+ children: a
93
73
  }
94
74
  );
95
- return p || c ? /* @__PURE__ */ o.jsx(P, { fadeIn: !0, ref: n, onClose: l, children: i }) : i;
96
- }, X = Object.assign(I, {
75
+ return i || f ? /* @__PURE__ */ t.jsx(C, { fadeIn: !0, ref: e, onClose: m, children: u }) : u;
76
+ }, P = Object.assign(I, {
97
77
  /**
98
78
  * Renders a h2 styled title
99
79
  * */
100
- Title: b,
80
+ Title: p,
101
81
  /**
102
82
  * Renders a h3 styled subtitle
103
83
  * */
@@ -105,18 +85,18 @@ const b = ({ children: t }) => /* @__PURE__ */ o.jsx("h2", { className: "proton-
105
85
  /**
106
86
  * Renders a div styled body
107
87
  * */
108
- Body: j,
88
+ Body: x,
109
89
  /**
110
90
  * Renders a Proton Button action
111
91
  * - @prop buttonProps {@link ButtonProps}
112
92
  * */
113
- Action: A,
93
+ Action: B,
114
94
  /**
115
95
  * Renders a group of Proton Buttons
116
96
  * */
117
- Actions: R
97
+ Actions: g
118
98
  });
119
99
  export {
120
- X as Modal
100
+ P as Modal
121
101
  };
122
102
  //# sourceMappingURL=Modal.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.es.js","sources":["../../../src/components/Modal/Modal.tsx"],"sourcesContent":["\"use client\";\n\nimport { useButton } from \"@react-aria/button\";\nimport { useDialog } from \"@react-aria/dialog\";\nimport { FocusScope } from \"@react-aria/focus\";\nimport { useModalOverlay, usePreventScroll } from \"@react-aria/overlays\";\nimport { mergeProps } from \"@react-aria/utils\";\nimport { useRef } from \"react\";\nimport { useOverlayTriggerState } from \"@react-stately/overlays\";\nimport { BREAKPOINTS } from \"../../constants\";\nimport { useBreakpoint } from \"../../hooks\";\nimport { useIsClosing } from \"../../hooks/useIsClosing\";\nimport { csx } from \"../../utils\";\nimport { Button, ButtonProps } from \"../Button/Button\";\nimport \"./Modal.css\";\nimport { ScreenOverlay } from \"../ScreenOverlay/ScreenOverlay\";\n\nconst ModalTitle = ({ children }: { children: React.ReactNode }) => {\n return <h2 className=\"proton-Modal__title\">{children}</h2>;\n};\n\nconst ModalSubtitle = ({ children }: { children: React.ReactNode }) => {\n return <h3 className=\"proton-Modal__subtitle\">{children}</h3>;\n};\n\nconst ModalBody = ({ children }: { children: React.ReactNode }) => {\n return <div className=\"proton-Modal__body\">{children}</div>;\n};\n\nconst ModalAction = (buttonProps: ButtonProps) => {\n return (\n <div className=\"proton-Modal__action\">\n <Button {...buttonProps} />\n </div>\n );\n};\n\nconst ModalActions = ({ children }: { children: React.ReactNode }) => {\n return (\n <FocusScope autoFocus>\n <div className=\"proton-Modal__actions\">{children}</div>\n </FocusScope>\n );\n};\n\nconst ModalContent = ({\n title,\n subtitle,\n body,\n onClose,\n children,\n isClosing,\n \"data-testid\": dataTestId,\n}: ModalProps & {\n isClosing: boolean;\n}) => {\n const ref = useRef<HTMLDivElement>(null);\n const state = useOverlayTriggerState({ isOpen: true, onOpenChange: onClose });\n const { modalProps } = useModalOverlay(\n {\n isDismissable: false, //handle dismiss behavior in useIsClosing\n },\n state,\n ref\n );\n\n const { dialogProps } = useDialog({ role: \"dialog\" }, ref);\n usePreventScroll();\n\n const closeButtonRef = useRef<HTMLButtonElement>(null);\n const { buttonProps: closeButtonProps } = useButton(\n {\n onPress: onClose,\n \"aria-label\": \"Close\",\n },\n closeButtonRef\n );\n\n return (\n <FocusScope contain restoreFocus autoFocus>\n <div\n data-testid={dataTestId}\n className={csx(\"proton-Modal\", isClosing && \"proton-Modal--closing\")}\n {...mergeProps(modalProps, dialogProps)}\n ref={ref}\n >\n <button\n name=\"Close\"\n className=\"proton-Modal__close-button\"\n {...closeButtonProps}\n ref={closeButtonRef}\n >\n ×\n </button>\n {title && <ModalTitle>{title}</ModalTitle>}\n {subtitle && <ModalSubtitle>{subtitle}</ModalSubtitle>}\n {body && <ModalBody>{body}</ModalBody>}\n <div className=\"proton-Modal__content\">{children}</div>\n </div>\n </FocusScope>\n );\n};\n\nexport interface ModalProps {\n /**\n * Optional body text content for the modal\n * */\n body?: string;\n /**\n * Content to render inside the modal\n * */\n children: React.ReactNode;\n /**\n * data-testid for the modal\n * */\n \"data-testid\"?: string;\n /**\n * Controls the visibility of the modal\n * */\n isOpen: boolean;\n /**\n * Whether to show the modal with an overlay background.\n * @default true\n * */\n isOverlay?: boolean;\n /**\n * Callback function when modal is closed\n * */\n onClose?: () => void;\n /**\n * Optional subtitle text below the modal title\n * */\n subtitle?: string;\n /**\n * Optional title text for the modal header\n * */\n title?: string;\n}\n\n/**\n * Modal component with overlay support and responsive behavior.\n *\n * API:\n * - {@link ModalProps}\n */\nconst ModalWrapper = ({\n isOpen,\n onClose,\n title,\n subtitle,\n body,\n children,\n isOverlay = true,\n \"data-testid\": dataTestId,\n}: ModalProps) => {\n const overlayRef = useRef<HTMLDivElement>(null);\n const { isClosing, handleClose } = useIsClosing({\n onClose,\n overlayRef,\n });\n const isMobile = useBreakpoint(BREAKPOINTS.MEDIUM);\n\n if (!isOpen) return null;\n\n const modalContent = (\n <ModalContent\n isOpen={isOpen}\n title={title}\n subtitle={subtitle}\n body={body}\n onClose={handleClose}\n isClosing={isClosing}\n data-testid={dataTestId}\n >\n {children}\n </ModalContent>\n );\n\n return isOverlay || isMobile ? (\n <ScreenOverlay fadeIn ref={overlayRef} onClose={handleClose}>\n {modalContent}\n </ScreenOverlay>\n ) : (\n modalContent\n );\n};\n\nexport const Modal = Object.assign(ModalWrapper, {\n /**\n * Renders a h2 styled title\n * */\n Title: ModalTitle,\n /**\n * Renders a h3 styled subtitle\n * */\n Subtitle: ModalSubtitle,\n /**\n * Renders a div styled body\n * */\n Body: ModalBody,\n /**\n * Renders a Proton Button action\n * - @prop buttonProps {@link ButtonProps}\n * */\n Action: ModalAction,\n /**\n * Renders a group of Proton Buttons\n * */\n Actions: ModalActions,\n});\n"],"names":["ModalTitle","children","jsx","ModalSubtitle","ModalBody","ModalAction","buttonProps","Button","ModalActions","FocusScope","ModalContent","title","subtitle","body","onClose","isClosing","dataTestId","ref","useRef","state","useOverlayTriggerState","modalProps","useModalOverlay","dialogProps","useDialog","usePreventScroll","closeButtonRef","closeButtonProps","useButton","jsxs","csx","mergeProps","ModalWrapper","isOpen","isOverlay","overlayRef","handleClose","useIsClosing","isMobile","useBreakpoint","BREAKPOINTS","modalContent","ScreenOverlay","Modal"],"mappings":"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"}
1
+ {"version":3,"file":"Modal.es.js","sources":["../../../src/components/Modal/Modal.tsx"],"sourcesContent":["\"use client\";\n\nimport { useRef } from \"react\";\nimport { BREAKPOINTS } from \"../../constants\";\nimport { useBreakpoint } from \"../../hooks\";\nimport { useIsClosing } from \"../../hooks/useIsClosing\";\nimport { csx } from \"../../utils\";\nimport { Button, ButtonProps } from \"../Button/Button\";\nimport \"./Modal.css\";\nimport { ScreenOverlay } from \"../ScreenOverlay/ScreenOverlay\";\n\nconst ModalTitle = ({ children }: { children: React.ReactNode }) => {\n return <h2 className=\"proton-Modal__title\">{children}</h2>;\n};\n\nconst ModalSubtitle = ({ children }: { children: React.ReactNode }) => {\n return <h3 className=\"proton-Modal__subtitle\">{children}</h3>;\n};\n\nconst ModalBody = ({ children }: { children: React.ReactNode }) => {\n return <div className=\"proton-Modal__body\">{children}</div>;\n};\n\nconst ModalAction = (buttonProps: ButtonProps) => {\n return (\n <div className=\"proton-Modal__action\">\n <Button {...buttonProps} />\n </div>\n );\n};\n\nconst ModalActions = ({ children }: { children: React.ReactNode }) => {\n return <div className=\"proton-Modal__actions\">{children}</div>;\n};\n\nconst ModalContent = ({\n title,\n subtitle,\n body,\n onClose,\n children,\n isClosing,\n \"data-testid\": dataTestId,\n}: ModalProps & {\n isClosing: boolean;\n}) => {\n const ref = useRef<HTMLDivElement>(null);\n const closeButtonRef = useRef<HTMLButtonElement>(null);\n\n return (\n <div\n data-testid={dataTestId}\n className={csx(\"proton-Modal\", isClosing && \"proton-Modal--closing\")}\n role=\"dialog\"\n tabIndex={-1}\n ref={ref}\n >\n <button\n name=\"Close\"\n className=\"proton-Modal__close-button\"\n onClick={onClose}\n aria-label=\"Close\"\n ref={closeButtonRef}\n >\n ×\n </button>\n {title && <ModalTitle>{title}</ModalTitle>}\n {subtitle && <ModalSubtitle>{subtitle}</ModalSubtitle>}\n {body && <ModalBody>{body}</ModalBody>}\n <div className=\"proton-Modal__content\">{children}</div>\n </div>\n );\n};\n\nexport interface ModalProps {\n /**\n * Optional body text content for the modal\n * */\n body?: string;\n /**\n * Content to render inside the modal\n * */\n children: React.ReactNode;\n /**\n * data-testid for the modal\n * */\n \"data-testid\"?: string;\n /**\n * Controls the visibility of the modal\n * */\n isOpen: boolean;\n /**\n * Whether to show the modal with an overlay background.\n * @default true\n * */\n isOverlay?: boolean;\n /**\n * Callback function when modal is closed\n * */\n onClose?: () => void;\n /**\n * Optional subtitle text below the modal title\n * */\n subtitle?: string;\n /**\n * Optional title text for the modal header\n * */\n title?: string;\n}\n\n/**\n * Modal component with overlay support and responsive behavior.\n *\n * API:\n * - {@link ModalProps}\n */\nconst ModalWrapper = ({\n isOpen,\n onClose,\n title,\n subtitle,\n body,\n children,\n isOverlay = true,\n \"data-testid\": dataTestId,\n}: ModalProps) => {\n const overlayRef = useRef<HTMLDivElement>(null);\n const { isClosing, handleClose } = useIsClosing({\n onClose,\n overlayRef,\n });\n const isMobile = useBreakpoint(BREAKPOINTS.MEDIUM);\n\n if (!isOpen) return null;\n\n const modalContent = (\n <ModalContent\n isOpen={isOpen}\n title={title}\n subtitle={subtitle}\n body={body}\n onClose={handleClose}\n isClosing={isClosing}\n data-testid={dataTestId}\n >\n {children}\n </ModalContent>\n );\n\n return isOverlay || isMobile ? (\n <ScreenOverlay fadeIn ref={overlayRef} onClose={handleClose}>\n {modalContent}\n </ScreenOverlay>\n ) : (\n modalContent\n );\n};\n\nexport const Modal = Object.assign(ModalWrapper, {\n /**\n * Renders a h2 styled title\n * */\n Title: ModalTitle,\n /**\n * Renders a h3 styled subtitle\n * */\n Subtitle: ModalSubtitle,\n /**\n * Renders a div styled body\n * */\n Body: ModalBody,\n /**\n * Renders a Proton Button action\n * - @prop buttonProps {@link ButtonProps}\n * */\n Action: ModalAction,\n /**\n * Renders a group of Proton Buttons\n * */\n Actions: ModalActions,\n});\n"],"names":["ModalTitle","children","jsx","ModalSubtitle","ModalBody","ModalAction","buttonProps","Button","ModalActions","ModalContent","title","subtitle","body","onClose","isClosing","dataTestId","ref","useRef","closeButtonRef","jsxs","csx","ModalWrapper","isOpen","isOverlay","overlayRef","handleClose","useIsClosing","isMobile","useBreakpoint","BREAKPOINTS","modalContent","ScreenOverlay","Modal"],"mappings":";;;;;;;;;AAWA,MAAMA,IAAa,CAAC,EAAE,UAAAC,QACZC,gBAAAA,EAAAA,IAAA,MAAA,EAAG,WAAU,uBAAuB,UAAAD,EAAS,CAAA,GAGjDE,IAAgB,CAAC,EAAE,UAAAF,QACfC,gBAAAA,EAAAA,IAAA,MAAA,EAAG,WAAU,0BAA0B,UAAAD,EAAS,CAAA,GAGpDG,IAAY,CAAC,EAAE,UAAAH,QACXC,gBAAAA,EAAAA,IAAA,OAAA,EAAI,WAAU,sBAAsB,UAAAD,EAAS,CAAA,GAGjDI,IAAc,CAACC,MAEjBJ,gBAAAA,MAAC,SAAI,WAAU,wBACb,gCAACK,GAAQ,EAAA,GAAGD,EAAa,CAAA,EAC3B,CAAA,GAIEE,IAAe,CAAC,EAAE,UAAAP,QACdC,gBAAAA,EAAAA,IAAA,OAAA,EAAI,WAAU,yBAAyB,UAAAD,EAAS,CAAA,GAGpDQ,IAAe,CAAC;AAAA,EACpB,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,MAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAZ;AAAA,EACA,WAAAa;AAAA,EACA,eAAeC;AACjB,MAEM;AACE,QAAAC,IAAMC,EAAuB,IAAI,GACjCC,IAAiBD,EAA0B,IAAI;AAGnD,SAAAE,gBAAAA,EAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,eAAaJ;AAAA,MACb,WAAWK,EAAI,gBAAgBN,KAAa,uBAAuB;AAAA,MACnE,MAAK;AAAA,MACL,UAAU;AAAA,MACV,KAAAE;AAAA,MAEA,UAAA;AAAA,QAAAd,gBAAAA,EAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,WAAU;AAAA,YACV,SAASW;AAAA,YACT,cAAW;AAAA,YACX,KAAKK;AAAA,YACN,UAAA;AAAA,UAAA;AAAA,QAED;AAAA,QACCR,KAAUR,gBAAAA,EAAAA,IAAAF,GAAA,EAAY,UAAMU,EAAA,CAAA;AAAA,QAC5BC,KAAaT,gBAAAA,EAAAA,IAAAC,GAAA,EAAe,UAASQ,EAAA,CAAA;AAAA,QACrCC,KAASV,gBAAAA,EAAAA,IAAAE,GAAA,EAAW,UAAKQ,EAAA,CAAA;AAAA,QACzBV,gBAAAA,EAAAA,IAAA,OAAA,EAAI,WAAU,yBAAyB,UAAAD,EAAS,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGvD,GA4CMoB,IAAe,CAAC;AAAA,EACpB,QAAAC;AAAA,EACA,SAAAT;AAAA,EACA,OAAAH;AAAA,EACA,UAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAX;AAAA,EACA,WAAAsB,IAAY;AAAA,EACZ,eAAeR;AACjB,MAAkB;AACV,QAAAS,IAAaP,EAAuB,IAAI,GACxC,EAAE,WAAAH,GAAW,aAAAW,EAAY,IAAIC,EAAa;AAAA,IAC9C,SAAAb;AAAA,IACA,YAAAW;AAAA,EAAA,CACD,GACKG,IAAWC,EAAcC,EAAY,MAAM;AAE7C,MAAA,CAACP,EAAe,QAAA;AAEpB,QAAMQ,IACJ5B,gBAAAA,EAAA;AAAA,IAACO;AAAA,IAAA;AAAA,MACC,QAAAa;AAAA,MACA,OAAAZ;AAAA,MACA,UAAAC;AAAA,MACA,MAAAC;AAAA,MACA,SAASa;AAAA,MACT,WAAAX;AAAA,MACA,eAAaC;AAAA,MAEZ,UAAAd;AAAA,IAAA;AAAA,EAAA;AAIE,SAAAsB,KAAaI,IAClBzB,gBAAAA,EAAAA,IAAC6B,GAAc,EAAA,QAAM,IAAC,KAAKP,GAAY,SAASC,GAC7C,UAAAK,EAAA,CACH,IAEAA;AAEJ,GAEaE,IAAQ,OAAO,OAAOX,GAAc;AAAA;AAAA;AAAA;AAAA,EAI/C,OAAOrB;AAAA;AAAA;AAAA;AAAA,EAIP,UAAUG;AAAA;AAAA;AAAA;AAAA,EAIV,MAAMC;AAAA;AAAA;AAAA;AAAA;AAAA,EAKN,QAAQC;AAAA;AAAA;AAAA;AAAA,EAIR,SAASG;AACX,CAAC;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@react-aria/utils"),I=require("../../interactions/dist/useFocusVisible.cjs.js"),K=require("../../interactions/dist/focusSafely.cjs.js"),N=require("react"),D=N.createContext(null),R="react-aria-focus-scope-restore";let v=null;function P(e){let{children:t,contain:r,restoreFocus:u,autoFocus:n}=e,i=N.useRef(null),a=N.useRef(null),o=N.useRef([]),{parentNode:E}=N.useContext(D)||{},l=N.useMemo(()=>new x({scopeRef:o}),[o]);d.useLayoutEffect(()=>{let f=E||m.root;if(m.getTreeNode(f.scopeRef)&&v&&!L(v,f.scopeRef)){let s=m.getTreeNode(v);s&&(f=s)}f.addChild(l),m.addNode(l)},[l,E]),d.useLayoutEffect(()=>{let f=m.getTreeNode(o);f&&(f.contain=!!r)},[r]),d.useLayoutEffect(()=>{var f;let s=(f=i.current)===null||f===void 0?void 0:f.nextSibling,p=[],y=F=>F.stopPropagation();for(;s&&s!==a.current;)p.push(s),s.addEventListener(R,y),s=s.nextSibling;return o.current=p,()=>{for(let F of p)F.removeEventListener(R,y)}},[t]),B(o,u,r),J(o,r),V(o,u,r),W(o,n),N.useEffect(()=>{const f=d.getActiveElement(d.getOwnerDocument(o.current?o.current[0]:void 0));let s=null;if(g(f,o.current)){for(let p of m.traverse())p.scopeRef&&g(f,p.scopeRef.current)&&(s=p);s===m.getTreeNode(o)&&(v=s.scopeRef)}},[o]),d.useLayoutEffect(()=>()=>{var f,s,p;let y=(p=(s=m.getTreeNode(o))===null||s===void 0||(f=s.parent)===null||f===void 0?void 0:f.scopeRef)!==null&&p!==void 0?p:null;(o===v||L(o,v))&&(!y||m.getTreeNode(y))&&(v=y),m.removeTreeNode(o)},[o]);let b=N.useMemo(()=>q(o),[]),c=N.useMemo(()=>({focusManager:b,parentNode:l}),[l,b]);return N.createElement(D.Provider,{value:c},N.createElement("span",{"data-focus-scope-start":!0,hidden:!0,ref:i}),t,N.createElement("span",{"data-focus-scope-end":!0,hidden:!0,ref:a}))}function q(e){return{focusNext(t={}){let r=e.current,{from:u,tabbable:n,wrap:i,accept:a}=t;var o;let E=u||d.getActiveElement(d.getOwnerDocument((o=r[0])!==null&&o!==void 0?o:void 0)),l=r[0].previousElementSibling,b=w(r),c=h(b,{tabbable:n,accept:a},r);c.currentNode=g(E,r)?E:l;let f=c.nextNode();return!f&&i&&(c.currentNode=l,f=c.nextNode()),f&&T(f,!0),f},focusPrevious(t={}){let r=e.current,{from:u,tabbable:n,wrap:i,accept:a}=t;var o;let E=u||d.getActiveElement(d.getOwnerDocument((o=r[0])!==null&&o!==void 0?o:void 0)),l=r[r.length-1].nextElementSibling,b=w(r),c=h(b,{tabbable:n,accept:a},r);c.currentNode=g(E,r)?E:l;let f=c.previousNode();return!f&&i&&(c.currentNode=l,f=c.previousNode()),f&&T(f,!0),f},focusFirst(t={}){let r=e.current,{tabbable:u,accept:n}=t,i=w(r),a=h(i,{tabbable:u,accept:n},r);a.currentNode=r[0].previousElementSibling;let o=a.nextNode();return o&&T(o,!0),o},focusLast(t={}){let r=e.current,{tabbable:u,accept:n}=t,i=w(r),a=h(i,{tabbable:u,accept:n},r);a.currentNode=r[r.length-1].nextElementSibling;let o=a.previousNode();return o&&T(o,!0),o}}}function w(e){return e[0].parentElement}function S(e){let t=m.getTreeNode(v);for(;t&&t.scopeRef!==e;){if(t.contain)return!1;t=t.parent}return!0}function z(e){if(e.checked)return!0;let t=[];if(!e.form)t=[...d.getOwnerDocument(e).querySelectorAll(`input[type="radio"][name="${CSS.escape(e.name)}"]`)].filter(i=>!i.form);else{var r,u;let i=(u=e.form)===null||u===void 0||(r=u.elements)===null||r===void 0?void 0:r.namedItem(e.name);t=[...i??[]]}return t?!t.some(i=>i.checked):!1}function J(e,t){let r=N.useRef(void 0),u=N.useRef(void 0);d.useLayoutEffect(()=>{let n=e.current;if(!t){u.current&&(cancelAnimationFrame(u.current),u.current=void 0);return}const i=d.getOwnerDocument(n?n[0]:void 0);let a=l=>{if(l.key!=="Tab"||l.altKey||l.ctrlKey||l.metaKey||!S(e)||l.isComposing)return;let b=d.getActiveElement(i),c=e.current;if(!c||!g(b,c))return;let f=w(c),s=h(f,{tabbable:!0},c);if(!b)return;s.currentNode=b;let p=l.shiftKey?s.previousNode():s.nextNode();p||(s.currentNode=l.shiftKey?c[c.length-1].nextElementSibling:c[0].previousElementSibling,p=l.shiftKey?s.previousNode():s.nextNode()),l.preventDefault(),p&&T(p,!0)},o=l=>{(!v||L(v,e))&&g(d.getEventTarget(l),e.current)?(v=e,r.current=d.getEventTarget(l)):S(e)&&!$(d.getEventTarget(l),e)?r.current?r.current.focus():v&&v.current&&C(v.current):S(e)&&(r.current=d.getEventTarget(l))},E=l=>{u.current&&cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{let b=I.getInteractionModality(),c=(b==="virtual"||b===null)&&d.isAndroid()&&d.isChrome(),f=d.getActiveElement(i);if(!c&&f&&S(e)&&!$(f,e)){v=e;let p=d.getEventTarget(l);if(p&&p.isConnected){var s;r.current=p,(s=r.current)===null||s===void 0||s.focus()}else v.current&&C(v.current)}})};return i.addEventListener("keydown",a,!1),i.addEventListener("focusin",o,!1),n==null||n.forEach(l=>l.addEventListener("focusin",o,!1)),n==null||n.forEach(l=>l.addEventListener("focusout",E,!1)),()=>{i.removeEventListener("keydown",a,!1),i.removeEventListener("focusin",o,!1),n==null||n.forEach(l=>l.removeEventListener("focusin",o,!1)),n==null||n.forEach(l=>l.removeEventListener("focusout",E,!1))}},[e,t]),d.useLayoutEffect(()=>()=>{u.current&&cancelAnimationFrame(u.current)},[u])}function _(e){return $(e)}function g(e,t){return!e||!t?!1:t.some(r=>r.contains(e))}function $(e,t=null){if(e instanceof Element&&e.closest("[data-react-aria-top-layer]"))return!0;for(let{scopeRef:r}of m.traverse(m.getTreeNode(t)))if(r&&g(e,r.current))return!0;return!1}function U(e){return $(e,v)}function L(e,t){var r;let u=(r=m.getTreeNode(t))===null||r===void 0?void 0:r.parent;for(;u;){if(u.scopeRef===e)return!0;u=u.parent}return!1}function T(e,t=!1){if(e!=null&&!t)try{K.focusSafely(e)}catch{}else if(e!=null)try{e.focus()}catch{}}function O(e,t=!0){let r=e[0].previousElementSibling,u=w(e),n=h(u,{tabbable:t},e);n.currentNode=r;let i=n.nextNode();return t&&!i&&(u=w(e),n=h(u,{tabbable:!1},e),n.currentNode=r,i=n.nextNode()),i}function C(e,t=!0){T(O(e,t))}function W(e,t){const r=N.useRef(t);N.useEffect(()=>{if(r.current){v=e;const u=d.getOwnerDocument(e.current?e.current[0]:void 0);!g(d.getActiveElement(u),v.current)&&e.current&&C(e.current)}r.current=!1},[e])}function B(e,t,r){d.useLayoutEffect(()=>{if(t||r)return;let u=e.current;const n=d.getOwnerDocument(u?u[0]:void 0);let i=a=>{let o=d.getEventTarget(a);g(o,e.current)?v=e:_(o)||(v=null)};return n.addEventListener("focusin",i,!1),u==null||u.forEach(a=>a.addEventListener("focusin",i,!1)),()=>{n.removeEventListener("focusin",i,!1),u==null||u.forEach(a=>a.removeEventListener("focusin",i,!1))}},[e,t,r])}function k(e){let t=m.getTreeNode(v);for(;t&&t.scopeRef!==e;){if(t.nodeToRestore)return!1;t=t.parent}return(t==null?void 0:t.scopeRef)===e}function V(e,t,r){const u=N.useRef(typeof document<"u"?d.getActiveElement(d.getOwnerDocument(e.current?e.current[0]:void 0)):null);d.useLayoutEffect(()=>{let n=e.current;const i=d.getOwnerDocument(n?n[0]:void 0);if(!t||r)return;let a=()=>{(!v||L(v,e))&&g(d.getActiveElement(i),e.current)&&(v=e)};return i.addEventListener("focusin",a,!1),n==null||n.forEach(o=>o.addEventListener("focusin",a,!1)),()=>{i.removeEventListener("focusin",a,!1),n==null||n.forEach(o=>o.removeEventListener("focusin",a,!1))}},[e,r]),d.useLayoutEffect(()=>{const n=d.getOwnerDocument(e.current?e.current[0]:void 0);if(!t)return;let i=a=>{if(a.key!=="Tab"||a.altKey||a.ctrlKey||a.metaKey||!S(e)||a.isComposing)return;let o=n.activeElement;if(!$(o,e)||!k(e))return;let E=m.getTreeNode(e);if(!E)return;let l=E.nodeToRestore,b=h(n.body,{tabbable:!0});b.currentNode=o;let c=a.shiftKey?b.previousNode():b.nextNode();if((!l||!l.isConnected||l===n.body)&&(l=void 0,E.nodeToRestore=void 0),(!c||!$(c,e))&&l){b.currentNode=l;do c=a.shiftKey?b.previousNode():b.nextNode();while($(c,e));a.preventDefault(),a.stopPropagation(),c?T(c,!0):_(l)?T(l,!0):o.blur()}};return r||n.addEventListener("keydown",i,!0),()=>{r||n.removeEventListener("keydown",i,!0)}},[e,t,r]),d.useLayoutEffect(()=>{const n=d.getOwnerDocument(e.current?e.current[0]:void 0);if(!t)return;let i=m.getTreeNode(e);if(i){var a;return i.nodeToRestore=(a=u.current)!==null&&a!==void 0?a:void 0,()=>{let o=m.getTreeNode(e);if(!o)return;let E=o.nodeToRestore,l=d.getActiveElement(n);if(t&&E&&(l&&$(l,e)||l===n.body&&k(e))){let b=m.clone();requestAnimationFrame(()=>{if(n.activeElement===n.body){let c=b.getTreeNode(e);for(;c;){if(c.nodeToRestore&&c.nodeToRestore.isConnected){M(c.nodeToRestore);return}c=c.parent}for(c=b.getTreeNode(e);c;){if(c.scopeRef&&c.scopeRef.current&&m.getTreeNode(c.scopeRef)){let f=O(c.scopeRef.current,!0);M(f);return}c=c.parent}}})}}}},[e,t])}function M(e){e.dispatchEvent(new CustomEvent(R,{bubbles:!0,cancelable:!0}))&&T(e)}function h(e,t,r){let u=t!=null&&t.tabbable?d.isTabbable:d.isFocusable,n=(e==null?void 0:e.nodeType)===Node.ELEMENT_NODE?e:null,i=d.getOwnerDocument(n),a=d.createShadowTreeWalker(i,e||i,NodeFilter.SHOW_ELEMENT,{acceptNode(o){var E;return!(t==null||(E=t.from)===null||E===void 0)&&E.contains(o)||t!=null&&t.tabbable&&o.tagName==="INPUT"&&o.getAttribute("type")==="radio"&&(!z(o)||a.currentNode.tagName==="INPUT"&&a.currentNode.type==="radio"&&a.currentNode.name===o.name)?NodeFilter.FILTER_REJECT:u(o)&&(!r||g(o,r))&&(!(t!=null&&t.accept)||t.accept(o))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});return t!=null&&t.from&&(a.currentNode=t.from),a}class A{get size(){return this.fastMap.size}getTreeNode(t){return this.fastMap.get(t)}addTreeNode(t,r,u){let n=this.fastMap.get(r??null);if(!n)return;let i=new x({scopeRef:t});n.addChild(i),i.parent=n,this.fastMap.set(t,i),u&&(i.nodeToRestore=u)}addNode(t){this.fastMap.set(t.scopeRef,t)}removeTreeNode(t){if(t===null)return;let r=this.fastMap.get(t);if(!r)return;let u=r.parent;for(let i of this.traverse())i!==r&&r.nodeToRestore&&i.nodeToRestore&&r.scopeRef&&r.scopeRef.current&&g(i.nodeToRestore,r.scopeRef.current)&&(i.nodeToRestore=r.nodeToRestore);let n=r.children;u&&(u.removeChild(r),n.size>0&&n.forEach(i=>u&&u.addChild(i))),this.fastMap.delete(r.scopeRef)}*traverse(t=this.root){if(t.scopeRef!=null&&(yield t),t.children.size>0)for(let r of t.children)yield*this.traverse(r)}clone(){var t;let r=new A;var u;for(let n of this.traverse())r.addTreeNode(n.scopeRef,(u=(t=n.parent)===null||t===void 0?void 0:t.scopeRef)!==null&&u!==void 0?u:null,n.nodeToRestore);return r}constructor(){this.fastMap=new Map,this.root=new x({scopeRef:null}),this.fastMap.set(null,this.root)}}class x{addChild(t){this.children.add(t),t.parent=this}removeChild(t){this.children.delete(t),t.parent=void 0}constructor(t){this.children=new Set,this.contain=!1,this.scopeRef=t.scopeRef}}let m=new A;exports.FocusScope=P;exports.focusScopeTree=m;exports.getFocusableTreeWalker=h;exports.isElementInChildOfActiveScope=U;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@react-aria/utils");function h(a){if(a.checked)return!0;let e=[];if(!a.form)e=[...n.getOwnerDocument(a).querySelectorAll(`input[type="radio"][name="${CSS.escape(a.name)}"]`)].filter(t=>!t.form);else{var r,i;let t=(i=a.form)===null||i===void 0||(r=i.elements)===null||r===void 0?void 0:r.namedItem(a.name);e=[...t??[]]}return e?!e.some(t=>t.checked):!1}function u(a,e){return!a||!e?!1:e.some(r=>r.contains(a))}function v(a,e,r){let i=e!=null&&e.tabbable?n.isTabbable:n.isFocusable,l=(a==null?void 0:a.nodeType)===Node.ELEMENT_NODE?a:null,t=n.getOwnerDocument(l),d=n.createShadowTreeWalker(t,a||t,NodeFilter.SHOW_ELEMENT,{acceptNode(o){var s;return!(e==null||(s=e.from)===null||s===void 0)&&s.contains(o)||e!=null&&e.tabbable&&o.tagName==="INPUT"&&o.getAttribute("type")==="radio"&&(!h(o)||d.currentNode.tagName==="INPUT"&&d.currentNode.type==="radio"&&d.currentNode.name===o.name)?NodeFilter.FILTER_REJECT:i(o)&&(!r||u(o,r))&&(!(e!=null&&e.accept)||e.accept(o))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});return e!=null&&e.from&&(d.currentNode=e.from),d}class f{get size(){return this.fastMap.size}getTreeNode(e){return this.fastMap.get(e)}addTreeNode(e,r,i){let l=this.fastMap.get(r??null);if(!l)return;let t=new c({scopeRef:e});l.addChild(t),t.parent=l,this.fastMap.set(e,t),i&&(t.nodeToRestore=i)}addNode(e){this.fastMap.set(e.scopeRef,e)}removeTreeNode(e){if(e===null)return;let r=this.fastMap.get(e);if(!r)return;let i=r.parent;for(let t of this.traverse())t!==r&&r.nodeToRestore&&t.nodeToRestore&&r.scopeRef&&r.scopeRef.current&&u(t.nodeToRestore,r.scopeRef.current)&&(t.nodeToRestore=r.nodeToRestore);let l=r.children;i&&(i.removeChild(r),l.size>0&&l.forEach(t=>i&&i.addChild(t))),this.fastMap.delete(r.scopeRef)}*traverse(e=this.root){if(e.scopeRef!=null&&(yield e),e.children.size>0)for(let r of e.children)yield*this.traverse(r)}clone(){var e;let r=new f;var i;for(let l of this.traverse())r.addTreeNode(l.scopeRef,(i=(e=l.parent)===null||e===void 0?void 0:e.scopeRef)!==null&&i!==void 0?i:null,l.nodeToRestore);return r}constructor(){this.fastMap=new Map,this.root=new c({scopeRef:null}),this.fastMap.set(null,this.root)}}class c{addChild(e){this.children.add(e),e.parent=this}removeChild(e){this.children.delete(e),e.parent=void 0}constructor(e){this.children=new Set,this.contain=!1,this.scopeRef=e.scopeRef}}new f;exports.getFocusableTreeWalker=v;
2
2
  //# sourceMappingURL=FocusScope.cjs.js.map