react-cheminfo 0.30.0 → 0.32.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 (127) hide show
  1. package/README.md +21 -0
  2. package/lib/core.d.ts +1 -0
  3. package/lib/core.d.ts.map +1 -1
  4. package/lib/core.js +1 -0
  5. package/lib/core.js.map +1 -1
  6. package/lib/download/core/downloadFigure.d.ts +7 -5
  7. package/lib/download/core/downloadFigure.d.ts.map +1 -1
  8. package/lib/download/core/downloadFigure.js +7 -6
  9. package/lib/download/core/downloadFigure.js.map +1 -1
  10. package/lib/download/core/figureLayout.d.ts +55 -0
  11. package/lib/download/core/figureLayout.d.ts.map +1 -0
  12. package/lib/download/core/figureLayout.js +89 -0
  13. package/lib/download/core/figureLayout.js.map +1 -0
  14. package/lib/download/core/figureScale.d.ts +9 -0
  15. package/lib/download/core/figureScale.d.ts.map +1 -1
  16. package/lib/download/core/figureScale.js +10 -0
  17. package/lib/download/core/figureScale.js.map +1 -1
  18. package/lib/download/core/figureSettle.d.ts +51 -0
  19. package/lib/download/core/figureSettle.d.ts.map +1 -0
  20. package/lib/download/core/figureSettle.js +81 -0
  21. package/lib/download/core/figureSettle.js.map +1 -0
  22. package/lib/download/core/figureSvg.d.ts +7 -1
  23. package/lib/download/core/figureSvg.d.ts.map +1 -1
  24. package/lib/download/core/figureSvg.js +1 -0
  25. package/lib/download/core/figureSvg.js.map +1 -1
  26. package/lib/download/core/figureSvgDocument.d.ts +7 -0
  27. package/lib/download/core/figureSvgDocument.d.ts.map +1 -1
  28. package/lib/download/core/figureSvgDocument.js +11 -2
  29. package/lib/download/core/figureSvgDocument.js.map +1 -1
  30. package/lib/download/core/index.d.ts +5 -1
  31. package/lib/download/core/index.d.ts.map +1 -1
  32. package/lib/download/core/index.js +3 -1
  33. package/lib/download/core/index.js.map +1 -1
  34. package/lib/download/ui/FigureDownload.d.ts +18 -4
  35. package/lib/download/ui/FigureDownload.d.ts.map +1 -1
  36. package/lib/download/ui/FigureDownload.js +35 -9
  37. package/lib/download/ui/FigureDownload.js.map +1 -1
  38. package/lib/download/ui/FigureDownloadPanel.d.ts +17 -7
  39. package/lib/download/ui/FigureDownloadPanel.d.ts.map +1 -1
  40. package/lib/download/ui/FigureDownloadPanel.js +30 -22
  41. package/lib/download/ui/FigureDownloadPanel.js.map +1 -1
  42. package/lib/download/ui/FigureSizeField.d.ts +27 -0
  43. package/lib/download/ui/FigureSizeField.d.ts.map +1 -0
  44. package/lib/download/ui/FigureSizeField.js +87 -0
  45. package/lib/download/ui/FigureSizeField.js.map +1 -0
  46. package/lib/download/ui/FigureSizeRows.d.ts +34 -0
  47. package/lib/download/ui/FigureSizeRows.d.ts.map +1 -0
  48. package/lib/download/ui/FigureSizeRows.js +54 -0
  49. package/lib/download/ui/FigureSizeRows.js.map +1 -0
  50. package/lib/download/ui/index.d.ts +2 -0
  51. package/lib/download/ui/index.d.ts.map +1 -1
  52. package/lib/download/ui/index.js.map +1 -1
  53. package/lib/download/ui/useFigureRedraw.d.ts +27 -0
  54. package/lib/download/ui/useFigureRedraw.d.ts.map +1 -0
  55. package/lib/download/ui/useFigureRedraw.js +78 -0
  56. package/lib/download/ui/useFigureRedraw.js.map +1 -0
  57. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  58. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  59. package/lib/locales/de.json +13 -3
  60. package/lib/locales/en.json +13 -3
  61. package/lib/locales/es.json +13 -3
  62. package/lib/locales/fr.json +13 -3
  63. package/lib/number/core/index.d.ts +2 -0
  64. package/lib/number/core/index.d.ts.map +1 -0
  65. package/lib/number/core/index.js +2 -0
  66. package/lib/number/core/index.js.map +1 -0
  67. package/lib/number/core/numberText.d.ts +46 -0
  68. package/lib/number/core/numberText.d.ts.map +1 -0
  69. package/lib/number/core/numberText.js +88 -0
  70. package/lib/number/core/numberText.js.map +1 -0
  71. package/lib/number/ui/NumberInput.d.ts +113 -0
  72. package/lib/number/ui/NumberInput.d.ts.map +1 -0
  73. package/lib/number/ui/NumberInput.js +100 -0
  74. package/lib/number/ui/NumberInput.js.map +1 -0
  75. package/lib/number/ui/index.d.ts +3 -0
  76. package/lib/number/ui/index.d.ts.map +1 -0
  77. package/lib/number/ui/index.js +2 -0
  78. package/lib/number/ui/index.js.map +1 -0
  79. package/lib/overlay/ui/OverlayValueMenu.d.ts.map +1 -1
  80. package/lib/overlay/ui/OverlayValueMenu.js +7 -1
  81. package/lib/overlay/ui/OverlayValueMenu.js.map +1 -1
  82. package/lib/periodic/ui/ElementCell.d.ts +10 -0
  83. package/lib/periodic/ui/ElementCell.d.ts.map +1 -1
  84. package/lib/periodic/ui/ElementCell.js +124 -14
  85. package/lib/periodic/ui/ElementCell.js.map +1 -1
  86. package/lib/periodic/ui/PeriodicTable.d.ts.map +1 -1
  87. package/lib/periodic/ui/PeriodicTable.js +46 -19
  88. package/lib/periodic/ui/PeriodicTable.js.map +1 -1
  89. package/lib/periodic/ui/PeriodicTableChrome.js +2 -2
  90. package/lib/periodic/ui/PeriodicTableChrome.js.map +1 -1
  91. package/lib/spectra/ui/NumberField.d.ts +2 -5
  92. package/lib/spectra/ui/NumberField.d.ts.map +1 -1
  93. package/lib/spectra/ui/NumberField.js +4 -54
  94. package/lib/spectra/ui/NumberField.js.map +1 -1
  95. package/lib/ui.d.ts +1 -0
  96. package/lib/ui.d.ts.map +1 -1
  97. package/lib/ui.js +1 -0
  98. package/lib/ui.js.map +1 -1
  99. package/package.json +1 -1
  100. package/src/core.ts +1 -0
  101. package/src/download/core/downloadFigure.ts +12 -9
  102. package/src/download/core/figureLayout.ts +114 -0
  103. package/src/download/core/figureScale.ts +13 -0
  104. package/src/download/core/figureSettle.ts +112 -0
  105. package/src/download/core/figureSvg.ts +8 -1
  106. package/src/download/core/figureSvgDocument.ts +19 -2
  107. package/src/download/core/index.ts +13 -0
  108. package/src/download/ui/FigureDownload.tsx +88 -35
  109. package/src/download/ui/FigureDownloadPanel.tsx +45 -22
  110. package/src/download/ui/FigureSizeField.tsx +153 -0
  111. package/src/download/ui/FigureSizeRows.tsx +108 -0
  112. package/src/download/ui/index.ts +2 -0
  113. package/src/download/ui/useFigureRedraw.tsx +115 -0
  114. package/src/locales/de.json +13 -3
  115. package/src/locales/en.json +13 -3
  116. package/src/locales/es.json +13 -3
  117. package/src/locales/fr.json +13 -3
  118. package/src/number/core/index.ts +6 -0
  119. package/src/number/core/numberText.ts +91 -0
  120. package/src/number/ui/NumberInput.tsx +300 -0
  121. package/src/number/ui/index.ts +7 -0
  122. package/src/overlay/ui/OverlayValueMenu.tsx +7 -1
  123. package/src/periodic/ui/ElementCell.tsx +153 -14
  124. package/src/periodic/ui/PeriodicTable.tsx +51 -22
  125. package/src/periodic/ui/PeriodicTableChrome.tsx +2 -2
  126. package/src/spectra/ui/NumberField.tsx +11 -58
  127. package/src/ui.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"PeriodicTable.js","sourceRoot":"","sources":["../../../src/periodic/ui/PeriodicTable.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,cAAc,GACf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAmB,CAAC;AAChD,OAAO,EACL,YAAY,EACZ,sBAAsB,GACvB,MAAM,0BAA2B,CAAC;AA6EnC;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAyB;IACrD,MAAM,EACJ,QAAQ,EACR,QAAQ,EACR,QAAQ,GAAG,eAAe,EAC1B,QAAQ,EACR,MAAM,GAAG,aAAa,EACtB,UAAU,EACV,OAAO,GAAG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,MAAM,IAAI,GAAG,aAAa,GAAG,KAAK,UAAU,cAAc,GAAG,GAAG,CAAC;IACjE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;YACL,GAAG,aAAa;YAChB,mBAAmB,EAAE,UAAU,MAAM,CAAC,YAAY,CAAC,mBAAmB;YACtE,gBAAgB,EAAE,IAAI;SACvB,CAAC;IACJ,CAAC;IACD,OAAO;QACL,GAAG,aAAa;QAChB,mBAAmB,EAAE,4BAA4B,MAAM,CAAC,YAAY,CAAC,mBAAmB;QACxF,gBAAgB,EAAE,mBAAmB,IAAI,EAAE;KAC5C,CAAC;AACJ,CAAC"}
@@ -53,7 +53,7 @@ const headerStyle = {
53
53
  alignItems: 'center',
54
54
  color: TOKEN.textMuted,
55
55
  display: 'flex',
56
- fontSize: 'clamp(0.4rem, 1.9cqw, 0.62rem)',
56
+ fontSize: 'max(0.45rem, 1.35cqw)',
57
57
  justifyContent: 'center',
58
58
  padding: 0,
59
59
  };
@@ -69,7 +69,7 @@ const markerStyle = {
69
69
  borderRadius: 3,
70
70
  color: TOKEN.textMuted,
71
71
  display: 'flex',
72
- fontSize: 'clamp(0.36rem, 1.7cqw, 0.55rem)',
72
+ fontSize: 'max(0.4rem, 1.15cqw)',
73
73
  justifyContent: 'center',
74
74
  };
75
75
  //# sourceMappingURL=PeriodicTableChrome.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PeriodicTableChrome.js","sourceRoot":"","sources":["../../../src/periodic/ui/PeriodicTableChrome.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAE1D,OAAO,EACL,YAAY,EACZ,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAY3B;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,KAAwB;IACnD,MAAM,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;I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EAAE,SAAS;CACiB,CAAC;AAEnC,MAAM,WAAW,GAAG;IAClB,UAAU,EAAE,QAAQ;IACpB,MAAM,EAAE,cAAc,KAAK,CAAC,YAAY,EAAE;IAC1C,YAAY,EAAE,CAAC;IACf,KAAK,EAAE,KAAK,CAAC,SAAS;IACtB,OAAO,EAAE,MAAM;IACf,QAAQ,EAAE,sBAAsB;IAChC,cAAc,EAAE,QAAQ;CACQ,CAAC"}
@@ -29,11 +29,8 @@ interface NumberFieldProps {
29
29
  /**
30
30
  * One number of the settings.
31
31
  *
32
- * The box keeps what was typed rather than what parsed, because a reader
33
- * halfway through `1e-` has typed something no number can hold yet; clearing it
34
- * under them would make the field unusable. Nothing is handed up until the text
35
- * reads as a number, and emptying the box hands up nothing at all — which is
36
- * how a reader gets back to upstream's default after typing over it.
32
+ * Emptying the box hands up nothing at all, which is how a reader gets back to
33
+ * upstream's default after typing over it.
37
34
  * @param props - See {@link NumberFieldProps}.
38
35
  * @returns The labelled box.
39
36
  */
@@ -1 +1 @@
1
- {"version":3,"file":"NumberField.d.ts","sourceRoot":"","sources":["../../../src/spectra/ui/NumberField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAK1C,sCAAsC;AACtC,UAAU,gBAAgB;IACxB,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6EAA6E;IAC7E,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC9C;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,YAAY,CAuCjE"}
1
+ {"version":3,"file":"NumberField.d.ts","sourceRoot":"","sources":["../../../src/spectra/ui/NumberField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAM1C,sCAAsC;AACtC,UAAU,gBAAgB;IACxB,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6EAA6E;IAC7E,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC9C;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,YAAY,CAmBjE"}
@@ -1,67 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { InputGroup } from '@blueprintjs/core';
3
- import { useState } from 'react';
2
+ import { NumberInput } from "../../number/ui/NumberInput.js";
4
3
  import { HELP_STYLE, LABEL_STYLE, sizedFieldStyle } from "./fieldStyles.js";
5
4
  /**
6
5
  * One number of the settings.
7
6
  *
8
- * The box keeps what was typed rather than what parsed, because a reader
9
- * halfway through `1e-` has typed something no number can hold yet; clearing it
10
- * under them would make the field unusable. Nothing is handed up until the text
11
- * reads as a number, and emptying the box hands up nothing at all — which is
12
- * how a reader gets back to upstream's default after typing over it.
7
+ * Emptying the box hands up nothing at all, which is how a reader gets back to
8
+ * upstream's default after typing over it.
13
9
  * @param props - See {@link NumberFieldProps}.
14
10
  * @returns The labelled box.
15
11
  */
16
12
  export function NumberField(props) {
17
13
  const { label, value, placeholder, onChange, integer = false, help } = props;
18
- const [draft, setDraft] = useState(() => ({
19
- text: asText(value),
20
- held: value,
21
- }));
22
- // The settings changed from somewhere else — a preset, a reset, a pasted
23
- // configuration — so the box has to follow rather than hold the old text.
24
- // `held` is what this box last handed up, not the prop it was rendered with:
25
- // comparing against the prop would make the box's own edit look external and
26
- // rewrite `-0.` as `0` under the caret before the reader reaches the digits.
27
- if (draft.held !== value)
28
- setDraft({ text: asText(value), held: value });
29
- return (_jsxs("label", { style: FIELD_STYLE, children: [_jsx("span", { style: LABEL_STYLE, children: label }), _jsx(InputGroup, { size: "small", fill: true, inputMode: integer ? 'numeric' : 'decimal', value: draft.text, placeholder: placeholder, spellCheck: false, autoComplete: "off", onValueChange: (text) => {
30
- const parsed = read(text, integer);
31
- const emptied = text.trim() === '';
32
- setDraft({ text, held: emptied ? undefined : (parsed ?? value) });
33
- if (emptied) {
34
- onChange(undefined);
35
- }
36
- else if (parsed !== undefined) {
37
- onChange(parsed);
38
- }
39
- } }), help === undefined ? null : _jsx("span", { style: HELP_STYLE, children: help })] }));
40
- }
41
- /**
42
- * The number as the box shows it.
43
- * @param value - What the settings hold.
44
- * @returns Its text, empty when nothing is held.
45
- */
46
- function asText(value) {
47
- return value === undefined ? '' : String(value);
48
- }
49
- /**
50
- * The text as a number, when it reads as one.
51
- * @param text - What was typed.
52
- * @param integer - Whether only whole numbers make sense.
53
- * @returns The number, or undefined while the text is not one yet.
54
- */
55
- function read(text, integer) {
56
- const trimmed = text.trim();
57
- if (trimmed === '')
58
- return undefined;
59
- const parsed = Number(trimmed);
60
- if (!Number.isFinite(parsed))
61
- return undefined;
62
- if (integer && !Number.isInteger(parsed))
63
- return undefined;
64
- return parsed;
14
+ return (_jsxs("label", { style: FIELD_STYLE, children: [_jsx("span", { style: LABEL_STYLE, children: label }), _jsx(NumberInput, { allowEmpty: true, buttons: false, fill: true, size: "small", value: value, placeholder: placeholder, integer: integer, onChange: onChange }), help === undefined ? null : _jsx("span", { style: HELP_STYLE, children: help })] }));
65
15
  }
66
16
  const FIELD_STYLE = sizedFieldStyle(120);
67
17
  //# sourceMappingURL=NumberField.js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AAC,GAAG,CAAC,CAAC"}
1
+ {"version":3,"file":"NumberField.js","sourceRoot":"","sources":["../../../src/spectra/ui/NumberField.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAiC,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AA8B5E;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,KAAuB;IACjD,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,GAAG,KAAK,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IAE7E,OAAO,CACL,iBAAO,KAAK,EAAE,WAAW,aACvB,eAAM,KAAK,EAAE,WAAW,YAAG,KAAK,GAAQ,EACxC,KAAC,WAAW,IACV,UAAU,QACV,OAAO,EAAE,KAAK,EACd,IAAI,QACJ,IAAI,EAAC,OAAO,EACZ,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,GAClB,EACD,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAM,KAAK,EAAE,UAAU,YAAG,IAAI,GAAQ,IAC7D,CACT,CAAC;AACJ,CAAC;AAED,MAAM,WAAW,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC"}
package/lib/ui.d.ts CHANGED
@@ -16,6 +16,7 @@ export * from './help/ui/index.ts';
16
16
  export * from './hooks/ui/index.ts';
17
17
  export * from './i18n/ui/index.ts';
18
18
  export * from './language/ui/index.ts';
19
+ export * from './number/ui/index.ts';
19
20
  export * from './overlay/ui/index.ts';
20
21
  export * from './panel/ui/index.ts';
21
22
  export * from './parallel/ui/index.ts';
package/lib/ui.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"A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,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AAKrC,YAAY,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,YAAY,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,eAAe,GAChB,MAAM,oCAAoC,CAAC"}
package/lib/ui.js CHANGED
@@ -16,6 +16,7 @@ export * from "./help/ui/index.js";
16
16
  export * from "./hooks/ui/index.js";
17
17
  export * from "./i18n/ui/index.js";
18
18
  export * from "./language/ui/index.js";
19
+ export * from "./number/ui/index.js";
19
20
  export * from "./overlay/ui/index.js";
20
21
  export * from "./panel/ui/index.js";
21
22
  export * from "./parallel/ui/index.js";
package/lib/ui.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAA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AwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AAMrC,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAmC,CAAC;AAEnE,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,eAAe,GAChB,MAAM,oCAAoC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-cheminfo",
3
- "version": "0.30.0",
3
+ "version": "0.32.0",
4
4
  "license": "MIT",
5
5
  "description": "React components, hooks and framework-free helpers shared by the cheminfo sites: site chrome, citations, sharing, routing, pedagogy, charts, and the structure, orbital and 3D molecule viewers",
6
6
  "author": "Luc Patiny",
package/src/core.ts CHANGED
@@ -12,6 +12,7 @@ export * from './error/core/index.ts';
12
12
  export * from './format/core/index.ts';
13
13
  export * from './i18n/core/index.ts';
14
14
  export * from './language/core/index.ts';
15
+ export * from './number/core/index.ts';
15
16
  export * from './orbital/core/index.ts';
16
17
  export * from './overlay/core/index.ts';
17
18
  export * from './panel/core/index.ts';
@@ -4,13 +4,13 @@
4
4
  * Which of the two formats a reader wants is not a question the figure can
5
5
  * answer for them: an SVG is the one to put in a paper, where it stays sharp
6
6
  * at any size and can still be edited, and a PNG is the one every chat window,
7
- * slide deck and issue tracker actually accepts. So both are offered, and the
8
- * resolution goes with the second.
7
+ * slide deck and issue tracker actually accepts. So both are offered. The
8
+ * resolution paints a PNG with more pixels, and makes an SVG open larger.
9
9
  */
10
10
 
11
11
  import { downloadBlob } from './downloadBlob.ts';
12
12
  import { figurePng } from './figurePng.ts';
13
- import { DEFAULT_FIGURE_SCALE } from './figureScale.ts';
13
+ import { defaultFigureScale } from './figureScale.ts';
14
14
  import type { FigureSvgOptions } from './figureSvg.ts';
15
15
  import { FIGURE_SVG_TYPE, figureSvg } from './figureSvg.ts';
16
16
  import { sanitizeFileName } from './sanitizeFileName.ts';
@@ -26,9 +26,11 @@ export interface DownloadFigureOptions extends FigureSvgOptions {
26
26
  */
27
27
  format?: FigureFormat;
28
28
  /**
29
- * How many pixels are painted per pixel on screen. An SVG ignores it: it
30
- * carries no resolution of its own.
31
- * @default 2
29
+ * How many pixels are painted per pixel on screen. An SVG is drawn the same
30
+ * and opens this many times larger, which is the size a slide or a word
31
+ * processor places it at.
32
+ * @default 2 for a PNG, 1 for an SVG — which then opens at the size it has
33
+ * on screen
32
34
  */
33
35
  scale?: number;
34
36
  /**
@@ -51,16 +53,17 @@ export async function downloadFigure(
51
53
  target: string | Element,
52
54
  options: DownloadFigureOptions = {},
53
55
  ): Promise<void> {
54
- const { format = 'png', scale = DEFAULT_FIGURE_SCALE } = options;
55
- const { fileName = DEFAULT_FILE_NAME, background } = options;
56
+ const { format = 'png', fileName = DEFAULT_FILE_NAME, background } = options;
57
+ const scale = options.scale ?? defaultFigureScale(format);
56
58
 
57
- const figure = figureSvg(target, { background });
58
59
  const name = sanitizeFileName(fileName, DEFAULT_FILE_NAME);
59
60
 
60
61
  if (format === 'svg') {
62
+ const figure = figureSvg(target, { background, scale });
61
63
  const blob = new Blob([figure.markup], { type: FIGURE_SVG_TYPE });
62
64
  downloadBlob(blob, `${name}.svg`);
63
65
  return;
64
66
  }
67
+ const figure = figureSvg(target, { background });
65
68
  downloadBlob(await figurePng(figure, scale), `${name}.png`);
66
69
  }
@@ -0,0 +1,114 @@
1
+ /**
2
+ * The shape a figure is drawn at before it is saved.
3
+ *
4
+ * A saved figure is the drawing the reader is looking at, so its proportions
5
+ * are the proportions of the box it sits in. The resolution scales that
6
+ * drawing — more pixels for a PNG, a larger page for an SVG — but leaves its
7
+ * shape, and the size of its words against its axes, exactly as they were. A
8
+ * figure for a slide or for a journal column wants another shape, and the only
9
+ * way to give it one is to draw it again at that size, so its axes and labels
10
+ * are laid out for the new box rather than stretched into it.
11
+ */
12
+
13
+ import type { FigurePixels } from './figureScale.ts';
14
+
15
+ /** The shapes a figure can be drawn at for a file. */
16
+ export type FigureLayout = 'screen' | 'standard' | 'wide' | 'column' | 'custom';
17
+
18
+ /** The shapes, in the order they are offered. */
19
+ export const FIGURE_LAYOUTS = [
20
+ 'screen',
21
+ 'standard',
22
+ 'wide',
23
+ 'column',
24
+ 'custom',
25
+ ] as const satisfies readonly FigureLayout[];
26
+
27
+ /**
28
+ * How wide a journal's single column is, in CSS pixels: 8.5 cm at 96 pixels
29
+ * per inch. A figure laid out at that width prints its text at the size it is
30
+ * read at on screen, a 12 px label becoming a 9 pt one.
31
+ */
32
+ export const FIGURE_COLUMN_WIDTH = 321;
33
+
34
+ /** The narrowest side a figure is drawn at, below which no chart has room for its axes. */
35
+ export const FIGURE_LAYOUT_MIN = 120;
36
+
37
+ /** The widest side a figure is drawn at: past it the page would be laying out a poster. */
38
+ export const FIGURE_LAYOUT_MAX = 4096;
39
+
40
+ /**
41
+ * The size a figure is drawn at, in the shape the reader picked.
42
+ *
43
+ * The two slide shapes keep the width of the figure on screen and change its
44
+ * height, since the width is what a page already gave it. The journal column
45
+ * does the reverse: its width is fixed by the journal, and the figure keeps
46
+ * the proportions it has on screen.
47
+ * @param layout - The shape picked.
48
+ * @param screen - The figure as it is drawn on the page.
49
+ * @param custom - The size typed in, read only for `custom`. Defaults to the
50
+ * figure on screen.
51
+ * @returns The size to draw it at, in whole pixels.
52
+ */
53
+ export function figureLayoutSize(
54
+ layout: FigureLayout,
55
+ screen: FigurePixels,
56
+ custom: FigurePixels = screen,
57
+ ): FigurePixels {
58
+ switch (layout) {
59
+ case 'standard':
60
+ return sized(screen.width, (screen.width * 3) / 4);
61
+ case 'wide':
62
+ return sized(screen.width, (screen.width * 9) / 16);
63
+ case 'column':
64
+ return sized(
65
+ FIGURE_COLUMN_WIDTH,
66
+ (FIGURE_COLUMN_WIDTH * screen.height) / Math.max(screen.width, 1),
67
+ );
68
+ case 'custom':
69
+ return sized(custom.width, custom.height);
70
+ case 'screen':
71
+ return { width: screen.width, height: screen.height };
72
+ default:
73
+ throw new Error(`unknown figure layout: ${String(layout)}`);
74
+ }
75
+ }
76
+
77
+ /**
78
+ * One side, held to the range a figure can be drawn at.
79
+ * @param value - What was asked for, typed or computed.
80
+ * @returns A whole number of pixels, inside the range.
81
+ */
82
+ export function figureLayoutSide(value: number): number {
83
+ if (!Number.isFinite(value)) return FIGURE_LAYOUT_MIN;
84
+ return Math.min(
85
+ FIGURE_LAYOUT_MAX,
86
+ Math.max(FIGURE_LAYOUT_MIN, Math.round(value)),
87
+ );
88
+ }
89
+
90
+ /**
91
+ * Whether a figure is drawn again for the file, rather than copied as it is.
92
+ * @param layout - The shape picked.
93
+ * @param screen - The figure as it is drawn on the page.
94
+ * @param custom - The size typed in.
95
+ * @returns Whether the size differs from the one on screen.
96
+ */
97
+ export function figureLayoutRedraws(
98
+ layout: FigureLayout,
99
+ screen: FigurePixels,
100
+ custom?: FigurePixels,
101
+ ): boolean {
102
+ const drawn = figureLayoutSize(layout, screen, custom);
103
+ return drawn.width !== screen.width || drawn.height !== screen.height;
104
+ }
105
+
106
+ /**
107
+ * A size, both sides held to the range.
108
+ * @param width - The width asked for.
109
+ * @param height - The height asked for.
110
+ * @returns The size.
111
+ */
112
+ function sized(width: number, height: number): FigurePixels {
113
+ return { width: figureLayoutSide(width), height: figureLayoutSide(height) };
114
+ }
@@ -8,6 +8,8 @@
8
8
  * to work it out.
9
9
  */
10
10
 
11
+ import type { FigureFormat } from './downloadFigure.ts';
12
+
11
13
  /** The size of a saved figure, in pixels. */
12
14
  export interface FigurePixels {
13
15
  /** Its width. */
@@ -28,6 +30,17 @@ export const FIGURE_SCALES: readonly number[] = [1, 2, 3, 4];
28
30
  */
29
31
  export const DEFAULT_FIGURE_SCALE = 2;
30
32
 
33
+ /**
34
+ * The multiple a figure is saved at in this format unless the reader says
35
+ * otherwise. An SVG stays sharp however large it is shown, so it opens at the
36
+ * size it has on screen; a PNG is painted twice over, for a slide.
37
+ * @param format - The file being written.
38
+ * @returns The multiple.
39
+ */
40
+ export function defaultFigureScale(format: FigureFormat): number {
41
+ return format === 'svg' ? 1 : DEFAULT_FIGURE_SCALE;
42
+ }
43
+
31
44
  /**
32
45
  * The longest side a browser will paint into one canvas.
33
46
  *
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Knowing when a figure drawn for a file has finished drawing.
3
+ *
4
+ * A chart mounted off the page to be saved at another size does not arrive in
5
+ * one piece: it may render once at a guessed size, measure its box, and render
6
+ * again, and a chart behind a lazy import arrives whenever its chunk does. So
7
+ * nothing here waits a fixed time. The figure is watched frame by frame, and
8
+ * it is taken the moment it has stood still for two frames running.
9
+ */
10
+
11
+ import { figureSize } from './figureTarget.ts';
12
+
13
+ /** How the wait is run. */
14
+ export interface FigureSettleOptions {
15
+ /**
16
+ * Stops the wait, for a panel closed or a page left while the figure is
17
+ * still drawing.
18
+ * @default undefined — the wait runs to its end
19
+ */
20
+ signal?: AbortSignal;
21
+ /**
22
+ * How many frames the figure is given to settle before the save is given
23
+ * up, about ten seconds at sixty frames a second. It is how a figure that
24
+ * never draws is reported, not how long a slow one is expected to take.
25
+ * @default 600
26
+ */
27
+ maxFrames?: number;
28
+ /**
29
+ * Resolves at the next frame.
30
+ * @default the browser's `requestAnimationFrame`
31
+ */
32
+ nextFrame?: () => Promise<void>;
33
+ }
34
+
35
+ /** How many frames in a row the figure has to hold still. */
36
+ const STILL_FRAMES = 2;
37
+
38
+ /** What {@link FigureSettleOptions.maxFrames} is unless the caller says. */
39
+ const DEFAULT_MAX_FRAMES = 600;
40
+
41
+ /**
42
+ * Wait until the figure mounted in a box has finished drawing.
43
+ * @param element - The box the figure is being drawn in.
44
+ * @param options - See {@link FigureSettleOptions}.
45
+ * @returns Resolves once the figure has stood still.
46
+ * @throws {Error} When the wait is stopped, or the figure never settles.
47
+ */
48
+ export async function whenFigureSettles(
49
+ element: Element,
50
+ options: FigureSettleOptions = {},
51
+ ): Promise<void> {
52
+ let changes = 0;
53
+ const observer = new MutationObserver(() => {
54
+ changes++;
55
+ });
56
+ observer.observe(element, {
57
+ subtree: true,
58
+ childList: true,
59
+ attributes: true,
60
+ characterData: true,
61
+ });
62
+ try {
63
+ await settle(() => {
64
+ const size = figureSize(element);
65
+ return size === null ? null : `${changes}:${size.width}×${size.height}`;
66
+ }, options);
67
+ } finally {
68
+ observer.disconnect();
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Wait until a reading of the figure comes back the same frames in a row.
74
+ *
75
+ * The reading is whatever says the figure has changed — for a drawing on the
76
+ * page, how many times it was touched and the size it came out at — and
77
+ * `null` while there is nothing drawn yet.
78
+ * @param read - Takes the reading.
79
+ * @param options - See {@link FigureSettleOptions}.
80
+ * @returns Resolves once the reading has held.
81
+ * @throws {Error} When the wait is stopped, or the reading never holds.
82
+ */
83
+ export async function settle(
84
+ read: () => string | null,
85
+ options: FigureSettleOptions = {},
86
+ ): Promise<void> {
87
+ const { signal, maxFrames = DEFAULT_MAX_FRAMES } = options;
88
+ const { nextFrame = animationFrame } = options;
89
+
90
+ let last: string | null = null;
91
+ let still = 0;
92
+ for (let frame = 0; frame < maxFrames; frame++) {
93
+ // eslint-disable-next-line no-await-in-loop -- each frame is compared with the one before it
94
+ await nextFrame();
95
+ if (signal?.aborted) throw new Error('The figure was not saved.');
96
+ const reading = read();
97
+ still = reading !== null && reading === last ? still + 1 : 0;
98
+ if (still >= STILL_FRAMES) return;
99
+ last = reading;
100
+ }
101
+ throw new Error('The figure did not finish drawing, so nothing was saved.');
102
+ }
103
+
104
+ /**
105
+ * The next frame the browser paints.
106
+ * @returns Resolves at that frame.
107
+ */
108
+ function animationFrame(): Promise<void> {
109
+ return new Promise((resolve) => {
110
+ requestAnimationFrame(() => resolve());
111
+ });
112
+ }
@@ -27,13 +27,19 @@ export interface FigureSvgOptions {
27
27
  * @default the surface the figure is drawn on, which is the page's own
28
28
  */
29
29
  background?: string;
30
+ /**
31
+ * How many times the figure on screen the document says it is. The drawing
32
+ * is unchanged; only the size the file opens at grows.
33
+ * @default 1
34
+ */
35
+ scale?: number;
30
36
  }
31
37
 
32
38
  /** A figure, as the file that leaves the page. */
33
39
  export interface FigureSvg {
34
40
  /** The whole SVG document, tokens resolved. */
35
41
  markup: string;
36
- /** Its width in pixels, at the size the figure was drawn. */
42
+ /** Its width in pixels, at the size the figure was drawn on screen. */
37
43
  width: number;
38
44
  /** Its height. */
39
45
  height: number;
@@ -94,6 +100,7 @@ export function figureSvg(
94
100
  background: options.background ?? surfaceOf(styles),
95
101
  fontFamily: styles.fontFamily,
96
102
  fontSize: Number.parseFloat(styles.fontSize),
103
+ scale: options.scale,
97
104
  });
98
105
 
99
106
  return {
@@ -53,6 +53,13 @@ export interface FigureSvgDocumentOptions {
53
53
  * @default undefined — the reader's own default
54
54
  */
55
55
  fontSize?: number;
56
+ /**
57
+ * How many times the figure on screen the document says it is. Only the
58
+ * size it opens at changes — the drawing keeps its own coordinates, so every
59
+ * line and every word grows together and stays as sharp as before.
60
+ * @default 1
61
+ */
62
+ scale?: number;
56
63
  }
57
64
 
58
65
  /** Where an SVG document says it belongs. */
@@ -69,7 +76,8 @@ export function figureSvgDocument(
69
76
  pieces: readonly FigurePiece[],
70
77
  options: FigureSvgDocumentOptions,
71
78
  ): string {
72
- const { width, height, background, fontFamily, fontSize } = options;
79
+ const { width, height, background, fontFamily, fontSize, scale } = options;
80
+ const factor = positiveOrOne(scale);
73
81
  const box = `0 0 ${round(width)} ${round(height)}`;
74
82
  const style = documentStyle(fontFamily, fontSize);
75
83
 
@@ -86,7 +94,7 @@ export function figureSvgDocument(
86
94
 
87
95
  return (
88
96
  `<?xml version="1.0" encoding="UTF-8"?>` +
89
- `<svg xmlns="${SVG_NAMESPACE}" width="${round(width)}" height="${round(height)}" viewBox="${box}"${style}>` +
97
+ `<svg xmlns="${SVG_NAMESPACE}" width="${round(width * factor)}" height="${round(height * factor)}" viewBox="${box}"${style}>` +
90
98
  `${inside}</svg>`
91
99
  );
92
100
  }
@@ -113,6 +121,15 @@ function documentStyle(
113
121
  : ` style="${escapeAttribute(rules.join(';'))}"`;
114
122
  }
115
123
 
124
+ /**
125
+ * A multiple that makes sense, or one.
126
+ * @param value - The multiple asked for.
127
+ * @returns It, where it is a positive number; one otherwise.
128
+ */
129
+ function positiveOrOne(value: number | undefined): number {
130
+ return value !== undefined && Number.isFinite(value) && value > 0 ? value : 1;
131
+ }
132
+
116
133
  /**
117
134
  * A number as an attribute reads it: whole pixels where it is one, and two
118
135
  * decimals otherwise, because a serialized figure carrying sixteen digits per
@@ -3,12 +3,25 @@ export { downloadBlob } from './downloadBlob.ts';
3
3
  export type { DownloadFigureOptions, FigureFormat } from './downloadFigure.ts';
4
4
  export { downloadFigure } from './downloadFigure.ts';
5
5
  export { downloadText } from './downloadText.ts';
6
+ export type { FigureLayout } from './figureLayout.ts';
7
+ export {
8
+ FIGURE_COLUMN_WIDTH,
9
+ FIGURE_LAYOUTS,
10
+ FIGURE_LAYOUT_MAX,
11
+ FIGURE_LAYOUT_MIN,
12
+ figureLayoutRedraws,
13
+ figureLayoutSide,
14
+ figureLayoutSize,
15
+ } from './figureLayout.ts';
6
16
  export { FIGURE_PNG_TYPE, figurePng } from './figurePng.ts';
17
+ export type { FigureSettleOptions } from './figureSettle.ts';
18
+ export { whenFigureSettles } from './figureSettle.ts';
7
19
  export type { FigurePixels } from './figureScale.ts';
8
20
  export {
9
21
  DEFAULT_FIGURE_SCALE,
10
22
  FIGURE_MAX_PIXELS,
11
23
  FIGURE_SCALES,
24
+ defaultFigureScale,
12
25
  figurePixels,
13
26
  figureScaleFits,
14
27
  figureScaleLabel,