@webflow/designer-extension-typings 2.0.34 → 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/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
@@ -304,6 +318,44 @@ interface Component {
304
318
  */
305
319
  createProps(options: CreatePropOptions[]): Promise<Prop[]>;
306
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
+
307
359
  /**
308
360
  * Remove a prop from this component.
309
361
  * @param propId - The ID of the prop to remove.
@@ -423,12 +475,12 @@ interface Prop {
423
475
  readonly defaultValue: ResolvedValue | null;
424
476
  /** Whether the text input allows multiple lines. Present on string and textContent props. */
425
477
  multiline?: boolean;
426
- /** The minimum allowed value. Present on number props. */
427
- min?: number;
428
- /** The maximum allowed value. Present on number props. */
429
- max?: number;
430
- /** The number of decimal places (precision) allowed. Present on number props. */
431
- 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;
432
484
  /** The label shown when the boolean is true. Present on boolean props. */
433
485
  trueLabel?: string;
434
486
  /** The label shown when the boolean is false. Present on boolean props. */
@@ -439,16 +491,29 @@ interface Prop {
439
491
  // createProp input types (discriminated union on `type`)
440
492
  // ---------------------------------------------------------------------------
441
493
 
442
- /** Common fields shared by all prop types. */
443
- interface CreatePropCommon {
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 {
444
511
  /** Display name for the prop. Auto-incremented on conflicts within the same group. */
445
512
  name: string;
446
513
  /** Group/folder name. Props with the same group appear together in the props panel. */
447
514
  group?: string;
448
515
  /** Tooltip text shown on hover in the props panel. */
449
516
  tooltip?: string;
450
- /** The default value for this prop, or null if not set or not applicable. */
451
- defaultValue?: ResolvedValue | null;
452
517
  }
453
518
 
454
519
  interface TextContentPropInput extends CreatePropCommon {
@@ -534,6 +599,37 @@ type CreatePropOptions =
534
599
  | IdPropInput
535
600
  | AltTextPropInput;
536
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
+
537
633
  /**
538
634
  * Settings for a component, including name, group, and description.
539
635
  */
@@ -107,6 +107,38 @@ interface Attributes {
107
107
  getResolvedAttributes(this: {
108
108
  id: FullElementId;
109
109
  }): Promise<Array<ResolvedElementAttribute>>;
110
+ getAttributeValue(
111
+ this: {id: FullElementId},
112
+ name: string
113
+ ): Promise<string | BindingValue | null>;
114
+ getAttributeValue(
115
+ this: {id: FullElementId},
116
+ index: number
117
+ ): Promise<string | BindingValue | null>;
118
+ getResolvedAttributeValue(
119
+ this: {id: FullElementId},
120
+ name: string
121
+ ): Promise<string | null>;
122
+ getResolvedAttributeValue(
123
+ this: {id: FullElementId},
124
+ index: number
125
+ ): Promise<string | null>;
126
+ setAttribute(
127
+ this: {id: FullElementId},
128
+ name: string,
129
+ value: string | BindingInput
130
+ ): Promise<null>;
131
+ setAttribute(
132
+ this: {id: FullElementId},
133
+ index: number,
134
+ attribute: SetElementAttribute
135
+ ): Promise<null>;
136
+ setAttributes(
137
+ this: {id: FullElementId},
138
+ attributes: Array<SetElementAttribute>
139
+ ): Promise<null>;
140
+ removeAttribute(this: {id: FullElementId}, name: string): Promise<null>;
141
+ removeAttribute(this: {id: FullElementId}, index: number): Promise<null>;
110
142
  }
111
143
 
112
144
  interface NoAttributes {
@@ -294,9 +326,7 @@ interface DOMElement
294
326
  setTag(tag: string): Promise<null>;
295
327
  setTag(binding: BindingInput): Promise<null>;
296
328
  getAttribute(name: string): Promise<null | string>;
297
- setAttribute(name: string, value: string): Promise<null>;
298
329
  getAllAttributes(): Promise<Array<NamedValue> | null>;
299
- removeAttribute(name: string): Promise<null>;
300
330
  }
301
331
 
302
332
  interface SearchFormElement
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webflow/designer-extension-typings",
3
- "version": "2.0.34",
3
+ "version": "2.0.35",
4
4
  "license": "MIT",
5
5
  "description": "Typings for the Webflow Designer Extension API",
6
6
  "main": "",