nmrium 0.58.0 → 0.60.0

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.
Files changed (194) hide show
  1. package/lib/component/1d/LinesSeries.js +17 -5
  2. package/lib/component/1d/Viewer1D.js +10 -4
  3. package/lib/component/1d/integral/IntegralResizable.js +2 -2
  4. package/lib/component/1d/matrix/useMatrix.d.ts +1 -1
  5. package/lib/component/1d/multiAnalysis/AnalysisRange.js +1 -1
  6. package/lib/component/1d/ranges/Atoms.js +6 -4
  7. package/lib/component/1d/ranges/Range.js +4 -2
  8. package/lib/component/1d/tool/PivotIndicator.d.ts +1 -0
  9. package/lib/component/1d/tool/{VerticalIndicator.js → PivotIndicator.js} +8 -4
  10. package/lib/component/1d-2d/tools/BrushXY.js +0 -1
  11. package/lib/component/1d-2d/tools/CrossLinePointer.js +0 -1
  12. package/lib/component/2d/Viewer2D.js +7 -3
  13. package/lib/component/2d/tools/PivotIndicator.d.ts +1 -2
  14. package/lib/component/2d/tools/PivotIndicator.js +2 -3
  15. package/lib/component/2d/zones/Zone.js +2 -2
  16. package/lib/component/EventsTrackers/KeysListenerTracker.js +8 -8
  17. package/lib/component/context/ChartContext.js +12 -1
  18. package/lib/component/context/ShareDataContext.d.ts +1 -1
  19. package/lib/component/context/ShareDataContext.js +2 -4
  20. package/lib/component/context/ToasterContext.d.ts +1 -0
  21. package/lib/component/context/ToasterContext.js +12 -3
  22. package/lib/component/elements/ActionsButtonsPopover.js +1 -3
  23. package/lib/component/elements/Alert.d.ts +20 -0
  24. package/lib/component/elements/Alert.js +80 -0
  25. package/lib/component/elements/ContextMenuBluePrint.d.ts +7 -2
  26. package/lib/component/elements/ContextMenuBluePrint.js +9 -3
  27. package/lib/component/elements/DialogManager.d.ts +34 -0
  28. package/lib/component/elements/DialogManager.js +96 -0
  29. package/lib/component/elements/DraggableDialog.d.ts +13 -0
  30. package/lib/component/elements/DraggableDialog.js +156 -0
  31. package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +1 -1
  32. package/lib/component/elements/ReactTable/ReactTableFlexLayout.d.ts +0 -3
  33. package/lib/component/elements/ReactTable/ReactTableFlexLayout.js +1 -1
  34. package/lib/component/elements/Select2.d.ts +12 -7
  35. package/lib/component/elements/Select2.js +5 -4
  36. package/lib/component/elements/Select2Controller.d.ts +2 -2
  37. package/lib/component/elements/Select2Controller.js +5 -5
  38. package/lib/component/elements/TabTitle.d.ts +9 -0
  39. package/lib/component/elements/TabTitle.js +18 -0
  40. package/lib/component/elements/ToolbarPopoverItem.d.ts +7 -6
  41. package/lib/component/elements/ToolbarPopoverItem.js +13 -5
  42. package/lib/component/elements/print/PrintContent.d.ts +17 -0
  43. package/lib/component/elements/print/PrintContent.js +281 -0
  44. package/lib/component/elements/print/PrintProvider.d.ts +12 -0
  45. package/lib/component/elements/print/PrintProvider.js +28 -0
  46. package/lib/component/elements/print/index.d.ts +2 -0
  47. package/lib/component/elements/print/index.js +2 -0
  48. package/lib/component/header/ApodizationOptionsPanel.js +2 -2
  49. package/lib/component/header/BaseLineCorrectionPanel.js +3 -0
  50. package/lib/component/hooks/useSaveSettings.d.ts +1 -1
  51. package/lib/component/hooks/useSaveSettings.js +18 -22
  52. package/lib/component/hooks/useToggleSpectraVisibility.d.ts +14 -9
  53. package/lib/component/hooks/useToggleSpectraVisibility.js +45 -16
  54. package/lib/component/loader/DropZone.js +3 -67
  55. package/lib/component/loader/useLoadFiles.d.ts +1 -0
  56. package/lib/component/loader/useLoadFiles.js +78 -0
  57. package/lib/component/main/InnerNMRium.d.ts +4 -3
  58. package/lib/component/main/InnerNMRium.js +5 -10
  59. package/lib/component/main/InnerNMRiumContents.d.ts +3 -2
  60. package/lib/component/main/InnerNMRiumContents.js +38 -29
  61. package/lib/component/main/NMRium.d.ts +2 -5
  62. package/lib/component/main/NMRium.js +1 -1
  63. package/lib/component/main/NMRiumRefAPI.d.ts +7 -0
  64. package/lib/component/main/NMRiumRefAPI.js +12 -0
  65. package/lib/component/main/NMRiumViewer.d.ts +10 -0
  66. package/lib/component/main/NMRiumViewer.js +35 -0
  67. package/lib/component/main/index.d.ts +1 -0
  68. package/lib/component/modal/CopyClipboardModal.d.ts +3 -2
  69. package/lib/component/modal/CopyClipboardModal.js +18 -32
  70. package/lib/component/modal/EditPeakShapeModal.d.ts +4 -6
  71. package/lib/component/modal/EditPeakShapeModal.js +45 -33
  72. package/lib/component/modal/ExportAsJcampModal.d.ts +6 -3
  73. package/lib/component/modal/ExportAsJcampModal.js +69 -35
  74. package/lib/component/modal/ImportPublicationStringModal.js +1 -1
  75. package/lib/component/modal/editRange/EditRangeModal.d.ts +2 -10
  76. package/lib/component/modal/editRange/EditRangeModal.js +26 -54
  77. package/lib/component/modal/editZone/EditZoneModal.d.ts +3 -8
  78. package/lib/component/modal/editZone/EditZoneModal.js +74 -91
  79. package/lib/component/modal/editZone/SignalsForm.d.ts +1 -2
  80. package/lib/component/modal/editZone/SignalsForm.js +33 -50
  81. package/lib/component/modal/editZone/validation/isDefaultPathLength.d.ts +1 -2
  82. package/lib/component/modal/editZone/validation/isDefaultPathLength.js +3 -5
  83. package/lib/component/modal/setting/GeneralSettings.js +4 -2
  84. package/lib/component/modal/setting/settings-tabs/ExternalAPIsTabContent.d.ts +1 -0
  85. package/lib/component/modal/setting/settings-tabs/ExternalAPIsTabContent.js +89 -0
  86. package/lib/component/modal/setting/settingsValidation.js +15 -1
  87. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +8 -5
  88. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +5 -1
  89. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +13 -3
  90. package/lib/component/panels/Panels.js +2 -2
  91. package/lib/component/panels/PeaksPanel/PeaksPanel.js +8 -5
  92. package/lib/component/panels/PeaksPanel/PeaksTable.js +7 -13
  93. package/lib/component/panels/RangesPanel/RangesHeader.js +52 -15
  94. package/lib/component/panels/RangesPanel/RangesTable.js +6 -3
  95. package/lib/component/panels/RangesPanel/TableColumns/ActionsColumn.js +21 -3
  96. package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.d.ts +6 -5
  97. package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.js +41 -64
  98. package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +13 -6
  99. package/lib/component/panels/SpectraPanel/SpectraTable.js +63 -21
  100. package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnField.d.ts +1 -2
  101. package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnField.js +33 -41
  102. package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnHeader.js +68 -53
  103. package/lib/component/panels/SummaryPanel/CorrelationTable/CorrelationTableRow.js +70 -58
  104. package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.d.ts +13 -8
  105. package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +17 -81
  106. package/lib/component/panels/SummaryPanel/SummaryPanel.d.ts +3 -0
  107. package/lib/component/panels/SummaryPanel/SummaryPanel.js +8 -1
  108. package/lib/component/panels/SummaryPanel/utilities/Utilities.js +1 -1
  109. package/lib/component/panels/ZonesPanel/TableColumns/ActionsColumn.js +62 -43
  110. package/lib/component/panels/ZonesPanel/ZonesPanel.js +16 -8
  111. package/lib/component/panels/ZonesPanel/ZonesTable.js +4 -1
  112. package/lib/component/panels/ZonesPanel/hooks/useZoneActions.d.ts +5 -0
  113. package/lib/component/panels/ZonesPanel/hooks/useZoneActions.js +40 -0
  114. package/lib/component/panels/databasePanel/DatabasePanel.js +7 -8
  115. package/lib/component/panels/filtersPanel/FilterPanel.js +9 -6
  116. package/lib/component/panels/filtersPanel/FiltersTable.js +12 -10
  117. package/lib/component/panels/header/DefaultPanelHeader.d.ts +1 -0
  118. package/lib/component/panels/header/DefaultPanelHeader.js +2 -2
  119. package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.js +10 -12
  120. package/lib/component/reducer/IgnoreActions.js +1 -0
  121. package/lib/component/reducer/Reducer.js +2 -4
  122. package/lib/component/reducer/actions/DatabaseActions.d.ts +15 -13
  123. package/lib/component/reducer/actions/DatabaseActions.js +52 -34
  124. package/lib/component/reducer/actions/DomainActions.d.ts +2 -2
  125. package/lib/component/reducer/actions/FiltersActions.js +9 -4
  126. package/lib/component/reducer/actions/RangesActions.d.ts +1 -0
  127. package/lib/component/reducer/actions/RangesActions.js +9 -4
  128. package/lib/component/reducer/actions/SpectraActions.d.ts +2 -1
  129. package/lib/component/reducer/actions/SpectraActions.js +53 -43
  130. package/lib/component/reducer/actions/ToolsActions.js +0 -17
  131. package/lib/component/reducer/helper/removeSpectrumRelatedObjectsById.d.ts +3 -0
  132. package/lib/component/reducer/helper/removeSpectrumRelatedObjectsById.js +16 -0
  133. package/lib/component/reducer/preferences/actions/changePrintPageSettings.d.ts +3 -0
  134. package/lib/component/reducer/preferences/actions/changePrintPageSettings.js +6 -0
  135. package/lib/component/reducer/preferences/actions/matrixGeneration.d.ts +0 -4
  136. package/lib/component/reducer/preferences/actions/matrixGeneration.js +1 -2
  137. package/lib/component/reducer/preferences/preferencesReducer.d.ts +3 -2
  138. package/lib/component/reducer/preferences/preferencesReducer.js +4 -1
  139. package/lib/component/toolbar/ToolBar.js +33 -14
  140. package/lib/component/toolbar/ToolTypes.d.ts +1 -1
  141. package/lib/component/toolbar/ToolTypes.js +0 -14
  142. package/lib/component/workspaces/workspaceDefaultProperties.js +2 -0
  143. package/lib/data/SpectraManager.d.ts +7 -10
  144. package/lib/data/SpectraManager.js +51 -30
  145. package/lib/data/data1d/Spectrum1D/SumManager.d.ts +0 -1
  146. package/lib/data/data1d/Spectrum1D/SumManager.js +2 -10
  147. package/lib/data/data1d/Spectrum1D/get1DColor.d.ts +1 -1
  148. package/lib/data/data1d/Spectrum1D/index.d.ts +1 -1
  149. package/lib/data/data1d/Spectrum1D/index.js +1 -1
  150. package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +10 -16
  151. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +1 -7
  152. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +2 -1
  153. package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +10 -16
  154. package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +10 -16
  155. package/lib/data/data1d/Spectrum1D/ranges/resurrectSpectrum.d.ts +13 -0
  156. package/lib/data/data1d/Spectrum1D/ranges/resurrectSpectrum.js +65 -0
  157. package/lib/data/molecules/MoleculeManager.d.ts +1 -1
  158. package/lib/data/molecules/MoleculeManager.js +21 -49
  159. package/lib/data/utilities/getCustomColor.d.ts +1 -1
  160. package/lib/data/utilities/removeByPaths.d.ts +3 -0
  161. package/lib/data/utilities/removeByPaths.js +33 -0
  162. package/lib/versionInfo.js +1 -1
  163. package/package.json +34 -34
  164. package/lib/component/1d/tool/VerticalIndicator.d.ts +0 -2
  165. package/lib/component/elements/ContextMenu.d.ts +0 -9
  166. package/lib/component/elements/ContextMenu.js +0 -116
  167. package/lib/component/elements/popup/Modal/ConfirmDialog.d.ts +0 -21
  168. package/lib/component/elements/popup/Modal/ConfirmDialog.js +0 -68
  169. package/lib/component/elements/popup/Modal/Context.d.ts +0 -2
  170. package/lib/component/elements/popup/Modal/Context.js +0 -6
  171. package/lib/component/elements/popup/Modal/Modal.d.ts +0 -9
  172. package/lib/component/elements/popup/Modal/Modal.js +0 -42
  173. package/lib/component/elements/popup/Modal/ModalContent.d.ts +0 -6
  174. package/lib/component/elements/popup/Modal/ModalContent.js +0 -27
  175. package/lib/component/elements/popup/Modal/Provider.d.ts +0 -11
  176. package/lib/component/elements/popup/Modal/Provider.js +0 -172
  177. package/lib/component/elements/popup/Modal/index.d.ts +0 -4
  178. package/lib/component/elements/popup/Modal/index.js +0 -4
  179. package/lib/component/elements/popup/Transition.d.ts +0 -14
  180. package/lib/component/elements/popup/Transition.js +0 -35
  181. package/lib/component/elements/popup/Wrapper.d.ts +0 -8
  182. package/lib/component/elements/popup/Wrapper.js +0 -83
  183. package/lib/component/elements/popup/options.d.ts +0 -28
  184. package/lib/component/elements/popup/options.js +0 -25
  185. package/lib/component/elements/popup/utility.d.ts +0 -2
  186. package/lib/component/elements/popup/utility.js +0 -13
  187. package/lib/component/modal/editZone/EditPathLengthFormik.d.ts +0 -5
  188. package/lib/component/modal/editZone/EditPathLengthFormik.js +0 -67
  189. package/lib/component/modal/editZone/SignalFormTab.d.ts +0 -5
  190. package/lib/component/modal/editZone/SignalFormTab.js +0 -6
  191. package/lib/component/modal/editZone/validation/EditZoneValidation.d.ts +0 -14
  192. package/lib/component/modal/editZone/validation/EditZoneValidation.js +0 -14
  193. package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.d.ts +0 -11
  194. package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.js +0 -29
@@ -1,68 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
- /** @jsxImportSource @emotion/react */
3
- import { DialogBody } from '@blueprintjs/core';
4
- import { css } from '@emotion/react';
5
- import { useCallback } from 'react';
6
- const styles = css `
7
- background-color: white;
8
- padding: 0;
9
-
10
- .message {
11
- font-weight: bold;
12
- font-size: 14px;
13
- text-align: center;
14
- color: #af0000;
15
- padding: 25px;
16
- display: block;
17
- }
18
-
19
- .buttons-container {
20
- display: flex;
21
- flex-direction: row-reverse;
22
- align-items: flex-end;
23
- padding: 5px;
24
- border-top: 1px solid #efefef;
25
-
26
- button {
27
- border-color: #dcdcdc;
28
- border-width: 1px 0 1px 1px;
29
- background-color: white;
30
- display: inline-block;
31
- cursor: pointer;
32
- color: #363636;
33
- font-weight: bold;
34
- padding: 6px 24px;
35
- text-decoration: none;
36
- }
37
-
38
- button:hover {
39
- background: linear-gradient(to bottom, #f6f6f6 5%, #fff 100%);
40
- background-color: #f6f6f6;
41
- }
42
-
43
- button:first-of-type {
44
- border-radius: 0 5px 5px 0;
45
- border-width: 1px;
46
- }
47
-
48
- button:last-of-type {
49
- border-radius: 5px 0 0 5px;
50
- }
51
- }
52
- `;
53
- const defaultStyle = {
54
- display: 'block',
55
- borderRadius: '5px',
56
- minWidth: '400px',
57
- borderTop: '10px solid #ed0000',
58
- };
59
- function ConfirmationDialog({ style = {}, buttons = [], onClose, message, render, id, disableDefaultStyle = false, }) {
60
- const optionsHandler = useCallback((e, { handler = () => null, preventClose = false }) => {
61
- handler(e);
62
- if (!preventClose) {
63
- onClose();
64
- }
65
- }, [onClose]);
66
- return (_jsx(DialogBody, { css: styles, children: _jsxs("div", { style: { ...(!disableDefaultStyle && defaultStyle), ...style }, "data-testid": id, children: [render ? (render({ message, className: 'message' })) : (_jsx("p", { className: "message", children: message })), _jsx("div", { className: "buttons-container", children: buttons.map((option) => (_jsx("button", { type: "button", onClick: (e) => optionsHandler(e, option), style: option.style && option.style, children: option.text }, option.text))) })] }) }));
67
- }
68
- export default ConfirmationDialog;
@@ -1,2 +0,0 @@
1
- export declare const ModalProvider: import("react").Provider<any>;
2
- export declare function useModal(): any;
@@ -1,6 +0,0 @@
1
- import { createContext, useContext } from 'react';
2
- const ModalContext = createContext({});
3
- export const ModalProvider = ModalContext.Provider;
4
- export function useModal() {
5
- return useContext(ModalContext);
6
- }
@@ -1,9 +0,0 @@
1
- import { ReactNode, CSSProperties } from 'react';
2
- interface ModalProps {
3
- children: ReactNode;
4
- open?: boolean;
5
- onClose?: (element: any) => void;
6
- style?: CSSProperties;
7
- }
8
- declare const Modal: ({ children, open, onClose, style, }: ModalProps) => false | import("react/jsx-runtime").JSX.Element;
9
- export default Modal;
@@ -1,42 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect, useCallback } from 'react';
3
- const styles = {
4
- outerContainer: {
5
- position: 'fixed',
6
- top: 0,
7
- right: 0,
8
- bottom: 0,
9
- left: 0,
10
- backgroundColor: 'rgba(255,255,255,0.8)',
11
- display: 'flex',
12
- justifyContent: 'center',
13
- alignItems: 'center',
14
- zIndex: 1,
15
- },
16
- innerContainer: {
17
- boxSizing: 'initial',
18
- backgroundColor: '#fff',
19
- boxShadow: '0 0 0 0, 0 8px 16px rgba(0,0,0,.30)',
20
- display: 'flex',
21
- flexDirection: 'column',
22
- minWidth: '300px',
23
- minHeight: '140px',
24
- justifyContent: 'space-between',
25
- borderRadius: '5px',
26
- },
27
- };
28
- const Modal = ({ children, open = false, onClose = () => null, style, }) => {
29
- const handleClose = useCallback((e) => {
30
- onClose(e);
31
- }, [onClose]);
32
- useEffect(() => {
33
- if (!open) {
34
- handleClose();
35
- }
36
- }, [handleClose, open]);
37
- return (open && (_jsx("div", { style: styles.outerContainer, onClick: handleClose, children: _jsx("div", { style: { ...styles.innerContainer, ...style }, onClick: (e) => {
38
- e.preventDefault();
39
- e.stopPropagation();
40
- }, children: children }) })));
41
- };
42
- export default Modal;
@@ -1,6 +0,0 @@
1
- declare const ModalContent: ({ modal, onClose, onLayout }: {
2
- modal: any;
3
- onClose: any;
4
- onLayout: any;
5
- }) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
6
- export default ModalContent;
@@ -1,27 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useRef, useEffect, cloneElement } from 'react';
3
- import { useSize } from 'react-use';
4
- const ModalContent = ({ modal, onClose, onLayout }) => {
5
- const contentSize = useRef();
6
- const [Content, { width, height }] = useSize(() => {
7
- return (_jsx("div", { style: {
8
- height: '100%',
9
- display: 'block',
10
- overflow: 'auto',
11
- }, children: cloneElement(modal.component, {
12
- ...modal.options,
13
- onClose,
14
- style: { cursor: 'default' },
15
- }) }));
16
- });
17
- useEffect(() => {
18
- if (Number.isFinite(height) &&
19
- Number.isFinite(width) &&
20
- !contentSize.current) {
21
- contentSize.current = { width, height };
22
- onLayout({ modal, layout: { width, height } });
23
- }
24
- }, [width, height, contentSize, onLayout, modal]);
25
- return Content;
26
- };
27
- export default ModalContent;
@@ -1,11 +0,0 @@
1
- import { CSSProperties, ReactNode } from 'react';
2
- interface ProviderProps {
3
- children: ReactNode;
4
- style?: CSSProperties;
5
- offset?: string;
6
- position?: string;
7
- transition?: string;
8
- wrapperRef?: HTMLDivElement | null;
9
- }
10
- declare function Provider({ children, style, offset, position, transition, wrapperRef, }: ProviderProps): import("@emotion/react/jsx-runtime").JSX.Element;
11
- export default Provider;
@@ -1,172 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
- /** @jsxImportSource @emotion/react */
3
- import { css } from '@emotion/react';
4
- import { v4 } from '@lukeed/uuid';
5
- import { useRef, useState, useEffect, useCallback, Fragment, useMemo, } from 'react';
6
- import { createPortal } from 'react-dom';
7
- import { Rnd } from 'react-rnd';
8
- import { TransitionGroup } from 'react-transition-group';
9
- import Transition from '../Transition';
10
- import Wrapper from '../Wrapper';
11
- import { positions, transitions } from '../options';
12
- import ConfirmDialog from './ConfirmDialog';
13
- import { ModalProvider } from './Context';
14
- import ModalContent from './ModalContent';
15
- const transitionStyles = {
16
- [transitions.FADE]: {
17
- entering: { opacity: 0 },
18
- entered: { opacity: 1 },
19
- },
20
- [transitions.SCALE]: {
21
- entering: { transform: 'scale(0)' },
22
- entered: { transform: 'scale(1)' },
23
- exiting: { transform: 'scale(0)' },
24
- exited: { transform: 'scale(0)' },
25
- },
26
- };
27
- function Provider({ children, style, offset = '0px', position = positions.MIDDLE, transition = transitions.SCALE, wrapperRef = null, }) {
28
- const root = useRef();
29
- const modalRef = useRef();
30
- const [modals, setModal] = useState([]);
31
- useEffect(() => {
32
- root.current = document.createElement('div');
33
- const ref = root.current;
34
- if (wrapperRef) {
35
- wrapperRef.append(ref);
36
- }
37
- return () => {
38
- if (ref && wrapperRef) {
39
- ref.remove();
40
- }
41
- };
42
- }, [wrapperRef]);
43
- const close = useCallback((modal) => {
44
- setModal((prevModals) => {
45
- if (modal) {
46
- return prevModals.filter((m) => m.id !== modal.id);
47
- }
48
- else {
49
- return modals.slice(0, -1);
50
- }
51
- });
52
- }, [modals]);
53
- // todo: optimize this
54
- const parentStyle = wrapperRef?.getBoundingClientRect() || {
55
- top: 0,
56
- left: 0,
57
- width: window.innerWidth,
58
- height: window.innerHeight,
59
- };
60
- /**
61
- *
62
- * @param {*} component <component />
63
- * @param {object} options {onYest:()=>{}, prop1, .... etc}
64
- * @param {transitions} options.transition
65
- * @param {positions} options.position
66
- * @param {boolean} options.isBackgroundBlur
67
- * @param {boolean} options.enableResizing
68
- */
69
- const show = useCallback((component, options = {}) => {
70
- const _modal = {
71
- id: v4(),
72
- component,
73
- options: { isBackgroundBlur: true, enableResizing: false, ...options },
74
- };
75
- _modal.close = () => close(_modal);
76
- setModal((prevModals) => [...prevModals, _modal]);
77
- if (_modal.options.onOpen)
78
- _modal.options.onOpen();
79
- return _modal;
80
- }, [close]);
81
- /**
82
- * @param {object} dialogOptions
83
- * @param {object} dialogOptions.message
84
- * @param {Array<{ handler: Function,text: string,style: object}>} dialogOptions.buttons
85
- * @param {object} dialogOptions.style
86
- */
87
- const showConfirmDialog = useCallback((dialogOptions, options = {}) => {
88
- const { enableResizing = false, ...otherOptions } = options;
89
- const _modal = {
90
- id: v4(),
91
- component: _jsx(ConfirmDialog, { ...dialogOptions }),
92
- options: { isBackgroundBlur: true, enableResizing, ...otherOptions },
93
- };
94
- _modal.close = () => close(_modal);
95
- setModal((prevModals) => [...prevModals, _modal]);
96
- if (_modal.options.onOpen)
97
- _modal.options.onOpen();
98
- return _modal;
99
- }, [close]);
100
- useEffect(() => {
101
- function keyHandler(e) {
102
- if (['Escape', 'Esc'].includes(e.key)) {
103
- close();
104
- }
105
- }
106
- document.addEventListener('keydown', keyHandler, false);
107
- return () => document.removeEventListener('keydown', keyHandler, false);
108
- }, [close, modals]);
109
- const styles = css `
110
- position: absolute;
111
- inset: 0;
112
- z-index: 0;
113
- pointer-events: all;
114
-
115
- .handle {
116
- cursor: move;
117
- }
118
-
119
- .rnd-container {
120
- box-sizing: initial;
121
- background-color: #fff;
122
- box-shadow:
123
- 0 0 0 0,
124
- 0 8px 16px rgb(0 0 0 / 30%);
125
- border-radius: 5px;
126
- }
127
- `;
128
- const modalContextValue = useMemo(() => ({ show, close, showConfirmDialog }), [show, close, showConfirmDialog]);
129
- const contentLayoutHandler = useCallback(({ modal, layout }) => {
130
- const width = modal.options.width ||
131
- (layout.width > parentStyle.width ? parentStyle.width : layout.width);
132
- const height = modal.options.height ||
133
- (layout.height > parentStyle.height
134
- ? parentStyle.height
135
- : layout.height);
136
- modalRef.current.updateSize({ width, height });
137
- }, [parentStyle.height, parentStyle.width]);
138
- return (_jsxs(ModalProvider, { value: modalContextValue, children: [children, root.current &&
139
- createPortal(_jsx(Fragment, { children: modals?.length > 0
140
- ? modals.map((modal) => (_jsx("div", { css: styles, style: {
141
- ...(modal?.options.isBackgroundBlur
142
- ? { backgroundColor: 'rgba(255,255,255,0.8)' }
143
- : { pointerEvents: 'none' }),
144
- }, children: _jsx(TransitionGroup, { appear: true, options: {
145
- position: modal.options.position || position,
146
- }, containerStyle: parentStyle, component: Wrapper, children: _jsx(Transition, { type: modal.options.transition || transition, transitionStyles: {
147
- ...transitionStyles,
148
- default: {
149
- width: modal.options.width
150
- ? `${modal.options.width}px`
151
- : 'auto',
152
- },
153
- height: modal.options.height
154
- ? `${modal.options.height}px`
155
- : 'auto',
156
- }, children: _jsx(Rnd, { maxWidth: parentStyle.width, maxHeight: parentStyle.height, ref: modalRef, default: {
157
- width: modal.options.width || 'auto',
158
- height: modal.options.height || 'auto',
159
- x: 0,
160
- y: 0,
161
- }, className: "rnd-container", style: {
162
- ...style,
163
- margin: offset,
164
- position: 'static',
165
- pointerEvents: 'all',
166
- userSelect: 'none',
167
- }, enableResizing: modal.options.enableResizing, dragHandleClassName: "handle", enableUserSelectHack: false, children: _jsx(ModalContent, { modal: modal, onClose: () => {
168
- close(modal);
169
- }, onLayout: contentLayoutHandler }) }) }, modal.id) }, positions[modal.options.transition || transition]) }, modal.id)))
170
- : null }), root.current)] }));
171
- }
172
- export default Provider;
@@ -1,4 +0,0 @@
1
- export { positions, transitions } from '../options';
2
- export { useModal } from './Context';
3
- export { default as Modal } from './Modal';
4
- export { default as ModalProvider } from './Provider';
@@ -1,4 +0,0 @@
1
- export { positions, transitions } from '../options';
2
- export { useModal } from './Context';
3
- export { default as Modal } from './Modal';
4
- export { default as ModalProvider } from './Provider';
@@ -1,14 +0,0 @@
1
- import { CSSProperties, ReactNode } from 'react';
2
- type TransitionStyles = Record<string, Partial<{
3
- entering: CSSProperties;
4
- entered: CSSProperties;
5
- exiting: CSSProperties;
6
- exited: CSSProperties;
7
- }>>;
8
- interface TransitionProps {
9
- children: ReactNode;
10
- type: string;
11
- transitionStyles?: TransitionStyles;
12
- }
13
- export default function Transtion({ children, type, transitionStyles, ...props }: TransitionProps): import("react/jsx-runtime").JSX.Element;
14
- export {};
@@ -1,35 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useRef } from 'react';
3
- import { Transition as ContainerTransition } from 'react-transition-group';
4
- import { transitions } from './options';
5
- const duration = 250;
6
- const defaultStyle = {
7
- [transitions.FADE]: {
8
- transition: `opacity ${duration}ms ease`,
9
- opacity: 0,
10
- },
11
- [transitions.SCALE]: {
12
- transform: 'scale(1)',
13
- transition: `all ${duration}ms ease-in-out`,
14
- },
15
- };
16
- const defaultTransitionStyles = {
17
- [transitions.FADE]: {
18
- entering: { opacity: 0 },
19
- entered: { opacity: 1 },
20
- },
21
- [transitions.SCALE]: {
22
- entering: { transform: 'scale(0)' },
23
- entered: { transform: 'scale(1)' },
24
- exiting: { transform: 'scale(0)' },
25
- exited: { transform: 'scale(1)' },
26
- },
27
- };
28
- export default function Transtion({ children, type, transitionStyles = defaultTransitionStyles, ...props }) {
29
- const ref = useRef(null);
30
- return (_jsx(ContainerTransition, { nodeRef: ref, ...props, timeout: duration, children: (state) => (_jsx("div", { ref: ref, style: {
31
- ...defaultStyle[type],
32
- ...transitionStyles[type][state],
33
- ...transitionStyles.default,
34
- }, children: children })) }));
35
- }
@@ -1,8 +0,0 @@
1
- export default function Wrapper({ children, options: { position }, containerStyle, ...props }: {
2
- [x: string]: any;
3
- children: any;
4
- options: {
5
- position: any;
6
- };
7
- containerStyle: any;
8
- }): false | import("react/jsx-runtime").JSX.Element;
@@ -1,83 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useMemo } from 'react';
3
- import { positions } from './options';
4
- function getStyles(position, containerStyle) {
5
- const initialStyles = {
6
- position: 'fixed',
7
- display: 'flex',
8
- justifyContent: 'center',
9
- alignItems: 'center',
10
- flexDirection: 'column',
11
- pointerEvents: 'none',
12
- overflow: 'visible',
13
- ...(containerStyle
14
- ? {
15
- top: `${containerStyle.top}px`,
16
- left: `${containerStyle.left}px`,
17
- height: `${containerStyle.height}px`,
18
- width: `${containerStyle.width}px`,
19
- }
20
- : { width: '100%', height: '100%' }),
21
- };
22
- switch (position) {
23
- case positions.TOP_LEFT:
24
- return {
25
- ...initialStyles,
26
- justifyContent: 'flex-start',
27
- alignItems: 'flex-start',
28
- };
29
- case positions.TOP_CENTER:
30
- return {
31
- ...initialStyles,
32
- justifyContent: 'flex-start',
33
- };
34
- case positions.TOP_RIGHT:
35
- return {
36
- ...initialStyles,
37
- justifyContent: 'flex-start',
38
- alignItems: 'flex-end',
39
- };
40
- case positions.MIDDLE_LEFT:
41
- return {
42
- ...initialStyles,
43
- justifyContent: 'center',
44
- alignItems: 'flex-start',
45
- };
46
- case positions.MIDDLE: {
47
- return {
48
- ...initialStyles,
49
- justifyContent: 'center',
50
- };
51
- }
52
- case positions.MIDDLE_RIGHT:
53
- return {
54
- ...initialStyles,
55
- justifyContent: 'center',
56
- alignItems: 'flex-end',
57
- };
58
- case positions.BOTTOM_LEFT:
59
- return {
60
- ...initialStyles,
61
- justifyContent: 'flex-end',
62
- alignItems: 'flex-start',
63
- };
64
- case positions.BOTTOM_CENTER:
65
- return {
66
- ...initialStyles,
67
- justifyContent: 'flex-end',
68
- };
69
- case positions.BOTTOM_RIGHT:
70
- return {
71
- ...initialStyles,
72
- justifyContent: 'flex-end',
73
- alignItems: 'flex-end',
74
- };
75
- default: {
76
- return initialStyles;
77
- }
78
- }
79
- }
80
- export default function Wrapper({ children, options: { position }, containerStyle, ...props }) {
81
- const styles = useMemo(() => getStyles(position, containerStyle), [position, containerStyle]);
82
- return (children.length > 0 && (_jsx("div", { style: styles, ...props, children: children })));
83
- }
@@ -1,28 +0,0 @@
1
- export declare const positions: {
2
- readonly TOP_LEFT: "top left";
3
- readonly TOP_CENTER: "top center";
4
- readonly TOP_RIGHT: "top right";
5
- readonly MIDDLE_LEFT: "middle left";
6
- readonly MIDDLE: "middle";
7
- readonly MIDDLE_RIGHT: "middle right";
8
- readonly BOTTOM_LEFT: "bottom left";
9
- readonly BOTTOM_CENTER: "bottom center";
10
- readonly BOTTOM_RIGHT: "bottom right";
11
- };
12
- export type Position = (typeof positions)[keyof typeof positions];
13
- export declare const types: {
14
- readonly INFO: "info";
15
- readonly SUCCESS: "success";
16
- readonly ERROR: "error";
17
- readonly PROGRESS_INDICATOR: "progress_indicator";
18
- };
19
- export type Type = (typeof types)[keyof typeof types];
20
- export declare const transitions: {
21
- readonly FADE: "fade";
22
- readonly SCALE: "scale";
23
- readonly SLIDE_RIGHT: "slide_right";
24
- readonly SLIDE_LEFT: "slide_left";
25
- readonly SLIDE_TOP: "slide_top";
26
- readonly SLIDE_BOTTOM: "slide_bottom";
27
- };
28
- export type Transition = (typeof transitions)[keyof typeof transitions];
@@ -1,25 +0,0 @@
1
- export const positions = {
2
- TOP_LEFT: 'top left',
3
- TOP_CENTER: 'top center',
4
- TOP_RIGHT: 'top right',
5
- MIDDLE_LEFT: 'middle left',
6
- MIDDLE: 'middle',
7
- MIDDLE_RIGHT: 'middle right',
8
- BOTTOM_LEFT: 'bottom left',
9
- BOTTOM_CENTER: 'bottom center',
10
- BOTTOM_RIGHT: 'bottom right',
11
- };
12
- export const types = {
13
- INFO: 'info',
14
- SUCCESS: 'success',
15
- ERROR: 'error',
16
- PROGRESS_INDICATOR: 'progress_indicator',
17
- };
18
- export const transitions = {
19
- FADE: 'fade',
20
- SCALE: 'scale',
21
- SLIDE_RIGHT: 'slide_right',
22
- SLIDE_LEFT: 'slide_left',
23
- SLIDE_TOP: 'slide_top',
24
- SLIDE_BOTTOM: 'slide_bottom',
25
- };
@@ -1,2 +0,0 @@
1
- declare function load(filePath: any): Promise<string>;
2
- export { load };
@@ -1,13 +0,0 @@
1
- async function load(filePath) {
2
- const response = await fetch(filePath);
3
- checkStatus(response);
4
- const data = await response.text();
5
- return data;
6
- }
7
- function checkStatus(response) {
8
- if (!response.ok) {
9
- throw new Error(`HTTP ${response.status} - ${response.statusText}`);
10
- }
11
- return response;
12
- }
13
- export { load };
@@ -1,5 +0,0 @@
1
- interface InputProps {
2
- signalIndex: number;
3
- }
4
- declare function EditPathLengthFormik({ signalIndex }: InputProps): import("@emotion/react/jsx-runtime").JSX.Element;
5
- export default EditPathLengthFormik;
@@ -1,67 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
- /** @jsxImportSource @emotion/react */
3
- import { css } from '@emotion/react';
4
- import { useFormikContext } from 'formik';
5
- import DefaultPathLengths from '../../../data/constants/DefaultPathLengths';
6
- import Label from '../../elements/Label';
7
- import FormikNumberInput from '../../elements/formik/FormikNumberInput';
8
- const editPathLengthsStyles = css `
9
- width: 100%;
10
- height: 100%;
11
- margin-top: 10px;
12
- text-align: center;
13
-
14
- .input-container {
15
- width: 100%;
16
- margin-top: 5px;
17
- text-align: center;
18
- display: flex;
19
- flex-direction: column;
20
- align-items: center;
21
- justify-content: center;
22
-
23
- input::-webkit-outer-spin-button,
24
- input::-webkit-inner-spin-button {
25
- appearance: none;
26
- }
27
- }
28
-
29
- button {
30
- flex: 2;
31
- padding: 5px;
32
- border: 1px solid gray;
33
- border-radius: 5px;
34
- height: 30px;
35
- margin: 0 auto;
36
- margin-top: 15px;
37
- display: block;
38
- width: 60px;
39
- color: white;
40
- background-color: gray;
41
- }
42
-
43
- .warning {
44
- margin-top: 5px;
45
- color: red;
46
- }
47
- `;
48
- function EditPathLengthFormik({ signalIndex }) {
49
- const { errors, values, } = useFormikContext();
50
- return (_jsxs("div", { css: editPathLengthsStyles, children: [_jsx("p", { children: "Setting of the minimum and maximum path length (J coupling)." }), _jsxs("div", { className: "input-container", children: [_jsx(Label, { title: "Min:", children: _jsx(FormikNumberInput, { name: `signals[${signalIndex}].j.pathLength.from`, defaultValue: values.signals[signalIndex].j?.pathLength?.from ||
51
- DefaultPathLengths[values.experimentType]?.from ||
52
- 1, style: {
53
- color: errors.signals?.[signalIndex].j?.pathLength?.from
54
- ? 'red'
55
- : 'black',
56
- }, min: 1, max: values.signals[signalIndex].j?.pathLength?.to ||
57
- DefaultPathLengths[values.experimentType]?.to, pattern: "[1-9]+" }) }), _jsx(Label, { title: "Max:", children: _jsx(FormikNumberInput, { name: `signals[${signalIndex}].j.pathLength.to`, defaultValue: values.signals[signalIndex].j?.pathLength?.to ||
58
- DefaultPathLengths[values.experimentType]?.to ||
59
- 1, style: {
60
- color: errors.signals?.[signalIndex].j?.pathLength?.to
61
- ? 'red'
62
- : 'black',
63
- }, min: values.signals[signalIndex].j?.pathLength?.from ||
64
- DefaultPathLengths[values.experimentType]?.from ||
65
- 1, pattern: "[1-9]+" }) })] })] }));
66
- }
67
- export default EditPathLengthFormik;
@@ -1,5 +0,0 @@
1
- interface SignalFormTabProps {
2
- signalIndex: number;
3
- }
4
- declare function SignalFormTab({ signalIndex }: SignalFormTabProps): import("react/jsx-runtime").JSX.Element;
5
- export default SignalFormTab;