@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.
- package/AdvancedOptions.js +33 -0
- package/AssignDefaultsModeContext.js +22 -0
- package/DataTable/utils/filterLocalEntitiesToHasura.d.ts +5 -0
- package/DataTable/utils/initializeHasuraWhereAndFilter.d.ts +2 -0
- package/DataTable/utils/queryParams.d.ts +8 -12
- package/DataTable/utils/simplifyHasuraWhere.d.ts +1 -0
- package/DataTable/utils/tableQueryParamsToHasuraClauses.d.ts +14 -0
- package/DropdownButton.js +36 -0
- package/FillWindow.css +6 -0
- package/FillWindow.js +69 -0
- package/{src/DataTable/FilterAndSortMenu.js → FilterAndSortMenu.js} +27 -30
- package/MatchHeaders.js +234 -0
- package/SimpleStepViz.js +22 -0
- package/Tag.js +112 -0
- package/UploadCsvWizard.css +4 -0
- package/UploadCsvWizard.js +719 -0
- package/autoTooltip.js +201 -0
- package/constants.js +1 -0
- package/customIcons.js +361 -0
- package/filterLocalEntitiesToHasura.js +216 -0
- package/index.cjs.js +695 -967
- package/index.d.ts +1 -0
- package/index.es.js +695 -967
- package/initializeHasuraWhereAndFilter.js +27 -0
- package/{src/utils/isBeingCalledExcessively.js → isBeingCalledExcessively.js} +0 -1
- package/package.json +1 -1
- package/queryParams.js +336 -0
- package/rerenderOnWindowResize.js +26 -0
- package/showAppSpinner.js +12 -0
- package/showDialogOnDocBody.js +33 -0
- package/simplifyHasuraWhere.js +80 -0
- package/src/CellDragHandle.js +132 -0
- package/src/ColumnFilterMenu.js +62 -0
- package/src/Columns.js +979 -0
- package/src/DisabledLoadingComponent.js +15 -0
- package/src/DisplayOptions.js +199 -0
- package/src/DropdownCell.js +61 -0
- package/src/EditableCell.js +44 -0
- package/src/FilterAndSortMenu.js +388 -0
- package/src/FormSeparator.js +9 -0
- package/src/LoadingDots.js +14 -0
- package/src/PagingTool.js +225 -0
- package/src/RenderCell.js +191 -0
- package/src/SearchBar.js +69 -0
- package/src/SortableColumns.js +100 -0
- package/src/TableFormTrackerContext.js +10 -0
- package/src/ThComponent.js +44 -0
- package/src/TimelineEvent.js +31 -0
- package/src/Uploader.js +1278 -0
- package/src/adHoc.js +10 -0
- package/src/basicHandleActionsWithFullState.js +14 -0
- package/src/browserUtils.js +3 -0
- package/src/combineReducersWithFullState.js +14 -0
- package/src/commandControls.js +82 -0
- package/src/commandUtils.js +112 -0
- package/src/convertSchema.js +69 -0
- package/src/dataTableEnhancer.js +41 -0
- package/src/defaultFormatters.js +32 -0
- package/src/defaultValidators.js +40 -0
- package/src/determineBlackOrWhiteTextColor.js +4 -0
- package/src/editCellHelper.js +44 -0
- package/src/filterLocalEntitiesToHasura.js +216 -0
- package/src/formatPasteData.js +16 -0
- package/src/getAllRows.js +11 -0
- package/src/getCellCopyText.js +7 -0
- package/src/getCellInfo.js +36 -0
- package/src/getCellVal.js +20 -0
- package/src/getDayjsFormatter.js +35 -0
- package/src/getFieldPathToField.js +7 -0
- package/src/getIdOrCodeOrIndex.js +9 -0
- package/src/getLastSelectedEntity.js +11 -0
- package/src/getNewEntToSelect.js +25 -0
- package/src/getNewName.js +31 -0
- package/src/getRowCopyText.js +28 -0
- package/src/getTableConfigFromStorage.js +5 -0
- package/src/getTextFromEl.js +28 -0
- package/src/getVals.js +8 -0
- package/src/handleCopyColumn.js +21 -0
- package/src/handleCopyHelper.js +15 -0
- package/src/handleCopyRows.js +23 -0
- package/src/handleCopyTable.js +16 -0
- package/src/handlerHelpers.js +24 -0
- package/src/hotkeyUtils.js +131 -0
- package/src/index.js +1 -87
- package/src/initializeHasuraWhereAndFilter.js +27 -0
- package/src/isBeingCalledExcessively.js +24 -0
- package/src/isBottomRightCornerOfRectangle.js +20 -0
- package/src/isEntityClean.js +15 -0
- package/src/isTruthy.js +12 -0
- package/src/isValueEmpty.js +3 -0
- package/src/itemUpload.js +84 -0
- package/src/menuUtils.js +433 -0
- package/src/popoverOverflowModifiers.js +11 -0
- package/src/primarySelectedValue.js +1 -0
- package/src/pureNoFunc.js +31 -0
- package/src/queryParams.js +336 -0
- package/src/removeCleanRows.js +22 -0
- package/src/renderOnDoc.js +32 -0
- package/src/rowClick.js +181 -0
- package/src/selection.js +8 -0
- package/src/showProgressToast.js +22 -0
- package/src/simplifyHasuraWhere.js +80 -0
- package/src/sortify.js +73 -0
- package/src/style.css +24 -260
- package/src/tableQueryParamsToHasuraClauses.js +113 -0
- package/src/{DataTable/utils/withTableParams.js → withTableParams.js} +1 -14
- package/tableQueryParamsToHasuraClauses.js +113 -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 +288 -0
- package/wrapDialog.js +116 -0
- package/src/AdvancedOptions.spec.js +0 -26
- package/src/AsyncValidateFieldSpinner/index.js +0 -12
- package/src/BlueprintError/index.js +0 -14
- package/src/BounceLoader/index.js +0 -16
- package/src/BounceLoader/style.css +0 -45
- package/src/CollapsibleCard/index.js +0 -68
- package/src/CollapsibleCard/style.css +0 -23
- package/src/DNALoader/index.js +0 -20
- package/src/DNALoader/style.css +0 -251
- package/src/DataTable/index.js +0 -3213
- package/src/DataTable/style.css +0 -608
- package/src/DataTable/utils/index.js +0 -55
- package/src/DataTable/utils/queryParams.js +0 -1058
- package/src/DialogFooter/index.js +0 -86
- package/src/DialogFooter/style.css +0 -9
- package/src/FormComponents/index.js +0 -1266
- package/src/FormComponents/style.css +0 -275
- package/src/FormComponents/utils.js +0 -6
- package/src/HotkeysDialog/index.js +0 -79
- package/src/HotkeysDialog/style.css +0 -54
- package/src/InfoHelper/index.js +0 -78
- package/src/InfoHelper/style.css +0 -7
- package/src/IntentText/index.js +0 -18
- package/src/Loading/index.js +0 -70
- package/src/Loading/style.css +0 -4
- package/src/MenuBar/index.js +0 -423
- package/src/MenuBar/style.css +0 -45
- package/src/PromptUnsavedChanges/index.js +0 -38
- package/src/ResizableDraggableDialog/index.js +0 -141
- package/src/ResizableDraggableDialog/style.css +0 -42
- package/src/ScrollToTop/index.js +0 -72
- package/src/TagSelect/index.js +0 -69
- package/src/TagSelect/style.css +0 -13
- package/src/TgHtmlSelect/index.js +0 -20
- package/src/TgSelect/index.js +0 -537
- package/src/TgSelect/style.css +0 -61
- package/src/TgSuggest/index.js +0 -124
- package/src/Timeline/index.js +0 -15
- package/src/enhancers/withDialog/index.js +0 -196
- package/src/showConfirmationDialog/index.js +0 -148
- /package/{src/DataTable/CellDragHandle.js → CellDragHandle.js} +0 -0
- /package/{src/DataTable/ColumnFilterMenu.js → ColumnFilterMenu.js} +0 -0
- /package/{src/DataTable/Columns.js → Columns.js} +0 -0
- /package/{src/DataTable/DisabledLoadingComponent.js → DisabledLoadingComponent.js} +0 -0
- /package/{src/DataTable/DisplayOptions.js → DisplayOptions.js} +0 -0
- /package/{src/DataTable/DropdownCell.js → DropdownCell.js} +0 -0
- /package/{src/DataTable/EditableCell.js → EditableCell.js} +0 -0
- /package/{src/FormComponents/FormSeparator.js → FormSeparator.js} +0 -0
- /package/{src/FormComponents/LoadingDots.js → LoadingDots.js} +0 -0
- /package/{src/DataTable/PagingTool.js → PagingTool.js} +0 -0
- /package/{src/DataTable/RenderCell.js → RenderCell.js} +0 -0
- /package/{src/DataTable/SearchBar.js → SearchBar.js} +0 -0
- /package/{src/DataTable/SortableColumns.js → SortableColumns.js} +0 -0
- /package/{src/DataTable/TableFormTrackerContext.js → TableFormTrackerContext.js} +0 -0
- /package/{src/DataTable/ThComponent.js → ThComponent.js} +0 -0
- /package/{src/Timeline/TimelineEvent.js → TimelineEvent.js} +0 -0
- /package/{src/FormComponents/Uploader.js → Uploader.js} +0 -0
- /package/{src/utils/adHoc.js → adHoc.js} +0 -0
- /package/{src/utils/basicHandleActionsWithFullState.js → basicHandleActionsWithFullState.js} +0 -0
- /package/{src/utils/browserUtils.js → browserUtils.js} +0 -0
- /package/{src/utils/combineReducersWithFullState.js → combineReducersWithFullState.js} +0 -0
- /package/{src/utils/commandControls.js → commandControls.js} +0 -0
- /package/{src/utils/commandUtils.js → commandUtils.js} +0 -0
- /package/{src/DataTable/utils/convertSchema.js → convertSchema.js} +0 -0
- /package/{src/DataTable/dataTableEnhancer.js → dataTableEnhancer.js} +0 -0
- /package/{src/DataTable/defaultFormatters.js → defaultFormatters.js} +0 -0
- /package/{src/DataTable/defaultValidators.js → defaultValidators.js} +0 -0
- /package/{src/utils/determineBlackOrWhiteTextColor.js → determineBlackOrWhiteTextColor.js} +0 -0
- /package/{src/DataTable/editCellHelper.js → editCellHelper.js} +0 -0
- /package/{src/DataTable/utils/formatPasteData.js → formatPasteData.js} +0 -0
- /package/{src/DataTable/utils/getAllRows.js → getAllRows.js} +0 -0
- /package/{src/DataTable/utils/getCellCopyText.js → getCellCopyText.js} +0 -0
- /package/{src/DataTable/utils/getCellInfo.js → getCellInfo.js} +0 -0
- /package/{src/DataTable/getCellVal.js → getCellVal.js} +0 -0
- /package/{src/utils/getDayjsFormatter.js → getDayjsFormatter.js} +0 -0
- /package/{src/DataTable/utils/getFieldPathToField.js → getFieldPathToField.js} +0 -0
- /package/{src/DataTable/utils/getIdOrCodeOrIndex.js → getIdOrCodeOrIndex.js} +0 -0
- /package/{src/DataTable/utils/getLastSelectedEntity.js → getLastSelectedEntity.js} +0 -0
- /package/{src/DataTable/utils/getNewEntToSelect.js → getNewEntToSelect.js} +0 -0
- /package/{src/FormComponents/getNewName.js → getNewName.js} +0 -0
- /package/{src/DataTable/utils/getRowCopyText.js → getRowCopyText.js} +0 -0
- /package/{src/DataTable/utils/getTableConfigFromStorage.js → getTableConfigFromStorage.js} +0 -0
- /package/{src/utils/getTextFromEl.js → getTextFromEl.js} +0 -0
- /package/{src/DataTable/getVals.js → getVals.js} +0 -0
- /package/{src/DataTable/utils/handleCopyColumn.js → handleCopyColumn.js} +0 -0
- /package/{src/DataTable/utils/handleCopyHelper.js → handleCopyHelper.js} +0 -0
- /package/{src/DataTable/utils/handleCopyRows.js → handleCopyRows.js} +0 -0
- /package/{src/DataTable/utils/handleCopyTable.js → handleCopyTable.js} +0 -0
- /package/{src/utils/handlerHelpers.js → handlerHelpers.js} +0 -0
- /package/{src/utils/hotkeyUtils.js → hotkeyUtils.js} +0 -0
- /package/{src/utils/hooks/index.js → index.js} +0 -0
- /package/{src/DataTable/utils/isBottomRightCornerOfRectangle.js → isBottomRightCornerOfRectangle.js} +0 -0
- /package/{src/DataTable/utils/isEntityClean.js → isEntityClean.js} +0 -0
- /package/{src/DataTable/isTruthy.js → isTruthy.js} +0 -0
- /package/{src/DataTable/isValueEmpty.js → isValueEmpty.js} +0 -0
- /package/{src/FormComponents/itemUpload.js → itemUpload.js} +0 -0
- /package/{src/utils/menuUtils.js → menuUtils.js} +0 -0
- /package/{src/utils/popoverOverflowModifiers.js → popoverOverflowModifiers.js} +0 -0
- /package/{src/DataTable/utils/primarySelectedValue.js → primarySelectedValue.js} +0 -0
- /package/{src/utils/pureNoFunc.js → pureNoFunc.js} +0 -0
- /package/{src/DataTable/utils/removeCleanRows.js → removeCleanRows.js} +0 -0
- /package/{src/utils/renderOnDoc.js → renderOnDoc.js} +0 -0
- /package/{src/DataTable/utils/rowClick.js → rowClick.js} +0 -0
- /package/{src/DataTable/utils/selection.js → selection.js} +0 -0
- /package/{src/utils/showProgressToast.js → showProgressToast.js} +0 -0
- /package/{src/FormComponents/sortify.js → sortify.js} +0 -0
- /package/src/{utils/tagUtils.js → tagUtils.js} +0 -0
- /package/src/{utils/tgFormValues.js → tgFormValues.js} +0 -0
- /package/src/{enhancers/withDialog/tg_modalState.js → tg_modalState.js} +0 -0
- /package/src/{FormComponents/tryToMatchSchemas.js → tryToMatchSchemas.js} +0 -0
- /package/src/{utils/hooks/useDeepEqualMemo.js → useDeepEqualMemo.js} +0 -0
- /package/src/{utils/hooks/useStableReference.js → useStableReference.js} +0 -0
- /package/src/{DataTable/utils/useTableEntities.js → useTableEntities.js} +0 -0
- /package/src/{utils/useTraceUpdate.js → useTraceUpdate.js} +0 -0
- /package/src/{DataTable/utils/utils.js → utils.js} +0 -0
- /package/src/{DataTable/validateTableWideErrors.js → validateTableWideErrors.js} +0 -0
- /package/src/{DataTable/viewColumn.js → viewColumn.js} +0 -0
- /package/src/{enhancers/withField.js → withField.js} +0 -0
- /package/src/{enhancers/withFields.js → withFields.js} +0 -0
- /package/src/{enhancers/withLocalStorage.js → withLocalStorage.js} +0 -0
- /package/src/{utils/withSelectTableRecords.js → withSelectTableRecords.js} +0 -0
- /package/src/{DataTable/utils/withSelectedEntities.js → withSelectedEntities.js} +0 -0
- /package/src/{utils/withStore.js → withStore.js} +0 -0
- /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
|
-
}
|
package/src/DNALoader/index.js
DELETED
|
@@ -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
|
-
}
|