@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.
- package/DataTable/ColumnFilterMenu.d.ts +2 -1
- package/DataTable/Columns.d.ts +51 -0
- package/DataTable/DisplayOptions.d.ts +14 -14
- package/DataTable/EditabelCell.d.ts +2 -5
- package/DataTable/EditableCell.d.ts +7 -0
- package/DataTable/FilterAndSortMenu.d.ts +9 -9
- package/DataTable/PagingTool.d.ts +25 -2
- package/DataTable/RenderCell.d.ts +18 -0
- package/DataTable/SearchBar.d.ts +4 -3
- package/DataTable/SortableColumns.d.ts +6 -9
- package/DataTable/ThComponent.d.ts +9 -0
- package/DataTable/index.d.ts +0 -5
- package/DataTable/utils/getIdOrCodeOrIndex.d.ts +1 -2
- package/DataTable/utils/handleCopyTable.d.ts +1 -0
- package/DataTable/utils/index.d.ts +4 -2
- package/DataTable/utils/primarySelectedValue.d.ts +1 -0
- package/DataTable/utils/queryParams.d.ts +13 -8
- package/DataTable/utils/removeCleanRows.d.ts +1 -1
- package/DataTable/utils/rowClick.d.ts +24 -3
- package/DataTable/utils/useDeepEqualMemo.d.ts +1 -0
- package/DataTable/utils/useTableEntities.d.ts +5 -0
- package/DataTable/utils/useTableParams.d.ts +49 -0
- package/DataTable/utils/withTableParams.d.ts +3 -16
- package/DataTable/viewColumn.d.ts +11 -4
- package/FormComponents/AbstractField.d.ts +1 -0
- package/FormComponents/Uploader.d.ts +34 -1
- package/FormComponents/index.d.ts +111 -60
- package/MatchHeaders.d.ts +9 -10
- package/SimpleStepViz.d.ts +2 -1
- package/TgSuggest/index.d.ts +1 -21
- package/UploadCsvWizard.d.ts +1 -1
- package/index.cjs.js +47861 -49125
- package/index.d.ts +6 -3
- package/index.es.js +47959 -49223
- package/package.json +6 -5
- package/src/DataTable/CellDragHandle.js +70 -69
- package/src/DataTable/ColumnFilterMenu.js +23 -21
- package/src/DataTable/Columns.js +948 -0
- package/src/DataTable/Columns.jsx +945 -0
- package/src/DataTable/DisplayOptions.js +173 -192
- package/src/DataTable/EditabelCell.js +7 -18
- package/src/DataTable/EditabelCell.jsx +44 -0
- package/src/DataTable/EditableCell.js +44 -0
- package/src/DataTable/FilterAndSortMenu.js +215 -234
- package/src/DataTable/PagingTool.js +47 -56
- package/src/DataTable/RenderCell.js +191 -0
- package/src/DataTable/RenderCell.jsx +191 -0
- package/src/DataTable/SearchBar.js +12 -5
- package/src/DataTable/SortableColumns.js +44 -39
- package/src/DataTable/ThComponent.js +44 -0
- package/src/DataTable/dataTableEnhancer.js +32 -295
- package/src/DataTable/index.js +2945 -3596
- package/src/DataTable/utils/getIdOrCodeOrIndex.js +1 -1
- package/src/DataTable/utils/handleCopyTable.js +16 -0
- package/src/DataTable/utils/index.js +7 -3
- package/src/DataTable/utils/primarySelectedValue.js +1 -0
- package/src/DataTable/utils/queryParams.js +110 -85
- package/src/DataTable/utils/removeCleanRows.js +3 -3
- package/src/DataTable/utils/rowClick.js +34 -9
- package/src/DataTable/utils/selection.js +1 -1
- package/src/DataTable/utils/useDeepEqualMemo.js +10 -0
- package/src/DataTable/utils/useTableEntities.js +38 -0
- package/src/DataTable/utils/useTableParams.js +362 -0
- package/src/DataTable/utils/withTableParams.js +244 -274
- package/src/DataTable/validateTableWideErrors.js +1 -1
- package/src/DataTable/viewColumn.js +5 -9
- package/src/DialogFooter/index.js +3 -3
- package/src/FillWindow.js +2 -3
- package/src/FormComponents/AbstractField.js +388 -0
- package/src/FormComponents/Uploader.js +674 -649
- package/src/FormComponents/index.js +505 -654
- package/src/FormComponents/tryToMatchSchemas.js +1 -6
- package/src/MatchHeaders.js +27 -22
- package/src/SimpleStepViz.js +19 -23
- package/src/TgSelect/index.js +1 -1
- package/src/TgSuggest/index.js +94 -106
- package/src/UploadCsvWizard.js +571 -577
- package/src/enhancers/withDialog/tg_modalState.js +1 -0
- package/src/index.js +10 -4
- package/src/showDialogOnDocBody.js +5 -9
- package/src/useDialog.js +25 -26
- package/src/utils/commandControls.js +2 -2
- package/src/utils/handlerHelpers.js +19 -25
- package/src/utils/hooks/index.js +1 -0
- package/src/utils/hooks/useDeepEqualMemo.js +10 -0
- package/src/utils/hooks/useStableReference.js +9 -0
- package/src/utils/renderOnDoc.js +8 -5
- package/src/utils/tagUtils.js +3 -3
- package/src/utils/useTraceUpdate.js +19 -0
- package/src/wrapDialog.js +0 -2
- package/style.css +251 -251
- package/useDialog.d.ts +2 -6
- package/utils/hooks/index.d.ts +1 -0
- package/utils/hooks/useDeepEqualMemo.d.ts +1 -0
- package/utils/hooks/useStableReference.d.ts +1 -0
- package/utils/renderOnDoc.d.ts +1 -1
- package/utils/tagUtils.d.ts +5 -1
- package/utils/useTraceUpdate.d.ts +1 -0
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import { change, formValueSelector } from "redux-form";
|
|
3
|
-
import {
|
|
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
|
-
|
|
17
|
-
|
|
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
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
43
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
125
|
-
const
|
|
126
|
-
const currentParams =
|
|
120
|
+
const _currentParams = useMemo(() => {
|
|
121
|
+
const tmp =
|
|
127
122
|
(urlConnected
|
|
128
|
-
? getCurrentParamsFromUrl(history
|
|
129
|
-
:
|
|
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
|
-
|
|
132
|
-
|
|
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,
|
|
171
|
+
? additionalFilter.bind(this, passingProps)
|
|
138
172
|
: () => additionalFilter;
|
|
173
|
+
|
|
139
174
|
const additionalOrFilterToUse =
|
|
140
175
|
typeof additionalOrFilter === "function"
|
|
141
|
-
? additionalOrFilter.bind(this,
|
|
176
|
+
? additionalOrFilter.bind(this, passingProps)
|
|
142
177
|
: () => additionalOrFilter;
|
|
143
178
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
|
|
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
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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
|
-
|
|
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
|
-
|
|
263
|
-
|
|
242
|
+
const tableParams = useMemo(
|
|
243
|
+
() => ({
|
|
244
|
+
changeFormValue: (...args) => change(...args),
|
|
264
245
|
selectedEntities,
|
|
265
|
-
...
|
|
266
|
-
|
|
267
|
-
|
|
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
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
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
|
-
|
|
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
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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;
|
|
@@ -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
|
|
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
|
-
|
|
23
|
-
|
|
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
|
|
30
|
+
const divRef = useRef();
|
|
31
31
|
return (
|
|
32
32
|
<div
|
|
33
33
|
style={style}
|
|
34
|
-
ref={
|
|
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
|
-
|
|
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
|
|
65
|
+
if (asPortal) return createPortal(inner, window.document.body);
|
|
67
66
|
return inner;
|
|
68
67
|
}
|
|
69
68
|
}
|