@teselagen/ui 0.6.6 → 0.7.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 (98) hide show
  1. package/DataTable/ColumnFilterMenu.d.ts +2 -1
  2. package/DataTable/Columns.d.ts +51 -0
  3. package/DataTable/DisplayOptions.d.ts +14 -14
  4. package/DataTable/EditabelCell.d.ts +2 -5
  5. package/DataTable/EditableCell.d.ts +7 -0
  6. package/DataTable/FilterAndSortMenu.d.ts +9 -9
  7. package/DataTable/PagingTool.d.ts +25 -2
  8. package/DataTable/RenderCell.d.ts +18 -0
  9. package/DataTable/SearchBar.d.ts +4 -3
  10. package/DataTable/SortableColumns.d.ts +6 -9
  11. package/DataTable/ThComponent.d.ts +9 -0
  12. package/DataTable/index.d.ts +0 -5
  13. package/DataTable/utils/getIdOrCodeOrIndex.d.ts +1 -2
  14. package/DataTable/utils/handleCopyTable.d.ts +1 -0
  15. package/DataTable/utils/index.d.ts +4 -2
  16. package/DataTable/utils/primarySelectedValue.d.ts +1 -0
  17. package/DataTable/utils/queryParams.d.ts +13 -8
  18. package/DataTable/utils/removeCleanRows.d.ts +1 -1
  19. package/DataTable/utils/rowClick.d.ts +24 -3
  20. package/DataTable/utils/useDeepEqualMemo.d.ts +1 -0
  21. package/DataTable/utils/useTableEntities.d.ts +5 -0
  22. package/DataTable/utils/useTableParams.d.ts +49 -0
  23. package/DataTable/utils/withTableParams.d.ts +3 -16
  24. package/DataTable/viewColumn.d.ts +11 -4
  25. package/FormComponents/AbstractField.d.ts +1 -0
  26. package/FormComponents/Uploader.d.ts +34 -1
  27. package/FormComponents/index.d.ts +111 -60
  28. package/MatchHeaders.d.ts +9 -10
  29. package/SimpleStepViz.d.ts +2 -1
  30. package/TgSuggest/index.d.ts +1 -21
  31. package/UploadCsvWizard.d.ts +1 -1
  32. package/index.cjs.js +47861 -49125
  33. package/index.d.ts +6 -3
  34. package/index.es.js +47959 -49223
  35. package/package.json +6 -5
  36. package/src/DataTable/CellDragHandle.js +70 -69
  37. package/src/DataTable/ColumnFilterMenu.js +23 -21
  38. package/src/DataTable/Columns.js +948 -0
  39. package/src/DataTable/Columns.jsx +945 -0
  40. package/src/DataTable/DisplayOptions.js +173 -192
  41. package/src/DataTable/EditabelCell.js +7 -18
  42. package/src/DataTable/EditabelCell.jsx +44 -0
  43. package/src/DataTable/EditableCell.js +44 -0
  44. package/src/DataTable/FilterAndSortMenu.js +215 -234
  45. package/src/DataTable/PagingTool.js +47 -56
  46. package/src/DataTable/RenderCell.js +191 -0
  47. package/src/DataTable/RenderCell.jsx +191 -0
  48. package/src/DataTable/SearchBar.js +12 -5
  49. package/src/DataTable/SortableColumns.js +44 -39
  50. package/src/DataTable/ThComponent.js +44 -0
  51. package/src/DataTable/dataTableEnhancer.js +32 -295
  52. package/src/DataTable/index.js +2945 -3596
  53. package/src/DataTable/utils/getIdOrCodeOrIndex.js +1 -1
  54. package/src/DataTable/utils/handleCopyTable.js +16 -0
  55. package/src/DataTable/utils/index.js +7 -3
  56. package/src/DataTable/utils/primarySelectedValue.js +1 -0
  57. package/src/DataTable/utils/queryParams.js +110 -85
  58. package/src/DataTable/utils/removeCleanRows.js +3 -3
  59. package/src/DataTable/utils/rowClick.js +34 -9
  60. package/src/DataTable/utils/selection.js +1 -1
  61. package/src/DataTable/utils/useDeepEqualMemo.js +10 -0
  62. package/src/DataTable/utils/useTableEntities.js +38 -0
  63. package/src/DataTable/utils/useTableParams.js +362 -0
  64. package/src/DataTable/utils/withTableParams.js +244 -274
  65. package/src/DataTable/validateTableWideErrors.js +1 -1
  66. package/src/DataTable/viewColumn.js +5 -9
  67. package/src/DialogFooter/index.js +3 -3
  68. package/src/FillWindow.js +2 -3
  69. package/src/FormComponents/AbstractField.js +388 -0
  70. package/src/FormComponents/Uploader.js +674 -649
  71. package/src/FormComponents/index.js +505 -654
  72. package/src/FormComponents/tryToMatchSchemas.js +1 -6
  73. package/src/MatchHeaders.js +27 -22
  74. package/src/SimpleStepViz.js +19 -23
  75. package/src/TgSelect/index.js +1 -1
  76. package/src/TgSuggest/index.js +94 -106
  77. package/src/UploadCsvWizard.js +571 -577
  78. package/src/enhancers/withDialog/tg_modalState.js +1 -0
  79. package/src/index.js +10 -4
  80. package/src/showDialogOnDocBody.js +5 -9
  81. package/src/useDialog.js +25 -26
  82. package/src/utils/commandControls.js +2 -2
  83. package/src/utils/handlerHelpers.js +19 -25
  84. package/src/utils/hooks/index.js +1 -0
  85. package/src/utils/hooks/useDeepEqualMemo.js +10 -0
  86. package/src/utils/hooks/useStableReference.js +9 -0
  87. package/src/utils/renderOnDoc.js +8 -5
  88. package/src/utils/tagUtils.js +3 -3
  89. package/src/utils/useTraceUpdate.js +19 -0
  90. package/src/wrapDialog.js +0 -2
  91. package/style.css +251 -251
  92. package/useDialog.d.ts +2 -6
  93. package/utils/hooks/index.d.ts +1 -0
  94. package/utils/hooks/useDeepEqualMemo.d.ts +1 -0
  95. package/utils/hooks/useStableReference.d.ts +1 -0
  96. package/utils/renderOnDoc.d.ts +1 -1
  97. package/utils/tagUtils.d.ts +5 -1
  98. package/utils/useTraceUpdate.d.ts +1 -0
@@ -1,22 +1,18 @@
1
- import React, { useContext, useEffect } from "react";
2
- import { change, formValueSelector } from "redux-form";
3
- import { connect } from "react-redux";
4
- import { camelCase, isFunction, set } from "lodash-es";
5
- import { withRouter } from "react-router-dom";
6
- import { branch, compose } from "recompose";
7
-
8
- import pureNoFunc from "../../utils/pureNoFunc";
9
- import TableFormTrackerContext from "../TableFormTrackerContext";
1
+ import React, { useCallback, useMemo } from "react";
2
+ import { change as _change, formValueSelector } from "redux-form";
3
+ import { useDispatch, useSelector } from "react-redux";
10
4
  import convertSchema from "./convertSchema";
11
- import { getRecordsFromReduxForm } from "./withSelectedEntities";
12
5
  import {
13
6
  makeDataTableHandlers,
14
7
  getQueryParams,
15
8
  setCurrentParamsOnUrl,
16
- getMergedOpts,
17
- getCurrentParamsFromUrl
9
+ getCurrentParamsFromUrl,
10
+ getCCDisplayName
18
11
  } from "./queryParams";
12
+ import { withRouter } from "react-router-dom";
19
13
  import getTableConfigFromStorage from "./getTableConfigFromStorage";
14
+ import { useDeepEqualMemo } from "../../utils/hooks/useDeepEqualMemo";
15
+ import { branch, compose } from "recompose";
20
16
 
21
17
  /**
22
18
  * Note all these options can be passed at Design Time or at Runtime (like reduxForm())
@@ -33,299 +29,273 @@ import getTableConfigFromStorage from "./getTableConfigFromStorage";
33
29
  * @property {object} defaults - tableParam defaults such as pageSize, filter, etc
34
30
  * @property {boolean} noOrderError - won't console an error if an order is not found on schema
35
31
  */
36
- export default function withTableParams(compOrOpts, pTopLevelOpts) {
37
- let topLevelOptions;
38
- let Component;
39
- if (!pTopLevelOpts) {
40
- topLevelOptions = compOrOpts;
32
+ export const useTableParams = props => {
33
+ const {
34
+ additionalFilter,
35
+ additionalOrFilter,
36
+ controlled_pageSize,
37
+ defaults: _defaults,
38
+ doNotCoercePageSize,
39
+ entities,
40
+ formName = "tgDataTable",
41
+ history,
42
+ initialValues,
43
+ isCodeModel,
44
+ isInfinite,
45
+ isLocalCall = false,
46
+ isSimple,
47
+ noForm,
48
+ noOrderError,
49
+ onlyOneFilter,
50
+ orderByFirstColumn,
51
+ pageSize,
52
+ schema,
53
+ syncDisplayOptionsToDb,
54
+ tableParams: _tableParams,
55
+ urlConnected,
56
+ withDisplayOptions,
57
+ withPaging,
58
+ withSelectedEntities
59
+ } = props;
60
+
61
+ const defaults = useMemo(
62
+ () => ({
63
+ pageSize: controlled_pageSize || 25,
64
+ order: [], //[-name, statusCode] //an array of camelCase display names with - sign to denote reverse
65
+ searchTerm: "",
66
+ page: 1,
67
+ filters: [
68
+ //filters look like this:
69
+ // {
70
+ // selectedFilter: 'textContains', //camel case
71
+ // filterOn: ccDisplayName, //camel case display name if available and string, otherwise path
72
+ // filterValue: 'thomas',
73
+ // }
74
+ ],
75
+ ..._defaults
76
+ }),
77
+ [_defaults, controlled_pageSize]
78
+ );
79
+
80
+ const convertedSchema = useMemo(() => convertSchema(schema), [schema]);
81
+
82
+ if (isLocalCall) {
83
+ if (!noForm && (!formName || formName === "tgDataTable")) {
84
+ console.error(
85
+ "Please pass a unique 'formName' prop to the locally connected <DataTable/> component with schema: ",
86
+ schema
87
+ );
88
+ }
89
+ if (orderByFirstColumn && !defaults?.order?.length) {
90
+ defaults.order = [getCCDisplayName(convertedSchema.fields[0])];
91
+ }
41
92
  } else {
42
- topLevelOptions = pTopLevelOpts;
43
- Component = compOrOpts;
93
+ //in user instantiated withTableParams() call
94
+ if (!formName || formName === "tgDataTable") {
95
+ console.error(
96
+ "Please pass a unique 'formName' prop to the withTableParams() with schema: ",
97
+ schema
98
+ );
99
+ }
44
100
  }
45
- const { isLocalCall } = topLevelOptions;
46
- const mapStateToProps = (state, ownProps) => {
47
- const mergedOpts = getMergedOpts(topLevelOptions, ownProps);
48
- const {
49
- history,
50
- urlConnected,
51
- withSelectedEntities,
52
- formName,
53
- formNameFromWithTPCall,
54
- syncDisplayOptionsToDb,
55
- defaults,
56
- isInfinite,
57
- isSimple,
58
- withPaging,
59
- doNotCoercePageSize,
60
- initialValues,
61
- additionalFilter = {},
62
- additionalOrFilter = {},
63
- noOrderError,
64
- withDisplayOptions,
65
- cellRenderer,
66
- model,
67
- isCodeModel,
68
- noForm
69
- } = mergedOpts;
70
101
 
71
- const schema = getSchema(mergedOpts);
72
- const convertedSchema = convertSchema(schema);
73
- if (ownProps.isTableParamsConnected) {
74
- if (
75
- formName &&
76
- formNameFromWithTPCall &&
77
- formName !== formNameFromWithTPCall
78
- ) {
79
- console.error(
80
- `You passed a formName prop, ${formName} to a <DataTable/> component that is already withTableParams() connected, formNameFromWithTableParamsCall: ${formNameFromWithTPCall}`
81
- );
82
- }
83
- if (ownProps.tableParams && !ownProps.tableParams.entities) {
84
- console.error(
85
- `No entities array detected in tableParams object (<DataTable {...tableParams}/>). You need to call withQuery() after withTableParams() like: compose(withTableParams(), withQuery(something)). formNameFromWithTableParamsCall: ${formNameFromWithTPCall}`
86
- );
87
- }
88
- //short circuit because we've already run this logic
89
- return {};
90
- }
102
+ const {
103
+ reduxFormQueryParams: _reduxFormQueryParams = {},
104
+ reduxFormSelectedEntityIdMap: _reduxFormSelectedEntityIdMap = {}
105
+ } = useSelector(state =>
106
+ formValueSelector(formName)(
107
+ state,
108
+ "reduxFormQueryParams",
109
+ "reduxFormSelectedEntityIdMap"
110
+ )
111
+ );
91
112
 
92
- let formNameFromWithTableParamsCall;
93
- if (isLocalCall) {
94
- if (!noForm && (!formName || formName === "tgDataTable")) {
95
- console.error(
96
- "Please pass a unique 'formName' prop to the locally connected <DataTable/> component with schema: ",
97
- schema
98
- );
99
- }
100
- if (
101
- mergedOpts.orderByFirstColumn &&
102
- !mergedOpts.defaults?.order?.length
103
- ) {
104
- const r = [
105
- camelCase(
106
- convertedSchema.fields[0].displayName ||
107
- convertedSchema.fields[0].path
108
- )
109
- ];
110
- set(mergedOpts, "defaults.order", r);
111
- }
112
- } else {
113
- //in user instantiated withTableParams() call
114
- if (!formName || formName === "tgDataTable") {
115
- console.error(
116
- "Please pass a unique 'formName' prop to the withTableParams() with schema: ",
117
- schema
118
- );
119
- } else {
120
- formNameFromWithTableParamsCall = formName;
121
- }
122
- }
113
+ // We want to make sure we don't rerender everything unnecessary
114
+ // with redux-forms we tend to do unnecessary renders
115
+ const reduxFormQueryParams = useDeepEqualMemo(_reduxFormQueryParams);
116
+ const reduxFormSelectedEntityIdMap = useDeepEqualMemo(
117
+ _reduxFormSelectedEntityIdMap
118
+ );
123
119
 
124
- const tableConfig = getTableConfigFromStorage(formName);
125
- const formSelector = formValueSelector(formName);
126
- const currentParams =
120
+ const _currentParams = useMemo(() => {
121
+ const tmp =
127
122
  (urlConnected
128
- ? getCurrentParamsFromUrl(history.location) //important to use history location and not ownProps.location because for some reason the location path lags one render behind!!
129
- : formSelector(state, "reduxFormQueryParams")) || {};
123
+ ? getCurrentParamsFromUrl(history?.location) //important to use history location and not ownProps.location because for some reason the location path lags one render behind!!
124
+ : reduxFormQueryParams) || {};
130
125
 
131
- const selectedEntities = withSelectedEntities
132
- ? getRecordsFromReduxForm(state, formName)
133
- : undefined;
126
+ return tmp;
127
+ }, [history?.location, reduxFormQueryParams, urlConnected]);
134
128
 
129
+ const selectedEntities = useMemo(
130
+ () =>
131
+ withSelectedEntities
132
+ ? Object.values(reduxFormSelectedEntityIdMap)
133
+ .sort((a, b) => a.rowIndex - b.rowIndex)
134
+ .map(item => item.entity)
135
+ : undefined,
136
+ [reduxFormSelectedEntityIdMap, withSelectedEntities]
137
+ );
138
+
139
+ const currentParams = useDeepEqualMemo(_currentParams);
140
+
141
+ const defaultsToUse = useMemo(() => {
142
+ const _tableConfig = getTableConfigFromStorage(formName);
143
+ const userSetPageSize =
144
+ _tableConfig?.userSetPageSize &&
145
+ parseInt(_tableConfig.userSetPageSize, 10);
146
+ let _defaultsToUse = defaults;
147
+ if (!syncDisplayOptionsToDb && userSetPageSize) {
148
+ _defaultsToUse = _defaultsToUse || {};
149
+ _defaultsToUse.pageSize = userSetPageSize;
150
+ }
151
+
152
+ return _defaultsToUse;
153
+ }, [defaults, formName, syncDisplayOptionsToDb]);
154
+
155
+ const passingProps = useMemo(
156
+ () => ({
157
+ formName: "tgDataTable",
158
+ ...props,
159
+ pageSize: controlled_pageSize || pageSize,
160
+ defaults: defaultsToUse,
161
+ location: history?.location
162
+ }),
163
+ // We don't want to rerender this every time a prop changes
164
+ // eslint-disable-next-line react-hooks/exhaustive-deps
165
+ [controlled_pageSize, defaultsToUse, pageSize, history?.location]
166
+ );
167
+
168
+ const queryParams = useMemo(() => {
135
169
  const additionalFilterToUse =
136
170
  typeof additionalFilter === "function"
137
- ? additionalFilter.bind(this, ownProps)
171
+ ? additionalFilter.bind(this, passingProps)
138
172
  : () => additionalFilter;
173
+
139
174
  const additionalOrFilterToUse =
140
175
  typeof additionalOrFilter === "function"
141
- ? additionalOrFilter.bind(this, ownProps)
176
+ ? additionalOrFilter.bind(this, passingProps)
142
177
  : () => additionalOrFilter;
143
178
 
144
- let defaultsToUse = defaults;
145
-
146
- // make user set page size persist
147
- const userSetPageSize =
148
- tableConfig?.userSetPageSize && parseInt(tableConfig.userSetPageSize, 10);
149
- if (!syncDisplayOptionsToDb && userSetPageSize) {
150
- defaultsToUse = defaultsToUse || {};
151
- defaultsToUse.pageSize = userSetPageSize;
152
- }
153
- const mapStateProps = {
154
- history,
179
+ return getQueryParams({
180
+ doNotCoercePageSize,
181
+ currentParams,
182
+ entities, // for local table
155
183
  urlConnected,
156
- withSelectedEntities,
157
- formName,
158
184
  defaults: defaultsToUse,
159
- isInfinite,
160
- isSimple,
161
- withPaging,
162
- doNotCoercePageSize,
163
- additionalFilter,
164
- additionalOrFilter,
165
- noOrderError,
166
- withDisplayOptions,
167
- cellRenderer,
185
+ schema: convertedSchema,
186
+ isInfinite: isInfinite || (isSimple && !withPaging),
168
187
  isLocalCall,
169
- model,
170
- schema,
171
- mergedOpts,
172
- ...getQueryParams({
173
- doNotCoercePageSize,
174
- currentParams,
175
- entities: mergedOpts.entities, // for local table
176
- urlConnected,
177
- defaults: defaultsToUse,
178
- schema: convertedSchema,
179
- isInfinite: isInfinite || (isSimple && !withPaging),
180
- isLocalCall,
181
- additionalFilter: additionalFilterToUse,
182
- additionalOrFilter: additionalOrFilterToUse,
183
- noOrderError,
184
- isCodeModel,
185
- ownProps: mergedOpts
186
- }),
187
- formNameFromWithTPCall: formNameFromWithTableParamsCall,
188
- randomVarToForceLocalStorageUpdate: formSelector(
189
- state,
190
- "localStorageForceUpdate"
191
- ),
192
- currentParams,
193
- selectedEntities,
194
- ...(withSelectedEntities &&
195
- typeof withSelectedEntities === "string" && {
196
- [withSelectedEntities]: selectedEntities
197
- }),
198
- initialValues: {
199
- ...initialValues,
200
- reduxFormSearchInput: currentParams.searchTerm
201
- }
202
- };
203
- return mapStateProps;
204
- // return { ...mergedOpts, ...mapStateProps };
205
- };
188
+ additionalFilter: additionalFilterToUse,
189
+ additionalOrFilter: additionalOrFilterToUse,
190
+ noOrderError,
191
+ isCodeModel,
192
+ ownProps: passingProps
193
+ });
194
+ }, [
195
+ additionalFilter,
196
+ passingProps,
197
+ additionalOrFilter,
198
+ doNotCoercePageSize,
199
+ currentParams,
200
+ entities,
201
+ urlConnected,
202
+ defaultsToUse,
203
+ convertedSchema,
204
+ isInfinite,
205
+ isSimple,
206
+ withPaging,
207
+ isLocalCall,
208
+ noOrderError,
209
+ isCodeModel
210
+ ]);
206
211
 
207
- const mapDispatchToProps = (dispatch, ownProps) => {
208
- if (ownProps.isTableParamsConnected) {
209
- return {};
210
- }
211
- const mergedOpts = getMergedOpts(topLevelOptions, ownProps);
212
- const { formName, urlConnected, history, defaults, onlyOneFilter } =
213
- mergedOpts;
212
+ const dispatch = useDispatch();
213
+ const change = useCallback(
214
+ (...args) => dispatch(_change(formName, ...args)),
215
+ [dispatch, formName]
216
+ );
214
217
 
215
- function updateSearch(val) {
216
- setTimeout(function () {
217
- dispatch(change(formName, "reduxFormSearchInput", val || ""));
218
+ const setNewParams = useCallback(
219
+ newParams => {
220
+ // we always will update the redux params as a workaround for withRouter not always working
221
+ // if inside a redux-connected container https://github.com/ReactTraining/react-router/issues/5037
222
+ change("reduxFormQueryParams", prev => {
223
+ let tmp = newParams;
224
+ if (typeof tmp === "function") tmp = newParams(prev);
225
+ urlConnected && setCurrentParamsOnUrl(tmp, history?.replace);
226
+ return tmp;
218
227
  });
219
- }
228
+ },
229
+ [change, history?.replace, urlConnected]
230
+ );
220
231
 
221
- let setNewParams;
222
- if (urlConnected) {
223
- setNewParams = function (newParams) {
224
- setCurrentParamsOnUrl(newParams, history.replace);
225
- dispatch(change(formName, "reduxFormQueryParams", newParams)); //we always will update the redux params as a workaround for withRouter not always working if inside a redux-connected container https://github.com/ReactTraining/react-router/issues/5037
226
- };
227
- } else {
228
- setNewParams = function (newParams) {
229
- dispatch(change(formName, "reduxFormQueryParams", newParams));
230
- };
231
- }
232
- return {
233
- bindThese: makeDataTableHandlers({
232
+ const dispatchProps = useMemo(
233
+ () =>
234
+ makeDataTableHandlers({
234
235
  setNewParams,
235
- updateSearch,
236
236
  defaults,
237
237
  onlyOneFilter
238
238
  }),
239
- dispatch
240
- };
241
- };
242
-
243
- function mergeProps(stateProps, dispatchProps, ownProps) {
244
- if (ownProps.isTableParamsConnected) {
245
- return ownProps;
246
- }
247
- const { currentParams, formName } = stateProps;
248
- const boundDispatchProps = {};
249
- //bind currentParams to actions
250
- Object.keys(dispatchProps.bindThese).forEach(function (key) {
251
- const action = dispatchProps.bindThese[key];
252
- boundDispatchProps[key] = function (...args) {
253
- action(...args, currentParams);
254
- };
255
- });
256
- const { variables, selectedEntities, mergedOpts, ...restStateProps } =
257
- stateProps;
258
-
259
- const changeFormValue = (...args) =>
260
- dispatchProps.dispatch(change(formName, ...args));
239
+ [defaults, onlyOneFilter, setNewParams]
240
+ );
261
241
 
262
- const tableParams = {
263
- changeFormValue,
242
+ const tableParams = useMemo(
243
+ () => ({
244
+ changeFormValue: (...args) => change(...args),
264
245
  selectedEntities,
265
- ...ownProps.tableParams,
266
- ...restStateProps,
267
- ...boundDispatchProps,
246
+ ..._tableParams,
247
+ formName,
248
+ initialValues,
249
+ isLocalCall,
250
+ schema,
251
+ currentParams,
252
+ withDisplayOptions,
253
+ ...queryParams,
254
+ ...dispatchProps,
268
255
  form: formName, //this will override the default redux form name
269
256
  isTableParamsConnected: true //let the table know not to do local sorting/filtering etc.
270
- };
271
-
272
- const allMergedProps = {
273
- ...ownProps,
274
- ...mergedOpts,
275
- variables: stateProps.variables,
276
- selectedEntities: stateProps.selectedEntities,
277
- tableParams
278
- };
279
-
280
- return allMergedProps;
281
- }
282
-
283
- function addFormTracking(Component) {
284
- return props => {
285
- const formTracker = useContext(TableFormTrackerContext);
286
- const { formName } = props;
287
- useEffect(() => {
288
- if (formTracker.isActive && !formTracker.formNames.includes(formName)) {
289
- formTracker.pushFormName(formName);
290
- }
291
- }, [formTracker, formName]);
257
+ }),
258
+ [
259
+ _tableParams,
260
+ change,
261
+ currentParams,
262
+ dispatchProps,
263
+ formName,
264
+ initialValues,
265
+ isLocalCall,
266
+ queryParams,
267
+ schema,
268
+ selectedEntities,
269
+ withDisplayOptions
270
+ ]
271
+ );
292
272
 
293
- return <Component {...props} />;
294
- };
295
- }
273
+ return {
274
+ isLocalCall,
275
+ schema,
276
+ ...queryParams,
277
+ ...(withSelectedEntities &&
278
+ typeof withSelectedEntities === "string" && {
279
+ [withSelectedEntities]: selectedEntities
280
+ }),
281
+ currentParams,
282
+ selectedEntities,
283
+ tableParams,
284
+ urlConnected
285
+ };
286
+ };
296
287
 
297
- const toReturn = compose(
298
- connect((state, ownProps) => {
299
- if (ownProps.isTableParamsConnected) {
300
- return {};
301
- }
302
- const { formName } = getMergedOpts(topLevelOptions, ownProps);
303
- return {
304
- unusedProp:
305
- formValueSelector(formName)(state, "reduxFormQueryParams") || {} //tnr: we need this to trigger withRouter and force it to update if it is nested in a redux-connected container.. very ugly but necessary
306
- };
307
- }),
308
- branch(props => {
309
- //don't use withRouter if noRouter is passed!
310
- return !props.noRouter;
311
- }, withRouter),
312
- connect(mapStateToProps, mapDispatchToProps, mergeProps),
313
- pureNoFunc,
314
- addFormTracking
288
+ const withTableParams = topLevelOptions =>
289
+ compose(
290
+ //don't use withRouter if noRouter is passed!
291
+ branch(({ noRouter }) => !noRouter, withRouter),
292
+ Comp => props => {
293
+ const tableParams = useTableParams({
294
+ ...topLevelOptions,
295
+ ...props
296
+ });
297
+ return <Comp {...props} {...tableParams} />;
298
+ }
315
299
  );
316
- if (Component) {
317
- return toReturn(Component);
318
- }
319
- return toReturn;
320
- }
321
300
 
322
- /**
323
- * Given the options, get the schema. This enables the user to provide
324
- * a function instead of an object for the schema.
325
- * @param {Object} options Merged options
326
- */
327
- function getSchema(options) {
328
- const { schema } = options;
329
- if (isFunction(schema)) return schema(options);
330
- else return schema;
331
- }
301
+ export default withTableParams;
@@ -1,4 +1,4 @@
1
- import getIdOrCodeOrIndex from "./utils/getIdOrCodeOrIndex";
1
+ import { getIdOrCodeOrIndex } from "./utils";
2
2
  import { getCellVal } from "./getCellVal";
3
3
  import { forEach, isArray } from "lodash-es";
4
4
  import { startCase } from "lodash-es";
@@ -11,20 +11,16 @@ export const viewColumn = {
11
11
  return <Icon className="dt-eyeIcon" icon="eye-open" />;
12
12
  }
13
13
  };
14
- export const openColumn = {
14
+ export const openColumn = ({ onDoubleClick, history }) => ({
15
15
  ...viewColumn,
16
- render: (val, record, rowInfo, props) => {
16
+ render: (val, record, rowInfo) => {
17
17
  return (
18
18
  <Tooltip content="Open">
19
19
  <Button
20
20
  onClick={e => {
21
21
  e.stopPropagation();
22
- props.onDoubleClick &&
23
- props.onDoubleClick(
24
- rowInfo.original,
25
- rowInfo.index,
26
- props.history
27
- );
22
+ onDoubleClick &&
23
+ onDoubleClick(rowInfo.original, rowInfo.index, history);
28
24
  }}
29
25
  minimal
30
26
  small
@@ -34,4 +30,4 @@ export const openColumn = {
34
30
  </Tooltip>
35
31
  );
36
32
  }
37
- };
33
+ });
@@ -27,11 +27,11 @@ function DialogFooter({
27
27
  containerClassname,
28
28
  noCancel
29
29
  }) {
30
- const r = useRef();
30
+ const divRef = useRef();
31
31
  return (
32
32
  <div
33
33
  style={style}
34
- ref={r}
34
+ ref={divRef}
35
35
  className={classNames(Classes.DIALOG_FOOTER, containerClassname)}
36
36
  >
37
37
  <div className={Classes.DIALOG_FOOTER_ACTIONS}>
@@ -57,7 +57,7 @@ function DialogFooter({
57
57
  hideModal ||
58
58
  function () {
59
59
  try {
60
- r.current
60
+ divRef.current
61
61
  .closest(".bp3-dialog")
62
62
  .querySelector(".bp3-dialog-close-button")
63
63
  .click();
package/src/FillWindow.js CHANGED
@@ -1,6 +1,5 @@
1
- import React from "react";
1
+ import React, { createPortal } from "react";
2
2
  import { isFunction } from "lodash-es";
3
- import reactDom from "react-dom";
4
3
  import rerenderOnWindowResize from "./rerenderOnWindowResize";
5
4
  import "./FillWindow.css";
6
5
 
@@ -63,7 +62,7 @@ export default class FillWindow extends React.Component {
63
62
  : this.props.children}
64
63
  </div>
65
64
  );
66
- if (asPortal) return reactDom.createPortal(inner, window.document.body);
65
+ if (asPortal) return createPortal(inner, window.document.body);
67
66
  return inner;
68
67
  }
69
68
  }