@webflow/designer-extension-typings 2.0.31 → 2.0.33

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 CHANGED
@@ -29,6 +29,7 @@ interface SharedApi {
29
29
  * - siteId: the unique ID of the current Webflow site.
30
30
  * - siteName: the name of the current Webflow site.
31
31
  * - shortName: a shortened reference to the name of the current Webflow site.
32
+ * - kind: the type of site ('site' for standard Webflow sites).
32
33
  * - isPasswordProtected: whether the site is password protected.
33
34
  * - isPrivateStaging: whether the site has private staging turned on or not.
34
35
  * - domains: an array of objects representing the domains associated with the site, each containing the following properties:
@@ -42,6 +43,7 @@ interface SharedApi {
42
43
  * console.log('Site ID:', siteInfo.siteId);
43
44
  * console.log('Site Name:', siteInfo.siteName);
44
45
  * console.log('Shortened Site Name:', siteInfo.shortName);
46
+ * console.log('Site Kind:', siteInfo.kind);
45
47
  * console.log('Domains:', siteInfo.domains);
46
48
  * console.log('Workspace ID:', siteInfo.workspaceId);
47
49
  * console.log('Workspace Slug:', siteInfo.workspaceSlug);
@@ -51,6 +53,7 @@ interface SharedApi {
51
53
  siteId: string;
52
54
  siteName: string;
53
55
  shortName: string;
56
+ kind: 'site';
54
57
  isPasswordProtected: boolean;
55
58
  isPrivateStaging: boolean;
56
59
  workspaceId: string;
@@ -830,6 +833,27 @@ interface DesignerOnlyApi {
830
833
  event: 'pseudomode',
831
834
  callback: (pseudoMode: null | PseudoStateKey) => void
832
835
  ): Unsubscribe;
836
+ /**
837
+ * Subscribe to variant selection changes. The callback fires whenever the selected
838
+ * variant changes on the component canvas.
839
+ * @param event - The name of the event to subscribe to, specifically 'selectedvariant'.
840
+ * @param callback - A callback function receiving the newly selected Variant.
841
+ * @returns An Unsubscribe function that can be used to stop receiving notifications.
842
+ * @example
843
+ * ```ts
844
+ * const unsub = webflow.subscribe('selectedvariant', (variant) => {
845
+ * console.log('Variant changed:', variant.name);
846
+ * console.log('Variant ID:', variant.id);
847
+ * });
848
+ *
849
+ * // Later, to stop listening:
850
+ * unsub();
851
+ * ```
852
+ */
853
+ subscribe(
854
+ event: 'selectedvariant',
855
+ callback: (variant: Variant) => void
856
+ ): Unsubscribe;
833
857
  /**
834
858
  * Checks if the user has the ability to perform the given App Mode
835
859
  * @param appModes
package/components.d.ts CHANGED
@@ -132,6 +132,88 @@ interface Component {
132
132
  options: SetSelectedVariantOptions | string
133
133
  ): Promise<null>;
134
134
 
135
+ /**
136
+ * Reorder variants on this component by specifying an array of variant IDs
137
+ * in the desired order. Accepts variant IDs or `'base'`.
138
+ *
139
+ * When a partial list is provided, the listed variants are repositioned
140
+ * relative to the first item in the list while unlisted variants keep their
141
+ * existing relative order.
142
+ *
143
+ * @param variantIds - Array of variant IDs (or `'base'`) in the desired order.
144
+ * @returns A Promise that resolves when the reorder is complete.
145
+ * @example
146
+ * ```ts
147
+ * // Full reorder
148
+ * await component.reorderVariants(['base', 'variant-2', 'variant-1', 'variant-3']);
149
+ *
150
+ * // Partial reorder — move variant-1 and variant-3 together
151
+ * // Before: base, variant-1, variant-2, variant-3
152
+ * await component.reorderVariants(['variant-1', 'variant-3']);
153
+ * // After: base, variant-1, variant-3, variant-2
154
+ * ```
155
+ */
156
+ reorderVariants(variantIds: string[]): Promise<null>;
157
+
158
+ /**
159
+ * Delete a variant from this component by ID.
160
+ * The base variant cannot be deleted.
161
+ *
162
+ * @param options - An object containing the `id` of the variant to delete.
163
+ * @returns A promise that resolves when the variant has been deleted.
164
+ * @example
165
+ * ```ts
166
+ * await heroComponent.deleteVariant({ id: 'variant-456' });
167
+ * ```
168
+ */
169
+ deleteVariant(options: DeleteVariantOptions): Promise<null>;
170
+ /**
171
+ * Get a single variant by ID.
172
+ * Use `'base'` to retrieve the base variant.
173
+ * @param variantId - The variant ID, or `'base'` for the base variant
174
+ * @returns A Promise resolving to the Variant object.
175
+ * @example
176
+ * ```ts
177
+ * const variant = await component.getVariant('variant-123');
178
+ * console.log(variant.name); // "Dark Mode"
179
+ *
180
+ * const base = await component.getVariant('base');
181
+ * console.log(base.name); // "Primary"
182
+ * ```
183
+ */
184
+ getVariant(variantId: string): Promise<Variant>;
185
+
186
+ /**
187
+ * Update settings on a variant. Currently only `name` is supported.
188
+ * Use `'base'` as the variant ID to rename the base variant.
189
+ *
190
+ * @param variantId - The variant ID, or `'base'` for the base variant
191
+ * @param settings - An object with the properties to update
192
+ * @returns A Promise resolving to the updated Variant object.
193
+ * @example
194
+ * ```ts
195
+ * // Two-argument form
196
+ * const updated = await component.setVariant('variant-123', { name: 'Foo' });
197
+ *
198
+ * // Rename the base variant
199
+ * const base = await component.setVariant('base', { name: 'Default' });
200
+ * ```
201
+ */
202
+ setVariant(variantId: string, settings: {name: string}): Promise<Variant>;
203
+
204
+ /**
205
+ * Update settings on a variant using an options object.
206
+ * Currently only `name` is supported.
207
+ *
208
+ * @param options - An object containing the variant `id` and properties to update
209
+ * @returns A Promise resolving to the updated Variant object.
210
+ * @example
211
+ * ```ts
212
+ * const updated = await component.setVariant({ id: 'variant-123', name: 'Foo' });
213
+ * ```
214
+ */
215
+ setVariant(options: SetVariantOptions): Promise<Variant>;
216
+
135
217
  /**
136
218
  * Get the settings (name, group, description) of a component.
137
219
  * @returns A Promise resolving to the component's settings.
@@ -157,6 +239,46 @@ interface Component {
157
239
  * ```
158
240
  */
159
241
  setSettings(settings: Partial<ComponentSettings>): Promise<null>;
242
+
243
+ /**
244
+ * Get all prop definitions on this component.
245
+ * Returns all prop types including variant, visibility, filter, sort, selectedItems,
246
+ * and booleanFilter — not only the creatable types.
247
+ * Props are returned in panel display order: ungrouped first, then grouped.
248
+ * @returns A Promise resolving to an array of prop definitions.
249
+ */
250
+ getProps(): Promise<Prop[]>;
251
+
252
+ /**
253
+ * Create a new prop on this component.
254
+ *
255
+ * Supports all 10 creatable prop types. Name conflicts within the same group
256
+ * are auto-incremented (e.g., "Heading" → "Heading 2"). The returned `Prop`
257
+ * includes computed fields (`id`, `valueType`, `bindableTo`) so callers don't
258
+ * need a follow-up `getProps()` call.
259
+ *
260
+ * @param options - The prop definition including type, name, and optional settings.
261
+ * @returns A Promise resolving to the created prop with computed binding metadata.
262
+ *
263
+ * @example
264
+ * ```ts
265
+ * const prop = await component.createProp({
266
+ * type: 'textContent',
267
+ * name: 'Heading',
268
+ * group: 'Content',
269
+ * defaultValue: 'Welcome',
270
+ * });
271
+ * ```
272
+ */
273
+ createProp(options: CreatePropOptions): Promise<Prop>;
274
+
275
+ /**
276
+ * Create multiple props on this component in a single transaction.
277
+ * If any prop fails validation, no props are created.
278
+ * @param options - An array of prop definitions, each using the same shape as createProp.
279
+ * @returns A Promise resolving to an array of created props, in the same order as the input.
280
+ */
281
+ createProps(options: CreatePropOptions[]): Promise<Prop[]>;
160
282
  }
161
283
 
162
284
  /**
@@ -184,6 +306,19 @@ type SetSelectedVariantOptions =
184
306
  | SetSelectedVariantByName
185
307
  | SetSelectedVariantById;
186
308
 
309
+ /** Options for deleting a variant by ID. */
310
+ interface DeleteVariantOptions {
311
+ /** The ID of the variant to delete. The base variant ('base') cannot be deleted. */
312
+ id: string;
313
+ }
314
+ /** Options for setVariant — update variant settings by ID. */
315
+ interface SetVariantOptions {
316
+ /** The variant ID, or `'base'` for the base variant. */
317
+ id: string;
318
+ /** The new display name for the variant. */
319
+ name: string;
320
+ }
321
+
187
322
  interface Variant {
188
323
  /** The variant ID. The base variant always has id 'base'. */
189
324
  readonly id: string;
@@ -198,6 +333,170 @@ interface Variant {
198
333
  readonly isSelected: boolean;
199
334
  }
200
335
 
336
+ /**
337
+ * A prop definition on a component.
338
+ *
339
+ * `type` and `valueType` describe the same prop from two different angles:
340
+ * - `type` is the prop's structural category in the component definition
341
+ * (e.g. `'image'` for image asset props).
342
+ * - `valueType` is the data-binding value type used when binding a CMS field
343
+ * or variable to this prop (e.g. `'imageAsset'` for the same image prop).
344
+ * For most prop types these are identical. The only current exception is image
345
+ * asset props, where `type === 'image'` and `valueType === 'imageAsset'`.
346
+ */
347
+ interface Prop {
348
+ /** The field ID from the component's WFDL data type. */
349
+ readonly id: string;
350
+ /**
351
+ * The prop's structural category (e.g. `'string'`, `'boolean'`, `'image'`,
352
+ * `'variant'`, `'slot'`). Use this to determine which optional fields
353
+ * (`min`/`max`/`decimals`, `trueLabel`/`falseLabel`, `multiline`) are present.
354
+ */
355
+ readonly type: PropType;
356
+ /**
357
+ * The data-binding value type for this prop (e.g. `'string'`, `'boolean'`,
358
+ * `'imageAsset'`, `'variant'`). Use this when filtering which CMS fields or
359
+ * variables are compatible with this prop via `bindableTo`.
360
+ * Identical to `type` for all prop types except image asset props
361
+ * (`type: 'image'`, `valueType: 'imageAsset'`).
362
+ */
363
+ readonly valueType: BindableValueType;
364
+ /** The data-binding target types this prop can accept. */
365
+ readonly bindableTo: readonly BindableValueType[];
366
+ /** The display name for this prop (derived from its label). */
367
+ name: string;
368
+ /** The group name this prop belongs to, or null if ungrouped. */
369
+ group: string | null;
370
+ /** A tooltip description for this prop, or null if not set. */
371
+ tooltip: string | null;
372
+ /**
373
+ * The default value for this prop, or null if not set or not applicable.
374
+ *
375
+ * The shape depends on `valueType`:
376
+ * - `'string'` | `'number'` | `'id'` | `'altText'` → the raw primitive value
377
+ * - `'boolean'` → `true` or `false`
378
+ * - `'imageAsset'` → the asset ID string
379
+ * - `'link'` → `{ mode: string; to?: string | object; openInNewTab?: boolean; rel?: string }`
380
+ * - `'video'` → `{ src?: string; title?: string }`
381
+ * - `'textContent'` → the plain-text string extracted from the default children
382
+ * - `'richText'` → `{ innerText: string }`
383
+ * - `'variant'` | `'visibility'` | `'filter'` | `'sort'` | `'selectedItems'`
384
+ * → always `null`
385
+ */
386
+ readonly defaultValue: ResolvedValue | null;
387
+ /** Whether the text input allows multiple lines. Present on string and textContent props. */
388
+ 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;
395
+ /** The label shown when the boolean is true. Present on boolean props. */
396
+ trueLabel?: string;
397
+ /** The label shown when the boolean is false. Present on boolean props. */
398
+ falseLabel?: string;
399
+ }
400
+
401
+ // ---------------------------------------------------------------------------
402
+ // createProp input types (discriminated union on `type`)
403
+ // ---------------------------------------------------------------------------
404
+
405
+ /** Common fields shared by all prop types. */
406
+ interface CreatePropCommon {
407
+ /** Display name for the prop. Auto-incremented on conflicts within the same group. */
408
+ name: string;
409
+ /** Group/folder name. Props with the same group appear together in the props panel. */
410
+ group?: string;
411
+ /** Tooltip text shown on hover in the props panel. */
412
+ tooltip?: string;
413
+ /** The default value for this prop, or null if not set or not applicable. */
414
+ defaultValue?: ResolvedValue | null;
415
+ }
416
+
417
+ interface TextContentPropInput extends CreatePropCommon {
418
+ type: 'textContent';
419
+ /** Whether the text input supports multiple lines. */
420
+ multiline?: boolean;
421
+ defaultValue?: string;
422
+ }
423
+
424
+ interface StringPropInput extends CreatePropCommon {
425
+ type: 'string';
426
+ defaultValue?: string;
427
+ }
428
+
429
+ interface RichTextPropInput extends CreatePropCommon {
430
+ type: 'richText';
431
+ defaultValue?: RichTextResolvedValue;
432
+ }
433
+
434
+ interface ImagePropInput extends CreatePropCommon {
435
+ type: 'image';
436
+ /** Default asset ID. */
437
+ defaultValue?: string;
438
+ }
439
+
440
+ interface LinkPropInput extends CreatePropCommon {
441
+ type: 'link';
442
+ defaultValue?: LinkResolvedValue;
443
+ }
444
+
445
+ interface VideoPropInput extends CreatePropCommon {
446
+ type: 'video';
447
+ defaultValue?: VideoResolvedValue;
448
+ }
449
+
450
+ interface NumberPropInput extends CreatePropCommon {
451
+ type: 'number';
452
+ min?: number;
453
+ max?: number;
454
+ /** Number of decimal places allowed. */
455
+ decimals?: number;
456
+ defaultValue?: number;
457
+ }
458
+
459
+ interface BooleanPropInput extends CreatePropCommon {
460
+ type: 'boolean';
461
+ /** Label shown when the value is true (e.g., "Visible"). */
462
+ trueLabel?: string;
463
+ /** Label shown when the value is false (e.g., "Hidden"). */
464
+ falseLabel?: string;
465
+ defaultValue?: boolean;
466
+ }
467
+
468
+ interface IdPropInput extends CreatePropCommon {
469
+ type: 'id';
470
+ /**
471
+ * Default ID value. Normalized on the host side — invalid characters are
472
+ * stripped, spaces become hyphens, result is lowercased. The response returns
473
+ * the normalized value. Error if normalization produces an empty string.
474
+ */
475
+ defaultValue?: string;
476
+ }
477
+
478
+ interface AltTextPropInput extends CreatePropCommon {
479
+ type: 'altText';
480
+ /**
481
+ * Default alt text value. The special strings `"decorative"` (marks image as
482
+ * decorative) and `"inherit"` (inherit from asset) have semantic meaning.
483
+ */
484
+ defaultValue?: string | null;
485
+ }
486
+
487
+ /** Options for creating a new prop on a component. Discriminated on `type`. */
488
+ type CreatePropOptions =
489
+ | TextContentPropInput
490
+ | StringPropInput
491
+ | RichTextPropInput
492
+ | ImagePropInput
493
+ | LinkPropInput
494
+ | VideoPropInput
495
+ | NumberPropInput
496
+ | BooleanPropInput
497
+ | IdPropInput
498
+ | AltTextPropInput;
499
+
201
500
  /**
202
501
  * Settings for a component, including name, group, and description.
203
502
  */
@@ -31,7 +31,8 @@ type BindableValueType =
31
31
  | 'visibility'
32
32
  | 'booleanFilter'
33
33
  | 'altText'
34
- | 'id';
34
+ | 'id'
35
+ | 'headingTag';
35
36
 
36
37
  type PropType =
37
38
  | 'textContent'
@@ -50,7 +51,8 @@ type PropType =
50
51
  | 'visibility'
51
52
  | 'filter'
52
53
  | 'sort'
53
- | 'selectedItems';
54
+ | 'selectedItems'
55
+ | 'headingTag';
54
56
 
55
57
  type CmsFieldType =
56
58
  | 'plainText'
@@ -63,6 +65,7 @@ type CmsFieldType =
63
65
  | 'color'
64
66
  | 'boolean'
65
67
  | 'image'
68
+ | 'multiImage'
66
69
  | 'file'
67
70
  | 'video'
68
71
  | 'richText';
@@ -52,9 +52,54 @@ type BindableSource =
52
52
  | LocaleBindableSource
53
53
  | LocaleItemBindableSource;
54
54
 
55
+ interface ElementSetting {
56
+ valueType: BindableValueType;
57
+ canBind: boolean;
58
+ value: SettingValue;
59
+ resolvedValue: ResolvedValue | null;
60
+ display: SettingDisplay;
61
+ }
62
+
63
+ interface SearchSettingsOptions {
64
+ /** Filter to settings that produce a specific value type (e.g., "string", "image") */
65
+ valueType?: BindableValueType;
66
+ /** Filter to a specific setting by key (e.g., "domId", "assetId") */
67
+ key?: string;
68
+ }
69
+
55
70
  interface SearchBindableSourcesOptions {
56
71
  /** Filter to sources compatible with a specific element setting key (e.g., "altText", "src", "domId") */
57
72
  settingKey?: string;
58
73
  /** Filter to sources that produce a specific value type (e.g., "string", "imageAsset") */
59
74
  valueType?: BindableValueType;
60
75
  }
76
+
77
+ /**
78
+ * Input to element.setSettings().
79
+ * Each key is a setting key (e.g., 'domId', 'tag', 'assetId').
80
+ * Values can be:
81
+ * - A static value (string, number, boolean, or object depending on the setting type)
82
+ * - A BindingInput to bind the setting to a data source
83
+ * - null to reset the setting to its default / disconnect any binding
84
+ */
85
+ type SetSettingsInput = Record<string, ResolvedValue | BindingInput | null>;
86
+
87
+ /**
88
+ * Return type for element.getSettings().
89
+ * Each key is a setting key (e.g., 'domId', 'tag', 'visibility').
90
+ * Static values are bare (string, number, boolean, etc.).
91
+ * Bound values include binding metadata (sourceType + source fields).
92
+ * Settings with no value and no default are null.
93
+ */
94
+ type ElementSettingSummaries = Record<
95
+ string,
96
+ ResolvedValue | BindingValue | null
97
+ >;
98
+
99
+ /**
100
+ * Return type for element.getResolvedSettings().
101
+ * Each key is a setting key (e.g., 'domId', 'tag', 'visibility').
102
+ * Values are the resolved output — static values are bare, bindings
103
+ * are evaluated to their current value, and unresolvable bindings are null.
104
+ */
105
+ type ResolvedElementSettings = Record<string, ResolvedValue | null>;