react-cheminfo 0.33.0 → 0.35.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 (248) hide show
  1. package/README.md +28 -28
  2. package/lib/about/core/about.d.ts +1 -30
  3. package/lib/about/core/about.d.ts.map +1 -1
  4. package/lib/about/core/about.js +0 -16
  5. package/lib/about/core/about.js.map +1 -1
  6. package/lib/about/core/index.d.ts +0 -1
  7. package/lib/about/core/index.d.ts.map +1 -1
  8. package/lib/about/core/index.js +0 -1
  9. package/lib/about/core/index.js.map +1 -1
  10. package/lib/about/ui/AboutBuild.d.ts +2 -5
  11. package/lib/about/ui/AboutBuild.d.ts.map +1 -1
  12. package/lib/about/ui/AboutBuild.js +7 -19
  13. package/lib/about/ui/AboutBuild.js.map +1 -1
  14. package/lib/about/ui/AboutPage.d.ts +2 -2
  15. package/lib/about/ui/AboutPage.d.ts.map +1 -1
  16. package/lib/about/ui/AboutPage.js +3 -14
  17. package/lib/about/ui/AboutPage.js.map +1 -1
  18. package/lib/about/ui/AboutVersion.d.ts +0 -4
  19. package/lib/about/ui/AboutVersion.d.ts.map +1 -1
  20. package/lib/about/ui/AboutVersion.js +3 -31
  21. package/lib/about/ui/AboutVersion.js.map +1 -1
  22. package/lib/axis/core/axisMarks.d.ts +54 -0
  23. package/lib/axis/core/axisMarks.d.ts.map +1 -0
  24. package/lib/axis/core/axisMarks.js +69 -0
  25. package/lib/axis/core/axisMarks.js.map +1 -0
  26. package/lib/axis/core/axisScale.d.ts +31 -0
  27. package/lib/axis/core/axisScale.d.ts.map +1 -0
  28. package/lib/axis/core/axisScale.js +31 -0
  29. package/lib/axis/core/axisScale.js.map +1 -0
  30. package/lib/axis/core/index.d.ts +16 -0
  31. package/lib/axis/core/index.d.ts.map +1 -0
  32. package/lib/axis/core/index.js +13 -0
  33. package/lib/axis/core/index.js.map +1 -0
  34. package/lib/axis/core/logAxisBounds.d.ts +78 -0
  35. package/lib/axis/core/logAxisBounds.d.ts.map +1 -0
  36. package/lib/axis/core/logAxisBounds.js +129 -0
  37. package/lib/axis/core/logAxisBounds.js.map +1 -0
  38. package/lib/axis/ui/AxisScaleControl.d.ts +66 -0
  39. package/lib/axis/ui/AxisScaleControl.d.ts.map +1 -0
  40. package/lib/axis/ui/AxisScaleControl.js +26 -0
  41. package/lib/axis/ui/AxisScaleControl.js.map +1 -0
  42. package/lib/axis/ui/index.d.ts +6 -0
  43. package/lib/axis/ui/index.d.ts.map +1 -0
  44. package/lib/axis/ui/index.js +5 -0
  45. package/lib/axis/ui/index.js.map +1 -0
  46. package/lib/core.d.ts +1 -0
  47. package/lib/core.d.ts.map +1 -1
  48. package/lib/core.js +1 -0
  49. package/lib/core.js.map +1 -1
  50. package/lib/delimited/core/index.d.ts +2 -0
  51. package/lib/delimited/core/index.d.ts.map +1 -1
  52. package/lib/delimited/core/index.js +1 -0
  53. package/lib/delimited/core/index.js.map +1 -1
  54. package/lib/delimited/core/tableRows.d.ts +49 -0
  55. package/lib/delimited/core/tableRows.d.ts.map +1 -0
  56. package/lib/delimited/core/tableRows.js +63 -0
  57. package/lib/delimited/core/tableRows.js.map +1 -0
  58. package/lib/delimited/ui/DelimitedTextPanel.d.ts +9 -0
  59. package/lib/delimited/ui/DelimitedTextPanel.d.ts.map +1 -1
  60. package/lib/delimited/ui/DelimitedTextPanel.js +3 -2
  61. package/lib/delimited/ui/DelimitedTextPanel.js.map +1 -1
  62. package/lib/delimited/ui/TableDataButton.d.ts +96 -0
  63. package/lib/delimited/ui/TableDataButton.d.ts.map +1 -0
  64. package/lib/delimited/ui/TableDataButton.js +39 -0
  65. package/lib/delimited/ui/TableDataButton.js.map +1 -0
  66. package/lib/delimited/ui/index.d.ts +2 -0
  67. package/lib/delimited/ui/index.d.ts.map +1 -1
  68. package/lib/delimited/ui/index.js +1 -0
  69. package/lib/delimited/ui/index.js.map +1 -1
  70. package/lib/download/core/index.d.ts +0 -5
  71. package/lib/download/core/index.d.ts.map +1 -1
  72. package/lib/download/core/index.js +0 -3
  73. package/lib/download/core/index.js.map +1 -1
  74. package/lib/download/ui/FigureDownload.d.ts +4 -55
  75. package/lib/download/ui/FigureDownload.d.ts.map +1 -1
  76. package/lib/download/ui/FigureDownload.js +6 -66
  77. package/lib/download/ui/FigureDownload.js.map +1 -1
  78. package/lib/download/ui/FigureDownloadPanel.d.ts +16 -2
  79. package/lib/download/ui/FigureDownloadPanel.d.ts.map +1 -1
  80. package/lib/download/ui/FigureDownloadPanel.js +11 -30
  81. package/lib/download/ui/FigureDownloadPanel.js.map +1 -1
  82. package/lib/download/ui/figureDownloadHint.d.ts +30 -0
  83. package/lib/download/ui/figureDownloadHint.d.ts.map +1 -0
  84. package/lib/download/ui/figureDownloadHint.js +33 -0
  85. package/lib/download/ui/figureDownloadHint.js.map +1 -0
  86. package/lib/download/ui/index.d.ts +3 -10
  87. package/lib/download/ui/index.d.ts.map +1 -1
  88. package/lib/download/ui/index.js +1 -5
  89. package/lib/download/ui/index.js.map +1 -1
  90. package/lib/download/ui/useFigureActions.d.ts +50 -0
  91. package/lib/download/ui/useFigureActions.d.ts.map +1 -0
  92. package/lib/download/ui/useFigureActions.js +58 -0
  93. package/lib/download/ui/useFigureActions.js.map +1 -0
  94. package/lib/download/ui/useFigureDownload.d.ts +85 -0
  95. package/lib/download/ui/useFigureDownload.d.ts.map +1 -0
  96. package/lib/download/ui/useFigureDownload.js +75 -0
  97. package/lib/download/ui/useFigureDownload.js.map +1 -0
  98. package/lib/ecosystem/core/sites.d.ts.map +1 -1
  99. package/lib/ecosystem/core/sites.js +0 -40
  100. package/lib/ecosystem/core/sites.js.map +1 -1
  101. package/lib/ecosystem/core/types.d.ts +0 -10
  102. package/lib/ecosystem/core/types.d.ts.map +1 -1
  103. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  104. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  105. package/lib/ir/core/irCommands.d.ts +2 -2
  106. package/lib/ir/core/irCommands.js +2 -2
  107. package/lib/ir/core/irCommands.js.map +1 -1
  108. package/lib/ir/ui/IrAboutDialog.d.ts.map +1 -1
  109. package/lib/ir/ui/IrAboutDialog.js +1 -1
  110. package/lib/ir/ui/IrAboutDialog.js.map +1 -1
  111. package/lib/ir/ui/IrCanvas.d.ts +6 -0
  112. package/lib/ir/ui/IrCanvas.d.ts.map +1 -1
  113. package/lib/ir/ui/IrCanvas.js +2 -2
  114. package/lib/ir/ui/IrCanvas.js.map +1 -1
  115. package/lib/ir/ui/IrShell.d.ts.map +1 -1
  116. package/lib/ir/ui/IrShell.js +16 -11
  117. package/lib/ir/ui/IrShell.js.map +1 -1
  118. package/lib/ir/ui/IrToolbar.d.ts +11 -1
  119. package/lib/ir/ui/IrToolbar.d.ts.map +1 -1
  120. package/lib/ir/ui/IrToolbar.js +12 -2
  121. package/lib/ir/ui/IrToolbar.js.map +1 -1
  122. package/lib/ir/ui/index.d.ts +1 -0
  123. package/lib/ir/ui/index.d.ts.map +1 -1
  124. package/lib/ir/ui/index.js.map +1 -1
  125. package/lib/locales/de.json +8 -4
  126. package/lib/locales/en.json +8 -4
  127. package/lib/locales/es.json +8 -4
  128. package/lib/locales/fr.json +8 -4
  129. package/lib/locales/it.json +8 -4
  130. package/lib/overlay/ui/OverlayPanel.d.ts +6 -0
  131. package/lib/overlay/ui/OverlayPanel.d.ts.map +1 -1
  132. package/lib/overlay/ui/OverlayPanel.js +2 -2
  133. package/lib/overlay/ui/OverlayPanel.js.map +1 -1
  134. package/lib/overlay/ui/overlayPanelStyles.d.ts +2 -1
  135. package/lib/overlay/ui/overlayPanelStyles.d.ts.map +1 -1
  136. package/lib/overlay/ui/overlayPanelStyles.js +3 -1
  137. package/lib/overlay/ui/overlayPanelStyles.js.map +1 -1
  138. package/lib/periodic/core/index.d.ts +1 -1
  139. package/lib/periodic/core/index.d.ts.map +1 -1
  140. package/lib/periodic/core/index.js +1 -1
  141. package/lib/periodic/core/index.js.map +1 -1
  142. package/lib/periodic/core/layout.d.ts +18 -0
  143. package/lib/periodic/core/layout.d.ts.map +1 -1
  144. package/lib/periodic/core/layout.js +9 -0
  145. package/lib/periodic/core/layout.js.map +1 -1
  146. package/lib/periodic/ui/ElementCell.d.ts +0 -6
  147. package/lib/periodic/ui/ElementCell.d.ts.map +1 -1
  148. package/lib/periodic/ui/ElementCell.js +35 -19
  149. package/lib/periodic/ui/ElementCell.js.map +1 -1
  150. package/lib/periodic/ui/PeriodicTable.d.ts +12 -1
  151. package/lib/periodic/ui/PeriodicTable.d.ts.map +1 -1
  152. package/lib/periodic/ui/PeriodicTable.js +34 -15
  153. package/lib/periodic/ui/PeriodicTable.js.map +1 -1
  154. package/lib/ui.d.ts +1 -0
  155. package/lib/ui.d.ts.map +1 -1
  156. package/lib/ui.js +1 -0
  157. package/lib/ui.js.map +1 -1
  158. package/package.json +1 -1
  159. package/src/about/core/about.ts +1 -51
  160. package/src/about/core/index.ts +0 -1
  161. package/src/about/ui/AboutBuild.tsx +8 -37
  162. package/src/about/ui/AboutPage.tsx +8 -64
  163. package/src/about/ui/AboutVersion.tsx +5 -45
  164. package/src/axis/core/axisMarks.ts +114 -0
  165. package/src/axis/core/axisScale.ts +41 -0
  166. package/src/axis/core/index.ts +20 -0
  167. package/src/axis/core/logAxisBounds.ts +198 -0
  168. package/src/axis/ui/AxisScaleControl.tsx +103 -0
  169. package/src/axis/ui/index.ts +9 -0
  170. package/src/core.ts +1 -0
  171. package/src/delimited/core/index.ts +2 -0
  172. package/src/delimited/core/tableRows.ts +93 -0
  173. package/src/delimited/ui/DelimitedTextPanel.tsx +25 -9
  174. package/src/delimited/ui/TableDataButton.tsx +162 -0
  175. package/src/delimited/ui/index.ts +2 -0
  176. package/src/download/core/index.ts +0 -25
  177. package/src/download/ui/FigureDownload.tsx +11 -148
  178. package/src/download/ui/FigureDownloadPanel.tsx +46 -45
  179. package/src/download/ui/figureDownloadHint.ts +52 -0
  180. package/src/download/ui/index.ts +6 -10
  181. package/src/download/ui/useFigureActions.ts +113 -0
  182. package/src/download/ui/useFigureDownload.tsx +191 -0
  183. package/src/ecosystem/core/sites.ts +0 -40
  184. package/src/ecosystem/core/types.ts +0 -10
  185. package/src/ir/core/irCommands.ts +2 -2
  186. package/src/ir/ui/IrAboutDialog.tsx +0 -13
  187. package/src/ir/ui/IrCanvas.tsx +8 -2
  188. package/src/ir/ui/IrShell.tsx +23 -25
  189. package/src/ir/ui/IrToolbar.tsx +36 -6
  190. package/src/ir/ui/index.ts +1 -0
  191. package/src/locales/de.json +8 -4
  192. package/src/locales/en.json +8 -4
  193. package/src/locales/es.json +8 -4
  194. package/src/locales/fr.json +8 -4
  195. package/src/locales/it.json +8 -4
  196. package/src/overlay/ui/OverlayPanel.tsx +8 -2
  197. package/src/overlay/ui/overlayPanelStyles.ts +3 -0
  198. package/src/periodic/core/index.ts +1 -0
  199. package/src/periodic/core/layout.ts +19 -0
  200. package/src/periodic/ui/ElementCell.tsx +35 -26
  201. package/src/periodic/ui/PeriodicTable.tsx +55 -16
  202. package/src/ui.ts +1 -0
  203. package/styles/chrome.css +71 -0
  204. package/lib/about/core/repository.d.ts +0 -14
  205. package/lib/about/core/repository.d.ts.map +0 -1
  206. package/lib/about/core/repository.js +0 -21
  207. package/lib/about/core/repository.js.map +0 -1
  208. package/lib/download/core/exportStyles.d.ts +0 -22
  209. package/lib/download/core/exportStyles.d.ts.map +0 -1
  210. package/lib/download/core/exportStyles.js +0 -19
  211. package/lib/download/core/exportStyles.js.map +0 -1
  212. package/lib/download/core/imageResolution.d.ts +0 -88
  213. package/lib/download/core/imageResolution.d.ts.map +0 -1
  214. package/lib/download/core/imageResolution.js +0 -77
  215. package/lib/download/core/imageResolution.js.map +0 -1
  216. package/lib/download/core/pictureExport.d.ts +0 -93
  217. package/lib/download/core/pictureExport.d.ts.map +0 -1
  218. package/lib/download/core/pictureExport.js +0 -116
  219. package/lib/download/core/pictureExport.js.map +0 -1
  220. package/lib/download/ui/ExportDialogFrame.d.ts +0 -46
  221. package/lib/download/ui/ExportDialogFrame.d.ts.map +0 -1
  222. package/lib/download/ui/ExportDialogFrame.js +0 -24
  223. package/lib/download/ui/ExportDialogFrame.js.map +0 -1
  224. package/lib/download/ui/ExportImageDialog.d.ts +0 -47
  225. package/lib/download/ui/ExportImageDialog.d.ts.map +0 -1
  226. package/lib/download/ui/ExportImageDialog.js +0 -25
  227. package/lib/download/ui/ExportImageDialog.js.map +0 -1
  228. package/lib/download/ui/ExportNameField.d.ts +0 -29
  229. package/lib/download/ui/ExportNameField.d.ts.map +0 -1
  230. package/lib/download/ui/ExportNameField.js +0 -99
  231. package/lib/download/ui/ExportNameField.js.map +0 -1
  232. package/lib/download/ui/ExportPictureSection.d.ts +0 -38
  233. package/lib/download/ui/ExportPictureSection.d.ts.map +0 -1
  234. package/lib/download/ui/ExportPictureSection.js +0 -48
  235. package/lib/download/ui/ExportPictureSection.js.map +0 -1
  236. package/lib/download/ui/useDrawingBox.d.ts +0 -23
  237. package/lib/download/ui/useDrawingBox.d.ts.map +0 -1
  238. package/lib/download/ui/useDrawingBox.js +0 -21
  239. package/lib/download/ui/useDrawingBox.js.map +0 -1
  240. package/src/about/core/repository.ts +0 -22
  241. package/src/download/core/exportStyles.ts +0 -20
  242. package/src/download/core/imageResolution.ts +0 -118
  243. package/src/download/core/pictureExport.ts +0 -207
  244. package/src/download/ui/ExportDialogFrame.tsx +0 -86
  245. package/src/download/ui/ExportImageDialog.tsx +0 -91
  246. package/src/download/ui/ExportNameField.tsx +0 -148
  247. package/src/download/ui/ExportPictureSection.tsx +0 -142
  248. package/src/download/ui/useDrawingBox.ts +0 -37
@@ -1,142 +0,0 @@
1
- import { Button, HTMLSelect } from '@blueprintjs/core';
2
- import { useState } from 'react';
3
-
4
- import {
5
- exportButtonsStyle,
6
- exportNoteStyle,
7
- exportSectionStyle,
8
- } from '../core/exportStyles.ts';
9
- import {
10
- IMAGE_RESOLUTIONS,
11
- formatImageSize,
12
- imageResolution,
13
- } from '../core/imageResolution.ts';
14
- import type { PictureFrame } from '../core/pictureExport.ts';
15
- import {
16
- copyPicture,
17
- pictureSize,
18
- savePngPicture,
19
- saveSvgPicture,
20
- } from '../core/pictureExport.ts';
21
- import { sanitizeFileName } from '../core/sanitizeFileName.ts';
22
-
23
- import { ExportNameField } from './ExportNameField.tsx';
24
-
25
- export interface ExportPictureSectionProps {
26
- /** The drawing a picture is taken of, as it is rendered. */
27
- getDrawing: () => SVGSVGElement | null;
28
- /** Which of the resolutions is picked. */
29
- resolutionId: string;
30
- /** Called with the resolution that was picked. */
31
- onResolutionChange: (id: string) => void;
32
- /**
33
- * The name the name box opens on, and falls back to when it is cleared,
34
- * without its extension.
35
- */
36
- filename: string;
37
- /** What the picture is read out as in the file it is written to. */
38
- label: string;
39
- /**
40
- * Whether the picture is the drawing inside the element or the element as it
41
- * is laid out.
42
- * @default 'content'
43
- */
44
- frame?: PictureFrame;
45
- /** Called with what became of the last thing written out. */
46
- onStatus: (status: string) => void;
47
- }
48
-
49
- /**
50
- * The drawing as a picture: how big it comes out, and where it goes.
51
- *
52
- * The size the file will be is shown beside the resolution rather than after
53
- * the fact, since that is the number the choice is made on — a figure for a
54
- * paper and a thumbnail for a slide are the same drawing at very different
55
- * sizes. What is measured is what the picture will be of and not whatever is on
56
- * screen, so the answer does not change when the window is resized or the
57
- * drawing panned.
58
- * @param props - Component props.
59
- * @returns The section.
60
- */
61
- export function ExportPictureSection(props: ExportPictureSectionProps) {
62
- const {
63
- getDrawing,
64
- resolutionId,
65
- onResolutionChange,
66
- filename,
67
- label,
68
- frame,
69
- onStatus,
70
- } = props;
71
-
72
- const [name, setName] = useState(filename);
73
-
74
- const savedName = sanitizeFileName(name, filename);
75
- const { scale } = imageResolution(resolutionId);
76
- const size = pictureSize(getDrawing(), scale, { frame });
77
- const options = { scale, filename: savedName, label, frame };
78
-
79
- return (
80
- <section style={exportSectionStyle}>
81
- <div style={resolutionStyle}>
82
- <HTMLSelect
83
- value={resolutionId}
84
- aria-label="Resolution"
85
- onChange={(event) => onResolutionChange(event.currentTarget.value)}
86
- >
87
- {IMAGE_RESOLUTIONS.map((resolution) => (
88
- <option key={resolution.id} value={resolution.id}>
89
- {resolution.label}
90
- </option>
91
- ))}
92
- </HTMLSelect>
93
- <span style={exportNoteStyle}>{formatImageSize(size)}</span>
94
- </div>
95
- <div style={exportButtonsStyle}>
96
- <Button
97
- icon="duplicate"
98
- disabled={size === null}
99
- text="Copy PNG"
100
- onClick={() => {
101
- // The rasterization is started here rather than awaited: Safari
102
- // only allows a clipboard write the click itself started.
103
- void copyPicture(getDrawing(), options).then(
104
- (copied) =>
105
- onStatus(copied ? 'Picture copied.' : 'Nothing was copied.'),
106
- () => onStatus('Nothing was copied.'),
107
- );
108
- }}
109
- />
110
- <ExportNameField name={name} onChange={setName} />
111
- <Button
112
- icon="download"
113
- disabled={size === null}
114
- text="Save PNG"
115
- title={`Save as ${savedName}.png`}
116
- onClick={() => {
117
- void savePngPicture(getDrawing(), options).then((saved) => {
118
- if (saved) onStatus(`Saved as ${savedName}.png.`);
119
- });
120
- }}
121
- />
122
- <Button
123
- icon="download"
124
- disabled={size === null}
125
- text="Save SVG"
126
- title={`Save as ${savedName}.svg`}
127
- onClick={() => {
128
- if (saveSvgPicture(getDrawing(), options)) {
129
- onStatus(`Saved as ${savedName}.svg.`);
130
- }
131
- }}
132
- />
133
- </div>
134
- </section>
135
- );
136
- }
137
-
138
- const resolutionStyle = {
139
- display: 'flex',
140
- alignItems: 'center',
141
- gap: 8,
142
- } as const;
@@ -1,37 +0,0 @@
1
- import { useCallback, useRef } from 'react';
2
-
3
- import { drawingIn } from '../core/stackedDrawing.ts';
4
-
5
- /** The box a picture is taken out of. */
6
- export interface DrawingBox {
7
- /** Put on the box the drawing sits in, so it can be found again. */
8
- attach: (element: HTMLElement | null) => void;
9
- /**
10
- * The drawing a picture is taken of, `null` when the box holds none — which
11
- * is what an editor showing nothing yet, or one whose box has not been
12
- * mounted, hands the export dialog.
13
- */
14
- getDrawing: () => SVGSVGElement | null;
15
- }
16
-
17
- /**
18
- * Find the drawing a picture is to be taken of, when it is asked for.
19
- *
20
- * A drawing is laid out again on every resize, so the element itself is never
21
- * held onto: what is kept is the box it sits in, and the drawing is read out of
22
- * it at the moment a button is pressed. What counts as the drawing in there —
23
- * the one element for an editor showing one, the panes composed for an editor
24
- * showing a stack of charts — is `drawingIn`.
25
- * @returns The box to attach, and the drawing inside it.
26
- */
27
- export function useDrawingBox(): DrawingBox {
28
- const box = useRef<HTMLElement | null>(null);
29
-
30
- const attach = useCallback((element: HTMLElement | null) => {
31
- box.current = element;
32
- }, []);
33
-
34
- const getDrawing = useCallback(() => drawingIn(box.current), []);
35
-
36
- return { attach, getDrawing };
37
- }