@bento-core/paginated-table 1.0.1-icdc.11 → 1.0.1-icdc.14

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.
@@ -43,10 +43,29 @@ const TableController = props => {
43
43
  numeric: true,
44
44
  sensitivity: 'base'
45
45
  });
46
+
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
+
46
58
  /**
47
59
  * sort base on table state
48
60
  */
49
61
  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
+ }
50
69
  if (sortOrder === 'asc') {
51
70
  return alphaNumericSort(a, b);
52
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/paginated-table",
3
- "version": "1.0.1-icdc.11",
3
+ "version": "1.0.1-icdc.14",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@bento-core/cart": "^1.0.0",
17
- "@bento-core/table": "1.0.1-icdc.2",
17
+ "@bento-core/table": "^1.0.0",
18
18
  "@bento-core/tool-tip": "^1.0.0",
19
19
  "@bento-core/util": "^1.0.0"
20
20
  },
@@ -37,10 +37,30 @@ const TableController = ((props) => {
37
37
  sensitivity: 'base',
38
38
  },
39
39
  );
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
+
40
52
  /**
41
53
  * sort base on table state
42
54
  */
43
55
  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
+
44
64
  if (sortOrder === 'asc') {
45
65
  return alphaNumericSort(a, b);
46
66
  }