@teselagen/ui 0.0.9 → 0.0.12
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/README.md +7 -0
- package/cypress.config.ts +6 -0
- package/index.html +12 -0
- package/package.json +2 -2
- package/project.json +74 -0
- package/src/AdvancedOptions.js +33 -0
- package/src/AdvancedOptions.spec.js +24 -0
- package/src/AssignDefaultsModeContext.js +21 -0
- package/src/AsyncValidateFieldSpinner/index.js +12 -0
- package/src/BlueprintError/index.js +14 -0
- package/src/BounceLoader/index.js +16 -0
- package/src/BounceLoader/style.css +45 -0
- package/src/CollapsibleCard/index.js +92 -0
- package/src/CollapsibleCard/style.css +21 -0
- package/src/DNALoader/index.js +20 -0
- package/src/DNALoader/style.css +251 -0
- package/src/DataTable/CellDragHandle.js +130 -0
- package/src/DataTable/DisabledLoadingComponent.js +15 -0
- package/src/DataTable/DisplayOptions.js +218 -0
- package/src/DataTable/FilterAndSortMenu.js +397 -0
- package/src/DataTable/PagingTool.js +232 -0
- package/src/DataTable/SearchBar.js +57 -0
- package/src/DataTable/SortableColumns.js +53 -0
- package/src/DataTable/TableFormTrackerContext.js +10 -0
- package/src/DataTable/dataTableEnhancer.js +291 -0
- package/src/DataTable/defaultFormatters.js +32 -0
- package/src/DataTable/defaultProps.js +45 -0
- package/src/DataTable/defaultValidators.js +40 -0
- package/src/DataTable/editCellHelper.js +44 -0
- package/src/DataTable/getCellVal.js +20 -0
- package/src/DataTable/getVals.js +8 -0
- package/src/DataTable/index.js +3537 -0
- package/src/DataTable/isTruthy.js +12 -0
- package/src/DataTable/isValueEmpty.js +3 -0
- package/src/DataTable/style.css +600 -0
- package/src/DataTable/utils/computePresets.js +42 -0
- package/src/DataTable/utils/convertSchema.js +69 -0
- package/src/DataTable/utils/getIdOrCodeOrIndex.js +9 -0
- package/src/DataTable/utils/getTableConfigFromStorage.js +5 -0
- package/src/DataTable/utils/queryParams.js +1032 -0
- package/src/DataTable/utils/rowClick.js +156 -0
- package/src/DataTable/utils/selection.js +8 -0
- package/src/DataTable/utils/withSelectedEntities.js +65 -0
- package/src/DataTable/utils/withTableParams.js +328 -0
- package/src/DataTable/validateTableWideErrors.js +135 -0
- package/src/DataTable/viewColumn.js +37 -0
- package/src/DialogFooter/index.js +79 -0
- package/src/DialogFooter/style.css +9 -0
- package/src/DropdownButton.js +36 -0
- package/src/FillWindow.css +6 -0
- package/src/FillWindow.js +69 -0
- package/src/FormComponents/Uploader.js +1197 -0
- package/src/FormComponents/getNewName.js +31 -0
- package/src/FormComponents/index.js +1384 -0
- package/src/FormComponents/itemUpload.js +84 -0
- package/src/FormComponents/sortify.js +73 -0
- package/src/FormComponents/style.css +247 -0
- package/src/FormComponents/tryToMatchSchemas.js +222 -0
- package/src/FormComponents/utils.js +6 -0
- package/src/HotkeysDialog/index.js +79 -0
- package/src/HotkeysDialog/style.css +54 -0
- package/src/InfoHelper/index.js +83 -0
- package/src/InfoHelper/style.css +7 -0
- package/src/IntentText/index.js +18 -0
- package/src/Loading/index.js +74 -0
- package/src/Loading/style.css +4 -0
- package/src/MatchHeaders.js +223 -0
- package/src/MenuBar/index.js +416 -0
- package/src/MenuBar/style.css +45 -0
- package/src/PromptUnsavedChanges/index.js +40 -0
- package/src/ResizableDraggableDialog/index.js +138 -0
- package/src/ResizableDraggableDialog/style.css +42 -0
- package/src/ScrollToTop/index.js +72 -0
- package/src/SimpleStepViz.js +26 -0
- package/src/TgSelect/index.js +465 -0
- package/src/TgSelect/style.css +34 -0
- package/src/TgSuggest/index.js +121 -0
- package/src/Timeline/TimelineEvent.js +31 -0
- package/src/Timeline/index.js +22 -0
- package/src/Timeline/style.css +29 -0
- package/src/UploadCsvWizard.css +4 -0
- package/src/UploadCsvWizard.js +731 -0
- package/src/autoTooltip.js +89 -0
- package/src/constants.js +1 -0
- package/src/customIcons.js +361 -0
- package/src/enhancers/withDialog/index.js +196 -0
- package/src/enhancers/withDialog/tg_modalState.js +46 -0
- package/src/enhancers/withField.js +20 -0
- package/src/enhancers/withFields.js +11 -0
- package/src/enhancers/withLocalStorage.js +11 -0
- package/src/index.js +76 -0
- package/src/rerenderOnWindowResize.js +27 -0
- package/src/showAppSpinner.js +12 -0
- package/src/showConfirmationDialog/index.js +116 -0
- package/src/showDialogOnDocBody.js +37 -0
- package/src/style.css +214 -0
- package/src/toastr.js +92 -0
- package/src/typeToCommonType.js +6 -0
- package/src/useDialog.js +64 -0
- package/src/utils/S3Download.js +14 -0
- package/src/utils/adHoc.js +10 -0
- package/src/utils/basicHandleActionsWithFullState.js +14 -0
- package/src/utils/combineReducersWithFullState.js +14 -0
- package/src/utils/commandControls.js +83 -0
- package/src/utils/commandUtils.js +112 -0
- package/src/utils/determineBlackOrWhiteTextColor.js +4 -0
- package/src/utils/getDayjsFormatter.js +35 -0
- package/src/utils/getTextFromEl.js +28 -0
- package/src/utils/handlerHelpers.js +30 -0
- package/src/utils/hotkeyUtils.js +129 -0
- package/src/utils/menuUtils.js +402 -0
- package/src/utils/popoverOverflowModifiers.js +11 -0
- package/src/utils/pureNoFunc.js +31 -0
- package/src/utils/renderOnDoc.js +29 -0
- package/src/utils/showProgressToast.js +22 -0
- package/src/utils/tagUtils.js +45 -0
- package/src/utils/tgFormValues.js +32 -0
- package/src/utils/withSelectTableRecords.js +38 -0
- package/src/utils/withStore.js +10 -0
- package/src/wrapDialog.js +112 -0
- package/tsconfig.json +4 -0
- package/vite.config.ts +7 -0
- package/index.js +0 -80652
- package/index.mjs +0 -80636
- package/index.umd.js +0 -80649
- package/style.css +0 -10421
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { omit } from "lodash";
|
|
2
|
+
export default function tg_modalState(
|
|
3
|
+
state = {},
|
|
4
|
+
{ type, name, uniqueName, props = {} }
|
|
5
|
+
) {
|
|
6
|
+
const existingModalState = state[name] || {};
|
|
7
|
+
const { __registeredAs = {} } = existingModalState;
|
|
8
|
+
if (type === "TG_REGISTER_MODAL") {
|
|
9
|
+
return {
|
|
10
|
+
...state,
|
|
11
|
+
[name]: {
|
|
12
|
+
...existingModalState,
|
|
13
|
+
__registeredAs: { ...__registeredAs, [uniqueName]: true }
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
if (type === "TG_UNREGISTER_MODAL") {
|
|
18
|
+
return {
|
|
19
|
+
...state,
|
|
20
|
+
[name]: {
|
|
21
|
+
...existingModalState,
|
|
22
|
+
__registeredAs: omit(__registeredAs, uniqueName)
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if (type === "TG_SHOW_MODAL") {
|
|
27
|
+
return {
|
|
28
|
+
...state,
|
|
29
|
+
[name]: {
|
|
30
|
+
...existingModalState,
|
|
31
|
+
...props,
|
|
32
|
+
open: true
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (type === "TG_HIDE_MODAL") {
|
|
37
|
+
return {
|
|
38
|
+
...state,
|
|
39
|
+
[name]: {
|
|
40
|
+
__registeredAs: existingModalState.__registeredAs,
|
|
41
|
+
open: false
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return state;
|
|
46
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Field } from "redux-form";
|
|
3
|
+
import { fieldRequired } from "../FormComponents/utils";
|
|
4
|
+
|
|
5
|
+
//simple enhancer that wraps a component in a redux <Field/> component
|
|
6
|
+
//all options are passed as props to <Field/>
|
|
7
|
+
export default function WithField(fieldProps) {
|
|
8
|
+
return function AddFieldHOC(Component) {
|
|
9
|
+
return function AddField({ isRequired, ...rest }) {
|
|
10
|
+
return (
|
|
11
|
+
<Field
|
|
12
|
+
{...(isRequired && { validate: fieldRequired })}
|
|
13
|
+
{...fieldProps}
|
|
14
|
+
{...rest}
|
|
15
|
+
component={Component}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Fields } from "redux-form";
|
|
3
|
+
//simple enhancer that wraps a component in a redux <Fields/> component
|
|
4
|
+
//all options are passed as props to <Fields/>
|
|
5
|
+
export default function WithFields(fieldsProps) {
|
|
6
|
+
return function AddFieldsHOC(Component) {
|
|
7
|
+
return function AddFields(props) {
|
|
8
|
+
return <Fields {...fieldsProps} {...props} component={Component} />;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Field } from "redux-form";
|
|
3
|
+
//simple enhancer that wraps a component in a redux <Field/> component
|
|
4
|
+
//all options are passed as props to <Field/>
|
|
5
|
+
export default function WithField(fieldProps) {
|
|
6
|
+
return function AddFieldHOC(Component) {
|
|
7
|
+
return function AddField(props) {
|
|
8
|
+
return <Field {...fieldProps} {...props} component={Component} />;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import "@blueprintjs/core/lib/css/blueprint.css";
|
|
2
|
+
import "@blueprintjs/datetime/lib/css/blueprint-datetime.css";
|
|
3
|
+
import "@blueprintjs/icons/lib/css/blueprint-icons.css";
|
|
4
|
+
import "./style.css";
|
|
5
|
+
import "./autoTooltip";
|
|
6
|
+
export * from "./AssignDefaultsModeContext";
|
|
7
|
+
export { default as Uploader } from "./FormComponents/Uploader";
|
|
8
|
+
export { mergeSchemas } from "./DataTable/utils/convertSchema";
|
|
9
|
+
export {
|
|
10
|
+
getCurrentParamsFromUrl,
|
|
11
|
+
setCurrentParamsOnUrl
|
|
12
|
+
} from "./DataTable/utils/queryParams";
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
default as withSelectedEntities,
|
|
16
|
+
getSelectedEntities
|
|
17
|
+
} from "./DataTable/utils/withSelectedEntities";
|
|
18
|
+
export {
|
|
19
|
+
default as DataTable,
|
|
20
|
+
ConnectedPagingTool as PagingTool
|
|
21
|
+
} from "./DataTable";
|
|
22
|
+
|
|
23
|
+
export { default as getIdOrCodeOrIndex } from "./DataTable/utils/getIdOrCodeOrIndex";
|
|
24
|
+
export { default as Loading } from "./Loading";
|
|
25
|
+
export { default as AdvancedOptions } from "./AdvancedOptions";
|
|
26
|
+
export { default as TgSelect } from "./TgSelect";
|
|
27
|
+
export { default as wrapDialog } from "./wrapDialog";
|
|
28
|
+
export { default as PromptUnsavedChanges } from "./PromptUnsavedChanges";
|
|
29
|
+
export { default as BlueprintError } from "./BlueprintError";
|
|
30
|
+
export { default as DropdownButton } from "./DropdownButton";
|
|
31
|
+
export { default as DialogFooter } from "./DialogFooter";
|
|
32
|
+
export { default as adHoc } from "./utils/adHoc";
|
|
33
|
+
export { default as IntentText } from "./IntentText";
|
|
34
|
+
export { default as popoverOverflowModifiers } from "./utils/popoverOverflowModifiers";
|
|
35
|
+
export { default as tgFormValues } from "./utils/tgFormValues";
|
|
36
|
+
export { default as withStore } from "./utils/withStore";
|
|
37
|
+
export { default as withTableParams } from "./DataTable/utils/withTableParams";
|
|
38
|
+
export { default as InfoHelper } from "./InfoHelper";
|
|
39
|
+
export { default as showConfirmationDialog } from "./showConfirmationDialog";
|
|
40
|
+
export { default as showAppSpinner } from "./showAppSpinner";
|
|
41
|
+
export { default as CollapsibleCard } from "./CollapsibleCard";
|
|
42
|
+
export { default as ResizableDraggableDialog } from "./ResizableDraggableDialog";
|
|
43
|
+
export { default as MenuBar } from "./MenuBar";
|
|
44
|
+
export { default as rerenderOnWindowResize } from "./rerenderOnWindowResize";
|
|
45
|
+
export { default as HotkeysDialog } from "./HotkeysDialog";
|
|
46
|
+
export { default as FillWindow } from "./FillWindow";
|
|
47
|
+
export { default as withFields } from "./enhancers/withFields";
|
|
48
|
+
export { default as withField } from "./enhancers/withField";
|
|
49
|
+
export { default as withDialog } from "./enhancers/withDialog";
|
|
50
|
+
export { default as tg_modalState } from "./enhancers/withDialog/tg_modalState";
|
|
51
|
+
export { default as Timeline, TimelineEvent } from "./Timeline";
|
|
52
|
+
export * from "./FormComponents";
|
|
53
|
+
export * from "./useDialog";
|
|
54
|
+
|
|
55
|
+
export * from "./toastr";
|
|
56
|
+
export * from "./utils/handlerHelpers";
|
|
57
|
+
export * from "./customIcons";
|
|
58
|
+
export { default as basicHandleActionsWithFullState } from "./utils/basicHandleActionsWithFullState";
|
|
59
|
+
export { default as combineReducersWithFullState } from "./utils/combineReducersWithFullState";
|
|
60
|
+
export { default as withSelectTableRecords } from "./utils/withSelectTableRecords";
|
|
61
|
+
export { default as pureNoFunc } from "./utils/pureNoFunc";
|
|
62
|
+
export * from "./utils/tagUtils";
|
|
63
|
+
export * from "./utils/hotkeyUtils";
|
|
64
|
+
export * from "./utils/menuUtils";
|
|
65
|
+
export * from "./utils/commandUtils";
|
|
66
|
+
export * from "./utils/commandControls";
|
|
67
|
+
|
|
68
|
+
export { default as AsyncValidateFieldSpinner } from "./AsyncValidateFieldSpinner";
|
|
69
|
+
export { default as showProgressToast } from "./utils/showProgressToast";
|
|
70
|
+
export { default as getTextFromEl } from "./utils/getTextFromEl";
|
|
71
|
+
export { default as ScrollToTop } from "./ScrollToTop";
|
|
72
|
+
const noop = () => undefined;
|
|
73
|
+
export { noop };
|
|
74
|
+
export { default as showDialogOnDocBody } from "./showDialogOnDocBody";
|
|
75
|
+
|
|
76
|
+
export { default as TableFormTrackerContext } from "./DataTable/TableFormTrackerContext";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {throttle} from 'lodash'
|
|
2
|
+
// use like this within a react component:
|
|
3
|
+
|
|
4
|
+
// constructor(props){
|
|
5
|
+
// super(props)
|
|
6
|
+
// rerenderOnWindowResize(this)
|
|
7
|
+
// }
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export default function rerenderOnWindowResize(that) {
|
|
11
|
+
that.updateDimensions = throttle(() => {
|
|
12
|
+
if (that.props.disabled) return
|
|
13
|
+
that.forceUpdate()
|
|
14
|
+
}, 250);
|
|
15
|
+
const componentDidMount = that.componentDidMount
|
|
16
|
+
const componentWillUnmount = that.componentWillUnmount
|
|
17
|
+
|
|
18
|
+
that.componentDidMount = (...args)=> {
|
|
19
|
+
componentDidMount && componentDidMount.bind(that)(...args)
|
|
20
|
+
window.addEventListener("resize", that.updateDimensions);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
that.componentWillUnmount = (...args)=> {
|
|
24
|
+
componentWillUnmount && componentWillUnmount.bind(that)(...args)
|
|
25
|
+
window.removeEventListener("resize", that.updateDimensions);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Overlay } from "@blueprintjs/core";
|
|
3
|
+
import { renderOnDocSimple } from "./utils/renderOnDoc";
|
|
4
|
+
import Loading from "./Loading";
|
|
5
|
+
|
|
6
|
+
export default function showAppSpinner() {
|
|
7
|
+
return renderOnDocSimple(
|
|
8
|
+
<Overlay isOpen={true}>
|
|
9
|
+
<Loading centeredInPage loading></Loading>
|
|
10
|
+
</Overlay>
|
|
11
|
+
);
|
|
12
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import React, { Component } from "react";
|
|
2
|
+
import { Button, Dialog, Intent } from "@blueprintjs/core";
|
|
3
|
+
import { renderOnDoc } from "../utils/renderOnDoc";
|
|
4
|
+
import DialogFooter from "../DialogFooter";
|
|
5
|
+
|
|
6
|
+
// usage
|
|
7
|
+
// const doAction = await showConfirmationDialog({
|
|
8
|
+
// text:
|
|
9
|
+
// "Are you sure you want to re-run this tool? Downstream tools with linked outputs will need to be re-run as well!",
|
|
10
|
+
// intent: Intent.DANGER, //applied to the right most confirm button
|
|
11
|
+
// confirmButtonText: "Yep!",
|
|
12
|
+
// cancelButtonText: "Nope",
|
|
13
|
+
// canEscapeKeyCancel: true //this is false by default
|
|
14
|
+
// });
|
|
15
|
+
// console.info("doAction:", doAction);
|
|
16
|
+
|
|
17
|
+
// const doAction = await showConfirmationDialog({
|
|
18
|
+
// thirdButtonText: 'Click me'
|
|
19
|
+
// thirdButtonIntent: 'primary'
|
|
20
|
+
// });
|
|
21
|
+
// console.info("doAction:", doAction); //logs thirdButtonClicked
|
|
22
|
+
//returns a promise that resolves with true or false depending on if the user cancels or not!
|
|
23
|
+
export default function showConfirmationDialog(opts) {
|
|
24
|
+
return new Promise(resolve => {
|
|
25
|
+
renderOnDoc(handleClose => {
|
|
26
|
+
return <AlertWrapper {...{ ...opts, handleClose, resolve }} />;
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
class AlertWrapper extends Component {
|
|
32
|
+
state = { isOpen: true };
|
|
33
|
+
render() {
|
|
34
|
+
const {
|
|
35
|
+
handleClose,
|
|
36
|
+
text,
|
|
37
|
+
resolve,
|
|
38
|
+
noCancelButton,
|
|
39
|
+
content,
|
|
40
|
+
className,
|
|
41
|
+
thirdButtonText,
|
|
42
|
+
thirdButtonIntent,
|
|
43
|
+
fourthButtonText,
|
|
44
|
+
fourthButtonIntent,
|
|
45
|
+
canEscapeKeyCancel,
|
|
46
|
+
confirmButtonText = "OK",
|
|
47
|
+
cancelButtonText = "Cancel",
|
|
48
|
+
intent = Intent.PRIMARY,
|
|
49
|
+
...rest
|
|
50
|
+
} = this.props;
|
|
51
|
+
const doClose = confirm => {
|
|
52
|
+
handleClose();
|
|
53
|
+
this.setState({ isOpen: false });
|
|
54
|
+
resolve(confirm);
|
|
55
|
+
};
|
|
56
|
+
return (
|
|
57
|
+
<Dialog
|
|
58
|
+
className={`bp3-alert ${className || ""}`}
|
|
59
|
+
isOpen={this.state.isOpen}
|
|
60
|
+
intent={intent}
|
|
61
|
+
cancelButtonText={cancelButtonText}
|
|
62
|
+
onCancel={cancelButtonText ? () => doClose(false) : undefined}
|
|
63
|
+
onConfirm={() => doClose(true)}
|
|
64
|
+
{...rest}
|
|
65
|
+
{...(noCancelButton && {
|
|
66
|
+
onCancel: undefined,
|
|
67
|
+
cancelButtonText: undefined
|
|
68
|
+
})}
|
|
69
|
+
>
|
|
70
|
+
<div className="bp3-alert-contents" style={{ padding: 5 }}>
|
|
71
|
+
{content}
|
|
72
|
+
{text && <div style={{ marginBottom: 10 }}>{text}</div>}
|
|
73
|
+
</div>
|
|
74
|
+
<DialogFooter
|
|
75
|
+
{...{
|
|
76
|
+
onBackClick:
|
|
77
|
+
cancelButtonText && !noCancelButton
|
|
78
|
+
? () => doClose(false)
|
|
79
|
+
: undefined,
|
|
80
|
+
onClick: () => doClose(true),
|
|
81
|
+
noCancel: true,
|
|
82
|
+
additionalButtons:
|
|
83
|
+
thirdButtonText || fourthButtonText ? (
|
|
84
|
+
<React.Fragment>
|
|
85
|
+
{!!fourthButtonText && (
|
|
86
|
+
<Button
|
|
87
|
+
intent={fourthButtonIntent}
|
|
88
|
+
text={fourthButtonText}
|
|
89
|
+
onClick={() => {
|
|
90
|
+
doClose("fourthButtonClicked");
|
|
91
|
+
}}
|
|
92
|
+
></Button>
|
|
93
|
+
)}
|
|
94
|
+
{!!thirdButtonText && (
|
|
95
|
+
<Button
|
|
96
|
+
intent={thirdButtonIntent}
|
|
97
|
+
text={thirdButtonText}
|
|
98
|
+
onClick={() => {
|
|
99
|
+
doClose("thirdButtonClicked");
|
|
100
|
+
}}
|
|
101
|
+
></Button>
|
|
102
|
+
)}
|
|
103
|
+
</React.Fragment>
|
|
104
|
+
) : (
|
|
105
|
+
undefined
|
|
106
|
+
),
|
|
107
|
+
containerClassname: "bp3-alert-footer",
|
|
108
|
+
backText: noCancelButton ? "" : cancelButtonText,
|
|
109
|
+
text: confirmButtonText,
|
|
110
|
+
intent
|
|
111
|
+
}}
|
|
112
|
+
></DialogFooter>
|
|
113
|
+
</Dialog>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import ReactDOM from "react-dom";
|
|
2
|
+
import React from "react";
|
|
3
|
+
// import withDialog from "./enhancers/withDialog";
|
|
4
|
+
import { Dialog } from "@blueprintjs/core";
|
|
5
|
+
import { nanoid } from "nanoid";
|
|
6
|
+
|
|
7
|
+
//this is only really useful for unconnected standalone simple dialogs
|
|
8
|
+
//remember to pass usePortal={false} to the <Dialog/> component so it will close properly
|
|
9
|
+
export default function showDialogOnDocBody(DialogComp, options = {}) {
|
|
10
|
+
const dialogHolder = document.createElement("div");
|
|
11
|
+
const className = "myDialog" + nanoid();
|
|
12
|
+
dialogHolder.className = className;
|
|
13
|
+
document.body.appendChild(dialogHolder);
|
|
14
|
+
const onClose = () => {
|
|
15
|
+
document.querySelector("." + className).remove();
|
|
16
|
+
};
|
|
17
|
+
let DialogCompToUse;
|
|
18
|
+
if (options.addDialogContainer) {
|
|
19
|
+
DialogCompToUse = props => {
|
|
20
|
+
return (
|
|
21
|
+
<Dialog usePortal={false} title="pass a {title} prop" isOpen {...props}>
|
|
22
|
+
<DialogComp
|
|
23
|
+
{...props}
|
|
24
|
+
hideModal={onClose}
|
|
25
|
+
onClose={onClose}
|
|
26
|
+
></DialogComp>
|
|
27
|
+
</Dialog>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
} else {
|
|
31
|
+
DialogCompToUse = DialogComp;
|
|
32
|
+
}
|
|
33
|
+
ReactDOM.render(
|
|
34
|
+
<DialogCompToUse hideModal={onClose} onClose={onClose} {...options} />,
|
|
35
|
+
dialogHolder
|
|
36
|
+
);
|
|
37
|
+
}
|
package/src/style.css
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--base1: #ffffff;
|
|
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;
|
|
89
|
+
position: relative;
|
|
90
|
+
vertical-align: top;
|
|
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;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.link-button {
|
|
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
|
+
[data-tippy-root] {
|
|
161
|
+
z-index: 100000 !important;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
[data-tippy-root] .tippy-box {
|
|
165
|
+
background-color: #394b59;
|
|
166
|
+
color: #f5f8fa;
|
|
167
|
+
padding: 4px 4px;
|
|
168
|
+
word-break: break-word;
|
|
169
|
+
}
|
|
170
|
+
[data-tippy-root] .tippy-arrow {
|
|
171
|
+
color: #394b59;
|
|
172
|
+
}
|
|
173
|
+
.bp3-dark [data-tippy-root] .tippy-box {
|
|
174
|
+
background-color: #e1e8ed;
|
|
175
|
+
color: #394b59;
|
|
176
|
+
}
|
|
177
|
+
.bp3-dark [data-tippy-root] .tippy-arrow {
|
|
178
|
+
/* background-color: #e1e8ed; */
|
|
179
|
+
color: #e1e8ed;
|
|
180
|
+
}
|
|
181
|
+
.isCellEditable .rt-td {
|
|
182
|
+
position: relative;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.ReactTable .tg-cell-edit-boolean-checkbox {
|
|
186
|
+
margin-bottom: 0;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.cellDragHandle {
|
|
190
|
+
height: 8px;
|
|
191
|
+
width: 8px;
|
|
192
|
+
cursor: crosshair;
|
|
193
|
+
border: 1px solid rgb(255, 255, 255);
|
|
194
|
+
background-color: rgb(76, 107, 171);
|
|
195
|
+
position: absolute;
|
|
196
|
+
bottom: -4px;
|
|
197
|
+
right: -4px;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/* make AnchorButton match Button */
|
|
201
|
+
.bp3-button {
|
|
202
|
+
font-family: Arial;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
button {
|
|
206
|
+
transition: all 0.2s ease-in-out;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
button:not(:disabled):active {
|
|
210
|
+
transform: translateY(1px);
|
|
211
|
+
}
|
|
212
|
+
.bp3-tabs.bp3-vertical > .bp3-tab-panel {
|
|
213
|
+
min-width: 0px;
|
|
214
|
+
}
|
package/src/toastr.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Position, Toaster, Intent } from "@blueprintjs/core";
|
|
2
|
+
|
|
3
|
+
const TopToaster = Toaster.create({
|
|
4
|
+
className: "top-toaster",
|
|
5
|
+
position: Position.TOP
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
const BottomToaster = Toaster.create({
|
|
9
|
+
className: "bottom-toaster",
|
|
10
|
+
position: Position.BOTTOM
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
window.__tgClearAllToasts = () => {
|
|
14
|
+
TopToaster.clear();
|
|
15
|
+
BottomToaster.clear();
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
let counter = 5000;
|
|
19
|
+
const generateToast = intent => (message, options) => {
|
|
20
|
+
options = options || {};
|
|
21
|
+
const toastToUse = options.bottom ? BottomToaster : TopToaster;
|
|
22
|
+
let updatedTimeout;
|
|
23
|
+
if (options.updateTimeout) {
|
|
24
|
+
//generate a slightly different than default timeout to make the update stay on the page for a full 5 seconds
|
|
25
|
+
if (counter > 5500) {
|
|
26
|
+
updatedTimeout = --counter;
|
|
27
|
+
} else {
|
|
28
|
+
updatedTimeout = ++counter;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (window.Cypress && intent === Intent.DANGER) {
|
|
32
|
+
console.error("toastr error message: ", message);
|
|
33
|
+
}
|
|
34
|
+
const uniqKey = toastToUse.show(
|
|
35
|
+
{
|
|
36
|
+
intent,
|
|
37
|
+
message,
|
|
38
|
+
timeout: options.timeout || updatedTimeout,
|
|
39
|
+
action: options.action,
|
|
40
|
+
icon: options.icon,
|
|
41
|
+
className: options.className
|
|
42
|
+
},
|
|
43
|
+
options.key
|
|
44
|
+
);
|
|
45
|
+
function clear() {
|
|
46
|
+
toastToUse.dismiss(uniqKey);
|
|
47
|
+
}
|
|
48
|
+
clear.key = uniqKey;
|
|
49
|
+
return clear;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
function preventDuplicates(func) {
|
|
53
|
+
const previousToasts = {};
|
|
54
|
+
return (message, options = {}) => {
|
|
55
|
+
const clearToast = func(message, options);
|
|
56
|
+
// no duplicate check for toasts with updates
|
|
57
|
+
|
|
58
|
+
if (!options.key) {
|
|
59
|
+
if (!options.key && previousToasts[message]) {
|
|
60
|
+
previousToasts[message](); //clear it!
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
setTimeout(() => {
|
|
64
|
+
delete previousToasts[message];
|
|
65
|
+
}, options.timeout || 5000);
|
|
66
|
+
|
|
67
|
+
previousToasts[message] = clearToast;
|
|
68
|
+
}
|
|
69
|
+
return clearToast;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (!window.toastr) window.toastr = {};
|
|
74
|
+
if (!window.toastr.success) {
|
|
75
|
+
window.toastr.success = preventDuplicates(generateToast(Intent.SUCCESS));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!window.toastr.error) {
|
|
79
|
+
window.toastr.error = preventDuplicates(generateToast(Intent.DANGER));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (!window.toastr.warning) {
|
|
83
|
+
window.toastr.warning = preventDuplicates(generateToast(Intent.WARNING));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (!window.toastr.info) {
|
|
87
|
+
window.toastr.info = preventDuplicates(generateToast(Intent.PRIMARY));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!window.toastr.default) {
|
|
91
|
+
window.toastr.default = preventDuplicates(generateToast(Intent.NONE));
|
|
92
|
+
}
|