@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,12 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = exports.Head = void 0;
8
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
8
  var _react = require("react");
10
9
  var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
11
10
  var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
12
11
  var _latest = require("@instructure/ui-simple-select/latest");
13
- var _ScreenReaderContent2 = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
12
+ var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
14
13
  var _uiIcons = require("@instructure/ui-icons");
15
14
  var _console = require("@instructure/console");
16
15
  var _emotion = require("@instructure/emotion");
@@ -18,7 +17,7 @@ var _styles = _interopRequireDefault(require("./styles"));
18
17
  var _props = require("./props");
19
18
  var _TableContext = _interopRequireDefault(require("../TableContext"));
20
19
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
21
- var _dec, _class, _Head, _ScreenReaderContent, _CheckInstUIIcon, _CheckInstUIIcon2, _CheckInstUIIcon3;
20
+ var _dec, _class;
22
21
  /*
23
22
  * The MIT License (MIT)
24
23
  *
@@ -48,19 +47,24 @@ parent: Table
48
47
  id: Table.Head
49
48
  ---
50
49
  **/
51
- let Head = exports.Head = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class = (_Head = class Head extends _react.Component {
50
+ let Head = exports.Head = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class = class Head extends _react.Component {
51
+ static displayName = "Head";
52
+ static componentId = 'Table.Head';
53
+ static contextType = _TableContext.default;
54
+ static allowedProps = _props.allowedProps;
55
+ static defaultProps = {
56
+ children: null
57
+ };
58
+
52
59
  /**
53
60
  * Returns `true` if the first child's children have a `onRequestSort` prop
54
61
  */
55
62
  get isSortable() {
56
- const _ref = _react.Children.toArray(this.props.children),
57
- _ref2 = (0, _slicedToArray2.default)(_ref, 1),
58
- firstRow = _ref2[0];
63
+ const [firstRow] = _react.Children.toArray(this.props.children);
59
64
  let sortable = false;
60
65
  if (firstRow && firstRow.props && firstRow.props.children) {
61
66
  _react.Children.forEach(firstRow.props.children, grandchild => {
62
- var _grandchild$props;
63
- if (grandchild !== null && grandchild !== void 0 && (_grandchild$props = grandchild.props) !== null && _grandchild$props !== void 0 && _grandchild$props.onRequestSort) {
67
+ if (grandchild?.props?.onRequestSort) {
64
68
  sortable = true;
65
69
  return;
66
70
  }
@@ -69,15 +73,13 @@ let Head = exports.Head = (_dec = (0, _emotion.withStyle)(_styles.default), _dec
69
73
  return sortable;
70
74
  }
71
75
  componentDidMount() {
72
- var _this$props$makeStyle, _this$props;
73
- (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
76
+ this.props.makeStyles?.();
74
77
  }
75
78
  componentDidUpdate() {
76
- var _this$props$makeStyle2, _this$props2;
77
79
  if (this.isSortable && typeof this.props.renderSortLabel === 'undefined') {
78
80
  (0, _console.warn)(false, '[Table.Head] The `renderSortLabel` prop should be provided when Table is sortable.');
79
81
  }
80
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
82
+ this.props.makeStyles?.();
81
83
  }
82
84
 
83
85
  /**
@@ -86,14 +88,12 @@ let Head = exports.Head = (_dec = (0, _emotion.withStyle)(_styles.default), _dec
86
88
  * there the `id`, `stackedSortByLabel`, `sortDirection`, `onRequestSort` props
87
89
  */
88
90
  renderSelect() {
89
- var _firstRow$props;
90
- const _this$props3 = this.props,
91
- children = _this$props3.children,
92
- renderSortLabel = _this$props3.renderSortLabel;
93
- const _ref3 = _react.Children.toArray(children),
94
- _ref4 = (0, _slicedToArray2.default)(_ref3, 1),
95
- firstRow = _ref4[0];
96
- if (!(firstRow !== null && firstRow !== void 0 && (_firstRow$props = firstRow.props) !== null && _firstRow$props !== void 0 && _firstRow$props.children)) {
91
+ const {
92
+ children,
93
+ renderSortLabel
94
+ } = this.props;
95
+ const [firstRow] = _react.Children.toArray(children);
96
+ if (!firstRow?.props?.children) {
97
97
  return null;
98
98
  }
99
99
  const options = [];
@@ -102,12 +102,13 @@ let Head = exports.Head = (_dec = (0, _emotion.withStyle)(_styles.default), _dec
102
102
  let count = 0;
103
103
  _react.Children.forEach(firstRow.props.children, grandchild => {
104
104
  count += 1;
105
- if (!(grandchild !== null && grandchild !== void 0 && grandchild.props)) return; // grandchild can be false
106
- const _grandchild$props2 = grandchild.props,
107
- id = _grandchild$props2.id,
108
- stackedSortByLabel = _grandchild$props2.stackedSortByLabel,
109
- sortDirection = _grandchild$props2.sortDirection,
110
- onRequestSort = _grandchild$props2.onRequestSort;
105
+ if (!grandchild?.props) return; // grandchild can be false
106
+ const {
107
+ id,
108
+ stackedSortByLabel,
109
+ sortDirection,
110
+ onRequestSort
111
+ } = grandchild.props;
111
112
  if (id && onRequestSort) {
112
113
  const label = stackedSortByLabel || id;
113
114
  options.push({
@@ -140,8 +141,8 @@ let Head = exports.Head = (_dec = (0, _emotion.withStyle)(_styles.default), _dec
140
141
  role: "cell",
141
142
  "aria-colspan": count,
142
143
  children: (0, _jsxRuntime.jsx)(_latest.SimpleSelect, {
143
- renderLabel: renderSortLabel ? (0, _callRenderProp.callRenderProp)(renderSortLabel) : _ScreenReaderContent || (_ScreenReaderContent = (0, _jsxRuntime.jsx)(_ScreenReaderContent2.ScreenReaderContent, {})),
144
- renderBeforeInput: selectedOption ? () => _CheckInstUIIcon || (_CheckInstUIIcon = (0, _jsxRuntime.jsx)(_uiIcons.CheckInstUIIcon, {})) : void 0,
144
+ renderLabel: renderSortLabel ? (0, _callRenderProp.callRenderProp)(renderSortLabel) : (0, _jsxRuntime.jsx)(_ScreenReaderContent.ScreenReaderContent, {}),
145
+ renderBeforeInput: selectedOption ? () => (0, _jsxRuntime.jsx)(_uiIcons.CheckInstUIIcon, {}) : undefined,
145
146
  value: selectedOption,
146
147
  onChange: handleSelect,
147
148
  children: options.map(({
@@ -150,11 +151,11 @@ let Head = exports.Head = (_dec = (0, _emotion.withStyle)(_styles.default), _dec
150
151
  }) => (0, _jsxRuntime.jsx)(_latest.SimpleSelect.Option, {
151
152
  id: id,
152
153
  value: id,
153
- renderBeforeLabel: id === selectedOption ? () => _CheckInstUIIcon2 || (_CheckInstUIIcon2 = (0, _jsxRuntime.jsx)(_uiIcons.CheckInstUIIcon, {})) : () => (0, _jsxRuntime.jsx)("span", {
154
+ renderBeforeLabel: id === selectedOption ? () => (0, _jsxRuntime.jsx)(_uiIcons.CheckInstUIIcon, {}) : () => (0, _jsxRuntime.jsx)("span", {
154
155
  style: {
155
156
  visibility: 'hidden'
156
157
  },
157
- children: _CheckInstUIIcon3 || (_CheckInstUIIcon3 = (0, _jsxRuntime.jsx)(_uiIcons.CheckInstUIIcon, {}))
158
+ children: (0, _jsxRuntime.jsx)(_uiIcons.CheckInstUIIcon, {})
158
159
  }),
159
160
  children: label
160
161
  }, id))
@@ -164,16 +165,15 @@ let Head = exports.Head = (_dec = (0, _emotion.withStyle)(_styles.default), _dec
164
165
  });
165
166
  }
166
167
  render() {
167
- const _this$props4 = this.props,
168
- children = _this$props4.children,
169
- styles = _this$props4.styles;
168
+ const {
169
+ children,
170
+ styles
171
+ } = this.props;
170
172
  return this.context.isStacked ? this.renderSelect() : (0, _jsxRuntime.jsx)("thead", {
171
173
  ...(0, _omitProps.omitProps)(this.props, Head.allowedProps),
172
- css: styles === null || styles === void 0 ? void 0 : styles.head,
174
+ css: styles?.head,
173
175
  children: children
174
176
  });
175
177
  }
176
- }, _Head.displayName = "Head", _Head.componentId = 'Table.Head', _Head.contextType = _TableContext.default, _Head.allowedProps = _props.allowedProps, _Head.defaultProps = {
177
- children: null
178
- }, _Head)) || _class);
178
+ }) || _class);
179
179
  var _default = exports.default = Head;
@@ -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, _Row;
17
+ var _dec, _class;
18
18
  /*
19
19
  * The MIT License (MIT)
20
20
  *
@@ -44,32 +44,38 @@ parent: Table
44
44
  id: Table.Row
45
45
  ---
46
46
  **/
47
- let Row = exports.Row = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class = (_Row = class Row extends _react.Component {
47
+ let Row = exports.Row = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class = class Row extends _react.Component {
48
+ static displayName = "Row";
49
+ static componentId = 'Table.Row';
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
  isStacked: this.context.isStacked,
52
58
  hover: this.context.hover
53
59
  });
54
60
  }
55
61
  componentDidUpdate() {
56
- var _this$props$makeStyle2, _this$props2;
57
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, {
62
+ this.props.makeStyles?.({
58
63
  isStacked: this.context.isStacked,
59
64
  hover: this.context.hover
60
65
  });
61
66
  }
62
67
  render() {
63
- const _this$props3 = this.props,
64
- children = _this$props3.children,
65
- styles = _this$props3.styles;
68
+ const {
69
+ children,
70
+ styles
71
+ } = this.props;
66
72
  const isStacked = this.context.isStacked;
67
73
  const headers = this.context.headers;
68
74
  return (0, _jsxRuntime.jsx)(_latest.View, {
69
75
  ..._latest.View.omitViewProps((0, _omitProps.omitProps)(this.props, Row.allowedProps), Row),
70
76
  as: isStacked ? 'div' : 'tr',
71
- css: styles === null || styles === void 0 ? void 0 : styles.row,
72
- role: isStacked ? 'row' : void 0,
77
+ css: styles?.row,
78
+ role: isStacked ? 'row' : undefined,
73
79
  children: _react.Children.toArray(children).filter(Boolean).map((child, index) => {
74
80
  if (/*#__PURE__*/(0, _react.isValidElement)(child)) {
75
81
  return (0, _safeCloneElement.safeCloneElement)(child, {
@@ -82,7 +88,5 @@ let Row = exports.Row = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_
82
88
  })
83
89
  });
84
90
  }
85
- }, _Row.displayName = "Row", _Row.componentId = 'Table.Row', _Row.contextType = _TableContext.default, _Row.allowedProps = _props.allowedProps, _Row.defaultProps = {
86
- children: null
87
- }, _Row)) || _class);
91
+ }) || _class);
88
92
  var _default = exports.default = Row;
@@ -40,7 +40,9 @@ exports.default = void 0;
40
40
  * @return {Object} The final style object, which will be used in the component
41
41
  */
42
42
  const generateStyle = (componentTheme, props, _sharedTokens, extraArgs) => {
43
- const setHoverStateTo = props.setHoverStateTo;
43
+ const {
44
+ setHoverStateTo
45
+ } = props;
44
46
  const hoverStyles = {
45
47
  borderLeftColor: componentTheme.hoverBorderColor,
46
48
  borderRightColor: componentTheme.hoverBorderColor
@@ -57,7 +59,7 @@ const generateStyle = (componentTheme, props, _sharedTokens, extraArgs) => {
57
59
  borderBottomStyle: 'solid',
58
60
  borderBottomWidth: '0.0625rem',
59
61
  borderBottomColor: componentTheme.borderColor,
60
- ...((setHoverStateTo !== null && setHoverStateTo !== void 0 ? setHoverStateTo : extraArgs.hover) && {
62
+ ...((setHoverStateTo ?? extraArgs.hover) && {
61
63
  borderLeft: '0.1875rem solid transparent',
62
64
  borderRight: '0.1875rem solid transparent',
63
65
  ...(setHoverStateTo === true ? hoverStyles : {
@@ -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, _RowHeader;
17
+ var _dec, _class;
18
18
  /*
19
19
  * The MIT License (MIT)
20
20
  *
@@ -44,31 +44,35 @@ parent: Table
44
44
  id: Table.RowHeader
45
45
  ---
46
46
  **/
47
- let RowHeader = exports.RowHeader = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class = (_RowHeader = class RowHeader extends _react.Component {
47
+ let RowHeader = exports.RowHeader = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class = class RowHeader extends _react.Component {
48
+ static displayName = "RowHeader";
49
+ static componentId = 'Table.RowHeader';
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;
63
+ const {
64
+ children,
65
+ styles
66
+ } = this.props;
60
67
  const isStacked = this.context.isStacked;
61
68
  return (0, _jsxRuntime.jsx)(_latest.View, {
62
69
  ..._latest.View.omitViewProps((0, _omitProps.omitProps)(this.props, RowHeader.allowedProps), RowHeader),
63
70
  as: isStacked ? 'div' : 'th',
64
- css: styles === null || styles === void 0 ? void 0 : styles.rowHeader,
71
+ css: styles?.rowHeader,
65
72
  scope: "row",
66
- role: isStacked ? 'rowheader' : void 0,
73
+ role: isStacked ? 'rowheader' : undefined,
67
74
  children: (0, _callRenderProp.callRenderProp)(children)
68
75
  });
69
76
  }
70
- }, _RowHeader.displayName = "RowHeader", _RowHeader.componentId = 'Table.RowHeader', _RowHeader.contextType = _TableContext.default, _RowHeader.allowedProps = _props.allowedProps, _RowHeader.defaultProps = {
71
- textAlign: 'start',
72
- children: null
73
- }, _RowHeader)) || _class);
77
+ }) || _class);
74
78
  var _default = exports.default = RowHeader;
@@ -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
  rowHeader: {
44
46
  label: 'rowHeader',
@@ -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");
@@ -23,7 +22,7 @@ var _props = require("./props");
23
22
  var _TableContext = _interopRequireDefault(require("./TableContext"));
24
23
  var _console = require("@instructure/console");
25
24
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
26
- var _dec, _class, _Table;
25
+ var _dec, _class;
27
26
  /*
28
27
  * The MIT License (MIT)
29
28
  *
@@ -52,34 +51,42 @@ var _dec, _class, _Table;
52
51
  category: components
53
52
  ---
54
53
  **/
55
- let Table = exports.Table = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class = (_Table = class Table extends _react.Component {
56
- constructor(...args) {
57
- super(...args);
58
- this.ref = null;
59
- // Reference to hidden aria-live region for announcing caption changes to screen readers
60
- this._liveRegionRef = null;
61
- // Timeout for delayed announcement (workaround for Safari/VoiceOver caption update bug)
62
- this._announcementTimeout = void 0;
63
- this.handleRef = el => {
64
- var _this$props$elementRe, _this$props;
65
- this.ref = el;
66
- (_this$props$elementRe = (_this$props = this.props).elementRef) === null || _this$props$elementRe === void 0 ? void 0 : _this$props$elementRe.call(_this$props, el);
67
- };
68
- }
54
+ let Table = exports.Table = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class = class Table extends _react.Component {
55
+ static displayName = "Table";
56
+ static componentId = 'Table';
57
+ static allowedProps = _props.allowedProps;
58
+ static defaultProps = {
59
+ children: null,
60
+ hover: false,
61
+ layout: 'auto'
62
+ };
63
+ static Head = _Head.Head;
64
+ static Body = _Body.Body;
65
+ static Row = _Row.Row;
66
+ static ColHeader = _ColHeader.ColHeader;
67
+ static RowHeader = _RowHeader.RowHeader;
68
+ static Cell = _Cell.Cell;
69
+ ref = null;
70
+ // Reference to hidden aria-live region for announcing caption changes to screen readers
71
+ _liveRegionRef = null;
72
+ // Timeout for delayed announcement (workaround for Safari/VoiceOver caption update bug)
73
+ _announcementTimeout;
74
+ handleRef = el => {
75
+ this.ref = el;
76
+ this.props.elementRef?.(el);
77
+ };
69
78
  componentDidMount() {
70
- var _this$props$makeStyle, _this$props2;
71
- (_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
79
+ this.props.makeStyles?.();
72
80
  }
73
81
  componentDidUpdate(prevProps) {
74
- var _this$props$makeStyle2, _this$props3;
75
- (_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
82
+ this.props.makeStyles?.();
76
83
  // Announce caption changes for screen readers (especially VoiceOver)
77
84
  // Safari/VoiceOver has a known bug where dynamic <caption> updates aren't announced,
78
85
  // so we use an aria-live region as a workaround
79
86
  const prevSortInfo = this.getSortedHeaderInfo(prevProps);
80
87
  const currentSortInfo = this.getSortedHeaderInfo(this.props);
81
88
  // Only announce if sorting actually changed
82
- 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);
89
+ const sortingChanged = prevSortInfo?.header !== currentSortInfo?.header || prevSortInfo?.direction !== currentSortInfo?.direction;
83
90
  if (sortingChanged && currentSortInfo && this._liveRegionRef) {
84
91
  // Clear any pending announcement
85
92
  clearTimeout(this._announcementTimeout);
@@ -101,33 +108,24 @@ let Table = exports.Table = (_dec = (0, _emotion.withStyle)(_styles.default), _d
101
108
  clearTimeout(this._announcementTimeout);
102
109
  }
103
110
  getHeaders() {
104
- const _Children$toArray = _react.Children.toArray(this.props.children),
105
- _Children$toArray2 = (0, _slicedToArray2.default)(_Children$toArray, 1),
106
- headChild = _Children$toArray2[0];
107
- if (!headChild || ! /*#__PURE__*/(0, _react.isValidElement)(headChild)) return void 0;
108
- const _Children$toArray3 = _react.Children.toArray(headChild.props.children),
109
- _Children$toArray4 = (0, _slicedToArray2.default)(_Children$toArray3, 1),
110
- firstRow = _Children$toArray4[0];
111
- if (!firstRow || ! /*#__PURE__*/(0, _react.isValidElement)(firstRow)) return void 0;
111
+ const [headChild] = _react.Children.toArray(this.props.children);
112
+ if (!headChild || ! /*#__PURE__*/(0, _react.isValidElement)(headChild)) return undefined;
113
+ const [firstRow] = _react.Children.toArray(headChild.props.children);
114
+ if (!firstRow || ! /*#__PURE__*/(0, _react.isValidElement)(firstRow)) return undefined;
112
115
  return _react.Children.map(firstRow.props.children, colHeader => {
113
- if (! /*#__PURE__*/(0, _react.isValidElement)(colHeader)) return void 0;
116
+ if (! /*#__PURE__*/(0, _react.isValidElement)(colHeader)) return undefined;
114
117
  return colHeader.props.children;
115
118
  });
116
119
  }
117
120
  getSortedHeaderInfo(props) {
118
- const _Children$toArray5 = _react.Children.toArray(props.children),
119
- _Children$toArray6 = (0, _slicedToArray2.default)(_Children$toArray5, 1),
120
- headChild = _Children$toArray6[0];
121
- const _Children$toArray7 = _react.Children.toArray(/*#__PURE__*/(0, _react.isValidElement)(headChild) ? headChild.props.children : []),
122
- _Children$toArray8 = (0, _slicedToArray2.default)(_Children$toArray7, 1),
123
- firstRow = _Children$toArray8[0];
121
+ const [headChild] = _react.Children.toArray(props.children);
122
+ const [firstRow] = _react.Children.toArray(/*#__PURE__*/(0, _react.isValidElement)(headChild) ? headChild.props.children : []);
124
123
  const colHeaders = _react.Children.toArray(/*#__PURE__*/(0, _react.isValidElement)(firstRow) ? firstRow.props.children : []);
125
124
  // Find the column with an active sort direction
126
125
  for (const colHeader of colHeaders) {
127
126
  if (/*#__PURE__*/(0, _react.isValidElement)(colHeader) && colHeader.props.sortDirection && colHeader.props.sortDirection !== 'none') {
128
- var _colHeader$props$chil, _colHeader$props$chil2, _colHeader$props$chil3;
129
127
  // Extract header text (may be nested in child components)
130
- 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 : '';
128
+ const headerText = typeof colHeader.props.children === 'string' ? colHeader.props.children : colHeader.props.children?.props?.children ?? '';
131
129
  return {
132
130
  header: headerText,
133
131
  direction: colHeader.props.sortDirection
@@ -144,14 +142,15 @@ let Table = exports.Table = (_dec = (0, _emotion.withStyle)(_styles.default), _d
144
142
  return caption ? caption + sortText : sortText.trim();
145
143
  }
146
144
  render() {
147
- const _this$props4 = this.props,
148
- margin = _this$props4.margin,
149
- layout = _this$props4.layout,
150
- caption = _this$props4.caption,
151
- children = _this$props4.children,
152
- hover = _this$props4.hover,
153
- styles = _this$props4.styles,
154
- minWidth = _this$props4.minWidth;
145
+ const {
146
+ margin,
147
+ layout,
148
+ caption,
149
+ children,
150
+ hover,
151
+ styles,
152
+ minWidth
153
+ } = this.props;
155
154
  const isStacked = layout === 'stacked';
156
155
  const captionText = this.getCaptionText(this.props);
157
156
  if (!caption) {
@@ -161,7 +160,7 @@ let Table = exports.Table = (_dec = (0, _emotion.withStyle)(_styles.default), _d
161
160
  value: {
162
161
  isStacked,
163
162
  hover: hover,
164
- headers: isStacked ? this.getHeaders() : void 0
163
+ headers: isStacked ? this.getHeaders() : undefined
165
164
  },
166
165
  children: [(0, _jsxRuntime.jsx)("div", {
167
166
  ref: el => {
@@ -170,7 +169,7 @@ let Table = exports.Table = (_dec = (0, _emotion.withStyle)(_styles.default), _d
170
169
  "aria-live": "polite",
171
170
  "aria-atomic": "true",
172
171
  role: "status",
173
- css: styles === null || styles === void 0 ? void 0 : styles.liveRegion
172
+ css: styles?.liveRegion
174
173
  }), (0, _jsxRuntime.jsxs)(_latest.View
175
174
  // All HTML props, except the ones accepted by `View` and `Table`
176
175
  , {
@@ -179,8 +178,8 @@ let Table = exports.Table = (_dec = (0, _emotion.withStyle)(_styles.default), _d
179
178
  as: isStacked ? 'div' : 'table',
180
179
  margin: margin,
181
180
  elementRef: this.handleRef,
182
- css: styles === null || styles === void 0 ? void 0 : styles.table,
183
- role: isStacked ? 'table' : void 0,
181
+ css: styles?.table,
182
+ role: isStacked ? 'table' : undefined,
184
183
  "aria-label": captionText,
185
184
  children: [!isStacked && caption && (0, _jsxRuntime.jsx)("caption", {
186
185
  children: (0, _jsxRuntime.jsx)(_ScreenReaderContent.ScreenReaderContent, {
@@ -192,9 +191,5 @@ let Table = exports.Table = (_dec = (0, _emotion.withStyle)(_styles.default), _d
192
191
  })]
193
192
  });
194
193
  }
195
- }, _Table.displayName = "Table", _Table.componentId = 'Table', _Table.allowedProps = _props.allowedProps, _Table.defaultProps = {
196
- children: null,
197
- hover: false,
198
- layout: 'auto'
199
- }, _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);
194
+ }) || _class);
200
195
  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, _sharedTokens) => {
42
- const layout = props.layout;
42
+ const {
43
+ layout
44
+ } = props;
43
45
  return {
44
46
  table: {
45
47
  label: 'table',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-table",
3
- "version": "11.7.3-snapshot-7",
3
+ "version": "11.7.3-snapshot-26",
4
4
  "description": "A styled HTML table component",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -14,26 +14,26 @@
14
14
  "bugs": "https://github.com/instructure/instructure-ui/issues",
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
- "@babel/runtime": "^7.27.6",
18
- "@instructure/console": "11.7.3-snapshot-7",
19
- "@instructure/emotion": "11.7.3-snapshot-7",
20
- "@instructure/shared-types": "11.7.3-snapshot-7",
21
- "@instructure/ui-icons": "11.7.3-snapshot-7",
22
- "@instructure/ui-a11y-content": "11.7.3-snapshot-7",
23
- "@instructure/ui-simple-select": "11.7.3-snapshot-7",
24
- "@instructure/ui-view": "11.7.3-snapshot-7",
25
- "@instructure/ui-utils": "11.7.3-snapshot-7",
26
- "@instructure/ui-react-utils": "11.7.3-snapshot-7",
27
- "@instructure/ui-themes": "11.7.3-snapshot-7"
17
+ "@babel/runtime": "^7.29.2",
18
+ "@instructure/console": "11.7.3-snapshot-26",
19
+ "@instructure/shared-types": "11.7.3-snapshot-26",
20
+ "@instructure/emotion": "11.7.3-snapshot-26",
21
+ "@instructure/ui-a11y-content": "11.7.3-snapshot-26",
22
+ "@instructure/ui-icons": "11.7.3-snapshot-26",
23
+ "@instructure/ui-simple-select": "11.7.3-snapshot-26",
24
+ "@instructure/ui-themes": "11.7.3-snapshot-26",
25
+ "@instructure/ui-utils": "11.7.3-snapshot-26",
26
+ "@instructure/ui-view": "11.7.3-snapshot-26",
27
+ "@instructure/ui-react-utils": "11.7.3-snapshot-26"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@testing-library/jest-dom": "^6.6.3",
31
31
  "@testing-library/react": "15.0.7",
32
32
  "@testing-library/user-event": "^14.6.1",
33
33
  "vitest": "^3.2.2",
34
- "@instructure/ui-axe-check": "11.7.3-snapshot-7",
35
- "@instructure/ui-color-utils": "11.7.3-snapshot-7",
36
- "@instructure/ui-babel-preset": "11.7.3-snapshot-7"
34
+ "@instructure/ui-axe-check": "11.7.3-snapshot-26",
35
+ "@instructure/ui-babel-preset": "11.7.3-snapshot-26",
36
+ "@instructure/ui-color-utils": "11.7.3-snapshot-26"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "react": ">=18 <=19"