@teselagen/ui 0.7.33-beta.6 → 0.7.34
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/AdvancedOptions.js +33 -0
- package/AssignDefaultsModeContext.js +22 -0
- package/CellDragHandle.js +132 -0
- package/ColumnFilterMenu.js +62 -0
- package/Columns.js +979 -0
- package/DataTable/utils/queryParams.d.ts +14 -7
- package/DisabledLoadingComponent.js +15 -0
- package/DisplayOptions.js +199 -0
- package/DropdownButton.js +36 -0
- package/DropdownCell.js +61 -0
- package/EditableCell.js +44 -0
- package/FillWindow.css +6 -0
- package/FillWindow.js +69 -0
- package/FilterAndSortMenu.js +391 -0
- package/FormSeparator.js +9 -0
- package/LoadingDots.js +14 -0
- package/MatchHeaders.js +234 -0
- package/PagingTool.js +225 -0
- package/RenderCell.js +191 -0
- package/SearchBar.js +69 -0
- package/SimpleStepViz.js +22 -0
- package/SortableColumns.js +100 -0
- package/TableFormTrackerContext.js +10 -0
- package/Tag.js +112 -0
- package/ThComponent.js +44 -0
- package/TimelineEvent.js +31 -0
- package/UploadCsvWizard.css +4 -0
- package/UploadCsvWizard.js +719 -0
- package/Uploader.js +1278 -0
- package/adHoc.js +10 -0
- package/autoTooltip.js +201 -0
- package/basicHandleActionsWithFullState.js +14 -0
- package/browserUtils.js +3 -0
- package/combineReducersWithFullState.js +14 -0
- package/commandControls.js +82 -0
- package/commandUtils.js +112 -0
- package/constants.js +1 -0
- package/convertSchema.js +69 -0
- package/customIcons.js +361 -0
- package/dataTableEnhancer.js +41 -0
- package/defaultFormatters.js +32 -0
- package/defaultValidators.js +40 -0
- package/determineBlackOrWhiteTextColor.js +4 -0
- package/editCellHelper.js +44 -0
- package/formatPasteData.js +16 -0
- package/getAllRows.js +11 -0
- package/getCellCopyText.js +7 -0
- package/getCellInfo.js +36 -0
- package/getCellVal.js +20 -0
- package/getDayjsFormatter.js +35 -0
- package/getFieldPathToField.js +7 -0
- package/getIdOrCodeOrIndex.js +9 -0
- package/getLastSelectedEntity.js +11 -0
- package/getNewEntToSelect.js +25 -0
- package/getNewName.js +31 -0
- package/getRowCopyText.js +28 -0
- package/getTableConfigFromStorage.js +5 -0
- package/getTextFromEl.js +28 -0
- package/getVals.js +8 -0
- package/handleCopyColumn.js +21 -0
- package/handleCopyHelper.js +15 -0
- package/handleCopyRows.js +23 -0
- package/handleCopyTable.js +16 -0
- package/handlerHelpers.js +24 -0
- package/hotkeyUtils.js +131 -0
- package/index.cjs.js +972 -837
- package/index.d.ts +0 -1
- package/index.es.js +972 -837
- package/index.js +1 -0
- package/isBeingCalledExcessively.js +31 -0
- package/isBottomRightCornerOfRectangle.js +20 -0
- package/isEntityClean.js +15 -0
- package/isTruthy.js +12 -0
- package/isValueEmpty.js +3 -0
- package/itemUpload.js +84 -0
- package/menuUtils.js +433 -0
- package/package.json +1 -2
- package/popoverOverflowModifiers.js +11 -0
- package/primarySelectedValue.js +1 -0
- package/pureNoFunc.js +31 -0
- package/queryParams.js +1058 -0
- package/removeCleanRows.js +22 -0
- package/renderOnDoc.js +32 -0
- package/rerenderOnWindowResize.js +26 -0
- package/rowClick.js +181 -0
- package/selection.js +8 -0
- package/showAppSpinner.js +12 -0
- package/showDialogOnDocBody.js +33 -0
- package/showProgressToast.js +22 -0
- package/sortify.js +73 -0
- package/style.css +13 -0
- package/tagUtils.js +45 -0
- package/tgFormValues.js +35 -0
- package/tg_modalState.js +47 -0
- package/throwFormError.js +16 -0
- package/toastr.js +148 -0
- package/tryToMatchSchemas.js +264 -0
- package/typeToCommonType.js +6 -0
- package/useDeepEqualMemo.js +15 -0
- package/useDialog.js +63 -0
- package/useStableReference.js +9 -0
- package/useTableEntities.js +38 -0
- package/useTraceUpdate.js +19 -0
- package/utils.js +37 -0
- package/validateTableWideErrors.js +160 -0
- package/viewColumn.js +97 -0
- package/withField.js +20 -0
- package/withFields.js +11 -0
- package/withLocalStorage.js +11 -0
- package/withSelectTableRecords.js +43 -0
- package/withSelectedEntities.js +65 -0
- package/withStore.js +10 -0
- package/withTableParams.js +301 -0
- package/wrapDialog.js +116 -0
|
@@ -0,0 +1,301 @@
|
|
|
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
|
+
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
|
+
}
|
|
92
|
+
} else {
|
|
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
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const {
|
|
103
|
+
reduxFormQueryParams: _reduxFormQueryParams = {},
|
|
104
|
+
reduxFormSelectedEntityIdMap: _reduxFormSelectedEntityIdMap = {}
|
|
105
|
+
} = useSelector(state =>
|
|
106
|
+
formValueSelector(formName)(
|
|
107
|
+
state,
|
|
108
|
+
"reduxFormQueryParams",
|
|
109
|
+
"reduxFormSelectedEntityIdMap"
|
|
110
|
+
)
|
|
111
|
+
);
|
|
112
|
+
|
|
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
|
+
);
|
|
119
|
+
|
|
120
|
+
const _currentParams = useMemo(() => {
|
|
121
|
+
const tmp =
|
|
122
|
+
(urlConnected
|
|
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) || {};
|
|
125
|
+
|
|
126
|
+
return tmp;
|
|
127
|
+
}, [history?.location, reduxFormQueryParams, urlConnected]);
|
|
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(() => {
|
|
169
|
+
const additionalFilterToUse =
|
|
170
|
+
typeof additionalFilter === "function"
|
|
171
|
+
? additionalFilter
|
|
172
|
+
: () => additionalFilter;
|
|
173
|
+
|
|
174
|
+
const additionalOrFilterToUse =
|
|
175
|
+
typeof additionalOrFilter === "function"
|
|
176
|
+
? additionalOrFilter
|
|
177
|
+
: () => additionalOrFilter;
|
|
178
|
+
|
|
179
|
+
return getQueryParams({
|
|
180
|
+
doNotCoercePageSize,
|
|
181
|
+
currentParams,
|
|
182
|
+
entities, // for local table
|
|
183
|
+
urlConnected,
|
|
184
|
+
defaults: defaultsToUse,
|
|
185
|
+
schema: convertedSchema,
|
|
186
|
+
isInfinite: isInfinite || (isSimple && !withPaging),
|
|
187
|
+
isLocalCall,
|
|
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
|
+
]);
|
|
211
|
+
|
|
212
|
+
const dispatch = useDispatch();
|
|
213
|
+
const change = useCallback(
|
|
214
|
+
(...args) => dispatch(_change(formName, ...args)),
|
|
215
|
+
[dispatch, formName]
|
|
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;
|
|
227
|
+
});
|
|
228
|
+
},
|
|
229
|
+
[change, history?.replace, urlConnected]
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
const dispatchProps = useMemo(
|
|
233
|
+
() =>
|
|
234
|
+
makeDataTableHandlers({
|
|
235
|
+
setNewParams,
|
|
236
|
+
defaults,
|
|
237
|
+
onlyOneFilter
|
|
238
|
+
}),
|
|
239
|
+
[defaults, onlyOneFilter, setNewParams]
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
const tableParams = useMemo(
|
|
243
|
+
() => ({
|
|
244
|
+
changeFormValue: (...args) => change(...args),
|
|
245
|
+
selectedEntities,
|
|
246
|
+
..._tableParams,
|
|
247
|
+
formName,
|
|
248
|
+
initialValues,
|
|
249
|
+
isLocalCall,
|
|
250
|
+
schema,
|
|
251
|
+
currentParams,
|
|
252
|
+
withDisplayOptions,
|
|
253
|
+
...queryParams,
|
|
254
|
+
...dispatchProps,
|
|
255
|
+
form: formName, //this will override the default redux form name
|
|
256
|
+
isTableParamsConnected: true //let the table know not to do local sorting/filtering etc.
|
|
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
|
+
);
|
|
272
|
+
|
|
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
|
+
};
|
|
287
|
+
|
|
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
|
+
}
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
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
|
+
};
|