@weasel-js/labkit 1.4.4 → 1.5.1
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 +54 -6
- package/dist/_dts/{CanvasStackContext-kTEZvEgE.d.ts → CanvasStackContext-CJNMS6mz.d.ts} +1 -1
- package/dist/_dts/{PrefsForm.d-DDHFANkc.d.ts → PrefsForm.d-DPy9I8It.d.ts} +4 -0
- package/dist/_dts/Select.d-Gwr8fLpK.d.ts +453 -0
- package/dist/_dts/{frac-z7ker2Vx.d.ts → frac-B4okC2lX.d.ts} +291 -31
- package/dist/_dts/{index-Blv9uQzu.d.ts → index-BNdz-tNd.d.ts} +105 -17
- package/dist/_dts/index-CSJoj4LC.d.ts +248 -0
- package/dist/_dts/{types-B9_zrHmb.d.ts → types-DzoNY1pO.d.ts} +91 -4
- package/dist/_dts/usePanZoom-Pzf9f2jh.d.ts +160 -0
- package/dist/_dts/useTrialState-uLlmaccn.d.ts +212 -0
- package/dist/canvas/index.d.ts +18 -129
- package/dist/canvas/index.js +4 -2
- package/dist/chrome/index.d.ts +5 -93
- package/dist/chrome/index.js +10 -6
- package/dist/chunk-7PFH3CNM.js +150 -0
- package/dist/chunk-7PFH3CNM.js.map +1 -0
- package/dist/{chunk-I6JCVE24.js → chunk-CEIUBPPW.js} +143 -17
- package/dist/chunk-CEIUBPPW.js.map +1 -0
- package/dist/chunk-EH7UEQV7.js +590 -0
- package/dist/chunk-EH7UEQV7.js.map +1 -0
- package/dist/{chunk-MOM3GOVY.js → chunk-EHGVROVV.js} +125 -27
- package/dist/chunk-EHGVROVV.js.map +1 -0
- package/dist/{chunk-TJ7QY3OC.js → chunk-ERFMC6WU.js} +160 -78
- package/dist/chunk-ERFMC6WU.js.map +1 -0
- package/dist/{chunk-CTRKTLYZ.js → chunk-H6ZAOWNE.js} +11 -11
- package/dist/chunk-H6ZAOWNE.js.map +1 -0
- package/dist/{chunk-64ZCN3DA.js → chunk-IHUVQ3TX.js} +250 -160
- package/dist/chunk-IHUVQ3TX.js.map +1 -0
- package/dist/{chunk-FQMJUVHJ.js → chunk-IJJUK4FU.js} +53 -46
- package/dist/chunk-IJJUK4FU.js.map +1 -0
- package/dist/chunk-IXTQI7JX.js +737 -0
- package/dist/chunk-IXTQI7JX.js.map +1 -0
- package/dist/{chunk-BKFVHKJH.js → chunk-MDVTK5U3.js} +4 -4
- package/dist/{chunk-BKFVHKJH.js.map → chunk-MDVTK5U3.js.map} +1 -1
- package/dist/chunk-PHK4W562.js +72 -0
- package/dist/chunk-PHK4W562.js.map +1 -0
- package/dist/chunk-PJ7WEQBJ.js +18 -0
- package/dist/chunk-PJ7WEQBJ.js.map +1 -0
- package/dist/chunk-RWNDDKOH.js +682 -0
- package/dist/chunk-RWNDDKOH.js.map +1 -0
- package/dist/chunk-T3EC2DXD.js +12628 -0
- package/dist/chunk-T3EC2DXD.js.map +1 -0
- package/dist/{chunk-SMHP6XZ4.js → chunk-UN4U4P63.js} +10 -8
- package/dist/chunk-UN4U4P63.js.map +1 -0
- package/dist/chunk-WIG6XHJ7.js +35 -0
- package/dist/chunk-WIG6XHJ7.js.map +1 -0
- package/dist/chunk-Z76KEZAX.js +15 -0
- package/dist/chunk-Z76KEZAX.js.map +1 -0
- package/dist/chunk-ZDHY47EV.js +363 -0
- package/dist/chunk-ZDHY47EV.js.map +1 -0
- package/dist/config/index.d.ts +276 -0
- package/dist/config/index.js +8 -0
- package/dist/config/index.js.map +1 -0
- package/dist/controls/index.d.ts +3 -4
- package/dist/controls/index.js +4 -3
- package/dist/dragdrop/index.d.ts +3 -5
- package/dist/index.d.ts +266 -413
- package/dist/index.js +1775 -2251
- package/dist/index.js.map +1 -1
- package/dist/layers/index.d.ts +4 -6
- package/dist/layers/index.js +2 -2
- package/dist/loupe/index.d.ts +69 -20
- package/dist/loupe/index.js +2 -2
- package/dist/passthrough/weasel-ui.d.ts +175 -309
- package/dist/passthrough/weasel-ui.js +1 -1
- package/dist/primitives/index.d.ts +55 -6
- package/dist/primitives/index.js +6 -4
- package/dist/state/index.d.ts +13 -8
- package/dist/state/index.js +18 -13
- package/dist/state/index.js.map +1 -1
- package/dist/styles.css +223 -76
- package/dist/surface/index.d.ts +44 -7
- package/dist/surface/index.js +2 -1
- package/dist/ui/layers/index.js +1 -1
- package/dist/undo/index.d.ts +3 -5
- package/package.json +15 -8
- package/src/annotations/AnnotationOverlay.tsx +56 -5
- package/src/annotations/Annotations.less +4 -0
- package/src/annotations/Annotations.overlay.test.tsx +105 -6
- package/src/annotations/drawOne.test.ts +1 -1
- package/src/annotations/drawOne.ts +2 -2
- package/src/annotations/paint.test.ts +2 -2
- package/src/annotations/paint.ts +1 -1
- package/src/annotations/preload.ts +6 -0
- package/src/annotations/store.test.ts +18 -0
- package/src/annotations/store.ts +5 -4
- package/src/annotations/svgNodes.test.ts +2 -2
- package/src/annotations/svgNodes.ts +1 -0
- package/src/annotations/toolMap.test.ts +9 -5
- package/src/annotations/toolMap.ts +6 -3
- package/src/annotations/types.ts +6 -3
- package/src/canvas/CameraWheelContext.ts +12 -0
- package/src/canvas/CanvasStack.stories.tsx +1 -1
- package/src/canvas/CanvasStack.test.tsx +25 -0
- package/src/canvas/CanvasStack.tsx +31 -4
- package/src/canvas/Stage.less +18 -0
- package/src/canvas/Stage.test.tsx +186 -0
- package/src/canvas/Stage.tsx +134 -0
- package/src/canvas/camera.test.ts +17 -2
- package/src/canvas/camera.ts +9 -9
- package/src/canvas/index.ts +4 -0
- package/src/canvas/usePanZoom.test.ts +28 -0
- package/src/canvas/usePanZoom.ts +21 -9
- package/src/chrome/ChromeRegions.stories.tsx +1 -4
- package/src/chrome/LabChrome.tsx +130 -0
- package/src/chrome/builtins.test.ts +1 -0
- package/src/chrome/builtins.tsx +21 -31
- package/src/chrome/index.ts +16 -0
- package/src/chrome/labRegions.test.tsx +208 -0
- package/src/chrome/labTypes.ts +50 -0
- package/src/chrome/merge.ts +7 -9
- package/src/chrome/regions/PaletteRegion.test.tsx +6 -4
- package/src/chrome/regions/PaletteRegion.tsx +16 -9
- package/src/chrome/regions/SidebarRegion.stories.tsx +44 -0
- package/src/chrome/regions/SidebarRegion.tsx +25 -13
- package/src/chrome/regions/StatusRegion.tsx +15 -8
- package/src/chrome/regions/ToolbarRegion.tsx +34 -16
- package/src/chrome/types.ts +50 -20
- package/src/config/auto.test.ts +12 -0
- package/src/config/auto.ts +15 -0
- package/src/config/autoConfig.test.ts +107 -0
- package/src/config/autoConfig.ts +153 -0
- package/src/config/builder.test.ts +42 -0
- package/src/config/builder.ts +68 -17
- package/src/config/declarationEmit.fixture.ts +11 -0
- package/src/config/declarationEmit.test.ts +51 -0
- package/src/config/entry.test.ts +46 -0
- package/src/config/index.ts +16 -1
- package/src/config/nodeClasses.test.ts +18 -0
- package/src/config/path.ts +7 -2
- package/src/config/resolve.test.ts +25 -0
- package/src/config/resolve.ts +17 -1
- package/src/config/types.ts +34 -2
- package/src/config/useResolvedConfig.ts +26 -0
- package/src/controls/AutoControls.stories.tsx +88 -0
- package/src/controls/ControlPanel.stories.tsx +42 -1
- package/src/controls/ControlPanel.test.tsx +530 -4
- package/src/controls/ControlPanel.tsx +562 -82
- package/src/fake-indexeddb-auto.d.ts +5 -0
- package/src/index.test.ts +7 -0
- package/src/index.ts +66 -5
- package/src/instrument/serializers.test.ts +22 -0
- package/src/instrument/serializers.ts +40 -1
- package/src/instrument/types.ts +25 -1
- package/src/lab/Lab.chrome.test.tsx +16 -0
- package/src/lab/Lab.less +4 -13
- package/src/lab/Lab.persist.test.tsx +147 -0
- package/src/lab/Lab.stories.tsx +1 -3
- package/src/lab/Lab.surface.test.tsx +71 -3
- package/src/lab/Lab.test.tsx +168 -16
- package/src/lab/Lab.tsx +434 -129
- package/src/lab/LabContext.ts +8 -0
- package/src/lab/LabFit.stories.less +18 -0
- package/src/lab/LabFit.stories.tsx +219 -0
- package/src/lab/LabFullChrome.stories.tsx +1 -4
- package/src/lab/LabHeader.test.tsx +40 -9
- package/src/lab/LabHeader.tsx +7 -14
- package/src/lab/LabPalette.tsx +13 -26
- package/src/lab/LabRoot.test.tsx +56 -0
- package/src/lab/LabRoot.tsx +47 -0
- package/src/lab/LabShell.less +73 -15
- package/src/lab/LabShell.stories.tsx +50 -1
- package/src/lab/LabShell.tsx +18 -27
- package/src/lab/LabSwitcher.less +18 -11
- package/src/lab/LabSwitcher.test.tsx +14 -9
- package/src/lab/LabSwitcher.tsx +8 -4
- package/src/lab/Workspace.less +1 -1
- package/src/lab/Workspace.stories.tsx +1 -1
- package/src/lab/Workspace.surface.test.tsx +1 -0
- package/src/lab/fitCheck.test.ts +57 -0
- package/src/lab/fitCheck.ts +125 -0
- package/src/lab/index.ts +2 -0
- package/src/layers/LayerList.stories.tsx +1 -1
- package/src/loupe/AGENTS.md +17 -5
- package/src/loupe/Loupe.less +1 -1
- package/src/loupe/LoupeGestures.tsx +67 -0
- package/src/loupe/TrialLoupe.tsx +43 -28
- package/src/loupe/canvasLens.ts +1 -1
- package/src/loupe/index.ts +4 -0
- package/src/loupe/loupeActions.ts +98 -0
- package/src/loupe/types.ts +1 -1
- package/src/loupe/useLoupe.test.tsx +60 -3
- package/src/loupe/useLoupe.ts +29 -49
- package/src/passthrough/weasel-ui.ts +9 -0
- package/src/primitives/FloatingPanel.stories.tsx +14 -2
- package/src/primitives/FloatingPanel.test.tsx +47 -16
- package/src/primitives/FloatingPanel.tsx +11 -25
- package/src/primitives/FpsMeter.stories.tsx +1 -1
- package/src/primitives/JobProgress.stories.tsx +1 -1
- package/src/primitives/Legend.stories.tsx +1 -1
- package/src/primitives/ScaleIndicator.stories.tsx +1 -1
- package/src/primitives/Sidebar.less +7 -0
- package/src/primitives/Sidebar.stories.tsx +1 -1
- package/src/primitives/Split.less +14 -0
- package/src/primitives/Split.test.tsx +133 -0
- package/src/primitives/Split.tsx +175 -0
- package/src/primitives/StatusBar.stories.tsx +1 -1
- package/src/primitives/Toolbar.stories.tsx +1 -1
- package/src/primitives/ZoomControl.tsx +5 -2
- package/src/primitives/index.ts +2 -0
- package/src/specimen/Specimen.less +95 -0
- package/src/specimen/Specimen.stories.tsx +13 -0
- package/src/specimen/Specimen.test.tsx +13 -0
- package/src/specimen/Specimen.tsx +888 -0
- package/src/state/Persistence.stories.tsx +75 -0
- package/src/state/Persistence.tsx +33 -0
- package/src/state/SingletonExperiment.test.tsx +47 -53
- package/src/state/SingletonExperiment.tsx +24 -13
- package/src/state/adapterContract.ts +116 -0
- package/src/state/adapters.test.ts +113 -61
- package/src/state/adapters.ts +328 -69
- package/src/state/document.test.ts +71 -96
- package/src/state/document.ts +66 -52
- package/src/state/helpers.test.ts +1 -1
- package/src/state/index.ts +8 -0
- package/src/state/labRecords.test.ts +105 -0
- package/src/state/labRecords.ts +160 -0
- package/src/state/openLabStore.test.ts +658 -0
- package/src/state/openLabStore.ts +403 -0
- package/src/state/records.test.ts +234 -0
- package/src/state/records.ts +219 -0
- package/src/state/store.test.ts +169 -635
- package/src/state/store.ts +146 -163
- package/src/state/toolSlot.test.ts +1 -1
- package/src/state/types.ts +65 -17
- package/src/state/useOpenOnce.ts +68 -0
- package/src/state/usePersistedState.test.tsx +125 -0
- package/src/state/usePersistedState.ts +66 -0
- package/src/state/useTrialState.test.tsx +87 -3
- package/src/state/useTrialState.ts +9 -1
- package/src/state/view.test.ts +49 -15
- package/src/state/view.ts +18 -1
- package/src/styles.less +3 -0
- package/src/surface/AGENTS.md +39 -7
- package/src/surface/SurfaceContext.ts +26 -3
- package/src/surface/index.ts +2 -0
- package/src/surface/useSurfaceTile.test.tsx +1 -0
- package/src/surface/useSurfaceTile.ts +6 -5
- package/src/surface/useTiledSurface.test.tsx +231 -1
- package/src/surface/useTiledSurface.ts +76 -15
- package/src/theme/Interstellar.stories.tsx +9 -9
- package/src/theme/interstellar.test.ts +17 -6
- package/src/theme/interstellar.theme.json +180 -0
- package/src/theme/interstellar.ts +8 -5
- package/src/tools/labTool.ts +11 -0
- package/src/trial/Trial.annotations.persist.test.tsx +100 -58
- package/src/trial/Trial.annotations.test.tsx +59 -7
- package/src/trial/Trial.canvas.test.tsx +32 -0
- package/src/trial/Trial.config.test.tsx +75 -2
- package/src/trial/Trial.job.test.tsx +3 -3
- package/src/trial/Trial.less +5 -26
- package/src/trial/Trial.stories.tsx +5 -3
- package/src/trial/Trial.test.tsx +31 -4
- package/src/trial/Trial.trialId.test.tsx +23 -1
- package/src/trial/Trial.tsx +139 -52
- package/src/trial/TrialBody.tsx +17 -141
- package/src/trial/TrialChrome.tsx +24 -7
- package/src/trial/trialOps.test.ts +101 -1
- package/src/trial/trialOps.ts +67 -7
- package/dist/_dts/types-BP2OCcpg.d.ts +0 -155
- package/dist/_dts/types-x92Kfeme.d.ts +0 -62
- package/dist/_dts/useTrialState-D6Vb3T-g.d.ts +0 -99
- package/dist/chunk-2P6PP5N4.js +0 -553
- package/dist/chunk-2P6PP5N4.js.map +0 -1
- package/dist/chunk-64ZCN3DA.js.map +0 -1
- package/dist/chunk-CTRKTLYZ.js.map +0 -1
- package/dist/chunk-E44SU6XS.js +0 -50
- package/dist/chunk-E44SU6XS.js.map +0 -1
- package/dist/chunk-FQMJUVHJ.js.map +0 -1
- package/dist/chunk-I6JCVE24.js.map +0 -1
- package/dist/chunk-MOM3GOVY.js.map +0 -1
- package/dist/chunk-SMHP6XZ4.js.map +0 -1
- package/dist/chunk-TJ7QY3OC.js.map +0 -1
- package/dist/chunk-U3IYHIAE.js +0 -343
- package/dist/chunk-U3IYHIAE.js.map +0 -1
- package/dist/chunk-W3ECWC2K.js +0 -7335
- package/dist/chunk-W3ECWC2K.js.map +0 -1
- package/src/theme/interstellar.tokens.json +0 -61
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
import { fromConfigFields, isLeafVisible } from './chunk-PHK4W562.js';
|
|
2
|
+
import { resolveAutoConfig, schemaNodeAtPath, valueAtPath, auto } from './chunk-7PFH3CNM.js';
|
|
3
|
+
import { k, J, n3, j2, L3, U, H, z2, R2, F2, V, g, a4, e2, B } from './chunk-T3EC2DXD.js';
|
|
4
|
+
import { isBuiltinToolPref } from '@weasel-js/core';
|
|
5
|
+
import { useMemo, useState, useRef, useEffect, Fragment as Fragment$1 } from 'react';
|
|
6
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
var gridOf = (pack) => pack === "one-up" ? "auto-color" : "pairs";
|
|
9
|
+
function sectionRows(section, rows) {
|
|
10
|
+
return {
|
|
11
|
+
pack: section.pack ?? rows.pack,
|
|
12
|
+
layout: section.layout ?? rows.layout,
|
|
13
|
+
grid: section.pack ? gridOf(section.pack) : rows.grid
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
var NO_AUTO = /* @__PURE__ */ new Set();
|
|
17
|
+
function ControlPanel({
|
|
18
|
+
schema,
|
|
19
|
+
fields,
|
|
20
|
+
config,
|
|
21
|
+
setConfig,
|
|
22
|
+
renderers,
|
|
23
|
+
pack = "pairs",
|
|
24
|
+
layout,
|
|
25
|
+
density,
|
|
26
|
+
align,
|
|
27
|
+
collapse,
|
|
28
|
+
collapsed,
|
|
29
|
+
onCollapse,
|
|
30
|
+
auto: given,
|
|
31
|
+
showHidden = false,
|
|
32
|
+
className
|
|
33
|
+
}) {
|
|
34
|
+
const resolved = useMemo(() => schema ?? fromConfigFields(fields ?? []), [schema, fields]);
|
|
35
|
+
const [ownAuto, setOwnAuto] = useState(NO_AUTO);
|
|
36
|
+
const auto2 = given ?? ownAuto;
|
|
37
|
+
const setRowAuto = (path, next, value) => {
|
|
38
|
+
if (given) {
|
|
39
|
+
setConfig(path, next ? auto : value);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
setOwnAuto((prev) => {
|
|
43
|
+
const now = new Set(prev);
|
|
44
|
+
if (next) now.add(path);
|
|
45
|
+
else now.delete(path);
|
|
46
|
+
return now;
|
|
47
|
+
});
|
|
48
|
+
if (!next) setConfig(path, value);
|
|
49
|
+
};
|
|
50
|
+
const shown = useMemo(
|
|
51
|
+
() => auto2 && auto2.size > 0 ? resolveAutoConfig(resolved, config, auto2) : config,
|
|
52
|
+
[resolved, config, auto2]
|
|
53
|
+
);
|
|
54
|
+
const listRef = useRef(null);
|
|
55
|
+
const toggles = useRef(/* @__PURE__ */ new Map());
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
const host = listRef.current;
|
|
58
|
+
if (!host) return;
|
|
59
|
+
const onDown = (e2) => {
|
|
60
|
+
if (!e2.shiftKey) return;
|
|
61
|
+
const row = e2.target?.closest("[data-auto-path]");
|
|
62
|
+
const path = row?.getAttribute("data-auto-path");
|
|
63
|
+
const toggle = path ? toggles.current.get(path) : void 0;
|
|
64
|
+
if (!toggle) return;
|
|
65
|
+
e2.preventDefault();
|
|
66
|
+
e2.stopPropagation();
|
|
67
|
+
toggle();
|
|
68
|
+
};
|
|
69
|
+
host.addEventListener("pointerdown", onDown, true);
|
|
70
|
+
return () => host.removeEventListener("pointerdown", onDown, true);
|
|
71
|
+
}, []);
|
|
72
|
+
const gridPack = gridOf(pack);
|
|
73
|
+
const folds = collapse !== void 0 || collapsed !== void 0 || onCollapse !== void 0 || resolved.sections.some((s) => s.collapsed !== void 0);
|
|
74
|
+
const startsFolded = collapse === "closed";
|
|
75
|
+
const fold = (key, declared, grid = gridPack) => ({
|
|
76
|
+
pack: grid,
|
|
77
|
+
collapsible: folds,
|
|
78
|
+
defaultCollapsed: declared ?? startsFolded,
|
|
79
|
+
collapsed: collapsed ? collapsed[key] ?? declared ?? startsFolded : void 0,
|
|
80
|
+
onCollapsedChange: onCollapse ? (next) => onCollapse(key, next) : void 0
|
|
81
|
+
});
|
|
82
|
+
const node = (path, rows) => {
|
|
83
|
+
const found = schemaNodeAtPath(resolved.group, path);
|
|
84
|
+
if (!found) return null;
|
|
85
|
+
if (!isLeafVisible(resolved, path, config, showHidden)) return null;
|
|
86
|
+
if (n3(found)) {
|
|
87
|
+
return /* @__PURE__ */ jsx(
|
|
88
|
+
ControlRow,
|
|
89
|
+
{
|
|
90
|
+
path,
|
|
91
|
+
leaf: found,
|
|
92
|
+
resolved,
|
|
93
|
+
config,
|
|
94
|
+
shown,
|
|
95
|
+
setConfig,
|
|
96
|
+
renderers,
|
|
97
|
+
pack: rows.pack,
|
|
98
|
+
layout: rows.layout,
|
|
99
|
+
auto: auto2,
|
|
100
|
+
setRowAuto,
|
|
101
|
+
toggles: toggles.current
|
|
102
|
+
},
|
|
103
|
+
path
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
if (found.name === "") return /* @__PURE__ */ jsx(Fragment$1, { children: body(found, path, rows) }, path);
|
|
107
|
+
return /* @__PURE__ */ jsx(J, { title: found.name, ...fold(path, void 0, rows.grid), children: body(found, path, rows) }, path);
|
|
108
|
+
};
|
|
109
|
+
const pairable = (path) => {
|
|
110
|
+
const found = schemaNodeAtPath(resolved.group, path);
|
|
111
|
+
if (!found || !n3(found)) return void 0;
|
|
112
|
+
const pair = extra(found, "pair");
|
|
113
|
+
if (pair === void 0) return void 0;
|
|
114
|
+
if (!isLeafVisible(resolved, path, config, showHidden))
|
|
115
|
+
return void 0;
|
|
116
|
+
if (renderers?.[path] ?? resolved.renderers[path] ?? renderers?.[found.kind]) return void 0;
|
|
117
|
+
if (!isBuiltinToolPref(found)) return void 0;
|
|
118
|
+
if (found.kind === "paint" || found.kind === "object" || isSliderLeaf(found)) return void 0;
|
|
119
|
+
return { leaf: found, pair };
|
|
120
|
+
};
|
|
121
|
+
const rowsFor = (paths, rows) => {
|
|
122
|
+
const out = [];
|
|
123
|
+
for (let i = 0; i < paths.length; ) {
|
|
124
|
+
const head = pairable(paths[i]);
|
|
125
|
+
if (!head) {
|
|
126
|
+
out.push(node(paths[i], rows));
|
|
127
|
+
i += 1;
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
const { pair } = head;
|
|
131
|
+
const cells = [{ path: paths[i], leaf: head.leaf }];
|
|
132
|
+
let j2 = i + 1;
|
|
133
|
+
for (; j2 < paths.length; j2 += 1) {
|
|
134
|
+
const next = pairable(paths[j2]);
|
|
135
|
+
if (!next || next.pair !== pair) break;
|
|
136
|
+
cells.push({ path: paths[j2], leaf: next.leaf });
|
|
137
|
+
}
|
|
138
|
+
out.push(
|
|
139
|
+
/* @__PURE__ */ jsx(
|
|
140
|
+
PairedRow,
|
|
141
|
+
{
|
|
142
|
+
label: pair,
|
|
143
|
+
cells,
|
|
144
|
+
shown,
|
|
145
|
+
setConfig,
|
|
146
|
+
layout: rows.layout
|
|
147
|
+
},
|
|
148
|
+
paths[i]
|
|
149
|
+
)
|
|
150
|
+
);
|
|
151
|
+
i = j2;
|
|
152
|
+
}
|
|
153
|
+
return out;
|
|
154
|
+
};
|
|
155
|
+
const body = (group, at, rows) => {
|
|
156
|
+
const sections = resolved.sections.filter((s) => s.at === at);
|
|
157
|
+
const sectioned = new Set(sections.flatMap((s) => s.paths));
|
|
158
|
+
const paths = Object.keys(group.children).map((key) => at === "" ? key : `${at}.${key}`);
|
|
159
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
160
|
+
rowsFor(
|
|
161
|
+
paths.filter((p) => !sectioned.has(p)),
|
|
162
|
+
rows
|
|
163
|
+
),
|
|
164
|
+
sections.map((section) => {
|
|
165
|
+
const inner = sectionRows(section, rows);
|
|
166
|
+
return /* @__PURE__ */ jsx(
|
|
167
|
+
J,
|
|
168
|
+
{
|
|
169
|
+
title: section.label,
|
|
170
|
+
...fold(sectionKey(section), section.collapsed, inner.grid),
|
|
171
|
+
children: rowsFor(section.paths, inner)
|
|
172
|
+
},
|
|
173
|
+
sectionKey(section)
|
|
174
|
+
);
|
|
175
|
+
})
|
|
176
|
+
] });
|
|
177
|
+
};
|
|
178
|
+
return /* @__PURE__ */ jsx("div", { ref: listRef, children: /* @__PURE__ */ jsx(
|
|
179
|
+
k,
|
|
180
|
+
{
|
|
181
|
+
pack: gridPack,
|
|
182
|
+
density,
|
|
183
|
+
align,
|
|
184
|
+
className: className ? `lk-control-panel ${className}` : "lk-control-panel",
|
|
185
|
+
children: body(resolved.group, "", { pack, layout, grid: gridPack })
|
|
186
|
+
}
|
|
187
|
+
) });
|
|
188
|
+
}
|
|
189
|
+
function sectionKey(section) {
|
|
190
|
+
return section.at === "" ? section.label : `${section.at}.${section.label}`;
|
|
191
|
+
}
|
|
192
|
+
function isSliderLeaf(leaf) {
|
|
193
|
+
return leaf.kind === "number" && extra(leaf, "control") === "slider" && extra(leaf, "min") !== void 0 && extra(leaf, "max") !== void 0;
|
|
194
|
+
}
|
|
195
|
+
function extra(leaf, key) {
|
|
196
|
+
return leaf[key];
|
|
197
|
+
}
|
|
198
|
+
function ControlRow({
|
|
199
|
+
path,
|
|
200
|
+
leaf,
|
|
201
|
+
resolved,
|
|
202
|
+
config,
|
|
203
|
+
shown,
|
|
204
|
+
setConfig,
|
|
205
|
+
renderers,
|
|
206
|
+
pack,
|
|
207
|
+
layout,
|
|
208
|
+
auto: auto2,
|
|
209
|
+
setRowAuto,
|
|
210
|
+
toggles
|
|
211
|
+
}) {
|
|
212
|
+
const write = (value2) => setConfig(path, value2);
|
|
213
|
+
const fallback = extra(leaf, "default");
|
|
214
|
+
const pinned = valueAtPath(config, path) ?? fallback;
|
|
215
|
+
const isAutoRow = auto2?.has(path) ?? false;
|
|
216
|
+
const canAuto = !extra(leaf, "manual");
|
|
217
|
+
const resolvedValue = isAutoRow ? valueAtPath(shown, path) : void 0;
|
|
218
|
+
const value = resolvedValue ?? pinned;
|
|
219
|
+
const setAuto = (next) => setRowAuto(path, next, value);
|
|
220
|
+
const onAutoChange = canAuto ? setAuto : void 0;
|
|
221
|
+
const readsItsOwnValue = !isSliderLeaf(leaf);
|
|
222
|
+
const readoutValue = leaf.kind === "number" && typeof resolvedValue === "number" ? numberField(leaf, resolvedValue).shown : resolvedValue;
|
|
223
|
+
const autoReadout = !isAutoRow ? void 0 : resolvedValue === void 0 || readsItsOwnValue ? "auto" : `auto \xB7 ${String(readoutValue)}`;
|
|
224
|
+
const autoProps = { auto: isAutoRow, onAutoChange, "data-auto-path": canAuto ? path : void 0 };
|
|
225
|
+
useEffect(() => {
|
|
226
|
+
if (!canAuto) return;
|
|
227
|
+
toggles.set(path, () => setAuto(!isAutoRow));
|
|
228
|
+
return () => {
|
|
229
|
+
toggles.delete(path);
|
|
230
|
+
};
|
|
231
|
+
});
|
|
232
|
+
const custom = renderers?.[path] ?? resolved.renderers[path] ?? renderers?.[leaf.kind];
|
|
233
|
+
if (custom) return custom({ path, pref: leaf, value, setValue: write, auto: isAutoRow, setAuto });
|
|
234
|
+
const label = leaf.name;
|
|
235
|
+
const description = leaf.description;
|
|
236
|
+
const read = () => value;
|
|
237
|
+
const wide = pack === "auto";
|
|
238
|
+
if (!isBuiltinToolPref(leaf))
|
|
239
|
+
return /* @__PURE__ */ jsx(UnwiredRow, { label, kind: leaf.kind, description });
|
|
240
|
+
switch (leaf.kind) {
|
|
241
|
+
case "number": {
|
|
242
|
+
const field = numberField(leaf, read());
|
|
243
|
+
const suffix = extra(leaf, "suffix") ?? field.unit?.suffix;
|
|
244
|
+
const notation = extra(leaf, "format");
|
|
245
|
+
if (isSliderLeaf(leaf)) {
|
|
246
|
+
return /* @__PURE__ */ jsx(
|
|
247
|
+
F2,
|
|
248
|
+
{
|
|
249
|
+
label,
|
|
250
|
+
value: field.shown,
|
|
251
|
+
min: field.min,
|
|
252
|
+
max: field.max,
|
|
253
|
+
step: field.step,
|
|
254
|
+
notation,
|
|
255
|
+
unit: suffix,
|
|
256
|
+
onChange: (n2) => write(field.store(n2)),
|
|
257
|
+
readout: autoReadout,
|
|
258
|
+
layout,
|
|
259
|
+
span: wide,
|
|
260
|
+
description,
|
|
261
|
+
...autoProps
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
return /* @__PURE__ */ jsx(
|
|
266
|
+
V,
|
|
267
|
+
{
|
|
268
|
+
label,
|
|
269
|
+
value: field.shown,
|
|
270
|
+
min: field.min,
|
|
271
|
+
max: field.max,
|
|
272
|
+
step: field.step,
|
|
273
|
+
unit: suffix,
|
|
274
|
+
onChange: (n2) => write(field.store(n2)),
|
|
275
|
+
readout: autoReadout,
|
|
276
|
+
layout,
|
|
277
|
+
description,
|
|
278
|
+
...autoProps
|
|
279
|
+
}
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
case "boolean": {
|
|
283
|
+
const Row = extra(leaf, "control") === "switch" ? z2 : R2;
|
|
284
|
+
return /* @__PURE__ */ jsx(
|
|
285
|
+
Row,
|
|
286
|
+
{
|
|
287
|
+
label,
|
|
288
|
+
value: read(),
|
|
289
|
+
onChange: write,
|
|
290
|
+
readout: autoReadout,
|
|
291
|
+
layout,
|
|
292
|
+
description,
|
|
293
|
+
...autoProps
|
|
294
|
+
}
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
case "enum": {
|
|
298
|
+
const options = extra(leaf, "options") ?? [];
|
|
299
|
+
const segmented = extra(leaf, "control") === "radio";
|
|
300
|
+
const Row = segmented ? U : H;
|
|
301
|
+
return /* @__PURE__ */ jsx(
|
|
302
|
+
Row,
|
|
303
|
+
{
|
|
304
|
+
label,
|
|
305
|
+
value: read(),
|
|
306
|
+
options,
|
|
307
|
+
onChange: write,
|
|
308
|
+
readout: autoReadout,
|
|
309
|
+
layout,
|
|
310
|
+
span: segmented && wide,
|
|
311
|
+
description,
|
|
312
|
+
...autoProps
|
|
313
|
+
}
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
case "string":
|
|
317
|
+
return /* @__PURE__ */ jsx(
|
|
318
|
+
DebouncedTextRow,
|
|
319
|
+
{
|
|
320
|
+
leaf,
|
|
321
|
+
label,
|
|
322
|
+
value: read(),
|
|
323
|
+
write,
|
|
324
|
+
readout: autoReadout,
|
|
325
|
+
layout,
|
|
326
|
+
span: wide,
|
|
327
|
+
description,
|
|
328
|
+
...autoProps
|
|
329
|
+
}
|
|
330
|
+
);
|
|
331
|
+
case "color": {
|
|
332
|
+
const common = {
|
|
333
|
+
label,
|
|
334
|
+
readout: autoReadout,
|
|
335
|
+
layout,
|
|
336
|
+
description,
|
|
337
|
+
...autoProps
|
|
338
|
+
};
|
|
339
|
+
if (extra(leaf, "alpha") !== true)
|
|
340
|
+
return /* @__PURE__ */ jsx(L3, { ...common, value: read(), onChange: write });
|
|
341
|
+
const { rgb, alpha } = splitHexAlpha(read());
|
|
342
|
+
return /* @__PURE__ */ jsx(
|
|
343
|
+
L3,
|
|
344
|
+
{
|
|
345
|
+
...common,
|
|
346
|
+
value: rgb,
|
|
347
|
+
onChange: (next) => write(joinHexAlpha(next, alpha)),
|
|
348
|
+
alpha,
|
|
349
|
+
onAlphaChange: (next) => write(joinHexAlpha(rgb, next))
|
|
350
|
+
}
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
case "paint":
|
|
354
|
+
case "object":
|
|
355
|
+
return /* @__PURE__ */ jsx(UnwiredRow, { label, kind: leaf.kind, description });
|
|
356
|
+
default: {
|
|
357
|
+
const _exhaustive = leaf;
|
|
358
|
+
throw new Error(
|
|
359
|
+
`ControlPanel: no control for built-in pref kind "${_exhaustive.kind}"`
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
function UnwiredRow({
|
|
365
|
+
label,
|
|
366
|
+
kind,
|
|
367
|
+
description
|
|
368
|
+
}) {
|
|
369
|
+
return /* @__PURE__ */ jsx(j2, { label, description, children: /* @__PURE__ */ jsxs("span", { className: "lk-control-panel__unknown", children: [
|
|
370
|
+
"no control for \u201C",
|
|
371
|
+
kind,
|
|
372
|
+
"\u201D"
|
|
373
|
+
] }) });
|
|
374
|
+
}
|
|
375
|
+
function DebouncedTextRow({
|
|
376
|
+
leaf,
|
|
377
|
+
label,
|
|
378
|
+
value,
|
|
379
|
+
write,
|
|
380
|
+
layout,
|
|
381
|
+
span,
|
|
382
|
+
description,
|
|
383
|
+
readout,
|
|
384
|
+
auto: auto2,
|
|
385
|
+
onAutoChange,
|
|
386
|
+
"data-auto-path": autoPath
|
|
387
|
+
}) {
|
|
388
|
+
const text = useDebouncedText(
|
|
389
|
+
value,
|
|
390
|
+
write,
|
|
391
|
+
extra(leaf, "debounceMs") ?? 150
|
|
392
|
+
);
|
|
393
|
+
return /* @__PURE__ */ jsx(
|
|
394
|
+
B,
|
|
395
|
+
{
|
|
396
|
+
label,
|
|
397
|
+
readout,
|
|
398
|
+
layout,
|
|
399
|
+
span,
|
|
400
|
+
description,
|
|
401
|
+
auto: auto2,
|
|
402
|
+
onAutoChange,
|
|
403
|
+
"data-auto-path": autoPath,
|
|
404
|
+
value: text.local,
|
|
405
|
+
placeholder: extra(leaf, "placeholder"),
|
|
406
|
+
maxLength: extra(leaf, "maxLength"),
|
|
407
|
+
onChange: text.type
|
|
408
|
+
}
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
function numberField(leaf, value) {
|
|
412
|
+
const unit = extra(leaf, "unit");
|
|
413
|
+
const bounds = unit ? e2(leaf) : {
|
|
414
|
+
min: extra(leaf, "min"),
|
|
415
|
+
max: extra(leaf, "max"),
|
|
416
|
+
step: extra(leaf, "step")
|
|
417
|
+
};
|
|
418
|
+
const lo = bounds.min ?? Number.NEGATIVE_INFINITY;
|
|
419
|
+
const hi = bounds.max ?? Number.POSITIVE_INFINITY;
|
|
420
|
+
return {
|
|
421
|
+
unit,
|
|
422
|
+
min: bounds.min,
|
|
423
|
+
max: bounds.max,
|
|
424
|
+
step: bounds.step,
|
|
425
|
+
shown: unit ? unit.toDisplay(value) : value,
|
|
426
|
+
store: (shown) => {
|
|
427
|
+
const clamped = Math.min(hi, Math.max(lo, shown));
|
|
428
|
+
return unit ? unit.fromDisplay(clamped) : clamped;
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
function splitHexAlpha(value) {
|
|
433
|
+
const digits = /^#([0-9a-f]{3,8})$/i.exec(value?.trim() ?? "")?.[1];
|
|
434
|
+
const twice = (s) => s.split("").map((c) => c + c).join("");
|
|
435
|
+
const byte = (s) => Number.parseInt(s, 16) / 255;
|
|
436
|
+
switch (digits?.length) {
|
|
437
|
+
case 3:
|
|
438
|
+
return { rgb: `#${twice(digits)}`, alpha: 1 };
|
|
439
|
+
case 4:
|
|
440
|
+
return { rgb: `#${twice(digits.slice(0, 3))}`, alpha: byte(twice(digits.slice(3))) };
|
|
441
|
+
case 6:
|
|
442
|
+
return { rgb: `#${digits}`, alpha: 1 };
|
|
443
|
+
case 8:
|
|
444
|
+
return { rgb: `#${digits.slice(0, 6)}`, alpha: byte(digits.slice(6)) };
|
|
445
|
+
default:
|
|
446
|
+
return { rgb: "#000000", alpha: 1 };
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
function joinHexAlpha(rgb, alpha) {
|
|
450
|
+
const byte = Math.max(0, Math.min(255, Math.round(alpha * 255)));
|
|
451
|
+
return `${rgb}${byte.toString(16).padStart(2, "0")}`;
|
|
452
|
+
}
|
|
453
|
+
function PairedRow({
|
|
454
|
+
label,
|
|
455
|
+
cells,
|
|
456
|
+
shown,
|
|
457
|
+
setConfig,
|
|
458
|
+
layout
|
|
459
|
+
}) {
|
|
460
|
+
return /* @__PURE__ */ jsx(j2, { group: true, label, layout, children: cells.map(({ path, leaf }) => /* @__PURE__ */ jsx(
|
|
461
|
+
PairCell,
|
|
462
|
+
{
|
|
463
|
+
leaf,
|
|
464
|
+
value: valueAtPath(shown, path) ?? extra(leaf, "default"),
|
|
465
|
+
write: (value) => setConfig(path, value)
|
|
466
|
+
},
|
|
467
|
+
path
|
|
468
|
+
)) });
|
|
469
|
+
}
|
|
470
|
+
function PairCell({
|
|
471
|
+
leaf,
|
|
472
|
+
value,
|
|
473
|
+
write
|
|
474
|
+
}) {
|
|
475
|
+
const name = leaf.name;
|
|
476
|
+
const title = leaf.description;
|
|
477
|
+
const text = useDebouncedText(
|
|
478
|
+
typeof value === "string" ? value : "",
|
|
479
|
+
write,
|
|
480
|
+
extra(leaf, "debounceMs") ?? 150
|
|
481
|
+
);
|
|
482
|
+
switch (leaf.kind) {
|
|
483
|
+
case "number": {
|
|
484
|
+
const field = numberField(leaf, typeof value === "number" ? value : 0);
|
|
485
|
+
return /* @__PURE__ */ jsx(
|
|
486
|
+
"input",
|
|
487
|
+
{
|
|
488
|
+
type: "number",
|
|
489
|
+
"aria-label": name,
|
|
490
|
+
title,
|
|
491
|
+
value: field.shown,
|
|
492
|
+
min: field.min,
|
|
493
|
+
max: field.max,
|
|
494
|
+
step: field.step,
|
|
495
|
+
onChange: (e2) => {
|
|
496
|
+
const n2 = Number(e2.target.value);
|
|
497
|
+
if (e2.target.value !== "" && Number.isFinite(n2)) write(field.store(n2));
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
case "boolean":
|
|
503
|
+
return extra(leaf, "control") === "switch" ? /* @__PURE__ */ jsx(a4, { "aria-label": name, isSelected: value === true, onChange: write }) : /* @__PURE__ */ jsx(
|
|
504
|
+
"input",
|
|
505
|
+
{
|
|
506
|
+
type: "checkbox",
|
|
507
|
+
"aria-label": name,
|
|
508
|
+
title,
|
|
509
|
+
checked: value === true,
|
|
510
|
+
onChange: (e2) => write(e2.target.checked)
|
|
511
|
+
}
|
|
512
|
+
);
|
|
513
|
+
case "string":
|
|
514
|
+
return /* @__PURE__ */ jsx(
|
|
515
|
+
"input",
|
|
516
|
+
{
|
|
517
|
+
type: "text",
|
|
518
|
+
"aria-label": name,
|
|
519
|
+
title,
|
|
520
|
+
value: text.local,
|
|
521
|
+
placeholder: extra(leaf, "placeholder"),
|
|
522
|
+
maxLength: extra(leaf, "maxLength"),
|
|
523
|
+
onChange: (e2) => text.type(e2.target.value)
|
|
524
|
+
}
|
|
525
|
+
);
|
|
526
|
+
case "color": {
|
|
527
|
+
const { rgb, alpha } = splitHexAlpha(typeof value === "string" ? value : "");
|
|
528
|
+
const carriesAlpha = extra(leaf, "alpha") === true;
|
|
529
|
+
return /* @__PURE__ */ jsx(
|
|
530
|
+
"input",
|
|
531
|
+
{
|
|
532
|
+
type: "color",
|
|
533
|
+
"aria-label": name,
|
|
534
|
+
title,
|
|
535
|
+
value: rgb,
|
|
536
|
+
onChange: (e2) => write(carriesAlpha ? joinHexAlpha(e2.target.value, alpha) : e2.target.value)
|
|
537
|
+
}
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
case "enum": {
|
|
541
|
+
const options = extra(leaf, "options") ?? [];
|
|
542
|
+
return /* @__PURE__ */ jsx("span", { title, children: /* @__PURE__ */ jsx(
|
|
543
|
+
g,
|
|
544
|
+
{
|
|
545
|
+
variant: "bare",
|
|
546
|
+
"aria-label": name,
|
|
547
|
+
options,
|
|
548
|
+
selectedKey: typeof value === "string" ? value : null,
|
|
549
|
+
onSelectionChange: write
|
|
550
|
+
}
|
|
551
|
+
) });
|
|
552
|
+
}
|
|
553
|
+
default:
|
|
554
|
+
return null;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
function useDebouncedText(value, write, debounceMs) {
|
|
558
|
+
const [local, setLocal] = useState(value);
|
|
559
|
+
const timer = useRef(null);
|
|
560
|
+
const lastExternal = useRef(value);
|
|
561
|
+
useEffect(() => {
|
|
562
|
+
if (value !== lastExternal.current) {
|
|
563
|
+
lastExternal.current = value;
|
|
564
|
+
setLocal(value);
|
|
565
|
+
}
|
|
566
|
+
}, [value]);
|
|
567
|
+
useEffect(
|
|
568
|
+
() => () => {
|
|
569
|
+
if (timer.current) clearTimeout(timer.current);
|
|
570
|
+
},
|
|
571
|
+
[]
|
|
572
|
+
);
|
|
573
|
+
return {
|
|
574
|
+
local,
|
|
575
|
+
type: (next) => {
|
|
576
|
+
setLocal(next);
|
|
577
|
+
if (timer.current) clearTimeout(timer.current);
|
|
578
|
+
const commit = () => {
|
|
579
|
+
lastExternal.current = next;
|
|
580
|
+
write(next);
|
|
581
|
+
};
|
|
582
|
+
if (debounceMs === 0) commit();
|
|
583
|
+
else timer.current = setTimeout(commit, debounceMs);
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
export { ControlPanel };
|
|
589
|
+
//# sourceMappingURL=chunk-EH7UEQV7.js.map
|
|
590
|
+
//# sourceMappingURL=chunk-EH7UEQV7.js.map
|