nmrium 0.55.0 → 0.57.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.
- package/lib/component/1d/Chart1D.js +3 -1
- package/lib/component/1d/ExclusionZoneAnnotation.d.ts +0 -1
- package/lib/component/1d/Viewer1D.js +36 -11
- package/lib/component/1d/database/DatabaseSpectrum.js +14 -19
- package/lib/component/1d/jCouplingGraph/JGraphContext.d.ts +0 -1
- package/lib/component/1d/matrix/Boxplot.d.ts +6 -0
- package/lib/component/1d/matrix/Boxplot.js +97 -0
- package/lib/component/1d/matrix/Stocsy.d.ts +5 -0
- package/lib/component/1d/matrix/Stocsy.js +101 -0
- package/lib/component/1d/matrix/useMatrix.d.ts +29 -0
- package/lib/component/1d/matrix/useMatrix.js +93 -0
- package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.d.ts +0 -1
- package/lib/component/1d/peaks/PeakEditionManager.js +16 -10
- package/lib/component/1d/utilities/getDecimalsCount.js +1 -1
- package/lib/component/1d/utilities/intersectionResolver.js +1 -1
- package/lib/component/1d/utilities/scale.d.ts +2 -1
- package/lib/component/1d/utilities/scale.js +6 -1
- package/lib/component/1d-2d/FieldEdition.d.ts +3 -1
- package/lib/component/1d-2d/FieldEdition.js +26 -10
- package/lib/component/2d/1d-tracer/Left1DChart.d.ts +0 -1
- package/lib/component/2d/1d-tracer/Top1DChart.d.ts +0 -1
- package/lib/component/2d/XAxis.d.ts +0 -1
- package/lib/component/2d/YAxis.d.ts +0 -1
- package/lib/component/2d/ft/Contours.js +7 -7
- package/lib/component/assignment/AssignmentsContext.d.ts +0 -1
- package/lib/component/context/ChartContext.d.ts +0 -1
- package/lib/component/context/DispatchContext.d.ts +0 -1
- package/lib/component/context/GlobalContext.d.ts +0 -1
- package/lib/component/context/KeyModifierContext.js +1 -1
- package/lib/component/context/LoaderContext.d.ts +0 -1
- package/lib/component/context/PreferencesContext.d.ts +0 -1
- package/lib/component/context/PrepareExportContext.d.ts +21 -0
- package/lib/component/context/PrepareExportContext.js +124 -0
- package/lib/component/context/ScaleContext.d.ts +0 -1
- package/lib/component/elements/ActionButtons.d.ts +1 -0
- package/lib/component/elements/ActionButtons.js +4 -4
- package/lib/component/elements/ColorInput.d.ts +0 -1
- package/lib/component/elements/ColorPickerDropdownController.d.ts +2 -0
- package/lib/component/elements/ColorPickerDropdownController.js +8 -0
- package/lib/component/elements/ColumnWrapper.d.ts +0 -1
- package/lib/component/elements/ContextMenu.d.ts +0 -1
- package/lib/component/elements/Input.d.ts +1 -0
- package/lib/component/elements/Input.js +2 -1
- package/lib/component/elements/Input2.d.ts +13 -0
- package/lib/component/elements/Input2.js +118 -0
- package/lib/component/elements/Input2Controller.d.ts +12 -0
- package/lib/component/elements/Input2Controller.js +22 -0
- package/lib/component/elements/MoleculeSelection.js +1 -1
- package/lib/component/elements/NumberInput.js +1 -1
- package/lib/component/elements/NumberInput2.d.ts +12 -0
- package/lib/component/elements/NumberInput2.js +65 -0
- package/lib/component/elements/NumberInput2Controller.d.ts +8 -0
- package/lib/component/elements/NumberInput2Controller.js +15 -0
- package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +3 -3
- package/lib/component/elements/ReactTable/Style.d.ts +3 -1
- package/lib/component/elements/ReactTable/Style.js +11 -1
- package/lib/component/elements/ReactTable/utility/ReactTableContext.d.ts +0 -1
- package/lib/component/elements/Select2.d.ts +26 -0
- package/lib/component/elements/Select2.js +25 -0
- package/lib/component/elements/Select2Controller.d.ts +7 -0
- package/lib/component/elements/Select2Controller.js +12 -0
- package/lib/component/elements/draggable/useDraggable.d.ts +0 -1
- package/lib/component/elements/dropDownButton/DropDownButton.d.ts +2 -4
- package/lib/component/elements/dropDownButton/DropDownButton.js +11 -37
- package/lib/component/elements/dropDownButton/DropDownList.js +3 -32
- package/lib/component/elements/formik/FormikColorPicker.d.ts +0 -1
- package/lib/component/elements/formik/FormikColumnFormatField.d.ts +0 -1
- package/lib/component/elements/formik/FormikInput.d.ts +0 -1
- package/lib/component/elements/formik/FormikInput2.d.ts +11 -0
- package/lib/component/elements/formik/FormikInput2.js +26 -0
- package/lib/component/elements/formik/FormikOnChange.d.ts +0 -1
- package/lib/component/elements/popup/Modal/Context.d.ts +0 -1
- package/lib/component/elements/popup/Modal/ModalContent.d.ts +0 -1
- package/lib/component/elements/resizer/SVGResizer.d.ts +0 -1
- package/lib/component/elements/useFormValidateField.d.ts +1 -0
- package/lib/component/elements/useFormValidateField.js +9 -0
- package/lib/component/header/ApodizationOptionsPanel.js +26 -11
- package/lib/component/header/AutoPeakPickingOptionPanel.d.ts +1 -4
- package/lib/component/header/AutoPeakPickingOptionPanel.js +16 -16
- package/lib/component/header/BaseLineCorrectionPanel.js +49 -27
- package/lib/component/header/Header.js +1 -1
- package/lib/component/header/PhaseCorrectionPanel.js +12 -24
- package/lib/component/header/RangesPickingOptionPanel.js +12 -12
- package/lib/component/header/ZeroFillingOptionsPanel.js +18 -7
- package/lib/component/header/Zones2DOptionPanel.js +19 -18
- package/lib/component/hooks/useExport.d.ts +1 -1
- package/lib/component/hooks/useExport.js +4 -4
- package/lib/component/hooks/usePanelPreferences.d.ts +2 -3
- package/lib/component/hooks/usePanelPreferences.js +3 -1
- package/lib/component/hooks/useToggleSpectraVisibility.d.ts +10 -0
- package/lib/component/hooks/useToggleSpectraVisibility.js +41 -0
- package/lib/component/hooks/useWorkspaceAction.d.ts +1 -1
- package/lib/component/modal/editRange/forms/components/SignalTab.d.ts +0 -1
- package/lib/component/modal/editRange/forms/components/SignalsContent.d.ts +0 -1
- package/lib/component/modal/setting/GeneralSettings.d.ts +5 -1
- package/lib/component/modal/setting/GeneralSettings.js +107 -111
- package/lib/component/modal/setting/WorkspaceItem.js +4 -9
- package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.d.ts +1 -1
- package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.js +95 -59
- package/lib/component/modal/setting/settings-tabs/DisplayTabContent.js +33 -25
- package/lib/component/modal/setting/settings-tabs/GeneralTabContent.js +15 -4
- package/lib/component/modal/setting/settings-tabs/ImportationFiltersTabContent.js +56 -39
- package/lib/component/modal/setting/settings-tabs/InfoBlockTabContent.js +36 -36
- package/lib/component/modal/setting/settings-tabs/NucleiTabContent.js +44 -36
- package/lib/component/modal/setting/settings-tabs/OnLoadProcessingTabContent.js +16 -11
- package/lib/component/modal/setting/settings-tabs/SpectraColorsTabContent.js +47 -40
- package/lib/component/modal/setting/settings-tabs/ToolsTabContent.js +50 -40
- package/lib/component/modal/setting/settingsValidation.js +8 -34
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignmentTable.d.ts +0 -1
- package/lib/component/panels/IntegralsPanel/IntegralTable.d.ts +0 -1
- package/lib/component/panels/IntegralsPanel/IntegralsPreferences.d.ts +0 -1
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.d.ts +2 -2
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +121 -36
- package/lib/component/panels/Panels.js +32 -9
- package/lib/component/panels/PeaksPanel/PeaksPreferences.d.ts +0 -1
- package/lib/component/panels/PeaksPanel/PeaksTable.d.ts +0 -1
- package/lib/component/panels/RangesPanel/RangesPreferences.d.ts +0 -1
- package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.d.ts +0 -1
- package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +4 -27
- package/lib/component/panels/SpectraPanel/SpectraPreferences.d.ts +0 -1
- package/lib/component/panels/SpectraPanel/SpectraPreferences.js +32 -24
- package/lib/component/panels/SpectraPanel/SpectraTable.js +17 -2
- package/lib/component/panels/SpectraPanel/SpectrumListPanel.d.ts +0 -1
- package/lib/component/panels/SpectraPanel/base/ColorIndicator.d.ts +0 -1
- package/lib/component/panels/SpectraPanel/base/SpectraColumnsManager.d.ts +3 -3
- package/lib/component/panels/SpectraPanel/base/SpectraColumnsManager.js +25 -16
- package/lib/component/panels/SpectraPanel/base/setting/Spectrum1DHistogram.d.ts +0 -1
- package/lib/component/panels/SpectraPanel/base/setting/Spectrum1DSetting.js +15 -5
- package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DHistogram.d.ts +0 -1
- package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DSetting.js +44 -6
- package/lib/component/panels/SpectraPanel/base/setting/SpectrumSetting.d.ts +0 -1
- package/lib/component/panels/SummaryPanel/Overview.d.ts +0 -1
- package/lib/component/panels/SummaryPanel/SummaryPanel.d.ts +0 -1
- package/lib/component/panels/SummaryPanel/utilities/Utilities.d.ts +1 -1
- package/lib/component/panels/ZonesPanel/ZonesPreferences.d.ts +0 -1
- package/lib/component/panels/databasePanel/DatabasePanel.js +17 -3
- package/lib/component/panels/databasePanel/DatabasePreferences.d.ts +0 -1
- package/lib/component/panels/databasePanel/DatabaseTable.d.ts +11 -4
- package/lib/component/panels/databasePanel/DatabaseTable.js +22 -7
- package/lib/component/panels/informationPanel/InformationEditionModal.d.ts +6 -0
- package/lib/component/panels/informationPanel/InformationEditionModal.js +105 -0
- package/lib/component/panels/informationPanel/InformationPanel.d.ts +1 -0
- package/lib/component/panels/{InformationPanel.js → informationPanel/InformationPanel.js} +2 -2
- package/lib/component/panels/multipleAnalysisPanel/preferences/MultipleAnalysisCodeEditor.d.ts +0 -1
- package/lib/component/panels/multipleAnalysisPanel/preferences/index.d.ts +0 -1
- package/lib/component/panels/predictionPanel/PredictionOptionsPanel.d.ts +0 -1
- package/lib/component/panels/predictionPanel/PredictionOptionsPanel.js +1 -1
- package/lib/component/panels/predictionPanel/PredictionPreferences.d.ts +0 -1
- package/lib/component/panels/spectrumSimulation/SpectrumSimulationPreferences.d.ts +0 -1
- package/lib/component/reducer/Reducer.d.ts +7 -1
- package/lib/component/reducer/Reducer.js +2 -0
- package/lib/component/reducer/actions/DatabaseActions.js +22 -5
- package/lib/component/reducer/actions/DomainActions.d.ts +5 -2
- package/lib/component/reducer/actions/DomainActions.js +6 -4
- package/lib/component/reducer/actions/FiltersActions.js +2 -2
- package/lib/component/reducer/actions/LoadActions.js +5 -2
- package/lib/component/reducer/actions/SpectraActions.d.ts +9 -2
- package/lib/component/reducer/actions/SpectraActions.js +65 -23
- package/lib/component/reducer/actions/ToolsActions.js +3 -4
- package/lib/component/reducer/preferences/actions/matrixGeneration.d.ts +47 -2
- package/lib/component/reducer/preferences/actions/matrixGeneration.js +62 -25
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.d.ts +11 -8
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +19 -1
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +3 -26
- package/lib/component/reducer/preferences/preferencesReducer.js +7 -1
- package/lib/component/toolbar/ToolBar.js +6 -7
- package/lib/component/utility/PathBuilder.d.ts +1 -0
- package/lib/component/utility/PathBuilder.js +8 -1
- package/lib/component/utility/checkUniqueByKey.d.ts +2 -0
- package/lib/component/utility/checkUniqueByKey.js +40 -0
- package/lib/component/utility/colorToHexWithAlpha.d.ts +9 -0
- package/lib/component/utility/colorToHexWithAlpha.js +4 -0
- package/lib/component/workspaces/exercise.js +2 -0
- package/lib/component/workspaces/process1D.js +0 -1
- package/lib/component/workspaces/workspaceDefaultProperties.js +1 -0
- package/lib/data/PredictionManager.js +3 -5
- package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +13 -13
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +9 -9
- package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +13 -13
- package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +13 -13
- package/lib/data/data1d/database.d.ts +1 -0
- package/lib/data/data1d/database.js +4 -2
- package/lib/data/data2d/Spectrum2D/contours.d.ts +8 -22
- package/lib/data/data2d/Spectrum2D/contours.js +88 -67
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +4 -2
- package/lib/data/data2d/Spectrum2D/zones/detectZonesManual.d.ts +20 -20
- package/lib/data/data2d/Spectrum2D/zones/initiateZones.d.ts +20 -20
- package/lib/data/getDefaultMatrixFilters.d.ts +1 -1
- package/lib/data/initiateFilters.d.ts +1 -1
- package/lib/data/matrixGeneration.js +1 -2
- package/lib/data/types/common/DeepPartial.d.ts +3 -0
- package/lib/data/types/common/DeepPartial.js +1 -0
- package/lib/data/types/common/Keys.d.ts +3 -0
- package/lib/data/types/common/Keys.js +1 -0
- package/lib/data/utilities/generateNumbersPowerOfX.d.ts +2 -2
- package/lib/versionInfo.js +1 -1
- package/package.json +39 -38
- package/lib/component/elements/CustomToolTip.d.ts +0 -8
- package/lib/component/elements/CustomToolTip.js +0 -107
- package/lib/component/elements/formik/FormikSlider.d.ts +0 -6
- package/lib/component/elements/formik/FormikSlider.js +0 -15
- package/lib/component/panels/InformationPanel.d.ts +0 -1
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
import { PopoverProps } from '@blueprintjs/core';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
type InputType = 'number' | 'text';
|
|
5
|
-
interface
|
|
5
|
+
interface FieldProps {
|
|
6
6
|
value: number | string;
|
|
7
7
|
inputType?: InputType;
|
|
8
8
|
onChange: (value: any) => void;
|
|
9
|
+
}
|
|
10
|
+
interface FieldEditionsProps extends FieldProps {
|
|
9
11
|
children: ReactNode;
|
|
10
12
|
PopoverProps?: PopoverProps;
|
|
11
13
|
}
|
|
@@ -2,10 +2,12 @@ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { Popover } from '@blueprintjs/core';
|
|
4
4
|
import { css } from '@emotion/react';
|
|
5
|
-
import {
|
|
5
|
+
import { yupResolver } from '@hookform/resolvers/yup';
|
|
6
6
|
import { useState } from 'react';
|
|
7
|
+
import { useForm } from 'react-hook-form';
|
|
7
8
|
import * as Yup from 'yup';
|
|
8
|
-
import
|
|
9
|
+
import { Input2Controller } from '../elements/Input2Controller';
|
|
10
|
+
import { NumberInput2Controller } from '../elements/NumberInput2Controller';
|
|
9
11
|
const InputDimension = { height: 28, width: 100 };
|
|
10
12
|
const validationSchema = (inputType) => Yup.object({
|
|
11
13
|
value: (inputType === 'number' ? Yup.number() : Yup.string()).required(),
|
|
@@ -24,7 +26,7 @@ function keyDownCheck(event) {
|
|
|
24
26
|
export function FieldEdition(props) {
|
|
25
27
|
const { value, inputType = 'text', onChange, children, PopoverProps } = props;
|
|
26
28
|
const [isOpen, setIsOpen] = useState(false);
|
|
27
|
-
function
|
|
29
|
+
function handleChange({ value: newValue }) {
|
|
28
30
|
onChange(newValue);
|
|
29
31
|
setIsOpen(false);
|
|
30
32
|
}
|
|
@@ -32,11 +34,25 @@ export function FieldEdition(props) {
|
|
|
32
34
|
.field-edition-popover {
|
|
33
35
|
border-radius: 5px;
|
|
34
36
|
}
|
|
35
|
-
`, popoverClassName: "field-edition-popover", isOpen: isOpen, onClose: () => setIsOpen(false), onInteraction: () => setIsOpen(true), content: _jsx(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
`, popoverClassName: "field-edition-popover", isOpen: isOpen, onClose: () => setIsOpen(false), onInteraction: () => setIsOpen(true), content: _jsx(Field, { onChange: handleChange, value: value, inputType: inputType }), ...PopoverProps, children: children }));
|
|
38
|
+
}
|
|
39
|
+
function Field(props) {
|
|
40
|
+
const { value, inputType = 'text', onChange } = props;
|
|
41
|
+
const { control, handleSubmit } = useForm({
|
|
42
|
+
defaultValues: { value },
|
|
43
|
+
resolver: yupResolver(validationSchema(inputType)),
|
|
44
|
+
});
|
|
45
|
+
function handleKeyDown(event) {
|
|
46
|
+
if (keyDownCheck(event)) {
|
|
47
|
+
void handleSubmit(onChange)();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const style = {
|
|
51
|
+
height: `${InputDimension.height}px`,
|
|
52
|
+
outline: 'none',
|
|
53
|
+
};
|
|
54
|
+
if (inputType === 'number') {
|
|
55
|
+
return (_jsx(NumberInput2Controller, { name: "value", control: control, style: style, onKeyDown: handleKeyDown, onClick: stopPropagation, onMouseDown: stopPropagation, autoFocus: true, buttonPosition: "none" }));
|
|
56
|
+
}
|
|
57
|
+
return (_jsx(Input2Controller, { name: "value", control: control, style: style, onKeyDown: handleKeyDown, onClick: stopPropagation, onMouseDown: stopPropagation, autoFocus: true }));
|
|
42
58
|
}
|
|
@@ -28,12 +28,10 @@ function usePath(spectrum, contours) {
|
|
|
28
28
|
pathBuilder.closePath();
|
|
29
29
|
return pathBuilder.toString();
|
|
30
30
|
}
|
|
31
|
-
const useContoursLevel = (spectrum, sign) => {
|
|
32
|
-
const {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
const level = levels?.[id]?.[sign];
|
|
36
|
-
return typeof level !== 'number' ? defaultLevel[sign] : level;
|
|
31
|
+
const useContoursLevel = (spectrum, sign, quadrant = 'rr') => {
|
|
32
|
+
const { display: { contourOptions }, } = spectrum;
|
|
33
|
+
const level = contourOptions[sign];
|
|
34
|
+
return level ?? getDefaultContoursLevel(spectrum, quadrant)[sign];
|
|
37
35
|
};
|
|
38
36
|
function ContoursPaths({ id: spectrumID, sign, color, spectrum, onTimeout, }) {
|
|
39
37
|
const activeSpectrum = useActiveSpectrum();
|
|
@@ -63,7 +61,9 @@ function ContoursInner({ spectra, displayerKey }) {
|
|
|
63
61
|
function timeoutHandler() {
|
|
64
62
|
debounceAlert.current();
|
|
65
63
|
}
|
|
66
|
-
return (_jsx("g", { clipPath: `url(#${displayerKey}clip-chart-2d)`, className: "contours", children: spectra?.map((spectrum) =>
|
|
64
|
+
return (_jsx("g", { clipPath: `url(#${displayerKey}clip-chart-2d)`, className: "contours", children: spectra?.map((spectrum) => {
|
|
65
|
+
return (_jsxs("g", { children: [spectrum.display.isPositiveVisible && (_jsx(ContoursPaths, { id: spectrum.id, sign: "positive", spectrum: spectrum, color: spectrum.display.positiveColor, onTimeout: timeoutHandler })), spectrum.display.isNegativeVisible && (_jsx(ContoursPaths, { id: spectrum.id, sign: "negative", spectrum: spectrum, color: spectrum.display.negativeColor, onTimeout: timeoutHandler }))] }, spectrum.id));
|
|
66
|
+
}) }));
|
|
67
67
|
}
|
|
68
68
|
const MemoizedContours = memo(ContoursInner);
|
|
69
69
|
export default function Contours() {
|
|
@@ -21,7 +21,7 @@ export function useKeyModifiers() {
|
|
|
21
21
|
}
|
|
22
22
|
return context;
|
|
23
23
|
}
|
|
24
|
-
const isMac = navigator
|
|
24
|
+
const isMac = globalThis.navigator?.userAgent?.toLowerCase().includes('mac');
|
|
25
25
|
export function getModifiers(event) {
|
|
26
26
|
const { shiftKey, altKey, metaKey } = event;
|
|
27
27
|
const ctrlKey = isMac ? metaKey : event.ctrlKey;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface PrepareExportContextState {
|
|
3
|
+
registerComponent: (componentId: any) => void;
|
|
4
|
+
unRegisterComponent: (componentId: any) => void;
|
|
5
|
+
notifyComponentLoaded: (componentId: any) => void;
|
|
6
|
+
prepareExportStart: () => void;
|
|
7
|
+
waitForAllComponentsRendered: () => Promise<void>;
|
|
8
|
+
prepareExportEnd: () => void;
|
|
9
|
+
isExporting: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface PrepareExportProviderProps {
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
timeout?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare function usePrepareExport(): PrepareExportContextState;
|
|
16
|
+
export declare function useRegisterExportComponents(componentId: string): void;
|
|
17
|
+
export declare function useNotifyComponentLoaded(componentId: string): void;
|
|
18
|
+
export declare function PrepareExportProvider(props: PrepareExportProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare function withExportRegister<P extends object>(Component: React.ComponentType<P>, componentId: string): (props: P) => import("react/jsx-runtime").JSX.Element | null;
|
|
20
|
+
export declare function withExport<P extends object>(Component: React.ComponentType<P>, componentId: string): (props: P) => import("react/jsx-runtime").JSX.Element | null;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from 'react';
|
|
3
|
+
const PrepareExportContext = createContext(null);
|
|
4
|
+
export function usePrepareExport() {
|
|
5
|
+
const context = useContext(PrepareExportContext);
|
|
6
|
+
if (!context) {
|
|
7
|
+
throw new Error('Export prepare context was not found');
|
|
8
|
+
}
|
|
9
|
+
return context;
|
|
10
|
+
}
|
|
11
|
+
export function useRegisterExportComponents(componentId) {
|
|
12
|
+
const { registerComponent, unRegisterComponent } = usePrepareExport();
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
registerComponent(componentId);
|
|
15
|
+
return () => {
|
|
16
|
+
unRegisterComponent(componentId);
|
|
17
|
+
};
|
|
18
|
+
}, [componentId, registerComponent, unRegisterComponent]);
|
|
19
|
+
}
|
|
20
|
+
export function useNotifyComponentLoaded(componentId) {
|
|
21
|
+
const { notifyComponentLoaded } = usePrepareExport();
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
notifyComponentLoaded(componentId);
|
|
24
|
+
}, [componentId, notifyComponentLoaded]);
|
|
25
|
+
}
|
|
26
|
+
export function PrepareExportProvider(props) {
|
|
27
|
+
const { children, timeout = 10000 } = props;
|
|
28
|
+
const [isExporting, setIsExporting] = useState(false);
|
|
29
|
+
const componentRefs = useRef(new Map());
|
|
30
|
+
const registerComponent = useCallback((componentId) => {
|
|
31
|
+
componentRefs.current.set(componentId, false);
|
|
32
|
+
}, []);
|
|
33
|
+
const unRegisterComponent = useCallback((componentId) => {
|
|
34
|
+
componentRefs.current.delete(componentId);
|
|
35
|
+
}, []);
|
|
36
|
+
const notifyComponentLoaded = useCallback((componentId) => {
|
|
37
|
+
componentRefs.current.set(componentId, true);
|
|
38
|
+
}, []);
|
|
39
|
+
const prepareExportStart = useCallback(() => {
|
|
40
|
+
setIsExporting(true);
|
|
41
|
+
}, []);
|
|
42
|
+
const prepareExportEnd = useCallback(() => {
|
|
43
|
+
for (const key of componentRefs.current.keys()) {
|
|
44
|
+
componentRefs.current.set(key, false);
|
|
45
|
+
}
|
|
46
|
+
setIsExporting(false);
|
|
47
|
+
}, []);
|
|
48
|
+
const waitForAllComponentsRendered = useCallback(() => {
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
const loadPromise = checkComponents(componentRefs.current);
|
|
51
|
+
const timeoutPromise = createTimeoutPromise(timeout);
|
|
52
|
+
Promise.race([loadPromise, timeoutPromise])
|
|
53
|
+
.then(resolve)
|
|
54
|
+
.catch((error) => {
|
|
55
|
+
if (error instanceof Error) {
|
|
56
|
+
reject(error);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
reject(new Error('Unknown error occurred'));
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}, [timeout]);
|
|
64
|
+
const state = useMemo(() => {
|
|
65
|
+
return {
|
|
66
|
+
prepareExportStart,
|
|
67
|
+
prepareExportEnd,
|
|
68
|
+
registerComponent,
|
|
69
|
+
notifyComponentLoaded,
|
|
70
|
+
waitForAllComponentsRendered,
|
|
71
|
+
unRegisterComponent,
|
|
72
|
+
isExporting,
|
|
73
|
+
};
|
|
74
|
+
}, [
|
|
75
|
+
prepareExportStart,
|
|
76
|
+
prepareExportEnd,
|
|
77
|
+
registerComponent,
|
|
78
|
+
notifyComponentLoaded,
|
|
79
|
+
waitForAllComponentsRendered,
|
|
80
|
+
unRegisterComponent,
|
|
81
|
+
isExporting,
|
|
82
|
+
]);
|
|
83
|
+
return (_jsx(PrepareExportContext.Provider, { value: state, children: children }));
|
|
84
|
+
}
|
|
85
|
+
const interval = 100;
|
|
86
|
+
function checkComponents(componentsStatus) {
|
|
87
|
+
if (componentsStatus.size === 0)
|
|
88
|
+
return Promise.resolve();
|
|
89
|
+
return new Promise((resolve) => {
|
|
90
|
+
const checkInterval = setInterval(() => {
|
|
91
|
+
const allLoaded = Array.from(componentsStatus.values()).every(Boolean);
|
|
92
|
+
if (allLoaded) {
|
|
93
|
+
clearInterval(checkInterval);
|
|
94
|
+
resolve();
|
|
95
|
+
}
|
|
96
|
+
}, interval);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function createTimeoutPromise(timeout) {
|
|
100
|
+
return new Promise((_, reject) => {
|
|
101
|
+
setTimeout(() => {
|
|
102
|
+
reject(new Error('Load svg component timeout'));
|
|
103
|
+
}, timeout);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
export function withExportRegister(Component, componentId) {
|
|
107
|
+
return (props) => {
|
|
108
|
+
const { isExporting } = usePrepareExport();
|
|
109
|
+
useRegisterExportComponents(componentId);
|
|
110
|
+
if (isExporting)
|
|
111
|
+
return null;
|
|
112
|
+
return _jsx(Component, { ...props });
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export function withExport(Component, componentId) {
|
|
116
|
+
return (props) => {
|
|
117
|
+
const { isExporting } = usePrepareExport();
|
|
118
|
+
useNotifyComponentLoaded(componentId);
|
|
119
|
+
if (!isExporting) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
return _jsx(Component, { ...props });
|
|
123
|
+
};
|
|
124
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import Button from '
|
|
2
|
+
import { Button } from '@blueprintjs/core';
|
|
3
3
|
export default function ActionButtons(props) {
|
|
4
|
-
const { onDone, onCancel, doneLabel = 'Apply', cancelLabel = 'Cancel', style = {}, } = props;
|
|
5
|
-
return (_jsxs("div", { style: { margin: '0 10px', display: 'flex', ...style }, children: [_jsx(Button
|
|
4
|
+
const { onDone, onCancel, doneLabel = 'Apply', cancelLabel = 'Cancel', style = {}, disabledDone = false, } = props;
|
|
5
|
+
return (_jsxs("div", { style: { margin: '0 10px', display: 'flex', ...style }, children: [_jsx(Button, { disabled: disabledDone, intent: "success", onClick: onDone, style: style?.flexDirection === 'row-reverse'
|
|
6
6
|
? {
|
|
7
7
|
marginLeft: '10px',
|
|
8
8
|
}
|
|
9
|
-
: {}, children: doneLabel }), _jsx(Button
|
|
9
|
+
: {}, children: doneLabel }), _jsx(Button, { outlined: true, intent: "danger", onClick: onCancel, style: !style.flexDirection || style.flexDirection === 'row'
|
|
10
10
|
? {
|
|
11
11
|
marginLeft: '10px',
|
|
12
12
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Controller } from 'react-hook-form';
|
|
3
|
+
import { ColorPickerDropdown } from 'react-science/ui';
|
|
4
|
+
export function ColorPickerDropdownController(props) {
|
|
5
|
+
return (_jsx(Controller, { ...props, render: ({ field }) => {
|
|
6
|
+
return (_jsx(ColorPickerDropdown, { onChangeComplete: ({ hex }) => field.onChange(hex), color: { hex: field.value } }));
|
|
7
|
+
} }));
|
|
8
|
+
}
|
|
@@ -13,6 +13,7 @@ export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElem
|
|
|
13
13
|
onClear?: () => void;
|
|
14
14
|
datalist?: string[];
|
|
15
15
|
debounceTime?: number;
|
|
16
|
+
small?: boolean;
|
|
16
17
|
}
|
|
17
18
|
declare const Input: import("react").ForwardRefExoticComponent<InputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
18
19
|
export default Input;
|
|
@@ -36,7 +36,7 @@ const Input = forwardRef((props, ref) => {
|
|
|
36
36
|
const { value: externalValue = undefined, name, style = {
|
|
37
37
|
input: {},
|
|
38
38
|
inputWrapper: {},
|
|
39
|
-
}, onChange, checkValue = () => true, type = 'text', autoSelect = false, className, renderIcon, canClear = false, onClear, datalist = [], debounceTime = 0, ...otherProps } = props;
|
|
39
|
+
}, onChange, checkValue = () => true, type = 'text', autoSelect = false, className, renderIcon, canClear = false, onClear, datalist = [], debounceTime = 0, small = false, ...otherProps } = props;
|
|
40
40
|
const [internalValue, setInternalValue] = useState();
|
|
41
41
|
const value = debounceTime ? internalValue : externalValue;
|
|
42
42
|
const localRef = useRef();
|
|
@@ -82,6 +82,7 @@ const Input = forwardRef((props, ref) => {
|
|
|
82
82
|
}, className: `input ${className || ''} `, children: [renderIcon?.(), _jsx("input", { ...otherProps, className: isDebounced ? 'debounce-end' : '', ref: combinedRef, name: name, style: {
|
|
83
83
|
...styles.input,
|
|
84
84
|
...style?.input,
|
|
85
|
+
padding: !small ? '0.4rem' : '0 0.4rem',
|
|
85
86
|
}, type: type, value: mapValue(value), onChange: onChangeHandler, list: `${name || ''}-data-list` }), canClear && value && (_jsx("button", { type: "button", style: styles.clearButton, onClick: clearHandler, children: _jsx("span", { style: { display: 'block', margin: '0 auto' }, children: "\u2715" }) })), _jsx("datalist", { id: `${name || ''}-data-list`, children: datalist.map((value) => (_jsx("option", { value: value }, value))) })] }));
|
|
86
87
|
});
|
|
87
88
|
export default Input;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { InputGroupProps } from '@blueprintjs/core';
|
|
2
|
+
interface BaseInputProps {
|
|
3
|
+
debounceTime?: number;
|
|
4
|
+
autoSelect?: boolean;
|
|
5
|
+
checkValue?: (element?: number | string) => boolean;
|
|
6
|
+
onChange?: (value: string, event?: React.ChangeEvent<HTMLInputElement>) => void;
|
|
7
|
+
}
|
|
8
|
+
export interface Input2Props<FilterItem extends string = string> extends Omit<InputGroupProps, 'onChange' | 'inputRef'>, BaseInputProps {
|
|
9
|
+
getFilterValue?: (item: FilterItem) => string;
|
|
10
|
+
filterItems?: FilterItem[];
|
|
11
|
+
}
|
|
12
|
+
declare const Input2: import("react").ForwardRefExoticComponent<Input2Props<string> & import("react").RefAttributes<unknown>>;
|
|
13
|
+
export { Input2 };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Classes, MenuItem } from '@blueprintjs/core';
|
|
3
|
+
import { Suggest } from '@blueprintjs/select';
|
|
4
|
+
import debounce from 'lodash/debounce';
|
|
5
|
+
import { useEffect, useRef, useMemo, useState, isValidElement, forwardRef, } from 'react';
|
|
6
|
+
import useCombinedRefs from '../hooks/useCombinedRefs';
|
|
7
|
+
function useInput(props) {
|
|
8
|
+
const { value: externalValue, debounceTime, ref, autoSelect, onChange, checkValue, } = props;
|
|
9
|
+
const [internalValue, setValue] = useState();
|
|
10
|
+
const value = debounceTime ? internalValue : externalValue;
|
|
11
|
+
const localRef = useRef();
|
|
12
|
+
const innerRef = useCombinedRefs([ref, localRef]);
|
|
13
|
+
const [isDebounced, setDebouncedStatus] = useState(false);
|
|
14
|
+
const debounceOnChange = useMemo(() => debounce((val, event) => {
|
|
15
|
+
onChange?.(val, event);
|
|
16
|
+
setDebouncedStatus(true);
|
|
17
|
+
}, debounceTime), [debounceTime, onChange]);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (debounceTime) {
|
|
20
|
+
setValue(externalValue);
|
|
21
|
+
}
|
|
22
|
+
}, [debounceTime, externalValue]);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (autoSelect) {
|
|
25
|
+
innerRef?.current?.select();
|
|
26
|
+
}
|
|
27
|
+
}, [autoSelect, innerRef]);
|
|
28
|
+
function handleChange(val, event) {
|
|
29
|
+
if (!event)
|
|
30
|
+
return;
|
|
31
|
+
event?.stopPropagation();
|
|
32
|
+
event?.preventDefault();
|
|
33
|
+
setDebouncedStatus(false);
|
|
34
|
+
if (!checkValue || checkValue?.(val)) {
|
|
35
|
+
if (debounceTime) {
|
|
36
|
+
setValue(val);
|
|
37
|
+
debounceOnChange(val, event);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
onChange?.(val, event);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
handleChange,
|
|
46
|
+
setValue,
|
|
47
|
+
innerRef,
|
|
48
|
+
debounceOnChange,
|
|
49
|
+
isDebounced,
|
|
50
|
+
value,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function getIcon(leftIcon) {
|
|
54
|
+
if (isValidElement(leftIcon)) {
|
|
55
|
+
return _jsx("span", { className: Classes.ICON, children: leftIcon });
|
|
56
|
+
}
|
|
57
|
+
return leftIcon;
|
|
58
|
+
}
|
|
59
|
+
function getClasses(isDebounced) {
|
|
60
|
+
const classes = ['text-input'];
|
|
61
|
+
if (isDebounced) {
|
|
62
|
+
classes.push('debounce-end');
|
|
63
|
+
}
|
|
64
|
+
return classes.join(' ');
|
|
65
|
+
}
|
|
66
|
+
function InnerInput(props, ref) {
|
|
67
|
+
const { debounceTime = 0, onChange, checkValue, value: externalValue, getFilterValue = (item) => item, filterItems, leftIcon, autoSelect = false, ...otherInputProps } = props;
|
|
68
|
+
const { handleChange, setValue, isDebounced, innerRef, value } = useInput({
|
|
69
|
+
value: externalValue,
|
|
70
|
+
ref,
|
|
71
|
+
autoSelect,
|
|
72
|
+
debounceTime,
|
|
73
|
+
onChange,
|
|
74
|
+
checkValue,
|
|
75
|
+
});
|
|
76
|
+
function handleItemSelect(item, event) {
|
|
77
|
+
const val = getFilterValue(item);
|
|
78
|
+
setValue(val);
|
|
79
|
+
onChange?.(val, event);
|
|
80
|
+
}
|
|
81
|
+
function renderItem(item, { handleClick, modifiers }) {
|
|
82
|
+
const { active, matchesPredicate } = modifiers;
|
|
83
|
+
if (!matchesPredicate) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
const val = getFilterValue(item);
|
|
87
|
+
return (_jsx(MenuItem, { text: val, onClick: handleClick, roleStructure: "listoption", active: active }, val));
|
|
88
|
+
}
|
|
89
|
+
function itemPredicate(query, item) {
|
|
90
|
+
return getFilterValue(item).toLowerCase().includes(query.toLowerCase());
|
|
91
|
+
}
|
|
92
|
+
const icon = getIcon(leftIcon);
|
|
93
|
+
const classes = getClasses(isDebounced);
|
|
94
|
+
return (_jsx(Suggest, { inputProps: {
|
|
95
|
+
placeholder: '',
|
|
96
|
+
leftIcon: icon,
|
|
97
|
+
inputClassName: classes,
|
|
98
|
+
inputRef: innerRef,
|
|
99
|
+
...otherInputProps,
|
|
100
|
+
}, items: [], query: value, onQueryChange: handleChange, popoverProps: { disabled: true }, ...(filterItems &&
|
|
101
|
+
filterItems.length > 0 && {
|
|
102
|
+
items: filterItems,
|
|
103
|
+
itemRenderer: renderItem,
|
|
104
|
+
onItemSelect: handleItemSelect,
|
|
105
|
+
inputValueRenderer: getFilterValue,
|
|
106
|
+
itemPredicate,
|
|
107
|
+
popoverProps: { minimal: true, placement: 'bottom' },
|
|
108
|
+
popoverContentProps: {
|
|
109
|
+
style: {
|
|
110
|
+
maxHeight: '250px',
|
|
111
|
+
overflowY: 'auto',
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
noResults: (_jsx(MenuItem, { disabled: true, text: "No results.", roleStructure: "listoption" })),
|
|
115
|
+
}), closeOnSelect: true, resetOnQuery: true }));
|
|
116
|
+
}
|
|
117
|
+
const Input2 = forwardRef(InnerInput);
|
|
118
|
+
export { Input2 };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ControllerProps, FieldValues } from 'react-hook-form';
|
|
2
|
+
import { Input2Props } from './Input2';
|
|
3
|
+
export interface InputMapValueFunctions {
|
|
4
|
+
mapOnChangeValue?: (value: string) => any;
|
|
5
|
+
mapValue?: (value: any) => string;
|
|
6
|
+
}
|
|
7
|
+
interface Input2ControllerProps<TFieldValues extends FieldValues = FieldValues> extends Omit<Input2Props, 'name'>, Pick<ControllerProps<TFieldValues>, 'control' | 'name'>, InputMapValueFunctions {
|
|
8
|
+
controllerProps?: Omit<ControllerProps<TFieldValues>, 'render'>;
|
|
9
|
+
noShadowBox?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function Input2Controller<TFieldValues extends FieldValues = FieldValues>(props: Input2ControllerProps<TFieldValues>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Controller } from 'react-hook-form';
|
|
3
|
+
import { Input2 } from './Input2';
|
|
4
|
+
export function Input2Controller(props) {
|
|
5
|
+
const { controllerProps, onChange, name, control, intent = 'none', mapOnChangeValue, mapValue, noShadowBox = false, style, ...otherInputProps } = props;
|
|
6
|
+
return (_jsx(Controller, { name: name, control: control, ...controllerProps, render: ({ field, fieldState: { invalid } }) => {
|
|
7
|
+
const { value: originValue, ...otherFieldProps } = field;
|
|
8
|
+
const value = mapValue?.(originValue) || originValue;
|
|
9
|
+
return (_jsx(Input2, { value: value, ...otherFieldProps, onChange: (value, event) => {
|
|
10
|
+
if (typeof mapOnChangeValue === 'function') {
|
|
11
|
+
field.onChange(mapOnChangeValue(value));
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
field.onChange(value);
|
|
15
|
+
}
|
|
16
|
+
onChange?.(value, event);
|
|
17
|
+
}, style: {
|
|
18
|
+
...style,
|
|
19
|
+
...(noShadowBox && !invalid && { boxShadow: 'none' }),
|
|
20
|
+
}, intent: invalid ? 'danger' : intent, ...otherInputProps }));
|
|
21
|
+
} }));
|
|
22
|
+
}
|
|
@@ -2,7 +2,7 @@ import { jsxs as _jsxs, jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
import { useCallback, useEffect, useState } from 'react';
|
|
5
|
-
import MF from 'react-mf
|
|
5
|
+
import { MF } from 'react-mf';
|
|
6
6
|
import { MolfileSvgRenderer } from 'react-ocl/full';
|
|
7
7
|
import NextPrev from './NextPrev';
|
|
8
8
|
const toolbarStyle = css `
|
|
@@ -8,7 +8,7 @@ const inputStyle = {
|
|
|
8
8
|
border: '0.55px solid #c7c7c7',
|
|
9
9
|
textAlign: 'center',
|
|
10
10
|
};
|
|
11
|
-
const NumberInput = forwardRef(({ name, value: valueProp, style = {}, onChange, pattern =
|
|
11
|
+
const NumberInput = forwardRef(({ name, value: valueProp, style = {}, onChange, pattern = String.raw `^\d*.\d*$`, step = 'any', min = 'any', max = 'any', autoSelect = false, ...otherProps }, ref) => {
|
|
12
12
|
const combinedRef = useCombinedRefs([ref]);
|
|
13
13
|
useEffect(() => {
|
|
14
14
|
if (autoSelect) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** @jsxImportSource @emotion/react */
|
|
2
|
+
import { HTMLInputProps, NumericInputProps } from '@blueprintjs/core';
|
|
3
|
+
interface ValueProps extends Pick<React.InputHTMLAttributes<HTMLInputElement>, 'name' | 'style'>, Pick<NumericInputProps, 'onValueChange' | 'value'> {
|
|
4
|
+
checkValue?: (element?: number) => boolean;
|
|
5
|
+
debounceTime?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface NumberInput2Props extends Omit<HTMLInputProps & NumericInputProps, 'value' | 'onValueChange'>, ValueProps {
|
|
8
|
+
format?: () => (element: string) => number | string;
|
|
9
|
+
autoSelect?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const NumberInput2: import("react").ForwardRefExoticComponent<NumberInput2Props & import("react").RefAttributes<unknown>>;
|
|
12
|
+
export { NumberInput2 };
|