@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.
Files changed (65) hide show
  1. package/CHANGELOG.md +5 -2
  2. package/es/Table/v1/Body/index.js +21 -15
  3. package/es/Table/v1/Body/theme.js +9 -8
  4. package/es/Table/v1/Cell/index.js +20 -16
  5. package/es/Table/v1/Cell/styles.js +3 -1
  6. package/es/Table/v1/Cell/theme.js +13 -12
  7. package/es/Table/v1/ColHeader/index.js +43 -41
  8. package/es/Table/v1/ColHeader/styles.js +4 -2
  9. package/es/Table/v1/ColHeader/theme.js +19 -18
  10. package/es/Table/v1/Head/index.js +34 -34
  11. package/es/Table/v1/Head/theme.js +9 -8
  12. package/es/Table/v1/Row/index.js +18 -14
  13. package/es/Table/v1/Row/styles.js +4 -2
  14. package/es/Table/v1/Row/theme.js +14 -13
  15. package/es/Table/v1/RowHeader/index.js +19 -15
  16. package/es/Table/v1/RowHeader/styles.js +3 -1
  17. package/es/Table/v1/RowHeader/theme.js +13 -12
  18. package/es/Table/v1/index.js +50 -55
  19. package/es/Table/v1/styles.js +3 -1
  20. package/es/Table/v1/theme.js +10 -9
  21. package/es/Table/v2/Body/index.js +21 -15
  22. package/es/Table/v2/Cell/index.js +20 -16
  23. package/es/Table/v2/Cell/styles.js +3 -1
  24. package/es/Table/v2/ColHeader/index.js +45 -43
  25. package/es/Table/v2/ColHeader/styles.js +4 -2
  26. package/es/Table/v2/Head/index.js +37 -37
  27. package/es/Table/v2/Row/index.js +18 -14
  28. package/es/Table/v2/Row/styles.js +4 -2
  29. package/es/Table/v2/RowHeader/index.js +19 -15
  30. package/es/Table/v2/RowHeader/styles.js +3 -1
  31. package/es/Table/v2/index.js +50 -55
  32. package/es/Table/v2/styles.js +3 -1
  33. package/lib/Table/v1/Body/index.js +21 -15
  34. package/lib/Table/v1/Body/theme.js +9 -8
  35. package/lib/Table/v1/Cell/index.js +20 -16
  36. package/lib/Table/v1/Cell/styles.js +3 -1
  37. package/lib/Table/v1/Cell/theme.js +13 -12
  38. package/lib/Table/v1/ColHeader/index.js +43 -41
  39. package/lib/Table/v1/ColHeader/styles.js +4 -2
  40. package/lib/Table/v1/ColHeader/theme.js +19 -18
  41. package/lib/Table/v1/Head/index.js +35 -35
  42. package/lib/Table/v1/Head/theme.js +9 -8
  43. package/lib/Table/v1/Row/index.js +18 -14
  44. package/lib/Table/v1/Row/styles.js +4 -2
  45. package/lib/Table/v1/Row/theme.js +14 -13
  46. package/lib/Table/v1/RowHeader/index.js +19 -15
  47. package/lib/Table/v1/RowHeader/styles.js +3 -1
  48. package/lib/Table/v1/RowHeader/theme.js +13 -12
  49. package/lib/Table/v1/index.js +50 -55
  50. package/lib/Table/v1/styles.js +3 -1
  51. package/lib/Table/v1/theme.js +10 -9
  52. package/lib/Table/v2/Body/index.js +21 -15
  53. package/lib/Table/v2/Cell/index.js +20 -16
  54. package/lib/Table/v2/Cell/styles.js +3 -1
  55. package/lib/Table/v2/ColHeader/index.js +45 -43
  56. package/lib/Table/v2/ColHeader/styles.js +4 -2
  57. package/lib/Table/v2/Head/index.js +38 -38
  58. package/lib/Table/v2/Row/index.js +18 -14
  59. package/lib/Table/v2/Row/styles.js +4 -2
  60. package/lib/Table/v2/RowHeader/index.js +19 -15
  61. package/lib/Table/v2/RowHeader/styles.js +3 -1
  62. package/lib/Table/v2/index.js +50 -55
  63. package/lib/Table/v2/styles.js +3 -1
  64. package/package.json +15 -15
  65. package/tsconfig.build.tsbuildinfo +1 -1
@@ -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, _Table;
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 = (_Table = class Table extends _react.Component {
57
- constructor(...args) {
58
- super(...args);
59
- this.ref = null;
60
- // Reference to hidden aria-live region for announcing caption changes to screen readers
61
- this._liveRegionRef = null;
62
- // Timeout for delayed announcement (workaround for Safari/VoiceOver caption update bug)
63
- this._announcementTimeout = void 0;
64
- this.handleRef = el => {
65
- var _this$props$elementRe, _this$props;
66
- this.ref = el;
67
- (_this$props$elementRe = (_this$props = this.props).elementRef) === null || _this$props$elementRe === void 0 ? void 0 : _this$props$elementRe.call(_this$props, el);
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
- var _this$props$makeStyle, _this$props2;
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
- var _this$props$makeStyle2, _this$props3;
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 = (prevSortInfo === null || prevSortInfo === void 0 ? void 0 : prevSortInfo.header) !== (currentSortInfo === null || currentSortInfo === void 0 ? void 0 : currentSortInfo.header) || (prevSortInfo === null || prevSortInfo === void 0 ? void 0 : prevSortInfo.direction) !== (currentSortInfo === null || currentSortInfo === void 0 ? void 0 : currentSortInfo.direction);
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 _Children$toArray = _react.Children.toArray(this.props.children),
106
- _Children$toArray2 = (0, _slicedToArray2.default)(_Children$toArray, 1),
107
- headChild = _Children$toArray2[0];
108
- if (!headChild || ! /*#__PURE__*/(0, _react.isValidElement)(headChild)) return void 0;
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 void 0;
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 _Children$toArray5 = _react.Children.toArray(props.children),
120
- _Children$toArray6 = (0, _slicedToArray2.default)(_Children$toArray5, 1),
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 : (_colHeader$props$chil = (_colHeader$props$chil2 = colHeader.props.children) === null || _colHeader$props$chil2 === void 0 ? void 0 : (_colHeader$props$chil3 = _colHeader$props$chil2.props) === null || _colHeader$props$chil3 === void 0 ? void 0 : _colHeader$props$chil3.children) !== null && _colHeader$props$chil !== void 0 ? _colHeader$props$chil : '';
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 _this$props4 = this.props,
149
- margin = _this$props4.margin,
150
- layout = _this$props4.layout,
151
- caption = _this$props4.caption,
152
- children = _this$props4.children,
153
- hover = _this$props4.hover,
154
- styles = _this$props4.styles,
155
- minWidth = _this$props4.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() : void 0
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 === null || styles === void 0 ? void 0 : styles.liveRegion
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 === null || styles === void 0 ? void 0 : styles.table,
184
- role: isStacked ? 'table' : void 0,
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
- }, _Table.displayName = "Table", _Table.componentId = 'Table', _Table.allowedProps = _props.allowedProps, _Table.defaultProps = {
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;
@@ -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 layout = props.layout;
42
+ const {
43
+ layout
44
+ } = props;
43
45
  return {
44
46
  table: {
45
47
  label: 'table',
@@ -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
- var _colors$contrasts, _colors$contrasts2;
38
- const colors = theme.colors,
39
- typography = theme.typography,
40
- themeName = theme.key;
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 === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
48
- fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
49
- fontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightNormal,
50
- color: colors === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.grey125125,
51
- background: colors === null || colors === void 0 ? void 0 : (_colors$contrasts2 = colors.contrasts) === null || _colors$contrasts2 === void 0 ? void 0 : _colors$contrasts2.white1010
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, _Body;
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 = (_Body = class Body extends _react.Component {
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
- var _this$props$makeStyle, _this$props;
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
- var _this$props$makeStyle2, _this$props2;
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 _this$props3 = this.props,
58
- children = _this$props3.children,
59
- styles = _this$props3.styles;
60
- const isStacked = this.context.isStacked;
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 === null || styles === void 0 ? void 0 : styles.body,
65
- role: isStacked ? 'rowgroup' : void 0,
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
- }, _Body.displayName = "Body", _Body.componentId = 'Table.Body', _Body.contextType = _TableContext.default, _Body.allowedProps = _props.allowedProps, _Body.defaultProps = {
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, _Cell;
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 = (_Cell = class Cell extends _react.Component {
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
- var _this$props$makeStyle, _this$props;
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
- var _this$props$makeStyle2, _this$props2;
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 _this$props3 = this.props,
58
- children = _this$props3.children,
59
- styles = _this$props3.styles,
60
- header = _this$props3.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 === null || styles === void 0 ? void 0 : styles.cell,
66
- role: isStacked ? 'cell' : void 0,
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
- }, _Cell.displayName = "Cell", _Cell.componentId = 'Table.Cell', _Cell.contextType = _TableContext.default, _Cell.allowedProps = _props.allowedProps, _Cell.defaultProps = {
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 textAlign = props.textAlign;
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, _ColHeader, _ChevronUpInstUIIcon, _ChevronDownInstUIIco, _ChevronsUpDownInstUI;
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 = (_ColHeader = class ColHeader extends _react.Component {
47
- constructor(...args) {
48
- super(...args);
49
- this.handleClick = event => {
50
- const _this$props = this.props,
51
- id = _this$props.id,
52
- onRequestSort = _this$props.onRequestSort;
53
- onRequestSort && onRequestSort(event, {
54
- id
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
- var _this$props$makeStyle, _this$props2;
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
- var _this$props$makeStyle2, _this$props3;
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 _this$props4 = this.props,
68
- sortDirection = _this$props4.sortDirection,
69
- onRequestSort = _this$props4.onRequestSort;
72
+ const {
73
+ sortDirection,
74
+ onRequestSort
75
+ } = this.props;
70
76
  if (sortDirection === 'ascending') {
71
- return _ChevronUpInstUIIcon || (_ChevronUpInstUIIcon = (0, _jsxRuntime.jsx)(_uiIcons.ChevronUpInstUIIcon, {
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 _ChevronDownInstUIIco || (_ChevronDownInstUIIco = (0, _jsxRuntime.jsx)(_uiIcons.ChevronDownInstUIIcon, {
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 _ChevronsUpDownInstUI || (_ChevronsUpDownInstUI = (0, _jsxRuntime.jsx)(_uiIcons.ChevronsUpDownInstUIIcon, {
89
+ return (0, _jsxRuntime.jsx)(_uiIcons.ChevronsUpDownInstUIIcon, {
84
90
  color: "baseColor",
85
91
  size: "sm"
86
- }));
92
+ });
87
93
  }
88
- return void 0;
94
+ return undefined;
89
95
  }
90
96
  render() {
91
- const _this$props5 = this.props,
92
- onRequestSort = _this$props5.onRequestSort,
93
- width = _this$props5.width,
94
- children = _this$props5.children,
95
- sortDirection = _this$props5.sortDirection,
96
- scope = _this$props5.scope,
97
- styles = _this$props5.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 === null || styles === void 0 ? void 0 : styles.colHeader,
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 === null || styles === void 0 ? void 0 : styles.button,
115
+ css: styles?.button,
109
116
  children: (0, _jsxRuntime.jsxs)("div", {
110
- css: styles === null || styles === void 0 ? void 0 : styles.buttonContent,
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
- }, _ColHeader.displayName = "ColHeader", _ColHeader.componentId = 'Table.ColHeader', _ColHeader.allowedProps = _props.allowedProps, _ColHeader.defaultProps = {
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 onRequestSort = props.onRequestSort,
43
- textAlign = props.textAlign;
42
+ const {
43
+ onRequestSort,
44
+ textAlign
45
+ } = props;
44
46
  const headerStyle = {
45
47
  color: componentTheme.color,
46
48
  fontSize: componentTheme.fontSize,