@weasel-js/labkit 1.4.0-pre.1 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_dts/{CanvasStackContext-LnCfqNBA.d.ts → CanvasStackContext-BIRUVVGH.d.ts} +1 -1
- package/dist/_dts/PrefsForm.d-CgxUequc.d.ts +20 -0
- package/dist/_dts/{frac-C-2c72Ij.d.ts → frac-X7mWgd7y.d.ts} +10 -4
- package/dist/_dts/{index-BDVzvRzQ.d.ts → index-FEa1MudK.d.ts} +8 -2
- package/dist/_dts/{types-DYMaEvM5.d.ts → types-ChVJJHvk.d.ts} +3 -0
- package/dist/_dts/{types-D6s4b7if.d.ts → types-lg4TSCb2.d.ts} +3 -1
- package/dist/_dts/{useTrialState-gmMvZqPc.d.ts → useTrialState-Cdm13fvl.d.ts} +2 -1
- package/dist/_dts/weasel-canvas-FJTFi3ZZ.d.ts +5041 -0
- package/dist/canvas/index.d.ts +16 -16
- package/dist/canvas/index.js +2 -2
- package/dist/chrome/index.d.ts +6 -6
- package/dist/chrome/index.js +5 -5
- package/dist/chunk-2YILQ7Y5.js +33 -0
- package/dist/chunk-2YILQ7Y5.js.map +1 -0
- package/dist/{chunk-TO2FUOKF.js → chunk-53AZ2O2N.js} +16 -13
- package/dist/chunk-53AZ2O2N.js.map +1 -0
- package/dist/{chunk-QB5SM4BM.js → chunk-7TRFMIWX.js} +55 -41
- package/dist/chunk-7TRFMIWX.js.map +1 -0
- package/dist/{chunk-6OEYTYML.js → chunk-BMQWLKOL.js} +15 -15
- package/dist/chunk-BMQWLKOL.js.map +1 -0
- package/dist/{chunk-M75ZU6ZZ.js → chunk-D7QIPGEB.js} +3 -3
- package/dist/{chunk-M75ZU6ZZ.js.map → chunk-D7QIPGEB.js.map} +1 -1
- package/dist/{chunk-L5QJOOLV.js → chunk-DG2IFMLA.js} +1309 -273
- package/dist/chunk-DG2IFMLA.js.map +1 -0
- package/dist/{chunk-LN6JDUGB.js → chunk-HXXTULDN.js} +2 -2
- package/dist/{chunk-LN6JDUGB.js.map → chunk-HXXTULDN.js.map} +1 -1
- package/dist/{chunk-RBGKL7NF.js → chunk-J6SBFZYT.js} +1807 -1814
- package/dist/chunk-J6SBFZYT.js.map +1 -0
- package/dist/{chunk-XJ6N32QP.js → chunk-LJSIUFYD.js} +14 -30
- package/dist/chunk-LJSIUFYD.js.map +1 -0
- package/dist/{chunk-AE5CNVRU.js → chunk-MIT3ISW4.js} +37 -31
- package/dist/chunk-MIT3ISW4.js.map +1 -0
- package/dist/{chunk-HHGVISVZ.js → chunk-MSR7EVS6.js} +7 -5
- package/dist/chunk-MSR7EVS6.js.map +1 -0
- package/dist/{chunk-ESIQNQ6K.js → chunk-OFCBEZMU.js} +12 -6
- package/dist/chunk-OFCBEZMU.js.map +1 -0
- package/dist/{chunk-HMFODCOX.js → chunk-PP7ZWAMV.js} +83 -75
- package/dist/chunk-PP7ZWAMV.js.map +1 -0
- package/dist/{chunk-E2UQVZ44.js → chunk-RLOXQZW3.js} +3 -3
- package/dist/{chunk-E2UQVZ44.js.map → chunk-RLOXQZW3.js.map} +1 -1
- package/dist/controls/index.d.ts +4 -3
- package/dist/controls/index.js +3 -3
- package/dist/dragdrop/index.d.ts +5 -5
- package/dist/dragdrop/index.js +2 -2
- package/dist/index.d.ts +57 -77
- package/dist/index.js +308 -161
- package/dist/index.js.map +1 -1
- package/dist/job/index.js +1 -1
- package/dist/layers/index.d.ts +6 -6
- package/dist/layers/index.js +3 -3
- package/dist/loupe/index.d.ts +7 -13
- package/dist/loupe/index.js +2 -2
- package/dist/passthrough/weasel-canvas.d.ts +3 -343
- package/dist/passthrough/weasel-canvas.js +1 -1
- package/dist/passthrough/weasel-ui.d.ts +141 -2866
- package/dist/passthrough/weasel-ui.js +2 -2
- package/dist/primitives/index.js +4 -4
- package/dist/state/index.d.ts +3 -3
- package/dist/state/index.js +4 -2
- package/dist/state/index.js.map +1 -1
- package/dist/styles.css +74 -5
- package/dist/surface/index.d.ts +17 -2
- package/dist/surface/index.js +3 -2
- package/dist/ui/layers/index.js +2 -2
- package/dist/undo/index.d.ts +6 -5
- package/package.json +8 -8
- package/src/annotations/AnnotationOverlay.tsx +10 -6
- package/src/annotations/Annotations.less +6 -0
- package/src/annotations/Annotations.overlay.test.tsx +113 -0
- package/src/annotations/MarkList.tsx +3 -2
- package/src/canvas/CanvasStack.tsx +8 -13
- package/src/canvas/useOrbit.test.ts +93 -1
- package/src/canvas/useOrbit.ts +41 -34
- package/src/canvas/usePanZoom.test.ts +102 -1
- package/src/canvas/usePanZoom.ts +54 -36
- package/src/config/builder.test.ts +5 -0
- package/src/config/builder.ts +6 -0
- package/src/config/types.ts +1 -0
- package/src/controls/ControlPanel.test.tsx +23 -0
- package/src/controls/ControlPanel.tsx +3 -0
- package/src/job/useJob.ts +1 -1
- package/src/lab/Lab.surface.test.tsx +8 -3
- package/src/lab/LabHeader.test.tsx +12 -0
- package/src/lab/LabHeader.tsx +16 -6
- package/src/lab/Workspace.tsx +1 -1
- package/src/layers/LayerList.test.tsx +72 -1
- package/src/layers/LayerList.tsx +40 -32
- package/src/passthrough/weasel-ui.test.ts +9 -0
- package/src/passthrough/weasel-ui.ts +4 -0
- package/src/primitives/FloatingPanel.test.tsx +82 -0
- package/src/primitives/FloatingPanel.tsx +59 -41
- package/src/primitives/ZoomControl.tsx +2 -0
- package/src/state/store.ts +10 -0
- package/src/state/types.ts +3 -0
- package/src/surface/AGENTS.md +11 -1
- package/src/surface/index.ts +7 -1
- package/src/surface/useSurfaceTile.ts +20 -2
- package/src/surface/useTiledSurface.ts +4 -1
- package/src/theme/Interstellar.stories.tsx +4 -3
- package/src/theme/base.less +39 -1
- package/src/trial/Trial.less +27 -5
- package/src/trial/TrialBody.test.tsx +67 -0
- package/src/trial/TrialBody.tsx +155 -0
- package/src/trial/TrialChrome.tsx +18 -10
- package/src/trial/index.ts +2 -0
- package/dist/_dts/DrawCommand-B3bskUsC.d.ts +0 -564
- package/dist/_dts/PrefsForm-BkUJZx0A.d.ts +0 -204
- package/dist/_dts/fitViewToBounds-dZ2UDB6e.d.ts +0 -21
- package/dist/_dts/shapeKinds-Cx_rxwsa.d.ts +0 -87
- package/dist/_dts/types-C-gh9Ap-.d.ts +0 -695
- package/dist/chunk-6OEYTYML.js.map +0 -1
- package/dist/chunk-AE5CNVRU.js.map +0 -1
- package/dist/chunk-ESIQNQ6K.js.map +0 -1
- package/dist/chunk-HHGVISVZ.js.map +0 -1
- package/dist/chunk-HMFODCOX.js.map +0 -1
- package/dist/chunk-L5QJOOLV.js.map +0 -1
- package/dist/chunk-QB5SM4BM.js.map +0 -1
- package/dist/chunk-RBGKL7NF.js.map +0 -1
- package/dist/chunk-TO2FUOKF.js.map +0 -1
- package/dist/chunk-XJ6N32QP.js.map +0 -1
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
/** The value types a built-in pref leaf can hold. */
|
|
4
|
-
type ToolPrefKind = 'number' | 'boolean' | 'string' | 'enum' | 'color' | 'paint' | 'object';
|
|
5
|
-
interface ToolPrefBase<K extends string, Value> {
|
|
6
|
-
kind: K;
|
|
7
|
-
/** Human-readable label. */
|
|
8
|
-
name: string;
|
|
9
|
-
/** Longer help text — shown in tooltips / a settings pane. */
|
|
10
|
-
description: string;
|
|
11
|
-
/** Fallback when nothing is persisted. */
|
|
12
|
-
default: Value;
|
|
13
|
-
/** Hide from a host app's settings UI by default. */
|
|
14
|
-
hidden?: boolean;
|
|
15
|
-
/** Render full-width with no label row in schema-driven settings UIs
|
|
16
|
-
* (weasel-ui `PrefsForm` honors this for leaves whose control brings
|
|
17
|
-
* its own chrome). */
|
|
18
|
-
block?: boolean;
|
|
19
|
-
/** Glyph naming this leaf in a host UI's icon set (weasel-ui resolves it
|
|
20
|
-
* against `ICON_PATHS`). A plain string because core ships no icon set and
|
|
21
|
-
* cannot depend on one. Read where a leaf's `name` has nowhere to go — a
|
|
22
|
-
* `pair`ed row is labeled by the pair, so its fields have only the glyph
|
|
23
|
-
* to tell them apart. */
|
|
24
|
-
icon?: string;
|
|
25
|
-
/** Row-pairing hint for compact property UIs (weasel-ui
|
|
26
|
-
* `SelectionPanel`): leaves sharing a `pair` id render side-by-side
|
|
27
|
-
* on one row labeled with the `pair` string (e.g. `'Position'` for
|
|
28
|
-
* `pose.x` / `pose.y`). Purely presentational. */
|
|
29
|
-
pair?: string;
|
|
30
|
-
}
|
|
31
|
-
/** How a schema-driven UI should present a number pref. */
|
|
32
|
-
type ToolPrefNumberControl = 'input' | 'slider';
|
|
33
|
-
/** How a schema-driven UI should present a boolean pref. */
|
|
34
|
-
type ToolPrefBooleanControl = 'checkbox' | 'switch' | 'toggle';
|
|
35
|
-
/** How a schema-driven UI should present a string pref. */
|
|
36
|
-
type ToolPrefStringControl = 'input' | 'textarea';
|
|
37
|
-
/** How a schema-driven UI should present an enum pref. */
|
|
38
|
-
type ToolPrefEnumControl = 'select' | 'radio' | 'toggle';
|
|
39
|
-
/** Display-unit conversion for number leaves whose stored value uses a
|
|
40
|
-
* canonical unit the user shouldn't see (e.g. radians stored, degrees
|
|
41
|
-
* shown). The stored value stays canonical; UIs convert at the edge. */
|
|
42
|
-
interface ToolPrefNumberUnit {
|
|
43
|
-
toDisplay: (stored: number) => number;
|
|
44
|
-
fromDisplay: (display: number) => number;
|
|
45
|
-
/** Shown after the input, e.g. `'°'`. */
|
|
46
|
-
suffix?: string;
|
|
47
|
-
}
|
|
48
|
-
/** A numeric pref, optionally bounded and stepped, and optionally stored in a
|
|
49
|
-
* different unit from the one shown. */
|
|
50
|
-
interface ToolPrefNumber extends ToolPrefBase<'number', number> {
|
|
51
|
-
min?: number;
|
|
52
|
-
max?: number;
|
|
53
|
-
step?: number;
|
|
54
|
-
control?: ToolPrefNumberControl;
|
|
55
|
-
unit?: ToolPrefNumberUnit;
|
|
56
|
-
}
|
|
57
|
-
/** An on/off pref. */
|
|
58
|
-
interface ToolPrefBoolean extends ToolPrefBase<'boolean', boolean> {
|
|
59
|
-
control?: ToolPrefBooleanControl;
|
|
60
|
-
/** The label a `toggle` shows, since a `pair`ed row is named by the pair
|
|
61
|
-
* rather than by the leaf. `name` stays the accessible name. */
|
|
62
|
-
short?: string;
|
|
63
|
-
}
|
|
64
|
-
/** A free-text pref. */
|
|
65
|
-
interface ToolPrefString extends ToolPrefBase<'string', string> {
|
|
66
|
-
control?: ToolPrefStringControl;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Stored-value bridge for an enum leaf whose value is not the option string —
|
|
70
|
-
* the counterpart of {@link ToolPrefNumberUnit}, which does the same for a
|
|
71
|
-
* number stored in a canonical unit.
|
|
72
|
-
*
|
|
73
|
-
* A dash array is the case that needs it: `Stroke.dash` stores lengths, and
|
|
74
|
-
* the thing a person chooses is a style. The presets scale by the stroke's
|
|
75
|
-
* width, so both directions are given the object's other fields — a style is
|
|
76
|
-
* meaningless without the width it is a multiple of.
|
|
77
|
-
*/
|
|
78
|
-
interface ToolPrefEnumEncoding<T extends string = string> {
|
|
79
|
-
/**
|
|
80
|
-
* The option `stored` reads as, or `undefined` for none — which a UI shows
|
|
81
|
-
* the way it shows a mixed selection, by selecting nothing.
|
|
82
|
-
*
|
|
83
|
-
* `siblings` is the object the leaf is a field of, or `undefined` when the
|
|
84
|
-
* node does not hold that object (and for a top-level leaf, which has none).
|
|
85
|
-
*/
|
|
86
|
-
read: (stored: unknown, siblings: Record<string, unknown> | undefined) => T | undefined;
|
|
87
|
-
/** What to store for `option`. `undefined` removes the field. */
|
|
88
|
-
write: (option: T, siblings: Record<string, unknown> | undefined) => unknown;
|
|
89
|
-
}
|
|
90
|
-
/** A pref with a fixed set of labeled choices. */
|
|
91
|
-
interface ToolPrefEnum<T extends string = string> extends ToolPrefBase<'enum', T> {
|
|
92
|
-
/** `short` is the label a segmented control uses when a full one would not
|
|
93
|
-
* fit — a capital or two. `icon` names a glyph in the host UI's set
|
|
94
|
-
* (weasel-ui resolves it against `ICON_PATHS`) and outranks `short` where
|
|
95
|
-
* it resolves. It is a plain string because core ships no icon set and
|
|
96
|
-
* cannot depend on one. The full `label` stays the accessible name, so
|
|
97
|
-
* neither the abbreviation nor the glyph becomes the only thing naming
|
|
98
|
-
* the option.
|
|
99
|
-
*
|
|
100
|
-
* `disabled` marks an option a control reports but cannot author — the
|
|
101
|
-
* value a stored form reads as when it matches nothing offered. Dropping it
|
|
102
|
-
* from the list instead would leave the control selecting nothing and
|
|
103
|
-
* claiming the field is unset. */
|
|
104
|
-
options: readonly {
|
|
105
|
-
value: T;
|
|
106
|
-
label: string;
|
|
107
|
-
short?: string;
|
|
108
|
-
icon?: string;
|
|
109
|
-
disabled?: boolean;
|
|
110
|
-
}[];
|
|
111
|
-
control?: ToolPrefEnumControl;
|
|
112
|
-
encoding?: ToolPrefEnumEncoding<T>;
|
|
113
|
-
}
|
|
114
|
-
/** A single color, stored as a hex string. For a value that may also be a
|
|
115
|
-
* gradient or a pattern, use {@link ToolPrefPaint} instead. */
|
|
116
|
-
interface ToolPrefColor extends ToolPrefBase<'color', string> {
|
|
117
|
-
/** Value is `#rrggbb`, or `#rrggbbaa` when `alpha` is set (UIs then
|
|
118
|
-
* offer an opacity control). */
|
|
119
|
-
alpha?: boolean;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Open leaf: any node with a `kind` outside the built-ins. Schema-driven
|
|
123
|
-
* UIs (weasel-ui `PrefsForm` / `SelectionPanel`) dispatch it to an
|
|
124
|
-
* app-supplied renderer. Deliberately NOT index-signatured so concrete
|
|
125
|
-
* app interfaces stay assignable. Mirrors weasel-ui's `PrefCustom`.
|
|
126
|
-
*/
|
|
127
|
-
type ToolPrefCustom = ToolPrefBase<string, unknown>;
|
|
128
|
-
/**
|
|
129
|
-
* A whole `FillStyle`, not a color inside one. Use it wherever the value is
|
|
130
|
-
* the tagged paint union — a solid color, a pattern, a gradient — rather
|
|
131
|
-
* than a hex string.
|
|
132
|
-
*
|
|
133
|
-
* Addressing `…fill.color` instead reads `undefined` off a gradient (so the
|
|
134
|
-
* control shows its default and claims the text is black) and writes a
|
|
135
|
-
* hybrid `{ fill: 'gradient', stops, color }` that the renderer's structural
|
|
136
|
-
* `'color' in paint` checks then paint flat solid. The union has to be
|
|
137
|
-
* edited as a union.
|
|
138
|
-
*/
|
|
139
|
-
interface ToolPrefPaint extends ToolPrefBase<'paint', unknown> {
|
|
140
|
-
/** Offer an opacity control alongside the color. */
|
|
141
|
-
alpha?: boolean;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* A leaf whose value is one object, with its own fields hanging off it.
|
|
145
|
-
*
|
|
146
|
-
* A compound value — a stroke, a shadow, a pattern spec — could be described
|
|
147
|
-
* as several sibling leaves addressing into it (`data.stroke.width`,
|
|
148
|
-
* `data.stroke.cap`). It shouldn't be: each control would then write one field
|
|
149
|
-
* of a value it can only half see, and writing into something that is not an
|
|
150
|
-
* object yet corrupts it. Here the fields are `children` of one leaf, and
|
|
151
|
-
* every edit commits the parent object whole.
|
|
152
|
-
*
|
|
153
|
-
* `children` paths are relative to the object. They are ordinary leaves, so a
|
|
154
|
-
* field that is itself a union (a stroke's `paint`) declares the kind that
|
|
155
|
-
* edits that union. A child may also be a {@link ToolPrefGroup}, which
|
|
156
|
-
* organises the fields under a heading without contributing to the path —
|
|
157
|
-
* the same rule group keys follow at the top level. A `TextStyle` needs it:
|
|
158
|
-
* its character and paragraph fields belong to one value but read as two
|
|
159
|
-
* lists.
|
|
160
|
-
*/
|
|
161
|
-
interface ToolPrefObject extends ToolPrefBase<'object', unknown> {
|
|
162
|
-
children: Record<string, ToolPrefLeaf | ToolPrefGroup>;
|
|
163
|
-
/**
|
|
164
|
-
* Lift a non-object value into the object form, for a consumer field that
|
|
165
|
-
* may also be held as a scalar. Called before a child edit is applied;
|
|
166
|
-
* without it a scalar-valued leaf shows its children empty and refuses the
|
|
167
|
-
* edit.
|
|
168
|
-
*/
|
|
169
|
-
fromScalar?: (value: unknown) => Record<string, unknown>;
|
|
170
|
-
}
|
|
171
|
-
/** One built-in pref leaf. `ToolPrefLeaf` widens this to include
|
|
172
|
-
* app-defined kinds. */
|
|
173
|
-
type ToolPref = ToolPrefNumber | ToolPrefBoolean | ToolPrefString | ToolPrefEnum | ToolPrefColor | ToolPrefPaint | ToolPrefObject;
|
|
174
|
-
/** Built-in or app-defined leaf. */
|
|
175
|
-
type ToolPrefLeaf = ToolPref | ToolPrefCustom;
|
|
176
|
-
/** Nestable group: branch nodes a tool can use to organize its prefs. */
|
|
177
|
-
interface ToolPrefGroup {
|
|
178
|
-
/** Heading for the group's rows. **Empty means no heading** — for a group
|
|
179
|
-
* that exists to organise, not to name: one whose children are themselves
|
|
180
|
-
* groups carrying the labels a reader needs. Give it a name whenever the
|
|
181
|
-
* name is the referent (a `Border` group over `Top` / `Right` / `Bottom`
|
|
182
|
-
* reads as nothing without it). */
|
|
183
|
-
name: string;
|
|
184
|
-
description?: string;
|
|
185
|
-
children: Record<string, ToolPrefLeaf | ToolPrefGroup>;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/** What a {@link PrefRenderer} is given for the leaf it is rendering. */
|
|
189
|
-
interface PrefRenderContext {
|
|
190
|
-
/** Dotted path of the leaf within the schema root. */
|
|
191
|
-
path: string;
|
|
192
|
-
/** The schema node. App renderers narrow this to their own kind shape. */
|
|
193
|
-
pref: ToolPrefLeaf;
|
|
194
|
-
/** Current value — `values` at `path`, falling back to `pref.default`. */
|
|
195
|
-
value: unknown;
|
|
196
|
-
setValue: (value: unknown) => void;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Renders the control cell for one preference leaf. Returning `null`
|
|
200
|
-
* collapses the row.
|
|
201
|
-
*/
|
|
202
|
-
type PrefRenderer = (ctx: PrefRenderContext) => ReactNode;
|
|
203
|
-
|
|
204
|
-
export type { PrefRenderer as P, ToolPrefLeaf as T, ToolPrefGroup as a, ToolPref as b, ToolPrefBoolean as c, ToolPrefBooleanControl as d, ToolPrefColor as e, ToolPrefCustom as f, ToolPrefEnum as g, ToolPrefEnumControl as h, ToolPrefEnumEncoding as i, ToolPrefKind as j, ToolPrefNumber as k, ToolPrefNumberControl as l, ToolPrefNumberUnit as m, ToolPrefObject as n, ToolPrefPaint as o, PrefRenderContext as p, ToolPrefString as q, ToolPrefStringControl as r };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Axis-aligned rectangle in world space. Kit-wide `Bounds` shape used by
|
|
3
|
-
* selection, group, and viewport helpers. The optional `rotation` field
|
|
4
|
-
* (radians, around the AABB center) lets selection chrome attach a rotated
|
|
5
|
-
* orientation to an otherwise axis-aligned rect without needing a parallel
|
|
6
|
-
* type.
|
|
7
|
-
*/
|
|
8
|
-
interface Bounds {
|
|
9
|
-
x: number;
|
|
10
|
-
y: number;
|
|
11
|
-
width: number;
|
|
12
|
-
height: number;
|
|
13
|
-
rotation?: number;
|
|
14
|
-
}
|
|
15
|
-
/** Pixel dimensions of the canvas viewport. */
|
|
16
|
-
interface ViewportDims {
|
|
17
|
-
width: number;
|
|
18
|
-
height: number;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type { Bounds as B, ViewportDims as V };
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The kit's built-in shape kinds — one table, every other spelling derived.
|
|
3
|
-
*
|
|
4
|
-
* Lives in `core/` rather than beside the shape tools because both layers ask
|
|
5
|
-
* questions of the same set: the interactions layer decides whether
|
|
6
|
-
* `insertAction` can paint a live preview for a kind, and the canvas layer
|
|
7
|
-
* decides which shape tools `useBuiltinShapeTools` mounts and what
|
|
8
|
-
* `BUNDLE_TOOLS` / `defaultNodeRouting` / `defaultNodeProperties` enumerate.
|
|
9
|
-
*
|
|
10
|
-
* This module imports nothing on purpose: `useBuiltinShapeTools` imports the
|
|
11
|
-
* package barrel, so anything barrel-reachable that needs these lists at
|
|
12
|
-
* module-evaluation time must not route through it.
|
|
13
|
-
*/
|
|
14
|
-
/** What the kit knows about one built-in shape kind. */
|
|
15
|
-
interface ShapeKindDescriptor {
|
|
16
|
-
/** Mounted as a built-in shape tool by `useBuiltinShapeTools`, and so a
|
|
17
|
-
* member of `BuiltinShapeToolId` / `KIT_SHAPE_KINDS`. `image` is false:
|
|
18
|
-
* `useImageTool` needs a `src` and can't be auto-mounted. */
|
|
19
|
-
readonly tool: boolean;
|
|
20
|
-
/** `insertAction` emits an `insertPreview` overlay for this kind, and the
|
|
21
|
-
* dispatcher overlay layer knows how to draw it. Kinds without one still
|
|
22
|
-
* commit; they just have no live drag preview (`pen` and `lasso` don't
|
|
23
|
-
* route through `insertAction` at all). */
|
|
24
|
-
readonly insertPreview: boolean;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Declaration order is the enumeration order of every derived list —
|
|
28
|
-
* `KIT_SHAPE_KINDS`, and through it `defaultNodeRouting` /
|
|
29
|
-
* `defaultNodeProperties` / `BUNDLE_TOOLS.exhaustive`.
|
|
30
|
-
*/
|
|
31
|
-
declare const SHAPE_KINDS: {
|
|
32
|
-
readonly rect: {
|
|
33
|
-
readonly tool: true;
|
|
34
|
-
readonly insertPreview: true;
|
|
35
|
-
};
|
|
36
|
-
readonly ellipse: {
|
|
37
|
-
readonly tool: true;
|
|
38
|
-
readonly insertPreview: true;
|
|
39
|
-
};
|
|
40
|
-
readonly line: {
|
|
41
|
-
readonly tool: true;
|
|
42
|
-
readonly insertPreview: true;
|
|
43
|
-
};
|
|
44
|
-
readonly polygon: {
|
|
45
|
-
readonly tool: true;
|
|
46
|
-
readonly insertPreview: true;
|
|
47
|
-
};
|
|
48
|
-
readonly star: {
|
|
49
|
-
readonly tool: true;
|
|
50
|
-
readonly insertPreview: true;
|
|
51
|
-
};
|
|
52
|
-
readonly pen: {
|
|
53
|
-
readonly tool: true;
|
|
54
|
-
readonly insertPreview: false;
|
|
55
|
-
};
|
|
56
|
-
readonly pencil: {
|
|
57
|
-
readonly tool: true;
|
|
58
|
-
readonly insertPreview: true;
|
|
59
|
-
};
|
|
60
|
-
readonly lasso: {
|
|
61
|
-
readonly tool: true;
|
|
62
|
-
readonly insertPreview: false;
|
|
63
|
-
};
|
|
64
|
-
readonly text: {
|
|
65
|
-
readonly tool: true;
|
|
66
|
-
readonly insertPreview: true;
|
|
67
|
-
};
|
|
68
|
-
readonly image: {
|
|
69
|
-
readonly tool: false;
|
|
70
|
-
readonly insertPreview: true;
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
/** The keys of a shape-kind table whose descriptor sets `F` to `true`. */
|
|
74
|
-
type ShapeKindsWhere<T, F extends keyof ShapeKindDescriptor> = {
|
|
75
|
-
[K in keyof T]: T[K] extends Record<F, true> ? K : never;
|
|
76
|
-
}[keyof T];
|
|
77
|
-
/**
|
|
78
|
-
* Built-in shape tool ids handled by `useBuiltinShapeTools`. Each maps to a
|
|
79
|
-
* kit tool hook + a default `create` that produces a leaf node compatible
|
|
80
|
-
* with `PATH_PAINTER`.
|
|
81
|
-
*/
|
|
82
|
-
type BuiltinShapeToolId = ShapeKindsWhere<typeof SHAPE_KINDS, 'tool'>;
|
|
83
|
-
/** The insert kinds the kit's dispatcher overlay layer knows how to render.
|
|
84
|
-
* Consumer-defined kinds fall outside it: no live preview, commit unaffected. */
|
|
85
|
-
type KitInsertShape = ShapeKindsWhere<typeof SHAPE_KINDS, 'insertPreview'>;
|
|
86
|
-
|
|
87
|
-
export type { BuiltinShapeToolId as B, KitInsertShape as K };
|