@teselagen/ui 0.7.33-beta.5 → 0.7.33

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 (119) hide show
  1. package/AdvancedOptions.js +33 -0
  2. package/AssignDefaultsModeContext.js +22 -0
  3. package/CellDragHandle.js +132 -0
  4. package/ColumnFilterMenu.js +62 -0
  5. package/Columns.js +979 -0
  6. package/DataTable/utils/queryParams.d.ts +18 -9
  7. package/DisabledLoadingComponent.js +15 -0
  8. package/DisplayOptions.js +199 -0
  9. package/DropdownButton.js +36 -0
  10. package/DropdownCell.js +61 -0
  11. package/EditableCell.js +44 -0
  12. package/FillWindow.css +6 -0
  13. package/FillWindow.js +69 -0
  14. package/FilterAndSortMenu.js +391 -0
  15. package/FormSeparator.js +9 -0
  16. package/LoadingDots.js +14 -0
  17. package/MatchHeaders.js +234 -0
  18. package/PagingTool.js +225 -0
  19. package/RenderCell.js +191 -0
  20. package/SearchBar.js +69 -0
  21. package/SimpleStepViz.js +22 -0
  22. package/SortableColumns.js +100 -0
  23. package/TableFormTrackerContext.js +10 -0
  24. package/Tag.js +112 -0
  25. package/ThComponent.js +44 -0
  26. package/TimelineEvent.js +31 -0
  27. package/UploadCsvWizard.css +4 -0
  28. package/UploadCsvWizard.js +719 -0
  29. package/Uploader.js +1278 -0
  30. package/adHoc.js +10 -0
  31. package/autoTooltip.js +201 -0
  32. package/basicHandleActionsWithFullState.js +14 -0
  33. package/browserUtils.js +3 -0
  34. package/combineReducersWithFullState.js +14 -0
  35. package/commandControls.js +82 -0
  36. package/commandUtils.js +112 -0
  37. package/constants.js +1 -0
  38. package/convertSchema.js +69 -0
  39. package/customIcons.js +361 -0
  40. package/dataTableEnhancer.js +41 -0
  41. package/defaultFormatters.js +32 -0
  42. package/defaultValidators.js +40 -0
  43. package/determineBlackOrWhiteTextColor.js +4 -0
  44. package/editCellHelper.js +44 -0
  45. package/formatPasteData.js +16 -0
  46. package/getAllRows.js +11 -0
  47. package/getCellCopyText.js +7 -0
  48. package/getCellInfo.js +36 -0
  49. package/getCellVal.js +20 -0
  50. package/getDayjsFormatter.js +35 -0
  51. package/getFieldPathToField.js +7 -0
  52. package/getIdOrCodeOrIndex.js +9 -0
  53. package/getLastSelectedEntity.js +11 -0
  54. package/getNewEntToSelect.js +25 -0
  55. package/getNewName.js +31 -0
  56. package/getRowCopyText.js +28 -0
  57. package/getTableConfigFromStorage.js +5 -0
  58. package/getTextFromEl.js +28 -0
  59. package/getVals.js +8 -0
  60. package/handleCopyColumn.js +21 -0
  61. package/handleCopyHelper.js +15 -0
  62. package/handleCopyRows.js +23 -0
  63. package/handleCopyTable.js +16 -0
  64. package/handlerHelpers.js +24 -0
  65. package/hotkeyUtils.js +131 -0
  66. package/index.cjs.js +970 -826
  67. package/index.d.ts +0 -1
  68. package/index.es.js +970 -826
  69. package/index.js +196 -0
  70. package/isBeingCalledExcessively.js +31 -0
  71. package/isBottomRightCornerOfRectangle.js +20 -0
  72. package/isEntityClean.js +15 -0
  73. package/isTruthy.js +12 -0
  74. package/isValueEmpty.js +3 -0
  75. package/itemUpload.js +84 -0
  76. package/menuUtils.js +433 -0
  77. package/package.json +1 -2
  78. package/popoverOverflowModifiers.js +11 -0
  79. package/primarySelectedValue.js +1 -0
  80. package/pureNoFunc.js +31 -0
  81. package/queryParams.js +1058 -0
  82. package/removeCleanRows.js +22 -0
  83. package/renderOnDoc.js +32 -0
  84. package/rerenderOnWindowResize.js +26 -0
  85. package/rowClick.js +181 -0
  86. package/selection.js +8 -0
  87. package/showAppSpinner.js +12 -0
  88. package/showDialogOnDocBody.js +33 -0
  89. package/showProgressToast.js +22 -0
  90. package/sortify.js +73 -0
  91. package/src/DataTable/index.js +1 -1
  92. package/src/DataTable/utils/filterLocalEntitiesToHasura.js +14 -0
  93. package/src/DataTable/utils/filterLocalEntitiesToHasura.test.js +49 -0
  94. package/src/DataTable/utils/queryParams.js +12 -9
  95. package/src/DataTable/utils/tableQueryParamsToHasuraClauses.js +146 -143
  96. package/style.css +29 -0
  97. package/tagUtils.js +45 -0
  98. package/tgFormValues.js +35 -0
  99. package/tg_modalState.js +47 -0
  100. package/throwFormError.js +16 -0
  101. package/toastr.js +148 -0
  102. package/tryToMatchSchemas.js +264 -0
  103. package/typeToCommonType.js +6 -0
  104. package/useDeepEqualMemo.js +15 -0
  105. package/useDialog.js +63 -0
  106. package/useStableReference.js +9 -0
  107. package/useTableEntities.js +38 -0
  108. package/useTraceUpdate.js +19 -0
  109. package/utils.js +37 -0
  110. package/validateTableWideErrors.js +160 -0
  111. package/viewColumn.js +97 -0
  112. package/withField.js +20 -0
  113. package/withFields.js +11 -0
  114. package/withLocalStorage.js +11 -0
  115. package/withSelectTableRecords.js +43 -0
  116. package/withSelectedEntities.js +65 -0
  117. package/withStore.js +10 -0
  118. package/withTableParams.js +301 -0
  119. package/wrapDialog.js +116 -0
package/index.js ADDED
@@ -0,0 +1,196 @@
1
+ import React from "react";
2
+ import { Dialog } from "@blueprintjs/core";
3
+ import { connect } from "react-redux";
4
+ import { lifecycle, compose } from "recompose";
5
+ import { camelCase } from "lodash-es";
6
+ import { nanoid } from "nanoid";
7
+ import ResizableDraggableDialog from "../../ResizableDraggableDialog";
8
+
9
+ /**
10
+ * usage:
11
+ * in container:
12
+ * compose(
13
+ * withDialog({ title: "Select Aliquot(s) From", other bp dialog props here })
14
+ * )
15
+ *
16
+ *
17
+ * in react component
18
+ * import MyDialogEnhancedComponent from "./MyDialogEnhancedComponent"
19
+ *
20
+ * render() {
21
+ * return <div>
22
+ * <MyDialogEnhancedComponent
23
+ * dialogProps={} //bp dialog overrides can go here
24
+ * target={<button>Open Dialog</button> } //target can also be passed as a child component
25
+ * myRandomProp={'yuppp'} //pass any other props like normal to the component
26
+ *
27
+ * />
28
+ * </div>
29
+ * }
30
+ */
31
+
32
+ // or programatically:
33
+ // const ProgramaticDialog = withDialog({
34
+ // dialogName: "programaticDialog", //giving it a unique dialogName means you can
35
+ // title: "Programatic Dialog Demo"
36
+ // })(DialogInner);
37
+ //
38
+ // add the no target dialog somewhere on the page
39
+ // <ProgramaticDialog></ProgramaticDialog> //this just renders without any target
40
+ //
41
+ // somewhere else on the page:
42
+ // <Button>Click To Open Dialog</Button>
43
+
44
+ export default function withDialog(topLevelDialogProps) {
45
+ function dialogHoc(WrappedComponent) {
46
+ return class DialogWrapper extends React.Component {
47
+ componentWillUnmount() {
48
+ const { dispatch, dialogName, uniqueName } = this.props;
49
+ if (dialogName) {
50
+ dispatch({
51
+ type: "TG_UNREGISTER_MODAL",
52
+ name: dialogName,
53
+ uniqueName
54
+ });
55
+ }
56
+ }
57
+ render() {
58
+ const {
59
+ target,
60
+ noTarget,
61
+ isDialogOpen,
62
+ showModal,
63
+ dialogName,
64
+ onClickRename,
65
+ hideModal,
66
+ fetchPolicy = "network-only",
67
+ children,
68
+ onCloseHook,
69
+ dialogProps,
70
+ title,
71
+ isDraggable,
72
+ alreadyRendering,
73
+ ...rest
74
+ } = this.props;
75
+ const extraDialogProps = {
76
+ ...topLevelDialogProps,
77
+ ...dialogProps
78
+ };
79
+ const _onCloseHook = onCloseHook || extraDialogProps.onCloseHook;
80
+ const { noButtonClickPropagate } = {
81
+ ...this.props,
82
+ ...extraDialogProps
83
+ };
84
+ const isOpen = isDialogOpen || extraDialogProps.isOpen;
85
+ const targetEl = target || children;
86
+ // if (!targetEl && !dialogName)
87
+ // throw new Error(
88
+ // "withDialog error: Please provide a target or child element to the withDialog() enhanced component. If you really don't want a target, please pass a 'noTarget=true' prop"
89
+ // );
90
+ const DialogToUse =
91
+ isDraggable || extraDialogProps.isDraggable
92
+ ? ResizableDraggableDialog
93
+ : Dialog;
94
+ return (
95
+ <React.Fragment>
96
+ {isOpen && (
97
+ <DialogToUse
98
+ onClose={function () {
99
+ hideModal();
100
+ _onCloseHook && _onCloseHook();
101
+ }}
102
+ className={dialogName || camelCase()}
103
+ title={title}
104
+ isOpen={isOpen}
105
+ canEscapeKeyClose={false}
106
+ canOutsideClickClose={false}
107
+ {...extraDialogProps}
108
+ >
109
+ <WrappedComponent
110
+ {...{
111
+ ...rest,
112
+ fetchPolicy,
113
+ ssr: false,
114
+ hideModal
115
+ }}
116
+ />
117
+ </DialogToUse>
118
+ )}
119
+ {targetEl &&
120
+ React.cloneElement(targetEl, {
121
+ [onClickRename || "onClick"]: e => {
122
+ showModal();
123
+ if (noButtonClickPropagate) {
124
+ e.preventDefault();
125
+ e.stopPropagation();
126
+ }
127
+ }
128
+ })}
129
+ </React.Fragment>
130
+ );
131
+ }
132
+ };
133
+ }
134
+
135
+ return compose(
136
+ connect(({ tg_modalState }) => {
137
+ return { ...topLevelDialogProps, tg_modalState };
138
+ }),
139
+ lifecycle({
140
+ componentWillMount: function () {
141
+ const { dispatch, dialogName } = this.props;
142
+ const uniqueName = nanoid();
143
+ const nameToUse = dialogName || uniqueName;
144
+ this.setState({
145
+ nameToUse,
146
+ uniqueName
147
+ });
148
+ if (dialogName) {
149
+ dispatch({
150
+ type: "TG_REGISTER_MODAL",
151
+ name: dialogName,
152
+ uniqueName
153
+ });
154
+ }
155
+ }
156
+ }),
157
+ connect(
158
+ function ({ tg_modalState }, { nameToUse, uniqueName }) {
159
+ const dialogState = tg_modalState[nameToUse] || {};
160
+ const { open, __registeredAs, ...rest } = dialogState;
161
+ const newProps = {
162
+ ...rest,
163
+ isDialogOpen:
164
+ open &&
165
+ (__registeredAs
166
+ ? Object.keys(__registeredAs)[
167
+ Object.keys(__registeredAs).length - 1
168
+ ] === uniqueName
169
+ : true)
170
+ };
171
+ return newProps;
172
+ },
173
+ function (dispatch, { nameToUse, hideModal, showModal }) {
174
+ return {
175
+ showModal:
176
+ showModal ||
177
+ function () {
178
+ dispatch({
179
+ type: "TG_SHOW_MODAL",
180
+ name: nameToUse
181
+ });
182
+ },
183
+ hideModal:
184
+ hideModal ||
185
+ function () {
186
+ dispatch({
187
+ type: "TG_HIDE_MODAL",
188
+ name: nameToUse
189
+ });
190
+ }
191
+ };
192
+ }
193
+ ),
194
+ dialogHoc
195
+ );
196
+ }
@@ -0,0 +1,31 @@
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
3
+ export const isBeingCalledExcessively = ({ uniqName }) => {
4
+ if (process.env.NODE_ENV !== "development") {
5
+ return;
6
+ }
7
+ if (!uniqName) {
8
+ throw new Error("uniqName is required");
9
+ }
10
+ // Initialize the count if it doesn't exist
11
+ keyCount[uniqName] = keyCount[uniqName] || 0;
12
+ keyCount[uniqName]++;
13
+
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
+ }
21
+
22
+ if (keyCount[uniqName] > 20) {
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
+ }
29
+ throw new Error(`isBeingCalledExcessively: ${uniqName}`);
30
+ }
31
+ };
@@ -0,0 +1,20 @@
1
+ export const isBottomRightCornerOfRectangle = ({
2
+ cellId,
3
+ selectionGrid,
4
+ lastRowIndex,
5
+ lastCellIndex,
6
+ entityMap,
7
+ pathToIndex
8
+ }) => {
9
+ selectionGrid.forEach(row => {
10
+ // remove undefineds from start of row
11
+ while (row[0] === undefined && row.length) row.shift();
12
+ });
13
+ const [rowId, cellPath] = cellId.split(":");
14
+ const ent = entityMap[rowId];
15
+ if (!ent) return;
16
+ const { i } = ent;
17
+ const cellIndex = pathToIndex[cellPath];
18
+ const isBottomRight = i === lastRowIndex && cellIndex === lastCellIndex;
19
+ return isBottomRight;
20
+ };
@@ -0,0 +1,15 @@
1
+ export function isEntityClean(e) {
2
+ if (typeof e !== "object" || e === null) {
3
+ return true; // or return false depending on what you want for non-object inputs
4
+ }
5
+ let isClean = true;
6
+ for (const [key, val] of Object.entries(e)) {
7
+ if (key === "id") continue;
8
+ if (key === "_isClean") continue;
9
+ if (val) {
10
+ isClean = false;
11
+ break;
12
+ }
13
+ }
14
+ return isClean;
15
+ }
package/isTruthy.js ADDED
@@ -0,0 +1,12 @@
1
+ export function isTruthy(v) {
2
+ if (!v) return false;
3
+ if (typeof v === "string") {
4
+ if (v.toLowerCase() === "false") {
5
+ return false;
6
+ }
7
+ if (v.toLowerCase() === "no") {
8
+ return false;
9
+ }
10
+ }
11
+ return true;
12
+ }
@@ -0,0 +1,3 @@
1
+ export function isValueEmpty(val) {
2
+ return val === undefined || val === null || val === "";
3
+ }
package/itemUpload.js ADDED
@@ -0,0 +1,84 @@
1
+ import React from "react";
2
+ import {
3
+ ProgressBar,
4
+ Intent,
5
+ Button,
6
+ Tooltip,
7
+ Position,
8
+ Icon
9
+ } from "@blueprintjs/core";
10
+
11
+ const itemUpload = props => {
12
+ const item = props.item;
13
+ const name = nameShortener(item.name);
14
+
15
+ return (
16
+ <div className="item-upload-container" key={item.id}>
17
+ <div className="item-upload">
18
+ <div>
19
+ {!props.saved ? (
20
+ <Tooltip
21
+ content={
22
+ <span>
23
+ {`Click to
24
+ ${props.active ? "abort this uploading" : "remove this file"}`}
25
+ </span>
26
+ }
27
+ position={Position.LEFT}
28
+ usePortal={true}
29
+ >
30
+ <Button
31
+ intent={Intent.DANGER}
32
+ minimal
33
+ icon="delete"
34
+ onClick={props.onCancel}
35
+ />
36
+ </Tooltip>
37
+ ) : null}
38
+ </div>
39
+ <div>
40
+ <span>{name}</span>
41
+ </div>
42
+ <div>
43
+ {props.active ? `${props.value}%` : null}
44
+ {props.error ? (
45
+ <Tooltip content={props.error} usePortal={true}>
46
+ <Icon icon="error" intent={Intent.DANGER} />
47
+ </Tooltip>
48
+ ) : null}
49
+ {props.saved ? (
50
+ <Tooltip content={"File Saved"} usePortal={true}>
51
+ <Icon icon="saved" intent={Intent.SUCCESS} />
52
+ </Tooltip>
53
+ ) : null}
54
+ </div>
55
+ </div>
56
+ {props.active ? (
57
+ <ProgressBar intent={Intent.PRIMARY} value={props.value / 100} />
58
+ ) : null}
59
+ </div>
60
+ );
61
+ };
62
+
63
+ /**
64
+ * Short file names length to display
65
+ * @param {*} itemName
66
+ */
67
+ const nameShortener = itemName => {
68
+ if (itemName.length > 40) {
69
+ let name = "";
70
+ const arr = itemName.split(".");
71
+ name += `${arr[0].substring(0, 20)}...`;
72
+ if (arr.length >= 2) {
73
+ name += `${arr[arr.length - 2].substring(
74
+ arr[arr.length - 2].length - 5,
75
+ arr[arr.length - 2].length
76
+ )}`;
77
+ name += `.${arr[arr.length - 1]}`;
78
+ }
79
+ return name;
80
+ }
81
+ return itemName;
82
+ };
83
+
84
+ export default itemUpload;