@dhis2-ui/table 9.11.0 → 9.11.1-beta.1
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/build/cjs/data-table/__tests__/data-table-cell.test.js +7 -13
- package/build/cjs/data-table/__tests__/data-table-column-header/filter-handle.test.js +1 -8
- package/build/cjs/data-table/__tests__/data-table-column-header/sorter.test.js +1 -6
- package/build/cjs/data-table/__tests__/data-table-column-header.test.js +5 -12
- package/build/cjs/data-table/__tests__/data-table-row/expand-handle-cell.js +1 -6
- package/build/cjs/data-table/__tests__/data-table-row/expanded-row.test.js +3 -8
- package/build/cjs/data-table/__tests__/data-table-row.test.js +5 -13
- package/build/cjs/data-table/__tests__/data-table.test.js +1 -7
- package/build/cjs/data-table/data-table-body.js +0 -1
- package/build/cjs/data-table/data-table-cell.js +5 -24
- package/build/cjs/data-table/data-table-column-header/data-table-column-header.js +8 -27
- package/build/cjs/data-table/data-table-column-header/data-table-column-header.styles.js +4 -10
- package/build/cjs/data-table/data-table-column-header/filter-handle.js +1 -10
- package/build/cjs/data-table/data-table-column-header/sorter.js +6 -23
- package/build/cjs/data-table/data-table-foot.js +0 -1
- package/build/cjs/data-table/data-table-head.js +0 -1
- package/build/cjs/data-table/data-table-row/data-table-row.js +5 -27
- package/build/cjs/data-table/data-table-row/data-table-row.styles.js +4 -10
- package/build/cjs/data-table/data-table-row/drag-handle-cell.js +1 -7
- package/build/cjs/data-table/data-table-row/expand-handle-cell.js +1 -11
- package/build/cjs/data-table/data-table-row/expanded-row.js +4 -14
- package/build/cjs/data-table/data-table-toolbar.js +0 -1
- package/build/cjs/data-table/{data-table.stories.e2e.js → data-table.e2e.stories.js} +2 -14
- package/build/cjs/data-table/data-table.js +5 -20
- package/build/cjs/data-table/{data-table.stories.js → data-table.prod.stories.js} +39 -101
- package/build/cjs/data-table/features/can_scroll/index.js +0 -1
- package/build/cjs/data-table/index.js +0 -8
- package/build/cjs/data-table/table-elements/__tests__/table-body.test.js +1 -6
- package/build/cjs/data-table/table-elements/__tests__/table-data-cell.test.js +4 -9
- package/build/cjs/data-table/table-elements/__tests__/table-foot.test.js +1 -6
- package/build/cjs/data-table/table-elements/__tests__/table-head.test.js +1 -6
- package/build/cjs/data-table/table-elements/__tests__/table-header-cell-action.test.js +1 -6
- package/build/cjs/data-table/table-elements/__tests__/table-header-cell.test.js +5 -10
- package/build/cjs/data-table/table-elements/__tests__/table-row.test.js +1 -6
- package/build/cjs/data-table/table-elements/__tests__/table-scroll-box.test.js +1 -6
- package/build/cjs/data-table/table-elements/__tests__/table-toolbar.test.js +1 -6
- package/build/cjs/data-table/table-elements/__tests__/table.test.js +3 -8
- package/build/cjs/data-table/table-elements/features/can_scroll/index.js +0 -1
- package/build/cjs/data-table/table-elements/index.js +0 -10
- package/build/cjs/data-table/table-elements/table-body.js +6 -17
- package/build/cjs/data-table/table-elements/table-data-cell/table-data-cell.js +7 -27
- package/build/cjs/data-table/table-elements/table-data-cell/table-data-cell.styles.js +2 -5
- package/build/cjs/data-table/table-elements/table-foot.js +5 -13
- package/build/cjs/data-table/table-elements/table-head.js +5 -13
- package/build/cjs/data-table/table-elements/table-header-cell/table-header-cell.js +7 -27
- package/build/cjs/data-table/table-elements/table-header-cell/table-header-cell.styles.js +2 -5
- package/build/cjs/data-table/table-elements/table-header-cell-action.js +6 -16
- package/build/cjs/data-table/table-elements/table-row.js +5 -17
- package/build/cjs/data-table/table-elements/table-scroll-box.js +6 -16
- package/build/cjs/data-table/table-elements/table-toolbar.js +6 -17
- package/build/cjs/data-table/table-elements/{table.stories.e2e.js → table.e2e.stories.js} +2 -15
- package/build/cjs/data-table/table-elements/table.js +6 -20
- package/build/cjs/data-table/table-elements/table.stories.internal.js +41 -78
- package/build/cjs/index.js +0 -3
- package/build/cjs/locales/index.js +3 -33
- package/build/cjs/stacked-table/add-col-num-to-children.js +0 -3
- package/build/cjs/stacked-table/content-with-title.js +4 -13
- package/build/cjs/stacked-table/extract-header-labels.js +25 -28
- package/build/cjs/stacked-table/index.js +0 -8
- package/build/cjs/stacked-table/stacked-table-body.js +1 -7
- package/build/cjs/stacked-table/stacked-table-cell-head.js +2 -9
- package/build/cjs/stacked-table/stacked-table-cell.js +2 -10
- package/build/cjs/stacked-table/stacked-table-foot.js +1 -7
- package/build/cjs/stacked-table/stacked-table-head.js +1 -7
- package/build/cjs/stacked-table/stacked-table-row-head.js +1 -7
- package/build/cjs/stacked-table/stacked-table-row.js +2 -12
- package/build/cjs/stacked-table/stacked-table.js +1 -10
- package/build/cjs/stacked-table/{stacked-table.stories.js → stacked-table.prod.stories.js} +20 -40
- package/build/cjs/stacked-table/stacked-table.test.js +9 -19
- package/build/cjs/stacked-table/supply-header-labels-to-children.js +0 -3
- package/build/cjs/stacked-table/table-context.js +1 -4
- package/build/cjs/stacked-table/table.js +2 -9
- package/build/cjs/table/index.js +0 -8
- package/build/cjs/table/table-body.js +1 -6
- package/build/cjs/table/table-cell-head.js +2 -11
- package/build/cjs/table/table-cell.js +2 -11
- package/build/cjs/table/table-context.js +1 -4
- package/build/cjs/table/table-foot.js +1 -6
- package/build/cjs/table/table-head.js +1 -6
- package/build/cjs/table/table-row-head.js +1 -8
- package/build/cjs/table/table-row.js +5 -18
- package/build/cjs/table/table.js +2 -11
- package/build/cjs/table/{table.stories.js → table.prod.stories.js} +18 -30
- package/build/es/data-table/__tests__/data-table-cell.test.js +6 -6
- package/build/es/data-table/__tests__/data-table-column-header.test.js +4 -3
- package/build/es/data-table/__tests__/data-table-row/expanded-row.test.js +2 -2
- package/build/es/data-table/__tests__/data-table-row.test.js +4 -2
- package/build/es/data-table/data-table-cell.js +1 -11
- package/build/es/data-table/data-table-column-header/data-table-column-header.js +4 -9
- package/build/es/data-table/data-table-column-header/sorter.js +1 -1
- package/build/es/data-table/data-table-row/data-table-row.js +1 -7
- package/build/es/data-table/data-table-row/data-table-row.styles.js +1 -1
- package/build/es/data-table/data-table-row/expanded-row.js +3 -3
- package/build/es/data-table/data-table.js +1 -5
- package/build/es/data-table/{data-table.stories.js → data-table.prod.stories.js} +19 -44
- package/build/es/data-table/table-elements/__tests__/table-data-cell.test.js +3 -3
- package/build/es/data-table/table-elements/__tests__/table-header-cell.test.js +4 -4
- package/build/es/data-table/table-elements/__tests__/table.test.js +2 -2
- package/build/es/data-table/table-elements/table-body.js +2 -4
- package/build/es/data-table/table-elements/table-data-cell/table-data-cell.js +3 -12
- package/build/es/data-table/table-elements/table-data-cell/table-data-cell.styles.js +1 -1
- package/build/es/data-table/table-elements/table-foot.js +1 -2
- package/build/es/data-table/table-elements/table-head.js +1 -2
- package/build/es/data-table/table-elements/table-header-cell/table-header-cell.js +3 -12
- package/build/es/data-table/table-elements/table-header-cell/table-header-cell.styles.js +1 -1
- package/build/es/data-table/table-elements/table-header-cell-action.js +2 -4
- package/build/es/data-table/table-elements/table-row.js +1 -5
- package/build/es/data-table/table-elements/table-scroll-box.js +2 -4
- package/build/es/data-table/table-elements/table-toolbar.js +2 -4
- package/build/es/data-table/table-elements/table.js +2 -7
- package/build/es/data-table/table-elements/table.stories.internal.js +23 -29
- package/build/es/stacked-table/content-with-title.js +1 -1
- package/build/es/stacked-table/extract-header-labels.js +24 -23
- package/build/es/stacked-table/stacked-table-cell-head.js +1 -1
- package/build/es/stacked-table/stacked-table-cell.js +1 -1
- package/build/es/stacked-table/stacked-table-row.js +1 -1
- package/build/es/stacked-table/stacked-table.js +0 -1
- package/build/es/stacked-table/{stacked-table.stories.js → stacked-table.prod.stories.js} +17 -2
- package/build/es/stacked-table/stacked-table.test.js +8 -9
- package/build/es/stacked-table/table.js +1 -1
- package/build/es/table/table-cell-head.js +1 -2
- package/build/es/table/table-cell.js +1 -2
- package/build/es/table/table-row-head.js +0 -1
- package/build/es/table/table-row.js +2 -5
- package/build/es/table/table.js +1 -2
- package/build/es/table/{table.stories.js → table.prod.stories.js} +15 -3
- package/package.json +6 -6
- /package/build/es/data-table/{data-table.stories.e2e.js → data-table.e2e.stories.js} +0 -0
- /package/build/es/data-table/table-elements/{table.stories.e2e.js → table.e2e.stories.js} +0 -0
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import _JSXStyle from "styled-jsx/style";
|
|
2
|
-
|
|
3
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
-
|
|
2
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
5
3
|
import { colors } from '@dhis2/ui-constants';
|
|
6
4
|
import PropTypes from 'prop-types';
|
|
7
5
|
import React, { forwardRef } from 'react';
|
|
@@ -21,7 +19,7 @@ export const TableScrollBox = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
21
19
|
}), children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
22
20
|
id: "2859562182",
|
|
23
21
|
dynamic: [colors.grey300, maxHeight, maxWidth]
|
|
24
|
-
}, [
|
|
22
|
+
}, [`div.__jsx-style-dynamic-selector{border:1px solid ${colors.grey300};border-top:none;box-sizing:border-box;max-height:${maxHeight};max-width:${maxWidth};overflow:auto;}`]));
|
|
25
23
|
});
|
|
26
24
|
TableScrollBox.displayName = 'TableScrollBox';
|
|
27
25
|
TableScrollBox.defaultProps = {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import _JSXStyle from "styled-jsx/style";
|
|
2
|
-
|
|
3
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
-
|
|
2
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
5
3
|
import { colors, spacers } from '@dhis2/ui-constants';
|
|
6
4
|
import cx from 'classnames';
|
|
7
5
|
import PropTypes from 'prop-types';
|
|
@@ -21,7 +19,7 @@ export const TableToolbar = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
21
19
|
}), children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
22
20
|
id: "247244135",
|
|
23
21
|
dynamic: [colors.grey300, spacers.dp12]
|
|
24
|
-
}, [
|
|
22
|
+
}, [`div.__jsx-style-dynamic-selector{width:100%;box-sizing:border-box;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;border:1px solid ${colors.grey300};padding:${spacers.dp12};}`, "div.top.__jsx-style-dynamic-selector{border-bottom:none;}", "div.bottom.__jsx-style-dynamic-selector{border-top:none;}"]));
|
|
25
23
|
});
|
|
26
24
|
TableToolbar.displayName = 'TableToolbar';
|
|
27
25
|
TableToolbar.defaultProps = {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import _JSXStyle from "styled-jsx/style";
|
|
2
|
-
|
|
3
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
-
|
|
2
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
5
3
|
import { colors } from '@dhis2/ui-constants';
|
|
6
4
|
import cx from 'classnames';
|
|
7
5
|
import PropTypes from 'prop-types';
|
|
@@ -27,7 +25,7 @@ export const Table = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
27
25
|
}), children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
28
26
|
id: "3140496910",
|
|
29
27
|
dynamic: [layout, width, colors.grey300]
|
|
30
|
-
}, [
|
|
28
|
+
}, [`table.__jsx-style-dynamic-selector{table-layout:${layout};border-collapse:separate;border-spacing:0;width:${width};box-sizing:border-box;border:1px solid ${colors.grey300};}`, "table.borderless.__jsx-style-dynamic-selector{border:none;}"]));
|
|
31
29
|
});
|
|
32
30
|
Table.displayName = 'Table';
|
|
33
31
|
Table.defaultProps = {
|
|
@@ -40,14 +38,12 @@ Table.propTypes = {
|
|
|
40
38
|
* Removes border from the table
|
|
41
39
|
*/
|
|
42
40
|
borderless: PropTypes.bool,
|
|
43
|
-
|
|
44
41
|
/**
|
|
45
42
|
* Should be `<TableHead>`, `<TableBody>`, and `<TableFoot>` components
|
|
46
43
|
*/
|
|
47
44
|
children: PropTypes.node,
|
|
48
45
|
className: PropTypes.string,
|
|
49
46
|
dataTest: PropTypes.string,
|
|
50
|
-
|
|
51
47
|
/**
|
|
52
48
|
* Sets the `table-layout` property. Switching to `fixed` can prevent style
|
|
53
49
|
* issues when dealing with a table with multiple frozen columns or when dealing
|
|
@@ -55,7 +51,6 @@ Table.propTypes = {
|
|
|
55
51
|
*/
|
|
56
52
|
layout: PropTypes.oneOf(['auto', 'fixed', 'initial', 'inherit']),
|
|
57
53
|
role: PropTypes.string,
|
|
58
|
-
|
|
59
54
|
/**
|
|
60
55
|
* Sets the `width` property. Providing an explicit width can prevent style
|
|
61
56
|
* issues when dealing with horizontally scrolling tables with a fixed layout.
|
|
@@ -1,20 +1,36 @@
|
|
|
1
1
|
/* eslint-disable react/prop-types */
|
|
2
|
+
import { IconAttachment16 } from '@dhis2/ui-icons';
|
|
2
3
|
import { Box } from '@dhis2-ui/box';
|
|
3
4
|
import { Checkbox } from '@dhis2-ui/checkbox';
|
|
4
|
-
import { IconAttachment16 } from '@dhis2/ui-icons';
|
|
5
5
|
import React, { useState } from 'react';
|
|
6
6
|
import { TableBody } from './table-body.js';
|
|
7
7
|
import { TableDataCell } from './table-data-cell/table-data-cell.js';
|
|
8
8
|
import { TableFoot } from './table-foot.js';
|
|
9
9
|
import { TableHead } from './table-head.js';
|
|
10
|
-
import { TableHeaderCellAction } from './table-header-cell-action.js';
|
|
11
10
|
import { TableHeaderCell } from './table-header-cell/table-header-cell.js';
|
|
11
|
+
import { TableHeaderCellAction } from './table-header-cell-action.js';
|
|
12
12
|
import { TableRow } from './table-row.js';
|
|
13
13
|
import { TableScrollBox } from './table-scroll-box.js';
|
|
14
14
|
import { TableToolbar } from './table-toolbar.js';
|
|
15
15
|
import { Table } from './table.js';
|
|
16
16
|
const subtitle = 'Used to display information in a standard, effective way.';
|
|
17
|
-
const description =
|
|
17
|
+
const description = `
|
|
18
|
+
Should be used with multiple Table-related child components - see the table and examples below.
|
|
19
|
+
|
|
20
|
+
\`\`\`js
|
|
21
|
+
import {
|
|
22
|
+
Table,
|
|
23
|
+
TableToolbar,
|
|
24
|
+
TableHead,
|
|
25
|
+
TableBody,
|
|
26
|
+
TableFoot,
|
|
27
|
+
TableRow,
|
|
28
|
+
TableDataCell,
|
|
29
|
+
TableHeaderCell,
|
|
30
|
+
TableScrollBox,
|
|
31
|
+
} from '@dhis2/ui'
|
|
32
|
+
\`\`\`
|
|
33
|
+
`;
|
|
18
34
|
export default {
|
|
19
35
|
title: 'Data Display/Table',
|
|
20
36
|
component: Table,
|
|
@@ -66,7 +82,6 @@ export default {
|
|
|
66
82
|
}
|
|
67
83
|
}
|
|
68
84
|
};
|
|
69
|
-
|
|
70
85
|
const BasicTemplate = _ref => {
|
|
71
86
|
let {
|
|
72
87
|
borderedCells,
|
|
@@ -144,7 +159,6 @@ const BasicTemplate = _ref => {
|
|
|
144
159
|
colSpan: "4"
|
|
145
160
|
}, "Footer content"))));
|
|
146
161
|
};
|
|
147
|
-
|
|
148
162
|
export const Default = BasicTemplate.bind({});
|
|
149
163
|
Default.args = {};
|
|
150
164
|
export const BorderedCells = BasicTemplate.bind({});
|
|
@@ -163,7 +177,6 @@ export const DraggableRows = BasicTemplate.bind({});
|
|
|
163
177
|
DraggableRows.args = {
|
|
164
178
|
draggableRows: true
|
|
165
179
|
};
|
|
166
|
-
|
|
167
180
|
const IndividualCellTemplate = args => /*#__PURE__*/React.createElement(Table, args, /*#__PURE__*/React.createElement(TableHead, null, /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableHeaderCell, null, "Header"), /*#__PURE__*/React.createElement(TableHeaderCell, null, "Header"), /*#__PURE__*/React.createElement(TableHeaderCell, null, "Header"), /*#__PURE__*/React.createElement(TableHeaderCell, null, "Header"))), /*#__PURE__*/React.createElement(TableBody, null, /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableDataCell, {
|
|
168
181
|
tag: "th"
|
|
169
182
|
}, "Active Cells"), /*#__PURE__*/React.createElement(TableDataCell, null, "Inactive cell"), /*#__PURE__*/React.createElement(TableDataCell, {
|
|
@@ -188,10 +201,8 @@ const IndividualCellTemplate = args => /*#__PURE__*/React.createElement(Table, a
|
|
|
188
201
|
}, "Valid"), /*#__PURE__*/React.createElement(TableDataCell, {
|
|
189
202
|
muted: true
|
|
190
203
|
}, "Muted"))));
|
|
191
|
-
|
|
192
204
|
export const CellStyling = IndividualCellTemplate.bind({});
|
|
193
205
|
CellStyling.args = {};
|
|
194
|
-
|
|
195
206
|
const IrregularHeadersTemplate = args => /*#__PURE__*/React.createElement(Table, args, /*#__PURE__*/React.createElement("colgroup", null), /*#__PURE__*/React.createElement("colgroup", {
|
|
196
207
|
span: "2"
|
|
197
208
|
}), /*#__PURE__*/React.createElement("colgroup", {
|
|
@@ -246,32 +257,27 @@ const IrregularHeadersTemplate = args => /*#__PURE__*/React.createElement(Table,
|
|
|
246
257
|
}, "12,000"), /*#__PURE__*/React.createElement(TableDataCell, {
|
|
247
258
|
staticStyle: true
|
|
248
259
|
}, "9,000"))));
|
|
249
|
-
|
|
250
260
|
export const IrregularHeaders = IrregularHeadersTemplate.bind({});
|
|
251
261
|
IrregularHeaders.args = {};
|
|
252
|
-
|
|
253
262
|
const ToolbarsTemplate = args => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TableToolbar, null, /*#__PURE__*/React.createElement("p", null, "Content")), /*#__PURE__*/React.createElement(Table, args, /*#__PURE__*/React.createElement(TableHead, null, /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableHeaderCell, null, "First name"), /*#__PURE__*/React.createElement(TableHeaderCell, null, "Last name"), /*#__PURE__*/React.createElement(TableHeaderCell, null, "Incident date"), /*#__PURE__*/React.createElement(TableHeaderCell, null, "Last updated"))), /*#__PURE__*/React.createElement(TableBody, null, /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableDataCell, null, "Onyekachukwu"), /*#__PURE__*/React.createElement(TableDataCell, null, "Kariuki"), /*#__PURE__*/React.createElement(TableDataCell, null, "02/06/2007"), /*#__PURE__*/React.createElement(TableDataCell, null, "05/25/1972")), /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableDataCell, null, "Kwasi"), /*#__PURE__*/React.createElement(TableDataCell, null, "Okafor"), /*#__PURE__*/React.createElement(TableDataCell, null, "08/11/2010"), /*#__PURE__*/React.createElement(TableDataCell, null, "02/26/1991")), /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableDataCell, null, "Siyabonga"), /*#__PURE__*/React.createElement(TableDataCell, null, "Abiodun"), /*#__PURE__*/React.createElement(TableDataCell, null, "07/21/1981"), /*#__PURE__*/React.createElement(TableDataCell, null, "02/06/2007")))), /*#__PURE__*/React.createElement(TableToolbar, {
|
|
254
263
|
position: "bottom"
|
|
255
264
|
}, /*#__PURE__*/React.createElement("p", null, "Content (bottom)")));
|
|
256
|
-
|
|
257
265
|
export const Toolbars = ToolbarsTemplate.bind({});
|
|
258
266
|
Toolbars.args = {};
|
|
259
|
-
|
|
260
267
|
const SelectableRowsTemplate = args => {
|
|
261
268
|
const [selected, setSelected] = useState({
|
|
262
269
|
id_2: true
|
|
263
270
|
});
|
|
264
|
-
|
|
265
271
|
const toggleSelected = _ref2 => {
|
|
266
272
|
let {
|
|
267
273
|
value,
|
|
268
274
|
checked
|
|
269
275
|
} = _ref2;
|
|
270
|
-
setSelected({
|
|
276
|
+
setSelected({
|
|
277
|
+
...selected,
|
|
271
278
|
[value]: checked
|
|
272
279
|
});
|
|
273
280
|
};
|
|
274
|
-
|
|
275
281
|
const toggleAll = _ref3 => {
|
|
276
282
|
let {
|
|
277
283
|
checked
|
|
@@ -282,9 +288,7 @@ const SelectableRowsTemplate = args => {
|
|
|
282
288
|
id_3: checked
|
|
283
289
|
});
|
|
284
290
|
};
|
|
285
|
-
|
|
286
291
|
const allSelected = () => Object.values(selected).filter(value => value).length === 3;
|
|
287
|
-
|
|
288
292
|
return /*#__PURE__*/React.createElement(Table, args, /*#__PURE__*/React.createElement(TableHead, null, /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableHeaderCell, {
|
|
289
293
|
width: "48px"
|
|
290
294
|
}, /*#__PURE__*/React.createElement(Checkbox, {
|
|
@@ -316,12 +320,11 @@ const SelectableRowsTemplate = args => {
|
|
|
316
320
|
onChange: toggleSelected
|
|
317
321
|
})), /*#__PURE__*/React.createElement(TableDataCell, null, "Siyabonga"), /*#__PURE__*/React.createElement(TableDataCell, null, "Abiodun"), /*#__PURE__*/React.createElement(TableDataCell, null, "07/21/1981"), /*#__PURE__*/React.createElement(TableDataCell, null, "02/06/2007"))));
|
|
318
322
|
};
|
|
319
|
-
|
|
320
323
|
export const SelectableRows = SelectableRowsTemplate.bind({});
|
|
321
324
|
SelectableRows.args = {};
|
|
322
|
-
|
|
323
325
|
const FixedHeaderTemplate = _ref4 => {
|
|
324
|
-
let {
|
|
326
|
+
let {
|
|
327
|
+
...args
|
|
325
328
|
} = _ref4;
|
|
326
329
|
return /*#__PURE__*/React.createElement(TableScrollBox, {
|
|
327
330
|
maxHeight: "350px"
|
|
@@ -351,12 +354,10 @@ const FixedHeaderTemplate = _ref4 => {
|
|
|
351
354
|
top: "0"
|
|
352
355
|
}, "Status"))), /*#__PURE__*/React.createElement(TableBody, null, /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableDataCell, null, "Onyekachukwu"), /*#__PURE__*/React.createElement(TableDataCell, null, "Kariuki"), /*#__PURE__*/React.createElement(TableDataCell, null, "02/06/2007"), /*#__PURE__*/React.createElement(TableDataCell, null, "05/25/1972"), /*#__PURE__*/React.createElement(TableDataCell, null, "66"), /*#__PURE__*/React.createElement(TableDataCell, null, "Jawi"), /*#__PURE__*/React.createElement(TableDataCell, null, "Sofie Hubert"), /*#__PURE__*/React.createElement(TableDataCell, null, "Incomplete")), /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableDataCell, null, "Kwasi"), /*#__PURE__*/React.createElement(TableDataCell, null, "Okafor"), /*#__PURE__*/React.createElement(TableDataCell, null, "08/11/2010"), /*#__PURE__*/React.createElement(TableDataCell, null, "02/26/1991"), /*#__PURE__*/React.createElement(TableDataCell, null, "38"), /*#__PURE__*/React.createElement(TableDataCell, null, "Mokassie MCHP"), /*#__PURE__*/React.createElement(TableDataCell, null, "Dashonte Clarke"), /*#__PURE__*/React.createElement(TableDataCell, null, "Complete")), /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableDataCell, null, "Siyabonga"), /*#__PURE__*/React.createElement(TableDataCell, null, "Abiodun"), /*#__PURE__*/React.createElement(TableDataCell, null, "07/21/1981"), /*#__PURE__*/React.createElement(TableDataCell, null, "02/06/2007"), /*#__PURE__*/React.createElement(TableDataCell, null, "98"), /*#__PURE__*/React.createElement(TableDataCell, null, "Bathurst MCHP"), /*#__PURE__*/React.createElement(TableDataCell, null, "Unassigned"), /*#__PURE__*/React.createElement(TableDataCell, null, "Incomplete")), /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableDataCell, null, "Chiyembekezo"), /*#__PURE__*/React.createElement(TableDataCell, null, "Okeke"), /*#__PURE__*/React.createElement(TableDataCell, null, "01/23/1982"), /*#__PURE__*/React.createElement(TableDataCell, null, "07/15/2003"), /*#__PURE__*/React.createElement(TableDataCell, null, "2"), /*#__PURE__*/React.createElement(TableDataCell, null, "Mayolla MCHP"), /*#__PURE__*/React.createElement(TableDataCell, null, "Wan Gengxin"), /*#__PURE__*/React.createElement(TableDataCell, null, "Incomplete")), /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableDataCell, null, "Mtendere"), /*#__PURE__*/React.createElement(TableDataCell, null, "Afolayan"), /*#__PURE__*/React.createElement(TableDataCell, null, "08/12/1994"), /*#__PURE__*/React.createElement(TableDataCell, null, "05/12/1972"), /*#__PURE__*/React.createElement(TableDataCell, null, "37"), /*#__PURE__*/React.createElement(TableDataCell, null, "Gbangadu MCHP"), /*#__PURE__*/React.createElement(TableDataCell, null, "Gvozden Boskovsky"), /*#__PURE__*/React.createElement(TableDataCell, null, "Complete")), /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableDataCell, null, "Inyene"), /*#__PURE__*/React.createElement(TableDataCell, null, "Okonkwo"), /*#__PURE__*/React.createElement(TableDataCell, null, "04/01/1971"), /*#__PURE__*/React.createElement(TableDataCell, null, "03/16/2000"), /*#__PURE__*/React.createElement(TableDataCell, null, "70"), /*#__PURE__*/React.createElement(TableDataCell, null, "Kunike Barina"), /*#__PURE__*/React.createElement(TableDataCell, null, "Oscar de la Cavaller\xEDa"), /*#__PURE__*/React.createElement(TableDataCell, null, "Complete")), /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableDataCell, null, "Amaka"), /*#__PURE__*/React.createElement(TableDataCell, null, "Pretorius"), /*#__PURE__*/React.createElement(TableDataCell, null, "01/25/1996"), /*#__PURE__*/React.createElement(TableDataCell, null, "09/15/1986"), /*#__PURE__*/React.createElement(TableDataCell, null, "32"), /*#__PURE__*/React.createElement(TableDataCell, null, "Bargbo"), /*#__PURE__*/React.createElement(TableDataCell, null, "Alberto Raya"), /*#__PURE__*/React.createElement(TableDataCell, null, "Incomplete")), /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableDataCell, null, "Meti"), /*#__PURE__*/React.createElement(TableDataCell, null, "Abiodun"), /*#__PURE__*/React.createElement(TableDataCell, null, "10/24/2010"), /*#__PURE__*/React.createElement(TableDataCell, null, "07/26/1989"), /*#__PURE__*/React.createElement(TableDataCell, null, "8"), /*#__PURE__*/React.createElement(TableDataCell, null, "Majihun MCHP"), /*#__PURE__*/React.createElement(TableDataCell, null, "Unassigned"), /*#__PURE__*/React.createElement(TableDataCell, null, "Complete")), /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableDataCell, null, "Eshe"), /*#__PURE__*/React.createElement(TableDataCell, null, "Okeke"), /*#__PURE__*/React.createElement(TableDataCell, null, "01/31/1995"), /*#__PURE__*/React.createElement(TableDataCell, null, "01/31/1995"), /*#__PURE__*/React.createElement(TableDataCell, null, "63"), /*#__PURE__*/React.createElement(TableDataCell, null, "Mambiama CHP"), /*#__PURE__*/React.createElement(TableDataCell, null, "Shadrias Pearson"), /*#__PURE__*/React.createElement(TableDataCell, null, "Incomplete")), /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableDataCell, null, "Obi"), /*#__PURE__*/React.createElement(TableDataCell, null, "Okafor"), /*#__PURE__*/React.createElement(TableDataCell, null, "06/07/1990"), /*#__PURE__*/React.createElement(TableDataCell, null, "01/03/2006"), /*#__PURE__*/React.createElement(TableDataCell, null, "28"), /*#__PURE__*/React.createElement(TableDataCell, null, "Dalakuru CHP"), /*#__PURE__*/React.createElement(TableDataCell, null, "Anatoliy Shcherbatykh"), /*#__PURE__*/React.createElement(TableDataCell, null, "Incomplete")))));
|
|
353
356
|
};
|
|
354
|
-
|
|
355
357
|
export const FixedHeader = FixedHeaderTemplate.bind({});
|
|
356
358
|
FixedHeader.args = {
|
|
357
359
|
borderless: true
|
|
358
360
|
};
|
|
359
|
-
|
|
360
361
|
const FixedFirstColumnTemplate = args => /*#__PURE__*/React.createElement(TableScrollBox, {
|
|
361
362
|
maxWidth: "500px"
|
|
362
363
|
}, /*#__PURE__*/React.createElement(Table, args, /*#__PURE__*/React.createElement(TableHead, null, /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableHeaderCell, {
|
|
@@ -394,13 +395,11 @@ const FixedFirstColumnTemplate = args => /*#__PURE__*/React.createElement(TableS
|
|
|
394
395
|
fixed: true,
|
|
395
396
|
left: "0"
|
|
396
397
|
}, "Obi"), /*#__PURE__*/React.createElement(TableDataCell, null, "Okafor"), /*#__PURE__*/React.createElement(TableDataCell, null, "06/07/1990"), /*#__PURE__*/React.createElement(TableDataCell, null, "01/03/2006"), /*#__PURE__*/React.createElement(TableDataCell, null, "28"), /*#__PURE__*/React.createElement(TableDataCell, null, "Dalakuru CHP"), /*#__PURE__*/React.createElement(TableDataCell, null, "Anatoliy Shcherbatykh"), /*#__PURE__*/React.createElement(TableDataCell, null, "Incomplete")))));
|
|
397
|
-
|
|
398
398
|
export const FixedFirstColumn = FixedFirstColumnTemplate.bind({});
|
|
399
399
|
FixedFirstColumn.args = {
|
|
400
400
|
borderless: true,
|
|
401
401
|
width: '1000px'
|
|
402
402
|
};
|
|
403
|
-
|
|
404
403
|
const FixedHeaderAndTwoColumnsTemplate = args => /*#__PURE__*/React.createElement(TableScrollBox, {
|
|
405
404
|
maxHeight: "350px",
|
|
406
405
|
maxWidth: "500px"
|
|
@@ -502,14 +501,12 @@ const FixedHeaderAndTwoColumnsTemplate = args => /*#__PURE__*/React.createElemen
|
|
|
502
501
|
fixed: true,
|
|
503
502
|
left: "120px"
|
|
504
503
|
}, "Okafor"), /*#__PURE__*/React.createElement(TableDataCell, null, "06/07/1990"), /*#__PURE__*/React.createElement(TableDataCell, null, "01/03/2006"), /*#__PURE__*/React.createElement(TableDataCell, null, "28"), /*#__PURE__*/React.createElement(TableDataCell, null, "Dalakuru CHP"), /*#__PURE__*/React.createElement(TableDataCell, null, "Anatoliy Shcherbatykh"), /*#__PURE__*/React.createElement(TableDataCell, null, "Incomplete")))));
|
|
505
|
-
|
|
506
504
|
export const FixedHeaderAndTwoColumns = FixedHeaderAndTwoColumnsTemplate.bind({});
|
|
507
505
|
FixedHeaderAndTwoColumns.args = {
|
|
508
506
|
layout: 'fixed',
|
|
509
507
|
borderless: true,
|
|
510
508
|
width: '1000px'
|
|
511
509
|
};
|
|
512
|
-
|
|
513
510
|
const ScrollingTableWithToolbarsTemplate = args => /*#__PURE__*/React.createElement(Box, {
|
|
514
511
|
width: "500px"
|
|
515
512
|
}, /*#__PURE__*/React.createElement(TableToolbar, null, /*#__PURE__*/React.createElement("p", null, "Content")), /*#__PURE__*/React.createElement(TableScrollBox, {
|
|
@@ -615,14 +612,12 @@ const ScrollingTableWithToolbarsTemplate = args => /*#__PURE__*/React.createElem
|
|
|
615
612
|
}, "Okafor"), /*#__PURE__*/React.createElement(TableDataCell, null, "06/07/1990"), /*#__PURE__*/React.createElement(TableDataCell, null, "01/03/2006"), /*#__PURE__*/React.createElement(TableDataCell, null, "28"), /*#__PURE__*/React.createElement(TableDataCell, null, "Dalakuru CHP"), /*#__PURE__*/React.createElement(TableDataCell, null, "Anatoliy Shcherbatykh"), /*#__PURE__*/React.createElement(TableDataCell, null, "Incomplete"))))), /*#__PURE__*/React.createElement(TableToolbar, {
|
|
616
613
|
position: "bottom"
|
|
617
614
|
}, /*#__PURE__*/React.createElement("p", null, "Content (bottom)")));
|
|
618
|
-
|
|
619
615
|
export const ScrollingTableWithToolbars = ScrollingTableWithToolbarsTemplate.bind({});
|
|
620
616
|
ScrollingTableWithToolbars.args = {
|
|
621
617
|
layout: 'fixed',
|
|
622
618
|
borderless: true,
|
|
623
619
|
width: '1000px'
|
|
624
620
|
};
|
|
625
|
-
|
|
626
621
|
const HeaderActionsTemplate = args => /*#__PURE__*/React.createElement(Table, args, /*#__PURE__*/React.createElement(TableHead, null, /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableHeaderCell, null, /*#__PURE__*/React.createElement("span", {
|
|
627
622
|
style: {
|
|
628
623
|
display: 'flex',
|
|
@@ -642,6 +637,5 @@ const HeaderActionsTemplate = args => /*#__PURE__*/React.createElement(Table, ar
|
|
|
642
637
|
})))))), /*#__PURE__*/React.createElement(TableBody, null, /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableDataCell, {
|
|
643
638
|
colSpan: "3"
|
|
644
639
|
}))));
|
|
645
|
-
|
|
646
640
|
export const HeaderActions = HeaderActionsTemplate.bind({});
|
|
647
641
|
HeaderActions.args = {};
|
|
@@ -14,7 +14,7 @@ export const ContentWithTitle = _ref => {
|
|
|
14
14
|
}, children), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
15
15
|
id: "215664166",
|
|
16
16
|
dynamic: [colors.grey700]
|
|
17
|
-
}, [
|
|
17
|
+
}, [`.title.__jsx-style-dynamic-selector{display:block;white-space:normal;min-height:24px;font-size:13px;line-height:16px;padding:8px 0 4px;font-weight:normal;color:${colors.grey700};}`, ".content.__jsx-style-dynamic-selector{display:block;padding:0 0 8px 0;font-size:14px;line-height:18px;}", ".content.__jsx-style-dynamic-selector:first-child{padding-top:8px;padding-bottom:8px;}"]));
|
|
18
18
|
};
|
|
19
19
|
ContentWithTitle.propTypes = {
|
|
20
20
|
children: PropTypes.node.isRequired,
|
|
@@ -1,60 +1,61 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { StackedTableHead } from './stacked-table-head.js';
|
|
3
|
-
|
|
4
3
|
const isChildTableHead = child => child.type === StackedTableHead;
|
|
5
|
-
|
|
6
4
|
const extractChildrenProp = component => component.props.children;
|
|
5
|
+
const extractRowsFromTableChildren = children => React.Children.toArray(children).filter(isChildTableHead)
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
.map(extractChildrenProp)
|
|
7
|
+
// extract table head children (rows)
|
|
8
|
+
.map(extractChildrenProp)
|
|
9
|
+
|
|
10
|
+
// when there are multiple header rows,
|
|
10
11
|
// children will come as arrays
|
|
11
|
-
.reduce((flattened, row) => Array.isArray(row) ? [...flattened, ...row] : [...flattened, row], [])
|
|
12
|
+
.reduce((flattened, row) => Array.isArray(row) ? [...flattened, ...row] : [...flattened, row], [])
|
|
13
|
+
|
|
14
|
+
// extract table row children (cells),
|
|
12
15
|
// will return an array with arrays of cells
|
|
13
16
|
.map(extractChildrenProp);
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
const calculateColumnCount = row => Array.isArray(row) ? row.reduce((total, col) =>
|
|
18
|
+
// make sure to take col span into account
|
|
16
19
|
col.props.colSpan ? total + parseInt(col.props.colSpan, 10) : total + 1, 0) : 1;
|
|
17
|
-
|
|
18
20
|
const mapCellsToLabels = rowChildren => {
|
|
19
|
-
let labels = [];
|
|
21
|
+
let labels = [];
|
|
22
|
+
// in case there's only one cell, the children are not an array
|
|
23
|
+
const row = Array.isArray(rowChildren) ? rowChildren : [rowChildren];
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
// Using a for loop here to be able to increment "i"
|
|
22
26
|
// when a cell has a colspan prop by the colspan number
|
|
23
|
-
|
|
24
27
|
for (let i = 0, count = row.length; i < count; ++i) {
|
|
25
28
|
const cell = row[i];
|
|
26
29
|
const colSpan = cell.props.colSpan ? parseInt(cell.props.colSpan, 10) : 1;
|
|
27
|
-
const label = extractLabelFromCell(cell);
|
|
30
|
+
const label = extractLabelFromCell(cell);
|
|
28
31
|
|
|
32
|
+
// Add a label entry for each column
|
|
29
33
|
labels = [...labels, ...Array(colSpan).fill(label)];
|
|
30
34
|
}
|
|
31
|
-
|
|
32
35
|
return labels;
|
|
33
36
|
};
|
|
34
|
-
|
|
35
37
|
const extractLabelFromCell = cell => !cell.props.hideResponsiveLabel ? cell.props.children : '';
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
const combineRowLables = (columnCount, rowCount, headerLabels) =>
|
|
39
|
+
// create array with length of column count
|
|
38
40
|
Array(columnCount).fill('').reduce((labels, _, colIndex) => {
|
|
39
41
|
// an array with all labels for a column
|
|
40
|
-
const colLabels =
|
|
41
|
-
|
|
42
|
-
.
|
|
42
|
+
const colLabels =
|
|
43
|
+
// create array with length of rows
|
|
44
|
+
Array(rowCount).fill('')
|
|
45
|
+
// get label for current row & col
|
|
46
|
+
.map((__, rowIndex) => headerLabels[rowIndex][colIndex])
|
|
47
|
+
// remove empty ones
|
|
43
48
|
.filter(val => val);
|
|
44
49
|
return [...labels, colLabels.join(' / ')];
|
|
45
50
|
}, []);
|
|
46
|
-
|
|
47
51
|
export const extractHeaderLabels = children => {
|
|
48
52
|
if (React.Children.count(children) === 0) {
|
|
49
53
|
return [];
|
|
50
54
|
}
|
|
51
|
-
|
|
52
55
|
const rows = extractRowsFromTableChildren(children);
|
|
53
|
-
|
|
54
56
|
if (!rows.length) {
|
|
55
57
|
return [];
|
|
56
58
|
}
|
|
57
|
-
|
|
58
59
|
const rowCount = rows.length;
|
|
59
60
|
const columnCount = calculateColumnCount(rows[0]);
|
|
60
61
|
const headerLabels = rows.map(mapCellsToLabels);
|
|
@@ -20,7 +20,7 @@ export const StackedTableCellHead = _ref => {
|
|
|
20
20
|
}, children), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
21
21
|
id: "178822310",
|
|
22
22
|
dynamic: [colors.grey300]
|
|
23
|
-
}, [
|
|
23
|
+
}, [`th.__jsx-style-dynamic-selector{border-bottom:1px solid ${colors.grey300};padding:0 12px;}`, "div.__jsx-style-dynamic-selector{min-height:36px;}"]));
|
|
24
24
|
};
|
|
25
25
|
StackedTableCellHead.propTypes = {
|
|
26
26
|
children: PropTypes.string,
|
|
@@ -27,7 +27,7 @@ export const StackedTableCell = _ref => {
|
|
|
27
27
|
}, children), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
28
28
|
id: "1923758240",
|
|
29
29
|
dynamic: [colors.grey300]
|
|
30
|
-
}, [
|
|
30
|
+
}, [`td.__jsx-style-dynamic-selector{border-bottom:1px solid ${colors.grey300};padding:0 12px;font-size:14px;width:100%;display:block;}`, "td.__jsx-style-dynamic-selector:dir(rtl){text-align:right;}", "td.__jsx-style-dynamic-selector:last-child{border-bottom:0;}"]));
|
|
31
31
|
};
|
|
32
32
|
StackedTableCell.propTypes = {
|
|
33
33
|
children: PropTypes.node,
|
|
@@ -22,7 +22,7 @@ export const StackedTableRow = _ref => {
|
|
|
22
22
|
}), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
23
23
|
id: "2003961452",
|
|
24
24
|
dynamic: [colors.grey300, colors.white]
|
|
25
|
-
}, [
|
|
25
|
+
}, [`tr.__jsx-style-dynamic-selector{min-height:45px;display:block;border:1px solid ${colors.grey300};}`, `tr.__jsx-style-dynamic-selector:nth-child(even){background:${colors.white};}`, "thead>tr.__jsx-style-dynamic-selector,tbody>tr.__jsx-style-dynamic-selector{min-height:36px;}", "tr.__jsx-style-dynamic-selector+tr.__jsx-style-dynamic-selector{margin-top:32px;}"]));
|
|
26
26
|
};
|
|
27
27
|
StackedTableRow.propTypes = {
|
|
28
28
|
children: PropTypes.node,
|
|
@@ -8,10 +8,25 @@ import { StackedTableHead } from './stacked-table-head.js';
|
|
|
8
8
|
import { StackedTableRowHead } from './stacked-table-row-head.js';
|
|
9
9
|
import { StackedTableRow } from './stacked-table-row.js';
|
|
10
10
|
import { StackedTable } from './stacked-table.js';
|
|
11
|
-
const description =
|
|
11
|
+
const description = `
|
|
12
|
+
Expresses tabular data such that each 'row' becomes a table section with the 'column' header in each cell. Multiple rows become multiple sections.
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
Compose with StackedTable child components, as seen in the examples.
|
|
14
15
|
|
|
16
|
+
\`\`\`js
|
|
17
|
+
import {
|
|
18
|
+
StackedTable,
|
|
19
|
+
StackedTableBody,
|
|
20
|
+
StackedTableCell,
|
|
21
|
+
StackedTableCellHead,
|
|
22
|
+
StackedTableFoot,
|
|
23
|
+
StackedTableHead,
|
|
24
|
+
StackedTableRow,
|
|
25
|
+
StackedTableRowHead,
|
|
26
|
+
} from 'dhis2/ui'
|
|
27
|
+
\`\`\`
|
|
28
|
+
`;
|
|
29
|
+
const CustomCell = props => /*#__PURE__*/React.createElement("td", null, "Received props:", /*#__PURE__*/React.createElement("code", null, /*#__PURE__*/React.createElement("pre", null, JSON.stringify(props, null, 2))));
|
|
15
30
|
export default {
|
|
16
31
|
title: 'Stacked Table',
|
|
17
32
|
component: StackedTable,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign
|
|
2
|
-
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
2
|
/* eslint-disable react/prop-types */
|
|
4
3
|
import { mount } from 'enzyme';
|
|
5
4
|
import React from 'react';
|
|
@@ -10,7 +9,6 @@ import { StackedTableHead } from './stacked-table-head.js';
|
|
|
10
9
|
import { StackedTableRowHead } from './stacked-table-row-head.js';
|
|
11
10
|
import { StackedTableRow } from './stacked-table-row.js';
|
|
12
11
|
import { StackedTable } from './stacked-table.js';
|
|
13
|
-
|
|
14
12
|
const Table = _ref => {
|
|
15
13
|
let {
|
|
16
14
|
headerLabels,
|
|
@@ -34,7 +32,6 @@ const Table = _ref => {
|
|
|
34
32
|
}), label);
|
|
35
33
|
}))));
|
|
36
34
|
};
|
|
37
|
-
|
|
38
35
|
describe('StackedTable', () => {
|
|
39
36
|
const headerLabels = [{
|
|
40
37
|
label: 'First name',
|
|
@@ -106,25 +103,27 @@ describe('StackedTable', () => {
|
|
|
106
103
|
const indexWithColspan = 1;
|
|
107
104
|
const colSpan = 3;
|
|
108
105
|
const originalHeaderLabel = headerLabels[indexWithColspan];
|
|
109
|
-
const headerLabelsWithColspan = [...headerLabels.slice(0, indexWithColspan), {
|
|
110
|
-
|
|
106
|
+
const headerLabelsWithColspan = [...headerLabels.slice(0, indexWithColspan), {
|
|
107
|
+
...originalHeaderLabel,
|
|
108
|
+
colSpan: `${colSpan}`
|
|
111
109
|
}, ...headerLabels.slice(indexWithColspan + colSpan)];
|
|
112
110
|
const table = mount( /*#__PURE__*/React.createElement(Table, {
|
|
113
111
|
headerLabels: headerLabelsWithColspan,
|
|
114
112
|
bodyLabels: bodyLabels
|
|
115
113
|
}));
|
|
116
114
|
const cells = table.find('td');
|
|
117
|
-
const label = headerLabelsWithColspan[indexWithColspan].label;
|
|
115
|
+
const label = headerLabelsWithColspan[indexWithColspan].label;
|
|
118
116
|
|
|
117
|
+
// all body cells that are group under the single header should share the same label
|
|
119
118
|
for (let i = 0; i < colSpan; ++i) {
|
|
120
119
|
const index = indexWithColspan + i;
|
|
121
120
|
const cell = cells.at(index);
|
|
122
121
|
expect(cell).toHaveLength(1);
|
|
123
122
|
const title = cell.find('.title');
|
|
124
123
|
expect(title.text()).toBe(label);
|
|
125
|
-
}
|
|
126
|
-
|
|
124
|
+
}
|
|
127
125
|
|
|
126
|
+
// the next body cell should have the label of the next header cell
|
|
128
127
|
const titleAfterColspan = headerLabelsWithColspan[indexWithColspan + 1].label;
|
|
129
128
|
const cellAfterColspan = cells.at(indexWithColspan + colSpan);
|
|
130
129
|
expect(cellAfterColspan).toHaveLength(1);
|
|
@@ -14,7 +14,7 @@ export const Table = _ref => {
|
|
|
14
14
|
}, children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
15
15
|
id: "4278890465",
|
|
16
16
|
dynamic: [colors.white, colors.grey900]
|
|
17
|
-
}, [
|
|
17
|
+
}, [`table.__jsx-style-dynamic-selector{display:block;border:0;background-color:${colors.white};min-width:100%;text-align:left;border-collapse:collapse;vertical-align:top;color:${colors.grey900};}`]));
|
|
18
18
|
};
|
|
19
19
|
Table.propTypes = {
|
|
20
20
|
children: PropTypes.node.isRequired,
|
|
@@ -19,7 +19,7 @@ export const TableCellHead = _ref => {
|
|
|
19
19
|
rowSpan: rowSpan,
|
|
20
20
|
"data-test": dataTest,
|
|
21
21
|
role: role,
|
|
22
|
-
className:
|
|
22
|
+
className: `jsx-${tableCellHeadStyles.__hash}` + " " + (cx({
|
|
23
23
|
dense
|
|
24
24
|
}, className) || "")
|
|
25
25
|
}, children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
@@ -34,7 +34,6 @@ TableCellHead.propTypes = {
|
|
|
34
34
|
className: PropTypes.string,
|
|
35
35
|
colSpan: PropTypes.string,
|
|
36
36
|
dataTest: PropTypes.string,
|
|
37
|
-
|
|
38
37
|
/** Uses less padding and height for information-dense layouts */
|
|
39
38
|
dense: PropTypes.bool,
|
|
40
39
|
role: PropTypes.string,
|
|
@@ -19,7 +19,7 @@ export const TableCell = _ref => {
|
|
|
19
19
|
rowSpan: rowSpan,
|
|
20
20
|
"data-test": dataTest,
|
|
21
21
|
role: role,
|
|
22
|
-
className:
|
|
22
|
+
className: `jsx-${tableCellStyles.__hash}` + " " + (cx({
|
|
23
23
|
dense
|
|
24
24
|
}, className) || "")
|
|
25
25
|
}, children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
@@ -34,7 +34,6 @@ TableCell.propTypes = {
|
|
|
34
34
|
className: PropTypes.string,
|
|
35
35
|
colSpan: PropTypes.string,
|
|
36
36
|
dataTest: PropTypes.string,
|
|
37
|
-
|
|
38
37
|
/** Usees less padding and height for information-dense layouts */
|
|
39
38
|
dense: PropTypes.bool,
|
|
40
39
|
role: PropTypes.string,
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import _JSXStyle from "styled-jsx/style";
|
|
2
|
-
|
|
3
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
-
|
|
2
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
5
3
|
import cx from 'classnames';
|
|
6
4
|
import PropTypes from 'prop-types';
|
|
7
5
|
import React, { useContext } from 'react';
|
|
@@ -25,7 +23,7 @@ export const TableRow = _ref => {
|
|
|
25
23
|
"data-test": dataTest,
|
|
26
24
|
role: role
|
|
27
25
|
}, rest, {
|
|
28
|
-
className:
|
|
26
|
+
className: `jsx-${tableRowStyles.__hash}` + " " + (rest && rest.className != null && rest.className || cx(className, {
|
|
29
27
|
zebraStriping
|
|
30
28
|
}) || "")
|
|
31
29
|
}), children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
@@ -41,7 +39,6 @@ TableRow.propTypes = {
|
|
|
41
39
|
className: PropTypes.string,
|
|
42
40
|
dataTest: PropTypes.string,
|
|
43
41
|
role: PropTypes.string,
|
|
44
|
-
|
|
45
42
|
/** Disables the default row striping for this row */
|
|
46
43
|
suppressZebraStriping: PropTypes.bool
|
|
47
44
|
};
|
package/build/es/table/table.js
CHANGED
|
@@ -19,7 +19,7 @@ export const Table = _ref => {
|
|
|
19
19
|
}, /*#__PURE__*/React.createElement("table", {
|
|
20
20
|
"data-test": dataTest,
|
|
21
21
|
role: role,
|
|
22
|
-
className:
|
|
22
|
+
className: `jsx-${tableStyles.__hash}` + " " + (className || "")
|
|
23
23
|
}, children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
24
24
|
id: tableStyles.__hash
|
|
25
25
|
}, tableStyles)));
|
|
@@ -33,7 +33,6 @@ Table.propTypes = {
|
|
|
33
33
|
className: PropTypes.string,
|
|
34
34
|
dataTest: PropTypes.string,
|
|
35
35
|
role: PropTypes.string,
|
|
36
|
-
|
|
37
36
|
/** Remove the default striping on alternating rows */
|
|
38
37
|
suppressZebraStriping: PropTypes.bool
|
|
39
38
|
};
|