react-cheminfo 0.45.0 → 0.47.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/lib/chart/core/chartDomain.d.ts +30 -5
- package/lib/chart/core/chartDomain.d.ts.map +1 -1
- package/lib/chart/core/chartDomain.js +1 -0
- package/lib/chart/core/chartDomain.js.map +1 -1
- package/lib/chart/core/index.d.ts +1 -1
- package/lib/chart/core/index.d.ts.map +1 -1
- package/lib/chart/core/index.js +1 -1
- package/lib/chart/core/index.js.map +1 -1
- package/lib/chart/core/selectionGeometry.d.ts +8 -5
- package/lib/chart/core/selectionGeometry.d.ts.map +1 -1
- package/lib/chart/core/selectionGeometry.js +8 -5
- package/lib/chart/core/selectionGeometry.js.map +1 -1
- package/lib/chart/core/zoomDomain.d.ts +39 -4
- package/lib/chart/core/zoomDomain.d.ts.map +1 -1
- package/lib/chart/core/zoomDomain.js +90 -22
- package/lib/chart/core/zoomDomain.js.map +1 -1
- package/lib/chart/ui/SelectionRect.d.ts.map +1 -1
- package/lib/chart/ui/SelectionRect.js +1 -1
- package/lib/chart/ui/SelectionRect.js.map +1 -1
- package/lib/chart/ui/chartGestures.d.ts +26 -1
- package/lib/chart/ui/chartGestures.d.ts.map +1 -1
- package/lib/chart/ui/chartGestures.js +21 -0
- package/lib/chart/ui/chartGestures.js.map +1 -1
- package/lib/chart/ui/index.d.ts +1 -1
- package/lib/chart/ui/index.d.ts.map +1 -1
- package/lib/chart/ui/index.js +1 -1
- package/lib/chart/ui/index.js.map +1 -1
- package/lib/chart/ui/useChartZoom.d.ts.map +1 -1
- package/lib/chart/ui/useChartZoom.js +17 -1
- package/lib/chart/ui/useChartZoom.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/ir/core/irMode.d.ts.map +1 -1
- package/lib/ir/core/irMode.js +6 -1
- package/lib/ir/core/irMode.js.map +1 -1
- package/lib/locales/de.json +1 -0
- package/lib/locales/en.json +1 -0
- package/lib/locales/es.json +1 -0
- package/lib/locales/fr.json +1 -0
- package/lib/locales/it.json +1 -0
- package/lib/periodic/core/index.d.ts +1 -1
- package/lib/periodic/core/index.d.ts.map +1 -1
- package/lib/periodic/core/layout.d.ts +11 -0
- package/lib/periodic/core/layout.d.ts.map +1 -1
- package/lib/periodic/core/layout.js.map +1 -1
- package/lib/periodic/ui/ElementCell.d.ts +6 -2
- package/lib/periodic/ui/ElementCell.d.ts.map +1 -1
- package/lib/periodic/ui/ElementCell.js +2 -2
- package/lib/periodic/ui/ElementCell.js.map +1 -1
- package/lib/periodic/ui/PeriodicTable.d.ts +12 -3
- package/lib/periodic/ui/PeriodicTable.d.ts.map +1 -1
- package/lib/periodic/ui/PeriodicTable.js +5 -3
- package/lib/periodic/ui/PeriodicTable.js.map +1 -1
- package/lib/periodic/ui/PeriodicTableChrome.d.ts +13 -3
- package/lib/periodic/ui/PeriodicTableChrome.d.ts.map +1 -1
- package/lib/periodic/ui/PeriodicTableChrome.js +18 -6
- package/lib/periodic/ui/PeriodicTableChrome.js.map +1 -1
- package/lib/split/ui/SplitColumn.d.ts +30 -0
- package/lib/split/ui/SplitColumn.d.ts.map +1 -0
- package/lib/split/ui/SplitColumn.js +20 -0
- package/lib/split/ui/SplitColumn.js.map +1 -0
- package/lib/split/ui/SplitRow.d.ts +15 -53
- package/lib/split/ui/SplitRow.d.ts.map +1 -1
- package/lib/split/ui/SplitRow.js +9 -90
- package/lib/split/ui/SplitRow.js.map +1 -1
- package/lib/split/ui/index.d.ts +3 -0
- package/lib/split/ui/index.d.ts.map +1 -1
- package/lib/split/ui/index.js +1 -0
- package/lib/split/ui/index.js.map +1 -1
- package/lib/split/ui/splitPanes.d.ts +73 -0
- package/lib/split/ui/splitPanes.d.ts.map +1 -0
- package/lib/split/ui/splitPanes.js +128 -0
- package/lib/split/ui/splitPanes.js.map +1 -0
- package/package.json +1 -1
- package/src/chart/core/chartDomain.ts +31 -5
- package/src/chart/core/index.ts +2 -0
- package/src/chart/core/selectionGeometry.ts +8 -5
- package/src/chart/core/zoomDomain.ts +109 -26
- package/src/chart/ui/SelectionRect.tsx +4 -0
- package/src/chart/ui/chartGestures.ts +41 -1
- package/src/chart/ui/index.ts +1 -1
- package/src/chart/ui/useChartZoom.ts +25 -1
- package/src/ir/core/irMode.ts +6 -1
- package/src/locales/de.json +1 -0
- package/src/locales/en.json +1 -0
- package/src/locales/es.json +1 -0
- package/src/locales/fr.json +1 -0
- package/src/locales/it.json +1 -0
- package/src/periodic/core/index.ts +1 -1
- package/src/periodic/core/layout.ts +12 -0
- package/src/periodic/ui/ElementCell.tsx +8 -4
- package/src/periodic/ui/PeriodicTable.tsx +23 -5
- package/src/periodic/ui/PeriodicTableChrome.tsx +28 -4
- package/src/split/ui/SplitColumn.tsx +36 -0
- package/src/split/ui/SplitRow.tsx +17 -208
- package/src/split/ui/index.ts +3 -0
- package/src/split/ui/splitPanes.tsx +267 -0
|
@@ -4,15 +4,17 @@ import { TOKEN } from "../../tokens/core/familyTokens.js";
|
|
|
4
4
|
import { COLUMN_COUNT, INNER_TRANSITION_MARKERS, INNER_TRANSITION_ROWS, } from "../core/layout.js";
|
|
5
5
|
import { ofWidth } from "./unit.js";
|
|
6
6
|
/**
|
|
7
|
-
* The 1–18 strip along the top
|
|
7
|
+
* The 1–18 strip along the top, the 1–7 strip down the left, and the corner
|
|
8
|
+
* where they meet.
|
|
8
9
|
*
|
|
9
10
|
* They are buttons when the table takes a range: "plot period 3" is one click
|
|
10
|
-
* there and eight on the cells.
|
|
11
|
+
* there and eight on the cells. The corner takes the whole table, which is the
|
|
12
|
+
* gesture a spreadsheet has taught everybody.
|
|
11
13
|
* @param props - See {@link HeaderStripsProps}.
|
|
12
|
-
* @returns The two strips,
|
|
14
|
+
* @returns The two strips, the corner, and the inner-transition period numbers.
|
|
13
15
|
*/
|
|
14
16
|
export function HeaderStrips(props) {
|
|
15
|
-
const { onSelectRange } = props;
|
|
17
|
+
const { onSelectRange, onSelectAll } = props;
|
|
16
18
|
const t = useChromeT();
|
|
17
19
|
const groups = [];
|
|
18
20
|
for (let group = 1; group <= COLUMN_COUNT; group++) {
|
|
@@ -36,7 +38,17 @@ export function HeaderStrips(props) {
|
|
|
36
38
|
});
|
|
37
39
|
}) }, `period-${String(period)}`));
|
|
38
40
|
}
|
|
39
|
-
return (_jsxs(_Fragment, { children: [
|
|
41
|
+
return (_jsxs(_Fragment, { children: [onSelectAll === undefined ? null : (_jsx(HeaderCell
|
|
42
|
+
// The glyph points into the grid it takes, as a spreadsheet's does.
|
|
43
|
+
// It is a mark rather than a word because the corner is a
|
|
44
|
+
// seventeenth of the table's width, and the word differs in every
|
|
45
|
+
// language the chrome speaks.
|
|
46
|
+
, {
|
|
47
|
+
// The glyph points into the grid it takes, as a spreadsheet's does.
|
|
48
|
+
// It is a mark rather than a word because the corner is a
|
|
49
|
+
// seventeenth of the table's width, and the word differs in every
|
|
50
|
+
// language the chrome speaks.
|
|
51
|
+
label: "\u25E2", title: t('periodic.allElements'), column: 1, row: 1, onClick: onSelectAll })), groups, periods, INNER_TRANSITION_ROWS.map(({ row, period }) => (_jsx("div", { style: { ...headerStyle, gridColumn: 1, gridRow: row + 1 }, children: period }, `inner-${String(row)}`)))] }));
|
|
40
52
|
}
|
|
41
53
|
/**
|
|
42
54
|
* The two cells the lanthanoids and the actinoids were lifted out of.
|
|
@@ -66,7 +78,7 @@ function HeaderCell(props) {
|
|
|
66
78
|
const style = { ...headerStyle, gridColumn: column, gridRow: row };
|
|
67
79
|
if (onClick === undefined)
|
|
68
80
|
return _jsx("div", { style: style, children: label });
|
|
69
|
-
return (_jsx("button", { type: "button", "aria-label": title, onClick: onClick, style: { ...style, ...headerButtonStyle }, children: label }));
|
|
81
|
+
return (_jsx("button", { type: "button", "aria-label": title, title: title, onClick: onClick, style: { ...style, ...headerButtonStyle }, children: label }));
|
|
70
82
|
}
|
|
71
83
|
const headerStyle = {
|
|
72
84
|
alignItems: 'center',
|
|
@@ -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;AAE3B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
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;AAE3B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoBpC;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CAAC,KAAwB;IACnD,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IAC7C,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC;IACvB,MAAM,MAAM,GAAmB,EAAE,CAAC;IAClC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,IAAI,YAAY,EAAE,KAAK,EAAE,EAAE,CAAC;QACnD,MAAM,CAAC,IAAI,CACT,KAAC,UAAU,IAET,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EACpB,KAAK,EAAE,CAAC,CAAC,gBAAgB,EAAE,EAAE,KAAK,EAAE,CAAC,EACrC,MAAM,EAAE,KAAK,GAAG,CAAC,EACjB,GAAG,EAAE,CAAC,EACN,OAAO,EACL,aAAa;gBACb,CA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,iBACE,IAAI,EAAC,QAAQ,gBACD,KAAK,EACjB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,GAAG,iBAAiB,EAAE,YAExC,KAAK,GACC,CACV,CAAC;AACJ,CAAC;AAED,MAAM,WAAW,GAAG;IAClB,UAAU,EAAE,QAAQ;IACpB,KAAK,EAAE,KAAK,CAAC,SAAS;IACtB,OAAO,EAAE,MAAM;IACf,QAAQ,EAAE,gBAAgB,OAAO,CAAC,IAAI,CAAC,GAAG;IAC1C,cAAc,EAAE,QAAQ;IACxB,OAAO,EAAE,CAAC;CACsB,CAAC;AAEnC,MAAM,iBAAiB,GAAG;IACxB,UAAU,EAAE,MAAM;IAClB,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,SAAS;IACjB,IAAI,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,eAAe,OAAO,CAAC,IAAI,CAAC,GAAG;IACzC,cAAc,EAAE,QAAQ;CACQ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Two figures one above the other, with a splitter between them and the share
|
|
3
|
+
* each takes written into the address.
|
|
4
|
+
*
|
|
5
|
+
* The body is `splitPanes.tsx`, which `<SplitRow>` shares; its header is where
|
|
6
|
+
* the design is written down.
|
|
7
|
+
*/
|
|
8
|
+
import type { ReactElement } from 'react';
|
|
9
|
+
import type { SplitPanesProps } from './splitPanes.tsx';
|
|
10
|
+
/**
|
|
11
|
+
* Props of {@link SplitColumn}. `start` is the top pane, `end` the bottom one,
|
|
12
|
+
* and `stackBelow` a height.
|
|
13
|
+
*/
|
|
14
|
+
export type SplitColumnProps = SplitPanesProps;
|
|
15
|
+
/**
|
|
16
|
+
* Two panes sharing a column, divided where the address says.
|
|
17
|
+
*
|
|
18
|
+
* **A share needs a height to be a share of.** Put this inside a box that has
|
|
19
|
+
* one — a workbench pane, a page that fills the viewport — not inside an
|
|
20
|
+
* ordinary page column, whose height is whatever its content comes to. Given
|
|
21
|
+
* no height to divide, it measures nothing, says nothing about it, and simply
|
|
22
|
+
* stacks the two panes with no splitter, which is what an ordinary page wanted
|
|
23
|
+
* anyway.
|
|
24
|
+
*
|
|
25
|
+
* @param props - See {@link SplitColumnProps}.
|
|
26
|
+
* @returns The two panes with the splitter between them, the two stacked where
|
|
27
|
+
* there is no height to divide, or whichever one a link left, alone.
|
|
28
|
+
*/
|
|
29
|
+
export declare function SplitColumn(props: SplitColumnProps): ReactElement | null;
|
|
30
|
+
//# sourceMappingURL=SplitColumn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SplitColumn.d.ts","sourceRoot":"","sources":["../../../src/split/ui/SplitColumn.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGxD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAE/C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,YAAY,GAAG,IAAI,CAExE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { SplitPanes } from "./splitPanes.js";
|
|
3
|
+
/**
|
|
4
|
+
* Two panes sharing a column, divided where the address says.
|
|
5
|
+
*
|
|
6
|
+
* **A share needs a height to be a share of.** Put this inside a box that has
|
|
7
|
+
* one — a workbench pane, a page that fills the viewport — not inside an
|
|
8
|
+
* ordinary page column, whose height is whatever its content comes to. Given
|
|
9
|
+
* no height to divide, it measures nothing, says nothing about it, and simply
|
|
10
|
+
* stacks the two panes with no splitter, which is what an ordinary page wanted
|
|
11
|
+
* anyway.
|
|
12
|
+
*
|
|
13
|
+
* @param props - See {@link SplitColumnProps}.
|
|
14
|
+
* @returns The two panes with the splitter between them, the two stacked where
|
|
15
|
+
* there is no height to divide, or whichever one a link left, alone.
|
|
16
|
+
*/
|
|
17
|
+
export function SplitColumn(props) {
|
|
18
|
+
return _jsx(SplitPanes, { direction: "vertical", ...props });
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=SplitColumn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SplitColumn.js","sourceRoot":"","sources":["../../../src/split/ui/SplitColumn.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAkB,CAAC;AAQ9C;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,WAAW,CAAC,KAAuB;IACjD,OAAO,KAAC,UAAU,IAAC,SAAS,EAAC,UAAU,KAAK,KAAK,GAAI,CAAC;AACxD,CAAC"}
|
|
@@ -2,62 +2,24 @@
|
|
|
2
2
|
* Two figures side by side, with a splitter between them and the share each
|
|
3
3
|
* takes written into the address.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* is no room for two columns at all, so the panes stack and no splitter is
|
|
14
|
-
* drawn; and a link that hid everything one pane holds leaves the other the
|
|
15
|
-
* whole width rather than a share of it.
|
|
16
|
-
*
|
|
17
|
-
* The bar itself is react-science's `SplitPane`, and it keeps react-science's
|
|
18
|
-
* look — barely visible on purpose, found by the pointer that changes over it
|
|
19
|
-
* rather than by the eye. All `chrome.css` says about it is that eleven pixels
|
|
20
|
-
* is more gutter than two figures need.
|
|
5
|
+
* The body is `splitPanes.tsx`, which `<SplitColumn>` shares; its header is
|
|
6
|
+
* where the design is written down.
|
|
7
|
+
*/
|
|
8
|
+
import type { ReactElement } from 'react';
|
|
9
|
+
import type { SplitPanesProps } from './splitPanes.tsx';
|
|
10
|
+
/**
|
|
11
|
+
* Props of {@link SplitRow}. `start` is the left-hand pane, `end` the
|
|
12
|
+
* right-hand one, and `stackBelow` a width.
|
|
21
13
|
*/
|
|
22
|
-
|
|
23
|
-
import type { SplitRange } from '../core/split.ts';
|
|
24
|
-
/** Props of {@link SplitRow}. */
|
|
25
|
-
export interface SplitRowProps extends SplitRange {
|
|
26
|
-
/**
|
|
27
|
-
* Share of the row the first pane takes, as a whole percentage, or `null`
|
|
28
|
-
* while the page sits at {@link SplitRowProps.defaultRatio}.
|
|
29
|
-
*/
|
|
30
|
-
ratio: number | null;
|
|
31
|
-
/** The share the row opens at when the address names none. */
|
|
32
|
-
defaultRatio: number;
|
|
33
|
-
/**
|
|
34
|
-
* Take the share a drag came to rest at, or `null` when the splitter was
|
|
35
|
-
* double-clicked back to the default.
|
|
36
|
-
*/
|
|
37
|
-
onRatio: (ratio: number | null) => void;
|
|
38
|
-
/** The left-hand pane, or `null` when a link left nothing in it. */
|
|
39
|
-
start: ReactNode;
|
|
40
|
-
/** The right-hand pane, or `null` when a link left nothing in it. */
|
|
41
|
-
end: ReactNode;
|
|
42
|
-
/**
|
|
43
|
-
* The narrowest row that is still split; under it the two panes stack.
|
|
44
|
-
* @default 860
|
|
45
|
-
*/
|
|
46
|
-
stackBelow?: number;
|
|
47
|
-
/**
|
|
48
|
-
* The gutter each pane keeps beside the splitter, in pixels, so neither
|
|
49
|
-
* figure is read against its edge.
|
|
50
|
-
* @default 6
|
|
51
|
-
*/
|
|
52
|
-
gutter?: number;
|
|
53
|
-
/**
|
|
54
|
-
* The gap between the two panes once they have stacked, in pixels.
|
|
55
|
-
* @default 16
|
|
56
|
-
*/
|
|
57
|
-
stackedGap?: number;
|
|
58
|
-
}
|
|
14
|
+
export type SplitRowProps = SplitPanesProps;
|
|
59
15
|
/**
|
|
60
16
|
* Two panes sharing a row, divided where the address says.
|
|
17
|
+
*
|
|
18
|
+
* **Set `max` where the first pane stops being able to use the room.** A pane
|
|
19
|
+
* of forms dragged past about half the row does not grow: the labels stay put
|
|
20
|
+
* and the fields stretch to a width nobody types into, so the room becomes
|
|
21
|
+
* empty card. The figure beside it is what the drag exists to enlarge.
|
|
22
|
+
*
|
|
61
23
|
* @param props - See {@link SplitRowProps}.
|
|
62
24
|
* @returns The two panes with the splitter between them, the two stacked on a
|
|
63
25
|
* narrow screen, or whichever one a link left on the page, alone.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SplitRow.d.ts","sourceRoot":"","sources":["../../../src/split/ui/SplitRow.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"SplitRow.d.ts","sourceRoot":"","sources":["../../../src/split/ui/SplitRow.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGxD;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,eAAe,CAAC;AAE5C;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,YAAY,GAAG,IAAI,CAElE"}
|
package/lib/split/ui/SplitRow.js
CHANGED
|
@@ -1,99 +1,18 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import {
|
|
3
|
-
import { SplitPane } from 'react-science/ui';
|
|
4
|
-
import { useResizeObserver } from "../../hooks/ui/useResizeObserver.js";
|
|
5
|
-
import { clampSplit } from "../core/split.js";
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { SplitPanes } from "./splitPanes.js";
|
|
6
3
|
/**
|
|
7
4
|
* Two panes sharing a row, divided where the address says.
|
|
5
|
+
*
|
|
6
|
+
* **Set `max` where the first pane stops being able to use the room.** A pane
|
|
7
|
+
* of forms dragged past about half the row does not grow: the labels stay put
|
|
8
|
+
* and the fields stretch to a width nobody types into, so the room becomes
|
|
9
|
+
* empty card. The figure beside it is what the drag exists to enlarge.
|
|
10
|
+
*
|
|
8
11
|
* @param props - See {@link SplitRowProps}.
|
|
9
12
|
* @returns The two panes with the splitter between them, the two stacked on a
|
|
10
13
|
* narrow screen, or whichever one a link left on the page, alone.
|
|
11
14
|
*/
|
|
12
15
|
export function SplitRow(props) {
|
|
13
|
-
|
|
14
|
-
const row = useRef(null);
|
|
15
|
-
const [width, setWidth] = useState(windowWidth);
|
|
16
|
-
// The share under the pointer, which is not the one in the address: a drag
|
|
17
|
-
// reports every pixel it crosses, and the address is rewritten once, where
|
|
18
|
-
// the splitter is let go.
|
|
19
|
-
const [dragged, setDragged] = useState(null);
|
|
20
|
-
useResizeObserver(row, (size) => {
|
|
21
|
-
setWidth(size.width);
|
|
22
|
-
});
|
|
23
|
-
if (start === null && end === null)
|
|
24
|
-
return null;
|
|
25
|
-
const stacked = start === null || end === null || width < stackBelow;
|
|
26
|
-
const startPane = start === null ? null : (_jsx("div", { "data-testid": "split-start", style: stacked ? STACKED_PANE : paneStyle('start', gutter), children: start }));
|
|
27
|
-
const endPane = end === null ? null : (_jsx("div", { "data-testid": "split-end", style: stacked ? STACKED_PANE : paneStyle('end', gutter), children: end }));
|
|
28
|
-
if (stacked) {
|
|
29
|
-
return (_jsxs("div", { ref: row, style: { ...STACK, gap: stackedGap }, children: [startPane, endPane] }));
|
|
30
|
-
}
|
|
31
|
-
const share = clampSplit(dragged ?? ratio ?? defaultRatio, { min, max });
|
|
32
|
-
return (_jsx("div", { ref: row, className: "split-row", children: _jsxs(SplitPane, { direction: "horizontal", controlledSide: "start", size: `${share}%`,
|
|
33
|
-
// Held open, so the only layout a visitor can reach is one the address
|
|
34
|
-
// describes: left to itself a double click collapses a pane, and a link
|
|
35
|
-
// shared from there would open with the pane back. The double click is
|
|
36
|
-
// answered here instead, by returning to the page's own share.
|
|
37
|
-
open: true, onOpenChange: () => {
|
|
38
|
-
setDragged(null);
|
|
39
|
-
onRatio(null);
|
|
40
|
-
}, onSizeChange: (asked) => {
|
|
41
|
-
setDragged(shareOf(asked, share, { min, max }));
|
|
42
|
-
}, onResize: (asked) => {
|
|
43
|
-
const rested = shareOf(asked, share, { min, max });
|
|
44
|
-
setDragged(null);
|
|
45
|
-
onRatio(rested);
|
|
46
|
-
}, children: [startPane, endPane] }) }));
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* The share a splitter asked for.
|
|
50
|
-
* @param asked - What it reported, a percentage because that is what it was
|
|
51
|
-
* given.
|
|
52
|
-
* @param current - The share in force, kept when the report is not a number.
|
|
53
|
-
* @param range - The range this row is divided in.
|
|
54
|
-
* @returns A whole percentage inside it.
|
|
55
|
-
*/
|
|
56
|
-
function shareOf(asked, current, range) {
|
|
57
|
-
const value = Number.parseFloat(asked);
|
|
58
|
-
return Number.isFinite(value) ? clampSplit(value, range) : current;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* How wide the window is, which is what the row is taken to be until it has
|
|
62
|
-
* been measured. Reading it rather than starting at zero is what keeps a wide
|
|
63
|
-
* page from laying itself out stacked and splitting a frame later, which would
|
|
64
|
-
* build both figures twice on every load.
|
|
65
|
-
* @returns The width in pixels, or the threshold itself where there is no
|
|
66
|
-
* window to read — a test, or a page rendered to a string — which is the
|
|
67
|
-
* narrowest a row is still split at.
|
|
68
|
-
*/
|
|
69
|
-
function windowWidth() {
|
|
70
|
-
const { innerWidth } = globalThis;
|
|
71
|
-
return typeof innerWidth === 'number' && innerWidth > 0
|
|
72
|
-
? innerWidth
|
|
73
|
-
: STACK_BELOW;
|
|
74
|
-
}
|
|
75
|
-
/** The narrowest row that is still split, in pixels. */
|
|
76
|
-
const STACK_BELOW = 860;
|
|
77
|
-
/** The gutter a pane keeps beside the splitter, in pixels. */
|
|
78
|
-
const GUTTER = 6;
|
|
79
|
-
/** The gap between the panes once they have stacked, in pixels. */
|
|
80
|
-
const STACKED_GAP = 16;
|
|
81
|
-
const STACK = {
|
|
82
|
-
display: 'flex',
|
|
83
|
-
flexDirection: 'column',
|
|
84
|
-
};
|
|
85
|
-
const STACKED_PANE = {
|
|
86
|
-
display: 'flex',
|
|
87
|
-
flexDirection: 'column',
|
|
88
|
-
minWidth: 0,
|
|
89
|
-
};
|
|
90
|
-
function paneStyle(side, gutter) {
|
|
91
|
-
return {
|
|
92
|
-
display: 'flex',
|
|
93
|
-
flex: '1 1 0%',
|
|
94
|
-
flexDirection: 'column',
|
|
95
|
-
minWidth: 0,
|
|
96
|
-
[side === 'start' ? 'paddingRight' : 'paddingLeft']: gutter,
|
|
97
|
-
};
|
|
16
|
+
return _jsx(SplitPanes, { direction: "horizontal", ...props });
|
|
98
17
|
}
|
|
99
18
|
//# sourceMappingURL=SplitRow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SplitRow.js","sourceRoot":"","sources":["../../../src/split/ui/SplitRow.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"SplitRow.js","sourceRoot":"","sources":["../../../src/split/ui/SplitRow.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAkB,CAAC;AAQ9C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAoB;IAC3C,OAAO,KAAC,UAAU,IAAC,SAAS,EAAC,YAAY,KAAK,KAAK,GAAI,CAAC;AAC1D,CAAC"}
|
package/lib/split/ui/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export type { SplitColumnProps } from './SplitColumn.tsx';
|
|
2
|
+
export { SplitColumn } from './SplitColumn.tsx';
|
|
1
3
|
export type { SplitRowProps } from './SplitRow.tsx';
|
|
2
4
|
export { SplitRow } from './SplitRow.tsx';
|
|
5
|
+
export type { SplitPanesProps } from './splitPanes.tsx';
|
|
3
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/split/ui/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/split/ui/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
|
package/lib/split/ui/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/split/ui/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/split/ui/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAmB,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAgB,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Two figures with a splitter between them, and the share each takes written
|
|
3
|
+
* into the address. The body of `<SplitRow>` and `<SplitColumn>` both.
|
|
4
|
+
*
|
|
5
|
+
* How much room one half deserves beside the other is not ours to decide:
|
|
6
|
+
* somebody embedding the chart wants it nearly whole, somebody teaching off the
|
|
7
|
+
* picker wants the picker nearly whole, and both want the link they hand out to
|
|
8
|
+
* open the way they left it. So the splitter is dragged, the share it comes to
|
|
9
|
+
* rest at goes into `?split=`, and the address is the figure.
|
|
10
|
+
*
|
|
11
|
+
* Two things it cannot do, and must not pretend to: on a screen with no room
|
|
12
|
+
* for two the panes stack and no splitter is drawn; and a link that hid
|
|
13
|
+
* everything one pane holds leaves the other the whole of it rather than a
|
|
14
|
+
* share.
|
|
15
|
+
*
|
|
16
|
+
* The bar itself is react-science's `SplitPane`, and it keeps react-science's
|
|
17
|
+
* look — barely visible on purpose, found by the pointer that changes over it
|
|
18
|
+
* rather than by the eye. All `chrome.css` says about it is that eleven pixels
|
|
19
|
+
* is more gutter than two figures need.
|
|
20
|
+
*/
|
|
21
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
22
|
+
import type { SplitRange } from '../core/split.ts';
|
|
23
|
+
/** What both splitters take. */
|
|
24
|
+
export interface SplitPanesProps extends SplitRange {
|
|
25
|
+
/**
|
|
26
|
+
* Share of the box the first pane takes, as a whole percentage, or `null`
|
|
27
|
+
* while the page sits at {@link SplitPanesProps.defaultRatio}.
|
|
28
|
+
*/
|
|
29
|
+
ratio: number | null;
|
|
30
|
+
/** The share it opens at when the address names none. */
|
|
31
|
+
defaultRatio: number;
|
|
32
|
+
/**
|
|
33
|
+
* Take the share a drag came to rest at, or `null` when the splitter was
|
|
34
|
+
* double-clicked back to the default.
|
|
35
|
+
*/
|
|
36
|
+
onRatio: (ratio: number | null) => void;
|
|
37
|
+
/** The first pane — left, or top — or `null` when a link left nothing in it. */
|
|
38
|
+
start: ReactNode;
|
|
39
|
+
/** The second pane, or `null` when a link left nothing in it. */
|
|
40
|
+
end: ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* The smallest box that is still split, in pixels — a width for a row, a
|
|
43
|
+
* height for a column. Under it the two panes stack and no splitter is drawn.
|
|
44
|
+
* @default 860 across, 420 down
|
|
45
|
+
*/
|
|
46
|
+
stackBelow?: number;
|
|
47
|
+
/**
|
|
48
|
+
* The gutter each pane keeps beside the splitter, in pixels, so neither
|
|
49
|
+
* figure is read against its edge.
|
|
50
|
+
* @default 6
|
|
51
|
+
*/
|
|
52
|
+
gutter?: number;
|
|
53
|
+
/**
|
|
54
|
+
* The gap between the two panes once they have stacked, in pixels.
|
|
55
|
+
* @default 16
|
|
56
|
+
*/
|
|
57
|
+
stackedGap?: number;
|
|
58
|
+
}
|
|
59
|
+
/** What {@link SplitPanes} takes on top of the public props. */
|
|
60
|
+
interface InternalProps extends SplitPanesProps {
|
|
61
|
+
/** Across the box, or down it. */
|
|
62
|
+
direction: 'horizontal' | 'vertical';
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The two panes, divided where the address says.
|
|
66
|
+
*
|
|
67
|
+
* @param props - See {@link SplitPanesProps}.
|
|
68
|
+
* @returns The panes with the splitter between them, the two stacked where
|
|
69
|
+
* there is no room for both, or whichever one a link left, alone.
|
|
70
|
+
*/
|
|
71
|
+
export declare function SplitPanes(props: InternalProps): ReactElement | null;
|
|
72
|
+
export {};
|
|
73
|
+
//# sourceMappingURL=splitPanes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"splitPanes.d.ts","sourceRoot":"","sources":["../../../src/split/ui/splitPanes.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAiB,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD,gCAAgC;AAChC,MAAM,WAAW,eAAgB,SAAQ,UAAU;IACjD;;;OAGG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,yDAAyD;IACzD,YAAY,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACxC,gFAAgF;IAChF,KAAK,EAAE,SAAS,CAAC;IACjB,iEAAiE;IACjE,GAAG,EAAE,SAAS,CAAC;IACf;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,gEAAgE;AAChE,UAAU,aAAc,SAAQ,eAAe;IAC7C,kCAAkC;IAClC,SAAS,EAAE,YAAY,GAAG,UAAU,CAAC;CACtC;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,aAAa,GAAG,YAAY,GAAG,IAAI,CA6FpE"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState } from 'react';
|
|
3
|
+
import { SplitPane } from 'react-science/ui';
|
|
4
|
+
import { useResizeObserver } from "../../hooks/ui/useResizeObserver.js";
|
|
5
|
+
import { clampSplit } from "../core/split.js";
|
|
6
|
+
/**
|
|
7
|
+
* The two panes, divided where the address says.
|
|
8
|
+
*
|
|
9
|
+
* @param props - See {@link SplitPanesProps}.
|
|
10
|
+
* @returns The panes with the splitter between them, the two stacked where
|
|
11
|
+
* there is no room for both, or whichever one a link left, alone.
|
|
12
|
+
*/
|
|
13
|
+
export function SplitPanes(props) {
|
|
14
|
+
const { direction, ratio, defaultRatio, onRatio, start, end, min, max, stackBelow = direction === 'horizontal' ? STACK_ACROSS : STACK_DOWN, gutter = GUTTER, stackedGap = STACKED_GAP, } = props;
|
|
15
|
+
const across = direction === 'horizontal';
|
|
16
|
+
const box = useRef(null);
|
|
17
|
+
const [size, setSize] = useState(() => viewportSize(across, stackBelow));
|
|
18
|
+
// The share under the pointer, which is not the one in the address: a drag
|
|
19
|
+
// reports every pixel it crosses, and the address is rewritten once, where
|
|
20
|
+
// the splitter is let go.
|
|
21
|
+
const [dragged, setDragged] = useState(null);
|
|
22
|
+
useResizeObserver(box, (measured) => {
|
|
23
|
+
setSize(across ? measured.width : measured.height);
|
|
24
|
+
});
|
|
25
|
+
if (start === null && end === null)
|
|
26
|
+
return null;
|
|
27
|
+
// A column divided by a share needs a box of a definite height to take a
|
|
28
|
+
// share of; in an ordinary page-height one it would measure zero and both
|
|
29
|
+
// panes would collapse, so it stacks instead and says nothing about it.
|
|
30
|
+
const stacked = start === null || end === null || size < stackBelow;
|
|
31
|
+
const startPane = start === null ? null : (_jsx("div", { "data-testid": "split-start", style: stacked ? STACKED_PANE : paneStyle(across, 'start', gutter), children: start }));
|
|
32
|
+
const endPane = end === null ? null : (_jsx("div", { "data-testid": "split-end", style: stacked ? STACKED_PANE : paneStyle(across, 'end', gutter), children: end }));
|
|
33
|
+
if (stacked) {
|
|
34
|
+
return (_jsxs("div", { ref: box, style: { ...STACK, gap: stackedGap }, children: [startPane, endPane] }));
|
|
35
|
+
}
|
|
36
|
+
const share = clampSplit(dragged ?? ratio ?? defaultRatio, { min, max });
|
|
37
|
+
return (_jsx("div", { ref: box, className: "split-row", style: across ? undefined : FILL, children: _jsxs(SplitPane, { direction: direction, controlledSide: "start", size: `${share}%`,
|
|
38
|
+
// Held open, so the only layout a visitor can reach is one the address
|
|
39
|
+
// describes: left to itself a double click collapses a pane, and a link
|
|
40
|
+
// shared from there would open with the pane back. The double click is
|
|
41
|
+
// answered here instead, by returning to the page's own share.
|
|
42
|
+
open: true, onOpenChange: () => {
|
|
43
|
+
setDragged(null);
|
|
44
|
+
onRatio(null);
|
|
45
|
+
}, onSizeChange: (asked) => {
|
|
46
|
+
setDragged(shareOf(asked, share, { min, max }));
|
|
47
|
+
}, onResize: (asked) => {
|
|
48
|
+
const rested = shareOf(asked, share, { min, max });
|
|
49
|
+
setDragged(null);
|
|
50
|
+
onRatio(rested);
|
|
51
|
+
}, children: [startPane, endPane] }) }));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The share a splitter asked for.
|
|
55
|
+
*
|
|
56
|
+
* @param asked - What it reported, a percentage because that is what it was
|
|
57
|
+
* given.
|
|
58
|
+
* @param current - The share in force, kept when the report is not a number.
|
|
59
|
+
* @param range - The range this box is divided in.
|
|
60
|
+
* @returns A whole percentage inside it.
|
|
61
|
+
*/
|
|
62
|
+
function shareOf(asked, current, range) {
|
|
63
|
+
const value = Number.parseFloat(asked);
|
|
64
|
+
return Number.isFinite(value) ? clampSplit(value, range) : current;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* How big the window is, which is what the box is taken to be until it has been
|
|
68
|
+
* measured. Reading it rather than starting at zero is what keeps a wide page
|
|
69
|
+
* from laying itself out stacked and splitting a frame later, which would build
|
|
70
|
+
* both figures twice on every load.
|
|
71
|
+
*
|
|
72
|
+
* @param across - Whether the box is divided across or down.
|
|
73
|
+
* @param fallback - What to answer where there is no window to read — a test,
|
|
74
|
+
* or a page rendered to a string.
|
|
75
|
+
* @returns The size in pixels.
|
|
76
|
+
*/
|
|
77
|
+
function viewportSize(across, fallback) {
|
|
78
|
+
const measure = across ? globalThis.innerWidth : globalThis.innerHeight;
|
|
79
|
+
return typeof measure === 'number' && measure > 0 ? measure : fallback;
|
|
80
|
+
}
|
|
81
|
+
/** The narrowest box still divided across, in pixels. */
|
|
82
|
+
const STACK_ACROSS = 860;
|
|
83
|
+
/**
|
|
84
|
+
* The shortest box still divided down, in pixels. Two figures sharing less than
|
|
85
|
+
* this have about two hundred pixels each, which is under what any of them
|
|
86
|
+
* reads at.
|
|
87
|
+
*/
|
|
88
|
+
const STACK_DOWN = 420;
|
|
89
|
+
/** The gutter a pane keeps beside the splitter, in pixels. */
|
|
90
|
+
const GUTTER = 6;
|
|
91
|
+
/** The gap between the panes once they have stacked, in pixels. */
|
|
92
|
+
const STACKED_GAP = 16;
|
|
93
|
+
const STACK = {
|
|
94
|
+
display: 'flex',
|
|
95
|
+
flexDirection: 'column',
|
|
96
|
+
minHeight: 0,
|
|
97
|
+
};
|
|
98
|
+
const STACKED_PANE = {
|
|
99
|
+
display: 'flex',
|
|
100
|
+
flexDirection: 'column',
|
|
101
|
+
minWidth: 0,
|
|
102
|
+
minHeight: 0,
|
|
103
|
+
};
|
|
104
|
+
/** A column takes the height it is given, so its share has something to divide. */
|
|
105
|
+
const FILL = {
|
|
106
|
+
display: 'flex',
|
|
107
|
+
flex: '1 1 0%',
|
|
108
|
+
flexDirection: 'column',
|
|
109
|
+
minHeight: 0,
|
|
110
|
+
};
|
|
111
|
+
function paneStyle(across, side, gutter) {
|
|
112
|
+
const edge = across
|
|
113
|
+
? side === 'start'
|
|
114
|
+
? 'paddingRight'
|
|
115
|
+
: 'paddingLeft'
|
|
116
|
+
: side === 'start'
|
|
117
|
+
? 'paddingBottom'
|
|
118
|
+
: 'paddingTop';
|
|
119
|
+
return {
|
|
120
|
+
display: 'flex',
|
|
121
|
+
flex: '1 1 0%',
|
|
122
|
+
flexDirection: 'column',
|
|
123
|
+
minWidth: 0,
|
|
124
|
+
minHeight: 0,
|
|
125
|
+
[edge]: gutter,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=splitPanes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"splitPanes.js","sourceRoot":"","sources":["../../../src/split/ui/splitPanes.tsx"],"names":[],"mappings":";AAsBA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAExE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AA6C9C;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,KAAoB;IAC7C,MAAM,EACJ,SAAS,EACT,KAAK,EACL,YAAY,EACZ,OAAO,EACP,KAAK,EACL,GAAG,EACH,GAAG,EACH,GAAG,EACH,UAAU,GAAG,SAAS,KAAK,YAAY,CAAC,CAAC,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AAS,EAAE,CAAC;CACoB,CAAC;AAEnC,SAAS,SAAS,CAChB,MAAe,EACf,IAAqB,EACrB,MAAc;IAEd,MAAM,IAAI,GAAG,MAAM;QACjB,CAAC,CAAC,IAAI,KAAK,OAAO;YAChB,CAAC,CAAC,cAAc;YAChB,CAAC,CAAC,aAAa;QACjB,CAAC,CAAC,IAAI,KAAK,OAAO;YAChB,CAAC,CAAC,eAAe;YACjB,CAAC,CAAC,YAAY,CAAC;IACnB,OAAO;QACL,OAAO,EAAE,MAAM;QACf,IAAI,EAAE,QAAQ;QACd,aAAa,EAAE,QAAQ;QACvB,QAAQ,EAAE,CAAC;QACX,SAAS,EAAE,CAAC;QACZ,CAAC,IAAI,CAAC,EAAE,MAAM;KACf,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-cheminfo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.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",
|