@teselagen/ui 0.7.32 → 0.7.33-beta.2

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 (254) hide show
  1. package/AdvancedOptions.js +33 -0
  2. package/AssignDefaultsModeContext.js +22 -0
  3. package/DataTable/utils/filterLocalEntitiesToHasura.d.ts +5 -0
  4. package/DataTable/utils/initializeHasuraWhereAndFilter.d.ts +2 -0
  5. package/DataTable/utils/queryParams.d.ts +8 -12
  6. package/DataTable/utils/simplifyHasuraWhere.d.ts +1 -0
  7. package/DataTable/utils/tableQueryParamsToHasuraClauses.d.ts +14 -0
  8. package/DropdownButton.js +36 -0
  9. package/FillWindow.css +6 -0
  10. package/FillWindow.js +69 -0
  11. package/{src/DataTable/FilterAndSortMenu.js → FilterAndSortMenu.js} +27 -30
  12. package/MatchHeaders.js +234 -0
  13. package/SimpleStepViz.js +22 -0
  14. package/Tag.js +112 -0
  15. package/UploadCsvWizard.css +4 -0
  16. package/UploadCsvWizard.js +719 -0
  17. package/autoTooltip.js +201 -0
  18. package/constants.js +1 -0
  19. package/customIcons.js +361 -0
  20. package/filterLocalEntitiesToHasura.js +216 -0
  21. package/index.cjs.js +695 -967
  22. package/index.d.ts +1 -0
  23. package/index.es.js +695 -967
  24. package/initializeHasuraWhereAndFilter.js +27 -0
  25. package/{src/utils/isBeingCalledExcessively.js → isBeingCalledExcessively.js} +0 -1
  26. package/package.json +1 -1
  27. package/queryParams.js +336 -0
  28. package/rerenderOnWindowResize.js +26 -0
  29. package/showAppSpinner.js +12 -0
  30. package/showDialogOnDocBody.js +33 -0
  31. package/simplifyHasuraWhere.js +80 -0
  32. package/src/CellDragHandle.js +132 -0
  33. package/src/ColumnFilterMenu.js +62 -0
  34. package/src/Columns.js +979 -0
  35. package/src/DisabledLoadingComponent.js +15 -0
  36. package/src/DisplayOptions.js +199 -0
  37. package/src/DropdownCell.js +61 -0
  38. package/src/EditableCell.js +44 -0
  39. package/src/FilterAndSortMenu.js +388 -0
  40. package/src/FormSeparator.js +9 -0
  41. package/src/LoadingDots.js +14 -0
  42. package/src/PagingTool.js +225 -0
  43. package/src/RenderCell.js +191 -0
  44. package/src/SearchBar.js +69 -0
  45. package/src/SortableColumns.js +100 -0
  46. package/src/TableFormTrackerContext.js +10 -0
  47. package/src/ThComponent.js +44 -0
  48. package/src/TimelineEvent.js +31 -0
  49. package/src/Uploader.js +1278 -0
  50. package/src/adHoc.js +10 -0
  51. package/src/basicHandleActionsWithFullState.js +14 -0
  52. package/src/browserUtils.js +3 -0
  53. package/src/combineReducersWithFullState.js +14 -0
  54. package/src/commandControls.js +82 -0
  55. package/src/commandUtils.js +112 -0
  56. package/src/convertSchema.js +69 -0
  57. package/src/dataTableEnhancer.js +41 -0
  58. package/src/defaultFormatters.js +32 -0
  59. package/src/defaultValidators.js +40 -0
  60. package/src/determineBlackOrWhiteTextColor.js +4 -0
  61. package/src/editCellHelper.js +44 -0
  62. package/src/filterLocalEntitiesToHasura.js +216 -0
  63. package/src/formatPasteData.js +16 -0
  64. package/src/getAllRows.js +11 -0
  65. package/src/getCellCopyText.js +7 -0
  66. package/src/getCellInfo.js +36 -0
  67. package/src/getCellVal.js +20 -0
  68. package/src/getDayjsFormatter.js +35 -0
  69. package/src/getFieldPathToField.js +7 -0
  70. package/src/getIdOrCodeOrIndex.js +9 -0
  71. package/src/getLastSelectedEntity.js +11 -0
  72. package/src/getNewEntToSelect.js +25 -0
  73. package/src/getNewName.js +31 -0
  74. package/src/getRowCopyText.js +28 -0
  75. package/src/getTableConfigFromStorage.js +5 -0
  76. package/src/getTextFromEl.js +28 -0
  77. package/src/getVals.js +8 -0
  78. package/src/handleCopyColumn.js +21 -0
  79. package/src/handleCopyHelper.js +15 -0
  80. package/src/handleCopyRows.js +23 -0
  81. package/src/handleCopyTable.js +16 -0
  82. package/src/handlerHelpers.js +24 -0
  83. package/src/hotkeyUtils.js +131 -0
  84. package/src/index.js +1 -87
  85. package/src/initializeHasuraWhereAndFilter.js +27 -0
  86. package/src/isBeingCalledExcessively.js +24 -0
  87. package/src/isBottomRightCornerOfRectangle.js +20 -0
  88. package/src/isEntityClean.js +15 -0
  89. package/src/isTruthy.js +12 -0
  90. package/src/isValueEmpty.js +3 -0
  91. package/src/itemUpload.js +84 -0
  92. package/src/menuUtils.js +433 -0
  93. package/src/popoverOverflowModifiers.js +11 -0
  94. package/src/primarySelectedValue.js +1 -0
  95. package/src/pureNoFunc.js +31 -0
  96. package/src/queryParams.js +336 -0
  97. package/src/removeCleanRows.js +22 -0
  98. package/src/renderOnDoc.js +32 -0
  99. package/src/rowClick.js +181 -0
  100. package/src/selection.js +8 -0
  101. package/src/showProgressToast.js +22 -0
  102. package/src/simplifyHasuraWhere.js +80 -0
  103. package/src/sortify.js +73 -0
  104. package/src/style.css +24 -260
  105. package/src/tableQueryParamsToHasuraClauses.js +113 -0
  106. package/src/{DataTable/utils/withTableParams.js → withTableParams.js} +1 -14
  107. package/tableQueryParamsToHasuraClauses.js +113 -0
  108. package/tagUtils.js +45 -0
  109. package/tgFormValues.js +35 -0
  110. package/tg_modalState.js +47 -0
  111. package/throwFormError.js +16 -0
  112. package/toastr.js +148 -0
  113. package/tryToMatchSchemas.js +264 -0
  114. package/typeToCommonType.js +6 -0
  115. package/useDeepEqualMemo.js +15 -0
  116. package/useDialog.js +63 -0
  117. package/useStableReference.js +9 -0
  118. package/useTableEntities.js +38 -0
  119. package/useTraceUpdate.js +19 -0
  120. package/utils.js +37 -0
  121. package/validateTableWideErrors.js +160 -0
  122. package/viewColumn.js +97 -0
  123. package/withField.js +20 -0
  124. package/withFields.js +11 -0
  125. package/withLocalStorage.js +11 -0
  126. package/withSelectTableRecords.js +43 -0
  127. package/withSelectedEntities.js +65 -0
  128. package/withStore.js +10 -0
  129. package/withTableParams.js +288 -0
  130. package/wrapDialog.js +116 -0
  131. package/src/AdvancedOptions.spec.js +0 -26
  132. package/src/AsyncValidateFieldSpinner/index.js +0 -12
  133. package/src/BlueprintError/index.js +0 -14
  134. package/src/BounceLoader/index.js +0 -16
  135. package/src/BounceLoader/style.css +0 -45
  136. package/src/CollapsibleCard/index.js +0 -68
  137. package/src/CollapsibleCard/style.css +0 -23
  138. package/src/DNALoader/index.js +0 -20
  139. package/src/DNALoader/style.css +0 -251
  140. package/src/DataTable/index.js +0 -3213
  141. package/src/DataTable/style.css +0 -608
  142. package/src/DataTable/utils/index.js +0 -55
  143. package/src/DataTable/utils/queryParams.js +0 -1058
  144. package/src/DialogFooter/index.js +0 -86
  145. package/src/DialogFooter/style.css +0 -9
  146. package/src/FormComponents/index.js +0 -1266
  147. package/src/FormComponents/style.css +0 -275
  148. package/src/FormComponents/utils.js +0 -6
  149. package/src/HotkeysDialog/index.js +0 -79
  150. package/src/HotkeysDialog/style.css +0 -54
  151. package/src/InfoHelper/index.js +0 -78
  152. package/src/InfoHelper/style.css +0 -7
  153. package/src/IntentText/index.js +0 -18
  154. package/src/Loading/index.js +0 -70
  155. package/src/Loading/style.css +0 -4
  156. package/src/MenuBar/index.js +0 -423
  157. package/src/MenuBar/style.css +0 -45
  158. package/src/PromptUnsavedChanges/index.js +0 -38
  159. package/src/ResizableDraggableDialog/index.js +0 -141
  160. package/src/ResizableDraggableDialog/style.css +0 -42
  161. package/src/ScrollToTop/index.js +0 -72
  162. package/src/TagSelect/index.js +0 -69
  163. package/src/TagSelect/style.css +0 -13
  164. package/src/TgHtmlSelect/index.js +0 -20
  165. package/src/TgSelect/index.js +0 -537
  166. package/src/TgSelect/style.css +0 -61
  167. package/src/TgSuggest/index.js +0 -124
  168. package/src/Timeline/index.js +0 -15
  169. package/src/enhancers/withDialog/index.js +0 -196
  170. package/src/showConfirmationDialog/index.js +0 -148
  171. /package/{src/DataTable/CellDragHandle.js → CellDragHandle.js} +0 -0
  172. /package/{src/DataTable/ColumnFilterMenu.js → ColumnFilterMenu.js} +0 -0
  173. /package/{src/DataTable/Columns.js → Columns.js} +0 -0
  174. /package/{src/DataTable/DisabledLoadingComponent.js → DisabledLoadingComponent.js} +0 -0
  175. /package/{src/DataTable/DisplayOptions.js → DisplayOptions.js} +0 -0
  176. /package/{src/DataTable/DropdownCell.js → DropdownCell.js} +0 -0
  177. /package/{src/DataTable/EditableCell.js → EditableCell.js} +0 -0
  178. /package/{src/FormComponents/FormSeparator.js → FormSeparator.js} +0 -0
  179. /package/{src/FormComponents/LoadingDots.js → LoadingDots.js} +0 -0
  180. /package/{src/DataTable/PagingTool.js → PagingTool.js} +0 -0
  181. /package/{src/DataTable/RenderCell.js → RenderCell.js} +0 -0
  182. /package/{src/DataTable/SearchBar.js → SearchBar.js} +0 -0
  183. /package/{src/DataTable/SortableColumns.js → SortableColumns.js} +0 -0
  184. /package/{src/DataTable/TableFormTrackerContext.js → TableFormTrackerContext.js} +0 -0
  185. /package/{src/DataTable/ThComponent.js → ThComponent.js} +0 -0
  186. /package/{src/Timeline/TimelineEvent.js → TimelineEvent.js} +0 -0
  187. /package/{src/FormComponents/Uploader.js → Uploader.js} +0 -0
  188. /package/{src/utils/adHoc.js → adHoc.js} +0 -0
  189. /package/{src/utils/basicHandleActionsWithFullState.js → basicHandleActionsWithFullState.js} +0 -0
  190. /package/{src/utils/browserUtils.js → browserUtils.js} +0 -0
  191. /package/{src/utils/combineReducersWithFullState.js → combineReducersWithFullState.js} +0 -0
  192. /package/{src/utils/commandControls.js → commandControls.js} +0 -0
  193. /package/{src/utils/commandUtils.js → commandUtils.js} +0 -0
  194. /package/{src/DataTable/utils/convertSchema.js → convertSchema.js} +0 -0
  195. /package/{src/DataTable/dataTableEnhancer.js → dataTableEnhancer.js} +0 -0
  196. /package/{src/DataTable/defaultFormatters.js → defaultFormatters.js} +0 -0
  197. /package/{src/DataTable/defaultValidators.js → defaultValidators.js} +0 -0
  198. /package/{src/utils/determineBlackOrWhiteTextColor.js → determineBlackOrWhiteTextColor.js} +0 -0
  199. /package/{src/DataTable/editCellHelper.js → editCellHelper.js} +0 -0
  200. /package/{src/DataTable/utils/formatPasteData.js → formatPasteData.js} +0 -0
  201. /package/{src/DataTable/utils/getAllRows.js → getAllRows.js} +0 -0
  202. /package/{src/DataTable/utils/getCellCopyText.js → getCellCopyText.js} +0 -0
  203. /package/{src/DataTable/utils/getCellInfo.js → getCellInfo.js} +0 -0
  204. /package/{src/DataTable/getCellVal.js → getCellVal.js} +0 -0
  205. /package/{src/utils/getDayjsFormatter.js → getDayjsFormatter.js} +0 -0
  206. /package/{src/DataTable/utils/getFieldPathToField.js → getFieldPathToField.js} +0 -0
  207. /package/{src/DataTable/utils/getIdOrCodeOrIndex.js → getIdOrCodeOrIndex.js} +0 -0
  208. /package/{src/DataTable/utils/getLastSelectedEntity.js → getLastSelectedEntity.js} +0 -0
  209. /package/{src/DataTable/utils/getNewEntToSelect.js → getNewEntToSelect.js} +0 -0
  210. /package/{src/FormComponents/getNewName.js → getNewName.js} +0 -0
  211. /package/{src/DataTable/utils/getRowCopyText.js → getRowCopyText.js} +0 -0
  212. /package/{src/DataTable/utils/getTableConfigFromStorage.js → getTableConfigFromStorage.js} +0 -0
  213. /package/{src/utils/getTextFromEl.js → getTextFromEl.js} +0 -0
  214. /package/{src/DataTable/getVals.js → getVals.js} +0 -0
  215. /package/{src/DataTable/utils/handleCopyColumn.js → handleCopyColumn.js} +0 -0
  216. /package/{src/DataTable/utils/handleCopyHelper.js → handleCopyHelper.js} +0 -0
  217. /package/{src/DataTable/utils/handleCopyRows.js → handleCopyRows.js} +0 -0
  218. /package/{src/DataTable/utils/handleCopyTable.js → handleCopyTable.js} +0 -0
  219. /package/{src/utils/handlerHelpers.js → handlerHelpers.js} +0 -0
  220. /package/{src/utils/hotkeyUtils.js → hotkeyUtils.js} +0 -0
  221. /package/{src/utils/hooks/index.js → index.js} +0 -0
  222. /package/{src/DataTable/utils/isBottomRightCornerOfRectangle.js → isBottomRightCornerOfRectangle.js} +0 -0
  223. /package/{src/DataTable/utils/isEntityClean.js → isEntityClean.js} +0 -0
  224. /package/{src/DataTable/isTruthy.js → isTruthy.js} +0 -0
  225. /package/{src/DataTable/isValueEmpty.js → isValueEmpty.js} +0 -0
  226. /package/{src/FormComponents/itemUpload.js → itemUpload.js} +0 -0
  227. /package/{src/utils/menuUtils.js → menuUtils.js} +0 -0
  228. /package/{src/utils/popoverOverflowModifiers.js → popoverOverflowModifiers.js} +0 -0
  229. /package/{src/DataTable/utils/primarySelectedValue.js → primarySelectedValue.js} +0 -0
  230. /package/{src/utils/pureNoFunc.js → pureNoFunc.js} +0 -0
  231. /package/{src/DataTable/utils/removeCleanRows.js → removeCleanRows.js} +0 -0
  232. /package/{src/utils/renderOnDoc.js → renderOnDoc.js} +0 -0
  233. /package/{src/DataTable/utils/rowClick.js → rowClick.js} +0 -0
  234. /package/{src/DataTable/utils/selection.js → selection.js} +0 -0
  235. /package/{src/utils/showProgressToast.js → showProgressToast.js} +0 -0
  236. /package/{src/FormComponents/sortify.js → sortify.js} +0 -0
  237. /package/src/{utils/tagUtils.js → tagUtils.js} +0 -0
  238. /package/src/{utils/tgFormValues.js → tgFormValues.js} +0 -0
  239. /package/src/{enhancers/withDialog/tg_modalState.js → tg_modalState.js} +0 -0
  240. /package/src/{FormComponents/tryToMatchSchemas.js → tryToMatchSchemas.js} +0 -0
  241. /package/src/{utils/hooks/useDeepEqualMemo.js → useDeepEqualMemo.js} +0 -0
  242. /package/src/{utils/hooks/useStableReference.js → useStableReference.js} +0 -0
  243. /package/src/{DataTable/utils/useTableEntities.js → useTableEntities.js} +0 -0
  244. /package/src/{utils/useTraceUpdate.js → useTraceUpdate.js} +0 -0
  245. /package/src/{DataTable/utils/utils.js → utils.js} +0 -0
  246. /package/src/{DataTable/validateTableWideErrors.js → validateTableWideErrors.js} +0 -0
  247. /package/src/{DataTable/viewColumn.js → viewColumn.js} +0 -0
  248. /package/src/{enhancers/withField.js → withField.js} +0 -0
  249. /package/src/{enhancers/withFields.js → withFields.js} +0 -0
  250. /package/src/{enhancers/withLocalStorage.js → withLocalStorage.js} +0 -0
  251. /package/src/{utils/withSelectTableRecords.js → withSelectTableRecords.js} +0 -0
  252. /package/src/{DataTable/utils/withSelectedEntities.js → withSelectedEntities.js} +0 -0
  253. /package/src/{utils/withStore.js → withStore.js} +0 -0
  254. /package/{src/Timeline/style.css → style.css} +0 -0
@@ -0,0 +1,288 @@
1
+ import React, { useCallback, useMemo } from "react";
2
+ import { change as _change, formValueSelector } from "redux-form";
3
+ import { useDispatch, useSelector } from "react-redux";
4
+ import convertSchema from "./convertSchema";
5
+ import {
6
+ makeDataTableHandlers,
7
+ getQueryParams,
8
+ setCurrentParamsOnUrl,
9
+ getCurrentParamsFromUrl,
10
+ getCCDisplayName
11
+ } from "./queryParams";
12
+ import { withRouter } from "react-router-dom";
13
+ import getTableConfigFromStorage from "./getTableConfigFromStorage";
14
+ import { useDeepEqualMemo } from "../../utils/hooks/useDeepEqualMemo";
15
+ import { branch, compose } from "recompose";
16
+
17
+ /**
18
+ * Note all these options can be passed at Design Time or at Runtime (like reduxForm())
19
+ *
20
+ * @export
21
+ *
22
+ * @param {compOrOpts} compOrOpts
23
+ * @typedef {object} compOrOpts
24
+ * @property {*string} formName - required unique identifier for the table
25
+ * @property {Object | Function} schema - The data table schema or a function returning it. The function wll be called with props as the argument.
26
+ * @property {boolean} urlConnected - whether the table should connect to/update the URL
27
+ * @property {boolean} withSelectedEntities - whether or not to pass the selected entities
28
+ * @property {boolean} isCodeModel - whether the model is keyed by code instead of id in the db
29
+ * @property {object} defaults - tableParam defaults such as pageSize, filter, etc
30
+ * @property {boolean} noOrderError - won't console an error if an order is not found on schema
31
+ */
32
+ export const useTableParams = props => {
33
+ const {
34
+ additionalFilter,
35
+ controlled_pageSize,
36
+ defaults: _defaults,
37
+ doNotCoercePageSize,
38
+ entities,
39
+ formName = "tgDataTable",
40
+ history,
41
+ initialValues,
42
+ isCodeModel,
43
+ isInfinite,
44
+ isLocalCall = false,
45
+ isSimple,
46
+ noForm,
47
+ noOrderError,
48
+ onlyOneFilter,
49
+ orderByFirstColumn,
50
+ pageSize,
51
+ schema,
52
+ syncDisplayOptionsToDb,
53
+ tableParams: _tableParams,
54
+ urlConnected,
55
+ withDisplayOptions,
56
+ withPaging,
57
+ withSelectedEntities
58
+ } = props;
59
+
60
+ const defaults = useMemo(
61
+ () => ({
62
+ pageSize: controlled_pageSize || 25,
63
+ order: [], //[-name, statusCode] //an array of camelCase display names with - sign to denote reverse
64
+ searchTerm: "",
65
+ page: 1,
66
+ filters: [
67
+ //filters look like this:
68
+ // {
69
+ // selectedFilter: 'textContains', //camel case
70
+ // filterOn: ccDisplayName, //camel case display name if available and string, otherwise path
71
+ // filterValue: 'thomas',
72
+ // }
73
+ ],
74
+ ..._defaults
75
+ }),
76
+ [_defaults, controlled_pageSize]
77
+ );
78
+
79
+ const convertedSchema = useMemo(() => convertSchema(schema), [schema]);
80
+
81
+ if (isLocalCall) {
82
+ if (!noForm && (!formName || formName === "tgDataTable")) {
83
+ console.error(
84
+ "Please pass a unique 'formName' prop to the locally connected <DataTable/> component with schema: ",
85
+ schema
86
+ );
87
+ }
88
+ if (orderByFirstColumn && !defaults?.order?.length) {
89
+ defaults.order = [getCCDisplayName(convertedSchema.fields[0])];
90
+ }
91
+ } else {
92
+ //in user instantiated withTableParams() call
93
+ if (!formName || formName === "tgDataTable") {
94
+ console.error(
95
+ "Please pass a unique 'formName' prop to the withTableParams() with schema: ",
96
+ schema
97
+ );
98
+ }
99
+ }
100
+
101
+ const {
102
+ reduxFormQueryParams: _reduxFormQueryParams = {},
103
+ reduxFormSelectedEntityIdMap: _reduxFormSelectedEntityIdMap = {}
104
+ } = useSelector(state =>
105
+ formValueSelector(formName)(
106
+ state,
107
+ "reduxFormQueryParams",
108
+ "reduxFormSelectedEntityIdMap"
109
+ )
110
+ );
111
+
112
+ // We want to make sure we don't rerender everything unnecessary
113
+ // with redux-forms we tend to do unnecessary renders
114
+ const reduxFormQueryParams = useDeepEqualMemo(_reduxFormQueryParams);
115
+ const reduxFormSelectedEntityIdMap = useDeepEqualMemo(
116
+ _reduxFormSelectedEntityIdMap
117
+ );
118
+
119
+ const _currentParams = useMemo(() => {
120
+ const tmp =
121
+ (urlConnected
122
+ ? getCurrentParamsFromUrl(history?.location) //important to use history location and not ownProps.location because for some reason the location path lags one render behind!!
123
+ : reduxFormQueryParams) || {};
124
+
125
+ return tmp;
126
+ }, [history?.location, reduxFormQueryParams, urlConnected]);
127
+
128
+ const selectedEntities = useMemo(
129
+ () =>
130
+ withSelectedEntities
131
+ ? Object.values(reduxFormSelectedEntityIdMap)
132
+ .sort((a, b) => a.rowIndex - b.rowIndex)
133
+ .map(item => item.entity)
134
+ : undefined,
135
+ [reduxFormSelectedEntityIdMap, withSelectedEntities]
136
+ );
137
+
138
+ const currentParams = useDeepEqualMemo(_currentParams);
139
+
140
+ const defaultsToUse = useMemo(() => {
141
+ const _tableConfig = getTableConfigFromStorage(formName);
142
+ const userSetPageSize =
143
+ _tableConfig?.userSetPageSize &&
144
+ parseInt(_tableConfig.userSetPageSize, 10);
145
+ let _defaultsToUse = defaults;
146
+ if (!syncDisplayOptionsToDb && userSetPageSize) {
147
+ _defaultsToUse = _defaultsToUse || {};
148
+ _defaultsToUse.pageSize = userSetPageSize;
149
+ }
150
+
151
+ return _defaultsToUse;
152
+ }, [defaults, formName, syncDisplayOptionsToDb]);
153
+
154
+ const passingProps = useMemo(
155
+ () => ({
156
+ formName: "tgDataTable",
157
+ ...props,
158
+ pageSize: controlled_pageSize || pageSize,
159
+ defaults: defaultsToUse,
160
+ location: history?.location
161
+ }),
162
+ // We don't want to rerender this every time a prop changes
163
+ // eslint-disable-next-line react-hooks/exhaustive-deps
164
+ [controlled_pageSize, defaultsToUse, pageSize, history?.location]
165
+ );
166
+
167
+ const queryParams = useMemo(() => {
168
+ return getQueryParams({
169
+ doNotCoercePageSize,
170
+ currentParams,
171
+ entities, // for local table
172
+ urlConnected,
173
+ defaults: defaultsToUse,
174
+ schema: convertedSchema,
175
+ isInfinite: isInfinite || (isSimple && !withPaging),
176
+ isLocalCall,
177
+ additionalFilter,
178
+ noOrderError,
179
+ isCodeModel,
180
+ ownProps: passingProps
181
+ });
182
+ }, [
183
+ additionalFilter,
184
+ passingProps,
185
+ doNotCoercePageSize,
186
+ currentParams,
187
+ entities,
188
+ urlConnected,
189
+ defaultsToUse,
190
+ convertedSchema,
191
+ isInfinite,
192
+ isSimple,
193
+ withPaging,
194
+ isLocalCall,
195
+ noOrderError,
196
+ isCodeModel
197
+ ]);
198
+
199
+ const dispatch = useDispatch();
200
+ const change = useCallback(
201
+ (...args) => dispatch(_change(formName, ...args)),
202
+ [dispatch, formName]
203
+ );
204
+
205
+ const setNewParams = useCallback(
206
+ newParams => {
207
+ // we always will update the redux params as a workaround for withRouter not always working
208
+ // if inside a redux-connected container https://github.com/ReactTraining/react-router/issues/5037
209
+ change("reduxFormQueryParams", prev => {
210
+ let tmp = newParams;
211
+ if (typeof tmp === "function") tmp = newParams(prev);
212
+ urlConnected && setCurrentParamsOnUrl(tmp, history?.replace);
213
+ return tmp;
214
+ });
215
+ },
216
+ [change, history?.replace, urlConnected]
217
+ );
218
+
219
+ const dispatchProps = useMemo(
220
+ () =>
221
+ makeDataTableHandlers({
222
+ setNewParams,
223
+ defaults,
224
+ onlyOneFilter
225
+ }),
226
+ [defaults, onlyOneFilter, setNewParams]
227
+ );
228
+
229
+ const tableParams = useMemo(
230
+ () => ({
231
+ changeFormValue: (...args) => change(...args),
232
+ selectedEntities,
233
+ ..._tableParams,
234
+ formName,
235
+ initialValues,
236
+ isLocalCall,
237
+ schema,
238
+ currentParams,
239
+ withDisplayOptions,
240
+ ...queryParams,
241
+ ...dispatchProps,
242
+ form: formName, //this will override the default redux form name
243
+ isTableParamsConnected: true //let the table know not to do local sorting/filtering etc.
244
+ }),
245
+ [
246
+ _tableParams,
247
+ change,
248
+ currentParams,
249
+ dispatchProps,
250
+ formName,
251
+ initialValues,
252
+ isLocalCall,
253
+ queryParams,
254
+ schema,
255
+ selectedEntities,
256
+ withDisplayOptions
257
+ ]
258
+ );
259
+
260
+ return {
261
+ isLocalCall,
262
+ schema,
263
+ ...queryParams,
264
+ ...(withSelectedEntities &&
265
+ typeof withSelectedEntities === "string" && {
266
+ [withSelectedEntities]: selectedEntities
267
+ }),
268
+ currentParams,
269
+ selectedEntities,
270
+ tableParams,
271
+ urlConnected
272
+ };
273
+ };
274
+
275
+ const withTableParams = topLevelOptions =>
276
+ compose(
277
+ //don't use withRouter if noRouter is passed!
278
+ branch(({ noRouter }) => !noRouter, withRouter),
279
+ Comp => props => {
280
+ const tableParams = useTableParams({
281
+ ...topLevelOptions,
282
+ ...props
283
+ });
284
+ return <Comp {...props} {...tableParams} />;
285
+ }
286
+ );
287
+
288
+ export default withTableParams;
package/wrapDialog.js ADDED
@@ -0,0 +1,116 @@
1
+ /* Copyright (C) 2018 TeselaGen Biotechnology, Inc. */
2
+ import React, { useMemo, useRef } from "react";
3
+ import { Dialog, useHotkeys } from "@blueprintjs/core";
4
+ import { noop, isFunction } from "lodash-es";
5
+ import { ResizableDraggableDialog } from ".";
6
+
7
+ export default (topLevelDialogProps = {}) =>
8
+ Component =>
9
+ props => {
10
+ const r = useRef();
11
+ const memoedHotkeys = useMemo(
12
+ () => [
13
+ {
14
+ combo: topLevelDialogProps.useCmdEnter ? "cmd+enter" : "enter",
15
+ global: true,
16
+ allowInInput: true,
17
+ onKeyDown: () => {
18
+ function doNotTriggerClick() {
19
+ //leave this here for debugging purposes
20
+ // console.log(`Not triggering dialog submit`);
21
+ }
22
+
23
+ try {
24
+ if (!document.activeElement) return doNotTriggerClick();
25
+ if (
26
+ !document.activeElement.closest(".tg-allow-dialog-form-enter")
27
+ ) {
28
+ //don't do this if you're in any type of bp multi select by default
29
+ if (document.activeElement.closest(".bp3-multi-select"))
30
+ return doNotTriggerClick();
31
+ //don't do this if there is an explicit class saying not to
32
+ if (
33
+ document.activeElement.closest(".tg-stop-dialog-form-enter")
34
+ )
35
+ return doNotTriggerClick();
36
+ //don't do this in text areas
37
+ if (document.activeElement.type === "textarea")
38
+ return doNotTriggerClick();
39
+ }
40
+ const parentEl = r.current?.closest(".bp3-dialog-container");
41
+ // eslint-disable-next-line no-inner-declarations
42
+ function triggerClick() {
43
+ parentEl?.querySelector(`button[type='submit']`).click();
44
+ }
45
+
46
+ const dialogs = document.querySelectorAll(
47
+ ".bp3-dialog-container"
48
+ );
49
+ const numDialogs = dialogs?.length;
50
+
51
+ if (numDialogs > 1) {
52
+ const topMostDialog = dialogs[numDialogs - 1];
53
+ if (topMostDialog === parentEl) {
54
+ triggerClick();
55
+ }
56
+ } else {
57
+ //just 1 dialog
58
+ triggerClick();
59
+ }
60
+ } catch (error) {
61
+ console.error(`error:`, error);
62
+ }
63
+ }
64
+ }
65
+ ],
66
+ []
67
+ );
68
+
69
+ useHotkeys(memoedHotkeys);
70
+
71
+ let otherTopLevelProps,
72
+ getDialogProps = noop;
73
+ if (isFunction(topLevelDialogProps)) {
74
+ getDialogProps = topLevelDialogProps;
75
+ } else {
76
+ const {
77
+ footerProps,
78
+ getDialogProps: _pullOff,
79
+ ...additionalProps
80
+ } = topLevelDialogProps;
81
+ otherTopLevelProps = additionalProps;
82
+ getDialogProps = topLevelDialogProps.getDialogProps || noop;
83
+ }
84
+ const { dialogProps, hideModal, ...otherProps } = props;
85
+
86
+ const extraDialogProps = {
87
+ ...otherTopLevelProps,
88
+ ...dialogProps,
89
+ ...getDialogProps(props)
90
+ };
91
+ const DialogToUse = extraDialogProps.isDraggable
92
+ ? ResizableDraggableDialog
93
+ : Dialog;
94
+ return (
95
+ <DialogToUse
96
+ canOutsideClickClose={false}
97
+ isOpen
98
+ onClose={e => {
99
+ e.stopPropagation();
100
+ if (
101
+ e.key === "Escape" &&
102
+ extraDialogProps.canEscapeKeyClose === false
103
+ ) {
104
+ return;
105
+ }
106
+ hideModal(e);
107
+ }}
108
+ {...extraDialogProps}
109
+ canEscapeKeyClose={true}
110
+ style={{ ...extraDialogProps.style }}
111
+ >
112
+ <div ref={r}></div>
113
+ <Component hideModal={hideModal} {...otherProps} />
114
+ </DialogToUse>
115
+ );
116
+ };
@@ -1,26 +0,0 @@
1
- import React from "react";
2
- import { render, fireEvent } from "@testing-library/react";
3
- import AdvancedOptions from "./AdvancedOptions";
4
-
5
- describe("AdvancedOptions", () => {
6
- test("renders correctly with given props and default state", () => {
7
- const { queryByText, container } = render(
8
- <AdvancedOptions label="Test Label" content="Test Content" />
9
- );
10
- expect(queryByText("Test Label")).toBeInTheDocument();
11
- expect(queryByText("Test Content")).not.toBeInTheDocument();
12
-
13
- expect(
14
- container.querySelector(".bp3-icon-caret-right")
15
- ).toBeInTheDocument();
16
- });
17
-
18
- test("toggles content when clicked", () => {
19
- const { getByText, queryByText, container } = render(
20
- <AdvancedOptions label="Test Label" content="Test Content" />
21
- );
22
- fireEvent.click(getByText("Test Label"));
23
- expect(queryByText("Test Content")).toBeInTheDocument();
24
- expect(container.querySelector(".bp3-icon-caret-down")).toBeInTheDocument();
25
- });
26
- });
@@ -1,12 +0,0 @@
1
- /* Copyright (C) 2018 TeselaGen Biotechnology, Inc. */
2
-
3
- import React from "react";
4
- import { Spinner } from "@blueprintjs/core";
5
-
6
- export default function AsyncValidateFieldSpinner({ validating }) {
7
- if (validating) {
8
- return <Spinner size="18" />;
9
- } else {
10
- return null;
11
- }
12
- }
@@ -1,14 +0,0 @@
1
- import React from "react";
2
- import { Classes } from "@blueprintjs/core";
3
- import classNames from "classnames";
4
-
5
- export default function BlueprintError({ error }) {
6
- if (!error) return null;
7
- return (
8
- <div className={classNames(Classes.FORM_GROUP, Classes.INTENT_DANGER)}>
9
- <div className={classNames(Classes.FORM_HELPER_TEXT, "preserve-newline")}>
10
- {error}
11
- </div>
12
- </div>
13
- );
14
- }
@@ -1,16 +0,0 @@
1
- /* taken from http://tobiasahlin.com/spinkit/ */
2
- import React from "react";
3
- import classNames from "classnames";
4
- import "./style.css";
5
-
6
- export function BounceLoader({ style, className }) {
7
- return (
8
- <div className={classNames("tg-bounce-loader", className)} style={style}>
9
- <div className="rect1" />
10
- <div className="rect2" />
11
- <div className="rect3" />
12
- <div className="rect4" />
13
- <div className="rect5" />
14
- </div>
15
- );
16
- }
@@ -1,45 +0,0 @@
1
- .tg-bounce-loader {
2
- width: 50px;
3
- height: 40px;
4
- text-align: center;
5
- font-size: 10px;
6
- display: flex;
7
- align-items: center;
8
- }
9
-
10
- .tg-bounce-loader > div {
11
- background-color: #006cab;
12
- height: 100%;
13
- max-height: 30px;
14
- width: 6px;
15
- display: inline-block;
16
- margin-right: 3px;
17
- animation: sk-stretchdelay 1.2s infinite ease-in-out;
18
- }
19
-
20
- .tg-bounce-loader .rect2 {
21
- animation-delay: -1.1s;
22
- }
23
-
24
- .tg-bounce-loader .rect3 {
25
- animation-delay: -1s;
26
- }
27
-
28
- .tg-bounce-loader .rect4 {
29
- animation-delay: -0.9s;
30
- }
31
-
32
- .tg-bounce-loader .rect5 {
33
- animation-delay: -0.8s;
34
- }
35
-
36
- @keyframes sk-stretchdelay {
37
- 0%,
38
- 40%,
39
- 100% {
40
- transform: scaleY(0.4);
41
- }
42
- 20% {
43
- transform: scaleY(1);
44
- }
45
- }
@@ -1,68 +0,0 @@
1
- import React, { useState } from "react";
2
- import { Button, Classes, Icon } from "@blueprintjs/core";
3
- import classNames from "classnames";
4
- import "./style.css";
5
-
6
- export default function CollapsibleCard({
7
- title,
8
- icon,
9
- openTitleElements,
10
- noCard = false,
11
- className,
12
- style,
13
- children,
14
- initialClosed = false,
15
- toggle,
16
- isOpen
17
- }) {
18
- let [open, setOpen] = useState(!initialClosed);
19
- if (isOpen !== undefined) open = isOpen;
20
-
21
- const toggleCardInfo = () => {
22
- if (toggle) toggle();
23
- else {
24
- setOpen(!open);
25
- }
26
- };
27
-
28
- return (
29
- <div
30
- className={classNames({ "tg-card": !noCard, open }, className)}
31
- style={{
32
- paddingTop: 10,
33
- paddingBottom: 10,
34
- paddingLeft: 15,
35
- paddingRight: 15,
36
- ...style
37
- }}
38
- >
39
- <div className="tg-card-header" style={{ marginBottom: 8 }}>
40
- <div className="tg-card-header-title">
41
- {icon && <Icon icon={icon} />}
42
- <h6
43
- style={{
44
- marginBottom: 0,
45
- marginRight: 10,
46
- marginLeft: 10
47
- }}
48
- >
49
- {title}
50
- </h6>
51
- <div>{open && openTitleElements}</div>
52
- </div>
53
- <div>
54
- <Button
55
- icon={open ? "minimize" : "maximize"}
56
- className={classNames(
57
- Classes.MINIMAL,
58
- "info-btn",
59
- "tg-collapse-toggle"
60
- )}
61
- onClick={toggleCardInfo}
62
- />
63
- </div>
64
- </div>
65
- {open && children}
66
- </div>
67
- );
68
- }
@@ -1,23 +0,0 @@
1
- /* Use in the place of .bp3-card */
2
- .tg-card {
3
- padding: 20px;
4
- margin-bottom: 20px;
5
- border-radius: 5px;
6
- background: white;
7
- box-shadow:
8
- 0 1px 3px rgba(0, 0, 0, 0.12),
9
- 0 1px 2px rgba(0, 0, 0, 0.18);
10
- }
11
-
12
- .tg-card-header {
13
- display: flex;
14
- flex-direction: row;
15
- justify-content: space-between;
16
- align-items: center;
17
- }
18
-
19
- .tg-card-header-title {
20
- display: flex;
21
- flex-direction: row;
22
- align-items: center;
23
- }
@@ -1,20 +0,0 @@
1
- import React from "react";
2
- import classNames from "classnames";
3
- import "./style.css";
4
-
5
- export default function DNALoader({ style, className }) {
6
- return (
7
- <div className={classNames("dna-loader", className)} style={style}>
8
- <div className="nucleobase" />
9
- <div className="nucleobase" />
10
- <div className="nucleobase" />
11
- <div className="nucleobase" />
12
- <div className="nucleobase" />
13
- <div className="nucleobase" />
14
- <div className="nucleobase" />
15
- <div className="nucleobase" />
16
- <div className="nucleobase" />
17
- <div className="nucleobase" />
18
- </div>
19
- );
20
- }