@teselagen/ui 0.7.35 → 0.7.36

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 (160) hide show
  1. package/isBeingCalledExcessively.js +1 -0
  2. package/package.json +1 -1
  3. package/DataTable/utils/filterLocalEntitiesToHasura.d.ts +0 -5
  4. package/DataTable/utils/initializeHasuraWhereAndFilter.d.ts +0 -2
  5. package/DataTable/utils/tableQueryParamsToHasuraClauses.d.ts +0 -26
  6. package/src/AdvancedOptions.js +0 -33
  7. package/src/AdvancedOptions.spec.js +0 -26
  8. package/src/AssignDefaultsModeContext.js +0 -22
  9. package/src/AsyncValidateFieldSpinner/index.js +0 -12
  10. package/src/BlueprintError/index.js +0 -14
  11. package/src/BounceLoader/index.js +0 -16
  12. package/src/BounceLoader/style.css +0 -45
  13. package/src/CollapsibleCard/index.js +0 -68
  14. package/src/CollapsibleCard/style.css +0 -23
  15. package/src/DNALoader/index.js +0 -20
  16. package/src/DNALoader/style.css +0 -251
  17. package/src/DataTable/CellDragHandle.js +0 -132
  18. package/src/DataTable/ColumnFilterMenu.js +0 -62
  19. package/src/DataTable/Columns.js +0 -979
  20. package/src/DataTable/DisabledLoadingComponent.js +0 -15
  21. package/src/DataTable/DisplayOptions.js +0 -199
  22. package/src/DataTable/DropdownCell.js +0 -61
  23. package/src/DataTable/EditableCell.js +0 -44
  24. package/src/DataTable/FilterAndSortMenu.js +0 -388
  25. package/src/DataTable/PagingTool.js +0 -225
  26. package/src/DataTable/RenderCell.js +0 -191
  27. package/src/DataTable/SearchBar.js +0 -69
  28. package/src/DataTable/SortableColumns.js +0 -100
  29. package/src/DataTable/TableFormTrackerContext.js +0 -10
  30. package/src/DataTable/ThComponent.js +0 -44
  31. package/src/DataTable/dataTableEnhancer.js +0 -41
  32. package/src/DataTable/defaultFormatters.js +0 -32
  33. package/src/DataTable/defaultValidators.js +0 -40
  34. package/src/DataTable/editCellHelper.js +0 -44
  35. package/src/DataTable/getCellVal.js +0 -20
  36. package/src/DataTable/getVals.js +0 -8
  37. package/src/DataTable/index.js +0 -3209
  38. package/src/DataTable/isTruthy.js +0 -12
  39. package/src/DataTable/isValueEmpty.js +0 -3
  40. package/src/DataTable/style.css +0 -608
  41. package/src/DataTable/utils/convertSchema.js +0 -69
  42. package/src/DataTable/utils/filterLocalEntitiesToHasura.js +0 -236
  43. package/src/DataTable/utils/filterLocalEntitiesToHasura.test.js +0 -587
  44. package/src/DataTable/utils/formatPasteData.js +0 -16
  45. package/src/DataTable/utils/getAllRows.js +0 -11
  46. package/src/DataTable/utils/getCellCopyText.js +0 -7
  47. package/src/DataTable/utils/getCellInfo.js +0 -36
  48. package/src/DataTable/utils/getFieldPathToField.js +0 -7
  49. package/src/DataTable/utils/getIdOrCodeOrIndex.js +0 -9
  50. package/src/DataTable/utils/getLastSelectedEntity.js +0 -11
  51. package/src/DataTable/utils/getNewEntToSelect.js +0 -25
  52. package/src/DataTable/utils/getRowCopyText.js +0 -28
  53. package/src/DataTable/utils/getTableConfigFromStorage.js +0 -5
  54. package/src/DataTable/utils/handleCopyColumn.js +0 -21
  55. package/src/DataTable/utils/handleCopyHelper.js +0 -15
  56. package/src/DataTable/utils/handleCopyRows.js +0 -23
  57. package/src/DataTable/utils/handleCopyTable.js +0 -16
  58. package/src/DataTable/utils/index.js +0 -55
  59. package/src/DataTable/utils/initializeHasuraWhereAndFilter.js +0 -26
  60. package/src/DataTable/utils/isBottomRightCornerOfRectangle.js +0 -20
  61. package/src/DataTable/utils/isEntityClean.js +0 -15
  62. package/src/DataTable/utils/primarySelectedValue.js +0 -1
  63. package/src/DataTable/utils/queryParams.js +0 -350
  64. package/src/DataTable/utils/removeCleanRows.js +0 -22
  65. package/src/DataTable/utils/rowClick.js +0 -181
  66. package/src/DataTable/utils/selection.js +0 -8
  67. package/src/DataTable/utils/tableQueryParamsToHasuraClauses.js +0 -253
  68. package/src/DataTable/utils/tableQueryParamsToHasuraClauses.test.js +0 -206
  69. package/src/DataTable/utils/useTableEntities.js +0 -38
  70. package/src/DataTable/utils/utils.js +0 -37
  71. package/src/DataTable/utils/withSelectedEntities.js +0 -65
  72. package/src/DataTable/utils/withTableParams.js +0 -288
  73. package/src/DataTable/validateTableWideErrors.js +0 -160
  74. package/src/DataTable/viewColumn.js +0 -97
  75. package/src/DialogFooter/index.js +0 -86
  76. package/src/DialogFooter/style.css +0 -9
  77. package/src/DropdownButton.js +0 -36
  78. package/src/FillWindow.css +0 -6
  79. package/src/FillWindow.js +0 -69
  80. package/src/FormComponents/FormSeparator.js +0 -9
  81. package/src/FormComponents/LoadingDots.js +0 -14
  82. package/src/FormComponents/Uploader.js +0 -1278
  83. package/src/FormComponents/getNewName.js +0 -31
  84. package/src/FormComponents/index.js +0 -1266
  85. package/src/FormComponents/itemUpload.js +0 -84
  86. package/src/FormComponents/sortify.js +0 -73
  87. package/src/FormComponents/style.css +0 -275
  88. package/src/FormComponents/tryToMatchSchemas.js +0 -264
  89. package/src/FormComponents/utils.js +0 -6
  90. package/src/HotkeysDialog/index.js +0 -79
  91. package/src/HotkeysDialog/style.css +0 -54
  92. package/src/InfoHelper/index.js +0 -78
  93. package/src/InfoHelper/style.css +0 -7
  94. package/src/IntentText/index.js +0 -18
  95. package/src/Loading/index.js +0 -70
  96. package/src/Loading/style.css +0 -4
  97. package/src/MatchHeaders.js +0 -234
  98. package/src/MenuBar/index.js +0 -423
  99. package/src/MenuBar/style.css +0 -45
  100. package/src/PromptUnsavedChanges/index.js +0 -38
  101. package/src/ResizableDraggableDialog/index.js +0 -141
  102. package/src/ResizableDraggableDialog/style.css +0 -42
  103. package/src/ScrollToTop/index.js +0 -72
  104. package/src/SimpleStepViz.js +0 -22
  105. package/src/Tag.js +0 -112
  106. package/src/TagSelect/index.js +0 -69
  107. package/src/TagSelect/style.css +0 -13
  108. package/src/TgHtmlSelect/index.js +0 -20
  109. package/src/TgSelect/index.js +0 -537
  110. package/src/TgSelect/style.css +0 -61
  111. package/src/TgSuggest/index.js +0 -124
  112. package/src/Timeline/TimelineEvent.js +0 -31
  113. package/src/Timeline/index.js +0 -15
  114. package/src/Timeline/style.css +0 -29
  115. package/src/UploadCsvWizard.css +0 -4
  116. package/src/UploadCsvWizard.js +0 -719
  117. package/src/autoTooltip.js +0 -201
  118. package/src/constants.js +0 -1
  119. package/src/customIcons.js +0 -361
  120. package/src/enhancers/withDialog/index.js +0 -196
  121. package/src/enhancers/withDialog/tg_modalState.js +0 -47
  122. package/src/enhancers/withField.js +0 -20
  123. package/src/enhancers/withFields.js +0 -11
  124. package/src/enhancers/withLocalStorage.js +0 -11
  125. package/src/index.js +0 -88
  126. package/src/rerenderOnWindowResize.js +0 -26
  127. package/src/showAppSpinner.js +0 -12
  128. package/src/showConfirmationDialog/index.js +0 -148
  129. package/src/showDialogOnDocBody.js +0 -33
  130. package/src/style.css +0 -265
  131. package/src/throwFormError.js +0 -16
  132. package/src/toastr.js +0 -148
  133. package/src/typeToCommonType.js +0 -6
  134. package/src/useDialog.js +0 -63
  135. package/src/utils/adHoc.js +0 -10
  136. package/src/utils/basicHandleActionsWithFullState.js +0 -14
  137. package/src/utils/browserUtils.js +0 -3
  138. package/src/utils/combineReducersWithFullState.js +0 -14
  139. package/src/utils/commandControls.js +0 -82
  140. package/src/utils/commandUtils.js +0 -112
  141. package/src/utils/determineBlackOrWhiteTextColor.js +0 -4
  142. package/src/utils/getDayjsFormatter.js +0 -35
  143. package/src/utils/getTextFromEl.js +0 -28
  144. package/src/utils/handlerHelpers.js +0 -24
  145. package/src/utils/hooks/index.js +0 -1
  146. package/src/utils/hooks/useDeepEqualMemo.js +0 -15
  147. package/src/utils/hooks/useStableReference.js +0 -9
  148. package/src/utils/hotkeyUtils.js +0 -131
  149. package/src/utils/isBeingCalledExcessively.js +0 -24
  150. package/src/utils/menuUtils.js +0 -433
  151. package/src/utils/popoverOverflowModifiers.js +0 -11
  152. package/src/utils/pureNoFunc.js +0 -31
  153. package/src/utils/renderOnDoc.js +0 -32
  154. package/src/utils/showProgressToast.js +0 -22
  155. package/src/utils/tagUtils.js +0 -45
  156. package/src/utils/tgFormValues.js +0 -35
  157. package/src/utils/useTraceUpdate.js +0 -19
  158. package/src/utils/withSelectTableRecords.js +0 -43
  159. package/src/utils/withStore.js +0 -10
  160. package/src/wrapDialog.js +0 -116
package/src/style.css DELETED
@@ -1,265 +0,0 @@
1
- :root {
2
- --base1: #ffffff;
3
- --base2: #cdcdcd;
4
- }
5
-
6
- body.bp3-dark {
7
- --base1: #393a3a;
8
- --base2: #293742;
9
- }
10
-
11
- .bp3-dark .tg-card {
12
- background: #394b59 !important;
13
- }
14
-
15
- .preserve-newline {
16
- white-space: pre-line;
17
- }
18
-
19
- .bp3-dialog {
20
- max-width: 100vw;
21
- }
22
-
23
- /* adding back in blueprint v2 default styling to all <h/> elements */
24
- h1 {
25
- line-height: 40px;
26
- font-size: 36px;
27
- }
28
-
29
- h2 {
30
- line-height: 32px;
31
- font-size: 28px;
32
- }
33
-
34
- h3 {
35
- line-height: 25px;
36
- font-size: 22px;
37
- }
38
-
39
- h4 {
40
- line-height: 21px;
41
- font-size: 18px;
42
- }
43
-
44
- h5 {
45
- line-height: 19px;
46
- font-size: 16px;
47
- }
48
-
49
- h6 {
50
- line-height: 16px;
51
- font-size: 14px;
52
- }
53
-
54
- h1,
55
- h2,
56
- h3,
57
- h4,
58
- h5,
59
- h6,
60
- h1.bp3-heading,
61
- h2.bp3-heading,
62
- h3.bp3-heading,
63
- h4.bp3-heading,
64
- h5.bp3-heading,
65
- h6.bp3-heading {
66
- color: #182026;
67
- font-weight: 300;
68
- margin: 0 0 10px;
69
- padding: 0;
70
- line-height: normal;
71
- }
72
-
73
- .bp3-dark h1,
74
- .bp3-dark h2,
75
- .bp3-dark h3,
76
- .bp3-dark h4,
77
- .bp3-dark h5,
78
- .bp3-dark h6 {
79
- color: #f5f8fa;
80
- }
81
- .bp3-dark textarea {
82
- background: #293742;
83
- color: #f5f8fa;
84
- }
85
-
86
- /* bp3 fix https://github.com/palantir/blueprint/issues/2807 */
87
- .bp3-popover-wrapper {
88
- display: inline-block;
89
- position: relative;
90
- vertical-align: top;
91
- }
92
- /* this line is necessary otherwise the line above setting "position: relative;" caused nested long bp3 submenus to not appear correctly when using the fix below */
93
- .bp3-submenu .bp3-popover-wrapper {
94
- position: unset;
95
- }
96
- /* this fixes https://github.com/palantir/blueprint/issues/4791 but requires the "position: unset;" fix above */
97
- .bp3-submenu > * > .bp3-menu {
98
- max-height: 96vh;
99
- overflow: auto;
100
- }
101
-
102
- /* bp3 fix https://github.com/palantir/blueprint/issues/2807 */
103
- span.bp3-popover-target {
104
- display: block;
105
- }
106
-
107
- .bp3-portal {
108
- z-index: 100000;
109
- }
110
- .bp3-switch {
111
- width: fit-content;
112
- display: flex;
113
- align-items: center;
114
- }
115
-
116
- .Select {
117
- min-width: 170px;
118
- }
119
-
120
- /* override the default blueprint input focus to instead rely on an inset box shadow. This resolves any issues with overflow:hidden cutting off input box shadows */
121
- .bp3-dark .bp3-input:focus,
122
- .bp3-input:focus {
123
- box-shadow: inset 0 0 3px 1px #137cbd;
124
- }
125
-
126
- .notClickable {
127
- cursor: default !important;
128
- }
129
- .bp3-toast-container {
130
- z-index: 100001;
131
- }
132
-
133
- .link-button {
134
- background: none !important;
135
- border: none;
136
- padding: 0 !important;
137
- font-family: arial, sans-serif;
138
- color: rgb(0, 151, 227);
139
- /* text-decoration: underline; */
140
- cursor: pointer;
141
- }
142
- .link-button:hover {
143
- color: rgb(98, 198, 248);
144
- text-decoration: underline;
145
- }
146
-
147
- .above-dialog {
148
- z-index: 100001;
149
- }
150
-
151
- code {
152
- display: block;
153
- white-space: pre-wrap;
154
- }
155
-
156
- .bp3-toast.no-close-button [aria-label="Close"] {
157
- display: none;
158
- }
159
-
160
- .isDataTitle .tippy-box[data-theme~="teselagen"] .tippy-arrow {
161
- opacity: 0 !important;
162
- }
163
- .isDataTitle .tippy-box[data-theme~="teselagen"] {
164
- background-color: #4f4a50f4 !important;
165
- border-radius: 0 !important;
166
- color: #f3f3f3 !important;
167
- font-size: 11px !important;
168
- white-space: pre-wrap;
169
- padding: 0px 0px !important;
170
- }
171
-
172
- [data-tippy-root]:has(.tippy-box[data-theme~="teselagen"]) {
173
- z-index: 100000 !important;
174
- }
175
-
176
- [data-tippy-root] .tippy-box[data-theme~="teselagen"] {
177
- background-color: #394b59;
178
- color: #f5f8fa;
179
- padding: 4px 4px;
180
- word-break: break-word;
181
- }
182
- [data-tippy-root] .tippy-box[data-theme~="teselagen"] .tippy-arrow {
183
- color: #394b59;
184
- }
185
- .bp3-dark [data-tippy-root] .tippy-box[data-theme~="teselagen"] {
186
- background-color: #e1e8ed;
187
- color: #394b59;
188
- }
189
- .bp3-dark [data-tippy-root] .tippy-box[data-theme~="teselagen"] .tippy-arrow {
190
- /* background-color: #e1e8ed; */
191
- color: #e1e8ed;
192
- }
193
- .isCellEditable .rt-td {
194
- position: relative;
195
- }
196
-
197
- .ReactTable .tg-cell-edit-boolean-checkbox {
198
- margin-bottom: 0;
199
- }
200
-
201
- .cellDragHandle {
202
- height: 8px;
203
- width: 8px;
204
- cursor: crosshair;
205
- border: 1px solid rgb(255, 255, 255);
206
- background-color: rgb(76, 107, 171);
207
- position: absolute;
208
- bottom: -4px;
209
- right: -4px;
210
- }
211
-
212
- /* make AnchorButton match Button */
213
- .bp3-button {
214
- font-family: Arial;
215
- }
216
-
217
- button {
218
- transition: all 0.2s ease-in-out;
219
- }
220
-
221
- button:not(:disabled):active {
222
- transform: translateY(1px);
223
- }
224
- .bp3-tabs.bp3-vertical > .bp3-tab-panel {
225
- min-width: 0px;
226
- }
227
- .bp3-toast[class*="bp3-intent-"] .bp3-button.tg-clear-all-toasts {
228
- border: 1px solid white !important;
229
- }
230
- .bp3-toast[class*="bp3-intent-"] .bp3-button.tg-clear-all-toasts:hover {
231
- /* background: blue !important; */
232
- /* background: unset !important; */
233
- background-color: #137cbd !important;
234
- }
235
-
236
- /* .bp3-toast .tg-clear-all-toasts {
237
- background: unset !important;
238
- color: unset !important;
239
- padding: unset !important;
240
- margin: unset !important;
241
- font-size: unset !important;
242
- line-height: unset !important;
243
- border: unset !important;
244
- box-shadow: unset !important;
245
- text-align: unset !important;
246
- cursor: pointer !important;
247
- } */
248
-
249
- .bp3-dialog-header .bp3-heading {
250
- width: 10px; /* tnw: this is a hack to prevent the dialog title from causing the dialog width to expand larger than the dialog content*/
251
- }
252
-
253
- /* to fix tooltip styling issue - https://github.com/palantir/blueprint/issues/3430 */
254
- .bp3-popover[style*="transform-origin"][style*="bottom"] .bp3-popover-arrow {
255
- transform: translate(0, -0.5px);
256
- }
257
- .bp3-popover[style*="transform-origin"][style*="left"] .bp3-popover-arrow {
258
- transform: translate(0.5px, 0);
259
- }
260
- .bp3-popover[style*="transform-origin"][style*="top"] .bp3-popover-arrow {
261
- transform: translate(0, 0.5px);
262
- }
263
- .bp3-popover[style*="transform-origin"][style*="right"] .bp3-popover-arrow {
264
- transform: translate(-0.5px, 0);
265
- }
@@ -1,16 +0,0 @@
1
- import { SubmissionError } from "redux-form";
2
-
3
- export const throwFormError = error => {
4
- if (error.message) {
5
- console.error("error:", error);
6
- }
7
- const errorToUse = error.message
8
- ? { _error: error.message }
9
- : typeof error === "string"
10
- ? { _error: error }
11
- : error;
12
- if (!errorToUse._error) {
13
- errorToUse._error = "Error Submitting Form";
14
- }
15
- throw new SubmissionError(errorToUse);
16
- };
package/src/toastr.js DELETED
@@ -1,148 +0,0 @@
1
- import { Position, Toaster, Intent, Classes } from "@blueprintjs/core";
2
- import classNames from "classnames";
3
-
4
- const TopToaster = Toaster.create({
5
- className: "top-toaster",
6
- position: Position.TOP
7
- });
8
-
9
- const BottomToaster = Toaster.create({
10
- className: "bottom-toaster",
11
- position: Position.BOTTOM
12
- });
13
-
14
- window.__tgClearAllToasts = () => {
15
- TopToaster.clear();
16
- BottomToaster.clear();
17
- };
18
-
19
- let counter = 5000;
20
- const generateToast = intent => (message, options) => {
21
- options = options || {};
22
- const toastToUse = options.bottom ? BottomToaster : TopToaster;
23
- let updatedTimeout;
24
- if (options.updateTimeout) {
25
- //generate a slightly different than default timeout to make the update stay on the page for a full 5 seconds
26
- if (counter > 5500) {
27
- updatedTimeout = --counter;
28
- } else {
29
- updatedTimeout = ++counter;
30
- }
31
- }
32
- if (intent === Intent.DANGER) {
33
- console.error("Toastr error message: ", message);
34
- }
35
- if (intent === Intent.WARNING) {
36
- console.error("Toastr warning message: ", message);
37
- }
38
-
39
- const maybeAddClearAll = () => {
40
- // wipe any existing clear all buttons
41
- const existingClearAllButtons =
42
- document.querySelectorAll(`.tg-clear-all-toasts`);
43
- existingClearAllButtons.forEach(button => {
44
- button.remove();
45
- });
46
- const activeToasts = document.querySelectorAll(
47
- `.bp3-toast:not(.bp3-toast-exit)`
48
- );
49
- if (activeToasts.length > 1) {
50
- // add custom clear all button
51
-
52
- const topToaster = document.querySelector(`.bp3-toast`);
53
- if (!topToaster) return;
54
- const closeButton = document.createElement("div");
55
- closeButton.classList.add(
56
- Classes.BUTTON,
57
- Classes.LARGE,
58
- Classes.INTENT_PRIMARY,
59
- "tg-clear-all-toasts"
60
- );
61
- closeButton.innerText = "Clear all";
62
- closeButton.onclick = window.__tgClearAllToasts;
63
- // position the button to the right of the message
64
- closeButton.style.position = "absolute";
65
- closeButton.style.right = "-100px";
66
-
67
- topToaster.appendChild(closeButton);
68
- }
69
- };
70
- const uniqKey = toastToUse.show(
71
- {
72
- intent,
73
- message,
74
- onDismiss: () => {
75
- if (options.onDismiss) {
76
- options.onDismiss();
77
- }
78
- setTimeout(() => {
79
- maybeAddClearAll();
80
- }, 0);
81
- },
82
- timeout:
83
- options.timeout ||
84
- updatedTimeout ||
85
- (!window.Cypress &&
86
- (intent === Intent.DANGER || intent === Intent.WARNING)
87
- ? 60000
88
- : undefined),
89
- action: options.action,
90
- icon: options.icon,
91
- className: classNames("preserve-newline", options.className)
92
- },
93
- options.key
94
- );
95
- setTimeout(() => {
96
- maybeAddClearAll();
97
- }, 0);
98
- function clear() {
99
- toastToUse.dismiss(uniqKey);
100
- setTimeout(() => {
101
- maybeAddClearAll();
102
- }, 0);
103
- }
104
- clear.key = uniqKey;
105
- return clear;
106
- };
107
-
108
- function preventDuplicates(func) {
109
- const previousToasts = {};
110
- return (message, options = {}) => {
111
- const clearToast = func(message, options);
112
- // no duplicate check for toasts with updates
113
-
114
- if (!options.key) {
115
- if (!options.key && previousToasts[message]) {
116
- previousToasts[message](); //clear it!
117
- }
118
-
119
- setTimeout(() => {
120
- delete previousToasts[message];
121
- }, options.timeout || 5000);
122
-
123
- previousToasts[message] = clearToast;
124
- }
125
- return clearToast;
126
- };
127
- }
128
-
129
- if (!window.toastr) window.toastr = {};
130
- if (!window.toastr.success) {
131
- window.toastr.success = preventDuplicates(generateToast(Intent.SUCCESS));
132
- }
133
-
134
- if (!window.toastr.error) {
135
- window.toastr.error = preventDuplicates(generateToast(Intent.DANGER));
136
- }
137
-
138
- if (!window.toastr.warning) {
139
- window.toastr.warning = preventDuplicates(generateToast(Intent.WARNING));
140
- }
141
-
142
- if (!window.toastr.info) {
143
- window.toastr.info = preventDuplicates(generateToast(Intent.PRIMARY));
144
- }
145
-
146
- if (!window.toastr.default) {
147
- window.toastr.default = preventDuplicates(generateToast(Intent.NONE));
148
- }
@@ -1,6 +0,0 @@
1
- export const typeToCommonType = {
2
- string: "Text",
3
- number: "Number",
4
- boolean: "True/False",
5
- dropdown: "Select One"
6
- };
package/src/useDialog.js DELETED
@@ -1,63 +0,0 @@
1
- import React, { useCallback, useState } from "react";
2
-
3
- /*
4
-
5
- const {toggleDialog, comp} = useDialog({
6
- ModalComponent: SimpleInsertData,
7
- });
8
-
9
- return <div>
10
- {comp} //stick the returned dialog comp somewhere in the dom! (it should not effect layout)
11
- {...your code here}
12
- </div>
13
-
14
- */
15
- export const useDialog = ({ ModalComponent }) => {
16
- const [isOpen, setOpen] = useState(false);
17
- const [additionalProps, setAdditionalProps] = useState(false);
18
- const Comp = useCallback(
19
- () => (
20
- <ModalComponent
21
- hideModal={() => {
22
- setOpen(false);
23
- }}
24
- hideDialog={() => {
25
- setOpen(false);
26
- }}
27
- {...additionalProps}
28
- dialogProps={{
29
- isOpen,
30
- ...additionalProps?.dialogProps
31
- }}
32
- />
33
- ),
34
- [ModalComponent, additionalProps, isOpen]
35
- );
36
-
37
- const showDialogPromise = useCallback(async (handlerName, moreProps = {}) => {
38
- return new Promise(resolve => {
39
- //return a promise that can be awaited
40
- setAdditionalProps({
41
- hideModal: () => {
42
- //override hideModal to resolve also
43
- setOpen(false);
44
- resolve({});
45
- },
46
- hideDialog: () => {
47
- //override hideModal to resolve also
48
- setOpen(false);
49
- resolve({});
50
- },
51
- [handlerName]: r => {
52
- setOpen(false);
53
- resolve(r || {});
54
- },
55
- //pass any additional props to the dialog
56
- ...moreProps
57
- });
58
- setOpen(true); //open the dialog
59
- });
60
- }, []);
61
-
62
- return { Comp, showDialogPromise };
63
- };
@@ -1,10 +0,0 @@
1
- import React from "react";
2
- import { compose } from "recompose";
3
-
4
- //adHoc allows you to add dynamic HOCs to a component
5
- export default func => WrappedComponent => props => {
6
- const calledFunc = func(props);
7
- const composeArgs = Array.isArray(calledFunc) ? calledFunc : [calledFunc];
8
- const ComposedAndWrapped = compose(...composeArgs)(WrappedComponent);
9
- return <ComposedAndWrapped {...props} />;
10
- };
@@ -1,14 +0,0 @@
1
- export default function basicHandleActionsWithFullState(
2
- handlers,
3
- defaultState
4
- ) {
5
- return (state = defaultState, action, fullState) => {
6
- const { type } = action;
7
- const handler = handlers[type];
8
- if (handler) {
9
- return handler(state, action, fullState);
10
- } else {
11
- return state;
12
- }
13
- };
14
- }
@@ -1,3 +0,0 @@
1
- export const isSafari = /^((?!chrome|android).)*safari/i.test(
2
- navigator.userAgent
3
- );
@@ -1,14 +0,0 @@
1
- export default function combineReducers(reducers = {}) {
2
- const reducerKeys = Object.keys(reducers);
3
- return function combination(state = {}, action, fullState) {
4
- let hasChanged = false;
5
- const nextState = {};
6
- fullState = fullState || state;
7
- for (let i = 0; i < reducerKeys.length; i++) {
8
- const key = reducerKeys[i];
9
- nextState[key] = reducers[key](state[key], action, fullState);
10
- hasChanged = hasChanged || nextState[key] !== state[key];
11
- }
12
- return hasChanged ? nextState : state;
13
- };
14
- }
@@ -1,82 +0,0 @@
1
- import React from "react";
2
- import { Tooltip, Checkbox, Button, Switch } from "@blueprintjs/core";
3
-
4
- export const withCommand =
5
- mappings =>
6
- WrappedComponent =>
7
- ({ cmd, cmdOptions = {}, ...props }) => {
8
- const mappedProps = {};
9
- Object.keys(mappings).forEach(k => {
10
- mappedProps[k] =
11
- mappings[k] === "execute"
12
- ? event => cmd.execute({ event })
13
- : typeof mappings[k] === "function"
14
- ? mappings[k](cmd, props)
15
- : cmd[mappings[k]];
16
- });
17
-
18
- let out = <WrappedComponent {...mappedProps} {...props} />;
19
- const tooltip =
20
- cmd.tooltip || (typeof cmd.isDisabled === "string" && cmd.isDisabled);
21
- if (tooltip && !cmdOptions.ignoreTooltip) {
22
- out = <Tooltip content={tooltip}>{out}</Tooltip>;
23
- }
24
-
25
- return cmd.isHidden && !cmdOptions.ignoreHidden ? null : out;
26
- };
27
-
28
- export const CmdCheckbox = withCommand({
29
- onChange: "execute",
30
- label: (cmd, props) =>
31
- props.name ||
32
- (props.prefix && (
33
- <React.Fragment>
34
- {props.prefix}
35
- {cmd.name}
36
- </React.Fragment>
37
- )) ||
38
- cmd.name,
39
- disabled: "isDisabled",
40
- checked: "isActive"
41
- })(Checkbox);
42
-
43
- export const CmdSwitch = withCommand({
44
- onChange: "execute",
45
- label: (cmd, props) =>
46
- props.name ||
47
- (props.prefix && (
48
- <React.Fragment>
49
- {props.prefix}
50
- {cmd.name}
51
- </React.Fragment>
52
- )) ||
53
- cmd.name,
54
- disabled: "isDisabled",
55
- checked: "isActive"
56
- })(Switch);
57
-
58
- const Div = ({ onChange, children }) => {
59
- return <div onClick={onChange}>{children}</div>;
60
- };
61
-
62
- export const CmdDiv = withCommand({
63
- onChange: "execute",
64
- children: (cmd, props) =>
65
- props.name ||
66
- (props.prefix && (
67
- <React.Fragment>
68
- {props.prefix}
69
- {cmd.name}
70
- </React.Fragment>
71
- )) ||
72
- cmd.name,
73
- disabled: "isDisabled",
74
- checked: "isActive"
75
- })(Div);
76
-
77
- export const CmdButton = withCommand({
78
- onClick: "execute",
79
- text: cmd => (cmd.isActive === false && cmd.inactiveName) || cmd.name,
80
- icon: "icon",
81
- disabled: "isDisabled"
82
- })(Button);