@webflow/designer-extension-typings 2.0.34 → 2.1.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/api.d.ts +48 -0
- package/components.d.ts +106 -10
- package/elements-generated.d.ts +34 -2
- package/package.json +1 -1
- package/styles-generated.d.ts +0 -1
- package/styles.d.ts +10 -0
package/api.d.ts
CHANGED
|
@@ -21,6 +21,19 @@ interface AppModeChangeEvent {
|
|
|
21
21
|
appModes: {[key in AppMode]: boolean};
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
type AppearanceSettings =
|
|
25
|
+
| 'darkDefault'
|
|
26
|
+
| 'darkDarker'
|
|
27
|
+
| 'darkBrighter'
|
|
28
|
+
| 'light';
|
|
29
|
+
|
|
30
|
+
type ThemeStyles = {
|
|
31
|
+
colors: Record<string, string>;
|
|
32
|
+
boxShadows: Record<string, string>;
|
|
33
|
+
controls: Record<string, string>;
|
|
34
|
+
opacities: Record<string, string>;
|
|
35
|
+
};
|
|
36
|
+
|
|
24
37
|
interface SharedApi {
|
|
25
38
|
/**
|
|
26
39
|
* Get metadata about the current Site.
|
|
@@ -169,6 +182,20 @@ interface SharedApi {
|
|
|
169
182
|
options: ComponentOptions,
|
|
170
183
|
source: Component
|
|
171
184
|
): Promise<Component>;
|
|
185
|
+
/**
|
|
186
|
+
* Duplicate an existing component by ID.
|
|
187
|
+
* @param options - Options for the new component, including a required name.
|
|
188
|
+
* @param source - The ID of the existing Component to duplicate.
|
|
189
|
+
* @returns A Promise resolving to the newly created Component.
|
|
190
|
+
* @example
|
|
191
|
+
* ```ts
|
|
192
|
+
* const copy = await webflow.registerComponent({name: 'Hero Copy'}, '204d04de-bf48-5b5b-0ca8-6ec4c5364fd2')
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
registerComponent(
|
|
196
|
+
options: ComponentOptions,
|
|
197
|
+
source: string
|
|
198
|
+
): Promise<Component>;
|
|
172
199
|
/**
|
|
173
200
|
* Convert an element or element preset into a component. Equivalent to the
|
|
174
201
|
* "Convert selection" action in the Designer's "New component" menu.
|
|
@@ -660,6 +687,19 @@ interface DesignerOnlyApi {
|
|
|
660
687
|
* ```
|
|
661
688
|
*/
|
|
662
689
|
getMediaQuery(): Promise<BreakpointId>;
|
|
690
|
+
/**
|
|
691
|
+
* Get the currently active designer theme.
|
|
692
|
+
* @returns The active theme name.
|
|
693
|
+
*/
|
|
694
|
+
getTheme(): Promise<AppearanceSettings>;
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* Get the structured style tokens for a given theme. Returns color, box-shadow,
|
|
698
|
+
* control, and opacity token values as flat key-value records.
|
|
699
|
+
* @param themeName - The theme to get tokens for.
|
|
700
|
+
* @returns The ThemeStyles object for the requested theme.
|
|
701
|
+
*/
|
|
702
|
+
getThemeStyles(themeName: AppearanceSettings): Promise<ThemeStyles>;
|
|
663
703
|
/**
|
|
664
704
|
* Get the current pseudo mode.
|
|
665
705
|
* @returns A Promise that resolves to a PseudoStateKey which is a string representing the current pseudo mode.
|
|
@@ -860,6 +900,14 @@ interface DesignerOnlyApi {
|
|
|
860
900
|
event: 'selectedvariant',
|
|
861
901
|
callback: (variant: Variant) => void
|
|
862
902
|
): Unsubscribe;
|
|
903
|
+
/**
|
|
904
|
+
* Subscribe to designer theme changes. The callback fires whenever the user
|
|
905
|
+
* switches themes in the Webflow designer appearance settings.
|
|
906
|
+
*/
|
|
907
|
+
subscribe(
|
|
908
|
+
event: 'currenttheme',
|
|
909
|
+
callback: (theme: AppearanceSettings) => void
|
|
910
|
+
): Unsubscribe;
|
|
863
911
|
/**
|
|
864
912
|
* Checks if the user has the ability to perform the given App Mode
|
|
865
913
|
* @param appModes
|
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
|
-
/**
|
|
443
|
-
|
|
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
|
*/
|
package/elements-generated.d.ts
CHANGED
|
@@ -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 {
|
|
@@ -241,8 +273,10 @@ interface ComponentElement
|
|
|
241
273
|
readonly id: FullElementId;
|
|
242
274
|
readonly type: 'ComponentInstance';
|
|
243
275
|
readonly plugin: '';
|
|
276
|
+
readonly selectedSlotId?: string | null;
|
|
244
277
|
getComponent(): Promise<Component>;
|
|
245
278
|
getSlots(): Promise<Array<SlotInstanceElement>>;
|
|
279
|
+
getSelectedSlot(): Promise<SlotInstanceElement | null>;
|
|
246
280
|
getProps(): Promise<Array<InstancePropSummary>>;
|
|
247
281
|
getResolvedProps(): Promise<Array<ResolvedInstanceProp>>;
|
|
248
282
|
searchProps(
|
|
@@ -294,9 +328,7 @@ interface DOMElement
|
|
|
294
328
|
setTag(tag: string): Promise<null>;
|
|
295
329
|
setTag(binding: BindingInput): Promise<null>;
|
|
296
330
|
getAttribute(name: string): Promise<null | string>;
|
|
297
|
-
setAttribute(name: string, value: string): Promise<null>;
|
|
298
331
|
getAllAttributes(): Promise<Array<NamedValue> | null>;
|
|
299
|
-
removeAttribute(name: string): Promise<null>;
|
|
300
332
|
}
|
|
301
333
|
|
|
302
334
|
interface SearchFormElement
|
package/package.json
CHANGED
package/styles-generated.d.ts
CHANGED
package/styles.d.ts
CHANGED
|
@@ -12,6 +12,16 @@ interface Style {
|
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
14
|
getName(): Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Rename the Style.
|
|
17
|
+
* @param name - The new name for the Style.
|
|
18
|
+
* @returns A Promise that resolves to null when the rename is complete.
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* await myStyle.setName('NewStyleName');
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
setName(name: string): Promise<null>;
|
|
15
25
|
/**
|
|
16
26
|
* Retrieve the properties of the style.
|
|
17
27
|
* @param options - Options to filter properties based on breakpoints, pseudo states, and component variants.
|