matterviz 0.1.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/dist/BohrAtom.svelte +105 -0
- package/dist/BohrAtom.svelte.d.ts +21 -0
- package/dist/ControlPanel.svelte +158 -0
- package/dist/ControlPanel.svelte.d.ts +18 -0
- package/dist/Icon.svelte +23 -0
- package/dist/Icon.svelte.d.ts +8 -0
- package/dist/InfoCard.svelte +79 -0
- package/dist/InfoCard.svelte.d.ts +23 -0
- package/dist/Nucleus.svelte +64 -0
- package/dist/Nucleus.svelte.d.ts +16 -0
- package/dist/Spinner.svelte +44 -0
- package/dist/Spinner.svelte.d.ts +7 -0
- package/dist/api.d.ts +6 -0
- package/dist/api.js +30 -0
- package/dist/colors/alloy-colors.json +111 -0
- package/dist/colors/dark-mode-colors.json +111 -0
- package/dist/colors/index.d.ts +26 -0
- package/dist/colors/index.js +72 -0
- package/dist/colors/jmol-colors.json +111 -0
- package/dist/colors/muted-colors.json +111 -0
- package/dist/colors/pastel-colors.json +111 -0
- package/dist/colors/vesta-colors.json +111 -0
- package/dist/composition/BarChart.svelte +260 -0
- package/dist/composition/BarChart.svelte.d.ts +33 -0
- package/dist/composition/BubbleChart.svelte +166 -0
- package/dist/composition/BubbleChart.svelte.d.ts +30 -0
- package/dist/composition/Composition.svelte +73 -0
- package/dist/composition/Composition.svelte.d.ts +27 -0
- package/dist/composition/PieChart.svelte +236 -0
- package/dist/composition/PieChart.svelte.d.ts +36 -0
- package/dist/composition/index.d.ts +5 -0
- package/dist/composition/index.js +5 -0
- package/dist/composition/parse.d.ts +14 -0
- package/dist/composition/parse.js +307 -0
- package/dist/element/ElementHeading.svelte +21 -0
- package/dist/element/ElementHeading.svelte.d.ts +8 -0
- package/dist/element/ElementPhoto.svelte +56 -0
- package/dist/element/ElementPhoto.svelte.d.ts +9 -0
- package/dist/element/ElementStats.svelte +73 -0
- package/dist/element/ElementStats.svelte.d.ts +8 -0
- package/dist/element/ElementTile.svelte +449 -0
- package/dist/element/ElementTile.svelte.d.ts +25 -0
- package/dist/element/data.d.ts +4958 -0
- package/dist/element/data.js +5628 -0
- package/dist/element/index.d.ts +4 -0
- package/dist/element/index.js +4 -0
- package/dist/icons.d.ts +435 -0
- package/dist/icons.js +435 -0
- package/dist/index.d.ts +82 -0
- package/dist/index.js +43 -0
- package/dist/io/decompress.d.ts +16 -0
- package/dist/io/decompress.js +78 -0
- package/dist/io/export.d.ts +9 -0
- package/dist/io/export.js +205 -0
- package/dist/io/parse.d.ts +53 -0
- package/dist/io/parse.js +747 -0
- package/dist/labels.d.ts +31 -0
- package/dist/labels.js +209 -0
- package/dist/material/MaterialCard.svelte +135 -0
- package/dist/material/MaterialCard.svelte.d.ts +10 -0
- package/dist/material/SymmetryCard.svelte +23 -0
- package/dist/material/SymmetryCard.svelte.d.ts +9 -0
- package/dist/material/index.d.ts +2 -0
- package/dist/material/index.js +2 -0
- package/dist/math.d.ts +24 -0
- package/dist/math.js +216 -0
- package/dist/periodic-table/PeriodicTable.svelte +284 -0
- package/dist/periodic-table/PeriodicTable.svelte.d.ts +50 -0
- package/dist/periodic-table/PropertySelect.svelte +20 -0
- package/dist/periodic-table/PropertySelect.svelte.d.ts +13 -0
- package/dist/periodic-table/TableInset.svelte +18 -0
- package/dist/periodic-table/TableInset.svelte.d.ts +9 -0
- package/dist/periodic-table/index.d.ts +9 -0
- package/dist/periodic-table/index.js +3 -0
- package/dist/plot/ColorBar.svelte +414 -0
- package/dist/plot/ColorBar.svelte.d.ts +22 -0
- package/dist/plot/ColorScaleSelect.svelte +31 -0
- package/dist/plot/ColorScaleSelect.svelte.d.ts +15 -0
- package/dist/plot/ElementScatter.svelte +38 -0
- package/dist/plot/ElementScatter.svelte.d.ts +14 -0
- package/dist/plot/Line.svelte +42 -0
- package/dist/plot/Line.svelte.d.ts +15 -0
- package/dist/plot/PlotLegend.svelte +206 -0
- package/dist/plot/PlotLegend.svelte.d.ts +18 -0
- package/dist/plot/ScatterPlot.svelte +1753 -0
- package/dist/plot/ScatterPlot.svelte.d.ts +114 -0
- package/dist/plot/ScatterPlotControls.svelte +505 -0
- package/dist/plot/ScatterPlotControls.svelte.d.ts +33 -0
- package/dist/plot/ScatterPoint.svelte +72 -0
- package/dist/plot/ScatterPoint.svelte.d.ts +17 -0
- package/dist/plot/index.d.ts +168 -0
- package/dist/plot/index.js +46 -0
- package/dist/state.svelte.d.ts +12 -0
- package/dist/state.svelte.js +11 -0
- package/dist/structure/Bond.svelte +68 -0
- package/dist/structure/Bond.svelte.d.ts +13 -0
- package/dist/structure/Lattice.svelte +115 -0
- package/dist/structure/Lattice.svelte.d.ts +15 -0
- package/dist/structure/Structure.svelte +298 -0
- package/dist/structure/Structure.svelte.d.ts +28 -0
- package/dist/structure/StructureCard.svelte +26 -0
- package/dist/structure/StructureCard.svelte.d.ts +9 -0
- package/dist/structure/StructureControls.svelte +383 -0
- package/dist/structure/StructureControls.svelte.d.ts +23 -0
- package/dist/structure/StructureLegend.svelte +130 -0
- package/dist/structure/StructureLegend.svelte.d.ts +17 -0
- package/dist/structure/StructureScene.svelte +331 -0
- package/dist/structure/StructureScene.svelte.d.ts +47 -0
- package/dist/structure/bonding.d.ts +16 -0
- package/dist/structure/bonding.js +150 -0
- package/dist/structure/index.d.ts +98 -0
- package/dist/structure/index.js +114 -0
- package/dist/structure/pbc.d.ts +6 -0
- package/dist/structure/pbc.js +72 -0
- package/dist/trajectory/Sidebar.svelte +412 -0
- package/dist/trajectory/Sidebar.svelte.d.ts +14 -0
- package/dist/trajectory/Trajectory.svelte +1084 -0
- package/dist/trajectory/Trajectory.svelte.d.ts +49 -0
- package/dist/trajectory/TrajectoryError.svelte +120 -0
- package/dist/trajectory/TrajectoryError.svelte.d.ts +12 -0
- package/dist/trajectory/extract.d.ts +5 -0
- package/dist/trajectory/extract.js +157 -0
- package/dist/trajectory/index.d.ts +16 -0
- package/dist/trajectory/index.js +49 -0
- package/dist/trajectory/parse.d.ts +13 -0
- package/dist/trajectory/parse.js +1093 -0
- package/dist/trajectory/plotting.d.ts +12 -0
- package/dist/trajectory/plotting.js +148 -0
- package/license +21 -0
- package/package.json +131 -0
- package/readme.md +95 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
<script lang="ts">import { goto } from '$app/navigation';
|
|
2
|
+
import { elem_symbols, ElementPhoto, ElementTile } from '..';
|
|
3
|
+
import { is_color } from '../colors';
|
|
4
|
+
import element_data from '../element/data';
|
|
5
|
+
import * as d3_sc from 'd3-scale-chromatic';
|
|
6
|
+
const default_f_block_inset_tiles = [
|
|
7
|
+
{ name: `Lanthanides`, symbol: `La-Lu`, number: `57-71`, category: `lanthanide` },
|
|
8
|
+
{ name: `Actinides`, symbol: `Ac-Lr`, number: `89-103`, category: `actinide` },
|
|
9
|
+
];
|
|
10
|
+
let { tile_props, show_photo = false, disabled = false, heatmap_values = [], links = null, log = false, color_scale = $bindable(`interpolateViridis`), active_element = $bindable(null), active_category = $bindable(null), gap = `0.3cqw`, inner_transition_metal_offset = 0.5, lanth_act_tiles = tile_props?.show_symbol == false
|
|
11
|
+
? []
|
|
12
|
+
: [...default_f_block_inset_tiles], lanth_act_style = ``, color_scale_range = [null, null], color_overrides = {}, labels = {}, missing_color = `element-category`, split_layout = undefined, inset, bottom_left_inset, tooltip = false, children, ...rest } = $props();
|
|
13
|
+
let heat_values = $derived.by(() => {
|
|
14
|
+
if (Array.isArray(heatmap_values)) {
|
|
15
|
+
if (heatmap_values.length > 118) {
|
|
16
|
+
console.error(`heatmap_values is an array of numbers/arrays, length should be 118 or less, one for ` +
|
|
17
|
+
`each element possibly omitting elements at the end, got ${heatmap_values.length}`);
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
else
|
|
21
|
+
return heatmap_values;
|
|
22
|
+
}
|
|
23
|
+
else if (typeof heatmap_values == `object`) {
|
|
24
|
+
const bad_keys = Object.keys(heatmap_values).filter((key) => !elem_symbols.includes(key));
|
|
25
|
+
if (bad_keys.length > 0) {
|
|
26
|
+
console.error(`heatmap_values is an object, keys should be element symbols, got ${bad_keys}`);
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
return elem_symbols.map((symbol) => heatmap_values[symbol] ?? 0);
|
|
30
|
+
}
|
|
31
|
+
return [];
|
|
32
|
+
});
|
|
33
|
+
let set_active_element = $derived((element) => () => {
|
|
34
|
+
if (disabled)
|
|
35
|
+
return;
|
|
36
|
+
active_element = element;
|
|
37
|
+
});
|
|
38
|
+
let window_width = $state(0);
|
|
39
|
+
let tooltip_element = $state(null);
|
|
40
|
+
let tooltip_pos = $state({ x: 0, y: 0 });
|
|
41
|
+
let tooltip_visible = $state(false);
|
|
42
|
+
function handle_key(event) {
|
|
43
|
+
if (disabled || !active_element)
|
|
44
|
+
return;
|
|
45
|
+
if (event.key == `Enter`)
|
|
46
|
+
return goto(active_element.name.toLowerCase());
|
|
47
|
+
if (![`ArrowUp`, `ArrowDown`, `ArrowLeft`, `ArrowRight`].includes(event.key)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
event.preventDefault(); // prevent scrolling the page
|
|
51
|
+
event.stopPropagation();
|
|
52
|
+
// change the active element in the periodic table with arrow keys
|
|
53
|
+
// TODO doesn't allow navigating to lanthanides and actinides yet
|
|
54
|
+
const { column, row } = active_element;
|
|
55
|
+
active_element = element_data.find((elem) => {
|
|
56
|
+
return {
|
|
57
|
+
ArrowUp: elem.column == column && elem.row == row - 1,
|
|
58
|
+
ArrowDown: elem.column == column && elem.row == row + 1,
|
|
59
|
+
ArrowLeft: elem.column == column - 1 && elem.row == row,
|
|
60
|
+
ArrowRight: elem.column == column + 1 && elem.row == row,
|
|
61
|
+
}[event.key];
|
|
62
|
+
}) ?? active_element;
|
|
63
|
+
}
|
|
64
|
+
function handle_tooltip_enter(element, event) {
|
|
65
|
+
if (tooltip === false || disabled)
|
|
66
|
+
return;
|
|
67
|
+
tooltip_element = element;
|
|
68
|
+
const target = event.currentTarget;
|
|
69
|
+
const rect = target.getBoundingClientRect();
|
|
70
|
+
const container_rect = target.closest(`.periodic-table`)?.getBoundingClientRect();
|
|
71
|
+
if (container_rect) {
|
|
72
|
+
tooltip_pos = {
|
|
73
|
+
x: rect.left - container_rect.left + rect.width / 2,
|
|
74
|
+
y: rect.bottom - container_rect.top + 8,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
tooltip_visible = true;
|
|
78
|
+
}
|
|
79
|
+
function handle_tooltip_leave() {
|
|
80
|
+
tooltip_visible = false;
|
|
81
|
+
tooltip_element = null;
|
|
82
|
+
}
|
|
83
|
+
let color_scale_fn = $derived(typeof color_scale == `string` ? d3_sc[color_scale] : color_scale);
|
|
84
|
+
let cs_min = $derived(color_scale_range[0] ??
|
|
85
|
+
(heat_values.length
|
|
86
|
+
? Math.min(...heat_values.flat().filter((v) => typeof v === `number`))
|
|
87
|
+
: 0));
|
|
88
|
+
let cs_max = $derived(color_scale_range[1] ??
|
|
89
|
+
(heat_values.length
|
|
90
|
+
? Math.max(...heat_values.flat().filter((v) => typeof v === `number`))
|
|
91
|
+
: 1));
|
|
92
|
+
let bg_color = $derived((value, element) => {
|
|
93
|
+
if (Array.isArray(value)) {
|
|
94
|
+
// For arrays, return the color of the first value (used as fallback)
|
|
95
|
+
return bg_color(value[0], element);
|
|
96
|
+
}
|
|
97
|
+
// If it's already a color string, return it directly
|
|
98
|
+
if (is_color(value))
|
|
99
|
+
return value;
|
|
100
|
+
// Return missing color for zero/invalid values or when no heatmap data
|
|
101
|
+
if (!value ||
|
|
102
|
+
value === 0 ||
|
|
103
|
+
(log && value <= 0) ||
|
|
104
|
+
!heat_values?.length ||
|
|
105
|
+
!color_scale_fn) {
|
|
106
|
+
// Use missing color for zero/missing values or when no heatmap data
|
|
107
|
+
if (missing_color === `element-category` && element) {
|
|
108
|
+
return `var(--${element.category.replaceAll(` `, `-`)}-bg-color)`;
|
|
109
|
+
}
|
|
110
|
+
return missing_color;
|
|
111
|
+
}
|
|
112
|
+
// map value to [0, 1] range
|
|
113
|
+
const span = cs_max - cs_min;
|
|
114
|
+
if (span === 0)
|
|
115
|
+
return color_scale_fn?.(0.5); // midpoint when all values equal
|
|
116
|
+
if (log)
|
|
117
|
+
value = Math.log(value - cs_min + 1) / Math.log(span + 1);
|
|
118
|
+
else
|
|
119
|
+
value = (value - cs_min) / span;
|
|
120
|
+
return color_scale_fn?.(value);
|
|
121
|
+
});
|
|
122
|
+
let bg_colors = $derived((value, element) => {
|
|
123
|
+
if (!Array.isArray(value))
|
|
124
|
+
return [];
|
|
125
|
+
return value.map((v) => {
|
|
126
|
+
// If it's already a color string, return it directly
|
|
127
|
+
if (is_color(v))
|
|
128
|
+
return v;
|
|
129
|
+
// Otherwise, map it through the color scale
|
|
130
|
+
return bg_color(v, element);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
</script>
|
|
134
|
+
|
|
135
|
+
<svelte:window bind:innerWidth={window_width} onkeydown={handle_key} />
|
|
136
|
+
|
|
137
|
+
<div class="periodic-table-container" {...rest}>
|
|
138
|
+
<div class="periodic-table" style:gap>
|
|
139
|
+
{@render inset?.({ active_element })}
|
|
140
|
+
{#each element_data as element (element.number)}
|
|
141
|
+
{@const { column, row, category, name, symbol } = element}
|
|
142
|
+
{@const value = heat_values[element.number - 1]}
|
|
143
|
+
{@const active = active_category === category.replaceAll(` `, `-`) ||
|
|
144
|
+
active_element?.name === name}
|
|
145
|
+
{@const style = `grid-column: ${column}; grid-row: ${row};`}
|
|
146
|
+
<ElementTile
|
|
147
|
+
{element}
|
|
148
|
+
href={links
|
|
149
|
+
? typeof links == `string`
|
|
150
|
+
? `${element[links]}`.toLowerCase()
|
|
151
|
+
: links[symbol]
|
|
152
|
+
: null}
|
|
153
|
+
{style}
|
|
154
|
+
{value}
|
|
155
|
+
bg_color={color_overrides[symbol] ?? bg_color(value, element)}
|
|
156
|
+
bg_colors={Array.isArray(value) ? bg_colors(value, element) : []}
|
|
157
|
+
{active}
|
|
158
|
+
label={labels[symbol]}
|
|
159
|
+
{...tile_props}
|
|
160
|
+
onmouseenter={(event: MouseEvent) => {
|
|
161
|
+
set_active_element(element)()
|
|
162
|
+
handle_tooltip_enter(element, event)
|
|
163
|
+
}}
|
|
164
|
+
onmouseleave={() => {
|
|
165
|
+
set_active_element(null)()
|
|
166
|
+
handle_tooltip_leave()
|
|
167
|
+
}}
|
|
168
|
+
onfocus={set_active_element(element)}
|
|
169
|
+
onblur={set_active_element(null)}
|
|
170
|
+
{split_layout}
|
|
171
|
+
/>
|
|
172
|
+
{/each}
|
|
173
|
+
<!-- show tile for lanthanides and actinides with text La-Lu and Ac-Lr respectively -->
|
|
174
|
+
{#each lanth_act_tiles || [] as lanth_act_element, idx (lanth_act_element.symbol)}
|
|
175
|
+
{@const style = `opacity: 0.8; grid-column: 3; grid-row: ${
|
|
176
|
+
6 + idx
|
|
177
|
+
}; ${lanth_act_style};`}
|
|
178
|
+
<ElementTile
|
|
179
|
+
element={lanth_act_element as unknown as ChemicalElement}
|
|
180
|
+
{style}
|
|
181
|
+
onmouseenter={() => (active_category = lanth_act_element.category)}
|
|
182
|
+
onmouseleave={() => (active_category = null)}
|
|
183
|
+
symbol_style="font-size: 30cqw;"
|
|
184
|
+
/>
|
|
185
|
+
{/each}
|
|
186
|
+
{#if inner_transition_metal_offset}
|
|
187
|
+
<!-- provide vertical offset for lanthanides + actinides -->
|
|
188
|
+
<div class="spacer" style:aspect-ratio={1 / inner_transition_metal_offset}></div>
|
|
189
|
+
{/if}
|
|
190
|
+
|
|
191
|
+
{#if bottom_left_inset}
|
|
192
|
+
{@render bottom_left_inset({ active_element })}
|
|
193
|
+
{:else if show_photo && active_element}
|
|
194
|
+
<ElementPhoto element={active_element} style="grid-area: 9/1/span 2/span 2" />
|
|
195
|
+
{/if}
|
|
196
|
+
|
|
197
|
+
<!-- Tooltip -->
|
|
198
|
+
{#if tooltip_visible && tooltip_element && tooltip !== false}
|
|
199
|
+
{@const style = `left: ${tooltip_pos.x}px; top: ${tooltip_pos.y}px;`}
|
|
200
|
+
<div class="tooltip" {style}>
|
|
201
|
+
{#if typeof tooltip == `function`}
|
|
202
|
+
{@const tooltip_value = heat_values[tooltip_element.number - 1]}
|
|
203
|
+
{@render tooltip({
|
|
204
|
+
element: tooltip_element,
|
|
205
|
+
value: tooltip_value,
|
|
206
|
+
active:
|
|
207
|
+
active_category === tooltip_element.category.replaceAll(` `, `-`) ||
|
|
208
|
+
active_element?.name === tooltip_element.name,
|
|
209
|
+
bg_color: color_overrides[tooltip_element.symbol] ??
|
|
210
|
+
bg_color(tooltip_value, tooltip_element),
|
|
211
|
+
scale_context: { min: cs_min, max: cs_max, color_scale },
|
|
212
|
+
})}
|
|
213
|
+
{:else}
|
|
214
|
+
{tooltip_element.name}<br />
|
|
215
|
+
<small>{tooltip_element.symbol} • {tooltip_element.number}</small>
|
|
216
|
+
{#if Array.isArray(heat_values[tooltip_element.number - 1])}
|
|
217
|
+
<br />
|
|
218
|
+
<small>Values: {
|
|
219
|
+
(heat_values[tooltip_element.number - 1] as number[]).join(
|
|
220
|
+
`, `,
|
|
221
|
+
)
|
|
222
|
+
}</small>
|
|
223
|
+
{/if}
|
|
224
|
+
{/if}
|
|
225
|
+
</div>
|
|
226
|
+
{/if}
|
|
227
|
+
|
|
228
|
+
{@render children?.()}
|
|
229
|
+
</div>
|
|
230
|
+
</div>
|
|
231
|
+
|
|
232
|
+
<style>
|
|
233
|
+
.periodic-table-container {
|
|
234
|
+
/* needed for gap: 0.3cqw; to work */
|
|
235
|
+
container-type: inline-size;
|
|
236
|
+
|
|
237
|
+
/* Default category colors - can be overridden by user */
|
|
238
|
+
--diatomic-nonmetal-bg-color: #ff8c00;
|
|
239
|
+
--noble-gas-bg-color: darkorchid;
|
|
240
|
+
--alkali-metal-bg-color: darkgreen;
|
|
241
|
+
--alkaline-earth-metal-bg-color: darkslateblue;
|
|
242
|
+
--metalloid-bg-color: darkgoldenrod;
|
|
243
|
+
--polyatomic-nonmetal-bg-color: brown;
|
|
244
|
+
--transition-metal-bg-color: #571e6c;
|
|
245
|
+
--post-transition-metal-bg-color: #938d4a;
|
|
246
|
+
--lanthanide-bg-color: #58748e;
|
|
247
|
+
--actinide-bg-color: cornflowerblue;
|
|
248
|
+
--experimental-bg-color: gray;
|
|
249
|
+
}
|
|
250
|
+
div.periodic-table {
|
|
251
|
+
display: grid;
|
|
252
|
+
grid-template-columns: repeat(18, 1fr);
|
|
253
|
+
position: relative;
|
|
254
|
+
container-type: inline-size;
|
|
255
|
+
gap: var(--ptable-gap, 0.3cqw);
|
|
256
|
+
}
|
|
257
|
+
div.spacer {
|
|
258
|
+
grid-row: 8;
|
|
259
|
+
aspect-ratio: var(--ptable-spacer-ratio, 2);
|
|
260
|
+
}
|
|
261
|
+
.tooltip {
|
|
262
|
+
position: absolute;
|
|
263
|
+
transform: translate(-50%, -10%);
|
|
264
|
+
background: var(--tooltip-bg, rgba(0, 0, 0, 0.8));
|
|
265
|
+
color: var(--tooltip-color, white);
|
|
266
|
+
padding: var(--tooltip-padding, 4px 6px);
|
|
267
|
+
border-radius: var(--tooltip-border-radius, 6px);
|
|
268
|
+
font-size: var(--tooltip-font-size, 14px);
|
|
269
|
+
text-align: var(--tooltip-text-align, center);
|
|
270
|
+
line-height: var(--tooltip-line-height, 1.2);
|
|
271
|
+
}
|
|
272
|
+
.tooltip::before {
|
|
273
|
+
content: '';
|
|
274
|
+
position: absolute;
|
|
275
|
+
top: -15%;
|
|
276
|
+
left: 50%;
|
|
277
|
+
transform: translateX(-50%);
|
|
278
|
+
border-left: 8px solid transparent;
|
|
279
|
+
border-right: 8px solid transparent;
|
|
280
|
+
border-bottom: 8px solid var(--tooltip-bg, rgba(0, 0, 0, 0.8));
|
|
281
|
+
box-sizing: border-box;
|
|
282
|
+
margin: 0 auto;
|
|
283
|
+
}
|
|
284
|
+
</style>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Category, ChemicalElement } from '..';
|
|
2
|
+
import { type ElementSymbol, ElementTile } from '..';
|
|
3
|
+
import type { ComponentProps, Snippet } from 'svelte';
|
|
4
|
+
import type { D3InterpolateName } from '../colors';
|
|
5
|
+
import type { ScaleContext } from './index';
|
|
6
|
+
interface Props {
|
|
7
|
+
tile_props?: Partial<ComponentProps<typeof ElementTile>>;
|
|
8
|
+
show_photo?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
heatmap_values?: Partial<Record<ElementSymbol, number | number[] | string | string[]>> | (number | number[] | string | string[])[];
|
|
11
|
+
links?: keyof ChemicalElement | Record<ElementSymbol, string> | null;
|
|
12
|
+
log?: boolean;
|
|
13
|
+
color_scale?: D3InterpolateName | ((num: number) => string);
|
|
14
|
+
active_element?: ChemicalElement | null;
|
|
15
|
+
active_category?: Category | null;
|
|
16
|
+
gap?: string;
|
|
17
|
+
inner_transition_metal_offset?: number;
|
|
18
|
+
lanth_act_tiles?: {
|
|
19
|
+
name: string;
|
|
20
|
+
symbol: string;
|
|
21
|
+
number: string;
|
|
22
|
+
category: Category;
|
|
23
|
+
}[];
|
|
24
|
+
lanth_act_style?: string;
|
|
25
|
+
color_scale_range?: [number | null, number | null];
|
|
26
|
+
color_overrides?: Partial<Record<ElementSymbol, string>>;
|
|
27
|
+
labels?: Partial<Record<ElementSymbol, string>>;
|
|
28
|
+
missing_color?: string;
|
|
29
|
+
split_layout?: `diagonal` | `horizontal` | `vertical` | `triangular` | `quadrant`;
|
|
30
|
+
inset?: Snippet<[{
|
|
31
|
+
active_element: ChemicalElement | null;
|
|
32
|
+
}]>;
|
|
33
|
+
bottom_left_inset?: Snippet<[{
|
|
34
|
+
active_element: ChemicalElement | null;
|
|
35
|
+
}]>;
|
|
36
|
+
tooltip?: Snippet<[
|
|
37
|
+
{
|
|
38
|
+
element: ChemicalElement;
|
|
39
|
+
value: number | number[] | string | string[];
|
|
40
|
+
active: boolean;
|
|
41
|
+
bg_color: string | null;
|
|
42
|
+
scale_context: ScaleContext;
|
|
43
|
+
}
|
|
44
|
+
]> | boolean;
|
|
45
|
+
children?: Snippet;
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
}
|
|
48
|
+
declare const PeriodicTable: import("svelte").Component<Props, {}, "color_scale" | "active_element" | "active_category">;
|
|
49
|
+
type PeriodicTable = ReturnType<typeof PeriodicTable>;
|
|
50
|
+
export default PeriodicTable;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script lang="ts">import { heatmap_labels } from '../labels';
|
|
2
|
+
import Select from 'svelte-multiselect';
|
|
3
|
+
const options = Object.keys(heatmap_labels);
|
|
4
|
+
let { value = $bindable(null), empty = false, selected = empty ? [] : [options[1]], minSelect = 0, id = null, key = $bindable(``), ...rest } = $props();
|
|
5
|
+
$effect.pre(() => {
|
|
6
|
+
key = heatmap_labels[value ?? ``] ?? null;
|
|
7
|
+
});
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<Select
|
|
11
|
+
{id}
|
|
12
|
+
{options}
|
|
13
|
+
{selected}
|
|
14
|
+
maxSelect={1}
|
|
15
|
+
{minSelect}
|
|
16
|
+
bind:value
|
|
17
|
+
placeholder="Select a heat map"
|
|
18
|
+
inputStyle="padding: 3pt 6pt;"
|
|
19
|
+
{...rest}
|
|
20
|
+
/>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ChemicalElement } from '..';
|
|
2
|
+
interface Props {
|
|
3
|
+
value?: keyof ChemicalElement | null;
|
|
4
|
+
empty?: boolean;
|
|
5
|
+
selected?: string[];
|
|
6
|
+
minSelect?: number;
|
|
7
|
+
id?: string | null;
|
|
8
|
+
key?: string | null;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
declare const PropertySelect: import("svelte").Component<Props, {}, "key" | "value">;
|
|
12
|
+
type PropertySelect = ReturnType<typeof PropertySelect>;
|
|
13
|
+
export default PropertySelect;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script lang="ts">let { style = null, tag = `aside`, children } = $props();
|
|
2
|
+
export {};
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<svelte:element this={tag} {style}>
|
|
6
|
+
{@render children?.()}
|
|
7
|
+
</svelte:element>
|
|
8
|
+
|
|
9
|
+
<style>
|
|
10
|
+
aside,
|
|
11
|
+
div {
|
|
12
|
+
display: grid;
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
grid-row: var(--ptable-inset-row, 1 / span 3);
|
|
15
|
+
grid-column: var(--ptable-inset-col, 3 / span 10);
|
|
16
|
+
container-type: inline-size;
|
|
17
|
+
}
|
|
18
|
+
</style>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
interface Props {
|
|
3
|
+
style?: string | null;
|
|
4
|
+
tag?: string;
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
}
|
|
7
|
+
declare const TableInset: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type TableInset = ReturnType<typeof TableInset>;
|
|
9
|
+
export default TableInset;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { D3InterpolateName } from '../colors';
|
|
2
|
+
export { default, default as PeriodicTable } from './PeriodicTable.svelte';
|
|
3
|
+
export { default as PropertySelect } from './PropertySelect.svelte';
|
|
4
|
+
export { default as TableInset } from './TableInset.svelte';
|
|
5
|
+
export type ScaleContext = {
|
|
6
|
+
min: number;
|
|
7
|
+
max: number;
|
|
8
|
+
color_scale: D3InterpolateName | ((num: number) => string);
|
|
9
|
+
};
|