@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
package/src/sortify.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2015-2016 Thomas Rosenau
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Create a “sorted” version of an object.
|
|
19
|
+
*
|
|
20
|
+
* JS engines internally keep track of an object's keys in the order of
|
|
21
|
+
* creation time, i.e. {a:1,b:2} is treated differently from {b:2,a:1}.
|
|
22
|
+
* That difference can be seen when JSON.stringify is called on that object.
|
|
23
|
+
* This function normalizes any kind of object by rearranging the keys in
|
|
24
|
+
* alphabetical order (numerical keys first, since v8 does so, and there's
|
|
25
|
+
* nothing we can do about it).
|
|
26
|
+
* @param {*} o The object to be sorted
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/* eslint-disable */
|
|
30
|
+
const sortKeys = o => {
|
|
31
|
+
if (Array.isArray(o)) {
|
|
32
|
+
return o.map(sortKeys);
|
|
33
|
+
} else if (o instanceof Object) {
|
|
34
|
+
// put numeric keys first
|
|
35
|
+
let numeric = [];
|
|
36
|
+
let nonNumeric = [];
|
|
37
|
+
Object.keys(o).forEach(key => {
|
|
38
|
+
if (/^(0|[1-9][0-9]*)$/.test(key)) {
|
|
39
|
+
numeric.push(+key);
|
|
40
|
+
} else {
|
|
41
|
+
nonNumeric.push(key);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
// do the rearrangement
|
|
45
|
+
return numeric
|
|
46
|
+
.sort(function (a, b) {
|
|
47
|
+
return a - b;
|
|
48
|
+
})
|
|
49
|
+
.concat(nonNumeric.sort())
|
|
50
|
+
.reduce((result, key) => {
|
|
51
|
+
result[key] = sortKeys(o[key]); // recurse!
|
|
52
|
+
return result;
|
|
53
|
+
}, {});
|
|
54
|
+
}
|
|
55
|
+
return o;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const jsonStringify = JSON.stringify.bind(JSON);
|
|
59
|
+
|
|
60
|
+
const sortify = (value, replacer, space) => {
|
|
61
|
+
// replacer, toJSON(), cyclic references and other stuff is better handled by native stringifier.
|
|
62
|
+
// So we do JSON.stringify(sortKeys( JSON.parse(JSON.stringify()) )).
|
|
63
|
+
// This approach is slightly slower but much safer than a manual stringification.
|
|
64
|
+
let nativeJson = jsonStringify(value, replacer, 0);
|
|
65
|
+
if (!nativeJson || (nativeJson[0] !== "{" && nativeJson[0] !== "[")) {
|
|
66
|
+
// if value is not an Object or Array
|
|
67
|
+
return nativeJson;
|
|
68
|
+
}
|
|
69
|
+
let cleanObj = JSON.parse(nativeJson);
|
|
70
|
+
return jsonStringify(sortKeys(cleanObj), null, space);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export default sortify;
|
package/src/style.css
CHANGED
|
@@ -1,265 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
--base2: #cdcdcd;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
body.bp3-dark {
|
|
7
|
-
--base1: #393a3a;
|
|
8
|
-
--base2: #293742;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.bp3-dark .tg-card {
|
|
12
|
-
background: #394b59 !important;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.preserve-newline {
|
|
16
|
-
white-space: pre-line;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.bp3-dialog {
|
|
20
|
-
max-width: 100vw;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/* adding back in blueprint v2 default styling to all <h/> elements */
|
|
24
|
-
h1 {
|
|
25
|
-
line-height: 40px;
|
|
26
|
-
font-size: 36px;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
h2 {
|
|
30
|
-
line-height: 32px;
|
|
31
|
-
font-size: 28px;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
h3 {
|
|
35
|
-
line-height: 25px;
|
|
36
|
-
font-size: 22px;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
h4 {
|
|
40
|
-
line-height: 21px;
|
|
41
|
-
font-size: 18px;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
h5 {
|
|
45
|
-
line-height: 19px;
|
|
46
|
-
font-size: 16px;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
h6 {
|
|
50
|
-
line-height: 16px;
|
|
51
|
-
font-size: 14px;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
h1,
|
|
55
|
-
h2,
|
|
56
|
-
h3,
|
|
57
|
-
h4,
|
|
58
|
-
h5,
|
|
59
|
-
h6,
|
|
60
|
-
h1.bp3-heading,
|
|
61
|
-
h2.bp3-heading,
|
|
62
|
-
h3.bp3-heading,
|
|
63
|
-
h4.bp3-heading,
|
|
64
|
-
h5.bp3-heading,
|
|
65
|
-
h6.bp3-heading {
|
|
66
|
-
color: #182026;
|
|
67
|
-
font-weight: 300;
|
|
68
|
-
margin: 0 0 10px;
|
|
69
|
-
padding: 0;
|
|
70
|
-
line-height: normal;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.bp3-dark h1,
|
|
74
|
-
.bp3-dark h2,
|
|
75
|
-
.bp3-dark h3,
|
|
76
|
-
.bp3-dark h4,
|
|
77
|
-
.bp3-dark h5,
|
|
78
|
-
.bp3-dark h6 {
|
|
79
|
-
color: #f5f8fa;
|
|
80
|
-
}
|
|
81
|
-
.bp3-dark textarea {
|
|
82
|
-
background: #293742;
|
|
83
|
-
color: #f5f8fa;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/* bp3 fix https://github.com/palantir/blueprint/issues/2807 */
|
|
87
|
-
.bp3-popover-wrapper {
|
|
88
|
-
display: inline-block;
|
|
1
|
+
/* Copyright (C) 2018 TeselaGen Biotechnology, Inc. */
|
|
2
|
+
.tg-timeline {
|
|
89
3
|
position: relative;
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
/* this line is necessary otherwise the line above setting "position: relative;" caused nested long bp3 submenus to not appear correctly when using the fix below */
|
|
93
|
-
.bp3-submenu .bp3-popover-wrapper {
|
|
94
|
-
position: unset;
|
|
95
|
-
}
|
|
96
|
-
/* this fixes https://github.com/palantir/blueprint/issues/4791 but requires the "position: unset;" fix above */
|
|
97
|
-
.bp3-submenu > * > .bp3-menu {
|
|
98
|
-
max-height: 96vh;
|
|
99
|
-
overflow: auto;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/* bp3 fix https://github.com/palantir/blueprint/issues/2807 */
|
|
103
|
-
span.bp3-popover-target {
|
|
104
|
-
display: block;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.bp3-portal {
|
|
108
|
-
z-index: 100000;
|
|
109
|
-
}
|
|
110
|
-
.bp3-switch {
|
|
111
|
-
width: fit-content;
|
|
112
|
-
display: flex;
|
|
113
|
-
align-items: center;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
.Select {
|
|
117
|
-
min-width: 170px;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/* override the default blueprint input focus to instead rely on an inset box shadow. This resolves any issues with overflow:hidden cutting off input box shadows */
|
|
121
|
-
.bp3-dark .bp3-input:focus,
|
|
122
|
-
.bp3-input:focus {
|
|
123
|
-
box-shadow: inset 0 0 3px 1px #137cbd;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.notClickable {
|
|
127
|
-
cursor: default !important;
|
|
128
|
-
}
|
|
129
|
-
.bp3-toast-container {
|
|
130
|
-
z-index: 100001;
|
|
4
|
+
white-space: nowrap;
|
|
131
5
|
}
|
|
132
6
|
|
|
133
|
-
.
|
|
134
|
-
background: none !important;
|
|
135
|
-
border: none;
|
|
136
|
-
padding: 0 !important;
|
|
137
|
-
font-family: arial, sans-serif;
|
|
138
|
-
color: rgb(0, 151, 227);
|
|
139
|
-
/* text-decoration: underline; */
|
|
140
|
-
cursor: pointer;
|
|
141
|
-
}
|
|
142
|
-
.link-button:hover {
|
|
143
|
-
color: rgb(98, 198, 248);
|
|
144
|
-
text-decoration: underline;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.above-dialog {
|
|
148
|
-
z-index: 100001;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
code {
|
|
152
|
-
display: block;
|
|
153
|
-
white-space: pre-wrap;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
.bp3-toast.no-close-button [aria-label="Close"] {
|
|
157
|
-
display: none;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
.isDataTitle .tippy-box[data-theme~="teselagen"] .tippy-arrow {
|
|
161
|
-
opacity: 0 !important;
|
|
162
|
-
}
|
|
163
|
-
.isDataTitle .tippy-box[data-theme~="teselagen"] {
|
|
164
|
-
background-color: #4f4a50f4 !important;
|
|
165
|
-
border-radius: 0 !important;
|
|
166
|
-
color: #f3f3f3 !important;
|
|
167
|
-
font-size: 11px !important;
|
|
168
|
-
white-space: pre-wrap;
|
|
169
|
-
padding: 0px 0px !important;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
[data-tippy-root]:has(.tippy-box[data-theme~="teselagen"]) {
|
|
173
|
-
z-index: 100000 !important;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
[data-tippy-root] .tippy-box[data-theme~="teselagen"] {
|
|
177
|
-
background-color: #394b59;
|
|
178
|
-
color: #f5f8fa;
|
|
179
|
-
padding: 4px 4px;
|
|
180
|
-
word-break: break-word;
|
|
181
|
-
}
|
|
182
|
-
[data-tippy-root] .tippy-box[data-theme~="teselagen"] .tippy-arrow {
|
|
183
|
-
color: #394b59;
|
|
184
|
-
}
|
|
185
|
-
.bp3-dark [data-tippy-root] .tippy-box[data-theme~="teselagen"] {
|
|
186
|
-
background-color: #e1e8ed;
|
|
187
|
-
color: #394b59;
|
|
188
|
-
}
|
|
189
|
-
.bp3-dark [data-tippy-root] .tippy-box[data-theme~="teselagen"] .tippy-arrow {
|
|
190
|
-
/* background-color: #e1e8ed; */
|
|
191
|
-
color: #e1e8ed;
|
|
192
|
-
}
|
|
193
|
-
.isCellEditable .rt-td {
|
|
194
|
-
position: relative;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.ReactTable .tg-cell-edit-boolean-checkbox {
|
|
198
|
-
margin-bottom: 0;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
.cellDragHandle {
|
|
202
|
-
height: 8px;
|
|
203
|
-
width: 8px;
|
|
204
|
-
cursor: crosshair;
|
|
205
|
-
border: 1px solid rgb(255, 255, 255);
|
|
206
|
-
background-color: rgb(76, 107, 171);
|
|
7
|
+
.tg-timeline-line {
|
|
207
8
|
position: absolute;
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
border: 1px solid white !important;
|
|
229
|
-
}
|
|
230
|
-
.bp3-toast[class*="bp3-intent-"] .bp3-button.tg-clear-all-toasts:hover {
|
|
231
|
-
/* background: blue !important; */
|
|
232
|
-
/* background: unset !important; */
|
|
233
|
-
background-color: #137cbd !important;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/* .bp3-toast .tg-clear-all-toasts {
|
|
237
|
-
background: unset !important;
|
|
238
|
-
color: unset !important;
|
|
239
|
-
padding: unset !important;
|
|
240
|
-
margin: unset !important;
|
|
241
|
-
font-size: unset !important;
|
|
242
|
-
line-height: unset !important;
|
|
243
|
-
border: unset !important;
|
|
244
|
-
box-shadow: unset !important;
|
|
245
|
-
text-align: unset !important;
|
|
246
|
-
cursor: pointer !important;
|
|
247
|
-
} */
|
|
248
|
-
|
|
249
|
-
.bp3-dialog-header .bp3-heading {
|
|
250
|
-
width: 10px; /* tnw: this is a hack to prevent the dialog title from causing the dialog width to expand larger than the dialog content*/
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/* to fix tooltip styling issue - https://github.com/palantir/blueprint/issues/3430 */
|
|
254
|
-
.bp3-popover[style*="transform-origin"][style*="bottom"] .bp3-popover-arrow {
|
|
255
|
-
transform: translate(0, -0.5px);
|
|
256
|
-
}
|
|
257
|
-
.bp3-popover[style*="transform-origin"][style*="left"] .bp3-popover-arrow {
|
|
258
|
-
transform: translate(0.5px, 0);
|
|
259
|
-
}
|
|
260
|
-
.bp3-popover[style*="transform-origin"][style*="top"] .bp3-popover-arrow {
|
|
261
|
-
transform: translate(0, 0.5px);
|
|
262
|
-
}
|
|
263
|
-
.bp3-popover[style*="transform-origin"][style*="right"] .bp3-popover-arrow {
|
|
264
|
-
transform: translate(-0.5px, 0);
|
|
9
|
+
height: 90%;
|
|
10
|
+
border-left: 2px solid #bfccd6;
|
|
11
|
+
top: 3px;
|
|
12
|
+
left: 5px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.tg-timeline-event {
|
|
16
|
+
margin-bottom: 15px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.tg-timeline-circle {
|
|
20
|
+
width: 12px;
|
|
21
|
+
min-width: 12px;
|
|
22
|
+
height: 12px;
|
|
23
|
+
min-height: 12px;
|
|
24
|
+
z-index: 1;
|
|
25
|
+
margin-right: 10px;
|
|
26
|
+
border-radius: 100px;
|
|
27
|
+
background: #e1e8ed;
|
|
28
|
+
border: 2px solid #137cbd;
|
|
265
29
|
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export function tableQueryParamsToHasuraClauses({
|
|
2
|
+
page,
|
|
3
|
+
pageSize,
|
|
4
|
+
searchTerm,
|
|
5
|
+
filters,
|
|
6
|
+
order,
|
|
7
|
+
schema, // Add schema as a parameter
|
|
8
|
+
additionalFilter
|
|
9
|
+
}) {
|
|
10
|
+
let where = {};
|
|
11
|
+
const order_by = {};
|
|
12
|
+
const limit = pageSize || 25;
|
|
13
|
+
const offset = page && pageSize ? (page - 1) * pageSize : 0;
|
|
14
|
+
|
|
15
|
+
if (searchTerm) {
|
|
16
|
+
const searchTermFilters = [];
|
|
17
|
+
schema.fields.forEach(field => {
|
|
18
|
+
const { type, path, searchDisabled } = field;
|
|
19
|
+
if (searchDisabled || field.filterDisabled || type === "color") return;
|
|
20
|
+
const filterValue = searchTerm; // No cleaning needed here, we're using _ilike
|
|
21
|
+
|
|
22
|
+
if (type === "string" || type === "lookup") {
|
|
23
|
+
searchTermFilters.push({
|
|
24
|
+
[path]: { _ilike: `%${filterValue}%` }
|
|
25
|
+
});
|
|
26
|
+
} else if (type === "boolean") {
|
|
27
|
+
let regex;
|
|
28
|
+
try {
|
|
29
|
+
regex = new RegExp("^" + searchTerm, "ig");
|
|
30
|
+
} catch (error) {
|
|
31
|
+
//ignore
|
|
32
|
+
}
|
|
33
|
+
if (regex) {
|
|
34
|
+
if ("true".replace(regex, "") !== "true") {
|
|
35
|
+
searchTermFilters.push({
|
|
36
|
+
[path]: { _eq: true }
|
|
37
|
+
});
|
|
38
|
+
} else if ("false".replace(regex, "") !== "false") {
|
|
39
|
+
searchTermFilters.push({
|
|
40
|
+
[path]: { _eq: false }
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
} else if (
|
|
45
|
+
(type === "number" || type === "integer") &&
|
|
46
|
+
!isNaN(filterValue)
|
|
47
|
+
) {
|
|
48
|
+
searchTermFilters.push({
|
|
49
|
+
[path]: { _eq: parseFloat(filterValue) }
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
if (searchTermFilters.length > 0) {
|
|
54
|
+
if (Object.keys(where).length > 0) {
|
|
55
|
+
where = { _and: [where, { _or: searchTermFilters }] };
|
|
56
|
+
} else {
|
|
57
|
+
where = { _or: searchTermFilters };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (filters && filters.length > 0) {
|
|
63
|
+
const filterClauses = filters.map(filter => {
|
|
64
|
+
const { selectedFilter, filterOn, filterValue } = filter;
|
|
65
|
+
switch (selectedFilter) {
|
|
66
|
+
case "textContains":
|
|
67
|
+
return { [filterOn]: { _ilike: `%${filterValue}%` } };
|
|
68
|
+
case "textEquals":
|
|
69
|
+
return { [filterOn]: { _eq: filterValue } };
|
|
70
|
+
case "textNotEquals":
|
|
71
|
+
return { [filterOn]: { _neq: filterValue } };
|
|
72
|
+
case "numberEquals":
|
|
73
|
+
return { [filterOn]: { _eq: parseFloat(filterValue) } };
|
|
74
|
+
case "numberGreaterThan":
|
|
75
|
+
return { [filterOn]: { _gt: parseFloat(filterValue) } };
|
|
76
|
+
case "numberLessThan":
|
|
77
|
+
return { [filterOn]: { _lt: parseFloat(filterValue) } };
|
|
78
|
+
case "numberGreaterThanEquals":
|
|
79
|
+
return { [filterOn]: { _gte: parseFloat(filterValue) } };
|
|
80
|
+
case "numberLessThanEquals":
|
|
81
|
+
return { [filterOn]: { _lte: parseFloat(filterValue) } };
|
|
82
|
+
case "isNull":
|
|
83
|
+
return { [filterOn]: { _is_null: true } };
|
|
84
|
+
case "isNotNull":
|
|
85
|
+
return { [filterOn]: { _is_null: false } };
|
|
86
|
+
default:
|
|
87
|
+
console.warn(`Unsupported filter type: ${selectedFilter}`);
|
|
88
|
+
return {};
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
if (filterClauses.length > 0) {
|
|
93
|
+
if (Object.keys(where).length > 0) {
|
|
94
|
+
where = { _and: [where, ...filterClauses] };
|
|
95
|
+
} else {
|
|
96
|
+
where = { _and: filterClauses };
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (order && order.length > 0) {
|
|
102
|
+
order.forEach(item => {
|
|
103
|
+
const field = item.startsWith("-") ? item.substring(1) : item;
|
|
104
|
+
const direction = item.startsWith("-") ? "desc" : "asc";
|
|
105
|
+
order_by[field] = direction;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (additionalFilter) {
|
|
110
|
+
where = { _and: [where, additionalFilter] };
|
|
111
|
+
}
|
|
112
|
+
return { where, order_by, limit, offset };
|
|
113
|
+
}
|
|
@@ -32,7 +32,6 @@ import { branch, compose } from "recompose";
|
|
|
32
32
|
export const useTableParams = props => {
|
|
33
33
|
const {
|
|
34
34
|
additionalFilter,
|
|
35
|
-
additionalOrFilter,
|
|
36
35
|
controlled_pageSize,
|
|
37
36
|
defaults: _defaults,
|
|
38
37
|
doNotCoercePageSize,
|
|
@@ -166,16 +165,6 @@ export const useTableParams = props => {
|
|
|
166
165
|
);
|
|
167
166
|
|
|
168
167
|
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
168
|
return getQueryParams({
|
|
180
169
|
doNotCoercePageSize,
|
|
181
170
|
currentParams,
|
|
@@ -185,8 +174,7 @@ export const useTableParams = props => {
|
|
|
185
174
|
schema: convertedSchema,
|
|
186
175
|
isInfinite: isInfinite || (isSimple && !withPaging),
|
|
187
176
|
isLocalCall,
|
|
188
|
-
additionalFilter
|
|
189
|
-
additionalOrFilter: additionalOrFilterToUse,
|
|
177
|
+
additionalFilter,
|
|
190
178
|
noOrderError,
|
|
191
179
|
isCodeModel,
|
|
192
180
|
ownProps: passingProps
|
|
@@ -194,7 +182,6 @@ export const useTableParams = props => {
|
|
|
194
182
|
}, [
|
|
195
183
|
additionalFilter,
|
|
196
184
|
passingProps,
|
|
197
|
-
additionalOrFilter,
|
|
198
185
|
doNotCoercePageSize,
|
|
199
186
|
currentParams,
|
|
200
187
|
entities,
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export function tableQueryParamsToHasuraClauses({
|
|
2
|
+
page,
|
|
3
|
+
pageSize,
|
|
4
|
+
searchTerm,
|
|
5
|
+
filters,
|
|
6
|
+
order,
|
|
7
|
+
schema, // Add schema as a parameter
|
|
8
|
+
additionalFilter
|
|
9
|
+
}) {
|
|
10
|
+
let where = {};
|
|
11
|
+
const order_by = {};
|
|
12
|
+
const limit = pageSize || 25;
|
|
13
|
+
const offset = page && pageSize ? (page - 1) * pageSize : 0;
|
|
14
|
+
|
|
15
|
+
if (searchTerm) {
|
|
16
|
+
const searchTermFilters = [];
|
|
17
|
+
schema.fields.forEach(field => {
|
|
18
|
+
const { type, path, searchDisabled } = field;
|
|
19
|
+
if (searchDisabled || field.filterDisabled || type === "color") return;
|
|
20
|
+
const filterValue = searchTerm; // No cleaning needed here, we're using _ilike
|
|
21
|
+
|
|
22
|
+
if (type === "string" || type === "lookup") {
|
|
23
|
+
searchTermFilters.push({
|
|
24
|
+
[path]: { _ilike: `%${filterValue}%` }
|
|
25
|
+
});
|
|
26
|
+
} else if (type === "boolean") {
|
|
27
|
+
let regex;
|
|
28
|
+
try {
|
|
29
|
+
regex = new RegExp("^" + searchTerm, "ig");
|
|
30
|
+
} catch (error) {
|
|
31
|
+
//ignore
|
|
32
|
+
}
|
|
33
|
+
if (regex) {
|
|
34
|
+
if ("true".replace(regex, "") !== "true") {
|
|
35
|
+
searchTermFilters.push({
|
|
36
|
+
[path]: { _eq: true }
|
|
37
|
+
});
|
|
38
|
+
} else if ("false".replace(regex, "") !== "false") {
|
|
39
|
+
searchTermFilters.push({
|
|
40
|
+
[path]: { _eq: false }
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
} else if (
|
|
45
|
+
(type === "number" || type === "integer") &&
|
|
46
|
+
!isNaN(filterValue)
|
|
47
|
+
) {
|
|
48
|
+
searchTermFilters.push({
|
|
49
|
+
[path]: { _eq: parseFloat(filterValue) }
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
if (searchTermFilters.length > 0) {
|
|
54
|
+
if (Object.keys(where).length > 0) {
|
|
55
|
+
where = { _and: [where, { _or: searchTermFilters }] };
|
|
56
|
+
} else {
|
|
57
|
+
where = { _or: searchTermFilters };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (filters && filters.length > 0) {
|
|
63
|
+
const filterClauses = filters.map(filter => {
|
|
64
|
+
const { selectedFilter, filterOn, filterValue } = filter;
|
|
65
|
+
switch (selectedFilter) {
|
|
66
|
+
case "textContains":
|
|
67
|
+
return { [filterOn]: { _ilike: `%${filterValue}%` } };
|
|
68
|
+
case "textEquals":
|
|
69
|
+
return { [filterOn]: { _eq: filterValue } };
|
|
70
|
+
case "textNotEquals":
|
|
71
|
+
return { [filterOn]: { _neq: filterValue } };
|
|
72
|
+
case "numberEquals":
|
|
73
|
+
return { [filterOn]: { _eq: parseFloat(filterValue) } };
|
|
74
|
+
case "numberGreaterThan":
|
|
75
|
+
return { [filterOn]: { _gt: parseFloat(filterValue) } };
|
|
76
|
+
case "numberLessThan":
|
|
77
|
+
return { [filterOn]: { _lt: parseFloat(filterValue) } };
|
|
78
|
+
case "numberGreaterThanEquals":
|
|
79
|
+
return { [filterOn]: { _gte: parseFloat(filterValue) } };
|
|
80
|
+
case "numberLessThanEquals":
|
|
81
|
+
return { [filterOn]: { _lte: parseFloat(filterValue) } };
|
|
82
|
+
case "isNull":
|
|
83
|
+
return { [filterOn]: { _is_null: true } };
|
|
84
|
+
case "isNotNull":
|
|
85
|
+
return { [filterOn]: { _is_null: false } };
|
|
86
|
+
default:
|
|
87
|
+
console.warn(`Unsupported filter type: ${selectedFilter}`);
|
|
88
|
+
return {};
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
if (filterClauses.length > 0) {
|
|
93
|
+
if (Object.keys(where).length > 0) {
|
|
94
|
+
where = { _and: [where, ...filterClauses] };
|
|
95
|
+
} else {
|
|
96
|
+
where = { _and: filterClauses };
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (order && order.length > 0) {
|
|
102
|
+
order.forEach(item => {
|
|
103
|
+
const field = item.startsWith("-") ? item.substring(1) : item;
|
|
104
|
+
const direction = item.startsWith("-") ? "desc" : "asc";
|
|
105
|
+
order_by[field] = direction;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (additionalFilter) {
|
|
110
|
+
where = { _and: [where, additionalFilter] };
|
|
111
|
+
}
|
|
112
|
+
return { where, order_by, limit, offset };
|
|
113
|
+
}
|
package/tagUtils.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { flatMap, keyBy } from "lodash-es";
|
|
2
|
+
import determineBlackOrWhiteTextColor from "./determineBlackOrWhiteTextColor";
|
|
3
|
+
|
|
4
|
+
export function getTagsAndTagOptions(allTags) {
|
|
5
|
+
return flatMap(allTags, tag => {
|
|
6
|
+
if (tag.tagOptions && tag.tagOptions.length) {
|
|
7
|
+
return tag.tagOptions.map(tagO => {
|
|
8
|
+
const fullname = `${tag.name}: ${tagO.name}`;
|
|
9
|
+
const value = `${tag.id}:${tagO.id}`;
|
|
10
|
+
return {
|
|
11
|
+
...tagO,
|
|
12
|
+
label: fullname,
|
|
13
|
+
value,
|
|
14
|
+
id: tagO.id
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
...tag,
|
|
20
|
+
label: tag.name,
|
|
21
|
+
value: tag.id
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function getKeyedTagsAndTagOptions(tags) {
|
|
27
|
+
return keyBy(getTagsAndTagOptions(tags), "value");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function getTagColorStyle(color) {
|
|
31
|
+
return color
|
|
32
|
+
? {
|
|
33
|
+
style: {
|
|
34
|
+
backgroundColor: color,
|
|
35
|
+
color: determineBlackOrWhiteTextColor(color)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
: {};
|
|
39
|
+
}
|
|
40
|
+
export function getTagProps({ color, label, name }) {
|
|
41
|
+
return {
|
|
42
|
+
...getTagColorStyle(color),
|
|
43
|
+
children: label || name
|
|
44
|
+
};
|
|
45
|
+
}
|
package/tgFormValues.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import { connect } from "react-redux";
|
|
3
|
+
import { FormName, formValueSelector } from "redux-form";
|
|
4
|
+
|
|
5
|
+
const tgFormValues =
|
|
6
|
+
(...fieldNames) =>
|
|
7
|
+
Component =>
|
|
8
|
+
props => {
|
|
9
|
+
return (
|
|
10
|
+
<FormName>
|
|
11
|
+
{formName => {
|
|
12
|
+
const name = formName.form;
|
|
13
|
+
const Wrapped = useMemo(() => {
|
|
14
|
+
const selector = formValueSelector(name || "");
|
|
15
|
+
const wrapper = connect(state => {
|
|
16
|
+
const vals = {};
|
|
17
|
+
fieldNames.forEach(name => {
|
|
18
|
+
vals[name] = selector(state, name);
|
|
19
|
+
});
|
|
20
|
+
return vals;
|
|
21
|
+
});
|
|
22
|
+
return wrapper(Component);
|
|
23
|
+
}, [name]);
|
|
24
|
+
return <Wrapped {...props} />;
|
|
25
|
+
}}
|
|
26
|
+
</FormName>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
export default tgFormValues;
|
|
30
|
+
|
|
31
|
+
export const tgFormValueSelector = (formName, ...fields) => {
|
|
32
|
+
return connect(state => {
|
|
33
|
+
return formValueSelector(formName)(state, ...fields);
|
|
34
|
+
});
|
|
35
|
+
};
|