@instructure/ui-table 11.7.3-snapshot-7 → 11.7.3-snapshot-26
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 +5 -2
- package/es/Table/v1/Body/index.js +21 -15
- package/es/Table/v1/Body/theme.js +9 -8
- package/es/Table/v1/Cell/index.js +20 -16
- package/es/Table/v1/Cell/styles.js +3 -1
- package/es/Table/v1/Cell/theme.js +13 -12
- package/es/Table/v1/ColHeader/index.js +43 -41
- package/es/Table/v1/ColHeader/styles.js +4 -2
- package/es/Table/v1/ColHeader/theme.js +19 -18
- package/es/Table/v1/Head/index.js +34 -34
- package/es/Table/v1/Head/theme.js +9 -8
- package/es/Table/v1/Row/index.js +18 -14
- package/es/Table/v1/Row/styles.js +4 -2
- package/es/Table/v1/Row/theme.js +14 -13
- package/es/Table/v1/RowHeader/index.js +19 -15
- package/es/Table/v1/RowHeader/styles.js +3 -1
- package/es/Table/v1/RowHeader/theme.js +13 -12
- package/es/Table/v1/index.js +50 -55
- package/es/Table/v1/styles.js +3 -1
- package/es/Table/v1/theme.js +10 -9
- package/es/Table/v2/Body/index.js +21 -15
- package/es/Table/v2/Cell/index.js +20 -16
- package/es/Table/v2/Cell/styles.js +3 -1
- package/es/Table/v2/ColHeader/index.js +45 -43
- package/es/Table/v2/ColHeader/styles.js +4 -2
- package/es/Table/v2/Head/index.js +37 -37
- package/es/Table/v2/Row/index.js +18 -14
- package/es/Table/v2/Row/styles.js +4 -2
- package/es/Table/v2/RowHeader/index.js +19 -15
- package/es/Table/v2/RowHeader/styles.js +3 -1
- package/es/Table/v2/index.js +50 -55
- package/es/Table/v2/styles.js +3 -1
- package/lib/Table/v1/Body/index.js +21 -15
- package/lib/Table/v1/Body/theme.js +9 -8
- package/lib/Table/v1/Cell/index.js +20 -16
- package/lib/Table/v1/Cell/styles.js +3 -1
- package/lib/Table/v1/Cell/theme.js +13 -12
- package/lib/Table/v1/ColHeader/index.js +43 -41
- package/lib/Table/v1/ColHeader/styles.js +4 -2
- package/lib/Table/v1/ColHeader/theme.js +19 -18
- package/lib/Table/v1/Head/index.js +35 -35
- package/lib/Table/v1/Head/theme.js +9 -8
- package/lib/Table/v1/Row/index.js +18 -14
- package/lib/Table/v1/Row/styles.js +4 -2
- package/lib/Table/v1/Row/theme.js +14 -13
- package/lib/Table/v1/RowHeader/index.js +19 -15
- package/lib/Table/v1/RowHeader/styles.js +3 -1
- package/lib/Table/v1/RowHeader/theme.js +13 -12
- package/lib/Table/v1/index.js +50 -55
- package/lib/Table/v1/styles.js +3 -1
- package/lib/Table/v1/theme.js +10 -9
- package/lib/Table/v2/Body/index.js +21 -15
- package/lib/Table/v2/Cell/index.js +20 -16
- package/lib/Table/v2/Cell/styles.js +3 -1
- package/lib/Table/v2/ColHeader/index.js +45 -43
- package/lib/Table/v2/ColHeader/styles.js +4 -2
- package/lib/Table/v2/Head/index.js +38 -38
- package/lib/Table/v2/Row/index.js +18 -14
- package/lib/Table/v2/Row/styles.js +4 -2
- package/lib/Table/v2/RowHeader/index.js +19 -15
- package/lib/Table/v2/RowHeader/styles.js +3 -1
- package/lib/Table/v2/index.js +50 -55
- package/lib/Table/v2/styles.js +3 -1
- package/package.json +15 -15
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var _dec, _class, _Head, _ScreenReaderContent, _CheckInstUIIcon, _CheckInstUIIcon2, _CheckInstUIIcon3;
|
|
1
|
+
var _dec, _class;
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -41,19 +40,24 @@ id: Table.Head
|
|
|
41
40
|
---
|
|
42
41
|
**/
|
|
43
42
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
44
|
-
let Head = (_dec = withStyle(generateStyle), _dec(_class =
|
|
43
|
+
let Head = (_dec = withStyle(generateStyle), _dec(_class = class Head extends Component {
|
|
44
|
+
static displayName = "Head";
|
|
45
|
+
static componentId = 'Table.Head';
|
|
46
|
+
static contextType = TableContext;
|
|
47
|
+
static allowedProps = allowedProps;
|
|
48
|
+
static defaultProps = {
|
|
49
|
+
children: null
|
|
50
|
+
};
|
|
51
|
+
|
|
45
52
|
/**
|
|
46
53
|
* Returns `true` if the first child's children have a `onRequestSort` prop
|
|
47
54
|
*/
|
|
48
55
|
get isSortable() {
|
|
49
|
-
const
|
|
50
|
-
_ref2 = _slicedToArray(_ref, 1),
|
|
51
|
-
firstRow = _ref2[0];
|
|
56
|
+
const [firstRow] = Children.toArray(this.props.children);
|
|
52
57
|
let sortable = false;
|
|
53
58
|
if (firstRow && firstRow.props && firstRow.props.children) {
|
|
54
59
|
Children.forEach(firstRow.props.children, grandchild => {
|
|
55
|
-
|
|
56
|
-
if (grandchild !== null && grandchild !== void 0 && (_grandchild$props = grandchild.props) !== null && _grandchild$props !== void 0 && _grandchild$props.onRequestSort) {
|
|
60
|
+
if (grandchild?.props?.onRequestSort) {
|
|
57
61
|
sortable = true;
|
|
58
62
|
return;
|
|
59
63
|
}
|
|
@@ -62,15 +66,13 @@ let Head = (_dec = withStyle(generateStyle), _dec(_class = (_Head = class Head e
|
|
|
62
66
|
return sortable;
|
|
63
67
|
}
|
|
64
68
|
componentDidMount() {
|
|
65
|
-
|
|
66
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
69
|
+
this.props.makeStyles?.();
|
|
67
70
|
}
|
|
68
71
|
componentDidUpdate() {
|
|
69
|
-
var _this$props$makeStyle2, _this$props2;
|
|
70
72
|
if (this.isSortable && typeof this.props.renderSortLabel === 'undefined') {
|
|
71
73
|
warn(false, '[Table.Head] The `renderSortLabel` prop should be provided when Table is sortable.');
|
|
72
74
|
}
|
|
73
|
-
|
|
75
|
+
this.props.makeStyles?.();
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
/**
|
|
@@ -79,14 +81,12 @@ let Head = (_dec = withStyle(generateStyle), _dec(_class = (_Head = class Head e
|
|
|
79
81
|
* there the `id`, `stackedSortByLabel`, `sortDirection`, `onRequestSort` props
|
|
80
82
|
*/
|
|
81
83
|
renderSelect() {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
firstRow = _ref4[0];
|
|
89
|
-
if (!(firstRow !== null && firstRow !== void 0 && (_firstRow$props = firstRow.props) !== null && _firstRow$props !== void 0 && _firstRow$props.children)) {
|
|
84
|
+
const {
|
|
85
|
+
children,
|
|
86
|
+
renderSortLabel
|
|
87
|
+
} = this.props;
|
|
88
|
+
const [firstRow] = Children.toArray(children);
|
|
89
|
+
if (!firstRow?.props?.children) {
|
|
90
90
|
return null;
|
|
91
91
|
}
|
|
92
92
|
const options = [];
|
|
@@ -95,12 +95,13 @@ let Head = (_dec = withStyle(generateStyle), _dec(_class = (_Head = class Head e
|
|
|
95
95
|
let count = 0;
|
|
96
96
|
Children.forEach(firstRow.props.children, grandchild => {
|
|
97
97
|
count += 1;
|
|
98
|
-
if (!
|
|
99
|
-
const
|
|
100
|
-
id
|
|
101
|
-
stackedSortByLabel
|
|
102
|
-
sortDirection
|
|
103
|
-
onRequestSort
|
|
98
|
+
if (!grandchild?.props) return; // grandchild can be false
|
|
99
|
+
const {
|
|
100
|
+
id,
|
|
101
|
+
stackedSortByLabel,
|
|
102
|
+
sortDirection,
|
|
103
|
+
onRequestSort
|
|
104
|
+
} = grandchild.props;
|
|
104
105
|
if (id && onRequestSort) {
|
|
105
106
|
const label = stackedSortByLabel || id;
|
|
106
107
|
options.push({
|
|
@@ -133,8 +134,8 @@ let Head = (_dec = withStyle(generateStyle), _dec(_class = (_Head = class Head e
|
|
|
133
134
|
role: "cell",
|
|
134
135
|
"aria-colspan": count,
|
|
135
136
|
children: _jsx(SimpleSelect, {
|
|
136
|
-
renderLabel: renderSortLabel ? callRenderProp(renderSortLabel) :
|
|
137
|
-
renderBeforeInput: selectedOption ? () =>
|
|
137
|
+
renderLabel: renderSortLabel ? callRenderProp(renderSortLabel) : _jsx(ScreenReaderContent, {}),
|
|
138
|
+
renderBeforeInput: selectedOption ? () => _jsx(CheckInstUIIcon, {}) : undefined,
|
|
138
139
|
value: selectedOption,
|
|
139
140
|
onChange: handleSelect,
|
|
140
141
|
children: options.map(({
|
|
@@ -143,11 +144,11 @@ let Head = (_dec = withStyle(generateStyle), _dec(_class = (_Head = class Head e
|
|
|
143
144
|
}) => _jsx(SimpleSelect.Option, {
|
|
144
145
|
id: id,
|
|
145
146
|
value: id,
|
|
146
|
-
renderBeforeLabel: id === selectedOption ? () =>
|
|
147
|
+
renderBeforeLabel: id === selectedOption ? () => _jsx(CheckInstUIIcon, {}) : () => _jsx("span", {
|
|
147
148
|
style: {
|
|
148
149
|
visibility: 'hidden'
|
|
149
150
|
},
|
|
150
|
-
children:
|
|
151
|
+
children: _jsx(CheckInstUIIcon, {})
|
|
151
152
|
}),
|
|
152
153
|
children: label
|
|
153
154
|
}, id))
|
|
@@ -157,17 +158,16 @@ let Head = (_dec = withStyle(generateStyle), _dec(_class = (_Head = class Head e
|
|
|
157
158
|
});
|
|
158
159
|
}
|
|
159
160
|
render() {
|
|
160
|
-
const
|
|
161
|
-
children
|
|
162
|
-
styles
|
|
161
|
+
const {
|
|
162
|
+
children,
|
|
163
|
+
styles
|
|
164
|
+
} = this.props;
|
|
163
165
|
return this.context.isStacked ? this.renderSelect() : _jsx("thead", {
|
|
164
166
|
...omitProps(this.props, Head.allowedProps),
|
|
165
|
-
css: styles
|
|
167
|
+
css: styles?.head,
|
|
166
168
|
children: children
|
|
167
169
|
});
|
|
168
170
|
}
|
|
169
|
-
}
|
|
170
|
-
children: null
|
|
171
|
-
}, _Head)) || _class);
|
|
171
|
+
}) || _class);
|
|
172
172
|
export default Head;
|
|
173
173
|
export { Head };
|
package/es/Table/v2/Row/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _class
|
|
1
|
+
var _dec, _class;
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License (MIT)
|
|
4
4
|
*
|
|
@@ -37,32 +37,38 @@ id: Table.Row
|
|
|
37
37
|
---
|
|
38
38
|
**/
|
|
39
39
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
40
|
-
let Row = (_dec = withStyle(generateStyle), _dec(_class =
|
|
40
|
+
let Row = (_dec = withStyle(generateStyle), _dec(_class = class Row extends Component {
|
|
41
|
+
static displayName = "Row";
|
|
42
|
+
static componentId = 'Table.Row';
|
|
43
|
+
static contextType = TableContext;
|
|
44
|
+
static allowedProps = allowedProps;
|
|
45
|
+
static defaultProps = {
|
|
46
|
+
children: null
|
|
47
|
+
};
|
|
41
48
|
componentDidMount() {
|
|
42
|
-
|
|
43
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, {
|
|
49
|
+
this.props.makeStyles?.({
|
|
44
50
|
isStacked: this.context.isStacked,
|
|
45
51
|
hover: this.context.hover
|
|
46
52
|
});
|
|
47
53
|
}
|
|
48
54
|
componentDidUpdate() {
|
|
49
|
-
|
|
50
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, {
|
|
55
|
+
this.props.makeStyles?.({
|
|
51
56
|
isStacked: this.context.isStacked,
|
|
52
57
|
hover: this.context.hover
|
|
53
58
|
});
|
|
54
59
|
}
|
|
55
60
|
render() {
|
|
56
|
-
const
|
|
57
|
-
children
|
|
58
|
-
styles
|
|
61
|
+
const {
|
|
62
|
+
children,
|
|
63
|
+
styles
|
|
64
|
+
} = this.props;
|
|
59
65
|
const isStacked = this.context.isStacked;
|
|
60
66
|
const headers = this.context.headers;
|
|
61
67
|
return _jsx(View, {
|
|
62
68
|
...View.omitViewProps(omitProps(this.props, Row.allowedProps), Row),
|
|
63
69
|
as: isStacked ? 'div' : 'tr',
|
|
64
|
-
css: styles
|
|
65
|
-
role: isStacked ? 'row' :
|
|
70
|
+
css: styles?.row,
|
|
71
|
+
role: isStacked ? 'row' : undefined,
|
|
66
72
|
children: Children.toArray(children).filter(Boolean).map((child, index) => {
|
|
67
73
|
if (/*#__PURE__*/isValidElement(child)) {
|
|
68
74
|
return safeCloneElement(child, {
|
|
@@ -75,8 +81,6 @@ let Row = (_dec = withStyle(generateStyle), _dec(_class = (_Row = class Row exte
|
|
|
75
81
|
})
|
|
76
82
|
});
|
|
77
83
|
}
|
|
78
|
-
}
|
|
79
|
-
children: null
|
|
80
|
-
}, _Row)) || _class);
|
|
84
|
+
}) || _class);
|
|
81
85
|
export default Row;
|
|
82
86
|
export { Row };
|
|
@@ -34,7 +34,9 @@
|
|
|
34
34
|
* @return {Object} The final style object, which will be used in the component
|
|
35
35
|
*/
|
|
36
36
|
const generateStyle = (componentTheme, props, _sharedTokens, extraArgs) => {
|
|
37
|
-
const
|
|
37
|
+
const {
|
|
38
|
+
setHoverStateTo
|
|
39
|
+
} = props;
|
|
38
40
|
const hoverStyles = {
|
|
39
41
|
borderLeftColor: componentTheme.hoverBorderColor,
|
|
40
42
|
borderRightColor: componentTheme.hoverBorderColor
|
|
@@ -51,7 +53,7 @@ const generateStyle = (componentTheme, props, _sharedTokens, extraArgs) => {
|
|
|
51
53
|
borderBottomStyle: 'solid',
|
|
52
54
|
borderBottomWidth: '0.0625rem',
|
|
53
55
|
borderBottomColor: componentTheme.borderColor,
|
|
54
|
-
...((setHoverStateTo
|
|
56
|
+
...((setHoverStateTo ?? extraArgs.hover) && {
|
|
55
57
|
borderLeft: '0.1875rem solid transparent',
|
|
56
58
|
borderRight: '0.1875rem solid transparent',
|
|
57
59
|
...(setHoverStateTo === true ? hoverStyles : {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _class
|
|
1
|
+
var _dec, _class;
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License (MIT)
|
|
4
4
|
*
|
|
@@ -37,32 +37,36 @@ id: Table.RowHeader
|
|
|
37
37
|
---
|
|
38
38
|
**/
|
|
39
39
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
40
|
-
let RowHeader = (_dec = withStyle(generateStyle), _dec(_class =
|
|
40
|
+
let RowHeader = (_dec = withStyle(generateStyle), _dec(_class = class RowHeader extends Component {
|
|
41
|
+
static displayName = "RowHeader";
|
|
42
|
+
static componentId = 'Table.RowHeader';
|
|
43
|
+
static contextType = TableContext;
|
|
44
|
+
static allowedProps = allowedProps;
|
|
45
|
+
static defaultProps = {
|
|
46
|
+
textAlign: 'start',
|
|
47
|
+
children: null
|
|
48
|
+
};
|
|
41
49
|
componentDidMount() {
|
|
42
|
-
|
|
43
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
50
|
+
this.props.makeStyles?.();
|
|
44
51
|
}
|
|
45
52
|
componentDidUpdate() {
|
|
46
|
-
|
|
47
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
53
|
+
this.props.makeStyles?.();
|
|
48
54
|
}
|
|
49
55
|
render() {
|
|
50
|
-
const
|
|
51
|
-
children
|
|
52
|
-
styles
|
|
56
|
+
const {
|
|
57
|
+
children,
|
|
58
|
+
styles
|
|
59
|
+
} = this.props;
|
|
53
60
|
const isStacked = this.context.isStacked;
|
|
54
61
|
return _jsx(View, {
|
|
55
62
|
...View.omitViewProps(omitProps(this.props, RowHeader.allowedProps), RowHeader),
|
|
56
63
|
as: isStacked ? 'div' : 'th',
|
|
57
|
-
css: styles
|
|
64
|
+
css: styles?.rowHeader,
|
|
58
65
|
scope: "row",
|
|
59
|
-
role: isStacked ? 'rowheader' :
|
|
66
|
+
role: isStacked ? 'rowheader' : undefined,
|
|
60
67
|
children: callRenderProp(children)
|
|
61
68
|
});
|
|
62
69
|
}
|
|
63
|
-
}
|
|
64
|
-
textAlign: 'start',
|
|
65
|
-
children: null
|
|
66
|
-
}, _RowHeader)) || _class);
|
|
70
|
+
}) || _class);
|
|
67
71
|
export default RowHeader;
|
|
68
72
|
export { RowHeader };
|
|
@@ -32,7 +32,9 @@
|
|
|
32
32
|
* @return {Object} The final style object, which will be used in the component
|
|
33
33
|
*/
|
|
34
34
|
const generateStyle = (componentTheme, props) => {
|
|
35
|
-
const
|
|
35
|
+
const {
|
|
36
|
+
textAlign
|
|
37
|
+
} = props;
|
|
36
38
|
return {
|
|
37
39
|
rowHeader: {
|
|
38
40
|
label: 'rowHeader',
|
package/es/Table/v2/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var _dec, _class, _Table;
|
|
1
|
+
var _dec, _class;
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -46,34 +45,42 @@ category: components
|
|
|
46
45
|
---
|
|
47
46
|
**/
|
|
48
47
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
49
|
-
let Table = (_dec = withStyle(generateStyle), _dec(_class =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
48
|
+
let Table = (_dec = withStyle(generateStyle), _dec(_class = class Table extends Component {
|
|
49
|
+
static displayName = "Table";
|
|
50
|
+
static componentId = 'Table';
|
|
51
|
+
static allowedProps = allowedProps;
|
|
52
|
+
static defaultProps = {
|
|
53
|
+
children: null,
|
|
54
|
+
hover: false,
|
|
55
|
+
layout: 'auto'
|
|
56
|
+
};
|
|
57
|
+
static Head = Head;
|
|
58
|
+
static Body = Body;
|
|
59
|
+
static Row = Row;
|
|
60
|
+
static ColHeader = ColHeader;
|
|
61
|
+
static RowHeader = RowHeader;
|
|
62
|
+
static Cell = Cell;
|
|
63
|
+
ref = null;
|
|
64
|
+
// Reference to hidden aria-live region for announcing caption changes to screen readers
|
|
65
|
+
_liveRegionRef = null;
|
|
66
|
+
// Timeout for delayed announcement (workaround for Safari/VoiceOver caption update bug)
|
|
67
|
+
_announcementTimeout;
|
|
68
|
+
handleRef = el => {
|
|
69
|
+
this.ref = el;
|
|
70
|
+
this.props.elementRef?.(el);
|
|
71
|
+
};
|
|
63
72
|
componentDidMount() {
|
|
64
|
-
|
|
65
|
-
(_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
|
|
73
|
+
this.props.makeStyles?.();
|
|
66
74
|
}
|
|
67
75
|
componentDidUpdate(prevProps) {
|
|
68
|
-
|
|
69
|
-
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
|
|
76
|
+
this.props.makeStyles?.();
|
|
70
77
|
// Announce caption changes for screen readers (especially VoiceOver)
|
|
71
78
|
// Safari/VoiceOver has a known bug where dynamic <caption> updates aren't announced,
|
|
72
79
|
// so we use an aria-live region as a workaround
|
|
73
80
|
const prevSortInfo = this.getSortedHeaderInfo(prevProps);
|
|
74
81
|
const currentSortInfo = this.getSortedHeaderInfo(this.props);
|
|
75
82
|
// Only announce if sorting actually changed
|
|
76
|
-
const sortingChanged =
|
|
83
|
+
const sortingChanged = prevSortInfo?.header !== currentSortInfo?.header || prevSortInfo?.direction !== currentSortInfo?.direction;
|
|
77
84
|
if (sortingChanged && currentSortInfo && this._liveRegionRef) {
|
|
78
85
|
// Clear any pending announcement
|
|
79
86
|
clearTimeout(this._announcementTimeout);
|
|
@@ -95,33 +102,24 @@ let Table = (_dec = withStyle(generateStyle), _dec(_class = (_Table = class Tabl
|
|
|
95
102
|
clearTimeout(this._announcementTimeout);
|
|
96
103
|
}
|
|
97
104
|
getHeaders() {
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (!
|
|
102
|
-
const _Children$toArray3 = Children.toArray(headChild.props.children),
|
|
103
|
-
_Children$toArray4 = _slicedToArray(_Children$toArray3, 1),
|
|
104
|
-
firstRow = _Children$toArray4[0];
|
|
105
|
-
if (!firstRow || ! /*#__PURE__*/isValidElement(firstRow)) return void 0;
|
|
105
|
+
const [headChild] = Children.toArray(this.props.children);
|
|
106
|
+
if (!headChild || ! /*#__PURE__*/isValidElement(headChild)) return undefined;
|
|
107
|
+
const [firstRow] = Children.toArray(headChild.props.children);
|
|
108
|
+
if (!firstRow || ! /*#__PURE__*/isValidElement(firstRow)) return undefined;
|
|
106
109
|
return Children.map(firstRow.props.children, colHeader => {
|
|
107
|
-
if (! /*#__PURE__*/isValidElement(colHeader)) return
|
|
110
|
+
if (! /*#__PURE__*/isValidElement(colHeader)) return undefined;
|
|
108
111
|
return colHeader.props.children;
|
|
109
112
|
});
|
|
110
113
|
}
|
|
111
114
|
getSortedHeaderInfo(props) {
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
headChild = _Children$toArray6[0];
|
|
115
|
-
const _Children$toArray7 = Children.toArray(/*#__PURE__*/isValidElement(headChild) ? headChild.props.children : []),
|
|
116
|
-
_Children$toArray8 = _slicedToArray(_Children$toArray7, 1),
|
|
117
|
-
firstRow = _Children$toArray8[0];
|
|
115
|
+
const [headChild] = Children.toArray(props.children);
|
|
116
|
+
const [firstRow] = Children.toArray(/*#__PURE__*/isValidElement(headChild) ? headChild.props.children : []);
|
|
118
117
|
const colHeaders = Children.toArray(/*#__PURE__*/isValidElement(firstRow) ? firstRow.props.children : []);
|
|
119
118
|
// Find the column with an active sort direction
|
|
120
119
|
for (const colHeader of colHeaders) {
|
|
121
120
|
if (/*#__PURE__*/isValidElement(colHeader) && colHeader.props.sortDirection && colHeader.props.sortDirection !== 'none') {
|
|
122
|
-
var _colHeader$props$chil, _colHeader$props$chil2, _colHeader$props$chil3;
|
|
123
121
|
// Extract header text (may be nested in child components)
|
|
124
|
-
const headerText = typeof colHeader.props.children === 'string' ? colHeader.props.children :
|
|
122
|
+
const headerText = typeof colHeader.props.children === 'string' ? colHeader.props.children : colHeader.props.children?.props?.children ?? '';
|
|
125
123
|
return {
|
|
126
124
|
header: headerText,
|
|
127
125
|
direction: colHeader.props.sortDirection
|
|
@@ -138,14 +136,15 @@ let Table = (_dec = withStyle(generateStyle), _dec(_class = (_Table = class Tabl
|
|
|
138
136
|
return caption ? caption + sortText : sortText.trim();
|
|
139
137
|
}
|
|
140
138
|
render() {
|
|
141
|
-
const
|
|
142
|
-
margin
|
|
143
|
-
layout
|
|
144
|
-
caption
|
|
145
|
-
children
|
|
146
|
-
hover
|
|
147
|
-
styles
|
|
148
|
-
minWidth
|
|
139
|
+
const {
|
|
140
|
+
margin,
|
|
141
|
+
layout,
|
|
142
|
+
caption,
|
|
143
|
+
children,
|
|
144
|
+
hover,
|
|
145
|
+
styles,
|
|
146
|
+
minWidth
|
|
147
|
+
} = this.props;
|
|
149
148
|
const isStacked = layout === 'stacked';
|
|
150
149
|
const captionText = this.getCaptionText(this.props);
|
|
151
150
|
if (!caption) {
|
|
@@ -155,7 +154,7 @@ let Table = (_dec = withStyle(generateStyle), _dec(_class = (_Table = class Tabl
|
|
|
155
154
|
value: {
|
|
156
155
|
isStacked,
|
|
157
156
|
hover: hover,
|
|
158
|
-
headers: isStacked ? this.getHeaders() :
|
|
157
|
+
headers: isStacked ? this.getHeaders() : undefined
|
|
159
158
|
},
|
|
160
159
|
children: [_jsx("div", {
|
|
161
160
|
ref: el => {
|
|
@@ -164,7 +163,7 @@ let Table = (_dec = withStyle(generateStyle), _dec(_class = (_Table = class Tabl
|
|
|
164
163
|
"aria-live": "polite",
|
|
165
164
|
"aria-atomic": "true",
|
|
166
165
|
role: "status",
|
|
167
|
-
css: styles
|
|
166
|
+
css: styles?.liveRegion
|
|
168
167
|
}), _jsxs(View
|
|
169
168
|
// All HTML props, except the ones accepted by `View` and `Table`
|
|
170
169
|
, {
|
|
@@ -173,8 +172,8 @@ let Table = (_dec = withStyle(generateStyle), _dec(_class = (_Table = class Tabl
|
|
|
173
172
|
as: isStacked ? 'div' : 'table',
|
|
174
173
|
margin: margin,
|
|
175
174
|
elementRef: this.handleRef,
|
|
176
|
-
css: styles
|
|
177
|
-
role: isStacked ? 'table' :
|
|
175
|
+
css: styles?.table,
|
|
176
|
+
role: isStacked ? 'table' : undefined,
|
|
178
177
|
"aria-label": captionText,
|
|
179
178
|
children: [!isStacked && caption && _jsx("caption", {
|
|
180
179
|
children: _jsx(ScreenReaderContent, {
|
|
@@ -186,10 +185,6 @@ let Table = (_dec = withStyle(generateStyle), _dec(_class = (_Table = class Tabl
|
|
|
186
185
|
})]
|
|
187
186
|
});
|
|
188
187
|
}
|
|
189
|
-
}
|
|
190
|
-
children: null,
|
|
191
|
-
hover: false,
|
|
192
|
-
layout: 'auto'
|
|
193
|
-
}, _Table.Head = Head, _Table.Body = Body, _Table.Row = Row, _Table.ColHeader = ColHeader, _Table.RowHeader = RowHeader, _Table.Cell = Cell, _Table)) || _class);
|
|
188
|
+
}) || _class);
|
|
194
189
|
export default Table;
|
|
195
190
|
export { Table };
|
package/es/Table/v2/styles.js
CHANGED
|
@@ -33,7 +33,9 @@
|
|
|
33
33
|
* @return {Object} The final style object, which will be used in the component
|
|
34
34
|
*/
|
|
35
35
|
const generateStyle = (componentTheme, props, _sharedTokens) => {
|
|
36
|
-
const
|
|
36
|
+
const {
|
|
37
|
+
layout
|
|
38
|
+
} = props;
|
|
37
39
|
return {
|
|
38
40
|
table: {
|
|
39
41
|
label: 'table',
|
|
@@ -15,7 +15,7 @@ var _theme = _interopRequireDefault(require("./theme"));
|
|
|
15
15
|
var _props = require("./props");
|
|
16
16
|
var _TableContext = _interopRequireDefault(require("../TableContext"));
|
|
17
17
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
18
|
-
var _dec, _class
|
|
18
|
+
var _dec, _class;
|
|
19
19
|
/*
|
|
20
20
|
* The MIT License (MIT)
|
|
21
21
|
*
|
|
@@ -45,25 +45,33 @@ parent: Table
|
|
|
45
45
|
id: Table.Body
|
|
46
46
|
---
|
|
47
47
|
**/
|
|
48
|
-
let Body = exports.Body = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class =
|
|
48
|
+
let Body = exports.Body = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = class Body extends _react.Component {
|
|
49
|
+
static displayName = "Body";
|
|
50
|
+
static componentId = 'Table.Body';
|
|
51
|
+
static contextType = _TableContext.default;
|
|
52
|
+
static allowedProps = _props.allowedProps;
|
|
53
|
+
static defaultProps = {
|
|
54
|
+
children: null
|
|
55
|
+
};
|
|
49
56
|
componentDidMount() {
|
|
50
|
-
|
|
51
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
57
|
+
this.props.makeStyles?.();
|
|
52
58
|
}
|
|
53
59
|
componentDidUpdate() {
|
|
54
|
-
|
|
55
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
60
|
+
this.props.makeStyles?.();
|
|
56
61
|
}
|
|
57
62
|
render() {
|
|
58
|
-
const
|
|
59
|
-
children
|
|
60
|
-
styles
|
|
61
|
-
|
|
63
|
+
const {
|
|
64
|
+
children,
|
|
65
|
+
styles
|
|
66
|
+
} = this.props;
|
|
67
|
+
const {
|
|
68
|
+
isStacked
|
|
69
|
+
} = this.context;
|
|
62
70
|
return (0, _jsxRuntime.jsx)(_v11_.View, {
|
|
63
71
|
..._v11_.View.omitViewProps((0, _omitProps.omitProps)(this.props, Body.allowedProps), Body),
|
|
64
72
|
as: isStacked ? 'div' : 'tbody',
|
|
65
|
-
css: styles
|
|
66
|
-
role: isStacked ? 'rowgroup' :
|
|
73
|
+
css: styles?.body,
|
|
74
|
+
role: isStacked ? 'rowgroup' : undefined,
|
|
67
75
|
children: _react.Children.map(children, child => {
|
|
68
76
|
if (/*#__PURE__*/(0, _react.isValidElement)(child)) {
|
|
69
77
|
return (0, _safeCloneElement.safeCloneElement)(child, {
|
|
@@ -74,7 +82,5 @@ let Body = exports.Body = (_dec = (0, _emotion.withStyleLegacy)(_styles.default,
|
|
|
74
82
|
})
|
|
75
83
|
});
|
|
76
84
|
}
|
|
77
|
-
}
|
|
78
|
-
children: null
|
|
79
|
-
}, _Body)) || _class);
|
|
85
|
+
}) || _class);
|
|
80
86
|
var _default = exports.default = Body;
|
|
@@ -34,15 +34,16 @@ exports.default = void 0;
|
|
|
34
34
|
* @return {Object} The final theme object with the overrides and component variables
|
|
35
35
|
*/
|
|
36
36
|
const generateComponentTheme = theme => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
typography
|
|
37
|
+
const {
|
|
38
|
+
colors,
|
|
39
|
+
typography
|
|
40
|
+
} = theme;
|
|
40
41
|
const componentVariables = {
|
|
41
|
-
fontSize: typography
|
|
42
|
-
fontFamily: typography
|
|
43
|
-
fontWeight: typography
|
|
44
|
-
color: colors
|
|
45
|
-
background: colors
|
|
42
|
+
fontSize: typography?.fontSizeMedium,
|
|
43
|
+
fontFamily: typography?.fontFamily,
|
|
44
|
+
fontWeight: typography?.fontWeightNormal,
|
|
45
|
+
color: colors?.contrasts?.grey125125,
|
|
46
|
+
background: colors?.contrasts?.white1010
|
|
46
47
|
};
|
|
47
48
|
return {
|
|
48
49
|
...componentVariables
|
|
@@ -15,7 +15,7 @@ var _theme = _interopRequireDefault(require("./theme"));
|
|
|
15
15
|
var _props = require("./props");
|
|
16
16
|
var _TableContext = _interopRequireDefault(require("../TableContext"));
|
|
17
17
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
18
|
-
var _dec, _class
|
|
18
|
+
var _dec, _class;
|
|
19
19
|
/*
|
|
20
20
|
* The MIT License (MIT)
|
|
21
21
|
*
|
|
@@ -45,31 +45,35 @@ parent: Table
|
|
|
45
45
|
id: Table.Cell
|
|
46
46
|
---
|
|
47
47
|
**/
|
|
48
|
-
let Cell = exports.Cell = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class =
|
|
48
|
+
let Cell = exports.Cell = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = class Cell extends _react.Component {
|
|
49
|
+
static displayName = "Cell";
|
|
50
|
+
static componentId = 'Table.Cell';
|
|
51
|
+
static contextType = _TableContext.default;
|
|
52
|
+
static allowedProps = _props.allowedProps;
|
|
53
|
+
static defaultProps = {
|
|
54
|
+
textAlign: 'start',
|
|
55
|
+
children: null
|
|
56
|
+
};
|
|
49
57
|
componentDidMount() {
|
|
50
|
-
|
|
51
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
58
|
+
this.props.makeStyles?.();
|
|
52
59
|
}
|
|
53
60
|
componentDidUpdate() {
|
|
54
|
-
|
|
55
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
61
|
+
this.props.makeStyles?.();
|
|
56
62
|
}
|
|
57
63
|
render() {
|
|
58
|
-
const
|
|
59
|
-
children
|
|
60
|
-
styles
|
|
61
|
-
header
|
|
64
|
+
const {
|
|
65
|
+
children,
|
|
66
|
+
styles,
|
|
67
|
+
header
|
|
68
|
+
} = this.props;
|
|
62
69
|
const isStacked = this.context.isStacked;
|
|
63
70
|
return (0, _jsxRuntime.jsxs)(_v11_.View, {
|
|
64
71
|
..._v11_.View.omitViewProps((0, _omitProps.omitProps)(this.props, Cell.allowedProps), Cell),
|
|
65
72
|
as: isStacked ? 'div' : 'td',
|
|
66
|
-
css: styles
|
|
67
|
-
role: isStacked ? 'cell' :
|
|
73
|
+
css: styles?.cell,
|
|
74
|
+
role: isStacked ? 'cell' : undefined,
|
|
68
75
|
children: [header && (0, _callRenderProp.callRenderProp)(header), header && ': ', (0, _callRenderProp.callRenderProp)(children)]
|
|
69
76
|
});
|
|
70
77
|
}
|
|
71
|
-
}
|
|
72
|
-
textAlign: 'start',
|
|
73
|
-
children: null
|
|
74
|
-
}, _Cell)) || _class);
|
|
78
|
+
}) || _class);
|
|
75
79
|
var _default = exports.default = Cell;
|
|
@@ -39,7 +39,9 @@ exports.default = void 0;
|
|
|
39
39
|
* @return {Object} The final style object, which will be used in the component
|
|
40
40
|
*/
|
|
41
41
|
const generateStyle = (componentTheme, props) => {
|
|
42
|
-
const
|
|
42
|
+
const {
|
|
43
|
+
textAlign
|
|
44
|
+
} = props;
|
|
43
45
|
return {
|
|
44
46
|
cell: {
|
|
45
47
|
label: 'cell',
|