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.
- package/README.md +21 -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/download/core/downloadFigure.d.ts +7 -5
- package/lib/download/core/downloadFigure.d.ts.map +1 -1
- package/lib/download/core/downloadFigure.js +7 -6
- package/lib/download/core/downloadFigure.js.map +1 -1
- package/lib/download/core/figureLayout.d.ts +55 -0
- package/lib/download/core/figureLayout.d.ts.map +1 -0
- package/lib/download/core/figureLayout.js +89 -0
- package/lib/download/core/figureLayout.js.map +1 -0
- package/lib/download/core/figureScale.d.ts +9 -0
- package/lib/download/core/figureScale.d.ts.map +1 -1
- package/lib/download/core/figureScale.js +10 -0
- package/lib/download/core/figureScale.js.map +1 -1
- package/lib/download/core/figureSettle.d.ts +51 -0
- package/lib/download/core/figureSettle.d.ts.map +1 -0
- package/lib/download/core/figureSettle.js +81 -0
- package/lib/download/core/figureSettle.js.map +1 -0
- package/lib/download/core/figureSvg.d.ts +7 -1
- package/lib/download/core/figureSvg.d.ts.map +1 -1
- package/lib/download/core/figureSvg.js +1 -0
- package/lib/download/core/figureSvg.js.map +1 -1
- package/lib/download/core/figureSvgDocument.d.ts +7 -0
- package/lib/download/core/figureSvgDocument.d.ts.map +1 -1
- package/lib/download/core/figureSvgDocument.js +11 -2
- package/lib/download/core/figureSvgDocument.js.map +1 -1
- package/lib/download/core/index.d.ts +5 -1
- package/lib/download/core/index.d.ts.map +1 -1
- package/lib/download/core/index.js +3 -1
- package/lib/download/core/index.js.map +1 -1
- package/lib/download/ui/FigureDownload.d.ts +18 -4
- package/lib/download/ui/FigureDownload.d.ts.map +1 -1
- package/lib/download/ui/FigureDownload.js +35 -9
- package/lib/download/ui/FigureDownload.js.map +1 -1
- package/lib/download/ui/FigureDownloadPanel.d.ts +17 -7
- package/lib/download/ui/FigureDownloadPanel.d.ts.map +1 -1
- package/lib/download/ui/FigureDownloadPanel.js +30 -22
- package/lib/download/ui/FigureDownloadPanel.js.map +1 -1
- package/lib/download/ui/FigureSizeField.d.ts +27 -0
- package/lib/download/ui/FigureSizeField.d.ts.map +1 -0
- package/lib/download/ui/FigureSizeField.js +87 -0
- package/lib/download/ui/FigureSizeField.js.map +1 -0
- package/lib/download/ui/FigureSizeRows.d.ts +34 -0
- package/lib/download/ui/FigureSizeRows.d.ts.map +1 -0
- package/lib/download/ui/FigureSizeRows.js +54 -0
- package/lib/download/ui/FigureSizeRows.js.map +1 -0
- package/lib/download/ui/index.d.ts +2 -0
- package/lib/download/ui/index.d.ts.map +1 -1
- package/lib/download/ui/index.js.map +1 -1
- package/lib/download/ui/useFigureRedraw.d.ts +27 -0
- package/lib/download/ui/useFigureRedraw.d.ts.map +1 -0
- package/lib/download/ui/useFigureRedraw.js +78 -0
- package/lib/download/ui/useFigureRedraw.js.map +1 -0
- package/lib/i18n/core/chromeCatalog.d.ts +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
- package/lib/locales/de.json +13 -3
- package/lib/locales/en.json +13 -3
- package/lib/locales/es.json +13 -3
- package/lib/locales/fr.json +13 -3
- package/lib/number/core/index.d.ts +2 -0
- package/lib/number/core/index.d.ts.map +1 -0
- package/lib/number/core/index.js +2 -0
- package/lib/number/core/index.js.map +1 -0
- package/lib/number/core/numberText.d.ts +46 -0
- package/lib/number/core/numberText.d.ts.map +1 -0
- package/lib/number/core/numberText.js +88 -0
- package/lib/number/core/numberText.js.map +1 -0
- package/lib/number/ui/NumberInput.d.ts +113 -0
- package/lib/number/ui/NumberInput.d.ts.map +1 -0
- package/lib/number/ui/NumberInput.js +100 -0
- package/lib/number/ui/NumberInput.js.map +1 -0
- package/lib/number/ui/index.d.ts +3 -0
- package/lib/number/ui/index.d.ts.map +1 -0
- package/lib/number/ui/index.js +2 -0
- package/lib/number/ui/index.js.map +1 -0
- package/lib/overlay/ui/OverlayValueMenu.d.ts.map +1 -1
- package/lib/overlay/ui/OverlayValueMenu.js +7 -1
- package/lib/overlay/ui/OverlayValueMenu.js.map +1 -1
- package/lib/periodic/ui/ElementCell.d.ts +10 -0
- package/lib/periodic/ui/ElementCell.d.ts.map +1 -1
- package/lib/periodic/ui/ElementCell.js +124 -14
- package/lib/periodic/ui/ElementCell.js.map +1 -1
- package/lib/periodic/ui/PeriodicTable.d.ts.map +1 -1
- package/lib/periodic/ui/PeriodicTable.js +46 -19
- package/lib/periodic/ui/PeriodicTable.js.map +1 -1
- package/lib/periodic/ui/PeriodicTableChrome.js +2 -2
- package/lib/periodic/ui/PeriodicTableChrome.js.map +1 -1
- package/lib/spectra/ui/NumberField.d.ts +2 -5
- package/lib/spectra/ui/NumberField.d.ts.map +1 -1
- package/lib/spectra/ui/NumberField.js +4 -54
- package/lib/spectra/ui/NumberField.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/core.ts +1 -0
- package/src/download/core/downloadFigure.ts +12 -9
- package/src/download/core/figureLayout.ts +114 -0
- package/src/download/core/figureScale.ts +13 -0
- package/src/download/core/figureSettle.ts +112 -0
- package/src/download/core/figureSvg.ts +8 -1
- package/src/download/core/figureSvgDocument.ts +19 -2
- package/src/download/core/index.ts +13 -0
- package/src/download/ui/FigureDownload.tsx +88 -35
- package/src/download/ui/FigureDownloadPanel.tsx +45 -22
- package/src/download/ui/FigureSizeField.tsx +153 -0
- package/src/download/ui/FigureSizeRows.tsx +108 -0
- package/src/download/ui/index.ts +2 -0
- package/src/download/ui/useFigureRedraw.tsx +115 -0
- package/src/locales/de.json +13 -3
- package/src/locales/en.json +13 -3
- package/src/locales/es.json +13 -3
- package/src/locales/fr.json +13 -3
- package/src/number/core/index.ts +6 -0
- package/src/number/core/numberText.ts +91 -0
- package/src/number/ui/NumberInput.tsx +300 -0
- package/src/number/ui/index.ts +7 -0
- package/src/overlay/ui/OverlayValueMenu.tsx +7 -1
- package/src/periodic/ui/ElementCell.tsx +153 -14
- package/src/periodic/ui/PeriodicTable.tsx +51 -22
- package/src/periodic/ui/PeriodicTableChrome.tsx +2 -2
- package/src/spectra/ui/NumberField.tsx +11 -58
- package/src/ui.ts +1 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { CSSProperties, ReactElement } from 'react';
|
|
2
|
+
/** What every number box takes, whether or not it can be left empty. */
|
|
3
|
+
export interface NumberInputBaseProps {
|
|
4
|
+
/**
|
|
5
|
+
* Smallest accepted value, applied when the box is left rather than while it
|
|
6
|
+
* is typed in.
|
|
7
|
+
* @default undefined — unbounded below
|
|
8
|
+
*/
|
|
9
|
+
min?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Largest accepted value, applied when the box is left.
|
|
12
|
+
* @default undefined — unbounded above
|
|
13
|
+
*/
|
|
14
|
+
max?: number;
|
|
15
|
+
/**
|
|
16
|
+
* What one press of an arrow key or a stepper button adds; Shift multiplies
|
|
17
|
+
* it by ten and Alt divides it by ten.
|
|
18
|
+
* @default 1
|
|
19
|
+
*/
|
|
20
|
+
step?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Whether only whole numbers are wanted. A typed decimal is rounded when the
|
|
23
|
+
* box is left.
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
integer?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the up and down buttons are drawn beside the box.
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
31
|
+
buttons?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Grey text shown while the box is empty.
|
|
34
|
+
* @default undefined — the box carries no placeholder
|
|
35
|
+
*/
|
|
36
|
+
placeholder?: string;
|
|
37
|
+
/** @default false */
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Whether the control takes the whole width it is given.
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
fill?: boolean;
|
|
44
|
+
/** @default 'medium' */
|
|
45
|
+
size?: 'small' | 'medium' | 'large';
|
|
46
|
+
/**
|
|
47
|
+
* Accessible name, for a box no `<label>` points at.
|
|
48
|
+
* @default undefined — the box is named by its label
|
|
49
|
+
*/
|
|
50
|
+
ariaLabel?: string;
|
|
51
|
+
/**
|
|
52
|
+
* The box's id, for a `<label htmlFor>` elsewhere in the form.
|
|
53
|
+
* @default undefined
|
|
54
|
+
*/
|
|
55
|
+
id?: string;
|
|
56
|
+
/**
|
|
57
|
+
* A name a test finds the box by, written as `data-testid`.
|
|
58
|
+
* @default undefined
|
|
59
|
+
*/
|
|
60
|
+
testId?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Drawn inside the box at its left — a unit, a prefix such as `10⁻`.
|
|
63
|
+
* @default undefined
|
|
64
|
+
*/
|
|
65
|
+
leftElement?: ReactElement;
|
|
66
|
+
/**
|
|
67
|
+
* Drawn inside the box at its right — a unit, a small button.
|
|
68
|
+
* @default undefined
|
|
69
|
+
*/
|
|
70
|
+
rightElement?: ReactElement;
|
|
71
|
+
/** @default undefined */
|
|
72
|
+
className?: string;
|
|
73
|
+
/** @default undefined */
|
|
74
|
+
style?: CSSProperties;
|
|
75
|
+
}
|
|
76
|
+
/** A box that always holds a number. */
|
|
77
|
+
export interface RequiredNumberInputProps extends NumberInputBaseProps {
|
|
78
|
+
/** The number the box shows. */
|
|
79
|
+
value: number;
|
|
80
|
+
/**
|
|
81
|
+
* Whether an emptied box hands up nothing. A required box keeps the number
|
|
82
|
+
* it had and shows it again when the box is left.
|
|
83
|
+
* @default false
|
|
84
|
+
*/
|
|
85
|
+
allowEmpty?: false;
|
|
86
|
+
/** Called with the new number, never while the text is half-typed. */
|
|
87
|
+
onChange: (value: number) => void;
|
|
88
|
+
}
|
|
89
|
+
/** A box that may be left empty, which hands up `undefined`. */
|
|
90
|
+
export interface OptionalNumberInputProps extends NumberInputBaseProps {
|
|
91
|
+
/** The number the box shows, or nothing when it is empty. */
|
|
92
|
+
value: number | undefined;
|
|
93
|
+
allowEmpty: true;
|
|
94
|
+
/** Called with the new number, or with `undefined` when the box is emptied. */
|
|
95
|
+
onChange: (value: number | undefined) => void;
|
|
96
|
+
}
|
|
97
|
+
/** See {@link NumberInput}. */
|
|
98
|
+
export type NumberInputProps = RequiredNumberInputProps | OptionalNumberInputProps;
|
|
99
|
+
/**
|
|
100
|
+
* A number typed into a box.
|
|
101
|
+
*
|
|
102
|
+
* The box keeps what was typed rather than what parsed. A reader halfway
|
|
103
|
+
* through `0.2` has typed `0.`, which reads as zero, and a box rendered from
|
|
104
|
+
* that number would write `0` back over the dot before the `2` arrives —
|
|
105
|
+
* which is why Blueprint's `NumericInput` cannot be given a number to show and
|
|
106
|
+
* is never used directly on our sites. Nothing is handed up until the text
|
|
107
|
+
* reads as a number, so a calculation never sees a half-typed value, and the
|
|
108
|
+
* bounds are applied when the box is left rather than under the caret.
|
|
109
|
+
* @param props - See {@link NumberInputProps}.
|
|
110
|
+
* @returns The box, with its stepper buttons unless they are turned off.
|
|
111
|
+
*/
|
|
112
|
+
export declare function NumberInput(props: NumberInputProps): ReactElement;
|
|
113
|
+
//# sourceMappingURL=NumberInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberInput.d.ts","sourceRoot":"","sources":["../../../src/number/ui/NumberInput.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AAYxE,wEAAwE;AACxE,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,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CA8IjE"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, ButtonGroup, Classes, ControlGroup, InputGroup, } from '@blueprintjs/core';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { clamp } from "../../format/core/clamp.js";
|
|
5
|
+
import { useChromeT } from "../../i18n/ui/useT.js";
|
|
6
|
+
import { isPartialNumber, numberText, readNumber, stepNumber, } from "../core/numberText.js";
|
|
7
|
+
/**
|
|
8
|
+
* A number typed into a box.
|
|
9
|
+
*
|
|
10
|
+
* The box keeps what was typed rather than what parsed. A reader halfway
|
|
11
|
+
* through `0.2` has typed `0.`, which reads as zero, and a box rendered from
|
|
12
|
+
* that number would write `0` back over the dot before the `2` arrives —
|
|
13
|
+
* which is why Blueprint's `NumericInput` cannot be given a number to show and
|
|
14
|
+
* is never used directly on our sites. Nothing is handed up until the text
|
|
15
|
+
* reads as a number, so a calculation never sees a half-typed value, and the
|
|
16
|
+
* bounds are applied when the box is left rather than under the caret.
|
|
17
|
+
* @param props - See {@link NumberInputProps}.
|
|
18
|
+
* @returns The box, with its stepper buttons unless they are turned off.
|
|
19
|
+
*/
|
|
20
|
+
export function NumberInput(props) {
|
|
21
|
+
const { value, min, max, step = 1, integer = false, allowEmpty = false, buttons = true, placeholder, disabled = false, fill = false, size = 'medium', ariaLabel, id, testId, leftElement, rightElement, className, style, } = props;
|
|
22
|
+
const t = useChromeT();
|
|
23
|
+
const onChange = props.onChange;
|
|
24
|
+
const [draft, setDraft] = useState(() => ({
|
|
25
|
+
text: numberText(value),
|
|
26
|
+
held: value,
|
|
27
|
+
}));
|
|
28
|
+
// The number changed elsewhere — a preset, a reset, a link — so the box has
|
|
29
|
+
// to follow. `held` is what this box last handed up, not the prop it was
|
|
30
|
+
// rendered with: comparing against the prop would make the box's own edit
|
|
31
|
+
// look external and rewrite `-0.` as `0` under the caret.
|
|
32
|
+
if (draft.held !== value)
|
|
33
|
+
setDraft({ text: numberText(value), held: value });
|
|
34
|
+
function hold(text, held) {
|
|
35
|
+
setDraft({ text, held });
|
|
36
|
+
}
|
|
37
|
+
function commit(next) {
|
|
38
|
+
hold(numberText(next), next);
|
|
39
|
+
onChange(next);
|
|
40
|
+
}
|
|
41
|
+
function type(text) {
|
|
42
|
+
const emptied = text.trim() === '';
|
|
43
|
+
const parsed = readNumber(text, integer);
|
|
44
|
+
hold(text, emptied && allowEmpty ? undefined : (parsed ?? value));
|
|
45
|
+
if (emptied) {
|
|
46
|
+
if (allowEmpty)
|
|
47
|
+
onChange(undefined);
|
|
48
|
+
}
|
|
49
|
+
else if (parsed !== undefined) {
|
|
50
|
+
onChange(parsed);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function leave() {
|
|
54
|
+
if (draft.text.trim() === '') {
|
|
55
|
+
if (!allowEmpty)
|
|
56
|
+
hold(numberText(value), value);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const parsed = readNumber(draft.text);
|
|
60
|
+
if (parsed === undefined) {
|
|
61
|
+
hold(numberText(value), value);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const settled = settle(parsed, integer, min, max);
|
|
65
|
+
if (settled !== parsed || !Object.is(settled, value))
|
|
66
|
+
commit(settled);
|
|
67
|
+
}
|
|
68
|
+
function press(event) {
|
|
69
|
+
const direction = event.key === 'ArrowUp' ? 1 : event.key === 'ArrowDown' ? -1 : 0;
|
|
70
|
+
if (direction === 0 || disabled)
|
|
71
|
+
return;
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
const scale = event.shiftKey ? 10 : event.altKey ? 0.1 : 1;
|
|
74
|
+
move(direction * scale);
|
|
75
|
+
}
|
|
76
|
+
function move(scale) {
|
|
77
|
+
const from = readNumber(draft.text) ?? value ?? 0;
|
|
78
|
+
commit(settle(stepNumber(from, step * scale), integer, min, max));
|
|
79
|
+
}
|
|
80
|
+
const box = (_jsx(InputGroup, { id: id, size: size, fill: fill, disabled: disabled, placeholder: placeholder, value: draft.text, intent: isPartialNumber(draft.text) ? 'none' : 'danger', inputMode: integer ? 'numeric' : 'decimal', spellCheck: false, autoComplete: "off", autoCorrect: "off", autoCapitalize: "off", "aria-label": ariaLabel, "data-testid": testId, leftElement: leftElement, rightElement: rightElement, className: buttons ? undefined : className, style: buttons ? undefined : style, onValueChange: type, onKeyDown: press, onBlur: leave }));
|
|
81
|
+
if (!buttons)
|
|
82
|
+
return box;
|
|
83
|
+
const shown = readNumber(draft.text) ?? value;
|
|
84
|
+
return (_jsxs(ControlGroup, { fill: fill, style: style, className: [Classes.NUMERIC_INPUT, className].filter(Boolean).join(' '), children: [box, _jsxs(ButtonGroup, { className: Classes.FIXED, vertical: true, children: [_jsx(Button, { icon: "chevron-up", size: size, "aria-label": t('number.increment'), disabled: disabled ||
|
|
85
|
+
(max !== undefined && shown !== undefined && shown >= max), onClick: () => move(1) }), _jsx(Button, { icon: "chevron-down", size: size, "aria-label": t('number.decrement'), disabled: disabled ||
|
|
86
|
+
(min !== undefined && shown !== undefined && shown <= min), onClick: () => move(-1) })] })] }));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The number a box settles on once it is left or stepped.
|
|
90
|
+
* @param value - What the text read as.
|
|
91
|
+
* @param integer - Whether only whole numbers are wanted.
|
|
92
|
+
* @param min - Smallest accepted value, when there is one.
|
|
93
|
+
* @param max - Largest accepted value, when there is one.
|
|
94
|
+
* @returns The rounded, bounded number.
|
|
95
|
+
*/
|
|
96
|
+
function settle(value, integer, min, max) {
|
|
97
|
+
const rounded = integer ? Math.round(value) : value;
|
|
98
|
+
return clamp(rounded, min ?? Number.NEGATIVE_INFINITY, max ?? Number.POSITIVE_INFINITY, rounded);
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=NumberInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberInput.js","sourceRoot":"","sources":["../../../src/number/ui/NumberInput.t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kB,CAAC,EACjC,QAAQ,EACN,QAAQ;4BACR,CAAC,GAAG,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,IAAI,GAAG,CAAC,EAE5D,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GACvB,IACU,IACD,CAChB,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,MAAM,CACb,KAAa,EACb,OAAgB,EAChB,GAAuB,EACvB,GAAuB;IAEvB,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACpD,OAAO,KAAK,CACV,OAAO,EACP,GAAG,IAAI,MAAM,CAAC,iBAAiB,EAC/B,GAAG,IAAI,MAAM,CAAC,iBAAiB,EAC/B,OAAO,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/number/ui/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,oBAAoB,EACpB,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/number/ui/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAmB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OverlayValueMenu.d.ts","sourceRoot":"","sources":["../../../src/overlay/ui/OverlayValueMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AAGzD,OAAO,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IACnE;;;;;OAKG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,OAAO,EAAE,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9C,kCAAkC;IAClC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,SAAS,CAAC,EAAE,oBAAoB,CAAC;IACjC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,EAC7D,KAAK,EAAE,qBAAqB,CAAC,MAAM,CAAC,GACnC,YAAY,CA6Dd"}
|
|
@@ -26,7 +26,13 @@ export function OverlayValueMenu(props) {
|
|
|
26
26
|
if (option.value === value)
|
|
27
27
|
written = option.label;
|
|
28
28
|
}
|
|
29
|
-
return (_jsx(PopoverNext, { isOpen: open, disabled: disabled, placement: placement, onInteraction: (next) => setOpen(next), content: _jsxs(Menu, { role: "listbox", "aria-labelledby": headingId, size: metrics.blueprintSize, style: OVERLAY_VALUE_MENU_STYLE, children: [_jsx(MenuDivider, { title: label, titleId: headingId }), options.map((option) => (_jsx(MenuItem, { roleStructure: "listoption", selected: option.value === value, text: option.label, htmlTitle: option.title, disabled: option.disabled,
|
|
29
|
+
return (_jsx(PopoverNext, { isOpen: open, disabled: disabled, placement: placement, onInteraction: (next) => setOpen(next), content: _jsxs(Menu, { role: "listbox", "aria-labelledby": headingId, size: metrics.blueprintSize, style: OVERLAY_VALUE_MENU_STYLE, children: [_jsx(MenuDivider, { title: label, titleId: headingId }), options.map((option) => (_jsx(MenuItem, { roleStructure: "listoption", selected: option.value === value, text: option.label, htmlTitle: option.title, disabled: option.disabled,
|
|
30
|
+
// A menu opened from inside a panel would otherwise dismiss the
|
|
31
|
+
// panel too, taking the reader's other settings away mid-choice.
|
|
32
|
+
shouldDismissPopover: false, onClick: () => {
|
|
33
|
+
onChange(option.value);
|
|
34
|
+
setOpen(false);
|
|
35
|
+
} }, option.value)))] }), children: _jsx(OverlayValueButton, { label: label, value: written, keyWord: keyWord, showKey: showKey, swatches: swatches, active: open, disabled: disabled, disabledReason: disabledReason, testId: testId, opensMenu: true }) }));
|
|
30
36
|
}
|
|
31
37
|
/**
|
|
32
38
|
* The menu the value opens.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OverlayValueMenu.js","sourceRoot":"","sources":["../../../src/overlay/ui/OverlayValueMenu.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE7E,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAA0B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAuDxD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAoC;IAEpC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IACpE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAC7D,MAAM,EAAE,SAAS,GAAG,YAAY,EAAE,MAAM,EAAE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,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACvB,KAAC,QAAQ,IAEP,aAAa,EAAC,YAAY,EAC1B,QAAQ,EAAE,MAAM,CAAC,KAAK,KAAK,KAAK,EAChC,IAAI,EAAE,MAAM,CAAC,KAAK,EAClB,SAAS,EAAE,MAAM,CAAC,KAAK,EACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,gEAAgE;oBAChE,iEAAiE;oBACjE,oBAAoB,EAAE,KAAK,EAC3B,OAAO,EAAE,GAAG,EAAE;wBACZ,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;wBACvB,OAAO,CAAC,KAAK,CAAC,CAAC;oBACjB,CAAC,IAZI,MAAM,CAAC,KAAK,CAajB,CACH,CAAC,IACG,YAGT,KAAC,kBAAkB,IACjB,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,IAAI,EACZ,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,cAAc,EAC9B,MAAM,EAAE,MAAM,EACd,SAAS,SACT,GACU,CACf,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,wBAAwB,GAAkB;IAC9C,QAAQ,EAAE,GAAG;CACd,CAAC"}
|
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
*
|
|
5
5
|
* A cell is a real `<button>`, so Tab reaches it, Enter and Space activate it,
|
|
6
6
|
* and a screen reader reads the element's name rather than its symbol.
|
|
7
|
+
*
|
|
8
|
+
* Everything written in it is sized in container-query units, so a cell shows
|
|
9
|
+
* the same proportions at 280px beside a chart and across a lecture-hall
|
|
10
|
+
* screen — the table a class reads is the same drawing, larger.
|
|
7
11
|
*/
|
|
8
12
|
import type { ReactElement } from 'react';
|
|
9
13
|
import type { Swatch } from '../../color/core/interpolate.ts';
|
|
@@ -28,6 +32,12 @@ export interface ElementCellProps {
|
|
|
28
32
|
* @default '' — nothing is written
|
|
29
33
|
*/
|
|
30
34
|
detail?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Whether the table this cell belongs to writes a third line at all. A table
|
|
37
|
+
* that writes none gives the room to the symbol, and its rows are shorter.
|
|
38
|
+
* @default whether this cell has one
|
|
39
|
+
*/
|
|
40
|
+
writesDetail?: boolean;
|
|
31
41
|
/**
|
|
32
42
|
* Whether the cell is the one the tools are pointed at.
|
|
33
43
|
* @default false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementCell.d.ts","sourceRoot":"","sources":["../../../src/periodic/ui/ElementCell.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ElementCell.d.ts","sourceRoot":"","sources":["../../../src/periodic/ui/ElementCell.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AAGzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAG9D,0DAA0D;AAC1D,MAAM,WAAW,gBAAgB;IAC/B,kDAAkD;IAClD,YAAY,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,MAAM,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,sDAAsD;IACtD,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC1C;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,YAAY,CA8EjE"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
2
3
|
import { useChromeT } from "../../i18n/ui/useT.js";
|
|
3
4
|
/**
|
|
4
5
|
* A single element of the table.
|
|
@@ -6,15 +7,22 @@ import { useChromeT } from "../../i18n/ui/useT.js";
|
|
|
6
7
|
* @returns The cell.
|
|
7
8
|
*/
|
|
8
9
|
export function ElementCell(props) {
|
|
9
|
-
const { className, atomicNumber, symbol, name, swatch, column, row, onSelect, detail = '', isSelected = false, isIncluded = true, onHover, } = props;
|
|
10
|
+
const { className, atomicNumber, symbol, name, swatch, column, row, onSelect, detail = '', writesDetail = detail !== '', isSelected = false, isIncluded = true, onHover, } = props;
|
|
10
11
|
const t = useChromeT();
|
|
11
|
-
|
|
12
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
13
|
+
return (_jsxs("button", { type: "button", className: className, "data-testid": `element-${symbol}`, "data-symbol": symbol, title: detail === '' ? name : `${name} · ${detail}`, "aria-label": t('periodic.cellLabel', {
|
|
12
14
|
name,
|
|
13
15
|
symbol,
|
|
14
16
|
atomicNumber,
|
|
15
17
|
}), "aria-pressed": isSelected, onClick: () => {
|
|
16
18
|
onSelect(symbol);
|
|
17
|
-
}, onPointerEnter: () =>
|
|
19
|
+
}, onPointerEnter: () => {
|
|
20
|
+
setIsHovered(true);
|
|
21
|
+
onHover?.(symbol);
|
|
22
|
+
}, onPointerLeave: () => {
|
|
23
|
+
setIsHovered(false);
|
|
24
|
+
onHover?.(null);
|
|
25
|
+
}, style: {
|
|
18
26
|
...cellStyle,
|
|
19
27
|
gridColumn: column,
|
|
20
28
|
gridRow: row,
|
|
@@ -23,10 +31,110 @@ export function ElementCell(props) {
|
|
|
23
31
|
opacity: isIncluded ? 1 : 0.28,
|
|
24
32
|
// An outline rather than a fill: a table coloured by a property must
|
|
25
33
|
// keep saying what the value is while a cell is selected.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
outlineStyle: isSelected ? 'solid' : 'none',
|
|
35
|
+
outlineColor: swatch.foreground,
|
|
36
|
+
// Thick enough to be seen from the back of a room, and drawn inside
|
|
37
|
+
// the cell so a neighbour never covers it.
|
|
38
|
+
outlineWidth: 'max(2px, 0.3cqw)',
|
|
39
|
+
outlineOffset: 'max(-3px, -0.4cqw)',
|
|
40
|
+
// The cell the pointer is on, for a class following a demonstration.
|
|
41
|
+
filter: isHovered ? 'brightness(1.08)' : undefined,
|
|
42
|
+
}, children: [_jsx("span", { style: numberStyle, children: atomicNumber }), _jsx("span", { style: {
|
|
43
|
+
...symbolStyle,
|
|
44
|
+
fontSize: symbolFontSize(symbol, writesDetail),
|
|
45
|
+
}, children: symbol }), detail === '' ? null : (_jsx("span", { style: { ...detailStyle, fontSize: detailFontSize(detail) }, children: detail }))] }));
|
|
29
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* The size the symbol is written at.
|
|
49
|
+
*
|
|
50
|
+
* Every symbol is written at the same size, except the widest of them — the
|
|
51
|
+
* ones whose second letter is an `m` — which are written a tenth smaller
|
|
52
|
+
* rather than run into the edges of their cell.
|
|
53
|
+
* @param symbol - The chemical symbol.
|
|
54
|
+
* @param writesDetail - Whether the table writes a third line under it.
|
|
55
|
+
* @returns A CSS length.
|
|
56
|
+
*/
|
|
57
|
+
function symbolFontSize(symbol, writesDetail) {
|
|
58
|
+
const cap = writesDetail ? SYMBOL_CQW : SYMBOL_ALONE_CQW;
|
|
59
|
+
return fitted(symbolWidthInEm(symbol), cap, '0.5rem');
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The size the third line takes so the whole of it is written.
|
|
63
|
+
*
|
|
64
|
+
* A value cut short by an ellipsis is a wrong value — `0.0899` read as `0.0…`
|
|
65
|
+
* is worse than not writing it at all — so a long string is written smaller
|
|
66
|
+
* rather than trimmed.
|
|
67
|
+
* @param detail - What the third line says.
|
|
68
|
+
* @returns A CSS length.
|
|
69
|
+
*/
|
|
70
|
+
function detailFontSize(detail) {
|
|
71
|
+
return fitted(detailWidthInEm(detail), DETAIL_CQW, '0.25rem');
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The largest size a string of the given width fits its cell at.
|
|
75
|
+
*
|
|
76
|
+
* The room a cell leaves is a share of the table's width less its border and
|
|
77
|
+
* its padding, which are the same few pixels at every size — hence the two
|
|
78
|
+
* units in one expression.
|
|
79
|
+
* @param widthInEm - How wide the string is, in ems of its own size.
|
|
80
|
+
* @param cap - The size it is written at when it has room to spare.
|
|
81
|
+
* @param floor - The size under which it is not shrunk any further.
|
|
82
|
+
* @returns A CSS length.
|
|
83
|
+
*/
|
|
84
|
+
function fitted(widthInEm, cap, floor) {
|
|
85
|
+
const room = `calc((${CELL_CQW} - ${CELL_CHROME}) / ${widthInEm.toFixed(2)})`;
|
|
86
|
+
return `max(${floor}, min(${cap}, ${room}))`;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* How wide a symbol is, in ems of its own size.
|
|
90
|
+
* @param symbol - The chemical symbol.
|
|
91
|
+
* @returns Its width, never zero.
|
|
92
|
+
*/
|
|
93
|
+
function symbolWidthInEm(symbol) {
|
|
94
|
+
let width = 0;
|
|
95
|
+
for (const character of symbol) {
|
|
96
|
+
if (character === 'm' || character === 'w') {
|
|
97
|
+
width += 0.95;
|
|
98
|
+
}
|
|
99
|
+
else if (character >= 'a' && character <= 'z') {
|
|
100
|
+
width += 0.63;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
width += 0.85;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return Math.max(width, 0.85);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* How wide the third line is, in ems of its own size.
|
|
110
|
+
*
|
|
111
|
+
* It is written with tabular figures, where every glyph — the decimal point
|
|
112
|
+
* and the minus of an exponent included — advances the same width, so counting
|
|
113
|
+
* the characters is the measurement.
|
|
114
|
+
* @param detail - What the third line says.
|
|
115
|
+
* @returns Its width, never zero.
|
|
116
|
+
*/
|
|
117
|
+
function detailWidthInEm(detail) {
|
|
118
|
+
return Math.max(detail.length, 1) * TABULAR_EM;
|
|
119
|
+
}
|
|
120
|
+
/** What one tabular glyph advances, as a share of its own size. */
|
|
121
|
+
const TABULAR_EM = 0.6;
|
|
122
|
+
/** The size the symbol is written at wherever it fits, as a share of the table. */
|
|
123
|
+
const SYMBOL_CQW = '2.4cqw';
|
|
124
|
+
/** The same, in a table that writes nothing under the symbol. */
|
|
125
|
+
const SYMBOL_ALONE_CQW = '2.8cqw';
|
|
126
|
+
/**
|
|
127
|
+
* The tallest the third line is ever written, as a share of the table.
|
|
128
|
+
*
|
|
129
|
+
* Close to three quarters of the symbol: the symbol is how a cell is found,
|
|
130
|
+
* but the value is what the table is being read for, and a value half the size
|
|
131
|
+
* of the symbol is the one thing on the cell a class cannot make out.
|
|
132
|
+
*/
|
|
133
|
+
const DETAIL_CQW = '1.75cqw';
|
|
134
|
+
/** How wide one column is, as a share of the table's width. */
|
|
135
|
+
const CELL_CQW = '4.85cqw';
|
|
136
|
+
/** What the border and the padding of a cell take off that width. */
|
|
137
|
+
const CELL_CHROME = '4px';
|
|
30
138
|
const cellStyle = {
|
|
31
139
|
alignItems: 'center',
|
|
32
140
|
border: '1px solid rgb(255 255 255 / 0.55)',
|
|
@@ -36,27 +144,29 @@ const cellStyle = {
|
|
|
36
144
|
flexDirection: 'column',
|
|
37
145
|
font: 'inherit',
|
|
38
146
|
justifyContent: 'center',
|
|
39
|
-
lineHeight: 1.05,
|
|
40
147
|
minWidth: 0,
|
|
41
148
|
overflow: 'hidden',
|
|
42
|
-
padding:
|
|
43
|
-
transition: 'opacity 120ms ease',
|
|
149
|
+
padding: '1px',
|
|
150
|
+
transition: 'opacity 120ms ease, filter 120ms ease',
|
|
44
151
|
};
|
|
45
152
|
const numberStyle = {
|
|
46
153
|
alignSelf: 'flex-start',
|
|
47
|
-
fontSize: '
|
|
154
|
+
fontSize: 'max(0.33rem, 1.2cqw)',
|
|
155
|
+
fontVariantNumeric: 'tabular-nums',
|
|
156
|
+
lineHeight: 1,
|
|
48
157
|
opacity: 0.8,
|
|
49
|
-
paddingLeft:
|
|
158
|
+
paddingLeft: '0.15cqw',
|
|
50
159
|
};
|
|
51
160
|
const symbolStyle = {
|
|
52
|
-
fontSize: 'clamp(0.55rem, 3.3cqw, 1.05rem)',
|
|
53
161
|
fontWeight: 700,
|
|
162
|
+
letterSpacing: '-0.02em',
|
|
163
|
+
lineHeight: 1.02,
|
|
54
164
|
};
|
|
55
165
|
const detailStyle = {
|
|
56
|
-
|
|
166
|
+
fontVariantNumeric: 'tabular-nums',
|
|
167
|
+
lineHeight: 1,
|
|
57
168
|
maxWidth: '100%',
|
|
58
169
|
overflow: 'hidden',
|
|
59
|
-
textOverflow: 'ellipsis',
|
|
60
170
|
whiteSpace: 'nowrap',
|
|
61
171
|
};
|
|
62
172
|
//# sourceMappingURL=ElementCell.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementCell.js","sourceRoot":"","sources":["../../../src/periodic/ui/ElementCell.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"ElementCell.js","sourceRoot":"","sources":["../../../src/periodic/ui/ElementCell.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGjC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAoDnD;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAuB;IACjD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,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,MAAM,CAAC;IAChD;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,MAAM,CAAC;IAChD;;;;OAIG;IACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,MAAM,CAAC;IAC9C;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC;IACnD;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAC9C;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC1C;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,YAAY,CA2ErE"}
|
|
@@ -14,6 +14,7 @@ import { HeaderStrips, InnerTransitionMarkers, } from "./PeriodicTableChrome.js"
|
|
|
14
14
|
export function PeriodicTable(props) {
|
|
15
15
|
const { selected, onSelect, swatchOf = defaultSwatchOf, detailOf, nameOf = defaultNameOf, isIncluded, headers = false, onSelectRange, legend = false, markers = true, keyboard = true, onHover, className, } = props;
|
|
16
16
|
const t = useChromeT();
|
|
17
|
+
const writesDetail = detailOf !== undefined;
|
|
17
18
|
const gridRef = useRef(null);
|
|
18
19
|
const cameFromKeyRef = useRef(false);
|
|
19
20
|
const offset = headers ? 1 : 0;
|
|
@@ -35,7 +36,7 @@ export function PeriodicTable(props) {
|
|
|
35
36
|
cameFromKeyRef.current = true;
|
|
36
37
|
onSelect(next.symbol);
|
|
37
38
|
}
|
|
38
|
-
return (_jsxs("div", { className: className, style: rootStyle, children: [_jsxs("div", { ref: gridRef, role: "grid", "aria-label": t('periodic.table'), "data-testid": "periodic-table", style: headers
|
|
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
40
|
}
|
|
40
41
|
function defaultSwatchOf(element) {
|
|
41
42
|
return categorySwatch(element.category);
|
|
@@ -47,33 +48,59 @@ function noop() {
|
|
|
47
48
|
// A table with no `onSelect` is a figure; its cells stay buttons so the
|
|
48
49
|
// keyboard and a screen reader still reach every element.
|
|
49
50
|
}
|
|
51
|
+
/** Narrowest the table is ever drawn; under it the type stops being readable. */
|
|
52
|
+
const MIN_WIDTH = 280;
|
|
53
|
+
/**
|
|
54
|
+
* How tall one row of elements is, as a share of the table's width.
|
|
55
|
+
*
|
|
56
|
+
* A column is about 5.4% of that width, so a cell is a seventh taller than it
|
|
57
|
+
* is wide — the proportion of a wall chart, and the room the three lines of a
|
|
58
|
+
* cell need to be written at a size a class can read.
|
|
59
|
+
*/
|
|
60
|
+
const ROW_HEIGHT = '6.1cqw';
|
|
61
|
+
/** The same, in a table that writes nothing under the symbol. */
|
|
62
|
+
const ROW_HEIGHT_ALONE = '4.9cqw';
|
|
63
|
+
/** The band the two inner-transition series were lifted out across. */
|
|
64
|
+
const SERIES_GAP = 'max(6px, 1.1cqw)';
|
|
50
65
|
const rootStyle = {
|
|
51
66
|
display: 'flex',
|
|
52
67
|
flexDirection: 'column',
|
|
53
68
|
gap: 8,
|
|
69
|
+
minWidth: MIN_WIDTH,
|
|
70
|
+
// Everything inside — the height of a row as much as the type in a cell — is
|
|
71
|
+
// a share of this box rather than of the page, so the same table reads at
|
|
72
|
+
// 280px beside a chart and fills a lecture-hall screen at twice that.
|
|
73
|
+
containerType: 'inline-size',
|
|
54
74
|
};
|
|
55
75
|
const baseGridStyle = {
|
|
56
76
|
display: 'grid',
|
|
57
77
|
gap: 2,
|
|
78
|
+
minWidth: MIN_WIDTH,
|
|
58
79
|
width: '100%',
|
|
59
|
-
// The cells size their type against this box rather than against the page,
|
|
60
|
-
// so the same table reads at 320px beside a chart and at 900px on its own.
|
|
61
|
-
containerType: 'inline-size',
|
|
62
80
|
};
|
|
63
|
-
|
|
64
|
-
|
|
81
|
+
/**
|
|
82
|
+
* The grid the cells are placed on.
|
|
83
|
+
* @param headers - Whether a leading column and row hold the period and group
|
|
84
|
+
* numbers.
|
|
85
|
+
* @param writesDetail - Whether a cell writes a third line, which is what a
|
|
86
|
+
* row is tall enough for.
|
|
87
|
+
* @returns The style of the grid.
|
|
88
|
+
*/
|
|
89
|
+
function gridStyle(headers, writesDetail) {
|
|
90
|
+
const row = writesDetail ? ROW_HEIGHT : ROW_HEIGHT_ALONE;
|
|
65
91
|
// The eighth row is the gap the inner-transition series are lifted out into.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
};
|
|
92
|
+
const rows = `repeat(7, ${row}) ${SERIES_GAP} repeat(2, ${row})`;
|
|
93
|
+
if (!headers) {
|
|
94
|
+
return {
|
|
95
|
+
...baseGridStyle,
|
|
96
|
+
gridTemplateColumns: `repeat(${String(COLUMN_COUNT)}, minmax(0, 1fr))`,
|
|
97
|
+
gridTemplateRows: rows,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
...baseGridStyle,
|
|
102
|
+
gridTemplateColumns: `max(14px, 2.4cqw) repeat(${String(COLUMN_COUNT)}, minmax(0, 1fr))`,
|
|
103
|
+
gridTemplateRows: `max(12px, 2cqw) ${rows}`,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
79
106
|
//# sourceMappingURL=PeriodicTable.js.map
|