@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
package/lib/Table/v1/index.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.Table = void 0;
|
|
8
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
8
|
var _react = require("react");
|
|
10
9
|
var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
|
|
11
10
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
@@ -24,7 +23,7 @@ var _props = require("./props");
|
|
|
24
23
|
var _TableContext = _interopRequireDefault(require("./TableContext"));
|
|
25
24
|
var _console = require("@instructure/console");
|
|
26
25
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
27
|
-
var _dec, _class
|
|
26
|
+
var _dec, _class;
|
|
28
27
|
/*
|
|
29
28
|
* The MIT License (MIT)
|
|
30
29
|
*
|
|
@@ -53,34 +52,42 @@ var _dec, _class, _Table;
|
|
|
53
52
|
category: components
|
|
54
53
|
---
|
|
55
54
|
**/
|
|
56
|
-
let Table = exports.Table = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
55
|
+
let Table = exports.Table = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = class Table extends _react.Component {
|
|
56
|
+
static displayName = "Table";
|
|
57
|
+
static componentId = 'Table';
|
|
58
|
+
static allowedProps = _props.allowedProps;
|
|
59
|
+
static defaultProps = {
|
|
60
|
+
children: null,
|
|
61
|
+
hover: false,
|
|
62
|
+
layout: 'auto'
|
|
63
|
+
};
|
|
64
|
+
static Head = _Head.Head;
|
|
65
|
+
static Body = _Body.Body;
|
|
66
|
+
static Row = _Row.Row;
|
|
67
|
+
static ColHeader = _ColHeader.ColHeader;
|
|
68
|
+
static RowHeader = _RowHeader.RowHeader;
|
|
69
|
+
static Cell = _Cell.Cell;
|
|
70
|
+
ref = null;
|
|
71
|
+
// Reference to hidden aria-live region for announcing caption changes to screen readers
|
|
72
|
+
_liveRegionRef = null;
|
|
73
|
+
// Timeout for delayed announcement (workaround for Safari/VoiceOver caption update bug)
|
|
74
|
+
_announcementTimeout;
|
|
75
|
+
handleRef = el => {
|
|
76
|
+
this.ref = el;
|
|
77
|
+
this.props.elementRef?.(el);
|
|
78
|
+
};
|
|
70
79
|
componentDidMount() {
|
|
71
|
-
|
|
72
|
-
(_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
|
|
80
|
+
this.props.makeStyles?.();
|
|
73
81
|
}
|
|
74
82
|
componentDidUpdate(prevProps) {
|
|
75
|
-
|
|
76
|
-
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
|
|
83
|
+
this.props.makeStyles?.();
|
|
77
84
|
// Announce caption changes for screen readers (especially VoiceOver)
|
|
78
85
|
// Safari/VoiceOver has a known bug where dynamic <caption> updates aren't announced,
|
|
79
86
|
// so we use an aria-live region as a workaround
|
|
80
87
|
const prevSortInfo = this.getSortedHeaderInfo(prevProps);
|
|
81
88
|
const currentSortInfo = this.getSortedHeaderInfo(this.props);
|
|
82
89
|
// Only announce if sorting actually changed
|
|
83
|
-
const sortingChanged =
|
|
90
|
+
const sortingChanged = prevSortInfo?.header !== currentSortInfo?.header || prevSortInfo?.direction !== currentSortInfo?.direction;
|
|
84
91
|
if (sortingChanged && currentSortInfo && this._liveRegionRef) {
|
|
85
92
|
// Clear any pending announcement
|
|
86
93
|
clearTimeout(this._announcementTimeout);
|
|
@@ -102,33 +109,24 @@ let Table = exports.Table = (_dec = (0, _emotion.withStyleLegacy)(_styles.defaul
|
|
|
102
109
|
clearTimeout(this._announcementTimeout);
|
|
103
110
|
}
|
|
104
111
|
getHeaders() {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (!
|
|
109
|
-
const _Children$toArray3 = _react.Children.toArray(headChild.props.children),
|
|
110
|
-
_Children$toArray4 = (0, _slicedToArray2.default)(_Children$toArray3, 1),
|
|
111
|
-
firstRow = _Children$toArray4[0];
|
|
112
|
-
if (!firstRow || ! /*#__PURE__*/(0, _react.isValidElement)(firstRow)) return void 0;
|
|
112
|
+
const [headChild] = _react.Children.toArray(this.props.children);
|
|
113
|
+
if (!headChild || ! /*#__PURE__*/(0, _react.isValidElement)(headChild)) return undefined;
|
|
114
|
+
const [firstRow] = _react.Children.toArray(headChild.props.children);
|
|
115
|
+
if (!firstRow || ! /*#__PURE__*/(0, _react.isValidElement)(firstRow)) return undefined;
|
|
113
116
|
return _react.Children.map(firstRow.props.children, colHeader => {
|
|
114
|
-
if (! /*#__PURE__*/(0, _react.isValidElement)(colHeader)) return
|
|
117
|
+
if (! /*#__PURE__*/(0, _react.isValidElement)(colHeader)) return undefined;
|
|
115
118
|
return colHeader.props.children;
|
|
116
119
|
});
|
|
117
120
|
}
|
|
118
121
|
getSortedHeaderInfo(props) {
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
headChild = _Children$toArray6[0];
|
|
122
|
-
const _Children$toArray7 = _react.Children.toArray(/*#__PURE__*/(0, _react.isValidElement)(headChild) ? headChild.props.children : []),
|
|
123
|
-
_Children$toArray8 = (0, _slicedToArray2.default)(_Children$toArray7, 1),
|
|
124
|
-
firstRow = _Children$toArray8[0];
|
|
122
|
+
const [headChild] = _react.Children.toArray(props.children);
|
|
123
|
+
const [firstRow] = _react.Children.toArray(/*#__PURE__*/(0, _react.isValidElement)(headChild) ? headChild.props.children : []);
|
|
125
124
|
const colHeaders = _react.Children.toArray(/*#__PURE__*/(0, _react.isValidElement)(firstRow) ? firstRow.props.children : []);
|
|
126
125
|
// Find the column with an active sort direction
|
|
127
126
|
for (const colHeader of colHeaders) {
|
|
128
127
|
if (/*#__PURE__*/(0, _react.isValidElement)(colHeader) && colHeader.props.sortDirection && colHeader.props.sortDirection !== 'none') {
|
|
129
|
-
var _colHeader$props$chil, _colHeader$props$chil2, _colHeader$props$chil3;
|
|
130
128
|
// Extract header text (may be nested in child components)
|
|
131
|
-
const headerText = typeof colHeader.props.children === 'string' ? colHeader.props.children :
|
|
129
|
+
const headerText = typeof colHeader.props.children === 'string' ? colHeader.props.children : colHeader.props.children?.props?.children ?? '';
|
|
132
130
|
return {
|
|
133
131
|
header: headerText,
|
|
134
132
|
direction: colHeader.props.sortDirection
|
|
@@ -145,14 +143,15 @@ let Table = exports.Table = (_dec = (0, _emotion.withStyleLegacy)(_styles.defaul
|
|
|
145
143
|
return caption ? caption + sortText : sortText.trim();
|
|
146
144
|
}
|
|
147
145
|
render() {
|
|
148
|
-
const
|
|
149
|
-
margin
|
|
150
|
-
layout
|
|
151
|
-
caption
|
|
152
|
-
children
|
|
153
|
-
hover
|
|
154
|
-
styles
|
|
155
|
-
minWidth
|
|
146
|
+
const {
|
|
147
|
+
margin,
|
|
148
|
+
layout,
|
|
149
|
+
caption,
|
|
150
|
+
children,
|
|
151
|
+
hover,
|
|
152
|
+
styles,
|
|
153
|
+
minWidth
|
|
154
|
+
} = this.props;
|
|
156
155
|
const isStacked = layout === 'stacked';
|
|
157
156
|
const captionText = this.getCaptionText(this.props);
|
|
158
157
|
if (!caption) {
|
|
@@ -162,7 +161,7 @@ let Table = exports.Table = (_dec = (0, _emotion.withStyleLegacy)(_styles.defaul
|
|
|
162
161
|
value: {
|
|
163
162
|
isStacked,
|
|
164
163
|
hover: hover,
|
|
165
|
-
headers: isStacked ? this.getHeaders() :
|
|
164
|
+
headers: isStacked ? this.getHeaders() : undefined
|
|
166
165
|
},
|
|
167
166
|
children: [(0, _jsxRuntime.jsx)("div", {
|
|
168
167
|
ref: el => {
|
|
@@ -171,7 +170,7 @@ let Table = exports.Table = (_dec = (0, _emotion.withStyleLegacy)(_styles.defaul
|
|
|
171
170
|
"aria-live": "polite",
|
|
172
171
|
"aria-atomic": "true",
|
|
173
172
|
role: "status",
|
|
174
|
-
css: styles
|
|
173
|
+
css: styles?.liveRegion
|
|
175
174
|
}), (0, _jsxRuntime.jsxs)(_v11_.View
|
|
176
175
|
// All HTML props, except the ones accepted by `View` and `Table`
|
|
177
176
|
, {
|
|
@@ -180,8 +179,8 @@ let Table = exports.Table = (_dec = (0, _emotion.withStyleLegacy)(_styles.defaul
|
|
|
180
179
|
as: isStacked ? 'div' : 'table',
|
|
181
180
|
margin: margin,
|
|
182
181
|
elementRef: this.handleRef,
|
|
183
|
-
css: styles
|
|
184
|
-
role: isStacked ? 'table' :
|
|
182
|
+
css: styles?.table,
|
|
183
|
+
role: isStacked ? 'table' : undefined,
|
|
185
184
|
"aria-label": captionText,
|
|
186
185
|
children: [!isStacked && caption && (0, _jsxRuntime.jsx)("caption", {
|
|
187
186
|
children: (0, _jsxRuntime.jsx)(_ScreenReaderContent.ScreenReaderContent, {
|
|
@@ -193,9 +192,5 @@ let Table = exports.Table = (_dec = (0, _emotion.withStyleLegacy)(_styles.defaul
|
|
|
193
192
|
})]
|
|
194
193
|
});
|
|
195
194
|
}
|
|
196
|
-
}
|
|
197
|
-
children: null,
|
|
198
|
-
hover: false,
|
|
199
|
-
layout: 'auto'
|
|
200
|
-
}, _Table.Head = _Head.Head, _Table.Body = _Body.Body, _Table.Row = _Row.Row, _Table.ColHeader = _ColHeader.ColHeader, _Table.RowHeader = _RowHeader.RowHeader, _Table.Cell = _Cell.Cell, _Table)) || _class);
|
|
195
|
+
}) || _class);
|
|
201
196
|
var _default = exports.default = Table;
|
package/lib/Table/v1/styles.js
CHANGED
|
@@ -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
|
+
layout
|
|
44
|
+
} = props;
|
|
43
45
|
return {
|
|
44
46
|
table: {
|
|
45
47
|
label: 'table',
|
package/lib/Table/v1/theme.js
CHANGED
|
@@ -34,21 +34,22 @@ 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
|
|
40
|
-
themeName
|
|
37
|
+
const {
|
|
38
|
+
colors,
|
|
39
|
+
typography,
|
|
40
|
+
key: themeName
|
|
41
|
+
} = theme;
|
|
41
42
|
const themeSpecificStyle = {
|
|
42
43
|
canvas: {
|
|
43
44
|
color: theme['ic-brand-font-color-dark']
|
|
44
45
|
}
|
|
45
46
|
};
|
|
46
47
|
const componentVariables = {
|
|
47
|
-
fontSize: typography
|
|
48
|
-
fontFamily: typography
|
|
49
|
-
fontWeight: typography
|
|
50
|
-
color: colors
|
|
51
|
-
background: colors
|
|
48
|
+
fontSize: typography?.fontSizeMedium,
|
|
49
|
+
fontFamily: typography?.fontFamily,
|
|
50
|
+
fontWeight: typography?.fontWeightNormal,
|
|
51
|
+
color: colors?.contrasts?.grey125125,
|
|
52
|
+
background: colors?.contrasts?.white1010
|
|
52
53
|
};
|
|
53
54
|
return {
|
|
54
55
|
...componentVariables,
|
|
@@ -14,7 +14,7 @@ var _styles = _interopRequireDefault(require("./styles"));
|
|
|
14
14
|
var _props = require("./props");
|
|
15
15
|
var _TableContext = _interopRequireDefault(require("../TableContext"));
|
|
16
16
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
17
|
-
var _dec, _class
|
|
17
|
+
var _dec, _class;
|
|
18
18
|
/*
|
|
19
19
|
* The MIT License (MIT)
|
|
20
20
|
*
|
|
@@ -44,25 +44,33 @@ parent: Table
|
|
|
44
44
|
id: Table.Body
|
|
45
45
|
---
|
|
46
46
|
**/
|
|
47
|
-
let Body = exports.Body = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class =
|
|
47
|
+
let Body = exports.Body = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class = class Body extends _react.Component {
|
|
48
|
+
static displayName = "Body";
|
|
49
|
+
static componentId = 'Table.Body';
|
|
50
|
+
static contextType = _TableContext.default;
|
|
51
|
+
static allowedProps = _props.allowedProps;
|
|
52
|
+
static defaultProps = {
|
|
53
|
+
children: null
|
|
54
|
+
};
|
|
48
55
|
componentDidMount() {
|
|
49
|
-
|
|
50
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
56
|
+
this.props.makeStyles?.();
|
|
51
57
|
}
|
|
52
58
|
componentDidUpdate() {
|
|
53
|
-
|
|
54
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
59
|
+
this.props.makeStyles?.();
|
|
55
60
|
}
|
|
56
61
|
render() {
|
|
57
|
-
const
|
|
58
|
-
children
|
|
59
|
-
styles
|
|
60
|
-
|
|
62
|
+
const {
|
|
63
|
+
children,
|
|
64
|
+
styles
|
|
65
|
+
} = this.props;
|
|
66
|
+
const {
|
|
67
|
+
isStacked
|
|
68
|
+
} = this.context;
|
|
61
69
|
return (0, _jsxRuntime.jsx)(_latest.View, {
|
|
62
70
|
..._latest.View.omitViewProps((0, _omitProps.omitProps)(this.props, Body.allowedProps), Body),
|
|
63
71
|
as: isStacked ? 'div' : 'tbody',
|
|
64
|
-
css: styles
|
|
65
|
-
role: isStacked ? 'rowgroup' :
|
|
72
|
+
css: styles?.body,
|
|
73
|
+
role: isStacked ? 'rowgroup' : undefined,
|
|
66
74
|
children: _react.Children.map(children, child => {
|
|
67
75
|
if (/*#__PURE__*/(0, _react.isValidElement)(child)) {
|
|
68
76
|
return (0, _safeCloneElement.safeCloneElement)(child, {
|
|
@@ -73,7 +81,5 @@ let Body = exports.Body = (_dec = (0, _emotion.withStyle)(_styles.default), _dec
|
|
|
73
81
|
})
|
|
74
82
|
});
|
|
75
83
|
}
|
|
76
|
-
}
|
|
77
|
-
children: null
|
|
78
|
-
}, _Body)) || _class);
|
|
84
|
+
}) || _class);
|
|
79
85
|
var _default = exports.default = Body;
|
|
@@ -14,7 +14,7 @@ var _styles = _interopRequireDefault(require("./styles"));
|
|
|
14
14
|
var _props = require("./props");
|
|
15
15
|
var _TableContext = _interopRequireDefault(require("../TableContext"));
|
|
16
16
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
17
|
-
var _dec, _class
|
|
17
|
+
var _dec, _class;
|
|
18
18
|
/*
|
|
19
19
|
* The MIT License (MIT)
|
|
20
20
|
*
|
|
@@ -44,31 +44,35 @@ parent: Table
|
|
|
44
44
|
id: Table.Cell
|
|
45
45
|
---
|
|
46
46
|
**/
|
|
47
|
-
let Cell = exports.Cell = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class =
|
|
47
|
+
let Cell = exports.Cell = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class = class Cell extends _react.Component {
|
|
48
|
+
static displayName = "Cell";
|
|
49
|
+
static componentId = 'Table.Cell';
|
|
50
|
+
static contextType = _TableContext.default;
|
|
51
|
+
static allowedProps = _props.allowedProps;
|
|
52
|
+
static defaultProps = {
|
|
53
|
+
textAlign: 'start',
|
|
54
|
+
children: null
|
|
55
|
+
};
|
|
48
56
|
componentDidMount() {
|
|
49
|
-
|
|
50
|
-
(_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?.();
|
|
51
58
|
}
|
|
52
59
|
componentDidUpdate() {
|
|
53
|
-
|
|
54
|
-
(_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?.();
|
|
55
61
|
}
|
|
56
62
|
render() {
|
|
57
|
-
const
|
|
58
|
-
children
|
|
59
|
-
styles
|
|
60
|
-
header
|
|
63
|
+
const {
|
|
64
|
+
children,
|
|
65
|
+
styles,
|
|
66
|
+
header
|
|
67
|
+
} = this.props;
|
|
61
68
|
const isStacked = this.context.isStacked;
|
|
62
69
|
return (0, _jsxRuntime.jsxs)(_latest.View, {
|
|
63
70
|
..._latest.View.omitViewProps((0, _omitProps.omitProps)(this.props, Cell.allowedProps), Cell),
|
|
64
71
|
as: isStacked ? 'div' : 'td',
|
|
65
|
-
css: styles
|
|
66
|
-
role: isStacked ? 'cell' :
|
|
72
|
+
css: styles?.cell,
|
|
73
|
+
role: isStacked ? 'cell' : undefined,
|
|
67
74
|
children: [header && (0, _callRenderProp.callRenderProp)(header), header && ': ', (0, _callRenderProp.callRenderProp)(children)]
|
|
68
75
|
});
|
|
69
76
|
}
|
|
70
|
-
}
|
|
71
|
-
textAlign: 'start',
|
|
72
|
-
children: null
|
|
73
|
-
}, _Cell)) || _class);
|
|
77
|
+
}) || _class);
|
|
74
78
|
var _default = exports.default = Cell;
|
|
@@ -38,7 +38,9 @@ exports.default = void 0;
|
|
|
38
38
|
* @return {Object} The final style object, which will be used in the component
|
|
39
39
|
*/
|
|
40
40
|
const generateStyle = (componentTheme, props) => {
|
|
41
|
-
const
|
|
41
|
+
const {
|
|
42
|
+
textAlign
|
|
43
|
+
} = props;
|
|
42
44
|
return {
|
|
43
45
|
cell: {
|
|
44
46
|
label: 'cell',
|
|
@@ -13,7 +13,7 @@ var _styles = _interopRequireDefault(require("./styles"));
|
|
|
13
13
|
var _props = require("./props");
|
|
14
14
|
var _uiIcons = require("@instructure/ui-icons");
|
|
15
15
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
16
|
-
var _dec, _class
|
|
16
|
+
var _dec, _class;
|
|
17
17
|
/*
|
|
18
18
|
* The MIT License (MIT)
|
|
19
19
|
*
|
|
@@ -43,61 +43,68 @@ parent: Table
|
|
|
43
43
|
id: Table.ColHeader
|
|
44
44
|
---
|
|
45
45
|
**/
|
|
46
|
-
let ColHeader = exports.ColHeader = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
};
|
|
57
|
-
}
|
|
46
|
+
let ColHeader = exports.ColHeader = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class = class ColHeader extends _react.Component {
|
|
47
|
+
static displayName = "ColHeader";
|
|
48
|
+
static componentId = 'Table.ColHeader';
|
|
49
|
+
static allowedProps = _props.allowedProps;
|
|
50
|
+
static defaultProps = {
|
|
51
|
+
textAlign: 'start',
|
|
52
|
+
sortDirection: 'none',
|
|
53
|
+
children: null,
|
|
54
|
+
scope: 'col'
|
|
55
|
+
};
|
|
58
56
|
componentDidMount() {
|
|
59
|
-
|
|
60
|
-
(_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
|
|
57
|
+
this.props.makeStyles?.();
|
|
61
58
|
}
|
|
62
59
|
componentDidUpdate() {
|
|
63
|
-
|
|
64
|
-
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
|
|
60
|
+
this.props.makeStyles?.();
|
|
65
61
|
}
|
|
62
|
+
handleClick = event => {
|
|
63
|
+
const {
|
|
64
|
+
id,
|
|
65
|
+
onRequestSort
|
|
66
|
+
} = this.props;
|
|
67
|
+
onRequestSort && onRequestSort(event, {
|
|
68
|
+
id
|
|
69
|
+
});
|
|
70
|
+
};
|
|
66
71
|
renderSortArrow() {
|
|
67
|
-
const
|
|
68
|
-
sortDirection
|
|
69
|
-
onRequestSort
|
|
72
|
+
const {
|
|
73
|
+
sortDirection,
|
|
74
|
+
onRequestSort
|
|
75
|
+
} = this.props;
|
|
70
76
|
if (sortDirection === 'ascending') {
|
|
71
|
-
return
|
|
77
|
+
return (0, _jsxRuntime.jsx)(_uiIcons.ChevronUpInstUIIcon, {
|
|
72
78
|
color: "infoColor",
|
|
73
79
|
size: "sm"
|
|
74
|
-
})
|
|
80
|
+
});
|
|
75
81
|
}
|
|
76
82
|
if (sortDirection === 'descending') {
|
|
77
|
-
return
|
|
83
|
+
return (0, _jsxRuntime.jsx)(_uiIcons.ChevronDownInstUIIcon, {
|
|
78
84
|
color: "infoColor",
|
|
79
85
|
size: "sm"
|
|
80
|
-
})
|
|
86
|
+
});
|
|
81
87
|
}
|
|
82
88
|
if (onRequestSort) {
|
|
83
|
-
return
|
|
89
|
+
return (0, _jsxRuntime.jsx)(_uiIcons.ChevronsUpDownInstUIIcon, {
|
|
84
90
|
color: "baseColor",
|
|
85
91
|
size: "sm"
|
|
86
|
-
})
|
|
92
|
+
});
|
|
87
93
|
}
|
|
88
|
-
return
|
|
94
|
+
return undefined;
|
|
89
95
|
}
|
|
90
96
|
render() {
|
|
91
|
-
const
|
|
92
|
-
onRequestSort
|
|
93
|
-
width
|
|
94
|
-
children
|
|
95
|
-
sortDirection
|
|
96
|
-
scope
|
|
97
|
-
styles
|
|
97
|
+
const {
|
|
98
|
+
onRequestSort,
|
|
99
|
+
width,
|
|
100
|
+
children,
|
|
101
|
+
sortDirection,
|
|
102
|
+
scope,
|
|
103
|
+
styles
|
|
104
|
+
} = this.props;
|
|
98
105
|
return (0, _jsxRuntime.jsxs)("th", {
|
|
99
106
|
...(0, _omitProps.omitProps)(this.props, ColHeader.allowedProps),
|
|
100
|
-
css: styles
|
|
107
|
+
css: styles?.colHeader,
|
|
101
108
|
style: {
|
|
102
109
|
width
|
|
103
110
|
},
|
|
@@ -105,18 +112,13 @@ let ColHeader = exports.ColHeader = (_dec = (0, _emotion.withStyle)(_styles.defa
|
|
|
105
112
|
"aria-sort": sortDirection,
|
|
106
113
|
children: [onRequestSort && (0, _jsxRuntime.jsx)("button", {
|
|
107
114
|
onClick: this.handleClick,
|
|
108
|
-
css: styles
|
|
115
|
+
css: styles?.button,
|
|
109
116
|
children: (0, _jsxRuntime.jsxs)("div", {
|
|
110
|
-
css: styles
|
|
117
|
+
css: styles?.buttonContent,
|
|
111
118
|
children: [(0, _callRenderProp.callRenderProp)(children), this.renderSortArrow()]
|
|
112
119
|
})
|
|
113
120
|
}), !onRequestSort && children, !onRequestSort && this.renderSortArrow()]
|
|
114
121
|
});
|
|
115
122
|
}
|
|
116
|
-
}
|
|
117
|
-
textAlign: 'start',
|
|
118
|
-
sortDirection: 'none',
|
|
119
|
-
children: null,
|
|
120
|
-
scope: 'col'
|
|
121
|
-
}, _ColHeader)) || _class);
|
|
123
|
+
}) || _class);
|
|
122
124
|
var _default = exports.default = ColHeader;
|
|
@@ -39,8 +39,10 @@ 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, sharedTokens) => {
|
|
42
|
-
const
|
|
43
|
-
|
|
42
|
+
const {
|
|
43
|
+
onRequestSort,
|
|
44
|
+
textAlign
|
|
45
|
+
} = props;
|
|
44
46
|
const headerStyle = {
|
|
45
47
|
color: componentTheme.color,
|
|
46
48
|
fontSize: componentTheme.fontSize,
|