@simplybusiness/mobius 4.3.6 → 4.4.1

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 (91) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/components/Box/Box.js +19 -1
  3. package/dist/cjs/components/Box/Box.js.map +1 -1
  4. package/dist/cjs/components/Box/types.js +6 -0
  5. package/dist/cjs/components/Box/types.js.map +1 -0
  6. package/dist/cjs/components/Drawer/Drawer.js +12 -6
  7. package/dist/cjs/components/Drawer/Drawer.js.map +1 -1
  8. package/dist/cjs/components/Flex/propUtils.js +6 -8
  9. package/dist/cjs/components/Flex/propUtils.js.map +1 -1
  10. package/dist/cjs/components/Grid/Grid.js +5 -5
  11. package/dist/cjs/components/Grid/Grid.js.map +1 -1
  12. package/dist/cjs/components/Modal/Modal.js +12 -6
  13. package/dist/cjs/components/Modal/Modal.js.map +1 -1
  14. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  15. package/dist/cjs/utils/filterUndefinedProps.js +21 -0
  16. package/dist/cjs/utils/filterUndefinedProps.js.map +1 -0
  17. package/dist/cjs/utils/getSpacingValue.js +21 -0
  18. package/dist/cjs/utils/getSpacingValue.js.map +1 -0
  19. package/dist/cjs/utils/index.js +3 -0
  20. package/dist/cjs/utils/index.js.map +1 -1
  21. package/dist/cjs/utils/sizeClasses.js +1 -0
  22. package/dist/cjs/utils/sizeClasses.js.map +1 -1
  23. package/dist/cjs/utils/sizeOptions.js +22 -0
  24. package/dist/cjs/utils/sizeOptions.js.map +1 -0
  25. package/dist/esm/components/Box/Box.js +19 -1
  26. package/dist/esm/components/Box/Box.js.map +1 -1
  27. package/dist/esm/components/Box/types.js +3 -0
  28. package/dist/esm/components/Box/types.js.map +1 -0
  29. package/dist/esm/components/Drawer/Drawer.js +12 -6
  30. package/dist/esm/components/Drawer/Drawer.js.map +1 -1
  31. package/dist/esm/components/Flex/propUtils.js +6 -5
  32. package/dist/esm/components/Flex/propUtils.js.map +1 -1
  33. package/dist/esm/components/Flex/types.js.map +1 -1
  34. package/dist/esm/components/Grid/Grid.js +5 -5
  35. package/dist/esm/components/Grid/Grid.js.map +1 -1
  36. package/dist/esm/components/Modal/Modal.js +12 -6
  37. package/dist/esm/components/Modal/Modal.js.map +1 -1
  38. package/dist/esm/types/size.js.map +1 -1
  39. package/dist/esm/utils/filterUndefinedProps.js +11 -0
  40. package/dist/esm/utils/filterUndefinedProps.js.map +1 -0
  41. package/dist/esm/utils/getSpacingValue.js +11 -0
  42. package/dist/esm/utils/getSpacingValue.js.map +1 -0
  43. package/dist/esm/utils/index.js +3 -0
  44. package/dist/esm/utils/index.js.map +1 -1
  45. package/dist/esm/utils/sizeClasses.js +1 -0
  46. package/dist/esm/utils/sizeClasses.js.map +1 -1
  47. package/dist/esm/utils/sizeOptions.js +12 -0
  48. package/dist/esm/utils/sizeOptions.js.map +1 -0
  49. package/dist/types/components/Box/Box.d.ts +2 -11
  50. package/dist/types/components/Box/types.d.ts +31 -0
  51. package/dist/types/components/Flex/propUtils.d.ts +1 -6
  52. package/dist/types/components/Flex/types.d.ts +4 -3
  53. package/dist/types/components/Grid/Grid.d.ts +4 -3
  54. package/dist/types/types/size.d.ts +2 -1
  55. package/dist/types/utils/filterUndefinedProps.d.ts +1 -0
  56. package/dist/types/utils/filterUndefinedProps.test.d.ts +1 -0
  57. package/dist/types/utils/getSpacingValue.d.ts +2 -0
  58. package/dist/types/utils/getSpacingValue.test.d.ts +1 -0
  59. package/dist/types/utils/index.d.ts +3 -0
  60. package/dist/types/utils/sizeClasses.d.ts +2 -0
  61. package/dist/types/utils/sizeOptions.d.ts +2 -0
  62. package/package.json +19 -19
  63. package/src/components/Box/Box.mdx +6 -2
  64. package/src/components/Box/Box.stories.tsx +72 -6
  65. package/src/components/Box/Box.test.tsx +189 -8
  66. package/src/components/Box/Box.tsx +52 -15
  67. package/src/components/Box/types.ts +34 -0
  68. package/src/components/Drawer/Drawer.tsx +15 -7
  69. package/src/components/Flex/Flex.mdx +0 -10
  70. package/src/components/Flex/Flex.stories.tsx +3 -17
  71. package/src/components/Flex/propUtils.test.ts +14 -35
  72. package/src/components/Flex/propUtils.ts +6 -7
  73. package/src/components/Flex/types.ts +4 -3
  74. package/src/components/Grid/Grid.mdx +0 -10
  75. package/src/components/Grid/Grid.stories.tsx +6 -19
  76. package/src/components/Grid/Grid.tsx +9 -8
  77. package/src/components/Modal/Modal.tsx +15 -7
  78. package/src/types/size.ts +3 -1
  79. package/src/utils/filterUndefinedProps.test.ts +15 -0
  80. package/src/utils/filterUndefinedProps.ts +9 -0
  81. package/src/utils/getSpacingValue.test.ts +33 -0
  82. package/src/utils/getSpacingValue.ts +15 -0
  83. package/src/utils/index.ts +3 -0
  84. package/src/utils/sizeClasses.test.ts +1 -1
  85. package/src/utils/sizeClasses.ts +1 -0
  86. package/src/utils/sizeOptions.ts +12 -0
  87. package/dist/cjs/components/Icon/IconStyle.js +0 -413
  88. package/dist/cjs/components/Icon/IconStyle.js.map +0 -1
  89. package/dist/esm/components/Icon/IconStyle.js +0 -403
  90. package/dist/esm/components/Icon/IconStyle.js.map +0 -1
  91. package/dist/types/components/Icon/IconStyle.d.ts +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 10a1de9: Fix `<Drawer>` closing transition occasionally not firing
8
+
9
+ ## 4.4.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 9cff6ac: Add new props to `<Box>`: padding, min/max width/height to make the component more flexible when building layouts
14
+
3
15
  ## 4.3.6
4
16
 
5
17
  ### Patch Changes
@@ -11,16 +11,34 @@ Object.defineProperty(exports, "Box", {
11
11
  const _jsxruntime = require("react/jsx-runtime");
12
12
  const _react = require("react");
13
13
  const _dedupe = /*#__PURE__*/ _interop_require_default(require("classnames/dedupe"));
14
+ const _utils = require("../../utils");
14
15
  function _interop_require_default(obj) {
15
16
  return obj && obj.__esModule ? obj : {
16
17
  default: obj
17
18
  };
18
19
  }
19
20
  const Box = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
20
- const { elementType: Element = "div", ...otherProps } = props;
21
+ const { elementType: Element = "div", padding, paddingX, paddingInline, paddingInlineStart, paddingInlineEnd, paddingY, paddingBlock, paddingBlockStart, paddingBlockEnd, paddingTop, paddingRight, paddingBottom, paddingLeft, minWidth, minHeight, maxWidth, maxHeight, width, height, style, ...otherProps } = props;
21
22
  const classes = (0, _dedupe.default)("mobius", "mobius/Box", otherProps.className);
23
+ const styleProps = (0, _utils.filterUndefinedProps)({
24
+ padding: (0, _utils.getSpacingValue)(padding),
25
+ paddingInline: (0, _utils.getSpacingValue)(paddingInline || paddingX),
26
+ paddingBlock: (0, _utils.getSpacingValue)(paddingBlock || paddingY),
27
+ paddingTop: (0, _utils.getSpacingValue)(paddingTop || paddingBlockStart),
28
+ paddingRight: (0, _utils.getSpacingValue)(paddingRight || paddingInlineEnd),
29
+ paddingBottom: (0, _utils.getSpacingValue)(paddingBottom || paddingBlockEnd),
30
+ paddingLeft: (0, _utils.getSpacingValue)(paddingLeft || paddingInlineStart),
31
+ minWidth,
32
+ minHeight,
33
+ maxWidth,
34
+ maxHeight,
35
+ width,
36
+ height,
37
+ ...style
38
+ });
22
39
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(Element, {
23
40
  ref: ref,
41
+ style: styleProps,
24
42
  ...otherProps,
25
43
  className: classes
26
44
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/Box/Box.tsx"],"sourcesContent":["import { Ref, forwardRef, RefAttributes, ReactNode } from \"react\";\nimport classNames from \"classnames/dedupe\";\nimport { DOMProps } from \"../../types/dom\";\nimport { ForwardedRefComponent } from \"../../types/components\";\n\nexport type BoxElementType = HTMLDivElement;\n\nexport interface BoxProps extends DOMProps, RefAttributes<BoxElementType> {\n children?: ReactNode;\n /** Custom class name for setting specific CSS */\n className?: string;\n /** HTML element for the Box */\n elementType?: \"div\" | \"span\";\n style?: React.CSSProperties;\n}\n\nexport type BoxRef = Ref<BoxElementType>;\n\nconst Box: ForwardedRefComponent<BoxProps, BoxElementType> = forwardRef(\n (props: BoxProps, ref: BoxRef) => {\n const { elementType: Element = \"div\", ...otherProps } = props;\n\n const classes = classNames(\"mobius\", \"mobius/Box\", otherProps.className);\n\n return <Element ref={ref} {...otherProps} className={classes} />;\n },\n);\n\nBox.displayName = \"Box\";\nexport { Box };\n"],"names":["Box","forwardRef","props","ref","elementType","Element","otherProps","classes","classNames","className","displayName"],"mappings":";;;;+BA6BSA;;;eAAAA;;;;uBA7BiD;+DACnC;;;;;;AAiBvB,MAAMA,oBAAuDC,IAAAA,iBAAU,EACrE,CAACC,OAAiBC;IAChB,MAAM,EAAEC,aAAaC,UAAU,KAAK,EAAE,GAAGC,YAAY,GAAGJ;IAExD,MAAMK,UAAUC,IAAAA,eAAU,EAAC,UAAU,cAAcF,WAAWG,SAAS;IAEvE,qBAAO,qBAACJ;QAAQF,KAAKA;QAAM,GAAGG,UAAU;QAAEG,WAAWF;;AACvD;AAGFP,IAAIU,WAAW,GAAG"}
1
+ {"version":3,"sources":["../../../../src/components/Box/Box.tsx"],"sourcesContent":["import { Ref, forwardRef } from \"react\";\nimport classNames from \"classnames/dedupe\";\nimport { ForwardedRefComponent } from \"../../types/components\";\nimport { BoxElementType, BoxProps } from \"./types\";\nimport { getSpacingValue, filterUndefinedProps } from \"../../utils\";\n\nexport type BoxRef = Ref<BoxElementType>;\n\nconst Box: ForwardedRefComponent<BoxProps, BoxElementType> = forwardRef(\n (props: BoxProps, ref: BoxRef) => {\n const {\n elementType: Element = \"div\",\n padding,\n paddingX,\n paddingInline,\n paddingInlineStart,\n paddingInlineEnd,\n paddingY,\n paddingBlock,\n paddingBlockStart,\n paddingBlockEnd,\n paddingTop,\n paddingRight,\n paddingBottom,\n paddingLeft,\n minWidth,\n minHeight,\n maxWidth,\n maxHeight,\n width,\n height,\n style,\n ...otherProps\n } = props;\n\n const classes = classNames(\"mobius\", \"mobius/Box\", otherProps.className);\n\n const styleProps = filterUndefinedProps({\n padding: getSpacingValue(padding),\n paddingInline: getSpacingValue(paddingInline || paddingX),\n paddingBlock: getSpacingValue(paddingBlock || paddingY),\n paddingTop: getSpacingValue(paddingTop || paddingBlockStart),\n paddingRight: getSpacingValue(paddingRight || paddingInlineEnd),\n paddingBottom: getSpacingValue(paddingBottom || paddingBlockEnd),\n paddingLeft: getSpacingValue(paddingLeft || paddingInlineStart),\n minWidth,\n minHeight,\n maxWidth,\n maxHeight,\n width,\n height,\n ...style,\n });\n\n return (\n <Element\n ref={ref}\n style={styleProps}\n {...otherProps}\n className={classes}\n />\n );\n },\n);\n\nBox.displayName = \"Box\";\nexport { Box };\n"],"names":["Box","forwardRef","props","ref","elementType","Element","padding","paddingX","paddingInline","paddingInlineStart","paddingInlineEnd","paddingY","paddingBlock","paddingBlockStart","paddingBlockEnd","paddingTop","paddingRight","paddingBottom","paddingLeft","minWidth","minHeight","maxWidth","maxHeight","width","height","style","otherProps","classes","classNames","className","styleProps","filterUndefinedProps","getSpacingValue","displayName"],"mappings":";;;;+BAkESA;;;eAAAA;;;;uBAlEuB;+DACT;uBAG+B;;;;;;AAItD,MAAMA,oBAAuDC,IAAAA,iBAAU,EACrE,CAACC,OAAiBC;IAChB,MAAM,EACJC,aAAaC,UAAU,KAAK,EAC5BC,OAAO,EACPC,QAAQ,EACRC,aAAa,EACbC,kBAAkB,EAClBC,gBAAgB,EAChBC,QAAQ,EACRC,YAAY,EACZC,iBAAiB,EACjBC,eAAe,EACfC,UAAU,EACVC,YAAY,EACZC,aAAa,EACbC,WAAW,EACXC,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,SAAS,EACTC,KAAK,EACLC,MAAM,EACNC,KAAK,EACL,GAAGC,YACJ,GAAGxB;IAEJ,MAAMyB,UAAUC,IAAAA,eAAU,EAAC,UAAU,cAAcF,WAAWG,SAAS;IAEvE,MAAMC,aAAaC,IAAAA,2BAAoB,EAAC;QACtCzB,SAAS0B,IAAAA,sBAAe,EAAC1B;QACzBE,eAAewB,IAAAA,sBAAe,EAACxB,iBAAiBD;QAChDK,cAAcoB,IAAAA,sBAAe,EAACpB,gBAAgBD;QAC9CI,YAAYiB,IAAAA,sBAAe,EAACjB,cAAcF;QAC1CG,cAAcgB,IAAAA,sBAAe,EAAChB,gBAAgBN;QAC9CO,eAAee,IAAAA,sBAAe,EAACf,iBAAiBH;QAChDI,aAAac,IAAAA,sBAAe,EAACd,eAAeT;QAC5CU;QACAC;QACAC;QACAC;QACAC;QACAC;QACA,GAAGC,KAAK;IACV;IAEA,qBACE,qBAACpB;QACCF,KAAKA;QACLsB,OAAOK;QACN,GAAGJ,UAAU;QACdG,WAAWF;;AAGjB;AAGF3B,IAAIiC,WAAW,GAAG"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/Box/types.ts"],"names":[],"mappings":""}
@@ -82,20 +82,26 @@ const Drawer = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
82
82
  event.preventDefault();
83
83
  event.stopPropagation();
84
84
  }
85
+ // Name the callback function, so we can add and remove event listener
86
+ const transitionCallback = (e)=>{
87
+ // Close drawer only if the transition is on the dialog element
88
+ // As it can be on a child element (ie `<Button>` inside the drawer)
89
+ if (e.target === modalRef.current) {
90
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
91
+ doClose();
92
+ }
93
+ };
85
94
  const doClose = ()=>{
86
- var _modalRef_current;
95
+ var _modalRef_current, _modalRef_current1;
87
96
  (_modalRef_current = modalRef.current) === null || _modalRef_current === void 0 ? void 0 : _modalRef_current.close();
88
97
  onClose === null || onClose === void 0 ? void 0 : onClose();
98
+ (_modalRef_current1 = modalRef.current) === null || _modalRef_current1 === void 0 ? void 0 : _modalRef_current1.removeEventListener("transitionend", transitionCallback);
89
99
  };
90
100
  // Delay close to allow backdrop exit transition
91
101
  if (hasDialogSupport) {
92
102
  var _modalRef_current, _modalRef_current1;
93
103
  (_modalRef_current = modalRef.current) === null || _modalRef_current === void 0 ? void 0 : _modalRef_current.classList.remove(TRANSITION_CLASS_NAME);
94
- (_modalRef_current1 = modalRef.current) === null || _modalRef_current1 === void 0 ? void 0 : _modalRef_current1.addEventListener("transitionend", ()=>{
95
- doClose();
96
- }, {
97
- once: true
98
- });
104
+ (_modalRef_current1 = modalRef.current) === null || _modalRef_current1 === void 0 ? void 0 : _modalRef_current1.addEventListener("transitionend", transitionCallback);
99
105
  } else {
100
106
  doClose();
101
107
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/Drawer/Drawer.tsx"],"sourcesContent":["\"use client\";\n\nimport classNames from \"classnames/dedupe\";\nimport {\n Children,\n Ref,\n SyntheticEvent,\n cloneElement,\n forwardRef,\n isValidElement,\n useCallback,\n useEffect,\n useRef,\n} from \"react\";\nimport { useBodyScrollLock } from \"../../hooks/useBodyScrollLock\";\nimport { supportsDialog } from \"../../utils/polyfill-tests\";\nimport { VisuallyHidden } from \"../VisuallyHidden\";\nimport { DrawerProps } from \"./types\";\nimport { mergeRefs } from \"../../utils\";\n\nexport type DialogElementType = HTMLDialogElement;\nexport type DialogRef = Ref<DialogElementType>;\n\nconst TRANSITION_CLASS_NAME = \"--transition\";\n\nconst Drawer = forwardRef((props: DrawerProps, ref: DialogRef) => {\n const {\n isOpen,\n className,\n closeLabel,\n direction,\n announce = \"Drawer opened on screen\",\n onOpen,\n onClose,\n children,\n } = props;\n const hasOpened = useRef<boolean>(false);\n const modalRef = useRef<HTMLDialogElement | null>(null);\n const hasDialogSupport = supportsDialog();\n\n // Fire onOpen once\n if (onOpen && !hasOpened.current) {\n onOpen();\n hasOpened.current = true;\n }\n\n useBodyScrollLock({ enabled: isOpen });\n\n // Add close handler, to enable closing transitions\n const handleClose = useCallback(\n (event?: SyntheticEvent<HTMLElement, Event>) => {\n if (event) {\n event.preventDefault();\n event.stopPropagation();\n }\n\n const doClose = () => {\n modalRef.current?.close();\n onClose?.();\n };\n\n // Delay close to allow backdrop exit transition\n if (hasDialogSupport) {\n modalRef.current?.classList.remove(TRANSITION_CLASS_NAME);\n modalRef.current?.addEventListener(\n \"transitionend\",\n () => {\n doClose();\n },\n { once: true },\n );\n } else {\n doClose();\n }\n },\n [onClose, hasDialogSupport],\n );\n\n const modalClasses = classNames(\n \"mobius\",\n \"mobius/Drawer\",\n `--${direction}`,\n className,\n {\n \"--should-transition\": hasDialogSupport,\n },\n );\n\n // Add polyfill for HTML Dialog in old browsers\n useEffect(() => {\n async function toggleModal() {\n if (\n !hasDialogSupport &&\n typeof window !== \"undefined\" &&\n modalRef.current !== null\n ) {\n // eslint-disable-next-line import/no-extraneous-dependencies\n const { default: dialogPolyfill } = await import(\"dialog-polyfill\");\n try {\n dialogPolyfill.registerDialog(modalRef.current);\n } catch (error) {\n // In iOS 15 <= 15.2 this intermittently fails with\n // TypeError: null is not an object (evaluating 'element.showModal')\n // Checking showModal presence through hasOwnProperty is falsy natively, truthy with polyfill 🤷🏼‍♂️\n console.error(\"Failed to load dialog-polyfill\", error);\n }\n }\n\n if (isOpen && !modalRef.current?.open) {\n modalRef.current?.showModal();\n modalRef.current?.classList.add(TRANSITION_CLASS_NAME);\n onOpen?.();\n } else if (!isOpen && modalRef.current?.open) {\n handleClose();\n }\n }\n\n toggleModal();\n }, [isOpen, onOpen, handleClose, hasDialogSupport]);\n\n return (\n <dialog\n ref={mergeRefs([modalRef, ref])}\n onCancel={handleClose}\n className={modalClasses}\n aria-describedby=\"screen-reader-announce\"\n >\n <VisuallyHidden>\n <div id=\"screen-reader-announce\">{announce}</div>\n </VisuallyHidden>\n {Children.map(children, child => {\n if (isValidElement(child)) {\n return cloneElement(child, {\n onClose: handleClose,\n closeLabel,\n } as any);\n }\n\n return child;\n })}\n </dialog>\n );\n});\n\nDrawer.displayName = \"Drawer\";\nexport { Drawer };\n"],"names":["Drawer","TRANSITION_CLASS_NAME","forwardRef","props","ref","isOpen","className","closeLabel","direction","announce","onOpen","onClose","children","hasOpened","useRef","modalRef","hasDialogSupport","supportsDialog","current","useBodyScrollLock","enabled","handleClose","useCallback","event","preventDefault","stopPropagation","doClose","close","classList","remove","addEventListener","once","modalClasses","classNames","useEffect","toggleModal","window","default","dialogPolyfill","registerDialog","error","console","open","showModal","add","dialog","mergeRefs","onCancel","aria-describedby","VisuallyHidden","div","id","Children","map","child","isValidElement","cloneElement","displayName"],"mappings":"AAAA;;;;;+BAiJSA;;;eAAAA;;;;+DA/Ic;uBAWhB;mCAC2B;+BACH;gCACA;uBAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAK1B,MAAMC,wBAAwB;AAE9B,MAAMD,uBAASE,IAAAA,iBAAU,EAAC,CAACC,OAAoBC;IAC7C,MAAM,EACJC,MAAM,EACNC,SAAS,EACTC,UAAU,EACVC,SAAS,EACTC,WAAW,yBAAyB,EACpCC,MAAM,EACNC,OAAO,EACPC,QAAQ,EACT,GAAGT;IACJ,MAAMU,YAAYC,IAAAA,aAAM,EAAU;IAClC,MAAMC,WAAWD,IAAAA,aAAM,EAA2B;IAClD,MAAME,mBAAmBC,IAAAA,6BAAc;IAEvC,mBAAmB;IACnB,IAAIP,UAAU,CAACG,UAAUK,OAAO,EAAE;QAChCR;QACAG,UAAUK,OAAO,GAAG;IACtB;IAEAC,IAAAA,oCAAiB,EAAC;QAAEC,SAASf;IAAO;IAEpC,mDAAmD;IACnD,MAAMgB,cAAcC,IAAAA,kBAAW,EAC7B,CAACC;QACC,IAAIA,OAAO;YACTA,MAAMC,cAAc;YACpBD,MAAME,eAAe;QACvB;QAEA,MAAMC,UAAU;gBACdX;aAAAA,oBAAAA,SAASG,OAAO,cAAhBH,wCAAAA,kBAAkBY,KAAK;YACvBhB,oBAAAA,8BAAAA;QACF;QAEA,gDAAg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;QAAaL;KAAiB;IAElD,qBACE,sBAAC6B;QACCzC,KAAK0C,IAAAA,gBAAS,EAAC;YAAC/B;YAAUX;SAAI;QAC9B2C,UAAU1B;QACVf,WAAW0B;QACXgB,oBAAiB;;0BAEjB,qBAACC,8BAAc;0BACb,cAAA,qBAACC;oBAAIC,IAAG;8BAA0B1C;;;YAEnC2C,eAAQ,CAACC,GAAG,CAACzC,UAAU0C,CAAAA;gBACtB,kBAAIC,IAAAA,qBAAc,EAACD,QAAQ;oBACzB,qBAAOE,IAAAA,mBAAY,EAACF,OAAO;wBACzB3C,SAASU;wBACTd;oBACF;gBACF;gBAEA,OAAO+C;YACT;;;AAGN;AAEAtD,OAAOyD,WAAW,GAAG"}
1
+ {"version":3,"sources":["../../../../src/components/Drawer/Drawer.tsx"],"sourcesContent":["\"use client\";\n\nimport classNames from \"classnames/dedupe\";\nimport {\n Children,\n Ref,\n SyntheticEvent,\n cloneElement,\n forwardRef,\n isValidElement,\n useCallback,\n useEffect,\n useRef,\n} from \"react\";\nimport { useBodyScrollLock } from \"../../hooks/useBodyScrollLock\";\nimport { supportsDialog } from \"../../utils/polyfill-tests\";\nimport { VisuallyHidden } from \"../VisuallyHidden\";\nimport { DrawerProps } from \"./types\";\nimport { mergeRefs } from \"../../utils\";\n\nexport type DialogElementType = HTMLDialogElement;\nexport type DialogRef = Ref<DialogElementType>;\n\nconst TRANSITION_CLASS_NAME = \"--transition\";\n\nconst Drawer = forwardRef((props: DrawerProps, ref: DialogRef) => {\n const {\n isOpen,\n className,\n closeLabel,\n direction,\n announce = \"Drawer opened on screen\",\n onOpen,\n onClose,\n children,\n } = props;\n const hasOpened = useRef<boolean>(false);\n const modalRef = useRef<HTMLDialogElement | null>(null);\n const hasDialogSupport = supportsDialog();\n\n // Fire onOpen once\n if (onOpen && !hasOpened.current) {\n onOpen();\n hasOpened.current = true;\n }\n\n useBodyScrollLock({ enabled: isOpen });\n\n // Add close handler, to enable closing transitions\n const handleClose = useCallback(\n (event?: SyntheticEvent<HTMLElement, Event>) => {\n if (event) {\n event.preventDefault();\n event.stopPropagation();\n }\n\n // Name the callback function, so we can add and remove event listener\n const transitionCallback = (e: Event) => {\n // Close drawer only if the transition is on the dialog element\n // As it can be on a child element (ie `<Button>` inside the drawer)\n if (e.target === modalRef.current) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n doClose();\n }\n };\n\n const doClose = () => {\n modalRef.current?.close();\n onClose?.();\n modalRef.current?.removeEventListener(\n \"transitionend\",\n transitionCallback,\n );\n };\n\n // Delay close to allow backdrop exit transition\n if (hasDialogSupport) {\n modalRef.current?.classList.remove(TRANSITION_CLASS_NAME);\n modalRef.current?.addEventListener(\"transitionend\", transitionCallback);\n } else {\n doClose();\n }\n },\n [onClose, hasDialogSupport],\n );\n\n const modalClasses = classNames(\n \"mobius\",\n \"mobius/Drawer\",\n `--${direction}`,\n className,\n {\n \"--should-transition\": hasDialogSupport,\n },\n );\n\n // Add polyfill for HTML Dialog in old browsers\n useEffect(() => {\n async function toggleModal() {\n if (\n !hasDialogSupport &&\n typeof window !== \"undefined\" &&\n modalRef.current !== null\n ) {\n // eslint-disable-next-line import/no-extraneous-dependencies\n const { default: dialogPolyfill } = await import(\"dialog-polyfill\");\n try {\n dialogPolyfill.registerDialog(modalRef.current);\n } catch (error) {\n // In iOS 15 <= 15.2 this intermittently fails with\n // TypeError: null is not an object (evaluating 'element.showModal')\n // Checking showModal presence through hasOwnProperty is falsy natively, truthy with polyfill 🤷🏼‍♂️\n console.error(\"Failed to load dialog-polyfill\", error);\n }\n }\n\n if (isOpen && !modalRef.current?.open) {\n modalRef.current?.showModal();\n modalRef.current?.classList.add(TRANSITION_CLASS_NAME);\n onOpen?.();\n } else if (!isOpen && modalRef.current?.open) {\n handleClose();\n }\n }\n\n toggleModal();\n }, [isOpen, onOpen, handleClose, hasDialogSupport]);\n\n return (\n <dialog\n ref={mergeRefs([modalRef, ref])}\n onCancel={handleClose}\n className={modalClasses}\n aria-describedby=\"screen-reader-announce\"\n >\n <VisuallyHidden>\n <div id=\"screen-reader-announce\">{announce}</div>\n </VisuallyHidden>\n {Children.map(children, child => {\n if (isValidElement(child)) {\n return cloneElement(child, {\n onClose: handleClose,\n closeLabel,\n } as any);\n }\n\n return child;\n })}\n </dialog>\n );\n});\n\nDrawer.displayName = \"Drawer\";\nexport { Drawer };\n"],"names":["Drawer","TRANSITION_CLASS_NAME","forwardRef","props","ref","isOpen","className","closeLabel","direction","announce","onOpen","onClose","children","hasOpened","useRef","modalRef","hasDialogSupport","supportsDialog","current","useBodyScrollLock","enabled","handleClose","useCallback","event","preventDefault","stopPropagation","transitionCallback","e","target","doClose","close","removeEventListener","classList","remove","addEventListener","modalClasses","classNames","useEffect","toggleModal","window","default","dialogPolyfill","registerDialog","error","console","open","showModal","add","dialog","mergeRefs","onCancel","aria-describedby","VisuallyHidden","div","id","Children","map","child","isValidElement","cloneElement","displayName"],"mappings":"AAAA;;;;;+BAyJSA;;;eAAAA;;;;+DAvJc;uBAWhB;mCAC2B;+BACH;gCACA;uBAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAK1B,MAAMC,wBAAwB;AAE9B,MAAMD,uBAASE,IAAAA,iBAAU,EAAC,CAACC,OAAoBC;IAC7C,MAAM,EACJC,MAAM,EACNC,SAAS,EACTC,UAAU,EACVC,SAAS,EACTC,WAAW,yBAAyB,EACpCC,MAAM,EACNC,OAAO,EACPC,QAAQ,EACT,GAAGT;IACJ,MAAMU,YAAYC,IAAAA,aAAM,EAAU;IAClC,MAAMC,WAAWD,IAAAA,aAAM,EAA2B;IAClD,MAAME,mBAAmBC,IAAAA,6BAAc;IAEvC,mBAAmB;IACnB,IAAIP,UAAU,CAACG,UAAUK,OAAO,EAAE;QAChCR;QACAG,UAAUK,OAAO,GAAG;IACtB;IAEAC,IAAAA,oCAAiB,EAAC;QAAEC,SAASf;IAAO;IAEpC,mDAAmD;IACnD,MAAMgB,cAAcC,IAAAA,kBAAW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IAAItC,UAAU,GAACU,oBAAAA,SAASG,OAAO,cAAhBH,wCAAAA,kBAAkB8B,IAAI,GAAE;oBACrC9B,oBACAA;iBADAA,qBAAAA,SAASG,OAAO,cAAhBH,yCAAAA,mBAAkB+B,SAAS;iBAC3B/B,qBAAAA,SAASG,OAAO,cAAhBH,yCAAAA,mBAAkBiB,SAAS,CAACe,GAAG,CAAC9C;gBAChCS,mBAAAA,6BAAAA;YACF,OAAO,IAAI,CAACL,YAAUU,qBAAAA,SAASG,OAAO,cAAhBH,yCAAAA,mBAAkB8B,IAAI,GAAE;gBAC5CxB;YACF;QACF;QAEAiB;IACF,GAAG;QAACjC;QAAQK;QAAQW;QAAaL;KAAiB;IAElD,qBACE,sBAACgC;QACC5C,KAAK6C,IAAAA,gBAAS,EAAC;YAAClC;YAAUX;SAAI;QAC9B8C,UAAU7B;QACVf,WAAW6B;QACXgB,oBAAiB;;0BAEjB,qBAACC,8BAAc;0BACb,cAAA,qBAACC;oBAAIC,IAAG;8BAA0B7C;;;YAEnC8C,eAAQ,CAACC,GAAG,CAAC5C,UAAU6C,CAAAA;gBACtB,kBAAIC,IAAAA,qBAAc,EAACD,QAAQ;oBACzB,qBAAOE,IAAAA,mBAAY,EAACF,OAAO;wBACzB9C,SAASU;wBACTd;oBACF;gBACF;gBAEA,OAAOkD;YACT;;;AAGN;AAEAzD,OAAO4D,WAAW,GAAG"}
@@ -14,12 +14,10 @@ _export(exports, {
14
14
  },
15
15
  splitProps: function() {
16
16
  return splitProps;
17
- },
18
- withoutUndefinedValues: function() {
19
- return withoutUndefinedValues;
20
17
  }
21
18
  });
22
- const withoutUndefinedValues = (obj)=>Object.fromEntries(Object.entries(obj).filter(([_, value])=>value));
19
+ const _utils = require("../../utils");
20
+ const _filterUndefinedProps = require("../../utils/filterUndefinedProps");
23
21
  const buildFlexStyles = (props)=>{
24
22
  const { flexDirection, flexWrap, flexGrow, flex, justifyContent, alignItems, alignContent, gap, rowGap, columnGap } = props;
25
23
  const styleProps = {
@@ -31,11 +29,11 @@ const buildFlexStyles = (props)=>{
31
29
  justifyContent,
32
30
  alignItems,
33
31
  alignContent,
34
- gap,
35
- rowGap,
36
- columnGap
32
+ gap: (0, _utils.getSpacingValue)(gap),
33
+ columnGap: (0, _utils.getSpacingValue)(columnGap),
34
+ rowGap: (0, _utils.getSpacingValue)(rowGap)
37
35
  };
38
- return withoutUndefinedValues(styleProps);
36
+ return (0, _filterUndefinedProps.filterUndefinedProps)(styleProps);
39
37
  };
40
38
  const splitProps = (props)=>{
41
39
  const { flexDirection, flexWrap, flexGrow, flex, justifyContent, alignItems, alignContent, gap, rowGap, columnGap, ...otherProps } = props;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/Flex/propUtils.ts"],"sourcesContent":["import { FlexNonStyleProps, FlexProps, FlexStyleProps } from \"./types\";\n\nexport const withoutUndefinedValues = (obj: Record<string, unknown>) =>\n Object.fromEntries(Object.entries(obj).filter(([_, value]) => value));\n\nexport const buildFlexStyles = (props: FlexStyleProps) => {\n const {\n flexDirection,\n flexWrap,\n flexGrow,\n flex,\n justifyContent,\n alignItems,\n alignContent,\n gap,\n rowGap,\n columnGap,\n } = props;\n\n const styleProps = {\n display: \"flex\",\n flexDirection,\n flexWrap,\n flexGrow,\n flex,\n justifyContent,\n alignItems,\n alignContent,\n gap,\n rowGap,\n columnGap,\n };\n\n return withoutUndefinedValues(styleProps);\n};\n\nexport const splitProps = (\n props: FlexProps,\n): [FlexStyleProps, FlexNonStyleProps] => {\n const {\n flexDirection,\n flexWrap,\n flexGrow,\n flex,\n justifyContent,\n alignItems,\n alignContent,\n gap,\n rowGap,\n columnGap,\n ...otherProps\n } = props;\n\n return [\n {\n flexDirection,\n flexWrap,\n flexGrow,\n flex,\n justifyContent,\n alignItems,\n alignContent,\n gap,\n rowGap,\n columnGap,\n },\n otherProps,\n ];\n};\n"],"names":["buildFlexStyles","splitProps","withoutUndefinedValues","obj","Object","fromEntries","entries","filter","_","value","props","flexDirection","flexWrap","flexGrow","flex","justifyContent","alignItems","alignContent","gap","rowGap","columnGap","styleProps","display","otherProps"],"mappings":";;;;;;;;;;;IAKaA,eAAe;eAAfA;;IA+BAC,UAAU;eAAVA;;IAlCAC,sBAAsB;eAAtBA;;;AAAN,MAAMA,yBAAyB,CAACC,MACrCC,OAAOC,WAAW,CAACD,OAAOE,OAAO,CAACH,KAAKI,MAAM,CAAC,CAAC,CAACC,GAAGC,MAAM,GAAKA;AAEzD,MAAMT,kBAAkB,CAACU;IAC9B,MAAM,EACJC,aAAa,EACbC,QAAQ,EACRC,QAAQ,EACRC,IAAI,EACJC,cAAc,EACdC,UAAU,EACVC,YAAY,EACZC,GAAG,EACHC,MAAM,EACNC,SAAS,EACV,GAAGV;IAEJ,MAAMW,aAAa;QACjBC,SAAS;QACTX;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;IACF;IAEA,OAAOlB,uBAAuBmB;AAChC;AAEO,MAAMpB,aAAa,CACxBS;IAEA,MAAM,EACJC,aAAa,EACbC,QAAQ,EACRC,QAAQ,EACRC,IAAI,EACJC,cAAc,EACdC,UAAU,EACVC,YAAY,EACZC,GAAG,EACHC,MAAM,EACNC,SAAS,EACT,GAAGG,YACJ,GAAGb;IAEJ,OAAO;QACL;YACEC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;QACAG;KACD;AACH"}
1
+ {"version":3,"sources":["../../../../src/components/Flex/propUtils.ts"],"sourcesContent":["import { getSpacingValue } from \"../../utils\";\nimport { filterUndefinedProps } from \"../../utils/filterUndefinedProps\";\nimport { FlexNonStyleProps, FlexProps, FlexStyleProps } from \"./types\";\n\nexport const buildFlexStyles = (props: FlexStyleProps) => {\n const {\n flexDirection,\n flexWrap,\n flexGrow,\n flex,\n justifyContent,\n alignItems,\n alignContent,\n gap,\n rowGap,\n columnGap,\n } = props;\n\n const styleProps = {\n display: \"flex\",\n flexDirection,\n flexWrap,\n flexGrow,\n flex,\n justifyContent,\n alignItems,\n alignContent,\n gap: getSpacingValue(gap),\n columnGap: getSpacingValue(columnGap),\n rowGap: getSpacingValue(rowGap),\n };\n\n return filterUndefinedProps(styleProps);\n};\n\nexport const splitProps = (\n props: FlexProps,\n): [FlexStyleProps, FlexNonStyleProps] => {\n const {\n flexDirection,\n flexWrap,\n flexGrow,\n flex,\n justifyContent,\n alignItems,\n alignContent,\n gap,\n rowGap,\n columnGap,\n ...otherProps\n } = props;\n\n return [\n {\n flexDirection,\n flexWrap,\n flexGrow,\n flex,\n justifyContent,\n alignItems,\n alignContent,\n gap,\n rowGap,\n columnGap,\n },\n otherProps,\n ];\n};\n"],"names":["buildFlexStyles","splitProps","props","flexDirection","flexWrap","flexGrow","flex","justifyContent","alignItems","alignContent","gap","rowGap","columnGap","styleProps","display","getSpacingValue","filterUndefinedProps","otherProps"],"mappings":";;;;;;;;;;;IAIaA,eAAe;eAAfA;;IA+BAC,UAAU;eAAVA;;;uBAnCmB;sCACK;AAG9B,MAAMD,kBAAkB,CAACE;IAC9B,MAAM,EACJC,aAAa,EACbC,QAAQ,EACRC,QAAQ,EACRC,IAAI,EACJC,cAAc,EACdC,UAAU,EACVC,YAAY,EACZC,GAAG,EACHC,MAAM,EACNC,SAAS,EACV,GAAGV;IAEJ,MAAMW,aAAa;QACjBC,SAAS;QACTX;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC,KAAKK,IAAAA,sBAAe,EAACL;QACrBE,WAAWG,IAAAA,sBAAe,EAACH;QAC3BD,QAAQI,IAAAA,sBAAe,EAACJ;IAC1B;IAEA,OAAOK,IAAAA,0CAAoB,EAACH;AAC9B;AAEO,MAAMZ,aAAa,CACxBC;IAEA,MAAM,EACJC,aAAa,EACbC,QAAQ,EACRC,QAAQ,EACRC,IAAI,EACJC,cAAc,EACdC,UAAU,EACVC,YAAY,EACZC,GAAG,EACHC,MAAM,EACNC,SAAS,EACT,GAAGK,YACJ,GAAGf;IAEJ,OAAO;QACL;YACEC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;QACAK;KACD;AACH"}
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "Grid", {
11
11
  const _jsxruntime = require("react/jsx-runtime");
12
12
  const _react = require("react");
13
13
  const _dedupe = /*#__PURE__*/ _interop_require_default(require("classnames/dedupe"));
14
- const _propUtils = require("../Flex/propUtils");
14
+ const _utils = require("../../utils");
15
15
  function _interop_require_default(obj) {
16
16
  return obj && obj.__esModule ? obj : {
17
17
  default: obj
@@ -20,13 +20,13 @@ function _interop_require_default(obj) {
20
20
  const Grid = /*#__PURE__*/ (0, _react.forwardRef)((props, _ref)=>{
21
21
  const { columns = 12, gap, columnGap, rowGap, alignContent, alignItems, justifyContent, justifyItems, className, ...rest } = props;
22
22
  const classes = (0, _dedupe.default)("mobius", "mobius/Grid", className);
23
- const styles = (0, _propUtils.withoutUndefinedValues)({
23
+ const styles = (0, _utils.filterUndefinedProps)({
24
24
  boxSizing: "border-box",
25
25
  display: "grid",
26
26
  gridTemplateColumns: `repeat(${columns}, 1fr)`,
27
- gap: gap ? `var(--${gap})` : undefined,
28
- columnGap: columnGap ? `var(--${columnGap})` : undefined,
29
- rowGap: rowGap ? `var(--${rowGap})` : undefined,
27
+ gap: (0, _utils.getSpacingValue)(gap),
28
+ columnGap: (0, _utils.getSpacingValue)(columnGap),
29
+ rowGap: (0, _utils.getSpacingValue)(rowGap),
30
30
  alignContent,
31
31
  alignItems,
32
32
  justifyContent,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/Grid/Grid.tsx"],"sourcesContent":["import {\n Ref,\n forwardRef,\n ReactNode,\n RefAttributes,\n CSSProperties,\n} from \"react\";\nimport classNames from \"classnames/dedupe\";\nimport { DOMProps } from \"../../types/dom\";\nimport { ForwardedRefComponent } from \"../../types/components\";\nimport { withoutUndefinedValues } from \"../Flex/propUtils\";\n\nexport type GridElementType = HTMLDivElement;\n\nexport interface GridProps extends RefAttributes<GridElementType>, DOMProps {\n children?: ReactNode;\n /** The number of columns */\n columns?: number;\n /** How big a gap between the columns and rows */\n gap?: string;\n /** How big a gap between the columns */\n columnGap?: string;\n /** How big a gap between the rows */\n rowGap?: string;\n /** Aligns the grid along the block (column) axis */\n alignContent?:\n | \"center\"\n | \"space-around\"\n | \"space-between\"\n | \"space-evenly\"\n | \"stretch\";\n /** Aligns the grid along the inline (row) axis */\n justifyContent?:\n | \"center\"\n | \"start\"\n | \"end\"\n | \"space-around\"\n | \"space-between\"\n | \"space-evenly\";\n /** Aligns grid items along the block (column) axis */\n alignItems?: \"center\" | \"start\" | \"end\" | \"stretch\" | \"baseline\";\n /** Aligns grid items along the inline (row) axis */\n justifyItems?: \"start\" | \"end\" | \"center\" | \"stretch\";\n /** Custom class name for setting specific CSS */\n className?: string;\n}\n\nexport type GridRef = Ref<GridElementType>;\n\nconst Grid: ForwardedRefComponent<GridProps, GridElementType> = forwardRef(\n (props: GridProps, _ref: GridRef) => {\n const {\n columns = 12,\n gap,\n columnGap,\n rowGap,\n alignContent,\n alignItems,\n justifyContent,\n justifyItems,\n className,\n ...rest\n } = props;\n const classes = classNames(\"mobius\", \"mobius/Grid\", className);\n\n const styles: CSSProperties = withoutUndefinedValues({\n boxSizing: \"border-box\",\n display: \"grid\",\n gridTemplateColumns: `repeat(${columns}, 1fr)`,\n gap: gap ? `var(--${gap})` : undefined,\n columnGap: columnGap ? `var(--${columnGap})` : undefined,\n rowGap: rowGap ? `var(--${rowGap})` : undefined,\n alignContent,\n alignItems,\n justifyContent,\n justifyItems,\n });\n\n return <div style={styles} className={classes} {...rest} />;\n },\n);\n\nGrid.displayName = \"Grid\";\nexport { Grid };\n"],"names":["Grid","forwardRef","props","_ref","columns","gap","columnGap","rowGap","alignContent","alignItems","justifyContent","justifyItems","className","rest","classes","classNames","styles","withoutUndefinedValues","boxSizing","display","gridTemplateColumns","undefined","div","style","displayName"],"mappings":";;;;+BAmFSA;;;eAAAA;;;;uBA7EF;+DACgB;2BAGgB;;;;;;AAuCvC,MAAMA,qBAA0DC,IAAAA,iBAAU,EACxE,CAACC,OAAkBC;IACjB,MAAM,EACJC,UAAU,EAAE,EACZC,GAAG,EACHC,SAAS,EACTC,MAAM,EACNC,YAAY,EACZC,UAAU,EACVC,cAAc,EACdC,YAAY,EACZC,SAAS,EACT,GAAGC,MACJ,GAAGX;IACJ,MAAMY,UAAUC,IAAAA,eAAU,EAAC,UAAU,eAAeH;IAEpD,MAAMI,SAAwBC,IAAAA,iCAAsB,EAAC;QACnDC,WAAW;QACXC,SAAS;QACTC,qBAAqB,CAAC,OAAO,EAAEhB,QAAQ,MAAM,CAAC;QAC9CC,KAAKA,MAAM,CAAC,MAAM,EAAEA,IAAI,CAAC,CAAC,GAAGgB;QAC7Bf,WAAWA,YAAY,CAAC,MAAM,EAAEA,UAAU,CAAC,CAAC,GAAGe;QAC/Cd,QAAQA,SAAS,CAAC,MAAM,EAAEA,OAAO,CAAC,CAAC,GAAGc;QACtCb;QACAC;QACAC;QACAC;IACF;IAEA,qBAAO,qBAACW;QAAIC,OAAOP;QAAQJ,WAAWE;QAAU,GAAGD,IAAI;;AACzD;AAGFb,KAAKwB,WAAW,GAAG"}
1
+ {"version":3,"sources":["../../../../src/components/Grid/Grid.tsx"],"sourcesContent":["import {\n Ref,\n forwardRef,\n ReactNode,\n RefAttributes,\n CSSProperties,\n} from \"react\";\nimport classNames from \"classnames/dedupe\";\nimport { DOMProps } from \"../../types/dom\";\nimport { ForwardedRefComponent } from \"../../types/components\";\nimport { filterUndefinedProps, getSpacingValue } from \"../../utils\";\nimport { SpacingType } from \"../../types\";\n\nexport type GridElementType = HTMLDivElement;\n\nexport interface GridProps extends RefAttributes<GridElementType>, DOMProps {\n children?: ReactNode;\n /** The number of columns */\n columns?: number;\n /** How big a gap between the columns and rows */\n gap?: SpacingType;\n /** How big a gap between the columns */\n columnGap?: SpacingType;\n /** How big a gap between the rows */\n rowGap?: SpacingType;\n /** Aligns the grid along the block (column) axis */\n alignContent?:\n | \"center\"\n | \"space-around\"\n | \"space-between\"\n | \"space-evenly\"\n | \"stretch\";\n /** Aligns the grid along the inline (row) axis */\n justifyContent?:\n | \"center\"\n | \"start\"\n | \"end\"\n | \"space-around\"\n | \"space-between\"\n | \"space-evenly\";\n /** Aligns grid items along the block (column) axis */\n alignItems?: \"center\" | \"start\" | \"end\" | \"stretch\" | \"baseline\";\n /** Aligns grid items along the inline (row) axis */\n justifyItems?: \"start\" | \"end\" | \"center\" | \"stretch\";\n /** Custom class name for setting specific CSS */\n className?: string;\n}\n\nexport type GridRef = Ref<GridElementType>;\n\nconst Grid: ForwardedRefComponent<GridProps, GridElementType> = forwardRef(\n (props: GridProps, _ref: GridRef) => {\n const {\n columns = 12,\n gap,\n columnGap,\n rowGap,\n alignContent,\n alignItems,\n justifyContent,\n justifyItems,\n className,\n ...rest\n } = props;\n const classes = classNames(\"mobius\", \"mobius/Grid\", className);\n\n const styles: CSSProperties = filterUndefinedProps({\n boxSizing: \"border-box\",\n display: \"grid\",\n gridTemplateColumns: `repeat(${columns}, 1fr)`,\n gap: getSpacingValue(gap),\n columnGap: getSpacingValue(columnGap),\n rowGap: getSpacingValue(rowGap),\n alignContent,\n alignItems,\n justifyContent,\n justifyItems,\n });\n\n return <div style={styles} className={classes} {...rest} />;\n },\n);\n\nGrid.displayName = \"Grid\";\nexport { Grid };\n"],"names":["Grid","forwardRef","props","_ref","columns","gap","columnGap","rowGap","alignContent","alignItems","justifyContent","justifyItems","className","rest","classes","classNames","styles","filterUndefinedProps","boxSizing","display","gridTemplateColumns","getSpacingValue","div","style","displayName"],"mappings":";;;;+BAoFSA;;;eAAAA;;;;uBA9EF;+DACgB;uBAG+B;;;;;;AAwCtD,MAAMA,qBAA0DC,IAAAA,iBAAU,EACxE,CAACC,OAAkBC;IACjB,MAAM,EACJC,UAAU,EAAE,EACZC,GAAG,EACHC,SAAS,EACTC,MAAM,EACNC,YAAY,EACZC,UAAU,EACVC,cAAc,EACdC,YAAY,EACZC,SAAS,EACT,GAAGC,MACJ,GAAGX;IACJ,MAAMY,UAAUC,IAAAA,eAAU,EAAC,UAAU,eAAeH;IAEpD,MAAMI,SAAwBC,IAAAA,2BAAoB,EAAC;QACjDC,WAAW;QACXC,SAAS;QACTC,qBAAqB,CAAC,OAAO,EAAEhB,QAAQ,MAAM,CAAC;QAC9CC,KAAKgB,IAAAA,sBAAe,EAAChB;QACrBC,WAAWe,IAAAA,sBAAe,EAACf;QAC3BC,QAAQc,IAAAA,sBAAe,EAACd;QACxBC;QACAC;QACAC;QACAC;IACF;IAEA,qBAAO,qBAACW;QAAIC,OAAOP;QAAQJ,WAAWE;QAAU,GAAGD,IAAI;;AACzD;AAGFb,KAAKwB,WAAW,GAAG"}
@@ -90,20 +90,26 @@ const Modal = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
90
90
  event.preventDefault();
91
91
  event.stopPropagation();
92
92
  }
93
+ // Name the callback function, so we can add and remove event listener
94
+ const transitionCallback = (e)=>{
95
+ // Close modal only if the transition is on the dialog element
96
+ // As it can be on a child element (ie `<Button>` inside the drawer)
97
+ if (e.target === modalRef.current) {
98
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
99
+ doClose();
100
+ }
101
+ };
93
102
  const doClose = ()=>{
94
- var _modalRef_current;
103
+ var _modalRef_current, _modalRef_current1;
95
104
  (_modalRef_current = modalRef.current) === null || _modalRef_current === void 0 ? void 0 : _modalRef_current.close();
96
105
  onClose === null || onClose === void 0 ? void 0 : onClose();
106
+ (_modalRef_current1 = modalRef.current) === null || _modalRef_current1 === void 0 ? void 0 : _modalRef_current1.removeEventListener("transitionend", transitionCallback);
97
107
  };
98
108
  // Delay close to allow backdrop exit transition
99
109
  if (hasDialogSupport && animation) {
100
110
  var _modalRef_current, _modalRef_current1;
101
111
  (_modalRef_current = modalRef.current) === null || _modalRef_current === void 0 ? void 0 : _modalRef_current.classList.remove(TRANSITION_CLASS_NAME);
102
- (_modalRef_current1 = modalRef.current) === null || _modalRef_current1 === void 0 ? void 0 : _modalRef_current1.addEventListener("transitionend", ()=>{
103
- doClose();
104
- }, {
105
- once: true
106
- });
112
+ (_modalRef_current1 = modalRef.current) === null || _modalRef_current1 === void 0 ? void 0 : _modalRef_current1.addEventListener("transitionend", transitionCallback);
107
113
  } else {
108
114
  doClose();
109
115
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/Modal/Modal.tsx"],"sourcesContent":["\"use client\";\n\nimport classNames from \"classnames/dedupe\";\nimport {\n Children,\n Ref,\n SyntheticEvent,\n cloneElement,\n forwardRef,\n isValidElement,\n useCallback,\n useEffect,\n useRef,\n} from \"react\";\nimport { useBodyScrollLock } from \"../../hooks/useBodyScrollLock\";\nimport { supportsDialog } from \"../../utils/polyfill-tests\";\nimport { ModalProps } from \"./types\";\nimport { mergeRefs } from \"../../utils\";\n\nexport type ModalElementType = HTMLDialogElement;\nexport type ModalRef = Ref<ModalElementType>;\n\nconst TRANSITION_CLASS_NAME = \"--transition\";\n\nconst Modal = forwardRef((props: ModalProps, ref: ModalRef) => {\n const {\n isOpen,\n onClose,\n onOpen,\n children,\n className,\n closeLabel,\n isFullScreen,\n animation,\n // Deprecated props below\n size,\n appElement,\n preventCloseOnEsc,\n shouldFocusAfterRender,\n parentSelector,\n } = props;\n const hasWarnedAboutMissingLabels = useRef<boolean>(false);\n // Handle deprecated props\n if (!hasWarnedAboutMissingLabels.current) {\n if (\n size ||\n appElement ||\n preventCloseOnEsc ||\n shouldFocusAfterRender ||\n parentSelector\n ) {\n console.warn(\n `Deprecation warning: Mobius Modal no longer supports the following props: size, appElement, preventCloseOnEsc, shouldFocusAfterRender and parentSelector.`,\n );\n hasWarnedAboutMissingLabels.current = true;\n }\n }\n\n const hasOpened = useRef<boolean>(false);\n const modalRef = useRef<HTMLDialogElement | null>(null);\n const hasDialogSupport = supportsDialog();\n\n // Fire onOpen once\n if (onOpen && !hasOpened.current) {\n onOpen();\n hasOpened.current = true;\n }\n\n useBodyScrollLock({ enabled: isOpen });\n\n // Add close handler, to enable closing animations\n const handleClose = useCallback(\n (event?: SyntheticEvent<HTMLElement, Event>) => {\n if (event) {\n event.preventDefault();\n event.stopPropagation();\n }\n\n const doClose = () => {\n modalRef.current?.close();\n onClose?.();\n };\n\n // Delay close to allow backdrop exit transition\n if (hasDialogSupport && animation) {\n modalRef.current?.classList.remove(TRANSITION_CLASS_NAME);\n modalRef.current?.addEventListener(\n \"transitionend\",\n () => {\n doClose();\n },\n { once: true },\n );\n } else {\n doClose();\n }\n },\n [onClose, hasDialogSupport, animation],\n );\n\n const modalClasses = classNames(\n \"mobius\",\n \"mobius/Modal\",\n {\n \"--no-dialog-support\": !hasDialogSupport, // This class is used to correctly position modal in x/y middle on iOS <= 15.2\n \"--should-transition\": hasDialogSupport && animation,\n \"--slide-up\": animation === \"slideUp\",\n \"--fade\": animation === \"fade\",\n \"--is-fullscreen\": isFullScreen,\n },\n className,\n );\n\n // Add polyfill for HTML Dialog in old browsers\n useEffect(() => {\n async function toggleModal() {\n if (\n !hasDialogSupport &&\n typeof window !== \"undefined\" &&\n modalRef.current !== null\n ) {\n // eslint-disable-next-line import/no-extraneous-dependencies\n const { default: dialogPolyfill } = await import(\"dialog-polyfill\");\n\n try {\n dialogPolyfill.registerDialog(modalRef.current);\n } catch (error) {\n // In iOS 15 <= 15.2 this intermittently fails with\n // TypeError: null is not an object (evaluating 'element.showModal')\n // Checking showModal presence through hasOwnProperty is falsy natively, truthy with polyfill 🤷🏼‍♂️\n console.error(\"Failed to load dialog-polyfill\", error);\n }\n }\n\n if (isOpen && !modalRef.current?.open) {\n modalRef.current?.showModal();\n modalRef.current?.classList.add(TRANSITION_CLASS_NAME);\n onOpen?.();\n } else if (!isOpen && modalRef.current?.open) {\n handleClose();\n }\n }\n\n toggleModal();\n }, [isOpen, onOpen, handleClose, hasDialogSupport]);\n\n return (\n <dialog\n ref={mergeRefs([modalRef, ref])}\n onCancel={handleClose}\n className={modalClasses}\n >\n {Children.map(children, child => {\n if (isValidElement(child)) {\n return cloneElement(child, {\n onClose: handleClose,\n closeLabel,\n } as any);\n }\n\n return child;\n })}\n </dialog>\n );\n});\n\nModal.displayName = \"Modal\";\nexport { Modal };\n"],"names":["Modal","TRANSITION_CLASS_NAME","forwardRef","props","ref","isOpen","onClose","onOpen","children","className","closeLabel","isFullScreen","animation","size","appElement","preventCloseOnEsc","shouldFocusAfterRender","parentSelector","hasWarnedAboutMissingLabels","useRef","current","console","warn","hasOpened","modalRef","hasDialogSupport","supportsDialog","useBodyScrollLock","enabled","handleClose","useCallback","event","preventDefault","stopPropagation","doClose","close","classList","remove","addEventListener","once","modalClasses","classNames","useEffect","toggleModal","window","default","dialogPolyfill","registerDialog","error","open","showModal","add","dialog","mergeRefs","onCancel","Children","map","child","isValidElement","cloneElement","displayName"],"mappings":"AAAA;;;;;+BAuKSA;;;eAAAA;;;;+DArKc;uBAWhB;mCAC2B;+BACH;uBAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAK1B,MAAMC,wBAAwB;AAE9B,MAAMD,sBAAQE,IAAAA,iBAAU,EAAC,CAACC,OAAmBC;IAC3C,MAAM,EACJC,MAAM,EACNC,OAAO,EACPC,MAAM,EACNC,QAAQ,EACRC,SAAS,EACTC,UAAU,EACVC,YAAY,EACZC,SAAS,EACT,yBAAyB;IACzBC,IAAI,EACJC,UAAU,EACVC,iBAAiB,EACjBC,sBAAsB,EACtBC,cAAc,EACf,GAAGd;IACJ,MAAMe,8BAA8BC,IAAAA,aAAM,EAAU;IACpD,0BAA0B;IAC1B,IAAI,CAACD,4BAA4BE,OAAO,EAAE;QACxC,IACEP,QACAC,cACAC,qBACAC,0BACAC,gBACA;YACAI,QAAQC,IAAI,CACV,CAAC,yJAAyJ,CAAC;YAE7JJ,4BAA4BE,OAAO,GAAG;QACxC;IACF;IAEA,MAAMG,YAAYJ,IAAAA,aAAM,EAAU;IAClC,MAAMK,WAAWL,IAAAA,aAAM,EAA2B;IA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ACd,mDAAmD;oBACnD,oEAAoE;oBACpE,qGAAqG;oBACrG3B,QAAQ2B,KAAK,CAAC,kCAAkCA;gBAClD;YACF;YAEA,IAAI3C,UAAU,GAACmB,oBAAAA,SAASJ,OAAO,cAAhBI,wCAAAA,kBAAkByB,IAAI,GAAE;oBACrCzB,oBACAA;iBADAA,qBAAAA,SAASJ,OAAO,cAAhBI,yCAAAA,mBAAkB0B,SAAS;iBAC3B1B,qBAAAA,SAASJ,OAAO,cAAhBI,yCAAAA,mBAAkBY,SAAS,CAACe,GAAG,CAAClD;gBAChCM,mBAAAA,6BAAAA;YACF,OAAO,IAAI,CAACF,YAAUmB,qBAAAA,SAASJ,OAAO,cAAhBI,yCAAAA,mBAAkByB,IAAI,GAAE;gBAC5CpB;YACF;QACF;QAEAc;IACF,GAAG;QAACtC;QAAQE;QAAQsB;QAAaJ;KAAiB;IAElD,qBACE,qBAAC2B;QACChD,KAAKiD,IAAAA,gBAAS,EAAC;YAAC7B;YAAUpB;SAAI;QAC9BkD,UAAUzB;QACVpB,WAAW+B;kBAEVe,eAAQ,CAACC,GAAG,CAAChD,UAAUiD,CAAAA;YACtB,kBAAIC,IAAAA,qBAAc,EAACD,QAAQ;gBACzB,qBAAOE,IAAAA,mBAAY,EAACF,OAAO;oBACzBnD,SAASuB;oBACTnB;gBACF;YACF;YAEA,OAAO+C;QACT;;AAGN;AAEAzD,MAAM4D,WAAW,GAAG"}
1
+ {"version":3,"sources":["../../../../src/components/Modal/Modal.tsx"],"sourcesContent":["\"use client\";\n\nimport classNames from \"classnames/dedupe\";\nimport {\n Children,\n Ref,\n SyntheticEvent,\n cloneElement,\n forwardRef,\n isValidElement,\n useCallback,\n useEffect,\n useRef,\n} from \"react\";\nimport { useBodyScrollLock } from \"../../hooks/useBodyScrollLock\";\nimport { supportsDialog } from \"../../utils/polyfill-tests\";\nimport { ModalProps } from \"./types\";\nimport { mergeRefs } from \"../../utils\";\n\nexport type ModalElementType = HTMLDialogElement;\nexport type ModalRef = Ref<ModalElementType>;\n\nconst TRANSITION_CLASS_NAME = \"--transition\";\n\nconst Modal = forwardRef((props: ModalProps, ref: ModalRef) => {\n const {\n isOpen,\n onClose,\n onOpen,\n children,\n className,\n closeLabel,\n isFullScreen,\n animation,\n // Deprecated props below\n size,\n appElement,\n preventCloseOnEsc,\n shouldFocusAfterRender,\n parentSelector,\n } = props;\n const hasWarnedAboutMissingLabels = useRef<boolean>(false);\n // Handle deprecated props\n if (!hasWarnedAboutMissingLabels.current) {\n if (\n size ||\n appElement ||\n preventCloseOnEsc ||\n shouldFocusAfterRender ||\n parentSelector\n ) {\n console.warn(\n `Deprecation warning: Mobius Modal no longer supports the following props: size, appElement, preventCloseOnEsc, shouldFocusAfterRender and parentSelector.`,\n );\n hasWarnedAboutMissingLabels.current = true;\n }\n }\n\n const hasOpened = useRef<boolean>(false);\n const modalRef = useRef<HTMLDialogElement | null>(null);\n const hasDialogSupport = supportsDialog();\n\n // Fire onOpen once\n if (onOpen && !hasOpened.current) {\n onOpen();\n hasOpened.current = true;\n }\n\n useBodyScrollLock({ enabled: isOpen });\n\n // Add close handler, to enable closing animations\n const handleClose = useCallback(\n (event?: SyntheticEvent<HTMLElement, Event>) => {\n if (event) {\n event.preventDefault();\n event.stopPropagation();\n }\n\n // Name the callback function, so we can add and remove event listener\n const transitionCallback = (e: Event) => {\n // Close modal only if the transition is on the dialog element\n // As it can be on a child element (ie `<Button>` inside the drawer)\n if (e.target === modalRef.current) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n doClose();\n }\n };\n\n const doClose = () => {\n modalRef.current?.close();\n onClose?.();\n modalRef.current?.removeEventListener(\n \"transitionend\",\n transitionCallback,\n );\n };\n\n // Delay close to allow backdrop exit transition\n if (hasDialogSupport && animation) {\n modalRef.current?.classList.remove(TRANSITION_CLASS_NAME);\n modalRef.current?.addEventListener(\"transitionend\", transitionCallback);\n } else {\n doClose();\n }\n },\n [onClose, hasDialogSupport, animation],\n );\n\n const modalClasses = classNames(\n \"mobius\",\n \"mobius/Modal\",\n {\n \"--no-dialog-support\": !hasDialogSupport, // This class is used to correctly position modal in x/y middle on iOS <= 15.2\n \"--should-transition\": hasDialogSupport && animation,\n \"--slide-up\": animation === \"slideUp\",\n \"--fade\": animation === \"fade\",\n \"--is-fullscreen\": isFullScreen,\n },\n className,\n );\n\n // Add polyfill for HTML Dialog in old browsers\n useEffect(() => {\n async function toggleModal() {\n if (\n !hasDialogSupport &&\n typeof window !== \"undefined\" &&\n modalRef.current !== null\n ) {\n // eslint-disable-next-line import/no-extraneous-dependencies\n const { default: dialogPolyfill } = await import(\"dialog-polyfill\");\n\n try {\n dialogPolyfill.registerDialog(modalRef.current);\n } catch (error) {\n // In iOS 15 <= 15.2 this intermittently fails with\n // TypeError: null is not an object (evaluating 'element.showModal')\n // Checking showModal presence through hasOwnProperty is falsy natively, truthy with polyfill 🤷🏼‍♂️\n console.error(\"Failed to load dialog-polyfill\", error);\n }\n }\n\n if (isOpen && !modalRef.current?.open) {\n modalRef.current?.showModal();\n modalRef.current?.classList.add(TRANSITION_CLASS_NAME);\n onOpen?.();\n } else if (!isOpen && modalRef.current?.open) {\n handleClose();\n }\n }\n\n toggleModal();\n }, [isOpen, onOpen, handleClose, hasDialogSupport]);\n\n return (\n <dialog\n ref={mergeRefs([modalRef, ref])}\n onCancel={handleClose}\n className={modalClasses}\n >\n {Children.map(children, child => {\n if (isValidElement(child)) {\n return cloneElement(child, {\n onClose: handleClose,\n closeLabel,\n } as any);\n }\n\n return child;\n })}\n </dialog>\n );\n});\n\nModal.displayName = \"Modal\";\nexport { Modal };\n"],"names":["Modal","TRANSITION_CLASS_NAME","forwardRef","props","ref","isOpen","onClose","onOpen","children","className","closeLabel","isFullScreen","animation","size","appElement","preventCloseOnEsc","shouldFocusAfterRender","parentSelector","hasWarnedAboutMissingLabels","useRef","current","console","warn","hasOpened","modalRef","hasDialogSupport","supportsDialog","useBodyScrollLock","enabled","handleClose","useCallback","event","preventDefault","stopPropagation","transitionCallback","e","target","doClose","close","removeEventListener","classList","remove","addEventListener","modalClasses","classNames","useEffect","toggleModal","window","default","dialogPolyfill","registerDialog","error","open","showModal","add","dialog","mergeRefs","onCancel","Children","map","child","isValidElement","cloneElement","displayName"],"mappings":"AAAA;;;;;+BA+KSA;;;eAAAA;;;;+DA7Kc;uBAWhB;mCAC2B;+BACH;uBAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAK1B,MAAMC,wBAAwB;AAE9B,MAAMD,sBAAQE,IAAAA,iBAAU,EAAC,CAACC,OAAmBC;IAC3C,MAAM,EACJC,MAAM,EACNC,OAAO,EACPC,MAAM,EACNC,QAAQ,EACRC,SAAS,EACTC,UAAU,EACVC,YAAY,EACZC,SAAS,EACT,yBAAyB;IACzBC,IAAI,EACJC,UAAU,EACVC,iBAAiB,EACjBC,sBAAsB,EACtBC,cAAc,EACf,GAAGd;IACJ,MAAMe,8BAA8BC,IAAAA,aAAM,EAAU;IACpD,0BAA0B;IAC1B,IAAI,CAACD,4BAA4BE,OAAO,EAAE;QACxC,IACEP,QACAC,cACAC,qBACAC,0BACAC,gBACA;YACAI,QAAQC,IAAI,CACV,CAAC,yJAAyJ,CAAC;YAE7JJ,4BAA4BE,OAAO,GAAG;QACxC;IACF;IAEA,MAAMG,YAAYJ,IAAAA,aAAM,EAAU;IAClC,MAAMK,WAAWL,IAAAA,aAAM,EAA2B;IAClD,MAAMM,mBAAmBC,IAAAA,6BAAc;IAEvC,mBAAmB;IACnB,IAAInB,UAAU,CAACgB,UAAUH,OAAO,EAAE;QAChCb;QACAgB,UAAUH,OAAO,GAAG;IACtB;IAEAO,IAAAA,oCAAiB,EAAC;QAAEC,SAASvB;IAAO;IAEpC,kDAAkD;IAClD,MAAMwB,cAAcC,IAAAA,kBAAW,EAC7B,CAACC;QACC,IAAIA,OAAO;YACTA,MAAMC,cAAc;YACpBD,MAAME,eAAe;QACvB;QAEA,sEAAsE;QACtE,MAAMC,qBAAqB,C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