@instructure/ui-grid 8.33.1 → 8.33.2-snapshot-5
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/CHANGELOG.md +8 -0
- package/es/Grid/index.js +9 -22
- package/es/Grid/props.js +1 -0
- package/es/Grid/styles.js +7 -7
- package/es/Grid/theme.js +3 -3
- package/es/GridCol/index.js +2 -16
- package/es/GridCol/props.js +1 -0
- package/es/GridCol/styles.js +19 -34
- package/es/GridCol/theme.js +3 -3
- package/es/GridRow/index.js +9 -22
- package/es/GridRow/props.js +1 -0
- package/es/GridRow/styles.js +14 -14
- package/es/GridRow/theme.js +3 -3
- package/lib/Grid/index.js +9 -36
- package/lib/Grid/props.js +1 -6
- package/lib/Grid/styles.js +7 -8
- package/lib/Grid/theme.js +3 -4
- package/lib/GridCol/index.js +2 -24
- package/lib/GridCol/props.js +1 -4
- package/lib/GridCol/styles.js +19 -35
- package/lib/GridCol/theme.js +3 -4
- package/lib/GridRow/index.js +9 -33
- package/lib/GridRow/props.js +1 -6
- package/lib/GridRow/styles.js +14 -15
- package/lib/GridRow/theme.js +3 -4
- package/lib/index.js +0 -1
- package/package.json +13 -13
- package/tsconfig.build.tsbuildinfo +1 -1
package/lib/Grid/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
@@ -21,36 +19,21 @@ Object.defineProperty(exports, "GridRow", {
|
|
|
21
19
|
}
|
|
22
20
|
});
|
|
23
21
|
exports.default = void 0;
|
|
24
|
-
|
|
25
22
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
26
|
-
|
|
27
23
|
var _react = _interopRequireWildcard(require("react"));
|
|
28
|
-
|
|
29
24
|
var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
|
|
30
|
-
|
|
31
25
|
var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
|
|
32
|
-
|
|
33
26
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
34
|
-
|
|
35
27
|
var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
|
|
36
|
-
|
|
37
28
|
var _GridRow = require("../GridRow");
|
|
38
|
-
|
|
39
29
|
var _GridCol = require("../GridCol");
|
|
40
|
-
|
|
41
30
|
var _emotion = require("@instructure/emotion");
|
|
42
|
-
|
|
43
31
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
44
|
-
|
|
45
32
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
46
|
-
|
|
47
33
|
var _props = require("./props");
|
|
48
|
-
|
|
49
34
|
const _excluded = ["styles", "makeStyles"],
|
|
50
|
-
|
|
51
|
-
|
|
35
|
+
_excluded2 = ["styles"];
|
|
52
36
|
var _dec, _class, _class2;
|
|
53
|
-
|
|
54
37
|
/**
|
|
55
38
|
---
|
|
56
39
|
category: components
|
|
@@ -61,38 +44,29 @@ let Grid = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
61
44
|
constructor() {
|
|
62
45
|
super(...arguments);
|
|
63
46
|
this.ref = null;
|
|
64
|
-
|
|
65
47
|
this.handleRef = el => {
|
|
66
48
|
this.ref = el;
|
|
67
49
|
};
|
|
68
50
|
}
|
|
69
|
-
|
|
70
51
|
componentDidMount() {
|
|
71
52
|
var _this$props$makeStyle, _this$props;
|
|
72
|
-
|
|
73
53
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
74
54
|
}
|
|
75
|
-
|
|
76
55
|
componentDidUpdate() {
|
|
77
56
|
var _this$props$makeStyle2, _this$props2;
|
|
78
|
-
|
|
79
57
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
80
58
|
}
|
|
81
|
-
|
|
82
59
|
renderChildren() {
|
|
83
60
|
const _this$props3 = this.props,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
61
|
+
styles = _this$props3.styles,
|
|
62
|
+
makeStyles = _this$props3.makeStyles,
|
|
63
|
+
props = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
|
|
88
64
|
const children = _react.Children.toArray(this.props.children);
|
|
89
|
-
|
|
90
65
|
return children.map((child, index) => {
|
|
91
66
|
if ((0, _matchComponentTypes.matchComponentTypes)(child, [_GridRow.GridRow])) {
|
|
92
|
-
return (0, _safeCloneElement.safeCloneElement)(child, {
|
|
93
|
-
...
|
|
94
|
-
/* child props should override parent
|
|
95
|
-
,
|
|
67
|
+
return (0, _safeCloneElement.safeCloneElement)(child, {
|
|
68
|
+
...(0, _pickProps.pickProps)(props, Grid.allowedProps),
|
|
69
|
+
...child.props /* child props should override parent */,
|
|
96
70
|
isLastRow: index + 1 === children.length
|
|
97
71
|
});
|
|
98
72
|
} else {
|
|
@@ -103,15 +77,14 @@ let Grid = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
103
77
|
|
|
104
78
|
render() {
|
|
105
79
|
const _this$props4 = this.props,
|
|
106
|
-
|
|
107
|
-
|
|
80
|
+
styles = _this$props4.styles,
|
|
81
|
+
restProps = (0, _objectWithoutProperties2.default)(_this$props4, _excluded2);
|
|
108
82
|
const props = (0, _omitProps.omitProps)(restProps, Grid.allowedProps);
|
|
109
83
|
return (0, _emotion.jsx)("span", Object.assign({}, props, {
|
|
110
84
|
css: styles === null || styles === void 0 ? void 0 : styles.grid,
|
|
111
85
|
ref: this.handleRef
|
|
112
86
|
}), this.renderChildren());
|
|
113
87
|
}
|
|
114
|
-
|
|
115
88
|
}, _class2.displayName = "Grid", _class2.componentId = 'Grid', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
116
89
|
colSpacing: 'medium',
|
|
117
90
|
rowSpacing: 'medium',
|
package/lib/Grid/props.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _Children = require("@instructure/ui-prop-types/lib/Children.js");
|
|
13
|
-
|
|
14
10
|
var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
|
|
15
|
-
|
|
16
11
|
var _GridRow = require("../GridRow");
|
|
17
|
-
|
|
18
12
|
/*
|
|
19
13
|
* The MIT License (MIT)
|
|
20
14
|
*
|
|
@@ -38,6 +32,7 @@ var _GridRow = require("../GridRow");
|
|
|
38
32
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
39
33
|
* SOFTWARE.
|
|
40
34
|
*/
|
|
35
|
+
|
|
41
36
|
const propTypes = {
|
|
42
37
|
children: _Children.Children.oneOf([_GridRow.GridRow, _ScreenReaderContent.ScreenReaderContent]),
|
|
43
38
|
colSpacing: _propTypes.default.oneOf(['none', 'small', 'medium', 'large']),
|
package/lib/Grid/styles.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -41,22 +40,23 @@ exports.default = void 0;
|
|
|
41
40
|
*/
|
|
42
41
|
const generateStyle = (componentTheme, props) => {
|
|
43
42
|
const startAt = props.startAt,
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
visualDebug = props.visualDebug;
|
|
46
44
|
const getStartAtVariants = breakpoint => !!startAt && startAt === breakpoint ? {
|
|
47
45
|
boxSizing: 'border-box'
|
|
48
46
|
} : {};
|
|
49
|
-
|
|
50
47
|
return {
|
|
51
48
|
grid: {
|
|
52
49
|
label: 'grid',
|
|
53
50
|
display: 'block',
|
|
54
51
|
...getStartAtVariants('small'),
|
|
55
|
-
[`@media screen and (${componentTheme.mediumMin})`]: {
|
|
52
|
+
[`@media screen and (${componentTheme.mediumMin})`]: {
|
|
53
|
+
...getStartAtVariants('medium')
|
|
56
54
|
},
|
|
57
|
-
[`@media screen and (${componentTheme.largeMin})`]: {
|
|
55
|
+
[`@media screen and (${componentTheme.largeMin})`]: {
|
|
56
|
+
...getStartAtVariants('large')
|
|
58
57
|
},
|
|
59
|
-
[`@media screen and (${componentTheme.xLargeMin})`]: {
|
|
58
|
+
[`@media screen and (${componentTheme.xLargeMin})`]: {
|
|
59
|
+
...getStartAtVariants('x-large')
|
|
60
60
|
},
|
|
61
61
|
...(visualDebug && {
|
|
62
62
|
outline: '0.0625rem dashed red'
|
|
@@ -64,6 +64,5 @@ const generateStyle = (componentTheme, props) => {
|
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
};
|
|
67
|
-
|
|
68
67
|
var _default = generateStyle;
|
|
69
68
|
exports.default = _default;
|
package/lib/Grid/theme.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -36,16 +35,16 @@ exports.default = void 0;
|
|
|
36
35
|
*/
|
|
37
36
|
const generateComponentTheme = theme => {
|
|
38
37
|
const spacing = theme.spacing,
|
|
39
|
-
|
|
38
|
+
media = theme.media;
|
|
40
39
|
const componentVariables = {
|
|
41
40
|
spacingSmall: spacing === null || spacing === void 0 ? void 0 : spacing.small,
|
|
42
41
|
spacingMedium: spacing === null || spacing === void 0 ? void 0 : spacing.medium,
|
|
43
42
|
spacingLarge: spacing === null || spacing === void 0 ? void 0 : spacing.large,
|
|
44
43
|
...media
|
|
45
44
|
};
|
|
46
|
-
return {
|
|
45
|
+
return {
|
|
46
|
+
...componentVariables
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
|
-
|
|
50
49
|
var _default = generateComponentTheme;
|
|
51
50
|
exports.default = _default;
|
package/lib/GridCol/index.js
CHANGED
|
@@ -1,28 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = exports.GridCol = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = require("react");
|
|
11
|
-
|
|
12
9
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
13
|
-
|
|
14
10
|
var _emotion = require("@instructure/emotion");
|
|
15
|
-
|
|
16
11
|
var _console = require("@instructure/console");
|
|
17
|
-
|
|
18
12
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
19
|
-
|
|
20
13
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
21
|
-
|
|
22
14
|
var _props = require("./props");
|
|
23
|
-
|
|
24
15
|
var _dec, _class, _class2;
|
|
25
|
-
|
|
26
16
|
/**
|
|
27
17
|
---
|
|
28
18
|
parent: Grid
|
|
@@ -34,26 +24,21 @@ let GridCol = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
|
|
|
34
24
|
constructor() {
|
|
35
25
|
super(...arguments);
|
|
36
26
|
this.ref = null;
|
|
37
|
-
|
|
38
27
|
this.handleRef = el => {
|
|
39
28
|
const elementRef = this.props.elementRef;
|
|
40
29
|
this.ref = el;
|
|
41
|
-
|
|
42
30
|
if (typeof elementRef === 'function') {
|
|
43
31
|
elementRef(el);
|
|
44
32
|
}
|
|
45
33
|
};
|
|
46
34
|
}
|
|
47
|
-
|
|
48
35
|
widthCheck() {
|
|
49
36
|
const width = this.props.width;
|
|
50
37
|
let shouldWarn = false;
|
|
51
|
-
|
|
52
38
|
if (width) {
|
|
53
39
|
if (typeof width === 'number' && width <= 0) {
|
|
54
40
|
shouldWarn = true;
|
|
55
41
|
}
|
|
56
|
-
|
|
57
42
|
if (typeof width === 'object') {
|
|
58
43
|
Object.keys(width).forEach(breakpoint => {
|
|
59
44
|
//@ts-expect-error Ts doesn't understand Object.keys properly
|
|
@@ -63,37 +48,30 @@ let GridCol = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
|
|
|
63
48
|
});
|
|
64
49
|
}
|
|
65
50
|
}
|
|
66
|
-
|
|
67
51
|
if (shouldWarn) {
|
|
68
52
|
(0, _console.logWarn)(false, 'Col width must be positive!');
|
|
69
53
|
}
|
|
70
54
|
}
|
|
71
|
-
|
|
72
55
|
componentDidMount() {
|
|
73
56
|
var _this$props$makeStyle, _this$props;
|
|
74
|
-
|
|
75
57
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
76
58
|
this.widthCheck();
|
|
77
59
|
}
|
|
78
|
-
|
|
79
60
|
componentDidUpdate() {
|
|
80
61
|
var _this$props$makeStyle2, _this$props2;
|
|
81
|
-
|
|
82
62
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
83
63
|
this.widthCheck();
|
|
84
64
|
}
|
|
85
|
-
|
|
86
65
|
render() {
|
|
87
66
|
const _this$props3 = this.props,
|
|
88
|
-
|
|
89
|
-
|
|
67
|
+
children = _this$props3.children,
|
|
68
|
+
styles = _this$props3.styles;
|
|
90
69
|
const props = (0, _omitProps.omitProps)(this.props, GridCol.allowedProps);
|
|
91
70
|
return (0, _emotion.jsx)("span", Object.assign({}, props, {
|
|
92
71
|
ref: this.handleRef,
|
|
93
72
|
css: styles === null || styles === void 0 ? void 0 : styles.gridCol
|
|
94
73
|
}), children);
|
|
95
74
|
}
|
|
96
|
-
|
|
97
75
|
}, _class2.displayName = "GridCol", _class2.componentId = 'Grid.Col', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
98
76
|
textAlign: 'inherit',
|
|
99
77
|
children: null,
|
package/lib/GridCol/props.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
/*
|
|
13
10
|
* The MIT License (MIT)
|
|
14
11
|
*
|
|
@@ -32,9 +29,9 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
32
29
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
30
|
* SOFTWARE.
|
|
34
31
|
*/
|
|
32
|
+
|
|
35
33
|
// TODO: get numcols from theme config
|
|
36
34
|
const COL_WIDTHS = _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.oneOf(['auto'])]);
|
|
37
|
-
|
|
38
35
|
const propTypes = {
|
|
39
36
|
children: _propTypes.default.node,
|
|
40
37
|
colSpacing: _propTypes.default.oneOf(['none', 'small', 'medium', 'large']),
|
package/lib/GridCol/styles.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -41,13 +40,13 @@ exports.default = void 0;
|
|
|
41
40
|
*/
|
|
42
41
|
const generateStyle = (componentTheme, props) => {
|
|
43
42
|
const vAlign = props.vAlign,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
textAlign = props.textAlign,
|
|
44
|
+
rowSpacing = props.rowSpacing,
|
|
45
|
+
colSpacing = props.colSpacing,
|
|
46
|
+
isLastRow = props.isLastRow,
|
|
47
|
+
isLastCol = props.isLastCol,
|
|
48
|
+
startAt = props.startAt,
|
|
49
|
+
visualDebug = props.visualDebug;
|
|
51
50
|
const rowSpacingVariants = {
|
|
52
51
|
small: {
|
|
53
52
|
marginBottom: componentTheme.spacingSmall
|
|
@@ -62,7 +61,6 @@ const generateStyle = (componentTheme, props) => {
|
|
|
62
61
|
marginBottom: 0
|
|
63
62
|
}
|
|
64
63
|
};
|
|
65
|
-
|
|
66
64
|
const getStartGridColumnStyle = () => {
|
|
67
65
|
const colSpacingVariants = {
|
|
68
66
|
small: {
|
|
@@ -115,41 +113,31 @@ const generateStyle = (componentTheme, props) => {
|
|
|
115
113
|
...(textAlign && textAlignVariants[textAlign])
|
|
116
114
|
};
|
|
117
115
|
};
|
|
118
|
-
|
|
119
116
|
const enabledBreakpoints = () => {
|
|
120
117
|
const breakpoints = ['small', 'medium', 'large', 'x-large', null];
|
|
121
118
|
return breakpoints.slice(breakpoints.indexOf(startAt));
|
|
122
119
|
};
|
|
123
|
-
|
|
124
120
|
const breakpointIsEnabled = breakpoint => {
|
|
125
121
|
return enabledBreakpoints().includes(breakpoint);
|
|
126
122
|
};
|
|
127
|
-
|
|
128
123
|
const getColSize = breakpoint => {
|
|
129
124
|
let width = props.width;
|
|
130
125
|
if (!width) return;
|
|
131
|
-
|
|
132
126
|
if (width && typeof width === 'object') {
|
|
133
127
|
width = width[breakpoint === 'x-large' ? 'xLarge' : breakpoint];
|
|
134
128
|
}
|
|
135
|
-
|
|
136
129
|
return width;
|
|
137
130
|
};
|
|
138
|
-
|
|
139
131
|
const getColOffset = breakpoint => {
|
|
140
132
|
let offset = props.offset;
|
|
141
133
|
if (!offset) return;
|
|
142
|
-
|
|
143
134
|
if (offset && typeof offset === 'object') {
|
|
144
135
|
offset = offset[breakpoint === 'x-large' ? 'xLarge' : breakpoint];
|
|
145
136
|
}
|
|
146
|
-
|
|
147
137
|
return offset;
|
|
148
138
|
};
|
|
149
|
-
|
|
150
139
|
const getFlexColumnBySize = function () {
|
|
151
140
|
let size = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : '1';
|
|
152
|
-
|
|
153
141
|
switch (size) {
|
|
154
142
|
case 'auto':
|
|
155
143
|
return {
|
|
@@ -157,12 +145,10 @@ const generateStyle = (componentTheme, props) => {
|
|
|
157
145
|
flexShrink: 0,
|
|
158
146
|
flexBasis: 'auto'
|
|
159
147
|
};
|
|
160
|
-
|
|
161
148
|
case 12:
|
|
162
149
|
return {
|
|
163
150
|
flex: '0 0 100%'
|
|
164
151
|
};
|
|
165
|
-
|
|
166
152
|
default:
|
|
167
153
|
return {
|
|
168
154
|
flexGrow: 0,
|
|
@@ -172,15 +158,12 @@ const generateStyle = (componentTheme, props) => {
|
|
|
172
158
|
};
|
|
173
159
|
}
|
|
174
160
|
};
|
|
175
|
-
|
|
176
161
|
const getColumnOffsetBySize = function () {
|
|
177
162
|
let size = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : '1';
|
|
178
|
-
|
|
179
163
|
switch (size) {
|
|
180
164
|
case 'auto':
|
|
181
165
|
case 12:
|
|
182
166
|
return {};
|
|
183
|
-
|
|
184
167
|
default:
|
|
185
168
|
return {
|
|
186
169
|
marginInlineStart: `calc(${size} / 12 * 99.999%)`,
|
|
@@ -188,22 +171,21 @@ const generateStyle = (componentTheme, props) => {
|
|
|
188
171
|
};
|
|
189
172
|
}
|
|
190
173
|
};
|
|
191
|
-
|
|
192
|
-
|
|
174
|
+
const getStartAtVariants = breakpoint => !!startAt && startAt === breakpoint ? {
|
|
175
|
+
...getStartGridColumnStyle()
|
|
193
176
|
} : {};
|
|
194
|
-
|
|
195
177
|
const getGridColumnsForBreakpoint = breakpoint => {
|
|
196
178
|
const size = getColSize(breakpoint);
|
|
197
179
|
const offset = getColOffset(breakpoint);
|
|
198
|
-
return breakpointIsEnabled(breakpoint) ? {
|
|
180
|
+
return breakpointIsEnabled(breakpoint) ? {
|
|
181
|
+
...(size && getFlexColumnBySize(size)),
|
|
199
182
|
...(offset && getColumnOffsetBySize(size))
|
|
200
183
|
} : {};
|
|
201
184
|
};
|
|
202
|
-
|
|
203
|
-
|
|
185
|
+
const getBreakpointStyles = breakpoint => ({
|
|
186
|
+
...getStartAtVariants(breakpoint),
|
|
204
187
|
...getGridColumnsForBreakpoint(breakpoint)
|
|
205
188
|
});
|
|
206
|
-
|
|
207
189
|
return {
|
|
208
190
|
gridCol: {
|
|
209
191
|
label: 'gridCol',
|
|
@@ -216,11 +198,14 @@ const generateStyle = (componentTheme, props) => {
|
|
|
216
198
|
marginBottom: 0
|
|
217
199
|
}),
|
|
218
200
|
...getBreakpointStyles('small'),
|
|
219
|
-
[`@media screen and (${componentTheme.mediumMin})`]: {
|
|
201
|
+
[`@media screen and (${componentTheme.mediumMin})`]: {
|
|
202
|
+
...getBreakpointStyles('medium')
|
|
220
203
|
},
|
|
221
|
-
[`@media screen and (${componentTheme.largeMin})`]: {
|
|
204
|
+
[`@media screen and (${componentTheme.largeMin})`]: {
|
|
205
|
+
...getBreakpointStyles('large')
|
|
222
206
|
},
|
|
223
|
-
[`@media screen and (${componentTheme.xLargeMin})`]: {
|
|
207
|
+
[`@media screen and (${componentTheme.xLargeMin})`]: {
|
|
208
|
+
...getBreakpointStyles('x-large')
|
|
224
209
|
},
|
|
225
210
|
...(visualDebug && {
|
|
226
211
|
outline: '0.0625rem dashed red'
|
|
@@ -228,6 +213,5 @@ const generateStyle = (componentTheme, props) => {
|
|
|
228
213
|
}
|
|
229
214
|
};
|
|
230
215
|
};
|
|
231
|
-
|
|
232
216
|
var _default = generateStyle;
|
|
233
217
|
exports.default = _default;
|
package/lib/GridCol/theme.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -36,16 +35,16 @@ exports.default = void 0;
|
|
|
36
35
|
*/
|
|
37
36
|
const generateComponentTheme = theme => {
|
|
38
37
|
const spacing = theme.spacing,
|
|
39
|
-
|
|
38
|
+
media = theme.media;
|
|
40
39
|
const componentVariables = {
|
|
41
40
|
spacingSmall: spacing === null || spacing === void 0 ? void 0 : spacing.small,
|
|
42
41
|
spacingMedium: spacing === null || spacing === void 0 ? void 0 : spacing.medium,
|
|
43
42
|
spacingLarge: spacing === null || spacing === void 0 ? void 0 : spacing.large,
|
|
44
43
|
...media
|
|
45
44
|
};
|
|
46
|
-
return {
|
|
45
|
+
return {
|
|
46
|
+
...componentVariables
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
|
-
|
|
50
49
|
var _default = generateComponentTheme;
|
|
51
50
|
exports.default = _default;
|
package/lib/GridRow/index.js
CHANGED
|
@@ -1,41 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.default = exports.GridRow = void 0;
|
|
11
|
-
|
|
12
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
|
-
|
|
14
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
-
|
|
16
11
|
var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
|
|
17
|
-
|
|
18
12
|
var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
|
|
19
|
-
|
|
20
13
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
21
|
-
|
|
22
14
|
var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
|
|
23
|
-
|
|
24
15
|
var _GridCol = require("../GridCol");
|
|
25
|
-
|
|
26
16
|
var _emotion = require("@instructure/emotion");
|
|
27
|
-
|
|
28
17
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
29
|
-
|
|
30
18
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
31
|
-
|
|
32
19
|
var _props = require("./props");
|
|
33
|
-
|
|
34
20
|
const _excluded = ["styles", "makeStyles"],
|
|
35
|
-
|
|
36
|
-
|
|
21
|
+
_excluded2 = ["styles"];
|
|
37
22
|
var _dec, _class, _class2;
|
|
38
|
-
|
|
39
23
|
/**
|
|
40
24
|
---
|
|
41
25
|
parent: Grid
|
|
@@ -47,35 +31,28 @@ let GridRow = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
|
|
|
47
31
|
constructor() {
|
|
48
32
|
super(...arguments);
|
|
49
33
|
this.ref = null;
|
|
50
|
-
|
|
51
34
|
this.handleRef = el => {
|
|
52
35
|
this.ref = el;
|
|
53
36
|
};
|
|
54
37
|
}
|
|
55
|
-
|
|
56
38
|
componentDidMount() {
|
|
57
39
|
var _this$props$makeStyle, _this$props;
|
|
58
|
-
|
|
59
40
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
60
41
|
}
|
|
61
|
-
|
|
62
42
|
componentDidUpdate() {
|
|
63
43
|
var _this$props$makeStyle2, _this$props2;
|
|
64
|
-
|
|
65
44
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
66
45
|
}
|
|
67
|
-
|
|
68
46
|
renderChildren() {
|
|
69
47
|
const _this$props3 = this.props,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
48
|
+
styles = _this$props3.styles,
|
|
49
|
+
makeStyles = _this$props3.makeStyles,
|
|
50
|
+
props = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
|
|
73
51
|
return _react.Children.map(this.props.children, (child, index) => {
|
|
74
52
|
if ((0, _matchComponentTypes.matchComponentTypes)(child, [_GridCol.GridCol])) {
|
|
75
|
-
return (0, _safeCloneElement.safeCloneElement)(child, {
|
|
76
|
-
...
|
|
77
|
-
/* child props should override parent
|
|
78
|
-
,
|
|
53
|
+
return (0, _safeCloneElement.safeCloneElement)(child, {
|
|
54
|
+
...(0, _pickProps.pickProps)(props, GridRow.allowedProps),
|
|
55
|
+
...child.props /* child props should override parent */,
|
|
79
56
|
isLastRow: props.isLastRow,
|
|
80
57
|
isLastCol: index + 1 === _react.Children.count(this.props.children)
|
|
81
58
|
});
|
|
@@ -87,15 +64,14 @@ let GridRow = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
|
|
|
87
64
|
|
|
88
65
|
render() {
|
|
89
66
|
const _this$props4 = this.props,
|
|
90
|
-
|
|
91
|
-
|
|
67
|
+
styles = _this$props4.styles,
|
|
68
|
+
restProps = (0, _objectWithoutProperties2.default)(_this$props4, _excluded2);
|
|
92
69
|
const props = (0, _omitProps.omitProps)(restProps, GridRow.allowedProps);
|
|
93
70
|
return (0, _emotion.jsx)("span", Object.assign({}, props, {
|
|
94
71
|
css: styles === null || styles === void 0 ? void 0 : styles.gridRow,
|
|
95
72
|
ref: this.handleRef
|
|
96
73
|
}), this.renderChildren());
|
|
97
74
|
}
|
|
98
|
-
|
|
99
75
|
}, _class2.displayName = "GridRow", _class2.componentId = 'Grid.Row', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
100
76
|
children: null,
|
|
101
77
|
isLastRow: false
|
package/lib/GridRow/props.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _Children = require("@instructure/ui-prop-types/lib/Children.js");
|
|
13
|
-
|
|
14
10
|
var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
|
|
15
|
-
|
|
16
11
|
var _GridCol = require("../GridCol");
|
|
17
|
-
|
|
18
12
|
/*
|
|
19
13
|
* The MIT License (MIT)
|
|
20
14
|
*
|
|
@@ -38,6 +32,7 @@ var _GridCol = require("../GridCol");
|
|
|
38
32
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
39
33
|
* SOFTWARE.
|
|
40
34
|
*/
|
|
35
|
+
|
|
41
36
|
const propTypes = {
|
|
42
37
|
children: _Children.Children.oneOf([_GridCol.GridCol, _ScreenReaderContent.ScreenReaderContent]),
|
|
43
38
|
rowSpacing: _propTypes.default.oneOf(['none', 'small', 'medium', 'large']),
|