@weasel-js/ui-canvas 0.0.0-stage → 1.19.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.
@@ -0,0 +1,182 @@
1
+ import { asNodeId, createDeleteOp, createMoveToIndexOp, createReparentOp, createSetDataOp, createSetHiddenOp, createSetLockedOp, defaultCommitAdapter, dispatchApplyBatch, isAnnotationLayer, pageName, pageOfNode, pageRunOf, placedPagesOf, withoutPageStructure } from "@weasel-js/core";
2
+
3
+ // src/components/SceneLayerList/useSceneLayerList.ts
4
+ /** The id prefix of an annotation layer's own row, which holds its nodes. */
5
+ var ANNOTATION_LAYER_ROW = "annotation-layer:";
6
+ /** The annotation layer whose row `row` is, if it is one. */
7
+ var annotationLayerOf = (row) => row?.startsWith("annotation-layer:") ? row.slice(17) : null;
8
+ /** Commits a toggle's `changes` as one history entry. An annotation layer's row toggles the layer through
9
+ * `layerTo`, since a layer is no node and has no op. */
10
+ function commitToggle(commit, changes, layerTo, opOf, [on, off, mixed]) {
11
+ const ops = Object.entries(changes).flatMap(([id, to]) => {
12
+ if (!id.startsWith("annotation-layer:")) return [opOf(id, to)];
13
+ layerTo(id.slice(17), to);
14
+ return [];
15
+ });
16
+ if (ops.length === 0) return;
17
+ const values = Object.values(changes);
18
+ commit(ops, values.every(Boolean) ? on : values.some(Boolean) ? mixed : off);
19
+ }
20
+ /**
21
+ * How many of `shown`, the siblings under `parent` a drag left behind, lie behind a drop at gap `at` of the list's
22
+ * top level, where the page run's children are listed beside the other roots. A sibling is behind when its front-most
23
+ * row there is at or past the gap; the run, whose rows are its children's, counts by the first of them.
24
+ */
25
+ function behindTopGap(childrenOf, roots, run, moved, parent, shown, at) {
26
+ const owners = [];
27
+ for (const root of [...roots].reverse()) {
28
+ if (root !== run) {
29
+ if (!moved.has(root)) owners.push(parent === null ? root : void 0);
30
+ continue;
31
+ }
32
+ for (const kid of [...childrenOf(root)].reverse()) if (!moved.has(kid)) owners.push(parent === null ? root : parent === run ? kid : void 0);
33
+ }
34
+ return shown.filter((id) => {
35
+ const first = owners.indexOf(id);
36
+ return first < 0 || first >= at;
37
+ }).length;
38
+ }
39
+ /**
40
+ * The props that put a scene in a `<LayerList>`: a row per node, a container's
41
+ * children nested under it, the front-most at the top, selection read from and
42
+ * written to `selection`, a drag — among siblings or into another container —
43
+ * dispatched as a `MoveToIndexOp`, and each row's visibility and lock toggling
44
+ * the node's own (`setHidden` / `setLocked` ops), each click one undo step, an Alt-click's batch included.
45
+ * Annotation layers are left out unless `annotations` says how to show them;
46
+ * shown, an annotation moves only within its own layer's row.
47
+ */
48
+ function useSceneLayerList(args) {
49
+ const { scene, selection, adapter, itemFor, rename, label = "Reorder", annotations } = args;
50
+ const annotationLayers = scene.layers.filter(isAnnotationLayer);
51
+ const onAnnotation = new Set(annotationLayers.map((l) => l.id));
52
+ const isAnnotation = (id) => {
53
+ const layer = scene.get(asNodeId(id))?.layer;
54
+ return layer !== void 0 && onAnnotation.has(layer);
55
+ };
56
+ const commit = (ops, entry) => {
57
+ if (adapter) dispatchApplyBatch(adapter, ops, entry);
58
+ else scene.applyBatch(ops, entry, defaultCommitAdapter(scene, selection.adapterMethods));
59
+ };
60
+ const run = pageRunOf(scene);
61
+ const pages = new Map(placedPagesOf(scene).map((page) => [page.id, page]));
62
+ const build = (ids, extra) => [...ids].reverse().flatMap((id) => {
63
+ const node = scene.get(id);
64
+ if (!node) return [];
65
+ const kids = scene.childrenOf(id);
66
+ if (id === run) return build(kids, extra);
67
+ const children = kids.length > 0 ? { children: build(kids, extra) } : {};
68
+ const page = node.page === void 0 ? void 0 : pages.get(pageOfNode(scene, id));
69
+ if (page !== void 0) return [{
70
+ id,
71
+ label: pageName(page, page.index),
72
+ fixed: true,
73
+ ...children
74
+ }];
75
+ return [{
76
+ ...itemFor(node),
77
+ ...extra,
78
+ id,
79
+ visible: node.hidden !== true,
80
+ locked: node.locked === true,
81
+ ...children
82
+ }];
83
+ });
84
+ const topParent = (ids) => {
85
+ const from = scene.get(asNodeId(ids[0]))?.parent ?? null;
86
+ if (from === null || from === run) return from;
87
+ if (run === null) return null;
88
+ return scene.get(run).pageRun.pasteboard === true ? null : run;
89
+ };
90
+ const content = build(scene.roots.filter((id) => !isAnnotation(id)), annotations ? { removable: false } : {});
91
+ const annotationRows = annotations ? [...annotationLayers].reverse().map((layer) => ({
92
+ id: `${ANNOTATION_LAYER_ROW}${layer.id}`,
93
+ label: annotations.labelOf?.(layer.id) ?? layer.id,
94
+ nonPrinting: true,
95
+ visible: layer.visible,
96
+ locked: layer.locked,
97
+ removable: false,
98
+ renamable: false,
99
+ children: build(scene.roots.filter((id) => scene.get(id)?.layer === layer.id), { nonPrinting: true })
100
+ })) : [];
101
+ const picked = annotations?.picked ?? null;
102
+ return {
103
+ items: [...annotationRows, ...content],
104
+ selectedIds: [...selection.current.map(String), ...picked !== null ? [picked] : []],
105
+ onSelectionChange: (ids) => {
106
+ const notes = ids.filter(isAnnotation);
107
+ if (notes.length > 0) {
108
+ annotations?.pick(notes.at(-1));
109
+ return;
110
+ }
111
+ selection.set([...withoutPageStructure(scene, ids.filter((id) => !id.startsWith(ANNOTATION_LAYER_ROW)).map(asNodeId))]);
112
+ },
113
+ canMove: ({ ids, parentId }) => {
114
+ if (ids.some((id) => id.startsWith("annotation-layer:"))) return false;
115
+ const into = annotationLayerOf(parentId);
116
+ return ids.every((id) => isAnnotation(id) ? scene.get(asNodeId(id))?.layer === into : into === null);
117
+ },
118
+ onReorder: ({ ids, parentId, index }) => {
119
+ const layer = annotationLayerOf(parentId);
120
+ const parent = layer !== null ? null : parentId ?? topParent(ids);
121
+ const moved = new Set(ids);
122
+ const left = (parent === null ? scene.roots : scene.childrenOf(asNodeId(parent))).filter((id) => !moved.has(id));
123
+ const shown = left.filter((id) => layer !== null ? scene.get(id)?.layer === layer : !isAnnotation(id));
124
+ const at = parentId === null ? Math.max(0, index - annotationRows.length) : index;
125
+ const back = parentId === null && layer === null ? behindTopGap((id) => scene.childrenOf(id), scene.roots.filter((id) => !isAnnotation(id)), run, moved, parent, shown, at) : Math.max(0, shown.length - at);
126
+ const to = back < shown.length ? left.indexOf(shown[back]) : shown.length > 0 ? left.indexOf(shown.at(-1)) + 1 : left.length;
127
+ const joining = [...ids].reverse().flatMap((id) => {
128
+ const from = scene.get(asNodeId(id))?.parent ?? null;
129
+ return from === parent ? [] : [createReparentOp({
130
+ id,
131
+ fromParentId: from,
132
+ toParentId: parent
133
+ })];
134
+ });
135
+ commit([...joining, createMoveToIndexOp({
136
+ ids,
137
+ parentId: parent,
138
+ index: to
139
+ })], label);
140
+ },
141
+ onVisibilityChange: (changes) => commitToggle(commit, changes, (layer, on) => scene.setLayerVisible(layer, on), (id, on) => createSetHiddenOp({
142
+ id,
143
+ from: scene.get(asNodeId(id))?.hidden === true,
144
+ to: !on
145
+ }), [
146
+ "Show",
147
+ "Hide",
148
+ "Show Only"
149
+ ]),
150
+ onLockChange: (changes) => commitToggle(commit, changes, (layer, on) => scene.setLayerLocked(layer, on), (id, on) => createSetLockedOp({
151
+ id,
152
+ from: scene.get(asNodeId(id))?.locked === true,
153
+ to: on
154
+ }), [
155
+ "Lock",
156
+ "Unlock",
157
+ "Lock Only"
158
+ ]),
159
+ ...rename ? { onRename: (id, to) => {
160
+ const node = scene.get(asNodeId(id));
161
+ if (node) commit([createSetDataOp({
162
+ id,
163
+ from: node.data,
164
+ to: rename(node, to)
165
+ })], "Rename");
166
+ } } : {},
167
+ ...annotations ? { onRemove: (id) => {
168
+ const node = scene.get(asNodeId(id));
169
+ if (!node || !isAnnotation(id)) return;
170
+ const siblings = node.parent === null ? scene.roots : scene.childrenOf(node.parent);
171
+ commit([createDeleteOp({
172
+ node,
173
+ index: siblings.indexOf(node.id),
174
+ label: "Delete"
175
+ })], "Delete");
176
+ if (annotations.picked === id) annotations.pick(null);
177
+ } } : {}
178
+ };
179
+ }
180
+
181
+ export { useSceneLayerList as n, ANNOTATION_LAYER_ROW as t };
182
+ //# sourceMappingURL=SceneLayerList-DCYwqZkF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SceneLayerList-DCYwqZkF.js","names":[],"sources":["../../src/components/SceneLayerList/useSceneLayerList.ts"],"sourcesContent":["import {\n asNodeId, createDeleteOp, createMoveToIndexOp, createReparentOp, createSetDataOp, createSetHiddenOp, createSetLockedOp,\n defaultCommitAdapter, dispatchApplyBatch, isAnnotationLayer, pageName, pageOfNode, pageRunOf, placedPagesOf,\n withoutPageStructure,\n} from '@weasel-js/core';\nimport type { NodeId, SelectionApi } from '@weasel-js/routing';\nimport type { Op } from '@weasel-js/history';\nimport type { Scene, SceneNode } from '@weasel-js/core';\nimport type { LayerListItem, LayerListProps } from '@weasel-js/ui/components/LayerList';\n\n/** The id prefix of an annotation layer's own row, which holds its nodes. */\nexport const ANNOTATION_LAYER_ROW = 'annotation-layer:';\n\n/** The annotation layer whose row `row` is, if it is one. */\nconst annotationLayerOf = (row: string | null): string | null =>\n row?.startsWith(ANNOTATION_LAYER_ROW) ? row.slice(ANNOTATION_LAYER_ROW.length) : null;\n\n/** How a {@link useSceneLayerList} list shows annotation layers. */\nexport interface SceneLayerListAnnotations {\n /** The picked annotation node, which reads as a selected row. */\n picked: string | null;\n /** Selecting an annotation row picks it; the content selection stays. */\n pick(id: string | null): void;\n /** The row label for annotation layer `layer`. Default: its id. */\n labelOf?(layer: string): string;\n}\n\n/** Arguments for {@link useSceneLayerList}. */\nexport interface UseSceneLayerListOptions<TData, TLayer extends string, TPose> {\n scene: Scene<TData, TLayer, TPose>;\n selection: SelectionApi;\n /** What the reorder op is dispatched against. Default: the scene itself, as one history entry. */\n adapter?: object;\n /** A row's content for a node: its label, a leading swatch or icon. Its\n * `visible` and `locked` come from the node's own flags. */\n itemFor: (node: SceneNode<TData, TLayer, TPose>) => Omit<LayerListItem, 'id' | 'children'>;\n /** The data a rename to `label` writes, which makes rows renamable. The\n * scene has no name of its own, so where one lives is the consumer's call. */\n rename?: (node: SceneNode<TData, TLayer, TPose>, label: string) => TData;\n /** Label of the reorder's history entry. Default `'Reorder'`. */\n label?: string;\n /** Given, each annotation layer (`isAnnotationLayer`) gets a row holding its\n * nodes, marked not printed: the layer can be hidden and locked, its nodes\n * picked and removed. Absent, annotations are left out of the list — the canvas still\n * draws them. */\n annotations?: SceneLayerListAnnotations;\n}\n\n/** Commits a toggle's `changes` as one history entry. An annotation layer's row toggles the layer through\n * `layerTo`, since a layer is no node and has no op. */\nfunction commitToggle<TLayer extends string>(\n commit: (ops: Op[], entry: string) => void,\n changes: Readonly<Record<string, boolean>>,\n layerTo: (layer: TLayer, on: boolean) => void,\n opOf: (id: string, on: boolean) => Op,\n [on, off, mixed]: readonly [string, string, string],\n): void {\n const ops = Object.entries(changes).flatMap(([id, to]) => {\n if (!id.startsWith(ANNOTATION_LAYER_ROW)) return [opOf(id, to)];\n layerTo(id.slice(ANNOTATION_LAYER_ROW.length) as TLayer, to);\n return [];\n });\n if (ops.length === 0) return;\n // The entry names the direction every row went, or `mixed` for an Alt-click that went both ways.\n const values = Object.values(changes);\n commit(ops, values.every(Boolean) ? on : values.some(Boolean) ? mixed : off);\n}\n\n/**\n * How many of `shown`, the siblings under `parent` a drag left behind, lie behind a drop at gap `at` of the list's\n * top level, where the page run's children are listed beside the other roots. A sibling is behind when its front-most\n * row there is at or past the gap; the run, whose rows are its children's, counts by the first of them.\n */\nfunction behindTopGap(\n childrenOf: (id: NodeId) => readonly NodeId[],\n roots: readonly NodeId[],\n run: NodeId | null,\n moved: ReadonlySet<string>,\n parent: string | null,\n shown: readonly NodeId[],\n at: number,\n): number {\n const owners: (NodeId | undefined)[] = [];\n for (const root of [...roots].reverse()) {\n if (root !== run) {\n if (!moved.has(root)) owners.push(parent === null ? root : undefined);\n continue;\n }\n for (const kid of [...childrenOf(root)].reverse()) {\n if (!moved.has(kid)) owners.push(parent === null ? root : parent === run ? kid : undefined);\n }\n }\n return shown.filter((id) => {\n const first = owners.indexOf(id);\n return first < 0 || first >= at;\n }).length;\n}\n\n/** The `<LayerList>` props `useSceneLayerList` answers. */\nexport type SceneLayerListProps = Required<Pick<LayerListProps, 'items' | 'selectedIds' | 'onSelectionChange' | 'onReorder' | 'canMove' | 'onVisibilityChange' | 'onLockChange'>>\n & Pick<LayerListProps, 'onRemove' | 'onRename'>;\n\n/**\n * The props that put a scene in a `<LayerList>`: a row per node, a container's\n * children nested under it, the front-most at the top, selection read from and\n * written to `selection`, a drag — among siblings or into another container —\n * dispatched as a `MoveToIndexOp`, and each row's visibility and lock toggling\n * the node's own (`setHidden` / `setLocked` ops), each click one undo step, an Alt-click's batch included.\n * Annotation layers are left out unless `annotations` says how to show them;\n * shown, an annotation moves only within its own layer's row.\n */\nexport function useSceneLayerList<TData, TLayer extends string, TPose>(\n args: UseSceneLayerListOptions<TData, TLayer, TPose>,\n): SceneLayerListProps {\n const { scene, selection, adapter, itemFor, rename, label = 'Reorder', annotations } = args;\n const annotationLayers = scene.layers.filter(isAnnotationLayer);\n const onAnnotation = new Set<string>(annotationLayers.map((l) => l.id));\n const isAnnotation = (id: string) => {\n const layer = scene.get(asNodeId(id))?.layer;\n return layer !== undefined && onAnnotation.has(layer);\n };\n const commit = (ops: Op[], entry: string) => {\n if (adapter) dispatchApplyBatch(adapter, ops, entry);\n else scene.applyBatch(ops, entry, defaultCommitAdapter(scene, selection.adapterMethods));\n };\n\n // A scene orders children back to front and the list front to back. Rebuilt\n // every render: the scene keeps its identity across a reorder, so a memo keyed\n // on it would serve the order from before. The page run lists as what it holds,\n // and a page as a fixed row of what is on it: pages are edited through the page API.\n const run = pageRunOf(scene);\n const pages = new Map(placedPagesOf(scene).map((page) => [page.id, page]));\n const build = (ids: readonly NodeId[], extra: Partial<LayerListItem>): LayerListItem[] =>\n [...ids].reverse().flatMap((id) => {\n const node = scene.get(id);\n if (!node) return [];\n const kids = scene.childrenOf(id);\n if (id === run) return build(kids, extra);\n const children = kids.length > 0 ? { children: build(kids, extra) } : {};\n const page = node.page === undefined ? undefined : pages.get(pageOfNode(scene, id)!);\n if (page !== undefined) return [{ id, label: pageName(page, page.index), fixed: true, ...children }];\n return [{\n ...itemFor(node), ...extra, id, visible: node.hidden !== true, locked: node.locked === true, ...children,\n }];\n });\n\n // The list's top level holds the run's children and the scene's own roots alike. A drag that stays there\n // keeps its parent; one brought up from inside a container goes to the run, or with the pasteboard on, the root.\n const topParent = (ids: readonly string[]): NodeId | null => {\n const from = scene.get(asNodeId(ids[0]!))?.parent ?? null;\n if (from === null || from === run) return from;\n if (run === null) return null;\n return scene.get(run)!.pageRun!.pasteboard === true ? null : run;\n };\n\n const content = build(scene.roots.filter((id) => !isAnnotation(id)), annotations ? { removable: false } : {});\n const annotationRows: LayerListItem[] = annotations\n ? [...annotationLayers].reverse().map((layer) => ({\n id: `${ANNOTATION_LAYER_ROW}${layer.id}`,\n label: annotations.labelOf?.(layer.id) ?? layer.id,\n nonPrinting: true,\n visible: layer.visible,\n locked: layer.locked,\n removable: false,\n renamable: false,\n children: build(scene.roots.filter((id) => scene.get(id)?.layer === layer.id), { nonPrinting: true }),\n }))\n : [];\n const picked = annotations?.picked ?? null;\n\n return {\n items: [...annotationRows, ...content],\n selectedIds: [...selection.current.map(String), ...(picked !== null ? [picked] : [])],\n onSelectionChange: (ids) => {\n const notes = ids.filter(isAnnotation);\n if (notes.length > 0) {\n annotations?.pick(notes.at(-1)!);\n return;\n }\n selection.set([...withoutPageStructure(scene, ids.filter((id) => !id.startsWith(ANNOTATION_LAYER_ROW)).map(asNodeId))]);\n },\n canMove: ({ ids, parentId }) => {\n if (ids.some((id) => id.startsWith(ANNOTATION_LAYER_ROW))) return false;\n const into = annotationLayerOf(parentId);\n return ids.every((id) => (isAnnotation(id) ? scene.get(asNodeId(id))?.layer === into : into === null));\n },\n onReorder: ({ ids, parentId, index }) => {\n // An annotation layer's row holds roots on that layer; it is no node of the scene.\n const layer = annotationLayerOf(parentId);\n const parent = layer !== null ? null : (parentId ?? topParent(ids));\n const moved = new Set(ids);\n const left = (parent === null ? scene.roots : scene.childrenOf(asNodeId(parent))).filter((id) => !moved.has(id));\n // `index` counts from the front among the rows the drag left behind, the annotation rows heading the top\n // level among them; the rows shown stand for the siblings of the list's own level.\n const shown = left.filter((id) => (layer !== null ? scene.get(id)?.layer === layer : !isAnnotation(id)));\n const at = parentId === null ? Math.max(0, index - annotationRows.length) : index;\n const back = parentId === null && layer === null\n ? behindTopGap((id) => scene.childrenOf(id), scene.roots.filter((id) => !isAnnotation(id)), run, moved, parent, shown, at)\n : Math.max(0, shown.length - at);\n const to = back < shown.length ? left.indexOf(shown[back]!) : shown.length > 0 ? left.indexOf(shown.at(-1)!) + 1 : left.length;\n // A node from another container joins this one first, back to front as the scene orders children.\n const joining = [...ids].reverse().flatMap((id) => {\n const from = scene.get(asNodeId(id))?.parent ?? null;\n return from === parent ? [] : [createReparentOp({ id, fromParentId: from, toParentId: parent })];\n });\n commit([...joining, createMoveToIndexOp({ ids, parentId: parent, index: to })], label);\n },\n onVisibilityChange: (changes) => commitToggle(commit, changes, (layer: TLayer, on) => scene.setLayerVisible(layer, on),\n (id, on) => createSetHiddenOp({ id, from: scene.get(asNodeId(id))?.hidden === true, to: !on }), ['Show', 'Hide', 'Show Only']),\n onLockChange: (changes) => commitToggle(commit, changes, (layer: TLayer, on) => scene.setLayerLocked(layer, on),\n (id, on) => createSetLockedOp({ id, from: scene.get(asNodeId(id))?.locked === true, to: on }), ['Lock', 'Unlock', 'Lock Only']),\n ...(rename ? {\n onRename: (id: string, to: string) => {\n const node = scene.get(asNodeId(id));\n if (node) commit([createSetDataOp({ id, from: node.data, to: rename(node, to) })], 'Rename');\n },\n } : {}),\n ...(annotations ? {\n onRemove: (id: string) => {\n const node = scene.get(asNodeId(id));\n if (!node || !isAnnotation(id)) return;\n const siblings = node.parent === null ? scene.roots : scene.childrenOf(node.parent);\n commit([createDeleteOp({ node, index: siblings.indexOf(node.id), label: 'Delete' })], 'Delete');\n if (annotations.picked === id) annotations.pick(null);\n },\n } : {}),\n };\n}\n"],"mappings":";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AAY,KAAK,IAAI;EACtD,EACF,IAAI,CAAC;CACP;AACF"}
@@ -0,0 +1,323 @@
1
+ import { useMemo, useSyncExternalStore } from "react";
2
+ import { asNodeId, nodeTraitsOf, paintAbove, routeKind, sceneSharedUnitScopes } from "@weasel-js/core";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ import { compositeKey, isDev } from "@weasel-js/registry";
5
+ import { useLatest } from "@weasel-js/react";
6
+ import { prefHoldsValue, prefLeafInScopes, prefStoredReset } from "@weasel-js/prefs";
7
+ import { PanelMarksContext, boundAt, conditionedSections, isPanelSection, kindBreakdown, nodeLeafValue, panelEntryOf, panelMarkedPaths, panelRowsOf, panelSections, panelSource, setAtPath, sharedValue } from "@weasel-js/ui/components/PanelCells";
8
+ import { PrefsSource } from "@weasel-js/ui/components/PrefsSource";
9
+ import { prefFieldChoices, useParamsPolicy, useSelectedRow } from "@weasel-js/ui/components/Prefs";
10
+ import { holdScope } from "@weasel-js/ui/components/Disabled";
11
+
12
+ // src/components/inspector/SelectionPanel/declaredFields.ts
13
+ var DECLARED = {
14
+ clip: { write: (scene, id, value) => scene.setClip(id, value ?? null) },
15
+ units: { write: (scene, id, value) => scene.setUnits(id, value ?? null) }
16
+ };
17
+ var isDeclared = (head) => head !== void 0 && Object.hasOwn(DECLARED, head);
18
+ /** The declared field a path's first segment names, if it names one. */
19
+ var declaredField = (head) => isDeclared(head) ? DECLARED[head] : void 0;
20
+ /** What `node` holds in the field a path's first segment names: `pose`, `data`, or a declared field. */
21
+ function nodeRoot(node, head) {
22
+ if (head === "pose") return node.pose;
23
+ if (head === "data") return node.data;
24
+ return isDeclared(head) ? node[head] : void 0;
25
+ }
26
+
27
+ // src/components/inspector/SelectionPanel/nodeModel.ts
28
+ /** A node's routing kind under `routing`, as a canvas given the same table names it. A
29
+ * container is `'group'` only when the table carries `groupNodeRouting`. */
30
+ function classifyKind(node, routing) {
31
+ return routeKind(routing, node.data, node);
32
+ }
33
+ /** Read a node value at a dotted path of any depth (`pose.x`,
34
+ * `data.style.fontSize`, `data.style.fill.paint.color`), or at a field the
35
+ * node declares for its children (`clip`, `units.unit`). Returns `undefined`
36
+ * for a bare `pose` or `data` (mirrors `commit`'s no-op on a malformed schema
37
+ * key) or if any intermediate segment is missing or not an object. */
38
+ function nodeValueAt(node, path) {
39
+ const segments = path.split(".");
40
+ const head = segments[0];
41
+ if (segments.length < 2 && !declaredField(head)) return void 0;
42
+ let cursor = nodeRoot(node, head);
43
+ for (let i = 1; i < segments.length; i++) {
44
+ if (cursor == null || typeof cursor !== "object" || !Object.hasOwn(cursor, segments[i])) return void 0;
45
+ cursor = cursor[segments[i]];
46
+ }
47
+ return cursor;
48
+ }
49
+ /** Aggregate a path across nodes: the shared value, or `MIXED`. A node
50
+ * holding nothing there reads as `absent`. */
51
+ function aggregateValue(nodes, path, absent) {
52
+ return sharedValue(nodes.map((node) => {
53
+ const held = nodeValueAt(node, path);
54
+ return held === void 0 ? absent : held;
55
+ }));
56
+ }
57
+
58
+ // src/components/inspector/SelectionPanel/commitLeaf.ts
59
+ var NO_SETTLE = () => void 0;
60
+ /** `node` as a panel reads it, with what an `'inherit'` paint on it takes when `paintAbove` is given and it has a
61
+ * parent. */
62
+ function nodeRecord(node, paintAbove) {
63
+ const valueAt = (path) => nodeValueAt(node, path);
64
+ return paintAbove && node.parent != null ? {
65
+ valueAt,
66
+ paintAbove: () => paintAbove(node)
67
+ } : { valueAt };
68
+ }
69
+ /** Writes, into every node of `ids`, what `next` derives from the value that node holds at the leaf's path. */
70
+ function writeLeaf(scene, ids, leaf, next, settleOf) {
71
+ const [head, ...rest] = leaf.path.split(".");
72
+ for (const id of ids) {
73
+ const node = scene.get(id);
74
+ if (!node) continue;
75
+ const held = nodeValueAt(node, leaf.path);
76
+ const value = boundAt(leaf.leaf, nodeRecord(node), next(nodeLeafValue(leaf.leaf, held)), held);
77
+ const declared = declaredField(head);
78
+ if (declared) {
79
+ const field = nodeRoot(node, head);
80
+ const to = rest.length === 0 ? value : setAtPath(field ?? {}, rest, value);
81
+ if (to !== field) declared.write(scene, id, to);
82
+ continue;
83
+ }
84
+ const prev = {
85
+ pose: node.pose,
86
+ data: node.data
87
+ };
88
+ let written = head === "pose" ? {
89
+ pose: setAtPath(node.pose, rest, value),
90
+ data: prev.data
91
+ } : head === "data" ? {
92
+ pose: prev.pose,
93
+ data: setAtPath(node.data, rest, value)
94
+ } : null;
95
+ if (written === null) continue;
96
+ const settle = settleOf(node);
97
+ if (settle) written = settle(written, prev);
98
+ if (written.pose !== prev.pose) scene.setPose(id, written.pose);
99
+ if (written.data !== prev.data) scene.update(id, { data: written.data });
100
+ }
101
+ }
102
+ var writable = (leaf) => /^(pose|data)\../.test(leaf.path) || declaredField(leaf.path.split(".")[0]) !== void 0;
103
+ var warnedUnwritable = /* @__PURE__ */ new Set();
104
+ /** Warn once per kind and path, in dev, of a value leaf that `kinds`' schemas key where no edit can land. */
105
+ function warnUnwritable(kinds, leaves) {
106
+ if (!isDev()) return;
107
+ for (const leaf of leaves) {
108
+ if (writable(leaf) || !prefHoldsValue(leaf.leaf)) continue;
109
+ for (const kind of new Set(kinds)) {
110
+ const key = `${kind}\0${leaf.path}`;
111
+ if (warnedUnwritable.has(key)) continue;
112
+ warnedUnwritable.add(key);
113
+ console.warn(`weasel: the properties schema of kind "${kind}" keys a field at "${leaf.path}", which SelectionPanel draws but cannot save. Key it under "pose." or "data." (such as "data.${leaf.path}"), or as a field a node declares ("clip", "units").`);
114
+ }
115
+ }
116
+ }
117
+ /**
118
+ * Writes, into every selected node, what `next` derives from the value that
119
+ * node holds at the leaf's path, as one labeled batch. A node whose properties
120
+ * entry has a `settle` stores what that returns.
121
+ */
122
+ function commitLeaf(scene, selection, leaf, next, settleOf = NO_SETTLE) {
123
+ if (!writable(leaf)) return;
124
+ const ids = selection.current.map(asNodeId);
125
+ scene.batch(`Edit ${leaf.leaf.name}`, () => writeLeaf(scene, ids, leaf, next, settleOf));
126
+ }
127
+ var sameHeld = (a, b) => a !== void 0 && a.pose === b.pose && a.data === b.data && a.field === b.field;
128
+ /** The writes of one panel over `scene`. Keep one per panel: it holds what the drafts in flight wrote over. */
129
+ function leafWrites(scene, settleOf = NO_SETTLE) {
130
+ const drafted = /* @__PURE__ */ new Map();
131
+ const restore = (leaf) => {
132
+ const before = drafted.get(leaf.path);
133
+ if (!before) return;
134
+ drafted.delete(leaf.path);
135
+ scene.untracked(() => {
136
+ for (const [id, held] of before) {
137
+ const node = scene.get(id);
138
+ const head = leaf.path.split(".")[0];
139
+ if (!node || !sameHeld(held.left, {
140
+ pose: node.pose,
141
+ data: node.data,
142
+ field: nodeRoot(node, head)
143
+ })) continue;
144
+ if (node.pose !== held.pose) scene.setPose(id, held.pose);
145
+ if (node.data !== held.data) scene.update(id, { data: held.data });
146
+ const field = declaredField(head);
147
+ if (field && nodeRoot(node, head) !== held.field) field.write(scene, id, held.field);
148
+ }
149
+ });
150
+ };
151
+ return {
152
+ reset: (selection, leaves, label) => {
153
+ const ids = selection.current.map(asNodeId);
154
+ const due = leaves.filter(writable);
155
+ for (const leaf of due) restore(leaf);
156
+ scene.batch(`Reset ${label}`, () => {
157
+ for (const leaf of due) writeLeaf(scene, ids, leaf, () => prefStoredReset(leaf.leaf), settleOf);
158
+ });
159
+ },
160
+ commit: (selection, leaf, next) => {
161
+ restore(leaf);
162
+ commitLeaf(scene, selection, leaf, next, settleOf);
163
+ },
164
+ draft: (selection, leaf, next) => {
165
+ if (!writable(leaf)) return;
166
+ const ids = selection.current.map(asNodeId);
167
+ const head = leaf.path.split(".")[0];
168
+ const before = drafted.get(leaf.path) ?? /* @__PURE__ */ new Map();
169
+ drafted.set(leaf.path, before);
170
+ const now = (id) => {
171
+ const node = scene.get(id);
172
+ return node ? {
173
+ pose: node.pose,
174
+ data: node.data,
175
+ field: nodeRoot(node, head)
176
+ } : null;
177
+ };
178
+ for (const id of ids) {
179
+ const at = now(id);
180
+ const held = before.get(id);
181
+ if (at && (!held || !sameHeld(held.left, at))) before.set(id, at);
182
+ }
183
+ scene.untracked(() => writeLeaf(scene, ids, leaf, next, settleOf));
184
+ for (const id of ids) {
185
+ const held = before.get(id);
186
+ const at = now(id);
187
+ if (held && at) held.left = at;
188
+ }
189
+ }
190
+ };
191
+ }
192
+
193
+ // src/components/inspector/SelectionPanel/scopes.ts
194
+ /** `sections` with every leaf read where `nodes` sit under `root`: the scopes they share. */
195
+ function sectionsInScopes(sections, scene, nodes, root) {
196
+ if (!root || nodes.length === 0) return sections;
197
+ const chain = sceneSharedUnitScopes(scene, nodes.map((n) => asNodeId(n.id)), root);
198
+ const within = (item) => isPanelSection(item) ? {
199
+ ...item,
200
+ items: item.items.map(within)
201
+ } : {
202
+ ...item,
203
+ leaves: item.leaves.map((l) => ({
204
+ ...l,
205
+ leaf: prefLeafInScopes(l.leaf, chain)
206
+ }))
207
+ };
208
+ return sections.map((section) => within(section));
209
+ }
210
+
211
+ // src/components/inspector/SelectionPanel/SelectionPanel.module.css
212
+ var root = "_root_b9d690";
213
+ var header = "_header_b9d690";
214
+ var kind = "_kind_b9d690";
215
+ var breakdown = "_breakdown_b9d690";
216
+ var SelectionPanel_module_default = {
217
+ root,
218
+ header,
219
+ kind,
220
+ breakdown
221
+ };
222
+
223
+ // src/components/inspector/SelectionPanel/SelectionPanel.tsx
224
+ var NO_MARKS = [];
225
+ var defaultKindLabel = (kind) => kind.length === 0 ? kind : kind[0].toUpperCase() + kind.slice(1);
226
+ /**
227
+ * Pre-baked selection properties panel. Shows the selected nodes' kind
228
+ * and the properties-trait schema for that kind; multi-selections show
229
+ * the intersection of the kinds' schemas with per-field Mixed state.
230
+ * Edits commit as one labeled `scene.batch` fan-out per gesture.
231
+ */
232
+ function SelectionPanel(props) {
233
+ const { scene, selection, renderers, kindLabel = defaultKindLabel, emptyState = null, className } = props;
234
+ useSyncExternalStore(scene.subscribe, scene.getVersion, scene.getVersion);
235
+ const { properties, routing } = useMemo(() => nodeTraitsOf(props.features, {
236
+ routing: props.routing,
237
+ properties: props.properties
238
+ }), [
239
+ props.features,
240
+ props.routing,
241
+ props.properties
242
+ ]);
243
+ const traits = useLatest({
244
+ properties,
245
+ routing
246
+ });
247
+ const writes = useMemo(() => leafWrites(scene, (node) => panelEntryOf(traits.current.properties, classifyKind(node, traits.current.routing))?.settle), [scene, traits]);
248
+ const nodes = selection.current.map((id) => scene.get(asNodeId(id))).filter((n) => n != null);
249
+ const kinds = nodes.map((n) => classifyKind(n, routing));
250
+ const records = nodes.map((n) => nodeRecord(n, (node) => paintAbove(scene, node)));
251
+ const selectionKey = compositeKey(nodes.map((n) => n.id));
252
+ const scope = conditionedSections(kinds, properties, records, renderers?.alias !== void 0, props.markHidden === true, props.over);
253
+ const sections = sectionsInScopes(scope.sections, scene, nodes, props.units);
254
+ const panelLeaves = sections.flatMap(panelRowsOf).flatMap((row) => row.leaves);
255
+ warnUnwritable(kinds, panelLeaves);
256
+ const leaves = new Map(panelLeaves.map(({ path, leaf }) => [path, leaf]));
257
+ const fields = prefFieldChoices({
258
+ name: "",
259
+ members: Object.fromEntries(leaves)
260
+ });
261
+ const shown = panelMarkedPaths(sections, props.selected ?? NO_MARKS, renderers);
262
+ const marks = {
263
+ selected: shown,
264
+ lead: shown.at(-1) ?? null,
265
+ ...props.markHidden ? { hidden: scope.hidden } : {}
266
+ };
267
+ const rowSelection = useSelectedRow(props.selected ?? NO_MARKS, marks.lead ?? null, props.onSelect);
268
+ const { settles, textWaitMs } = useParamsPolicy("panel");
269
+ if (nodes.length === 0) return /* @__PURE__ */ jsx("div", {
270
+ className: [SelectionPanel_module_default.root, className].filter(Boolean).join(" "),
271
+ children: emptyState
272
+ });
273
+ const cells = {
274
+ records,
275
+ renderers,
276
+ commit: (leaf, next) => writes.commit(selection, leaf, next),
277
+ draft: (leaf, next) => writes.draft(selection, leaf, next),
278
+ source: panelSource({
279
+ records,
280
+ leaves: panelLeaves,
281
+ selection,
282
+ writes,
283
+ disabled: scope.disabled,
284
+ hidden: scope.hidden,
285
+ active: scope.active
286
+ }),
287
+ selectionKey,
288
+ fields,
289
+ disabled: scope.disabled,
290
+ active: scope.active,
291
+ hidden: scope.hidden,
292
+ entryAt: scope.entryAt,
293
+ targets: scope.targets,
294
+ settles,
295
+ textWaitMs
296
+ };
297
+ return /* @__PURE__ */ jsx(PrefsSource, {
298
+ source: cells.source,
299
+ children: /* @__PURE__ */ jsx(PanelMarksContext.Provider, {
300
+ value: marks,
301
+ children: /* @__PURE__ */ jsxs("div", {
302
+ className: [SelectionPanel_module_default.root, className].filter(Boolean).join(" "),
303
+ ...rowSelection,
304
+ children: [/* @__PURE__ */ jsx("header", {
305
+ className: SelectionPanel_module_default.header,
306
+ children: nodes.length === 1 ? /* @__PURE__ */ jsx("span", {
307
+ className: SelectionPanel_module_default.kind,
308
+ children: kindLabel(kinds[0])
309
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("span", {
310
+ className: SelectionPanel_module_default.kind,
311
+ children: [nodes.length, " selected"]
312
+ }), /* @__PURE__ */ jsx("span", {
313
+ className: SelectionPanel_module_default.breakdown,
314
+ children: kindBreakdown(kinds)
315
+ })] })
316
+ }), holdScope(props, panelSections(sections, cells, marks))]
317
+ })
318
+ })
319
+ });
320
+ }
321
+
322
+ export { nodeValueAt as i, aggregateValue as n, classifyKind as r, SelectionPanel as t };
323
+ //# sourceMappingURL=SelectionPanel-n-dIMvQ2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectionPanel-n-dIMvQ2.js","names":["s","_Fragment"],"sources":["../../src/components/inspector/SelectionPanel/declaredFields.ts","../../src/components/inspector/SelectionPanel/nodeModel.ts","../../src/components/inspector/SelectionPanel/commitLeaf.ts","../../src/components/inspector/SelectionPanel/scopes.ts","../../src/components/inspector/SelectionPanel/SelectionPanel.module.css","../../src/components/inspector/SelectionPanel/SelectionPanel.tsx"],"sourcesContent":["import type { NodeId } from '@weasel-js/routing';\nimport type { NodeClip, SceneNode } from '@weasel-js/core';\nimport type { UnitScope } from '@weasel-js/quantity';\n\n/** The scene methods that record a declared field. */\ninterface DeclaredWrites {\n setClip(id: NodeId, clip: NodeClip | null): void;\n setUnits(id: NodeId, units: UnitScope | null): void;\n}\n\n/** A node's field that a schema key can name outright: what the node declares for its children, stored\n * beside `pose` and `data` and written through the scene method that records it. */\ninterface DeclaredField {\n write(scene: DeclaredWrites, id: NodeId, value: unknown): void;\n}\n\nconst DECLARED = {\n clip: { write: (scene, id, value) => scene.setClip(id, (value ?? null) as NodeClip | null) },\n units: { write: (scene, id, value) => scene.setUnits(id, (value ?? null) as UnitScope | null) },\n} as const satisfies Readonly<Record<string, DeclaredField>>;\n\nconst isDeclared = (head: string | undefined): head is keyof typeof DECLARED => head !== undefined && Object.hasOwn(DECLARED, head);\n\n/** The declared field a path's first segment names, if it names one. */\nexport const declaredField = (head: string | undefined): DeclaredField | undefined =>\n isDeclared(head) ? DECLARED[head] : undefined;\n\n/** What `node` holds in the field a path's first segment names: `pose`, `data`, or a declared field. */\nexport function nodeRoot(node: SceneNode<unknown, string, unknown>, head: string | undefined): unknown {\n if (head === 'pose') return node.pose;\n if (head === 'data') return node.data;\n return isDeclared(head) ? (node as unknown as Record<keyof typeof DECLARED, unknown>)[head] : undefined;\n}\n","// Scene nodes as panel records: a node's kind, and its value at a leaf's path.\n\nimport { routeKind, type AnyNode, type NodeRoutingEntry } from '@weasel-js/core';\nimport { sharedValue, type Mixed } from '@weasel-js/ui/components/PanelCells';\nimport { declaredField, nodeRoot } from './declaredFields';\n\n/** A scene node of any data, layer, and pose. */\nexport type { AnyNode };\n\n/** A node's routing kind under `routing`, as a canvas given the same table names it. A\n * container is `'group'` only when the table carries `groupNodeRouting`. */\nexport function classifyKind(\n node: AnyNode,\n routing: readonly NodeRoutingEntry[],\n): string {\n return routeKind(routing, node.data, node);\n}\n\n/** Read a node value at a dotted path of any depth (`pose.x`,\n * `data.style.fontSize`, `data.style.fill.paint.color`), or at a field the\n * node declares for its children (`clip`, `units.unit`). Returns `undefined`\n * for a bare `pose` or `data` (mirrors `commit`'s no-op on a malformed schema\n * key) or if any intermediate segment is missing or not an object. */\nexport function nodeValueAt(node: AnyNode, path: string): unknown {\n const segments = path.split('.');\n const head = segments[0];\n if (segments.length < 2 && !declaredField(head)) return undefined;\n let cursor: unknown = nodeRoot(node, head);\n for (let i = 1; i < segments.length; i++) {\n if (cursor == null || typeof cursor !== 'object' || !Object.hasOwn(cursor, segments[i]!)) return undefined;\n cursor = (cursor as Record<string, unknown>)[segments[i]!];\n }\n return cursor;\n}\n\n/** Aggregate a path across nodes: the shared value, or `MIXED`. A node\n * holding nothing there reads as `absent`. */\nexport function aggregateValue(\n nodes: readonly AnyNode[],\n path: string,\n absent?: unknown,\n): unknown | Mixed {\n return sharedValue(\n nodes.map((node) => {\n const held = nodeValueAt(node, path);\n return held === undefined ? absent : held;\n }),\n );\n}\n","import type { NodeId, SelectionApi } from '@weasel-js/routing';\nimport { asNodeId, type NodePropertiesEntry, type Scene } from '@weasel-js/core';\nimport { prefHoldsValue, prefStoredReset } from '@weasel-js/prefs';\nimport { isDev } from '@weasel-js/registry';\nimport { boundAt } from '@weasel-js/ui/components/PanelCells';\nimport { declaredField, nodeRoot } from './declaredFields';\nimport { nodeLeafValue, setAtPath, type PanelLeaf, type PanelPaintAbove, type PanelRecord } from '@weasel-js/ui/components/PanelCells';\nimport { nodeValueAt, type AnyNode } from './nodeModel';\nimport type { LeafWrites } from '@weasel-js/ui/components/PanelCells';\n\ntype Next = (prev: unknown) => unknown;\n\n/** The `settle` of the properties entry a node is edited under, if it has one. */\nexport type SettleOf = (node: AnyNode) => NodePropertiesEntry['settle'];\n\nconst NO_SETTLE: SettleOf = () => undefined;\n\n/** `node` as a panel reads it, with what an `'inherit'` paint on it takes when `paintAbove` is given and it has a\n * parent. */\nexport function nodeRecord(node: AnyNode, paintAbove?: (node: AnyNode) => PanelPaintAbove): PanelRecord {\n const valueAt = (path: string): unknown => nodeValueAt(node, path);\n return paintAbove && node.parent != null ? { valueAt, paintAbove: () => paintAbove(node) } : { valueAt };\n}\n\n/** Writes, into every node of `ids`, what `next` derives from the value that node holds at the leaf's path. */\nfunction writeLeaf<TData, TLayer extends string, TPose>(\n scene: Scene<TData, TLayer, TPose>,\n ids: readonly NodeId[],\n leaf: PanelLeaf,\n next: Next,\n settleOf: SettleOf,\n): void {\n const [head, ...rest] = leaf.path.split('.');\n for (const id of ids) {\n const node = scene.get(id);\n if (!node) continue;\n const held = nodeValueAt(node as AnyNode, leaf.path);\n const value = boundAt(leaf.leaf, nodeRecord(node as AnyNode), next(nodeLeafValue(leaf.leaf, held)), held);\n const declared = declaredField(head);\n if (declared) {\n const field = nodeRoot(node as AnyNode, head);\n const to = rest.length === 0 ? value : setAtPath((field ?? {}) as object, rest, value);\n if (to !== field) declared.write(scene, id, to);\n continue;\n }\n // `setAtPath` spreads plain objects/arrays down the schema path;\n // consumer `pose`/`data` are assumed plain-object-shaped along\n // that path (a class instance's prototype would be dropped by\n // the spread) — the `as TPose`/`as TData` casts below rely on it.\n const prev = { pose: node.pose as unknown, data: node.data as unknown };\n let written = head === 'pose'\n ? { pose: setAtPath(node.pose as object, rest, value) as unknown, data: prev.data }\n : head === 'data'\n ? { pose: prev.pose, data: setAtPath(node.data as object, rest, value) as unknown }\n : null;\n if (written === null) continue;\n const settle = settleOf(node as AnyNode);\n if (settle) written = settle(written, prev);\n if (written.pose !== prev.pose) scene.setPose(id, written.pose as TPose);\n if (written.data !== prev.data) scene.update(id, { data: written.data as TData });\n }\n}\n\nconst writable = (leaf: PanelLeaf): boolean =>\n /^(pose|data)\\../.test(leaf.path) || declaredField(leaf.path.split('.')[0]) !== undefined;\n\nconst warnedUnwritable = new Set<string>();\n\n/** Warn once per kind and path, in dev, of a value leaf that `kinds`' schemas key where no edit can land. */\nexport function warnUnwritable(kinds: readonly string[], leaves: readonly PanelLeaf[]): void {\n if (!isDev()) return;\n for (const leaf of leaves) {\n if (writable(leaf) || !prefHoldsValue(leaf.leaf)) continue;\n for (const kind of new Set(kinds)) {\n const key = `${kind}\\0${leaf.path}`;\n if (warnedUnwritable.has(key)) continue;\n warnedUnwritable.add(key);\n console.warn(`weasel: the properties schema of kind \"${kind}\" keys a field at \"${leaf.path}\", which SelectionPanel draws but cannot save. Key it under \"pose.\" or \"data.\" (such as \"data.${leaf.path}\"), or as a field a node declares (\"clip\", \"units\").`);\n }\n }\n}\n\n/**\n * Writes, into every selected node, what `next` derives from the value that\n * node holds at the leaf's path, as one labeled batch. A node whose properties\n * entry has a `settle` stores what that returns.\n */\nexport function commitLeaf<TData, TLayer extends string, TPose>(\n scene: Scene<TData, TLayer, TPose>,\n selection: Pick<SelectionApi, 'current'>,\n leaf: PanelLeaf,\n next: Next,\n settleOf: SettleOf = NO_SETTLE,\n): void {\n if (!writable(leaf)) return;\n const ids = selection.current.map(asNodeId);\n scene.batch(`Edit ${leaf.leaf.name}`, () => writeLeaf(scene, ids, leaf, next, settleOf));\n}\n\n/** What a node held before a draft wrote over it, and what the last draft left it holding. */\ninterface Held { pose: unknown; data: unknown; field: unknown; left?: Omit<Held, 'left'> }\n\nconst sameHeld = (a: Omit<Held, 'left'> | undefined, b: Omit<Held, 'left'>): boolean =>\n a !== undefined && a.pose === b.pose && a.data === b.data && a.field === b.field;\n\n/** The writes of one panel over `scene`. Keep one per panel: it holds what the drafts in flight wrote over. */\nexport function leafWrites<TData, TLayer extends string, TPose>(\n scene: Scene<TData, TLayer, TPose>,\n settleOf: SettleOf = NO_SETTLE,\n): LeafWrites {\n // By leaf path: the pose, data and declared field each node held before the first draft of the edit in flight.\n const drafted = new Map<string, Map<NodeId, Held>>();\n\n const restore = (leaf: PanelLeaf): void => {\n const before = drafted.get(leaf.path);\n if (!before) return;\n drafted.delete(leaf.path);\n scene.untracked(() => {\n for (const [id, held] of before) {\n const node = scene.get(id);\n const head = leaf.path.split('.')[0];\n // Only a draft still in flight is put back: a node changed since the last draft left it keeps that change.\n if (!node || !sameHeld(held.left, { pose: node.pose, data: node.data, field: nodeRoot(node as AnyNode, head) })) continue;\n if (node.pose !== held.pose) scene.setPose(id, held.pose as TPose);\n if (node.data !== held.data) scene.update(id, { data: held.data as TData });\n const field = declaredField(head);\n if (field && nodeRoot(node as AnyNode, head) !== held.field) field.write(scene, id, held.field);\n }\n });\n };\n\n return {\n reset: (selection, leaves, label) => {\n const ids = selection.current.map(asNodeId);\n const due = leaves.filter(writable);\n for (const leaf of due) restore(leaf);\n scene.batch(`Reset ${label}`, () => {\n for (const leaf of due) writeLeaf(scene, ids, leaf, () => prefStoredReset(leaf.leaf), settleOf);\n });\n },\n commit: (selection, leaf, next) => {\n // A batch records a write from what the document holds, so the drafts come out first.\n restore(leaf);\n commitLeaf(scene, selection, leaf, next, settleOf);\n },\n draft: (selection, leaf, next) => {\n if (!writable(leaf)) return;\n const ids = selection.current.map(asNodeId);\n const head = leaf.path.split('.')[0];\n const before = drafted.get(leaf.path) ?? new Map<NodeId, Held>();\n drafted.set(leaf.path, before);\n const now = (id: NodeId): Omit<Held, 'left'> | null => {\n const node = scene.get(id);\n return node ? { pose: node.pose, data: node.data, field: nodeRoot(node as AnyNode, head) } : null;\n };\n for (const id of ids) {\n const at = now(id);\n const held = before.get(id);\n // A node changed since the last draft left it starts an edit of its own: an edit that never committed\n // (a slider dragged back where it began fires no change) must not put back what it held before that.\n if (at && (!held || !sameHeld(held.left, at))) before.set(id, at);\n }\n scene.untracked(() => writeLeaf(scene, ids, leaf, next, settleOf));\n for (const id of ids) {\n const held = before.get(id);\n const at = now(id);\n if (held && at) held.left = at;\n }\n },\n };\n}\n","import type { UnitScope } from '@weasel-js/quantity';\nimport { asNodeId, sceneSharedUnitScopes, type ScopedScene } from '@weasel-js/core';\nimport { prefLeafInScopes } from '@weasel-js/prefs';\nimport { isPanelSection, type PanelItem, type PanelSection } from '@weasel-js/ui/components/PanelCells';\nimport type { AnyNode } from './nodeModel';\n\n/** `sections` with every leaf read where `nodes` sit under `root`: the scopes they share. */\nexport function sectionsInScopes(\n sections: PanelSection[], scene: ScopedScene, nodes: readonly AnyNode[], root: UnitScope | undefined,\n): PanelSection[] {\n if (!root || nodes.length === 0) return sections;\n const chain = sceneSharedUnitScopes(scene, nodes.map((n) => asNodeId(n.id)), root);\n const within = (item: PanelItem): PanelItem =>\n isPanelSection(item)\n ? { ...item, items: item.items.map(within) }\n : { ...item, leaves: item.leaves.map((l) => ({ ...l, leaf: prefLeafInScopes(l.leaf, chain) })) };\n return sections.map((section) => within(section) as PanelSection);\n}\n","/* A field's text is set at its row label's size. */\n.root {\n display: flex;\n flex-direction: column;\n font-size: var(--wzl-params-text-size, var(--wzl-font-size-sm));\n color: var(--wzl-fg);\n --wzl-field-font-size: var(--wzl-params-text-size, var(--wzl-font-size-sm));\n}\n\n.header {\n display: flex;\n align-items: baseline;\n gap: var(--wzl-space-4);\n padding: var(--wzl-space-4) 0;\n border-block-end: 1px solid var(--wzl-border);\n}\n\n.kind {\n font-weight: var(--wzl-font-weight-bold);\n font-size: var(--wzl-font-size);\n}\n\n.breakdown {\n font-size: var(--wzl-font-size-sm);\n opacity: 0.6;\n}\n","import { useMemo, useSyncExternalStore, type ReactNode } from 'react';\nimport type { SelectionApi } from '@weasel-js/routing';\nimport type { UnitScope } from '@weasel-js/quantity';\nimport { useLatest } from '@weasel-js/react';\nimport {\n asNodeId,\n nodeTraitsOf,\n paintAbove,\n type FeaturePreset,\n type NodePropertiesEntry,\n type NodeRoutingEntry,\n type Scene,\n} from '@weasel-js/core';\nimport { leafWrites, nodeRecord, warnUnwritable } from './commitLeaf';\nimport { panelSource } from '@weasel-js/ui/components/PanelCells';\nimport { PrefsSource } from '@weasel-js/ui/components/PrefsSource';\nimport type { LeafRenderer } from '@weasel-js/ui/components/PanelCells';\nimport { kindBreakdown, panelEntryOf, panelRowsOf } from '@weasel-js/ui/components/PanelCells';\nimport { classifyKind, type AnyNode } from './nodeModel';\nimport type { PrefGroup, PrefSection } from '@weasel-js/prefs';\nimport { conditionedSections } from '@weasel-js/ui/components/PanelCells';\nimport type { MarkHiddenProps } from '@weasel-js/ui/components/Prefs';\nimport { prefFieldChoices } from '@weasel-js/ui/components/Prefs';\nimport { useSelectedRow, type PrefSelectHow } from '@weasel-js/ui/components/Prefs';\nimport { useParamsPolicy } from '@weasel-js/ui/components/Prefs';\nimport type { PanelCellScope } from '@weasel-js/ui/components/PanelCells';\nimport { panelSections } from '@weasel-js/ui/components/PanelCells';\nimport { sectionsInScopes } from './scopes';\nimport { PanelMarksContext, panelMarkedPaths, type PanelMarks } from '@weasel-js/ui/components/PanelCells';\nimport s from './SelectionPanel.module.css';\nimport { holdScope, type HoldProps } from '@weasel-js/ui/components/Disabled';\nimport { compositeKey } from '@weasel-js/registry';\n\n\n\n/** Props for {@link SelectionPanel}. */\nexport interface SelectionPanelProps<TData, TLayer extends string, TPose> extends MarkHiddenProps, HoldProps {\n /** The scene handle (`useScene`). The panel subscribes itself, so it\n * re-renders on scene mutations regardless of parent renders. */\n scene: Scene<TData, TLayer, TPose>;\n /** Selection handle (`useSelection`): the nodes the panel edits. Only `current` is read. */\n selection: Pick<SelectionApi, 'current'>;\n /** The presets the canvas runs (`<SceneCanvas features>`): the routing and\n * properties their node kinds bring are read from them, ahead of\n * `routing` and `properties`, as `nodeTraitsOf` merges them. */\n features?: readonly FeaturePreset[];\n /** Properties-trait entries, e.g. core's `defaultNodeProperties` /\n * `inferredNodeProperties` (+ consumer extras). A later entry of a name\n * replaces an earlier one. Default `inferredNodeProperties`. Memoize or hoist. */\n properties?: readonly NodePropertiesEntry[];\n /** Routing-trait classifiers used to derive each node's kind — pass\n * the same list the canvas's `routing` prop takes. Default\n * `inferredNodeRouting`, as on the canvas. Memoize or hoist. */\n routing?: readonly NodeRoutingEntry[];\n /** Control overrides / app-defined kinds (PrefsForm-style). Keys are\n * leaf paths (`data.fill`, checked first) or leaf kinds (`color`).\n * A renderer returning `null` collapses its leaf (and the row, when\n * every leaf in it collapses). */\n renderers?: Record<string, LeafRenderer>;\n /**\n * The schema the properties schemas' `alias` leaves point into. Default:\n * each kind's own. A panel drawn from layouts of aliases into another\n * schema passes that other: each alias row is drawn as the leaf of it at\n * the alias's path, reads that path of every selected node and writes\n * there, and is hidden and disabled by that leaf's conditions as well as\n * its own. A `PrefGroup`'s keys are steps of the node path (`data`, then\n * `fill`); a `PrefSection`'s leaf keys are whole node paths. A condition\n * of a kind's own schema may read a setting of that one too: a path no\n * leaf of the kind holds is read there, as the panel reads a leaf of its\n * own: a node holding nothing at the path reads as the leaf's default\n * only where the leaf is `absentIsDefault`.\n */\n over?: PrefGroup | PrefSection;\n /** The scene's outermost unit scope. Given, a field whose leaf measures a\n * length shows it in the unit scopes the selected nodes share, through\n * `prefLeafInScopes`; what is typed is still stored in world units. */\n units?: UnitScope;\n /** Kind → header label. Default: capitalized kind name. */\n kindLabel?: (kind: string) => string;\n /** Rendered when the selection is empty. */\n emptyState?: ReactNode;\n /**\n * What to mark: a leaf by its key in the schema (`data.fill`), a field of\n * an object leaf under its leaf's (`data.stroke.width`), and a top-level\n * section drawn under a heading, as a tab, or as a panel by its own key.\n * Leaves a `pair` draws in one row share its mark.\n * Each time the last one changes the panel brings it into view, opening\n * the tab that holds it. A path the panel draws no row for marks the row\n * it lies inside, or nothing.\n */\n selected?: readonly string[];\n /** The reader pressed or focused into a row, reported as `selected` names\n * it: a paired row as its first leaf, and a section's heading, tab, or\n * panel as the section's key. `how.toggle` is true when Cmd or Ctrl was\n * held. A press on one of several marked rows is reported on its click. */\n onSelect?: (path: string, how: PrefSelectHow) => void;\n className?: string;\n}\n\nconst NO_MARKS: readonly string[] = [];\n\nconst defaultKindLabel = (kind: string): string =>\n kind.length === 0 ? kind : kind[0].toUpperCase() + kind.slice(1);\n\n/**\n * Pre-baked selection properties panel. Shows the selected nodes' kind\n * and the properties-trait schema for that kind; multi-selections show\n * the intersection of the kinds' schemas with per-field Mixed state.\n * Edits commit as one labeled `scene.batch` fan-out per gesture.\n */\nexport function SelectionPanel<TData, TLayer extends string, TPose>(\n props: SelectionPanelProps<TData, TLayer, TPose>,\n) {\n const {\n scene,\n selection,\n renderers,\n kindLabel = defaultKindLabel,\n emptyState = null,\n className,\n } = props;\n\n useSyncExternalStore(scene.subscribe, scene.getVersion, scene.getVersion);\n const { properties, routing } = useMemo(\n () => nodeTraitsOf(props.features, { routing: props.routing, properties: props.properties }),\n [props.features, props.routing, props.properties],\n );\n const traits = useLatest({ properties, routing });\n const writes = useMemo(\n () => leafWrites(scene, (node) =>\n panelEntryOf(traits.current.properties, classifyKind(node, traits.current.routing))?.settle),\n [scene, traits],\n );\n\n const nodes = selection.current\n .map((id) => scene.get(asNodeId(id)))\n .filter((n): n is NonNullable<typeof n> => n != null) as readonly AnyNode[];\n\n const kinds = nodes.map((n) => classifyKind(n, routing));\n const records = nodes.map((n) => nodeRecord(n, (node) => paintAbove(scene, node as never)));\n const selectionKey = compositeKey(nodes.map((n) => n.id));\n const scope = conditionedSections(kinds, properties, records, renderers?.alias !== undefined, props.markHidden === true, props.over);\n const sections = sectionsInScopes(scope.sections, scene, nodes, props.units);\n const panelLeaves = sections.flatMap(panelRowsOf).flatMap((row) => row.leaves);\n warnUnwritable(kinds, panelLeaves);\n const leaves = new Map(panelLeaves.map(({ path, leaf }) => [path, leaf] as const));\n const fields = prefFieldChoices({ name: '', members: Object.fromEntries(leaves) });\n const shown = panelMarkedPaths(sections, props.selected ?? NO_MARKS, renderers);\n const marks: PanelMarks = { selected: shown, lead: shown.at(-1) ?? null, ...(props.markHidden ? { hidden: scope.hidden } : {}) };\n const rowSelection = useSelectedRow(props.selected ?? NO_MARKS, marks.lead ?? null, props.onSelect);\n const { settles, textWaitMs } = useParamsPolicy('panel');\n\n if (nodes.length === 0) {\n return <div className={[s.root, className].filter(Boolean).join(' ')}>{emptyState}</div>;\n }\n\n const cells: PanelCellScope = {\n records,\n renderers,\n commit: (leaf, next) => writes.commit(selection, leaf, next),\n draft: (leaf, next) => writes.draft(selection, leaf, next),\n source: panelSource({\n records,\n leaves: panelLeaves,\n selection,\n writes,\n disabled: scope.disabled,\n hidden: scope.hidden,\n active: scope.active,\n }),\n selectionKey,\n fields,\n disabled: scope.disabled,\n active: scope.active,\n hidden: scope.hidden,\n entryAt: scope.entryAt,\n targets: scope.targets,\n settles,\n textWaitMs,\n };\n\n return (\n <PrefsSource source={cells.source}>\n <PanelMarksContext.Provider value={marks}>\n <div className={[s.root, className].filter(Boolean).join(' ')} {...rowSelection}>\n <header className={s.header}>\n {nodes.length === 1 ? (\n <span className={s.kind}>{kindLabel(kinds[0])}</span>\n ) : (\n <>\n <span className={s.kind}>{nodes.length} selected</span>\n <span className={s.breakdown}>{kindBreakdown(kinds)}</span>\n </>\n )}\n </header>\n {holdScope(props, panelSections(sections, cells, marks))}\n </div>\n </PanelMarksContext.Provider>\n </PrefsSource>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAgBA,IAAM,WAAW;CACf,MAAM,EAAE,QAAQ,OAAO,IAAI,UAAU,MAAM,QAAQ,IAAK,SAAS,IAAwB,EAAE;CAC3F,OAAO,EAAE,QAAQ,OAAO,IAAI,UAAU,MAAM,SAAS,IAAK,SAAS,IAAyB,EAAE;AAChG;AAEA,IAAM,cAAc,SAA4D,SAAS,UAAa,OAAO,OAAO,UAAU,IAAI;;AAGlI,IAAa,iBAAiB,SAC5B,WAAW,IAAI,IAAI,SAAS,QAAQ;;AAGtC,SAAgB,SAAS,MAA2C,MAAmC;CACrG,IAAI,SAAS,QAAQ,OAAO,KAAK;CACjC,IAAI,SAAS,QAAQ,OAAO,KAAK;CACjC,OAAO,WAAW,IAAI,IAAK,KAA2D,QAAQ;AAChG;;;;;ACrBA,SAAgB,aACd,MACA,SACQ;CACR,OAAO,UAAU,SAAS,KAAK,MAAM,IAAI;AAC3C;;;;;;AAOA,SAAgB,YAAY,MAAe,MAAuB;CAChE,MAAM,WAAW,KAAK,MAAM,GAAG;CAC/B,MAAM,OAAO,SAAS;CACtB,IAAI,SAAS,SAAS,KAAK,CAAC,cAAc,IAAI,GAAG,OAAO;CACxD,I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AnB;GAA4B,OAAO;GACnC,UAAA,qBAAC,OAAD;IAAK,WAAW,CAACA,8BAAE,MAAM,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;IAAG,GAAI;IAAnE,UAAA,CACE,oBAAC,UAAD;KAAQ,WAAWA,8BAAE;KAClB,UAAA,MAAM,WAAW,IAChB,oBAAC,QAAD;MAAM,WAAWA,8BAAE;MAAO,UAAA,UAAU,MAAM,EAAE;KAAQ,CAAA,IAEpD,qBAAAC,UAAA,EAAA,UAAA,CACE,qBAAC,QAAD;MAAM,WAAWD,8BAAE;MAAnB,UAAA,CAA0B,MAAM,QAAO,WAAe;KACtD,CAAA,GAAA,oBAAC,QAAD;MAAM,WAAWA,8BAAE;MAAY,UAAA,cAAc,KAAK;KAAQ,CAAA,CAC1D,EAAA,CAAA;IAEE,CAAA,GACP,UAAU,OAAO,cAAc,UAAU,OAAO,KAAK,CAAC,CACpD;;EACuB,CAAA;CACf,CAAA;AAEjB"}
@@ -0,0 +1,3 @@
1
+ import { n as PlotTableView, t as PlotDataPanel } from "../../chunks/PlotDataPanel-DUNod3NJ.js";
2
+
3
+ export { PlotDataPanel, PlotTableView };
@@ -0,0 +1,3 @@
1
+ import { t as Rulers } from "../../chunks/Rulers-hkPFdPkH.js";
2
+
3
+ export { Rulers };
@@ -0,0 +1,3 @@
1
+ import { t as SceneGradientHandles } from "../../chunks/SceneGradientHandles-CHNSWx7U.js";
2
+
3
+ export { SceneGradientHandles };
@@ -0,0 +1,3 @@
1
+ import { n as useSceneLayerList, t as ANNOTATION_LAYER_ROW } from "../../chunks/SceneLayerList-DCYwqZkF.js";
2
+
3
+ export { ANNOTATION_LAYER_ROW, useSceneLayerList };
@@ -0,0 +1,3 @@
1
+ import { t as AnchorFields } from "../../../chunks/AnchorFields-Cam1xwpt.js";
2
+
3
+ export { AnchorFields };
@@ -0,0 +1,3 @@
1
+ import { n as isCharacterChrome, r as CHARACTER_OPTIONS, t as CharacterOptions } from "../../../chunks/CharacterOptions-BcT_lWjg.js";
2
+
3
+ export { CHARACTER_OPTIONS, CharacterOptions, isCharacterChrome };
@@ -0,0 +1,3 @@
1
+ import { i as nodeValueAt, n as aggregateValue, r as classifyKind, t as SelectionPanel } from "../../../chunks/SelectionPanel-n-dIMvQ2.js";
2
+
3
+ export { SelectionPanel, aggregateValue, classifyKind, nodeValueAt };