@webflow/designer-extension-typings 2.0.29 → 2.0.30
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 +355 -166
- package/components.d.ts +173 -0
- package/element-settings-generated.d.ts +49 -0
- package/element-settings.d.ts +17 -0
- package/elements-generated.d.ts +1440 -556
- package/package.json +1 -1
- package/pages.d.ts +47 -0
package/components.d.ts
CHANGED
|
@@ -44,10 +44,176 @@ interface Component {
|
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
46
|
getInstanceCount(): Promise<number>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get all variants for this component, including the base variant.
|
|
50
|
+
* Variants are returned in display order: base variant first (always `id: 'base'`),
|
|
51
|
+
* followed by style variants in the order they appear in the component's variant field.
|
|
52
|
+
*
|
|
53
|
+
* @returns A Promise resolving to an array of Variant objects. Each variant includes:
|
|
54
|
+
* - `id`: The unique identifier for the variant
|
|
55
|
+
* - `name`: The display name of the variant
|
|
56
|
+
* - `isSelected`: Indicates which variant is currently active in the Designer's editing context.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* const component = (await webflow.getAllComponents())[0];
|
|
61
|
+
* const variants = await component.getVariants();
|
|
62
|
+
* console.log(variants);
|
|
63
|
+
* // [{ id: 'base', name: 'Primary', isSelected: true }, { id: 'xxxx', name: 'Secondary', isSelected: false }]
|
|
64
|
+
*
|
|
65
|
+
* // Find which variant is currently being edited
|
|
66
|
+
* const activeVariant = variants.find(v => v.isSelected);
|
|
67
|
+
* console.log(`Currently editing: ${activeVariant.name}`);
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
getVariants(): Promise<Variant[]>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Get the currently selected variant for this component.
|
|
74
|
+
* The selected variant reflects the Designer's current editing
|
|
75
|
+
* context (which variant frame is active in Component Canvas).
|
|
76
|
+
*
|
|
77
|
+
* @returns A promise that resolves to the currently selected Variant.
|
|
78
|
+
* If no variant is explicitly selected, returns the base variant.
|
|
79
|
+
* Note: The returned variant will always have `isSelected: true`
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* const variant = await heroComponent.getSelectedVariant();
|
|
84
|
+
* console.log(variant.name); // "Primary"
|
|
85
|
+
* console.log(variant.isSelected); // always true
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
getSelectedVariant(): Promise<Variant>;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Set the selected variant for this component in the Designer.
|
|
92
|
+
* Accepts an options object ({ name } or { id }) or a string shorthand for variant ID.
|
|
93
|
+
* Use 'base' or { id: 'base' } to select the base variant.
|
|
94
|
+
* @param options - Variant to select by name, by id, or string shorthand for id
|
|
95
|
+
* @returns A promise that resolves when the variant is selected.
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* await heroComponent.setSelectedVariant('variant-dark');
|
|
99
|
+
* await heroComponent.setSelectedVariant({ name: 'Dark Mode' });
|
|
100
|
+
* await heroComponent.setSelectedVariant({ id: 'base' });
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
setSelectedVariant(
|
|
104
|
+
options: SetSelectedVariantOptions | string
|
|
105
|
+
): Promise<null>;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Get the settings (name, group, description) of a component.
|
|
109
|
+
* @returns A Promise resolving to the component's settings.
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* const settings = await component.getSettings();
|
|
113
|
+
* console.log(settings.name); // 'Hero Section'
|
|
114
|
+
* console.log(settings.group); // 'Sections'
|
|
115
|
+
* console.log(settings.description); // 'A reusable hero'
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
getSettings(): Promise<ComponentSettings>;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Update one or more settings on a component. All fields are optional.
|
|
122
|
+
* Updates happen immediately without requiring an explicit save().
|
|
123
|
+
* @param settings - A partial object of settings to update.
|
|
124
|
+
* @returns A Promise that resolves when the update is complete.
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* await component.setSettings({ group: 'Legacy' }); // Set the group
|
|
128
|
+
* await component.setSettings({ name: 'Hero v2', description: 'Redesigned hero' }); // Set the name and description
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
setSettings(settings: Partial<ComponentSettings>): Promise<null>;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Select variant by display name. */
|
|
135
|
+
interface SetSelectedVariantByName {
|
|
136
|
+
name: string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Select variant by ID. */
|
|
140
|
+
interface SetSelectedVariantById {
|
|
141
|
+
id: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Options for setSelectedVariant — select by name or by id. */
|
|
145
|
+
type SetSelectedVariantOptions =
|
|
146
|
+
| SetSelectedVariantByName
|
|
147
|
+
| SetSelectedVariantById;
|
|
148
|
+
|
|
149
|
+
interface Variant {
|
|
150
|
+
/** The variant ID. The base variant always has id 'base'. */
|
|
151
|
+
readonly id: string;
|
|
152
|
+
/** The display name of the variant. */
|
|
153
|
+
readonly name: string;
|
|
154
|
+
/**
|
|
155
|
+
* Indicates which variant is currently active in the Designer's editing context.
|
|
156
|
+
* This reflects global Designer state (which variant frame is selected in Component Canvas),
|
|
157
|
+
* not the component definition.
|
|
158
|
+
* The base variant has `isSelected: true` when no variant is active.
|
|
159
|
+
*/
|
|
160
|
+
readonly isSelected: boolean;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Settings for a component, including name, group, and description.
|
|
165
|
+
*/
|
|
166
|
+
interface ComponentSettings {
|
|
167
|
+
/** The name of the component */
|
|
168
|
+
name: string;
|
|
169
|
+
/** The group/folder the component belongs to (empty string if not set) */
|
|
170
|
+
group: string;
|
|
171
|
+
/** The description of the component (empty string if not set) */
|
|
172
|
+
description: string;
|
|
47
173
|
}
|
|
48
174
|
|
|
49
175
|
type ComponentId = string;
|
|
50
176
|
|
|
177
|
+
/** Library info for an imported library component. */
|
|
178
|
+
interface ComponentLibraryInfo {
|
|
179
|
+
/** The library's display name. */
|
|
180
|
+
name: string | null;
|
|
181
|
+
/** The library's identifier. */
|
|
182
|
+
id: string;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** A single result returned by {@link webflow.searchComponents}. */
|
|
186
|
+
interface ComponentSearchResult {
|
|
187
|
+
/** The component's unique identifier. */
|
|
188
|
+
id: ComponentId;
|
|
189
|
+
/** Display name of the component. */
|
|
190
|
+
name: string;
|
|
191
|
+
/** Group/folder the component belongs to. */
|
|
192
|
+
group: string;
|
|
193
|
+
/** Component description. */
|
|
194
|
+
description: string;
|
|
195
|
+
/** Number of instances used across the site. */
|
|
196
|
+
instances: number;
|
|
197
|
+
/**
|
|
198
|
+
* Whether the current user can edit this component.
|
|
199
|
+
* Always `false` for library and code components.
|
|
200
|
+
* For site components, depends on the user's `canModifyComponents` permission.
|
|
201
|
+
*/
|
|
202
|
+
canEdit: boolean;
|
|
203
|
+
/** Library info if this is an imported library component, otherwise `null`. */
|
|
204
|
+
library: ComponentLibraryInfo | null;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** Options for {@link webflow.searchComponents}. */
|
|
208
|
+
interface SearchComponentsOptions {
|
|
209
|
+
/**
|
|
210
|
+
* Optional search query.
|
|
211
|
+
* Uses the same fuzzy search (FlexSearch, `tokenize: 'full'`) as the Components panel.
|
|
212
|
+
* When omitted, all components are returned in panel order.
|
|
213
|
+
*/
|
|
214
|
+
q?: string;
|
|
215
|
+
}
|
|
216
|
+
|
|
51
217
|
/**
|
|
52
218
|
* Options for creating a blank component.
|
|
53
219
|
*/
|
|
@@ -58,4 +224,11 @@ interface ComponentOptions {
|
|
|
58
224
|
group?: string;
|
|
59
225
|
/** A description for the component (optional) */
|
|
60
226
|
description?: string;
|
|
227
|
+
/**
|
|
228
|
+
* Determines if the source element is replaced in the canvas by a
|
|
229
|
+
* new instance of the created component after conversion.
|
|
230
|
+
* Only applies when a canvas element is supplied as the `root` argument.
|
|
231
|
+
* @default true
|
|
232
|
+
*/
|
|
233
|
+
replace?: boolean;
|
|
61
234
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// This file was automatically generated. See designer-extensions docs.
|
|
2
|
+
|
|
3
|
+
type BindableValueType =
|
|
4
|
+
| 'string'
|
|
5
|
+
| 'textContent'
|
|
6
|
+
| 'richText'
|
|
7
|
+
| 'boolean'
|
|
8
|
+
| 'color'
|
|
9
|
+
| 'date'
|
|
10
|
+
| 'link'
|
|
11
|
+
| 'url'
|
|
12
|
+
| 'email'
|
|
13
|
+
| 'phone'
|
|
14
|
+
| 'file'
|
|
15
|
+
| 'videoUrl'
|
|
16
|
+
| 'video'
|
|
17
|
+
| 'image'
|
|
18
|
+
| 'imageAsset'
|
|
19
|
+
| 'cmsImage'
|
|
20
|
+
| 'imageSet'
|
|
21
|
+
| 'number'
|
|
22
|
+
| 'enum'
|
|
23
|
+
| 'slot'
|
|
24
|
+
| 'reference'
|
|
25
|
+
| 'referenceSet'
|
|
26
|
+
| 'variant'
|
|
27
|
+
| 'filter'
|
|
28
|
+
| 'sort'
|
|
29
|
+
| 'selectedItems'
|
|
30
|
+
| 'visibility'
|
|
31
|
+
| 'booleanFilter';
|
|
32
|
+
|
|
33
|
+
type PropType =
|
|
34
|
+
| 'textContent'
|
|
35
|
+
| 'string'
|
|
36
|
+
| 'richText'
|
|
37
|
+
| 'link'
|
|
38
|
+
| 'image'
|
|
39
|
+
| 'video'
|
|
40
|
+
| 'number'
|
|
41
|
+
| 'boolean'
|
|
42
|
+
| 'variant'
|
|
43
|
+
| 'slot'
|
|
44
|
+
| 'id'
|
|
45
|
+
| 'booleanFilter'
|
|
46
|
+
| 'visibility'
|
|
47
|
+
| 'filter'
|
|
48
|
+
| 'sort'
|
|
49
|
+
| 'selectedItems';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface PropBindableSource {
|
|
2
|
+
sourceType: 'prop';
|
|
3
|
+
propId: string;
|
|
4
|
+
propName: string;
|
|
5
|
+
propGroup: string | null;
|
|
6
|
+
valueType: BindableValueType;
|
|
7
|
+
bindableTo: readonly BindableValueType[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type BindableSource = PropBindableSource;
|
|
11
|
+
|
|
12
|
+
interface SearchBindableSourcesOptions {
|
|
13
|
+
/** Filter to sources compatible with a specific element setting key (e.g., "altText", "src", "domId") */
|
|
14
|
+
settingKey?: string;
|
|
15
|
+
/** Filter to sources that produce a specific value type (e.g., "string", "imageAsset") */
|
|
16
|
+
valueType?: BindableValueType;
|
|
17
|
+
}
|