react-cheminfo 0.65.0 → 0.66.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 (237) hide show
  1. package/README.md +11 -6
  2. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  3. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  4. package/lib/ir/core/analysisSpectra.d.ts +23 -6
  5. package/lib/ir/core/analysisSpectra.d.ts.map +1 -1
  6. package/lib/ir/core/analysisSpectra.js.map +1 -1
  7. package/lib/ir/core/bandLabelPlan.d.ts.map +1 -1
  8. package/lib/ir/core/bandLabelPlan.js +11 -6
  9. package/lib/ir/core/bandLabelPlan.js.map +1 -1
  10. package/lib/ir/core/index.d.ts +13 -9
  11. package/lib/ir/core/index.d.ts.map +1 -1
  12. package/lib/ir/core/index.js +9 -6
  13. package/lib/ir/core/index.js.map +1 -1
  14. package/lib/ir/core/irBand.d.ts +45 -14
  15. package/lib/ir/core/irBand.d.ts.map +1 -1
  16. package/lib/ir/core/irBand.js +28 -6
  17. package/lib/ir/core/irBand.js.map +1 -1
  18. package/lib/ir/core/irCommands.d.ts +11 -0
  19. package/lib/ir/core/irCommands.d.ts.map +1 -1
  20. package/lib/ir/core/irCommands.js +11 -1
  21. package/lib/ir/core/irCommands.js.map +1 -1
  22. package/lib/ir/core/irDomain.d.ts +4 -3
  23. package/lib/ir/core/irDomain.d.ts.map +1 -1
  24. package/lib/ir/core/irDomain.js +10 -7
  25. package/lib/ir/core/irDomain.js.map +1 -1
  26. package/lib/ir/core/irFormat.d.ts +14 -2
  27. package/lib/ir/core/irFormat.d.ts.map +1 -1
  28. package/lib/ir/core/irFormat.js +33 -4
  29. package/lib/ir/core/irFormat.js.map +1 -1
  30. package/lib/ir/core/irMode.d.ts +35 -8
  31. package/lib/ir/core/irMode.d.ts.map +1 -1
  32. package/lib/ir/core/irMode.js +38 -10
  33. package/lib/ir/core/irMode.js.map +1 -1
  34. package/lib/ir/core/irReducer.d.ts +0 -28
  35. package/lib/ir/core/irReducer.d.ts.map +1 -1
  36. package/lib/ir/core/irReducer.js +1 -24
  37. package/lib/ir/core/irReducer.js.map +1 -1
  38. package/lib/ir/core/irSpectrum.d.ts +52 -26
  39. package/lib/ir/core/irSpectrum.d.ts.map +1 -1
  40. package/lib/ir/core/irSpectrum.js +21 -15
  41. package/lib/ir/core/irSpectrum.js.map +1 -1
  42. package/lib/ir/core/irState.d.ts +40 -2
  43. package/lib/ir/core/irState.d.ts.map +1 -1
  44. package/lib/ir/core/irState.js +38 -1
  45. package/lib/ir/core/irState.js.map +1 -1
  46. package/lib/ir/core/irTechnique.d.ts +94 -0
  47. package/lib/ir/core/irTechnique.d.ts.map +1 -0
  48. package/lib/ir/core/irTechnique.js +87 -0
  49. package/lib/ir/core/irTechnique.js.map +1 -0
  50. package/lib/ir/core/irTechniqueCommands.d.ts +26 -0
  51. package/lib/ir/core/irTechniqueCommands.d.ts.map +1 -0
  52. package/lib/ir/core/irTechniqueCommands.js +68 -0
  53. package/lib/ir/core/irTechniqueCommands.js.map +1 -0
  54. package/lib/ir/core/pickBands.d.ts +6 -5
  55. package/lib/ir/core/pickBands.d.ts.map +1 -1
  56. package/lib/ir/core/pickBands.js +49 -26
  57. package/lib/ir/core/pickBands.js.map +1 -1
  58. package/lib/ir/core/ramanBands.d.ts +30 -0
  59. package/lib/ir/core/ramanBands.d.ts.map +1 -0
  60. package/lib/ir/core/ramanBands.js +83 -0
  61. package/lib/ir/core/ramanBands.js.map +1 -0
  62. package/lib/ir/core/spectrumJcamp.d.ts +10 -5
  63. package/lib/ir/core/spectrumJcamp.d.ts.map +1 -1
  64. package/lib/ir/core/spectrumJcamp.js +63 -15
  65. package/lib/ir/core/spectrumJcamp.js.map +1 -1
  66. package/lib/ir/core/toIrSpectrum.d.ts.map +1 -1
  67. package/lib/ir/core/toIrSpectrum.js +17 -2
  68. package/lib/ir/core/toIrSpectrum.js.map +1 -1
  69. package/lib/ir/ui/BandRow.d.ts +30 -0
  70. package/lib/ir/ui/BandRow.d.ts.map +1 -0
  71. package/lib/ir/ui/BandRow.js +42 -0
  72. package/lib/ir/ui/BandRow.js.map +1 -0
  73. package/lib/ir/ui/BandsPanel.d.ts +4 -0
  74. package/lib/ir/ui/BandsPanel.d.ts.map +1 -1
  75. package/lib/ir/ui/BandsPanel.js +14 -59
  76. package/lib/ir/ui/BandsPanel.js.map +1 -1
  77. package/lib/ir/ui/IrAboutDialog.d.ts +7 -0
  78. package/lib/ir/ui/IrAboutDialog.d.ts.map +1 -1
  79. package/lib/ir/ui/IrAboutDialog.js +16 -3
  80. package/lib/ir/ui/IrAboutDialog.js.map +1 -1
  81. package/lib/ir/ui/IrCanvas.d.ts.map +1 -1
  82. package/lib/ir/ui/IrCanvas.js +2 -2
  83. package/lib/ir/ui/IrCanvas.js.map +1 -1
  84. package/lib/ir/ui/IrChart.d.ts +2 -1
  85. package/lib/ir/ui/IrChart.d.ts.map +1 -1
  86. package/lib/ir/ui/IrChart.js +18 -21
  87. package/lib/ir/ui/IrChart.js.map +1 -1
  88. package/lib/ir/ui/IrCommandProvider.d.ts +7 -0
  89. package/lib/ir/ui/IrCommandProvider.d.ts.map +1 -1
  90. package/lib/ir/ui/IrCommandProvider.js +2 -2
  91. package/lib/ir/ui/IrCommandProvider.js.map +1 -1
  92. package/lib/ir/ui/IrCommandTooltip.d.ts +7 -0
  93. package/lib/ir/ui/IrCommandTooltip.d.ts.map +1 -1
  94. package/lib/ir/ui/IrCommandTooltip.js +3 -2
  95. package/lib/ir/ui/IrCommandTooltip.js.map +1 -1
  96. package/lib/ir/ui/IrDocumentationDialog.d.ts +8 -1
  97. package/lib/ir/ui/IrDocumentationDialog.d.ts.map +1 -1
  98. package/lib/ir/ui/IrDocumentationDialog.js +30 -7
  99. package/lib/ir/ui/IrDocumentationDialog.js.map +1 -1
  100. package/lib/ir/ui/IrEditor.d.ts +3 -1
  101. package/lib/ir/ui/IrEditor.d.ts.map +1 -1
  102. package/lib/ir/ui/IrEditor.js +3 -20
  103. package/lib/ir/ui/IrEditor.js.map +1 -1
  104. package/lib/ir/ui/IrHeader.d.ts.map +1 -1
  105. package/lib/ir/ui/IrHeader.js +5 -1
  106. package/lib/ir/ui/IrHeader.js.map +1 -1
  107. package/lib/ir/ui/IrLogo.d.ts +11 -3
  108. package/lib/ir/ui/IrLogo.d.ts.map +1 -1
  109. package/lib/ir/ui/IrLogo.js +14 -5
  110. package/lib/ir/ui/IrLogo.js.map +1 -1
  111. package/lib/ir/ui/IrShell.d.ts.map +1 -1
  112. package/lib/ir/ui/IrShell.js +23 -56
  113. package/lib/ir/ui/IrShell.js.map +1 -1
  114. package/lib/ir/ui/IrStatusBar.d.ts +3 -2
  115. package/lib/ir/ui/IrStatusBar.d.ts.map +1 -1
  116. package/lib/ir/ui/IrStatusBar.js +14 -9
  117. package/lib/ir/ui/IrStatusBar.js.map +1 -1
  118. package/lib/ir/ui/IrToolbar.d.ts +3 -0
  119. package/lib/ir/ui/IrToolbar.d.ts.map +1 -1
  120. package/lib/ir/ui/IrToolbar.js +10 -3
  121. package/lib/ir/ui/IrToolbar.js.map +1 -1
  122. package/lib/ir/ui/IrTraces.d.ts +4 -1
  123. package/lib/ir/ui/IrTraces.d.ts.map +1 -1
  124. package/lib/ir/ui/IrTraces.js +2 -0
  125. package/lib/ir/ui/IrTraces.js.map +1 -1
  126. package/lib/ir/ui/RamanEditor.d.ts +46 -0
  127. package/lib/ir/ui/RamanEditor.d.ts.map +1 -0
  128. package/lib/ir/ui/RamanEditor.js +17 -0
  129. package/lib/ir/ui/RamanEditor.js.map +1 -0
  130. package/lib/ir/ui/SpectraPanel.d.ts.map +1 -1
  131. package/lib/ir/ui/SpectraPanel.js +2 -2
  132. package/lib/ir/ui/SpectraPanel.js.map +1 -1
  133. package/lib/ir/ui/SpectrumRow.d.ts +7 -0
  134. package/lib/ir/ui/SpectrumRow.d.ts.map +1 -1
  135. package/lib/ir/ui/SpectrumRow.js +4 -5
  136. package/lib/ir/ui/SpectrumRow.js.map +1 -1
  137. package/lib/ir/ui/VibrationalEditor.d.ts +48 -0
  138. package/lib/ir/ui/VibrationalEditor.d.ts.map +1 -0
  139. package/lib/ir/ui/VibrationalEditor.js +31 -0
  140. package/lib/ir/ui/VibrationalEditor.js.map +1 -0
  141. package/lib/ir/ui/bandsTsv.d.ts +19 -0
  142. package/lib/ir/ui/bandsTsv.d.ts.map +1 -0
  143. package/lib/ir/ui/bandsTsv.js +38 -0
  144. package/lib/ir/ui/bandsTsv.js.map +1 -0
  145. package/lib/ir/ui/irChartProps.d.ts +14 -4
  146. package/lib/ir/ui/irChartProps.d.ts.map +1 -1
  147. package/lib/ir/ui/irChartProps.js +3 -2
  148. package/lib/ir/ui/irChartProps.js.map +1 -1
  149. package/lib/ir/ui/irCommandContext.d.ts +8 -0
  150. package/lib/ir/ui/irCommandContext.d.ts.map +1 -1
  151. package/lib/ir/ui/irCommandContext.js +14 -3
  152. package/lib/ir/ui/irCommandContext.js.map +1 -1
  153. package/lib/ir/ui/useIrEditor.d.ts +3 -3
  154. package/lib/ir/ui/useIrEditor.d.ts.map +1 -1
  155. package/lib/ir/ui/useIrEditor.js +13 -4
  156. package/lib/ir/ui/useIrEditor.js.map +1 -1
  157. package/lib/ir/ui/useIrHandle.d.ts +14 -0
  158. package/lib/ir/ui/useIrHandle.d.ts.map +1 -0
  159. package/lib/ir/ui/useIrHandle.js +39 -0
  160. package/lib/ir/ui/useIrHandle.js.map +1 -0
  161. package/lib/ir/ui/useIrText.d.ts +40 -0
  162. package/lib/ir/ui/useIrText.d.ts.map +1 -0
  163. package/lib/ir/ui/useIrText.js +118 -0
  164. package/lib/ir/ui/useIrText.js.map +1 -0
  165. package/lib/ir/ui/useIrZoom.d.ts +7 -0
  166. package/lib/ir/ui/useIrZoom.d.ts.map +1 -1
  167. package/lib/ir/ui/useIrZoom.js +5 -4
  168. package/lib/ir/ui/useIrZoom.js.map +1 -1
  169. package/lib/ir/ui/useValueAxisZoom.d.ts +20 -0
  170. package/lib/ir/ui/useValueAxisZoom.d.ts.map +1 -0
  171. package/lib/ir/ui/useValueAxisZoom.js +54 -0
  172. package/lib/ir/ui/useValueAxisZoom.js.map +1 -0
  173. package/lib/ir.d.ts +3 -0
  174. package/lib/ir.d.ts.map +1 -1
  175. package/lib/ir.js +3 -0
  176. package/lib/ir.js.map +1 -1
  177. package/lib/locales/de.json +20 -1
  178. package/lib/locales/en.json +20 -1
  179. package/lib/locales/es.json +20 -1
  180. package/lib/locales/fr.json +20 -1
  181. package/lib/locales/it.json +20 -1
  182. package/lib/raman.d.ts +16 -0
  183. package/lib/raman.d.ts.map +1 -0
  184. package/lib/raman.js +12 -0
  185. package/lib/raman.js.map +1 -0
  186. package/package.json +2 -1
  187. package/src/ir/core/analysisSpectra.ts +26 -10
  188. package/src/ir/core/bandLabelPlan.ts +21 -10
  189. package/src/ir/core/index.ts +25 -5
  190. package/src/ir/core/irBand.ts +52 -14
  191. package/src/ir/core/irCommands.ts +15 -1
  192. package/src/ir/core/irDomain.ts +9 -7
  193. package/src/ir/core/irFormat.ts +39 -6
  194. package/src/ir/core/irMode.ts +42 -10
  195. package/src/ir/core/irReducer.ts +1 -49
  196. package/src/ir/core/irSpectrum.ts +59 -30
  197. package/src/ir/core/irState.ts +67 -2
  198. package/src/ir/core/irTechnique.ts +115 -0
  199. package/src/ir/core/irTechniqueCommands.ts +82 -0
  200. package/src/ir/core/pickBands.ts +63 -28
  201. package/src/ir/core/ramanBands.ts +105 -0
  202. package/src/ir/core/spectrumJcamp.ts +65 -16
  203. package/src/ir/core/toIrSpectrum.ts +20 -2
  204. package/src/ir/ui/BandRow.tsx +107 -0
  205. package/src/ir/ui/BandsPanel.tsx +32 -125
  206. package/src/ir/ui/IrAboutDialog.tsx +69 -28
  207. package/src/ir/ui/IrCanvas.tsx +2 -1
  208. package/src/ir/ui/IrChart.tsx +20 -24
  209. package/src/ir/ui/IrCommandProvider.tsx +10 -3
  210. package/src/ir/ui/IrCommandTooltip.tsx +11 -2
  211. package/src/ir/ui/IrDocumentationDialog.tsx +99 -55
  212. package/src/ir/ui/IrEditor.tsx +5 -36
  213. package/src/ir/ui/IrHeader.tsx +10 -3
  214. package/src/ir/ui/IrLogo.tsx +28 -9
  215. package/src/ir/ui/IrShell.tsx +27 -75
  216. package/src/ir/ui/IrStatusBar.tsx +17 -12
  217. package/src/ir/ui/IrToolbar.tsx +26 -15
  218. package/src/ir/ui/IrTraces.tsx +5 -1
  219. package/src/ir/ui/RamanEditor.tsx +53 -0
  220. package/src/ir/ui/SpectraPanel.tsx +2 -1
  221. package/src/ir/ui/SpectrumRow.tsx +14 -5
  222. package/src/ir/ui/VibrationalEditor.tsx +94 -0
  223. package/src/ir/ui/bandsTsv.ts +46 -0
  224. package/src/ir/ui/irChartProps.ts +14 -4
  225. package/src/ir/ui/irCommandContext.tsx +18 -3
  226. package/src/ir/ui/useIrEditor.ts +20 -8
  227. package/src/ir/ui/useIrHandle.ts +51 -0
  228. package/src/ir/ui/useIrText.ts +170 -0
  229. package/src/ir/ui/useIrZoom.ts +12 -3
  230. package/src/ir/ui/useValueAxisZoom.ts +67 -0
  231. package/src/ir.ts +3 -0
  232. package/src/locales/de.json +20 -1
  233. package/src/locales/en.json +20 -1
  234. package/src/locales/es.json +20 -1
  235. package/src/locales/fr.json +20 -1
  236. package/src/locales/it.json +20 -1
  237. package/src/raman.ts +19 -0
@@ -1,12 +1,24 @@
1
1
  import { Dialog, DialogBody } from '@blueprintjs/core';
2
2
 
3
+ import { Prose } from '../../i18n/ui/Prose.tsx';
4
+ import { useChromeT } from '../../i18n/ui/useT.ts';
5
+ import { irCommands } from '../core/irCommands.ts';
6
+ import type { IrTechnique } from '../core/irTechnique.ts';
7
+
3
8
  import { IrLogo } from './IrLogo.tsx';
9
+ import { useIrText } from './useIrText.ts';
4
10
 
5
11
  export interface IrAboutDialogProps {
6
12
  /** Whether the dialog is open. */
7
13
  isOpen: boolean;
8
14
  /** Close it. */
9
15
  onClose: () => void;
16
+ /**
17
+ * What the spectra were measured with, which decides what the viewer says it
18
+ * does and whom it credits for it.
19
+ * @default 'infrared'
20
+ */
21
+ technique?: IrTechnique;
10
22
  }
11
23
 
12
24
  /**
@@ -20,42 +32,63 @@ export interface IrAboutDialogProps {
20
32
  * @returns The dialog.
21
33
  */
22
34
  export function IrAboutDialog(props: IrAboutDialogProps) {
23
- const { isOpen, onClose } = props;
35
+ const { isOpen, onClose, technique = 'infrared' } = props;
36
+ const t = useChromeT();
37
+ const title = (useIrText(technique).command('about') ?? irCommands.about)
38
+ .title;
39
+ const raman = technique === 'raman';
24
40
 
25
41
  return (
26
42
  <Dialog
27
43
  isOpen={isOpen}
28
44
  onClose={onClose}
29
- title="About the infrared viewer"
30
- icon={<IrLogo size={20} />}
45
+ title={title}
46
+ icon={<IrLogo size={20} technique={technique} />}
31
47
  style={dialogStyle}
32
48
  >
33
49
  <DialogBody>
34
50
  <div style={brandStyle}>
35
- <IrLogo size={64} />
51
+ <IrLogo size={64} technique={technique} />
36
52
  <div>
37
- <p style={leadStyle}>react-cheminfo/ir</p>
38
- <p style={paragraphStyle}>
39
- Draws an infrared spectrum the way infrared is printed, reads it
40
- as absorbance or as percent transmittance, picks its bands and
41
- offers every functional group each band could be.
42
- </p>
53
+ <p style={leadStyle}>{DOORS[technique]}</p>
54
+ {raman ? (
55
+ <p style={paragraphStyle}>{t('ir.raman.aboutLead')}</p>
56
+ ) : (
57
+ <p style={paragraphStyle}>
58
+ Draws an infrared spectrum the way infrared is printed, reads it
59
+ as absorbance or as percent transmittance, picks its bands and
60
+ offers every functional group each band could be.
61
+ </p>
62
+ )}
43
63
  </div>
44
64
  </div>
45
65
 
46
66
  <h4 style={headingStyle}>Credits</h4>
47
67
  <ul style={listStyle}>
48
- <li>
49
- <strong>ir-spectrum</strong> (cheminfo, MIT) reads the JCAMP-DX and
50
- SPC files, derives the absorbance/transmittance pair, and picks the
51
- bands. This package deliberately does none of that arithmetic
52
- itself.
53
- </li>
54
- <li>
55
- <strong>common-spectrum</strong>, <strong>jcampconverter</strong>{' '}
56
- and <strong>spc-parser</strong> (cheminfo, MIT) are what it reads
57
- through.
58
- </li>
68
+ {raman ? (
69
+ <>
70
+ <li>
71
+ <Prose text={t('ir.raman.credit.picking')} />
72
+ </li>
73
+ <li>
74
+ <Prose text={t('ir.raman.credit.jcamp')} />
75
+ </li>
76
+ </>
77
+ ) : (
78
+ <>
79
+ <li>
80
+ <strong>ir-spectrum</strong> (cheminfo, MIT) reads the JCAMP-DX
81
+ and SPC files, derives the absorbance/transmittance pair, and
82
+ picks the bands. This package deliberately does none of that
83
+ arithmetic itself.
84
+ </li>
85
+ <li>
86
+ <strong>common-spectrum</strong>,{' '}
87
+ <strong>jcampconverter</strong> and <strong>spc-parser</strong>{' '}
88
+ (cheminfo, MIT) are what it reads through.
89
+ </li>
90
+ </>
91
+ )}
59
92
  <li>
60
93
  <strong>ml-spectra-processing</strong> (mljs, MIT) for the array
61
94
  work.
@@ -69,13 +102,15 @@ export function IrAboutDialog(props: IrAboutDialogProps) {
69
102
  <strong>react-science</strong> and <strong>BlueprintJS</strong>
70
103
  (zakodium, Palantir) for the shell this viewer is shaped like.
71
104
  </li>
72
- <li>
73
- The <strong>correlation table</strong> is the conventional teaching
74
- set of group frequencies, as any introductory spectroscopy text
75
- tabulates them. The ranges are deliberately the rounded, generous
76
- ones: narrowing them to look precise would rule out assignments that
77
- are genuinely possible.
78
- </li>
105
+ {raman ? null : (
106
+ <li>
107
+ The <strong>correlation table</strong> is the conventional
108
+ teaching set of group frequencies, as any introductory
109
+ spectroscopy text tabulates them. The ranges are deliberately the
110
+ rounded, generous ones: narrowing them to look precise would rule
111
+ out assignments that are genuinely possible.
112
+ </li>
113
+ )}
79
114
  <li>
80
115
  The <strong>colours</strong> are Okabe and Ito&apos;s
81
116
  colour-universal palette, so two traces stay distinguishable for a
@@ -87,6 +122,12 @@ export function IrAboutDialog(props: IrAboutDialogProps) {
87
122
  );
88
123
  }
89
124
 
125
+ /** The entry point each technique's viewer is imported from. */
126
+ const DOORS: Record<IrTechnique, string> = {
127
+ infrared: 'react-cheminfo/ir',
128
+ raman: 'react-cheminfo/raman',
129
+ };
130
+
90
131
  const dialogStyle = { width: 'min(680px, 92vw)' } as const;
91
132
 
92
133
  const brandStyle = {
@@ -54,7 +54,7 @@ export function IrCanvas(props: IrCanvasProps) {
54
54
  const { state, visibleSpectra, assigned } = useIrEditorState();
55
55
  const actions = useIrActions();
56
56
  const { domain, tool, selectedId } = state.view;
57
- const { mode, showAssignments, labelLimit } = state.settings;
57
+ const { technique, mode, showAssignments, labelLimit } = state.settings;
58
58
 
59
59
  const onDomainChange = useCallback(
60
60
  (next: IrDomain) => {
@@ -68,6 +68,7 @@ export function IrCanvas(props: IrCanvasProps) {
68
68
  <div ref={attachChart} id={chartId} style={chartStyle}>
69
69
  <IrChart
70
70
  spectra={visibleSpectra}
71
+ technique={technique}
71
72
  mode={mode}
72
73
  assigned={assigned}
73
74
  showAssignments={showAssignments}
@@ -9,14 +9,14 @@ import { chartSurfaceStyle } from '../../chart/ui/chartSurface.ts';
9
9
  import { useChartSize } from '../../chart/ui/useChartSize.ts';
10
10
  import type { AssignedBand } from '../core/assignBands.ts';
11
11
  import type { IrBand } from '../core/irBand.ts';
12
- import { boxZoomOnly, yAxisTitle } from '../core/irMode.ts';
13
- import type { IrMode } from '../core/irSpectrum.ts';
12
+ import { irModeFor } from '../core/irTechnique.ts';
14
13
 
15
14
  import { BandMarks } from './BandMarks.tsx';
16
15
  import { IrPointerTracker } from './IrPointerTracker.tsx';
17
16
  import { IrTraces } from './IrTraces.tsx';
18
17
  import type { IrChartProps } from './irChartProps.ts';
19
18
  import { useIrPointer } from './useIrPointer.ts';
19
+ import { useIrText } from './useIrText.ts';
20
20
  import { useIrZoom } from './useIrZoom.ts';
21
21
 
22
22
  /**
@@ -28,7 +28,8 @@ import { useIrZoom } from './useIrZoom.ts';
28
28
  * building the scale onto a reversed pixel range and nothing else: the data stays
29
29
  * in ascending wavenumbers, every window stays low end first, and no other piece
30
30
  * of arithmetic in either package has to know. That is the whole reason
31
- * `createScale` takes its range rather than deriving it.
31
+ * `createScale` takes its range rather than deriving it. A Raman spectrum is
32
+ * drawn the other way, low shifts at the left, by the same means.
32
33
  *
33
34
  * The axes go under the data, so a grid line is never read as a band. Only the
34
35
  * data band is clipped, so a zoomed trace stops at the plot edge while the
@@ -46,7 +47,8 @@ import { useIrZoom } from './useIrZoom.ts';
46
47
  export function IrChart(props: IrChartProps): ReactElement {
47
48
  const {
48
49
  spectra,
49
- mode = 'transmittance',
50
+ technique = 'infrared',
51
+ mode: asked,
50
52
  assigned = NO_BANDS,
51
53
  showAssignments = false,
52
54
  labelLimit,
@@ -61,6 +63,8 @@ export function IrChart(props: IrChartProps): ReactElement {
61
63
  children,
62
64
  } = props;
63
65
 
66
+ const mode = irModeFor(technique, asked);
67
+ const text = useIrText(technique);
64
68
  const [containerRef, measured] = useChartSize<HTMLDivElement>();
65
69
  const svgRef = useRef<SVGSVGElement | null>(null);
66
70
 
@@ -79,7 +83,15 @@ export function IrChart(props: IrChartProps): ReactElement {
79
83
 
80
84
  // The host's window goes *into* the zoom rather than over it, so a drag is
81
85
  // always measured against what is on screen.
82
- const zoom = useIrZoom({ spectra, mode, svgRef, plot, domain, drag });
86
+ const zoom = useIrZoom({
87
+ spectra,
88
+ technique,
89
+ mode,
90
+ svgRef,
91
+ plot,
92
+ domain,
93
+ drag,
94
+ });
83
95
 
84
96
  // The scales the zoom measured its gestures against — the x one running right
85
97
  // to left. Taken from the hook rather than built here, because two scales over
@@ -128,7 +140,7 @@ export function IrChart(props: IrChartProps): ReactElement {
128
140
  <svg
129
141
  ref={svgRef}
130
142
  role="img"
131
- aria-label={chartLabel(mode)}
143
+ aria-label={text.chart(mode)}
132
144
  width={frameWidth}
133
145
  height={frameHeight}
134
146
  viewBox={`0 0 ${frameWidth} ${frameHeight}`}
@@ -154,8 +166,8 @@ export function IrChart(props: IrChartProps): ReactElement {
154
166
  yDomain={shown.y}
155
167
  xScale={xScale}
156
168
  yScale={yScale}
157
- xTitle="wavenumber (cm⁻¹)"
158
- yTitle={yAxisTitle(mode)}
169
+ xTitle={text.xTitle}
170
+ yTitle={text.yTitle(mode)}
159
171
  />
160
172
 
161
173
  <g clipPath={`url(#${clipId})`}>
@@ -192,22 +204,6 @@ export function IrChart(props: IrChartProps): ReactElement {
192
204
  );
193
205
  }
194
206
 
195
- /**
196
- * What the chart is, and what can be done to it, for whoever cannot see it.
197
- *
198
- * The gestures differ by mode, so the sentence does too — a label promising the
199
- * wheel to a reader who cannot watch it fail to do anything is worse than no
200
- * label at all.
201
- * @param mode - Which value axis is being drawn.
202
- * @returns The label.
203
- */
204
- function chartLabel(mode: IrMode): string {
205
- const axis = `Infrared spectrum read as ${yAxisTitle(mode)}, wavenumber running from high at the left to low at the right.`;
206
- return boxZoomOnly(mode)
207
- ? `${axis} Drag a rectangle over it to zoom to that rectangle, and double click to fit everything again.`
208
- : `${axis} Drag across it to zoom the wavenumber axis, drag past the baseline to take the value axis with it, turn the wheel to scale the value axis, and double click to fit everything again.`;
209
- }
210
-
211
207
  /** What a chart nobody has picked any bands for marks. */
212
208
  const NO_BANDS: readonly AssignedBand[] = Object.freeze([]);
213
209
 
@@ -2,6 +2,7 @@ import type { ReactNode } from 'react';
2
2
  import { useMemo } from 'react';
3
3
 
4
4
  import type { IrCommandHandlers } from '../core/irCommands.ts';
5
+ import type { IrTechnique } from '../core/irTechnique.ts';
5
6
 
6
7
  import type { IrCommandContextValue } from './irCommandContext.tsx';
7
8
  import { commandContext } from './irCommandContext.tsx';
@@ -9,6 +10,12 @@ import { commandContext } from './irCommandContext.tsx';
9
10
  export interface IrCommandProviderProps {
10
11
  /** What each command does. */
11
12
  handlers: IrCommandHandlers;
13
+ /**
14
+ * What the spectra were measured with, which decides how each command is
15
+ * worded in its tooltip and its label.
16
+ * @default 'infrared'
17
+ */
18
+ technique?: IrTechnique;
12
19
  /** The viewer. */
13
20
  children: ReactNode;
14
21
  }
@@ -19,11 +26,11 @@ export interface IrCommandProviderProps {
19
26
  * @returns The provider.
20
27
  */
21
28
  export function IrCommandProvider(props: IrCommandProviderProps) {
22
- const { handlers, children } = props;
29
+ const { handlers, technique = 'infrared', children } = props;
23
30
 
24
31
  const value = useMemo<IrCommandContextValue>(
25
- () => ({ handlers, run: (id) => handlers[id]?.() }),
26
- [handlers],
32
+ () => ({ handlers, technique, run: (id) => handlers[id]?.() }),
33
+ [handlers, technique],
27
34
  );
28
35
 
29
36
  return (
@@ -2,10 +2,19 @@ import { TooltipHelpContent } from 'react-science/ui';
2
2
 
3
3
  import type { IrCommand, IrCommandId } from '../core/irCommands.ts';
4
4
  import { irCommands } from '../core/irCommands.ts';
5
+ import type { IrTechnique } from '../core/irTechnique.ts';
6
+
7
+ import { useIrText } from './useIrText.ts';
5
8
 
6
9
  export interface IrCommandTooltipProps {
7
10
  /** Which command the tooltip is about. */
8
11
  id: IrCommandId;
12
+ /**
13
+ * What the spectra were measured with, which decides how the command is
14
+ * worded.
15
+ * @default 'infrared'
16
+ */
17
+ technique?: IrTechnique;
9
18
  }
10
19
 
11
20
  /**
@@ -18,8 +27,8 @@ export interface IrCommandTooltipProps {
18
27
  * @returns The tooltip's content.
19
28
  */
20
29
  export function IrCommandTooltip(props: IrCommandTooltipProps) {
21
- const { id } = props;
22
- const entry = irCommands[id] as IrCommand;
30
+ const { id, technique = 'infrared' } = props;
31
+ const entry: IrCommand = useIrText(technique).command(id) ?? irCommands[id];
23
32
  const shortcuts = entry.shortcut?.label ?? entry.shortcut?.keys;
24
33
 
25
34
  return (
@@ -1,17 +1,27 @@
1
1
  import { Dialog, DialogBody } from '@blueprintjs/core';
2
2
 
3
+ import { Prose } from '../../i18n/ui/Prose.tsx';
4
+ import { useChromeT } from '../../i18n/ui/useT.ts';
3
5
  import { TOKEN } from '../../tokens/core/familyTokens.ts';
4
6
  import type { IrCommand, IrCommandId } from '../core/irCommands.ts';
5
- import { irCommands } from '../core/irCommands.ts';
6
7
  import { IR_MODE_RULES } from '../core/irMode.ts';
8
+ import type { IrTechnique } from '../core/irTechnique.ts';
9
+ import { irCommandsFor } from '../core/irTechniqueCommands.ts';
7
10
 
8
11
  import { IrLogo } from './IrLogo.tsx';
12
+ import { useIrText } from './useIrText.ts';
9
13
 
10
14
  export interface IrDocumentationDialogProps {
11
15
  /** Whether the dialog is open. */
12
16
  isOpen: boolean;
13
17
  /** Close it. */
14
18
  onClose: () => void;
19
+ /**
20
+ * What the spectra were measured with, which decides what the guide says:
21
+ * only what is true of the technique, and only the commands it offers.
22
+ * @default 'infrared'
23
+ */
24
+ technique?: IrTechnique;
15
25
  }
16
26
 
17
27
  /**
@@ -19,73 +29,36 @@ export interface IrDocumentationDialogProps {
19
29
  *
20
30
  * In the component rather than on a site, so there is nowhere to leave for and
21
31
  * nothing to keep in step: every key in the table below is read out of the same
22
- * `irCommands` the toolbar and the key handler read, so a shortcut cannot be
32
+ * command table the toolbar and the key handler read, so a shortcut cannot be
23
33
  * documented as one thing and bound as another.
24
34
  * @param props - Component props.
25
35
  * @returns The dialog.
26
36
  */
27
37
  export function IrDocumentationDialog(props: IrDocumentationDialogProps) {
28
- const { isOpen, onClose } = props;
38
+ const { isOpen, onClose, technique = 'infrared' } = props;
39
+ const text = useIrText(technique);
40
+ const ids = Object.keys(irCommandsFor(technique)) as IrCommandId[];
29
41
 
30
42
  return (
31
43
  <Dialog
32
44
  isOpen={isOpen}
33
45
  onClose={onClose}
34
- title="Using the infrared viewer"
35
- icon={<IrLogo size={20} />}
46
+ title={text.documentation}
47
+ icon={<IrLogo size={20} technique={technique} />}
36
48
  style={dialogStyle}
37
49
  >
38
50
  <DialogBody>
39
- <h4 style={headingStyle}>Opening a spectrum</h4>
40
- <p style={paragraphStyle}>
41
- JCAMP-DX (<code>.jdx</code>, <code>.dx</code>) and Thermo Galactic SPC
42
- (<code>.spc</code>) are read. A file holding several blocks — a sample
43
- beside its background, or an infrared spectrum beside a Raman one —
44
- gives one spectrum per infrared block; the others are left to their
45
- own viewers. Two columns of numbers are not read yet.
46
- </p>
47
-
48
- <h4 style={headingStyle}>The axis runs backwards</h4>
49
- <p style={paragraphStyle}>
50
- Wavenumber decreases to the right, from 4000 cm⁻¹ down to 400, which
51
- is how infrared spectra have been printed since the instruments
52
- scanned that way. Every window is still stated low end first.
53
- </p>
54
-
55
- <h4 style={headingStyle}>Absorbance or transmittance</h4>
56
- <p style={paragraphStyle}>
57
- The same measurement, read the other way up — the file carries both,
58
- whichever it was written in. In{' '}
59
- <strong>{IR_MODE_RULES.transmittance.title}</strong> the bands hang
60
- down from a baseline near 100; in{' '}
61
- <strong>{IR_MODE_RULES.absorbance.title}</strong> they stand up out of
62
- zero. The labels and the marks follow, so the pair reads the same way
63
- up in either.
64
- </p>
65
-
66
- <h4 style={headingStyle}>Reading the bands</h4>
67
- <p style={paragraphStyle}>
68
- The bands of the <em>selected</em> spectrum are picked, marked on the
69
- chart, and listed in the bands panel with{' '}
70
- <strong>every vibration whose range contains them</strong> — narrowest
71
- claim first. That is deliberate: a band at 1715 cm⁻¹ really is a
72
- ketone, an aldehyde and a carboxylic acid until something else decides
73
- between them, and the note on each candidate is what tells them apart.
74
- Hovering a row marks the band on the chart, and hovering the chart
75
- lights the row.
76
- </p>
77
- <p style={paragraphStyle}>
78
- A band is reported at the sampled point it peaked on, so on a 4 cm⁻¹
79
- grid a carbonyl centred at 1710 reads 1708 or 1712. Do not quote one
80
- as though it were measured to the wavenumber.
81
- </p>
51
+ {technique === 'raman' ? <RamanGuide /> : <InfraredGuide />}
82
52
 
83
53
  <h4 style={headingStyle}>Gestures and keys</h4>
84
54
  <table style={tableStyle}>
85
55
  <tbody>
86
- {(Object.keys(irCommands) as IrCommandId[]).map((id) => (
87
- <CommandRow key={id} id={id} />
88
- ))}
56
+ {ids.map((id) => {
57
+ const entry = text.command(id);
58
+ return entry === undefined ? null : (
59
+ <CommandRow key={id} entry={entry} />
60
+ );
61
+ })}
89
62
  </tbody>
90
63
  </table>
91
64
  </DialogBody>
@@ -93,9 +66,81 @@ export function IrDocumentationDialog(props: IrDocumentationDialogProps) {
93
66
  );
94
67
  }
95
68
 
69
+ /**
70
+ * What is true of reading an infrared spectrum here.
71
+ * @returns The sections.
72
+ */
73
+ function InfraredGuide() {
74
+ return (
75
+ <>
76
+ <h4 style={headingStyle}>Opening a spectrum</h4>
77
+ <p style={paragraphStyle}>
78
+ JCAMP-DX (<code>.jdx</code>, <code>.dx</code>) and Thermo Galactic SPC (
79
+ <code>.spc</code>) are read. A file holding several blocks — a sample
80
+ beside its background, or an infrared spectrum beside a Raman one —
81
+ gives one spectrum per infrared block; the others are left to their own
82
+ viewers. Two columns of numbers are not read yet.
83
+ </p>
84
+
85
+ <h4 style={headingStyle}>The axis runs backwards</h4>
86
+ <p style={paragraphStyle}>
87
+ Wavenumber decreases to the right, from 4000 cm⁻¹ down to 400, which is
88
+ how infrared spectra have been printed since the instruments scanned
89
+ that way. Every window is still stated low end first.
90
+ </p>
91
+
92
+ <h4 style={headingStyle}>Absorbance or transmittance</h4>
93
+ <p style={paragraphStyle}>
94
+ The same measurement, read the other way up — the file carries both,
95
+ whichever it was written in. In{' '}
96
+ <strong>{IR_MODE_RULES.transmittance.title}</strong> the bands hang down
97
+ from a baseline near 100; in{' '}
98
+ <strong>{IR_MODE_RULES.absorbance.title}</strong> they stand up out of
99
+ zero. The labels and the marks follow, so the pair reads the same way up
100
+ in either.
101
+ </p>
102
+
103
+ <h4 style={headingStyle}>Reading the bands</h4>
104
+ <p style={paragraphStyle}>
105
+ The bands of the <em>selected</em> spectrum are picked, marked on the
106
+ chart, and listed in the bands panel with{' '}
107
+ <strong>every vibration whose range contains them</strong> — narrowest
108
+ claim first. That is deliberate: a band at 1715 cm⁻¹ really is a ketone,
109
+ an aldehyde and a carboxylic acid until something else decides between
110
+ them, and the note on each candidate is what tells them apart. Hovering
111
+ a row marks the band on the chart, and hovering the chart lights the
112
+ row.
113
+ </p>
114
+ <p style={paragraphStyle}>
115
+ A band is reported at the sampled point it peaked on, so on a 4 cm⁻¹
116
+ grid a carbonyl centred at 1710 reads 1708 or 1712. Do not quote one as
117
+ though it were measured to the wavenumber.
118
+ </p>
119
+ </>
120
+ );
121
+ }
122
+
123
+ /**
124
+ * What is true of reading a Raman spectrum here: only the bands, since it has
125
+ * one value axis, runs the usual way, and is not assigned.
126
+ * @returns The section.
127
+ */
128
+ function RamanGuide() {
129
+ const t = useChromeT();
130
+ return (
131
+ <>
132
+ <h4 style={headingStyle}>Reading the bands</h4>
133
+ <p style={paragraphStyle}>
134
+ <Prose text={t('ir.raman.doc.bands')} />
135
+ </p>
136
+ <p style={paragraphStyle}>{t('ir.raman.doc.sampled')}</p>
137
+ </>
138
+ );
139
+ }
140
+
96
141
  interface CommandRowProps {
97
- /** Which command the row is about. */
98
- id: IrCommandId;
142
+ /** The command, as the viewer words it. */
143
+ entry: IrCommand;
99
144
  }
100
145
 
101
146
  /**
@@ -104,8 +149,7 @@ interface CommandRowProps {
104
149
  * @returns The row.
105
150
  */
106
151
  function CommandRow(props: CommandRowProps) {
107
- const { id } = props;
108
- const entry = irCommands[id] as IrCommand;
152
+ const { entry } = props;
109
153
  const keys = entry.shortcut?.label ?? entry.shortcut?.keys;
110
154
 
111
155
  return (
@@ -1,13 +1,10 @@
1
1
  import type { Ref } from 'react';
2
- import { RootLayout } from 'react-science/ui';
3
2
 
4
3
  import type { IrEditorHandle } from '../core/irEditorApi.ts';
5
4
  import type { IrSidePanelId } from '../core/irSidePanels.ts';
6
5
  import type { IrMode, IrSpectrum } from '../core/irSpectrum.ts';
7
6
 
8
- import { IrShell } from './IrShell.tsx';
9
- import { IrStateProvider } from './IrStateProvider.tsx';
10
- import { useIrEditor } from './useIrEditor.ts';
7
+ import { VibrationalEditor } from './VibrationalEditor.tsx';
11
8
 
12
9
  export interface IrEditorProps {
13
10
  /**
@@ -29,7 +26,8 @@ export interface IrEditorProps {
29
26
  */
30
27
  onChange?: (spectra: IrSpectrum[]) => void;
31
28
  /**
32
- * Which value axis to open in.
29
+ * Which value axis to open in: transmittance or absorbance. Intensity, which
30
+ * infrared does not offer, opens transmittance instead.
33
31
  * @default 'transmittance'
34
32
  */
35
33
  mode?: IrMode;
@@ -49,6 +47,7 @@ export interface IrEditorProps {
49
47
  /**
50
48
  * An infrared spectrum viewer: a header across the top, the chart in the middle,
51
49
  * the tools down the left, and the panels that interrogate it down the right.
50
+ * `RamanEditor`, from `react-cheminfo/raman`, is the same viewer for Raman.
52
51
  *
53
52
  * The same shape as the mass viewer, deliberately — a page may well hold both,
54
53
  * and a chemist who has learned one should not have to learn the other. The chart
@@ -65,35 +64,5 @@ export interface IrEditorProps {
65
64
  * @returns The viewer.
66
65
  */
67
66
  export function IrEditor(props: IrEditorProps) {
68
- const { data = NO_SPECTRA, onChange, mode, defaultPanelIds, ref } = props;
69
-
70
- const editor = useIrEditor({
71
- spectra: data,
72
- settings: mode === undefined ? undefined : { mode },
73
- panelIds: defaultPanelIds,
74
- onChange,
75
- });
76
-
77
- return (
78
- <IrStateProvider editor={editor}>
79
- {/* `react-science`'s own root: it holds the element the browser is asked
80
- to show full screen, points Blueprint's portals at that element so
81
- dialogs and tooltips are not left behind in `document.body`, and paints
82
- the backdrop white. Above the shell rather than inside it, so the shell
83
- can ask whether it is full screen and offer the way out. */}
84
- <RootLayout style={rootLayoutStyle}>
85
- <IrShell handle={ref} />
86
- </RootLayout>
87
- </IrStateProvider>
88
- );
67
+ return <VibrationalEditor technique="infrared" {...props} />;
89
68
  }
90
-
91
- /**
92
- * The viewer fills what it is given, and its own children scroll rather than
93
- * push: `react-science` lays its root out as a column of full width and height,
94
- * and a flex column with no `minHeight` grows past its parent instead.
95
- */
96
- const rootLayoutStyle = { minHeight: 0 } as const;
97
-
98
- /** What a viewer opens on when it is handed nothing, kept stable for the memo. */
99
- const NO_SPECTRA: IrSpectrum[] = [];
@@ -2,6 +2,8 @@ import { Header, Toolbar, useFullscreen } from 'react-science/ui';
2
2
 
3
3
  import { IrLogo } from './IrLogo.tsx';
4
4
  import { useIrCommandProps } from './irCommandContext.tsx';
5
+ import { useIrEditorState } from './irStateContext.ts';
6
+ import { useIrText } from './useIrText.ts';
5
7
 
6
8
  /**
7
9
  * The bar across the top: the mark on the left, the viewer on the right.
@@ -17,13 +19,18 @@ import { useIrCommandProps } from './irCommandContext.tsx';
17
19
  export function IrHeader() {
18
20
  const command = useIrCommandProps();
19
21
  const { isFullScreen } = useFullscreen();
22
+ const { technique } = useIrEditorState().state.settings;
23
+ const text = useIrText(technique);
20
24
 
21
25
  return (
22
26
  <Header>
23
- <Toolbar aria-label="Infrared spectrum viewer">
24
- <Toolbar.Item icon={<IrLogo size={16} />} {...command('about')} />
27
+ <Toolbar aria-label={text.viewer}>
28
+ <Toolbar.Item
29
+ icon={<IrLogo size={16} technique={technique} />}
30
+ {...command('about')}
31
+ />
25
32
  </Toolbar>
26
- <Toolbar aria-label="Infrared spectrum viewer help">
33
+ <Toolbar aria-label={text.viewerHelp}>
27
34
  <Toolbar.Item icon="help" {...command('documentation')} />
28
35
  {/* Always the last thing in the bar, hard against the right edge: the
29
36
  corner a window is made bigger from is the corner it is looked for