@webflow/designer-extension-typings 2.0.33 → 2.0.35
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/api.d.ts +7 -1
- package/components.d.ts +143 -10
- package/element-settings.d.ts +55 -21
- package/elements-generated.d.ts +998 -339
- package/package.json +1 -1
- package/styles.d.ts +112 -28
package/api.d.ts
CHANGED
|
@@ -345,7 +345,13 @@ interface SharedApi {
|
|
|
345
345
|
* const heroComponent = await webflow.getComponent('4a669354-353a-97eb-795c-4471b406e043');
|
|
346
346
|
* await webflow.openCanvas(heroComponent);
|
|
347
347
|
*
|
|
348
|
-
* // Open a component canvas by
|
|
348
|
+
* // Open a component canvas by component instance (ComponentElement)
|
|
349
|
+
* const selectedElement = await webflow.getSelectedElement();
|
|
350
|
+
* if (selectedElement?.type === 'ComponentInstance') {
|
|
351
|
+
* await webflow.openCanvas(selectedElement);
|
|
352
|
+
* }
|
|
353
|
+
*
|
|
354
|
+
* // Open a page canvas by page
|
|
349
355
|
* const myPage = await webflow.getPage('123');
|
|
350
356
|
* await webflow.openCanvas(myPage);
|
|
351
357
|
* ```
|
package/components.d.ts
CHANGED
|
@@ -69,6 +69,20 @@ interface Component {
|
|
|
69
69
|
*/
|
|
70
70
|
getVariants(): Promise<Variant[]>;
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Create a new variant for this component.
|
|
74
|
+
* @param name - The name for the new variant
|
|
75
|
+
* @returns A promise that resolves to the newly created Variant.
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* const quickVariant = await heroComponent.createVariant("Dark Mode");
|
|
79
|
+
* const variant = await heroComponent.createVariant({ name: "Dark Mode" });
|
|
80
|
+
* console.log(quickVariant.name); // "Dark Mode"
|
|
81
|
+
* console.log(variant.name); // "Dark Mode"
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
createVariant(name: string): Promise<Variant>;
|
|
85
|
+
|
|
72
86
|
/**
|
|
73
87
|
* Create a new variant for this component.
|
|
74
88
|
* @param options - The name for the new variant and optional selection behavior
|
|
@@ -249,6 +263,30 @@ interface Component {
|
|
|
249
263
|
*/
|
|
250
264
|
getProps(): Promise<Prop[]>;
|
|
251
265
|
|
|
266
|
+
/**
|
|
267
|
+
* * Get a single prop definition by its ID.
|
|
268
|
+
* @param propId - The unique ID of the prop.
|
|
269
|
+
* @returns A Promise resolving to the prop definition.
|
|
270
|
+
*/
|
|
271
|
+
getProp(propId: string): Promise<Prop>;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Get a prop definition by its display name.
|
|
275
|
+
* Matches only ungrouped props.
|
|
276
|
+
* Use the `groupName` overload for grouped props.
|
|
277
|
+
* @param name - The display name of the prop.
|
|
278
|
+
* @returns A Promise resolving to the prop definition.
|
|
279
|
+
*/
|
|
280
|
+
getPropByName(name: string): Promise<Prop>;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Get a prop definition by its group and display name.
|
|
284
|
+
* @param groupName - The group the prop belongs to.
|
|
285
|
+
* @param name - The display name of the prop within that group.
|
|
286
|
+
* @returns A Promise resolving to the prop definition.
|
|
287
|
+
*/
|
|
288
|
+
getPropByName(groupName: string, name: string): Promise<Prop>;
|
|
289
|
+
|
|
252
290
|
/**
|
|
253
291
|
* Create a new prop on this component.
|
|
254
292
|
*
|
|
@@ -279,6 +317,57 @@ interface Component {
|
|
|
279
317
|
* @returns A Promise resolving to an array of created props, in the same order as the input.
|
|
280
318
|
*/
|
|
281
319
|
createProps(options: CreatePropOptions[]): Promise<Prop[]>;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Update an existing prop's settings.
|
|
323
|
+
*
|
|
324
|
+
* Accepts a partial update object — only the fields being changed need to be
|
|
325
|
+
* provided. Cannot change a prop's `type` (immutable after creation).
|
|
326
|
+
* Name conflicts within the target group are auto-incremented. Setting a field
|
|
327
|
+
* to `null` clears it where applicable.
|
|
328
|
+
*
|
|
329
|
+
* @param propId - The ID of the prop to update.
|
|
330
|
+
* @param updates - A partial object with the fields to change.
|
|
331
|
+
* @returns A Promise resolving to the full updated prop.
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* ```ts
|
|
335
|
+
* const updated = await component.setProp(prop.id, {
|
|
336
|
+
* name: 'Hero Heading',
|
|
337
|
+
* tooltip: 'The main headline for the hero section',
|
|
338
|
+
* });
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
setProp(propId: string, updates: SetPropOptions): Promise<Prop>;
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Update an existing prop's settings.
|
|
345
|
+
*
|
|
346
|
+
* @param updates - A partial object with `id` and the fields to change.
|
|
347
|
+
* @returns A Promise resolving to the full updated prop.
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* ```ts
|
|
351
|
+
* const updated = await component.setProp({
|
|
352
|
+
* id: prop.id,
|
|
353
|
+
* name: 'Hero Heading',
|
|
354
|
+
* });
|
|
355
|
+
* ```
|
|
356
|
+
*/
|
|
357
|
+
setProp(updates: SetPropOptionsWithId): Promise<Prop>;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Remove a prop from this component.
|
|
361
|
+
* @param propId - The ID of the prop to remove.
|
|
362
|
+
* @returns A Promise that resolves when the prop has been removed.
|
|
363
|
+
* @example
|
|
364
|
+
* ```ts
|
|
365
|
+
* const props = await component.getProps();
|
|
366
|
+
* const unused = props.find(p => p.name === 'Old Heading');
|
|
367
|
+
* await component.removeProp(unused.id);
|
|
368
|
+
* ```
|
|
369
|
+
*/
|
|
370
|
+
removeProp(propId: string): Promise<null>;
|
|
282
371
|
}
|
|
283
372
|
|
|
284
373
|
/**
|
|
@@ -386,12 +475,12 @@ interface Prop {
|
|
|
386
475
|
readonly defaultValue: ResolvedValue | null;
|
|
387
476
|
/** Whether the text input allows multiple lines. Present on string and textContent props. */
|
|
388
477
|
multiline?: boolean;
|
|
389
|
-
/** The minimum allowed value. Present on number props. */
|
|
390
|
-
min?: number;
|
|
391
|
-
/** The maximum allowed value. Present on number props. */
|
|
392
|
-
max?: number;
|
|
393
|
-
/** The number of decimal places (precision) allowed. Present on number props. */
|
|
394
|
-
decimals?: number;
|
|
478
|
+
/** The minimum allowed value. Present on number props, otherwise null when unset. */
|
|
479
|
+
min?: number | null;
|
|
480
|
+
/** The maximum allowed value. Present on number props, otherwise null when unset. */
|
|
481
|
+
max?: number | null;
|
|
482
|
+
/** The number of decimal places (precision) allowed. Present on number props, otherwise null when unset. */
|
|
483
|
+
decimals?: number | null;
|
|
395
484
|
/** The label shown when the boolean is true. Present on boolean props. */
|
|
396
485
|
trueLabel?: string;
|
|
397
486
|
/** The label shown when the boolean is false. Present on boolean props. */
|
|
@@ -402,16 +491,29 @@ interface Prop {
|
|
|
402
491
|
// createProp input types (discriminated union on `type`)
|
|
403
492
|
// ---------------------------------------------------------------------------
|
|
404
493
|
|
|
405
|
-
/**
|
|
406
|
-
|
|
494
|
+
/**
|
|
495
|
+
* Fields shared between creating and updating props.
|
|
496
|
+
* Used as the base interface for both {@link CreatePropCommon} and {@link SetPropOptions}.
|
|
497
|
+
*/
|
|
498
|
+
interface PropSettingsCommon {
|
|
499
|
+
/** Display name for the prop. */
|
|
500
|
+
name?: string;
|
|
501
|
+
/** Group/folder name. Props with the same group appear together. `null` to ungroup. */
|
|
502
|
+
group?: string | null;
|
|
503
|
+
/** Tooltip text shown on hover. `null` to remove. */
|
|
504
|
+
tooltip?: string | null;
|
|
505
|
+
/** The default value for this prop (shape depends on type). `null` to clear. */
|
|
506
|
+
defaultValue?: ResolvedValue | null;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/** Common fields shared by all prop types when creating. */
|
|
510
|
+
interface CreatePropCommon extends PropSettingsCommon {
|
|
407
511
|
/** Display name for the prop. Auto-incremented on conflicts within the same group. */
|
|
408
512
|
name: string;
|
|
409
513
|
/** Group/folder name. Props with the same group appear together in the props panel. */
|
|
410
514
|
group?: string;
|
|
411
515
|
/** Tooltip text shown on hover in the props panel. */
|
|
412
516
|
tooltip?: string;
|
|
413
|
-
/** The default value for this prop, or null if not set or not applicable. */
|
|
414
|
-
defaultValue?: ResolvedValue | null;
|
|
415
517
|
}
|
|
416
518
|
|
|
417
519
|
interface TextContentPropInput extends CreatePropCommon {
|
|
@@ -497,6 +599,37 @@ type CreatePropOptions =
|
|
|
497
599
|
| IdPropInput
|
|
498
600
|
| AltTextPropInput;
|
|
499
601
|
|
|
602
|
+
// ---------------------------------------------------------------------------
|
|
603
|
+
// setProp input types
|
|
604
|
+
// ---------------------------------------------------------------------------
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* Options for updating an existing prop on a component.
|
|
608
|
+
* All fields are optional — only the fields being changed need to be provided.
|
|
609
|
+
* Cannot change a prop's `type` (immutable after creation).
|
|
610
|
+
* Setting a field to `null` clears it where applicable.
|
|
611
|
+
*/
|
|
612
|
+
interface SetPropOptions extends PropSettingsCommon {
|
|
613
|
+
/** Whether the text input supports multiple lines. textContent only. */
|
|
614
|
+
multiline?: boolean;
|
|
615
|
+
/** Minimum allowed value. number only. `null` clears the constraint. */
|
|
616
|
+
min?: number | null;
|
|
617
|
+
/** Maximum allowed value. number only. `null` clears the constraint. */
|
|
618
|
+
max?: number | null;
|
|
619
|
+
/** Number of decimal places allowed. number only. `null` clears the constraint. */
|
|
620
|
+
decimals?: number | null;
|
|
621
|
+
/** Label shown when the value is true (e.g., "Visible"). boolean only. `null` clears. */
|
|
622
|
+
trueLabel?: string | null;
|
|
623
|
+
/** Label shown when the value is false (e.g., "Hidden"). boolean only. `null` clears. */
|
|
624
|
+
falseLabel?: string | null;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/** {@link SetPropOptions} with an inline `id` for the single-argument overload. */
|
|
628
|
+
interface SetPropOptionsWithId extends SetPropOptions {
|
|
629
|
+
/** The ID of the prop to update. */
|
|
630
|
+
id: string;
|
|
631
|
+
}
|
|
632
|
+
|
|
500
633
|
/**
|
|
501
634
|
* Settings for a component, including name, group, and description.
|
|
502
635
|
*/
|
package/element-settings.d.ts
CHANGED
|
@@ -74,32 +74,66 @@ interface SearchBindableSourcesOptions {
|
|
|
74
74
|
valueType?: BindableValueType;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
/** An attribute on an element, as returned by `getSettings()`. */
|
|
78
|
+
interface ElementAttribute {
|
|
79
|
+
/** The attribute name — a plain string, or binding metadata if bound to a data source. Null when the underlying binding can't be resolved. */
|
|
80
|
+
name: string | BindingValue | null;
|
|
81
|
+
/** The attribute's value — a plain string, or binding metadata if bound to a data source. Null when the underlying binding can't be resolved. */
|
|
82
|
+
value: string | BindingValue | null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** An attribute on an element, as returned by `getResolvedSettings()`. */
|
|
86
|
+
interface ResolvedElementAttribute {
|
|
87
|
+
/** The evaluated string name. Null when a binding can't be resolved at design time. */
|
|
88
|
+
name: string | null;
|
|
89
|
+
/** The evaluated string value. Null when a binding can't be resolved at design time. */
|
|
90
|
+
value: string | null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** An attribute to set on an element via `setSettings()`. */
|
|
94
|
+
interface SetElementAttribute {
|
|
95
|
+
/** A plain string name, or a binding descriptor. Name bindings are only supported on DOM elements. */
|
|
96
|
+
name: string | BindingInput;
|
|
97
|
+
/** A plain string value, or a binding descriptor to bind to a data source. */
|
|
98
|
+
value: string | BindingInput;
|
|
99
|
+
}
|
|
100
|
+
|
|
77
101
|
/**
|
|
78
|
-
* Input to element.setSettings()
|
|
79
|
-
*
|
|
80
|
-
* Values can be
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
102
|
+
* Input to `element.setSettings()`.
|
|
103
|
+
*
|
|
104
|
+
* Each key is a setting (e.g., `domId`, `tag`, `assetId`). Values can be a
|
|
105
|
+
* static value, a binding descriptor, or `null` to reset to default.
|
|
106
|
+
*
|
|
107
|
+
* The `attributes` key is special: it takes a `SetElementAttribute[]` that
|
|
108
|
+
* replaces all attributes on the element (pass an empty array to remove
|
|
109
|
+
* them all). Only `attributes` accepts `SetElementAttribute[]` — other
|
|
110
|
+
* setting keys expect a value, binding descriptor, or `null`.
|
|
84
111
|
*/
|
|
85
|
-
|
|
112
|
+
interface SetSettingsInput {
|
|
113
|
+
[key: string]: ResolvedValue | BindingInput | SetElementAttribute[] | null;
|
|
114
|
+
}
|
|
86
115
|
|
|
87
116
|
/**
|
|
88
|
-
* Return type for element.getSettings()
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* Bound values include binding metadata
|
|
92
|
-
*
|
|
117
|
+
* Return type for `element.getSettings()`.
|
|
118
|
+
*
|
|
119
|
+
* Each key is a setting (e.g., `domId`, `tag`, `visibility`). Static values
|
|
120
|
+
* are returned as-is. Bound values include binding metadata. Null means the
|
|
121
|
+
* setting has no value and no default.
|
|
122
|
+
*
|
|
123
|
+
* `attributes` (when present) is the element's full attribute list.
|
|
93
124
|
*/
|
|
94
|
-
|
|
95
|
-
string
|
|
96
|
-
|
|
97
|
-
>;
|
|
125
|
+
interface ElementSettingSummaries {
|
|
126
|
+
[key: string]: ResolvedValue | BindingValue | ElementAttribute[] | null;
|
|
127
|
+
}
|
|
98
128
|
|
|
99
129
|
/**
|
|
100
|
-
* Return type for element.getResolvedSettings()
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
130
|
+
* Return type for `element.getResolvedSettings()`.
|
|
131
|
+
*
|
|
132
|
+
* Same keys as `getSettings()`, but every value is fully evaluated.
|
|
133
|
+
* Bindings that can't be resolved at design time are null.
|
|
134
|
+
*
|
|
135
|
+
* `attributes` (when present) contains the resolved attribute values.
|
|
104
136
|
*/
|
|
105
|
-
|
|
137
|
+
interface ResolvedElementSettings {
|
|
138
|
+
[key: string]: ResolvedValue | ResolvedElementAttribute[] | null;
|
|
139
|
+
}
|