react-cheminfo 0.33.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/axis/core/axisMarks.d.ts +54 -0
- package/lib/axis/core/axisMarks.d.ts.map +1 -0
- package/lib/axis/core/axisMarks.js +69 -0
- package/lib/axis/core/axisMarks.js.map +1 -0
- package/lib/axis/core/axisScale.d.ts +31 -0
- package/lib/axis/core/axisScale.d.ts.map +1 -0
- package/lib/axis/core/axisScale.js +31 -0
- package/lib/axis/core/axisScale.js.map +1 -0
- package/lib/axis/core/index.d.ts +16 -0
- package/lib/axis/core/index.d.ts.map +1 -0
- package/lib/axis/core/index.js +13 -0
- package/lib/axis/core/index.js.map +1 -0
- package/lib/axis/core/logAxisBounds.d.ts +78 -0
- package/lib/axis/core/logAxisBounds.d.ts.map +1 -0
- package/lib/axis/core/logAxisBounds.js +129 -0
- package/lib/axis/core/logAxisBounds.js.map +1 -0
- package/lib/axis/ui/AxisScaleControl.d.ts +66 -0
- package/lib/axis/ui/AxisScaleControl.d.ts.map +1 -0
- package/lib/axis/ui/AxisScaleControl.js +26 -0
- package/lib/axis/ui/AxisScaleControl.js.map +1 -0
- package/lib/axis/ui/index.d.ts +6 -0
- package/lib/axis/ui/index.d.ts.map +1 -0
- package/lib/axis/ui/index.js +5 -0
- package/lib/axis/ui/index.js.map +1 -0
- package/lib/core.d.ts +1 -0
- package/lib/core.d.ts.map +1 -1
- package/lib/core.js +1 -0
- package/lib/core.js.map +1 -1
- package/lib/delimited/core/index.d.ts +2 -0
- package/lib/delimited/core/index.d.ts.map +1 -1
- package/lib/delimited/core/index.js +1 -0
- package/lib/delimited/core/index.js.map +1 -1
- package/lib/delimited/core/tableRows.d.ts +49 -0
- package/lib/delimited/core/tableRows.d.ts.map +1 -0
- package/lib/delimited/core/tableRows.js +63 -0
- package/lib/delimited/core/tableRows.js.map +1 -0
- package/lib/delimited/ui/DelimitedTextPanel.d.ts +9 -0
- package/lib/delimited/ui/DelimitedTextPanel.d.ts.map +1 -1
- package/lib/delimited/ui/DelimitedTextPanel.js +3 -2
- package/lib/delimited/ui/DelimitedTextPanel.js.map +1 -1
- package/lib/delimited/ui/TableDataButton.d.ts +96 -0
- package/lib/delimited/ui/TableDataButton.d.ts.map +1 -0
- package/lib/delimited/ui/TableDataButton.js +39 -0
- package/lib/delimited/ui/TableDataButton.js.map +1 -0
- package/lib/delimited/ui/index.d.ts +2 -0
- package/lib/delimited/ui/index.d.ts.map +1 -1
- package/lib/delimited/ui/index.js +1 -0
- package/lib/delimited/ui/index.js.map +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
- package/lib/locales/de.json +6 -0
- package/lib/locales/en.json +6 -0
- package/lib/locales/es.json +6 -0
- package/lib/locales/fr.json +6 -0
- package/lib/locales/it.json +6 -0
- package/lib/periodic/core/index.d.ts +1 -1
- package/lib/periodic/core/index.d.ts.map +1 -1
- package/lib/periodic/core/index.js +1 -1
- package/lib/periodic/core/index.js.map +1 -1
- package/lib/periodic/core/layout.d.ts +18 -0
- package/lib/periodic/core/layout.d.ts.map +1 -1
- package/lib/periodic/core/layout.js +9 -0
- package/lib/periodic/core/layout.js.map +1 -1
- package/lib/periodic/ui/ElementCell.js +15 -3
- package/lib/periodic/ui/ElementCell.js.map +1 -1
- package/lib/periodic/ui/PeriodicTable.d.ts +12 -1
- package/lib/periodic/ui/PeriodicTable.d.ts.map +1 -1
- package/lib/periodic/ui/PeriodicTable.js +25 -3
- package/lib/periodic/ui/PeriodicTable.js.map +1 -1
- package/lib/ui.d.ts +1 -0
- package/lib/ui.d.ts.map +1 -1
- package/lib/ui.js +1 -0
- package/lib/ui.js.map +1 -1
- package/package.json +1 -1
- package/src/axis/core/axisMarks.ts +114 -0
- package/src/axis/core/axisScale.ts +41 -0
- package/src/axis/core/index.ts +20 -0
- package/src/axis/core/logAxisBounds.ts +198 -0
- package/src/axis/ui/AxisScaleControl.tsx +103 -0
- package/src/axis/ui/index.ts +9 -0
- package/src/core.ts +1 -0
- package/src/delimited/core/index.ts +2 -0
- package/src/delimited/core/tableRows.ts +93 -0
- package/src/delimited/ui/DelimitedTextPanel.tsx +25 -9
- package/src/delimited/ui/TableDataButton.tsx +162 -0
- package/src/delimited/ui/index.ts +2 -0
- package/src/locales/de.json +6 -0
- package/src/locales/en.json +6 -0
- package/src/locales/es.json +6 -0
- package/src/locales/fr.json +6 -0
- package/src/locales/it.json +6 -0
- package/src/periodic/core/index.ts +1 -0
- package/src/periodic/core/layout.ts +19 -0
- package/src/periodic/ui/ElementCell.tsx +15 -3
- package/src/periodic/ui/PeriodicTable.tsx +45 -1
- package/src/ui.ts +1 -0
- package/styles/chrome.css +71 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/periodic/core/layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGtE,0DAA0D;AAC1D,MAAM,WAAW,YAAY;IAC3B,8CAA8C;IAC9C,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzB,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;CACf;AAED,2DAA2D;AAC3D,MAAM,WAAW,IAAI;IACnB,8BAA8B;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,2BAA2B;IAC3B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,4BAA4B;AAC5B,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B,uEAAuE;AACvE,eAAO,MAAM,SAAS,KAAK,CAAC;AAc5B;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAIrD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,aAAa,CAAC;IAC9C,OAAO,EAAE,eAA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zB,IAAI,EAAE,IAAI,CAAC;CACZ,CAAC,CAUD;AAOD;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,EAAE;IACxB,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,iCAAiC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;CACmC,CAAC;AAEtD;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,EAAE,aAAa,CAAC;IACnD,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,eAAe,CAAC;CAC3B,CAGA,CAAC;AAEF,0EAA0E;AAC1E,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAAC;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB,CAGA,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,GAAG,SAAS,GACvB,eAAe,GAAG,IAAI,CAgBxB"}
|
|
@@ -49,6 +49,15 @@ export function placedElements() {
|
|
|
49
49
|
return placedCache;
|
|
50
50
|
}
|
|
51
51
|
let placedCache = null;
|
|
52
|
+
/**
|
|
53
|
+
* The block of cells the table leaves empty, where no element belongs: logical
|
|
54
|
+
* columns 3 to 12 of the first three periods.
|
|
55
|
+
*
|
|
56
|
+
* It is a tenth of the drawing, in the middle of the top edge, and the one
|
|
57
|
+
* place a tool can write without covering an element — which is why a table
|
|
58
|
+
* printed on a wall puts its title or its key there.
|
|
59
|
+
*/
|
|
60
|
+
export const EMPTY_BLOCK = { column: 3, row: 1, columnSpan: 10, rowSpan: 3 };
|
|
52
61
|
/**
|
|
53
62
|
* The two cells the lanthanoids and the actinoids were lifted out of.
|
|
54
63
|
*
|
|
@@ -1 +1 @@
|
|
|
1
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,uBAAuB,CAAC,OAAO,EAAE,EAAE,CAAC;QAC/D,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,KAAK,CAAC;QAC5C,IAAI,MAAM,IAAI,CAAC,IAAI,MAAM,GAAG,uBAAuB,EAAE,CAAC;YACpD,OAAO;gBACL,MAAM,EAAE,uBAAuB,GAAG,MAAM;gBACxC,GAAG,EAAE,oBAAoB,GAAG,KAAK;aAClC,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -147,15 +147,27 @@ const cellStyle = {
|
|
|
147
147
|
minWidth: 0,
|
|
148
148
|
overflow: 'hidden',
|
|
149
149
|
padding: '1px',
|
|
150
|
+
// The corner the atomic number is pinned into.
|
|
151
|
+
position: 'relative',
|
|
150
152
|
transition: 'opacity 120ms ease, filter 120ms ease',
|
|
151
153
|
};
|
|
154
|
+
/**
|
|
155
|
+
* The atomic number sits out of the flow, in the corner.
|
|
156
|
+
*
|
|
157
|
+
* In the flow it rode on top of a stack the cell centres, so it moved down
|
|
158
|
+
* whenever what is written under the symbol was written smaller — the numbers
|
|
159
|
+
* of a row then sat at as many heights as the row had word lengths. Out of it,
|
|
160
|
+
* the number is in the same corner of every cell, and the symbol is centred in
|
|
161
|
+
* the cell rather than in what is left of it.
|
|
162
|
+
*/
|
|
152
163
|
const numberStyle = {
|
|
153
|
-
|
|
154
|
-
fontSize: 'max(0.33rem, 1.2cqw)',
|
|
164
|
+
fontSize: 'max(0.33rem, 1.1cqw)',
|
|
155
165
|
fontVariantNumeric: 'tabular-nums',
|
|
166
|
+
left: 'max(1px, 0.14cqw)',
|
|
156
167
|
lineHeight: 1,
|
|
157
168
|
opacity: 0.8,
|
|
158
|
-
|
|
169
|
+
position: 'absolute',
|
|
170
|
+
top: 'max(1px, 0.14cqw)',
|
|
159
171
|
};
|
|
160
172
|
const symbolStyle = {
|
|
161
173
|
fontWeight: 700,
|
|
@@ -1 +1 @@
|
|
|
1
|
-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,EAAE,cAAc;IAClC,UAAU,EAAE,CAAC;IACb,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,QAAQ;IAClB,UAAU,EAAE,QAAQ;CACY,CAAC"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Everything site-specific arrives through a callback keyed on the element, so
|
|
10
10
|
* a site's own richer element record never has to cross into this component.
|
|
11
11
|
*/
|
|
12
|
-
import type { ReactElement } from 'react';
|
|
12
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
13
13
|
import type { Swatch } from '../../color/core/interpolate.ts';
|
|
14
14
|
import type { PeriodicElement } from '../core/elements.ts';
|
|
15
15
|
import type { ElementRange } from '../core/layout.ts';
|
|
@@ -48,6 +48,17 @@ export interface PeriodicTableProps {
|
|
|
48
48
|
* @default every element is
|
|
49
49
|
*/
|
|
50
50
|
isIncluded?: (element: PeriodicElement) => boolean;
|
|
51
|
+
/**
|
|
52
|
+
* What is written in the block the table leaves empty — columns 3 to 12 of
|
|
53
|
+
* the first three periods, in the middle of the top edge. A tool that reads
|
|
54
|
+
* one element off the table puts what it says about it there, where the eye
|
|
55
|
+
* already is, rather than under the grid.
|
|
56
|
+
*
|
|
57
|
+
* It is sized against the table, like everything else in the grid, so give
|
|
58
|
+
* it type in `em` and it scales with the drawing.
|
|
59
|
+
* @default undefined — the block stays empty
|
|
60
|
+
*/
|
|
61
|
+
inset?: ReactNode;
|
|
51
62
|
/**
|
|
52
63
|
* Whether to draw the group and period strips.
|
|
53
64
|
* @default false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PeriodicTable.d.ts","sourceRoot":"","sources":["../../../src/periodic/ui/PeriodicTable.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"PeriodicTable.d.ts","sourceRoot":"","sources":["../../../src/periodic/ui/PeriodicTable.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KA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,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,YAAY,CA+ErE"}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useRef } from 'react';
|
|
3
3
|
import { useChromeT } from "../../i18n/ui/useT.js";
|
|
4
4
|
import { categorySwatch } from "../core/categories.js";
|
|
5
|
-
import { COLUMN_COUNT, elementByArrowKey, placedElements, } from "../core/layout.js";
|
|
5
|
+
import { COLUMN_COUNT, EMPTY_BLOCK, elementByArrowKey, placedElements, } from "../core/layout.js";
|
|
6
6
|
import { CategoryLegend } from "./CategoryLegend.js";
|
|
7
7
|
import { ElementCell } from "./ElementCell.js";
|
|
8
8
|
import { HeaderStrips, InnerTransitionMarkers, } from "./PeriodicTableChrome.js";
|
|
@@ -12,7 +12,7 @@ import { HeaderStrips, InnerTransitionMarkers, } from "./PeriodicTableChrome.js"
|
|
|
12
12
|
* @returns The grid, its optional chrome, and its optional legend.
|
|
13
13
|
*/
|
|
14
14
|
export function PeriodicTable(props) {
|
|
15
|
-
const { selected, onSelect, swatchOf = defaultSwatchOf, detailOf, nameOf = defaultNameOf, isIncluded, headers = false, onSelectRange, legend = false, markers = true, keyboard = true, onHover, className, } = props;
|
|
15
|
+
const { selected, onSelect, swatchOf = defaultSwatchOf, detailOf, nameOf = defaultNameOf, isIncluded, inset, headers = false, onSelectRange, legend = false, markers = true, keyboard = true, onHover, className, } = props;
|
|
16
16
|
const t = useChromeT();
|
|
17
17
|
const writesDetail = detailOf !== undefined;
|
|
18
18
|
const gridRef = useRef(null);
|
|
@@ -36,7 +36,29 @@ export function PeriodicTable(props) {
|
|
|
36
36
|
cameFromKeyRef.current = true;
|
|
37
37
|
onSelect(next.symbol);
|
|
38
38
|
}
|
|
39
|
-
return (_jsxs("div", { className: className, style: rootStyle, children: [_jsxs("div", { ref: gridRef, role: "grid", "aria-label": t('periodic.table'), "data-testid": "periodic-table", style: gridStyle(headers, writesDetail), onKeyDown: handleKeyDown, children: [headers ? _jsx(HeaderStrips, { onSelectRange: onSelectRange }) : null, markers ? _jsx(InnerTransitionMarkers, { offset: offset }) : null, placedElements().map(({ element, cell }) => (_jsx(ElementCell, { atomicNumber: element.atomicNumber, symbol: element.symbol, name: nameOf(element), detail: detailOf?.(element), writesDetail: writesDetail, swatch: swatchOf(element), isSelected: element.symbol === selected, isIncluded: isIncluded?.(element), column: cell.column + offset, row: cell.row + offset, onSelect: onSelect ?? noop, onHover: onHover }, element.symbol)))] }), legend ? _jsx(CategoryLegend, {}) : null] }));
|
|
39
|
+
return (_jsxs("div", { className: className, style: rootStyle, children: [_jsxs("div", { ref: gridRef, role: "grid", "aria-label": t('periodic.table'), "data-testid": "periodic-table", style: gridStyle(headers, writesDetail), onKeyDown: handleKeyDown, children: [headers ? _jsx(HeaderStrips, { onSelectRange: onSelectRange }) : null, inset === undefined ? null : (_jsx("div", { style: insetStyle(offset), children: inset })), markers ? _jsx(InnerTransitionMarkers, { offset: offset }) : null, placedElements().map(({ element, cell }) => (_jsx(ElementCell, { atomicNumber: element.atomicNumber, symbol: element.symbol, name: nameOf(element), detail: detailOf?.(element), writesDetail: writesDetail, swatch: swatchOf(element), isSelected: element.symbol === selected, isIncluded: isIncluded?.(element), column: cell.column + offset, row: cell.row + offset, onSelect: onSelect ?? noop, onHover: onHover }, element.symbol)))] }), legend ? _jsx(CategoryLegend, {}) : null] }));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Where what the caller writes in the empty block is placed.
|
|
43
|
+
* @param offset - 1 when the table draws its header strips, 0 otherwise.
|
|
44
|
+
* @returns The style of the slot.
|
|
45
|
+
*/
|
|
46
|
+
function insetStyle(offset) {
|
|
47
|
+
return {
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
display: 'flex',
|
|
50
|
+
// Narrower than the block so the writing never touches the cells beside it.
|
|
51
|
+
padding: '0 1cqw',
|
|
52
|
+
gridColumn: `${String(EMPTY_BLOCK.column + offset)} / span ${String(EMPTY_BLOCK.columnSpan)}`,
|
|
53
|
+
gridRow: `${String(EMPTY_BLOCK.row + offset)} / span ${String(EMPTY_BLOCK.rowSpan)}`,
|
|
54
|
+
// A share of the table, with a floor, exactly as a cell sizes its symbol:
|
|
55
|
+
// the block holds the same three rows at every width, so what is written
|
|
56
|
+
// in it has to shrink with them.
|
|
57
|
+
fontSize: 'max(0.6rem, 1.8cqw)',
|
|
58
|
+
lineHeight: 1.35,
|
|
59
|
+
minWidth: 0,
|
|
60
|
+
overflow: 'hidden',
|
|
61
|
+
};
|
|
40
62
|
}
|
|
41
63
|
function defaultSwatchOf(element) {
|
|
42
64
|
return categorySwatch(element.category);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PeriodicTable.js","sourceRoot":"","sources":["../../../src/periodic/ui/PeriodicTable.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"PeriodicTable.js","sourceRoot":"","sources":["../../../src/periodic/ui/PeriodicTable.tsx"],"names":[],"mappings":";AAkBA,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,WAAW,EACX,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;AAwFnC;;;;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,KAAK,EAC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B,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
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,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,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,cA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AAc,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.
|
|
3
|
+
"version": "0.34.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",
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a figure's marks land inside its box, so something else can count them.
|
|
3
|
+
*
|
|
4
|
+
* `emptiestCorner` picks the corner a floating card can sit in without covering
|
|
5
|
+
* the cluster the reader came for, and it needs screen positions to do it. A
|
|
6
|
+
* chart drawn by a library builds its scales during its own render, where a
|
|
7
|
+
* caller cannot reach them, so the positions are worked out here from the same
|
|
8
|
+
* values and the same two transforms the axes use.
|
|
9
|
+
*
|
|
10
|
+
* It is an estimate, which is all a corner needs: the plot area is inset from
|
|
11
|
+
* the box by the margins, and a mark a few pixels from a corner counts for that
|
|
12
|
+
* corner either way.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { AxisScale } from './axisScale.ts';
|
|
16
|
+
|
|
17
|
+
/** A point of the figure, in the quantities its axes carry. */
|
|
18
|
+
export interface AxisPoint {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Pixel positions of every mark, as `emptiestCorner` reads them. */
|
|
24
|
+
export interface AxisMarkPositions {
|
|
25
|
+
x: Float64Array;
|
|
26
|
+
y: Float64Array;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** What {@link axisMarkPositions} needs beyond the points and the box. */
|
|
30
|
+
export interface AxisMarkPositionsOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Width of the linear region of a logarithmic axis — d3's symmetric-log
|
|
33
|
+
* `constant`. Pass `0` for a true logarithmic axis.
|
|
34
|
+
* @default 1
|
|
35
|
+
*/
|
|
36
|
+
constant?: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Place every point in the box the figure is drawn in.
|
|
41
|
+
* @param points - The points the figure draws.
|
|
42
|
+
* @param box - Its size, in pixels, normally from `useContainerSize`.
|
|
43
|
+
* @param box.width - How wide the figure is drawn.
|
|
44
|
+
* @param box.height - How tall it is drawn.
|
|
45
|
+
* @param scale - The scale each axis is drawn on, which the positions have to
|
|
46
|
+
* follow to land where the marks do.
|
|
47
|
+
* @param scale.y - How the vertical axis is read.
|
|
48
|
+
* @param scale.x - How the horizontal axis is read.
|
|
49
|
+
* @param options - See {@link AxisMarkPositionsOptions}.
|
|
50
|
+
* @returns One position per point, in the order they were given.
|
|
51
|
+
*/
|
|
52
|
+
export function axisMarkPositions(
|
|
53
|
+
points: readonly AxisPoint[],
|
|
54
|
+
box: { width: number; height: number },
|
|
55
|
+
scale: { x: AxisScale; y: AxisScale },
|
|
56
|
+
options: AxisMarkPositionsOptions = {},
|
|
57
|
+
): AxisMarkPositions {
|
|
58
|
+
const { constant = 1 } = options;
|
|
59
|
+
const x = new Float64Array(points.length);
|
|
60
|
+
const y = new Float64Array(points.length);
|
|
61
|
+
|
|
62
|
+
place(points, 'x', scale.x === 'log', constant, box.width, x);
|
|
63
|
+
place(points, 'y', scale.y === 'log', constant, box.height, y);
|
|
64
|
+
// The vertical axis grows upwards while the box is measured from its top.
|
|
65
|
+
for (let index = 0; index < y.length; index++) {
|
|
66
|
+
y[index] = box.height - (y[index] as number);
|
|
67
|
+
}
|
|
68
|
+
return { x, y };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function place(
|
|
72
|
+
points: readonly AxisPoint[],
|
|
73
|
+
axis: 'x' | 'y',
|
|
74
|
+
logarithmic: boolean,
|
|
75
|
+
constant: number,
|
|
76
|
+
extent: number,
|
|
77
|
+
into: Float64Array,
|
|
78
|
+
): void {
|
|
79
|
+
let min = Infinity;
|
|
80
|
+
let max = -Infinity;
|
|
81
|
+
for (let index = 0; index < points.length; index++) {
|
|
82
|
+
const value = transform(
|
|
83
|
+
(points[index] as AxisPoint)[axis],
|
|
84
|
+
logarithmic,
|
|
85
|
+
constant,
|
|
86
|
+
);
|
|
87
|
+
into[index] = value;
|
|
88
|
+
if (value < min) min = value;
|
|
89
|
+
if (value > max) max = value;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const span = max - min;
|
|
93
|
+
for (let index = 0; index < into.length; index++) {
|
|
94
|
+
const value = (into[index] as number) - min;
|
|
95
|
+
into[index] = span === 0 ? extent / 2 : (value / span) * extent;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* d3's symmetric log, which is the one a genuine zero survives.
|
|
101
|
+
* @param value - The value to place.
|
|
102
|
+
* @param logarithmic - Whether the axis is read logarithmically at all.
|
|
103
|
+
* @param constant - Width of its linear region.
|
|
104
|
+
* @returns The value in the units the axis is spaced in.
|
|
105
|
+
*/
|
|
106
|
+
function transform(
|
|
107
|
+
value: number,
|
|
108
|
+
logarithmic: boolean,
|
|
109
|
+
constant: number,
|
|
110
|
+
): number {
|
|
111
|
+
if (!logarithmic) return value;
|
|
112
|
+
const width = constant > 0 ? constant : 1;
|
|
113
|
+
return Math.sign(value) * Math.log1p(Math.abs(value) / width);
|
|
114
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which of the two scales a quantity is read on, and who decided.
|
|
3
|
+
*
|
|
4
|
+
* Every quantity has a scale it is usually read on — a concentration spanning
|
|
5
|
+
* ten decades is read logarithmically, a first ionisation energy linearly — and
|
|
6
|
+
* a reader may overrule it. The two are kept apart rather than collapsed into
|
|
7
|
+
* one boolean, because a figure that forgets which it is holding gets both of
|
|
8
|
+
* the following wrong: picking another quantity has to bring that quantity's
|
|
9
|
+
* own scale rather than carry the last one over, and a link has to stay silent
|
|
10
|
+
* about a scale nobody chose, so that it keeps opening the way the quantity is
|
|
11
|
+
* read even after the usual scale is reconsidered.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** The two scales an axis is drawn on. */
|
|
15
|
+
export type AxisScale = 'linear' | 'log';
|
|
16
|
+
|
|
17
|
+
/** A reader's choice, or `null` while they have not made one. */
|
|
18
|
+
export type AxisScaleChoice = AxisScale | null;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The scale an axis is actually drawn on.
|
|
22
|
+
* @param usual - How the quantity on the axis is normally read.
|
|
23
|
+
* @param chosen - What the reader asked for, or `null` to leave it to the
|
|
24
|
+
* quantity.
|
|
25
|
+
* @returns The scale to draw.
|
|
26
|
+
*/
|
|
27
|
+
export function resolveAxisScale(
|
|
28
|
+
usual: AxisScale,
|
|
29
|
+
chosen: AxisScaleChoice,
|
|
30
|
+
): AxisScale {
|
|
31
|
+
return chosen ?? usual;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Narrow an arbitrary string — one off a query parameter — to a scale.
|
|
36
|
+
* @param value - Candidate scale.
|
|
37
|
+
* @returns True when it is one of the two.
|
|
38
|
+
*/
|
|
39
|
+
export function isAxisScale(value: string): value is AxisScale {
|
|
40
|
+
return value === 'linear' || value === 'log';
|
|
41
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How an axis is read: linearly or logarithmically, who decided, where it
|
|
3
|
+
* starts and ends, and where its marks land.
|
|
4
|
+
*
|
|
5
|
+
* It is a domain of its own rather than part of any chart, because the library
|
|
6
|
+
* draws figures with three different renderers and the sites draw more with
|
|
7
|
+
* libraries of their own — and the two things that go wrong on a logarithmic
|
|
8
|
+
* axis go wrong the same way in all of them.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export type {
|
|
12
|
+
AxisMarkPositions,
|
|
13
|
+
AxisMarkPositionsOptions,
|
|
14
|
+
AxisPoint,
|
|
15
|
+
} from './axisMarks.ts';
|
|
16
|
+
export { axisMarkPositions } from './axisMarks.ts';
|
|
17
|
+
export type { AxisScale, AxisScaleChoice } from './axisScale.ts';
|
|
18
|
+
export { isAxisScale, resolveAxisScale } from './axisScale.ts';
|
|
19
|
+
export type { LogAxisBounds, LogAxisBoundsOptions } from './logAxisBounds.ts';
|
|
20
|
+
export { logAxisBounds } from './logAxisBounds.ts';
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ends of a logarithmic axis, and the values it is graduated at.
|
|
3
|
+
*
|
|
4
|
+
* Both have to be stated rather than left to the charting library, and for two
|
|
5
|
+
* separate reasons.
|
|
6
|
+
*
|
|
7
|
+
* The ends, because a library that finds them itself may not look at every
|
|
8
|
+
* value. nivo is the measured case: it sorts and takes a true minimum and
|
|
9
|
+
* maximum only for a linear axis, and on a log or symmetric-log one `'auto'`
|
|
10
|
+
* resolves to the first value the data carries and the last — so the domain
|
|
11
|
+
* comes out in plotting order, upside down whenever the first point outweighs
|
|
12
|
+
* the last, and cutting off everything past the last point drawn.
|
|
13
|
+
*
|
|
14
|
+
* The graduations, because d3 rules a symmetric-log axis at evenly *spaced*
|
|
15
|
+
* values while placing them logarithmically, so the top of a wide axis collects
|
|
16
|
+
* every graduation it has into one unreadable line. Ruling it by decade spreads
|
|
17
|
+
* them evenly, which is also how such a quantity is read.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** What {@link logAxisBounds} answers. */
|
|
21
|
+
export interface LogAxisBounds {
|
|
22
|
+
/** The low end of the axis. */
|
|
23
|
+
min: number;
|
|
24
|
+
/** The high end. */
|
|
25
|
+
max: number;
|
|
26
|
+
/**
|
|
27
|
+
* The values to rule it at, or `undefined` for an axis spanning too few
|
|
28
|
+
* decades to be worth ruling by them — there the library's own linear
|
|
29
|
+
* graduations read better, and there is no pile-up to undo.
|
|
30
|
+
*/
|
|
31
|
+
tickValues?: number[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** What {@link logAxisBounds} needs beyond the values. */
|
|
35
|
+
export interface LogAxisBoundsOptions {
|
|
36
|
+
/**
|
|
37
|
+
* Width of the linear region at the bottom of a symmetric-log axis — d3's
|
|
38
|
+
* `constant`. Everything smaller than it is placed almost on the zero line,
|
|
39
|
+
* so no graduation is written below it; a graduation there would land on top
|
|
40
|
+
* of the one before it, which is the pile-up this exists to prevent.
|
|
41
|
+
*
|
|
42
|
+
* Pass `0` for a true logarithmic axis, which has no such region — and which
|
|
43
|
+
* cannot place a zero or a negative at all, so those values are then left out
|
|
44
|
+
* of the ends rather than dragging them to nothing.
|
|
45
|
+
* @default 1
|
|
46
|
+
*/
|
|
47
|
+
constant?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Whether the ends are rounded outwards to whole powers of ten. An axis that
|
|
50
|
+
* ends on its own extreme values reads as though those were round numbers;
|
|
51
|
+
* one that ends on decades says what it is. Worth it on a true logarithmic
|
|
52
|
+
* axis, where every graduation is a decade anyway.
|
|
53
|
+
* @default false — the ends are the data's own
|
|
54
|
+
*/
|
|
55
|
+
snapToDecades?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* How many decades the axis may span at most, counted down from its top. A
|
|
58
|
+
* quantity that reaches zero asymptotically has no meaningful bottom, and an
|
|
59
|
+
* axis given one spends most of its height on values nobody is reading.
|
|
60
|
+
* Only consulted with `snapToDecades`.
|
|
61
|
+
* @default Infinity — the axis spans whatever the data does
|
|
62
|
+
*/
|
|
63
|
+
maxDecades?: number;
|
|
64
|
+
/**
|
|
65
|
+
* How many graduations the axis may carry. More than this is a smear however
|
|
66
|
+
* they are spread, so the decades are stepped over rather than written out.
|
|
67
|
+
* @default 10
|
|
68
|
+
*/
|
|
69
|
+
mostTicks?: number;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Under this many decades the library's own graduations read better. */
|
|
73
|
+
const RULE_PAST_DECADES = 3;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Where a logarithmic axis starts and ends, and where it is graduated.
|
|
77
|
+
* @param values - Every value plotted on the axis. Anything not finite is
|
|
78
|
+
* ignored, so a sheet's gaps need not be filtered out first.
|
|
79
|
+
* @param options - See {@link LogAxisBoundsOptions}.
|
|
80
|
+
* @returns The ends and the graduations, or `null` when no value can be drawn
|
|
81
|
+
* and the caller should leave the axis to its library.
|
|
82
|
+
*/
|
|
83
|
+
export function logAxisBounds(
|
|
84
|
+
values: Iterable<number>,
|
|
85
|
+
options: LogAxisBoundsOptions = {},
|
|
86
|
+
): LogAxisBounds | null {
|
|
87
|
+
const { constant = 1, snapToDecades = false } = options;
|
|
88
|
+
const { maxDecades = Infinity, mostTicks = 10 } = options;
|
|
89
|
+
// A true logarithmic axis has no room for a zero or a negative, so they are
|
|
90
|
+
// not what its bottom end is taken from.
|
|
91
|
+
const positiveOnly = constant === 0;
|
|
92
|
+
|
|
93
|
+
let min = Infinity;
|
|
94
|
+
let max = -Infinity;
|
|
95
|
+
for (const value of values) {
|
|
96
|
+
if (!Number.isFinite(value)) continue;
|
|
97
|
+
if (positiveOnly && value <= 0) continue;
|
|
98
|
+
if (value < min) min = value;
|
|
99
|
+
if (value > max) max = value;
|
|
100
|
+
}
|
|
101
|
+
if (min > max) return null;
|
|
102
|
+
|
|
103
|
+
if (snapToDecades) {
|
|
104
|
+
const top = Math.ceil(Math.log10(Math.abs(max) || 1));
|
|
105
|
+
const bottom = Math.max(
|
|
106
|
+
Math.floor(Math.log10(Math.abs(min) || 1)),
|
|
107
|
+
top - maxDecades,
|
|
108
|
+
);
|
|
109
|
+
return withTicks(decade(bottom), decade(top), constant, mostTicks);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// A lone value, or a column of identical ones, spans nothing: reach to the
|
|
113
|
+
// origin so it is read against a zero rather than filling the axis.
|
|
114
|
+
if (min === max) {
|
|
115
|
+
if (min === 0) return { min: -1, max: 1 };
|
|
116
|
+
return { min: Math.min(min, 0), max: Math.max(max, 0) };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return withTicks(min, max, constant, mostTicks);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The ends, with the graduations when they are worth writing.
|
|
124
|
+
* @param min
|
|
125
|
+
* @param max
|
|
126
|
+
* @param constant
|
|
127
|
+
* @param mostTicks
|
|
128
|
+
*/
|
|
129
|
+
function withTicks(
|
|
130
|
+
min: number,
|
|
131
|
+
max: number,
|
|
132
|
+
constant: number,
|
|
133
|
+
mostTicks: number,
|
|
134
|
+
): LogAxisBounds {
|
|
135
|
+
const ticks = decadesBetween(min, max, constant, mostTicks);
|
|
136
|
+
return ticks === undefined ? { min, max } : { min, max, tickValues: ticks };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Zero, and the powers of ten the axis both reaches and can separate.
|
|
141
|
+
* @param min - The low end of the axis.
|
|
142
|
+
* @param max - Its high end.
|
|
143
|
+
* @param constant - Width of the linear region; see the options.
|
|
144
|
+
* @param mostTicks - How many graduations the axis may carry.
|
|
145
|
+
* @returns The values to rule it at, or nothing to leave it to the library.
|
|
146
|
+
*/
|
|
147
|
+
function decadesBetween(
|
|
148
|
+
min: number,
|
|
149
|
+
max: number,
|
|
150
|
+
constant: number,
|
|
151
|
+
mostTicks: number,
|
|
152
|
+
): number[] | undefined {
|
|
153
|
+
const largest = Math.max(Math.abs(min), Math.abs(max));
|
|
154
|
+
if (largest === 0) return undefined;
|
|
155
|
+
|
|
156
|
+
// Below the linear region every decade lands on the same pixel, so the axis
|
|
157
|
+
// is ruled from there up rather than from its smallest value.
|
|
158
|
+
const floor = constant > 0 ? Math.log10(constant) : smallestDecade(min, max);
|
|
159
|
+
const bottom = Math.ceil(floor);
|
|
160
|
+
const top = Math.floor(Math.log10(largest));
|
|
161
|
+
// Under a few decades the library's own graduations read better — but only
|
|
162
|
+
// where it has linear ones to offer. On a true logarithmic axis every
|
|
163
|
+
// graduation is a decade, so a short one is still ruled by decade.
|
|
164
|
+
if (constant > 0 && top - bottom + 1 < RULE_PAST_DECADES) return undefined;
|
|
165
|
+
|
|
166
|
+
const step = Math.ceil((top - bottom + 1) / mostTicks);
|
|
167
|
+
const ticks = min <= 0 && max >= 0 ? [0] : [];
|
|
168
|
+
for (let power = bottom; power <= top; power += step) {
|
|
169
|
+
const tick = decade(power);
|
|
170
|
+
if (tick >= min && tick <= max) ticks.push(tick);
|
|
171
|
+
}
|
|
172
|
+
if (constant === 0) return ticks;
|
|
173
|
+
return ticks.length < RULE_PAST_DECADES ? undefined : ticks;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* A whole power of ten.
|
|
178
|
+
* @param power - The exponent, a whole number.
|
|
179
|
+
* @returns Ten to that power, the same bits on every engine.
|
|
180
|
+
*/
|
|
181
|
+
function decade(power: number): number {
|
|
182
|
+
// Read as a decimal rather than computed: `10 ** power` goes through pow,
|
|
183
|
+
// which is not bit-exact across V8 versions — node 22 answers
|
|
184
|
+
// 0.00009999999999999999 for -4 and 1.0000000000000001e-20 for -20 — while a
|
|
185
|
+
// decimal literal is the correctly-rounded double everywhere.
|
|
186
|
+
return Number(`1e${power}`);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* The decade of the smaller end, for an axis with no linear region.
|
|
191
|
+
* @param min - The low end of the axis.
|
|
192
|
+
* @param max - Its high end.
|
|
193
|
+
* @returns The base-ten logarithm of the smaller end that is not zero.
|
|
194
|
+
*/
|
|
195
|
+
function smallestDecade(min: number, max: number): number {
|
|
196
|
+
const ends = [Math.abs(min), Math.abs(max)].filter((end) => end > 0);
|
|
197
|
+
return Math.log10(Math.min(...ends));
|
|
198
|
+
}
|