@teselagen/ui 0.7.35 → 0.8.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.
Files changed (128) hide show
  1. package/index.cjs.js +1 -2
  2. package/index.es.js +1 -2
  3. package/package.json +1 -1
  4. package/src/DataTable/Columns.js +1 -1
  5. package/src/DataTable/DisplayOptions.js +1 -1
  6. package/src/DataTable/FilterAndSortMenu.js +30 -27
  7. package/src/DataTable/index.js +14 -3
  8. package/src/DataTable/utils/queryParams.js +771 -64
  9. package/src/DataTable/utils/withTableParams.js +16 -3
  10. package/src/index.js +0 -1
  11. package/src/utils/isBeingCalledExcessively.js +14 -7
  12. package/AdvancedOptions.js +0 -33
  13. package/AssignDefaultsModeContext.js +0 -22
  14. package/CellDragHandle.js +0 -132
  15. package/ColumnFilterMenu.js +0 -62
  16. package/Columns.js +0 -979
  17. package/DataTable/utils/filterLocalEntitiesToHasura.d.ts +0 -5
  18. package/DataTable/utils/initializeHasuraWhereAndFilter.d.ts +0 -2
  19. package/DataTable/utils/tableQueryParamsToHasuraClauses.d.ts +0 -26
  20. package/DisabledLoadingComponent.js +0 -15
  21. package/DisplayOptions.js +0 -199
  22. package/DropdownButton.js +0 -36
  23. package/DropdownCell.js +0 -61
  24. package/EditableCell.js +0 -44
  25. package/FillWindow.css +0 -6
  26. package/FillWindow.js +0 -69
  27. package/FilterAndSortMenu.js +0 -391
  28. package/FormSeparator.js +0 -9
  29. package/LoadingDots.js +0 -14
  30. package/MatchHeaders.js +0 -234
  31. package/PagingTool.js +0 -225
  32. package/RenderCell.js +0 -191
  33. package/SearchBar.js +0 -69
  34. package/SimpleStepViz.js +0 -22
  35. package/SortableColumns.js +0 -100
  36. package/TableFormTrackerContext.js +0 -10
  37. package/Tag.js +0 -112
  38. package/ThComponent.js +0 -44
  39. package/TimelineEvent.js +0 -31
  40. package/UploadCsvWizard.css +0 -4
  41. package/UploadCsvWizard.js +0 -719
  42. package/Uploader.js +0 -1278
  43. package/adHoc.js +0 -10
  44. package/autoTooltip.js +0 -201
  45. package/basicHandleActionsWithFullState.js +0 -14
  46. package/browserUtils.js +0 -3
  47. package/combineReducersWithFullState.js +0 -14
  48. package/commandControls.js +0 -82
  49. package/commandUtils.js +0 -112
  50. package/constants.js +0 -1
  51. package/convertSchema.js +0 -69
  52. package/customIcons.js +0 -361
  53. package/dataTableEnhancer.js +0 -41
  54. package/defaultFormatters.js +0 -32
  55. package/defaultValidators.js +0 -40
  56. package/determineBlackOrWhiteTextColor.js +0 -4
  57. package/editCellHelper.js +0 -44
  58. package/formatPasteData.js +0 -16
  59. package/getAllRows.js +0 -11
  60. package/getCellCopyText.js +0 -7
  61. package/getCellInfo.js +0 -36
  62. package/getCellVal.js +0 -20
  63. package/getDayjsFormatter.js +0 -35
  64. package/getFieldPathToField.js +0 -7
  65. package/getIdOrCodeOrIndex.js +0 -9
  66. package/getLastSelectedEntity.js +0 -11
  67. package/getNewEntToSelect.js +0 -25
  68. package/getNewName.js +0 -31
  69. package/getRowCopyText.js +0 -28
  70. package/getTableConfigFromStorage.js +0 -5
  71. package/getTextFromEl.js +0 -28
  72. package/getVals.js +0 -8
  73. package/handleCopyColumn.js +0 -21
  74. package/handleCopyHelper.js +0 -15
  75. package/handleCopyRows.js +0 -23
  76. package/handleCopyTable.js +0 -16
  77. package/handlerHelpers.js +0 -24
  78. package/hotkeyUtils.js +0 -131
  79. package/index.js +0 -1
  80. package/isBeingCalledExcessively.js +0 -32
  81. package/isBottomRightCornerOfRectangle.js +0 -20
  82. package/isEntityClean.js +0 -15
  83. package/isTruthy.js +0 -12
  84. package/isValueEmpty.js +0 -3
  85. package/itemUpload.js +0 -84
  86. package/menuUtils.js +0 -433
  87. package/popoverOverflowModifiers.js +0 -11
  88. package/primarySelectedValue.js +0 -1
  89. package/pureNoFunc.js +0 -31
  90. package/queryParams.js +0 -1058
  91. package/removeCleanRows.js +0 -22
  92. package/renderOnDoc.js +0 -32
  93. package/rerenderOnWindowResize.js +0 -26
  94. package/rowClick.js +0 -181
  95. package/selection.js +0 -8
  96. package/showAppSpinner.js +0 -12
  97. package/showDialogOnDocBody.js +0 -33
  98. package/showProgressToast.js +0 -22
  99. package/sortify.js +0 -73
  100. package/src/DataTable/utils/filterLocalEntitiesToHasura.js +0 -236
  101. package/src/DataTable/utils/filterLocalEntitiesToHasura.test.js +0 -587
  102. package/src/DataTable/utils/initializeHasuraWhereAndFilter.js +0 -26
  103. package/src/DataTable/utils/tableQueryParamsToHasuraClauses.js +0 -253
  104. package/src/DataTable/utils/tableQueryParamsToHasuraClauses.test.js +0 -206
  105. package/style.css +0 -29
  106. package/tagUtils.js +0 -45
  107. package/tgFormValues.js +0 -35
  108. package/tg_modalState.js +0 -47
  109. package/throwFormError.js +0 -16
  110. package/toastr.js +0 -148
  111. package/tryToMatchSchemas.js +0 -264
  112. package/typeToCommonType.js +0 -6
  113. package/useDeepEqualMemo.js +0 -15
  114. package/useDialog.js +0 -63
  115. package/useStableReference.js +0 -9
  116. package/useTableEntities.js +0 -38
  117. package/useTraceUpdate.js +0 -19
  118. package/utils.js +0 -37
  119. package/validateTableWideErrors.js +0 -160
  120. package/viewColumn.js +0 -97
  121. package/withField.js +0 -20
  122. package/withFields.js +0 -11
  123. package/withLocalStorage.js +0 -11
  124. package/withSelectTableRecords.js +0 -43
  125. package/withSelectedEntities.js +0 -65
  126. package/withStore.js +0 -10
  127. package/withTableParams.js +0 -301
  128. package/wrapDialog.js +0 -116
@@ -6,13 +6,13 @@ import {
6
6
  makeDataTableHandlers,
7
7
  getQueryParams,
8
8
  setCurrentParamsOnUrl,
9
- getCurrentParamsFromUrl
9
+ getCurrentParamsFromUrl,
10
+ getCCDisplayName
10
11
  } from "./queryParams";
11
12
  import { withRouter } from "react-router-dom";
12
13
  import getTableConfigFromStorage from "./getTableConfigFromStorage";
13
14
  import { useDeepEqualMemo } from "../../utils/hooks/useDeepEqualMemo";
14
15
  import { branch, compose } from "recompose";
15
- import { getCCDisplayName } from "./tableQueryParamsToHasuraClauses";
16
16
 
17
17
  /**
18
18
  * Note all these options can be passed at Design Time or at Runtime (like reduxForm())
@@ -32,6 +32,7 @@ import { getCCDisplayName } from "./tableQueryParamsToHasuraClauses";
32
32
  export const useTableParams = props => {
33
33
  const {
34
34
  additionalFilter,
35
+ additionalOrFilter,
35
36
  controlled_pageSize,
36
37
  defaults: _defaults,
37
38
  doNotCoercePageSize,
@@ -165,6 +166,16 @@ export const useTableParams = props => {
165
166
  );
166
167
 
167
168
  const queryParams = useMemo(() => {
169
+ const additionalFilterToUse =
170
+ typeof additionalFilter === "function"
171
+ ? additionalFilter
172
+ : () => additionalFilter;
173
+
174
+ const additionalOrFilterToUse =
175
+ typeof additionalOrFilter === "function"
176
+ ? additionalOrFilter
177
+ : () => additionalOrFilter;
178
+
168
179
  return getQueryParams({
169
180
  doNotCoercePageSize,
170
181
  currentParams,
@@ -174,7 +185,8 @@ export const useTableParams = props => {
174
185
  schema: convertedSchema,
175
186
  isInfinite: isInfinite || (isSimple && !withPaging),
176
187
  isLocalCall,
177
- additionalFilter,
188
+ additionalFilter: additionalFilterToUse,
189
+ additionalOrFilter: additionalOrFilterToUse,
178
190
  noOrderError,
179
191
  isCodeModel,
180
192
  ownProps: passingProps
@@ -182,6 +194,7 @@ export const useTableParams = props => {
182
194
  }, [
183
195
  additionalFilter,
184
196
  passingProps,
197
+ additionalOrFilter,
185
198
  doNotCoercePageSize,
186
199
  currentParams,
187
200
  entities,
package/src/index.js CHANGED
@@ -85,4 +85,3 @@ const noop = () => undefined;
85
85
  export { noop };
86
86
  export { default as showDialogOnDocBody } from "./showDialogOnDocBody";
87
87
  export { default as TableFormTrackerContext } from "./DataTable/TableFormTrackerContext";
88
- export { initializeHasuraWhereAndFilter } from "./DataTable/utils/initializeHasuraWhereAndFilter";
@@ -1,4 +1,5 @@
1
1
  const keyCount = {};
2
+ // if this function is hit more than 20 times in a row in 2 seconds with the same uniqName then throw an error
2
3
  export const isBeingCalledExcessively = ({ uniqName }) => {
3
4
  if (process.env.NODE_ENV !== "development") {
4
5
  return;
@@ -6,19 +7,25 @@ export const isBeingCalledExcessively = ({ uniqName }) => {
6
7
  if (!uniqName) {
7
8
  throw new Error("uniqName is required");
8
9
  }
9
- // if this function is hit more than 10 times in a row in 2 seconds with the same uniqName then throw an error
10
- if (keyCount[uniqName + "_timeout"]) {
11
- clearTimeout(keyCount[uniqName + "_timeout"]);
12
- }
10
+ // Initialize the count if it doesn't exist
13
11
  keyCount[uniqName] = keyCount[uniqName] || 0;
14
12
  keyCount[uniqName]++;
15
13
 
16
- keyCount[uniqName + "_timeout"] = setTimeout(() => {
17
- keyCount[uniqName] = 0;
18
- }, 2000);
14
+ // Only set the timeout if it doesn't exist already to ensure it runs exactly once every 2 seconds
15
+ if (!keyCount[uniqName + "_timeout"]) {
16
+ keyCount[uniqName + "_timeout"] = setTimeout(() => {
17
+ keyCount[uniqName] = 0;
18
+ keyCount[uniqName + "_timeout"] = null;
19
+ }, 2000);
20
+ }
19
21
 
20
22
  if (keyCount[uniqName] > 20) {
21
23
  keyCount[uniqName] = 0;
24
+ // Also clear the timeout when throwing an error
25
+ if (keyCount[uniqName + "_timeout"]) {
26
+ clearTimeout(keyCount[uniqName + "_timeout"]);
27
+ keyCount[uniqName + "_timeout"] = null;
28
+ }
22
29
  throw new Error(`isBeingCalledExcessively: ${uniqName}`);
23
30
  }
24
31
  };
@@ -1,33 +0,0 @@
1
- import React, { useState } from "react";
2
- import { Icon } from "@blueprintjs/core";
3
-
4
- export default function AdvancedOptions({
5
- children,
6
- content,
7
- label,
8
- style,
9
- isOpenByDefault
10
- }) {
11
- const [isOpen, setOpen] = useState(isOpenByDefault);
12
- if (!(content || children)) {
13
- return null;
14
- }
15
- return (
16
- <div style={{ marginTop: 5, ...style }}>
17
- <div
18
- onClick={() => {
19
- setOpen(!isOpen);
20
- }}
21
- style={{ cursor: "pointer", display: "flex", alignItems: "flex-end" }}
22
- className="tg-toggle-advanced-options"
23
- >
24
- {label || "Advanced"}{" "}
25
- <Icon
26
- icon={isOpen ? "caret-down" : "caret-right"}
27
- style={{ marginLeft: 5 }}
28
- ></Icon>
29
- </div>
30
- {isOpen && <div style={{ marginTop: 10 }}>{content || children}</div>}
31
- </div>
32
- );
33
- }
@@ -1,22 +0,0 @@
1
- import React from "react";
2
-
3
- export const AssignDefaultsModeContext = React.createContext({
4
- inAssignDefaultsMode: false,
5
- // eslint-disable-next-line @typescript-eslint/no-empty-function
6
- setAssignDefaultsMode: () => {}
7
- });
8
-
9
- export const workflowDefaultParamsObj = {
10
- taskNumber: undefined,
11
- workflowDefinitionName: undefined,
12
- workflowDefinitionId: undefined,
13
- workflowRunName: undefined,
14
- workflowRunId: undefined,
15
- toolName: undefined,
16
- workflowToolTitle: undefined,
17
- workflowToolDefinitionId: undefined,
18
- workflowTaskCode: undefined
19
- };
20
- export const WorkflowDefaultParamsContext = React.createContext(
21
- workflowDefaultParamsObj
22
- );
package/CellDragHandle.js DELETED
@@ -1,132 +0,0 @@
1
- import { flatMap } from "lodash-es";
2
- import { forEach } from "lodash-es";
3
- import React, { useCallback, useRef } from "react";
4
-
5
- export const CellDragHandle = ({
6
- thisTable,
7
- onDragEnd,
8
- cellId,
9
- isSelectionARectangle
10
- }) => {
11
- const xStart = useRef(0);
12
- const timeoutkey = useRef();
13
- const rowsToSelect = useRef();
14
- const rectangleCellPaths = useRef();
15
-
16
- const handleDrag = useCallback(
17
- e => {
18
- const table = thisTable.querySelector(".rt-table");
19
- const trs = table.querySelectorAll(`.rt-tr-group.with-row-data`);
20
- const [rowId, path] = cellId.split(":");
21
- const selectedTr = table.querySelector(
22
- `.rt-tr-group.with-row-data[data-test-id="${rowId}"]`
23
- );
24
- if (!selectedTr) return;
25
- const selectedIndex = selectedTr.dataset.index;
26
-
27
- if (selectedTr && trs.length) {
28
- const selectedY = selectedTr.getBoundingClientRect().y;
29
- const cursorY = e.clientY;
30
- clearTimeout(timeoutkey.current);
31
- const updateScrollIfNecessary = () => {
32
- const { y, height } = table.getBoundingClientRect();
33
- if (cursorY < y) {
34
- table.scrollBy(0, -5);
35
- } else if (cursorY > y + height) {
36
- table.scrollBy(0, 5);
37
- }
38
- };
39
- updateScrollIfNecessary();
40
- timeoutkey.current = setInterval(() => {
41
- updateScrollIfNecessary();
42
- }, 10);
43
-
44
- const isCursorBelow = cursorY > selectedY;
45
- rowsToSelect.current = [];
46
- forEach(trs, (tr, index) => {
47
- let isSelectedForUpdate;
48
- const rowId = tr.dataset.testId;
49
- const changeDashedBorder = (path, on) => {
50
- tr.querySelector(
51
- `[data-test="tgCell_${path}"]`
52
- ).parentNode.classList[on ? "add" : "remove"]("selectedForUpdate");
53
- };
54
- if (isCursorBelow ? index > selectedIndex : index < selectedIndex) {
55
- const { y, height } = tr.getBoundingClientRect();
56
- if (isCursorBelow ? y < cursorY : y + height > cursorY) {
57
- rowsToSelect.current.push(rowId);
58
- isSelectedForUpdate = true;
59
- //add dashed borders
60
-
61
- if (rectangleCellPaths.current) {
62
- rectangleCellPaths.current.forEach(path => {
63
- changeDashedBorder(path, true);
64
- });
65
- } else {
66
- changeDashedBorder(path, true);
67
- }
68
- }
69
- }
70
- if (!isSelectedForUpdate) {
71
- if (rectangleCellPaths.current) {
72
- rectangleCellPaths.current.forEach(path => {
73
- changeDashedBorder(path, false);
74
- });
75
- } else {
76
- changeDashedBorder(path, false);
77
- }
78
- }
79
- });
80
- }
81
- },
82
- [cellId, thisTable]
83
- );
84
-
85
- const onMouseUp = useCallback(() => {
86
- clearTimeout(timeoutkey.current);
87
- const table = thisTable;
88
- const trs = table.querySelectorAll(`.rt-tr-group.with-row-data`);
89
- const [, path] = cellId.split(":");
90
- //remove the dashed borders
91
- forEach(trs, tr => {
92
- if (rectangleCellPaths.current) {
93
- rectangleCellPaths.current.forEach(path => {
94
- const el = tr.querySelector(`[data-test="tgCell_${path}"]`);
95
- el.parentNode.classList.remove("selectedForUpdate");
96
- });
97
- } else {
98
- const el = tr.querySelector(`[data-test="tgCell_${path}"]`);
99
- el.parentNode.classList.remove("selectedForUpdate");
100
- }
101
- });
102
- document.removeEventListener("mousemove", handleDrag, false);
103
- document.removeEventListener("mouseup", onMouseUp, false);
104
- onDragEnd(
105
- flatMap(rowsToSelect.current, id => {
106
- if (rectangleCellPaths.current) {
107
- return rectangleCellPaths.current.map(path => {
108
- return `${id}:${path}`;
109
- });
110
- } else {
111
- return `${id}:${path}`;
112
- }
113
- })
114
- );
115
- }, [cellId, handleDrag, onDragEnd, thisTable]);
116
-
117
- return (
118
- <div
119
- onMouseDown={e => {
120
- rowsToSelect.current = [];
121
- xStart.current = e.clientX;
122
- const { isRect, selectedPaths } = isSelectionARectangle();
123
- if (isRect) {
124
- rectangleCellPaths.current = selectedPaths;
125
- }
126
- document.addEventListener("mousemove", handleDrag, false);
127
- document.addEventListener("mouseup", onMouseUp, false);
128
- }}
129
- className="cellDragHandle"
130
- />
131
- );
132
- };
@@ -1,62 +0,0 @@
1
- import React, { useState } from "react";
2
- import classNames from "classnames";
3
- import { Icon, Popover } from "@blueprintjs/core";
4
-
5
- export const ColumnFilterMenu = ({
6
- addFilters,
7
- compact,
8
- currentFilter,
9
- currentParams,
10
- dataType,
11
- extraCompact,
12
- filterActiveForColumn,
13
- FilterMenu,
14
- filterOn,
15
- removeSingleFilter,
16
- schemaForField,
17
- setNewParams,
18
- formName
19
- }) => {
20
- const [columnFilterMenuOpen, setColumnFilterMenuOpen] = useState(false);
21
- return (
22
- <Popover
23
- position="bottom"
24
- onClose={() => setColumnFilterMenuOpen(false)}
25
- isOpen={columnFilterMenuOpen}
26
- modifiers={{
27
- preventOverflow: { enabled: true },
28
- hide: { enabled: false },
29
- flip: { enabled: false }
30
- }}
31
- content={
32
- <FilterMenu
33
- formName={formName}
34
- addFilters={addFilters}
35
- compact={compact}
36
- currentFilter={currentFilter}
37
- currentParams={currentParams}
38
- dataType={dataType}
39
- filterOn={filterOn}
40
- removeSingleFilter={removeSingleFilter}
41
- schemaForField={schemaForField}
42
- setNewParams={setNewParams}
43
- togglePopover={() => setColumnFilterMenuOpen(false)}
44
- />
45
- }
46
- >
47
- <Icon
48
- style={{ marginLeft: 5 }}
49
- icon="filter"
50
- size={extraCompact ? 14 : undefined}
51
- onClick={e => {
52
- e.preventDefault();
53
- e.stopPropagation();
54
- setColumnFilterMenuOpen(prev => !prev);
55
- }}
56
- className={classNames("tg-filter-menu-button", {
57
- "tg-active-filter": !!filterActiveForColumn
58
- })}
59
- />
60
- </Popover>
61
- );
62
- };