@teselagen/ui 0.7.35 → 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 +1 -0
- package/package.json +1 -1
- 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
package/src/utils/menuUtils.js
DELETED
|
@@ -1,433 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { lifecycle, compose, branch } from "recompose";
|
|
3
|
-
import { withRouter, Link } from "react-router-dom";
|
|
4
|
-
import {
|
|
5
|
-
MenuItem,
|
|
6
|
-
MenuDivider,
|
|
7
|
-
Tooltip,
|
|
8
|
-
KeyCombo,
|
|
9
|
-
ContextMenu,
|
|
10
|
-
Menu,
|
|
11
|
-
Classes,
|
|
12
|
-
Icon
|
|
13
|
-
} from "@blueprintjs/core";
|
|
14
|
-
import {
|
|
15
|
-
startCase,
|
|
16
|
-
omit,
|
|
17
|
-
isNumber,
|
|
18
|
-
flatMap,
|
|
19
|
-
isArray,
|
|
20
|
-
isString,
|
|
21
|
-
noop
|
|
22
|
-
} from "lodash-es";
|
|
23
|
-
import fuzzysearch from "fuzzysearch";
|
|
24
|
-
import classNames from "classnames";
|
|
25
|
-
// https://github.com/palantir/blueprint/issues/2820
|
|
26
|
-
export function MenuItemLink({ text, onClick, icon, navTo, active, disabled }) {
|
|
27
|
-
if (disabled) {
|
|
28
|
-
return (
|
|
29
|
-
<li className={Classes.POPOVER_DISMISS}>
|
|
30
|
-
<MenuItem icon={icon} disabled={true} text={text} />
|
|
31
|
-
</li>
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
const handleLinkClick = e => {
|
|
35
|
-
e.target.closest(`.${Classes.POPOVER_DISMISS}`).click();
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<li className={Classes.POPOVER_DISMISS} onClick={onClick}>
|
|
40
|
-
<Link
|
|
41
|
-
onClick={handleLinkClick}
|
|
42
|
-
to={navTo}
|
|
43
|
-
className={classNames(Classes.MENU_ITEM, {
|
|
44
|
-
[Classes.ACTIVE]: active,
|
|
45
|
-
[Classes.INTENT_PRIMARY]: active
|
|
46
|
-
})}
|
|
47
|
-
>
|
|
48
|
-
{icon && <Icon icon={icon} />}
|
|
49
|
-
<div className="bp3-text-overflow-ellipsis bp3-fill">{text}</div>
|
|
50
|
-
</Link>
|
|
51
|
-
</li>
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Enhanced MenuItem that supports history-based navigation when passed a
|
|
56
|
-
// `navTo` prop
|
|
57
|
-
export const EnhancedMenuItem = compose(
|
|
58
|
-
lifecycle({
|
|
59
|
-
componentDidMount: function () {
|
|
60
|
-
const { didMount = noop, className } = this.props;
|
|
61
|
-
didMount({ className });
|
|
62
|
-
},
|
|
63
|
-
componentWillUnmount: function () {
|
|
64
|
-
const { willUnmount = noop, className } = this.props;
|
|
65
|
-
willUnmount({ className });
|
|
66
|
-
}
|
|
67
|
-
}),
|
|
68
|
-
branch(({ navTo }) => navTo, withRouter)
|
|
69
|
-
)(function ({
|
|
70
|
-
navTo,
|
|
71
|
-
context,
|
|
72
|
-
staticContext,
|
|
73
|
-
didMount,
|
|
74
|
-
willUnmount,
|
|
75
|
-
...props
|
|
76
|
-
}) {
|
|
77
|
-
let MenuItemComp = MenuItem;
|
|
78
|
-
if (navTo) {
|
|
79
|
-
MenuItemComp = MenuItemLink;
|
|
80
|
-
}
|
|
81
|
-
return (
|
|
82
|
-
<MenuItemComp
|
|
83
|
-
popoverProps={{
|
|
84
|
-
autoFocus: false
|
|
85
|
-
}}
|
|
86
|
-
{...(navTo && { navTo })}
|
|
87
|
-
{...props}
|
|
88
|
-
onClick={
|
|
89
|
-
props.onClick
|
|
90
|
-
? (...args) => {
|
|
91
|
-
return props.onClick(...args, context);
|
|
92
|
-
}
|
|
93
|
-
: undefined
|
|
94
|
-
}
|
|
95
|
-
/>
|
|
96
|
-
);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
// First Non-Undefined
|
|
100
|
-
function fnu(...args) {
|
|
101
|
-
return args.find(v => v !== undefined);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Sets a tick icon if items has a `checked` prop
|
|
105
|
-
export const tickMenuEnhancer = def => {
|
|
106
|
-
const out = { ...def };
|
|
107
|
-
if (out.checked !== undefined) {
|
|
108
|
-
out.icon = out.checked ? "small-tick" : "blank";
|
|
109
|
-
}
|
|
110
|
-
return out;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
// Derives various menu item props based on command objects matched via the `cmd`
|
|
114
|
-
// prop. Derived props include `text`, `icon`, `hotkey`, `onClick` and `disabled`.
|
|
115
|
-
export const commandMenuEnhancer =
|
|
116
|
-
(commands, config = {}) =>
|
|
117
|
-
(def, context) => {
|
|
118
|
-
const cmdId = typeof def === "string" ? def : def.cmd;
|
|
119
|
-
let item = typeof def === "string" ? { cmd: def } : { ...def };
|
|
120
|
-
|
|
121
|
-
const useTicks = fnu(item.useTicks, config.useTicks);
|
|
122
|
-
delete item.useTicks;
|
|
123
|
-
|
|
124
|
-
if (cmdId && commands[cmdId] && def.divider === undefined) {
|
|
125
|
-
const command = commands[cmdId];
|
|
126
|
-
|
|
127
|
-
const { isActive, isDisabled, isHidden } = command;
|
|
128
|
-
const toggles = isActive !== undefined;
|
|
129
|
-
|
|
130
|
-
item.hidden = fnu(item.hidden, isHidden);
|
|
131
|
-
item.disabled = fnu(item.disabled, isDisabled);
|
|
132
|
-
|
|
133
|
-
item.key = item.key || cmdId;
|
|
134
|
-
item.submenu = item.submenu || command.submenu;
|
|
135
|
-
item.component = item.component || command.component;
|
|
136
|
-
|
|
137
|
-
if (toggles) {
|
|
138
|
-
if (useTicks) {
|
|
139
|
-
item.text = item.text || command.shortName || command.name;
|
|
140
|
-
item.checked = item.checked || isActive;
|
|
141
|
-
} else {
|
|
142
|
-
item.text =
|
|
143
|
-
item.text ||
|
|
144
|
-
(isActive ? command.name : command.inactiveName || command.name);
|
|
145
|
-
item.icon =
|
|
146
|
-
item.icon ||
|
|
147
|
-
(isActive ? command.icon : command.inactiveIcon || command.icon);
|
|
148
|
-
}
|
|
149
|
-
} else {
|
|
150
|
-
item.text = item.text || command.name;
|
|
151
|
-
item.icon = item.icon || command.icon;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
item.hotkey = item.hotkey || command.hotkey;
|
|
155
|
-
if (!item.onClick) {
|
|
156
|
-
item.onClick = event =>
|
|
157
|
-
command.execute({
|
|
158
|
-
event,
|
|
159
|
-
context,
|
|
160
|
-
menuItem: item,
|
|
161
|
-
viaMenu: true
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
} else if (cmdId && !commands[cmdId]) {
|
|
165
|
-
item.text = item.text || startCase(cmdId);
|
|
166
|
-
item.disabled = true;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (config.omitIcons) {
|
|
170
|
-
item.icon = undefined;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if (config.forceIconAlignment !== false) {
|
|
174
|
-
item.icon = item.icon || "blank";
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (useTicks) {
|
|
178
|
-
item = tickMenuEnhancer(item);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return item;
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
const ident = x => x;
|
|
185
|
-
|
|
186
|
-
const dividerShorthandEnhancer = def =>
|
|
187
|
-
typeof def === "string" && def.startsWith("--")
|
|
188
|
-
? { divider: def.substr(2) }
|
|
189
|
-
: def;
|
|
190
|
-
|
|
191
|
-
// filter out unwanted attributes here! we won't want these to show up on the dom element or react will give nasty warnings
|
|
192
|
-
const unwantedAttrs = [
|
|
193
|
-
"isSimpleText",
|
|
194
|
-
"justText",
|
|
195
|
-
"submenu",
|
|
196
|
-
"component",
|
|
197
|
-
"hotkey",
|
|
198
|
-
"changingProps",
|
|
199
|
-
"showInSearchMenu",
|
|
200
|
-
"hideFromMenuSearch"
|
|
201
|
-
];
|
|
202
|
-
|
|
203
|
-
/** A menu item component that adds many features over the standard MenuItem,
|
|
204
|
-
* and allows for dynamic menu structures that are computed efficiently (only
|
|
205
|
-
* visible sections are computed and rendered).
|
|
206
|
-
* TODO: document and add examples
|
|
207
|
-
*/
|
|
208
|
-
export const DynamicMenuItem = ({
|
|
209
|
-
def,
|
|
210
|
-
enhancers = [ident],
|
|
211
|
-
context,
|
|
212
|
-
doNotEnhanceTopLevelItem
|
|
213
|
-
}) => {
|
|
214
|
-
// If passed an element instead of a menu item definition, return it.
|
|
215
|
-
// This allows mixing menu item elements and menu item defs, and makes it
|
|
216
|
-
// safe to call menu creation utils with their own output.
|
|
217
|
-
if (React.isValidElement(def)) return def;
|
|
218
|
-
|
|
219
|
-
const item = [
|
|
220
|
-
dividerShorthandEnhancer,
|
|
221
|
-
...(doNotEnhanceTopLevelItem ? [ident] : enhancers)
|
|
222
|
-
].reduce((v, f) => f(v, context), def);
|
|
223
|
-
let out;
|
|
224
|
-
if (item.divider !== undefined) {
|
|
225
|
-
out = (
|
|
226
|
-
<MenuDivider
|
|
227
|
-
{...(item.divider
|
|
228
|
-
? { title: item.divider, className: item.className }
|
|
229
|
-
: {})}
|
|
230
|
-
/>
|
|
231
|
-
);
|
|
232
|
-
} else {
|
|
233
|
-
const ItemComponent = item.component || EnhancedMenuItem;
|
|
234
|
-
out = (
|
|
235
|
-
<ItemComponent
|
|
236
|
-
// filter out unwanted attributes here!
|
|
237
|
-
{...omit(item, unwantedAttrs)}
|
|
238
|
-
context={context}
|
|
239
|
-
icon={item.icon || item.iconName}
|
|
240
|
-
labelElement={item.hotkey && <KeyCombo minimal combo={item.hotkey} />}
|
|
241
|
-
text={item.text}
|
|
242
|
-
>
|
|
243
|
-
{item.submenu
|
|
244
|
-
? item.submenu
|
|
245
|
-
.filter(ident)
|
|
246
|
-
.map((def, index) => (
|
|
247
|
-
<DynamicMenuItem key={index} {...{ def, enhancers, context }} />
|
|
248
|
-
))
|
|
249
|
-
: undefined}
|
|
250
|
-
</ItemComponent>
|
|
251
|
-
);
|
|
252
|
-
}
|
|
253
|
-
// if (item.disabled && item.disabledTooltip) {
|
|
254
|
-
// item.tooltip = def.disabledTooltip
|
|
255
|
-
// }
|
|
256
|
-
if (item.disabled && typeof item.disabled === "string") {
|
|
257
|
-
item.tooltip = item.disabled;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
if (item.tooltip) {
|
|
261
|
-
out = <Tooltip content={item.tooltip}>{out}</Tooltip>;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
return item.hidden ? null : out;
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
// Map the passed item definition(s) to DynamicMenuItem elements
|
|
268
|
-
export const createDynamicMenu = (menuDef, enhancers, context) => {
|
|
269
|
-
if (menuDef instanceof Array) {
|
|
270
|
-
return menuDef.map((def, index) => (
|
|
271
|
-
<DynamicMenuItem key={index} {...{ def, enhancers, context }} />
|
|
272
|
-
));
|
|
273
|
-
} else {
|
|
274
|
-
return <DynamicMenuItem {...{ def: menuDef, enhancers, context }} />;
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
// Create a "bar" menu, keeping the top level array unchanged, and only
|
|
279
|
-
// map their submenus to DynamicMenuItem elements
|
|
280
|
-
export const createDynamicBarMenu = (topMenuDef, enhancers, context) => {
|
|
281
|
-
return topMenuDef.map(topLevelItem => {
|
|
282
|
-
const def = { ...topLevelItem };
|
|
283
|
-
if (def.submenu) {
|
|
284
|
-
def.submenu = def.submenu.map((subdef, index) => (
|
|
285
|
-
<DynamicMenuItem key={index} def={subdef} {...{ enhancers, context }} />
|
|
286
|
-
));
|
|
287
|
-
}
|
|
288
|
-
return def;
|
|
289
|
-
});
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
// Shorthand for command-based menus
|
|
293
|
-
export const createCommandMenu = (menuDef, commands, config, context) => {
|
|
294
|
-
return createDynamicMenu(
|
|
295
|
-
menuDef,
|
|
296
|
-
[commandMenuEnhancer(commands, config)],
|
|
297
|
-
context
|
|
298
|
-
);
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
// Shorthand for command-based bar menus
|
|
302
|
-
export const createCommandBarMenu = (menuDef, commands, config, context) => {
|
|
303
|
-
return createDynamicBarMenu(
|
|
304
|
-
menuDef,
|
|
305
|
-
[commandMenuEnhancer(commands, config)],
|
|
306
|
-
context
|
|
307
|
-
);
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
export function showCommandContextMenu(
|
|
311
|
-
menuDef,
|
|
312
|
-
commands,
|
|
313
|
-
config,
|
|
314
|
-
event,
|
|
315
|
-
onClose,
|
|
316
|
-
context
|
|
317
|
-
) {
|
|
318
|
-
return showContextMenu(
|
|
319
|
-
menuDef,
|
|
320
|
-
[commandMenuEnhancer(commands, config)],
|
|
321
|
-
event,
|
|
322
|
-
onClose,
|
|
323
|
-
context
|
|
324
|
-
);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* TODO: update documentation. This is now an alias of createDynamicMenu
|
|
329
|
-
*
|
|
330
|
-
* Creates the contents of a Blueprint menu based on a given menu structure.
|
|
331
|
-
*
|
|
332
|
-
* The input can be an array of item objects, where each may contain:
|
|
333
|
-
* text: text to show
|
|
334
|
-
* key: React key to use (optional)
|
|
335
|
-
* divider: indicates it's a divider instead of an item. Use an empty string
|
|
336
|
-
* for a normal divider, or some label text for a labeled one
|
|
337
|
-
* icon: name of icon to show (optional)
|
|
338
|
-
* label: right-aligned label, used mostly for shortcuts (optional)
|
|
339
|
-
* hotkey: right-aligned label formatted with <KeyCombo> (optional)
|
|
340
|
-
* tooltip: tooltip text to use (optional)
|
|
341
|
-
* submenu: nested menu structure describing submenu (i.e. array of item objects),
|
|
342
|
-
* or array of MenuItem elements
|
|
343
|
-
* onClick: click handler
|
|
344
|
-
* navTo: a url to navigate to (assumes react-router)
|
|
345
|
-
* href: a url to link to
|
|
346
|
-
* target: link target
|
|
347
|
-
*
|
|
348
|
-
* Since this function is recursive (to handle nested submenus), and React
|
|
349
|
-
* elements passed as input are returned unchanged, it is possible to freely mix
|
|
350
|
-
* item objects and MenuItem elements. That also makes it safe to call the function
|
|
351
|
-
* with its own output.
|
|
352
|
-
*
|
|
353
|
-
* A customize function may also be provided, and allows customization or
|
|
354
|
-
* replacement of the created MenuItems, allowing for custom props or behavior.
|
|
355
|
-
* That function receives the original created element and the item object, and
|
|
356
|
-
* must return an element.
|
|
357
|
-
*
|
|
358
|
-
* Usage example:
|
|
359
|
-
*
|
|
360
|
-
* const menu = createMenu([
|
|
361
|
-
* { text: 'Item One', icon: 'add', onClick: () => console.info('Clicked 1') },
|
|
362
|
-
* { text: 'Item One', onClick: () => console.info('Clicked 2') },
|
|
363
|
-
* { divider: '' },
|
|
364
|
-
* { text: 'Item Three', icon: 'numerical', onClick: () => console.info('Clicked 3') },
|
|
365
|
-
* { divider: '' },
|
|
366
|
-
* { text: 'Submenus', submenu: [
|
|
367
|
-
* { text: 'Sub One' },
|
|
368
|
-
* { text: 'Sub Two' },
|
|
369
|
-
* ]},
|
|
370
|
-
* ]);
|
|
371
|
-
*
|
|
372
|
-
*/
|
|
373
|
-
export const createMenu = createDynamicMenu;
|
|
374
|
-
|
|
375
|
-
export function showContextMenu(
|
|
376
|
-
menuDef,
|
|
377
|
-
enhancers,
|
|
378
|
-
event,
|
|
379
|
-
onClose,
|
|
380
|
-
context,
|
|
381
|
-
menuComp = Menu
|
|
382
|
-
) {
|
|
383
|
-
menuDef = filterMenuForCorrectness(menuDef);
|
|
384
|
-
if (!menuDef) return;
|
|
385
|
-
|
|
386
|
-
const MenuComponent = menuComp;
|
|
387
|
-
event.persist && event.persist();
|
|
388
|
-
// Render a context menu at the passed event's position
|
|
389
|
-
ContextMenu.show(
|
|
390
|
-
<MenuComponent>
|
|
391
|
-
{createDynamicMenu(menuDef, enhancers, context)}
|
|
392
|
-
</MenuComponent>,
|
|
393
|
-
{ left: event.clientX, top: event.clientY },
|
|
394
|
-
onClose
|
|
395
|
-
);
|
|
396
|
-
event.stopPropagation && event.stopPropagation();
|
|
397
|
-
event.preventDefault && event.preventDefault();
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
function filterMenuForCorrectness(menuDef) {
|
|
401
|
-
return menuDef && menuDef.length && menuDef.filter(ident);
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
export function getStringFromReactComponent(comp) {
|
|
405
|
-
if (!comp) return "";
|
|
406
|
-
if (isString(comp) || isNumber(comp)) return comp;
|
|
407
|
-
if (comp.props?.text) {
|
|
408
|
-
return getStringFromReactComponent(comp.props.text);
|
|
409
|
-
}
|
|
410
|
-
const { children } = comp.props || {};
|
|
411
|
-
if (!children) return "";
|
|
412
|
-
if (isArray(children))
|
|
413
|
-
return flatMap(children, getStringFromReactComponent).join("");
|
|
414
|
-
if (isString(children)) return children;
|
|
415
|
-
|
|
416
|
-
if (children.props) {
|
|
417
|
-
return getStringFromReactComponent(children.props);
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
export function doesSearchValMatchText(searchVal, justText) {
|
|
421
|
-
return fuzzysearch(
|
|
422
|
-
searchVal ? searchVal.toLowerCase() : "",
|
|
423
|
-
justText ? justText.toLowerCase() : ""
|
|
424
|
-
);
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
export const MenuItemWithTooltip = ({ tooltip, ...rest }) => {
|
|
428
|
-
let out = <MenuItem {...rest}></MenuItem>;
|
|
429
|
-
if (tooltip) {
|
|
430
|
-
out = <Tooltip content={tooltip}>{out}</Tooltip>;
|
|
431
|
-
}
|
|
432
|
-
return out;
|
|
433
|
-
};
|
package/src/utils/pureNoFunc.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This HOC compares props to create a pure component that will only update
|
|
3
|
-
* when props are not deep equal. It will compare the string values of functions
|
|
4
|
-
*/
|
|
5
|
-
import { shouldUpdate } from "recompose";
|
|
6
|
-
import { isEqualWith, isFunction } from "lodash-es";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* tgreen: This is an awful function which we should come up with a better solution for
|
|
10
|
-
* @param {*} o1
|
|
11
|
-
* @param {*} o2
|
|
12
|
-
*/
|
|
13
|
-
const isEq = (o1, o2) => {
|
|
14
|
-
const isEq = isEqualWith(o1, o2, function (val1, val2) {
|
|
15
|
-
if (isFunction(val1) && isFunction(val2)) {
|
|
16
|
-
return val1 === val2 || val1.toString() === val2.toString();
|
|
17
|
-
}
|
|
18
|
-
// tgreen: we were seeing an issue where the isEq would infinite loop on react children
|
|
19
|
-
// components. We decided to just ignore them (assume they are equal)
|
|
20
|
-
if (val1 && val1.constructor && val1.constructor.name === "FiberNode")
|
|
21
|
-
return true;
|
|
22
|
-
});
|
|
23
|
-
return isEq;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const pure = BaseComponent => {
|
|
27
|
-
const hoc = shouldUpdate((props, nextProps) => !isEq(props, nextProps));
|
|
28
|
-
return hoc(BaseComponent);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export default pure;
|
package/src/utils/renderOnDoc.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { createRoot } from "react-dom/client";
|
|
2
|
-
|
|
3
|
-
export function renderOnDoc(fn) {
|
|
4
|
-
const elemDiv = document.createElement("div");
|
|
5
|
-
elemDiv.style.cssText =
|
|
6
|
-
"position:absolute;width:100%;height:100%;top:0px;opacity:0.3;z-index:0;";
|
|
7
|
-
document.body.appendChild(elemDiv);
|
|
8
|
-
const root = createRoot(elemDiv);
|
|
9
|
-
const handleClose = () => {
|
|
10
|
-
setTimeout(() => {
|
|
11
|
-
root.unmount(elemDiv);
|
|
12
|
-
document.body.removeChild(elemDiv);
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
root.render(fn(handleClose));
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function renderOnDocSimple(el) {
|
|
19
|
-
const elemDiv = document.createElement("div");
|
|
20
|
-
elemDiv.style.cssText =
|
|
21
|
-
"position:absolute;width:100%;height:100%;top:0px;opacity:1;z-index:10000;";
|
|
22
|
-
document.body.appendChild(elemDiv);
|
|
23
|
-
const root = createRoot(elemDiv);
|
|
24
|
-
root.render(el);
|
|
25
|
-
const handleClose = () => {
|
|
26
|
-
setTimeout(() => {
|
|
27
|
-
root.unmount();
|
|
28
|
-
document.body.removeChild(elemDiv);
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
return handleClose;
|
|
32
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/* Copyright (C) 2018 TeselaGen Biotechnology, Inc. */
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { ProgressBar } from "@blueprintjs/core";
|
|
4
|
-
|
|
5
|
-
export default (message, value, key, opts) => {
|
|
6
|
-
return window.toastr.default(
|
|
7
|
-
<div>
|
|
8
|
-
<div style={{ marginBottom: 10 }}>{message}</div>
|
|
9
|
-
<ProgressBar
|
|
10
|
-
intent={value >= 1 ? "success" : "primary"}
|
|
11
|
-
animate={value < 1 || !value}
|
|
12
|
-
stripes={value < 1 || !value}
|
|
13
|
-
value={value}
|
|
14
|
-
/>
|
|
15
|
-
</div>,
|
|
16
|
-
{
|
|
17
|
-
timeout: value >= 1 ? 3000 : 100000,
|
|
18
|
-
key,
|
|
19
|
-
...opts
|
|
20
|
-
}
|
|
21
|
-
);
|
|
22
|
-
};
|
package/src/utils/tagUtils.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
|
|
3
|
-
// useful for debugging rerender errors
|
|
4
|
-
export const useTraceUpdate = props => {
|
|
5
|
-
const prev = useRef(props);
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
const changedProps = Object.entries(props).reduce((ps, [k, v]) => {
|
|
8
|
-
if (prev.current[k] !== v) {
|
|
9
|
-
ps[k] = [prev.current[k], v];
|
|
10
|
-
}
|
|
11
|
-
return ps;
|
|
12
|
-
}, {});
|
|
13
|
-
if (Object.keys(changedProps).length > 0) {
|
|
14
|
-
// eslint-disable-next-line no-console
|
|
15
|
-
console.log("Changed props:", changedProps);
|
|
16
|
-
}
|
|
17
|
-
prev.current = props;
|
|
18
|
-
});
|
|
19
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/* Copyright (C) 2018 TeselaGen Biotechnology, Inc. */
|
|
2
|
-
import { compose, withHandlers } from "recompose";
|
|
3
|
-
import { connect } from "react-redux";
|
|
4
|
-
import { change, initialize } from "redux-form";
|
|
5
|
-
|
|
6
|
-
export default function (_tableFormName, propName = "selectTableRecords") {
|
|
7
|
-
return compose(
|
|
8
|
-
connect(null, {
|
|
9
|
-
changeFormValue: change,
|
|
10
|
-
initializeForm: initialize
|
|
11
|
-
}),
|
|
12
|
-
withHandlers({
|
|
13
|
-
[propName]:
|
|
14
|
-
props =>
|
|
15
|
-
(_records = []) => {
|
|
16
|
-
let tableFormName = _tableFormName;
|
|
17
|
-
if (typeof _tableFormName === "function") {
|
|
18
|
-
tableFormName = _tableFormName(props);
|
|
19
|
-
}
|
|
20
|
-
// initialize if needed so that the values will stay
|
|
21
|
-
props.initializeForm(tableFormName, {}, true, {
|
|
22
|
-
keepDirty: true,
|
|
23
|
-
updateUnregisteredFields: true,
|
|
24
|
-
keepValues: true
|
|
25
|
-
});
|
|
26
|
-
const selectedEntityIdMap = {};
|
|
27
|
-
let records = _records;
|
|
28
|
-
if (_records && !Array.isArray(_records)) records = [records];
|
|
29
|
-
records.forEach(record => {
|
|
30
|
-
selectedEntityIdMap[record.id] = {
|
|
31
|
-
entity: record,
|
|
32
|
-
time: Date.now()
|
|
33
|
-
};
|
|
34
|
-
});
|
|
35
|
-
props.changeFormValue(
|
|
36
|
-
tableFormName,
|
|
37
|
-
"reduxFormSelectedEntityIdMap",
|
|
38
|
-
selectedEntityIdMap
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
})
|
|
42
|
-
);
|
|
43
|
-
}
|
package/src/utils/withStore.js
DELETED