@instructure/ui-table 11.7.3 → 11.7.4-pr-snapshot-1781695314229

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 (128) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE.md +1 -0
  3. package/{lib/Table/v1/Cell/props.js → babel.config.cjs} +12 -7
  4. package/es/Table/v1/Body/index.js +6 -5
  5. package/es/Table/v1/Cell/index.js +6 -5
  6. package/es/Table/v1/ColHeader/index.js +5 -4
  7. package/es/Table/v1/Head/index.js +6 -5
  8. package/es/Table/v1/Row/index.js +6 -5
  9. package/es/Table/v1/RowHeader/index.js +6 -5
  10. package/es/Table/v1/index.js +11 -11
  11. package/es/Table/v2/Body/index.js +5 -4
  12. package/es/Table/v2/Cell/index.js +5 -4
  13. package/es/Table/v2/ColHeader/index.js +3 -3
  14. package/es/Table/v2/Head/index.js +5 -4
  15. package/es/Table/v2/Row/index.js +5 -4
  16. package/es/Table/v2/RowHeader/index.js +5 -4
  17. package/es/Table/v2/index.js +10 -10
  18. package/es/exports/a.js +8 -8
  19. package/es/exports/b.js +8 -8
  20. package/package.json +16 -21
  21. package/src/Table/v1/Body/index.tsx +5 -4
  22. package/src/Table/v1/Cell/index.tsx +5 -4
  23. package/src/Table/v1/ColHeader/index.tsx +4 -3
  24. package/src/Table/v1/Head/index.tsx +5 -4
  25. package/src/Table/v1/Head/props.ts +1 -1
  26. package/src/Table/v1/Row/index.tsx +5 -4
  27. package/src/Table/v1/RowHeader/index.tsx +5 -4
  28. package/src/Table/v1/index.tsx +11 -10
  29. package/src/Table/v2/Body/index.tsx +4 -3
  30. package/src/Table/v2/Cell/index.tsx +4 -3
  31. package/src/Table/v2/ColHeader/index.tsx +3 -2
  32. package/src/Table/v2/Head/index.tsx +4 -3
  33. package/src/Table/v2/Head/props.ts +1 -1
  34. package/src/Table/v2/Row/index.tsx +4 -3
  35. package/src/Table/v2/RowHeader/index.tsx +4 -3
  36. package/src/Table/v2/index.tsx +10 -9
  37. package/src/exports/a.ts +8 -8
  38. package/src/exports/b.ts +8 -8
  39. package/tsconfig.build.tsbuildinfo +1 -1
  40. package/types/Table/v1/Body/index.d.ts +3 -2
  41. package/types/Table/v1/Body/index.d.ts.map +1 -1
  42. package/types/Table/v1/Cell/index.d.ts +3 -2
  43. package/types/Table/v1/Cell/index.d.ts.map +1 -1
  44. package/types/Table/v1/ColHeader/index.d.ts +1 -0
  45. package/types/Table/v1/ColHeader/index.d.ts.map +1 -1
  46. package/types/Table/v1/Head/index.d.ts +3 -2
  47. package/types/Table/v1/Head/index.d.ts.map +1 -1
  48. package/types/Table/v1/Head/props.d.ts +1 -1
  49. package/types/Table/v1/Head/props.d.ts.map +1 -1
  50. package/types/Table/v1/Row/index.d.ts +3 -2
  51. package/types/Table/v1/Row/index.d.ts.map +1 -1
  52. package/types/Table/v1/RowHeader/index.d.ts +3 -2
  53. package/types/Table/v1/RowHeader/index.d.ts.map +1 -1
  54. package/types/Table/v1/index.d.ts +7 -6
  55. package/types/Table/v1/index.d.ts.map +1 -1
  56. package/types/Table/v2/Body/index.d.ts +3 -2
  57. package/types/Table/v2/Body/index.d.ts.map +1 -1
  58. package/types/Table/v2/Cell/index.d.ts +3 -2
  59. package/types/Table/v2/Cell/index.d.ts.map +1 -1
  60. package/types/Table/v2/ColHeader/index.d.ts +1 -0
  61. package/types/Table/v2/ColHeader/index.d.ts.map +1 -1
  62. package/types/Table/v2/Head/index.d.ts +3 -2
  63. package/types/Table/v2/Head/index.d.ts.map +1 -1
  64. package/types/Table/v2/Head/props.d.ts +1 -1
  65. package/types/Table/v2/Head/props.d.ts.map +1 -1
  66. package/types/Table/v2/Row/index.d.ts +3 -2
  67. package/types/Table/v2/Row/index.d.ts.map +1 -1
  68. package/types/Table/v2/RowHeader/index.d.ts +3 -2
  69. package/types/Table/v2/RowHeader/index.d.ts.map +1 -1
  70. package/types/Table/v2/index.d.ts +7 -6
  71. package/types/Table/v2/index.d.ts.map +1 -1
  72. package/types/exports/a.d.ts +8 -8
  73. package/types/exports/a.d.ts.map +1 -1
  74. package/types/exports/b.d.ts +8 -8
  75. package/types/exports/b.d.ts.map +1 -1
  76. package/lib/Table/v1/Body/index.js +0 -86
  77. package/lib/Table/v1/Body/props.js +0 -31
  78. package/lib/Table/v1/Body/styles.js +0 -51
  79. package/lib/Table/v1/Body/theme.js +0 -52
  80. package/lib/Table/v1/Cell/index.js +0 -79
  81. package/lib/Table/v1/Cell/styles.js +0 -63
  82. package/lib/Table/v1/Cell/theme.js +0 -56
  83. package/lib/Table/v1/ColHeader/index.js +0 -125
  84. package/lib/Table/v1/ColHeader/props.js +0 -31
  85. package/lib/Table/v1/ColHeader/styles.js +0 -108
  86. package/lib/Table/v1/ColHeader/theme.js +0 -69
  87. package/lib/Table/v1/Head/index.js +0 -179
  88. package/lib/Table/v1/Head/props.js +0 -31
  89. package/lib/Table/v1/Head/styles.js +0 -51
  90. package/lib/Table/v1/Head/theme.js +0 -52
  91. package/lib/Table/v1/Row/index.js +0 -93
  92. package/lib/Table/v1/Row/props.js +0 -31
  93. package/lib/Table/v1/Row/styles.js +0 -74
  94. package/lib/Table/v1/Row/theme.js +0 -63
  95. package/lib/Table/v1/RowHeader/index.js +0 -79
  96. package/lib/Table/v1/RowHeader/props.js +0 -31
  97. package/lib/Table/v1/RowHeader/styles.js +0 -63
  98. package/lib/Table/v1/RowHeader/theme.js +0 -56
  99. package/lib/Table/v1/TableContext.js +0 -51
  100. package/lib/Table/v1/index.js +0 -196
  101. package/lib/Table/v1/props.js +0 -31
  102. package/lib/Table/v1/styles.js +0 -74
  103. package/lib/Table/v1/theme.js +0 -59
  104. package/lib/Table/v2/Body/index.js +0 -85
  105. package/lib/Table/v2/Body/props.js +0 -31
  106. package/lib/Table/v2/Body/styles.js +0 -51
  107. package/lib/Table/v2/Cell/index.js +0 -78
  108. package/lib/Table/v2/Cell/props.js +0 -31
  109. package/lib/Table/v2/Cell/styles.js +0 -62
  110. package/lib/Table/v2/ColHeader/index.js +0 -124
  111. package/lib/Table/v2/ColHeader/props.js +0 -31
  112. package/lib/Table/v2/ColHeader/styles.js +0 -101
  113. package/lib/Table/v2/Head/index.js +0 -179
  114. package/lib/Table/v2/Head/props.js +0 -31
  115. package/lib/Table/v2/Head/styles.js +0 -51
  116. package/lib/Table/v2/Row/index.js +0 -92
  117. package/lib/Table/v2/Row/props.js +0 -31
  118. package/lib/Table/v2/Row/styles.js +0 -75
  119. package/lib/Table/v2/RowHeader/index.js +0 -78
  120. package/lib/Table/v2/RowHeader/props.js +0 -31
  121. package/lib/Table/v2/RowHeader/styles.js +0 -62
  122. package/lib/Table/v2/TableContext.js +0 -51
  123. package/lib/Table/v2/index.js +0 -195
  124. package/lib/Table/v2/props.js +0 -31
  125. package/lib/Table/v2/styles.js +0 -74
  126. package/lib/exports/a.js +0 -61
  127. package/lib/exports/b.js +0 -61
  128. package/lib/package.json +0 -1
@@ -1,51 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- /*
8
- * The MIT License (MIT)
9
- *
10
- * Copyright (c) 2015 - present Instructure, Inc.
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining a copy
13
- * of this software and associated documentation files (the "Software"), to deal
14
- * in the Software without restriction, including without limitation the rights
15
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- * copies of the Software, and to permit persons to whom the Software is
17
- * furnished to do so, subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all
20
- * copies or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- * SOFTWARE.
29
- */
30
-
31
- /**
32
- * ---
33
- * private: true
34
- * ---
35
- * Generates the style object from the theme and provided additional information
36
- * @param {Object} componentTheme The theme variable object.
37
- * @return {Object} The final style object, which will be used in the component
38
- */
39
- const generateStyle = componentTheme => {
40
- return {
41
- head: {
42
- label: 'head',
43
- fontSize: componentTheme.fontSize,
44
- fontFamily: componentTheme.fontFamily,
45
- fontWeight: componentTheme.fontWeight,
46
- color: componentTheme.color,
47
- background: componentTheme.background
48
- }
49
- };
50
- };
51
- var _default = exports.default = generateStyle;
@@ -1,92 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = exports.Row = void 0;
8
- var _react = require("react");
9
- var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
10
- var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
11
- var _latest = require("@instructure/ui-view/latest");
12
- var _emotion = require("@instructure/emotion");
13
- var _styles = _interopRequireDefault(require("./styles"));
14
- var _props = require("./props");
15
- var _TableContext = _interopRequireDefault(require("../TableContext"));
16
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
17
- var _dec, _class;
18
- /*
19
- * The MIT License (MIT)
20
- *
21
- * Copyright (c) 2015 - present Instructure, Inc.
22
- *
23
- * Permission is hereby granted, free of charge, to any person obtaining a copy
24
- * of this software and associated documentation files (the "Software"), to deal
25
- * in the Software without restriction, including without limitation the rights
26
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
27
- * copies of the Software, and to permit persons to whom the Software is
28
- * furnished to do so, subject to the following conditions:
29
- *
30
- * The above copyright notice and this permission notice shall be included in all
31
- * copies or substantial portions of the Software.
32
- *
33
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39
- * SOFTWARE.
40
- */
41
- /**
42
- ---
43
- parent: Table
44
- id: Table.Row
45
- ---
46
- **/
47
- let Row = exports.Row = (_dec = (0, _emotion.withStyleNew)(_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
- };
55
- componentDidMount() {
56
- this.props.makeStyles?.({
57
- isStacked: this.context.isStacked,
58
- hover: this.context.hover
59
- });
60
- }
61
- componentDidUpdate() {
62
- this.props.makeStyles?.({
63
- isStacked: this.context.isStacked,
64
- hover: this.context.hover
65
- });
66
- }
67
- render() {
68
- const {
69
- children,
70
- styles
71
- } = this.props;
72
- const isStacked = this.context.isStacked;
73
- const headers = this.context.headers;
74
- return (0, _jsxRuntime.jsx)(_latest.View, {
75
- ..._latest.View.omitViewProps((0, _omitProps.omitProps)(this.props, Row.allowedProps), Row),
76
- as: isStacked ? 'div' : 'tr',
77
- css: styles?.row,
78
- role: isStacked ? 'row' : undefined,
79
- children: _react.Children.toArray(children).filter(Boolean).map((child, index) => {
80
- if (/*#__PURE__*/(0, _react.isValidElement)(child)) {
81
- return (0, _safeCloneElement.safeCloneElement)(child, {
82
- key: child.props.name,
83
- // used by `Cell` to render its column title in `stacked` layout
84
- header: headers && headers[index]
85
- });
86
- }
87
- return child;
88
- })
89
- });
90
- }
91
- }) || _class);
92
- var _default = exports.default = Row;
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.allowedProps = void 0;
7
- /*
8
- * The MIT License (MIT)
9
- *
10
- * Copyright (c) 2015 - present Instructure, Inc.
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining a copy
13
- * of this software and associated documentation files (the "Software"), to deal
14
- * in the Software without restriction, including without limitation the rights
15
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- * copies of the Software, and to permit persons to whom the Software is
17
- * furnished to do so, subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all
20
- * copies or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- * SOFTWARE.
29
- */
30
-
31
- const allowedProps = exports.allowedProps = ['children', 'setHoverStateTo'];
@@ -1,75 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- /*
8
- * The MIT License (MIT)
9
- *
10
- * Copyright (c) 2015 - present Instructure, Inc.
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining a copy
13
- * of this software and associated documentation files (the "Software"), to deal
14
- * in the Software without restriction, including without limitation the rights
15
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- * copies of the Software, and to permit persons to whom the Software is
17
- * furnished to do so, subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all
20
- * copies or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- * SOFTWARE.
29
- */
30
-
31
- /**
32
- * ---
33
- * private: true
34
- * ---
35
- * Generates the style object from the theme and provided additional information
36
- * @param {Object} componentTheme The theme variable object.
37
- * @param {Object} props the props of the component, the style is applied to
38
- * @param {Object} _sharedTokens Shared token object (not used in this component)
39
- * @param {Object} extraArgs the state of the component, the style is applied to
40
- * @return {Object} The final style object, which will be used in the component
41
- */
42
- const generateStyle = (componentTheme, props, _sharedTokens, extraArgs) => {
43
- const {
44
- setHoverStateTo
45
- } = props;
46
- const hoverStyles = {
47
- borderLeftColor: componentTheme.hoverBorderColor,
48
- borderRightColor: componentTheme.hoverBorderColor
49
- };
50
- return {
51
- row: {
52
- label: 'row',
53
- fontSize: componentTheme.fontSize,
54
- fontFamily: componentTheme.fontFamily,
55
- fontWeight: componentTheme.fontWeight,
56
- color: componentTheme.color,
57
- background: componentTheme.background,
58
- boxSizing: 'border-box',
59
- borderBottomStyle: 'solid',
60
- borderBottomWidth: '0.0625rem',
61
- borderBottomColor: componentTheme.borderColor,
62
- ...((setHoverStateTo ?? extraArgs.hover) && {
63
- borderLeft: '0.1875rem solid transparent',
64
- borderRight: '0.1875rem solid transparent',
65
- ...(setHoverStateTo === true ? hoverStyles : {
66
- '&:hover': hoverStyles
67
- })
68
- }),
69
- ...(extraArgs.isStacked && {
70
- padding: `${componentTheme.paddingVertical} ${componentTheme.paddingHorizontal}`
71
- })
72
- }
73
- };
74
- };
75
- var _default = exports.default = generateStyle;
@@ -1,78 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = exports.RowHeader = void 0;
8
- var _react = require("react");
9
- var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
10
- var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
11
- var _latest = require("@instructure/ui-view/latest");
12
- var _emotion = require("@instructure/emotion");
13
- var _styles = _interopRequireDefault(require("./styles"));
14
- var _props = require("./props");
15
- var _TableContext = _interopRequireDefault(require("../TableContext"));
16
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
17
- var _dec, _class;
18
- /*
19
- * The MIT License (MIT)
20
- *
21
- * Copyright (c) 2015 - present Instructure, Inc.
22
- *
23
- * Permission is hereby granted, free of charge, to any person obtaining a copy
24
- * of this software and associated documentation files (the "Software"), to deal
25
- * in the Software without restriction, including without limitation the rights
26
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
27
- * copies of the Software, and to permit persons to whom the Software is
28
- * furnished to do so, subject to the following conditions:
29
- *
30
- * The above copyright notice and this permission notice shall be included in all
31
- * copies or substantial portions of the Software.
32
- *
33
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39
- * SOFTWARE.
40
- */
41
- /**
42
- ---
43
- parent: Table
44
- id: Table.RowHeader
45
- ---
46
- **/
47
- let RowHeader = exports.RowHeader = (_dec = (0, _emotion.withStyleNew)(_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
- };
56
- componentDidMount() {
57
- this.props.makeStyles?.();
58
- }
59
- componentDidUpdate() {
60
- this.props.makeStyles?.();
61
- }
62
- render() {
63
- const {
64
- children,
65
- styles
66
- } = this.props;
67
- const isStacked = this.context.isStacked;
68
- return (0, _jsxRuntime.jsx)(_latest.View, {
69
- ..._latest.View.omitViewProps((0, _omitProps.omitProps)(this.props, RowHeader.allowedProps), RowHeader),
70
- as: isStacked ? 'div' : 'th',
71
- css: styles?.rowHeader,
72
- scope: "row",
73
- role: isStacked ? 'rowheader' : undefined,
74
- children: (0, _callRenderProp.callRenderProp)(children)
75
- });
76
- }
77
- }) || _class);
78
- var _default = exports.default = RowHeader;
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.allowedProps = void 0;
7
- /*
8
- * The MIT License (MIT)
9
- *
10
- * Copyright (c) 2015 - present Instructure, Inc.
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining a copy
13
- * of this software and associated documentation files (the "Software"), to deal
14
- * in the Software without restriction, including without limitation the rights
15
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- * copies of the Software, and to permit persons to whom the Software is
17
- * furnished to do so, subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all
20
- * copies or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- * SOFTWARE.
29
- */
30
-
31
- const allowedProps = exports.allowedProps = ['children', 'textAlign'];
@@ -1,62 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- /*
8
- * The MIT License (MIT)
9
- *
10
- * Copyright (c) 2015 - present Instructure, Inc.
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining a copy
13
- * of this software and associated documentation files (the "Software"), to deal
14
- * in the Software without restriction, including without limitation the rights
15
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- * copies of the Software, and to permit persons to whom the Software is
17
- * furnished to do so, subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all
20
- * copies or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- * SOFTWARE.
29
- */
30
-
31
- /**
32
- * ---
33
- * private: true
34
- * ---
35
- * Generates the style object from the theme and provided additional information
36
- * @param {Object} componentTheme The theme variable object.
37
- * @param {Object} props the props of the component, the style is applied to
38
- * @return {Object} The final style object, which will be used in the component
39
- */
40
- const generateStyle = (componentTheme, props) => {
41
- const {
42
- textAlign
43
- } = props;
44
- return {
45
- rowHeader: {
46
- label: 'rowHeader',
47
- fontSize: componentTheme.fontSize,
48
- fontFamily: componentTheme.fontFamily,
49
- fontWeight: componentTheme.fontWeight,
50
- color: componentTheme.color,
51
- background: componentTheme.background,
52
- boxSizing: 'border-box',
53
- verticalAlign: 'middle',
54
- lineHeight: componentTheme.lineHeight,
55
- padding: `${componentTheme.paddingVertical} ${componentTheme.paddingHorizontal}`,
56
- ...(textAlign && {
57
- textAlign
58
- })
59
- }
60
- };
61
- };
62
- var _default = exports.default = generateStyle;
@@ -1,51 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.TableContext = void 0;
7
- var _react = require("react");
8
- /*
9
- * The MIT License (MIT)
10
- *
11
- * Copyright (c) 2015 - present Instructure, Inc.
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
- * copies of the Software, and to permit persons to whom the Software is
18
- * furnished to do so, subject to the following conditions:
19
- *
20
- * The above copyright notice and this permission notice shall be included in all
21
- * copies or substantial portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
- * SOFTWARE.
30
- */
31
-
32
- /**
33
- * ---
34
- * category: components/contexts
35
- * ---
36
- * React context created by the `Table` component to hold its data which are
37
- * read by its children. You can access these to make custom Table cells/rows.
38
- *
39
- * It stores the following parameters:
40
- * - `isStacked`: Whether the `Table` is in `stacked` layout.
41
- * - `hover`: Whether highlight rows on mouse hover
42
- * - `headers`: in `stacked` layout the children of the first row of cells
43
- * (e.g. the titles in a table). This is used in `stacked` layout to display
44
- * the titles inline
45
- * @module
46
- */
47
- const TableContext = exports.TableContext = /*#__PURE__*/(0, _react.createContext)({
48
- isStacked: false,
49
- hover: false
50
- });
51
- var _default = exports.default = TableContext;
@@ -1,195 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = exports.Table = void 0;
8
- var _react = require("react");
9
- var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
10
- var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
11
- var _latest = require("@instructure/ui-view/latest");
12
- var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
13
- var _emotion = require("@instructure/emotion");
14
- var _styles = _interopRequireDefault(require("./styles"));
15
- var _Head = require("./Head");
16
- var _Body = require("./Body");
17
- var _Row = require("./Row");
18
- var _ColHeader = require("./ColHeader");
19
- var _RowHeader = require("./RowHeader");
20
- var _Cell = require("./Cell");
21
- var _props = require("./props");
22
- var _TableContext = _interopRequireDefault(require("./TableContext"));
23
- var _console = require("@instructure/console");
24
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
25
- var _dec, _class;
26
- /*
27
- * The MIT License (MIT)
28
- *
29
- * Copyright (c) 2015 - present Instructure, Inc.
30
- *
31
- * Permission is hereby granted, free of charge, to any person obtaining a copy
32
- * of this software and associated documentation files (the "Software"), to deal
33
- * in the Software without restriction, including without limitation the rights
34
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
35
- * copies of the Software, and to permit persons to whom the Software is
36
- * furnished to do so, subject to the following conditions:
37
- *
38
- * The above copyright notice and this permission notice shall be included in all
39
- * copies or substantial portions of the Software.
40
- *
41
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
44
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
46
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
47
- * SOFTWARE.
48
- */
49
- /**
50
- ---
51
- category: components
52
- ---
53
- **/
54
- let Table = exports.Table = (_dec = (0, _emotion.withStyleNew)(_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
- };
78
- componentDidMount() {
79
- this.props.makeStyles?.();
80
- }
81
- componentDidUpdate(prevProps) {
82
- this.props.makeStyles?.();
83
- // Announce caption changes for screen readers (especially VoiceOver)
84
- // Safari/VoiceOver has a known bug where dynamic <caption> updates aren't announced,
85
- // so we use an aria-live region as a workaround
86
- const prevSortInfo = this.getSortedHeaderInfo(prevProps);
87
- const currentSortInfo = this.getSortedHeaderInfo(this.props);
88
- // Only announce if sorting actually changed
89
- const sortingChanged = prevSortInfo?.header !== currentSortInfo?.header || prevSortInfo?.direction !== currentSortInfo?.direction;
90
- if (sortingChanged && currentSortInfo && this._liveRegionRef) {
91
- // Clear any pending announcement
92
- clearTimeout(this._announcementTimeout);
93
- // Clear the live region first (part of the clear-then-set pattern)
94
- this._liveRegionRef.textContent = '';
95
- // Wait 100ms before setting new content to ensure screen readers detect the change
96
- this._announcementTimeout = setTimeout(() => {
97
- if (this._liveRegionRef) {
98
- const currentCaption = this.getCaptionText(this.props);
99
- // Append non-breaking space (\u00A0) to force Safari/VoiceOver to treat
100
- // repeated captions as different announcements
101
- this._liveRegionRef.textContent = currentCaption + '\u00A0';
102
- }
103
- }, 100);
104
- }
105
- }
106
- componentWillUnmount() {
107
- // Clean up pending announcement timeout
108
- clearTimeout(this._announcementTimeout);
109
- }
110
- getHeaders() {
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;
115
- return _react.Children.map(firstRow.props.children, colHeader => {
116
- if (! /*#__PURE__*/(0, _react.isValidElement)(colHeader)) return undefined;
117
- return colHeader.props.children;
118
- });
119
- }
120
- getSortedHeaderInfo(props) {
121
- const [headChild] = _react.Children.toArray(props.children);
122
- const [firstRow] = _react.Children.toArray(/*#__PURE__*/(0, _react.isValidElement)(headChild) ? headChild.props.children : []);
123
- const colHeaders = _react.Children.toArray(/*#__PURE__*/(0, _react.isValidElement)(firstRow) ? firstRow.props.children : []);
124
- // Find the column with an active sort direction
125
- for (const colHeader of colHeaders) {
126
- if (/*#__PURE__*/(0, _react.isValidElement)(colHeader) && colHeader.props.sortDirection && colHeader.props.sortDirection !== 'none') {
127
- // Extract header text (may be nested in child components)
128
- const headerText = typeof colHeader.props.children === 'string' ? colHeader.props.children : colHeader.props.children?.props?.children ?? '';
129
- return {
130
- header: headerText,
131
- direction: colHeader.props.sortDirection
132
- };
133
- }
134
- }
135
- return null;
136
- }
137
- getCaptionText(props) {
138
- const sortInfo = this.getSortedHeaderInfo(props);
139
- const caption = props.caption;
140
- if (!sortInfo) return caption;
141
- const sortText = ` Sorted by ${sortInfo.header} (${sortInfo.direction})`;
142
- return caption ? caption + sortText : sortText.trim();
143
- }
144
- render() {
145
- const {
146
- margin,
147
- layout,
148
- caption,
149
- children,
150
- hover,
151
- styles,
152
- minWidth
153
- } = this.props;
154
- const isStacked = layout === 'stacked';
155
- const captionText = this.getCaptionText(this.props);
156
- if (!caption) {
157
- (0, _console.error)(false, `[Table] required prop caption is not set.`);
158
- }
159
- return (0, _jsxRuntime.jsxs)(_TableContext.default.Provider, {
160
- value: {
161
- isStacked,
162
- hover: hover,
163
- headers: isStacked ? this.getHeaders() : undefined
164
- },
165
- children: [(0, _jsxRuntime.jsx)("div", {
166
- ref: el => {
167
- this._liveRegionRef = el;
168
- },
169
- "aria-live": "polite",
170
- "aria-atomic": "true",
171
- role: "status",
172
- css: styles?.liveRegion
173
- }), (0, _jsxRuntime.jsxs)(_latest.View
174
- // All HTML props, except the ones accepted by `View` and `Table`
175
- , {
176
- ..._latest.View.omitViewProps((0, _omitProps.omitProps)(this.props, Table.allowedProps), Table),
177
- minWidth: minWidth,
178
- as: isStacked ? 'div' : 'table',
179
- margin: margin,
180
- elementRef: this.handleRef,
181
- css: styles?.table,
182
- role: isStacked ? 'table' : undefined,
183
- "aria-label": captionText,
184
- children: [!isStacked && caption && (0, _jsxRuntime.jsx)("caption", {
185
- children: (0, _jsxRuntime.jsx)(_ScreenReaderContent.ScreenReaderContent, {
186
- children: captionText
187
- })
188
- }), _react.Children.map(children, child => /*#__PURE__*/(0, _react.isValidElement)(child) ? (0, _safeCloneElement.safeCloneElement)(child, {
189
- key: child.props.name
190
- }) : child)]
191
- })]
192
- });
193
- }
194
- }) || _class);
195
- var _default = exports.default = Table;