@teselagen/ui 0.9.8 → 0.10.3

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 (83) hide show
  1. package/CollapsibleCard/index.d.ts +2 -1
  2. package/DataTable/Columns.d.ts +4 -1
  3. package/DataTable/DisplayOptions.d.ts +2 -1
  4. package/DataTable/index.d.ts +3 -3
  5. package/DividerWithText/index.d.ts +16 -0
  6. package/index.cjs.js +21122 -21084
  7. package/index.d.ts +1 -0
  8. package/index.es.js +21125 -21087
  9. package/package.json +2 -1
  10. package/src/CollapsibleCard/index.js +8 -1
  11. package/src/DataTable/Columns.js +69 -1
  12. package/src/DataTable/DisplayOptions.js +35 -6
  13. package/src/DataTable/PagingTool.js +2 -2
  14. package/src/DataTable/RenderCell.js +8 -4
  15. package/src/DataTable/index.js +1253 -229
  16. package/src/DataTable/utils/tableQueryParamsToHasuraClauses.js +2 -2
  17. package/src/DataTable/utils/tableQueryParamsToHasuraClauses.test.js +21 -0
  18. package/src/DataTable/utils/useTableEntities.js +3 -2
  19. package/src/DataTable/utils/withTableParams.js +34 -13
  20. package/src/DividerWithText/index.js +30 -0
  21. package/src/DividerWithText/style.css +37 -0
  22. package/src/InfoHelper/style.css +1 -0
  23. package/src/UploadCsvWizard.js +7 -5
  24. package/src/index.js +1 -0
  25. package/src/utils/hooks/useDeepEqualMemo.js +2 -2
  26. package/src/utils/isEqualIgnoreFunctions.js +23 -0
  27. package/src/utils/pureNoFunc.js +4 -20
  28. package/ui.css +38 -0
  29. package/utils/isEqualIgnoreFunctions.d.ts +1 -0
  30. package/DataTable/EditabelCell.d.ts +0 -7
  31. package/DataTable/ReactTable.d.ts +0 -78
  32. package/DataTable/defaultProps.d.ts +0 -43
  33. package/DataTable/utils/computePresets.d.ts +0 -1
  34. package/DataTable/utils/types/Entity.d.ts +0 -9
  35. package/DataTable/utils/types/Field.d.ts +0 -4
  36. package/DataTable/utils/types/OrderBy.d.ts +0 -11
  37. package/DataTable/utils/types/Schema.d.ts +0 -4
  38. package/DataTable/utils/useDeepEqualMemo.d.ts +0 -1
  39. package/DataTable/utils/useHotKeysWrapper.d.ts +0 -29
  40. package/DataTable/utils/useTableParams.d.ts +0 -49
  41. package/src/DataTable/Columns.jsx +0 -945
  42. package/src/DataTable/EditabelCell.js +0 -44
  43. package/src/DataTable/EditabelCell.jsx +0 -44
  44. package/src/DataTable/ReactTable.js +0 -738
  45. package/src/DataTable/RenderCell.jsx +0 -191
  46. package/src/DataTable/defaultProps.js +0 -45
  47. package/src/DataTable/utils/computePresets.js +0 -42
  48. package/src/DataTable/utils/convertSchema.ts +0 -79
  49. package/src/DataTable/utils/formatPasteData.ts +0 -34
  50. package/src/DataTable/utils/getAllRows.ts +0 -11
  51. package/src/DataTable/utils/getCellCopyText.ts +0 -7
  52. package/src/DataTable/utils/getCellInfo.ts +0 -46
  53. package/src/DataTable/utils/getFieldPathToField.ts +0 -10
  54. package/src/DataTable/utils/getIdOrCodeOrIndex.ts +0 -14
  55. package/src/DataTable/utils/getLastSelectedEntity.ts +0 -15
  56. package/src/DataTable/utils/getNewEntToSelect.ts +0 -32
  57. package/src/DataTable/utils/initializeHasuraWhereAndFilter.ts +0 -35
  58. package/src/DataTable/utils/isBottomRightCornerOfRectangle.ts +0 -27
  59. package/src/DataTable/utils/isEntityClean.ts +0 -15
  60. package/src/DataTable/utils/primarySelectedValue.ts +0 -1
  61. package/src/DataTable/utils/removeCleanRows.ts +0 -26
  62. package/src/DataTable/utils/selection.ts +0 -11
  63. package/src/DataTable/utils/types/Entity.ts +0 -13
  64. package/src/DataTable/utils/types/Field.ts +0 -4
  65. package/src/DataTable/utils/types/OrderBy.ts +0 -15
  66. package/src/DataTable/utils/types/Schema.ts +0 -5
  67. package/src/DataTable/utils/useDeepEqualMemo.js +0 -10
  68. package/src/DataTable/utils/useHotKeysWrapper.js +0 -395
  69. package/src/DataTable/utils/useTableEntities.ts +0 -60
  70. package/src/DataTable/utils/useTableParams.js +0 -361
  71. package/src/DataTable/utils/utils.ts +0 -39
  72. package/src/Timeline/TimelineEvent.tsx +0 -36
  73. package/src/Timeline/index.tsx +0 -21
  74. package/src/utils/browserUtils.ts +0 -3
  75. package/src/utils/determineBlackOrWhiteTextColor.ts +0 -11
  76. package/src/utils/getTextFromEl.ts +0 -45
  77. package/src/utils/handlerHelpers.ts +0 -32
  78. package/src/utils/hooks/index.ts +0 -1
  79. package/src/utils/hooks/useDeepEqualMemo.ts +0 -10
  80. package/src/utils/hooks/useStableReference.ts +0 -9
  81. package/src/utils/hotkeyUtils.tsx +0 -155
  82. package/src/utils/isBeingCalledExcessively.ts +0 -37
  83. package/style.css +0 -10537
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teselagen/ui",
3
- "version": "0.9.8",
3
+ "version": "0.10.3",
4
4
  "main": "./src/index.js",
5
5
  "type": "module",
6
6
  "exports": {
@@ -21,6 +21,7 @@
21
21
  "@teselagen/react-table": "6.10.18",
22
22
  "chance": "1.1.11",
23
23
  "classnames": "^2.3.2",
24
+ "color": "^3.2.1",
24
25
  "copy-to-clipboard": "^3.3.1",
25
26
  "dayjs": "^1.10.4",
26
27
  "dom-scroll-into-view": "^2.0.1",
@@ -2,6 +2,7 @@ import React, { useState } from "react";
2
2
  import { Button, Classes, Icon } from "@blueprintjs/core";
3
3
  import classNames from "classnames";
4
4
  import "./style.css";
5
+ import InfoHelper from "../InfoHelper";
5
6
 
6
7
  export default function CollapsibleCard({
7
8
  title,
@@ -11,6 +12,7 @@ export default function CollapsibleCard({
11
12
  className,
12
13
  style,
13
14
  children,
15
+ helperText,
14
16
  initialClosed = false,
15
17
  toggle,
16
18
  isOpen
@@ -48,7 +50,12 @@ export default function CollapsibleCard({
48
50
  >
49
51
  {title}
50
52
  </h6>
51
- <div>{open && openTitleElements}</div>
53
+ {helperText && (
54
+ <>
55
+ <InfoHelper children={helperText}></InfoHelper> &nbsp;
56
+ </>
57
+ )}
58
+ {open && <div> {openTitleElements}</div>}
52
59
  </div>
53
60
  <div>
54
61
  <Button
@@ -37,6 +37,7 @@ import { useDispatch } from "react-redux";
37
37
  import { change as _change } from "redux-form";
38
38
  import { RenderCell } from "./RenderCell";
39
39
  import { getCCDisplayName } from "./utils/tableQueryParamsToHasuraClauses";
40
+ import { showContextMenu } from "../utils/menuUtils";
40
41
 
41
42
  dayjs.extend(localizedFormat);
42
43
 
@@ -50,8 +51,13 @@ const RenderColumnHeader = ({
50
51
  entities,
51
52
  extraCompact,
52
53
  filters,
54
+ resetDefaultVisibility,
55
+ onlyOneVisibleColumn,
53
56
  formName,
54
57
  isCellEditable,
58
+ updateColumnVisibility,
59
+ schema,
60
+ withDisplayOptions,
55
61
  isLocalCall,
56
62
  order,
57
63
  removeSingleFilter,
@@ -163,6 +169,60 @@ const RenderColumnHeader = ({
163
169
  <strong>${columnTitle}:</strong> <br>
164
170
  ${description} ${isUnique ? "<br>Must be unique" : ""}</div>`
165
171
  })}
172
+ onContextMenu={e => {
173
+ if (!withDisplayOptions) {
174
+ return
175
+ }
176
+ e.preventDefault();
177
+ e.persist();
178
+ showContextMenu(
179
+ [
180
+ {
181
+ text: "Hide Column",
182
+ disabled: onlyOneVisibleColumn,
183
+ icon: "eye-off",
184
+ onClick: () => {
185
+ updateColumnVisibility({
186
+ shouldShow: false,
187
+ path
188
+ });
189
+ }
190
+ },
191
+ {
192
+ text: "Hide Other Columns",
193
+ icon: "eye-off",
194
+ onClick: () => {
195
+ updateColumnVisibility({
196
+ shouldShow: false,
197
+ paths: schema.fields
198
+ .map(c => c.path)
199
+ .filter(Boolean)
200
+ .filter(p => p !== path)
201
+ });
202
+ }
203
+ },
204
+ {
205
+ text: "Reset Column Visibilities",
206
+ icon: "reset",
207
+ onClick: () => {
208
+ resetDefaultVisibility();
209
+ }
210
+ },
211
+ {
212
+ text: "Table Display Options",
213
+ icon: "cog",
214
+ onClick: () => {
215
+ e.target
216
+ .closest(".data-table-container")
217
+ ?.querySelector(".tg-table-display-options")
218
+ ?.click();
219
+ }
220
+ }
221
+ ],
222
+ undefined,
223
+ e
224
+ );
225
+ }}
166
226
  data-test={columnTitleTextified}
167
227
  data-path={path}
168
228
  data-copy-text={columnTitleTextified}
@@ -340,6 +400,7 @@ export const useColumns = ({
340
400
  addFilters,
341
401
  cellRenderer,
342
402
  columns,
403
+ resetDefaultVisibility,
343
404
  currentParams,
344
405
  compact,
345
406
  editingCell,
@@ -374,6 +435,7 @@ export const useColumns = ({
374
435
  selectedCells,
375
436
  setExpandedEntityIdMap,
376
437
  setNewParams,
438
+ updateColumnVisibility,
377
439
  setOrder = noop,
378
440
  setSelectedCells,
379
441
  shouldShowSubComponent,
@@ -387,7 +449,8 @@ export const useColumns = ({
387
449
  withFilter: _withFilter,
388
450
  withSort = true,
389
451
  recordIdToIsVisibleMap,
390
- setRecordIdToIsVisibleMap
452
+ setRecordIdToIsVisibleMap,
453
+ withDisplayOptions
391
454
  }) => {
392
455
  const dispatch = useDispatch();
393
456
  const change = useCallback(
@@ -858,15 +921,20 @@ export const useColumns = ({
858
921
  const tableColumn = {
859
922
  ...column,
860
923
  Header: RenderColumnHeader({
924
+ onlyOneVisibleColumn: columns.length === 1,
861
925
  recordIdToIsVisibleMap,
862
926
  setRecordIdToIsVisibleMap,
863
927
  column,
928
+ withDisplayOptions,
864
929
  isLocalCall,
865
930
  filters,
866
931
  currentParams,
867
932
  order,
933
+ resetDefaultVisibility,
868
934
  setOrder,
869
935
  withSort,
936
+ schema,
937
+ updateColumnVisibility,
870
938
  formName,
871
939
  extraCompact,
872
940
  withFilter,
@@ -11,11 +11,13 @@ import {
11
11
  Switch
12
12
  } from "@blueprintjs/core";
13
13
  import { getCCDisplayName } from "./utils/tableQueryParamsToHasuraClauses";
14
+ import InfoHelper from "../InfoHelper";
14
15
 
15
16
  const DisplayOptions = ({
16
17
  compact,
17
18
  extraCompact,
18
19
  disabled,
20
+ doNotSearchHiddenColumns,
19
21
  hideDisplayOptionsIcon,
20
22
  resetDefaultVisibility = noop,
21
23
  updateColumnVisibility = noop,
@@ -52,7 +54,7 @@ const DisplayOptions = ({
52
54
  let numVisible = 0;
53
55
 
54
56
  const getFieldCheckbox = (field, i) => {
55
- const { displayName, isHidden, isForcedHidden, path } = field;
57
+ const { displayName, isHidden, isForcedHidden, path, subFrag } = field;
56
58
  if (isForcedHidden) return;
57
59
  if (!isHidden) numVisible++;
58
60
  return (
@@ -68,7 +70,20 @@ const DisplayOptions = ({
68
70
  updateColumnVisibility({ shouldShow: isHidden, path });
69
71
  }}
70
72
  checked={!isHidden}
71
- label={displayName}
73
+ label={
74
+ <span style={{ display: "flex", marginTop: -17 }}>
75
+ {displayName}
76
+ {subFrag && (
77
+ <InfoHelper
78
+ icon="warning-sign"
79
+ intent="warning"
80
+ style={{ marginLeft: 5 }}
81
+ >
82
+ Viewing this column may cause the table to load slower
83
+ </InfoHelper>
84
+ )}
85
+ </span>
86
+ }
72
87
  />
73
88
  );
74
89
  };
@@ -127,7 +142,9 @@ const DisplayOptions = ({
127
142
  content={
128
143
  <Menu>
129
144
  <div style={{ padding: 10, paddingLeft: 20, paddingRight: 20 }}>
130
- <h5 style={{ marginBottom: 10 }}>Display Density:</h5>
145
+ <h5 style={{ marginBottom: 10, fontWeight: "bold" }}>
146
+ Display Density:
147
+ </h5>
131
148
  <div className={Classes.SELECT + " tg-table-display-density"}>
132
149
  <select
133
150
  onChange={changeTableDensity}
@@ -150,8 +167,19 @@ const DisplayOptions = ({
150
167
  </option>
151
168
  </select>
152
169
  </div>
153
- <h5 style={{ marginBottom: 10, marginTop: 10 }}>
154
- Displayed Columns:
170
+ <h5
171
+ style={{
172
+ fontWeight: "bold",
173
+ marginBottom: 10,
174
+ marginTop: 10,
175
+ display: "flex"
176
+ }}
177
+ >
178
+ Displayed Columns: &nbsp;
179
+ {doNotSearchHiddenColumns && <InfoHelper>
180
+ Note: Hidden columns will NOT be used when searching the
181
+ datatable
182
+ </InfoHelper>}
155
183
  </h5>
156
184
  <div style={{ maxHeight: 260, overflowY: "auto", padding: 2 }}>
157
185
  {mainFields.map(getFieldCheckbox)}
@@ -176,9 +204,10 @@ const DisplayOptions = ({
176
204
  <Button
177
205
  onClick={resetDefaultVisibility}
178
206
  title="Display Options"
207
+ icon="reset"
179
208
  minimal
180
209
  >
181
- Reset
210
+ Reset Column Visibilites
182
211
  </Button>
183
212
  </div>
184
213
  </div>
@@ -1,6 +1,6 @@
1
1
  import React, { useState, useEffect, useRef, useCallback } from "react";
2
2
  import classNames from "classnames";
3
- import { noop, toInteger } from "lodash-es";
3
+ import { noop, get, toInteger } from "lodash-es";
4
4
  import { Button, Classes } from "@blueprintjs/core";
5
5
  import { onEnterOrBlurHelper } from "../utils/handlerHelpers";
6
6
  import { defaultPageSizes } from "./utils/queryParams";
@@ -69,7 +69,7 @@ const PagingTool = ({
69
69
  const setPageSize = controlled_setPageSize || _setPageSize;
70
70
 
71
71
  const onPageChange = useCallback(() => {
72
- const record = entities?.[0];
72
+ const record = get(entities, "[0]");
73
73
  if (
74
74
  !keepSelectionOnPageChange &&
75
75
  (!record || !getIdOrCodeOrIndex(record))
@@ -29,11 +29,15 @@ export const RenderCell = ({
29
29
  onDragEnd,
30
30
  args
31
31
  }) => {
32
- const editingCell = useSelector(
33
- state => state.form?.[formName]?.values?.reduxFormEditingCell
34
- );
32
+ const editingCellSelector = state =>
33
+ state.form?.[formName]?.values?.reduxFormEditingCell;
34
+
35
+ const shouldEditableCellInputBeClearedSelector = state =>
36
+ state.form?.[formName]?.values?.shouldEditableCellInputBeCleared;
37
+
38
+ const editingCell = useSelector(editingCellSelector);
35
39
  const shouldEditableCellInputBeCleared = useSelector(
36
- state => state.form?.[formName]?.values?.shouldEditableCellInputBeCleared
40
+ shouldEditableCellInputBeClearedSelector
37
41
  );
38
42
 
39
43
  const [row] = args;