nmrium 2.6.0 → 2.7.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/ApodizationLine.js +2 -2
- package/lib/component/1d/ApodizationLine.js.map +1 -1
- package/lib/component/1d/Line.js +2 -2
- package/lib/component/1d/Line.js.map +1 -1
- package/lib/component/1d/SVGContent1D.d.ts.map +1 -1
- package/lib/component/1d/SVGContent1D.js +4 -1
- package/lib/component/1d/SVGContent1D.js.map +1 -1
- package/lib/component/1d/baseline/BaselinePreview.js +2 -2
- package/lib/component/1d/baseline/BaselinePreview.js.map +1 -1
- package/lib/component/1d/database/DatabaseSpectrum.js +2 -2
- package/lib/component/1d/database/DatabaseSpectrum.js.map +1 -1
- package/lib/component/1d/database/ResurrectedDatabaseRanges.js +2 -2
- package/lib/component/1d/database/ResurrectedDatabaseRanges.js.map +1 -1
- package/lib/component/1d/matrix/Boxplot.js +5 -5
- package/lib/component/1d/matrix/Boxplot.js.map +1 -1
- package/lib/component/1d/matrix/Stocsy.js +2 -2
- package/lib/component/1d/matrix/Stocsy.js.map +1 -1
- package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.d.ts.map +1 -1
- package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.js +12 -3
- package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.js.map +1 -1
- package/lib/component/1d/peaks/usePeakShapesPath.js +2 -2
- package/lib/component/1d/peaks/usePeakShapesPath.js.map +1 -1
- package/lib/component/1d/plugin_svg_chart.d.ts +2 -0
- package/lib/component/1d/plugin_svg_chart.d.ts.map +1 -0
- package/lib/component/1d/plugin_svg_chart.js +43 -0
- package/lib/component/1d/plugin_svg_chart.js.map +1 -0
- package/lib/component/1d-2d/components/RangeIndicator.d.ts.map +1 -1
- package/lib/component/1d-2d/components/RangeIndicator.js +1 -7
- package/lib/component/1d-2d/components/RangeIndicator.js.map +1 -1
- package/lib/component/2d/1d-tracer/HorizontalSliceChart.js +2 -2
- package/lib/component/2d/1d-tracer/HorizontalSliceChart.js.map +1 -1
- package/lib/component/2d/1d-tracer/Left1DChart.js +2 -2
- package/lib/component/2d/1d-tracer/Left1DChart.js.map +1 -1
- package/lib/component/2d/1d-tracer/Top1DChart.js +2 -2
- package/lib/component/2d/1d-tracer/Top1DChart.js.map +1 -1
- package/lib/component/2d/1d-tracer/VerticalSliceChart.js +2 -2
- package/lib/component/2d/1d-tracer/VerticalSliceChart.js.map +1 -1
- package/lib/component/2d/1d-tracer/phase-correction-traces/SpectrumPhaseTrace.js +3 -3
- package/lib/component/2d/1d-tracer/phase-correction-traces/SpectrumPhaseTrace.js.map +1 -1
- package/lib/component/2d/ft/Contours.js +2 -2
- package/lib/component/2d/ft/Contours.js.map +1 -1
- package/lib/component/context/ScaleContext.d.ts +1 -1
- package/lib/component/context/ScaleContext.d.ts.map +1 -1
- package/lib/component/elements/D3Axis.d.ts.map +1 -1
- package/lib/component/elements/D3Axis.js +15 -32
- package/lib/component/elements/D3Axis.js.map +1 -1
- package/lib/component/elements/export/ExportContent.d.ts.map +1 -1
- package/lib/component/elements/export/ExportContent.js +2 -2
- package/lib/component/elements/export/ExportContent.js.map +1 -1
- package/lib/component/elements/export/ExportOptionsModal.d.ts.map +1 -1
- package/lib/component/elements/export/ExportOptionsModal.js +9 -3
- package/lib/component/elements/export/ExportOptionsModal.js.map +1 -1
- package/lib/component/elements/export/useExportConfigurer.d.ts +1 -0
- package/lib/component/elements/export/useExportConfigurer.d.ts.map +1 -1
- package/lib/component/elements/export/useExportConfigurer.js +5 -0
- package/lib/component/elements/export/useExportConfigurer.js.map +1 -1
- package/lib/component/elements/print/PrintContent.d.ts.map +1 -1
- package/lib/component/elements/print/PrintContent.js +6 -25
- package/lib/component/elements/print/PrintContent.js.map +1 -1
- package/lib/component/elements/utilities/transferStyles.d.ts +2 -0
- package/lib/component/elements/utilities/transferStyles.d.ts.map +1 -0
- package/lib/component/elements/utilities/transferStyles.js +29 -0
- package/lib/component/elements/utilities/transferStyles.js.map +1 -0
- package/lib/component/hooks/useIntegralPath.js +2 -2
- package/lib/component/hooks/useIntegralPath.js.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/errors/context.d.ts +106 -105
- package/lib/component/modal/setting/tanstack_general_settings/errors/context.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/errors/renderer.d.ts +106 -105
- package/lib/component/modal/setting/tanstack_general_settings/errors/renderer.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_body.d.ts +106 -105
- package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_body.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_footer.d.ts +91 -90
- package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_footer.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_header.d.ts +91 -90
- package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_header.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/hooks/use_safe_workspace.d.ts +15 -15
- package/lib/component/modal/setting/tanstack_general_settings/tabs/auto_processing_tab.d.ts +91 -90
- package/lib/component/modal/setting/tanstack_general_settings/tabs/auto_processing_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/axis_tab.d.ts +91 -90
- package/lib/component/modal/setting/tanstack_general_settings/tabs/axis_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/database_tab.d.ts +91 -90
- package/lib/component/modal/setting/tanstack_general_settings/tabs/database_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/export_tab.d.ts +91 -90
- package/lib/component/modal/setting/tanstack_general_settings/tabs/export_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/export_tab.fields.d.ts +12 -10
- package/lib/component/modal/setting/tanstack_general_settings/tabs/export_tab.fields.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/export_tab.fields.js +32 -40
- package/lib/component/modal/setting/tanstack_general_settings/tabs/export_tab.fields.js.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/external_api_tab.d.ts +91 -90
- package/lib/component/modal/setting/tanstack_general_settings/tabs/external_api_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/general_tab.d.ts +91 -90
- package/lib/component/modal/setting/tanstack_general_settings/tabs/general_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/import_filters_tab.d.ts +91 -90
- package/lib/component/modal/setting/tanstack_general_settings/tabs/import_filters_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/nuclei_tab.d.ts +91 -90
- package/lib/component/modal/setting/tanstack_general_settings/tabs/nuclei_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/panels_tab.d.ts +91 -90
- package/lib/component/modal/setting/tanstack_general_settings/tabs/panels_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/spectra_colors_tab.d.ts +91 -90
- package/lib/component/modal/setting/tanstack_general_settings/tabs/spectra_colors_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/spectra_label_tab.d.ts +91 -90
- package/lib/component/modal/setting/tanstack_general_settings/tabs/spectra_label_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/title_block_tab.d.ts +91 -90
- package/lib/component/modal/setting/tanstack_general_settings/tabs/title_block_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/tools_tab.d.ts +91 -90
- package/lib/component/modal/setting/tanstack_general_settings/tabs/tools_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/validation/export_tab_validation.d.ts +61 -17
- package/lib/component/modal/setting/tanstack_general_settings/validation/export_tab_validation.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/validation/export_tab_validation.js +79 -28
- package/lib/component/modal/setting/tanstack_general_settings/validation/export_tab_validation.js.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/validation.d.ts +15 -15
- package/lib/component/panels/filtersPanel/processings_sections_panel.js +1 -1
- package/lib/component/panels/filtersPanel/processings_sections_panel.js.map +1 -1
- package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.d.ts +3 -3
- package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.d.ts.map +1 -1
- package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.js +69 -56
- package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.js.map +1 -1
- package/lib/component/panels/multipleAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -1
- package/lib/component/panels/multipleAnalysisPanel/MultipleSpectraAnalysisPanel.js.map +1 -1
- package/lib/component/toolbar/nmr_toolbar.js +1 -1
- package/lib/component/toolbar/nmr_toolbar.js.map +1 -1
- package/lib/component/utility/core_slots/core_operator_chart_svg.d.ts +8 -0
- package/lib/component/utility/core_slots/core_operator_chart_svg.d.ts.map +1 -0
- package/lib/component/utility/core_slots/core_operator_chart_svg.js +23 -0
- package/lib/component/utility/core_slots/core_operator_chart_svg.js.map +1 -0
- package/lib/component/utility/core_slots/core_operator_panel_tool.d.ts +2 -8
- package/lib/component/utility/core_slots/core_operator_panel_tool.d.ts.map +1 -1
- package/lib/component/utility/core_slots/core_operator_panel_tool.js +8 -6
- package/lib/component/utility/core_slots/core_operator_panel_tool.js.map +1 -1
- package/lib/component/utility/core_slots/core_operator_tool.commons.d.ts +11 -0
- package/lib/component/utility/core_slots/core_operator_tool.commons.d.ts.map +1 -0
- package/lib/component/utility/core_slots/core_operator_tool.commons.js +30 -0
- package/lib/component/utility/core_slots/core_operator_tool.commons.js.map +1 -0
- package/lib/component/utility/core_slots/core_operator_tool.d.ts +2 -8
- package/lib/component/utility/core_slots/core_operator_tool.d.ts.map +1 -1
- package/lib/component/utility/core_slots/core_operator_tool.js +8 -6
- package/lib/component/utility/core_slots/core_operator_tool.js.map +1 -1
- package/lib/component/utility/export.d.ts +5 -0
- package/lib/component/utility/export.d.ts.map +1 -1
- package/lib/component/utility/export.js +22 -0
- package/lib/component/utility/export.js.map +1 -1
- package/lib/data/data2d/Spectrum2D/contours.d.ts.map +1 -1
- package/lib/data/data2d/Spectrum2D/contours.js +23 -10
- package/lib/data/data2d/Spectrum2D/contours.js.map +1 -1
- package/lib/data/data2d/Spectrum2D/findBestMinContour/estimateNoiseLevel.d.ts +13 -0
- package/lib/data/data2d/Spectrum2D/findBestMinContour/estimateNoiseLevel.d.ts.map +1 -0
- package/lib/data/data2d/Spectrum2D/findBestMinContour/estimateNoiseLevel.js +40 -0
- package/lib/data/data2d/Spectrum2D/findBestMinContour/estimateNoiseLevel.js.map +1 -0
- package/lib/data/data2d/Spectrum2D/findBestMinContour/evaluation.d.ts +27 -0
- package/lib/data/data2d/Spectrum2D/findBestMinContour/evaluation.d.ts.map +1 -0
- package/lib/data/data2d/Spectrum2D/findBestMinContour/evaluation.js +230 -0
- package/lib/data/data2d/Spectrum2D/findBestMinContour/evaluation.js.map +1 -0
- package/lib/data/data2d/Spectrum2D/findBestMinContour/findAutomaticContourLevels.d.ts +227 -0
- package/lib/data/data2d/Spectrum2D/findBestMinContour/findAutomaticContourLevels.d.ts.map +1 -0
- package/lib/data/data2d/Spectrum2D/findBestMinContour/findAutomaticContourLevels.js +67 -0
- package/lib/data/data2d/Spectrum2D/findBestMinContour/findAutomaticContourLevels.js.map +1 -0
- package/lib/data/data2d/Spectrum2D/findBestMinContour/math.d.ts +4 -0
- package/lib/data/data2d/Spectrum2D/findBestMinContour/math.d.ts.map +1 -0
- package/lib/data/data2d/Spectrum2D/findBestMinContour/math.js +42 -0
- package/lib/data/data2d/Spectrum2D/findBestMinContour/math.js.map +1 -0
- package/lib/data/utilities/calculateSanPlot.d.ts +3 -1
- package/lib/data/utilities/calculateSanPlot.d.ts.map +1 -1
- package/lib/data/utilities/calculateSanPlot.js +2 -2
- package/lib/data/utilities/calculateSanPlot.js.map +1 -1
- package/lib/versionInfo.js +1 -1
- package/package.json +5 -5
- package/src/component/1d/ApodizationLine.tsx +2 -2
- package/src/component/1d/Line.tsx +2 -2
- package/src/component/1d/SVGContent1D.tsx +6 -0
- package/src/component/1d/baseline/BaselinePreview.tsx +2 -2
- package/src/component/1d/database/DatabaseSpectrum.tsx +2 -2
- package/src/component/1d/database/ResurrectedDatabaseRanges.tsx +2 -2
- package/src/component/1d/matrix/Boxplot.tsx +5 -5
- package/src/component/1d/matrix/Stocsy.tsx +2 -2
- package/src/component/1d/peaks/PeakAnnotationsSpreadMode.tsx +17 -3
- package/src/component/1d/peaks/usePeakShapesPath.ts +2 -2
- package/src/component/1d/plugin_svg_chart.tsx +60 -0
- package/src/component/1d-2d/components/RangeIndicator.tsx +8 -9
- package/src/component/2d/1d-tracer/HorizontalSliceChart.tsx +2 -2
- package/src/component/2d/1d-tracer/Left1DChart.tsx +2 -2
- package/src/component/2d/1d-tracer/Top1DChart.tsx +2 -2
- package/src/component/2d/1d-tracer/VerticalSliceChart.tsx +2 -2
- package/src/component/2d/1d-tracer/phase-correction-traces/SpectrumPhaseTrace.tsx +3 -3
- package/src/component/2d/ft/Contours.tsx +2 -2
- package/src/component/context/ScaleContext.tsx +1 -1
- package/src/component/elements/D3Axis.tsx +49 -67
- package/src/component/elements/export/ExportContent.tsx +3 -2
- package/src/component/elements/export/ExportOptionsModal.tsx +32 -1
- package/src/component/elements/export/useExportConfigurer.tsx +6 -0
- package/src/component/elements/print/PrintContent.tsx +6 -27
- package/src/component/elements/utilities/transferStyles.ts +32 -0
- package/src/component/hooks/useIntegralPath.ts +2 -2
- package/src/component/modal/setting/tanstack_general_settings/tabs/export_tab.fields.tsx +47 -57
- package/src/component/modal/setting/tanstack_general_settings/validation/export_tab_validation.ts +100 -28
- package/src/component/panels/filtersPanel/processings_sections_panel.tsx +1 -1
- package/src/component/panels/multipleAnalysisPanel/AlignSpectra.tsx +128 -98
- package/src/component/panels/multipleAnalysisPanel/MultipleSpectraAnalysisPanel.tsx +1 -1
- package/src/component/toolbar/nmr_toolbar.tsx +1 -1
- package/src/component/utility/core_slots/core_operator_chart_svg.tsx +61 -0
- package/src/component/utility/core_slots/core_operator_panel_tool.tsx +9 -27
- package/src/component/utility/core_slots/core_operator_tool.commons.ts +63 -0
- package/src/component/utility/core_slots/core_operator_tool.tsx +9 -27
- package/src/component/utility/export.ts +34 -0
- package/src/data/data2d/Spectrum2D/contours.ts +40 -14
- package/src/data/data2d/Spectrum2D/findBestMinContour/estimateNoiseLevel.ts +67 -0
- package/src/data/data2d/Spectrum2D/findBestMinContour/evaluation.ts +432 -0
- package/src/data/data2d/Spectrum2D/findBestMinContour/findAutomaticContourLevels.ts +431 -0
- package/src/data/data2d/Spectrum2D/findBestMinContour/math.ts +59 -0
- package/src/data/utilities/calculateSanPlot.ts +2 -1
- package/src/versionInfo.ts +1 -1
- package/lib/component/elements/export/utilities/transferDocumentStyles.d.ts +0 -2
- package/lib/component/elements/export/utilities/transferDocumentStyles.d.ts.map +0 -1
- package/lib/component/elements/export/utilities/transferDocumentStyles.js +0 -21
- package/lib/component/elements/export/utilities/transferDocumentStyles.js.map +0 -1
- package/lib/component/utility/PathBuilder.d.ts +0 -10
- package/lib/component/utility/PathBuilder.d.ts.map +0 -1
- package/lib/component/utility/PathBuilder.js +0 -38
- package/lib/component/utility/PathBuilder.js.map +0 -1
- package/src/component/elements/export/utilities/transferDocumentStyles.ts +0 -21
- package/src/component/utility/PathBuilder.ts +0 -41
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SVGAttributes } from 'react';
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
|
-
import type {
|
|
3
|
+
import type { UseLinearPrimaryTicksResult } from 'react-d3-utils';
|
|
4
4
|
import type {
|
|
5
5
|
SVGStyledLineProps,
|
|
6
6
|
SVGStyledLineUserConfig,
|
|
@@ -49,6 +49,16 @@ function isVerticalAxis(axisPosition: AxisPosition) {
|
|
|
49
49
|
return ['left', 'right'].includes(axisPosition);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
function getSecondaryTickPositions(ticks: Array<{ position: number }>) {
|
|
53
|
+
return ticks
|
|
54
|
+
.slice(0, -1)
|
|
55
|
+
.map((tick, index) => (tick.position + ticks[index + 1].position) / 2);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function getTickTransform(position: number, isVertical: boolean) {
|
|
59
|
+
return `translate(${isVertical ? `0,${position}` : `${position},0`})`;
|
|
60
|
+
}
|
|
61
|
+
|
|
52
62
|
function BaseLine(props: BaseLineProps) {
|
|
53
63
|
const { axisPosition, tickLength = 6, scale } = props;
|
|
54
64
|
const { primaryTicks } = useTicksConfig();
|
|
@@ -100,86 +110,58 @@ function Tickets(props: TicketsProps) {
|
|
|
100
110
|
: { y1: positionSign * tickLength, y2: 0 };
|
|
101
111
|
|
|
102
112
|
const secondaryTickLength = tickLength / 2;
|
|
103
|
-
const secondaryTickOffset = getSecondaryTickOffset(ticks, positionSign);
|
|
104
113
|
const positionSecondaryLineConfig: SVGStyledLineProps = isVertical
|
|
105
114
|
? {
|
|
106
115
|
x1: positionSign * secondaryTickLength,
|
|
107
116
|
x2: 0,
|
|
108
|
-
y1: secondaryTickOffset,
|
|
109
|
-
y2: secondaryTickOffset,
|
|
110
117
|
}
|
|
111
118
|
: {
|
|
112
119
|
y1: positionSign * secondaryTickLength,
|
|
113
120
|
y2: 0,
|
|
114
|
-
x1: secondaryTickOffset,
|
|
115
|
-
x2: secondaryTickOffset,
|
|
116
121
|
};
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
y1: -secondaryTickOffset,
|
|
122
|
-
y2: -secondaryTickOffset,
|
|
123
|
-
}
|
|
124
|
-
: {
|
|
125
|
-
y1: positionSign * secondaryTickLength,
|
|
126
|
-
y2: 0,
|
|
127
|
-
x1: -secondaryTickOffset,
|
|
128
|
-
x2: -secondaryTickOffset,
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
return ticks.map(({ label, position }, index) => {
|
|
132
|
-
const isFirst = index === 0;
|
|
122
|
+
const secondaryTickPositions =
|
|
123
|
+
secondaryTicks.enabled && ticks.length > 1
|
|
124
|
+
? getSecondaryTickPositions(ticks)
|
|
125
|
+
: [];
|
|
133
126
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
127
|
+
return (
|
|
128
|
+
<>
|
|
129
|
+
{ticks.map(({ label, position }) => {
|
|
130
|
+
return (
|
|
131
|
+
<g key={`primary-${label}-${position}`} className="tick">
|
|
132
|
+
<line
|
|
133
|
+
data-testid="axis-primary-tick-line"
|
|
134
|
+
transform={getTickTransform(position, isVertical)}
|
|
135
|
+
{...positionPrimaryLineConfig}
|
|
136
|
+
stroke="black"
|
|
137
|
+
{...primaryTicks.tickStyle}
|
|
138
|
+
/>
|
|
139
|
+
|
|
140
|
+
<SVGStyledText
|
|
141
|
+
transform={getTickTransform(position, isVertical)}
|
|
142
|
+
fill="black"
|
|
143
|
+
data-testid="axis-primary-tick-label"
|
|
144
|
+
{...primaryTicks.textStyle}
|
|
145
|
+
{...positionTextConfig}
|
|
146
|
+
>
|
|
147
|
+
{label}
|
|
148
|
+
</SVGStyledText>
|
|
149
|
+
</g>
|
|
150
|
+
);
|
|
151
|
+
})}
|
|
147
152
|
|
|
153
|
+
{secondaryTickPositions.map((secondaryTickPosition) => (
|
|
148
154
|
<line
|
|
149
|
-
|
|
155
|
+
data-testid="axis-secondary-tick-line"
|
|
156
|
+
key={`secondary-${secondaryTickPosition}`}
|
|
157
|
+
transform={getTickTransform(secondaryTickPosition, isVertical)}
|
|
158
|
+
{...positionSecondaryLineConfig}
|
|
150
159
|
stroke="black"
|
|
151
|
-
{...
|
|
160
|
+
{...secondaryTicks.tickStyle}
|
|
152
161
|
/>
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
{...positionSecondaryLineConfig}
|
|
157
|
-
stroke="black"
|
|
158
|
-
{...secondaryTicks.tickStyle}
|
|
159
|
-
/>
|
|
160
|
-
)}
|
|
161
|
-
|
|
162
|
-
<SVGStyledText
|
|
163
|
-
fill="black"
|
|
164
|
-
{...primaryTicks.textStyle}
|
|
165
|
-
{...positionTextConfig}
|
|
166
|
-
>
|
|
167
|
-
{label}
|
|
168
|
-
</SVGStyledText>
|
|
169
|
-
</g>
|
|
170
|
-
);
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
function getSecondaryTickOffset(ticks: Array<Tick<number>>, direction: -1 | 1) {
|
|
175
|
-
if (ticks.length < 2) return 0;
|
|
176
|
-
|
|
177
|
-
let [first, second] = ticks;
|
|
178
|
-
if (direction === -1) {
|
|
179
|
-
[first, second] = [second, first];
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return (second.position - first.position) / 2;
|
|
162
|
+
))}
|
|
163
|
+
</>
|
|
164
|
+
);
|
|
183
165
|
}
|
|
184
166
|
|
|
185
167
|
function getLinePosition(
|
|
@@ -3,12 +3,13 @@ import type { ReactNode } from 'react';
|
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
5
5
|
|
|
6
|
+
import { transferStylesToDocument } from '../utilities/transferStyles.js';
|
|
7
|
+
|
|
6
8
|
import { ExportOptionsModal } from './ExportOptionsModal.js';
|
|
7
9
|
import { ExportSettingsProvider } from './ExportSettingsProvider.js';
|
|
8
10
|
import { RenderDetector } from './RenderDetector.js';
|
|
9
11
|
import { INITIAL_BASIC_EXPORT_OPTIONS } from './utilities/getExportOptions.js';
|
|
10
12
|
import { getSizeInPixel } from './utilities/getSizeInPixel.js';
|
|
11
|
-
import { transferDocumentStyles } from './utilities/transferDocumentStyles.js';
|
|
12
13
|
|
|
13
14
|
export interface BaseExportProps {
|
|
14
15
|
onExportOptionsChange: (options: ExportSettings) => void;
|
|
@@ -112,7 +113,7 @@ function InnerPrintFrame(props: InnerExportFrameProps) {
|
|
|
112
113
|
const document = frame.contentWindow?.document;
|
|
113
114
|
if (!document) return;
|
|
114
115
|
setIframeDocument(document);
|
|
115
|
-
|
|
116
|
+
transferStylesToDocument(document);
|
|
116
117
|
}
|
|
117
118
|
|
|
118
119
|
const exportWidthInPixel = Math.round(width);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { DialogFooter } from '@blueprintjs/core';
|
|
1
|
+
import { Callout, DialogFooter } from '@blueprintjs/core';
|
|
2
|
+
import { revalidateLogic } from '@tanstack/react-form';
|
|
2
3
|
import { useMemo } from 'react';
|
|
3
4
|
import { AppForm, Button, useForm } from 'react-science/ui';
|
|
4
5
|
import { z } from 'zod/v4';
|
|
@@ -52,6 +53,8 @@ function InnerExportOptionsModal(props: InnerExportOptionsModalProps) {
|
|
|
52
53
|
validators: {
|
|
53
54
|
onDynamic: validator,
|
|
54
55
|
},
|
|
56
|
+
// onDynamic validators are ignored by the default validation logic
|
|
57
|
+
validationLogic: revalidateLogic({ mode: 'change' }),
|
|
55
58
|
onSubmit: ({ value: { values } }) => {
|
|
56
59
|
const parsedValues = exportSettingsValidation.parse(values);
|
|
57
60
|
onExportOptionsChange(parsedValues);
|
|
@@ -69,6 +72,34 @@ function InnerExportOptionsModal(props: InnerExportOptionsModalProps) {
|
|
|
69
72
|
>
|
|
70
73
|
<AppForm form={form} layout="inline">
|
|
71
74
|
<StyledDialogBody>
|
|
75
|
+
<form.Subscribe
|
|
76
|
+
selector={(state) =>
|
|
77
|
+
Array.from(
|
|
78
|
+
new Set(
|
|
79
|
+
Object.values(state.errorMap.onDynamic ?? {})
|
|
80
|
+
.flat()
|
|
81
|
+
.map((error) => error?.message)
|
|
82
|
+
.filter((message) => typeof message === 'string'),
|
|
83
|
+
),
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
>
|
|
87
|
+
{(messages) =>
|
|
88
|
+
messages.length > 0 && (
|
|
89
|
+
<Callout
|
|
90
|
+
intent="danger"
|
|
91
|
+
title="Invalid export options"
|
|
92
|
+
style={{ marginBottom: 10 }}
|
|
93
|
+
>
|
|
94
|
+
<ul style={{ margin: 0, paddingInlineStart: '1.2em' }}>
|
|
95
|
+
{messages.map((message) => (
|
|
96
|
+
<li key={message}>{message}</li>
|
|
97
|
+
))}
|
|
98
|
+
</ul>
|
|
99
|
+
</Callout>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
</form.Subscribe>
|
|
72
103
|
<ExportFields form={form} fields="values" />
|
|
73
104
|
</StyledDialogBody>
|
|
74
105
|
<DialogFooter
|
|
@@ -12,6 +12,11 @@ export function useExportConfigurer(options: ExportSettings) {
|
|
|
12
12
|
const refSize = useRef({ width, height, dpi });
|
|
13
13
|
const previousUnit = useDeferredValue(unit);
|
|
14
14
|
|
|
15
|
+
function resetSize(newOptions: ExportSettings) {
|
|
16
|
+
const { width, height, dpi } = getExportOptions(newOptions);
|
|
17
|
+
refSize.current = { width, height, dpi };
|
|
18
|
+
}
|
|
19
|
+
|
|
15
20
|
function changeSize(
|
|
16
21
|
value: number,
|
|
17
22
|
target: 'width' | 'height',
|
|
@@ -65,5 +70,6 @@ export function useExportConfigurer(options: ExportSettings) {
|
|
|
65
70
|
changeUnit,
|
|
66
71
|
changeSize,
|
|
67
72
|
enableAspectRatio,
|
|
73
|
+
resetSize,
|
|
68
74
|
};
|
|
69
75
|
}
|
|
@@ -10,6 +10,7 @@ import { z } from 'zod';
|
|
|
10
10
|
|
|
11
11
|
import { StandardDialog } from '../StandardDialog.tsx';
|
|
12
12
|
import { StyledDialogBody } from '../StyledDialogBody.js';
|
|
13
|
+
import { transferStylesToDocument } from '../utilities/transferStyles.ts';
|
|
13
14
|
|
|
14
15
|
import { PrintProvider } from './PrintProvider.js';
|
|
15
16
|
import { getSizesList, pageSizes } from './pageSize.js';
|
|
@@ -142,16 +143,16 @@ function InnerPrintFrame(props: InnerPrintFrameProps) {
|
|
|
142
143
|
function refHandler(frame: HTMLIFrameElement | null) {
|
|
143
144
|
if (!frame) return;
|
|
144
145
|
|
|
145
|
-
const
|
|
146
|
+
const targetDocument = frame.contentWindow?.document;
|
|
146
147
|
|
|
147
|
-
if (!
|
|
148
|
+
if (!targetDocument) {
|
|
148
149
|
onError?.(new Error('Print document is not available'));
|
|
149
150
|
return;
|
|
150
151
|
}
|
|
151
152
|
|
|
152
|
-
|
|
153
|
-
appendPrintPageStyle(
|
|
154
|
-
setIframeDocument(
|
|
153
|
+
transferStylesToDocument(targetDocument);
|
|
154
|
+
appendPrintPageStyle(targetDocument, { size, layout, margin });
|
|
155
|
+
setIframeDocument(targetDocument);
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
useEffect(() => {
|
|
@@ -250,28 +251,6 @@ function appendPrintPageStyle(document: Document, style: Style = {}) {
|
|
|
250
251
|
document.head.append(styleElement);
|
|
251
252
|
}
|
|
252
253
|
|
|
253
|
-
function transferStyles(targetDocument: Document) {
|
|
254
|
-
// Copy the style from the main page and inject it inside the iframe
|
|
255
|
-
const styleSheets = Array.from(document.styleSheets);
|
|
256
|
-
const targetHead = targetDocument.head;
|
|
257
|
-
|
|
258
|
-
for (const styleSheet of styleSheets) {
|
|
259
|
-
try {
|
|
260
|
-
if (styleSheet.cssRules) {
|
|
261
|
-
const newStyleEl = document.createElement('style');
|
|
262
|
-
const cssRules = Array.from(styleSheet.cssRules);
|
|
263
|
-
const cssText = cssRules.map((rule) => rule.cssText).join('\n');
|
|
264
|
-
|
|
265
|
-
newStyleEl.append(document.createTextNode(cssText));
|
|
266
|
-
targetHead.append(newStyleEl);
|
|
267
|
-
}
|
|
268
|
-
} catch (error) {
|
|
269
|
-
// eslint-disable-next-line no-console
|
|
270
|
-
console.error('Error transferring styles:', error);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
254
|
interface InnerPrintOptionsModalProps extends BasePrintProps {
|
|
276
255
|
onCloseDialog: () => void;
|
|
277
256
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function getCssTextFromStyleSheet(
|
|
2
|
+
styleSheet: Pick<CSSStyleSheet, 'cssRules'>,
|
|
3
|
+
): string | undefined {
|
|
4
|
+
try {
|
|
5
|
+
if (!styleSheet.cssRules) return undefined;
|
|
6
|
+
return Array.from(styleSheet.cssRules)
|
|
7
|
+
.map((rule) => rule.cssText)
|
|
8
|
+
.join('\n');
|
|
9
|
+
} catch (error) {
|
|
10
|
+
if (
|
|
11
|
+
error instanceof DOMException &&
|
|
12
|
+
(error.name === 'SecurityError' || error.name === 'NotAllowedError')
|
|
13
|
+
) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function transferStylesToDocument(targetDocument: Document) {
|
|
21
|
+
const styleSheets = Array.from(document.styleSheets);
|
|
22
|
+
const targetHead = targetDocument.head;
|
|
23
|
+
|
|
24
|
+
for (const styleSheet of styleSheets) {
|
|
25
|
+
const cssText = getCssTextFromStyleSheet(styleSheet);
|
|
26
|
+
if (!cssText) continue;
|
|
27
|
+
|
|
28
|
+
const newStyleEl = document.createElement('style');
|
|
29
|
+
newStyleEl.append(document.createTextNode(cssText));
|
|
30
|
+
targetHead.append(newStyleEl);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ScaleLinear } from 'd3-scale';
|
|
2
2
|
import { xyReduce } from 'ml-spectra-processing';
|
|
3
|
+
import { SVGPathBuilder } from 'react-science/ui';
|
|
3
4
|
|
|
4
5
|
import { getIntegralYScale } from '../1d/utilities/scale.js';
|
|
5
6
|
import { useChartData } from '../context/ChartContext.js';
|
|
6
7
|
import { useScaleChecked } from '../context/ScaleContext.js';
|
|
7
|
-
import { PathBuilder } from '../utility/PathBuilder.js';
|
|
8
8
|
|
|
9
9
|
import { useXScale } from './useXScale.js';
|
|
10
10
|
|
|
@@ -48,7 +48,7 @@ export default function useIntegralPath(options: UseIntegralPathOptions) {
|
|
|
48
48
|
},
|
|
49
49
|
);
|
|
50
50
|
|
|
51
|
-
const pathBuilder = new
|
|
51
|
+
const pathBuilder = new SVGPathBuilder();
|
|
52
52
|
pathBuilder.moveTo(scaleX(xySeries.x[0]), scaleY(xySeries.y[0]));
|
|
53
53
|
for (let i = 1; i < xySeries.x.length; i++) {
|
|
54
54
|
pathBuilder.lineTo(scaleX(xySeries.x[i]), scaleY(xySeries.y[i]));
|
|
@@ -14,7 +14,14 @@ import {
|
|
|
14
14
|
getExportOptions,
|
|
15
15
|
} from '../../../../elements/export/utilities/getExportOptions.js';
|
|
16
16
|
import { pageSizes } from '../../../../elements/print/pageSize.js';
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
MAX_DPI,
|
|
19
|
+
MIN_DPI,
|
|
20
|
+
dpiField,
|
|
21
|
+
exportSettingsDecoder,
|
|
22
|
+
exportSettingsValidation,
|
|
23
|
+
sizeField,
|
|
24
|
+
} from '../validation/export_tab_validation.js';
|
|
18
25
|
import { defaultGeneralSettingsFormValues } from '../validation.js';
|
|
19
26
|
|
|
20
27
|
type Mode = 'basic' | 'advance';
|
|
@@ -48,96 +55,69 @@ const layoutItems: Array<SelectItem<Layout>> = [
|
|
|
48
55
|
{ value: 'landscape', label: 'Landscape' },
|
|
49
56
|
];
|
|
50
57
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
58
|
+
/** Returns null for values the schema rejects */
|
|
59
|
+
function parsePositiveNumber(str: string) {
|
|
60
|
+
const value = Number(str);
|
|
61
|
+
if (!Number.isFinite(value) || value <= 0) return null;
|
|
54
62
|
return value;
|
|
55
63
|
}
|
|
56
64
|
|
|
57
|
-
function safeStringNumber(str: string, onInvalid: (str: string) => void) {
|
|
58
|
-
let isInvalid = false;
|
|
59
|
-
let value = Number(str);
|
|
60
|
-
if (Number.isNaN(value)) {
|
|
61
|
-
value = 1;
|
|
62
|
-
isInvalid = true;
|
|
63
|
-
}
|
|
64
|
-
if (value <= 0) {
|
|
65
|
-
value = 1;
|
|
66
|
-
isInvalid = true;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (!isInvalid) {
|
|
70
|
-
const result = String(value);
|
|
71
|
-
onInvalid(result);
|
|
72
|
-
return result;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return str;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
65
|
export const ExportFields = withFieldGroup({
|
|
79
66
|
defaultValues: defaultGeneralSettingsFormValues.export.png,
|
|
80
67
|
render: function ExportFields({ group }) {
|
|
81
68
|
const inputValues = useSelector(group.store, (s) => s.values);
|
|
82
69
|
|
|
83
70
|
const outputValues = useMemo(() => {
|
|
84
|
-
return
|
|
71
|
+
return exportSettingsDecoder.decode(inputValues);
|
|
85
72
|
}, [inputValues]);
|
|
86
73
|
|
|
87
74
|
const advancedTransforms = useExportConfigurer(outputValues);
|
|
88
75
|
|
|
89
76
|
function onModeChange({ value }: { value: Mode }) {
|
|
90
|
-
const
|
|
77
|
+
const defaultOptions = getExportDefaultOptionsByMode(value);
|
|
78
|
+
const newOptions = exportSettingsValidation.encode(defaultOptions);
|
|
91
79
|
|
|
92
80
|
for (const [key, value] of Object.entries(newOptions)) {
|
|
93
81
|
group.setFieldValue(key as keyof typeof newOptions, value, {
|
|
94
82
|
dontRunListeners: true,
|
|
95
83
|
});
|
|
96
84
|
}
|
|
85
|
+
// keep the aspect ratio if the options is activated
|
|
86
|
+
advancedTransforms.resetSize(defaultOptions);
|
|
97
87
|
}
|
|
98
88
|
|
|
99
89
|
function onChangeUnit({ value }: { value: Unit }) {
|
|
100
90
|
const { width, height } = advancedTransforms.changeUnit({ unit: value });
|
|
101
|
-
group.setFieldValue('width', String(
|
|
91
|
+
group.setFieldValue('width', String(width), {
|
|
102
92
|
dontRunListeners: true,
|
|
103
93
|
});
|
|
104
|
-
group.setFieldValue('height', String(
|
|
94
|
+
group.setFieldValue('height', String(height), {
|
|
105
95
|
dontRunListeners: true,
|
|
106
96
|
});
|
|
107
97
|
}
|
|
108
98
|
|
|
109
99
|
function onWidthChange({ value }: { value: string }) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
);
|
|
100
|
+
const width = parsePositiveNumber(value);
|
|
101
|
+
if (width === null) return;
|
|
113
102
|
|
|
114
|
-
const height = advancedTransforms.changeSize(
|
|
115
|
-
Number(value),
|
|
116
|
-
'height',
|
|
117
|
-
'width',
|
|
118
|
-
);
|
|
103
|
+
const height = advancedTransforms.changeSize(width, 'height', 'width');
|
|
119
104
|
if (!advancedTransforms.isAspectRatioEnabled) {
|
|
120
105
|
return;
|
|
121
106
|
}
|
|
122
|
-
group.setFieldValue('height', String(
|
|
107
|
+
group.setFieldValue('height', String(height), {
|
|
123
108
|
dontRunListeners: true,
|
|
124
109
|
});
|
|
125
110
|
}
|
|
126
111
|
|
|
127
112
|
function onHeightChange({ value }: { value: string }) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
);
|
|
113
|
+
const height = parsePositiveNumber(value);
|
|
114
|
+
if (height === null) return;
|
|
131
115
|
|
|
132
|
-
const width = advancedTransforms.changeSize(
|
|
133
|
-
Number(value),
|
|
134
|
-
'width',
|
|
135
|
-
'height',
|
|
136
|
-
);
|
|
116
|
+
const width = advancedTransforms.changeSize(height, 'width', 'height');
|
|
137
117
|
if (!advancedTransforms.isAspectRatioEnabled) {
|
|
138
118
|
return;
|
|
139
119
|
}
|
|
140
|
-
group.setFieldValue('width', String(
|
|
120
|
+
group.setFieldValue('width', String(width), {
|
|
141
121
|
dontRunListeners: true,
|
|
142
122
|
});
|
|
143
123
|
}
|
|
@@ -146,14 +126,14 @@ export const ExportFields = withFieldGroup({
|
|
|
146
126
|
if (inputValues.mode !== 'advance') return;
|
|
147
127
|
if (inputValues.unit !== 'px') return;
|
|
148
128
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const { width, height } = advancedTransforms.changeDPI(
|
|
153
|
-
group.setFieldValue('width', String(
|
|
129
|
+
const dpi = parsePositiveNumber(value);
|
|
130
|
+
if (dpi === null || dpi < MIN_DPI || dpi > MAX_DPI) return;
|
|
131
|
+
|
|
132
|
+
const { width, height } = advancedTransforms.changeDPI(dpi);
|
|
133
|
+
group.setFieldValue('width', String(width), {
|
|
154
134
|
dontRunListeners: true,
|
|
155
135
|
});
|
|
156
|
-
group.setFieldValue('height', String(
|
|
136
|
+
group.setFieldValue('height', String(height), {
|
|
157
137
|
dontRunListeners: true,
|
|
158
138
|
});
|
|
159
139
|
}
|
|
@@ -179,6 +159,8 @@ export const ExportFields = withFieldGroup({
|
|
|
179
159
|
}}
|
|
180
160
|
>
|
|
181
161
|
{({ mode, layout, unit }) => {
|
|
162
|
+
const minSize = unit === 'px' ? 1 : 0;
|
|
163
|
+
|
|
182
164
|
switch (mode) {
|
|
183
165
|
case 'basic':
|
|
184
166
|
return (
|
|
@@ -218,11 +200,12 @@ export const ExportFields = withFieldGroup({
|
|
|
218
200
|
<AppField
|
|
219
201
|
name="width"
|
|
220
202
|
listeners={{ onChange: onWidthChange }}
|
|
203
|
+
validators={{ onChange: sizeField }}
|
|
221
204
|
>
|
|
222
205
|
{({ NumericInput }) => (
|
|
223
206
|
<NumericInput
|
|
224
207
|
label="Width"
|
|
225
|
-
min={
|
|
208
|
+
min={minSize}
|
|
226
209
|
rightElement={<Tag>{unit}</Tag>}
|
|
227
210
|
/>
|
|
228
211
|
)}
|
|
@@ -230,11 +213,12 @@ export const ExportFields = withFieldGroup({
|
|
|
230
213
|
<AppField
|
|
231
214
|
name="height"
|
|
232
215
|
listeners={{ onChange: onHeightChange }}
|
|
216
|
+
validators={{ onChange: sizeField }}
|
|
233
217
|
>
|
|
234
218
|
{({ NumericInput }) => (
|
|
235
219
|
<NumericInput
|
|
236
220
|
label="Height"
|
|
237
|
-
min={
|
|
221
|
+
min={minSize}
|
|
238
222
|
rightElement={<Tag>{unit}</Tag>}
|
|
239
223
|
/>
|
|
240
224
|
)}
|
|
@@ -246,8 +230,14 @@ export const ExportFields = withFieldGroup({
|
|
|
246
230
|
}
|
|
247
231
|
}}
|
|
248
232
|
</Subscribe>
|
|
249
|
-
<AppField
|
|
250
|
-
|
|
233
|
+
<AppField
|
|
234
|
+
name="dpi"
|
|
235
|
+
listeners={{ onChange: onDPIChange }}
|
|
236
|
+
validators={{ onChange: dpiField }}
|
|
237
|
+
>
|
|
238
|
+
{({ NumericInput }) => (
|
|
239
|
+
<NumericInput label="DPI" min={MIN_DPI} max={MAX_DPI} />
|
|
240
|
+
)}
|
|
251
241
|
</AppField>
|
|
252
242
|
<AppField name="useDefaultSettings">
|
|
253
243
|
{({ Checkbox }) => (
|