nmrium 0.32.0 → 0.33.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 (116) hide show
  1. package/lib/component/1d/Chart1D.js +1 -1
  2. package/lib/component/1d/{Integral.d.ts → integral/Integral.d.ts} +0 -0
  3. package/lib/component/1d/{Integral.js → integral/Integral.js} +2 -2
  4. package/lib/component/1d/integral/IntegralIndicator.d.ts +9 -0
  5. package/lib/component/1d/integral/IntegralIndicator.js +27 -0
  6. package/lib/component/1d/{IntegralResizable.d.ts → integral/IntegralResizable.d.ts} +0 -0
  7. package/lib/component/1d/integral/IntegralResizable.js +69 -0
  8. package/lib/component/1d/{IntegralsSeries.d.ts → integral/IntegralsSeries.d.ts} +0 -0
  9. package/lib/component/1d/{IntegralsSeries.js → integral/IntegralsSeries.js} +3 -3
  10. package/lib/component/1d/ranges/Range.js +27 -50
  11. package/lib/component/1d/utilities/scale.js +2 -2
  12. package/lib/component/2d/Contours.js +61 -42
  13. package/lib/component/NMRium.d.ts +1 -1
  14. package/lib/component/NMRium.js +1 -1
  15. package/lib/component/elements/formik/FormikColorPicker.d.ts +0 -1
  16. package/lib/component/elements/formik/FormikColorPicker.js +5 -8
  17. package/lib/component/elements/formik/FormikInput.d.ts +0 -1
  18. package/lib/component/elements/formik/FormikInput.js +8 -19
  19. package/lib/component/elements/formik/FormikOnChange.d.ts +1 -1
  20. package/lib/component/elements/formik/FormikOnChange.js +13 -10
  21. package/lib/component/elements/formik/FormikSlider.d.ts +2 -4
  22. package/lib/component/elements/formik/FormikSlider.js +8 -11
  23. package/lib/component/hooks/useExport.js +1 -1
  24. package/lib/component/modal/ExportAsMatrixModal.js +1 -1
  25. package/lib/component/modal/editRange/forms/components/SignalFormInfo.js +1 -1
  26. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +1 -1
  27. package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -1
  28. package/lib/component/panels/RangesPanel/RangesHeader.js +1 -1
  29. package/lib/component/panels/RangesPanel/RangesPanel.js +1 -1
  30. package/lib/component/panels/RangesPanel/RangesTableRow.js +1 -3
  31. package/lib/component/panels/SpectrumsPanel/SpectrumsTabs.js +1 -1
  32. package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum1DSetting.d.ts +1 -1
  33. package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum1DSetting.js +2 -1
  34. package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum2DSetting.d.ts +1 -1
  35. package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum2DSetting.js +2 -1
  36. package/lib/component/panels/extra/preferences/ColumnsHelper.js +5 -2
  37. package/lib/component/reducer/Reducer.d.ts +18 -12
  38. package/lib/component/reducer/Reducer.js +23 -9
  39. package/lib/component/reducer/actions/PreferencesActions.js +16 -35
  40. package/lib/component/reducer/actions/RangesActions.js +6 -4
  41. package/lib/component/reducer/actions/SpectrumsActions.js +10 -4
  42. package/lib/component/reducer/actions/ToolsActions.js +7 -22
  43. package/lib/component/reducer/core/Constants.js +1 -1
  44. package/lib/component/utility/FileUtility.d.ts +1 -8
  45. package/lib/component/utility/FileUtility.js +2 -17
  46. package/lib/component/utility/{Export.d.ts → export.d.ts} +0 -0
  47. package/lib/component/utility/{Export.js → export.js} +26 -49
  48. package/lib/component/utility/formatNumber.d.ts +6 -1
  49. package/lib/component/utility/formatNumber.js +4 -3
  50. package/lib/data/SpectraManager.d.ts +1 -2
  51. package/lib/data/SpectraManager.js +22 -55
  52. package/lib/data/data1d/filter1d/fft.js +21 -4
  53. package/lib/data/data2d/Spectrum2D/contours.d.ts +40 -0
  54. package/lib/data/data2d/Spectrum2D/contours.js +132 -0
  55. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +2 -3
  56. package/lib/data/types/common/Source.d.ts +1 -0
  57. package/lib/data/types/data2d/Data2D.d.ts +2 -0
  58. package/lib/data/types/data2d/Datum2D.d.ts +0 -1
  59. package/lib/versionInfo.js +1 -1
  60. package/lib-cjs/component/1d/Chart1D.js +1 -1
  61. package/lib-cjs/component/1d/{Integral.js → integral/Integral.js} +2 -2
  62. package/lib-cjs/component/1d/integral/IntegralIndicator.js +31 -0
  63. package/lib-cjs/component/1d/integral/IntegralResizable.js +74 -0
  64. package/lib-cjs/component/1d/{IntegralsSeries.js → integral/IntegralsSeries.js} +3 -3
  65. package/lib-cjs/component/1d/ranges/Range.js +27 -50
  66. package/lib-cjs/component/1d/utilities/scale.js +2 -2
  67. package/lib-cjs/component/2d/Contours.js +60 -41
  68. package/lib-cjs/component/NMRium.js +2 -2
  69. package/lib-cjs/component/elements/formik/FormikColorPicker.js +4 -7
  70. package/lib-cjs/component/elements/formik/FormikInput.js +8 -19
  71. package/lib-cjs/component/elements/formik/FormikOnChange.js +13 -10
  72. package/lib-cjs/component/elements/formik/FormikSlider.js +7 -10
  73. package/lib-cjs/component/hooks/useExport.js +6 -6
  74. package/lib-cjs/component/modal/ExportAsMatrixModal.js +2 -2
  75. package/lib-cjs/component/modal/editRange/forms/components/SignalFormInfo.js +1 -1
  76. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +4 -4
  77. package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +2 -2
  78. package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +2 -2
  79. package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +2 -2
  80. package/lib-cjs/component/panels/RangesPanel/RangesTableRow.js +1 -3
  81. package/lib-cjs/component/panels/SpectrumsPanel/SpectrumsTabs.js +2 -2
  82. package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum1DSetting.js +2 -1
  83. package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum2DSetting.js +2 -1
  84. package/lib-cjs/component/panels/extra/preferences/ColumnsHelper.js +5 -2
  85. package/lib-cjs/component/reducer/Reducer.js +22 -8
  86. package/lib-cjs/component/reducer/actions/PreferencesActions.js +16 -35
  87. package/lib-cjs/component/reducer/actions/RangesActions.js +6 -4
  88. package/lib-cjs/component/reducer/actions/SpectrumsActions.js +9 -3
  89. package/lib-cjs/component/reducer/actions/ToolsActions.js +7 -22
  90. package/lib-cjs/component/reducer/core/Constants.js +1 -1
  91. package/lib-cjs/component/utility/FileUtility.js +2 -18
  92. package/lib-cjs/component/utility/{Export.js → export.js} +50 -50
  93. package/lib-cjs/component/utility/formatNumber.js +4 -3
  94. package/lib-cjs/data/SpectraManager.js +23 -57
  95. package/lib-cjs/data/data1d/filter1d/fft.js +20 -3
  96. package/lib-cjs/data/data2d/Spectrum2D/contours.js +138 -0
  97. package/lib-cjs/data/data2d/Spectrum2D/initiateDatum2D.js +2 -3
  98. package/lib-cjs/versionInfo.js +1 -1
  99. package/package.json +6 -6
  100. package/lib/component/1d/IntegralResizable.js +0 -72
  101. package/lib/component/panels/RangesPanel/TableColumns/format.d.ts +0 -1
  102. package/lib/component/panels/RangesPanel/TableColumns/format.js +0 -8
  103. package/lib/data/data1d/Data1DManager.d.ts +0 -3
  104. package/lib/data/data1d/Data1DManager.js +0 -98
  105. package/lib/data/data2d/Data2DManager.d.ts +0 -3
  106. package/lib/data/data2d/Data2DManager.js +0 -34
  107. package/lib/data/types/data2d/Contour.d.ts +0 -4
  108. package/lib/data/types/data2d/Contour.js +0 -1
  109. package/lib/data/types/data2d/Contours.d.ts +0 -2
  110. package/lib/data/types/data2d/Contours.js +0 -1
  111. package/lib-cjs/component/1d/IntegralResizable.js +0 -77
  112. package/lib-cjs/component/panels/RangesPanel/TableColumns/format.js +0 -14
  113. package/lib-cjs/data/data1d/Data1DManager.js +0 -104
  114. package/lib-cjs/data/data2d/Data2DManager.js +0 -40
  115. package/lib-cjs/data/types/data2d/Contour.js +0 -2
  116. package/lib-cjs/data/types/data2d/Contours.js +0 -2
@@ -20,7 +20,6 @@ const RelativeColumn_1 = __importDefault(require("./TableColumns/RelativeColumn"
20
20
  const SignalAssignmentsColumn_1 = __importDefault(require("./TableColumns/SignalAssignmentsColumn"));
21
21
  const SignalDeltaColumn_1 = __importDefault(require("./TableColumns/SignalDeltaColumn"));
22
22
  const SignalDeltaHzColumn_1 = __importDefault(require("./TableColumns/SignalDeltaHzColumn"));
23
- const format_1 = __importDefault(require("./TableColumns/format"));
24
23
  const HighlightedRowStyle = (0, react_1.css) `
25
24
  background-color: #ff6f0057;
26
25
  `;
@@ -37,7 +36,6 @@ function RangesTableRow({ rowData, onUnlink, onContextMenu, preferences, info, }
37
36
  const highlightData = (0, highlight_1.useHighlightData)();
38
37
  const [unlinkRangeButtonVisibility, showUnlinkRangeButton] = (0, react_2.useState)(false);
39
38
  const [unlinkSignalButtonVisibility, showUnlinkSignalButton] = (0, react_2.useState)(false);
40
- const getFormat = (0, format_1.default)(preferences);
41
39
  const rowSpanTags = (0, react_2.useMemo)(() => {
42
40
  return {
43
41
  rowSpan: rowData.tableMetaInfo.rowSpan,
@@ -115,6 +113,6 @@ function RangesTableRow({ rowData, onUnlink, onContextMenu, preferences, info, }
115
113
  ? ConstantlyHighlightedRowStyle
116
114
  : null;
117
115
  }, [assignmentRange.isActive, highlightRange.isActive, rowData]);
118
- return ((0, jsx_runtime_1.jsxs)("tr", { onContextMenu: (e) => onContextMenu(e, rowData), css: trCss, children: [(0, jsx_runtime_1.jsx)("td", { ...rowSpanTags, ...onHoverRange, children: rowData.tableMetaInfo.rowIndex + 1 }), preferences.from.show && ((0, jsx_runtime_1.jsx)(RangeColumn_1.default, { value: rowData.from, rowSpanTags: rowSpanTags, onHoverRange: onHoverRange, format: preferences.from.format })), preferences.to.show && ((0, jsx_runtime_1.jsx)(RangeColumn_1.default, { value: rowData.to, rowSpanTags: rowSpanTags, onHoverRange: onHoverRange, format: preferences.to.format })), preferences.deltaPPM.show && ((0, jsx_runtime_1.jsx)(SignalDeltaColumn_1.default, { rowData: rowData, onHoverSignal: onHoverSignal, deltaPPMFormat: preferences.deltaPPM.format })), preferences.deltaHz.show && ((0, jsx_runtime_1.jsx)(SignalDeltaHzColumn_1.default, { rowData: rowData, onHoverSignal: onHoverSignal, deltaHzFormat: preferences.deltaHz.format, info: info })), preferences.relative.show && ((0, jsx_runtime_1.jsx)(RelativeColumn_1.default, { rowData: rowData, rowSpanTags: rowSpanTags, onHoverRange: onHoverRange, format: preferences.relative.format })), preferences.absolute.show && ((0, jsx_runtime_1.jsx)(AbsoluteColumn_1.default, { value: rowData.absolute, rowSpanTags: rowSpanTags, onHoverRange: onHoverRange, format: getFormat('absoluteFormat', undefined) })), (0, jsx_runtime_1.jsx)("td", { ...onHoverSignal, children: (0, get_1.default)(rowData, 'tableMetaInfo.signal.multiplicity', '') }), preferences.coupling.show && ((0, jsx_runtime_1.jsx)(CouplingColumn_1.default, { rowData: rowData, onHoverSignal: onHoverSignal, format: preferences.coupling.format })), (0, jsx_runtime_1.jsx)(SignalAssignmentsColumn_1.default, { rowData: rowData, assignment: assignmentSignal, highlight: highlightSignal, onHover: onHoverSignal, unlinkVisibility: unlinkSignalButtonVisibility, onUnlinkVisibilityChange: (flag) => showUnlinkSignalButton(flag), onLink: linkHandler, onUnlink: unlinkHandler }), (0, jsx_runtime_1.jsx)(RangeAssignmentsColumn_1.default, { rowData: rowData, assignment: assignmentRange, highlight: highlightRangeAssignmentsColumn, onHover: onHoverRangeAssignmentsColumn, unlinkVisibility: unlinkRangeButtonVisibility, onUnlinkVisibilityChange: (flag) => showUnlinkRangeButton(flag), onLink: linkHandler, onUnlink: unlinkHandler, rowSpanTags: rowSpanTags, highlightData: highlightData }), (0, jsx_runtime_1.jsx)(ActionsColumn_1.default, { rowData: rowData, onHoverSignal: onHoverSignal, onHoverRange: onHoverRange, rowSpanTags: rowSpanTags, showKind: preferences.showKind })] }));
116
+ return ((0, jsx_runtime_1.jsxs)("tr", { onContextMenu: (e) => onContextMenu(e, rowData), css: trCss, children: [(0, jsx_runtime_1.jsx)("td", { ...rowSpanTags, ...onHoverRange, children: rowData.tableMetaInfo.rowIndex + 1 }), preferences.from.show && ((0, jsx_runtime_1.jsx)(RangeColumn_1.default, { value: rowData.from, rowSpanTags: rowSpanTags, onHoverRange: onHoverRange, format: preferences.from.format })), preferences.to.show && ((0, jsx_runtime_1.jsx)(RangeColumn_1.default, { value: rowData.to, rowSpanTags: rowSpanTags, onHoverRange: onHoverRange, format: preferences.to.format })), preferences.deltaPPM.show && ((0, jsx_runtime_1.jsx)(SignalDeltaColumn_1.default, { rowData: rowData, onHoverSignal: onHoverSignal, deltaPPMFormat: preferences.deltaPPM.format })), preferences.deltaHz.show && ((0, jsx_runtime_1.jsx)(SignalDeltaHzColumn_1.default, { rowData: rowData, onHoverSignal: onHoverSignal, deltaHzFormat: preferences.deltaHz.format, info: info })), preferences.relative.show && ((0, jsx_runtime_1.jsx)(RelativeColumn_1.default, { rowData: rowData, rowSpanTags: rowSpanTags, onHoverRange: onHoverRange, format: preferences.relative.format })), preferences.absolute.show && ((0, jsx_runtime_1.jsx)(AbsoluteColumn_1.default, { value: rowData.absolute, rowSpanTags: rowSpanTags, onHoverRange: onHoverRange, format: preferences.absolute.format })), (0, jsx_runtime_1.jsx)("td", { ...onHoverSignal, children: (0, get_1.default)(rowData, 'tableMetaInfo.signal.multiplicity', '') }), preferences.coupling.show && ((0, jsx_runtime_1.jsx)(CouplingColumn_1.default, { rowData: rowData, onHoverSignal: onHoverSignal, format: preferences.coupling.format })), (0, jsx_runtime_1.jsx)(SignalAssignmentsColumn_1.default, { rowData: rowData, assignment: assignmentSignal, highlight: highlightSignal, onHover: onHoverSignal, unlinkVisibility: unlinkSignalButtonVisibility, onUnlinkVisibilityChange: (flag) => showUnlinkSignalButton(flag), onLink: linkHandler, onUnlink: unlinkHandler }), (0, jsx_runtime_1.jsx)(RangeAssignmentsColumn_1.default, { rowData: rowData, assignment: assignmentRange, highlight: highlightRangeAssignmentsColumn, onHover: onHoverRangeAssignmentsColumn, unlinkVisibility: unlinkRangeButtonVisibility, onUnlinkVisibilityChange: (flag) => showUnlinkRangeButton(flag), onLink: linkHandler, onUnlink: unlinkHandler, rowSpanTags: rowSpanTags, highlightData: highlightData }), (0, jsx_runtime_1.jsx)(ActionsColumn_1.default, { rowData: rowData, onHoverSignal: onHoverSignal, onHoverRange: onHoverRange, rowSpanTags: rowSpanTags, showKind: preferences.showKind })] }));
119
117
  }
120
118
  exports.default = RangesTableRow;
@@ -14,8 +14,8 @@ const Tabs_1 = __importDefault(require("../../elements/Tab/Tabs"));
14
14
  const Alert_1 = require("../../elements/popup/Alert");
15
15
  const Reducer_1 = require("../../reducer/Reducer");
16
16
  const Types_1 = require("../../reducer/types/Types");
17
- const Export_1 = require("../../utility/Export");
18
17
  const GroupByInfoKey_1 = __importDefault(require("../../utility/GroupByInfoKey"));
18
+ const export_1 = require("../../utility/export");
19
19
  const SpectrumListItem_1 = __importDefault(require("./SpectrumListItem"));
20
20
  const SpectrumSetting_1 = __importDefault(require("./base/setting/SpectrumSetting"));
21
21
  function SpectrumsTabsInner({ data, activeSpectrum, activeTab, onTabChange, }) {
@@ -75,7 +75,7 @@ function SpectrumsTabsInner({ data, activeSpectrum, activeTab, onTabChange, }) {
75
75
  onClick: (spectrumData) => {
76
76
  void (async () => {
77
77
  const { x, y, info } = spectrumData;
78
- const success = await (0, Export_1.copyTextToClipboard)(JSON.stringify({ x, y, info }, undefined, 2));
78
+ const success = await (0, export_1.copyTextToClipboard)(JSON.stringify({ x, y, info }, undefined, 2));
79
79
  if (success) {
80
80
  alert.success('Data copied to clipboard');
81
81
  }
@@ -6,8 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const FormikColorPicker_1 = __importDefault(require("../../../../elements/formik/FormikColorPicker"));
8
8
  const FormikForm_1 = __importDefault(require("../../../../elements/formik/FormikForm"));
9
+ const FormikOnChange_1 = __importDefault(require("../../../../elements/formik/FormikOnChange"));
9
10
  const Spectrum1DHistogram_1 = __importDefault(require("./Spectrum1DHistogram"));
10
11
  function Spectrum1DSetting({ data: SpectrumData, onSubmit, }) {
11
- return ((0, jsx_runtime_1.jsx)(FormikForm_1.default, { initialValues: SpectrumData.display, onSubmit: onSubmit, children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', gap: '1.25rem' }, children: [(0, jsx_runtime_1.jsx)("div", { style: { display: 'block', position: 'relative' }, children: (0, jsx_runtime_1.jsx)(FormikColorPicker_1.default, { name: "color", triggerSubmit: true }) }), (0, jsx_runtime_1.jsx)(Spectrum1DHistogram_1.default, { color: "red", data: SpectrumData.data })] }) }));
12
+ return ((0, jsx_runtime_1.jsxs)(FormikForm_1.default, { initialValues: SpectrumData.display, onSubmit: onSubmit, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', gap: '1.25rem' }, children: [(0, jsx_runtime_1.jsx)("div", { style: { display: 'block', position: 'relative' }, children: (0, jsx_runtime_1.jsx)(FormikColorPicker_1.default, { name: "color" }) }), (0, jsx_runtime_1.jsx)(Spectrum1DHistogram_1.default, { color: "red", data: SpectrumData.data })] }), (0, jsx_runtime_1.jsx)(FormikOnChange_1.default, { onChange: onSubmit })] }));
12
13
  }
13
14
  exports.default = Spectrum1DSetting;
@@ -9,6 +9,7 @@ const react_1 = require("@emotion/react");
9
9
  const FormikColorPicker_1 = __importDefault(require("../../../../elements/formik/FormikColorPicker"));
10
10
  const FormikForm_1 = __importDefault(require("../../../../elements/formik/FormikForm"));
11
11
  const FormikInput_1 = __importDefault(require("../../../../elements/formik/FormikInput"));
12
+ const FormikOnChange_1 = __importDefault(require("../../../../elements/formik/FormikOnChange"));
12
13
  const FormikSlider_1 = __importDefault(require("../../../../elements/formik/FormikSlider"));
13
14
  const Spectrum2DHistogram_1 = __importDefault(require("./Spectrum2DHistogram"));
14
15
  const style = (color) => (0, react_1.css) `
@@ -19,6 +20,6 @@ const style = (color) => (0, react_1.css) `
19
20
  `;
20
21
  function Spectrum2DSetting({ data: SpectrumData, onSubmit, }) {
21
22
  const { positiveColor, negativeColor } = SpectrumData.display;
22
- return ((0, jsx_runtime_1.jsx)(FormikForm_1.default, { initialValues: SpectrumData.display, onSubmit: onSubmit, children: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { css: style(positiveColor), children: [(0, jsx_runtime_1.jsx)("span", { style: { padding: '0 10px' }, children: "Positive" }), (0, jsx_runtime_1.jsx)(FormikColorPicker_1.default, { name: "positiveColor", triggerSubmit: true }), (0, jsx_runtime_1.jsxs)("div", { style: { padding: '5px' }, children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: "contour Levels [ min - max ]" }), (0, jsx_runtime_1.jsx)(FormikSlider_1.default, { name: "contourOptions.positive.contourLevels", triggerSubmit: true }), (0, jsx_runtime_1.jsx)("span", { className: "label", children: "number of Layers " }), (0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: "contourOptions.positive.numberOfLayers", triggerSubmit: true, type: "number" })] })] }), (0, jsx_runtime_1.jsxs)("div", { css: style(negativeColor), children: [(0, jsx_runtime_1.jsx)("span", { style: { padding: '0 10px' }, children: "Negative" }), (0, jsx_runtime_1.jsx)(FormikColorPicker_1.default, { name: "negativeColor", triggerSubmit: true }), (0, jsx_runtime_1.jsxs)("div", { style: { padding: '5px' }, children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: "contour Levels [ min - max ]" }), (0, jsx_runtime_1.jsx)(FormikSlider_1.default, { name: "contourOptions.negative.contourLevels", triggerSubmit: true }), (0, jsx_runtime_1.jsx)("span", { className: "label", children: "number of Layers " }), (0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: "contourOptions.negative.numberOfLayers", triggerSubmit: true, type: "number" })] })] }), (0, jsx_runtime_1.jsx)(Spectrum2DHistogram_1.default, { data: SpectrumData.data })] }) }));
23
+ return ((0, jsx_runtime_1.jsxs)(FormikForm_1.default, { initialValues: SpectrumData.display, children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { css: style(positiveColor), children: [(0, jsx_runtime_1.jsx)("span", { style: { padding: '0 10px' }, children: "Positive" }), (0, jsx_runtime_1.jsx)(FormikColorPicker_1.default, { name: "positiveColor" }), (0, jsx_runtime_1.jsxs)("div", { style: { padding: '5px' }, children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: "contour Levels [ min - max ]" }), (0, jsx_runtime_1.jsx)(FormikSlider_1.default, { name: "contourOptions.positive.contourLevels", debounceTime: 100 }), (0, jsx_runtime_1.jsx)("span", { className: "label", children: "number of Layers " }), (0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: "contourOptions.positive.numberOfLayers", type: "number", debounceTime: 250 })] })] }), (0, jsx_runtime_1.jsxs)("div", { css: style(negativeColor), children: [(0, jsx_runtime_1.jsx)("span", { style: { padding: '0 10px' }, children: "Negative" }), (0, jsx_runtime_1.jsx)(FormikColorPicker_1.default, { name: "negativeColor" }), (0, jsx_runtime_1.jsxs)("div", { style: { padding: '5px' }, children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: "contour Levels [ min - max ]" }), (0, jsx_runtime_1.jsx)(FormikSlider_1.default, { name: "contourOptions.negative.contourLevels", debounceTime: 100 }), (0, jsx_runtime_1.jsx)("span", { className: "label", children: "number of Layers " }), (0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: "contourOptions.negative.numberOfLayers", type: "number", debounceTime: 250 })] })] }), (0, jsx_runtime_1.jsx)(Spectrum2DHistogram_1.default, { data: SpectrumData.data })] }), (0, jsx_runtime_1.jsx)(FormikOnChange_1.default, { onChange: onSubmit })] }));
23
24
  }
24
25
  exports.default = Spectrum2DSetting;
@@ -35,10 +35,13 @@ class ColumnsHelper {
35
35
  : this.defaultPreference[formatKey];
36
36
  const { formatPrefix = '', formatSuffix = '', showPrefixSuffixCallback = () => true, } = options;
37
37
  if (showPrefixSuffixCallback(row)) {
38
- return (0, formatNumber_1.formatNumber)(row.original[columnKey], format, formatPrefix, formatSuffix);
38
+ return (0, formatNumber_1.formatNumber)(row.original[columnKey], format, {
39
+ prefix: formatPrefix,
40
+ suffix: formatSuffix,
41
+ });
39
42
  }
40
43
  else {
41
- return (0, formatNumber_1.formatNumber)(row.original[columnKey], format, '', '');
44
+ return (0, formatNumber_1.formatNumber)(row.original[columnKey], format);
42
45
  }
43
46
  });
44
47
  }
@@ -29,7 +29,8 @@ const immer_1 = require("immer");
29
29
  const nmr_correlation_1 = require("nmr-correlation");
30
30
  const nmr_load_save_1 = require("nmr-load-save");
31
31
  const PredictionManager_1 = require("../../data/PredictionManager");
32
- const SpectraManager = __importStar(require("../../data/SpectraManager"));
32
+ const Spectrum1D_1 = require("../../data/data1d/Spectrum1D");
33
+ const Spectrum2D_1 = require("../../data/data2d/Spectrum2D");
33
34
  const ChartContext_1 = require("../context/ChartContext");
34
35
  const Constants_1 = require("../panels/SummaryPanel/CorrelationTable/Constants");
35
36
  const ToolTypes_1 = require("../toolbar/ToolTypes");
@@ -67,7 +68,6 @@ exports.zoneStateInit = {
67
68
  const getInitialState = () => ({
68
69
  actionType: '',
69
70
  data: [],
70
- contours: {},
71
71
  tempData: null,
72
72
  xDomain: [],
73
73
  yDomain: [],
@@ -86,7 +86,7 @@ const getInitialState = () => ({
86
86
  margin: {
87
87
  top: 10,
88
88
  right: 20,
89
- bottom: 70,
89
+ bottom: 50,
90
90
  left: 0,
91
91
  },
92
92
  mode: 'RTL',
@@ -96,6 +96,9 @@ const getInitialState = () => ({
96
96
  ranges: [],
97
97
  zones: [],
98
98
  spectra: { activeSpectra: {}, activeTab: '' },
99
+ zoom: {
100
+ levels: {},
101
+ },
99
102
  },
100
103
  verticalAlign: {
101
104
  align: 'bottom',
@@ -160,14 +163,25 @@ function initState(state) {
160
163
  }
161
164
  exports.initState = initState;
162
165
  function dispatchMiddleware(dispatch) {
163
- const usedColors = { '1d': [], '2d': [] };
166
+ let usedColors = { '1d': [], '2d': [] };
164
167
  return (action) => {
165
168
  switch (action.type) {
166
169
  case types.INITIATE: {
167
170
  if (action.payload) {
168
- const { spectra, ...res } = (0, nmr_load_save_1.migrate)(action.payload);
169
- void SpectraManager.fromJSON(spectra, usedColors).then((data) => {
170
- action.payload = { spectra: data, ...res, usedColors };
171
+ usedColors = { '1d': [], '2d': [] };
172
+ void (0, nmr_load_save_1.readNMRiumObject)(action.payload).then((data) => {
173
+ const { spectra: spectraIn } = data;
174
+ const spectra = [];
175
+ for (let spectrum of spectraIn) {
176
+ const { info } = spectrum;
177
+ if (info.dimension === 1) {
178
+ spectra.push((0, Spectrum1D_1.initiateDatum1D)(spectrum, usedColors));
179
+ }
180
+ else if (info.dimension === 2) {
181
+ spectra.push((0, Spectrum2D_1.initiateDatum2D)(spectrum, usedColors));
182
+ }
183
+ }
184
+ action.payload = { ...data, usedColors, spectra };
171
185
  dispatch(action);
172
186
  });
173
187
  }
@@ -176,7 +190,7 @@ function dispatchMiddleware(dispatch) {
176
190
  case types.LOAD_DROP_FILES: {
177
191
  const { fileCollection } = action;
178
192
  action.usedColors = usedColors;
179
- (0, nmr_load_save_1.read)(fileCollection, usedColors)
193
+ (0, nmr_load_save_1.read)(fileCollection)
180
194
  .then((data) => {
181
195
  action.data = data;
182
196
  dispatch(action);
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.applyKeyPreferencesHandler = exports.setKeyPreferencesHandler = exports.changeSpectrumVerticalAlignment = void 0;
7
- const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
8
7
  const GroupByInfoKey_1 = __importDefault(require("../../utility/GroupByInfoKey"));
9
8
  const nucleusToString_1 = __importDefault(require("../../utility/nucleusToString"));
10
9
  const Constants_1 = require("../core/Constants");
@@ -62,16 +61,12 @@ function changeSpectrumVerticalAlignment(draft, options) {
62
61
  exports.changeSpectrumVerticalAlignment = changeSpectrumVerticalAlignment;
63
62
  function setKeyPreferencesHandler(draft, keyCode) {
64
63
  const { data, zoom, xDomain, xDomains, yDomain, yDomains, originDomain, margin, displayerMode, view, } = draft;
64
+ const { spectra: { activeTab }, } = view;
65
65
  const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
66
- if (view.spectra.activeTab) {
66
+ if (activeTab) {
67
67
  const groupByNucleus = (0, GroupByInfoKey_1.default)('nucleus');
68
68
  const spectrumsGroupsList = groupByNucleus(data);
69
- const level = displayerMode === Constants_1.DISPLAYER_MODE.DM_2D
70
- ? spectrumsGroupsList[view.spectra.activeTab].reduce((acc, datum) => {
71
- acc[datum.id] = datum.processingController.getLevel();
72
- return acc;
73
- }, {})
74
- : null;
69
+ const spectra = spectrumsGroupsList[activeTab];
75
70
  draft.keysPreferences[keyCode] = {
76
71
  activeSpectrum,
77
72
  displayerMode,
@@ -82,30 +77,26 @@ function setKeyPreferencesHandler(draft, keyCode) {
82
77
  yDomain,
83
78
  yDomains,
84
79
  originDomain,
85
- level,
86
80
  margin,
87
- data: spectrumsGroupsList[view.spectra.activeTab].reduce((acc, datum) => {
88
- acc[datum.id] = {
89
- display: {
90
- color: datum.display.color,
91
- isVisible: datum.display.isVisible,
92
- isPeaksMarkersVisible: datum.display.isPeaksMarkersVisible,
93
- },
94
- };
95
- return acc;
96
- }, {}),
81
+ data: spectra,
97
82
  };
98
83
  }
99
84
  }
100
85
  exports.setKeyPreferencesHandler = setKeyPreferencesHandler;
86
+ function setSpectraDisplayPreferences(draft, preferences) {
87
+ draft.data.forEach((datum, index) => {
88
+ if ((0, nucleusToString_1.default)(datum.info.nucleus) === preferences.activeTab) {
89
+ draft.data[index].display = {
90
+ ...datum.display,
91
+ ...preferences.data[datum.id].display,
92
+ };
93
+ }
94
+ });
95
+ }
101
96
  function applyKeyPreferencesHandler(draft, keyCode) {
102
97
  const preferences = draft.keysPreferences[keyCode];
103
98
  if (preferences) {
104
- draft.data.forEach((datum, index) => {
105
- if ((0, nucleusToString_1.default)(datum.info.nucleus) === preferences.activeTab) {
106
- draft.data[index].display = Object.assign((0, cloneDeep_1.default)(datum.display), preferences.data[datum.id].display);
107
- }
108
- });
99
+ setSpectraDisplayPreferences(draft, preferences);
109
100
  draft.view = preferences.view;
110
101
  draft.displayerMode = preferences.displayerMode;
111
102
  draft.margin = preferences.margin;
@@ -115,17 +106,7 @@ function applyKeyPreferencesHandler(draft, keyCode) {
115
106
  draft.yDomain = preferences.yDomain;
116
107
  draft.originDomain = preferences.originDomain;
117
108
  draft.yDomains = preferences.yDomains;
118
- if (draft.displayerMode === Constants_1.DISPLAYER_MODE.DM_2D) {
119
- for (const datumID of Object.keys(preferences.level)) {
120
- const { levelPositive, levelNegative } = preferences.level[datumID];
121
- const index = draft.data.findIndex((datum) => datum.id === datumID);
122
- const processController = draft.data[index]
123
- .processingController;
124
- processController.setLevel(levelPositive, levelNegative);
125
- draft.contours[datumID] = processController.drawContours();
126
- }
127
- }
128
- else {
109
+ if (draft.displayerMode !== Constants_1.DISPLAYER_MODE.DM_2D) {
129
110
  draft.zoom = preferences.zoom;
130
111
  }
131
112
  }
@@ -309,16 +309,18 @@ function handleAddRange(draft, action) {
309
309
  exports.handleAddRange = handleAddRange;
310
310
  function handleChangeRangeRelativeValue(draft, action) {
311
311
  const data = action.payload.data;
312
- if (draft.activeSpectrum?.id) {
313
- const { index } = draft.activeSpectrum;
312
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
313
+ if (activeSpectrum?.id) {
314
+ const { index } = activeSpectrum;
314
315
  (0, Spectrum1D_1.changeRangeRelativeValue)(draft.data[index], data);
315
316
  }
316
317
  }
317
318
  exports.handleChangeRangeRelativeValue = handleChangeRangeRelativeValue;
318
319
  function handleChangeRangeSignalValue(draft, action) {
319
320
  const { rangeID, signalID, value } = action.payload;
320
- if (draft.activeSpectrum?.id) {
321
- const { index } = draft.activeSpectrum;
321
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
322
+ if (activeSpectrum?.id) {
323
+ const { index } = activeSpectrum;
322
324
  const shift = (0, Spectrum1D_1.changeRangeSignal)(draft.data[index], {
323
325
  rangeID,
324
326
  signalID,
@@ -32,6 +32,7 @@ const Filters = __importStar(require("../../../data/Filters"));
32
32
  const FiltersManager_1 = require("../../../data/FiltersManager");
33
33
  const Spectrum1D_1 = require("../../../data/data1d/Spectrum1D");
34
34
  const Spectrum2D_1 = require("../../../data/data2d/Spectrum2D");
35
+ const contours_1 = require("../../../data/data2d/Spectrum2D/contours");
35
36
  const ToolTypes_1 = require("../../toolbar/ToolTypes");
36
37
  const GroupByInfoKey_1 = __importDefault(require("../../utility/GroupByInfoKey"));
37
38
  const Zoom1DManager_1 = require("../helper/Zoom1DManager");
@@ -147,10 +148,15 @@ function handleChangeActiveSpectrum(draft, activeSpectrum) {
147
148
  }
148
149
  exports.handleChangeActiveSpectrum = handleChangeActiveSpectrum;
149
150
  function changeSpectrumSetting(draft, { id, display }) {
150
- const state = (0, immer_1.original)(draft);
151
- const index = state.data.findIndex((d) => d.id === id);
151
+ const index = draft.data.findIndex((d) => d.id === id);
152
152
  if (index !== -1) {
153
- draft.data[index].display = display;
153
+ const spectrum = draft.data[index];
154
+ spectrum.display = display;
155
+ if ((0, Spectrum2D_1.isSpectrum2D)(spectrum)) {
156
+ const contoursLevels = draft.view.zoom.levels;
157
+ const { checkLevel } = (0, contours_1.contoursManager)(spectrum.id, contoursLevels, spectrum.display.contourOptions);
158
+ contoursLevels[spectrum.id] = checkLevel();
159
+ }
154
160
  }
155
161
  }
156
162
  exports.changeSpectrumSetting = changeSpectrumSetting;
@@ -7,6 +7,7 @@ exports.resetSpectraScale = exports.setSpectraSameTopHandler = exports.setTab =
7
7
  const uuid_1 = require("@lukeed/uuid");
8
8
  const immer_1 = require("immer");
9
9
  const ml_spectra_processing_1 = require("ml-spectra-processing");
10
+ const contours_1 = require("../../../data/data2d/Spectrum2D/contours");
10
11
  const scale_1 = require("../../1d/utilities/scale");
11
12
  const DimensionLayout_1 = require("../../2d/utilities/DimensionLayout");
12
13
  const scale_2 = require("../../2d/utilities/scale");
@@ -18,6 +19,7 @@ const Zoom1DManager_1 = require("../helper/Zoom1DManager");
18
19
  const ZoomHistoryManager_1 = __importDefault(require("../helper/ZoomHistoryManager"));
19
20
  const getActiveSpectrum_1 = require("../helper/getActiveSpectrum");
20
21
  const getActiveSpectrumOrFail_1 = require("../helper/getActiveSpectrumOrFail");
22
+ const getSpectrum_1 = require("../helper/getSpectrum");
21
23
  const DomainActions_1 = require("./DomainActions");
22
24
  const FiltersActions_1 = require("./FiltersActions");
23
25
  const PreferencesActions_1 = require("./PreferencesActions");
@@ -293,15 +295,6 @@ function setMargin(draft) {
293
295
  draft.margin = Constants_1.MARGIN['1D'];
294
296
  }
295
297
  }
296
- function processing2DData(draft, data) {
297
- if (draft.displayerMode === Constants_1.DISPLAYER_MODE.DM_2D) {
298
- let _data = {};
299
- for (const datum of data[draft.view.spectra.activeTab]) {
300
- _data[datum.id] = datum.processingController.drawContours();
301
- }
302
- draft.contours = _data;
303
- }
304
- }
305
298
  function setDisplayerMode(draft, data) {
306
299
  draft.displayerMode =
307
300
  data && data.some((d) => d.info.dimension === 2)
@@ -373,7 +366,6 @@ function setActiveTab(draft, options) {
373
366
  const currentTab = !tab || !tabs.includes(tab || '') ? tabs[0] : tab;
374
367
  setTab(draft, dataGroupByNucleus, currentTab, refreshActiveTab);
375
368
  resetTool(draft);
376
- processing2DData(draft, dataGroupByNucleus);
377
369
  (0, DomainActions_1.setDomain)(draft, domainOptions);
378
370
  (0, DomainActions_1.setIntegralsYDomain)(draft, dataGroupByNucleus[currentTab]);
379
371
  const zoomHistory = (0, ZoomHistoryManager_1.default)(draft.zoom.history, draft.view.spectra.activeTab);
@@ -392,20 +384,13 @@ function handelSetActiveTab(draft, tab) {
392
384
  }
393
385
  exports.handelSetActiveTab = handelSetActiveTab;
394
386
  function levelChangeHandler(draft, { deltaY, shiftKey }) {
395
- const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
387
+ const activeSpectrum = (0, getSpectrum_1.getSpectrum)(draft);
396
388
  try {
397
389
  if (activeSpectrum?.id) {
398
- const { index, id } = activeSpectrum;
399
- const processingController = draft.data[index]
400
- .processingController;
401
- if (shiftKey) {
402
- processingController.shiftWheel(deltaY);
403
- }
404
- else {
405
- processingController.wheel(deltaY);
406
- }
407
- const contours = Object.freeze(processingController.drawContours());
408
- draft.contours[id] = contours;
390
+ const { levels } = draft.view.zoom;
391
+ const contourOptions = activeSpectrum.display.contourOptions;
392
+ const zoom = (0, contours_1.contoursManager)(activeSpectrum.id, levels, contourOptions);
393
+ draft.view.zoom.levels[activeSpectrum.id] = zoom.wheel(deltaY, shiftKey);
409
394
  }
410
395
  }
411
396
  catch (e) {
@@ -12,7 +12,7 @@ exports.MARGIN = {
12
12
  '1D': {
13
13
  top: 10,
14
14
  right: 10,
15
- bottom: 70,
15
+ bottom: 50,
16
16
  left: 10,
17
17
  },
18
18
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFileSignature = exports.extractFileMetaFromPath = exports.getFileName = exports.getFileExtension = exports.loadFile = exports.loadFilesFromZip = exports.loadFiles = exports.FILES_SIGNATURES = exports.FILES_TYPES = void 0;
3
+ exports.getFileSignature = exports.extractFileMetaFromPath = exports.getFileName = exports.getFileExtension = exports.loadFile = exports.loadFiles = exports.FILES_SIGNATURES = exports.FILES_TYPES = void 0;
4
4
  exports.FILES_TYPES = {
5
5
  MOL: 'mol',
6
6
  NMRIUM: 'nmrium',
@@ -15,6 +15,7 @@ exports.FILES_SIGNATURES = {
15
15
  ZIP: '504b0304',
16
16
  };
17
17
  function getFileSignature(fileArrayBuffer) {
18
+ // eslint-disable-next-line no-restricted-properties
18
19
  return new Uint8Array(fileArrayBuffer)
19
20
  .slice(0, 4)
20
21
  .reduce((acc, byte) => (acc += byte.toString(16).padStart(2, '0')), '');
@@ -77,20 +78,3 @@ function loadFiles(acceptedFiles, options = {}) {
77
78
  }));
78
79
  }
79
80
  exports.loadFiles = loadFiles;
80
- async function loadFilesFromZip(files, options = {}) {
81
- const result = [];
82
- for (const file of files) {
83
- try {
84
- const binary = await file.async(options.asBuffer ? 'uint8array' : 'text');
85
- const name = getFileName(file.name);
86
- const extension = getFileExtension(file.name);
87
- result.push({ binary, name, extension });
88
- }
89
- catch (e) {
90
- // eslint-disable-next-line no-console
91
- console.error(e);
92
- }
93
- }
94
- return result;
95
- }
96
- exports.loadFilesFromZip = loadFilesFromZip;
@@ -1,69 +1,68 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  exports.getBlob = exports.exportAsMatrix = exports.exportAsMol = exports.copyHTMLToClipboard = exports.copyTextToClipboard = exports.copyPNGToClipboard = exports.exportAsPng = exports.exportAsNMRE = exports.exportAsJSON = exports.exportAsSVG = void 0;
30
+ const clipboard = __importStar(require("clipboard-polyfill"));
7
31
  const file_saver_1 = require("file-saver");
8
32
  const jszip_1 = __importDefault(require("jszip"));
9
- function copyFormattedHtml(html) {
10
- // Create an iframe (isolated container) for the HTML
11
- let container = document.createElement('div');
12
- container.innerHTML = html;
13
- // Hide element
14
- container.style.position = 'fixed';
15
- container.style.pointerEvents = 'none';
16
- container.style.opacity = '0';
17
- // Detect all style sheets of the page
18
- let activeSheets = Array.prototype.slice
19
- .call(document.styleSheets)
20
- .filter((sheet) => {
21
- return !sheet.disabled;
22
- });
23
- // Mount the iframe to the DOM to make `contentWindow` available
24
- document.body.appendChild(container);
25
- // Copy to clipboard
26
- window.getSelection()?.removeAllRanges();
27
- let range = document.createRange();
28
- range.selectNode(container);
29
- window.getSelection()?.addRange(range);
30
- document.execCommand('copy');
31
- for (const active of activeSheets) {
32
- active.disabled = true;
33
- }
34
- document.execCommand('copy');
35
- for (const active of activeSheets) {
36
- active.disabled = false;
37
- }
38
- // Remove the iframe
39
- document.body.removeChild(container);
40
- }
41
33
  async function copyHTMLToClipboard(data) {
42
- try {
43
- copyFormattedHtml(data);
44
- return true;
45
- }
46
- catch (err) {
47
- return false;
48
- }
34
+ return copyToClipboard(data, 'text/html');
49
35
  }
50
36
  exports.copyHTMLToClipboard = copyHTMLToClipboard;
51
37
  async function copyTextToClipboard(data) {
38
+ return copyToClipboard(data, 'text/plain');
39
+ }
40
+ exports.copyTextToClipboard = copyTextToClipboard;
41
+ async function copyToClipboard(data, type) {
52
42
  try {
53
- void navigator.clipboard.write([
54
- new ClipboardItem({
55
- 'text/plain': new Promise((resolve) => {
56
- resolve(new Blob([data], { type: 'text/plain' }));
43
+ if (typeof ClipboardItem !== 'undefined') {
44
+ void navigator.clipboard.write([
45
+ new ClipboardItem({
46
+ [type]: new Promise((resolve) => {
47
+ resolve(new Blob([data], { type }));
48
+ }),
57
49
  }),
58
- }),
59
- ]);
50
+ ]);
51
+ }
52
+ else {
53
+ //TODO when Firefox team implement ClipboardItem this code should be removed
54
+ // this library is used mainly to solve the problem of copy HTML to a clipboard in Firefox but we use it for both HTML and plain text
55
+ const item = new clipboard.ClipboardItem({
56
+ [type]: new Blob([data], { type }),
57
+ });
58
+ await clipboard.write([item]);
59
+ }
60
60
  return true;
61
61
  }
62
62
  catch (err) {
63
63
  return false;
64
64
  }
65
65
  }
66
- exports.copyTextToClipboard = copyTextToClipboard;
67
66
  /**
68
67
  * export the experiments result in JSON format
69
68
  * @param {*} data
@@ -159,7 +158,8 @@ function exportAsPng(rootRef, elementID, fileName = 'experiment') {
159
158
  }
160
159
  }
161
160
  exports.exportAsPng = exportAsPng;
162
- function copyDataURLCliboard(image) {
161
+ // hack way to copy the image to the clipboard
162
+ function copyDataURLClipboardFireFox(image) {
163
163
  const img = document.createElement('img');
164
164
  img.src = image;
165
165
  img.style.position = 'fixed';
@@ -172,7 +172,7 @@ function copyDataURLCliboard(image) {
172
172
  document.execCommand('Copy');
173
173
  document.body.removeChild(img);
174
174
  }
175
- function copyBlobToCliboard(canvas) {
175
+ function copyBlobToClipboard(canvas) {
176
176
  canvas.toBlob((b) => {
177
177
  const clip = new ClipboardItem({
178
178
  [b.type]: b,
@@ -204,10 +204,10 @@ function copyPNGToClipboard(rootRef, elementID) {
204
204
  const png = canvas.toDataURL('image/png', 1);
205
205
  // @ts-expect-error write exists in some browsers
206
206
  if (navigator.clipboard.write) {
207
- copyBlobToCliboard(canvas);
207
+ copyBlobToClipboard(canvas);
208
208
  }
209
209
  else {
210
- copyDataURLCliboard(png);
210
+ copyDataURLClipboardFireFox(png);
211
211
  }
212
212
  URL.revokeObjectURL(png);
213
213
  };
@@ -5,9 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getNumberOfDecimals = exports.formatNumber = void 0;
7
7
  const numeral_1 = __importDefault(require("numeral"));
8
- function formatNumber(value, format, prefix = '', suffix = '') {
9
- return (value || value === 0) && !isNaN(value)
10
- ? prefix + (0, numeral_1.default)(value).format(format) + suffix
8
+ function formatNumber(value, format, options = {}) {
9
+ const { prefix = '', suffix = '', defaultFormat = '0.00' } = options;
10
+ return typeof value === 'number' || !isNaN(value)
11
+ ? prefix + (0, numeral_1.default)(value).format(format || defaultFormat) + suffix
11
12
  : value;
12
13
  }
13
14
  exports.formatNumber = formatNumber;