react-cheminfo 0.121.0 → 0.123.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/drawing/core/index.d.ts +2 -0
- package/lib/drawing/core/index.d.ts.map +1 -1
- package/lib/drawing/core/index.js +1 -0
- package/lib/drawing/core/index.js.map +1 -1
- package/lib/drawing/core/undoHistory.d.ts +59 -0
- package/lib/drawing/core/undoHistory.d.ts.map +1 -0
- package/lib/drawing/core/undoHistory.js +68 -0
- package/lib/drawing/core/undoHistory.js.map +1 -0
- package/lib/ecosystem/core/index.d.ts +2 -2
- package/lib/ecosystem/core/index.d.ts.map +1 -1
- package/lib/ecosystem/core/index.js +1 -1
- package/lib/ecosystem/core/index.js.map +1 -1
- package/lib/ecosystem/core/lookup.d.ts +6 -0
- package/lib/ecosystem/core/lookup.d.ts.map +1 -1
- package/lib/ecosystem/core/lookup.js +8 -0
- package/lib/ecosystem/core/lookup.js.map +1 -1
- package/lib/ecosystem/core/sites.d.ts +1 -1
- package/lib/ecosystem/core/sites.d.ts.map +1 -1
- package/lib/ecosystem/core/sites.js.map +1 -1
- package/lib/ecosystem/core/types.d.ts +23 -1
- package/lib/ecosystem/core/types.d.ts.map +1 -1
- package/lib/ecosystem/core/unlistedSites.d.ts.map +1 -1
- package/lib/ecosystem/core/unlistedSites.js +77 -0
- package/lib/ecosystem/core/unlistedSites.js.map +1 -1
- package/lib/ecosystem/ui/glyphs.d.ts.map +1 -1
- package/lib/ecosystem/ui/glyphs.js +16 -0
- package/lib/ecosystem/ui/glyphs.js.map +1 -1
- package/lib/host/core/answerGet.js +1 -1
- package/lib/host/core/answerGet.js.map +1 -1
- package/lib/host/core/datasetKinds.d.ts +246 -0
- package/lib/host/core/datasetKinds.d.ts.map +1 -0
- package/lib/host/core/datasetKinds.js +97 -0
- package/lib/host/core/datasetKinds.js.map +1 -0
- package/lib/host/core/hostOutputs.js +1 -1
- package/lib/host/core/hostOutputs.js.map +1 -1
- package/lib/host/core/index.d.ts +6 -1
- package/lib/host/core/index.d.ts.map +1 -1
- package/lib/host/core/index.js +4 -1
- package/lib/host/core/index.js.map +1 -1
- package/lib/host/core/kindAccepts.d.ts +15 -0
- package/lib/host/core/kindAccepts.d.ts.map +1 -0
- package/lib/host/core/kindAccepts.js +22 -0
- package/lib/host/core/kindAccepts.js.map +1 -0
- package/lib/host/core/kinds.d.ts +7 -10
- package/lib/host/core/kinds.d.ts.map +1 -1
- package/lib/host/core/kinds.js +7 -17
- package/lib/host/core/kinds.js.map +1 -1
- package/lib/host/core/selectInputs.d.ts.map +1 -1
- package/lib/host/core/selectInputs.js +2 -1
- package/lib/host/core/selectInputs.js.map +1 -1
- package/lib/host/core/sendTargets.d.ts +32 -0
- package/lib/host/core/sendTargets.d.ts.map +1 -0
- package/lib/host/core/sendTargets.js +40 -0
- package/lib/host/core/sendTargets.js.map +1 -0
- package/lib/host/ui/SendToButton.d.ts +38 -0
- package/lib/host/ui/SendToButton.d.ts.map +1 -0
- package/lib/host/ui/SendToButton.js +61 -0
- package/lib/host/ui/SendToButton.js.map +1 -0
- package/lib/host/ui/index.d.ts +2 -0
- package/lib/host/ui/index.d.ts.map +1 -1
- package/lib/host/ui/index.js +1 -0
- package/lib/host/ui/index.js.map +1 -1
- package/lib/host/ui/openTool.d.ts +16 -8
- package/lib/host/ui/openTool.d.ts.map +1 -1
- package/lib/host/ui/openTool.js +36 -11
- package/lib/host/ui/openTool.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 +10 -1
- package/lib/locales/en.json +10 -1
- package/lib/locales/es.json +10 -1
- package/lib/locales/fr.json +10 -1
- package/lib/locales/it.json +10 -1
- package/lib/panel/core/createPanelState.d.ts +58 -0
- package/lib/panel/core/createPanelState.d.ts.map +1 -0
- package/lib/panel/core/createPanelState.js +74 -0
- package/lib/panel/core/createPanelState.js.map +1 -0
- package/lib/panel/core/index.d.ts +2 -0
- package/lib/panel/core/index.d.ts.map +1 -1
- package/lib/panel/core/index.js +1 -0
- package/lib/panel/core/index.js.map +1 -1
- package/lib/panel/ui/PanelFrame.d.ts +27 -0
- package/lib/panel/ui/PanelFrame.d.ts.map +1 -0
- package/lib/panel/ui/PanelFrame.js +12 -0
- package/lib/panel/ui/PanelFrame.js.map +1 -0
- package/lib/panel/ui/index.d.ts +2 -0
- package/lib/panel/ui/index.d.ts.map +1 -1
- package/lib/panel/ui/index.js +1 -0
- package/lib/panel/ui/index.js.map +1 -1
- package/package.json +1 -1
- package/src/drawing/core/index.ts +2 -0
- package/src/drawing/core/undoHistory.ts +118 -0
- package/src/ecosystem/core/index.ts +2 -0
- package/src/ecosystem/core/lookup.ts +9 -0
- package/src/ecosystem/core/sites.ts +1 -0
- package/src/ecosystem/core/types.ts +28 -0
- package/src/ecosystem/core/unlistedSites.ts +81 -0
- package/src/ecosystem/ui/glyphs.tsx +97 -0
- package/src/host/core/answerGet.ts +1 -1
- package/src/host/core/datasetKinds.ts +202 -0
- package/src/host/core/hostOutputs.ts +1 -1
- package/src/host/core/index.ts +12 -1
- package/src/host/core/kindAccepts.ts +21 -0
- package/src/host/core/kinds.ts +14 -18
- package/src/host/core/selectInputs.ts +2 -1
- package/src/host/core/sendTargets.ts +67 -0
- package/src/host/ui/SendToButton.tsx +147 -0
- package/src/host/ui/index.ts +2 -0
- package/src/host/ui/openTool.ts +57 -16
- package/src/locales/de.json +10 -1
- package/src/locales/en.json +10 -1
- package/src/locales/es.json +10 -1
- package/src/locales/fr.json +10 -1
- package/src/locales/it.json +10 -1
- package/src/panel/core/createPanelState.ts +126 -0
- package/src/panel/core/index.ts +6 -0
- package/src/panel/ui/PanelFrame.tsx +47 -0
- package/src/panel/ui/index.ts +2 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which panels of an editor are open beside its figure, and which are folded,
|
|
3
|
+
* kept on the site's own signals: the open and folded panels are preferences,
|
|
4
|
+
* what a narrow window shows is view state. On a window too narrow to keep
|
|
5
|
+
* panels beside the figure they collapse: the figure keeps the row, and one
|
|
6
|
+
* panel at a time comes over it when somebody asks for it.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { Cell, SignalTools } from '../../storage/core/documentFile.ts';
|
|
10
|
+
|
|
11
|
+
import { watchPanelsCollapsed } from './panelsCollapsed.ts';
|
|
12
|
+
|
|
13
|
+
/** The signals the panels of an editor are kept on. */
|
|
14
|
+
export interface PanelStateCells<P extends string> {
|
|
15
|
+
/** The panels open beside the figure: a preference. */
|
|
16
|
+
open: Cell<readonly P[]>;
|
|
17
|
+
/** The open panels drawn folded: a preference. */
|
|
18
|
+
folded: Cell<readonly P[]>;
|
|
19
|
+
/** Whether the window is too narrow for panels beside the figure. */
|
|
20
|
+
collapsed: Cell<boolean>;
|
|
21
|
+
/** The panel over the figure while the panels are collapsed. */
|
|
22
|
+
drawer: Cell<P | null>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** What the panels of an editor are kept on. */
|
|
26
|
+
export interface PanelStateOptions<P extends string> {
|
|
27
|
+
/** Every panel, in the order the rail lists them. */
|
|
28
|
+
ids: readonly P[];
|
|
29
|
+
/** The site's signals. */
|
|
30
|
+
cells: PanelStateCells<P>;
|
|
31
|
+
/** `batch` from the site's signals. */
|
|
32
|
+
signals: Pick<SignalTools, 'batch'>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The panels of an editor, and what changes them. */
|
|
36
|
+
export interface PanelState<P extends string> {
|
|
37
|
+
/** The panels on screen: the open ones, or the one over the figure. */
|
|
38
|
+
visible: () => readonly P[];
|
|
39
|
+
/** The panels on screen drawn folded; none while the panels collapse. */
|
|
40
|
+
visibleFolded: () => readonly P[];
|
|
41
|
+
/**
|
|
42
|
+
* Follow the width of the window; returns the stop.
|
|
43
|
+
* @returns Stops following it.
|
|
44
|
+
*/
|
|
45
|
+
start: () => () => void;
|
|
46
|
+
/** Open a panel or close it, from its button on the rail. */
|
|
47
|
+
toggle: (panel: P) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Show a panel open and unfolded. With the panels collapsed it only joins
|
|
50
|
+
* the preferences: a gesture on the figure must not cover the figure.
|
|
51
|
+
*/
|
|
52
|
+
open: (panel: P) => void;
|
|
53
|
+
/** Fold the panels given, as the panel stack reports them. */
|
|
54
|
+
setFolded: (folded: readonly string[]) => void;
|
|
55
|
+
/** The panels a stored value names, in the order of `ids`. */
|
|
56
|
+
panelsIn: (value: unknown) => P[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Keep which panels of an editor are open and folded.
|
|
61
|
+
* @param options - Every panel, the site's signals and its `batch`.
|
|
62
|
+
* @returns The panels, and what changes them.
|
|
63
|
+
*/
|
|
64
|
+
export function createPanelState<P extends string>(
|
|
65
|
+
options: PanelStateOptions<P>,
|
|
66
|
+
): PanelState<P> {
|
|
67
|
+
const { ids, cells, signals } = options;
|
|
68
|
+
const { open, folded, collapsed, drawer } = cells;
|
|
69
|
+
|
|
70
|
+
const panelsIn = (value: unknown): P[] =>
|
|
71
|
+
Array.isArray(value) ? ids.filter((id) => value.includes(id)) : [];
|
|
72
|
+
|
|
73
|
+
const openPanel = (panel: P) => {
|
|
74
|
+
const opened = panelsIn(open.value);
|
|
75
|
+
const foldedPanels = panelsIn(folded.value);
|
|
76
|
+
if (opened.includes(panel) && !foldedPanels.includes(panel)) return;
|
|
77
|
+
signals.batch(() => {
|
|
78
|
+
open.value = panelsIn([...opened, panel]);
|
|
79
|
+
folded.value = foldedPanels.filter((id) => id !== panel);
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
visible: () => {
|
|
85
|
+
if (!collapsed.value) return panelsIn(open.value);
|
|
86
|
+
const panel = drawer.value;
|
|
87
|
+
return panel === null ? [] : [panel];
|
|
88
|
+
},
|
|
89
|
+
visibleFolded: () => (collapsed.value ? [] : panelsIn(folded.value)),
|
|
90
|
+
start: () =>
|
|
91
|
+
watchPanelsCollapsed((next) => {
|
|
92
|
+
signals.batch(() => {
|
|
93
|
+
// What was on screen stays on screen when there is room for it.
|
|
94
|
+
const panel = drawer.peek();
|
|
95
|
+
collapsed.value = next;
|
|
96
|
+
drawer.value = null;
|
|
97
|
+
if (panel !== null && !next) openPanel(panel);
|
|
98
|
+
});
|
|
99
|
+
}),
|
|
100
|
+
toggle: (panel) => {
|
|
101
|
+
if (collapsed.value) {
|
|
102
|
+
drawer.value = drawer.value === panel ? null : panel;
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const opened = panelsIn(open.value);
|
|
106
|
+
if (!opened.includes(panel)) {
|
|
107
|
+
openPanel(panel);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
signals.batch(() => {
|
|
111
|
+
open.value = opened.filter((id) => id !== panel);
|
|
112
|
+
folded.value = panelsIn(folded.value).filter((id) => id !== panel);
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
open: openPanel,
|
|
116
|
+
setFolded: (next) => {
|
|
117
|
+
if (collapsed.value) {
|
|
118
|
+
// Folding the one over the figure sends it away.
|
|
119
|
+
if (next.length > 0) drawer.value = null;
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
folded.value = panelsIn(next);
|
|
123
|
+
},
|
|
124
|
+
panelsIn,
|
|
125
|
+
};
|
|
126
|
+
}
|
package/src/panel/core/index.ts
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
export { listStyle, paragraphStyle } from './dialogStyles.ts';
|
|
13
|
+
export type {
|
|
14
|
+
PanelState,
|
|
15
|
+
PanelStateCells,
|
|
16
|
+
PanelStateOptions,
|
|
17
|
+
} from './createPanelState.ts';
|
|
18
|
+
export { createPanelState } from './createPanelState.ts';
|
|
13
19
|
export { isEditingField } from './isEditingField.ts';
|
|
14
20
|
export type { PanelLayout, PanelStatus } from './panelLayout.ts';
|
|
15
21
|
export {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One panel's body: its own actions in a row under the header, at the left,
|
|
3
|
+
* then what it shows, which scrolls inside the panel.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
panelBodyStyle,
|
|
10
|
+
panelStyle,
|
|
11
|
+
panelToolbarStyle,
|
|
12
|
+
} from '../core/panelStyles.ts';
|
|
13
|
+
|
|
14
|
+
/** What a panel's body holds. */
|
|
15
|
+
export interface PanelFrameProps {
|
|
16
|
+
/**
|
|
17
|
+
* The panel's own actions, in a row under its header.
|
|
18
|
+
* @default none, and no row
|
|
19
|
+
*/
|
|
20
|
+
toolbar?: ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* What a test finds the panel by.
|
|
23
|
+
* @default none
|
|
24
|
+
*/
|
|
25
|
+
testId?: string;
|
|
26
|
+
/** What the panel shows. */
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A panel's body: its toolbar, kept off a print, over what it shows.
|
|
32
|
+
* @param props - What the panel holds.
|
|
33
|
+
* @returns The body.
|
|
34
|
+
*/
|
|
35
|
+
export function PanelFrame(props: PanelFrameProps): ReactElement {
|
|
36
|
+
const { toolbar, testId, children } = props;
|
|
37
|
+
return (
|
|
38
|
+
<div style={panelStyle} data-testid={testId}>
|
|
39
|
+
{toolbar ? (
|
|
40
|
+
<div style={panelToolbarStyle} className="no-print">
|
|
41
|
+
{toolbar}
|
|
42
|
+
</div>
|
|
43
|
+
) : null}
|
|
44
|
+
<div style={panelBodyStyle}>{children}</div>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
}
|
package/src/panel/ui/index.ts
CHANGED
|
@@ -32,6 +32,8 @@ export type {
|
|
|
32
32
|
PanelMessageProps,
|
|
33
33
|
} from './PanelMessage.tsx';
|
|
34
34
|
export { PanelEmpty, PanelMessage } from './PanelMessage.tsx';
|
|
35
|
+
export type { PanelFrameProps } from './PanelFrame.tsx';
|
|
36
|
+
export { PanelFrame } from './PanelFrame.tsx';
|
|
35
37
|
export type { PanelRowProps } from './PanelRow.tsx';
|
|
36
38
|
export { PanelRow } from './PanelRow.tsx';
|
|
37
39
|
export type { PanelRailProps, RailPanel } from './PanelRail.tsx';
|