@elliemae/ds-grid 2.3.1 → 3.0.0-alpha.3

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 (58) hide show
  1. package/dist/cjs/Grid.js +108 -0
  2. package/dist/cjs/Grid.js.map +7 -0
  3. package/dist/cjs/GridItem.js +53 -0
  4. package/dist/cjs/GridItem.js.map +7 -0
  5. package/dist/cjs/defaultProps.js +43 -0
  6. package/dist/cjs/defaultProps.js.map +7 -0
  7. package/dist/cjs/index.js +39 -0
  8. package/dist/cjs/index.js.map +7 -0
  9. package/dist/cjs/propTypes.js +79 -0
  10. package/dist/cjs/propTypes.js.map +7 -0
  11. package/dist/cjs/types.js +27 -0
  12. package/dist/cjs/types.js.map +7 -0
  13. package/dist/cjs/utils/constants.js +46 -0
  14. package/dist/cjs/utils/constants.js.map +7 -0
  15. package/dist/cjs/utils/styles.js +171 -0
  16. package/dist/cjs/utils/styles.js.map +7 -0
  17. package/dist/esm/Grid.js +81 -0
  18. package/dist/esm/Grid.js.map +7 -0
  19. package/dist/esm/GridItem.js +24 -0
  20. package/dist/esm/GridItem.js.map +7 -0
  21. package/dist/esm/defaultProps.js +14 -0
  22. package/dist/esm/defaultProps.js.map +7 -0
  23. package/dist/esm/index.js +10 -0
  24. package/dist/esm/index.js.map +7 -0
  25. package/dist/esm/propTypes.js +50 -0
  26. package/dist/esm/propTypes.js.map +7 -0
  27. package/dist/esm/types.js +2 -0
  28. package/dist/esm/types.js.map +7 -0
  29. package/dist/esm/utils/constants.js +17 -0
  30. package/dist/esm/utils/constants.js.map +7 -0
  31. package/dist/esm/utils/styles.js +142 -0
  32. package/dist/esm/utils/styles.js.map +7 -0
  33. package/package.json +44 -33
  34. package/cjs/Grid.js +0 -91
  35. package/cjs/GridItem.js +0 -29
  36. package/cjs/defaultProps.js +0 -15
  37. package/cjs/index.js +0 -13
  38. package/cjs/propTypes.js +0 -46
  39. package/cjs/types.js +0 -2
  40. package/cjs/utils/constants.js +0 -11
  41. package/cjs/utils/styles.js +0 -129
  42. package/esm/Grid.js +0 -80
  43. package/esm/GridItem.js +0 -21
  44. package/esm/defaultProps.js +0 -11
  45. package/esm/index.js +0 -1
  46. package/esm/propTypes.js +0 -42
  47. package/esm/types.js +0 -1
  48. package/esm/utils/constants.js +0 -5
  49. package/esm/utils/styles.js +0 -119
  50. package/types/Grid.d.ts +0 -11
  51. package/types/GridItem.d.ts +0 -2
  52. package/types/defaultProps.d.ts +0 -9
  53. package/types/index.d.ts +0 -5
  54. package/types/propTypes.d.ts +0 -135
  55. package/types/tests/DSGrid.events.test.d.ts +0 -1
  56. package/types/types.d.ts +0 -66
  57. package/types/utils/constants.d.ts +0 -3
  58. package/types/utils/styles.d.ts +0 -3
package/package.json CHANGED
@@ -1,43 +1,46 @@
1
1
  {
2
2
  "name": "@elliemae/ds-grid",
3
- "version": "2.3.1",
3
+ "version": "3.0.0-alpha.3",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Grid",
6
- "module": "./esm/index.js",
7
- "main": "./cjs/index.js",
8
- "types": "./types/index.d.ts",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "module": "./dist/esm/index.js",
10
+ "main": "./dist/cjs/index.js",
11
+ "types": "./dist/types/index.d.ts",
9
12
  "exports": {
10
13
  ".": {
11
- "import": "./esm/index.js",
12
- "require": "./cjs/index.js"
14
+ "import": "./dist/esm/index.js",
15
+ "require": "./dist/cjs/index.js"
13
16
  },
14
17
  "./utils/styles": {
15
- "import": "./esm/utils/styles.js",
16
- "require": "./cjs/utils/styles.js"
18
+ "import": "./dist/esm/utils/styles.js",
19
+ "require": "./dist/cjs/utils/styles.js"
17
20
  },
18
21
  "./utils/constants": {
19
- "import": "./esm/utils/constants.js",
20
- "require": "./cjs/utils/constants.js"
22
+ "import": "./dist/esm/utils/constants.js",
23
+ "require": "./dist/cjs/utils/constants.js"
21
24
  },
22
25
  "./types": {
23
- "import": "./esm/types.js",
24
- "require": "./cjs/types.js"
26
+ "import": "./dist/esm/types.js",
27
+ "require": "./dist/cjs/types.js"
25
28
  },
26
29
  "./propTypes": {
27
- "import": "./esm/propTypes.js",
28
- "require": "./cjs/propTypes.js"
30
+ "import": "./dist/esm/propTypes.js",
31
+ "require": "./dist/cjs/propTypes.js"
29
32
  },
30
33
  "./GridItem": {
31
- "import": "./esm/GridItem.js",
32
- "require": "./cjs/GridItem.js"
34
+ "import": "./dist/esm/GridItem.js",
35
+ "require": "./dist/cjs/GridItem.js"
33
36
  },
34
37
  "./Grid": {
35
- "import": "./esm/Grid.js",
36
- "require": "./cjs/Grid.js"
38
+ "import": "./dist/esm/Grid.js",
39
+ "require": "./dist/cjs/Grid.js"
37
40
  },
38
41
  "./defaultProps": {
39
- "import": "./esm/defaultProps.js",
40
- "require": "./cjs/defaultProps.js"
42
+ "import": "./dist/esm/defaultProps.js",
43
+ "require": "./dist/cjs/defaultProps.js"
41
44
  }
42
45
  },
43
46
  "sideEffects": [
@@ -49,25 +52,27 @@
49
52
  "url": "https://git.elliemae.io/platform-ui/dimsum.git"
50
53
  },
51
54
  "engines": {
52
- "npm": ">=7",
53
- "node": ">=14"
55
+ "pnpm": ">=6",
56
+ "node": ">=16"
54
57
  },
55
58
  "author": "ICE MT",
56
- "scripts": {
57
- "dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
58
- "prebuild": "exit 0",
59
- "predev": "exit 0",
60
- "build": "node ../../scripts/build/build.js"
59
+ "jestSonar": {
60
+ "sonar56x": true,
61
+ "reportPath": "reports",
62
+ "reportFile": "tests.xml",
63
+ "indent": 4
61
64
  },
62
65
  "dependencies": {
63
- "@elliemae/ds-system": "2.3.1",
64
- "@xstyled/styled-components": "~3.1.1",
66
+ "@elliemae/ds-system": "3.0.0-alpha.3",
67
+ "@xstyled/styled-components": "~3.1.2",
65
68
  "react-desc": "~4.1.3"
66
69
  },
67
70
  "devDependencies": {
68
- "@testing-library/jest-dom": "~5.15.0",
71
+ "@testing-library/jest-dom": "~5.15.1",
69
72
  "@testing-library/react": "~12.1.2",
70
- "@testing-library/user-event": "~13.5.0"
73
+ "@testing-library/user-event": "~13.5.0",
74
+ "styled-components": "~5.3.3",
75
+ "styled-system": "~5.1.5"
71
76
  },
72
77
  "peerDependencies": {
73
78
  "lodash": "^4.17.21",
@@ -78,7 +83,13 @@
78
83
  },
79
84
  "publishConfig": {
80
85
  "access": "public",
81
- "directory": "dist",
82
- "generateSubmodules": true
86
+ "typeSafety": false
87
+ },
88
+ "scripts": {
89
+ "dev": "cross-env NODE_ENV=development node ../../scripts/build/build.mjs --watch",
90
+ "test": "node ../../scripts/testing/test.mjs",
91
+ "lint": "node ../../scripts/lint.mjs",
92
+ "dts": "node ../../scripts/dts.mjs",
93
+ "build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs"
83
94
  }
84
95
  }
package/cjs/Grid.js DELETED
@@ -1,91 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
6
- var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
7
- require('core-js/modules/esnext.async-iterator.map.js');
8
- require('core-js/modules/esnext.iterator.map.js');
9
- require('core-js/modules/esnext.async-iterator.filter.js');
10
- require('core-js/modules/esnext.iterator.constructor.js');
11
- require('core-js/modules/esnext.iterator.filter.js');
12
- require('core-js/modules/esnext.async-iterator.for-each.js');
13
- require('core-js/modules/esnext.iterator.for-each.js');
14
- var React = require('react');
15
- var reactDesc = require('react-desc');
16
- var lodash = require('lodash');
17
- var dsSystem = require('@elliemae/ds-system');
18
- var propTypes = require('./propTypes.js');
19
- var GridItem = require('./GridItem.js');
20
- var defaultProps = require('./defaultProps.js');
21
- var jsxRuntime = require('react/jsx-runtime');
22
-
23
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
24
-
25
- var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
26
- var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
27
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
28
-
29
- const _excluded = ["rows", "cols", "alignItems", "children", "className", "justify", "gutter", "wrap", "width", "height"];
30
-
31
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
32
-
33
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
34
- const Grid = /*#__PURE__*/React__default["default"].forwardRef((props, ref) => {
35
- const {
36
- rows,
37
- cols,
38
- alignItems,
39
- children,
40
- className,
41
- justify,
42
- gutter,
43
- wrap,
44
- width,
45
- height
46
- } = props,
47
- rest = _objectWithoutProperties__default["default"](props, _excluded);
48
-
49
- let isSpanParent = true;
50
- const renderChildren = React__default["default"].Children.map(children, child => {
51
- if (lodash.get(child, 'child.type.name') === 'Grid' || lodash.get(child, 'type.displayName') === 'Grid' || parseInt(lodash.get(child, 'props.span', 0), 10) > 0) {
52
- const {
53
- width: wc,
54
- height: hc,
55
- span
56
- } = child.props;
57
- if (!span) isSpanParent = false;
58
- return /*#__PURE__*/React__default["default"].cloneElement(child, _objectSpread(_objectSpread({}, child.props), {}, {
59
- width: dsSystem.fixSpaceGutter(wc),
60
- height: dsSystem.fixSpaceGutter(hc)
61
- }));
62
- }
63
-
64
- return child;
65
- });
66
- return /*#__PURE__*/jsxRuntime.jsx(GridItem.GridItem, _objectSpread(_objectSpread({
67
- alignItems: alignItems,
68
- className: className,
69
- cols: cols,
70
- gutter: gutter,
71
- isSpanParent: isSpanParent,
72
- justify: justify,
73
- rows: rows,
74
- wrap: wrap,
75
- childNumber: React__default["default"].Children.count(children),
76
- ref: ref,
77
- w: width,
78
- h: height
79
- }, rest), {}, {
80
- children: renderChildren
81
- }));
82
- }); // Since this component is using ForwardRef, we must provide a displayName to avoid 'undefined' name in propsTable.
83
-
84
- Grid.displayName = 'Grid'; // We should use props helpers to merge default props in the future, right now it causes many issues within Dimsum
85
-
86
- Grid.defaultProps = defaultProps.defaultProps;
87
- const DSGridWithSchema = reactDesc.describe(Grid);
88
- DSGridWithSchema.propTypes = propTypes.propTypes;
89
-
90
- exports.DSGridWithSchema = DSGridWithSchema;
91
- exports["default"] = Grid;
package/cjs/GridItem.js DELETED
@@ -1,29 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var styled = require('styled-components');
6
- var styledComponents = require('@xstyled/styled-components');
7
- var dsSystem = require('@elliemae/ds-system');
8
- var styles = require('./utils/styles.js');
9
-
10
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
-
12
- var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
13
-
14
- /* eslint-disable max-lines */
15
- const GridItem = /*#__PURE__*/styled__default["default"].div.withConfig({
16
- componentId: "sc-1ch24x4-0"
17
- })(["display:grid;display:-ms-grid;column-gap:", ";row-gap:", ";", " ", " ", " ", " ", " ", " ", " ", " ", ""], _ref => {
18
- let {
19
- gutter
20
- } = _ref;
21
- return dsSystem.mapGap(gutter);
22
- }, _ref2 => {
23
- let {
24
- gutter
25
- } = _ref2;
26
- return dsSystem.mapGap(gutter);
27
- }, styledComponents.grids, styledComponents.flexboxes, styledComponents.sizing, styledComponents.space, styledComponents.height, styledComponents.width, styles.manageCols, styles.manageRows, styles.manageSpan);
28
-
29
- exports.GridItem = GridItem;
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const defaultProps = {
6
- rows: [],
7
- cols: [],
8
- className: '',
9
- justify: 'flex-start',
10
- gutter: 0,
11
- wrap: 'wrap',
12
- span: 1
13
- };
14
-
15
- exports.defaultProps = defaultProps;
package/cjs/index.js DELETED
@@ -1,13 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var Grid = require('./Grid.js');
6
-
7
-
8
-
9
- exports.DSGridWithSchema = Grid.DSGridWithSchema;
10
- exports.Grid = Grid["default"];
11
- exports.GridContainer = Grid["default"];
12
- exports.GridItem = Grid["default"];
13
- exports["default"] = Grid["default"];
package/cjs/propTypes.js DELETED
@@ -1,46 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var reactDesc = require('react-desc');
6
- var constants = require('./utils/constants.js');
7
-
8
- const rowColBreakpoints = reactDesc.PropTypes.shape({
9
- small: reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string])),
10
- medium: reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string])),
11
- large: reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string]))
12
- });
13
- const spanBreakpoints = reactDesc.PropTypes.shape({
14
- small: reactDesc.PropTypes.number,
15
- medium: reactDesc.PropTypes.number,
16
- large: reactDesc.PropTypes.number
17
- });
18
- const propTypes = {
19
- rows: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string])), rowColBreakpoints]).description('Row layout cells').defaultValue([]),
20
- cols: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string])), rowColBreakpoints]).description('Column layout cells').defaultValue([]),
21
- span: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, spanBreakpoints]).description('Expands the grid element within columns.'),
22
- alignItems: reactDesc.PropTypes.oneOf(constants.alignItemsPlacement).description('flex-like align items prop'),
23
- children: reactDesc.PropTypes.node.description('Children node inside grid cell'),
24
- className: reactDesc.PropTypes.string.description('CSS class').defaultValue(''),
25
- justifyContent: reactDesc.PropTypes.oneOf(constants.justifyPlacement).description('flex-like justify prop').defaultValue(constants.justifyPlacement[0]),
26
- gutter: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string]).description('Space between cells prop').defaultValue(0),
27
- wrap: reactDesc.PropTypes.oneOf(constants.wrap).description('Wrap type').defaultValue(constants.wrap[0]),
28
- height: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string]).description('Grid height.'),
29
- width: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string]).description('Grid width.'),
30
- p: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string]).description('Grid padding in all sides.'),
31
- m: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string]).description('Grid margin in all sides.'),
32
- px: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string]).description('Grid padding in left and right sides.'),
33
- mx: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string]).description('Grid margin in left and right sides.'),
34
- py: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string]).description('Grid padding in top and bottom sides.'),
35
- my: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string]).description('Grid margin in top and bottom sides.'),
36
- ml: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string]).description('Grid left margin.'),
37
- mr: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string]).description('Grid right margin'),
38
- mt: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string]).description('Grid top margin'),
39
- mb: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string]).description('Grid bottom margin'),
40
- pl: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string]).description('Grid left padding.'),
41
- pr: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string]).description('Grid right padding'),
42
- pt: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string]).description('Grid top padding'),
43
- pb: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string]).description('Grid bottom padding')
44
- };
45
-
46
- exports.propTypes = propTypes;
package/cjs/types.js DELETED
@@ -1,2 +0,0 @@
1
- 'use strict';
2
-
@@ -1,11 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const justifyPlacement = ['flex-start', 'center', 'flex-end', 'space-between', 'space-around', 'space-evenly'];
6
- const alignItemsPlacement = ['flex-start', 'center', 'flex-end', 'stretch', 'baseline'];
7
- const wrap = ['wrap', 'nowrap', 'wrap-reverse'];
8
-
9
- exports.alignItemsPlacement = alignItemsPlacement;
10
- exports.justifyPlacement = justifyPlacement;
11
- exports.wrap = wrap;
@@ -1,129 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _taggedTemplateLiteral = require('@babel/runtime/helpers/taggedTemplateLiteral');
6
- require('core-js/modules/esnext.async-iterator.for-each.js');
7
- require('core-js/modules/esnext.iterator.constructor.js');
8
- require('core-js/modules/esnext.iterator.for-each.js');
9
- require('core-js/modules/esnext.async-iterator.map.js');
10
- require('core-js/modules/esnext.iterator.map.js');
11
- var dsSystem = require('@elliemae/ds-system');
12
-
13
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
-
15
- var _taggedTemplateLiteral__default = /*#__PURE__*/_interopDefaultLegacy(_taggedTemplateLiteral);
16
-
17
- var _templateObject, _templateObject2, _templateObject3;
18
- const manageSpan = dsSystem.css(_templateObject || (_templateObject = _taggedTemplateLiteral__default["default"](["\n ", "\n"])), _ref => {
19
- let {
20
- isSpanParent,
21
- span,
22
- theme
23
- } = _ref;
24
- if (!isSpanParent) return '';
25
-
26
- if (typeof span === 'object') {
27
- let data = '';
28
- Object.keys(theme.media).forEach(key => {
29
- if (span[key] && theme.breakpoints[key]) {
30
- if (key === 'small') {
31
- data += "\n -ms-grid-column: auto / span ".concat(span[key], ";\n grid-column: auto / span ").concat(span[key], ";\n ");
32
- } else {
33
- data += "@media (min-width: ".concat(theme.breakpoints[key], ") {\n -ms-grid-column: auto / span ").concat(span[key], ";\n grid-column: auto / span ").concat(span[key], ";\n }");
34
- }
35
- }
36
- });
37
- return data;
38
- }
39
-
40
- return "\n -ms-grid-column: auto / span ".concat(span, ";\n grid-column: auto / span ").concat(span, ";");
41
- });
42
- const manageCols = dsSystem.css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral__default["default"](["\n ", "\n"])), _ref2 => {
43
- let {
44
- cols,
45
- theme,
46
- isSpanParent
47
- } = _ref2;
48
-
49
- if (typeof cols === 'object' && !Array.isArray(cols)) {
50
- let data = '';
51
- Object.keys(theme.media).forEach(key => {
52
- if (cols[key] && Array.isArray(cols[key])) {
53
- const mtg = dsSystem.mapTemplateGrid(cols[key]).join(' ');
54
- const mtgs = dsSystem.mapTemplateGrid(cols[key]).map(c => "minmax(0, ".concat(c, ")")).join(' ');
55
-
56
- if (key === 'small') {
57
- data += "-ms-grid-columns: ".concat(mtg || 'minmax(0px, 1fr)', ";\n grid-template-columns: ").concat(mtg || 'auto', ";\n -ms-grid-columns: ").concat(mtgs || 'minmax(0px, 1fr)', ";\n grid-template-columns: ").concat(mtgs || 'auto', ";");
58
- } else {
59
- data += "@media (min-width: ".concat(theme.breakpoints[key], ") {\n -ms-grid-columns: ").concat(mtg || 'minmax(0px, 1fr)', ";\n grid-template-columns: ").concat(mtg || 'auto', ";\n -ms-grid-columns: ").concat(mtgs || 'minmax(0px, 1fr)', ";\n grid-template-columns: ").concat(mtgs || 'auto', ";\n }");
60
- }
61
- } else if (isSpanParent) {
62
- if (key === 'small') {
63
- data += "-ms-grid-columns: repeat(".concat(cols[key], ", 1fr);\n grid-template-columns: repeat(").concat(cols[key], ", 1fr);");
64
- } else {
65
- data += "@media (min-width: ".concat(theme.breakpoints[key], ") {\n -ms-grid-columns: repeat(").concat(cols[key], ", 1fr);\n grid-template-columns: repeat(").concat(cols[key], ", 1fr);\n }");
66
- }
67
- }
68
- });
69
- return data;
70
- }
71
-
72
- if (Array.isArray(cols)) {
73
- const mtg = dsSystem.mapTemplateGrid(cols).join(' ');
74
- const mtgs = dsSystem.mapTemplateGrid(cols).map(c => "minmax(0, ".concat(c, ")")).join(' ');
75
- return "\n -ms-grid-columns: ".concat(mtg || 'minmax(0px, 1fr)', ";\n grid-template-columns: ").concat(mtg || 'auto', ";\n -ms-grid-columns: ").concat(mtgs || 'minmax(0px, 1fr)', ";\n grid-template-columns: ").concat(mtgs || 'auto', ";\n ");
76
- }
77
-
78
- if (isSpanParent) {
79
- return "\n -ms-grid-columns: repeat(".concat(cols, ", 1fr);\n grid-template-columns: repeat(").concat(cols, ", 1fr);");
80
- }
81
-
82
- return '';
83
- });
84
- const manageRows = dsSystem.css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral__default["default"](["\n ", "\n"])), _ref3 => {
85
- let {
86
- rows,
87
- theme,
88
- isSpanParent
89
- } = _ref3;
90
-
91
- if (typeof rows === 'object' && !Array.isArray(rows)) {
92
- let data = '';
93
- Object.keys(theme.media).forEach(key => {
94
- if (rows[key] && Array.isArray(rows[key])) {
95
- const mtg = dsSystem.mapTemplateGrid(rows[key]).join(' ');
96
- const mtgs = dsSystem.mapTemplateGrid(rows[key]).map(c => "minmax(0, ".concat(c, ")")).join(' ');
97
-
98
- if (key === 'small') {
99
- data += "-ms-grid-rows: ".concat(mtg || 'minmax(0px, 1fr)', ";\n grid-template-rows: ").concat(mtg || 'auto', ";\n -ms-grid-rows: ").concat(mtgs || 'minmax(0px, 1fr)', ";\n grid-template-rows: ").concat(mtgs || 'auto', ";");
100
- } else {
101
- data += "@media (min-width: ".concat(theme.breakpoints[key], ") {\n -ms-grid-rows: ").concat(mtg || 'minmax(0px, 1fr)', ";\n grid-template-rows: ").concat(mtg || 'auto', ";\n -ms-grid-rows: ").concat(mtgs || 'minmax(0px, 1fr)', ";\n grid-template-rows: ").concat(mtgs || 'auto', ";\n }");
102
- }
103
- } else if (isSpanParent) {
104
- if (key === 'small') {
105
- data += "-ms-grid-rows: repeat(".concat(rows[key], ", 1fr);\n grid-template-rows: repeat(").concat(rows[key], ", 1fr);");
106
- } else {
107
- data += "@media (min-width: ".concat(theme.breakpoints[key], ") {\n -ms-grid-rows: repeat(").concat(rows[key], ", 1fr);\n grid-template-rows: repeat(").concat(rows[key], ", 1fr);\n }");
108
- }
109
- }
110
- });
111
- return data;
112
- }
113
-
114
- if (Array.isArray(rows)) {
115
- const mtg = dsSystem.mapTemplateGrid(rows).join(' ');
116
- const mtgs = dsSystem.mapTemplateGrid(rows).map(c => "minmax(0, ".concat(c, ")")).join(' ');
117
- return "\n -ms-grid-rows: ".concat(mtg || 'minmax(0px, 1fr)', ";\n grid-template-rows: ").concat(mtg || 'auto', ";\n -ms-grid-rows: ").concat(mtgs || 'minmax(0px, 1fr)', ";\n grid-template-rows: ").concat(mtgs || 'auto', ";\n ");
118
- }
119
-
120
- if (isSpanParent) {
121
- return "\n -ms-grid-rows: repeat(".concat(rows, ", 1fr);\n grid-template-rows: repeat(").concat(rows, ", 1fr);");
122
- }
123
-
124
- return '';
125
- });
126
-
127
- exports.manageCols = manageCols;
128
- exports.manageRows = manageRows;
129
- exports.manageSpan = manageSpan;
package/esm/Grid.js DELETED
@@ -1,80 +0,0 @@
1
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
- import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
3
- import 'core-js/modules/esnext.async-iterator.map.js';
4
- import 'core-js/modules/esnext.iterator.map.js';
5
- import 'core-js/modules/esnext.async-iterator.filter.js';
6
- import 'core-js/modules/esnext.iterator.constructor.js';
7
- import 'core-js/modules/esnext.iterator.filter.js';
8
- import 'core-js/modules/esnext.async-iterator.for-each.js';
9
- import 'core-js/modules/esnext.iterator.for-each.js';
10
- import React from 'react';
11
- import { describe } from 'react-desc';
12
- import { get } from 'lodash';
13
- import { fixSpaceGutter } from '@elliemae/ds-system';
14
- import { propTypes } from './propTypes.js';
15
- import { GridItem } from './GridItem.js';
16
- import { defaultProps } from './defaultProps.js';
17
- import { jsx } from 'react/jsx-runtime';
18
-
19
- const _excluded = ["rows", "cols", "alignItems", "children", "className", "justify", "gutter", "wrap", "width", "height"];
20
-
21
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
22
-
23
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
24
- const Grid = /*#__PURE__*/React.forwardRef((props, ref) => {
25
- const {
26
- rows,
27
- cols,
28
- alignItems,
29
- children,
30
- className,
31
- justify,
32
- gutter,
33
- wrap,
34
- width,
35
- height
36
- } = props,
37
- rest = _objectWithoutProperties(props, _excluded);
38
-
39
- let isSpanParent = true;
40
- const renderChildren = React.Children.map(children, child => {
41
- if (get(child, 'child.type.name') === 'Grid' || get(child, 'type.displayName') === 'Grid' || parseInt(get(child, 'props.span', 0), 10) > 0) {
42
- const {
43
- width: wc,
44
- height: hc,
45
- span
46
- } = child.props;
47
- if (!span) isSpanParent = false;
48
- return /*#__PURE__*/React.cloneElement(child, _objectSpread(_objectSpread({}, child.props), {}, {
49
- width: fixSpaceGutter(wc),
50
- height: fixSpaceGutter(hc)
51
- }));
52
- }
53
-
54
- return child;
55
- });
56
- return /*#__PURE__*/jsx(GridItem, _objectSpread(_objectSpread({
57
- alignItems: alignItems,
58
- className: className,
59
- cols: cols,
60
- gutter: gutter,
61
- isSpanParent: isSpanParent,
62
- justify: justify,
63
- rows: rows,
64
- wrap: wrap,
65
- childNumber: React.Children.count(children),
66
- ref: ref,
67
- w: width,
68
- h: height
69
- }, rest), {}, {
70
- children: renderChildren
71
- }));
72
- }); // Since this component is using ForwardRef, we must provide a displayName to avoid 'undefined' name in propsTable.
73
-
74
- Grid.displayName = 'Grid'; // We should use props helpers to merge default props in the future, right now it causes many issues within Dimsum
75
-
76
- Grid.defaultProps = defaultProps;
77
- const DSGridWithSchema = describe(Grid);
78
- DSGridWithSchema.propTypes = propTypes;
79
-
80
- export { DSGridWithSchema, Grid as default };
package/esm/GridItem.js DELETED
@@ -1,21 +0,0 @@
1
- import styled from 'styled-components';
2
- import { grids, flexboxes, sizing, space, height, width } from '@xstyled/styled-components';
3
- import { mapGap } from '@elliemae/ds-system';
4
- import { manageCols, manageRows, manageSpan } from './utils/styles.js';
5
-
6
- /* eslint-disable max-lines */
7
- const GridItem = /*#__PURE__*/styled.div.withConfig({
8
- componentId: "sc-1ch24x4-0"
9
- })(["display:grid;display:-ms-grid;column-gap:", ";row-gap:", ";", " ", " ", " ", " ", " ", " ", " ", " ", ""], _ref => {
10
- let {
11
- gutter
12
- } = _ref;
13
- return mapGap(gutter);
14
- }, _ref2 => {
15
- let {
16
- gutter
17
- } = _ref2;
18
- return mapGap(gutter);
19
- }, grids, flexboxes, sizing, space, height, width, manageCols, manageRows, manageSpan);
20
-
21
- export { GridItem };
@@ -1,11 +0,0 @@
1
- const defaultProps = {
2
- rows: [],
3
- cols: [],
4
- className: '',
5
- justify: 'flex-start',
6
- gutter: 0,
7
- wrap: 'wrap',
8
- span: 1
9
- };
10
-
11
- export { defaultProps };
package/esm/index.js DELETED
@@ -1 +0,0 @@
1
- export { DSGridWithSchema, default as Grid, default as GridContainer, default as GridItem, default } from './Grid.js';
package/esm/propTypes.js DELETED
@@ -1,42 +0,0 @@
1
- import { PropTypes } from 'react-desc';
2
- import { alignItemsPlacement, justifyPlacement, wrap } from './utils/constants.js';
3
-
4
- const rowColBreakpoints = PropTypes.shape({
5
- small: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),
6
- medium: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),
7
- large: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string]))
8
- });
9
- const spanBreakpoints = PropTypes.shape({
10
- small: PropTypes.number,
11
- medium: PropTypes.number,
12
- large: PropTypes.number
13
- });
14
- const propTypes = {
15
- rows: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), rowColBreakpoints]).description('Row layout cells').defaultValue([]),
16
- cols: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), rowColBreakpoints]).description('Column layout cells').defaultValue([]),
17
- span: PropTypes.oneOfType([PropTypes.number, spanBreakpoints]).description('Expands the grid element within columns.'),
18
- alignItems: PropTypes.oneOf(alignItemsPlacement).description('flex-like align items prop'),
19
- children: PropTypes.node.description('Children node inside grid cell'),
20
- className: PropTypes.string.description('CSS class').defaultValue(''),
21
- justifyContent: PropTypes.oneOf(justifyPlacement).description('flex-like justify prop').defaultValue(justifyPlacement[0]),
22
- gutter: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Space between cells prop').defaultValue(0),
23
- wrap: PropTypes.oneOf(wrap).description('Wrap type').defaultValue(wrap[0]),
24
- height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid height.'),
25
- width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid width.'),
26
- p: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid padding in all sides.'),
27
- m: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid margin in all sides.'),
28
- px: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid padding in left and right sides.'),
29
- mx: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid margin in left and right sides.'),
30
- py: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid padding in top and bottom sides.'),
31
- my: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid margin in top and bottom sides.'),
32
- ml: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid left margin.'),
33
- mr: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid right margin'),
34
- mt: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid top margin'),
35
- mb: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid bottom margin'),
36
- pl: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid left padding.'),
37
- pr: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid right padding'),
38
- pt: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid top padding'),
39
- pb: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid bottom padding')
40
- };
41
-
42
- export { propTypes };
package/esm/types.js DELETED
@@ -1 +0,0 @@
1
-
@@ -1,5 +0,0 @@
1
- const justifyPlacement = ['flex-start', 'center', 'flex-end', 'space-between', 'space-around', 'space-evenly'];
2
- const alignItemsPlacement = ['flex-start', 'center', 'flex-end', 'stretch', 'baseline'];
3
- const wrap = ['wrap', 'nowrap', 'wrap-reverse'];
4
-
5
- export { alignItemsPlacement, justifyPlacement, wrap };