@bento-core/paginated-table 1.0.1-icdc.16 → 1.0.1-icdc.17

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.
@@ -1,5 +1,5 @@
1
1
 
2
- ### 1 Use bento-core/paginated-table package version publish by ICDC
2
+ ### 1 Use latest or bento-core/paginated-table package version publish by ICDC
3
3
  Alternative configuratoin for BLUE button
4
4
  ```
5
5
  // 1.0.1-icdc.3
@@ -12,7 +12,7 @@ or in package.json
12
12
  ```
13
13
  **NOTE: Create a new dashboard page using bento-core components before removing old dashboard page**
14
14
  <br>
15
- <span style="color:red">
15
+ <span style="color:yellow">
16
16
  Assuming New Dashboard page have Filter component and table component from bento-core
17
17
  </span>.
18
18
 
@@ -22,7 +22,7 @@ Assuming New Dashboard page have Filter component and table component from bento
22
22
 
23
23
  ```
24
24
  import React, { useCallback } from 'react';
25
- import { ButtonView, btnTypes } from '@bento-core/paginated-table';
25
+ import { ButtonView, btnTypes, TableContextProvider } from '@bento-core/paginated-table';
26
26
 
27
27
  const AddAllBlueButton = useCallback(() => (
28
28
  <ButtonView
@@ -78,9 +78,23 @@ const AddAllBlueButton = useCallback(() => (
78
78
  };
79
79
 
80
80
  const btnTheme = createTheme({ overrides: { ...customTheme } });
81
- <ThemeProvider theme={btnTheme}>
82
- <Container>
83
- <AddAllBlueButton /> // from step 2
84
- </Container>
85
- </ThemeProvider>
81
+ <TableContextProvider>
82
+ <ThemeProvider theme={btnTheme}>
83
+ <Container>
84
+ // add all button
85
+ <AddAllBlueButton /> // from step 2
86
+ // add selected file orange button
87
+ <AddSelectedFilesOrangeButton />
88
+ </Container>
89
+ </ThemeProvider>
90
+
91
+ // table view
92
+ <Grid container>
93
+ <Grid item xs={12} id={config.tableID}>
94
+ <TableView
95
+ ...
96
+ />
97
+ </Grid>
98
+ </Grid>
99
+ </TableContextProvider>
86
100
  ```
@@ -1,5 +1,5 @@
1
1
 
2
- ### 1 Use bento-core/paginated-table package version publish by ICDC
2
+ ### 1 Use latest or bento-core/paginated-table package version publish by ICDC
3
3
  Alternative configuration for ORANGE button
4
4
  ```
5
5
  // 1.0.1-icdc.3
@@ -11,7 +11,7 @@ or in package.json
11
11
  }
12
12
  ```
13
13
 
14
- <span style="color:red">
14
+ <span style="color:yellow">
15
15
  Assuming table component is imported from bento-core/paginated-table
16
16
  </span>
17
17
 
@@ -55,6 +55,7 @@ const AddSelectedFilesOrangeButton = useCallback(() => (
55
55
  | applyActiveFilter | FALSE | Only adds files of selected case or sample based on active filter | Bool |
56
56
 
57
57
 
58
+
58
59
  ### 3 Configure Add_All_Button Or BLUE Button in Dashboard
59
60
 
60
61
  ```
@@ -73,9 +74,24 @@ const AddSelectedFilesOrangeButton = useCallback(() => (
73
74
  };
74
75
 
75
76
  const btnTheme = createTheme({ overrides: { ...customTheme } });
76
- <ThemeProvider theme={btnTheme}>
77
- <Container>
78
- <AddSelectedFilesOrangeButton /> // from step 2
79
- </Container>
80
- </ThemeProvider>
77
+ <TableContextProvider>
78
+ // add all button
79
+ <ThemeProvider theme={btnTheme}>
80
+ <Container>
81
+ // add all button
82
+ <AddAllBlueButton />
83
+ // add selected file orange button
84
+ <AddSelectedFilesOrangeButton /> // step 2
85
+ </Container>
86
+ </ThemeProvider>
87
+
88
+ // table view
89
+ <Grid container>
90
+ <Grid item xs={12} id={config.tableID}>
91
+ <TableView
92
+ ...
93
+ />
94
+ </Grid>
95
+ </Grid>
96
+ </TableContextProvider>
81
97
  ```
package/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # PAGINATED TABLE COMPONENT DESIGN
2
2
 
3
+ ```diff
4
+ - After updating to latest version remove transform: 'rotateX(180deg)) in red
5
+ ```
3
6
  ### Bento core paginated table design:
4
7
 
5
8
  * Use of UseReducer to track table state and local state to display dialog component
@@ -228,6 +231,9 @@ TableContextProvider provides table state to Wrapper Component or it can be used
228
231
  ####
229
232
 
230
233
  ## 4 Wrapper Configuration:
234
+
235
+ **NOTE: Alternative option to configure Blue and Orange button refer to [ADD_ALL_FILES_BLUE_BUTTON_ReadME](Add_ALL_Files__BLUE_ButtonREADME.md) and [ADD_SELECTED_FILES_Orange_button_ReadMe](Add_Selected_Files_Orange_button_README.md). (Note: No Wrapper conponent required)**
236
+
231
237
  Wrapper component around table compnent.
232
238
  1. ADD ALL FILES button
233
239
  2. ADD SELECTED ROWS button
@@ -319,8 +325,8 @@ headerConfig - upper component on the table
319
325
 
320
326
  ####
321
327
 
322
- ## 5 Pagination Configuration:
323
-
328
+ ## 5 Customize Pagination Action:
329
+ Customize paginated action is provided to add event in addition to update of the table state. It will override default paginated action.
324
330
  ```
325
331
  import {
326
332
  TableContext,
@@ -339,7 +345,7 @@ import {
339
345
  const { context } = tableContext;
340
346
  const { dispatch } = context;
341
347
 
342
- const paginationOptions = {
348
+ const customPaginationOptions = {
343
349
  customizeOnRowSelect: (event, row) => {
344
350
  const payload = {
345
351
  page: 2,
@@ -362,7 +368,7 @@ import {
362
368
  queryVariables={activeFilters}
363
369
  totalRowCount={dashboardStats[config.count]}
364
370
  activeTab={activeTab}
365
- paginationOptions={paginationOptions}
371
+ paginationOptions={customPaginationOptions}
366
372
  />
367
373
  ```
368
374
 
@@ -16,7 +16,8 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
16
16
  const TableController = props => {
17
17
  const {
18
18
  tblRows,
19
- table
19
+ table,
20
+ onSortByColumn
20
21
  } = props;
21
22
  if (!tblRows) {
22
23
  return /*#__PURE__*/_react.default.createElement(_core.Container, {
@@ -44,34 +45,16 @@ const TableController = props => {
44
45
  sensitivity: 'base'
45
46
  });
46
47
 
47
- /**
48
- * client table array sorting for column table
49
- * checks array length to sort
50
- */
51
- const arraySort = (a, b) => {
52
- // handles sort for csvDownload column
53
- const aHasData = a.csvDataRow && a.csvDataRow.length > 0;
54
- const bHasData = b.csvDataRow && b.csvDataRow.length > 0;
55
- return aHasData === bHasData ? 0 : aHasData ? -1 : 1;
56
- };
57
-
58
48
  /**
59
49
  * sort base on table state
60
50
  */
61
51
  const sortRows = (a, b) => {
62
- const areValuesArrays = Array.isArray(a[sortBy]) && Array.isArray(b[sortBy]);
63
- if (areValuesArrays) {
64
- if (sortOrder === 'asc') {
65
- return arraySort(a, b);
66
- }
67
- return arraySort(b, a);
68
- }
69
52
  if (sortOrder === 'asc') {
70
53
  return alphaNumericSort(a, b);
71
54
  }
72
55
  return alphaNumericSort(b, a);
73
56
  };
74
- const sortedRows = [...updateRows].sort((a, b) => sortRows(a, b));
57
+ const sortedRows = onSortByColumn ? onSortByColumn(updateRows) : [...updateRows].sort((a, b) => sortRows(a, b));
75
58
  const startIndex = page * rowsPerPage;
76
59
  const endIndex = startIndex + rowsPerPage;
77
60
  const displayRows = [...sortedRows].slice(startIndex, endIndex);
@@ -205,7 +205,7 @@ const PaginatedTable = _ref => {
205
205
  onPageChange: customizeChangePage || handleChangePage,
206
206
  onRowSelectChange: customizeOnRowSelect || onRowSelectHandler,
207
207
  onToggleSelectAll: customizeToggleSelectAll || handleToggleSelectAll,
208
- onSortByColumn: customizeSortByColumn || handleSortByColumn,
208
+ onSortByColumn: customizeSortByColumn,
209
209
  onColumnViewChange: customizeColumnViewChange || handleColumnViewChange,
210
210
  onDeleteRow: customizeDeleteRow || onDeleteRow,
211
211
  onDeleteAllFiles: customizeDeleteAllRows || onDeleteAllRows,
@@ -21,10 +21,11 @@ const ToolTipView = props => {
21
21
  icon,
22
22
  alt,
23
23
  arrow = false,
24
- clsName
24
+ clsName,
25
+ toolTipText
25
26
  } = tooltipCofig;
26
27
  return /*#__PURE__*/_react.default.createElement(_toolTip.default, {
27
- title: tooltipCofig[section],
28
+ title: toolTipText || tooltipCofig[section],
28
29
  arrow: arrow,
29
30
  classes: {
30
31
  tooltip: classes.customTooltip,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/paginated-table",
3
- "version": "1.0.1-icdc.16",
3
+ "version": "1.0.1-icdc.17",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -12,8 +12,6 @@
12
12
  "publishConfig": {
13
13
  "access": "public"
14
14
  },
15
- "dependencies": {
16
- },
17
15
  "peerDependencies": {
18
16
  "@apollo/client": "^3.6.9",
19
17
  "@material-ui/core": "^4.12.4",
@@ -22,7 +20,7 @@
22
20
  "react-dom": "^17.0.0",
23
21
  "react-redux": "^7.2.1",
24
22
  "@bento-core/cart": "^1.0.0",
25
- "@bento-core/table": "^1.0.1-icdc.5",
23
+ "@bento-core/table": "1.0.1-icdc.0",
26
24
  "@bento-core/tool-tip": "^1.0.0",
27
25
  "@bento-core/util": "^1.0.0"
28
26
  },
@@ -7,7 +7,7 @@ import { setSelectedRows } from './TableService';
7
7
  * Updates table row when table state is changed 1. (paginated action) and 2. filter action
8
8
  */
9
9
  const TableController = ((props) => {
10
- const { tblRows, table } = props;
10
+ const { tblRows, table, onSortByColumn } = props;
11
11
  if (!tblRows) {
12
12
  return (
13
13
  <Container maxWidth="xl">
@@ -38,35 +38,17 @@ const TableController = ((props) => {
38
38
  },
39
39
  );
40
40
 
41
- /**
42
- * client table array sorting for column table
43
- * checks array length to sort
44
- */
45
- const arraySort = (a, b) => {
46
- // handles sort for csvDownload column
47
- const aHasData = a.csvDataRow && a.csvDataRow.length > 0;
48
- const bHasData = b.csvDataRow && b.csvDataRow.length > 0;
49
- return aHasData === bHasData ? 0 : aHasData ? -1 : 1;
50
- };
51
-
52
41
  /**
53
42
  * sort base on table state
54
43
  */
55
44
  const sortRows = (a, b) => {
56
- const areValuesArrays = Array.isArray(a[sortBy]) && Array.isArray(b[sortBy]);
57
- if (areValuesArrays) {
58
- if (sortOrder === 'asc') {
59
- return arraySort(a, b);
60
- }
61
- return arraySort(b, a);
62
- }
63
-
64
45
  if (sortOrder === 'asc') {
65
46
  return alphaNumericSort(a, b);
66
47
  }
67
48
  return alphaNumericSort(b, a);
68
49
  };
69
- const sortedRows = [...updateRows].sort((a, b) => sortRows(a, b));
50
+ const sortedRows = onSortByColumn ? onSortByColumn(updateRows)
51
+ : [...updateRows].sort((a, b) => sortRows(a, b));
70
52
  const startIndex = page * rowsPerPage;
71
53
  const endIndex = startIndex + rowsPerPage;
72
54
  const displayRows = [...sortedRows].slice(startIndex, endIndex);
@@ -196,7 +196,7 @@ const PaginatedTable = ({
196
196
  onPageChange={customizeChangePage || handleChangePage}
197
197
  onRowSelectChange={customizeOnRowSelect || onRowSelectHandler}
198
198
  onToggleSelectAll={customizeToggleSelectAll || handleToggleSelectAll}
199
- onSortByColumn={customizeSortByColumn || handleSortByColumn}
199
+ onSortByColumn={customizeSortByColumn}
200
200
  onColumnViewChange={customizeColumnViewChange || handleColumnViewChange}
201
201
  onDeleteRow={customizeDeleteRow || onDeleteRow}
202
202
  onDeleteAllFiles={customizeDeleteAllRows || onDeleteAllRows}
@@ -17,10 +17,11 @@ const ToolTipView = (props) => {
17
17
  alt,
18
18
  arrow = false,
19
19
  clsName,
20
+ toolTipText,
20
21
  } = tooltipCofig;
21
22
  return (
22
23
  <ToolTip
23
- title={tooltipCofig[section]}
24
+ title={toolTipText || tooltipCofig[section]}
24
25
  arrow={arrow}
25
26
  classes={{
26
27
  tooltip: classes.customTooltip,