@teselagen/ui 0.7.33-beta.6 → 0.7.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AdvancedOptions.js +33 -0
- package/AssignDefaultsModeContext.js +22 -0
- package/CellDragHandle.js +132 -0
- package/ColumnFilterMenu.js +62 -0
- package/Columns.js +979 -0
- package/DataTable/utils/queryParams.d.ts +14 -7
- package/DisabledLoadingComponent.js +15 -0
- package/DisplayOptions.js +199 -0
- package/DropdownButton.js +36 -0
- package/DropdownCell.js +61 -0
- package/EditableCell.js +44 -0
- package/FillWindow.css +6 -0
- package/FillWindow.js +69 -0
- package/FilterAndSortMenu.js +391 -0
- package/FormSeparator.js +9 -0
- package/LoadingDots.js +14 -0
- package/MatchHeaders.js +234 -0
- package/PagingTool.js +225 -0
- package/RenderCell.js +191 -0
- package/SearchBar.js +69 -0
- package/SimpleStepViz.js +22 -0
- package/SortableColumns.js +100 -0
- package/TableFormTrackerContext.js +10 -0
- package/Tag.js +112 -0
- package/ThComponent.js +44 -0
- package/TimelineEvent.js +31 -0
- package/UploadCsvWizard.css +4 -0
- package/UploadCsvWizard.js +719 -0
- package/Uploader.js +1278 -0
- package/adHoc.js +10 -0
- package/autoTooltip.js +201 -0
- package/basicHandleActionsWithFullState.js +14 -0
- package/browserUtils.js +3 -0
- package/combineReducersWithFullState.js +14 -0
- package/commandControls.js +82 -0
- package/commandUtils.js +112 -0
- package/constants.js +1 -0
- package/convertSchema.js +69 -0
- package/customIcons.js +361 -0
- package/dataTableEnhancer.js +41 -0
- package/defaultFormatters.js +32 -0
- package/defaultValidators.js +40 -0
- package/determineBlackOrWhiteTextColor.js +4 -0
- package/editCellHelper.js +44 -0
- package/formatPasteData.js +16 -0
- package/getAllRows.js +11 -0
- package/getCellCopyText.js +7 -0
- package/getCellInfo.js +36 -0
- package/getCellVal.js +20 -0
- package/getDayjsFormatter.js +35 -0
- package/getFieldPathToField.js +7 -0
- package/getIdOrCodeOrIndex.js +9 -0
- package/getLastSelectedEntity.js +11 -0
- package/getNewEntToSelect.js +25 -0
- package/getNewName.js +31 -0
- package/getRowCopyText.js +28 -0
- package/getTableConfigFromStorage.js +5 -0
- package/getTextFromEl.js +28 -0
- package/getVals.js +8 -0
- package/handleCopyColumn.js +21 -0
- package/handleCopyHelper.js +15 -0
- package/handleCopyRows.js +23 -0
- package/handleCopyTable.js +16 -0
- package/handlerHelpers.js +24 -0
- package/hotkeyUtils.js +131 -0
- package/index.cjs.js +972 -837
- package/index.d.ts +0 -1
- package/index.es.js +972 -837
- package/index.js +196 -0
- package/isBeingCalledExcessively.js +31 -0
- package/isBottomRightCornerOfRectangle.js +20 -0
- package/isEntityClean.js +15 -0
- package/isTruthy.js +12 -0
- package/isValueEmpty.js +3 -0
- package/itemUpload.js +84 -0
- package/menuUtils.js +433 -0
- package/package.json +1 -2
- package/popoverOverflowModifiers.js +11 -0
- package/primarySelectedValue.js +1 -0
- package/pureNoFunc.js +31 -0
- package/queryParams.js +1058 -0
- package/removeCleanRows.js +22 -0
- package/renderOnDoc.js +32 -0
- package/rerenderOnWindowResize.js +26 -0
- package/rowClick.js +181 -0
- package/selection.js +8 -0
- package/showAppSpinner.js +12 -0
- package/showDialogOnDocBody.js +33 -0
- package/showProgressToast.js +22 -0
- package/sortify.js +73 -0
- package/style.css +29 -0
- package/tagUtils.js +45 -0
- package/tgFormValues.js +35 -0
- package/tg_modalState.js +47 -0
- package/throwFormError.js +16 -0
- package/toastr.js +148 -0
- package/tryToMatchSchemas.js +264 -0
- package/typeToCommonType.js +6 -0
- package/useDeepEqualMemo.js +15 -0
- package/useDialog.js +63 -0
- package/useStableReference.js +9 -0
- package/useTableEntities.js +38 -0
- package/useTraceUpdate.js +19 -0
- package/utils.js +37 -0
- package/validateTableWideErrors.js +160 -0
- package/viewColumn.js +97 -0
- package/withField.js +20 -0
- package/withFields.js +11 -0
- package/withLocalStorage.js +11 -0
- package/withSelectTableRecords.js +43 -0
- package/withSelectedEntities.js +65 -0
- package/withStore.js +10 -0
- package/withTableParams.js +301 -0
- package/wrapDialog.js +116 -0
package/index.js
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Dialog } from "@blueprintjs/core";
|
|
3
|
+
import { connect } from "react-redux";
|
|
4
|
+
import { lifecycle, compose } from "recompose";
|
|
5
|
+
import { camelCase } from "lodash-es";
|
|
6
|
+
import { nanoid } from "nanoid";
|
|
7
|
+
import ResizableDraggableDialog from "../../ResizableDraggableDialog";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* usage:
|
|
11
|
+
* in container:
|
|
12
|
+
* compose(
|
|
13
|
+
* withDialog({ title: "Select Aliquot(s) From", other bp dialog props here })
|
|
14
|
+
* )
|
|
15
|
+
*
|
|
16
|
+
*
|
|
17
|
+
* in react component
|
|
18
|
+
* import MyDialogEnhancedComponent from "./MyDialogEnhancedComponent"
|
|
19
|
+
*
|
|
20
|
+
* render() {
|
|
21
|
+
* return <div>
|
|
22
|
+
* <MyDialogEnhancedComponent
|
|
23
|
+
* dialogProps={} //bp dialog overrides can go here
|
|
24
|
+
* target={<button>Open Dialog</button> } //target can also be passed as a child component
|
|
25
|
+
* myRandomProp={'yuppp'} //pass any other props like normal to the component
|
|
26
|
+
*
|
|
27
|
+
* />
|
|
28
|
+
* </div>
|
|
29
|
+
* }
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
// or programatically:
|
|
33
|
+
// const ProgramaticDialog = withDialog({
|
|
34
|
+
// dialogName: "programaticDialog", //giving it a unique dialogName means you can
|
|
35
|
+
// title: "Programatic Dialog Demo"
|
|
36
|
+
// })(DialogInner);
|
|
37
|
+
//
|
|
38
|
+
// add the no target dialog somewhere on the page
|
|
39
|
+
// <ProgramaticDialog></ProgramaticDialog> //this just renders without any target
|
|
40
|
+
//
|
|
41
|
+
// somewhere else on the page:
|
|
42
|
+
// <Button>Click To Open Dialog</Button>
|
|
43
|
+
|
|
44
|
+
export default function withDialog(topLevelDialogProps) {
|
|
45
|
+
function dialogHoc(WrappedComponent) {
|
|
46
|
+
return class DialogWrapper extends React.Component {
|
|
47
|
+
componentWillUnmount() {
|
|
48
|
+
const { dispatch, dialogName, uniqueName } = this.props;
|
|
49
|
+
if (dialogName) {
|
|
50
|
+
dispatch({
|
|
51
|
+
type: "TG_UNREGISTER_MODAL",
|
|
52
|
+
name: dialogName,
|
|
53
|
+
uniqueName
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
render() {
|
|
58
|
+
const {
|
|
59
|
+
target,
|
|
60
|
+
noTarget,
|
|
61
|
+
isDialogOpen,
|
|
62
|
+
showModal,
|
|
63
|
+
dialogName,
|
|
64
|
+
onClickRename,
|
|
65
|
+
hideModal,
|
|
66
|
+
fetchPolicy = "network-only",
|
|
67
|
+
children,
|
|
68
|
+
onCloseHook,
|
|
69
|
+
dialogProps,
|
|
70
|
+
title,
|
|
71
|
+
isDraggable,
|
|
72
|
+
alreadyRendering,
|
|
73
|
+
...rest
|
|
74
|
+
} = this.props;
|
|
75
|
+
const extraDialogProps = {
|
|
76
|
+
...topLevelDialogProps,
|
|
77
|
+
...dialogProps
|
|
78
|
+
};
|
|
79
|
+
const _onCloseHook = onCloseHook || extraDialogProps.onCloseHook;
|
|
80
|
+
const { noButtonClickPropagate } = {
|
|
81
|
+
...this.props,
|
|
82
|
+
...extraDialogProps
|
|
83
|
+
};
|
|
84
|
+
const isOpen = isDialogOpen || extraDialogProps.isOpen;
|
|
85
|
+
const targetEl = target || children;
|
|
86
|
+
// if (!targetEl && !dialogName)
|
|
87
|
+
// throw new Error(
|
|
88
|
+
// "withDialog error: Please provide a target or child element to the withDialog() enhanced component. If you really don't want a target, please pass a 'noTarget=true' prop"
|
|
89
|
+
// );
|
|
90
|
+
const DialogToUse =
|
|
91
|
+
isDraggable || extraDialogProps.isDraggable
|
|
92
|
+
? ResizableDraggableDialog
|
|
93
|
+
: Dialog;
|
|
94
|
+
return (
|
|
95
|
+
<React.Fragment>
|
|
96
|
+
{isOpen && (
|
|
97
|
+
<DialogToUse
|
|
98
|
+
onClose={function () {
|
|
99
|
+
hideModal();
|
|
100
|
+
_onCloseHook && _onCloseHook();
|
|
101
|
+
}}
|
|
102
|
+
className={dialogName || camelCase()}
|
|
103
|
+
title={title}
|
|
104
|
+
isOpen={isOpen}
|
|
105
|
+
canEscapeKeyClose={false}
|
|
106
|
+
canOutsideClickClose={false}
|
|
107
|
+
{...extraDialogProps}
|
|
108
|
+
>
|
|
109
|
+
<WrappedComponent
|
|
110
|
+
{...{
|
|
111
|
+
...rest,
|
|
112
|
+
fetchPolicy,
|
|
113
|
+
ssr: false,
|
|
114
|
+
hideModal
|
|
115
|
+
}}
|
|
116
|
+
/>
|
|
117
|
+
</DialogToUse>
|
|
118
|
+
)}
|
|
119
|
+
{targetEl &&
|
|
120
|
+
React.cloneElement(targetEl, {
|
|
121
|
+
[onClickRename || "onClick"]: e => {
|
|
122
|
+
showModal();
|
|
123
|
+
if (noButtonClickPropagate) {
|
|
124
|
+
e.preventDefault();
|
|
125
|
+
e.stopPropagation();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
})}
|
|
129
|
+
</React.Fragment>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return compose(
|
|
136
|
+
connect(({ tg_modalState }) => {
|
|
137
|
+
return { ...topLevelDialogProps, tg_modalState };
|
|
138
|
+
}),
|
|
139
|
+
lifecycle({
|
|
140
|
+
componentWillMount: function () {
|
|
141
|
+
const { dispatch, dialogName } = this.props;
|
|
142
|
+
const uniqueName = nanoid();
|
|
143
|
+
const nameToUse = dialogName || uniqueName;
|
|
144
|
+
this.setState({
|
|
145
|
+
nameToUse,
|
|
146
|
+
uniqueName
|
|
147
|
+
});
|
|
148
|
+
if (dialogName) {
|
|
149
|
+
dispatch({
|
|
150
|
+
type: "TG_REGISTER_MODAL",
|
|
151
|
+
name: dialogName,
|
|
152
|
+
uniqueName
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}),
|
|
157
|
+
connect(
|
|
158
|
+
function ({ tg_modalState }, { nameToUse, uniqueName }) {
|
|
159
|
+
const dialogState = tg_modalState[nameToUse] || {};
|
|
160
|
+
const { open, __registeredAs, ...rest } = dialogState;
|
|
161
|
+
const newProps = {
|
|
162
|
+
...rest,
|
|
163
|
+
isDialogOpen:
|
|
164
|
+
open &&
|
|
165
|
+
(__registeredAs
|
|
166
|
+
? Object.keys(__registeredAs)[
|
|
167
|
+
Object.keys(__registeredAs).length - 1
|
|
168
|
+
] === uniqueName
|
|
169
|
+
: true)
|
|
170
|
+
};
|
|
171
|
+
return newProps;
|
|
172
|
+
},
|
|
173
|
+
function (dispatch, { nameToUse, hideModal, showModal }) {
|
|
174
|
+
return {
|
|
175
|
+
showModal:
|
|
176
|
+
showModal ||
|
|
177
|
+
function () {
|
|
178
|
+
dispatch({
|
|
179
|
+
type: "TG_SHOW_MODAL",
|
|
180
|
+
name: nameToUse
|
|
181
|
+
});
|
|
182
|
+
},
|
|
183
|
+
hideModal:
|
|
184
|
+
hideModal ||
|
|
185
|
+
function () {
|
|
186
|
+
dispatch({
|
|
187
|
+
type: "TG_HIDE_MODAL",
|
|
188
|
+
name: nameToUse
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
),
|
|
194
|
+
dialogHoc
|
|
195
|
+
);
|
|
196
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const keyCount = {};
|
|
2
|
+
// if this function is hit more than 20 times in a row in 2 seconds with the same uniqName then throw an error
|
|
3
|
+
export const isBeingCalledExcessively = ({ uniqName }) => {
|
|
4
|
+
if (process.env.NODE_ENV !== "development") {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
if (!uniqName) {
|
|
8
|
+
throw new Error("uniqName is required");
|
|
9
|
+
}
|
|
10
|
+
// Initialize the count if it doesn't exist
|
|
11
|
+
keyCount[uniqName] = keyCount[uniqName] || 0;
|
|
12
|
+
keyCount[uniqName]++;
|
|
13
|
+
|
|
14
|
+
// Only set the timeout if it doesn't exist already to ensure it runs exactly once every 2 seconds
|
|
15
|
+
if (!keyCount[uniqName + "_timeout"]) {
|
|
16
|
+
keyCount[uniqName + "_timeout"] = setTimeout(() => {
|
|
17
|
+
keyCount[uniqName] = 0;
|
|
18
|
+
keyCount[uniqName + "_timeout"] = null;
|
|
19
|
+
}, 2000);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (keyCount[uniqName] > 20) {
|
|
23
|
+
keyCount[uniqName] = 0;
|
|
24
|
+
// Also clear the timeout when throwing an error
|
|
25
|
+
if (keyCount[uniqName + "_timeout"]) {
|
|
26
|
+
clearTimeout(keyCount[uniqName + "_timeout"]);
|
|
27
|
+
keyCount[uniqName + "_timeout"] = null;
|
|
28
|
+
}
|
|
29
|
+
throw new Error(`isBeingCalledExcessively: ${uniqName}`);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const isBottomRightCornerOfRectangle = ({
|
|
2
|
+
cellId,
|
|
3
|
+
selectionGrid,
|
|
4
|
+
lastRowIndex,
|
|
5
|
+
lastCellIndex,
|
|
6
|
+
entityMap,
|
|
7
|
+
pathToIndex
|
|
8
|
+
}) => {
|
|
9
|
+
selectionGrid.forEach(row => {
|
|
10
|
+
// remove undefineds from start of row
|
|
11
|
+
while (row[0] === undefined && row.length) row.shift();
|
|
12
|
+
});
|
|
13
|
+
const [rowId, cellPath] = cellId.split(":");
|
|
14
|
+
const ent = entityMap[rowId];
|
|
15
|
+
if (!ent) return;
|
|
16
|
+
const { i } = ent;
|
|
17
|
+
const cellIndex = pathToIndex[cellPath];
|
|
18
|
+
const isBottomRight = i === lastRowIndex && cellIndex === lastCellIndex;
|
|
19
|
+
return isBottomRight;
|
|
20
|
+
};
|
package/isEntityClean.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function isEntityClean(e) {
|
|
2
|
+
if (typeof e !== "object" || e === null) {
|
|
3
|
+
return true; // or return false depending on what you want for non-object inputs
|
|
4
|
+
}
|
|
5
|
+
let isClean = true;
|
|
6
|
+
for (const [key, val] of Object.entries(e)) {
|
|
7
|
+
if (key === "id") continue;
|
|
8
|
+
if (key === "_isClean") continue;
|
|
9
|
+
if (val) {
|
|
10
|
+
isClean = false;
|
|
11
|
+
break;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return isClean;
|
|
15
|
+
}
|
package/isTruthy.js
ADDED
package/isValueEmpty.js
ADDED
package/itemUpload.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
ProgressBar,
|
|
4
|
+
Intent,
|
|
5
|
+
Button,
|
|
6
|
+
Tooltip,
|
|
7
|
+
Position,
|
|
8
|
+
Icon
|
|
9
|
+
} from "@blueprintjs/core";
|
|
10
|
+
|
|
11
|
+
const itemUpload = props => {
|
|
12
|
+
const item = props.item;
|
|
13
|
+
const name = nameShortener(item.name);
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div className="item-upload-container" key={item.id}>
|
|
17
|
+
<div className="item-upload">
|
|
18
|
+
<div>
|
|
19
|
+
{!props.saved ? (
|
|
20
|
+
<Tooltip
|
|
21
|
+
content={
|
|
22
|
+
<span>
|
|
23
|
+
{`Click to
|
|
24
|
+
${props.active ? "abort this uploading" : "remove this file"}`}
|
|
25
|
+
</span>
|
|
26
|
+
}
|
|
27
|
+
position={Position.LEFT}
|
|
28
|
+
usePortal={true}
|
|
29
|
+
>
|
|
30
|
+
<Button
|
|
31
|
+
intent={Intent.DANGER}
|
|
32
|
+
minimal
|
|
33
|
+
icon="delete"
|
|
34
|
+
onClick={props.onCancel}
|
|
35
|
+
/>
|
|
36
|
+
</Tooltip>
|
|
37
|
+
) : null}
|
|
38
|
+
</div>
|
|
39
|
+
<div>
|
|
40
|
+
<span>{name}</span>
|
|
41
|
+
</div>
|
|
42
|
+
<div>
|
|
43
|
+
{props.active ? `${props.value}%` : null}
|
|
44
|
+
{props.error ? (
|
|
45
|
+
<Tooltip content={props.error} usePortal={true}>
|
|
46
|
+
<Icon icon="error" intent={Intent.DANGER} />
|
|
47
|
+
</Tooltip>
|
|
48
|
+
) : null}
|
|
49
|
+
{props.saved ? (
|
|
50
|
+
<Tooltip content={"File Saved"} usePortal={true}>
|
|
51
|
+
<Icon icon="saved" intent={Intent.SUCCESS} />
|
|
52
|
+
</Tooltip>
|
|
53
|
+
) : null}
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
{props.active ? (
|
|
57
|
+
<ProgressBar intent={Intent.PRIMARY} value={props.value / 100} />
|
|
58
|
+
) : null}
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Short file names length to display
|
|
65
|
+
* @param {*} itemName
|
|
66
|
+
*/
|
|
67
|
+
const nameShortener = itemName => {
|
|
68
|
+
if (itemName.length > 40) {
|
|
69
|
+
let name = "";
|
|
70
|
+
const arr = itemName.split(".");
|
|
71
|
+
name += `${arr[0].substring(0, 20)}...`;
|
|
72
|
+
if (arr.length >= 2) {
|
|
73
|
+
name += `${arr[arr.length - 2].substring(
|
|
74
|
+
arr[arr.length - 2].length - 5,
|
|
75
|
+
arr[arr.length - 2].length
|
|
76
|
+
)}`;
|
|
77
|
+
name += `.${arr[arr.length - 1]}`;
|
|
78
|
+
}
|
|
79
|
+
return name;
|
|
80
|
+
}
|
|
81
|
+
return itemName;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export default itemUpload;
|