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
@@ -0,0 +1,34 @@
1
+ interface DialogItem {
2
+ isOpen: boolean;
3
+ data: any;
4
+ }
5
+ type DialogStates = Record<string, DialogItem>;
6
+ type ComponentIdentifier = string | React.ComponentType<any>;
7
+ export interface DialogProps<T> {
8
+ dialogData: T;
9
+ onCloseDialog: () => void;
10
+ onOpenDialog: () => void;
11
+ }
12
+ interface DialogContextType {
13
+ openDialog: <T>(identifier: ComponentIdentifier, data?: T) => void;
14
+ closeDialog: (identifier: ComponentIdentifier) => void;
15
+ }
16
+ interface DialogDataContextType {
17
+ dialogStates: DialogStates;
18
+ getDialogData: <T>(identifier: ComponentIdentifier) => T | null;
19
+ isDialogOpen: (identifier: ComponentIdentifier) => boolean;
20
+ getDialog: (identifier: ComponentIdentifier) => DialogItem;
21
+ }
22
+ export declare function DialogProvider({ children }: {
23
+ children: any;
24
+ }): import("react/jsx-runtime").JSX.Element;
25
+ export declare function useDialog(): DialogContextType;
26
+ export declare function useDialogData(): DialogDataContextType;
27
+ type WrapperParameters<P> = Omit<P, keyof DialogProps<any>>;
28
+ interface WithDialogOptions {
29
+ dialogName?: string;
30
+ /** force re-render the dialog */
31
+ force?: boolean;
32
+ }
33
+ export declare function withDialog<P extends object>(WrappedComponent: React.ComponentType<P>, options?: WithDialogOptions): (props: WrapperParameters<P>) => import("react/jsx-runtime").JSX.Element | null;
34
+ export {};
@@ -0,0 +1,96 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useMemo, useState } from 'react';
3
+ const DialogContext = createContext(null);
4
+ const DialogDataContext = createContext(null);
5
+ function getDialogIdentifier(componentIdentifier) {
6
+ if (typeof componentIdentifier === 'string') {
7
+ return componentIdentifier;
8
+ }
9
+ else {
10
+ const name = componentIdentifier.displayName || componentIdentifier.name;
11
+ if (!name) {
12
+ throw new Error('Dialog identifier should be defined');
13
+ }
14
+ return name;
15
+ }
16
+ }
17
+ export function DialogProvider({ children }) {
18
+ const [dialogStates, setDialog] = useState({});
19
+ const state = useMemo(() => {
20
+ function closeDialog(componentIdentifier) {
21
+ const identifier = getDialogIdentifier(componentIdentifier);
22
+ setDialog((prevDialogState) => {
23
+ return {
24
+ ...prevDialogState,
25
+ [identifier]: { isOpen: false, data: null },
26
+ };
27
+ });
28
+ }
29
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
30
+ function openDialog(componentIdentifier, data) {
31
+ const identifier = getDialogIdentifier(componentIdentifier);
32
+ setDialog((prevDialogState) => ({
33
+ ...prevDialogState,
34
+ [identifier]: { isOpen: true, data },
35
+ }));
36
+ }
37
+ return { openDialog, closeDialog };
38
+ }, []);
39
+ const dataState = useMemo(() => {
40
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
41
+ function getDialogData(componentIdentifier) {
42
+ const identifier = getDialogIdentifier(componentIdentifier);
43
+ return dialogStates?.[identifier]?.data;
44
+ }
45
+ function isDialogOpen(componentIdentifier) {
46
+ const identifier = getDialogIdentifier(componentIdentifier);
47
+ return dialogStates?.[identifier]?.isOpen || false;
48
+ }
49
+ function getDialog(componentIdentifier) {
50
+ const identifier = getDialogIdentifier(componentIdentifier);
51
+ return dialogStates?.[identifier];
52
+ }
53
+ return { dialogStates, getDialog, getDialogData, isDialogOpen };
54
+ }, [dialogStates]);
55
+ return (_jsx(DialogContext.Provider, { value: state, children: _jsx(DialogDataContext.Provider, { value: dataState, children: children }) }));
56
+ }
57
+ export function useDialog() {
58
+ const context = useContext(DialogContext);
59
+ if (!context) {
60
+ throw new Error('useDialog must be used within a DialogProvider');
61
+ }
62
+ return context;
63
+ }
64
+ export function useDialogData() {
65
+ const context = useContext(DialogDataContext);
66
+ if (!context) {
67
+ throw new Error('useDialogData must be used within a DialogProvider');
68
+ }
69
+ return context;
70
+ }
71
+ export function withDialog(WrappedComponent, options = {}) {
72
+ const { dialogName, force = false } = options;
73
+ return (props) => {
74
+ const { closeDialog, openDialog } = useDialog();
75
+ const { getDialog } = useDialogData();
76
+ const dialogIdentifier = dialogName || getDialogIdentifier(WrappedComponent);
77
+ const { isOpen, data } = getDialog(dialogIdentifier) || {
78
+ isOpen: false,
79
+ data: null,
80
+ };
81
+ function handleCloseDialog() {
82
+ closeDialog(dialogIdentifier);
83
+ }
84
+ function handleOpenDialog() {
85
+ openDialog(dialogIdentifier);
86
+ }
87
+ if (!isOpen) {
88
+ return null;
89
+ }
90
+ // Generate a unique key based on dialogIdentifier and data to force re-render the dialog
91
+ const key = force
92
+ ? `${dialogIdentifier}-${JSON.stringify(data)}`
93
+ : undefined;
94
+ return (_jsx(WrappedComponent, { onCloseDialog: handleCloseDialog, onOpenDialog: handleOpenDialog, dialogData: data, ...props }, key));
95
+ };
96
+ }
@@ -0,0 +1,13 @@
1
+ /** @jsxImportSource @emotion/react */
2
+ import { DialogProps, OverlayProps } from '@blueprintjs/core';
3
+ import { ReactNode } from 'react';
4
+ type DialogPlacement = 'top' | 'bottom' | 'center' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center-left' | 'center-right';
5
+ interface HeaderElement {
6
+ headerLeftElement?: ReactNode;
7
+ headerRightElement?: ReactNode;
8
+ }
9
+ interface DraggableDialogProps extends Omit<DialogProps, 'hasBackdrop'>, Pick<OverlayProps, 'hasBackdrop'>, HeaderElement {
10
+ placement?: DialogPlacement;
11
+ }
12
+ export declare function DraggableDialog(props: DraggableDialogProps): import("@emotion/react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -0,0 +1,156 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
3
+ import { Button, Classes, H6, Icon, IconSize, mergeRefs, Overlay2, } from '@blueprintjs/core';
4
+ import { SmallCross } from '@blueprintjs/icons';
5
+ import { css, Global } from '@emotion/react';
6
+ import styled from '@emotion/styled';
7
+ import { useLayoutEffect, useRef } from 'react';
8
+ const Container = styled.div `
9
+ min-height: 100%;
10
+ pointer-events: none;
11
+ user-select: none;
12
+ position: absolute;
13
+ top: 0;
14
+ left: 0;
15
+ width: 100%;
16
+ `;
17
+ export function DraggableDialog(props) {
18
+ const { onClose, headerLeftElement, headerRightElement, placement, hasBackdrop, ...otherProps } = props;
19
+ const dialogRef = useRef(null);
20
+ return (_jsxs(_Fragment, { children: [_jsx(Global, { styles: css `
21
+ div[class*='-portal']:has(.draggable-portal) {
22
+ height: 100%;
23
+ pointer-events: ${hasBackdrop === undefined || hasBackdrop
24
+ ? 'all'
25
+ : 'none'};
26
+ }
27
+ ` }), _jsx(Overlay2, { ...otherProps, childRef: dialogRef, onClose: onClose, className: "draggable-portal", hasBackdrop: hasBackdrop, children: _jsx(InnerDraggableDialog, { innerDialogRef: dialogRef, ...props }) })] }));
28
+ }
29
+ function InnerDraggableDialog(props) {
30
+ const { children, containerRef, role = 'dialog', style, className = '', isCloseButtonShown, onClose, icon, title, headerLeftElement, headerRightElement, placement = 'center', innerDialogRef, } = props;
31
+ const offsetRef = useRef({
32
+ x: 0,
33
+ y: 0,
34
+ });
35
+ const containerRefInternal = useRef(null);
36
+ useLayoutEffect(() => {
37
+ const updateTransform = () => {
38
+ if (!innerDialogRef.current || !containerRefInternal.current) {
39
+ return;
40
+ }
41
+ const dialogRect = innerDialogRef.current.getBoundingClientRect();
42
+ const parentContainerRect = containerRefInternal.current.getBoundingClientRect();
43
+ const { transformX, transformY } = calculateTransform(placement, {
44
+ dialogRect,
45
+ parentContainerRect,
46
+ });
47
+ innerDialogRef.current.style.transform = `translate(${transformX}px, ${transformY}px)`;
48
+ };
49
+ const frameId = requestAnimationFrame(updateTransform);
50
+ return () => {
51
+ cancelAnimationFrame(frameId);
52
+ };
53
+ }, [innerDialogRef, placement]);
54
+ function handleMouseDown(event) {
55
+ const target = event.currentTarget;
56
+ if (!containerRefInternal.current) {
57
+ return;
58
+ }
59
+ const dialogRect = target.getBoundingClientRect();
60
+ const containerRect = containerRefInternal.current.getBoundingClientRect();
61
+ const offsetX = event.clientX - (dialogRect.left - containerRect.left);
62
+ const offsetY = event.clientY - (dialogRect.top - containerRect.top);
63
+ offsetRef.current = {
64
+ x: offsetX,
65
+ y: offsetY,
66
+ };
67
+ function handleMouseMove(event) {
68
+ target.style.cursor = 'move';
69
+ if (!innerDialogRef.current || !offsetRef.current) {
70
+ return;
71
+ }
72
+ const offsetX = event.clientX - offsetRef.current.x;
73
+ const offsetY = event.clientY - offsetRef.current.y;
74
+ innerDialogRef.current.style.transform = `translate(${offsetX}px, ${offsetY}px)`;
75
+ }
76
+ function handleMouseUp() {
77
+ target.style.cursor = 'default';
78
+ window.removeEventListener('mousemove', handleMouseMove);
79
+ window.removeEventListener('mouseup', handleMouseUp);
80
+ }
81
+ window.addEventListener('mousemove', handleMouseMove);
82
+ window.addEventListener('mouseup', handleMouseUp);
83
+ }
84
+ return (_jsx(Container, { ref: containerRefInternal, children: _jsxs("div", { ref: containerRef === undefined
85
+ ? innerDialogRef
86
+ : mergeRefs(containerRef, innerDialogRef), className: `${Classes.DIALOG} ${className}`, role: role, style: {
87
+ ...style,
88
+ position: 'fixed',
89
+ margin: 0,
90
+ }, children: [_jsx(Header, { isCloseButtonShown,
91
+ onClose,
92
+ icon,
93
+ title,
94
+ headerLeftElement,
95
+ headerRightElement, onMouseDown: handleMouseDown }), children] }) }));
96
+ }
97
+ function CloseButton(props) {
98
+ const { isCloseButtonShown = true, onClose } = props;
99
+ if (!isCloseButtonShown) {
100
+ return null;
101
+ }
102
+ return (_jsx(Button, { "aria-label": "Close", className: Classes.DIALOG_CLOSE_BUTTON, icon: _jsx(SmallCross, { size: IconSize.STANDARD }), minimal: true, onClick: onClose }));
103
+ }
104
+ function Header(props) {
105
+ const { icon, title, onMouseDown, headerRightElement, headerLeftElement, ...otherProps } = props;
106
+ if (title == null) {
107
+ return null;
108
+ }
109
+ return (_jsxs("div", { className: Classes.DIALOG_HEADER, onMouseDown: onMouseDown, children: [_jsx(Icon, { icon: icon, size: IconSize.STANDARD, tabIndex: -1 }), headerLeftElement, _jsx(H6, { children: title }), headerRightElement, _jsx(CloseButton, { ...otherProps })] }));
110
+ }
111
+ function calculateTransform(placement, option) {
112
+ let transformX = 0;
113
+ let transformY = 0;
114
+ const { parentContainerRect, dialogRect } = option;
115
+ switch (placement) {
116
+ case 'top':
117
+ transformX = (parentContainerRect.width - dialogRect.width) / 2;
118
+ transformY = 0;
119
+ break;
120
+ case 'bottom':
121
+ transformX = (parentContainerRect.width - dialogRect.width) / 2;
122
+ transformY = parentContainerRect.height - dialogRect.height;
123
+ break;
124
+ case 'center':
125
+ transformX = (parentContainerRect.width - dialogRect.width) / 2;
126
+ transformY = (parentContainerRect.height - dialogRect.height) / 2;
127
+ break;
128
+ case 'top-left':
129
+ transformX = 0;
130
+ transformY = 0;
131
+ break;
132
+ case 'top-right':
133
+ transformX = parentContainerRect.width - dialogRect.width;
134
+ transformY = 0;
135
+ break;
136
+ case 'bottom-left':
137
+ transformX = 0;
138
+ transformY = parentContainerRect.height - dialogRect.height;
139
+ break;
140
+ case 'bottom-right':
141
+ transformX = parentContainerRect.width - dialogRect.width;
142
+ transformY = parentContainerRect.height - dialogRect.height;
143
+ break;
144
+ case 'center-left':
145
+ transformX = 0;
146
+ transformY = (parentContainerRect.height - dialogRect.height) / 2;
147
+ break;
148
+ case 'center-right':
149
+ transformX = parentContainerRect.width - dialogRect.width;
150
+ transformY = (parentContainerRect.height - dialogRect.height) / 2;
151
+ break;
152
+ default:
153
+ break;
154
+ }
155
+ return { transformX, transformY };
156
+ }
@@ -52,7 +52,7 @@ function ReactTableRow(props) {
52
52
  onClick?.(event, row);
53
53
  }, [onClick, row]);
54
54
  const { key: rowKey, ...otherKeyProps } = row.getRowProps();
55
- return (_jsx(ContextMenu, { options: contextMenu, onSelect: (selected) => onContextMenuSelect?.(selected, row.original), as: "tr", style: { position: 'static' }, css: getRowStyle(highlight.isActive || isRowActive, rowStyle, disableDefaultRowStyle), ...otherKeyProps, ...highlight.onHover, children: row.cells.map((cell) => {
55
+ return (_jsx(ContextMenu, { data: row.original, options: contextMenu, onSelect: (selected) => onContextMenuSelect?.(selected, row.original), as: "tr", style: { position: 'static' }, css: getRowStyle(highlight.isActive || isRowActive, rowStyle, disableDefaultRowStyle), ...otherKeyProps, ...highlight.onHover, children: row.cells.map((cell) => {
56
56
  const { column: { style }, isRowSpanned, } = cell;
57
57
  if (isRowSpanned) {
58
58
  return null;
@@ -1,13 +1,10 @@
1
1
  /** @jsxImportSource @emotion/react */
2
2
  import { CSSProperties } from 'react';
3
- import { UseSortByOptions } from 'react-table';
4
3
  interface ReactTableFlexLayoutProps {
5
4
  data: any;
6
5
  columns: any;
7
6
  onMouseDown?: () => void;
8
7
  style?: CSSProperties;
9
8
  }
10
- export interface TableOptions<D extends Record<string, unknown>> extends UseSortByOptions<D> {
11
- }
12
9
  declare function ReactTableFlexLayout({ data, columns, onMouseDown, style, }: ReactTableFlexLayoutProps): import("@emotion/react/jsx-runtime").JSX.Element;
13
10
  export default ReactTableFlexLayout;
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
- import { useTable, useSortBy, useFlexLayout, } from 'react-table';
2
+ import { useTable, useSortBy, useFlexLayout } from 'react-table';
3
3
  import { ReactTableStyle } from './Style';
4
4
  function ReactTableFlexLayout({ data, columns, onMouseDown = () => null, style = {}, }) {
5
5
  const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow } = useTable({
@@ -1,26 +1,31 @@
1
1
  import { ButtonProps } from '@blueprintjs/core';
2
2
  import { SelectProps } from '@blueprintjs/select';
3
- import { ReactNode } from 'react';
3
+ import { ForwardedRef, ReactNode } from 'react';
4
4
  import { useSelect } from 'react-science/ui';
5
5
  import { FilterType } from '../utility/filterType';
6
6
  interface ItemOptions<T> {
7
7
  renderItem?: (item: T) => ReactNode;
8
8
  defaultSelectedItem?: T;
9
9
  }
10
- interface ItemSelectOptions<T extends SelectDefaultItem = SelectDefaultItem> {
10
+ interface ItemSelectOptions<T extends Record<string, any> = SelectDefaultItem> {
11
11
  itemTextKey?: keyof FilterType<T, string>;
12
12
  itemValueKey?: keyof T;
13
13
  selectedItemValue?: T[keyof T];
14
+ placeholder?: string;
15
+ filterPlaceholder?: string;
14
16
  }
15
- type SelectOptions<T extends SelectDefaultItem = SelectDefaultItem> = ItemOptions<T> & ItemSelectOptions;
17
+ type SelectOptions<T extends Record<string, any> = SelectDefaultItem> = ItemOptions<T> & ItemSelectOptions<T>;
16
18
  type ReturnedUseSelectOptions = ReturnType<typeof useSelect>;
17
- export type Select2Props<T extends SelectDefaultItem = SelectDefaultItem> = Omit<SelectProps<T>, keyof Omit<ReturnedUseSelectOptions, 'onItemSelect' | 'value'>> & SelectOptions<T> & {
19
+ export type Select2Props<T extends Record<string, any> = SelectDefaultItem> = Omit<SelectProps<T>, keyof Omit<ReturnedUseSelectOptions, 'onItemSelect' | 'value'>> & SelectOptions<T> & {
18
20
  selectedButtonProps?: Omit<ButtonProps, 'text'>;
19
- };
20
- export declare function getDefaultSelectedItem<T extends SelectDefaultItem = SelectDefaultItem>(items: T[], itemValueKey?: keyof T, value?: any): T | undefined;
21
+ } & Pick<ButtonProps, 'intent'>;
22
+ export declare function getDefaultSelectedItem<T extends Record<string, any> = SelectDefaultItem>(items: T[], itemValueKey?: keyof T, value?: any): T | undefined;
21
23
  export interface SelectDefaultItem {
22
24
  label: string;
23
25
  value: any;
24
26
  }
25
- export declare function Select2<T extends SelectDefaultItem = SelectDefaultItem>(props: Select2Props<T>): import("react/jsx-runtime").JSX.Element;
27
+ declare function InnerSelect2<T extends Record<string, any> = SelectDefaultItem>(props: Select2Props<T>, ref: any): import("react/jsx-runtime").JSX.Element;
28
+ export declare const Select2: <T extends Record<string, any> = SelectDefaultItem>(props: Select2Props<T> & {
29
+ ref?: ForwardedRef<HTMLButtonElement>;
30
+ }) => ReturnType<typeof InnerSelect2>;
26
31
  export {};
@@ -1,13 +1,13 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Button } from '@blueprintjs/core';
3
3
  import { Select } from '@blueprintjs/select';
4
- import { useEffect } from 'react';
4
+ import { forwardRef, useEffect } from 'react';
5
5
  import { useSelect } from 'react-science/ui';
6
6
  export function getDefaultSelectedItem(items, itemValueKey, value) {
7
7
  return items.find((item) => itemValueKey && item[itemValueKey] === value);
8
8
  }
9
- export function Select2(props) {
10
- const { items, defaultSelectedItem, itemTextKey = 'label', itemValueKey = 'value', selectedItemValue, onItemSelect, selectedButtonProps, fill, ...otherProps } = props;
9
+ function InnerSelect2(props, ref) {
10
+ const { items, defaultSelectedItem, itemTextKey = 'label', itemValueKey = 'value', selectedItemValue, onItemSelect, selectedButtonProps, fill, intent, placeholder = '', filterPlaceholder, ...otherProps } = props;
11
11
  const { value: item, onItemSelect: innerOnItemSelect, setValue, ...defaultSelectProps } = useSelect({
12
12
  defaultSelectedItem: defaultSelectedItem ??
13
13
  getDefaultSelectedItem(items, itemValueKey, selectedItemValue),
@@ -21,5 +21,6 @@ export function Select2(props) {
21
21
  return (_jsx(Select, { items: items, filterable: false, onItemSelect: (item, event) => {
22
22
  innerOnItemSelect(item);
23
23
  onItemSelect(item, event);
24
- }, ...defaultSelectProps, ...otherProps, fill: fill, children: _jsx(Button, { fill: fill, text: item?.[itemTextKey] ? String(item[itemTextKey]) : '', ...selectedButtonProps, rightIcon: "double-caret-vertical" }) }));
24
+ }, ...defaultSelectProps, ...otherProps, placeholder: filterPlaceholder, fill: fill, children: _jsx(Button, { ref: ref, fill: fill, text: item?.[itemTextKey] ? String(item[itemTextKey]) : placeholder, ...selectedButtonProps, rightIcon: "double-caret-vertical", intent: intent }) }));
25
25
  }
26
+ export const Select2 = forwardRef(InnerSelect2);
@@ -1,7 +1,7 @@
1
1
  import { ControllerProps, FieldValues } from 'react-hook-form';
2
2
  import { Select2Props, SelectDefaultItem } from './Select2';
3
- type Select2ControllerProps<T extends SelectDefaultItem = SelectDefaultItem, TFieldValues extends FieldValues = FieldValues> = {
3
+ type Select2ControllerProps<T extends Record<string, any> = SelectDefaultItem, TFieldValues extends FieldValues = FieldValues> = {
4
4
  controllerProps?: Omit<ControllerProps<TFieldValues>, 'render'>;
5
5
  } & Pick<ControllerProps<TFieldValues>, 'control' | 'name'> & Omit<Select2Props<T>, 'onItemSelect' | 'selectedItemValue'> & Partial<Pick<Select2Props<T>, 'onItemSelect'>>;
6
- export declare function Select2Controller<T extends SelectDefaultItem = SelectDefaultItem, TFieldValues extends FieldValues = FieldValues>(props: Select2ControllerProps<T, TFieldValues>): import("react/jsx-runtime").JSX.Element;
6
+ export declare function Select2Controller<T extends Record<string, any>, TFieldValues extends FieldValues = FieldValues>(props: Select2ControllerProps<T, TFieldValues>): import("react/jsx-runtime").JSX.Element;
7
7
  export {};
@@ -2,11 +2,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Controller } from 'react-hook-form';
3
3
  import { Select2 } from './Select2';
4
4
  export function Select2Controller(props) {
5
- const { name, control, controllerProps = {}, onItemSelect, ...otherSelectProps } = props;
6
- return (_jsx(Controller, { name: name, control: control, ...controllerProps, render: ({ field }) => {
7
- return (_jsx(Select2, { selectedItemValue: field.value, onItemSelect: (item, event) => {
8
- field.onChange(item.value);
5
+ const { name, control, controllerProps = {}, onItemSelect, intent, itemValueKey = 'value', ...otherSelectProps } = props;
6
+ return (_jsx(Controller, { name: name, control: control, ...controllerProps, render: ({ field, fieldState: { invalid } }) => {
7
+ return (_jsx(Select2, { itemValueKey: itemValueKey, selectedItemValue: field.value, onItemSelect: (item, event) => {
8
+ field.onChange(item[itemValueKey]);
9
9
  onItemSelect?.(item, event);
10
- }, ...otherSelectProps }));
10
+ }, ...otherSelectProps, intent: invalid ? 'danger' : intent }));
11
11
  } }));
12
12
  }
@@ -0,0 +1,9 @@
1
+ /** @jsxImportSource @emotion/react */
2
+ import { ButtonProps } from '@blueprintjs/core';
3
+ import { ReactNode } from 'react';
4
+ interface TabTitleProps {
5
+ onDelete?: ButtonProps['onClick'];
6
+ children?: ReactNode;
7
+ }
8
+ export declare function TabTitle(props: TabTitleProps): import("@emotion/react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
3
+ import { Button, Popover } from '@blueprintjs/core';
4
+ import styled from '@emotion/styled';
5
+ export function TabTitle(props) {
6
+ const { onDelete, children } = props;
7
+ function handleOnDelete(event) {
8
+ event.stopPropagation();
9
+ onDelete?.(event);
10
+ }
11
+ return (_jsx(Popover, { minimal: true, popoverClassName: "popover-tab", position: "top-left", interactionKind: "hover", enforceFocus: false, disabled: typeof onDelete !== 'function', content: _jsx(TabCloseButton, { icon: "cross", intent: "danger", className: "tab-close-btn", onClick: handleOnDelete, small: true }), children: children }));
12
+ }
13
+ const TabCloseButton = styled(Button) `
14
+ border-radius: 50%;
15
+ box-shadow:
16
+ rgb(9 30 66 / 25%) 0 4px 8px -2px,
17
+ rgb(9 30 66 / 8%) 0 0 0 1px !important;
18
+ `;
@@ -1,11 +1,12 @@
1
1
  import { MenuItemProps } from '@blueprintjs/core';
2
2
  import { ToolbarPopoverItemProps as BaseToolbarPopoverItemProps, ToolbarItemProps } from 'react-science/ui';
3
- export interface ToolbarPopoverMenuItem extends MenuItemProps {
4
- data?: object;
3
+ export interface ToolbarPopoverMenuItem<T = object> extends MenuItemProps {
4
+ data?: T;
5
5
  }
6
- interface ToolbarPopoverItemProps extends Omit<BaseToolbarPopoverItemProps, 'onClick' | 'content' | 'itemProps'>, ToolbarItemProps {
7
- options: ToolbarPopoverMenuItem[];
8
- onClick: (data?: object) => void;
6
+ interface ToolbarPopoverItemProps<T = object> extends Omit<BaseToolbarPopoverItemProps, 'onClick' | 'content' | 'itemProps'>, Pick<ToolbarItemProps, 'tooltip' | 'icon' | 'tooltipProps' | 'active' | 'id'> {
7
+ itemProps?: Omit<ToolbarItemProps, 'onClick' | 'disabled'>;
8
+ options: Array<ToolbarPopoverMenuItem<T>>;
9
+ onClick: (data?: T) => void;
9
10
  }
10
- export declare function ToolbarPopoverItem(props: ToolbarPopoverItemProps): import("react/jsx-runtime").JSX.Element;
11
+ export declare function ToolbarPopoverItem<T = object>(props: ToolbarPopoverItemProps<T>): import("react/jsx-runtime").JSX.Element;
11
12
  export {};
@@ -2,9 +2,17 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Menu, MenuItem } from '@blueprintjs/core';
3
3
  import { Toolbar, } from 'react-science/ui';
4
4
  export function ToolbarPopoverItem(props) {
5
- const { options, onClick, ...itemProps } = props;
6
- return (_jsx(Toolbar.PopoverItem, { content: _jsx(Menu, { children: options.map((option) => {
7
- const { data, ...otherOptions } = option;
8
- return (_jsx(MenuItem, { ...otherOptions, onClick: () => onClick(data) }, JSON.stringify(option)));
9
- }) }), itemProps: itemProps }));
5
+ const { options, onClick, icon, tooltip, tooltipProps, active, id, itemProps, disabled, ...otherPopoverItemProps } = props;
6
+ return (_jsx(Toolbar.PopoverItem, { disabled: disabled, ...otherPopoverItemProps, content: _jsx(Menu, { children: options.map((option) => {
7
+ const { data, text, ...otherOptions } = option;
8
+ return (_jsx(MenuItem, { text: text, ...otherOptions, onClick: () => onClick(data) }, JSON.stringify({ data, text })));
9
+ }) }), itemProps: {
10
+ icon,
11
+ tooltip,
12
+ tooltipProps,
13
+ active,
14
+ id,
15
+ disabled,
16
+ ...itemProps,
17
+ } }));
10
18
  }
@@ -0,0 +1,17 @@
1
+ import { PrintPageOptions } from 'nmr-load-save';
2
+ import { ReactNode } from 'react';
3
+ interface BasePrintProps {
4
+ onPrint: (options: PrintPageOptions) => void;
5
+ defaultPrintPageOptions: Partial<PrintPageOptions>;
6
+ }
7
+ interface InnerPrintFrameProps {
8
+ children: ReactNode;
9
+ onAfterPrint?: () => void;
10
+ onBeforePrint?: () => void;
11
+ printPageOptions?: Partial<PrintPageOptions>;
12
+ }
13
+ interface PrintFrameProps extends InnerPrintFrameProps, Partial<BasePrintProps> {
14
+ }
15
+ export declare function PrintContent(props: PrintFrameProps): import("@emotion/react/jsx-runtime").JSX.Element;
16
+ export declare function InnerPrintFrame(props: InnerPrintFrameProps): import("@emotion/react/jsx-runtime").JSX.Element;
17
+ export {};