@weasel-js/ui-canvas 1.19.1 → 2.0.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/chunks/{CharacterOptions-BcT_lWjg.js → CharacterOptions-CSqKZvwS.js} +23 -12
- package/dist/chunks/CharacterOptions-CSqKZvwS.js.map +1 -0
- package/dist/chunks/{PlotDataPanel-DUNod3NJ.js → PlotDataPanel-uHdh4X0l.js} +12 -6
- package/dist/chunks/PlotDataPanel-uHdh4X0l.js.map +1 -0
- package/dist/chunks/Rulers-hkPFdPkH.js.map +1 -1
- package/dist/chunks/{SceneGradientHandles-CHNSWx7U.js → SceneGradientHandles-CcXyTVav.js} +11 -8
- package/dist/chunks/SceneGradientHandles-CcXyTVav.js.map +1 -0
- package/dist/chunks/{SceneLayerList-DCYwqZkF.js → SceneLayerList-D2yc3eIk.js} +16 -13
- package/dist/chunks/SceneLayerList-D2yc3eIk.js.map +1 -0
- package/dist/chunks/{SelectionPanel-n-dIMvQ2.js → SelectionPanel-Dz6_c0rd.js} +12 -15
- package/dist/chunks/SelectionPanel-Dz6_c0rd.js.map +1 -0
- package/dist/components/PlotDataPanel/PlotDataPanel.d.ts +19 -0
- package/dist/components/PlotDataPanel/PlotDataPanel.d.ts.map +1 -0
- package/dist/components/PlotDataPanel/PlotTableView.d.ts +14 -0
- package/dist/components/PlotDataPanel/PlotTableView.d.ts.map +1 -0
- package/dist/components/PlotDataPanel/index.d.ts +5 -0
- package/dist/components/PlotDataPanel/index.d.ts.map +1 -0
- package/dist/components/PlotDataPanel/index.js +1 -1
- package/dist/components/PlotDataPanel/rowIds.d.ts +17 -0
- package/dist/components/PlotDataPanel/rowIds.d.ts.map +1 -0
- package/dist/components/PlotDataPanel/valueControl.d.ts +13 -0
- package/dist/components/PlotDataPanel/valueControl.d.ts.map +1 -0
- package/dist/components/Rulers/Rulers.d.ts +18 -0
- package/dist/components/Rulers/Rulers.d.ts.map +1 -0
- package/dist/components/Rulers/index.d.ts +3 -0
- package/dist/components/Rulers/index.d.ts.map +1 -0
- package/dist/components/SceneGradientHandles/SceneGradientHandles.d.ts +41 -0
- package/dist/components/SceneGradientHandles/SceneGradientHandles.d.ts.map +1 -0
- package/dist/components/SceneGradientHandles/index.d.ts +2 -0
- package/dist/components/SceneGradientHandles/index.d.ts.map +1 -0
- package/dist/components/SceneGradientHandles/index.js +1 -1
- package/dist/components/SceneLayerList/index.d.ts +2 -0
- package/dist/components/SceneLayerList/index.d.ts.map +1 -0
- package/dist/components/SceneLayerList/index.js +1 -1
- package/dist/components/SceneLayerList/useSceneLayerList.d.ts +47 -0
- package/dist/components/SceneLayerList/useSceneLayerList.d.ts.map +1 -0
- package/dist/components/inspector/AnchorFields/AnchorFields.d.ts +34 -0
- package/dist/components/inspector/AnchorFields/AnchorFields.d.ts.map +1 -0
- package/dist/components/inspector/AnchorFields/index.d.ts +2 -0
- package/dist/components/inspector/AnchorFields/index.d.ts.map +1 -0
- package/dist/components/inspector/CharacterOptions/CharacterOptions.d.ts +27 -0
- package/dist/components/inspector/CharacterOptions/CharacterOptions.d.ts.map +1 -0
- package/dist/components/inspector/CharacterOptions/characterSchema.d.ts +169 -0
- package/dist/components/inspector/CharacterOptions/characterSchema.d.ts.map +1 -0
- package/dist/components/inspector/CharacterOptions/index.d.ts +4 -0
- package/dist/components/inspector/CharacterOptions/index.d.ts.map +1 -0
- package/dist/components/inspector/CharacterOptions/index.js +1 -1
- package/dist/components/inspector/SelectionPanel/SelectionPanel.d.ts +80 -0
- package/dist/components/inspector/SelectionPanel/SelectionPanel.d.ts.map +1 -0
- package/dist/components/inspector/SelectionPanel/commitLeaf.d.ts +23 -0
- package/dist/components/inspector/SelectionPanel/commitLeaf.d.ts.map +1 -0
- package/dist/components/inspector/SelectionPanel/declaredFields.d.ts +19 -0
- package/dist/components/inspector/SelectionPanel/declaredFields.d.ts.map +1 -0
- package/dist/components/inspector/SelectionPanel/index.d.ts +3 -0
- package/dist/components/inspector/SelectionPanel/index.d.ts.map +1 -0
- package/dist/components/inspector/SelectionPanel/index.js +2 -2
- package/dist/components/inspector/SelectionPanel/nodeModel.d.ts +14 -0
- package/dist/components/inspector/SelectionPanel/nodeModel.d.ts.map +1 -0
- package/dist/components/inspector/SelectionPanel/scopes.d.ts +7 -0
- package/dist/components/inspector/SelectionPanel/scopes.d.ts.map +1 -0
- package/dist/icons.gen.d.ts +3 -0
- package/dist/icons.gen.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -6
- package/dist/kitIcons.d.ts +4 -0
- package/dist/kitIcons.d.ts.map +1 -0
- package/package.json +20 -18
- package/dist/chunks/CharacterOptions-BcT_lWjg.js.map +0 -1
- package/dist/chunks/PlotDataPanel-DUNod3NJ.js.map +0 -1
- package/dist/chunks/SceneGradientHandles-CHNSWx7U.js.map +0 -1
- package/dist/chunks/SceneLayerList-DCYwqZkF.js.map +0 -1
- package/dist/chunks/SelectionPanel-n-dIMvQ2.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectionPanel-Dz6_c0rd.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.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 type { AnyNode } 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/** 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/** A path's value shared across nodes, or `MIXED`. A node\n * holding nothing there reads as `absent`. */\nexport function sharedNodeValue(\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 cancel: restore,\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 { prefLeafInUnitScopes } 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: prefLeafInUnitScopes(l.leaf, chain) })) };\n return sections.map((section) => within(section) as PanelSection);\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 routeKind,\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 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 * `prefLeafInUnitScopes`; 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 marked?: readonly string[];\n /** The reader pressed or focused into a row, reported as `marked` 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 onMark?: (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, routeKind(traits.current.routing, node.data, node))?.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) => routeKind(routing, n.data, n));\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.marked ?? NO_MARKS, renderers);\n const marks: PanelMarks = { selected: shown, lead: shown.at(-1) ?? null, ...(props.markHidden ? { hidden: scope.hidden } : {}) };\n const rowSelection = useSelectedRow(props.marked ?? NO_MARKS, marks.lead ?? null, props.onMark);\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 cancel: (leaf) => writes.cancel?.(leaf),\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,O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
|
4
|
+
export interface PlotDataPanelProps {
|
|
5
|
+
/** The chart, any kind. */
|
|
6
|
+
data: PlotData;
|
|
7
|
+
/** The chart as an edit leaves it, and a name for the edit, for an undo entry. The panel holds no copy: show the
|
|
8
|
+
* change by passing it back as `data`. */
|
|
9
|
+
onChange: (next: PlotData, label: string) => void;
|
|
10
|
+
/** Default `'Data'`. */
|
|
11
|
+
title?: string;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Authors a chart's data, whatever its kind, from the kind's schema (`plotSchemaOf`): a row per field, and a grid
|
|
16
|
+
* per table whose rows can be added, removed, reordered, and opened onto the tables they hold.
|
|
17
|
+
*/
|
|
18
|
+
export declare function PlotDataPanel({ data, onChange, title, className }: PlotDataPanelProps): ReactElement;
|
|
19
|
+
//# sourceMappingURL=PlotDataPanel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlotDataPanel.d.ts","sourceRoot":"","sources":["../../../src/components/PlotDataPanel/PlotDataPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,QAAQ,EAAkB,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAKpD,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IACjC,2BAA2B;IAC3B,IAAI,EAAE,QAAQ,CAAC;IACf;+CAC2C;IAC3C,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,wBAAwB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAc,EAAE,SAAS,EAAE,EAAE,kBAAkB,GAAG,YAAY,CAkC7G"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PlotData, PlotScope, PlotTable } from '@weasel-js/plot';
|
|
2
|
+
import type { ReactElement } from 'react';
|
|
3
|
+
/** Props for {@link PlotTableView}. */
|
|
4
|
+
export interface PlotTableViewProps {
|
|
5
|
+
data: PlotData;
|
|
6
|
+
table: PlotTable;
|
|
7
|
+
scope: PlotScope;
|
|
8
|
+
/** Proposes `next` as the chart's data, an edit named `label`. */
|
|
9
|
+
edit: (next: (data: PlotData) => PlotData, label: string) => void;
|
|
10
|
+
}
|
|
11
|
+
/** One table of a plot schema as a grid of controls: a row per item, which can be added, removed, dragged into
|
|
12
|
+
* another order, and opened onto the tables it holds. */
|
|
13
|
+
export declare function PlotTableView({ data, table, scope, edit }: PlotTableViewProps): ReactElement;
|
|
14
|
+
//# sourceMappingURL=PlotTableView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlotTableView.d.ts","sourceRoot":"","sources":["../../../src/components/PlotDataPanel/PlotTableView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAa,MAAM,iBAAiB,CAAC;AACjF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAQ1C,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,kEAAkE;IAClE,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,QAAQ,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnE;AAID;0DAC0D;AAC1D,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,kBAAkB,GAAG,YAAY,CAoE5F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PlotDataPanel/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PlotData } from '@weasel-js/plot';
|
|
2
|
+
/** What an edit does to the rows' order: the ids before it, to the ids after. */
|
|
3
|
+
export type RowShift = (ids: readonly string[], fresh: () => string) => string[];
|
|
4
|
+
export declare const insertedAt: (at: number) => RowShift;
|
|
5
|
+
export declare const removedAt: (at: number) => RowShift;
|
|
6
|
+
export declare const movedTo: (from: number, to: number) => RowShift;
|
|
7
|
+
/**
|
|
8
|
+
* An id for each of a table's `count` rows that stays with its item through the panel's own inserts, removals and
|
|
9
|
+
* moves, so what a row holds open follows the item rather than its slot. `track` wraps an edit with what it does to
|
|
10
|
+
* the order; the order shifts only once `data` comes back as that edit made it, so an edit the host drops shifts
|
|
11
|
+
* nothing. A change from elsewhere keeps the ids by position.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useRowIds(data: PlotData, count: number): {
|
|
14
|
+
ids: readonly string[];
|
|
15
|
+
track: (change: (d: PlotData) => PlotData, shift: RowShift) => (d: PlotData) => PlotData;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=rowIds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rowIds.d.ts","sourceRoot":"","sources":["../../../src/components/PlotDataPanel/rowIds.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGhD,iFAAiF;AACjF,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,MAAM,KAAK,MAAM,EAAE,CAAC;AAEjF,eAAO,MAAM,UAAU,GAAI,IAAI,MAAM,KAAG,QAA4E,CAAC;AACrH,eAAO,MAAM,SAAS,GAAI,IAAI,MAAM,KAAG,QAAmD,CAAC;AAC3F,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,EAAE,IAAI,MAAM,KAAG,QAIlD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG;IACxD,GAAG,EAAE,SAAS,MAAM,EAAE,CAAC;IACvB,KAAK,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,QAAQ,KAAK,QAAQ,EAAE,KAAK,EAAE,QAAQ,KAAK,CAAC,CAAC,EAAE,QAAQ,KAAK,QAAQ,CAAC;CAC1F,CAmBA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** A plot schema field or cell as the props of the params control that edits it. */
|
|
2
|
+
import type { PlotValue, PlotValueType } from '@weasel-js/plot';
|
|
3
|
+
import type { PropertyControlProps } from '@weasel-js/ui/components/Properties';
|
|
4
|
+
/** What a field or cell is, for its control: its type, whether it can be unset or only read, and its value. */
|
|
5
|
+
export interface ValueSpec {
|
|
6
|
+
type: PlotValueType;
|
|
7
|
+
value: PlotValue;
|
|
8
|
+
optional?: boolean;
|
|
9
|
+
readOnly?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** The props of the control for `spec`, reporting each committed value through `set`. */
|
|
12
|
+
export declare function valueControl(spec: ValueSpec, name: string, set: (value: PlotValue) => void): PropertyControlProps;
|
|
13
|
+
//# sourceMappingURL=valueControl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valueControl.d.ts","sourceRoot":"","sources":["../../../src/components/PlotDataPanel/valueControl.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAEhF,+GAA+G;AAC/G,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,yFAAyF;AACzF,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,GAAG,oBAAoB,CAwBjH"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
import type { Rulers as RulersModel } from '@weasel-js/guides';
|
|
3
|
+
/** Props for {@link Rulers}. */
|
|
4
|
+
export interface RulersProps {
|
|
5
|
+
/** What `createRulers` returned; its contribution installed on the canvas. */
|
|
6
|
+
rulers: RulersModel;
|
|
7
|
+
/** Additional class for the root, which covers its positioned container. */
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Rulers along the top and left of a canvas, with a box in the corner naming
|
|
12
|
+
* the unit they read in: the chrome half of `createRulers` from
|
|
13
|
+
* `@weasel-js/guides`, whose contribution follows the view and takes the drags
|
|
14
|
+
* that place guides. Place it in the canvas's positioned container; it covers
|
|
15
|
+
* it and passes every pointer event through to the canvas below.
|
|
16
|
+
*/
|
|
17
|
+
export declare function Rulers({ rulers, className }: RulersProps): ReactElement | null;
|
|
18
|
+
//# sourceMappingURL=Rulers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rulers.d.ts","sourceRoot":"","sources":["../../../src/components/Rulers/Rulers.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,KAAK,EAAc,MAAM,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG3E,gCAAgC;AAChC,MAAM,WAAW,WAAW;IAC1B,8EAA8E;IAC9E,MAAM,EAAE,WAAW,CAAC;IACpB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAeD;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,WAAW,GAAG,YAAY,GAAG,IAAI,CAgC9E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Rulers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type ReactElement, type RefObject } from 'react';
|
|
2
|
+
import { type Stroke, type Fill, type Inherit } from '@weasel-js/paint';
|
|
3
|
+
import type { View } from '@weasel-js/geom';
|
|
4
|
+
import { type RectPose, type Scene } from '@weasel-js/core';
|
|
5
|
+
import type { PaintSlot } from '@weasel-js/paint';
|
|
6
|
+
import '@weasel-js/paint-kinds/mesh';
|
|
7
|
+
/** What `SceneGradientHandles` reads off a node. Every field is optional, so
|
|
8
|
+
* any richer app data shape satisfies it. */
|
|
9
|
+
export interface PaintedNodeData {
|
|
10
|
+
fill?: Fill | Inherit | null;
|
|
11
|
+
stroke?: Stroke | Inherit | null;
|
|
12
|
+
}
|
|
13
|
+
/** Props for {@link SceneGradientHandles}. */
|
|
14
|
+
export interface SceneGradientHandlesProps<TData extends PaintedNodeData, TLayer extends string, TPose extends RectPose> {
|
|
15
|
+
scene: Scene<TData, TLayer, TPose>;
|
|
16
|
+
/** The element the overlay is positioned in. Must be the canvas's own box,
|
|
17
|
+
* or the handles land somewhere other than the paint. */
|
|
18
|
+
containerRef: RefObject<HTMLElement | null>;
|
|
19
|
+
/** The node whose paint is being edited, and the one a drag writes to, whatever the selection holds. */
|
|
20
|
+
nodeId: string | null | undefined;
|
|
21
|
+
/** Which of the node's two paints these handles move. */
|
|
22
|
+
slot: PaintSlot;
|
|
23
|
+
/** Current viewport; a thunk is re-read per projection. See
|
|
24
|
+
* `useNodeOverlayFrame`. */
|
|
25
|
+
view?: View | (() => View);
|
|
26
|
+
className?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Scene-aware paint handles: on-canvas geometry handles for the gradient in
|
|
30
|
+
* one node's `fill` or `stroke` — `GradientHandles` for the three ramps,
|
|
31
|
+
* `MeshHandles` for a mesh — committed through the `setFill` / `setStroke`
|
|
32
|
+
* actions, on `nodeId` alone, as a single undo entry per drag. A canceled drag cancels the action,
|
|
33
|
+
* and so does unmounting the overlay while a handle is held.
|
|
34
|
+
*
|
|
35
|
+
* Renders nothing unless the targeted slot holds a gradient or a mesh. The
|
|
36
|
+
* node stores its gradient in `units: 'bounds'`, fractions of its own box; the
|
|
37
|
+
* handles get it resolved onto the box and every edit is normalized back on
|
|
38
|
+
* the way out.
|
|
39
|
+
*/
|
|
40
|
+
export declare function SceneGradientHandles<TData extends PaintedNodeData, TLayer extends string, TPose extends RectPose>(props: SceneGradientHandlesProps<TData, TLayer, TPose>): ReactElement | null;
|
|
41
|
+
//# sourceMappingURL=SceneGradientHandles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SceneGradientHandles.d.ts","sourceRoot":"","sources":["../../../src/components/SceneGradientHandles/SceneGradientHandles.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEnF,OAAO,EAA+E,KAAK,MAAM,EAAE,KAAK,IAAI,EAAE,KAAK,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAErJ,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAA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,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/SceneLayerList/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAAE,KAAK,yBAAyB,EAAE,KAAK,mBAAmB,EAAE,KAAK,wBAAwB,EAAE,iBAAiB,GACjI,MAAM,qBAAqB,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as useSceneLayerList, t as ANNOTATION_LAYER_ROW } from "../../chunks/SceneLayerList-
|
|
1
|
+
import { n as useSceneLayerList, t as ANNOTATION_LAYER_ROW } from "../../chunks/SceneLayerList-D2yc3eIk.js";
|
|
2
2
|
|
|
3
3
|
export { ANNOTATION_LAYER_ROW, useSceneLayerList };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { SelectionApi } from '@weasel-js/routing';
|
|
2
|
+
import type { Scene, SceneNode } from '@weasel-js/core';
|
|
3
|
+
import type { LayerListItem, LayerListProps } from '@weasel-js/ui/components/LayerList';
|
|
4
|
+
/** The id prefix of an annotation layer's own row, which holds its nodes. */
|
|
5
|
+
export declare const ANNOTATION_LAYER_ROW = "annotation-layer:";
|
|
6
|
+
/** How a {@link useSceneLayerList} list shows annotation layers. */
|
|
7
|
+
export interface SceneLayerListAnnotations {
|
|
8
|
+
/** The picked annotation node, which reads as a selected row. */
|
|
9
|
+
picked: string | null;
|
|
10
|
+
/** Selecting an annotation row picks it, leaving the content selection as it was; a selection holding no annotation picks `null`. */
|
|
11
|
+
pick(id: string | null): void;
|
|
12
|
+
/** The row label for annotation layer `layer`. Default: its id. */
|
|
13
|
+
labelOf?(layer: string): string;
|
|
14
|
+
}
|
|
15
|
+
/** Arguments for {@link useSceneLayerList}. */
|
|
16
|
+
export interface UseSceneLayerListOptions<TData, TLayer extends string, TPose> {
|
|
17
|
+
scene: Scene<TData, TLayer, TPose>;
|
|
18
|
+
selection: SelectionApi;
|
|
19
|
+
/** What the reorder op is dispatched against. Default: the scene itself, as one history entry. */
|
|
20
|
+
adapter?: object;
|
|
21
|
+
/** A row's content for a node: its label, a leading swatch or icon. Its
|
|
22
|
+
* `visible` and `locked` come from the node's own flags. */
|
|
23
|
+
itemFor: (node: SceneNode<TData, TLayer, TPose>) => Omit<LayerListItem, 'id' | 'children'>;
|
|
24
|
+
/** The data a rename to `label` writes, which makes rows renamable. The
|
|
25
|
+
* scene has no name of its own, so where one lives is the consumer's call. */
|
|
26
|
+
rename?: (node: SceneNode<TData, TLayer, TPose>, label: string) => TData;
|
|
27
|
+
/** Label of the reorder's history entry. Default `'Reorder'`. */
|
|
28
|
+
label?: string;
|
|
29
|
+
/** Given, each annotation layer (`isAnnotationLayer`) gets a row holding its
|
|
30
|
+
* nodes, marked not printed: the layer can be hidden and locked, its nodes
|
|
31
|
+
* picked and removed. Absent, annotations are left out of the list — the canvas still
|
|
32
|
+
* draws them. */
|
|
33
|
+
annotations?: SceneLayerListAnnotations;
|
|
34
|
+
}
|
|
35
|
+
/** The `<LayerList>` props `useSceneLayerList` answers. */
|
|
36
|
+
export type SceneLayerListProps = Required<Pick<LayerListProps, 'items' | 'selectedIds' | 'onSelectionChange' | 'onReorder' | 'canMove' | 'onVisibilityChange' | 'onLockChange'>> & Pick<LayerListProps, 'onRemove' | 'onRename'>;
|
|
37
|
+
/**
|
|
38
|
+
* The props that put a scene in a `<LayerList>`: a row per node, a container's
|
|
39
|
+
* children nested under it, the front-most at the top, selection read from and
|
|
40
|
+
* written to `selection`, a drag — among siblings or into another container —
|
|
41
|
+
* dispatched as a `MoveToIndexOp`, and each row's visibility and lock toggling
|
|
42
|
+
* the node's own (`setHidden` / `setLocked` ops), each click one undo step, an Alt-click's batch included.
|
|
43
|
+
* Annotation layers are left out unless `annotations` says how to show them;
|
|
44
|
+
* shown, an annotation moves only within its own layer's row.
|
|
45
|
+
*/
|
|
46
|
+
export declare function useSceneLayerList<TData, TLayer extends string, TPose>(args: UseSceneLayerListOptions<TData, TLayer, TPose>): SceneLayerListProps;
|
|
47
|
+
//# sourceMappingURL=useSceneLayerList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSceneLayerList.d.ts","sourceRoot":"","sources":["../../../src/components/SceneLayerList/useSceneLayerList.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAU,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGxF,6EAA6E;AAC7E,eAAO,MAAM,oBAAoB,sBAAsB,CAAC;AAMxD,oEAAoE;AACpE,MAAM,WAAW,yBAAyB;IACxC,iEAAiE;IACjE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,qIAAqI;IACrI,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IAC9B,mEAAmE;IACnE,OAAO,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACjC;AAED,+CAA+C;AAC/C,MAAM,WAAW,wBAAwB,CAAC,KAAK,EAAE,MAAM,SAAS,MAAM,EAAE,KAAK;IAC3E,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACnC,SAAS,EAAE,YAAY,CAAC;IACxB,kGAAkG;IAClG,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;iEAC6D;IAC7D,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,IAAI,CAAC,aAAa,EAAE,IAAI,GAAG,UAAU,CAAC,CAAC;IAC3F;mFAC+E;IAC/E,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC;IACzE,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;sBAGkB;IAClB,WAAW,CAAC,EAAE,yBAAyB,CAAC;CACzC;AAoDD,2DAA2D;AAC3D,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,aAAa,GAAG,mBAAmB,GAAG,WAAW,GAAG,SAAS,GAAG,oBAAoB,GAAG,cAAc,CAAC,CAAC,GAC7K,IAAI,CAAC,cAAc,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;AAElD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,SAAS,MAAM,EAAE,KAAK,EACnE,IAAI,EAAE,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,GACnD,mBAAmB,CAqHrB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type AnchorFieldsApi } from '@weasel-js/core';
|
|
3
|
+
import type { UnitTable } from '@weasel-js/quantity';
|
|
4
|
+
/** How a lone anchor's handles read: as points, or as a turn and a reach from the anchor. */
|
|
5
|
+
export type HandleCoords = 'xy' | 'polar';
|
|
6
|
+
/** Props for {@link AnchorFields}. */
|
|
7
|
+
export interface AnchorFieldsProps {
|
|
8
|
+
/** Units a person may type, each mapped to the factor that turns it into
|
|
9
|
+
* document units: `{ pt: 1, in: 72, mm: 72 / 25.4 }`. */
|
|
10
|
+
accepts?: Readonly<UnitTable>;
|
|
11
|
+
/** The suffix after each position and length. */
|
|
12
|
+
unit?: ReactNode;
|
|
13
|
+
/** How handles read, held by the caller; the panel's toggle asks to change it through
|
|
14
|
+
* `onHandleCoordsChange`. Absent, the panel holds it, starting at `defaultHandleCoords`. */
|
|
15
|
+
handleCoords?: HandleCoords;
|
|
16
|
+
onHandleCoordsChange?: (next: HandleCoords) => void;
|
|
17
|
+
/** How handles read first when the panel holds it. Default `'xy'`. */
|
|
18
|
+
defaultHandleCoords?: HandleCoords;
|
|
19
|
+
/** Shown while no anchor is selected in path edit. Default: nothing. */
|
|
20
|
+
emptyState?: ReactNode;
|
|
21
|
+
/** The fields to show and write, in place of the canvas in scope's. */
|
|
22
|
+
fields?: AnchorFieldsApi;
|
|
23
|
+
/** Class on the property list. */
|
|
24
|
+
className?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The anchors selected in path edit, as numbers to read and type: their X and
|
|
28
|
+
* Y, and for a lone anchor each handle's X and Y or angle and length. A field
|
|
29
|
+
* the anchors disagree on reads Mixed; typing a number there moves them all to
|
|
30
|
+
* it, and `+=` or `-=` with an amount moves each by that much. Every entry is
|
|
31
|
+
* one undo step.
|
|
32
|
+
*/
|
|
33
|
+
export declare function AnchorFields({ accepts, unit, handleCoords, onHandleCoordsChange, defaultHandleCoords, emptyState, fields: given, className, }: AnchorFieldsProps): import("react").JSX.Element;
|
|
34
|
+
//# sourceMappingURL=AnchorFields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnchorFields.d.ts","sourceRoot":"","sources":["../../../../src/components/inspector/AnchorFields/AnchorFields.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAE,KAAK,eAAe,EAAmB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,6FAA6F;AAC7F,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,OAAO,CAAC;AAE1C,sCAAsC;AACtC,MAAM,WAAW,iBAAiB;IAChC;8DAC0D;IAC1D,OAAO,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC9B,iDAAiD;IACjD,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;iGAC6F;IAC7F,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,oBAAoB,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;IACpD,sEAAsE;IACtE,mBAAmB,CAAC,EAAE,YAAY,CAAC;IACnC,wEAAwE;IACxE,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,uEAAuE;IACvE,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AASD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,oBAAoB,EACpB,mBAA0B,EAC1B,UAAiB,EACjB,MAAM,EAAE,KAAK,EACb,SAAS,GACV,EAAE,iBAAiB,+BAyCnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/inspector/AnchorFields/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { RangeStyle, RunStylePatch } from '@weasel-js/text';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
/** Props for {@link CharacterOptions}. */
|
|
4
|
+
export interface CharacterOptionsProps {
|
|
5
|
+
/** Styling to display. `MIXED` at a key means the sources disagree there.
|
|
6
|
+
* Absent or `null` renders no bar, unless `children` gives it a tenant. */
|
|
7
|
+
value?: RangeStyle | null;
|
|
8
|
+
/** Apply a styling change. One call per completed edit. */
|
|
9
|
+
onChange: (patch: RunStylePatch) => void;
|
|
10
|
+
/** Tenants of the bar that are not character styling, e.g. loupe controls. */
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Is `el` part of a `CharacterOptions` bar, or of a kit popover one of its
|
|
16
|
+
* controls opened? Pass it as `useTextEdit`'s `isEditorChrome`, so using the
|
|
17
|
+
* bar does not end the edit it styles.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isCharacterChrome(el: Element): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The strip of character controls for a text edit in progress. Wire it to
|
|
22
|
+
* `useTextEdit`: `value` takes `effectiveStyle`, `onChange` takes
|
|
23
|
+
* `applyStyleToSelection`, and {@link isCharacterChrome} goes in as
|
|
24
|
+
* `isEditorChrome`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function CharacterOptions({ value, onChange, children, className }: CharacterOptionsProps): import("react").JSX.Element;
|
|
27
|
+
//# sourceMappingURL=CharacterOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CharacterOptions.d.ts","sourceRoot":"","sources":["../../../../src/components/inspector/CharacterOptions/CharacterOptions.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAa,MAAM,iBAAiB,CAAC;AAE5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,0CAA0C;AAC1C,MAAM,WAAW,qBAAqB;IACpC;gFAC4E;IAC5E,KAAK,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAC1B,2DAA2D;IAC3D,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAGtD;AAKD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,qBAAqB,+BAc/F"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/** The schema {@link CharacterOptions} draws: one control per `StyledRun` field a range takes. */
|
|
2
|
+
import type { IconRef } from '@weasel-js/icons';
|
|
3
|
+
/**
|
|
4
|
+
* The character controls for a caret range — the character half of text
|
|
5
|
+
* styling, against the node-level Character group a selection shows.
|
|
6
|
+
*
|
|
7
|
+
* Keyed by {@link StyledRun} field, so a host reads values out of a
|
|
8
|
+
* `RangeStyle` and writes a `RunStylePatch` back with no name mapping of its
|
|
9
|
+
* own. `script` is a preset over `baselineShift` and `fontScale`, so all three
|
|
10
|
+
* are here and naming either primitive overrides that half. `noFill` is the one
|
|
11
|
+
* key that is not a field: on, it is `fill: null`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const CHARACTER_OPTIONS: {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
children: {
|
|
17
|
+
bold: {
|
|
18
|
+
pair: {
|
|
19
|
+
with: string[];
|
|
20
|
+
label: string;
|
|
21
|
+
};
|
|
22
|
+
kind: "boolean";
|
|
23
|
+
name: string;
|
|
24
|
+
description: `${string} for the characters in the range.`;
|
|
25
|
+
icon: IconRef;
|
|
26
|
+
control: "toggle";
|
|
27
|
+
default: false;
|
|
28
|
+
};
|
|
29
|
+
italic: {
|
|
30
|
+
readonly kind: "boolean";
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly description: `${string} for the characters in the range.`;
|
|
33
|
+
readonly icon: IconRef;
|
|
34
|
+
readonly control: "toggle";
|
|
35
|
+
readonly default: false;
|
|
36
|
+
};
|
|
37
|
+
underline: {
|
|
38
|
+
readonly kind: "boolean";
|
|
39
|
+
readonly name: string;
|
|
40
|
+
readonly description: `${string} for the characters in the range.`;
|
|
41
|
+
readonly icon: IconRef;
|
|
42
|
+
readonly control: "toggle";
|
|
43
|
+
readonly default: false;
|
|
44
|
+
};
|
|
45
|
+
strikethrough: {
|
|
46
|
+
readonly kind: "boolean";
|
|
47
|
+
readonly name: string;
|
|
48
|
+
readonly description: `${string} for the characters in the range.`;
|
|
49
|
+
readonly icon: IconRef;
|
|
50
|
+
readonly control: "toggle";
|
|
51
|
+
readonly default: false;
|
|
52
|
+
};
|
|
53
|
+
overline: {
|
|
54
|
+
readonly kind: "boolean";
|
|
55
|
+
readonly name: string;
|
|
56
|
+
readonly description: `${string} for the characters in the range.`;
|
|
57
|
+
readonly icon: IconRef;
|
|
58
|
+
readonly control: "toggle";
|
|
59
|
+
readonly default: false;
|
|
60
|
+
};
|
|
61
|
+
script: {
|
|
62
|
+
kind: "enum";
|
|
63
|
+
name: string;
|
|
64
|
+
description: string;
|
|
65
|
+
control: "toggle";
|
|
66
|
+
clearable: true;
|
|
67
|
+
default: undefined;
|
|
68
|
+
options: {
|
|
69
|
+
value: string;
|
|
70
|
+
label: string;
|
|
71
|
+
icon: IconRef;
|
|
72
|
+
}[];
|
|
73
|
+
};
|
|
74
|
+
textTransform: {
|
|
75
|
+
kind: "enum";
|
|
76
|
+
name: string;
|
|
77
|
+
description: string;
|
|
78
|
+
control: "toggle";
|
|
79
|
+
default: string;
|
|
80
|
+
options: {
|
|
81
|
+
value: string;
|
|
82
|
+
label: string;
|
|
83
|
+
short: string[];
|
|
84
|
+
}[];
|
|
85
|
+
};
|
|
86
|
+
fontVariantCaps: {
|
|
87
|
+
kind: "enum";
|
|
88
|
+
name: string;
|
|
89
|
+
description: string;
|
|
90
|
+
control: "toggle";
|
|
91
|
+
default: string;
|
|
92
|
+
options: {
|
|
93
|
+
value: string;
|
|
94
|
+
label: string;
|
|
95
|
+
short: string[];
|
|
96
|
+
}[];
|
|
97
|
+
};
|
|
98
|
+
fontFamily: {
|
|
99
|
+
kind: string;
|
|
100
|
+
name: string;
|
|
101
|
+
description: string;
|
|
102
|
+
default: undefined;
|
|
103
|
+
};
|
|
104
|
+
fontWeight: {
|
|
105
|
+
kind: string;
|
|
106
|
+
name: string;
|
|
107
|
+
description: string;
|
|
108
|
+
default: undefined;
|
|
109
|
+
};
|
|
110
|
+
fontSize: {
|
|
111
|
+
kind: "number";
|
|
112
|
+
name: string;
|
|
113
|
+
description: string;
|
|
114
|
+
min: number;
|
|
115
|
+
step: number;
|
|
116
|
+
default: number;
|
|
117
|
+
};
|
|
118
|
+
letterSpacing: {
|
|
119
|
+
kind: "number";
|
|
120
|
+
name: string;
|
|
121
|
+
short: string[];
|
|
122
|
+
description: string;
|
|
123
|
+
step: number;
|
|
124
|
+
default: number;
|
|
125
|
+
};
|
|
126
|
+
baselineShift: {
|
|
127
|
+
kind: "number";
|
|
128
|
+
name: string;
|
|
129
|
+
short: string[];
|
|
130
|
+
description: string;
|
|
131
|
+
step: number;
|
|
132
|
+
unit: {
|
|
133
|
+
scale: number;
|
|
134
|
+
places: number;
|
|
135
|
+
suffix: string;
|
|
136
|
+
};
|
|
137
|
+
default: number;
|
|
138
|
+
};
|
|
139
|
+
fontScale: {
|
|
140
|
+
kind: "number";
|
|
141
|
+
name: string;
|
|
142
|
+
description: string;
|
|
143
|
+
min: number;
|
|
144
|
+
step: number;
|
|
145
|
+
unit: {
|
|
146
|
+
scale: number;
|
|
147
|
+
places: number;
|
|
148
|
+
suffix: string;
|
|
149
|
+
};
|
|
150
|
+
default: number;
|
|
151
|
+
};
|
|
152
|
+
fill: {
|
|
153
|
+
kind: "color";
|
|
154
|
+
name: string;
|
|
155
|
+
description: string;
|
|
156
|
+
alpha: true;
|
|
157
|
+
default: string;
|
|
158
|
+
};
|
|
159
|
+
noFill: {
|
|
160
|
+
kind: "boolean";
|
|
161
|
+
name: string;
|
|
162
|
+
description: string;
|
|
163
|
+
icon: IconRef;
|
|
164
|
+
control: "toggle";
|
|
165
|
+
default: false;
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
//# sourceMappingURL=characterSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"characterSchema.d.ts","sourceRoot":"","sources":["../../../../src/components/inspector/CharacterOptions/characterSchema.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAqBhD;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqGT,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/inspector/CharacterOptions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACzE,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as isCharacterChrome, r as CHARACTER_OPTIONS, t as CharacterOptions } from "../../../chunks/CharacterOptions-
|
|
1
|
+
import { n as isCharacterChrome, r as CHARACTER_OPTIONS, t as CharacterOptions } from "../../../chunks/CharacterOptions-CSqKZvwS.js";
|
|
2
2
|
|
|
3
3
|
export { CHARACTER_OPTIONS, CharacterOptions, isCharacterChrome };
|