@instructure/ui-grid 11.6.0 → 11.6.1-snapshot-129
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 +27 -276
- package/es/Grid/{index.js → v1/index.js} +3 -3
- package/es/Grid/v2/index.js +98 -0
- package/es/Grid/v2/props.js +26 -0
- package/es/Grid/v2/styles.js +61 -0
- package/es/GridCol/{index.js → v1/index.js} +1 -1
- package/es/GridCol/v2/index.js +100 -0
- package/es/GridCol/v2/props.js +26 -0
- package/es/GridCol/v2/styles.js +211 -0
- package/es/GridRow/{index.js → v1/index.js} +2 -2
- package/es/GridRow/v2/index.js +93 -0
- package/es/GridRow/v2/props.js +26 -0
- package/es/GridRow/v2/styles.js +137 -0
- package/es/{index.js → exports/a.js} +1 -1
- package/es/exports/b.js +24 -0
- package/lib/Grid/v1/index.js +120 -0
- package/lib/Grid/{index.js → v2/index.js} +7 -8
- package/lib/Grid/v2/props.js +31 -0
- package/lib/Grid/v2/styles.js +67 -0
- package/lib/GridCol/v1/index.js +106 -0
- package/lib/GridCol/{index.js → v2/index.js} +1 -2
- package/lib/GridCol/v2/props.js +31 -0
- package/lib/GridCol/v2/styles.js +217 -0
- package/lib/GridRow/v1/index.js +102 -0
- package/lib/GridRow/{index.js → v2/index.js} +3 -4
- package/{src/index.ts → lib/GridRow/v2/props.js} +7 -6
- package/lib/GridRow/v2/styles.js +143 -0
- package/lib/{index.js → exports/a.js} +4 -4
- package/lib/exports/b.js +24 -0
- package/package.json +39 -17
- package/src/Grid/{index.tsx → v1/index.tsx} +4 -4
- package/src/Grid/{props.ts → v1/props.ts} +1 -1
- package/src/Grid/{styles.ts → v1/styles.ts} +1 -1
- package/src/Grid/v2/README.md +239 -0
- package/src/Grid/v2/index.tsx +117 -0
- package/src/Grid/v2/props.ts +62 -0
- package/src/Grid/v2/styles.ts +70 -0
- package/src/GridCol/{index.tsx → v1/index.tsx} +1 -1
- package/src/GridCol/{props.ts → v1/props.ts} +1 -1
- package/src/GridCol/{styles.ts → v1/styles.ts} +1 -1
- package/src/GridCol/v2/index.tsx +113 -0
- package/src/GridCol/v2/props.ts +90 -0
- package/src/GridCol/v2/styles.ts +221 -0
- package/src/GridRow/{index.tsx → v1/index.tsx} +3 -3
- package/src/GridRow/{props.ts → v1/props.ts} +1 -1
- package/src/GridRow/{styles.ts → v1/styles.ts} +1 -1
- package/src/GridRow/v2/index.tsx +109 -0
- package/src/GridRow/v2/props.ts +66 -0
- package/src/GridRow/v2/styles.ts +120 -0
- package/src/exports/a.ts +30 -0
- package/src/exports/b.ts +30 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Grid/{index.d.ts → v1/index.d.ts} +4 -4
- package/types/Grid/v1/index.d.ts.map +1 -0
- package/types/Grid/{props.d.ts → v1/props.d.ts} +1 -1
- package/types/Grid/v1/props.d.ts.map +1 -0
- package/types/Grid/v1/styles.d.ts.map +1 -0
- package/types/Grid/v1/theme.d.ts.map +1 -0
- package/types/Grid/v2/index.d.ts +42 -0
- package/types/Grid/v2/index.d.ts.map +1 -0
- package/types/Grid/v2/props.d.ts +23 -0
- package/types/Grid/v2/props.d.ts.map +1 -0
- package/types/Grid/v2/styles.d.ts +15 -0
- package/types/Grid/v2/styles.d.ts.map +1 -0
- package/types/GridCol/{index.d.ts → v1/index.d.ts} +1 -1
- package/types/GridCol/v1/index.d.ts.map +1 -0
- package/types/GridCol/{props.d.ts → v1/props.d.ts} +1 -1
- package/types/GridCol/v1/props.d.ts.map +1 -0
- package/types/GridCol/v1/styles.d.ts.map +1 -0
- package/types/GridCol/v1/theme.d.ts.map +1 -0
- package/types/GridCol/v2/index.d.ts +51 -0
- package/types/GridCol/v2/index.d.ts.map +1 -0
- package/types/GridCol/v2/props.d.ts +40 -0
- package/types/GridCol/v2/props.d.ts.map +1 -0
- package/types/GridCol/v2/styles.d.ts +15 -0
- package/types/GridCol/v2/styles.d.ts.map +1 -0
- package/types/GridRow/{index.d.ts → v1/index.d.ts} +3 -3
- package/types/GridRow/v1/index.d.ts.map +1 -0
- package/types/GridRow/{props.d.ts → v1/props.d.ts} +1 -1
- package/types/GridRow/v1/props.d.ts.map +1 -0
- package/types/GridRow/v1/styles.d.ts.map +1 -0
- package/types/GridRow/v1/theme.d.ts.map +1 -0
- package/types/GridRow/v2/index.d.ts +36 -0
- package/types/GridRow/v2/index.d.ts.map +1 -0
- package/types/GridRow/v2/props.d.ts +25 -0
- package/types/GridRow/v2/props.d.ts.map +1 -0
- package/types/GridRow/v2/styles.d.ts +15 -0
- package/types/GridRow/v2/styles.d.ts.map +1 -0
- package/types/exports/a.d.ts +6 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +6 -0
- package/types/exports/b.d.ts.map +1 -0
- package/types/utils/v1/GridTypes.d.ts.map +1 -0
- package/types/Grid/index.d.ts.map +0 -1
- package/types/Grid/props.d.ts.map +0 -1
- package/types/Grid/styles.d.ts.map +0 -1
- package/types/Grid/theme.d.ts.map +0 -1
- package/types/GridCol/index.d.ts.map +0 -1
- package/types/GridCol/props.d.ts.map +0 -1
- package/types/GridCol/styles.d.ts.map +0 -1
- package/types/GridCol/theme.d.ts.map +0 -1
- package/types/GridRow/index.d.ts.map +0 -1
- package/types/GridRow/props.d.ts.map +0 -1
- package/types/GridRow/styles.d.ts.map +0 -1
- package/types/GridRow/theme.d.ts.map +0 -1
- package/types/GridTypes.d.ts.map +0 -1
- package/types/index.d.ts +0 -6
- package/types/index.d.ts.map +0 -1
- /package/es/Grid/{props.js → v1/props.js} +0 -0
- /package/es/Grid/{styles.js → v1/styles.js} +0 -0
- /package/es/Grid/{theme.js → v1/theme.js} +0 -0
- /package/es/GridCol/{props.js → v1/props.js} +0 -0
- /package/es/GridCol/{styles.js → v1/styles.js} +0 -0
- /package/es/GridCol/{theme.js → v1/theme.js} +0 -0
- /package/es/GridRow/{props.js → v1/props.js} +0 -0
- /package/es/GridRow/{styles.js → v1/styles.js} +0 -0
- /package/es/GridRow/{theme.js → v1/theme.js} +0 -0
- /package/es/{GridTypes.js → utils/v1/GridTypes.js} +0 -0
- /package/lib/Grid/{props.js → v1/props.js} +0 -0
- /package/lib/Grid/{styles.js → v1/styles.js} +0 -0
- /package/lib/Grid/{theme.js → v1/theme.js} +0 -0
- /package/lib/GridCol/{props.js → v1/props.js} +0 -0
- /package/lib/GridCol/{styles.js → v1/styles.js} +0 -0
- /package/lib/GridCol/{theme.js → v1/theme.js} +0 -0
- /package/lib/GridRow/{props.js → v1/props.js} +0 -0
- /package/lib/GridRow/{styles.js → v1/styles.js} +0 -0
- /package/lib/GridRow/{theme.js → v1/theme.js} +0 -0
- /package/lib/{GridTypes.js → utils/v1/GridTypes.js} +0 -0
- /package/src/Grid/{README.md → v1/README.md} +0 -0
- /package/src/Grid/{theme.ts → v1/theme.ts} +0 -0
- /package/src/GridCol/{theme.ts → v1/theme.ts} +0 -0
- /package/src/GridRow/{theme.ts → v1/theme.ts} +0 -0
- /package/src/{GridTypes.ts → utils/v1/GridTypes.ts} +0 -0
- /package/types/Grid/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/Grid/{theme.d.ts → v1/theme.d.ts} +0 -0
- /package/types/GridCol/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/GridCol/{theme.d.ts → v1/theme.d.ts} +0 -0
- /package/types/GridRow/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/GridRow/{theme.d.ts → v1/theme.d.ts} +0 -0
- /package/types/{GridTypes.d.ts → utils/v1/GridTypes.d.ts} +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const allowedProps = ['children', 'colSpacing', 'rowSpacing', 'hAlign', 'vAlign', 'startAt', 'visualDebug'];
|
|
26
|
+
export { allowedProps };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* ---
|
|
27
|
+
* private: true
|
|
28
|
+
* ---
|
|
29
|
+
* Generates the style object from the theme and provided additional information
|
|
30
|
+
* @param {Object} componentTheme The theme variable object.
|
|
31
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
32
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
33
|
+
* @return {Object} The final style object, which will be used in the component
|
|
34
|
+
*/
|
|
35
|
+
const generateStyle = (componentTheme, props) => {
|
|
36
|
+
const startAt = props.startAt,
|
|
37
|
+
visualDebug = props.visualDebug;
|
|
38
|
+
const getStartAtVariants = breakpoint => !!startAt && startAt === breakpoint ? {
|
|
39
|
+
boxSizing: 'border-box'
|
|
40
|
+
} : {};
|
|
41
|
+
return {
|
|
42
|
+
grid: {
|
|
43
|
+
label: 'grid',
|
|
44
|
+
display: 'block',
|
|
45
|
+
...getStartAtVariants('small'),
|
|
46
|
+
[`@media screen and (min-width: ${componentTheme.mediumMin})`]: {
|
|
47
|
+
...getStartAtVariants('medium')
|
|
48
|
+
},
|
|
49
|
+
[`@media screen and (min-width: ${componentTheme.largeMin})`]: {
|
|
50
|
+
...getStartAtVariants('large')
|
|
51
|
+
},
|
|
52
|
+
[`@media screen and (min-width: ${componentTheme.xLargeMin})`]: {
|
|
53
|
+
...getStartAtVariants('x-large')
|
|
54
|
+
},
|
|
55
|
+
...(visualDebug && {
|
|
56
|
+
outline: '0.0625rem dashed red'
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export default generateStyle;
|
|
@@ -25,7 +25,7 @@ var _dec, _class, _GridCol;
|
|
|
25
25
|
|
|
26
26
|
import { Component } from 'react';
|
|
27
27
|
import { omitProps } from '@instructure/ui-react-utils';
|
|
28
|
-
import { withStyle } from '@instructure/emotion';
|
|
28
|
+
import { withStyleLegacy as withStyle } from '@instructure/emotion';
|
|
29
29
|
import { logWarn as warn } from '@instructure/console';
|
|
30
30
|
import generateStyle from "./styles.js";
|
|
31
31
|
import generateComponentTheme from "./theme.js";
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
var _dec, _class, _GridCol;
|
|
2
|
+
/*
|
|
3
|
+
* The MIT License (MIT)
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { Component } from 'react';
|
|
27
|
+
import { omitProps } from '@instructure/ui-react-utils';
|
|
28
|
+
import { withStyle } from '@instructure/emotion';
|
|
29
|
+
import { logWarn as warn } from '@instructure/console';
|
|
30
|
+
import generateStyle from "./styles.js";
|
|
31
|
+
import { allowedProps } from "./props.js";
|
|
32
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
33
|
+
/**
|
|
34
|
+
---
|
|
35
|
+
parent: Grid
|
|
36
|
+
id: Grid.Col
|
|
37
|
+
---
|
|
38
|
+
**/
|
|
39
|
+
let GridCol = (_dec = withStyle(generateStyle), _dec(_class = (_GridCol = class GridCol extends Component {
|
|
40
|
+
constructor(...args) {
|
|
41
|
+
super(...args);
|
|
42
|
+
this.ref = null;
|
|
43
|
+
this.handleRef = el => {
|
|
44
|
+
const elementRef = this.props.elementRef;
|
|
45
|
+
this.ref = el;
|
|
46
|
+
if (typeof elementRef === 'function') {
|
|
47
|
+
elementRef(el);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
widthCheck() {
|
|
52
|
+
const width = this.props.width;
|
|
53
|
+
let shouldWarn = false;
|
|
54
|
+
if (width) {
|
|
55
|
+
if (typeof width === 'number' && width <= 0) {
|
|
56
|
+
shouldWarn = true;
|
|
57
|
+
}
|
|
58
|
+
if (typeof width === 'object') {
|
|
59
|
+
Object.keys(width).forEach(breakpoint => {
|
|
60
|
+
//@ts-expect-error Ts doesn't understand Object.keys properly
|
|
61
|
+
if (typeof width[breakpoint] === 'number' && width[breakpoint] <= 0) {
|
|
62
|
+
shouldWarn = true;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (shouldWarn) {
|
|
68
|
+
warn(false, 'Col width must be positive!');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
componentDidMount() {
|
|
72
|
+
var _this$props$makeStyle, _this$props;
|
|
73
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
74
|
+
this.widthCheck();
|
|
75
|
+
}
|
|
76
|
+
componentDidUpdate() {
|
|
77
|
+
var _this$props$makeStyle2, _this$props2;
|
|
78
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
79
|
+
this.widthCheck();
|
|
80
|
+
}
|
|
81
|
+
render() {
|
|
82
|
+
const _this$props3 = this.props,
|
|
83
|
+
children = _this$props3.children,
|
|
84
|
+
styles = _this$props3.styles;
|
|
85
|
+
const props = omitProps(this.props, GridCol.allowedProps);
|
|
86
|
+
return _jsx("span", {
|
|
87
|
+
...props,
|
|
88
|
+
ref: this.handleRef,
|
|
89
|
+
css: styles === null || styles === void 0 ? void 0 : styles.gridCol,
|
|
90
|
+
children: children
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}, _GridCol.displayName = "GridCol", _GridCol.componentId = 'Grid.Col', _GridCol.allowedProps = allowedProps, _GridCol.defaultProps = {
|
|
94
|
+
textAlign: 'inherit',
|
|
95
|
+
children: null,
|
|
96
|
+
isLastCol: false,
|
|
97
|
+
isLastRow: false
|
|
98
|
+
}, _GridCol)) || _class);
|
|
99
|
+
export default GridCol;
|
|
100
|
+
export { GridCol };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const allowedProps = ['children', 'colSpacing', 'rowSpacing', 'textAlign', 'hAlign', 'vAlign', 'startAt', 'visualDebug', 'width', 'offset', 'isLastRow', 'isLastCol', 'elementRef'];
|
|
26
|
+
export { allowedProps };
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* ---
|
|
27
|
+
* private: true
|
|
28
|
+
* ---
|
|
29
|
+
* Generates the style object from the theme and provided additional information
|
|
30
|
+
* @param {Object} componentTheme The theme variable object.
|
|
31
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
32
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
33
|
+
* @return {Object} The final style object, which will be used in the component
|
|
34
|
+
*/
|
|
35
|
+
const generateStyle = (componentTheme, props) => {
|
|
36
|
+
const vAlign = props.vAlign,
|
|
37
|
+
textAlign = props.textAlign,
|
|
38
|
+
rowSpacing = props.rowSpacing,
|
|
39
|
+
colSpacing = props.colSpacing,
|
|
40
|
+
isLastRow = props.isLastRow,
|
|
41
|
+
isLastCol = props.isLastCol,
|
|
42
|
+
startAt = props.startAt,
|
|
43
|
+
visualDebug = props.visualDebug;
|
|
44
|
+
const rowSpacingVariants = {
|
|
45
|
+
small: {
|
|
46
|
+
marginBottom: componentTheme.spacingSmall
|
|
47
|
+
},
|
|
48
|
+
medium: {
|
|
49
|
+
marginBottom: componentTheme.spacingMedium
|
|
50
|
+
},
|
|
51
|
+
large: {
|
|
52
|
+
marginBottom: componentTheme.spacingLarge
|
|
53
|
+
},
|
|
54
|
+
none: {
|
|
55
|
+
marginBottom: 0
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const getStartGridColumnStyle = () => {
|
|
59
|
+
const colSpacingVariants = {
|
|
60
|
+
small: {
|
|
61
|
+
paddingLeft: `calc(${componentTheme.spacingSmall} / 2)`,
|
|
62
|
+
paddingRight: `calc(${componentTheme.spacingSmall} / 2)`
|
|
63
|
+
},
|
|
64
|
+
medium: {
|
|
65
|
+
paddingLeft: `calc(${componentTheme.spacingMedium} / 2)`,
|
|
66
|
+
paddingRight: `calc(${componentTheme.spacingMedium} / 2)`
|
|
67
|
+
},
|
|
68
|
+
large: {
|
|
69
|
+
paddingLeft: `calc(${componentTheme.spacingLarge} / 2)`,
|
|
70
|
+
paddingRight: `calc(${componentTheme.spacingLarge} / 2)`
|
|
71
|
+
},
|
|
72
|
+
none: {}
|
|
73
|
+
};
|
|
74
|
+
const vAlignVariants = {
|
|
75
|
+
top: {
|
|
76
|
+
alignSelf: 'flex-start'
|
|
77
|
+
},
|
|
78
|
+
middle: {
|
|
79
|
+
alignSelf: 'center'
|
|
80
|
+
},
|
|
81
|
+
bottom: {
|
|
82
|
+
alignSelf: 'flex-end'
|
|
83
|
+
},
|
|
84
|
+
stretch: {
|
|
85
|
+
alignSelf: 'stretch'
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const textAlignVariants = {
|
|
89
|
+
start: {
|
|
90
|
+
textAlign: 'start'
|
|
91
|
+
},
|
|
92
|
+
end: {
|
|
93
|
+
textAlign: 'end'
|
|
94
|
+
},
|
|
95
|
+
center: {
|
|
96
|
+
textAlign: 'center'
|
|
97
|
+
},
|
|
98
|
+
inherit: {
|
|
99
|
+
textAlign: 'inherit'
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
return {
|
|
103
|
+
flexGrow: 1,
|
|
104
|
+
flexShrink: 1,
|
|
105
|
+
flexBasis: '0%',
|
|
106
|
+
marginBottom: 0,
|
|
107
|
+
boxSizing: 'border-box',
|
|
108
|
+
...(colSpacing && colSpacingVariants[colSpacing]),
|
|
109
|
+
...(vAlign && vAlignVariants[vAlign]),
|
|
110
|
+
...(textAlign && textAlignVariants[textAlign])
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
const enabledBreakpoints = () => {
|
|
114
|
+
const breakpoints = ['small', 'medium', 'large', 'x-large', null];
|
|
115
|
+
return breakpoints.slice(breakpoints.indexOf(startAt));
|
|
116
|
+
};
|
|
117
|
+
const breakpointIsEnabled = breakpoint => {
|
|
118
|
+
return enabledBreakpoints().includes(breakpoint);
|
|
119
|
+
};
|
|
120
|
+
const getColSize = breakpoint => {
|
|
121
|
+
let width = props.width;
|
|
122
|
+
if (!width) return;
|
|
123
|
+
if (width && typeof width === 'object') {
|
|
124
|
+
width = width[breakpoint === 'x-large' ? 'xLarge' : breakpoint];
|
|
125
|
+
}
|
|
126
|
+
return width;
|
|
127
|
+
};
|
|
128
|
+
const getColOffset = breakpoint => {
|
|
129
|
+
let offset = props.offset;
|
|
130
|
+
if (!offset) return;
|
|
131
|
+
if (offset && typeof offset === 'object') {
|
|
132
|
+
offset = offset[breakpoint === 'x-large' ? 'xLarge' : breakpoint];
|
|
133
|
+
}
|
|
134
|
+
return offset;
|
|
135
|
+
};
|
|
136
|
+
const getFlexColumnBySize = (size = '1') => {
|
|
137
|
+
switch (size) {
|
|
138
|
+
case 'auto':
|
|
139
|
+
return {
|
|
140
|
+
flexGrow: 0,
|
|
141
|
+
flexShrink: 0,
|
|
142
|
+
flexBasis: 'auto'
|
|
143
|
+
};
|
|
144
|
+
case 12:
|
|
145
|
+
return {
|
|
146
|
+
flex: '0 0 100%'
|
|
147
|
+
};
|
|
148
|
+
default:
|
|
149
|
+
return {
|
|
150
|
+
flexGrow: 0,
|
|
151
|
+
flexShrink: 0,
|
|
152
|
+
flexBasis: `calc(${size} / 12 * 99.999%)`,
|
|
153
|
+
maxWidth: `calc(${size} / 12 * 99.999%)`
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
const getColumnOffsetBySize = (size = '1') => {
|
|
158
|
+
switch (size) {
|
|
159
|
+
case 'auto':
|
|
160
|
+
case 12:
|
|
161
|
+
return {};
|
|
162
|
+
default:
|
|
163
|
+
return {
|
|
164
|
+
marginInlineStart: `calc(${size} / 12 * 99.999%)`,
|
|
165
|
+
marginInlineEnd: 0
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
const getStartAtVariants = breakpoint => !!startAt && startAt === breakpoint ? {
|
|
170
|
+
...getStartGridColumnStyle()
|
|
171
|
+
} : {};
|
|
172
|
+
const getGridColumnsForBreakpoint = breakpoint => {
|
|
173
|
+
const size = getColSize(breakpoint);
|
|
174
|
+
const offset = getColOffset(breakpoint);
|
|
175
|
+
return breakpointIsEnabled(breakpoint) ? {
|
|
176
|
+
...(size && getFlexColumnBySize(size)),
|
|
177
|
+
...(offset && getColumnOffsetBySize(offset))
|
|
178
|
+
} : {};
|
|
179
|
+
};
|
|
180
|
+
const getBreakpointStyles = breakpoint => ({
|
|
181
|
+
...getStartAtVariants(breakpoint),
|
|
182
|
+
...getGridColumnsForBreakpoint(breakpoint)
|
|
183
|
+
});
|
|
184
|
+
return {
|
|
185
|
+
gridCol: {
|
|
186
|
+
label: 'gridCol',
|
|
187
|
+
display: 'block',
|
|
188
|
+
boxSizing: 'border-box',
|
|
189
|
+
textAlign: 'inherit',
|
|
190
|
+
minWidth: '0.0625rem',
|
|
191
|
+
...(rowSpacing && rowSpacingVariants[rowSpacing]),
|
|
192
|
+
...(isLastRow && isLastCol && {
|
|
193
|
+
marginBottom: 0
|
|
194
|
+
}),
|
|
195
|
+
...getBreakpointStyles('small'),
|
|
196
|
+
[`@media screen and (min-width: ${componentTheme.mediumMin})`]: {
|
|
197
|
+
...getBreakpointStyles('medium')
|
|
198
|
+
},
|
|
199
|
+
[`@media screen and (min-width: ${componentTheme.largeMin})`]: {
|
|
200
|
+
...getBreakpointStyles('large')
|
|
201
|
+
},
|
|
202
|
+
[`@media screen and (min-width: ${componentTheme.xLargeMin})`]: {
|
|
203
|
+
...getBreakpointStyles('x-large')
|
|
204
|
+
},
|
|
205
|
+
...(visualDebug && {
|
|
206
|
+
outline: '0.0625rem dashed red'
|
|
207
|
+
})
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
export default generateStyle;
|
|
@@ -28,8 +28,8 @@ var _dec, _class, _GridRow;
|
|
|
28
28
|
|
|
29
29
|
import { Component, Children } from 'react';
|
|
30
30
|
import { safeCloneElement, matchComponentTypes, omitProps, pickProps } from '@instructure/ui-react-utils';
|
|
31
|
-
import { GridCol } from "
|
|
32
|
-
import { withStyle } from '@instructure/emotion';
|
|
31
|
+
import { GridCol } from "../../GridCol/v1/index.js";
|
|
32
|
+
import { withStyleLegacy as withStyle } from '@instructure/emotion';
|
|
33
33
|
import generateStyle from "./styles.js";
|
|
34
34
|
import generateComponentTheme from "./theme.js";
|
|
35
35
|
import { allowedProps } from "./props.js";
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
const _excluded = ["styles", "makeStyles"],
|
|
3
|
+
_excluded2 = ["styles"];
|
|
4
|
+
var _dec, _class, _GridRow;
|
|
5
|
+
/*
|
|
6
|
+
* The MIT License (MIT)
|
|
7
|
+
*
|
|
8
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
9
|
+
*
|
|
10
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
* in the Software without restriction, including without limitation the rights
|
|
13
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
* furnished to do so, subject to the following conditions:
|
|
16
|
+
*
|
|
17
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
* copies or substantial portions of the Software.
|
|
19
|
+
*
|
|
20
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
* SOFTWARE.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import { Component, Children } from 'react';
|
|
30
|
+
import { safeCloneElement, matchComponentTypes, omitProps, pickProps } from '@instructure/ui-react-utils';
|
|
31
|
+
import { GridCol } from "../../GridCol/v2/index.js";
|
|
32
|
+
import { withStyle } from '@instructure/emotion';
|
|
33
|
+
import generateStyle from "./styles.js";
|
|
34
|
+
import { allowedProps } from "./props.js";
|
|
35
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
36
|
+
/**
|
|
37
|
+
---
|
|
38
|
+
parent: Grid
|
|
39
|
+
id: Grid.Row
|
|
40
|
+
---
|
|
41
|
+
**/
|
|
42
|
+
let GridRow = (_dec = withStyle(generateStyle), _dec(_class = (_GridRow = class GridRow extends Component {
|
|
43
|
+
constructor(...args) {
|
|
44
|
+
super(...args);
|
|
45
|
+
this.ref = null;
|
|
46
|
+
this.handleRef = el => {
|
|
47
|
+
this.ref = el;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
componentDidMount() {
|
|
51
|
+
var _this$props$makeStyle, _this$props;
|
|
52
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
53
|
+
}
|
|
54
|
+
componentDidUpdate() {
|
|
55
|
+
var _this$props$makeStyle2, _this$props2;
|
|
56
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
57
|
+
}
|
|
58
|
+
renderChildren() {
|
|
59
|
+
const _this$props3 = this.props,
|
|
60
|
+
styles = _this$props3.styles,
|
|
61
|
+
makeStyles = _this$props3.makeStyles,
|
|
62
|
+
props = _objectWithoutProperties(_this$props3, _excluded);
|
|
63
|
+
return Children.map(this.props.children, (child, index) => {
|
|
64
|
+
if (matchComponentTypes(child, [GridCol])) {
|
|
65
|
+
return safeCloneElement(child, {
|
|
66
|
+
...pickProps(props, GridRow.allowedProps),
|
|
67
|
+
...child.props /* child props should override parent */,
|
|
68
|
+
isLastRow: props.isLastRow,
|
|
69
|
+
isLastCol: index + 1 === Children.count(this.props.children)
|
|
70
|
+
});
|
|
71
|
+
} else {
|
|
72
|
+
return child; // PropType validation should handle errors
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
render() {
|
|
77
|
+
const _this$props4 = this.props,
|
|
78
|
+
styles = _this$props4.styles,
|
|
79
|
+
restProps = _objectWithoutProperties(_this$props4, _excluded2);
|
|
80
|
+
const props = omitProps(restProps, GridRow.allowedProps);
|
|
81
|
+
return _jsx("span", {
|
|
82
|
+
...props,
|
|
83
|
+
css: styles === null || styles === void 0 ? void 0 : styles.gridRow,
|
|
84
|
+
ref: this.handleRef,
|
|
85
|
+
children: this.renderChildren()
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}, _GridRow.displayName = "GridRow", _GridRow.componentId = 'Grid.Row', _GridRow.allowedProps = allowedProps, _GridRow.defaultProps = {
|
|
89
|
+
children: null,
|
|
90
|
+
isLastRow: false
|
|
91
|
+
}, _GridRow)) || _class);
|
|
92
|
+
export default GridRow;
|
|
93
|
+
export { GridRow };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const allowedProps = ['children', 'rowSpacing', 'colSpacing', 'hAlign', 'vAlign', 'startAt', 'visualDebug', 'isLastRow'];
|
|
26
|
+
export { allowedProps };
|