@teselagen/ui 0.7.34 → 0.7.36
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/isBeingCalledExcessively.js +2 -0
- package/package.json +1 -1
- package/style.css +26 -10
- package/DataTable/utils/filterLocalEntitiesToHasura.d.ts +0 -5
- package/DataTable/utils/initializeHasuraWhereAndFilter.d.ts +0 -2
- package/DataTable/utils/tableQueryParamsToHasuraClauses.d.ts +0 -26
- package/src/AdvancedOptions.js +0 -33
- package/src/AdvancedOptions.spec.js +0 -26
- package/src/AssignDefaultsModeContext.js +0 -22
- 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/CellDragHandle.js +0 -132
- package/src/DataTable/ColumnFilterMenu.js +0 -62
- package/src/DataTable/Columns.js +0 -979
- package/src/DataTable/DisabledLoadingComponent.js +0 -15
- package/src/DataTable/DisplayOptions.js +0 -199
- package/src/DataTable/DropdownCell.js +0 -61
- package/src/DataTable/EditableCell.js +0 -44
- package/src/DataTable/FilterAndSortMenu.js +0 -388
- package/src/DataTable/PagingTool.js +0 -225
- package/src/DataTable/RenderCell.js +0 -191
- package/src/DataTable/SearchBar.js +0 -69
- package/src/DataTable/SortableColumns.js +0 -100
- package/src/DataTable/TableFormTrackerContext.js +0 -10
- package/src/DataTable/ThComponent.js +0 -44
- package/src/DataTable/dataTableEnhancer.js +0 -41
- package/src/DataTable/defaultFormatters.js +0 -32
- package/src/DataTable/defaultValidators.js +0 -40
- package/src/DataTable/editCellHelper.js +0 -44
- package/src/DataTable/getCellVal.js +0 -20
- package/src/DataTable/getVals.js +0 -8
- package/src/DataTable/index.js +0 -3209
- package/src/DataTable/isTruthy.js +0 -12
- package/src/DataTable/isValueEmpty.js +0 -3
- package/src/DataTable/style.css +0 -608
- package/src/DataTable/utils/convertSchema.js +0 -69
- package/src/DataTable/utils/filterLocalEntitiesToHasura.js +0 -236
- package/src/DataTable/utils/filterLocalEntitiesToHasura.test.js +0 -587
- package/src/DataTable/utils/formatPasteData.js +0 -16
- package/src/DataTable/utils/getAllRows.js +0 -11
- package/src/DataTable/utils/getCellCopyText.js +0 -7
- package/src/DataTable/utils/getCellInfo.js +0 -36
- package/src/DataTable/utils/getFieldPathToField.js +0 -7
- package/src/DataTable/utils/getIdOrCodeOrIndex.js +0 -9
- package/src/DataTable/utils/getLastSelectedEntity.js +0 -11
- package/src/DataTable/utils/getNewEntToSelect.js +0 -25
- package/src/DataTable/utils/getRowCopyText.js +0 -28
- package/src/DataTable/utils/getTableConfigFromStorage.js +0 -5
- package/src/DataTable/utils/handleCopyColumn.js +0 -21
- package/src/DataTable/utils/handleCopyHelper.js +0 -15
- package/src/DataTable/utils/handleCopyRows.js +0 -23
- package/src/DataTable/utils/handleCopyTable.js +0 -16
- package/src/DataTable/utils/index.js +0 -55
- package/src/DataTable/utils/initializeHasuraWhereAndFilter.js +0 -26
- package/src/DataTable/utils/isBottomRightCornerOfRectangle.js +0 -20
- package/src/DataTable/utils/isEntityClean.js +0 -15
- package/src/DataTable/utils/primarySelectedValue.js +0 -1
- package/src/DataTable/utils/queryParams.js +0 -350
- package/src/DataTable/utils/removeCleanRows.js +0 -22
- package/src/DataTable/utils/rowClick.js +0 -181
- package/src/DataTable/utils/selection.js +0 -8
- package/src/DataTable/utils/tableQueryParamsToHasuraClauses.js +0 -253
- package/src/DataTable/utils/tableQueryParamsToHasuraClauses.test.js +0 -206
- package/src/DataTable/utils/useTableEntities.js +0 -38
- package/src/DataTable/utils/utils.js +0 -37
- package/src/DataTable/utils/withSelectedEntities.js +0 -65
- package/src/DataTable/utils/withTableParams.js +0 -288
- package/src/DataTable/validateTableWideErrors.js +0 -160
- package/src/DataTable/viewColumn.js +0 -97
- package/src/DialogFooter/index.js +0 -86
- package/src/DialogFooter/style.css +0 -9
- package/src/DropdownButton.js +0 -36
- package/src/FillWindow.css +0 -6
- package/src/FillWindow.js +0 -69
- package/src/FormComponents/FormSeparator.js +0 -9
- package/src/FormComponents/LoadingDots.js +0 -14
- package/src/FormComponents/Uploader.js +0 -1278
- package/src/FormComponents/getNewName.js +0 -31
- package/src/FormComponents/index.js +0 -1266
- package/src/FormComponents/itemUpload.js +0 -84
- package/src/FormComponents/sortify.js +0 -73
- package/src/FormComponents/style.css +0 -275
- package/src/FormComponents/tryToMatchSchemas.js +0 -264
- 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/MatchHeaders.js +0 -234
- 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/SimpleStepViz.js +0 -22
- package/src/Tag.js +0 -112
- 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/TimelineEvent.js +0 -31
- package/src/Timeline/index.js +0 -15
- package/src/Timeline/style.css +0 -29
- package/src/UploadCsvWizard.css +0 -4
- package/src/UploadCsvWizard.js +0 -719
- package/src/autoTooltip.js +0 -201
- package/src/constants.js +0 -1
- package/src/customIcons.js +0 -361
- package/src/enhancers/withDialog/index.js +0 -196
- package/src/enhancers/withDialog/tg_modalState.js +0 -47
- package/src/enhancers/withField.js +0 -20
- package/src/enhancers/withFields.js +0 -11
- package/src/enhancers/withLocalStorage.js +0 -11
- package/src/index.js +0 -88
- package/src/rerenderOnWindowResize.js +0 -26
- package/src/showAppSpinner.js +0 -12
- package/src/showConfirmationDialog/index.js +0 -148
- package/src/showDialogOnDocBody.js +0 -33
- package/src/style.css +0 -265
- package/src/throwFormError.js +0 -16
- package/src/toastr.js +0 -148
- package/src/typeToCommonType.js +0 -6
- package/src/useDialog.js +0 -63
- package/src/utils/adHoc.js +0 -10
- package/src/utils/basicHandleActionsWithFullState.js +0 -14
- package/src/utils/browserUtils.js +0 -3
- package/src/utils/combineReducersWithFullState.js +0 -14
- package/src/utils/commandControls.js +0 -82
- package/src/utils/commandUtils.js +0 -112
- package/src/utils/determineBlackOrWhiteTextColor.js +0 -4
- package/src/utils/getDayjsFormatter.js +0 -35
- package/src/utils/getTextFromEl.js +0 -28
- package/src/utils/handlerHelpers.js +0 -24
- package/src/utils/hooks/index.js +0 -1
- package/src/utils/hooks/useDeepEqualMemo.js +0 -15
- package/src/utils/hooks/useStableReference.js +0 -9
- package/src/utils/hotkeyUtils.js +0 -131
- package/src/utils/isBeingCalledExcessively.js +0 -24
- package/src/utils/menuUtils.js +0 -433
- package/src/utils/popoverOverflowModifiers.js +0 -11
- package/src/utils/pureNoFunc.js +0 -31
- package/src/utils/renderOnDoc.js +0 -32
- package/src/utils/showProgressToast.js +0 -22
- package/src/utils/tagUtils.js +0 -45
- package/src/utils/tgFormValues.js +0 -35
- package/src/utils/useTraceUpdate.js +0 -19
- package/src/utils/withSelectTableRecords.js +0 -43
- package/src/utils/withStore.js +0 -10
- package/src/wrapDialog.js +0 -116
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
Dialog,
|
|
4
|
-
Tab,
|
|
5
|
-
Tabs,
|
|
6
|
-
KeyCombo,
|
|
7
|
-
Classes /*, Tooltip*/
|
|
8
|
-
} from "@blueprintjs/core";
|
|
9
|
-
// import { startCase } from "lodash-es";
|
|
10
|
-
import classNames from "classnames";
|
|
11
|
-
import {
|
|
12
|
-
getHotkeyProps /*, hotkeysById, comboToLabel*/
|
|
13
|
-
} from "../utils/hotkeyUtils";
|
|
14
|
-
|
|
15
|
-
import "./style.css";
|
|
16
|
-
|
|
17
|
-
export default function HotkeysDialog(props) {
|
|
18
|
-
if (!props.hotkeySets) {
|
|
19
|
-
console.error("Missing hotkeySets in HotkeysDialog");
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
const sections = Object.keys(props.hotkeySets);
|
|
23
|
-
return (
|
|
24
|
-
<Dialog
|
|
25
|
-
isOpen={props.isOpen}
|
|
26
|
-
onClose={props.onClose}
|
|
27
|
-
title={props.dialogTitle || "Keyboard Shortcuts"}
|
|
28
|
-
>
|
|
29
|
-
<Tabs className="tg-hotkeys-dialog">
|
|
30
|
-
{sections.map(name => (
|
|
31
|
-
<Tab
|
|
32
|
-
key={name}
|
|
33
|
-
id={name}
|
|
34
|
-
title={sections.length === 1 ? undefined : name}
|
|
35
|
-
panel={
|
|
36
|
-
<div className="tg-table-wrapper">
|
|
37
|
-
<table
|
|
38
|
-
className={classNames(
|
|
39
|
-
Classes.HTML_TABLE,
|
|
40
|
-
Classes.HTML_TABLE_STRIPED,
|
|
41
|
-
Classes.HTML_TABLE_BORDERED
|
|
42
|
-
)}
|
|
43
|
-
>
|
|
44
|
-
<thead>
|
|
45
|
-
<tr>
|
|
46
|
-
<th>Action</th>
|
|
47
|
-
<th>Shortcut</th>
|
|
48
|
-
</tr>
|
|
49
|
-
</thead>
|
|
50
|
-
<tbody>
|
|
51
|
-
{Object.keys(props.hotkeySets[name]).map(id => {
|
|
52
|
-
const def = getHotkeyProps(
|
|
53
|
-
props.hotkeySets[name][id],
|
|
54
|
-
id
|
|
55
|
-
);
|
|
56
|
-
return (
|
|
57
|
-
<tr key={id}>
|
|
58
|
-
<td>{def.label}</td>
|
|
59
|
-
<td>
|
|
60
|
-
<KeyCombo combo={def.combo} />
|
|
61
|
-
{/* <Tooltip
|
|
62
|
-
content={comboToLabel(def.combo, false)}
|
|
63
|
-
>
|
|
64
|
-
{comboToLabel(def.combo)}
|
|
65
|
-
</Tooltip> */}
|
|
66
|
-
</td>
|
|
67
|
-
</tr>
|
|
68
|
-
);
|
|
69
|
-
})}
|
|
70
|
-
</tbody>
|
|
71
|
-
</table>
|
|
72
|
-
</div>
|
|
73
|
-
}
|
|
74
|
-
/>
|
|
75
|
-
))}
|
|
76
|
-
</Tabs>
|
|
77
|
-
</Dialog>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
.tg-hotkeys-dialog .bp3-tab-list {
|
|
2
|
-
/* border-top: 1px solid #ddd; */
|
|
3
|
-
display: flex;
|
|
4
|
-
justify-content: center;
|
|
5
|
-
padding-left: 10px;
|
|
6
|
-
margin-top: 5px;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.tg-hotkeys-dialog table {
|
|
10
|
-
table-layout: fixed;
|
|
11
|
-
margin: 0 5px 5px;
|
|
12
|
-
width: calc(100% - 10px);
|
|
13
|
-
border-spacing: 0;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.tg-hotkeys-dialog .bp3-tab-panel {
|
|
17
|
-
margin-top: 5px;
|
|
18
|
-
padding: 10px;
|
|
19
|
-
}
|
|
20
|
-
.tg-hotkeys-dialog thead,
|
|
21
|
-
.tg-hotkeys-dialog tbody tr {
|
|
22
|
-
display: table;
|
|
23
|
-
width: 100%;
|
|
24
|
-
table-layout: fixed; /* even columns width , fix width of table too*/
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.tg-hotkeys-dialog .tg-table-wrapper tbody {
|
|
28
|
-
display: block;
|
|
29
|
-
max-height: 55vh;
|
|
30
|
-
overflow-y: auto;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.tg-hotkeys-dialog th {
|
|
34
|
-
width: 50%;
|
|
35
|
-
font-weight: bold;
|
|
36
|
-
color: black;
|
|
37
|
-
border-bottom: 3px solid #ddd;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.tg-hotkeys-dialog tr:nth-child(2n) td {
|
|
41
|
-
background-color: #f8f8f8;
|
|
42
|
-
}
|
|
43
|
-
.bp3-dark .tg-hotkeys-dialog tr:nth-child(2n) td {
|
|
44
|
-
background-color: #3e4b6d;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.tg-hotkeys-dialog td,
|
|
48
|
-
.tg-hotkeys-dialog th {
|
|
49
|
-
padding: 8px 12px;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.tg-hotkeys-dialog td:first-child {
|
|
53
|
-
border-right: 1px solid lightgrey;
|
|
54
|
-
}
|
package/src/InfoHelper/index.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Popover, Button, Tooltip, Icon } from "@blueprintjs/core";
|
|
3
|
-
import classnames from "classnames";
|
|
4
|
-
import "./style.css";
|
|
5
|
-
import { popoverOverflowModifiers } from "..";
|
|
6
|
-
|
|
7
|
-
export default ({
|
|
8
|
-
className,
|
|
9
|
-
content,
|
|
10
|
-
children,
|
|
11
|
-
icon = "info-sign",
|
|
12
|
-
isPopover,
|
|
13
|
-
isButton,
|
|
14
|
-
size,
|
|
15
|
-
isInline,
|
|
16
|
-
clickable,
|
|
17
|
-
color,
|
|
18
|
-
noMarginTop,
|
|
19
|
-
popoverProps = {},
|
|
20
|
-
disabled,
|
|
21
|
-
displayToSide,
|
|
22
|
-
style,
|
|
23
|
-
...rest
|
|
24
|
-
}) => {
|
|
25
|
-
const IconToUse = isButton ? Button : Icon;
|
|
26
|
-
const iconProps = {
|
|
27
|
-
icon,
|
|
28
|
-
color,
|
|
29
|
-
disabled
|
|
30
|
-
};
|
|
31
|
-
if (!isButton) iconProps.iconSize = size;
|
|
32
|
-
|
|
33
|
-
const IconInner = <IconToUse {...iconProps} {...rest} />;
|
|
34
|
-
let toReturn;
|
|
35
|
-
const toolTipOrPopoverProps = {
|
|
36
|
-
disabled:
|
|
37
|
-
disabled ||
|
|
38
|
-
(!isPopover && window.Cypress && !window.Cypress.allowInfoHelperTooltips),
|
|
39
|
-
popoverClassName: "tg-info-helper-popover bp3-tooltip",
|
|
40
|
-
content: content || children,
|
|
41
|
-
modifiers: popoverOverflowModifiers,
|
|
42
|
-
...popoverProps
|
|
43
|
-
};
|
|
44
|
-
if (displayToSide) {
|
|
45
|
-
toReturn = (
|
|
46
|
-
<React.Fragment>
|
|
47
|
-
{IconInner}
|
|
48
|
-
<span style={{ paddingLeft: 5, fontStyle: "italic" }}>
|
|
49
|
-
{content || children}
|
|
50
|
-
</span>
|
|
51
|
-
</React.Fragment>
|
|
52
|
-
);
|
|
53
|
-
} else if (isPopover) {
|
|
54
|
-
toReturn = <Popover {...toolTipOrPopoverProps} target={IconInner} />;
|
|
55
|
-
} else {
|
|
56
|
-
toReturn = <Tooltip {...toolTipOrPopoverProps} target={IconInner} />;
|
|
57
|
-
}
|
|
58
|
-
const El = isInline ? "span" : "div";
|
|
59
|
-
return (
|
|
60
|
-
<El
|
|
61
|
-
style={{
|
|
62
|
-
...(clickable ? { cursor: "pointer" } : {}),
|
|
63
|
-
...(isInline ? {} : { display: "flex" }),
|
|
64
|
-
...style
|
|
65
|
-
}}
|
|
66
|
-
className={classnames(
|
|
67
|
-
"info-helper-wrapper",
|
|
68
|
-
{
|
|
69
|
-
"info-helper-wrapper-noMarginTop": noMarginTop,
|
|
70
|
-
"info-helper-clickable": isPopover
|
|
71
|
-
},
|
|
72
|
-
className
|
|
73
|
-
)}
|
|
74
|
-
>
|
|
75
|
-
{toReturn}
|
|
76
|
-
</El>
|
|
77
|
-
);
|
|
78
|
-
};
|
package/src/InfoHelper/style.css
DELETED
package/src/IntentText/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Classes } from "@blueprintjs/core";
|
|
3
|
-
import classNames from "classnames";
|
|
4
|
-
|
|
5
|
-
const intentToClass = {
|
|
6
|
-
danger: Classes.INTENT_DANGER,
|
|
7
|
-
warning: Classes.INTENT_WARNING,
|
|
8
|
-
success: Classes.INTENT_SUCCESS,
|
|
9
|
-
primary: Classes.INTENT_PRIMARY
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default function IntentText({ intent, text, children }) {
|
|
13
|
-
return (
|
|
14
|
-
<div className={classNames(Classes.FORM_GROUP, intentToClass[intent])}>
|
|
15
|
-
<div className={Classes.FORM_HELPER_TEXT}>{text || children}</div>
|
|
16
|
-
</div>
|
|
17
|
-
);
|
|
18
|
-
}
|
package/src/Loading/index.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from "react";
|
|
2
|
-
import DNALoader from "../DNALoader";
|
|
3
|
-
import "./style.css";
|
|
4
|
-
import { BounceLoader } from "../BounceLoader";
|
|
5
|
-
|
|
6
|
-
const Loading = ({
|
|
7
|
-
loading,
|
|
8
|
-
style: userStyle,
|
|
9
|
-
className,
|
|
10
|
-
containerStyle = {},
|
|
11
|
-
children,
|
|
12
|
-
displayInstantly = false,
|
|
13
|
-
bounce = false,
|
|
14
|
-
withTimeout,
|
|
15
|
-
inDialog,
|
|
16
|
-
centeredInPage
|
|
17
|
-
}) => {
|
|
18
|
-
const [longerThan200MS, setLongerThan200MS] = useState(false);
|
|
19
|
-
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
const timeoutId = setTimeout(() => {
|
|
22
|
-
setLongerThan200MS(true);
|
|
23
|
-
}, 200);
|
|
24
|
-
|
|
25
|
-
return () => {
|
|
26
|
-
clearTimeout(timeoutId);
|
|
27
|
-
};
|
|
28
|
-
}, []);
|
|
29
|
-
|
|
30
|
-
const style = {
|
|
31
|
-
...userStyle,
|
|
32
|
-
...(inDialog && { minHeight: 120 })
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const LoaderComp = bounce || inDialog ? BounceLoader : DNALoader;
|
|
36
|
-
|
|
37
|
-
if (loading || !children) {
|
|
38
|
-
if (
|
|
39
|
-
!displayInstantly &&
|
|
40
|
-
!longerThan200MS &&
|
|
41
|
-
((!bounce && !inDialog) || withTimeout)
|
|
42
|
-
) {
|
|
43
|
-
return <div />;
|
|
44
|
-
}
|
|
45
|
-
return (
|
|
46
|
-
<div
|
|
47
|
-
className="tg-loader-container tg-flex justify-center align-center"
|
|
48
|
-
style={{
|
|
49
|
-
width: "100%",
|
|
50
|
-
...containerStyle,
|
|
51
|
-
...(centeredInPage && {
|
|
52
|
-
width: undefined,
|
|
53
|
-
zIndex: 20,
|
|
54
|
-
height: 10,
|
|
55
|
-
position: "fixed",
|
|
56
|
-
top: "50%",
|
|
57
|
-
left: "50%",
|
|
58
|
-
transform: "translate(-50%, 0)"
|
|
59
|
-
})
|
|
60
|
-
}}
|
|
61
|
-
>
|
|
62
|
-
<LoaderComp style={style} className={className} />
|
|
63
|
-
</div>
|
|
64
|
-
);
|
|
65
|
-
} else {
|
|
66
|
-
return children || null;
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export default Loading;
|
package/src/Loading/style.css
DELETED
package/src/MatchHeaders.js
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from "react";
|
|
2
|
-
import { Callout, Card, Intent } from "@blueprintjs/core";
|
|
3
|
-
import immer, { setAutoFreeze } from "immer";
|
|
4
|
-
import { flatMap, forEach } from "lodash-es";
|
|
5
|
-
import { ReactSelectField } from "./FormComponents";
|
|
6
|
-
import showConfirmationDialog from "./showConfirmationDialog";
|
|
7
|
-
import { startCase } from "lodash-es";
|
|
8
|
-
import { typeToCommonType } from "./typeToCommonType";
|
|
9
|
-
import { camelCase } from "lodash-es";
|
|
10
|
-
import { change } from "redux-form";
|
|
11
|
-
import { useDispatch } from "react-redux";
|
|
12
|
-
|
|
13
|
-
setAutoFreeze(false);
|
|
14
|
-
export const MatchHeaders = ({
|
|
15
|
-
csvValidationIssue,
|
|
16
|
-
datatableFormName,
|
|
17
|
-
datatableFormNames: _datatableFormNames,
|
|
18
|
-
doAllFilesHaveSameHeaders,
|
|
19
|
-
fileIndex,
|
|
20
|
-
filesWIssues,
|
|
21
|
-
ignoredHeadersMsg,
|
|
22
|
-
matchedHeaders,
|
|
23
|
-
onMultiFileUploadSubmit,
|
|
24
|
-
reduxFormEntitiesArray,
|
|
25
|
-
searchResults,
|
|
26
|
-
setFilesWIssues,
|
|
27
|
-
userSchema
|
|
28
|
-
}) => {
|
|
29
|
-
const datatableFormNames = _datatableFormNames || [datatableFormName];
|
|
30
|
-
const dispatch = useDispatch();
|
|
31
|
-
const flippedMatchedHeaders = useMemo(() => {
|
|
32
|
-
const _flippedMatchedHeaders = {};
|
|
33
|
-
forEach(matchedHeaders, (v, k) => {
|
|
34
|
-
if (v) _flippedMatchedHeaders[v] = k;
|
|
35
|
-
});
|
|
36
|
-
return _flippedMatchedHeaders;
|
|
37
|
-
}, [matchedHeaders]);
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<div style={{ maxWidth: 500 }}>
|
|
41
|
-
{!onMultiFileUploadSubmit && (
|
|
42
|
-
<Callout style={{ width: "fit-content" }} intent="warning">
|
|
43
|
-
{csvValidationIssue}
|
|
44
|
-
</Callout>
|
|
45
|
-
)}
|
|
46
|
-
{!onMultiFileUploadSubmit && ignoredHeadersMsg && (
|
|
47
|
-
<Callout style={{ width: "fit-content" }} intent="warning">
|
|
48
|
-
{ignoredHeadersMsg}
|
|
49
|
-
</Callout>
|
|
50
|
-
)}
|
|
51
|
-
<br />
|
|
52
|
-
<tr
|
|
53
|
-
style={{
|
|
54
|
-
display: "flex",
|
|
55
|
-
minHeight: 50,
|
|
56
|
-
alignItems: "center",
|
|
57
|
-
justifyContent: "space-between"
|
|
58
|
-
}}
|
|
59
|
-
>
|
|
60
|
-
<td
|
|
61
|
-
style={{
|
|
62
|
-
width: 200,
|
|
63
|
-
marginLeft: 20,
|
|
64
|
-
display: "flex",
|
|
65
|
-
fontWeight: "bold"
|
|
66
|
-
}}
|
|
67
|
-
>
|
|
68
|
-
Accepted Headers
|
|
69
|
-
</td>
|
|
70
|
-
<td
|
|
71
|
-
style={{
|
|
72
|
-
width: 200,
|
|
73
|
-
marginLeft: 20,
|
|
74
|
-
display: "flex",
|
|
75
|
-
fontWeight: "bold"
|
|
76
|
-
}}
|
|
77
|
-
>
|
|
78
|
-
Your Headers
|
|
79
|
-
</td>
|
|
80
|
-
<td
|
|
81
|
-
style={{
|
|
82
|
-
fontWeight: "bold",
|
|
83
|
-
marginLeft: 30
|
|
84
|
-
}}
|
|
85
|
-
>
|
|
86
|
-
Data Preview
|
|
87
|
-
</td>
|
|
88
|
-
</tr>
|
|
89
|
-
{searchResults.map(({ path, displayName, type }, i) => {
|
|
90
|
-
const userMatchedHeader = matchedHeaders[path];
|
|
91
|
-
const opts = flatMap(userSchema.fields, ({ path: pathInner }) => {
|
|
92
|
-
if (
|
|
93
|
-
pathInner !== userMatchedHeader &&
|
|
94
|
-
flippedMatchedHeaders[pathInner]
|
|
95
|
-
) {
|
|
96
|
-
return [];
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
99
|
-
value: pathInner,
|
|
100
|
-
label: pathInner
|
|
101
|
-
};
|
|
102
|
-
}).sort((a, b) => {
|
|
103
|
-
const ra = searchResults[i].matches
|
|
104
|
-
.map(m => m.item.path)
|
|
105
|
-
.indexOf(a.value);
|
|
106
|
-
const rb = searchResults[i].matches
|
|
107
|
-
.map(m => m.item.path)
|
|
108
|
-
.indexOf(b.value);
|
|
109
|
-
if (!ra) return -1;
|
|
110
|
-
if (!rb) return 1;
|
|
111
|
-
return rb - ra;
|
|
112
|
-
});
|
|
113
|
-
return (
|
|
114
|
-
<Card style={{ padding: 2 }} key={`field-${i}`}>
|
|
115
|
-
<table>
|
|
116
|
-
<tbody>
|
|
117
|
-
<tr
|
|
118
|
-
style={{
|
|
119
|
-
display: "flex",
|
|
120
|
-
minHeight: 50,
|
|
121
|
-
alignItems: "center",
|
|
122
|
-
justifyContent: "space-between"
|
|
123
|
-
}}
|
|
124
|
-
>
|
|
125
|
-
<td
|
|
126
|
-
style={{
|
|
127
|
-
width: 200,
|
|
128
|
-
display: "flex"
|
|
129
|
-
}}
|
|
130
|
-
>
|
|
131
|
-
<div
|
|
132
|
-
style={{
|
|
133
|
-
paddingTop: 2,
|
|
134
|
-
marginLeft: 15,
|
|
135
|
-
fontSize: 15
|
|
136
|
-
}}
|
|
137
|
-
>
|
|
138
|
-
<span
|
|
139
|
-
data-tip={`Column Type: ${
|
|
140
|
-
typeToCommonType[type || "string"] || type
|
|
141
|
-
}`}
|
|
142
|
-
>
|
|
143
|
-
{displayName || startCase(camelCase(path))}
|
|
144
|
-
</span>
|
|
145
|
-
</div>
|
|
146
|
-
</td>
|
|
147
|
-
<td style={{ width: 200 }}>
|
|
148
|
-
<ReactSelectField
|
|
149
|
-
noMarginBottom
|
|
150
|
-
tooltipError
|
|
151
|
-
beforeOnChange={async () => {
|
|
152
|
-
const clearEntities = () => {
|
|
153
|
-
datatableFormNames.forEach(name => {
|
|
154
|
-
dispatch(change(name, "reduxFormEntities", null));
|
|
155
|
-
});
|
|
156
|
-
};
|
|
157
|
-
if (reduxFormEntitiesArray.some(r => r?.isDirty)) {
|
|
158
|
-
//when the column mapping changes, update the column in reduxFormEntities (if reduxFormEntities exists)
|
|
159
|
-
const doAction = await showConfirmationDialog({
|
|
160
|
-
text: "Are you sure you want to edit the columm mapping? This will clear any changes you've already made to the table data",
|
|
161
|
-
intent: Intent.DANGER,
|
|
162
|
-
confirmButtonText: "Yes",
|
|
163
|
-
cancelButtonText: "No"
|
|
164
|
-
// canEscapeKeyCancel: true //this is false by default
|
|
165
|
-
});
|
|
166
|
-
if (doAction) {
|
|
167
|
-
clearEntities();
|
|
168
|
-
} else {
|
|
169
|
-
return { stopEarly: true };
|
|
170
|
-
}
|
|
171
|
-
} else {
|
|
172
|
-
clearEntities();
|
|
173
|
-
return { stopEarly: false };
|
|
174
|
-
}
|
|
175
|
-
}}
|
|
176
|
-
onChange={val => {
|
|
177
|
-
setFilesWIssues(
|
|
178
|
-
immer(filesWIssues, files => {
|
|
179
|
-
files.forEach((f, i) => {
|
|
180
|
-
const isCurrentFile = fileIndex === i;
|
|
181
|
-
if (isCurrentFile || doAllFilesHaveSameHeaders) {
|
|
182
|
-
f.matchedHeaders[path] = val;
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
})
|
|
186
|
-
);
|
|
187
|
-
}}
|
|
188
|
-
name={path}
|
|
189
|
-
// isRequired={!allowEmpty && defaultValue === undefined}
|
|
190
|
-
defaultValue={userMatchedHeader}
|
|
191
|
-
options={opts}
|
|
192
|
-
/>
|
|
193
|
-
</td>
|
|
194
|
-
<td
|
|
195
|
-
style={{
|
|
196
|
-
marginTop: 10,
|
|
197
|
-
marginBottom: 10,
|
|
198
|
-
marginLeft: 20,
|
|
199
|
-
fontSize: 10 /* color: Colors.RED1 */
|
|
200
|
-
}}
|
|
201
|
-
>
|
|
202
|
-
{userMatchedHeader &&
|
|
203
|
-
[
|
|
204
|
-
// { [userMatchedHeader]: "Preview:" },
|
|
205
|
-
...(userSchema.userData?.slice(0, 3) || [])
|
|
206
|
-
// { [userMatchedHeader]: "..." }
|
|
207
|
-
].map((row, i) => {
|
|
208
|
-
return (
|
|
209
|
-
<div
|
|
210
|
-
style={{
|
|
211
|
-
maxWidth: 70,
|
|
212
|
-
overflow: "hidden",
|
|
213
|
-
textOverflow: "ellipsis",
|
|
214
|
-
whiteSpace: "nowrap"
|
|
215
|
-
}}
|
|
216
|
-
key={`userMatchedHeader-${i}`}
|
|
217
|
-
>
|
|
218
|
-
{row?.[userMatchedHeader] || ""}
|
|
219
|
-
</div>
|
|
220
|
-
);
|
|
221
|
-
})}
|
|
222
|
-
{/* {!allowEmpty &&
|
|
223
|
-
defaultValue === undefined &&
|
|
224
|
-
"(Required)"} */}
|
|
225
|
-
</td>
|
|
226
|
-
</tr>
|
|
227
|
-
</tbody>
|
|
228
|
-
</table>
|
|
229
|
-
</Card>
|
|
230
|
-
);
|
|
231
|
-
})}
|
|
232
|
-
</div>
|
|
233
|
-
);
|
|
234
|
-
};
|