@weasel-js/labkit 1.3.0-pre.0 → 1.3.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/_dts/{index-DgcNdEdh.d.ts → types-BttTIent.d.ts} +2 -2
- package/dist/_dts/{types-AHlQxBNN.d.ts → types-DCGEcMO_.d.ts} +1 -1
- package/dist/canvas/index.d.ts +2 -2
- package/dist/canvas/index.js +3 -2
- package/dist/chrome/index.d.ts +3 -3
- package/dist/chrome/index.js +6 -5
- package/dist/chunk-3XXPU73K.js +138 -0
- package/dist/chunk-3XXPU73K.js.map +1 -0
- package/dist/{chunk-PO6L3NSH.js → chunk-6X5RBC6G.js} +17 -17
- package/dist/chunk-6X5RBC6G.js.map +1 -0
- package/dist/{chunk-NS54R52R.js → chunk-BDJXIBRZ.js} +5 -17
- package/dist/chunk-BDJXIBRZ.js.map +1 -0
- package/dist/{chunk-V7PRSIRQ.js → chunk-BMW4TDP5.js} +4 -4
- package/dist/chunk-BMW4TDP5.js.map +1 -0
- package/dist/{chunk-O7NVSCLN.js → chunk-JDROYQM3.js} +8 -8
- package/dist/chunk-JDROYQM3.js.map +1 -0
- package/dist/{chunk-HFDVGF4X.js → chunk-LGKRIUSW.js} +3 -3
- package/dist/{chunk-HFDVGF4X.js.map → chunk-LGKRIUSW.js.map} +1 -1
- package/dist/{chunk-Z6HJ5FEM.js → chunk-QCICIHEO.js} +19 -7
- package/dist/{chunk-Z6HJ5FEM.js.map → chunk-QCICIHEO.js.map} +1 -1
- package/dist/{chunk-RVNN4CHQ.js → chunk-QRYPXSGP.js} +5 -5
- package/dist/{chunk-RVNN4CHQ.js.map → chunk-QRYPXSGP.js.map} +1 -1
- package/dist/chunk-RGT4EJIB.js +6961 -0
- package/dist/chunk-RGT4EJIB.js.map +1 -0
- package/dist/chunk-SBXNQW4G.js +3 -0
- package/dist/chunk-SBXNQW4G.js.map +1 -0
- package/dist/chunk-T66HU3HX.js +17 -0
- package/dist/chunk-T66HU3HX.js.map +1 -0
- package/dist/chunk-WTI26YTM.js +266 -0
- package/dist/chunk-WTI26YTM.js.map +1 -0
- package/dist/controls/index.d.ts +2 -2
- package/dist/controls/index.js +3 -3
- package/dist/dragdrop/index.d.ts +44 -3
- package/dist/dragdrop/index.js +3 -1
- package/dist/index.d.ts +571 -541
- package/dist/index.js +69 -541
- package/dist/index.js.map +1 -1
- package/dist/layers/index.d.ts +3 -3
- package/dist/layers/index.js +4 -2
- package/dist/passthrough/weasel-canvas.js +1 -1
- package/dist/passthrough/weasel-ui.d.ts +15 -2
- package/dist/passthrough/weasel-ui.js +3 -2
- package/dist/primitives/index.js +5 -4
- package/dist/styles.css +1 -703
- package/dist/surface/index.js +2 -2
- package/dist/ui/layers/index.d.ts +8 -2
- package/dist/ui/layers/index.js +2 -4
- package/dist/undo/index.d.ts +2 -2
- package/package.json +5 -5
- package/src/config/builder.test.ts +7 -1
- package/src/config/builder.ts +1 -5
- package/src/config/resolve.test.ts +1 -2
- package/src/controls/ControlPanel.stories.tsx +41 -2
- package/src/controls/ControlPanel.test.tsx +31 -9
- package/src/controls/ControlPanel.tsx +56 -22
- package/src/dragdrop/index.ts +11 -0
- package/src/index.ts +49 -2
- package/src/lab/index.ts +1 -1
- package/src/layers/AGENTS.md +1 -1
- package/src/layers/LayerList.tsx +1 -1
- package/src/passthrough/weasel-ui.ts +22 -17
- package/src/styles.less +0 -4
- package/src/theme/Interstellar.stories.tsx +1 -1
- package/src/trial/Trial.config.test.tsx +3 -8
- package/src/ui/layers/index.ts +5 -1
- package/dist/chunk-NS54R52R.js.map +0 -1
- package/dist/chunk-O2BULFHX.js +0 -152
- package/dist/chunk-O2BULFHX.js.map +0 -1
- package/dist/chunk-O7NVSCLN.js.map +0 -1
- package/dist/chunk-PO6L3NSH.js.map +0 -1
- package/dist/chunk-PQJ5B2U2.js +0 -27
- package/dist/chunk-PQJ5B2U2.js.map +0 -1
- package/dist/chunk-TLGRYALP.js +0 -6151
- package/dist/chunk-TLGRYALP.js.map +0 -1
- package/dist/chunk-V7PRSIRQ.js.map +0 -1
- package/dist/chunk-ZZAYVX4X.js +0 -505
- package/dist/chunk-ZZAYVX4X.js.map +0 -1
- package/src/primitives/DragHandleGlyph.tsx +0 -29
- package/src/ui/format.test.ts +0 -33
- package/src/ui/format.ts +0 -30
- package/src/ui/layers/LayerStack.less +0 -143
- package/src/ui/layers/LayerStack.stories.tsx +0 -45
- package/src/ui/layers/LayerStack.test.tsx +0 -170
- package/src/ui/layers/LayerStack.tsx +0 -208
- package/src/ui/properties/CheckboxRow.stories.tsx +0 -27
- package/src/ui/properties/ColorRow.stories.tsx +0 -106
- package/src/ui/properties/CurveField.less +0 -48
- package/src/ui/properties/CurveField.stories.tsx +0 -20
- package/src/ui/properties/CurveField.test.tsx +0 -127
- package/src/ui/properties/CurveField.tsx +0 -184
- package/src/ui/properties/EffectCard.tsx +0 -324
- package/src/ui/properties/Gallery.stories.tsx +0 -178
- package/src/ui/properties/NumberRow.stories.tsx +0 -65
- package/src/ui/properties/PropertyGroup.less +0 -50
- package/src/ui/properties/PropertyGroup.stories.tsx +0 -34
- package/src/ui/properties/PropertyGroup.test.tsx +0 -33
- package/src/ui/properties/PropertyGroup.tsx +0 -45
- package/src/ui/properties/PropertyList.stories.tsx +0 -83
- package/src/ui/properties/PropertyPanel.less +0 -606
- package/src/ui/properties/PropertyPanel.stories.tsx +0 -190
- package/src/ui/properties/PropertyPanel.test.tsx +0 -193
- package/src/ui/properties/PropertyPanel.tsx +0 -469
- package/src/ui/properties/PropertyRow.stories.tsx +0 -53
- package/src/ui/properties/SelectRow.stories.tsx +0 -58
- package/src/ui/properties/SliderRow.stories.tsx +0 -74
- package/src/ui/properties/SpeechBalloonPanels.stories.tsx +0 -398
- package/src/ui/properties/TextRow.stories.tsx +0 -62
- package/src/ui/properties/ToggleRow.stories.tsx +0 -57
- package/src/ui/properties/index.ts +0 -39
- package/src/ui/properties/storyLayouts.tsx +0 -36
package/dist/index.js
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { useDragDrop, DragOverlay, Palette } from './chunk-3XXPU73K.js';
|
|
2
|
+
import { useSurfaceOptional } from './chunk-LGKRIUSW.js';
|
|
3
|
+
export { SurfaceContext, composeRects, rectsEqual, toDeviceRect, useSurface, useSurfaceOptional, useSurfaceTile, useTiledSurface } from './chunk-LGKRIUSW.js';
|
|
3
4
|
import { useJob } from './chunk-LN6JDUGB.js';
|
|
4
5
|
export { useJob } from './chunk-LN6JDUGB.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export {
|
|
10
|
-
export { FpsMeter, ScaleIndicator, StatusBar, Toolbar, ZoomControl } from './chunk-O7NVSCLN.js';
|
|
6
|
+
import { suppressContributions, mergeContributions, builtinContributions, TitleBarRegion, ToolbarRegion, PaletteRegion, SidebarRegion, ViewportRegion, StatusRegion } from './chunk-6X5RBC6G.js';
|
|
7
|
+
export { PaletteRegion, SidebarRegion, StatusRegion, TitleBarRegion, ToolbarRegion, ViewportRegion, builtinContributions, mergeContributions, suppressContributions } from './chunk-6X5RBC6G.js';
|
|
8
|
+
import { JobProgress } from './chunk-QRYPXSGP.js';
|
|
9
|
+
export { FloatingPanel, JobProgress, Legend, Sidebar } from './chunk-QRYPXSGP.js';
|
|
10
|
+
export { FpsMeter, ScaleIndicator, StatusBar, Toolbar, ZoomControl } from './chunk-JDROYQM3.js';
|
|
11
11
|
import { LabStoreContext, createLabStore, noneAdapter } from './chunk-4TMMVIDM.js';
|
|
12
12
|
export { CURRENT_DOCUMENT_VERSION, LabStoreContext, LabStoreProvider, TrialIdContext, TrialIdProvider, createMemoryAdapter, labDocumentKey, localStorageAdapter, noneAdapter, quarantineKey, sessionStorageAdapter, urlHashAdapter, useLabStore, useTrialId, useTrialState } from './chunk-4TMMVIDM.js';
|
|
13
|
-
import { fromConfigFields } from './chunk-
|
|
14
|
-
export {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
export {
|
|
13
|
+
import { fromConfigFields } from './chunk-WTI26YTM.js';
|
|
14
|
+
export { ControlPanel, fromConfigFields, isLeafVisible } from './chunk-WTI26YTM.js';
|
|
15
|
+
import { CanvasStack } from './chunk-BDJXIBRZ.js';
|
|
16
|
+
export { CanvasStack } from './chunk-BDJXIBRZ.js';
|
|
17
|
+
export { screenToWorld, worldToScreen } from './chunk-T66HU3HX.js';
|
|
18
18
|
export { CanvasStackContext } from './chunk-CPUJ3QXL.js';
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
import './chunk-
|
|
23
|
-
|
|
19
|
+
import { LayerList } from './chunk-BMW4TDP5.js';
|
|
20
|
+
export { LayerList } from './chunk-BMW4TDP5.js';
|
|
21
|
+
import './chunk-SBXNQW4G.js';
|
|
22
|
+
import { Rt, p, r } from './chunk-RGT4EJIB.js';
|
|
23
|
+
export { k as CheckboxRow, O as ColorRow, m2 as CurveField, _2 as EffectCard, y as EffectCardList, c3 as LayerStack, j as NumberRow, b2 as PropertyGroup, S2 as PropertyList, x2 as PropertyPanel, w as PropertyRow, C as PropertySpan, M as SelectRow, E as SliderRow, g as Subpanel, A as TextRow, N as ToggleRow } from './chunk-RGT4EJIB.js';
|
|
24
|
+
import './chunk-QCICIHEO.js';
|
|
25
|
+
import { createEventBus, pushSnapshot, redo, undo } from './chunk-RL2LOLNI.js';
|
|
24
26
|
export { clearUndo, createEventBus, emptyStack, pushSnapshot, redo, undo } from './chunk-RL2LOLNI.js';
|
|
25
27
|
import { createContext, useRef, useCallback, useContext, useMemo, useState, Children, useLayoutEffect, useEffect } from 'react';
|
|
26
28
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
27
29
|
import { useStore } from 'zustand/react';
|
|
28
|
-
import { createPortal } from 'react-dom';
|
|
29
30
|
import { Provider, StrategyRegistryProvider, DragProvider, Container, useDragHandle } from 'windease/react';
|
|
30
31
|
import { asNodeId, Store, createNode, gridStrategy } from 'windease';
|
|
31
32
|
|
|
@@ -287,9 +288,9 @@ function applyRules(seed, ctx, rules) {
|
|
|
287
288
|
for (const rule of rules) {
|
|
288
289
|
const patch = rule({ ...ctx, leaf: acc });
|
|
289
290
|
if (patch === null) continue;
|
|
290
|
-
for (const [
|
|
291
|
-
if (v !== void 0 && acc[
|
|
292
|
-
acc[
|
|
291
|
+
for (const [k2, v] of Object.entries(patch)) {
|
|
292
|
+
if (v !== void 0 && acc[k2] === void 0) {
|
|
293
|
+
acc[k2] = v;
|
|
293
294
|
}
|
|
294
295
|
}
|
|
295
296
|
}
|
|
@@ -299,7 +300,7 @@ function applyRules(seed, ctx, rules) {
|
|
|
299
300
|
// src/config/resolve.ts
|
|
300
301
|
function defined(annotations) {
|
|
301
302
|
const out = {};
|
|
302
|
-
for (const [
|
|
303
|
+
for (const [k2, v] of Object.entries(annotations)) if (v !== void 0) out[k2] = v;
|
|
303
304
|
return out;
|
|
304
305
|
}
|
|
305
306
|
function resolveConfigSchema(schema, rules = []) {
|
|
@@ -950,21 +951,21 @@ var weaselTheme = {
|
|
|
950
951
|
modes: THEME_SOURCES.weasel.modes
|
|
951
952
|
};
|
|
952
953
|
function hexToRgba(hex, alpha) {
|
|
953
|
-
const
|
|
954
|
-
if (!
|
|
955
|
-
const body =
|
|
956
|
-
const full = body.length === 3 ? body.replace(/./g, (
|
|
954
|
+
const m2 = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
955
|
+
if (!m2) throw new Error(`Expected a hex color, got "${hex}"`);
|
|
956
|
+
const body = m2[1];
|
|
957
|
+
const full = body.length === 3 ? body.replace(/./g, (c2) => c2 + c2) : body;
|
|
957
958
|
const r2 = Number.parseInt(full.slice(0, 2), 16);
|
|
958
|
-
const
|
|
959
|
-
const
|
|
960
|
-
return `rgba(${r2}, ${
|
|
959
|
+
const g2 = Number.parseInt(full.slice(2, 4), 16);
|
|
960
|
+
const b2 = Number.parseInt(full.slice(4, 6), 16);
|
|
961
|
+
return `rgba(${r2}, ${g2}, ${b2}, ${alpha})`;
|
|
961
962
|
}
|
|
962
963
|
var REF = /^\{([^}]+)\}$/;
|
|
963
964
|
function refTarget(value) {
|
|
964
965
|
if (typeof value !== "string") return null;
|
|
965
|
-
const
|
|
966
|
-
if (!
|
|
967
|
-
const path =
|
|
966
|
+
const m2 = REF.exec(value.trim());
|
|
967
|
+
if (!m2) return null;
|
|
968
|
+
const path = m2[1];
|
|
968
969
|
const dot = path.indexOf(".");
|
|
969
970
|
return dot === -1 ? path : path.slice(dot + 1);
|
|
970
971
|
}
|
|
@@ -1103,9 +1104,9 @@ function flattenTokens(doc) {
|
|
|
1103
1104
|
for (const [groupName, group] of Object.entries(doc)) {
|
|
1104
1105
|
if (groupName.startsWith("$")) continue;
|
|
1105
1106
|
if (typeof group !== "object" || group === null) continue;
|
|
1106
|
-
const
|
|
1107
|
-
const groupType =
|
|
1108
|
-
for (const [leaf, node] of Object.entries(
|
|
1107
|
+
const g2 = group;
|
|
1108
|
+
const groupType = g2.$type;
|
|
1109
|
+
for (const [leaf, node] of Object.entries(g2)) {
|
|
1109
1110
|
if (leaf.startsWith("$")) continue;
|
|
1110
1111
|
if (!isToken(node)) continue;
|
|
1111
1112
|
const type = node.$type ?? groupType;
|
|
@@ -1210,134 +1211,6 @@ var interstellar_tokens_default = {
|
|
|
1210
1211
|
|
|
1211
1212
|
// src/theme/interstellar.ts
|
|
1212
1213
|
var interstellarTheme = loadDTCG(interstellar_tokens_default);
|
|
1213
|
-
function DragGhost({ item, screenPos }) {
|
|
1214
|
-
const [mounted, setMounted] = useState(false);
|
|
1215
|
-
useEffect(() => setMounted(true), []);
|
|
1216
|
-
if (!mounted || typeof document === "undefined") return null;
|
|
1217
|
-
const style = {
|
|
1218
|
-
left: `${screenPos.x + 12}px`,
|
|
1219
|
-
top: `${screenPos.y + 12}px`
|
|
1220
|
-
};
|
|
1221
|
-
return createPortal(
|
|
1222
|
-
/* @__PURE__ */ jsx("div", { className: "lk-drag-ghost", style, children: /* @__PURE__ */ jsx("span", { className: "lk-drag-ghost__label", children: item.label }) }),
|
|
1223
|
-
document.body
|
|
1224
|
-
);
|
|
1225
|
-
}
|
|
1226
|
-
function useDragDrop({
|
|
1227
|
-
capability,
|
|
1228
|
-
canvasContainerRef,
|
|
1229
|
-
view,
|
|
1230
|
-
state,
|
|
1231
|
-
config,
|
|
1232
|
-
setState,
|
|
1233
|
-
emit
|
|
1234
|
-
}) {
|
|
1235
|
-
const [drag, setDrag] = useState(null);
|
|
1236
|
-
const dragRef = useRef(null);
|
|
1237
|
-
dragRef.current = drag;
|
|
1238
|
-
const pendingPos = useRef(null);
|
|
1239
|
-
const isOverCanvas = useCallback(
|
|
1240
|
-
(screenPos) => {
|
|
1241
|
-
const el = canvasContainerRef.current;
|
|
1242
|
-
if (!el) return false;
|
|
1243
|
-
const r2 = el.getBoundingClientRect();
|
|
1244
|
-
return screenPos.x >= r2.left && screenPos.x <= r2.right && screenPos.y >= r2.top && screenPos.y <= r2.bottom;
|
|
1245
|
-
},
|
|
1246
|
-
[canvasContainerRef]
|
|
1247
|
-
);
|
|
1248
|
-
const screenToWorldFromContainer = useCallback(
|
|
1249
|
-
(screenPos) => {
|
|
1250
|
-
const el = canvasContainerRef.current;
|
|
1251
|
-
if (!el) return null;
|
|
1252
|
-
const r2 = el.getBoundingClientRect();
|
|
1253
|
-
return screenToWorld({ x: screenPos.x - r2.left, y: screenPos.y - r2.top }, view);
|
|
1254
|
-
},
|
|
1255
|
-
[canvasContainerRef, view]
|
|
1256
|
-
);
|
|
1257
|
-
const frameLoop = useVisibleRaf(() => {
|
|
1258
|
-
const screenPos = pendingPos.current;
|
|
1259
|
-
pendingPos.current = null;
|
|
1260
|
-
const active = dragRef.current;
|
|
1261
|
-
if (!active || !screenPos) return;
|
|
1262
|
-
let feedback = null;
|
|
1263
|
-
if (capability.onDragOver && isOverCanvas(screenPos)) {
|
|
1264
|
-
const world = screenToWorldFromContainer(screenPos);
|
|
1265
|
-
if (world) feedback = capability.onDragOver(world, active.item, state, config);
|
|
1266
|
-
}
|
|
1267
|
-
setDrag({ ...active, screenPos, feedback });
|
|
1268
|
-
});
|
|
1269
|
-
useEffect(() => {
|
|
1270
|
-
if (!drag) return;
|
|
1271
|
-
const handleMove = (e) => {
|
|
1272
|
-
const screenPos = { x: e.clientX, y: e.clientY };
|
|
1273
|
-
const current = dragRef.current;
|
|
1274
|
-
if (!current) return;
|
|
1275
|
-
if (pendingPos.current !== null) {
|
|
1276
|
-
pendingPos.current = screenPos;
|
|
1277
|
-
dragRef.current = { ...current, screenPos };
|
|
1278
|
-
setDrag(dragRef.current);
|
|
1279
|
-
return;
|
|
1280
|
-
}
|
|
1281
|
-
pendingPos.current = screenPos;
|
|
1282
|
-
frameLoop.request();
|
|
1283
|
-
};
|
|
1284
|
-
const handleUp = (e) => {
|
|
1285
|
-
const screenPos = { x: e.clientX, y: e.clientY };
|
|
1286
|
-
const active = dragRef.current;
|
|
1287
|
-
if (!active) return;
|
|
1288
|
-
pendingPos.current = null;
|
|
1289
|
-
frameLoop.cancel();
|
|
1290
|
-
if (isOverCanvas(screenPos)) {
|
|
1291
|
-
const world = screenToWorldFromContainer(screenPos);
|
|
1292
|
-
if (world) {
|
|
1293
|
-
const nextState = capability.onDrop(world, active.item, state, config);
|
|
1294
|
-
setState(nextState);
|
|
1295
|
-
emit("canvas.itemAdded");
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1298
|
-
setDrag(null);
|
|
1299
|
-
};
|
|
1300
|
-
window.addEventListener("pointermove", handleMove);
|
|
1301
|
-
window.addEventListener("pointerup", handleUp);
|
|
1302
|
-
return () => {
|
|
1303
|
-
window.removeEventListener("pointermove", handleMove);
|
|
1304
|
-
window.removeEventListener("pointerup", handleUp);
|
|
1305
|
-
};
|
|
1306
|
-
}, [
|
|
1307
|
-
drag,
|
|
1308
|
-
capability,
|
|
1309
|
-
state,
|
|
1310
|
-
config,
|
|
1311
|
-
setState,
|
|
1312
|
-
emit,
|
|
1313
|
-
frameLoop,
|
|
1314
|
-
isOverCanvas,
|
|
1315
|
-
screenToWorldFromContainer
|
|
1316
|
-
]);
|
|
1317
|
-
const startDrag = useCallback((item, originScreenPos) => {
|
|
1318
|
-
setDrag({ item, screenPos: originScreenPos, feedback: null });
|
|
1319
|
-
}, []);
|
|
1320
|
-
return { drag, startDrag };
|
|
1321
|
-
}
|
|
1322
|
-
function DragOverlay({ drag }) {
|
|
1323
|
-
if (!drag) return null;
|
|
1324
|
-
return /* @__PURE__ */ jsx(DragGhost, { item: drag.item, screenPos: drag.screenPos });
|
|
1325
|
-
}
|
|
1326
|
-
function Palette({ items, onDragStart, className }) {
|
|
1327
|
-
return /* @__PURE__ */ jsx("div", { className: className ? `lk-palette ${className}` : "lk-palette", children: items.map((item) => /* @__PURE__ */ jsx(
|
|
1328
|
-
"button",
|
|
1329
|
-
{
|
|
1330
|
-
type: "button",
|
|
1331
|
-
className: "lk-palette__item",
|
|
1332
|
-
onPointerDown: (e) => {
|
|
1333
|
-
e.preventDefault();
|
|
1334
|
-
onDragStart(item, { x: e.clientX, y: e.clientY });
|
|
1335
|
-
},
|
|
1336
|
-
children: /* @__PURE__ */ jsx("span", { className: "lk-palette__label", children: item.label })
|
|
1337
|
-
},
|
|
1338
|
-
item.id
|
|
1339
|
-
)) });
|
|
1340
|
-
}
|
|
1341
1214
|
|
|
1342
1215
|
// src/state/view.ts
|
|
1343
1216
|
var DEFAULT_VIEW = { zoom: 1, pan: { x: 0, y: 0 } };
|
|
@@ -1461,7 +1334,7 @@ function TrialChrome({
|
|
|
1461
1334
|
),
|
|
1462
1335
|
[instrument, ctx, trialChrome, chrome, suppress, lab.controls]
|
|
1463
1336
|
);
|
|
1464
|
-
const inRegion = (region) => contributions.filter((
|
|
1337
|
+
const inRegion = (region) => contributions.filter((c2) => c2.region === region);
|
|
1465
1338
|
const handleKeyDown = (e) => {
|
|
1466
1339
|
const mod = e.metaKey || e.ctrlKey;
|
|
1467
1340
|
if (!mod) return;
|
|
@@ -1504,7 +1377,7 @@ function Trial({ id, chrome, suppress }) {
|
|
|
1504
1377
|
const lab = useLabContext();
|
|
1505
1378
|
const storeCtx = useContext(LabStoreContext);
|
|
1506
1379
|
if (!storeCtx) throw new Error("[labkit] <Trial> requires <LabStoreProvider>");
|
|
1507
|
-
const record = useStore(storeCtx.store, (s) => s.trials.find((
|
|
1380
|
+
const record = useStore(storeCtx.store, (s) => s.trials.find((w2) => w2.id === id));
|
|
1508
1381
|
if (!record) {
|
|
1509
1382
|
return /* @__PURE__ */ jsxs("div", { className: "lk-trial lk-trial--unknown", children: [
|
|
1510
1383
|
"Trial not found: ",
|
|
@@ -1549,7 +1422,7 @@ function TrialRuntime({ record, instrument, store, isLast, chrome, suppress }) {
|
|
|
1549
1422
|
const maxDepth = undoCap?.maxDepth ?? 50;
|
|
1550
1423
|
const snapshotIfNeeded = (event) => {
|
|
1551
1424
|
if (!undoCap || !undoEvents.has(event)) return;
|
|
1552
|
-
const current = store.getState().trials.find((
|
|
1425
|
+
const current = store.getState().trials.find((w2) => w2.id === record.id);
|
|
1553
1426
|
if (!current) return;
|
|
1554
1427
|
const snap = structuredClone(current.state);
|
|
1555
1428
|
updateTrialUndoStack(record.id, (prev) => pushSnapshot(prev, snap, maxDepth));
|
|
@@ -1622,7 +1495,7 @@ function TrialRuntime({ record, instrument, store, isLast, chrome, suppress }) {
|
|
|
1622
1495
|
const canvasLayers = useMemo(() => {
|
|
1623
1496
|
if (!instrument.canvas) return [];
|
|
1624
1497
|
const baseLayers = instrument.canvas.layers;
|
|
1625
|
-
const ordered = layerOrder ? [...baseLayers].sort((a,
|
|
1498
|
+
const ordered = layerOrder ? [...baseLayers].sort((a, b2) => layerOrder.indexOf(a.id) - layerOrder.indexOf(b2.id)) : baseLayers;
|
|
1626
1499
|
return ordered.map((layer) => ({
|
|
1627
1500
|
id: layer.id,
|
|
1628
1501
|
visible: layerVisibility[layer.id] !== false,
|
|
@@ -1654,8 +1527,8 @@ function TrialRuntime({ record, instrument, store, isLast, chrome, suppress }) {
|
|
|
1654
1527
|
});
|
|
1655
1528
|
const paletteItems = useMemo(() => {
|
|
1656
1529
|
if (!instrument.dragDrop) return [];
|
|
1657
|
-
const
|
|
1658
|
-
return typeof
|
|
1530
|
+
const p2 = instrument.dragDrop.palette;
|
|
1531
|
+
return typeof p2 === "function" ? p2(record.state, record.config) : p2;
|
|
1659
1532
|
}, [instrument.dragDrop, record.state, record.config]);
|
|
1660
1533
|
const layersWithFeedback = useMemo(() => {
|
|
1661
1534
|
if (!dragDropResult.drag?.feedback) return canvasLayers;
|
|
@@ -1787,7 +1660,7 @@ function addTrial(trials, instruments, instrumentName) {
|
|
|
1787
1660
|
return [...trials, record];
|
|
1788
1661
|
}
|
|
1789
1662
|
function cloneTrial(trials, id) {
|
|
1790
|
-
const sourceIdx = trials.findIndex((
|
|
1663
|
+
const sourceIdx = trials.findIndex((w2) => w2.id === id);
|
|
1791
1664
|
const source = trials[sourceIdx];
|
|
1792
1665
|
if (!source) return trials;
|
|
1793
1666
|
const clone = {
|
|
@@ -1802,11 +1675,11 @@ function cloneTrial(trials, id) {
|
|
|
1802
1675
|
}
|
|
1803
1676
|
function closeTrial(trials, id) {
|
|
1804
1677
|
if (trials.length <= 1) return trials;
|
|
1805
|
-
const next = trials.filter((
|
|
1678
|
+
const next = trials.filter((w2) => w2.id !== id);
|
|
1806
1679
|
return next.length === trials.length ? trials : next;
|
|
1807
1680
|
}
|
|
1808
1681
|
function resetTrial(trials, id, instruments) {
|
|
1809
|
-
const idx = trials.findIndex((
|
|
1682
|
+
const idx = trials.findIndex((w2) => w2.id === id);
|
|
1810
1683
|
const current = trials[idx];
|
|
1811
1684
|
if (!current) return trials;
|
|
1812
1685
|
const instrument = findInstrument(instruments, current.instrumentName);
|
|
@@ -1821,10 +1694,10 @@ function resetTrial(trials, id, instruments) {
|
|
|
1821
1694
|
return [...trials.slice(0, idx), reset, ...trials.slice(idx + 1)];
|
|
1822
1695
|
}
|
|
1823
1696
|
function reorderTrials(trials, ids) {
|
|
1824
|
-
const byId = new Map(trials.map((
|
|
1825
|
-
const named = ids.map((id) => byId.get(id)).filter((
|
|
1826
|
-
const seen = new Set(named.map((
|
|
1827
|
-
const rest = trials.filter((
|
|
1697
|
+
const byId = new Map(trials.map((w2) => [w2.id, w2]));
|
|
1698
|
+
const named = ids.map((id) => byId.get(id)).filter((w2) => w2 !== void 0);
|
|
1699
|
+
const seen = new Set(named.map((w2) => w2.id));
|
|
1700
|
+
const rest = trials.filter((w2) => !seen.has(w2.id));
|
|
1828
1701
|
return [...named, ...rest];
|
|
1829
1702
|
}
|
|
1830
1703
|
var MODES = [
|
|
@@ -1843,7 +1716,7 @@ function LabHeader() {
|
|
|
1843
1716
|
className: "lk-lab-header__add",
|
|
1844
1717
|
onClick: () => lab.addTrial(only.name),
|
|
1845
1718
|
children: [
|
|
1846
|
-
/* @__PURE__ */ jsx(
|
|
1719
|
+
/* @__PURE__ */ jsx(Rt, { size: 16 }),
|
|
1847
1720
|
/* @__PURE__ */ jsx("span", { children: "Add trial" })
|
|
1848
1721
|
]
|
|
1849
1722
|
}
|
|
@@ -1851,7 +1724,7 @@ function LabHeader() {
|
|
|
1851
1724
|
// Held at null so the control stays an "add one" action rather than
|
|
1852
1725
|
// reading as the current instrument.
|
|
1853
1726
|
/* @__PURE__ */ jsx(
|
|
1854
|
-
|
|
1727
|
+
p,
|
|
1855
1728
|
{
|
|
1856
1729
|
className: "lk-lab-header__add-select",
|
|
1857
1730
|
"aria-label": "Add trial",
|
|
@@ -1930,11 +1803,11 @@ var ZONE_ID = asNodeId("lk-workspace");
|
|
|
1930
1803
|
var STRATEGIES = { grid: gridStrategy };
|
|
1931
1804
|
var KIND = "trial";
|
|
1932
1805
|
function extentOf(store, id) {
|
|
1933
|
-
const
|
|
1934
|
-
if (!
|
|
1806
|
+
const p2 = store.getNode(id)?.membership?.placement;
|
|
1807
|
+
if (!p2) return null;
|
|
1935
1808
|
const out = {};
|
|
1936
|
-
if (
|
|
1937
|
-
if (
|
|
1809
|
+
if (p2.size) out.size = p2.size;
|
|
1810
|
+
if (p2.span) out.span = p2.span;
|
|
1938
1811
|
return Object.keys(out).length > 0 ? out : null;
|
|
1939
1812
|
}
|
|
1940
1813
|
function Workspace({
|
|
@@ -1951,7 +1824,7 @@ function Workspace({
|
|
|
1951
1824
|
}) {
|
|
1952
1825
|
const items = Children.toArray(children);
|
|
1953
1826
|
const idKey = ids ? ids.join(",") : `#${items.length}`;
|
|
1954
|
-
const nodeIds = useMemo(() => items.map((
|
|
1827
|
+
const nodeIds = useMemo(() => items.map((_2, i) => asNodeId(ids?.[i] ?? `lk-ws-${i}`)), [idKey]);
|
|
1955
1828
|
const layoutRef = useRef(layout);
|
|
1956
1829
|
layoutRef.current = layout;
|
|
1957
1830
|
const onLayoutChangeRef = useRef(onLayoutChange);
|
|
@@ -2054,9 +1927,9 @@ var NEBULA_SLOTS = [
|
|
|
2054
1927
|
{ cx: "85%", cy: "18%", sx: "55%", sy: "80%", stop: "70%" }
|
|
2055
1928
|
];
|
|
2056
1929
|
function buildNebula(colors) {
|
|
2057
|
-
const blobs = colors.map((
|
|
2058
|
-
const
|
|
2059
|
-
return `radial-gradient(ellipse ${
|
|
1930
|
+
const blobs = colors.map((c2, i) => {
|
|
1931
|
+
const p2 = NEBULA_SLOTS[i % NEBULA_SLOTS.length];
|
|
1932
|
+
return `radial-gradient(ellipse ${p2.sx} ${p2.sy} at ${p2.cx} ${p2.cy}, color-mix(in srgb, ${c2} 22%, transparent), transparent ${p2.stop})`;
|
|
2060
1933
|
});
|
|
2061
1934
|
blobs.push("radial-gradient(ellipse at center, #0a0a18 0%, #02020a 100%)");
|
|
2062
1935
|
return blobs.join(", ");
|
|
@@ -2103,8 +1976,8 @@ function Lab({
|
|
|
2103
1976
|
}, [mode, store]);
|
|
2104
1977
|
const contextValue = useMemo(() => {
|
|
2105
1978
|
const replaceTrials = (next) => {
|
|
2106
|
-
const currentById = new Map(store.getState().trials.map((
|
|
2107
|
-
const merged = next.map((
|
|
1979
|
+
const currentById = new Map(store.getState().trials.map((w2) => [w2.id, w2]));
|
|
1980
|
+
const merged = next.map((w2) => currentById.get(w2.id) ?? w2);
|
|
2108
1981
|
store.setState({ trials: merged });
|
|
2109
1982
|
store.getState().setMode(store.getState().mode);
|
|
2110
1983
|
};
|
|
@@ -2128,11 +2001,11 @@ function Lab({
|
|
|
2128
2001
|
},
|
|
2129
2002
|
resetTrial: (id) => {
|
|
2130
2003
|
const next = resetTrial(store.getState().trials, id, instruments);
|
|
2131
|
-
const record = next.find((
|
|
2004
|
+
const record = next.find((w2) => w2.id === id);
|
|
2132
2005
|
if (!record) return;
|
|
2133
2006
|
store.setState((s) => ({
|
|
2134
2007
|
trials: s.trials.map(
|
|
2135
|
-
(
|
|
2008
|
+
(w2) => w2.id === id ? { ...w2, config: record.config, state: record.state, view: record.view } : w2
|
|
2136
2009
|
)
|
|
2137
2010
|
}));
|
|
2138
2011
|
store.getState().updateTrialView(id, record.view);
|
|
@@ -2149,8 +2022,8 @@ function Lab({
|
|
|
2149
2022
|
store.getState().deleteSnapshot(snapshotId);
|
|
2150
2023
|
},
|
|
2151
2024
|
mode: modeValue,
|
|
2152
|
-
setMode: (
|
|
2153
|
-
store.getState().setMode(
|
|
2025
|
+
setMode: (m2) => {
|
|
2026
|
+
store.getState().setMode(m2);
|
|
2154
2027
|
},
|
|
2155
2028
|
configRules,
|
|
2156
2029
|
controls
|
|
@@ -2179,13 +2052,13 @@ function Lab({
|
|
|
2179
2052
|
/* @__PURE__ */ jsx(
|
|
2180
2053
|
Workspace,
|
|
2181
2054
|
{
|
|
2182
|
-
ids: trials.map((
|
|
2055
|
+
ids: trials.map((w2) => w2.id),
|
|
2183
2056
|
resizable: true,
|
|
2184
2057
|
reorderable: true,
|
|
2185
2058
|
onReorder: (ids) => contextValue.reorderTrials(ids),
|
|
2186
2059
|
layout,
|
|
2187
2060
|
onLayoutChange: (next) => store.getState().setLayout(next),
|
|
2188
|
-
children: trials.map((
|
|
2061
|
+
children: trials.map((w2) => /* @__PURE__ */ jsx(Trial, { id: w2.id, chrome, suppress }, w2.id))
|
|
2189
2062
|
}
|
|
2190
2063
|
)
|
|
2191
2064
|
] })
|
|
@@ -2194,352 +2067,7 @@ function Lab({
|
|
|
2194
2067
|
}
|
|
2195
2068
|
) }) });
|
|
2196
2069
|
}
|
|
2197
|
-
function CurveField({
|
|
2198
|
-
values,
|
|
2199
|
-
min,
|
|
2200
|
-
max,
|
|
2201
|
-
step,
|
|
2202
|
-
width,
|
|
2203
|
-
height = 110,
|
|
2204
|
-
defaults,
|
|
2205
|
-
onChange,
|
|
2206
|
-
marks
|
|
2207
|
-
}) {
|
|
2208
|
-
const points = useMemo(() => {
|
|
2209
|
-
const out = [];
|
|
2210
|
-
for (let i = 0; i + 1 < values.length; i += 2) out.push({ x: values[i], y: values[i + 1] });
|
|
2211
|
-
return out;
|
|
2212
|
-
}, [values]);
|
|
2213
|
-
const handleChange = useCallback(
|
|
2214
|
-
(next) => {
|
|
2215
|
-
const flat = new Array(next.length * 2);
|
|
2216
|
-
for (let i = 0; i < next.length; i++) {
|
|
2217
|
-
const ySnap = Math.round(next[i].y / step) * step;
|
|
2218
|
-
const y = Math.max(min, Math.min(max, ySnap));
|
|
2219
|
-
flat[i * 2] = next[i].x;
|
|
2220
|
-
flat[i * 2 + 1] = y;
|
|
2221
|
-
}
|
|
2222
|
-
p("curve-field", "handleChange", {
|
|
2223
|
-
nLen: next.length,
|
|
2224
|
-
flatLen: flat.length,
|
|
2225
|
-
sample: flat.slice(0, 4)
|
|
2226
|
-
});
|
|
2227
|
-
onChange(flat);
|
|
2228
|
-
},
|
|
2229
|
-
[onChange, min, max, step]
|
|
2230
|
-
);
|
|
2231
|
-
const handleFlip = useCallback(() => {
|
|
2232
|
-
const flipped = [];
|
|
2233
|
-
for (let i = 0; i + 1 < values.length; i += 2) {
|
|
2234
|
-
flipped.push({ x: 1 - values[i], y: values[i + 1] });
|
|
2235
|
-
}
|
|
2236
|
-
flipped.sort((a, b) => a.x - b.x);
|
|
2237
|
-
const out = [];
|
|
2238
|
-
for (const p3 of flipped) out.push(p3.x, p3.y);
|
|
2239
|
-
onChange(out);
|
|
2240
|
-
}, [values, onChange]);
|
|
2241
|
-
const handleFlipVertical = useCallback(() => {
|
|
2242
|
-
const mid = (min + max) / 2;
|
|
2243
|
-
const flipped = new Array(values.length);
|
|
2244
|
-
for (let i = 0; i + 1 < values.length; i += 2) {
|
|
2245
|
-
flipped[i] = values[i];
|
|
2246
|
-
flipped[i + 1] = 2 * mid - values[i + 1];
|
|
2247
|
-
}
|
|
2248
|
-
onChange(flipped);
|
|
2249
|
-
}, [values, min, max, onChange]);
|
|
2250
|
-
return /* @__PURE__ */ jsxs("div", { className: "lk-curve-field", children: [
|
|
2251
|
-
/* @__PURE__ */ jsxs("div", { className: "lk-curve-field__plot", children: [
|
|
2252
|
-
/* @__PURE__ */ jsx(
|
|
2253
|
-
F,
|
|
2254
|
-
{
|
|
2255
|
-
value: points,
|
|
2256
|
-
onInput: handleChange,
|
|
2257
|
-
domain: "1d",
|
|
2258
|
-
constrain: "function",
|
|
2259
|
-
xRange: [0, 1],
|
|
2260
|
-
yRange: [min, max],
|
|
2261
|
-
width,
|
|
2262
|
-
height,
|
|
2263
|
-
endpoints: "pinned-x",
|
|
2264
|
-
addPointMode: "click-curve",
|
|
2265
|
-
minPoints: 2,
|
|
2266
|
-
grid: {},
|
|
2267
|
-
history: false
|
|
2268
|
-
}
|
|
2269
|
-
),
|
|
2270
|
-
marks && marks.length > 0 && /* @__PURE__ */ jsx(
|
|
2271
|
-
"svg",
|
|
2272
|
-
{
|
|
2273
|
-
className: "lk-curve-field__marks",
|
|
2274
|
-
width,
|
|
2275
|
-
height,
|
|
2276
|
-
viewBox: `0 0 ${width} ${height}`,
|
|
2277
|
-
"aria-hidden": "true",
|
|
2278
|
-
children: marks.map((m) => {
|
|
2279
|
-
const color = m.color ?? "#ffcc00";
|
|
2280
|
-
if (m.kind === "band") {
|
|
2281
|
-
const x0 = Math.max(0, Math.min(1, m.x[0])) * width;
|
|
2282
|
-
const x1 = Math.max(0, Math.min(1, m.x[1])) * width;
|
|
2283
|
-
const left = Math.min(x0, x1);
|
|
2284
|
-
const w = Math.abs(x1 - x0);
|
|
2285
|
-
return /* @__PURE__ */ jsxs("g", { children: [
|
|
2286
|
-
/* @__PURE__ */ jsx("rect", { x: left, y: 0, width: w, height, fill: color, fillOpacity: 0.4 }),
|
|
2287
|
-
/* @__PURE__ */ jsx(
|
|
2288
|
-
"line",
|
|
2289
|
-
{
|
|
2290
|
-
x1: left,
|
|
2291
|
-
y1: 0,
|
|
2292
|
-
x2: left,
|
|
2293
|
-
y2: height,
|
|
2294
|
-
stroke: color,
|
|
2295
|
-
strokeOpacity: 0.85,
|
|
2296
|
-
strokeWidth: 1
|
|
2297
|
-
}
|
|
2298
|
-
),
|
|
2299
|
-
/* @__PURE__ */ jsx(
|
|
2300
|
-
"line",
|
|
2301
|
-
{
|
|
2302
|
-
x1: left + w,
|
|
2303
|
-
y1: 0,
|
|
2304
|
-
x2: left + w,
|
|
2305
|
-
y2: height,
|
|
2306
|
-
stroke: color,
|
|
2307
|
-
strokeOpacity: 0.85,
|
|
2308
|
-
strokeWidth: 1
|
|
2309
|
-
}
|
|
2310
|
-
)
|
|
2311
|
-
] }, `band-${m.x[0]}-${m.x[1]}-${color}`);
|
|
2312
|
-
}
|
|
2313
|
-
const x = Math.max(0, Math.min(1, m.x)) * width;
|
|
2314
|
-
return /* @__PURE__ */ jsx(
|
|
2315
|
-
"line",
|
|
2316
|
-
{
|
|
2317
|
-
x1: x,
|
|
2318
|
-
y1: 0,
|
|
2319
|
-
x2: x,
|
|
2320
|
-
y2: height,
|
|
2321
|
-
stroke: color,
|
|
2322
|
-
strokeWidth: 1
|
|
2323
|
-
},
|
|
2324
|
-
`mark-${m.x}-${color}`
|
|
2325
|
-
);
|
|
2326
|
-
})
|
|
2327
|
-
}
|
|
2328
|
-
)
|
|
2329
|
-
] }),
|
|
2330
|
-
/* @__PURE__ */ jsxs("div", { className: "lk-curve-field__actions", children: [
|
|
2331
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "lk-curve-field__action", onClick: handleFlip, children: "Flip horizontally" }),
|
|
2332
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "lk-curve-field__action", onClick: handleFlipVertical, children: "Flip vertically" }),
|
|
2333
|
-
defaults && /* @__PURE__ */ jsx(
|
|
2334
|
-
"button",
|
|
2335
|
-
{
|
|
2336
|
-
type: "button",
|
|
2337
|
-
className: "lk-curve-field__action",
|
|
2338
|
-
onClick: () => onChange([...defaults]),
|
|
2339
|
-
children: "Reset"
|
|
2340
|
-
}
|
|
2341
|
-
)
|
|
2342
|
-
] })
|
|
2343
|
-
] });
|
|
2344
|
-
}
|
|
2345
|
-
function Subpanel({ title, children, className }) {
|
|
2346
|
-
const cls = className ? `lk-subpanel ${className}` : "lk-subpanel";
|
|
2347
|
-
return /* @__PURE__ */ jsxs("div", { className: cls, children: [
|
|
2348
|
-
/* @__PURE__ */ jsxs("h4", { className: "lk-subpanel__title", children: [
|
|
2349
|
-
/* @__PURE__ */ jsx("span", { children: title }),
|
|
2350
|
-
/* @__PURE__ */ jsx("hr", {})
|
|
2351
|
-
] }),
|
|
2352
|
-
children
|
|
2353
|
-
] });
|
|
2354
|
-
}
|
|
2355
|
-
function EffectCard({
|
|
2356
|
-
title,
|
|
2357
|
-
primary,
|
|
2358
|
-
accent,
|
|
2359
|
-
index,
|
|
2360
|
-
expanded = true,
|
|
2361
|
-
onToggleExpanded,
|
|
2362
|
-
onRemove,
|
|
2363
|
-
draggable,
|
|
2364
|
-
onPressHandle,
|
|
2365
|
-
onReleaseHandle,
|
|
2366
|
-
onDragStart,
|
|
2367
|
-
onDragEnd,
|
|
2368
|
-
onDragOver,
|
|
2369
|
-
onDragLeave,
|
|
2370
|
-
onDrop,
|
|
2371
|
-
dragging,
|
|
2372
|
-
children,
|
|
2373
|
-
className
|
|
2374
|
-
}) {
|
|
2375
|
-
const stateClass = `${expanded ? "is-expanded" : "is-collapsed"}${dragging ? " is-dragging" : ""}${accent ? " has-accent" : ""}`;
|
|
2376
|
-
const cls = `lk-effect-card ${stateClass}${className ? ` ${className}` : ""}`;
|
|
2377
|
-
const style = accent ? { "--lk-panel-accent": accent } : void 0;
|
|
2378
|
-
const headProps = onToggleExpanded ? {
|
|
2379
|
-
role: "button",
|
|
2380
|
-
tabIndex: 0,
|
|
2381
|
-
onClick: onToggleExpanded,
|
|
2382
|
-
onKeyDown: (e) => {
|
|
2383
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
2384
|
-
e.preventDefault();
|
|
2385
|
-
onToggleExpanded();
|
|
2386
|
-
}
|
|
2387
|
-
}
|
|
2388
|
-
} : {};
|
|
2389
|
-
return (
|
|
2390
|
-
// biome-ignore lint/a11y/noStaticElementInteractions: native HTML5 drag-and-drop container — drag events are not click/keyboard interactions and have no semantic element; the in-card handle and header carry the a11y affordances.
|
|
2391
|
-
/* @__PURE__ */ jsxs(
|
|
2392
|
-
"div",
|
|
2393
|
-
{
|
|
2394
|
-
className: cls,
|
|
2395
|
-
style,
|
|
2396
|
-
draggable,
|
|
2397
|
-
onDragStart,
|
|
2398
|
-
onDragEnd,
|
|
2399
|
-
onDragOver,
|
|
2400
|
-
onDragLeave,
|
|
2401
|
-
onDrop,
|
|
2402
|
-
children: [
|
|
2403
|
-
/* @__PURE__ */ jsxs("div", { className: "lk-effect-card__head", ...headProps, children: [
|
|
2404
|
-
index != null ? /* @__PURE__ */ jsx(
|
|
2405
|
-
"button",
|
|
2406
|
-
{
|
|
2407
|
-
type: "button",
|
|
2408
|
-
className: "lk-effect-card__index-badge lk-effect-card__handle",
|
|
2409
|
-
title: "Drag to reorder \xB7 click to toggle",
|
|
2410
|
-
"aria-label": `Item ${index + 1} \u2014 drag to reorder, click to toggle`,
|
|
2411
|
-
onMouseDown: onPressHandle,
|
|
2412
|
-
onMouseUp: onReleaseHandle,
|
|
2413
|
-
onClick: (e) => {
|
|
2414
|
-
e.stopPropagation();
|
|
2415
|
-
onToggleExpanded?.();
|
|
2416
|
-
},
|
|
2417
|
-
children: index + 1
|
|
2418
|
-
}
|
|
2419
|
-
) : /* @__PURE__ */ jsx(
|
|
2420
|
-
"span",
|
|
2421
|
-
{
|
|
2422
|
-
className: "lk-effect-card__handle",
|
|
2423
|
-
"aria-hidden": "true",
|
|
2424
|
-
title: "Drag to reorder",
|
|
2425
|
-
onMouseDown: onPressHandle,
|
|
2426
|
-
onMouseUp: onReleaseHandle,
|
|
2427
|
-
children: /* @__PURE__ */ jsx(DragHandleIcon, {})
|
|
2428
|
-
}
|
|
2429
|
-
),
|
|
2430
|
-
/* @__PURE__ */ jsx("span", { className: "lk-effect-card__title", children: title }),
|
|
2431
|
-
primary != null && /* @__PURE__ */ jsx("span", { className: "lk-effect-card__primary", children: primary }),
|
|
2432
|
-
onRemove && /* @__PURE__ */ jsx(
|
|
2433
|
-
"button",
|
|
2434
|
-
{
|
|
2435
|
-
type: "button",
|
|
2436
|
-
className: "lk-effect-card__remove",
|
|
2437
|
-
onClick: (e) => {
|
|
2438
|
-
e.stopPropagation();
|
|
2439
|
-
onRemove();
|
|
2440
|
-
},
|
|
2441
|
-
title: "Remove",
|
|
2442
|
-
"aria-label": "Remove",
|
|
2443
|
-
children: "\u2715"
|
|
2444
|
-
}
|
|
2445
|
-
)
|
|
2446
|
-
] }),
|
|
2447
|
-
expanded && /* @__PURE__ */ jsx("div", { className: "lk-effect-card__body", children })
|
|
2448
|
-
]
|
|
2449
|
-
}
|
|
2450
|
-
)
|
|
2451
|
-
);
|
|
2452
|
-
}
|
|
2453
|
-
function DragHandleIcon() {
|
|
2454
|
-
return /* @__PURE__ */ jsxs("svg", { width: "10", height: "14", viewBox: "0 0 10 14", "aria-hidden": "true", children: [
|
|
2455
|
-
/* @__PURE__ */ jsx("circle", { cx: "3", cy: "3", r: "1.3", fill: "currentColor" }),
|
|
2456
|
-
/* @__PURE__ */ jsx("circle", { cx: "7", cy: "3", r: "1.3", fill: "currentColor" }),
|
|
2457
|
-
/* @__PURE__ */ jsx("circle", { cx: "3", cy: "7", r: "1.3", fill: "currentColor" }),
|
|
2458
|
-
/* @__PURE__ */ jsx("circle", { cx: "7", cy: "7", r: "1.3", fill: "currentColor" }),
|
|
2459
|
-
/* @__PURE__ */ jsx("circle", { cx: "3", cy: "11", r: "1.3", fill: "currentColor" }),
|
|
2460
|
-
/* @__PURE__ */ jsx("circle", { cx: "7", cy: "11", r: "1.3", fill: "currentColor" })
|
|
2461
|
-
] });
|
|
2462
|
-
}
|
|
2463
|
-
function EffectCardList({
|
|
2464
|
-
items,
|
|
2465
|
-
renderItem,
|
|
2466
|
-
onReorder,
|
|
2467
|
-
empty,
|
|
2468
|
-
defaultExpandedIds
|
|
2469
|
-
}) {
|
|
2470
|
-
const [expanded, setExpanded] = useState(() => new Set(defaultExpandedIds ?? []));
|
|
2471
|
-
const [draggingId, setDraggingId] = useState(null);
|
|
2472
|
-
const [pressedId, setPressedId] = useState(null);
|
|
2473
|
-
const [dropHint, setDropHint] = useState(
|
|
2474
|
-
null
|
|
2475
|
-
);
|
|
2476
|
-
if (items.length === 0) {
|
|
2477
|
-
return /* @__PURE__ */ jsx(Fragment, { children: empty ?? /* @__PURE__ */ jsx("div", { className: "lk-effect-card-list__empty", children: "No items." }) });
|
|
2478
|
-
}
|
|
2479
|
-
return /* @__PURE__ */ jsx("div", { className: "lk-effect-card-list", children: items.map((item) => {
|
|
2480
|
-
const isExpanded = expanded.has(item.id);
|
|
2481
|
-
const isDragging = draggingId === item.id;
|
|
2482
|
-
const isPressed = pressedId === item.id;
|
|
2483
|
-
const showHintBefore = dropHint && dropHint.id === item.id && dropHint.position === "before";
|
|
2484
|
-
const showHintAfter = dropHint && dropHint.id === item.id && dropHint.position === "after";
|
|
2485
|
-
const toggleExpanded = () => setExpanded((prev) => {
|
|
2486
|
-
const next = new Set(prev);
|
|
2487
|
-
if (next.has(item.id)) next.delete(item.id);
|
|
2488
|
-
else next.add(item.id);
|
|
2489
|
-
return next;
|
|
2490
|
-
});
|
|
2491
|
-
return /* @__PURE__ */ jsxs("div", { className: "lk-effect-card-list__wrap", children: [
|
|
2492
|
-
showHintBefore && /* @__PURE__ */ jsx("div", { className: "lk-effect-card-list__drop-hint" }),
|
|
2493
|
-
renderItem(item, {
|
|
2494
|
-
isExpanded,
|
|
2495
|
-
isDragging,
|
|
2496
|
-
toggleExpanded,
|
|
2497
|
-
cardProps: {
|
|
2498
|
-
expanded: isExpanded,
|
|
2499
|
-
dragging: isDragging,
|
|
2500
|
-
draggable: isPressed,
|
|
2501
|
-
onToggleExpanded: toggleExpanded,
|
|
2502
|
-
onPressHandle: () => setPressedId(item.id),
|
|
2503
|
-
onReleaseHandle: () => setPressedId(null),
|
|
2504
|
-
onDragStart: (e) => {
|
|
2505
|
-
e.dataTransfer.effectAllowed = "move";
|
|
2506
|
-
e.dataTransfer.setData("text/plain", String(item.id));
|
|
2507
|
-
setDraggingId(item.id);
|
|
2508
|
-
},
|
|
2509
|
-
onDragEnd: () => {
|
|
2510
|
-
setDraggingId(null);
|
|
2511
|
-
setPressedId(null);
|
|
2512
|
-
setDropHint(null);
|
|
2513
|
-
},
|
|
2514
|
-
onDragOver: (e) => {
|
|
2515
|
-
if (draggingId === null || draggingId === item.id) return;
|
|
2516
|
-
e.preventDefault();
|
|
2517
|
-
e.dataTransfer.dropEffect = "move";
|
|
2518
|
-
const rect = e.currentTarget.getBoundingClientRect();
|
|
2519
|
-
const position = e.clientY < rect.top + rect.height / 2 ? "before" : "after";
|
|
2520
|
-
setDropHint({ id: item.id, position });
|
|
2521
|
-
},
|
|
2522
|
-
onDragLeave: () => {
|
|
2523
|
-
setDropHint((h) => h && h.id === item.id ? null : h);
|
|
2524
|
-
},
|
|
2525
|
-
onDrop: (e) => {
|
|
2526
|
-
e.preventDefault();
|
|
2527
|
-
if (draggingId === null || draggingId === item.id) {
|
|
2528
|
-
setDropHint(null);
|
|
2529
|
-
return;
|
|
2530
|
-
}
|
|
2531
|
-
const rect = e.currentTarget.getBoundingClientRect();
|
|
2532
|
-
const position = e.clientY < rect.top + rect.height / 2 ? "before" : "after";
|
|
2533
|
-
onReorder(draggingId, item.id, position);
|
|
2534
|
-
setDropHint(null);
|
|
2535
|
-
}
|
|
2536
|
-
}
|
|
2537
|
-
}),
|
|
2538
|
-
showHintAfter && /* @__PURE__ */ jsx("div", { className: "lk-effect-card-list__drop-hint" })
|
|
2539
|
-
] }, String(item.id));
|
|
2540
|
-
}) });
|
|
2541
|
-
}
|
|
2542
2070
|
|
|
2543
|
-
export {
|
|
2071
|
+
export { DEFAULT_VIEW, Lab, LabContext, LabPalette, LabShell, PITCH_LIMIT, Trial, TrialChrome, Workspace, addTrial, applyRules, as2DView, builtinRules, clampPitch, cloneTrial, closeTrial, defineInstrument, f, interstellarTheme, orbitAfterDrag, orbitAfterWheel, reorderTrials, resetTrial, resolveConfigSchema, titleCase, useConfigSchema, useLabContext, useOrbit, validateConfigSchema, wrapYaw };
|
|
2544
2072
|
//# sourceMappingURL=index.js.map
|
|
2545
2073
|
//# sourceMappingURL=index.js.map
|