@pairdraw/design-jsx 0.0.0-stage → 0.16.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/LICENSE +21 -0
- package/README.md +48 -2
- package/dist/chunks/attributes.js +32 -0
- package/dist/chunks/attributes.js.map +1 -0
- package/dist/chunks/behaviours/elements.js +321 -0
- package/dist/chunks/behaviours/elements.js.map +1 -0
- package/dist/chunks/behaviours/render.js +368 -0
- package/dist/chunks/behaviours/render.js.map +1 -0
- package/dist/chunks/component-properties.js +809 -0
- package/dist/chunks/component-properties.js.map +1 -0
- package/dist/chunks/components.js +78 -0
- package/dist/chunks/components.js.map +1 -0
- package/dist/chunks/connectors.js +290 -0
- package/dist/chunks/connectors.js.map +1 -0
- package/dist/chunks/effects.js +57 -0
- package/dist/chunks/effects.js.map +1 -0
- package/dist/chunks/elements.js +618 -0
- package/dist/chunks/elements.js.map +1 -0
- package/dist/chunks/export/behaviours.js +113 -0
- package/dist/chunks/export/behaviours.js.map +1 -0
- package/dist/chunks/export/bindings.js +273 -0
- package/dist/chunks/export/bindings.js.map +1 -0
- package/dist/chunks/export/decoration.js +96 -0
- package/dist/chunks/export/decoration.js.map +1 -0
- package/dist/chunks/export/font.js +17 -0
- package/dist/chunks/export/font.js.map +1 -0
- package/dist/chunks/export/icons.js +34 -0
- package/dist/chunks/export/icons.js.map +1 -0
- package/dist/chunks/export/index.js +1390 -0
- package/dist/chunks/export/index.js.map +1 -0
- package/dist/chunks/fields.js +1065 -0
- package/dist/chunks/fields.js.map +1 -0
- package/dist/chunks/index.js +438 -0
- package/dist/chunks/index.js.map +1 -0
- package/dist/chunks/jsx-dev-runtime.js +16 -0
- package/dist/chunks/jsx-dev-runtime.js.map +1 -0
- package/dist/index.d.ts +543 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/jsx-dev-runtime.d.ts +2 -0
- package/dist/jsx-dev-runtime.js +2 -0
- package/dist/jsx-runtime.d.ts +44 -0
- package/dist/jsx-runtime.d.ts.map +1 -0
- package/dist/jsx-runtime.js +2 -0
- package/dist/tree.d.ts +261 -0
- package/dist/tree.d.ts.map +1 -0
- package/package.json +54 -4
- package/src/attributes.ts +30 -0
- package/src/behaviours/elements.ts +47 -0
- package/src/behaviours/index.ts +253 -0
- package/src/behaviours/render.ts +144 -0
- package/src/component-properties.ts +428 -0
- package/src/components.ts +109 -0
- package/src/connectors.ts +316 -0
- package/src/definitions.ts +277 -0
- package/src/effects.ts +80 -0
- package/src/elements.ts +321 -0
- package/src/enums.ts +182 -0
- package/src/export/behaviours.ts +143 -0
- package/src/export/bindings.ts +155 -0
- package/src/export/decoration.ts +39 -0
- package/src/export/font.ts +25 -0
- package/src/export/helpers.ts +75 -0
- package/src/export/icons.ts +42 -0
- package/src/export/index.ts +297 -0
- package/src/export/paint.ts +276 -0
- package/src/export/props.ts +369 -0
- package/src/export/state.ts +52 -0
- package/src/export/text.ts +155 -0
- package/src/export/value.ts +99 -0
- package/src/export/variables.ts +393 -0
- package/src/fields.ts +39 -0
- package/src/figjam-text.ts +37 -0
- package/src/global.d.ts +4 -0
- package/src/helpers.ts +135 -0
- package/src/index.ts +155 -0
- package/src/jsx-dev-runtime.ts +1 -0
- package/src/jsx-runtime.ts +51 -0
- package/src/mini-react.ts +23 -0
- package/src/overrides/effects.ts +39 -0
- package/src/overrides/fills.ts +56 -0
- package/src/overrides/state.ts +55 -0
- package/src/overrides/strokes.ts +109 -0
- package/src/overrides/text.ts +116 -0
- package/src/overrides/vector.ts +122 -0
- package/src/paints.ts +230 -0
- package/src/props-overrides.ts +481 -0
- package/src/reconcile.ts +134 -0
- package/src/reference/authoring.md +76 -0
- package/src/reference/examples.ts +49 -0
- package/src/reference.ts +19 -0
- package/src/refs.ts +48 -0
- package/src/render.ts +147 -0
- package/src/renderer.ts +598 -0
- package/src/scalar-bindings.ts +36 -0
- package/src/schema.ts +213 -0
- package/src/services.ts +36 -0
- package/src/shapes-with-text.ts +73 -0
- package/src/stickies.ts +72 -0
- package/src/streaming/index.ts +47 -0
- package/src/streaming/literals.ts +82 -0
- package/src/streaming/projection.ts +189 -0
- package/src/text-content.ts +233 -0
- package/src/transform.ts +78 -0
- package/src/tree.ts +285 -0
- package/src/types.ts +13 -0
- package/src/variables/graph.ts +265 -0
- package/src/variables/index.ts +124 -0
- package/src/variables/props.ts +77 -0
package/dist/tree.d.ts
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { Effect, Fill, SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
2
|
+
import { Color } from "@pairdraw/scene-graph/primitives";
|
|
3
|
+
//#region src/component-properties.d.ts
|
|
4
|
+
declare const PROPERTY_SYMBOL: unique symbol;
|
|
5
|
+
/**
|
|
6
|
+
* A component property, by its name in the component that holds it. Where it is placed picks
|
|
7
|
+
* its type: `text` on a text layer makes a TEXT property, `visible` a BOOLEAN one, and `of` on an
|
|
8
|
+
* instance an INSTANCE_SWAP one, whose default is the component that `of` names.
|
|
9
|
+
*/
|
|
10
|
+
interface ComponentProperty<T extends string | boolean = string | boolean> {
|
|
11
|
+
readonly [PROPERTY_SYMBOL]: true;
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly defaultValue: T;
|
|
14
|
+
}
|
|
15
|
+
declare function isComponentProperty(value: unknown): value is ComponentProperty;
|
|
16
|
+
/**
|
|
17
|
+
* Bind a field to a property of the component it is drawn in, created on first use: on the
|
|
18
|
+
* component set, for a variant, as Figma keeps them, or else on the component.
|
|
19
|
+
*/
|
|
20
|
+
declare function property<T extends string | boolean>(name: string, defaultValue: T): ComponentProperty<T>;
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/variables/index.d.ts
|
|
23
|
+
declare const VAR_SYMBOL: unique symbol;
|
|
24
|
+
declare const MODE_SYMBOL: unique symbol;
|
|
25
|
+
/**
|
|
26
|
+
* A value a variable holds in one mode: a color as a string or a `Color`, a number, a boolean,
|
|
27
|
+
* or another variable, which makes it an alias.
|
|
28
|
+
*/
|
|
29
|
+
type VariableInput = string | Color | number | boolean | DesignVariable;
|
|
30
|
+
/** A collection as `defineVars` and `defineMode` declare it; the first mode is the default. */
|
|
31
|
+
interface CollectionDefinition {
|
|
32
|
+
name: string;
|
|
33
|
+
modes: Array<{
|
|
34
|
+
name: string;
|
|
35
|
+
values: Record<string, VariableInput>;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A variable a field binds to. `defineVars` gives one its collection, which a render creates or
|
|
40
|
+
* updates; `designVar` names a variable the document already has, and may name its collection.
|
|
41
|
+
*/
|
|
42
|
+
interface DesignVariable {
|
|
43
|
+
readonly [VAR_SYMBOL]: true;
|
|
44
|
+
/** The variable's name, or for `designVar` without a collection, its name or ID. */
|
|
45
|
+
readonly name: string;
|
|
46
|
+
readonly collection?: CollectionDefinition | string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A mode a layer shows a collection in. `defineMode` gives it the collection it declares;
|
|
50
|
+
* `designMode` names a collection the document already has.
|
|
51
|
+
*/
|
|
52
|
+
interface DesignMode {
|
|
53
|
+
readonly [MODE_SYMBOL]: true;
|
|
54
|
+
readonly name: string;
|
|
55
|
+
readonly collection: CollectionDefinition | string;
|
|
56
|
+
}
|
|
57
|
+
declare function isVariable(value: unknown): value is DesignVariable;
|
|
58
|
+
declare function isMode(value: unknown): value is DesignMode;
|
|
59
|
+
/** Whether a value can be a variable's value: a color, a number, a boolean, or a variable. */
|
|
60
|
+
declare function isVariableInput(value: unknown): value is VariableInput;
|
|
61
|
+
/**
|
|
62
|
+
* A variable the document already has: by its name or ID, or by the names of its collection and
|
|
63
|
+
* itself, as `designMode` names a mode, for a name more than one collection has.
|
|
64
|
+
*/
|
|
65
|
+
declare function designVar(idOrName: string): DesignVariable;
|
|
66
|
+
declare function designVar(collection: string, name: string): DesignVariable;
|
|
67
|
+
/**
|
|
68
|
+
* Define a variable collection: its variables, by name, with their values in its first mode,
|
|
69
|
+
* named `mode` (Figma's `Mode 1` by default). A render that binds any of them creates the
|
|
70
|
+
* collection, or updates the one with that name, so running the JSX again changes nothing twice.
|
|
71
|
+
*/
|
|
72
|
+
declare function defineVars<T extends Record<string, VariableInput>>(collection: string, values: T, options?: {
|
|
73
|
+
mode?: string;
|
|
74
|
+
}): { [K in keyof T]: DesignVariable; };
|
|
75
|
+
/**
|
|
76
|
+
* Add a mode to a collection `defineVars` defined, with the values that differ from its first
|
|
77
|
+
* mode; the rest keep the first mode's values, as a mode Figma adds copies them.
|
|
78
|
+
*/
|
|
79
|
+
declare function defineMode(vars: Record<string, DesignVariable>, name: string, values: Record<string, VariableInput>): DesignMode;
|
|
80
|
+
/**
|
|
81
|
+
* A mode of a collection the document already has, by their names, or by the collection's ID
|
|
82
|
+
* when several collections share its name.
|
|
83
|
+
*/
|
|
84
|
+
declare function designMode(collection: string, mode: string): DesignMode;
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/tree.d.ts
|
|
87
|
+
interface TreeNode {
|
|
88
|
+
type: string;
|
|
89
|
+
props: Record<string, unknown>;
|
|
90
|
+
children: (TreeNode | string)[];
|
|
91
|
+
/** Where the element was written, when the source is known. */
|
|
92
|
+
source?: {
|
|
93
|
+
line: number;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
declare function isTreeNode(x: unknown): x is TreeNode;
|
|
97
|
+
/**
|
|
98
|
+
* Resolve any element-like value (ReactElement, TreeNode, function component)
|
|
99
|
+
* into a TreeNode. Handles recursive function components up to depth 100.
|
|
100
|
+
*/
|
|
101
|
+
declare function resolveToTree(element: unknown, depth?: number): TreeNode | null;
|
|
102
|
+
declare function node(type: string, props: {
|
|
103
|
+
children?: unknown;
|
|
104
|
+
[key: string]: unknown;
|
|
105
|
+
}): TreeNode;
|
|
106
|
+
type PaintProp = string | Color | Fill | DesignVariable;
|
|
107
|
+
type StyleProps = {
|
|
108
|
+
flex?: 'row' | 'col' | 'column';
|
|
109
|
+
flow?: 'auto' | 'ltr' | 'rtl';
|
|
110
|
+
dir?: 'auto' | 'ltr' | 'rtl';
|
|
111
|
+
gap?: number | DesignVariable;
|
|
112
|
+
wrap?: boolean;
|
|
113
|
+
rowGap?: number | DesignVariable;
|
|
114
|
+
columnGap?: number | DesignVariable;
|
|
115
|
+
justify?: 'start' | 'end' | 'center' | 'between' | 'around';
|
|
116
|
+
justifyContent?: 'start' | 'end' | 'center' | 'between' | 'around';
|
|
117
|
+
items?: 'start' | 'end' | 'center' | 'stretch' | 'baseline';
|
|
118
|
+
align?: 'start' | 'end' | 'center' | 'stretch' | 'baseline';
|
|
119
|
+
alignItems?: 'start' | 'end' | 'center' | 'stretch' | 'baseline';
|
|
120
|
+
grow?: number;
|
|
121
|
+
w?: number | 'fill' | 'hug' | DesignVariable;
|
|
122
|
+
h?: number | 'fill' | 'hug' | DesignVariable;
|
|
123
|
+
minW?: number;
|
|
124
|
+
maxW?: number;
|
|
125
|
+
minH?: number;
|
|
126
|
+
maxH?: number;
|
|
127
|
+
x?: number;
|
|
128
|
+
y?: number;
|
|
129
|
+
p?: number | DesignVariable;
|
|
130
|
+
px?: number | DesignVariable;
|
|
131
|
+
py?: number | DesignVariable;
|
|
132
|
+
pt?: number | DesignVariable;
|
|
133
|
+
pr?: number | DesignVariable;
|
|
134
|
+
pb?: number | DesignVariable;
|
|
135
|
+
pl?: number | DesignVariable;
|
|
136
|
+
bg?: PaintProp;
|
|
137
|
+
fill?: PaintProp;
|
|
138
|
+
fills?: PaintProp[];
|
|
139
|
+
stroke?: PaintProp;
|
|
140
|
+
strokeWidth?: number | DesignVariable;
|
|
141
|
+
strokeAlign?: 'inside' | 'outside' | 'center';
|
|
142
|
+
strokeDash?: number[] | boolean;
|
|
143
|
+
dashPattern?: number[];
|
|
144
|
+
rounded?: number | DesignVariable;
|
|
145
|
+
roundedTL?: number | DesignVariable;
|
|
146
|
+
roundedTR?: number | DesignVariable;
|
|
147
|
+
roundedBL?: number | DesignVariable;
|
|
148
|
+
roundedBR?: number | DesignVariable;
|
|
149
|
+
cornerSmoothing?: number;
|
|
150
|
+
opacity?: number | DesignVariable;
|
|
151
|
+
blendMode?: string;
|
|
152
|
+
mask?: boolean | 'alpha' | 'luminance' | 'vector';
|
|
153
|
+
rotate?: number;
|
|
154
|
+
rotation?: number;
|
|
155
|
+
/** Reflects the layer across its vertical centre line, before it turns. */
|
|
156
|
+
flipX?: boolean;
|
|
157
|
+
/** Reflects the layer across its horizontal centre line, before it turns. */
|
|
158
|
+
flipY?: boolean;
|
|
159
|
+
overflow?: 'hidden' | 'visible';
|
|
160
|
+
shadow?: string;
|
|
161
|
+
blur?: number;
|
|
162
|
+
effects?: Effect[];
|
|
163
|
+
size?: number | DesignVariable;
|
|
164
|
+
fontSize?: number | DesignVariable;
|
|
165
|
+
/** Pixels, or a percent of the font size such as `'150%'`. */
|
|
166
|
+
lineHeight?: number | `${number}%` | 'auto' | DesignVariable;
|
|
167
|
+
/** Pixels, or a percent of the font size such as `'5%'`. */
|
|
168
|
+
letterSpacing?: number | `${number}%` | DesignVariable;
|
|
169
|
+
/** OpenType features on or off by tag, as CSS's `font-feature-settings`: `{ tnum: true }`. */
|
|
170
|
+
fontFeatures?: Record<string, boolean>;
|
|
171
|
+
/** Variable-font axis values by tag, as CSS's `font-variation-settings`: `{ wght: 650 }`. */
|
|
172
|
+
fontVariations?: Record<string, number>;
|
|
173
|
+
/** The language the text is in, as a BCP 47 tag such as `de` or `sr-Latn`. */
|
|
174
|
+
lang?: string | null;
|
|
175
|
+
/**
|
|
176
|
+
* Whether a variable font's optical size follows the font size (`auto`, the default) or takes
|
|
177
|
+
* the `opsz` in `fontVariations` (`none`), as CSS's `font-optical-sizing`.
|
|
178
|
+
*/
|
|
179
|
+
fontOpticalSizing?: 'auto' | 'none';
|
|
180
|
+
font?: string;
|
|
181
|
+
fontFamily?: string;
|
|
182
|
+
weight?: number | 'bold' | 'medium' | 'normal';
|
|
183
|
+
fontWeight?: number | 'bold' | 'medium' | 'normal';
|
|
184
|
+
color?: PaintProp;
|
|
185
|
+
text?: string | ComponentProperty<string>;
|
|
186
|
+
characters?: string;
|
|
187
|
+
textAlign?: 'left' | 'center' | 'right' | 'justified';
|
|
188
|
+
textAlignHorizontal?: 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFIED';
|
|
189
|
+
textHorizontalAlignment?: 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFIED';
|
|
190
|
+
textAlignVertical?: 'TOP' | 'CENTER' | 'BOTTOM';
|
|
191
|
+
textVerticalAlignment?: 'TOP' | 'CENTER' | 'BOTTOM';
|
|
192
|
+
textAutoResize?: 'none' | 'width' | 'height';
|
|
193
|
+
};
|
|
194
|
+
type NodeProps = StyleProps & {
|
|
195
|
+
name?: string;
|
|
196
|
+
key?: string | number;
|
|
197
|
+
children?: unknown;
|
|
198
|
+
bind?: Record<string, unknown>;
|
|
199
|
+
visible?: boolean | ComponentProperty<boolean>;
|
|
200
|
+
/** The modes the layer shows collections in, as the Appearance panel sets them. */
|
|
201
|
+
mode?: DesignMode | DesignMode[];
|
|
202
|
+
[key: string]: unknown;
|
|
203
|
+
};
|
|
204
|
+
type BaseProps = NodeProps & {
|
|
205
|
+
properties?: never;
|
|
206
|
+
};
|
|
207
|
+
/** An `<Ellipse>`'s arc: angles in degrees, clockwise from three o'clock, and its hole. */
|
|
208
|
+
type EllipseProps = {
|
|
209
|
+
startAngle?: number;
|
|
210
|
+
endAngle?: number;
|
|
211
|
+
/** The hole as a share of the ellipse, from 0 (none) to 1. */
|
|
212
|
+
innerRadius?: number;
|
|
213
|
+
};
|
|
214
|
+
/** A `<Vector>`'s path, in SVG's syntax as `d` or as Figma's `vectorPaths`. */
|
|
215
|
+
type VectorProps = {
|
|
216
|
+
/** Path data as SVG writes it, filled under `fillRule`; an open subpath fills only without a stroke. */
|
|
217
|
+
d?: string;
|
|
218
|
+
fillRule?: 'nonzero' | 'evenodd';
|
|
219
|
+
/** Paths with their own winding rules, as export writes them; `NONE` draws an open path. */
|
|
220
|
+
paths?: Array<{
|
|
221
|
+
windingRule: 'NONZERO' | 'EVENODD' | 'NONE';
|
|
222
|
+
data: string;
|
|
223
|
+
}>;
|
|
224
|
+
};
|
|
225
|
+
type TextProps = BaseProps;
|
|
226
|
+
/** A `<Span>`'s props: the character styles of `<Text>`, under the same names. */
|
|
227
|
+
type SpanProps = Pick<StyleProps, 'size' | 'fontSize' | 'font' | 'fontFamily' | 'weight' | 'fontWeight' | 'color' | 'fill' | 'fills' | 'lineHeight' | 'letterSpacing' | 'fontFeatures' | 'fontVariations' | 'lang'> & {
|
|
228
|
+
key?: string | number;
|
|
229
|
+
style?: Record<string, unknown>;
|
|
230
|
+
italic?: boolean;
|
|
231
|
+
textDecoration?: 'none' | 'underline' | 'strikethrough';
|
|
232
|
+
textDecorationStyle?: 'solid' | 'dotted' | 'wavy';
|
|
233
|
+
textDecorationColor?: string | Color | Fill;
|
|
234
|
+
textDecorationThickness?: number | 'auto';
|
|
235
|
+
textUnderlineOffset?: number | 'auto';
|
|
236
|
+
textDecorationSkipInk?: boolean;
|
|
237
|
+
children?: unknown;
|
|
238
|
+
};
|
|
239
|
+
/** A `<Paragraph>`'s props: a list item at `level` 1–5, or a plain paragraph, and its spacing. */
|
|
240
|
+
type ParagraphProps = {
|
|
241
|
+
key?: string | number;
|
|
242
|
+
list?: 'ordered' | 'unordered';
|
|
243
|
+
level?: number;
|
|
244
|
+
spacing?: number;
|
|
245
|
+
listSpacing?: number;
|
|
246
|
+
indent?: number;
|
|
247
|
+
children?: unknown;
|
|
248
|
+
};
|
|
249
|
+
type ComponentProps = BaseProps;
|
|
250
|
+
type InstanceProps = NodeProps & {
|
|
251
|
+
component?: string;
|
|
252
|
+
componentId?: string;
|
|
253
|
+
of?: string | ComponentProperty<string>;
|
|
254
|
+
/** Show the instance's own properties on instances of the component it is in, as Figma does. */
|
|
255
|
+
exposed?: boolean;
|
|
256
|
+
/** Values by property ID or name, or an exposed nested instance's values by its name. */
|
|
257
|
+
properties?: Record<string, string | boolean | number | Record<string, string | boolean | number>>;
|
|
258
|
+
};
|
|
259
|
+
//#endregion
|
|
260
|
+
export { BaseProps, ComponentProperty, ComponentProps, DesignMode, DesignVariable, EllipseProps, InstanceProps, PaintProp, ParagraphProps, SpanProps, StyleProps, TextProps, TreeNode, VariableInput, VectorProps, defineMode, defineVars, designMode, designVar, isComponentProperty, isMode, isTreeNode, isVariable, isVariableInput, node, property, resolveToTree };
|
|
261
|
+
//# sourceMappingURL=tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.d.ts","names":[],"sources":["../src/component-properties.ts","../src/variables/index.ts","../src/tree.ts"],"mappings":";;;cAuBM;;;;;;UAOW,kBAAkB;YACvB;WACD;WACA,cAAc;;iBAGT,oBAAoB,iBAAiB,SAAS;;;;;iBAQ9C,SAAS,4BACvB,cACA,cAAc,IACb,kBAAkB;;;cC3Cf;cACA;;;;;KASM,yBAAyB,2BAA2B;;UAG/C;EACf;EACA,OAAO;IAAQ;IAAc,QAAQ,eAAe;;;;;;;UAOrC;YACL;;WAED;WACA,aAAa;;;;;;UAOP;YACL;WACD;WACA,YAAY;;iBAGP,WAAW,iBAAiB,SAAS;iBAIrC,OAAO,iBAAiB,SAAS;;iBAKjC,gBAAgB,iBAAiB,SAAS;;;;;iBAW1C,UAAU,mBAAmB;iBAC7B,UAAU,oBAAoB,eAAe;;;;;;iBAc7C,WAAW,UAAU,eAAe,gBAClD,oBACA,QAAQ,GACR;EAAW;OACP,WAAW,IAAI;;;;;iBAgBL,WACd,MAAM,eAAe,iBACrB,cACA,QAAQ,eAAe,iBACtB;;;;;iBAmBa,WAAW,oBAAoB,eAAe;;;UCnH7C;EACf;EACA,OAAO;EACP,WAAW;;EAEX;IAAW;;;iBAoBG,WAAW,aAAa,KAAK;;;;;iBA0B7B,cAAc,kBAAkB,iBAAY;iBAuC5C,KACd,cACA;EAAS;GAAqB;IAC7B;KASS,qBAAqB,QAAQ,OAAO;KAEpC;EACV;EACA;EACA;EACA,eAAe;EACf;EACA,kBAAkB;EAClB,qBAAqB;EACrB;EACA;EACA;EACA;EACA;EACA;EAEA,8BAA8B;EAC9B,8BAA8B;EAC9B;EACA;EACA;EACA;EAEA;EACA;EAEA,aAAa;EACb,cAAc;EACd,cAAc;EACd,cAAc;EACd,cAAc;EACd,cAAc;EACd,cAAc;EAEd,KAAK;EACL,OAAO;EACP,QAAQ;EACR,SAAS;EACT,uBAAuB;EACvB;EACA;EACA;EACA,mBAAmB;EACnB,qBAAqB;EACrB,qBAAqB;EACrB,qBAAqB;EACrB,qBAAqB;EACrB;EACA,mBAAmB;EACnB;EACA;EACA;EACA;;EAEA;;EAEA;EACA;EACA;EACA;EACA,UAAU;EAEV,gBAAgB;EAChB,oBAAoB;;EAEpB,8CAA8C;;EAE9C,wCAAwC;;EAExC,eAAe;;EAEf,iBAAiB;;EAEjB;;;;;EAKA;EACA;EACA;EACA;EACA;EACA,QAAQ;EACR,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA;EACA;;KAGG,YAAY;EACf;EACA;EACA;EACA,OAAO;EACP,oBAAoB;;EAEpB,OAAO,aAAa;GACnB;;KAGS,YAAY;EAAc;;;KAG1B;EACV;EACA;;EAEA;;;KAGU;;EAEV;EACA;;EAEA,QAAQ;IAAQ;IAA6C;;;KAEnD,YAAY;;KAGZ,YAAY,KACtB;EAgBA;EACA,QAAQ;EACR;EACA;EACA;EACA,+BAA+B,QAAQ;EACvC;EACA;EACA;EACA;;;KAIU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU,iBAAiB;KAEjB,gBAAgB;EAC1B;EACA;EACA,cAAc;;EAEd;;EAEA,aAAa,2CAA2C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pairdraw/design-jsx",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.16.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist",
|
|
7
|
+
"src",
|
|
8
|
+
"README.md"
|
|
9
|
+
],
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@lezer/common": "^1.5.2",
|
|
14
|
+
"@lezer/javascript": "^1.5.4",
|
|
15
|
+
"@pairdraw/emit": "^0.16.0",
|
|
16
|
+
"acorn": "^8.18.0",
|
|
17
|
+
"dedent": "^1.7.2",
|
|
18
|
+
"entities": "^8.0.0",
|
|
19
|
+
"es-toolkit": "^1.52.0",
|
|
20
|
+
"sucrase": "^3.35.1",
|
|
21
|
+
"valibot": "^1.5.0"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@pairdraw/scene-graph": "^0.16.0"
|
|
25
|
+
},
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js",
|
|
30
|
+
"default": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./jsx-runtime": {
|
|
33
|
+
"types": "./dist/jsx-runtime.d.ts",
|
|
34
|
+
"import": "./dist/jsx-runtime.js",
|
|
35
|
+
"default": "./dist/jsx-runtime.js"
|
|
36
|
+
},
|
|
37
|
+
"./jsx-dev-runtime": {
|
|
38
|
+
"types": "./dist/jsx-dev-runtime.d.ts",
|
|
39
|
+
"import": "./dist/jsx-dev-runtime.js",
|
|
40
|
+
"default": "./dist/jsx-dev-runtime.js"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"imports": {
|
|
44
|
+
"#design-jsx/*": {
|
|
45
|
+
"types": "./src/*.ts",
|
|
46
|
+
"default": "./dist/*.js"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"type": "module",
|
|
50
|
+
"sideEffects": false,
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "git+https://github.com/BadryansahBangsawan/pairdraw.git",
|
|
54
|
+
"directory": "packages/design-jsx"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { parser } from '@lezer/javascript'
|
|
2
|
+
|
|
3
|
+
import type { JSXAttributeSource } from './export'
|
|
4
|
+
|
|
5
|
+
const elementParser = parser.configure({ dialect: 'jsx', top: 'SingleExpression' })
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Split JSX attributes, such as `w={200} bg="#FF0000"`, into each attribute as written.
|
|
9
|
+
* Throws on a syntax error or a spread, whose props cannot be named.
|
|
10
|
+
*/
|
|
11
|
+
export function parseJSXAttributes(source: string): JSXAttributeSource[] {
|
|
12
|
+
const element = `<Frame ${source} />`
|
|
13
|
+
const tree = elementParser.parse(element)
|
|
14
|
+
const attributes: JSXAttributeSource[] = []
|
|
15
|
+
const invalid = () => new SyntaxError(`Invalid JSX attributes: ${source}`)
|
|
16
|
+
tree.iterate({
|
|
17
|
+
enter(node) {
|
|
18
|
+
if (node.type.isError || node.name === 'JSXSpreadAttribute') throw invalid()
|
|
19
|
+
if (node.name !== 'JSXAttribute') return undefined
|
|
20
|
+
const key = node.node.firstChild
|
|
21
|
+
if (key?.name !== 'JSXIdentifier') throw invalid()
|
|
22
|
+
attributes.push({
|
|
23
|
+
name: element.slice(key.from, key.to),
|
|
24
|
+
source: element.slice(node.from, node.to)
|
|
25
|
+
})
|
|
26
|
+
return false
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
return attributes
|
|
30
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { node, type BaseProps, type TreeNode } from '../tree'
|
|
2
|
+
import { REKA_ELEMENTS, type BindingProp, type RekaNamespaces } from './index'
|
|
3
|
+
|
|
4
|
+
/** Props of a Reka element: a frame's, plus the behaviour a root binds and a group item's component. */
|
|
5
|
+
export interface RekaProps extends BaseProps {
|
|
6
|
+
modelValue?: BindingProp
|
|
7
|
+
open?: BindingProp
|
|
8
|
+
disabled?: BindingProp
|
|
9
|
+
filled?: BindingProp
|
|
10
|
+
/** The variant property whose values draw rest, hover, pressed, focus, and disabled. */
|
|
11
|
+
states?: string
|
|
12
|
+
min?: number
|
|
13
|
+
max?: number
|
|
14
|
+
step?: number
|
|
15
|
+
defaultValue?: number
|
|
16
|
+
/** For a group's item: the component or set it is an instance of. */
|
|
17
|
+
of?: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type Child = TreeNode | string
|
|
21
|
+
export type RekaElement = (props?: RekaProps, ...children: Child[]) => TreeNode
|
|
22
|
+
|
|
23
|
+
/** One Reka namespace as element functions, such as `Switch.Root` and `Switch.Thumb`. */
|
|
24
|
+
function namespace<N extends keyof RekaNamespaces>(name: N) {
|
|
25
|
+
const element =
|
|
26
|
+
(part: string): RekaElement =>
|
|
27
|
+
(props = {}, ...children) =>
|
|
28
|
+
node(`${name}.${part}`, children.length > 0 ? { ...props, children } : props)
|
|
29
|
+
return Object.fromEntries(
|
|
30
|
+
Object.keys(REKA_ELEMENTS[name]).map((part) => [part, element(part)])
|
|
31
|
+
) as { [P in keyof RekaNamespaces[N]]: RekaElement }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const Button = namespace('Button')
|
|
35
|
+
export const Toggle = namespace('Toggle')
|
|
36
|
+
export const Switch = namespace('Switch')
|
|
37
|
+
export const Checkbox = namespace('Checkbox')
|
|
38
|
+
export const RadioGroup = namespace('RadioGroup')
|
|
39
|
+
export const ToggleGroup = namespace('ToggleGroup')
|
|
40
|
+
export const Slider = namespace('Slider')
|
|
41
|
+
export const Progress = namespace('Progress')
|
|
42
|
+
export const Tabs = namespace('Tabs')
|
|
43
|
+
export const Collapsible = namespace('Collapsible')
|
|
44
|
+
export const Accordion = namespace('Accordion')
|
|
45
|
+
export const NumberField = namespace('NumberField')
|
|
46
|
+
export const TextField = namespace('TextField')
|
|
47
|
+
export const Textarea = namespace('Textarea')
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'
|
|
2
|
+
import {
|
|
3
|
+
behaviourFromSpec,
|
|
4
|
+
withBehaviour,
|
|
5
|
+
type BehaviourKind,
|
|
6
|
+
type BehaviourSpec
|
|
7
|
+
} from '@pairdraw/scene-graph/behaviours'
|
|
8
|
+
import { createComponentPropertyId } from '@pairdraw/scene-graph/components'
|
|
9
|
+
import { createSlotProperty } from '@pairdraw/scene-graph/slots'
|
|
10
|
+
|
|
11
|
+
import { node, type TreeNode } from '../tree'
|
|
12
|
+
|
|
13
|
+
/** What a Reka UI element is to the component it builds. */
|
|
14
|
+
export type RekaRole =
|
|
15
|
+
| { role: 'root'; kind: BehaviourKind }
|
|
16
|
+
/** A Reka subcomponent drawn by a slot of the component, such as a switch's thumb. */
|
|
17
|
+
| { role: 'part'; part: string }
|
|
18
|
+
/** One of a slot's repeated parts, such as a tab trigger in the tab list. */
|
|
19
|
+
| { role: 'repeat'; container: string }
|
|
20
|
+
/** The text layer a text value shows, which becomes the field's text property. */
|
|
21
|
+
| { role: 'input'; valueId: string }
|
|
22
|
+
/** A Reka wrapper with no state of its own, drawn as a plain frame. */
|
|
23
|
+
| { role: 'frame' }
|
|
24
|
+
|
|
25
|
+
const root = (kind: BehaviourKind): RekaRole => ({ role: 'root', kind })
|
|
26
|
+
const part = (id: string): RekaRole => ({ role: 'part', part: id })
|
|
27
|
+
const repeat = (container: string): RekaRole => ({ role: 'repeat', container })
|
|
28
|
+
const input = (valueId: string): RekaRole => ({ role: 'input', valueId })
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Design JSX's Reka UI elements, by namespace and part, after Reka's own anatomy: `Switch.Root`
|
|
32
|
+
* is a main component that behaves as a switch and `Switch.Thumb` its thumb slot. A group's
|
|
33
|
+
* `Item` is the component of its items when written on its own, and an item when it names one
|
|
34
|
+
* with `of`, as an `Instance` does.
|
|
35
|
+
*/
|
|
36
|
+
const REKA_PARTS = {
|
|
37
|
+
Button: { Root: root('button') },
|
|
38
|
+
Toggle: { Root: root('toggle') },
|
|
39
|
+
Switch: { Root: root('switch'), Thumb: part('thumb') },
|
|
40
|
+
Checkbox: { Root: root('checkbox'), Indicator: part('indicator') },
|
|
41
|
+
RadioGroup: { Root: root('radioGroup'), Item: root('radio'), Indicator: part('indicator') },
|
|
42
|
+
ToggleGroup: { Root: root('toggleGroup'), Item: root('toggle') },
|
|
43
|
+
Slider: {
|
|
44
|
+
Root: root('slider'),
|
|
45
|
+
Track: part('track'),
|
|
46
|
+
Range: part('range'),
|
|
47
|
+
Thumb: part('thumb')
|
|
48
|
+
},
|
|
49
|
+
Progress: { Root: root('progress'), Track: part('track'), Indicator: part('indicator') },
|
|
50
|
+
Tabs: {
|
|
51
|
+
Root: root('tabs'),
|
|
52
|
+
List: part('list'),
|
|
53
|
+
Trigger: repeat('list'),
|
|
54
|
+
Content: repeat('panels')
|
|
55
|
+
},
|
|
56
|
+
Collapsible: { Root: root('collapsible'), Trigger: part('trigger'), Content: part('content') },
|
|
57
|
+
Accordion: {
|
|
58
|
+
Root: root('accordion'),
|
|
59
|
+
Item: root('collapsible'),
|
|
60
|
+
Header: { role: 'frame' },
|
|
61
|
+
Trigger: part('trigger'),
|
|
62
|
+
Content: part('content')
|
|
63
|
+
},
|
|
64
|
+
NumberField: {
|
|
65
|
+
Root: root('numberField'),
|
|
66
|
+
Input: input('text'),
|
|
67
|
+
Increment: part('increment'),
|
|
68
|
+
Decrement: part('decrement')
|
|
69
|
+
},
|
|
70
|
+
TextField: { Root: root('textField'), Input: input('value') },
|
|
71
|
+
Textarea: { Root: root('textarea'), Input: input('value') }
|
|
72
|
+
} as const satisfies Readonly<Record<string, Readonly<Record<string, RekaRole>>>>
|
|
73
|
+
|
|
74
|
+
/** Each Reka namespace and its parts, as typed elements are built from them. */
|
|
75
|
+
export type RekaNamespaces = typeof REKA_PARTS
|
|
76
|
+
|
|
77
|
+
/** The same elements, looked up by any element name, as parsing and export do. */
|
|
78
|
+
export const REKA_ELEMENTS: Readonly<Record<string, Readonly<Record<string, RekaRole>>>> =
|
|
79
|
+
REKA_PARTS
|
|
80
|
+
|
|
81
|
+
/** The container a repeated part goes in when written directly under its root. */
|
|
82
|
+
const CONTAINER_NAMES: Record<string, string> = { list: 'List', panels: 'Panels', items: 'Items' }
|
|
83
|
+
|
|
84
|
+
/** The role of a Reka element type such as `Switch.Thumb`, or undefined for other elements. */
|
|
85
|
+
export function rekaRole(type: string): RekaRole | undefined {
|
|
86
|
+
const dot = type.indexOf('.')
|
|
87
|
+
if (dot === -1) return undefined
|
|
88
|
+
const namespace = REKA_ELEMENTS[type.slice(0, dot)] as Record<string, RekaRole> | undefined
|
|
89
|
+
return namespace?.[type.slice(dot + 1)]
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** The element type for a part container that JSX leaves implicit. */
|
|
93
|
+
const containerType = (container: string) => `reka-container:${container}`
|
|
94
|
+
|
|
95
|
+
export function containerPart(type: string): string | undefined {
|
|
96
|
+
return type.startsWith('reka-container:') ? type.slice('reka-container:'.length) : undefined
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Whether an element names an existing component, as an item of a group does. */
|
|
100
|
+
export function namesComponent(props: Record<string, unknown>): boolean {
|
|
101
|
+
return props.of !== undefined || props.component !== undefined || props.componentId !== undefined
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const GROUPS = new Set<BehaviourKind>(['radioGroup', 'toggleGroup', 'accordion'])
|
|
105
|
+
|
|
106
|
+
/** The container slot a child written directly under a root belongs in, if any. */
|
|
107
|
+
function containerOf(child: TreeNode, kind: BehaviourKind): string | undefined {
|
|
108
|
+
const role = rekaRole(child.type)
|
|
109
|
+
if (role?.role === 'repeat') return role.container
|
|
110
|
+
if (GROUPS.has(kind) && role?.role === 'root' && namesComponent(child.props)) return 'items'
|
|
111
|
+
return undefined
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* A root's children with repeated parts and group items that are written directly under it
|
|
116
|
+
* wrapped in their container slot, as the behaviour binds them: tab panels in Panels, a group's
|
|
117
|
+
* items in Items. Containers the JSX writes itself are kept.
|
|
118
|
+
*/
|
|
119
|
+
export function wrapRepeatedParts(tree: TreeNode, kind: BehaviourKind): TreeNode['children'] {
|
|
120
|
+
const result: TreeNode['children'] = []
|
|
121
|
+
let open: TreeNode | null = null
|
|
122
|
+
for (const child of tree.children) {
|
|
123
|
+
const container = typeof child === 'string' ? undefined : containerOf(child, kind)
|
|
124
|
+
if (!container || typeof child === 'string') {
|
|
125
|
+
open = null
|
|
126
|
+
result.push(child)
|
|
127
|
+
continue
|
|
128
|
+
}
|
|
129
|
+
if (open?.type !== containerType(container)) {
|
|
130
|
+
open = node(containerType(container), {
|
|
131
|
+
name: CONTAINER_NAMES[container] ?? container,
|
|
132
|
+
flex: kind === 'toggleGroup' ? 'row' : 'col',
|
|
133
|
+
gap: kind === 'toggleGroup' ? 4 : 8
|
|
134
|
+
})
|
|
135
|
+
result.push(open)
|
|
136
|
+
}
|
|
137
|
+
open.children.push(child)
|
|
138
|
+
}
|
|
139
|
+
return result
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** What a root collects from its parts while they render. */
|
|
143
|
+
export interface RekaScope {
|
|
144
|
+
kind: BehaviourKind
|
|
145
|
+
ownerId: string
|
|
146
|
+
/** Slot property ids by part, shared by every variant of a set. */
|
|
147
|
+
slots: Map<string, string>
|
|
148
|
+
/** Text property ids by value, defined once on the root. */
|
|
149
|
+
texts: Map<string, string>
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function createScope(kind: BehaviourKind, ownerId: string): RekaScope {
|
|
153
|
+
return { kind, ownerId, slots: new Map(), texts: new Map() }
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Make a rendered part frame its part's slot, with the id the part has in this component. */
|
|
157
|
+
export function bindPart(graph: SceneGraph, scope: RekaScope, frame: SceneNode, partId: string) {
|
|
158
|
+
const id = scope.slots.get(partId) ?? createComponentPropertyId()
|
|
159
|
+
if (!createSlotProperty(graph, frame.id, id))
|
|
160
|
+
throw new Error(`<${partId}> must be inside a main component`)
|
|
161
|
+
scope.slots.set(partId, id)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** Make a rendered text layer show the value's text property, defined on the root. */
|
|
165
|
+
export function bindInput(
|
|
166
|
+
graph: SceneGraph,
|
|
167
|
+
scope: RekaScope,
|
|
168
|
+
text: SceneNode,
|
|
169
|
+
valueId: string,
|
|
170
|
+
propertyName: string
|
|
171
|
+
) {
|
|
172
|
+
let id = scope.texts.get(valueId)
|
|
173
|
+
if (!id) {
|
|
174
|
+
id = createComponentPropertyId()
|
|
175
|
+
scope.texts.set(valueId, id)
|
|
176
|
+
const owner = graph.getNode(scope.ownerId)
|
|
177
|
+
graph.updateNode(scope.ownerId, {
|
|
178
|
+
componentPropertyDefinitions: [
|
|
179
|
+
...(owner?.componentPropertyDefinitions ?? []),
|
|
180
|
+
{ id, name: propertyName, type: 'TEXT', defaultValue: text.text }
|
|
181
|
+
]
|
|
182
|
+
})
|
|
183
|
+
}
|
|
184
|
+
graph.updateNode(text.id, {
|
|
185
|
+
componentPropertyReferences: [
|
|
186
|
+
...text.componentPropertyReferences,
|
|
187
|
+
{ propertyId: id, field: 'TEXT' }
|
|
188
|
+
]
|
|
189
|
+
})
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** Root props that describe the behaviour rather than the drawing. */
|
|
193
|
+
export const BEHAVIOUR_PROPS = [
|
|
194
|
+
'modelValue',
|
|
195
|
+
'open',
|
|
196
|
+
'disabled',
|
|
197
|
+
'filled',
|
|
198
|
+
'states',
|
|
199
|
+
'min',
|
|
200
|
+
'max',
|
|
201
|
+
'step',
|
|
202
|
+
'defaultValue'
|
|
203
|
+
] as const
|
|
204
|
+
|
|
205
|
+
/** A value bound to a component property by name; a variant property may name its on and off. */
|
|
206
|
+
export type BindingProp = string | { property: string; on?: string; off?: string }
|
|
207
|
+
|
|
208
|
+
function isBinding(value: unknown): value is BindingProp {
|
|
209
|
+
return (
|
|
210
|
+
typeof value === 'string' ||
|
|
211
|
+
(typeof value === 'object' &&
|
|
212
|
+
value !== null &&
|
|
213
|
+
'property' in value &&
|
|
214
|
+
typeof value.property === 'string')
|
|
215
|
+
)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** The spec a root's props give: values by property name, a range, and states. */
|
|
219
|
+
function rootSpec(kind: BehaviourKind, props: Record<string, unknown>): BehaviourSpec {
|
|
220
|
+
const values: NonNullable<BehaviourSpec['values']> = {}
|
|
221
|
+
const main = kind === 'collapsible' ? props.open : props.modelValue
|
|
222
|
+
if (isBinding(main)) values[kind === 'collapsible' ? 'open' : 'value'] = main
|
|
223
|
+
if (isBinding(props.disabled)) values.disabled = props.disabled
|
|
224
|
+
if (isBinding(props.filled)) values.filled = props.filled
|
|
225
|
+
const range = Object.fromEntries(
|
|
226
|
+
(['min', 'max', 'step'] as const).flatMap((key) =>
|
|
227
|
+
typeof props[key] === 'number' ? [[key, props[key]]] : []
|
|
228
|
+
)
|
|
229
|
+
)
|
|
230
|
+
if (typeof props.defaultValue === 'number') range.default = props.defaultValue
|
|
231
|
+
const spec: BehaviourSpec = { kind }
|
|
232
|
+
if (Object.keys(values).length) spec.values = values
|
|
233
|
+
if (Object.keys(range).length) spec.numbers = { value: range }
|
|
234
|
+
if (typeof props.states === 'string') spec.states = props.states
|
|
235
|
+
return spec
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** Store the behaviour a rendered root describes, with the slots and texts its parts made. */
|
|
239
|
+
export function finishRoot(
|
|
240
|
+
graph: SceneGraph,
|
|
241
|
+
scope: RekaScope,
|
|
242
|
+
props: Record<string, unknown>
|
|
243
|
+
): void {
|
|
244
|
+
const owner = graph.getNode(scope.ownerId)
|
|
245
|
+
if (!owner) return
|
|
246
|
+
const behaviour = behaviourFromSpec(graph, owner, rootSpec(scope.kind, props))
|
|
247
|
+
behaviour.parts = { ...behaviour.parts, ...Object.fromEntries(scope.slots) }
|
|
248
|
+
behaviour.texts = {
|
|
249
|
+
...behaviour.texts,
|
|
250
|
+
...Object.fromEntries([...scope.texts].map(([valueId, id]) => [valueId, { propertyId: id }]))
|
|
251
|
+
}
|
|
252
|
+
graph.updateNode(owner.id, { pluginData: withBehaviour(owner, behaviour) })
|
|
253
|
+
}
|