@instructure/ui-grid 8.8.1-snapshot.3 → 8.9.0
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 +6 -0
- package/es/Grid/index.js +3 -17
- package/{src/Grid/types.ts → es/Grid/props.js} +15 -13
- package/es/GridCol/index.js +5 -39
- package/es/GridCol/props.js +53 -0
- package/es/GridRow/index.js +3 -21
- package/{src/GridRow/types.ts → es/GridRow/props.js} +16 -14
- package/lib/Grid/index.js +4 -20
- package/lib/Grid/props.js +52 -0
- package/lib/GridCol/index.js +5 -40
- package/lib/GridCol/props.js +64 -0
- package/lib/GridRow/index.js +4 -24
- package/lib/GridRow/props.js +53 -0
- package/package.json +13 -14
- package/src/Grid/index.tsx +6 -25
- package/src/Grid/props.ts +78 -0
- package/src/Grid/styles.ts +1 -1
- package/src/GridCol/index.tsx +6 -51
- package/src/GridCol/{types.ts → props.ts} +73 -4
- package/src/GridCol/styles.ts +1 -1
- package/src/GridRow/index.tsx +6 -28
- package/src/GridRow/props.ts +82 -0
- package/src/GridRow/styles.ts +1 -1
- package/src/index.ts +3 -3
- package/types/Grid/index.d.ts +19 -16
- package/types/Grid/index.d.ts.map +1 -1
- package/types/Grid/props.d.ts +21 -0
- package/types/Grid/props.d.ts.map +1 -0
- package/types/Grid/styles.d.ts +1 -1
- package/types/GridCol/index.d.ts +31 -30
- package/types/GridCol/index.d.ts.map +1 -1
- package/types/GridCol/{types.d.ts → props.d.ts} +14 -5
- package/types/GridCol/props.d.ts.map +1 -0
- package/types/GridCol/styles.d.ts +1 -1
- package/types/GridRow/index.d.ts +21 -17
- package/types/GridRow/index.d.ts.map +1 -1
- package/types/GridRow/props.d.ts +22 -0
- package/types/GridRow/props.d.ts.map +1 -0
- package/types/GridRow/styles.d.ts +1 -1
- package/types/index.d.ts +3 -3
- package/LICENSE.md +0 -27
- package/es/Grid/types.js +0 -1
- package/es/GridCol/types.js +0 -1
- package/es/GridRow/types.js +0 -1
- package/lib/Grid/types.js +0 -1
- package/lib/GridCol/types.js +0 -1
- package/lib/GridRow/types.js +0 -1
- package/types/Grid/types.d.ts +0 -12
- package/types/Grid/types.d.ts.map +0 -1
- package/types/GridCol/types.d.ts.map +0 -1
- package/types/GridRow/types.d.ts +0 -13
- package/types/GridRow/types.d.ts.map +0 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.allowedProps = exports.propTypes = void 0;
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* The MIT License (MIT)
|
|
14
|
+
*
|
|
15
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
16
|
+
*
|
|
17
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
18
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
19
|
+
* in the Software without restriction, including without limitation the rights
|
|
20
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
21
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
22
|
+
* furnished to do so, subject to the following conditions:
|
|
23
|
+
*
|
|
24
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
25
|
+
* copies or substantial portions of the Software.
|
|
26
|
+
*
|
|
27
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
28
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
29
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
30
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
31
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
32
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
|
+
* SOFTWARE.
|
|
34
|
+
*/
|
|
35
|
+
// TODO: get numcols from theme config
|
|
36
|
+
const COL_WIDTHS = ['auto', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
|
37
|
+
const propTypes = {
|
|
38
|
+
children: _propTypes.default.node,
|
|
39
|
+
colSpacing: _propTypes.default.oneOf(['none', 'small', 'medium', 'large']),
|
|
40
|
+
rowSpacing: _propTypes.default.oneOf(['none', 'small', 'medium', 'large']),
|
|
41
|
+
textAlign: _propTypes.default.oneOf(['start', 'end', 'center', 'inherit']),
|
|
42
|
+
hAlign: _propTypes.default.oneOf(['start', 'center', 'end', 'space-around', 'space-between']),
|
|
43
|
+
vAlign: _propTypes.default.oneOf(['top', 'middle', 'bottom']),
|
|
44
|
+
startAt: _propTypes.default.oneOf(['small', 'medium', 'large', 'x-large', null]),
|
|
45
|
+
visualDebug: _propTypes.default.bool,
|
|
46
|
+
width: _propTypes.default.oneOfType([_propTypes.default.oneOf(COL_WIDTHS), _propTypes.default.shape({
|
|
47
|
+
small: _propTypes.default.oneOf(COL_WIDTHS),
|
|
48
|
+
medium: _propTypes.default.oneOf(COL_WIDTHS),
|
|
49
|
+
large: _propTypes.default.oneOf(COL_WIDTHS),
|
|
50
|
+
xLarge: _propTypes.default.oneOf(COL_WIDTHS)
|
|
51
|
+
})]),
|
|
52
|
+
offset: _propTypes.default.oneOfType([_propTypes.default.oneOf(COL_WIDTHS), _propTypes.default.shape({
|
|
53
|
+
small: _propTypes.default.oneOf(COL_WIDTHS),
|
|
54
|
+
medium: _propTypes.default.oneOf(COL_WIDTHS),
|
|
55
|
+
large: _propTypes.default.oneOf(COL_WIDTHS),
|
|
56
|
+
xLarge: _propTypes.default.oneOf(COL_WIDTHS)
|
|
57
|
+
})]),
|
|
58
|
+
isLastRow: _propTypes.default.bool,
|
|
59
|
+
isLastCol: _propTypes.default.bool,
|
|
60
|
+
elementRef: _propTypes.default.func
|
|
61
|
+
};
|
|
62
|
+
exports.propTypes = propTypes;
|
|
63
|
+
const allowedProps = ['children', 'colSpacing', 'rowSpacing', 'textAlign', 'hAlign', 'vAlign', 'startAt', 'visualDebug', 'width', 'offset', 'isLastRow', 'isLastCol', 'elementRef'];
|
|
64
|
+
exports.allowedProps = allowedProps;
|
package/lib/GridRow/index.js
CHANGED
|
@@ -11,10 +11,6 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
11
11
|
|
|
12
12
|
var _react = require("react");
|
|
13
13
|
|
|
14
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
|
|
16
|
-
var _Children = require("@instructure/ui-prop-types/lib/Children.js");
|
|
17
|
-
|
|
18
14
|
var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
|
|
19
15
|
|
|
20
16
|
var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
|
|
@@ -23,8 +19,6 @@ var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
|
23
19
|
|
|
24
20
|
var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
|
|
25
21
|
|
|
26
|
-
var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
|
|
27
|
-
|
|
28
22
|
var _GridCol = require("../GridCol");
|
|
29
23
|
|
|
30
24
|
var _emotion = require("@instructure/emotion");
|
|
@@ -33,6 +27,8 @@ var _styles = _interopRequireDefault(require("./styles"));
|
|
|
33
27
|
|
|
34
28
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
35
29
|
|
|
30
|
+
var _props = require("./props");
|
|
31
|
+
|
|
36
32
|
const _excluded = ["styles", "makeStyles"],
|
|
37
33
|
_excluded2 = ["styles"];
|
|
38
34
|
|
|
@@ -45,9 +41,6 @@ id: Grid.Row
|
|
|
45
41
|
---
|
|
46
42
|
**/
|
|
47
43
|
let GridRow = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_temp = _class2 = class GridRow extends _react.Component {
|
|
48
|
-
/* eslint-disable react/require-default-props */
|
|
49
|
-
|
|
50
|
-
/* eslint-enable react/require-default-props */
|
|
51
44
|
componentDidMount() {
|
|
52
45
|
this.props.makeStyles();
|
|
53
46
|
}
|
|
@@ -82,24 +75,11 @@ let GridRow = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
|
|
|
82
75
|
restProps = (0, _objectWithoutProperties2.default)(_this$props2, _excluded2);
|
|
83
76
|
const props = (0, _omitProps.omitProps)(restProps, GridRow.propTypes);
|
|
84
77
|
return (0, _emotion.jsx)("span", Object.assign({}, props, {
|
|
85
|
-
css: styles.gridRow
|
|
78
|
+
css: styles === null || styles === void 0 ? void 0 : styles.gridRow
|
|
86
79
|
}), this.renderChildren());
|
|
87
80
|
}
|
|
88
81
|
|
|
89
|
-
}, _class2.displayName = "GridRow", _class2.componentId = 'Grid.Row', _class2.propTypes = {
|
|
90
|
-
// eslint-disable-next-line react/require-default-props
|
|
91
|
-
makeStyles: _propTypes.default.func,
|
|
92
|
-
// eslint-disable-next-line react/require-default-props
|
|
93
|
-
styles: _propTypes.default.object,
|
|
94
|
-
children: _Children.Children.oneOf([_GridCol.GridCol, _ScreenReaderContent.ScreenReaderContent]),
|
|
95
|
-
rowSpacing: _propTypes.default.oneOf(['none', 'small', 'medium', 'large']),
|
|
96
|
-
colSpacing: _propTypes.default.oneOf(['none', 'small', 'medium', 'large']),
|
|
97
|
-
hAlign: _propTypes.default.oneOf(['start', 'center', 'end', 'space-around', 'space-between']),
|
|
98
|
-
vAlign: _propTypes.default.oneOf(['top', 'middle', 'bottom']),
|
|
99
|
-
startAt: _propTypes.default.oneOf(['small', 'medium', 'large', 'x-large', null]),
|
|
100
|
-
visualDebug: _propTypes.default.bool,
|
|
101
|
-
isLastRow: _propTypes.default.bool
|
|
102
|
-
}, _class2.defaultProps = {
|
|
82
|
+
}, _class2.displayName = "GridRow", _class2.componentId = 'Grid.Row', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
103
83
|
children: null,
|
|
104
84
|
isLastRow: false
|
|
105
85
|
}, _temp)) || _class);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.allowedProps = exports.propTypes = void 0;
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _Children = require("@instructure/ui-prop-types/lib/Children.js");
|
|
13
|
+
|
|
14
|
+
var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
|
|
15
|
+
|
|
16
|
+
var _GridCol = require("../GridCol");
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
* The MIT License (MIT)
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
22
|
+
*
|
|
23
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
24
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
25
|
+
* in the Software without restriction, including without limitation the rights
|
|
26
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
27
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
28
|
+
* furnished to do so, subject to the following conditions:
|
|
29
|
+
*
|
|
30
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
31
|
+
* copies or substantial portions of the Software.
|
|
32
|
+
*
|
|
33
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
34
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
35
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
36
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
37
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
38
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
39
|
+
* SOFTWARE.
|
|
40
|
+
*/
|
|
41
|
+
const propTypes = {
|
|
42
|
+
children: _Children.Children.oneOf([_GridCol.GridCol, _ScreenReaderContent.ScreenReaderContent]),
|
|
43
|
+
rowSpacing: _propTypes.default.oneOf(['none', 'small', 'medium', 'large']),
|
|
44
|
+
colSpacing: _propTypes.default.oneOf(['none', 'small', 'medium', 'large']),
|
|
45
|
+
hAlign: _propTypes.default.oneOf(['start', 'center', 'end', 'space-around', 'space-between']),
|
|
46
|
+
vAlign: _propTypes.default.oneOf(['top', 'middle', 'bottom']),
|
|
47
|
+
startAt: _propTypes.default.oneOf(['small', 'medium', 'large', 'x-large', null]),
|
|
48
|
+
visualDebug: _propTypes.default.bool,
|
|
49
|
+
isLastRow: _propTypes.default.bool
|
|
50
|
+
};
|
|
51
|
+
exports.propTypes = propTypes;
|
|
52
|
+
const allowedProps = ['children', 'rowSpacing', 'colSpacing', 'hAlign', 'vAlign', 'startAt', 'visualDebug', 'isLastRow'];
|
|
53
|
+
exports.allowedProps = allowedProps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-grid",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.9.0",
|
|
4
4
|
"description": "A Grid component.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -25,20 +25,20 @@
|
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@babel/runtime": "^7.13.10",
|
|
28
|
-
"@instructure/emotion": "8.
|
|
29
|
-
"@instructure/
|
|
30
|
-
"@instructure/ui-
|
|
31
|
-
"@instructure/ui-
|
|
32
|
-
"@instructure/ui-
|
|
33
|
-
"@instructure/ui-
|
|
28
|
+
"@instructure/emotion": "8.9.0",
|
|
29
|
+
"@instructure/shared-types": "8.9.0",
|
|
30
|
+
"@instructure/ui-a11y-content": "8.9.0",
|
|
31
|
+
"@instructure/ui-prop-types": "8.9.0",
|
|
32
|
+
"@instructure/ui-react-utils": "8.9.0",
|
|
33
|
+
"@instructure/ui-testable": "8.9.0",
|
|
34
|
+
"@instructure/ui-utils": "8.9.0",
|
|
34
35
|
"prop-types": "^15"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"@instructure/
|
|
38
|
-
"@instructure/ui-
|
|
39
|
-
"@instructure/ui-
|
|
40
|
-
"@instructure/ui-
|
|
41
|
-
"@instructure/ui-themes": "8.8.1-snapshot.3+d5d6d4cd8"
|
|
38
|
+
"@instructure/ui-babel-preset": "8.9.0",
|
|
39
|
+
"@instructure/ui-color-utils": "8.9.0",
|
|
40
|
+
"@instructure/ui-test-utils": "8.9.0",
|
|
41
|
+
"@instructure/ui-themes": "8.9.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": ">=16.8 <=17"
|
|
@@ -46,6 +46,5 @@
|
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
|
-
"sideEffects": false
|
|
50
|
-
"gitHead": "d5d6d4cd8f300e8635c69248f5d794c002269e08"
|
|
49
|
+
"sideEffects": false
|
|
51
50
|
}
|
package/src/Grid/index.tsx
CHANGED
|
@@ -24,16 +24,13 @@
|
|
|
24
24
|
|
|
25
25
|
/** @jsx jsx */
|
|
26
26
|
import { Component, Children, ReactElement } from 'react'
|
|
27
|
-
import PropTypes from 'prop-types'
|
|
28
27
|
|
|
29
|
-
import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types'
|
|
30
28
|
import {
|
|
31
29
|
safeCloneElement,
|
|
32
30
|
matchComponentTypes,
|
|
33
31
|
omitProps,
|
|
34
32
|
pickProps
|
|
35
33
|
} from '@instructure/ui-react-utils'
|
|
36
|
-
import { ScreenReaderContent } from '@instructure/ui-a11y-content'
|
|
37
34
|
|
|
38
35
|
import { GridRow } from '../GridRow'
|
|
39
36
|
import { GridCol } from '../GridCol'
|
|
@@ -42,7 +39,9 @@ import { withStyle, jsx } from '@instructure/emotion'
|
|
|
42
39
|
|
|
43
40
|
import generateStyle from './styles'
|
|
44
41
|
import generateComponentTheme from './theme'
|
|
45
|
-
|
|
42
|
+
|
|
43
|
+
import { propTypes, allowedProps } from './props'
|
|
44
|
+
import type { GridProps } from './props'
|
|
46
45
|
|
|
47
46
|
/**
|
|
48
47
|
---
|
|
@@ -53,26 +52,8 @@ category: components
|
|
|
53
52
|
class Grid extends Component<GridProps> {
|
|
54
53
|
static readonly componentId = 'Grid'
|
|
55
54
|
|
|
56
|
-
static propTypes =
|
|
57
|
-
|
|
58
|
-
makeStyles: PropTypes.func,
|
|
59
|
-
// eslint-disable-next-line react/require-default-props
|
|
60
|
-
styles: PropTypes.object,
|
|
61
|
-
children: ChildrenPropTypes.oneOf([GridRow, ScreenReaderContent]),
|
|
62
|
-
colSpacing: PropTypes.oneOf(['none', 'small', 'medium', 'large']),
|
|
63
|
-
rowSpacing: PropTypes.oneOf(['none', 'small', 'medium', 'large']),
|
|
64
|
-
hAlign: PropTypes.oneOf([
|
|
65
|
-
'start',
|
|
66
|
-
'center',
|
|
67
|
-
'end',
|
|
68
|
-
'space-around',
|
|
69
|
-
'space-between'
|
|
70
|
-
]),
|
|
71
|
-
vAlign: PropTypes.oneOf(['top', 'middle', 'bottom']),
|
|
72
|
-
startAt: PropTypes.oneOf(['small', 'medium', 'large', 'x-large', null]),
|
|
73
|
-
visualDebug: PropTypes.bool
|
|
74
|
-
}
|
|
75
|
-
|
|
55
|
+
static propTypes = propTypes
|
|
56
|
+
static allowedProps = allowedProps
|
|
76
57
|
static defaultProps = {
|
|
77
58
|
colSpacing: 'medium',
|
|
78
59
|
rowSpacing: 'medium',
|
|
@@ -121,7 +102,7 @@ class Grid extends Component<GridProps> {
|
|
|
121
102
|
const props = omitProps(restProps, Grid.propTypes)
|
|
122
103
|
|
|
123
104
|
return (
|
|
124
|
-
<span {...props} css={styles
|
|
105
|
+
<span {...props} css={styles?.grid}>
|
|
125
106
|
{this.renderChildren()}
|
|
126
107
|
</span>
|
|
127
108
|
)
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
import PropTypes from 'prop-types'
|
|
26
|
+
|
|
27
|
+
import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types'
|
|
28
|
+
import { ScreenReaderContent } from '@instructure/ui-a11y-content'
|
|
29
|
+
import { GridRow } from '../GridRow'
|
|
30
|
+
|
|
31
|
+
import type { PropValidators } from '@instructure/shared-types'
|
|
32
|
+
import type { WithStyleProps } from '@instructure/emotion'
|
|
33
|
+
import type { GridBreakpoints } from '../GridTypes'
|
|
34
|
+
|
|
35
|
+
type GridOwnProps = {
|
|
36
|
+
children?: React.ReactNode // TODO: oneOf([GridRow, ScreenReaderContent])
|
|
37
|
+
colSpacing?: 'none' | 'small' | 'medium' | 'large'
|
|
38
|
+
rowSpacing?: 'none' | 'small' | 'medium' | 'large'
|
|
39
|
+
hAlign?: 'start' | 'center' | 'end' | 'space-around' | 'space-between'
|
|
40
|
+
vAlign?: 'top' | 'middle' | 'bottom'
|
|
41
|
+
startAt?: GridBreakpoints
|
|
42
|
+
visualDebug?: boolean
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type PropKeys = keyof GridOwnProps
|
|
46
|
+
|
|
47
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
48
|
+
|
|
49
|
+
type GridProps = GridOwnProps & WithStyleProps
|
|
50
|
+
|
|
51
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
52
|
+
children: ChildrenPropTypes.oneOf([GridRow, ScreenReaderContent]),
|
|
53
|
+
colSpacing: PropTypes.oneOf(['none', 'small', 'medium', 'large']),
|
|
54
|
+
rowSpacing: PropTypes.oneOf(['none', 'small', 'medium', 'large']),
|
|
55
|
+
hAlign: PropTypes.oneOf([
|
|
56
|
+
'start',
|
|
57
|
+
'center',
|
|
58
|
+
'end',
|
|
59
|
+
'space-around',
|
|
60
|
+
'space-between'
|
|
61
|
+
]),
|
|
62
|
+
vAlign: PropTypes.oneOf(['top', 'middle', 'bottom']),
|
|
63
|
+
startAt: PropTypes.oneOf(['small', 'medium', 'large', 'x-large', null]),
|
|
64
|
+
visualDebug: PropTypes.bool
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const allowedProps: AllowedPropKeys = [
|
|
68
|
+
'children',
|
|
69
|
+
'colSpacing',
|
|
70
|
+
'rowSpacing',
|
|
71
|
+
'hAlign',
|
|
72
|
+
'vAlign',
|
|
73
|
+
'startAt',
|
|
74
|
+
'visualDebug'
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
export type { GridProps }
|
|
78
|
+
export { propTypes, allowedProps }
|
package/src/Grid/styles.ts
CHANGED
package/src/GridCol/index.tsx
CHANGED
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
|
|
25
25
|
/** @jsx jsx */
|
|
26
26
|
import { Component } from 'react'
|
|
27
|
-
import PropTypes from 'prop-types'
|
|
28
27
|
|
|
29
28
|
import { omitProps } from '@instructure/ui-react-utils'
|
|
30
29
|
|
|
@@ -32,10 +31,9 @@ import { withStyle, jsx } from '@instructure/emotion'
|
|
|
32
31
|
|
|
33
32
|
import generateStyle from './styles'
|
|
34
33
|
import generateComponentTheme from './theme'
|
|
35
|
-
import { GridColProps } from './types'
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
import { propTypes, allowedProps } from './props'
|
|
36
|
+
import type { GridColProps } from './props'
|
|
39
37
|
|
|
40
38
|
/**
|
|
41
39
|
---
|
|
@@ -47,56 +45,13 @@ id: Grid.Col
|
|
|
47
45
|
class GridCol extends Component<GridColProps> {
|
|
48
46
|
static readonly componentId = 'Grid.Col'
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
static
|
|
52
|
-
// eslint-disable-next-line react/require-default-props
|
|
53
|
-
makeStyles: PropTypes.func,
|
|
54
|
-
// eslint-disable-next-line react/require-default-props
|
|
55
|
-
styles: PropTypes.object,
|
|
56
|
-
children: PropTypes.node,
|
|
57
|
-
colSpacing: PropTypes.oneOf(['none', 'small', 'medium', 'large']),
|
|
58
|
-
rowSpacing: PropTypes.oneOf(['none', 'small', 'medium', 'large']),
|
|
59
|
-
textAlign: PropTypes.oneOf(['start', 'end', 'center', 'inherit']),
|
|
60
|
-
hAlign: PropTypes.oneOf([
|
|
61
|
-
'start',
|
|
62
|
-
'center',
|
|
63
|
-
'end',
|
|
64
|
-
'space-around',
|
|
65
|
-
'space-between'
|
|
66
|
-
]),
|
|
67
|
-
vAlign: PropTypes.oneOf(['top', 'middle', 'bottom']),
|
|
68
|
-
startAt: PropTypes.oneOf(['small', 'medium', 'large', 'x-large', null]),
|
|
69
|
-
visualDebug: PropTypes.bool,
|
|
70
|
-
width: PropTypes.oneOfType([
|
|
71
|
-
PropTypes.oneOf(COL_WIDTHS),
|
|
72
|
-
PropTypes.shape({
|
|
73
|
-
small: PropTypes.oneOf(COL_WIDTHS),
|
|
74
|
-
medium: PropTypes.oneOf(COL_WIDTHS),
|
|
75
|
-
large: PropTypes.oneOf(COL_WIDTHS),
|
|
76
|
-
xLarge: PropTypes.oneOf(COL_WIDTHS)
|
|
77
|
-
})
|
|
78
|
-
]),
|
|
79
|
-
offset: PropTypes.oneOfType([
|
|
80
|
-
PropTypes.oneOf(COL_WIDTHS),
|
|
81
|
-
PropTypes.shape({
|
|
82
|
-
small: PropTypes.oneOf(COL_WIDTHS),
|
|
83
|
-
medium: PropTypes.oneOf(COL_WIDTHS),
|
|
84
|
-
large: PropTypes.oneOf(COL_WIDTHS),
|
|
85
|
-
xLarge: PropTypes.oneOf(COL_WIDTHS)
|
|
86
|
-
})
|
|
87
|
-
]),
|
|
88
|
-
isLastRow: PropTypes.bool,
|
|
89
|
-
isLastCol: PropTypes.bool,
|
|
90
|
-
elementRef: PropTypes.func
|
|
91
|
-
}
|
|
92
|
-
/* eslint-enable react/require-default-props */
|
|
93
|
-
|
|
48
|
+
static propTypes = propTypes
|
|
49
|
+
static allowedProps = allowedProps
|
|
94
50
|
static defaultProps = {
|
|
95
51
|
textAlign: 'inherit',
|
|
96
52
|
children: null,
|
|
97
53
|
isLastCol: false,
|
|
98
|
-
isLastRow: false
|
|
99
|
-
elementRef: undefined
|
|
54
|
+
isLastRow: false
|
|
100
55
|
}
|
|
101
56
|
|
|
102
57
|
componentDidMount() {
|
|
@@ -116,7 +71,7 @@ class GridCol extends Component<GridColProps> {
|
|
|
116
71
|
const props = omitProps(this.props, GridCol.propTypes)
|
|
117
72
|
|
|
118
73
|
return (
|
|
119
|
-
<span {...props} ref={this.props.elementRef} css={styles
|
|
74
|
+
<span {...props} ref={this.props.elementRef} css={styles?.gridCol}>
|
|
120
75
|
{children}
|
|
121
76
|
</span>
|
|
122
77
|
)
|