react-cheminfo 0.6.0 → 0.7.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 +16 -0
- package/lib/citation/core/index.d.ts +1 -0
- package/lib/citation/core/index.d.ts.map +1 -1
- package/lib/citation/core/index.js +1 -0
- package/lib/citation/core/index.js.map +1 -1
- package/lib/citation/core/platformPaper.d.ts +14 -0
- package/lib/citation/core/platformPaper.d.ts.map +1 -0
- package/lib/citation/core/platformPaper.js +28 -0
- package/lib/citation/core/platformPaper.js.map +1 -0
- package/lib/color/core/index.d.ts +1 -1
- package/lib/color/core/index.d.ts.map +1 -1
- package/lib/color/core/index.js +1 -1
- package/lib/color/core/index.js.map +1 -1
- 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/ecosystem/core/sites.js +5 -5
- package/lib/orbital/core/index.d.ts +1 -1
- package/lib/orbital/core/index.d.ts.map +1 -1
- package/lib/orbital/core/index.js +1 -1
- package/lib/orbital/core/index.js.map +1 -1
- package/lib/periodic/core/categories.d.ts +25 -0
- package/lib/periodic/core/categories.d.ts.map +1 -0
- package/lib/periodic/core/categories.js +70 -0
- package/lib/periodic/core/categories.js.map +1 -0
- package/lib/periodic/core/elements.d.ts +49 -0
- package/lib/periodic/core/elements.d.ts.map +1 -0
- package/lib/periodic/core/elements.js +175 -0
- package/lib/periodic/core/elements.js.map +1 -0
- package/lib/periodic/core/index.d.ts +6 -0
- package/lib/periodic/core/index.d.ts.map +1 -0
- package/lib/periodic/core/index.js +4 -0
- package/lib/periodic/core/index.js.map +1 -0
- package/lib/periodic/core/layout.d.ts +73 -0
- package/lib/periodic/core/layout.d.ts.map +1 -0
- package/lib/periodic/core/layout.js +132 -0
- package/lib/periodic/core/layout.js.map +1 -0
- package/lib/periodic/ui/CategoryLegend.d.ts +26 -0
- package/lib/periodic/ui/CategoryLegend.d.ts.map +1 -0
- package/lib/periodic/ui/CategoryLegend.js +53 -0
- package/lib/periodic/ui/CategoryLegend.js.map +1 -0
- package/lib/periodic/ui/ElementCell.d.ts +53 -0
- package/lib/periodic/ui/ElementCell.d.ts.map +1 -0
- package/lib/periodic/ui/ElementCell.js +56 -0
- package/lib/periodic/ui/ElementCell.js.map +1 -0
- package/lib/periodic/ui/PeriodicTable.d.ts +90 -0
- package/lib/periodic/ui/PeriodicTable.d.ts.map +1 -0
- package/lib/periodic/ui/PeriodicTable.js +77 -0
- package/lib/periodic/ui/PeriodicTable.js.map +1 -0
- package/lib/periodic/ui/PeriodicTableChrome.d.ts +36 -0
- package/lib/periodic/ui/PeriodicTableChrome.d.ts.map +1 -0
- package/lib/periodic/ui/PeriodicTableChrome.js +72 -0
- package/lib/periodic/ui/PeriodicTableChrome.js.map +1 -0
- package/lib/periodic/ui/index.d.ts +7 -0
- package/lib/periodic/ui/index.d.ts.map +1 -0
- package/lib/periodic/ui/index.js +4 -0
- package/lib/periodic/ui/index.js.map +1 -0
- 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 +2 -1
- package/src/citation/core/index.ts +1 -0
- package/src/citation/core/platformPaper.ts +32 -0
- package/src/color/core/index.ts +6 -1
- package/src/core.ts +1 -0
- package/src/ecosystem/core/sites.ts +5 -5
- package/src/orbital/core/index.ts +1 -1
- package/src/periodic/core/categories.ts +83 -0
- package/src/periodic/core/elements.ts +217 -0
- package/src/periodic/core/index.ts +27 -0
- package/src/periodic/core/layout.ts +183 -0
- package/src/periodic/ui/CategoryLegend.tsx +105 -0
- package/src/periodic/ui/ElementCell.tsx +137 -0
- package/src/periodic/ui/PeriodicTable.tsx +226 -0
- package/src/periodic/ui/PeriodicTableChrome.tsx +170 -0
- package/src/periodic/ui/index.ts +6 -0
- package/src/ui.ts +1 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The furniture around the cells: the group and period strips, and the two
|
|
3
|
+
* markers the inner-transition series were lifted out of.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { CSSProperties, ReactElement } from 'react';
|
|
7
|
+
|
|
8
|
+
import type { ElementRange } from '../core/layout.ts';
|
|
9
|
+
import {
|
|
10
|
+
COLUMN_COUNT,
|
|
11
|
+
INNER_TRANSITION_MARKERS,
|
|
12
|
+
INNER_TRANSITION_ROWS,
|
|
13
|
+
} from '../core/layout.ts';
|
|
14
|
+
|
|
15
|
+
/** What {@link HeaderStrips} needs. */
|
|
16
|
+
export interface HeaderStripsProps {
|
|
17
|
+
/**
|
|
18
|
+
* Called with the run whose header was clicked. Without it the strips are
|
|
19
|
+
* labels rather than buttons.
|
|
20
|
+
* @default undefined
|
|
21
|
+
*/
|
|
22
|
+
onSelectRange?: (range: ElementRange) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The 1–18 strip along the top and the 1–7 strip down the left.
|
|
27
|
+
*
|
|
28
|
+
* They are buttons when the table takes a range: "plot period 3" is one click
|
|
29
|
+
* there and eight on the cells.
|
|
30
|
+
* @param props - See {@link HeaderStripsProps}.
|
|
31
|
+
* @returns The two strips, placed on the grid.
|
|
32
|
+
*/
|
|
33
|
+
export function HeaderStrips(props: HeaderStripsProps): ReactElement {
|
|
34
|
+
const { onSelectRange } = props;
|
|
35
|
+
const groups: ReactElement[] = [];
|
|
36
|
+
for (let group = 1; group <= COLUMN_COUNT; group++) {
|
|
37
|
+
groups.push(
|
|
38
|
+
<HeaderCell
|
|
39
|
+
key={`group-${String(group)}`}
|
|
40
|
+
label={String(group)}
|
|
41
|
+
title={`Group ${String(group)}`}
|
|
42
|
+
column={group + 1}
|
|
43
|
+
row={1}
|
|
44
|
+
onClick={
|
|
45
|
+
onSelectRange &&
|
|
46
|
+
(() => {
|
|
47
|
+
onSelectRange({ kind: 'group', value: group });
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
/>,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
const periods: ReactElement[] = [];
|
|
54
|
+
for (let period = 1; period <= 7; period++) {
|
|
55
|
+
periods.push(
|
|
56
|
+
<HeaderCell
|
|
57
|
+
key={`period-${String(period)}`}
|
|
58
|
+
label={String(period)}
|
|
59
|
+
title={`Period ${String(period)}`}
|
|
60
|
+
column={1}
|
|
61
|
+
row={period + 1}
|
|
62
|
+
onClick={
|
|
63
|
+
onSelectRange &&
|
|
64
|
+
(() => {
|
|
65
|
+
onSelectRange({ kind: 'period', value: period });
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
/>,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<>
|
|
74
|
+
{groups}
|
|
75
|
+
{periods}
|
|
76
|
+
{INNER_TRANSITION_ROWS.map(({ row, period }) => (
|
|
77
|
+
<div
|
|
78
|
+
key={`inner-${String(row)}`}
|
|
79
|
+
style={{ ...headerStyle, gridColumn: 1, gridRow: row + 1 }}
|
|
80
|
+
>
|
|
81
|
+
{period}
|
|
82
|
+
</div>
|
|
83
|
+
))}
|
|
84
|
+
</>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** What {@link InnerTransitionMarkers} needs. */
|
|
89
|
+
export interface InnerTransitionMarkersProps {
|
|
90
|
+
/** 1 when the table draws its header strips, 0 otherwise. */
|
|
91
|
+
offset: number;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The two cells the lanthanoids and the actinoids were lifted out of.
|
|
96
|
+
* @param props - See {@link InnerTransitionMarkersProps}.
|
|
97
|
+
* @returns The markers, placed on the grid.
|
|
98
|
+
*/
|
|
99
|
+
export function InnerTransitionMarkers(
|
|
100
|
+
props: InnerTransitionMarkersProps,
|
|
101
|
+
): ReactElement {
|
|
102
|
+
const { offset } = props;
|
|
103
|
+
return (
|
|
104
|
+
<>
|
|
105
|
+
{INNER_TRANSITION_MARKERS.map(({ cell, label, category }) => (
|
|
106
|
+
<div
|
|
107
|
+
key={category}
|
|
108
|
+
aria-hidden="true"
|
|
109
|
+
style={{
|
|
110
|
+
...markerStyle,
|
|
111
|
+
gridColumn: cell.column + offset,
|
|
112
|
+
gridRow: cell.row + offset,
|
|
113
|
+
}}
|
|
114
|
+
>
|
|
115
|
+
{label}
|
|
116
|
+
</div>
|
|
117
|
+
))}
|
|
118
|
+
</>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
interface HeaderCellProps {
|
|
123
|
+
label: string;
|
|
124
|
+
title: string;
|
|
125
|
+
column: number;
|
|
126
|
+
row: number;
|
|
127
|
+
onClick?: (() => void) | undefined;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function HeaderCell(props: HeaderCellProps): ReactElement {
|
|
131
|
+
const { label, title, column, row, onClick } = props;
|
|
132
|
+
const style = { ...headerStyle, gridColumn: column, gridRow: row };
|
|
133
|
+
if (onClick === undefined) return <div style={style}>{label}</div>;
|
|
134
|
+
return (
|
|
135
|
+
<button
|
|
136
|
+
type="button"
|
|
137
|
+
aria-label={title}
|
|
138
|
+
onClick={onClick}
|
|
139
|
+
style={{ ...style, ...headerButtonStyle }}
|
|
140
|
+
>
|
|
141
|
+
{label}
|
|
142
|
+
</button>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const headerStyle = {
|
|
147
|
+
alignItems: 'center',
|
|
148
|
+
color: 'rgb(95 107 124)',
|
|
149
|
+
display: 'flex',
|
|
150
|
+
fontSize: 'clamp(0.4rem, 1.9cqw, 0.62rem)',
|
|
151
|
+
justifyContent: 'center',
|
|
152
|
+
padding: 0,
|
|
153
|
+
} as const satisfies CSSProperties;
|
|
154
|
+
|
|
155
|
+
const headerButtonStyle = {
|
|
156
|
+
background: 'none',
|
|
157
|
+
border: 'none',
|
|
158
|
+
cursor: 'pointer',
|
|
159
|
+
font: 'inherit',
|
|
160
|
+
} as const satisfies CSSProperties;
|
|
161
|
+
|
|
162
|
+
const markerStyle = {
|
|
163
|
+
alignItems: 'center',
|
|
164
|
+
border: '1px dashed rgb(182 191 204)',
|
|
165
|
+
borderRadius: 3,
|
|
166
|
+
color: 'rgb(95 107 124)',
|
|
167
|
+
display: 'flex',
|
|
168
|
+
fontSize: 'clamp(0.36rem, 1.7cqw, 0.55rem)',
|
|
169
|
+
justifyContent: 'center',
|
|
170
|
+
} as const satisfies CSSProperties;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { CategoryLegendProps } from './CategoryLegend.tsx';
|
|
2
|
+
export { CategoryLegend } from './CategoryLegend.tsx';
|
|
3
|
+
export type { ElementCellProps } from './ElementCell.tsx';
|
|
4
|
+
export { ElementCell } from './ElementCell.tsx';
|
|
5
|
+
export type { PeriodicTableProps } from './PeriodicTable.tsx';
|
|
6
|
+
export { PeriodicTable } from './PeriodicTable.tsx';
|
package/src/ui.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from './error/ui/index.ts';
|
|
|
11
11
|
export * from './help/ui/index.ts';
|
|
12
12
|
export * from './hooks/ui/index.ts';
|
|
13
13
|
export * from './pedagogy/ui/index.ts';
|
|
14
|
+
export * from './periodic/ui/index.ts';
|
|
14
15
|
export * from './share/ui/index.ts';
|
|
15
16
|
export * from './shared/ui/index.ts';
|
|
16
17
|
export * from './state/ui/index.ts';
|