@instructure/ui-table 8.14.1-snapshot.63 → 8.14.1-snapshot.66
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/es/Table/Head/index.js +6 -6
- package/es/Table/index.js +7 -7
- package/lib/Table/Head/index.js +8 -10
- package/lib/Table/index.js +7 -9
- package/package.json +17 -17
- package/src/Table/Body/index.tsx +11 -13
- package/src/Table/Head/index.tsx +10 -18
- package/src/Table/Row/index.tsx +16 -9
- package/src/Table/index.tsx +34 -28
- package/src/Table/props.ts +31 -4
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Table/Body/index.d.ts.map +1 -1
- package/types/Table/Head/index.d.ts +5 -5
- package/types/Table/Head/index.d.ts.map +1 -1
- package/types/Table/Row/index.d.ts.map +1 -1
- package/types/Table/index.d.ts +6 -6
- package/types/Table/index.d.ts.map +1 -1
- package/types/Table/props.d.ts +19 -1
- package/types/Table/props.d.ts.map +1 -1
package/es/Table/Head/index.js
CHANGED
@@ -27,7 +27,7 @@ var _dec, _class, _class2, _temp, _ScreenReaderContent;
|
|
27
27
|
*/
|
28
28
|
|
29
29
|
/** @jsx jsx */
|
30
|
-
import
|
30
|
+
import { Component, Children } from 'react';
|
31
31
|
import { omitProps, matchComponentTypes, callRenderProp } from '@instructure/ui-react-utils';
|
32
32
|
import { SimpleSelect } from '@instructure/ui-simple-select';
|
33
33
|
import { ScreenReaderContent } from '@instructure/ui-a11y-content';
|
@@ -103,11 +103,11 @@ let Head = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class
|
|
103
103
|
count += 1;
|
104
104
|
|
105
105
|
if (matchComponentTypes(colHeader, [ColHeader])) {
|
106
|
-
const
|
107
|
-
id =
|
108
|
-
stackedSortByLabel =
|
109
|
-
sortDirection =
|
110
|
-
onRequestSort =
|
106
|
+
const _colHeader$props = colHeader.props,
|
107
|
+
id = _colHeader$props.id,
|
108
|
+
stackedSortByLabel = _colHeader$props.stackedSortByLabel,
|
109
|
+
sortDirection = _colHeader$props.sortDirection,
|
110
|
+
onRequestSort = _colHeader$props.onRequestSort;
|
111
111
|
const label = stackedSortByLabel || id;
|
112
112
|
|
113
113
|
if (onRequestSort) {
|
package/es/Table/index.js
CHANGED
@@ -27,7 +27,7 @@ var _dec, _class, _class2, _temp;
|
|
27
27
|
*/
|
28
28
|
|
29
29
|
/** @jsx jsx */
|
30
|
-
import
|
30
|
+
import { Component, Children } from 'react';
|
31
31
|
import { matchComponentTypes, safeCloneElement, omitProps } from '@instructure/ui-react-utils';
|
32
32
|
import { View } from '@instructure/ui-view';
|
33
33
|
import { ScreenReaderContent } from '@instructure/ui-a11y-content';
|
@@ -83,18 +83,18 @@ let Table = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_clas
|
|
83
83
|
head = _ref2[0];
|
84
84
|
|
85
85
|
if (matchComponentTypes(head, [Head])) {
|
86
|
-
const
|
87
|
-
|
88
|
-
row =
|
86
|
+
const _Children$toArray = Children.toArray(head.props.children),
|
87
|
+
_Children$toArray2 = _slicedToArray(_Children$toArray, 1),
|
88
|
+
row = _Children$toArray2[0];
|
89
89
|
|
90
90
|
if (matchComponentTypes(row, [Row])) {
|
91
91
|
return Children.map(row.props.children, colHeader => {
|
92
|
-
return matchComponentTypes(colHeader, [ColHeader]) ? colHeader.props.children :
|
92
|
+
return matchComponentTypes(colHeader, [ColHeader]) ? colHeader.props.children : void 0;
|
93
93
|
});
|
94
94
|
}
|
95
95
|
}
|
96
96
|
|
97
|
-
return
|
97
|
+
return void 0;
|
98
98
|
}
|
99
99
|
|
100
100
|
render() {
|
@@ -106,7 +106,7 @@ let Table = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_clas
|
|
106
106
|
hover = _this$props3.hover,
|
107
107
|
styles = _this$props3.styles;
|
108
108
|
const isStacked = layout === 'stacked';
|
109
|
-
const headers = isStacked ? this.getHeaders() :
|
109
|
+
const headers = isStacked ? this.getHeaders() : void 0;
|
110
110
|
return jsx(View, Object.assign({}, View.omitViewProps(omitProps(this.props, Table.allowedProps), Table), {
|
111
111
|
as: isStacked ? 'div' : 'table',
|
112
112
|
margin: margin,
|
package/lib/Table/Head/index.js
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
4
|
|
5
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
6
|
-
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
8
6
|
value: true
|
9
7
|
});
|
@@ -11,7 +9,7 @@ exports.default = exports.Head = void 0;
|
|
11
9
|
|
12
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
13
11
|
|
14
|
-
var _react =
|
12
|
+
var _react = require("react");
|
15
13
|
|
16
14
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
17
15
|
|
@@ -37,7 +35,7 @@ var _Row = require("../Row");
|
|
37
35
|
|
38
36
|
var _ColHeader = require("../ColHeader");
|
39
37
|
|
40
|
-
var
|
38
|
+
var _props = require("./props");
|
41
39
|
|
42
40
|
var _dec, _class, _class2, _temp, _ScreenReaderContent;
|
43
41
|
|
@@ -105,11 +103,11 @@ let Head = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
105
103
|
count += 1;
|
106
104
|
|
107
105
|
if ((0, _matchComponentTypes.matchComponentTypes)(colHeader, [_ColHeader.ColHeader])) {
|
108
|
-
const
|
109
|
-
id =
|
110
|
-
stackedSortByLabel =
|
111
|
-
sortDirection =
|
112
|
-
onRequestSort =
|
106
|
+
const _colHeader$props = colHeader.props,
|
107
|
+
id = _colHeader$props.id,
|
108
|
+
stackedSortByLabel = _colHeader$props.stackedSortByLabel,
|
109
|
+
sortDirection = _colHeader$props.sortDirection,
|
110
|
+
onRequestSort = _colHeader$props.onRequestSort;
|
113
111
|
const label = stackedSortByLabel || id;
|
114
112
|
|
115
113
|
if (onRequestSort) {
|
@@ -178,7 +176,7 @@ let Head = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
178
176
|
}), _react.Children.map(children, child => (0, _matchComponentTypes.matchComponentTypes)(child, [_Row.Row]) ? child : null));
|
179
177
|
}
|
180
178
|
|
181
|
-
}, _class2.displayName = "Head", _class2.componentId = 'Table.Head', _class2.allowedProps =
|
179
|
+
}, _class2.displayName = "Head", _class2.componentId = 'Table.Head', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
182
180
|
children: null
|
183
181
|
}, _temp)) || _class);
|
184
182
|
exports.Head = Head;
|
package/lib/Table/index.js
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
4
|
|
5
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
6
|
-
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
8
6
|
value: true
|
9
7
|
});
|
@@ -11,7 +9,7 @@ exports.default = exports.Table = void 0;
|
|
11
9
|
|
12
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
13
11
|
|
14
|
-
var _react =
|
12
|
+
var _react = require("react");
|
15
13
|
|
16
14
|
var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
|
17
15
|
|
@@ -86,18 +84,18 @@ let Table = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
|
|
86
84
|
head = _ref2[0];
|
87
85
|
|
88
86
|
if ((0, _matchComponentTypes.matchComponentTypes)(head, [_Head.Head])) {
|
89
|
-
const
|
90
|
-
|
91
|
-
row =
|
87
|
+
const _Children$toArray = _react.Children.toArray(head.props.children),
|
88
|
+
_Children$toArray2 = (0, _slicedToArray2.default)(_Children$toArray, 1),
|
89
|
+
row = _Children$toArray2[0];
|
92
90
|
|
93
91
|
if ((0, _matchComponentTypes.matchComponentTypes)(row, [_Row.Row])) {
|
94
92
|
return _react.Children.map(row.props.children, colHeader => {
|
95
|
-
return (0, _matchComponentTypes.matchComponentTypes)(colHeader, [_ColHeader.ColHeader]) ? colHeader.props.children :
|
93
|
+
return (0, _matchComponentTypes.matchComponentTypes)(colHeader, [_ColHeader.ColHeader]) ? colHeader.props.children : void 0;
|
96
94
|
});
|
97
95
|
}
|
98
96
|
}
|
99
97
|
|
100
|
-
return
|
98
|
+
return void 0;
|
101
99
|
}
|
102
100
|
|
103
101
|
render() {
|
@@ -109,7 +107,7 @@ let Table = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
|
|
109
107
|
hover = _this$props3.hover,
|
110
108
|
styles = _this$props3.styles;
|
111
109
|
const isStacked = layout === 'stacked';
|
112
|
-
const headers = isStacked ? this.getHeaders() :
|
110
|
+
const headers = isStacked ? this.getHeaders() : void 0;
|
113
111
|
return (0, _emotion.jsx)(_View.View, Object.assign({}, _View.View.omitViewProps((0, _omitProps.omitProps)(this.props, Table.allowedProps), Table), {
|
114
112
|
as: isStacked ? 'div' : 'table',
|
115
113
|
margin: margin,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@instructure/ui-table",
|
3
|
-
"version": "8.14.1-snapshot.
|
3
|
+
"version": "8.14.1-snapshot.66+ff0decd44",
|
4
4
|
"description": "A styled HTML table component",
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
6
6
|
"type": "commonjs",
|
@@ -24,24 +24,24 @@
|
|
24
24
|
},
|
25
25
|
"license": "MIT",
|
26
26
|
"devDependencies": {
|
27
|
-
"@instructure/ui-babel-preset": "8.14.1-snapshot.
|
28
|
-
"@instructure/ui-color-utils": "8.14.1-snapshot.
|
29
|
-
"@instructure/ui-test-utils": "8.14.1-snapshot.
|
30
|
-
"@instructure/ui-themes": "8.14.1-snapshot.
|
27
|
+
"@instructure/ui-babel-preset": "8.14.1-snapshot.66+ff0decd44",
|
28
|
+
"@instructure/ui-color-utils": "8.14.1-snapshot.66+ff0decd44",
|
29
|
+
"@instructure/ui-test-utils": "8.14.1-snapshot.66+ff0decd44",
|
30
|
+
"@instructure/ui-themes": "8.14.1-snapshot.66+ff0decd44"
|
31
31
|
},
|
32
32
|
"dependencies": {
|
33
33
|
"@babel/runtime": "^7.13.10",
|
34
|
-
"@instructure/console": "8.14.1-snapshot.
|
35
|
-
"@instructure/emotion": "8.14.1-snapshot.
|
36
|
-
"@instructure/shared-types": "8.14.1-snapshot.
|
37
|
-
"@instructure/ui-a11y-content": "8.14.1-snapshot.
|
38
|
-
"@instructure/ui-icons": "8.14.1-snapshot.
|
39
|
-
"@instructure/ui-prop-types": "8.14.1-snapshot.
|
40
|
-
"@instructure/ui-react-utils": "8.14.1-snapshot.
|
41
|
-
"@instructure/ui-simple-select": "8.14.1-snapshot.
|
42
|
-
"@instructure/ui-testable": "8.14.1-snapshot.
|
43
|
-
"@instructure/ui-utils": "8.14.1-snapshot.
|
44
|
-
"@instructure/ui-view": "8.14.1-snapshot.
|
34
|
+
"@instructure/console": "8.14.1-snapshot.66+ff0decd44",
|
35
|
+
"@instructure/emotion": "8.14.1-snapshot.66+ff0decd44",
|
36
|
+
"@instructure/shared-types": "8.14.1-snapshot.66+ff0decd44",
|
37
|
+
"@instructure/ui-a11y-content": "8.14.1-snapshot.66+ff0decd44",
|
38
|
+
"@instructure/ui-icons": "8.14.1-snapshot.66+ff0decd44",
|
39
|
+
"@instructure/ui-prop-types": "8.14.1-snapshot.66+ff0decd44",
|
40
|
+
"@instructure/ui-react-utils": "8.14.1-snapshot.66+ff0decd44",
|
41
|
+
"@instructure/ui-simple-select": "8.14.1-snapshot.66+ff0decd44",
|
42
|
+
"@instructure/ui-testable": "8.14.1-snapshot.66+ff0decd44",
|
43
|
+
"@instructure/ui-utils": "8.14.1-snapshot.66+ff0decd44",
|
44
|
+
"@instructure/ui-view": "8.14.1-snapshot.66+ff0decd44",
|
45
45
|
"prop-types": "^15"
|
46
46
|
},
|
47
47
|
"peerDependencies": {
|
@@ -51,5 +51,5 @@
|
|
51
51
|
"access": "public"
|
52
52
|
},
|
53
53
|
"sideEffects": false,
|
54
|
-
"gitHead": "
|
54
|
+
"gitHead": "ff0decd44fd390bd7f50885610373d2c9c793053"
|
55
55
|
}
|
package/src/Table/Body/index.tsx
CHANGED
@@ -23,7 +23,7 @@
|
|
23
23
|
*/
|
24
24
|
|
25
25
|
/** @jsx jsx */
|
26
|
-
import { Component, Children
|
26
|
+
import { Component, Children } from 'react'
|
27
27
|
|
28
28
|
import {
|
29
29
|
matchComponentTypes,
|
@@ -37,7 +37,7 @@ import generateStyle from './styles'
|
|
37
37
|
import generateComponentTheme from './theme'
|
38
38
|
import { Row } from '../Row'
|
39
39
|
import type { TableBodyProps } from './props'
|
40
|
-
import type {
|
40
|
+
import type { RowChild } from '../props'
|
41
41
|
import { allowedProps, propTypes } from './props'
|
42
42
|
|
43
43
|
/**
|
@@ -76,17 +76,15 @@ class Body extends Component<TableBodyProps> {
|
|
76
76
|
css={styles?.body}
|
77
77
|
role={isStacked ? 'rowgroup' : undefined}
|
78
78
|
>
|
79
|
-
{Children.map(
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
})
|
89
|
-
: null
|
79
|
+
{Children.map(children as RowChild[], (child) =>
|
80
|
+
matchComponentTypes(child, [Row])
|
81
|
+
? safeCloneElement(child, {
|
82
|
+
key: child.props.name,
|
83
|
+
hover,
|
84
|
+
isStacked,
|
85
|
+
headers
|
86
|
+
})
|
87
|
+
: null
|
90
88
|
)}
|
91
89
|
</View>
|
92
90
|
)
|
package/src/Table/Head/index.tsx
CHANGED
@@ -23,7 +23,7 @@
|
|
23
23
|
*/
|
24
24
|
|
25
25
|
/** @jsx jsx */
|
26
|
-
import
|
26
|
+
import { Component, Children } from 'react'
|
27
27
|
|
28
28
|
import {
|
29
29
|
omitProps,
|
@@ -45,7 +45,7 @@ import { Row } from '../Row'
|
|
45
45
|
import { ColHeader } from '../ColHeader'
|
46
46
|
import type { TableColHeaderProps } from '../ColHeader/props'
|
47
47
|
import type { TableHeadProps } from './props'
|
48
|
-
import type {
|
48
|
+
import type { ColHeaderChild, RowChild } from '../props'
|
49
49
|
import { allowedProps, propTypes } from './props'
|
50
50
|
|
51
51
|
/**
|
@@ -67,19 +67,14 @@ class Head extends Component<TableHeadProps> {
|
|
67
67
|
}
|
68
68
|
|
69
69
|
get isSortable() {
|
70
|
-
const [row] = Children.toArray(
|
71
|
-
this.props.children
|
72
|
-
) as React.ComponentElement<TableRowProps, Row>[]
|
70
|
+
const [row] = Children.toArray(this.props.children) as RowChild[]
|
73
71
|
let sortable = false
|
74
72
|
|
75
73
|
if (row) {
|
76
74
|
Children.forEach(
|
77
|
-
row.props.children as
|
78
|
-
TableColHeaderProps,
|
79
|
-
ColHeader
|
80
|
-
>[],
|
75
|
+
row.props.children as ColHeaderChild[],
|
81
76
|
(colHeader) => {
|
82
|
-
if (matchComponentTypes(colHeader, [ColHeader])) {
|
77
|
+
if (matchComponentTypes<ColHeaderChild>(colHeader, [ColHeader])) {
|
83
78
|
if (colHeader.props.onRequestSort) sortable = true
|
84
79
|
}
|
85
80
|
}
|
@@ -105,12 +100,9 @@ class Head extends Component<TableHeadProps> {
|
|
105
100
|
|
106
101
|
renderSelect() {
|
107
102
|
const { children, renderSortLabel } = this.props
|
108
|
-
const [row] = Children.toArray(children) as
|
109
|
-
TableRowProps,
|
110
|
-
Row
|
111
|
-
>[]
|
103
|
+
const [row] = Children.toArray(children) as RowChild[]
|
112
104
|
|
113
|
-
if (!matchComponentTypes(row, [Row])) {
|
105
|
+
if (!matchComponentTypes<RowChild>(row, [Row])) {
|
114
106
|
return null
|
115
107
|
}
|
116
108
|
const options: {
|
@@ -128,9 +120,9 @@ class Head extends Component<TableHeadProps> {
|
|
128
120
|
|
129
121
|
Children.forEach(row.props.children, (colHeader) => {
|
130
122
|
count += 1
|
131
|
-
if (matchComponentTypes(colHeader, [ColHeader])) {
|
123
|
+
if (matchComponentTypes<ColHeaderChild>(colHeader, [ColHeader])) {
|
132
124
|
const { id, stackedSortByLabel, sortDirection, onRequestSort } = (
|
133
|
-
colHeader
|
125
|
+
colHeader
|
134
126
|
).props
|
135
127
|
|
136
128
|
const label = stackedSortByLabel || id
|
@@ -197,7 +189,7 @@ class Head extends Component<TableHeadProps> {
|
|
197
189
|
) : (
|
198
190
|
<thead {...omitProps(this.props, Head.allowedProps)} css={styles?.head}>
|
199
191
|
{Children.map(children, (child) =>
|
200
|
-
matchComponentTypes(child, [Row]) ? child : null
|
192
|
+
matchComponentTypes<RowChild>(child, [Row]) ? child : null
|
201
193
|
)}
|
202
194
|
</thead>
|
203
195
|
)
|
package/src/Table/Row/index.tsx
CHANGED
@@ -23,7 +23,7 @@
|
|
23
23
|
*/
|
24
24
|
|
25
25
|
/** @jsx jsx */
|
26
|
-
import { Component, Children
|
26
|
+
import { Component, Children } from 'react'
|
27
27
|
|
28
28
|
import {
|
29
29
|
omitProps,
|
@@ -41,6 +41,7 @@ import { ColHeader } from '../ColHeader'
|
|
41
41
|
import { RowHeader } from '../RowHeader'
|
42
42
|
import { Cell } from '../Cell'
|
43
43
|
import type { TableRowProps } from './props'
|
44
|
+
import type { ColHeaderChild, RowHeaderChild, CellChild } from '../props'
|
44
45
|
import { allowedProps, propTypes } from './props'
|
45
46
|
|
46
47
|
/**
|
@@ -79,21 +80,27 @@ class Row extends Component<TableRowProps> {
|
|
79
80
|
css={styles?.row}
|
80
81
|
role={isStacked ? 'row' : undefined}
|
81
82
|
>
|
82
|
-
{
|
83
|
+
{(
|
84
|
+
Children.toArray(children) as (
|
85
|
+
| ColHeaderChild
|
86
|
+
| RowHeaderChild
|
87
|
+
| CellChild
|
88
|
+
)[]
|
89
|
+
)
|
83
90
|
.filter(Boolean)
|
84
91
|
.map((child, index) => {
|
85
|
-
if (matchComponentTypes(child, [ColHeader])) {
|
92
|
+
if (matchComponentTypes<ColHeaderChild>(child, [ColHeader])) {
|
86
93
|
return child
|
87
94
|
}
|
88
|
-
if (matchComponentTypes(child, [RowHeader])) {
|
89
|
-
return safeCloneElement(child
|
90
|
-
key:
|
95
|
+
if (matchComponentTypes<RowHeaderChild>(child, [RowHeader])) {
|
96
|
+
return safeCloneElement(child, {
|
97
|
+
key: child.props.name,
|
91
98
|
isStacked
|
92
99
|
})
|
93
100
|
}
|
94
|
-
if (matchComponentTypes(child, [Cell])) {
|
95
|
-
return safeCloneElement(child
|
96
|
-
key:
|
101
|
+
if (matchComponentTypes<CellChild>(child, [Cell])) {
|
102
|
+
return safeCloneElement(child, {
|
103
|
+
key: child.props.name,
|
97
104
|
isStacked,
|
98
105
|
header: headers && headers[index]
|
99
106
|
})
|
package/src/Table/index.tsx
CHANGED
@@ -23,7 +23,7 @@
|
|
23
23
|
*/
|
24
24
|
|
25
25
|
/** @jsx jsx */
|
26
|
-
import
|
26
|
+
import { Component, Children } from 'react'
|
27
27
|
|
28
28
|
import {
|
29
29
|
matchComponentTypes,
|
@@ -44,9 +44,17 @@ import { Row } from './Row'
|
|
44
44
|
import { ColHeader } from './ColHeader'
|
45
45
|
import { RowHeader } from './RowHeader'
|
46
46
|
import { Cell } from './Cell'
|
47
|
-
|
48
|
-
import type {
|
49
|
-
|
47
|
+
|
48
|
+
import type {
|
49
|
+
TableProps,
|
50
|
+
HeadChild,
|
51
|
+
BodyChild,
|
52
|
+
RowChild,
|
53
|
+
ColHeaderChild,
|
54
|
+
RowHeaderChild,
|
55
|
+
CellChild
|
56
|
+
} from './props'
|
57
|
+
|
50
58
|
import { allowedProps, propTypes } from './props'
|
51
59
|
|
52
60
|
/**
|
@@ -97,31 +105,29 @@ class Table extends Component<TableProps> {
|
|
97
105
|
|
98
106
|
getHeaders() {
|
99
107
|
const { children } = this.props
|
100
|
-
const [head] = Children.toArray(children) as
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
: null
|
115
|
-
})
|
108
|
+
const [head] = Children.toArray(children) as HeadChild[]
|
109
|
+
|
110
|
+
if (matchComponentTypes<HeadChild>(head, [Head])) {
|
111
|
+
const [row] = Children.toArray(head.props.children)
|
112
|
+
|
113
|
+
if (matchComponentTypes<RowChild>(row, [Row])) {
|
114
|
+
return Children.map(
|
115
|
+
row.props.children as (ColHeaderChild | RowHeaderChild | CellChild)[],
|
116
|
+
(colHeader) => {
|
117
|
+
return matchComponentTypes<ColHeaderChild>(colHeader, [ColHeader])
|
118
|
+
? colHeader.props.children
|
119
|
+
: undefined
|
120
|
+
}
|
121
|
+
)
|
116
122
|
}
|
117
123
|
}
|
118
|
-
return
|
124
|
+
return undefined
|
119
125
|
}
|
120
126
|
|
121
127
|
render() {
|
122
128
|
const { margin, layout, caption, children, hover, styles } = this.props
|
123
129
|
const isStacked = layout === 'stacked'
|
124
|
-
const headers = isStacked ? this.getHeaders() :
|
130
|
+
const headers = isStacked ? this.getHeaders() : undefined
|
125
131
|
|
126
132
|
return (
|
127
133
|
<View
|
@@ -142,15 +148,15 @@ class Table extends Component<TableProps> {
|
|
142
148
|
</caption>
|
143
149
|
)}
|
144
150
|
{Children.map(children, (child) => {
|
145
|
-
if (matchComponentTypes(child, [Head])) {
|
146
|
-
return safeCloneElement(child
|
147
|
-
key:
|
151
|
+
if (matchComponentTypes<HeadChild>(child, [Head])) {
|
152
|
+
return safeCloneElement(child, {
|
153
|
+
key: child.props.name,
|
148
154
|
isStacked
|
149
155
|
})
|
150
156
|
}
|
151
|
-
if (matchComponentTypes(child, [Body])) {
|
152
|
-
return safeCloneElement(child
|
153
|
-
key:
|
157
|
+
if (matchComponentTypes<BodyChild>(child, [Body])) {
|
158
|
+
return safeCloneElement(child, {
|
159
|
+
key: child.props.name,
|
154
160
|
isStacked,
|
155
161
|
hover,
|
156
162
|
headers
|
package/src/Table/props.ts
CHANGED
@@ -27,9 +27,6 @@ import PropTypes from 'prop-types'
|
|
27
27
|
import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types'
|
28
28
|
import { ThemeablePropTypes } from '@instructure/emotion'
|
29
29
|
|
30
|
-
import { Head } from './Head'
|
31
|
-
import { Body } from './Body'
|
32
|
-
|
33
30
|
import type {
|
34
31
|
Spacing,
|
35
32
|
WithStyleProps,
|
@@ -41,6 +38,26 @@ import type {
|
|
41
38
|
TableTheme
|
42
39
|
} from '@instructure/shared-types'
|
43
40
|
|
41
|
+
import { Head } from './Head'
|
42
|
+
import type { TableHeadProps } from './Head/props'
|
43
|
+
import { Body } from './Body'
|
44
|
+
import type { TableBodyProps } from './Body/props'
|
45
|
+
import { Row } from './Row'
|
46
|
+
import type { TableRowProps } from './Row/props'
|
47
|
+
import { ColHeader } from './ColHeader'
|
48
|
+
import type { TableColHeaderProps } from './ColHeader/props'
|
49
|
+
import { RowHeader } from './RowHeader'
|
50
|
+
import type { TableRowHeaderProps } from './RowHeader/props'
|
51
|
+
import { Cell } from './Cell'
|
52
|
+
import type { TableCellProps } from './Cell/props'
|
53
|
+
|
54
|
+
type HeadChild = React.ComponentElement<TableHeadProps, Head>
|
55
|
+
type BodyChild = React.ComponentElement<TableBodyProps, Body>
|
56
|
+
type RowChild = React.ComponentElement<TableRowProps, Row>
|
57
|
+
type ColHeaderChild = React.ComponentElement<TableColHeaderProps, ColHeader>
|
58
|
+
type RowHeaderChild = React.ComponentElement<TableRowHeaderProps, RowHeader>
|
59
|
+
type CellChild = React.ComponentElement<TableCellProps, Cell>
|
60
|
+
|
44
61
|
type TableOwnProps = {
|
45
62
|
/**
|
46
63
|
* Provide a screen reader friendly description. Anything passed to this
|
@@ -101,5 +118,15 @@ const allowedProps: AllowedPropKeys = [
|
|
101
118
|
'layout'
|
102
119
|
]
|
103
120
|
|
104
|
-
export type {
|
121
|
+
export type {
|
122
|
+
TableProps,
|
123
|
+
TableStyle,
|
124
|
+
// children
|
125
|
+
HeadChild,
|
126
|
+
BodyChild,
|
127
|
+
RowChild,
|
128
|
+
ColHeaderChild,
|
129
|
+
RowHeaderChild,
|
130
|
+
CellChild
|
131
|
+
}
|
105
132
|
export { propTypes, allowedProps }
|