@elliemae/ds-grid 2.0.0-alpha.1 → 2.0.0-alpha.13
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.
- package/cjs/Grid.js +27 -96
- package/cjs/GridItem.js +29 -0
- package/cjs/defaultProps.js +2 -2
- package/cjs/index.js +4 -4
- package/cjs/propTypes.js +46 -0
- package/cjs/types.js +2 -0
- package/cjs/utils/constants.js +11 -0
- package/cjs/utils/styles.js +129 -0
- package/esm/Grid.js +23 -91
- package/esm/GridItem.js +21 -0
- package/esm/defaultProps.js +2 -2
- package/esm/propTypes.js +42 -0
- package/esm/types.js +1 -0
- package/esm/utils/constants.js +5 -0
- package/esm/utils/styles.js +119 -0
- package/package.json +25 -10
- package/types/Grid.d.ts +8 -2
- package/types/GridItem.d.ts +2 -0
- package/types/defaultProps.d.ts +3 -3
- package/types/propTypes.d.ts +135 -0
- package/types/types.d.ts +66 -0
- package/types/utils/constants.d.ts +3 -0
- package/types/utils/styles.d.ts +3 -0
- package/cjs/ie11.js +0 -32
- package/cjs/package.json +0 -7
- package/cjs/props.js +0 -39
- package/esm/ie11.js +0 -28
- package/esm/package.json +0 -7
- package/esm/props.js +0 -35
- package/types/ie11.d.ts +0 -5
- package/types/props.d.ts +0 -22
package/cjs/Grid.js
CHANGED
|
@@ -4,14 +4,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
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');
|
|
7
14
|
var React = require('react');
|
|
8
15
|
var reactDesc = require('react-desc');
|
|
9
16
|
var lodash = require('lodash');
|
|
10
|
-
var styled = require('styled-components');
|
|
11
|
-
var styledSystem = require('styled-system');
|
|
12
17
|
var dsSystem = require('@elliemae/ds-system');
|
|
13
|
-
var
|
|
14
|
-
var
|
|
18
|
+
var propTypes = require('./propTypes.js');
|
|
19
|
+
var GridItem = require('./GridItem.js');
|
|
15
20
|
var defaultProps = require('./defaultProps.js');
|
|
16
21
|
var jsxRuntime = require('react/jsx-runtime');
|
|
17
22
|
|
|
@@ -20,101 +25,27 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
20
25
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
21
26
|
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
|
22
27
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
23
|
-
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
24
28
|
|
|
25
|
-
const _excluded = ["rows", "cols", "alignItems", "children", "className", "
|
|
29
|
+
const _excluded = ["rows", "cols", "alignItems", "children", "className", "justify", "gutter", "wrap"];
|
|
26
30
|
|
|
27
31
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
28
32
|
|
|
29
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default[
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
})(["display:grid;display:-ms-grid;", " ", " ", " ", " ", " ", " ", " ", " -ms-grid-rows:", ";grid-template-rows:", ";column-gap:", ";row-gap:", ";"], styledSystem.flexbox, styledSystem.justifyContent, styledSystem.space, styledSystem.height, styledSystem.width, ie11.positionIE11Grid, props => {
|
|
33
|
-
if (typeof props.cols === 'object' && !Array.isArray(props.cols)) {
|
|
34
|
-
let data = '';
|
|
35
|
-
|
|
36
|
-
for (const key in props.theme.media) {
|
|
37
|
-
// using grid approach
|
|
38
|
-
if (props.cols[key] && Array.isArray(props.cols[key])) {
|
|
39
|
-
const mtg = dsSystem.mapTemplateGrid(props.cols[key]).join(' ');
|
|
40
|
-
const mtgs = dsSystem.mapTemplateGrid(props.cols[key]).map(c => `minmax(0, ${c})`).join(' ');
|
|
41
|
-
data += `@media (min-width: ${props.theme.breakpoints[key]}) {
|
|
42
|
-
-ms-grid-columns: ${mtg || 'minmax(0px, 1fr)'};
|
|
43
|
-
grid-template-columns: ${mtg || 'auto'};
|
|
44
|
-
-ms-grid-columns: ${mtgs || 'minmax(0px, 1fr)'};
|
|
45
|
-
grid-template-columns: ${mtgs || 'auto'};
|
|
46
|
-
}`;
|
|
47
|
-
} else if (props.isSpanParent) {
|
|
48
|
-
data += `@media (min-width: ${props.theme.breakpoints[key]}) {
|
|
49
|
-
-ms-grid-columns: repeat(${props.cols[key]}, 1fr);
|
|
50
|
-
grid-template-columns: repeat(${props.cols[key]}, 1fr);
|
|
51
|
-
}`;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return data;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (Array.isArray(props.cols)) {
|
|
59
|
-
const mtg = dsSystem.mapTemplateGrid(props.cols).join(' ');
|
|
60
|
-
const mtgs = dsSystem.mapTemplateGrid(props.cols).map(c => `minmax(0, ${c})`).join(' ');
|
|
61
|
-
return `
|
|
62
|
-
-ms-grid-columns: ${mtg || 'minmax(0px, 1fr)'};
|
|
63
|
-
grid-template-columns: ${mtg || 'auto'};
|
|
64
|
-
-ms-grid-columns: ${mtgs || 'minmax(0px, 1fr)'};
|
|
65
|
-
grid-template-columns: ${mtgs || 'auto'};
|
|
66
|
-
`;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (props.isSpanParent) {
|
|
70
|
-
return `
|
|
71
|
-
-ms-grid-columns: repeat(${props.cols}, 1fr);
|
|
72
|
-
grid-template-columns: repeat(${props.cols}, 1fr);`;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return '';
|
|
76
|
-
}, props => {
|
|
77
|
-
if (!props.isSpanParent) return '';
|
|
78
|
-
|
|
79
|
-
if (typeof props.span === 'object') {
|
|
80
|
-
let data = '';
|
|
81
|
-
|
|
82
|
-
for (const key in props.theme.media) {
|
|
83
|
-
if (props.span[key] && props.theme.breakpoints[key]) {
|
|
84
|
-
data += `@media (min-width: ${props.theme.breakpoints[key]}) {
|
|
85
|
-
-ms-grid-column: auto / span ${props.span[key]};
|
|
86
|
-
grid-column: auto / span ${props.span[key]};
|
|
87
|
-
}`;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return data;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return `
|
|
95
|
-
-ms-grid-column: auto / span ${props.span};
|
|
96
|
-
grid-column: auto / span ${props.span};`;
|
|
97
|
-
}, props => dsSystem.mapTemplateGrid(props.rows).join(' ') || 'minmax(0px, 1fr)', props => dsSystem.mapTemplateGrid(props.rows).join(' ') || 'auto', props => dsSystem.mapGap(props.gutter), props => dsSystem.mapGap(props.gutter));
|
|
98
|
-
/* stylelint-enable property-no-vendor-prefix */
|
|
99
|
-
|
|
100
|
-
/* eslint-enable complexity */
|
|
101
|
-
|
|
102
|
-
const Grid = /*#__PURE__*/React__default['default'].forwardRef((_ref, ref) => {
|
|
103
|
-
let {
|
|
33
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { 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 {
|
|
104
36
|
rows,
|
|
105
37
|
cols,
|
|
106
38
|
alignItems,
|
|
107
39
|
children,
|
|
108
40
|
className,
|
|
109
|
-
direction,
|
|
110
41
|
justify,
|
|
111
42
|
gutter,
|
|
112
43
|
wrap
|
|
113
|
-
} =
|
|
114
|
-
|
|
44
|
+
} = props,
|
|
45
|
+
rest = _objectWithoutProperties__default["default"](props, _excluded);
|
|
115
46
|
|
|
116
47
|
let isSpanParent = true;
|
|
117
|
-
const renderChildren = React__default[
|
|
48
|
+
const renderChildren = React__default["default"].Children.map(children, child => {
|
|
118
49
|
if (lodash.get(child, 'child.type.name') === 'Grid' || lodash.get(child, 'type.displayName') === 'Grid' || parseInt(lodash.get(child, 'props.span', 0), 10) > 0) {
|
|
119
50
|
const {
|
|
120
51
|
width: wc,
|
|
@@ -122,35 +53,35 @@ const Grid = /*#__PURE__*/React__default['default'].forwardRef((_ref, ref) => {
|
|
|
122
53
|
span
|
|
123
54
|
} = child.props;
|
|
124
55
|
if (!span) isSpanParent = false;
|
|
125
|
-
return /*#__PURE__*/React__default[
|
|
56
|
+
return /*#__PURE__*/React__default["default"].cloneElement(child, _objectSpread(_objectSpread({}, child.props), {}, {
|
|
126
57
|
width: dsSystem.fixSpaceGutter(wc),
|
|
127
|
-
// eslint-disable-next-line max-lines
|
|
128
58
|
height: dsSystem.fixSpaceGutter(hc)
|
|
129
59
|
}));
|
|
130
60
|
}
|
|
131
61
|
|
|
132
62
|
return child;
|
|
133
63
|
});
|
|
134
|
-
return /*#__PURE__*/jsxRuntime.jsx(GridItem, _objectSpread(_objectSpread({
|
|
64
|
+
return /*#__PURE__*/jsxRuntime.jsx(GridItem.GridItem, _objectSpread(_objectSpread({
|
|
135
65
|
alignItems: alignItems,
|
|
136
66
|
className: className,
|
|
137
67
|
cols: cols,
|
|
138
|
-
direction: direction,
|
|
139
68
|
gutter: gutter,
|
|
140
69
|
isSpanParent: isSpanParent,
|
|
141
70
|
justify: justify,
|
|
142
71
|
rows: rows,
|
|
143
72
|
wrap: wrap,
|
|
144
|
-
childNumber: React__default[
|
|
73
|
+
childNumber: React__default["default"].Children.count(children),
|
|
74
|
+
ref: ref
|
|
145
75
|
}, rest), {}, {
|
|
146
|
-
ref: ref,
|
|
147
76
|
children: renderChildren
|
|
148
77
|
}));
|
|
149
|
-
});
|
|
150
|
-
|
|
78
|
+
}); // Since this component is using ForwardRef, we must provide a displayName to avoid 'undefined' name in propsTable.
|
|
79
|
+
|
|
80
|
+
Grid.displayName = 'Grid'; // We should use props helpers to merge default props in the future, right now it causes many issues within Dimsum
|
|
81
|
+
|
|
151
82
|
Grid.defaultProps = defaultProps.defaultProps;
|
|
152
|
-
const DSGridWithSchema = reactDesc.describe(Grid)
|
|
153
|
-
DSGridWithSchema.propTypes =
|
|
83
|
+
const DSGridWithSchema = reactDesc.describe(Grid);
|
|
84
|
+
DSGridWithSchema.propTypes = propTypes.propTypes;
|
|
154
85
|
|
|
155
86
|
exports.DSGridWithSchema = DSGridWithSchema;
|
|
156
|
-
exports[
|
|
87
|
+
exports["default"] = Grid;
|
package/cjs/GridItem.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var styled = require('styled-components');
|
|
6
|
+
var styledSystem = require('styled-system');
|
|
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
|
+
}, styledSystem.grid, styledSystem.flexbox, styledSystem.justifyContent, styledSystem.space, styledSystem.height, styledSystem.width, styles.manageCols, styles.manageRows, styles.manageSpan);
|
|
28
|
+
|
|
29
|
+
exports.GridItem = GridItem;
|
package/cjs/defaultProps.js
CHANGED
package/cjs/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var Grid = require('./Grid.js');
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
exports.DSGridWithSchema = Grid.DSGridWithSchema;
|
|
10
|
-
exports.Grid = Grid[
|
|
11
|
-
exports.GridContainer = Grid[
|
|
12
|
-
exports.GridItem = Grid[
|
|
13
|
-
exports
|
|
10
|
+
exports.Grid = Grid["default"];
|
|
11
|
+
exports.GridContainer = Grid["default"];
|
|
12
|
+
exports.GridItem = Grid["default"];
|
|
13
|
+
exports["default"] = Grid["default"];
|
package/cjs/propTypes.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
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;
|
|
@@ -0,0 +1,129 @@
|
|
|
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
CHANGED
|
@@ -1,106 +1,38 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
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';
|
|
3
10
|
import React from 'react';
|
|
4
11
|
import { describe } from 'react-desc';
|
|
5
12
|
import { get } from 'lodash';
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { positionIE11Grid } from './ie11.js';
|
|
10
|
-
import { gridProps } from './props.js';
|
|
13
|
+
import { fixSpaceGutter } from '@elliemae/ds-system';
|
|
14
|
+
import { propTypes } from './propTypes.js';
|
|
15
|
+
import { GridItem } from './GridItem.js';
|
|
11
16
|
import { defaultProps } from './defaultProps.js';
|
|
12
17
|
import { jsx } from 'react/jsx-runtime';
|
|
13
18
|
|
|
14
|
-
const _excluded = ["rows", "cols", "alignItems", "children", "className", "
|
|
19
|
+
const _excluded = ["rows", "cols", "alignItems", "children", "className", "justify", "gutter", "wrap"];
|
|
15
20
|
|
|
16
21
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
17
22
|
|
|
18
23
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
})(["display:grid;display:-ms-grid;", " ", " ", " ", " ", " ", " ", " ", " -ms-grid-rows:", ";grid-template-rows:", ";column-gap:", ";row-gap:", ";"], flexbox, justifyContent, space, height, width, positionIE11Grid, props => {
|
|
22
|
-
if (typeof props.cols === 'object' && !Array.isArray(props.cols)) {
|
|
23
|
-
let data = '';
|
|
24
|
-
|
|
25
|
-
for (const key in props.theme.media) {
|
|
26
|
-
// using grid approach
|
|
27
|
-
if (props.cols[key] && Array.isArray(props.cols[key])) {
|
|
28
|
-
const mtg = mapTemplateGrid(props.cols[key]).join(' ');
|
|
29
|
-
const mtgs = mapTemplateGrid(props.cols[key]).map(c => `minmax(0, ${c})`).join(' ');
|
|
30
|
-
data += `@media (min-width: ${props.theme.breakpoints[key]}) {
|
|
31
|
-
-ms-grid-columns: ${mtg || 'minmax(0px, 1fr)'};
|
|
32
|
-
grid-template-columns: ${mtg || 'auto'};
|
|
33
|
-
-ms-grid-columns: ${mtgs || 'minmax(0px, 1fr)'};
|
|
34
|
-
grid-template-columns: ${mtgs || 'auto'};
|
|
35
|
-
}`;
|
|
36
|
-
} else if (props.isSpanParent) {
|
|
37
|
-
data += `@media (min-width: ${props.theme.breakpoints[key]}) {
|
|
38
|
-
-ms-grid-columns: repeat(${props.cols[key]}, 1fr);
|
|
39
|
-
grid-template-columns: repeat(${props.cols[key]}, 1fr);
|
|
40
|
-
}`;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return data;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (Array.isArray(props.cols)) {
|
|
48
|
-
const mtg = mapTemplateGrid(props.cols).join(' ');
|
|
49
|
-
const mtgs = mapTemplateGrid(props.cols).map(c => `minmax(0, ${c})`).join(' ');
|
|
50
|
-
return `
|
|
51
|
-
-ms-grid-columns: ${mtg || 'minmax(0px, 1fr)'};
|
|
52
|
-
grid-template-columns: ${mtg || 'auto'};
|
|
53
|
-
-ms-grid-columns: ${mtgs || 'minmax(0px, 1fr)'};
|
|
54
|
-
grid-template-columns: ${mtgs || 'auto'};
|
|
55
|
-
`;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (props.isSpanParent) {
|
|
59
|
-
return `
|
|
60
|
-
-ms-grid-columns: repeat(${props.cols}, 1fr);
|
|
61
|
-
grid-template-columns: repeat(${props.cols}, 1fr);`;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return '';
|
|
65
|
-
}, props => {
|
|
66
|
-
if (!props.isSpanParent) return '';
|
|
67
|
-
|
|
68
|
-
if (typeof props.span === 'object') {
|
|
69
|
-
let data = '';
|
|
70
|
-
|
|
71
|
-
for (const key in props.theme.media) {
|
|
72
|
-
if (props.span[key] && props.theme.breakpoints[key]) {
|
|
73
|
-
data += `@media (min-width: ${props.theme.breakpoints[key]}) {
|
|
74
|
-
-ms-grid-column: auto / span ${props.span[key]};
|
|
75
|
-
grid-column: auto / span ${props.span[key]};
|
|
76
|
-
}`;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return data;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return `
|
|
84
|
-
-ms-grid-column: auto / span ${props.span};
|
|
85
|
-
grid-column: auto / span ${props.span};`;
|
|
86
|
-
}, props => mapTemplateGrid(props.rows).join(' ') || 'minmax(0px, 1fr)', props => mapTemplateGrid(props.rows).join(' ') || 'auto', props => mapGap(props.gutter), props => mapGap(props.gutter));
|
|
87
|
-
/* stylelint-enable property-no-vendor-prefix */
|
|
88
|
-
|
|
89
|
-
/* eslint-enable complexity */
|
|
90
|
-
|
|
91
|
-
const Grid = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
92
|
-
let {
|
|
24
|
+
const Grid = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
25
|
+
const {
|
|
93
26
|
rows,
|
|
94
27
|
cols,
|
|
95
28
|
alignItems,
|
|
96
29
|
children,
|
|
97
30
|
className,
|
|
98
|
-
direction,
|
|
99
31
|
justify,
|
|
100
32
|
gutter,
|
|
101
33
|
wrap
|
|
102
|
-
} =
|
|
103
|
-
|
|
34
|
+
} = props,
|
|
35
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
104
36
|
|
|
105
37
|
let isSpanParent = true;
|
|
106
38
|
const renderChildren = React.Children.map(children, child => {
|
|
@@ -113,7 +45,6 @@ const Grid = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
113
45
|
if (!span) isSpanParent = false;
|
|
114
46
|
return /*#__PURE__*/React.cloneElement(child, _objectSpread(_objectSpread({}, child.props), {}, {
|
|
115
47
|
width: fixSpaceGutter(wc),
|
|
116
|
-
// eslint-disable-next-line max-lines
|
|
117
48
|
height: fixSpaceGutter(hc)
|
|
118
49
|
}));
|
|
119
50
|
}
|
|
@@ -124,21 +55,22 @@ const Grid = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
124
55
|
alignItems: alignItems,
|
|
125
56
|
className: className,
|
|
126
57
|
cols: cols,
|
|
127
|
-
direction: direction,
|
|
128
58
|
gutter: gutter,
|
|
129
59
|
isSpanParent: isSpanParent,
|
|
130
60
|
justify: justify,
|
|
131
61
|
rows: rows,
|
|
132
62
|
wrap: wrap,
|
|
133
|
-
childNumber: React.Children.count(children)
|
|
63
|
+
childNumber: React.Children.count(children),
|
|
64
|
+
ref: ref
|
|
134
65
|
}, rest), {}, {
|
|
135
|
-
ref: ref,
|
|
136
66
|
children: renderChildren
|
|
137
67
|
}));
|
|
138
|
-
});
|
|
139
|
-
|
|
68
|
+
}); // Since this component is using ForwardRef, we must provide a displayName to avoid 'undefined' name in propsTable.
|
|
69
|
+
|
|
70
|
+
Grid.displayName = 'Grid'; // We should use props helpers to merge default props in the future, right now it causes many issues within Dimsum
|
|
71
|
+
|
|
140
72
|
Grid.defaultProps = defaultProps;
|
|
141
|
-
const DSGridWithSchema = describe(Grid)
|
|
142
|
-
DSGridWithSchema.propTypes =
|
|
73
|
+
const DSGridWithSchema = describe(Grid);
|
|
74
|
+
DSGridWithSchema.propTypes = propTypes;
|
|
143
75
|
|
|
144
76
|
export { DSGridWithSchema, Grid as default };
|
package/esm/GridItem.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { grid, flexbox, justifyContent, space, height, width } from 'styled-system';
|
|
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
|
+
}, grid, flexbox, justifyContent, space, height, width, manageCols, manageRows, manageSpan);
|
|
20
|
+
|
|
21
|
+
export { GridItem };
|