@instructure/ui-table 8.8.1-snapshot.8 → 8.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/es/Table/Body/index.js +16 -28
- package/{src/Table/Cell/types.ts → es/Table/Body/props.js} +14 -8
- package/es/Table/Cell/index.js +16 -28
- package/{src/Table/types.ts → es/Table/Cell/props.js} +12 -11
- package/es/Table/ColHeader/index.js +22 -63
- package/es/Table/ColHeader/props.js +66 -0
- package/es/Table/Head/index.js +18 -29
- package/{src/Table/Body/types.ts → es/Table/Head/props.js} +13 -8
- package/es/Table/Row/index.js +16 -28
- package/{src/Table/ColHeader/types.ts → es/Table/Row/props.js} +16 -12
- package/es/Table/RowHeader/index.js +15 -26
- package/{src/Table/Head/types.ts → es/Table/RowHeader/props.js} +11 -6
- package/es/Table/index.js +21 -60
- package/es/Table/props.js +66 -0
- package/lib/Table/Body/index.js +16 -29
- package/lib/Table/Body/props.js +50 -0
- package/lib/Table/Cell/index.js +16 -28
- package/lib/Table/Cell/props.js +47 -0
- package/lib/Table/ColHeader/index.js +22 -63
- package/lib/Table/ColHeader/props.js +77 -0
- package/lib/Table/Head/index.js +18 -30
- package/lib/Table/Head/props.js +49 -0
- package/lib/Table/Row/index.js +16 -29
- package/lib/Table/Row/props.js +54 -0
- package/lib/Table/RowHeader/index.js +15 -26
- package/lib/Table/RowHeader/props.js +46 -0
- package/lib/Table/index.js +20 -60
- package/lib/Table/props.js +81 -0
- package/package.json +17 -18
- package/src/Table/Body/index.tsx +7 -25
- package/src/Table/{Row/types.ts → Body/props.ts} +39 -3
- package/src/Table/Cell/index.tsx +8 -24
- package/src/Table/Cell/props.ts +62 -0
- package/src/Table/Cell/styles.ts +1 -1
- package/src/Table/ColHeader/index.tsx +9 -51
- package/src/Table/ColHeader/props.ts +94 -0
- package/src/Table/ColHeader/styles.ts +1 -1
- package/src/Table/Head/index.tsx +8 -24
- package/src/Table/Head/props.ts +62 -0
- package/src/Table/Row/index.tsx +8 -27
- package/src/Table/Row/props.ts +70 -0
- package/src/Table/Row/styles.ts +1 -1
- package/src/Table/RowHeader/index.tsx +8 -23
- package/src/Table/RowHeader/{types.ts → props.ts} +28 -3
- package/src/Table/RowHeader/styles.ts +1 -1
- package/src/Table/index.tsx +10 -49
- package/src/Table/props.ts +93 -0
- package/src/Table/styles.ts +1 -1
- package/src/index.ts +7 -7
- package/types/Table/Body/index.d.ts +13 -16
- package/types/Table/Body/index.d.ts.map +1 -1
- package/types/Table/Body/props.d.ts +17 -0
- package/types/Table/Body/props.d.ts.map +1 -0
- package/types/Table/Cell/index.d.ts +14 -14
- package/types/Table/Cell/index.d.ts.map +1 -1
- package/types/Table/Cell/props.d.ts +17 -0
- package/types/Table/Cell/props.d.ts.map +1 -0
- package/types/Table/Cell/styles.d.ts +1 -1
- package/types/Table/ColHeader/index.d.ts +22 -40
- package/types/Table/ColHeader/index.d.ts.map +1 -1
- package/types/Table/ColHeader/props.d.ts +21 -0
- package/types/Table/ColHeader/props.d.ts.map +1 -0
- package/types/Table/ColHeader/styles.d.ts +1 -1
- package/types/Table/Head/index.d.ts +11 -15
- package/types/Table/Head/index.d.ts.map +1 -1
- package/types/Table/Head/props.d.ts +16 -0
- package/types/Table/Head/props.d.ts.map +1 -0
- package/types/Table/Row/index.d.ts +14 -17
- package/types/Table/Row/index.d.ts.map +1 -1
- package/types/Table/Row/props.d.ts +17 -0
- package/types/Table/Row/props.d.ts.map +1 -0
- package/types/Table/Row/styles.d.ts +1 -1
- package/types/Table/RowHeader/index.d.ts +12 -13
- package/types/Table/RowHeader/index.d.ts.map +1 -1
- package/types/Table/RowHeader/props.d.ts +16 -0
- package/types/Table/RowHeader/props.d.ts.map +1 -0
- package/types/Table/RowHeader/styles.d.ts +1 -1
- package/types/Table/index.d.ts +18 -41
- package/types/Table/index.d.ts.map +1 -1
- package/types/Table/props.d.ts +19 -0
- package/types/Table/props.d.ts.map +1 -0
- package/types/Table/styles.d.ts +1 -1
- package/types/index.d.ts +7 -7
- package/LICENSE.md +0 -27
- package/es/Table/Body/types.js +0 -1
- package/es/Table/Cell/types.js +0 -1
- package/es/Table/ColHeader/types.js +0 -1
- package/es/Table/Head/types.js +0 -1
- package/es/Table/Row/types.js +0 -1
- package/es/Table/RowHeader/types.js +0 -1
- package/es/Table/types.js +0 -1
- package/lib/Table/Body/types.js +0 -1
- package/lib/Table/Cell/types.js +0 -1
- package/lib/Table/ColHeader/types.js +0 -1
- package/lib/Table/Head/types.js +0 -1
- package/lib/Table/Row/types.js +0 -1
- package/lib/Table/RowHeader/types.js +0 -1
- package/lib/Table/types.js +0 -1
- package/types/Table/Body/types.d.ts +0 -9
- package/types/Table/Body/types.d.ts.map +0 -1
- package/types/Table/Cell/types.d.ts +0 -9
- package/types/Table/Cell/types.d.ts.map +0 -1
- package/types/Table/ColHeader/types.d.ts +0 -12
- package/types/Table/ColHeader/types.d.ts.map +0 -1
- package/types/Table/Head/types.d.ts +0 -8
- package/types/Table/Head/types.d.ts.map +0 -1
- package/types/Table/Row/types.d.ts +0 -9
- package/types/Table/Row/types.d.ts.map +0 -1
- package/types/Table/RowHeader/types.d.ts +0 -7
- package/types/Table/RowHeader/types.d.ts.map +0 -1
- package/types/Table/types.d.ts +0 -12
- package/types/Table/types.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,12 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
# [8.9.0](https://github.com/instructure/instructure-ui/compare/v8.8.0...v8.9.0) (2021-09-15)
|
7
|
+
|
8
|
+
### Bug Fixes
|
9
|
+
|
10
|
+
- fix shared-types TS errors ([7b83164](https://github.com/instructure/instructure-ui/commit/7b83164f4c5872f3a217e010563f59bf584ae4fc))
|
11
|
+
|
6
12
|
# [8.8.0](https://github.com/instructure/instructure-ui/compare/v8.7.0...v8.8.0) (2021-08-27)
|
7
13
|
|
8
14
|
**Note:** Version bump only for package @instructure/ui-table
|
package/es/Table/Body/index.js
CHANGED
@@ -26,43 +26,43 @@ var _dec, _class, _class2, _temp;
|
|
26
26
|
|
27
27
|
/** @jsx jsx */
|
28
28
|
import { Component, Children } from 'react';
|
29
|
-
import PropTypes from 'prop-types';
|
30
29
|
import { matchComponentTypes, safeCloneElement, omitProps } from '@instructure/ui-react-utils';
|
31
|
-
import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types';
|
32
30
|
import { View } from '@instructure/ui-view';
|
33
31
|
import { withStyle, jsx } from '@instructure/emotion';
|
34
32
|
import generateStyle from './styles';
|
35
33
|
import generateComponentTheme from './theme';
|
36
34
|
import { Row } from '../Row';
|
37
|
-
|
35
|
+
import { allowedProps, propTypes } from './props';
|
38
36
|
/**
|
39
37
|
---
|
40
38
|
parent: Table
|
41
39
|
id: Table.Body
|
42
40
|
---
|
43
41
|
**/
|
44
|
-
let Body = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_temp = _class2 = class Body extends Component {
|
45
|
-
/* eslint-disable react/require-default-props */
|
46
42
|
|
47
|
-
|
43
|
+
let Body = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_temp = _class2 = class Body extends Component {
|
48
44
|
componentDidMount() {
|
49
|
-
|
45
|
+
var _this$props$makeStyle, _this$props;
|
46
|
+
|
47
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
50
48
|
}
|
51
49
|
|
52
50
|
componentDidUpdate(prevProps, prevState, snapshot) {
|
53
|
-
|
51
|
+
var _this$props$makeStyle2, _this$props2;
|
52
|
+
|
53
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
54
54
|
}
|
55
55
|
|
56
56
|
render() {
|
57
|
-
const _this$
|
58
|
-
children = _this$
|
59
|
-
hover = _this$
|
60
|
-
isStacked = _this$
|
61
|
-
headers = _this$
|
62
|
-
styles = _this$
|
57
|
+
const _this$props3 = this.props,
|
58
|
+
children = _this$props3.children,
|
59
|
+
hover = _this$props3.hover,
|
60
|
+
isStacked = _this$props3.isStacked,
|
61
|
+
headers = _this$props3.headers,
|
62
|
+
styles = _this$props3.styles;
|
63
63
|
return jsx(View, Object.assign({}, View.omitViewProps(omitProps(this.props, Body.propTypes), Body), {
|
64
64
|
as: isStacked ? 'div' : 'tbody',
|
65
|
-
css: styles.body,
|
65
|
+
css: styles === null || styles === void 0 ? void 0 : styles.body,
|
66
66
|
role: isStacked ? 'rowgroup' : void 0
|
67
67
|
}), Children.map(children, child => matchComponentTypes(child, [Row]) ? safeCloneElement(child, {
|
68
68
|
key: child.props.name,
|
@@ -72,19 +72,7 @@ let Body = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class
|
|
72
72
|
}) : null));
|
73
73
|
}
|
74
74
|
|
75
|
-
}, _class2.displayName = "Body", _class2.componentId = 'Table.Body', _class2.propTypes = {
|
76
|
-
/**
|
77
|
-
* `Table.Row`
|
78
|
-
*/
|
79
|
-
// eslint-disable-next-line react/require-default-props
|
80
|
-
makeStyles: PropTypes.func,
|
81
|
-
// eslint-disable-next-line react/require-default-props
|
82
|
-
styles: PropTypes.object,
|
83
|
-
children: ChildrenPropTypes.oneOf([Row]),
|
84
|
-
hover: PropTypes.bool,
|
85
|
-
isStacked: PropTypes.bool,
|
86
|
-
headers: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.node, PropTypes.func]))
|
87
|
-
}, _class2.defaultProps = {
|
75
|
+
}, _class2.displayName = "Body", _class2.componentId = 'Table.Body', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
88
76
|
children: null
|
89
77
|
}, _temp)) || _class);
|
90
78
|
export default Body;
|
@@ -21,11 +21,17 @@
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
22
|
* SOFTWARE.
|
23
23
|
*/
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
24
|
+
import PropTypes from 'prop-types';
|
25
|
+
import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types';
|
26
|
+
import { Row } from '../Row';
|
27
|
+
const propTypes = {
|
28
|
+
/**
|
29
|
+
* `Table.Row`
|
30
|
+
*/
|
31
|
+
children: ChildrenPropTypes.oneOf([Row]),
|
32
|
+
hover: PropTypes.bool,
|
33
|
+
isStacked: PropTypes.bool,
|
34
|
+
headers: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.node, PropTypes.func]))
|
35
|
+
};
|
36
|
+
const allowedProps = ['children', 'hover', 'isStacked', 'headers'];
|
37
|
+
export { propTypes, allowedProps };
|
package/es/Table/Cell/index.js
CHANGED
@@ -26,58 +26,46 @@ var _dec, _class, _class2, _temp;
|
|
26
26
|
|
27
27
|
/** @jsx jsx */
|
28
28
|
import { Component } from 'react';
|
29
|
-
import PropTypes from 'prop-types';
|
30
29
|
import { omitProps, callRenderProp } from '@instructure/ui-react-utils';
|
31
30
|
import { View } from '@instructure/ui-view';
|
32
31
|
import { withStyle, jsx } from '@instructure/emotion';
|
33
32
|
import generateStyle from './styles';
|
34
33
|
import generateComponentTheme from './theme';
|
35
|
-
|
34
|
+
import { allowedProps, propTypes } from './props';
|
36
35
|
/**
|
37
36
|
---
|
38
37
|
parent: Table
|
39
38
|
id: Table.Cell
|
40
39
|
---
|
41
40
|
**/
|
42
|
-
let Cell = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_temp = _class2 = class Cell extends Component {
|
43
|
-
/* eslint-disable react/require-default-props */
|
44
41
|
|
45
|
-
|
42
|
+
let Cell = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_temp = _class2 = class Cell extends Component {
|
46
43
|
componentDidMount() {
|
47
|
-
|
44
|
+
var _this$props$makeStyle, _this$props;
|
45
|
+
|
46
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
48
47
|
}
|
49
48
|
|
50
|
-
componentDidUpdate(
|
51
|
-
|
49
|
+
componentDidUpdate() {
|
50
|
+
var _this$props$makeStyle2, _this$props2;
|
51
|
+
|
52
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
52
53
|
}
|
53
54
|
|
54
55
|
render() {
|
55
|
-
const _this$
|
56
|
-
children = _this$
|
57
|
-
styles = _this$
|
58
|
-
isStacked = _this$
|
59
|
-
header = _this$
|
56
|
+
const _this$props3 = this.props,
|
57
|
+
children = _this$props3.children,
|
58
|
+
styles = _this$props3.styles,
|
59
|
+
isStacked = _this$props3.isStacked,
|
60
|
+
header = _this$props3.header;
|
60
61
|
return jsx(View, Object.assign({}, View.omitViewProps(omitProps(this.props, Cell.propTypes), Cell), {
|
61
62
|
as: isStacked ? 'div' : 'td',
|
62
|
-
css: styles.cell,
|
63
|
+
css: styles === null || styles === void 0 ? void 0 : styles.cell,
|
63
64
|
role: isStacked ? 'cell' : void 0
|
64
65
|
}), header && callRenderProp(header), header && ': ', callRenderProp(children));
|
65
66
|
}
|
66
67
|
|
67
|
-
}, _class2.displayName = "Cell", _class2.componentId = 'Table.Cell', _class2.propTypes = {
|
68
|
-
// eslint-disable-next-line react/require-default-props
|
69
|
-
makeStyles: PropTypes.func,
|
70
|
-
// eslint-disable-next-line react/require-default-props
|
71
|
-
styles: PropTypes.object,
|
72
|
-
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
73
|
-
isStacked: PropTypes.bool,
|
74
|
-
header: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
75
|
-
|
76
|
-
/**
|
77
|
-
* Control the text alignment in cell
|
78
|
-
*/
|
79
|
-
textAlign: PropTypes.oneOf(['start', 'center', 'end'])
|
80
|
-
}, _class2.defaultProps = {
|
68
|
+
}, _class2.displayName = "Cell", _class2.componentId = 'Table.Cell', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
81
69
|
textAlign: 'start',
|
82
70
|
children: null
|
83
71
|
}, _temp)) || _class);
|
@@ -21,15 +21,16 @@
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
22
|
* SOFTWARE.
|
23
23
|
*/
|
24
|
+
import PropTypes from 'prop-types';
|
25
|
+
const propTypes = {
|
26
|
+
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
27
|
+
isStacked: PropTypes.bool,
|
28
|
+
header: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
24
29
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
elementRef?: (...args: any[]) => any
|
33
|
-
hover?: boolean
|
34
|
-
layout?: 'auto' | 'fixed' | 'stacked'
|
35
|
-
}
|
30
|
+
/**
|
31
|
+
* Control the text alignment in cell
|
32
|
+
*/
|
33
|
+
textAlign: PropTypes.oneOf(['start', 'center', 'end'])
|
34
|
+
};
|
35
|
+
const allowedProps = ['children', 'isStacked', 'header', 'textAlign'];
|
36
|
+
export { propTypes, allowedProps };
|
@@ -26,19 +26,19 @@ var _dec, _class, _class2, _temp, _IconMiniArrowUpLine, _IconMiniArrowDownLin;
|
|
26
26
|
|
27
27
|
/** @jsx jsx */
|
28
28
|
import { Component } from 'react';
|
29
|
-
import PropTypes from 'prop-types';
|
30
29
|
import { omitProps, callRenderProp } from '@instructure/ui-react-utils';
|
31
30
|
import { IconMiniArrowUpLine, IconMiniArrowDownLine } from '@instructure/ui-icons';
|
32
31
|
import { withStyle, jsx } from '@instructure/emotion';
|
33
32
|
import generateStyle from './styles';
|
34
33
|
import generateComponentTheme from './theme';
|
35
|
-
|
34
|
+
import { allowedProps, propTypes } from './props';
|
36
35
|
/**
|
37
36
|
---
|
38
37
|
parent: Table
|
39
38
|
id: Table.ColHeader
|
40
39
|
---
|
41
40
|
**/
|
41
|
+
|
42
42
|
let ColHeader = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_temp = _class2 = class ColHeader extends Component {
|
43
43
|
constructor(...args) {
|
44
44
|
super(...args);
|
@@ -54,17 +54,21 @@ let ColHeader = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_
|
|
54
54
|
}
|
55
55
|
|
56
56
|
componentDidMount() {
|
57
|
-
|
57
|
+
var _this$props$makeStyle, _this$props2;
|
58
|
+
|
59
|
+
(_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
|
58
60
|
}
|
59
61
|
|
60
|
-
componentDidUpdate(
|
61
|
-
|
62
|
+
componentDidUpdate() {
|
63
|
+
var _this$props$makeStyle2, _this$props3;
|
64
|
+
|
65
|
+
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
|
62
66
|
}
|
63
67
|
|
64
68
|
renderSortArrow() {
|
65
|
-
const _this$
|
66
|
-
sortDirection = _this$
|
67
|
-
onRequestSort = _this$
|
69
|
+
const _this$props4 = this.props,
|
70
|
+
sortDirection = _this$props4.sortDirection,
|
71
|
+
onRequestSort = _this$props4.onRequestSort;
|
68
72
|
|
69
73
|
if (sortDirection === 'ascending') {
|
70
74
|
return _IconMiniArrowUpLine || (_IconMiniArrowUpLine = jsx(IconMiniArrowUpLine, null));
|
@@ -87,15 +91,15 @@ let ColHeader = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_
|
|
87
91
|
}
|
88
92
|
|
89
93
|
render() {
|
90
|
-
const _this$
|
91
|
-
onRequestSort = _this$
|
92
|
-
width = _this$
|
93
|
-
children = _this$
|
94
|
-
sortDirection = _this$
|
95
|
-
scope = _this$
|
96
|
-
styles = _this$
|
94
|
+
const _this$props5 = this.props,
|
95
|
+
onRequestSort = _this$props5.onRequestSort,
|
96
|
+
width = _this$props5.width,
|
97
|
+
children = _this$props5.children,
|
98
|
+
sortDirection = _this$props5.sortDirection,
|
99
|
+
scope = _this$props5.scope,
|
100
|
+
styles = _this$props5.styles;
|
97
101
|
return jsx("th", Object.assign({}, omitProps(this.props, ColHeader.propTypes), {
|
98
|
-
css: styles.colHeader,
|
102
|
+
css: styles === null || styles === void 0 ? void 0 : styles.colHeader,
|
99
103
|
style: {
|
100
104
|
width
|
101
105
|
},
|
@@ -103,58 +107,13 @@ let ColHeader = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_
|
|
103
107
|
"aria-sort": sortDirection
|
104
108
|
}), onRequestSort && jsx("button", {
|
105
109
|
onClick: this.handleClick,
|
106
|
-
css: styles.button
|
110
|
+
css: styles === null || styles === void 0 ? void 0 : styles.button
|
107
111
|
}, jsx("div", null, callRenderProp(children), this.renderSortArrow())), !onRequestSort && children, !onRequestSort && this.renderSortArrow());
|
108
112
|
}
|
109
113
|
|
110
|
-
}, _class2.displayName = "ColHeader", _class2.componentId = 'Table.ColHeader', _class2.propTypes = {
|
111
|
-
// eslint-disable-next-line react/require-default-props
|
112
|
-
makeStyles: PropTypes.func,
|
113
|
-
// eslint-disable-next-line react/require-default-props
|
114
|
-
styles: PropTypes.object,
|
115
|
-
|
116
|
-
/**
|
117
|
-
* A unique id for this column. The `id` is also used as option in combobox,
|
118
|
-
* when sortable table is in stacked layout,
|
119
|
-
* and no `stackedSortByLabel` is provided.
|
120
|
-
*/
|
121
|
-
id: PropTypes.string.isRequired,
|
122
|
-
|
123
|
-
/**
|
124
|
-
* A custom string to display as option text in the combobox (instead of
|
125
|
-
* using the `id` prop), when sortable table is in stacked layout.
|
126
|
-
*/
|
127
|
-
stackedSortByLabel: PropTypes.string,
|
128
|
-
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
129
|
-
|
130
|
-
/**
|
131
|
-
* Control the width of column.
|
132
|
-
*/
|
133
|
-
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
134
|
-
|
135
|
-
/**
|
136
|
-
* Control the text alignment in column header
|
137
|
-
*/
|
138
|
-
textAlign: PropTypes.oneOf(['start', 'center', 'end']),
|
139
|
-
|
140
|
-
/**
|
141
|
-
* The string of sorting direction
|
142
|
-
*/
|
143
|
-
sortDirection: PropTypes.oneOf(['none', 'ascending', 'descending']),
|
144
|
-
|
145
|
-
/**
|
146
|
-
* Callback fired when column header is clicked. Parameters: `(event, { id })`
|
147
|
-
*/
|
148
|
-
onRequestSort: PropTypes.func,
|
149
|
-
|
150
|
-
/**
|
151
|
-
* The column header scope attribute. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th#attr-scope
|
152
|
-
*/
|
153
|
-
scope: PropTypes.oneOf(['row', 'col', 'rowgroup', 'colgroup', 'auto'])
|
154
|
-
}, _class2.defaultProps = {
|
114
|
+
}, _class2.displayName = "ColHeader", _class2.componentId = 'Table.ColHeader', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
155
115
|
textAlign: 'start',
|
156
116
|
sortDirection: 'none',
|
157
|
-
stackedSortByLabel: void 0,
|
158
117
|
children: null,
|
159
118
|
scope: 'col'
|
160
119
|
}, _temp)) || _class);
|
@@ -0,0 +1,66 @@
|
|
1
|
+
/*
|
2
|
+
* The MIT License (MIT)
|
3
|
+
*
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
11
|
+
* furnished to do so, subject to the following conditions:
|
12
|
+
*
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
14
|
+
* copies or substantial portions of the Software.
|
15
|
+
*
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
* SOFTWARE.
|
23
|
+
*/
|
24
|
+
import PropTypes from 'prop-types';
|
25
|
+
const propTypes = {
|
26
|
+
/**
|
27
|
+
* A unique id for this column. The `id` is also used as option in combobox,
|
28
|
+
* when sortable table is in stacked layout,
|
29
|
+
* and no `stackedSortByLabel` is provided.
|
30
|
+
*/
|
31
|
+
id: PropTypes.string.isRequired,
|
32
|
+
|
33
|
+
/**
|
34
|
+
* A custom string to display as option text in the combobox (instead of
|
35
|
+
* using the `id` prop), when sortable table is in stacked layout.
|
36
|
+
*/
|
37
|
+
stackedSortByLabel: PropTypes.string,
|
38
|
+
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Control the width of column.
|
42
|
+
*/
|
43
|
+
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Control the text alignment in column header
|
47
|
+
*/
|
48
|
+
textAlign: PropTypes.oneOf(['start', 'center', 'end']),
|
49
|
+
|
50
|
+
/**
|
51
|
+
* The string of sorting direction
|
52
|
+
*/
|
53
|
+
sortDirection: PropTypes.oneOf(['none', 'ascending', 'descending']),
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Callback fired when column header is clicked. Parameters: `(event, { id })`
|
57
|
+
*/
|
58
|
+
onRequestSort: PropTypes.func,
|
59
|
+
|
60
|
+
/**
|
61
|
+
* The column header scope attribute. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th#attr-scope
|
62
|
+
*/
|
63
|
+
scope: PropTypes.oneOf(['row', 'col', 'rowgroup', 'colgroup', 'auto'])
|
64
|
+
};
|
65
|
+
const allowedProps = ['id', 'stackedSortByLabel', 'children', 'width', 'textAlign', 'sortDirection', 'onRequestSort', 'scope'];
|
66
|
+
export { propTypes, allowedProps };
|
package/es/Table/Head/index.js
CHANGED
@@ -28,9 +28,7 @@ var _dec, _class, _class2, _temp, _ScreenReaderContent;
|
|
28
28
|
|
29
29
|
/** @jsx jsx */
|
30
30
|
import { Component, Children } from 'react';
|
31
|
-
import PropTypes from 'prop-types';
|
32
31
|
import { omitProps, matchComponentTypes, callRenderProp } from '@instructure/ui-react-utils';
|
33
|
-
import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types';
|
34
32
|
import { SimpleSelect } from '@instructure/ui-simple-select';
|
35
33
|
import { ScreenReaderContent } from '@instructure/ui-a11y-content';
|
36
34
|
import { IconCheckLine } from '@instructure/ui-icons';
|
@@ -40,17 +38,15 @@ import generateStyle from './styles';
|
|
40
38
|
import generateComponentTheme from './theme';
|
41
39
|
import { Row } from '../Row';
|
42
40
|
import { ColHeader } from '../ColHeader';
|
43
|
-
|
41
|
+
import { allowedProps, propTypes } from './props';
|
44
42
|
/**
|
45
43
|
---
|
46
44
|
parent: Table
|
47
45
|
id: Table.Head
|
48
46
|
---
|
49
47
|
**/
|
50
|
-
let Head = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_temp = _class2 = class Head extends Component {
|
51
|
-
/* eslint-disable react/require-default-props */
|
52
48
|
|
53
|
-
|
49
|
+
let Head = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_temp = _class2 = class Head extends Component {
|
54
50
|
get isSortable() {
|
55
51
|
const _Children$toArray = Children.toArray(this.props.children),
|
56
52
|
_Children$toArray2 = _slicedToArray(_Children$toArray, 1),
|
@@ -70,21 +66,25 @@ let Head = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class
|
|
70
66
|
}
|
71
67
|
|
72
68
|
componentDidMount() {
|
73
|
-
|
69
|
+
var _this$props$makeStyle, _this$props;
|
70
|
+
|
71
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
74
72
|
}
|
75
73
|
|
76
74
|
componentDidUpdate() {
|
75
|
+
var _this$props$makeStyle2, _this$props2;
|
76
|
+
|
77
77
|
if (this.isSortable && typeof this.props.renderSortLabel === 'undefined') {
|
78
78
|
warn(false, '[Table.Head] The `renderSortLabel` prop should be provided when Table is sortable.');
|
79
79
|
}
|
80
80
|
|
81
|
-
this.props.makeStyles();
|
81
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
82
82
|
}
|
83
83
|
|
84
84
|
renderSelect() {
|
85
|
-
const _this$
|
86
|
-
children = _this$
|
87
|
-
renderSortLabel = _this$
|
85
|
+
const _this$props3 = this.props,
|
86
|
+
children = _this$props3.children,
|
87
|
+
renderSortLabel = _this$props3.renderSortLabel;
|
88
88
|
|
89
89
|
const _Children$toArray3 = Children.toArray(children),
|
90
90
|
_Children$toArray4 = _slicedToArray(_Children$toArray3, 1),
|
@@ -96,7 +96,7 @@ let Head = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class
|
|
96
96
|
|
97
97
|
const options = [];
|
98
98
|
const clickHandlers = {};
|
99
|
-
let selectedOption =
|
99
|
+
let selectedOption = void 0;
|
100
100
|
let count = 0;
|
101
101
|
Children.forEach(row.props.children, colHeader => {
|
102
102
|
count += 1;
|
@@ -163,27 +163,16 @@ let Head = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class
|
|
163
163
|
}
|
164
164
|
|
165
165
|
render() {
|
166
|
-
const _this$
|
167
|
-
children = _this$
|
168
|
-
isStacked = _this$
|
169
|
-
styles = _this$
|
166
|
+
const _this$props4 = this.props,
|
167
|
+
children = _this$props4.children,
|
168
|
+
isStacked = _this$props4.isStacked,
|
169
|
+
styles = _this$props4.styles;
|
170
170
|
return isStacked ? this.renderSelect() : jsx("thead", Object.assign({}, omitProps(this.props, Head.propTypes), {
|
171
|
-
css: styles.head
|
171
|
+
css: styles === null || styles === void 0 ? void 0 : styles.head
|
172
172
|
}), Children.map(children, child => matchComponentTypes(child, [Row]) ? child : null));
|
173
173
|
}
|
174
174
|
|
175
|
-
}, _class2.displayName = "Head", _class2.componentId = 'Table.Head', _class2.propTypes = {
|
176
|
-
/**
|
177
|
-
* `Table.Row`
|
178
|
-
*/
|
179
|
-
// eslint-disable-next-line react/require-default-props
|
180
|
-
makeStyles: PropTypes.func,
|
181
|
-
// eslint-disable-next-line react/require-default-props
|
182
|
-
styles: PropTypes.object,
|
183
|
-
children: ChildrenPropTypes.oneOf([Row]),
|
184
|
-
isStacked: PropTypes.bool,
|
185
|
-
renderSortLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
|
186
|
-
}, _class2.defaultProps = {
|
175
|
+
}, _class2.displayName = "Head", _class2.componentId = 'Table.Head', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
187
176
|
children: null
|
188
177
|
}, _temp)) || _class);
|
189
178
|
export default Head;
|