@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
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "filterUndefinedProps", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return filterUndefinedProps;
9
+ }
10
+ });
11
+ const filterUndefinedProps = (props)=>{
12
+ const filteredProps = {};
13
+ Object.keys(props).forEach((key)=>{
14
+ if (props[key] !== undefined) {
15
+ filteredProps[key] = props[key];
16
+ }
17
+ });
18
+ return filteredProps;
19
+ };
20
+
21
+ //# sourceMappingURL=filterUndefinedProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/filterUndefinedProps.ts"],"sourcesContent":["export const filterUndefinedProps = (props: Record<string, unknown>) => {\n const filteredProps: Record<string, unknown> = {};\n Object.keys(props).forEach(key => {\n if (props[key] !== undefined) {\n filteredProps[key] = props[key];\n }\n });\n return filteredProps;\n};\n"],"names":["filterUndefinedProps","props","filteredProps","Object","keys","forEach","key","undefined"],"mappings":";;;;+BAAaA;;;eAAAA;;;AAAN,MAAMA,uBAAuB,CAACC;IACnC,MAAMC,gBAAyC,CAAC;IAChDC,OAAOC,IAAI,CAACH,OAAOI,OAAO,CAACC,CAAAA;QACzB,IAAIL,KAAK,CAACK,IAAI,KAAKC,WAAW;YAC5BL,aAAa,CAACI,IAAI,GAAGL,KAAK,CAACK,IAAI;QACjC;IACF;IACA,OAAOJ;AACT"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getSpacingValue", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return getSpacingValue;
9
+ }
10
+ });
11
+ const getSpacingValue = (padding)=>{
12
+ if (typeof padding === "string") {
13
+ return `var(--size-${padding})`;
14
+ }
15
+ if (typeof padding === "number") {
16
+ return `${padding}px`;
17
+ }
18
+ return undefined;
19
+ };
20
+
21
+ //# sourceMappingURL=getSpacingValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/getSpacingValue.ts"],"sourcesContent":["import { SpacingType } from \"../types\";\n\nexport const getSpacingValue = (\n padding: SpacingType | undefined,\n): string | undefined => {\n if (typeof padding === \"string\") {\n return `var(--size-${padding})`;\n }\n\n if (typeof padding === \"number\") {\n return `${padding}px`;\n }\n\n return undefined;\n};\n"],"names":["getSpacingValue","padding","undefined"],"mappings":";;;;+BAEaA;;;eAAAA;;;AAAN,MAAMA,kBAAkB,CAC7BC;IAEA,IAAI,OAAOA,YAAY,UAAU;QAC/B,OAAO,CAAC,WAAW,EAAEA,QAAQ,CAAC,CAAC;IACjC;IAEA,IAAI,OAAOA,YAAY,UAAU;QAC/B,OAAO,CAAC,EAAEA,QAAQ,EAAE,CAAC;IACvB;IAEA,OAAOC;AACT"}
@@ -4,10 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  _export_star(require("./changeCSS"), exports);
6
6
  _export_star(require("./excludeControls"), exports);
7
+ _export_star(require("./filterUndefinedProps"), exports);
8
+ _export_star(require("./getSpacingValue"), exports);
7
9
  _export_star(require("./jestHTMLDialogPolyfill"), exports);
8
10
  _export_star(require("./mergeRefs"), exports);
9
11
  _export_star(require("./polyfill-tests"), exports);
10
12
  _export_star(require("./sizeClasses"), exports);
13
+ _export_star(require("./sizeOptions"), exports);
11
14
  _export_star(require("./spaceDelimitedList"), exports);
12
15
  function _export_star(from, to) {
13
16
  Object.keys(from).forEach(function(k) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/index.ts"],"sourcesContent":["export * from \"./changeCSS\";\nexport * from \"./excludeControls\";\nexport * from \"./jestHTMLDialogPolyfill\";\nexport * from \"./mergeRefs\";\nexport * from \"./polyfill-tests\";\nexport * from \"./sizeClasses\";\nexport * from \"./spaceDelimitedList\";\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
1
+ {"version":3,"sources":["../../../src/utils/index.ts"],"sourcesContent":["export * from \"./changeCSS\";\nexport * from \"./excludeControls\";\nexport * from \"./filterUndefinedProps\";\nexport * from \"./getSpacingValue\";\nexport * from \"./jestHTMLDialogPolyfill\";\nexport * from \"./mergeRefs\";\nexport * from \"./polyfill-tests\";\nexport * from \"./sizeClasses\";\nexport * from \"./sizeOptions\";\nexport * from \"./spaceDelimitedList\";\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
@@ -13,6 +13,7 @@ const sizeClasses = (size)=>{
13
13
  return {};
14
14
  }
15
15
  return {
16
+ "--is-xxs": size === "xxs",
16
17
  "--is-xs": size === "xs",
17
18
  "--is-sm": size === "sm",
18
19
  "--is-md": size === "md",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/sizeClasses.ts"],"sourcesContent":["import { SizeType } from \"../types/size\";\n\nexport const sizeClasses = (size: SizeType | undefined) => {\n if (!size) {\n return {};\n }\n\n return {\n \"--is-xs\": size === \"xs\",\n \"--is-sm\": size === \"sm\",\n \"--is-md\": size === \"md\",\n \"--is-lg\": size === \"lg\",\n \"--is-xl\": size === \"xl\",\n \"--is-xxl\": size === \"xxl\",\n };\n};\n"],"names":["sizeClasses","size"],"mappings":";;;;+BAEaA;;;eAAAA;;;AAAN,MAAMA,cAAc,CAACC;IAC1B,IAAI,CAACA,MAAM;QACT,OAAO,CAAC;IACV;IAEA,OAAO;QACL,WAAWA,SAAS;QACpB,WAAWA,SAAS;QACpB,WAAWA,SAAS;QACpB,WAAWA,SAAS;QACpB,WAAWA,SAAS;QACpB,YAAYA,SAAS;IACvB;AACF"}
1
+ {"version":3,"sources":["../../../src/utils/sizeClasses.ts"],"sourcesContent":["import { SizeType } from \"../types/size\";\n\nexport const sizeClasses = (size: SizeType | undefined) => {\n if (!size) {\n return {};\n }\n\n return {\n \"--is-xxs\": size === \"xxs\",\n \"--is-xs\": size === \"xs\",\n \"--is-sm\": size === \"sm\",\n \"--is-md\": size === \"md\",\n \"--is-lg\": size === \"lg\",\n \"--is-xl\": size === \"xl\",\n \"--is-xxl\": size === \"xxl\",\n };\n};\n"],"names":["sizeClasses","size"],"mappings":";;;;+BAEaA;;;eAAAA;;;AAAN,MAAMA,cAAc,CAACC;IAC1B,IAAI,CAACA,MAAM;QACT,OAAO,CAAC;IACV;IAEA,OAAO;QACL,YAAYA,SAAS;QACrB,WAAWA,SAAS;QACpB,WAAWA,SAAS;QACpB,WAAWA,SAAS;QACpB,WAAWA,SAAS;QACpB,WAAWA,SAAS;QACpB,YAAYA,SAAS;IACvB;AACF"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "sizeOptions", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return sizeOptions;
9
+ }
10
+ });
11
+ const sizeOptions = [
12
+ "",
13
+ "xxs",
14
+ "xs",
15
+ "sm",
16
+ "md",
17
+ "lg",
18
+ "xl",
19
+ "xxl"
20
+ ];
21
+
22
+ //# sourceMappingURL=sizeOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/sizeOptions.ts"],"sourcesContent":["import { SizeType } from \"../types\";\n\nexport const sizeOptions: Array<SizeType | \"\"> = [\n \"\",\n \"xxs\",\n \"xs\",\n \"sm\",\n \"md\",\n \"lg\",\n \"xl\",\n \"xxl\",\n];\n"],"names":["sizeOptions"],"mappings":";;;;+BAEaA;;;eAAAA;;;AAAN,MAAMA,cAAoC;IAC/C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD"}
@@ -1,11 +1,29 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  import classNames from "classnames/dedupe";
4
+ import { getSpacingValue, filterUndefinedProps } from "../../utils";
4
5
  const Box = /*#__PURE__*/ forwardRef((props, ref)=>{
5
- const { elementType: Element = "div", ...otherProps } = props;
6
+ 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;
6
7
  const classes = classNames("mobius", "mobius/Box", otherProps.className);
8
+ const styleProps = filterUndefinedProps({
9
+ padding: getSpacingValue(padding),
10
+ paddingInline: getSpacingValue(paddingInline || paddingX),
11
+ paddingBlock: getSpacingValue(paddingBlock || paddingY),
12
+ paddingTop: getSpacingValue(paddingTop || paddingBlockStart),
13
+ paddingRight: getSpacingValue(paddingRight || paddingInlineEnd),
14
+ paddingBottom: getSpacingValue(paddingBottom || paddingBlockEnd),
15
+ paddingLeft: getSpacingValue(paddingLeft || paddingInlineStart),
16
+ minWidth,
17
+ minHeight,
18
+ maxWidth,
19
+ maxHeight,
20
+ width,
21
+ height,
22
+ ...style
23
+ });
7
24
  return /*#__PURE__*/ _jsx(Element, {
8
25
  ref: ref,
26
+ style: styleProps,
9
27
  ...otherProps,
10
28
  className: classes
11
29
  });
@@ -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":["forwardRef","classNames","Box","props","ref","elementType","Element","otherProps","classes","className","displayName"],"mappings":";AAAA,SAAcA,UAAU,QAAkC,QAAQ;AAClE,OAAOC,gBAAgB,oBAAoB;AAiB3C,MAAMC,oBAAuDF,WAC3D,CAACG,OAAiBC;IAChB,MAAM,EAAEC,aAAaC,UAAU,KAAK,EAAE,GAAGC,YAAY,GAAGJ;IAExD,MAAMK,UAAUP,WAAW,UAAU,cAAcM,WAAWE,SAAS;IAEvE,qBAAO,KAACH;QAAQF,KAAKA;QAAM,GAAGG,UAAU;QAAEE,WAAWD;;AACvD;AAGFN,IAAIQ,WAAW,GAAG;AAClB,SAASR,GAAG,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":["forwardRef","classNames","getSpacingValue","filterUndefinedProps","Box","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","className","styleProps","displayName"],"mappings":";AAAA,SAAcA,UAAU,QAAQ,QAAQ;AACxC,OAAOC,gBAAgB,oBAAoB;AAG3C,SAASC,eAAe,EAAEC,oBAAoB,QAAQ,cAAc;AAIpE,MAAMC,oBAAuDJ,WAC3D,CAACK,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,UAAU7B,WAAW,UAAU,cAAc4B,WAAWE,SAAS;IAEvE,MAAMC,aAAa7B,qBAAqB;QACtCM,SAASP,gBAAgBO;QACzBE,eAAeT,gBAAgBS,iBAAiBD;QAChDK,cAAcb,gBAAgBa,gBAAgBD;QAC9CI,YAAYhB,gBAAgBgB,cAAcF;QAC1CG,cAAcjB,gBAAgBiB,gBAAgBN;QAC9CO,eAAelB,gBAAgBkB,iBAAiBH;QAChDI,aAAanB,gBAAgBmB,eAAeT;QAC5CU;QACAC;QACAC;QACAC;QACAC;QACAC;QACA,GAAGC,KAAK;IACV;IAEA,qBACE,KAACpB;QACCF,KAAKA;QACLsB,OAAOI;QACN,GAAGH,UAAU;QACdE,WAAWD;;AAGjB;AAGF1B,IAAI6B,WAAW,GAAG;AAClB,SAAS7B,GAAG,GAAG"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/Box/types.ts"],"sourcesContent":["import { ReactNode, RefAttributes } from \"react\";\nimport { DOMProps, SpacingType } from \"../../types\";\n\nexport type BoxElementType = HTMLDivElement;\n\nexport type BoxDimensionsType = string | number;\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 padding?: SpacingType;\n paddingX?: SpacingType;\n paddingInline?: SpacingType;\n paddingInlineStart?: SpacingType;\n paddingInlineEnd?: SpacingType;\n paddingY?: SpacingType;\n paddingBlock?: SpacingType;\n paddingBlockStart?: SpacingType;\n paddingBlockEnd?: SpacingType;\n paddingTop?: SpacingType;\n paddingRight?: SpacingType;\n paddingBottom?: SpacingType;\n paddingLeft?: SpacingType;\n minWidth?: BoxDimensionsType;\n minHeight?: BoxDimensionsType;\n maxWidth?: BoxDimensionsType;\n maxHeight?: BoxDimensionsType;\n width?: BoxDimensionsType;\n height?: BoxDimensionsType;\n}\n"],"names":[],"mappings":"AAOA,WA0BC"}
@@ -26,20 +26,26 @@ const Drawer = /*#__PURE__*/ forwardRef((props, ref)=>{
26
26
  event.preventDefault();
27
27
  event.stopPropagation();
28
28
  }
29
+ // Name the callback function, so we can add and remove event listener
30
+ const transitionCallback = (e)=>{
31
+ // Close drawer only if the transition is on the dialog element
32
+ // As it can be on a child element (ie `<Button>` inside the drawer)
33
+ if (e.target === modalRef.current) {
34
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
35
+ doClose();
36
+ }
37
+ };
29
38
  const doClose = ()=>{
30
- var _modalRef_current;
39
+ var _modalRef_current, _modalRef_current1;
31
40
  (_modalRef_current = modalRef.current) === null || _modalRef_current === void 0 ? void 0 : _modalRef_current.close();
32
41
  onClose === null || onClose === void 0 ? void 0 : onClose();
42
+ (_modalRef_current1 = modalRef.current) === null || _modalRef_current1 === void 0 ? void 0 : _modalRef_current1.removeEventListener("transitionend", transitionCallback);
33
43
  };
34
44
  // Delay close to allow backdrop exit transition
35
45
  if (hasDialogSupport) {
36
46
  var _modalRef_current, _modalRef_current1;
37
47
  (_modalRef_current = modalRef.current) === null || _modalRef_current === void 0 ? void 0 : _modalRef_current.classList.remove(TRANSITION_CLASS_NAME);
38
- (_modalRef_current1 = modalRef.current) === null || _modalRef_current1 === void 0 ? void 0 : _modalRef_current1.addEventListener("transitionend", ()=>{
39
- doClose();
40
- }, {
41
- once: true
42
- });
48
+ (_modalRef_current1 = modalRef.current) === null || _modalRef_current1 === void 0 ? void 0 : _modalRef_current1.addEventListener("transitionend", transitionCallback);
43
49
  } else {
44
50
  doClose();
45
51
  }
@@ -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":["classNames","Children","cloneElement","forwardRef","isValidElement","useCallback","useEffect","useRef","useBodyScrollLock","supportsDialog","VisuallyHidden","mergeRefs","TRANSITION_CLASS_NAME","Drawer","props","ref","isOpen","className","closeLabel","direction","announce","onOpen","onClose","children","hasOpened","modalRef","hasDialogSupport","current","enabled","handleClose","event","preventDefault","stopPropagation","doClose","close","classList","remove","addEventListener","once","modalClasses","toggleModal","window","default","dialogPolyfill","registerDialog","error","console","open","showModal","add","dialog","onCancel","aria-describedby","div","id","map","child","displayName"],"mappings":"AAAA;;AAEA,OAAOA,gBAAgB,oBAAoB;AAC3C,SACEC,QAAQ,EAGRC,YAAY,EACZC,UAAU,EACVC,cAAc,EACdC,WAAW,EACXC,SAAS,EACTC,MAAM,QACD,QAAQ;AACf,SAASC,iBAAiB,QAAQ,gCAAgC;AAClE,SAASC,cAAc,QAAQ,6BAA6B;AAC5D,SAASC,cAAc,QAAQ,oBAAoB;AAEnD,SAASC,SAAS,QAAQ,cAAc;AAKxC,MAAMC,wBAAwB;AAE9B,MAAMC,uBAASV,WAAW,CAACW,OAAoBC;IAC7C,MAAM,EACJC,MAAM,EACNC,SAAS,EACTC,UAAU,EACVC,SAAS,EACTC,WAAW,yBAAyB,EACpCC,MAAM,EACNC,OAAO,EACPC,QAAQ,EACT,GAAGT;IACJ,MAAMU,YAAYjB,OAAgB;IAClC,MAAMkB,WAAWlB,OAAiC;IAClD,MAAMmB,mBAAmBjB;IAEzB,mBAAmB;IACnB,IAAIY,UAAU,CAACG,UAAUG,OAAO,EAAE;QAChCN;QACAG,UAAUG,OAAO,GAAG;IACtB;IAEAnB,kBAAkB;QAAEoB,SAASZ;IAAO;IAEpC,mDAAmD;IACnD,MAAMa,cAAcxB,YAClB,CAACyB;QACC,IAAIA,OAAO;YACTA,MAAMC,cAAc;YACpBD,MAAME,eAAe;QACvB;QAEA,MAAMC,UAAU;gBACdR;aAAAA,oBAAAA,SAASE,OAAO,cAAhBF,wCAAAA,kBAAkBS,KAAK;YACvBZ,oBAAAA,8BAAAA;QACF;QAEA,gDAAgD;QAChD,IAAII,kBAAkB;gBACpBD,mBACAA;aADAA,oBAAAA,SAASE,OAAO,cAAhBF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ACXa,oBAAiB;;0BAEjB,KAAC1C;0BACC,cAAA,KAAC2C;oBAAIC,IAAG;8BAA0BlC;;;YAEnCnB,SAASsD,GAAG,CAAChC,UAAUiC,CAAAA;gBACtB,kBAAIpD,eAAeoD,QAAQ;oBACzB,qBAAOtD,aAAasD,OAAO;wBACzBlC,SAASO;wBACTX;oBACF;gBACF;gBAEA,OAAOsC;YACT;;;AAGN;AAEA3C,OAAO4C,WAAW,GAAG;AACrB,SAAS5C,MAAM,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":["classNames","Children","cloneElement","forwardRef","isValidElement","useCallback","useEffect","useRef","useBodyScrollLock","supportsDialog","VisuallyHidden","mergeRefs","TRANSITION_CLASS_NAME","Drawer","props","ref","isOpen","className","closeLabel","direction","announce","onOpen","onClose","children","hasOpened","modalRef","hasDialogSupport","current","enabled","handleClose","event","preventDefault","stopPropagation","transitionCallback","e","target","doClose","close","removeEventListener","classList","remove","addEventListener","modalClasses","toggleModal","window","default","dialogPolyfill","registerDialog","error","console","open","showModal","add","dialog","onCancel","aria-describedby","div","id","map","child","displayName"],"mappings":"AAAA;;AAEA,OAAOA,gBAAgB,oBAAoB;AAC3C,SACEC,QAAQ,EAGRC,YAAY,EACZC,UAAU,EACVC,cAAc,EACdC,WAAW,EACXC,SAAS,EACTC,MAAM,QACD,QAAQ;AACf,SAASC,iBAAiB,QAAQ,gCAAgC;AAClE,SAASC,cAAc,QAAQ,6BAA6B;AAC5D,SAASC,cAAc,QAAQ,oBAAoB;AAEnD,SAASC,SAAS,QAAQ,cAAc;AAKxC,MAAMC,wBAAwB;AAE9B,MAAMC,uBAASV,WAAW,CAACW,OAAoBC;IAC7C,MAAM,EACJC,MAAM,EACNC,SAAS,EACTC,UAAU,EACVC,SAAS,EACTC,WAAW,yBAAyB,EACpCC,MAAM,EACNC,OAAO,EACPC,QAAQ,EACT,GAAGT;IACJ,MAAMU,YAAYjB,OAAgB;IAClC,MAAMkB,WAAWlB,OAAiC;IAClD,MAAMmB,mBAAmBjB;IAEzB,mBAAmB;IACnB,IAAIY,UAAU,CAACG,UAAUG,OAAO,EAAE;QAChCN;QACAG,UAAUG,OAAO,GAAG;IACtB;IAEAnB,kBAAkB;QAAEoB,SAASZ;IAAO;IAEpC,mDAAmD;IACnD,MAAMa,cAAcxB,YAClB,CAACyB;QACC,IAAIA,OAAO;YACTA,MAAMC,cAAc;YACpBD,MAA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BADAA,qBAAAA,SAASE,OAAO,cAAhBF,yCAAAA,mBAAkB0B,SAAS;iBAC3B1B,qBAAAA,SAASE,OAAO,cAAhBF,yCAAAA,mBAAkBc,SAAS,CAACa,GAAG,CAACxC;gBAChCS,mBAAAA,6BAAAA;YACF,OAAO,IAAI,CAACL,YAAUS,qBAAAA,SAASE,OAAO,cAAhBF,yCAAAA,mBAAkByB,IAAI,GAAE;gBAC5CrB;YACF;QACF;QAEAc;IACF,GAAG;QAAC3B;QAAQK;QAAQQ;QAAaH;KAAiB;IAElD,qBACE,MAAC2B;QACCtC,KAAKJ,UAAU;YAACc;YAAUV;SAAI;QAC9BuC,UAAUzB;QACVZ,WAAWyB;QACXa,oBAAiB;;0BAEjB,KAAC7C;0BACC,cAAA,KAAC8C;oBAAIC,IAAG;8BAA0BrC;;;YAEnCnB,SAASyD,GAAG,CAACnC,UAAUoC,CAAAA;gBACtB,kBAAIvD,eAAeuD,QAAQ;oBACzB,qBAAOzD,aAAayD,OAAO;wBACzBrC,SAASO;wBACTX;oBACF;gBACF;gBAEA,OAAOyC;YACT;;;AAGN;AAEA9C,OAAO+C,WAAW,GAAG;AACrB,SAAS/C,MAAM,GAAG"}
@@ -1,4 +1,5 @@
1
- export const withoutUndefinedValues = (obj)=>Object.fromEntries(Object.entries(obj).filter(([_, value])=>value));
1
+ import { getSpacingValue } from "../../utils";
2
+ import { filterUndefinedProps } from "../../utils/filterUndefinedProps";
2
3
  export const buildFlexStyles = (props)=>{
3
4
  const { flexDirection, flexWrap, flexGrow, flex, justifyContent, alignItems, alignContent, gap, rowGap, columnGap } = props;
4
5
  const styleProps = {
@@ -10,11 +11,11 @@ export const buildFlexStyles = (props)=>{
10
11
  justifyContent,
11
12
  alignItems,
12
13
  alignContent,
13
- gap,
14
- rowGap,
15
- columnGap
14
+ gap: getSpacingValue(gap),
15
+ columnGap: getSpacingValue(columnGap),
16
+ rowGap: getSpacingValue(rowGap)
16
17
  };
17
- return withoutUndefinedValues(styleProps);
18
+ return filterUndefinedProps(styleProps);
18
19
  };
19
20
  export const splitProps = (props)=>{
20
21
  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":["withoutUndefinedValues","obj","Object","fromEntries","entries","filter","_","value","buildFlexStyles","props","flexDirection","flexWrap","flexGrow","flex","justifyContent","alignItems","alignContent","gap","rowGap","columnGap","styleProps","display","splitProps","otherProps"],"mappings":"AAEA,OAAO,MAAMA,yBAAyB,CAACC,MACrCC,OAAOC,WAAW,CAACD,OAAOE,OAAO,CAACH,KAAKI,MAAM,CAAC,CAAC,CAACC,GAAGC,MAAM,GAAKA,QAAQ;AAExE,OAAO,MAAMC,kBAAkB,CAACC;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,OAAOnB,uBAAuBoB;AAChC,EAAE;AAEF,OAAO,MAAME,aAAa,CACxBb;IAEA,MAAM,EACJC,aAAa,EACbC,QAAQ,EACRC,QAAQ,EACRC,IAAI,EACJC,cAAc,EACdC,UAAU,EACVC,YAAY,EACZC,GAAG,EACHC,MAAM,EACNC,SAAS,EACT,GAAGI,YACJ,GAAGd;IAEJ,OAAO;QACL;YACEC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;QACAI;KACD;AACH,EAAE"}
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":["getSpacingValue","filterUndefinedProps","buildFlexStyles","props","flexDirection","flexWrap","flexGrow","flex","justifyContent","alignItems","alignContent","gap","rowGap","columnGap","styleProps","display","splitProps","otherProps"],"mappings":"AAAA,SAASA,eAAe,QAAQ,cAAc;AAC9C,SAASC,oBAAoB,QAAQ,mCAAmC;AAGxE,OAAO,MAAMC,kBAAkB,CAACC;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,KAAKX,gBAAgBW;QACrBE,WAAWb,gBAAgBa;QAC3BD,QAAQZ,gBAAgBY;IAC1B;IAEA,OAAOX,qBAAqBa;AAC9B,EAAE;AAEF,OAAO,MAAME,aAAa,CACxBb;IAEA,MAAM,EACJC,aAAa,EACbC,QAAQ,EACRC,QAAQ,EACRC,IAAI,EACJC,cAAc,EACdC,UAAU,EACVC,YAAY,EACZC,GAAG,EACHC,MAAM,EACNC,SAAS,EACT,GAAGI,YACJ,GAAGd;IAEJ,OAAO;QACL;YACEC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;QACAI;KACD;AACH,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/Flex/types.ts"],"sourcesContent":["import { Ref, ReactNode, RefAttributes, AriaRole } from \"react\";\nimport type { Property } from \"csstype\";\nimport { DOMProps } from \"../../types/dom\";\n\nexport type FlexElementType = HTMLDivElement;\n\nexport interface FlexStyleProps {\n elementType?: string | React.ElementType;\n flexDirection?: Property.FlexDirection;\n flexWrap?: Property.FlexWrap;\n flexGrow?: Property.FlexGrow;\n flex?: Property.Flex;\n /** Aligns grid items along the block (column) axis */\n alignItems?: Property.AlignItems;\n /** Aligns the grid along the inline (row) axis */\n alignContent?: Property.AlignContent;\n /** Aligns the grid along the inline (row) axis */\n justifyContent?: Property.JustifyContent;\n /** How big a gap between the columns and rows */\n gap?: Property.Gap;\n /** How big a gap between the rows */\n rowGap?: Property.RowGap;\n /** How big a gap between the columns */\n columnGap?: Property.ColumnGap;\n style?: React.CSSProperties;\n role?: AriaRole;\n}\n\nexport interface FlexNonStyleProps\n extends DOMProps,\n RefAttributes<FlexElementType> {\n children?: ReactNode;\n /** Custom class name for setting specific CSS */\n className?: string;\n}\n\nexport interface FlexProps extends FlexStyleProps, FlexNonStyleProps {}\n\nexport type FlexRef = Ref<FlexElementType>;\n"],"names":[],"mappings":"AAsCA,WAA2C"}
1
+ {"version":3,"sources":["../../../../src/components/Flex/types.ts"],"sourcesContent":["import { Ref, ReactNode, RefAttributes, AriaRole } from \"react\";\nimport type { Property } from \"csstype\";\nimport { DOMProps } from \"../../types/dom\";\nimport { SpacingType } from \"../../types\";\n\nexport type FlexElementType = HTMLDivElement;\n\nexport interface FlexStyleProps {\n elementType?: string | React.ElementType;\n flexDirection?: Property.FlexDirection;\n flexWrap?: Property.FlexWrap;\n flexGrow?: Property.FlexGrow;\n flex?: Property.Flex;\n /** Aligns grid items along the block (column) axis */\n alignItems?: Property.AlignItems;\n /** Aligns the grid along the inline (row) axis */\n alignContent?: Property.AlignContent;\n /** Aligns the grid along the inline (row) axis */\n justifyContent?: Property.JustifyContent;\n /** How big a gap between the columns and rows */\n gap?: SpacingType;\n /** How big a gap between the rows */\n rowGap?: SpacingType;\n /** How big a gap between the columns */\n columnGap?: SpacingType;\n style?: React.CSSProperties;\n role?: AriaRole;\n}\n\nexport interface FlexNonStyleProps\n extends DOMProps,\n RefAttributes<FlexElementType> {\n children?: ReactNode;\n /** Custom class name for setting specific CSS */\n className?: string;\n}\n\nexport interface FlexProps extends FlexStyleProps, FlexNonStyleProps {}\n\nexport type FlexRef = Ref<FlexElementType>;\n"],"names":[],"mappings":"AAuCA,WAA2C"}
@@ -1,17 +1,17 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  import classNames from "classnames/dedupe";
4
- import { withoutUndefinedValues } from "../Flex/propUtils";
4
+ import { filterUndefinedProps, getSpacingValue } from "../../utils";
5
5
  const Grid = /*#__PURE__*/ forwardRef((props, _ref)=>{
6
6
  const { columns = 12, gap, columnGap, rowGap, alignContent, alignItems, justifyContent, justifyItems, className, ...rest } = props;
7
7
  const classes = classNames("mobius", "mobius/Grid", className);
8
- const styles = withoutUndefinedValues({
8
+ const styles = filterUndefinedProps({
9
9
  boxSizing: "border-box",
10
10
  display: "grid",
11
11
  gridTemplateColumns: `repeat(${columns}, 1fr)`,
12
- gap: gap ? `var(--${gap})` : undefined,
13
- columnGap: columnGap ? `var(--${columnGap})` : undefined,
14
- rowGap: rowGap ? `var(--${rowGap})` : undefined,
12
+ gap: getSpacingValue(gap),
13
+ columnGap: getSpacingValue(columnGap),
14
+ rowGap: getSpacingValue(rowGap),
15
15
  alignContent,
16
16
  alignItems,
17
17
  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":["forwardRef","classNames","withoutUndefinedValues","Grid","props","_ref","columns","gap","columnGap","rowGap","alignContent","alignItems","justifyContent","justifyItems","className","rest","classes","styles","boxSizing","display","gridTemplateColumns","undefined","div","style","displayName"],"mappings":";AAAA,SAEEA,UAAU,QAIL,QAAQ;AACf,OAAOC,gBAAgB,oBAAoB;AAG3C,SAASC,sBAAsB,QAAQ,oBAAoB;AAuC3D,MAAMC,qBAA0DH,WAC9D,CAACI,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,UAAUf,WAAW,UAAU,eAAea;IAEpD,MAAMG,SAAwBf,uBAAuB;QACnDgB,WAAW;QACXC,SAAS;QACTC,qBAAqB,CAAC,OAAO,EAAEd,QAAQ,MAAM,CAAC;QAC9CC,KAAKA,MAAM,CAAC,MAAM,EAAEA,IAAI,CAAC,CAAC,GAAGc;QAC7Bb,WAAWA,YAAY,CAAC,MAAM,EAAEA,UAAU,CAAC,CAAC,GAAGa;QAC/CZ,QAAQA,SAAS,CAAC,MAAM,EAAEA,OAAO,CAAC,CAAC,GAAGY;QACtCX;QACAC;QACAC;QACAC;IACF;IAEA,qBAAO,KAACS;QAAIC,OAAON;QAAQH,WAAWE;QAAU,GAAGD,IAAI;;AACzD;AAGFZ,KAAKqB,WAAW,GAAG;AACnB,SAASrB,IAAI,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":["forwardRef","classNames","filterUndefinedProps","getSpacingValue","Grid","props","_ref","columns","gap","columnGap","rowGap","alignContent","alignItems","justifyContent","justifyItems","className","rest","classes","styles","boxSizing","display","gridTemplateColumns","div","style","displayName"],"mappings":";AAAA,SAEEA,UAAU,QAIL,QAAQ;AACf,OAAOC,gBAAgB,oBAAoB;AAG3C,SAASC,oBAAoB,EAAEC,eAAe,QAAQ,cAAc;AAwCpE,MAAMC,qBAA0DJ,WAC9D,CAACK,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,UAAUhB,WAAW,UAAU,eAAec;IAEpD,MAAMG,SAAwBhB,qBAAqB;QACjDiB,WAAW;QACXC,SAAS;QACTC,qBAAqB,CAAC,OAAO,EAAEd,QAAQ,MAAM,CAAC;QAC9CC,KAAKL,gBAAgBK;QACrBC,WAAWN,gBAAgBM;QAC3BC,QAAQP,gBAAgBO;QACxBC;QACAC;QACAC;QACAC;IACF;IAEA,qBAAO,KAACQ;QAAIC,OAAOL;QAAQH,WAAWE;QAAU,GAAGD,IAAI;;AACzD;AAGFZ,KAAKoB,WAAW,GAAG;AACnB,SAASpB,IAAI,GAAG"}
@@ -34,20 +34,26 @@ const Modal = /*#__PURE__*/ forwardRef((props, ref)=>{
34
34
  event.preventDefault();
35
35
  event.stopPropagation();
36
36
  }
37
+ // Name the callback function, so we can add and remove event listener
38
+ const transitionCallback = (e)=>{
39
+ // Close modal only if the transition is on the dialog element
40
+ // As it can be on a child element (ie `<Button>` inside the drawer)
41
+ if (e.target === modalRef.current) {
42
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
43
+ doClose();
44
+ }
45
+ };
37
46
  const doClose = ()=>{
38
- var _modalRef_current;
47
+ var _modalRef_current, _modalRef_current1;
39
48
  (_modalRef_current = modalRef.current) === null || _modalRef_current === void 0 ? void 0 : _modalRef_current.close();
40
49
  onClose === null || onClose === void 0 ? void 0 : onClose();
50
+ (_modalRef_current1 = modalRef.current) === null || _modalRef_current1 === void 0 ? void 0 : _modalRef_current1.removeEventListener("transitionend", transitionCallback);
41
51
  };
42
52
  // Delay close to allow backdrop exit transition
43
53
  if (hasDialogSupport && animation) {
44
54
  var _modalRef_current, _modalRef_current1;
45
55
  (_modalRef_current = modalRef.current) === null || _modalRef_current === void 0 ? void 0 : _modalRef_current.classList.remove(TRANSITION_CLASS_NAME);
46
- (_modalRef_current1 = modalRef.current) === null || _modalRef_current1 === void 0 ? void 0 : _modalRef_current1.addEventListener("transitionend", ()=>{
47
- doClose();
48
- }, {
49
- once: true
50
- });
56
+ (_modalRef_current1 = modalRef.current) === null || _modalRef_current1 === void 0 ? void 0 : _modalRef_current1.addEventListener("transitionend", transitionCallback);
51
57
  } else {
52
58
  doClose();
53
59
  }
@@ -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":["classNames","Children","cloneElement","forwardRef","isValidElement","useCallback","useEffect","useRef","useBodyScrollLock","supportsDialog","mergeRefs","TRANSITION_CLASS_NAME","Modal","props","ref","isOpen","onClose","onOpen","children","className","closeLabel","isFullScreen","animation","size","appElement","preventCloseOnEsc","shouldFocusAfterRender","parentSelector","hasWarnedAboutMissingLabels","current","console","warn","hasOpened","modalRef","hasDialogSupport","enabled","handleClose","event","preventDefault","stopPropagation","doClose","close","classList","remove","addEventListener","once","modalClasses","toggleModal","window","default","dialogPolyfill","registerDialog","error","open","showModal","add","dialog","onCancel","map","child","displayName"],"mappings":"AAAA;;AAEA,OAAOA,gBAAgB,oBAAoB;AAC3C,SACEC,QAAQ,EAGRC,YAAY,EACZC,UAAU,EACVC,cAAc,EACdC,WAAW,EACXC,SAAS,EACTC,MAAM,QACD,QAAQ;AACf,SAASC,iBAAiB,QAAQ,gCAAgC;AAClE,SAASC,cAAc,QAAQ,6BAA6B;AAE5D,SAASC,SAAS,QAAQ,cAAc;AAKxC,MAAMC,wBAAwB;AAE9B,MAAMC,sBAAQT,WAAW,CAACU,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,8BAA8BrB,OAAgB;IACpD,0BAA0B;IAC1B,IAAI,CAACqB,4BAA4BC,OAAO,EAAE;QACxC,IACEN,QACAC,cACAC,qBACAC,0BACAC,gBACA;YACAG,QAAQC,IAAI,CACV,CAAC,yJAAyJ,CAAC;YAE7JH,4BAA4BC,OAAO,GAAG;QACxC;IACF;IAEA,MAAMG,YAAYzB,OAAgB;IAClC,MAAM0B,WAAW1B,OAAiC;IAClD,MAAM2B,mBAAmBzB;IAEzB,mBAAmB;IACnB,IAAIQ,UAAU,CAACe,UAAUH,OAAO,EAAE;QAChCZ;Q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AA,kBAAkBoB,IAAI,GAAE;oBACrCpB,oBACAA;iBADAA,qBAAAA,SAASJ,OAAO,cAAhBI,yCAAAA,mBAAkBqB,SAAS;iBAC3BrB,qBAAAA,SAASJ,OAAO,cAAhBI,yCAAAA,mBAAkBS,SAAS,CAACa,GAAG,CAAC5C;gBAChCM,mBAAAA,6BAAAA;YACF,OAAO,IAAI,CAACF,YAAUkB,qBAAAA,SAASJ,OAAO,cAAhBI,yCAAAA,mBAAkBoB,IAAI,GAAE;gBAC5CjB;YACF;QACF;QAEAW;IACF,GAAG;QAAChC;QAAQE;QAAQmB;QAAaF;KAAiB;IAElD,qBACE,KAACsB;QACC1C,KAAKJ,UAAU;YAACuB;YAAUnB;SAAI;QAC9B2C,UAAUrB;QACVjB,WAAW2B;kBAEV7C,SAASyD,GAAG,CAACxC,UAAUyC,CAAAA;YACtB,kBAAIvD,eAAeuD,QAAQ;gBACzB,qBAAOzD,aAAayD,OAAO;oBACzB3C,SAASoB;oBACThB;gBACF;YACF;YAEA,OAAOuC;QACT;;AAGN;AAEA/C,MAAMgD,WAAW,GAAG;AACpB,SAAShD,KAAK,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":["classNames","Children","cloneElement","forwardRef","isValidElement","useCallback","useEffect","useRef","useBodyScrollLock","supportsDialog","mergeRefs","TRANSITION_CLASS_NAME","Modal","props","ref","isOpen","onClose","onOpen","children","className","closeLabel","isFullScreen","animation","size","appElement","preventCloseOnEsc","shouldFocusAfterRender","parentSelector","hasWarnedAboutMissingLabels","current","console","warn","hasOpened","modalRef","hasDialogSupport","enabled","handleClose","event","preventDefault","stopPropagation","transitionCallback","e","target","doClose","close","removeEventListener","classList","remove","addEventListener","modalClasses","toggleModal","window","default","dialogPolyfill","registerDialog","error","open","showModal","add","dialog","onCancel","map","child","displayName"],"mappings":"AAAA;;AAEA,OAAOA,gB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A,mBAAkBa,SAAS,CAACY,GAAG,CAAC/C;gBAChCM,mBAAAA,6BAAAA;YACF,OAAO,IAAI,CAACF,YAAUkB,qBAAAA,SAASJ,OAAO,cAAhBI,yCAAAA,mBAAkBuB,IAAI,GAAE;gBAC5CpB;YACF;QACF;QAEAc;IACF,GAAG;QAACnC;QAAQE;QAAQmB;QAAaF;KAAiB;IAElD,qBACE,KAACyB;QACC7C,KAAKJ,UAAU;YAACuB;YAAUnB;SAAI;QAC9B8C,UAAUxB;QACVjB,WAAW8B;kBAEVhD,SAAS4D,GAAG,CAAC3C,UAAU4C,CAAAA;YACtB,kBAAI1D,eAAe0D,QAAQ;gBACzB,qBAAO5D,aAAa4D,OAAO;oBACzB9C,SAASoB;oBACThB;gBACF;YACF;YAEA,OAAO0C;QACT;;AAGN;AAEAlD,MAAMmD,WAAW,GAAG;AACpB,SAASnD,KAAK,GAAG"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/types/size.ts"],"sourcesContent":["export type SizeType = \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"xxl\";\n"],"names":[],"mappings":"AAAA,WAAgE"}
1
+ {"version":3,"sources":["../../../src/types/size.ts"],"sourcesContent":["export type SizeType = \"xxs\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"xxl\";\n\nexport type SpacingType = SizeType | number;\n"],"names":[],"mappings":"AAEA,WAA4C"}
@@ -0,0 +1,11 @@
1
+ export const filterUndefinedProps = (props)=>{
2
+ const filteredProps = {};
3
+ Object.keys(props).forEach((key)=>{
4
+ if (props[key] !== undefined) {
5
+ filteredProps[key] = props[key];
6
+ }
7
+ });
8
+ return filteredProps;
9
+ };
10
+
11
+ //# sourceMappingURL=filterUndefinedProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/filterUndefinedProps.ts"],"sourcesContent":["export const filterUndefinedProps = (props: Record<string, unknown>) => {\n const filteredProps: Record<string, unknown> = {};\n Object.keys(props).forEach(key => {\n if (props[key] !== undefined) {\n filteredProps[key] = props[key];\n }\n });\n return filteredProps;\n};\n"],"names":["filterUndefinedProps","props","filteredProps","Object","keys","forEach","key","undefined"],"mappings":"AAAA,OAAO,MAAMA,uBAAuB,CAACC;IACnC,MAAMC,gBAAyC,CAAC;IAChDC,OAAOC,IAAI,CAACH,OAAOI,OAAO,CAACC,CAAAA;QACzB,IAAIL,KAAK,CAACK,IAAI,KAAKC,WAAW;YAC5BL,aAAa,CAACI,IAAI,GAAGL,KAAK,CAACK,IAAI;QACjC;IACF;IACA,OAAOJ;AACT,EAAE"}
@@ -0,0 +1,11 @@
1
+ export const getSpacingValue = (padding)=>{
2
+ if (typeof padding === "string") {
3
+ return `var(--size-${padding})`;
4
+ }
5
+ if (typeof padding === "number") {
6
+ return `${padding}px`;
7
+ }
8
+ return undefined;
9
+ };
10
+
11
+ //# sourceMappingURL=getSpacingValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/getSpacingValue.ts"],"sourcesContent":["import { SpacingType } from \"../types\";\n\nexport const getSpacingValue = (\n padding: SpacingType | undefined,\n): string | undefined => {\n if (typeof padding === \"string\") {\n return `var(--size-${padding})`;\n }\n\n if (typeof padding === \"number\") {\n return `${padding}px`;\n }\n\n return undefined;\n};\n"],"names":["getSpacingValue","padding","undefined"],"mappings":"AAEA,OAAO,MAAMA,kBAAkB,CAC7BC;IAEA,IAAI,OAAOA,YAAY,UAAU;QAC/B,OAAO,CAAC,WAAW,EAAEA,QAAQ,CAAC,CAAC;IACjC;IAEA,IAAI,OAAOA,YAAY,UAAU;QAC/B,OAAO,CAAC,EAAEA,QAAQ,EAAE,CAAC;IACvB;IAEA,OAAOC;AACT,EAAE"}
@@ -1,9 +1,12 @@
1
1
  export * from "./changeCSS";
2
2
  export * from "./excludeControls";
3
+ export * from "./filterUndefinedProps";
4
+ export * from "./getSpacingValue";
3
5
  export * from "./jestHTMLDialogPolyfill";
4
6
  export * from "./mergeRefs";
5
7
  export * from "./polyfill-tests";
6
8
  export * from "./sizeClasses";
9
+ export * from "./sizeOptions";
7
10
  export * from "./spaceDelimitedList";
8
11
 
9
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/index.ts"],"sourcesContent":["export * from \"./changeCSS\";\nexport * from \"./excludeControls\";\nexport * from \"./jestHTMLDialogPolyfill\";\nexport * from \"./mergeRefs\";\nexport * from \"./polyfill-tests\";\nexport * from \"./sizeClasses\";\nexport * from \"./spaceDelimitedList\";\n"],"names":[],"mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,oBAAoB;AAClC,cAAc,2BAA2B;AACzC,cAAc,cAAc;AAC5B,cAAc,mBAAmB;AACjC,cAAc,gBAAgB;AAC9B,cAAc,uBAAuB"}
1
+ {"version":3,"sources":["../../../src/utils/index.ts"],"sourcesContent":["export * from \"./changeCSS\";\nexport * from \"./excludeControls\";\nexport * from \"./filterUndefinedProps\";\nexport * from \"./getSpacingValue\";\nexport * from \"./jestHTMLDialogPolyfill\";\nexport * from \"./mergeRefs\";\nexport * from \"./polyfill-tests\";\nexport * from \"./sizeClasses\";\nexport * from \"./sizeOptions\";\nexport * from \"./spaceDelimitedList\";\n"],"names":[],"mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,oBAAoB;AAClC,cAAc,yBAAyB;AACvC,cAAc,oBAAoB;AAClC,cAAc,2BAA2B;AACzC,cAAc,cAAc;AAC5B,cAAc,mBAAmB;AACjC,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,uBAAuB"}
@@ -3,6 +3,7 @@ export const sizeClasses = (size)=>{
3
3
  return {};
4
4
  }
5
5
  return {
6
+ "--is-xxs": size === "xxs",
6
7
  "--is-xs": size === "xs",
7
8
  "--is-sm": size === "sm",
8
9
  "--is-md": size === "md",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/sizeClasses.ts"],"sourcesContent":["import { SizeType } from \"../types/size\";\n\nexport const sizeClasses = (size: SizeType | undefined) => {\n if (!size) {\n return {};\n }\n\n return {\n \"--is-xs\": size === \"xs\",\n \"--is-sm\": size === \"sm\",\n \"--is-md\": size === \"md\",\n \"--is-lg\": size === \"lg\",\n \"--is-xl\": size === \"xl\",\n \"--is-xxl\": size === \"xxl\",\n };\n};\n"],"names":["sizeClasses","size"],"mappings":"AAEA,OAAO,MAAMA,cAAc,CAACC;IAC1B,IAAI,CAACA,MAAM;QACT,OAAO,CAAC;IACV;IAEA,OAAO;QACL,WAAWA,SAAS;QACpB,WAAWA,SAAS;QACpB,WAAWA,SAAS;QACpB,WAAWA,SAAS;QACpB,WAAWA,SAAS;QACpB,YAAYA,SAAS;IACvB;AACF,EAAE"}
1
+ {"version":3,"sources":["../../../src/utils/sizeClasses.ts"],"sourcesContent":["import { SizeType } from \"../types/size\";\n\nexport const sizeClasses = (size: SizeType | undefined) => {\n if (!size) {\n return {};\n }\n\n return {\n \"--is-xxs\": size === \"xxs\",\n \"--is-xs\": size === \"xs\",\n \"--is-sm\": size === \"sm\",\n \"--is-md\": size === \"md\",\n \"--is-lg\": size === \"lg\",\n \"--is-xl\": size === \"xl\",\n \"--is-xxl\": size === \"xxl\",\n };\n};\n"],"names":["sizeClasses","size"],"mappings":"AAEA,OAAO,MAAMA,cAAc,CAACC;IAC1B,IAAI,CAACA,MAAM;QACT,OAAO,CAAC;IACV;IAEA,OAAO;QACL,YAAYA,SAAS;QACrB,WAAWA,SAAS;QACpB,WAAWA,SAAS;QACpB,WAAWA,SAAS;QACpB,WAAWA,SAAS;QACpB,WAAWA,SAAS;QACpB,YAAYA,SAAS;IACvB;AACF,EAAE"}
@@ -0,0 +1,12 @@
1
+ export const sizeOptions = [
2
+ "",
3
+ "xxs",
4
+ "xs",
5
+ "sm",
6
+ "md",
7
+ "lg",
8
+ "xl",
9
+ "xxl"
10
+ ];
11
+
12
+ //# sourceMappingURL=sizeOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/sizeOptions.ts"],"sourcesContent":["import { SizeType } from \"../types\";\n\nexport const sizeOptions: Array<SizeType | \"\"> = [\n \"\",\n \"xxs\",\n \"xs\",\n \"sm\",\n \"md\",\n \"lg\",\n \"xl\",\n \"xxl\",\n];\n"],"names":["sizeOptions"],"mappings":"AAEA,OAAO,MAAMA,cAAoC;IAC/C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAC"}
@@ -1,15 +1,6 @@
1
- import { Ref, RefAttributes, ReactNode } from "react";
2
- import { DOMProps } from "../../types/dom";
1
+ import { Ref } from "react";
3
2
  import { ForwardedRefComponent } from "../../types/components";
4
- export type BoxElementType = HTMLDivElement;
5
- export interface BoxProps extends DOMProps, RefAttributes<BoxElementType> {
6
- children?: ReactNode;
7
- /** Custom class name for setting specific CSS */
8
- className?: string;
9
- /** HTML element for the Box */
10
- elementType?: "div" | "span";
11
- style?: React.CSSProperties;
12
- }
3
+ import { BoxElementType, BoxProps } from "./types";
13
4
  export type BoxRef = Ref<BoxElementType>;
14
5
  declare const Box: ForwardedRefComponent<BoxProps, BoxElementType>;
15
6
  export { Box };
@@ -0,0 +1,31 @@
1
+ import { ReactNode, RefAttributes } from "react";
2
+ import { DOMProps, SpacingType } from "../../types";
3
+ export type BoxElementType = HTMLDivElement;
4
+ export type BoxDimensionsType = string | number;
5
+ export interface BoxProps extends DOMProps, RefAttributes<BoxElementType> {
6
+ children?: ReactNode;
7
+ /** Custom class name for setting specific CSS */
8
+ className?: string;
9
+ /** HTML element for the Box */
10
+ elementType?: "div" | "span";
11
+ style?: React.CSSProperties;
12
+ padding?: SpacingType;
13
+ paddingX?: SpacingType;
14
+ paddingInline?: SpacingType;
15
+ paddingInlineStart?: SpacingType;
16
+ paddingInlineEnd?: SpacingType;
17
+ paddingY?: SpacingType;
18
+ paddingBlock?: SpacingType;
19
+ paddingBlockStart?: SpacingType;
20
+ paddingBlockEnd?: SpacingType;
21
+ paddingTop?: SpacingType;
22
+ paddingRight?: SpacingType;
23
+ paddingBottom?: SpacingType;
24
+ paddingLeft?: SpacingType;
25
+ minWidth?: BoxDimensionsType;
26
+ minHeight?: BoxDimensionsType;
27
+ maxWidth?: BoxDimensionsType;
28
+ maxHeight?: BoxDimensionsType;
29
+ width?: BoxDimensionsType;
30
+ height?: BoxDimensionsType;
31
+ }
@@ -1,8 +1,3 @@
1
1
  import { FlexNonStyleProps, FlexProps, FlexStyleProps } from "./types";
2
- export declare const withoutUndefinedValues: (obj: Record<string, unknown>) => {
3
- [k: string]: unknown;
4
- };
5
- export declare const buildFlexStyles: (props: FlexStyleProps) => {
6
- [k: string]: unknown;
7
- };
2
+ export declare const buildFlexStyles: (props: FlexStyleProps) => Record<string, unknown>;
8
3
  export declare const splitProps: (props: FlexProps) => [FlexStyleProps, FlexNonStyleProps];