@elliemae/ds-grid 2.0.0-next.7 → 2.0.0-rc.10
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 +23 -72
- package/cjs/GridItem.js +29 -0
- package/cjs/defaultProps.js +2 -2
- 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 -71
- 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 +49 -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/props.js +0 -39
- package/esm/ie11.js +0 -28
- 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,78 +25,24 @@ 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
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; }
|
|
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, ".concat(c, ")")).join(' ');
|
|
41
|
-
data += "@media (min-width: ".concat(props.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 }");
|
|
42
|
-
} else if (props.isSpanParent) {
|
|
43
|
-
data += "@media (min-width: ".concat(props.theme.breakpoints[key], ") {\n -ms-grid-columns: repeat(").concat(props.cols[key], ", 1fr);\n grid-template-columns: repeat(").concat(props.cols[key], ", 1fr);\n }");
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return data;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (Array.isArray(props.cols)) {
|
|
51
|
-
const mtg = dsSystem.mapTemplateGrid(props.cols).join(' ');
|
|
52
|
-
const mtgs = dsSystem.mapTemplateGrid(props.cols).map(c => "minmax(0, ".concat(c, ")")).join(' ');
|
|
53
|
-
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 ");
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (props.isSpanParent) {
|
|
57
|
-
return "\n -ms-grid-columns: repeat(".concat(props.cols, ", 1fr);\n grid-template-columns: repeat(").concat(props.cols, ", 1fr);");
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return '';
|
|
61
|
-
}, props => {
|
|
62
|
-
if (!props.isSpanParent) return '';
|
|
63
|
-
|
|
64
|
-
if (typeof props.span === 'object') {
|
|
65
|
-
let data = '';
|
|
66
|
-
|
|
67
|
-
for (const key in props.theme.media) {
|
|
68
|
-
if (props.span[key] && props.theme.breakpoints[key]) {
|
|
69
|
-
data += "@media (min-width: ".concat(props.theme.breakpoints[key], ") {\n -ms-grid-column: auto / span ").concat(props.span[key], ";\n grid-column: auto / span ").concat(props.span[key], ";\n }");
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return data;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return "\n -ms-grid-column: auto / span ".concat(props.span, ";\n grid-column: auto / span ").concat(props.span, ";");
|
|
77
|
-
}, 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));
|
|
78
|
-
/* stylelint-enable property-no-vendor-prefix */
|
|
79
|
-
|
|
80
|
-
/* eslint-enable complexity */
|
|
81
|
-
|
|
82
|
-
const Grid = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
|
|
83
|
-
let {
|
|
34
|
+
const Grid = /*#__PURE__*/React__default["default"].forwardRef((props, ref) => {
|
|
35
|
+
const {
|
|
84
36
|
rows,
|
|
85
37
|
cols,
|
|
86
38
|
alignItems,
|
|
87
39
|
children,
|
|
88
40
|
className,
|
|
89
|
-
direction,
|
|
90
41
|
justify,
|
|
91
42
|
gutter,
|
|
92
43
|
wrap
|
|
93
|
-
} =
|
|
94
|
-
|
|
44
|
+
} = props,
|
|
45
|
+
rest = _objectWithoutProperties__default["default"](props, _excluded);
|
|
95
46
|
|
|
96
47
|
let isSpanParent = true;
|
|
97
48
|
const renderChildren = React__default["default"].Children.map(children, child => {
|
|
@@ -104,33 +55,33 @@ const Grid = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
|
|
|
104
55
|
if (!span) isSpanParent = false;
|
|
105
56
|
return /*#__PURE__*/React__default["default"].cloneElement(child, _objectSpread(_objectSpread({}, child.props), {}, {
|
|
106
57
|
width: dsSystem.fixSpaceGutter(wc),
|
|
107
|
-
// eslint-disable-next-line max-lines
|
|
108
58
|
height: dsSystem.fixSpaceGutter(hc)
|
|
109
59
|
}));
|
|
110
60
|
}
|
|
111
61
|
|
|
112
62
|
return child;
|
|
113
63
|
});
|
|
114
|
-
return /*#__PURE__*/jsxRuntime.jsx(GridItem, _objectSpread(_objectSpread({
|
|
64
|
+
return /*#__PURE__*/jsxRuntime.jsx(GridItem.GridItem, _objectSpread(_objectSpread({
|
|
115
65
|
alignItems: alignItems,
|
|
116
66
|
className: className,
|
|
117
67
|
cols: cols,
|
|
118
|
-
direction: direction,
|
|
119
68
|
gutter: gutter,
|
|
120
69
|
isSpanParent: isSpanParent,
|
|
121
70
|
justify: justify,
|
|
122
71
|
rows: rows,
|
|
123
72
|
wrap: wrap,
|
|
124
|
-
childNumber: React__default["default"].Children.count(children)
|
|
73
|
+
childNumber: React__default["default"].Children.count(children),
|
|
74
|
+
ref: ref
|
|
125
75
|
}, rest), {}, {
|
|
126
|
-
ref: ref,
|
|
127
76
|
children: renderChildren
|
|
128
77
|
}));
|
|
129
|
-
});
|
|
130
|
-
|
|
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
|
+
|
|
131
82
|
Grid.defaultProps = defaultProps.defaultProps;
|
|
132
|
-
const DSGridWithSchema = reactDesc.describe(Grid)
|
|
133
|
-
DSGridWithSchema.propTypes =
|
|
83
|
+
const DSGridWithSchema = reactDesc.describe(Grid);
|
|
84
|
+
DSGridWithSchema.propTypes = propTypes.propTypes;
|
|
134
85
|
|
|
135
86
|
exports.DSGridWithSchema = DSGridWithSchema;
|
|
136
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/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,86 +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, ".concat(c, ")")).join(' ');
|
|
30
|
-
data += "@media (min-width: ".concat(props.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 }");
|
|
31
|
-
} else if (props.isSpanParent) {
|
|
32
|
-
data += "@media (min-width: ".concat(props.theme.breakpoints[key], ") {\n -ms-grid-columns: repeat(").concat(props.cols[key], ", 1fr);\n grid-template-columns: repeat(").concat(props.cols[key], ", 1fr);\n }");
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return data;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (Array.isArray(props.cols)) {
|
|
40
|
-
const mtg = mapTemplateGrid(props.cols).join(' ');
|
|
41
|
-
const mtgs = mapTemplateGrid(props.cols).map(c => "minmax(0, ".concat(c, ")")).join(' ');
|
|
42
|
-
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 ");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (props.isSpanParent) {
|
|
46
|
-
return "\n -ms-grid-columns: repeat(".concat(props.cols, ", 1fr);\n grid-template-columns: repeat(").concat(props.cols, ", 1fr);");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return '';
|
|
50
|
-
}, props => {
|
|
51
|
-
if (!props.isSpanParent) return '';
|
|
52
|
-
|
|
53
|
-
if (typeof props.span === 'object') {
|
|
54
|
-
let data = '';
|
|
55
|
-
|
|
56
|
-
for (const key in props.theme.media) {
|
|
57
|
-
if (props.span[key] && props.theme.breakpoints[key]) {
|
|
58
|
-
data += "@media (min-width: ".concat(props.theme.breakpoints[key], ") {\n -ms-grid-column: auto / span ").concat(props.span[key], ";\n grid-column: auto / span ").concat(props.span[key], ";\n }");
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return data;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return "\n -ms-grid-column: auto / span ".concat(props.span, ";\n grid-column: auto / span ").concat(props.span, ";");
|
|
66
|
-
}, props => mapTemplateGrid(props.rows).join(' ') || 'minmax(0px, 1fr)', props => mapTemplateGrid(props.rows).join(' ') || 'auto', props => mapGap(props.gutter), props => mapGap(props.gutter));
|
|
67
|
-
/* stylelint-enable property-no-vendor-prefix */
|
|
68
|
-
|
|
69
|
-
/* eslint-enable complexity */
|
|
70
|
-
|
|
71
|
-
const Grid = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
72
|
-
let {
|
|
24
|
+
const Grid = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
25
|
+
const {
|
|
73
26
|
rows,
|
|
74
27
|
cols,
|
|
75
28
|
alignItems,
|
|
76
29
|
children,
|
|
77
30
|
className,
|
|
78
|
-
direction,
|
|
79
31
|
justify,
|
|
80
32
|
gutter,
|
|
81
33
|
wrap
|
|
82
|
-
} =
|
|
83
|
-
|
|
34
|
+
} = props,
|
|
35
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
84
36
|
|
|
85
37
|
let isSpanParent = true;
|
|
86
38
|
const renderChildren = React.Children.map(children, child => {
|
|
@@ -93,7 +45,6 @@ const Grid = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
93
45
|
if (!span) isSpanParent = false;
|
|
94
46
|
return /*#__PURE__*/React.cloneElement(child, _objectSpread(_objectSpread({}, child.props), {}, {
|
|
95
47
|
width: fixSpaceGutter(wc),
|
|
96
|
-
// eslint-disable-next-line max-lines
|
|
97
48
|
height: fixSpaceGutter(hc)
|
|
98
49
|
}));
|
|
99
50
|
}
|
|
@@ -104,21 +55,22 @@ const Grid = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
104
55
|
alignItems: alignItems,
|
|
105
56
|
className: className,
|
|
106
57
|
cols: cols,
|
|
107
|
-
direction: direction,
|
|
108
58
|
gutter: gutter,
|
|
109
59
|
isSpanParent: isSpanParent,
|
|
110
60
|
justify: justify,
|
|
111
61
|
rows: rows,
|
|
112
62
|
wrap: wrap,
|
|
113
|
-
childNumber: React.Children.count(children)
|
|
63
|
+
childNumber: React.Children.count(children),
|
|
64
|
+
ref: ref
|
|
114
65
|
}, rest), {}, {
|
|
115
|
-
ref: ref,
|
|
116
66
|
children: renderChildren
|
|
117
67
|
}));
|
|
118
|
-
});
|
|
119
|
-
|
|
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
|
+
|
|
120
72
|
Grid.defaultProps = defaultProps;
|
|
121
|
-
const DSGridWithSchema = describe(Grid)
|
|
122
|
-
DSGridWithSchema.propTypes =
|
|
73
|
+
const DSGridWithSchema = describe(Grid);
|
|
74
|
+
DSGridWithSchema.propTypes = propTypes;
|
|
123
75
|
|
|
124
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 };
|
package/esm/defaultProps.js
CHANGED
package/esm/propTypes.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
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
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,5 @@
|
|
|
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 };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
|
|
2
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
7
|
+
import { css, mapTemplateGrid } from '@elliemae/ds-system';
|
|
8
|
+
|
|
9
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
10
|
+
const manageSpan = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", "\n"])), _ref => {
|
|
11
|
+
let {
|
|
12
|
+
isSpanParent,
|
|
13
|
+
span,
|
|
14
|
+
theme
|
|
15
|
+
} = _ref;
|
|
16
|
+
if (!isSpanParent) return '';
|
|
17
|
+
|
|
18
|
+
if (typeof span === 'object') {
|
|
19
|
+
let data = '';
|
|
20
|
+
Object.keys(theme.media).forEach(key => {
|
|
21
|
+
if (span[key] && theme.breakpoints[key]) {
|
|
22
|
+
if (key === 'small') {
|
|
23
|
+
data += "\n -ms-grid-column: auto / span ".concat(span[key], ";\n grid-column: auto / span ").concat(span[key], ";\n ");
|
|
24
|
+
} else {
|
|
25
|
+
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 }");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return "\n -ms-grid-column: auto / span ".concat(span, ";\n grid-column: auto / span ").concat(span, ";");
|
|
33
|
+
});
|
|
34
|
+
const manageCols = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", "\n"])), _ref2 => {
|
|
35
|
+
let {
|
|
36
|
+
cols,
|
|
37
|
+
theme,
|
|
38
|
+
isSpanParent
|
|
39
|
+
} = _ref2;
|
|
40
|
+
|
|
41
|
+
if (typeof cols === 'object' && !Array.isArray(cols)) {
|
|
42
|
+
let data = '';
|
|
43
|
+
Object.keys(theme.media).forEach(key => {
|
|
44
|
+
if (cols[key] && Array.isArray(cols[key])) {
|
|
45
|
+
const mtg = mapTemplateGrid(cols[key]).join(' ');
|
|
46
|
+
const mtgs = mapTemplateGrid(cols[key]).map(c => "minmax(0, ".concat(c, ")")).join(' ');
|
|
47
|
+
|
|
48
|
+
if (key === 'small') {
|
|
49
|
+
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', ";");
|
|
50
|
+
} else {
|
|
51
|
+
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 }");
|
|
52
|
+
}
|
|
53
|
+
} else if (isSpanParent) {
|
|
54
|
+
if (key === 'small') {
|
|
55
|
+
data += "-ms-grid-columns: repeat(".concat(cols[key], ", 1fr);\n grid-template-columns: repeat(").concat(cols[key], ", 1fr);");
|
|
56
|
+
} else {
|
|
57
|
+
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 }");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return data;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (Array.isArray(cols)) {
|
|
65
|
+
const mtg = mapTemplateGrid(cols).join(' ');
|
|
66
|
+
const mtgs = mapTemplateGrid(cols).map(c => "minmax(0, ".concat(c, ")")).join(' ');
|
|
67
|
+
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 ");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (isSpanParent) {
|
|
71
|
+
return "\n -ms-grid-columns: repeat(".concat(cols, ", 1fr);\n grid-template-columns: repeat(").concat(cols, ", 1fr);");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return '';
|
|
75
|
+
});
|
|
76
|
+
const manageRows = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n ", "\n"])), _ref3 => {
|
|
77
|
+
let {
|
|
78
|
+
rows,
|
|
79
|
+
theme,
|
|
80
|
+
isSpanParent
|
|
81
|
+
} = _ref3;
|
|
82
|
+
|
|
83
|
+
if (typeof rows === 'object' && !Array.isArray(rows)) {
|
|
84
|
+
let data = '';
|
|
85
|
+
Object.keys(theme.media).forEach(key => {
|
|
86
|
+
if (rows[key] && Array.isArray(rows[key])) {
|
|
87
|
+
const mtg = mapTemplateGrid(rows[key]).join(' ');
|
|
88
|
+
const mtgs = mapTemplateGrid(rows[key]).map(c => "minmax(0, ".concat(c, ")")).join(' ');
|
|
89
|
+
|
|
90
|
+
if (key === 'small') {
|
|
91
|
+
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', ";");
|
|
92
|
+
} else {
|
|
93
|
+
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 }");
|
|
94
|
+
}
|
|
95
|
+
} else if (isSpanParent) {
|
|
96
|
+
if (key === 'small') {
|
|
97
|
+
data += "-ms-grid-rows: repeat(".concat(rows[key], ", 1fr);\n grid-template-rows: repeat(").concat(rows[key], ", 1fr);");
|
|
98
|
+
} else {
|
|
99
|
+
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 }");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
return data;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (Array.isArray(rows)) {
|
|
107
|
+
const mtg = mapTemplateGrid(rows).join(' ');
|
|
108
|
+
const mtgs = mapTemplateGrid(rows).map(c => "minmax(0, ".concat(c, ")")).join(' ');
|
|
109
|
+
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 ");
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (isSpanParent) {
|
|
113
|
+
return "\n -ms-grid-rows: repeat(".concat(rows, ", 1fr);\n grid-template-rows: repeat(").concat(rows, ", 1fr);");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return '';
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
export { manageCols, manageRows, manageSpan };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-grid",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-rc.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Grid",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -11,13 +11,25 @@
|
|
|
11
11
|
"import": "./esm/index.js",
|
|
12
12
|
"require": "./cjs/index.js"
|
|
13
13
|
},
|
|
14
|
-
"./
|
|
15
|
-
"import": "./esm/
|
|
16
|
-
"require": "./cjs/
|
|
14
|
+
"./utils/styles": {
|
|
15
|
+
"import": "./esm/utils/styles.js",
|
|
16
|
+
"require": "./cjs/utils/styles.js"
|
|
17
17
|
},
|
|
18
|
-
"./
|
|
19
|
-
"import": "./esm/
|
|
20
|
-
"require": "./cjs/
|
|
18
|
+
"./utils/constants": {
|
|
19
|
+
"import": "./esm/utils/constants.js",
|
|
20
|
+
"require": "./cjs/utils/constants.js"
|
|
21
|
+
},
|
|
22
|
+
"./types": {
|
|
23
|
+
"import": "./esm/types.js",
|
|
24
|
+
"require": "./cjs/types.js"
|
|
25
|
+
},
|
|
26
|
+
"./propTypes": {
|
|
27
|
+
"import": "./esm/propTypes.js",
|
|
28
|
+
"require": "./cjs/propTypes.js"
|
|
29
|
+
},
|
|
30
|
+
"./GridItem": {
|
|
31
|
+
"import": "./esm/GridItem.js",
|
|
32
|
+
"require": "./cjs/GridItem.js"
|
|
21
33
|
},
|
|
22
34
|
"./Grid": {
|
|
23
35
|
"import": "./esm/Grid.js",
|
|
@@ -48,18 +60,21 @@
|
|
|
48
60
|
"build": "node ../../scripts/build/build.js"
|
|
49
61
|
},
|
|
50
62
|
"dependencies": {
|
|
51
|
-
"@elliemae/ds-system": "2.0.0-
|
|
63
|
+
"@elliemae/ds-system": "2.0.0-rc.10",
|
|
52
64
|
"react-desc": "~4.1.3"
|
|
53
65
|
},
|
|
54
66
|
"devDependencies": {
|
|
55
|
-
"
|
|
67
|
+
"@testing-library/jest-dom": "~5.15.0",
|
|
68
|
+
"@testing-library/react": "~12.1.2",
|
|
69
|
+
"@testing-library/user-event": "~13.5.0",
|
|
70
|
+
"styled-components": "~5.3.3",
|
|
56
71
|
"styled-system": "~5.1.5"
|
|
57
72
|
},
|
|
58
73
|
"peerDependencies": {
|
|
59
74
|
"lodash": "^4.17.21",
|
|
60
75
|
"react": "^17.0.2",
|
|
61
76
|
"react-dom": "^17.0.2",
|
|
62
|
-
"styled-components": "^5.3.
|
|
77
|
+
"styled-components": "^5.3.3",
|
|
63
78
|
"styled-system": "^5.1.5"
|
|
64
79
|
},
|
|
65
80
|
"publishConfig": {
|
package/types/Grid.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
/// <reference path="../../../../shared/typings/react-desc.d.ts" />
|
|
1
2
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
declare const
|
|
3
|
+
import type { GridPropsT } from './types';
|
|
4
|
+
declare const Grid: React.ForwardRefExoticComponent<GridPropsT & React.RefAttributes<HTMLDivElement>>;
|
|
5
|
+
declare const DSGridWithSchema: {
|
|
6
|
+
(props?: (GridPropsT & React.RefAttributes<HTMLDivElement>) | undefined): JSX.Element;
|
|
7
|
+
propTypes: unknown;
|
|
8
|
+
toTypescript: () => import("react-desc").TypescriptSchema;
|
|
9
|
+
};
|
|
4
10
|
export default Grid;
|
|
5
11
|
export { DSGridWithSchema };
|
package/types/defaultProps.d.ts
CHANGED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/// <reference path="../../../../shared/typings/react-desc.d.ts" />
|
|
2
|
+
export declare const propTypes: {
|
|
3
|
+
rows: {
|
|
4
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
5
|
+
};
|
|
6
|
+
cols: {
|
|
7
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
8
|
+
};
|
|
9
|
+
span: {
|
|
10
|
+
defaultValue<T = unknown>(arg: T): {
|
|
11
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
12
|
+
};
|
|
13
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
14
|
+
};
|
|
15
|
+
alignItems: {
|
|
16
|
+
defaultValue<T = unknown>(arg: T): {
|
|
17
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
18
|
+
};
|
|
19
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
20
|
+
};
|
|
21
|
+
children: {
|
|
22
|
+
defaultValue<T = unknown>(arg: T): {
|
|
23
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
24
|
+
};
|
|
25
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
26
|
+
};
|
|
27
|
+
className: {
|
|
28
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
29
|
+
};
|
|
30
|
+
justifyContent: {
|
|
31
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
32
|
+
};
|
|
33
|
+
gutter: {
|
|
34
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
35
|
+
};
|
|
36
|
+
wrap: {
|
|
37
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
38
|
+
};
|
|
39
|
+
height: {
|
|
40
|
+
defaultValue<T = unknown>(arg: T): {
|
|
41
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
42
|
+
};
|
|
43
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
44
|
+
};
|
|
45
|
+
width: {
|
|
46
|
+
defaultValue<T = unknown>(arg: T): {
|
|
47
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
48
|
+
};
|
|
49
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
50
|
+
};
|
|
51
|
+
p: {
|
|
52
|
+
defaultValue<T = unknown>(arg: T): {
|
|
53
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
54
|
+
};
|
|
55
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
56
|
+
};
|
|
57
|
+
m: {
|
|
58
|
+
defaultValue<T = unknown>(arg: T): {
|
|
59
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
60
|
+
};
|
|
61
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
62
|
+
};
|
|
63
|
+
px: {
|
|
64
|
+
defaultValue<T = unknown>(arg: T): {
|
|
65
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
66
|
+
};
|
|
67
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
68
|
+
};
|
|
69
|
+
mx: {
|
|
70
|
+
defaultValue<T = unknown>(arg: T): {
|
|
71
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
72
|
+
};
|
|
73
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
74
|
+
};
|
|
75
|
+
py: {
|
|
76
|
+
defaultValue<T = unknown>(arg: T): {
|
|
77
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
78
|
+
};
|
|
79
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
80
|
+
};
|
|
81
|
+
my: {
|
|
82
|
+
defaultValue<T = unknown>(arg: T): {
|
|
83
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
84
|
+
};
|
|
85
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
86
|
+
};
|
|
87
|
+
ml: {
|
|
88
|
+
defaultValue<T = unknown>(arg: T): {
|
|
89
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
90
|
+
};
|
|
91
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
92
|
+
};
|
|
93
|
+
mr: {
|
|
94
|
+
defaultValue<T = unknown>(arg: T): {
|
|
95
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
96
|
+
};
|
|
97
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
98
|
+
};
|
|
99
|
+
mt: {
|
|
100
|
+
defaultValue<T = unknown>(arg: T): {
|
|
101
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
102
|
+
};
|
|
103
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
104
|
+
};
|
|
105
|
+
mb: {
|
|
106
|
+
defaultValue<T = unknown>(arg: T): {
|
|
107
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
108
|
+
};
|
|
109
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
110
|
+
};
|
|
111
|
+
pl: {
|
|
112
|
+
defaultValue<T = unknown>(arg: T): {
|
|
113
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
114
|
+
};
|
|
115
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
116
|
+
};
|
|
117
|
+
pr: {
|
|
118
|
+
defaultValue<T = unknown>(arg: T): {
|
|
119
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
120
|
+
};
|
|
121
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
122
|
+
};
|
|
123
|
+
pt: {
|
|
124
|
+
defaultValue<T = unknown>(arg: T): {
|
|
125
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
126
|
+
};
|
|
127
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
128
|
+
};
|
|
129
|
+
pb: {
|
|
130
|
+
defaultValue<T = unknown>(arg: T): {
|
|
131
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
132
|
+
};
|
|
133
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
134
|
+
};
|
|
135
|
+
};
|
package/types/types.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { alignItemsPlacement, justifyPlacement, wrap } from './utils/constants';
|
|
3
|
+
interface RowColBreakpoints {
|
|
4
|
+
small?: string | number[];
|
|
5
|
+
medium?: string | number[];
|
|
6
|
+
large?: string | number[];
|
|
7
|
+
}
|
|
8
|
+
interface SpanBreakpoints {
|
|
9
|
+
small?: number;
|
|
10
|
+
medium?: number;
|
|
11
|
+
large?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface GridPropsT {
|
|
14
|
+
rows?: string | number[] | RowColBreakpoints;
|
|
15
|
+
cols?: string | number[] | RowColBreakpoints;
|
|
16
|
+
alignItems?: typeof alignItemsPlacement[number];
|
|
17
|
+
children?: React.ReactElement[];
|
|
18
|
+
className?: string;
|
|
19
|
+
justify?: typeof justifyPlacement[number];
|
|
20
|
+
gutter?: string | number;
|
|
21
|
+
wrap?: typeof wrap[number];
|
|
22
|
+
span?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface GridPropsWithDefaultT {
|
|
25
|
+
rows: string | number[] | RowColBreakpoints;
|
|
26
|
+
cols: string | number[] | RowColBreakpoints;
|
|
27
|
+
alignItems: typeof alignItemsPlacement[number];
|
|
28
|
+
children?: React.ReactElement[];
|
|
29
|
+
className: string;
|
|
30
|
+
justify: typeof justifyPlacement[number];
|
|
31
|
+
gutter: string | number;
|
|
32
|
+
wrap: typeof wrap[number];
|
|
33
|
+
span: number | SpanBreakpoints;
|
|
34
|
+
}
|
|
35
|
+
export interface GridItemPropsT {
|
|
36
|
+
rows: string | number[] | RowColBreakpoints;
|
|
37
|
+
cols: string | number[] | RowColBreakpoints;
|
|
38
|
+
alignItems: typeof alignItemsPlacement[number];
|
|
39
|
+
children: React.ReactElement[];
|
|
40
|
+
className: string;
|
|
41
|
+
justify: typeof justifyPlacement[number];
|
|
42
|
+
gutter: string | number;
|
|
43
|
+
wrap: typeof wrap[number];
|
|
44
|
+
childNumber: number;
|
|
45
|
+
isSpanParent: boolean;
|
|
46
|
+
span?: number | SpanBreakpoints;
|
|
47
|
+
ref: React.ForwardedRef<HTMLDivElement>;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const justifyPlacement: readonly ["flex-start", "center", "flex-end", "space-between", "space-around", "space-evenly"];
|
|
2
|
+
export declare const alignItemsPlacement: readonly ["flex-start", "center", "flex-end", "stretch", "baseline"];
|
|
3
|
+
export declare const wrap: readonly ["wrap", "nowrap", "wrap-reverse"];
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const manageSpan: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
|
|
2
|
+
export declare const manageCols: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
|
|
3
|
+
export declare const manageRows: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
|
package/cjs/ie11.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var lodash = require('lodash');
|
|
6
|
-
|
|
7
|
-
// m x n items (rows and cols simultaneously)
|
|
8
|
-
|
|
9
|
-
function positionIE11Grid({
|
|
10
|
-
rows,
|
|
11
|
-
cols,
|
|
12
|
-
childNumber
|
|
13
|
-
}) {
|
|
14
|
-
let css = '';
|
|
15
|
-
|
|
16
|
-
if (Array.isArray(rows) && rows.length === 0 || !rows) {
|
|
17
|
-
for (let x = 0; x <= childNumber; x++) {
|
|
18
|
-
// :nth-child() doesn't work in ie11
|
|
19
|
-
css = css.concat("& > div ".concat(lodash.repeat('+ div ', x), "{ -ms-grid-column: ").concat(x + 1, "; } "));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (Array.isArray(cols) && cols.length === 0 || !cols) {
|
|
24
|
-
for (let x = 0; x <= childNumber; x++) {
|
|
25
|
-
css = css.concat("& > div ".concat(lodash.repeat('+ div ', x), "{ -ms-grid-row: ").concat(x + 1, "; } "));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return css;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
exports.positionIE11Grid = positionIE11Grid;
|
package/cjs/props.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var reactDesc = require('react-desc');
|
|
6
|
-
|
|
7
|
-
const gridProps = {
|
|
8
|
-
/** Row layout cells */
|
|
9
|
-
rows: reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string])).description('Row layout cells'),
|
|
10
|
-
|
|
11
|
-
/** Column layout cells */
|
|
12
|
-
cols: reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string])).description('Column layout cells'),
|
|
13
|
-
|
|
14
|
-
/** Grid span */
|
|
15
|
-
span: reactDesc.PropTypes.number.description('Grid span'),
|
|
16
|
-
|
|
17
|
-
/** flex-like align items prop */
|
|
18
|
-
alignItems: reactDesc.PropTypes.oneOf(['flex-start', 'center', 'flex-end', 'stretch', 'baseline']).description('flex-like align items prop'),
|
|
19
|
-
|
|
20
|
-
/** Children node inside grid cell */
|
|
21
|
-
children: reactDesc.PropTypes.node.description('Children node inside grid cell'),
|
|
22
|
-
|
|
23
|
-
/** CSS class */
|
|
24
|
-
className: reactDesc.PropTypes.string.description('CSS class'),
|
|
25
|
-
|
|
26
|
-
/** flex-like direction prop */
|
|
27
|
-
direction: reactDesc.PropTypes.oneOf(['row', 'row-reverse', 'column', 'column-reverse']).description('flex-like direction prop'),
|
|
28
|
-
|
|
29
|
-
/** flex-like justify prop */
|
|
30
|
-
justify: reactDesc.PropTypes.oneOf(['flex-start', 'center', 'flex-end', 'space-between', 'space-around', 'space-evenly']).description('flex-like justify prop'),
|
|
31
|
-
|
|
32
|
-
/** Space between cells prop */
|
|
33
|
-
gutter: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.number, reactDesc.PropTypes.string]).description('Space between cells prop'),
|
|
34
|
-
|
|
35
|
-
/** Wrap type */
|
|
36
|
-
wrap: reactDesc.PropTypes.oneOf(['nowrap', 'wrap', 'wrap-reverse']).description('Wrap type')
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
exports.gridProps = gridProps;
|
package/esm/ie11.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { repeat } from 'lodash';
|
|
2
|
-
|
|
3
|
-
// m x n items (rows and cols simultaneously)
|
|
4
|
-
|
|
5
|
-
function positionIE11Grid({
|
|
6
|
-
rows,
|
|
7
|
-
cols,
|
|
8
|
-
childNumber
|
|
9
|
-
}) {
|
|
10
|
-
let css = '';
|
|
11
|
-
|
|
12
|
-
if (Array.isArray(rows) && rows.length === 0 || !rows) {
|
|
13
|
-
for (let x = 0; x <= childNumber; x++) {
|
|
14
|
-
// :nth-child() doesn't work in ie11
|
|
15
|
-
css = css.concat("& > div ".concat(repeat('+ div ', x), "{ -ms-grid-column: ").concat(x + 1, "; } "));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (Array.isArray(cols) && cols.length === 0 || !cols) {
|
|
20
|
-
for (let x = 0; x <= childNumber; x++) {
|
|
21
|
-
css = css.concat("& > div ".concat(repeat('+ div ', x), "{ -ms-grid-row: ").concat(x + 1, "; } "));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return css;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { positionIE11Grid };
|
package/esm/props.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { PropTypes } from 'react-desc';
|
|
2
|
-
|
|
3
|
-
const gridProps = {
|
|
4
|
-
/** Row layout cells */
|
|
5
|
-
rows: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])).description('Row layout cells'),
|
|
6
|
-
|
|
7
|
-
/** Column layout cells */
|
|
8
|
-
cols: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])).description('Column layout cells'),
|
|
9
|
-
|
|
10
|
-
/** Grid span */
|
|
11
|
-
span: PropTypes.number.description('Grid span'),
|
|
12
|
-
|
|
13
|
-
/** flex-like align items prop */
|
|
14
|
-
alignItems: PropTypes.oneOf(['flex-start', 'center', 'flex-end', 'stretch', 'baseline']).description('flex-like align items prop'),
|
|
15
|
-
|
|
16
|
-
/** Children node inside grid cell */
|
|
17
|
-
children: PropTypes.node.description('Children node inside grid cell'),
|
|
18
|
-
|
|
19
|
-
/** CSS class */
|
|
20
|
-
className: PropTypes.string.description('CSS class'),
|
|
21
|
-
|
|
22
|
-
/** flex-like direction prop */
|
|
23
|
-
direction: PropTypes.oneOf(['row', 'row-reverse', 'column', 'column-reverse']).description('flex-like direction prop'),
|
|
24
|
-
|
|
25
|
-
/** flex-like justify prop */
|
|
26
|
-
justify: PropTypes.oneOf(['flex-start', 'center', 'flex-end', 'space-between', 'space-around', 'space-evenly']).description('flex-like justify prop'),
|
|
27
|
-
|
|
28
|
-
/** Space between cells prop */
|
|
29
|
-
gutter: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Space between cells prop'),
|
|
30
|
-
|
|
31
|
-
/** Wrap type */
|
|
32
|
-
wrap: PropTypes.oneOf(['nowrap', 'wrap', 'wrap-reverse']).description('Wrap type')
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export { gridProps };
|
package/types/ie11.d.ts
DELETED
package/types/props.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export declare const gridProps: {
|
|
2
|
-
/** Row layout cells */
|
|
3
|
-
rows: any;
|
|
4
|
-
/** Column layout cells */
|
|
5
|
-
cols: any;
|
|
6
|
-
/** Grid span */
|
|
7
|
-
span: any;
|
|
8
|
-
/** flex-like align items prop */
|
|
9
|
-
alignItems: any;
|
|
10
|
-
/** Children node inside grid cell */
|
|
11
|
-
children: any;
|
|
12
|
-
/** CSS class */
|
|
13
|
-
className: any;
|
|
14
|
-
/** flex-like direction prop */
|
|
15
|
-
direction: any;
|
|
16
|
-
/** flex-like justify prop */
|
|
17
|
-
justify: any;
|
|
18
|
-
/** Space between cells prop */
|
|
19
|
-
gutter: any;
|
|
20
|
-
/** Wrap type */
|
|
21
|
-
wrap: any;
|
|
22
|
-
};
|