@webflow/designer-extension-typings 2.0.31 → 2.0.34

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/elements.d.ts CHANGED
@@ -14,6 +14,11 @@ type FormState = 'normal' | 'success' | 'error';
14
14
 
15
15
  type FormMethod = 'get' | 'post';
16
16
 
17
+ /**
18
+ * @deprecated Use `element.getSettings()` (returns `ElementSettingSummaries`) or
19
+ * `element.searchSettings()` (returns `Record<string, ElementSetting>`) instead.
20
+ * These generic APIs return the same form fields plus all other applicable settings.
21
+ */
17
22
  type FormSettings = {
18
23
  state: FormState;
19
24
  name: string;
@@ -1,25 +1,60 @@
1
1
  // Instance Props types
2
2
 
3
- interface LinkResolvedValue {
4
- mode:
5
- | 'url'
6
- | 'page'
7
- | 'pageSection'
8
- | 'email'
9
- | 'phone'
10
- | 'file'
11
- | 'collectionPage';
12
- to?:
13
- | string
14
- | {pageId: string}
15
- | {assetId: string}
16
- | {fullElementId: {element: string; component: string}}
17
- | {pageSlug: string};
3
+ /** All public-facing link mode identifiers. */
4
+ type LinkMode =
5
+ | 'url'
6
+ | 'page'
7
+ | 'pageSection'
8
+ | 'email'
9
+ | 'phone'
10
+ | 'file'
11
+ | 'collectionPage';
12
+
13
+ interface LinkResolvedValueBase {
14
+ mode: LinkMode;
18
15
  openInNewTab?: boolean;
16
+ rel?: 'none' | 'preload' | 'prefetch' | 'prerender';
17
+ }
18
+
19
+ interface PageLinkResolvedValue extends LinkResolvedValueBase {
20
+ mode: 'page';
21
+ to?: {pageId: string};
22
+ }
23
+
24
+ interface PageSectionLinkResolvedValue extends LinkResolvedValueBase {
25
+ mode: 'pageSection';
26
+ to?: {fullElementId: FullElementId};
27
+ }
28
+
29
+ interface CollectionPageLinkResolvedValue extends LinkResolvedValueBase {
30
+ mode: 'collectionPage';
31
+ to?: {pageSlug: string};
32
+ }
33
+
34
+ interface EmailLinkResolvedValue extends LinkResolvedValueBase {
35
+ mode: 'email';
36
+ to?: string;
19
37
  emailSubject?: string;
20
- rel?: string;
21
38
  }
22
39
 
40
+ interface FileLinkResolvedValue extends LinkResolvedValueBase {
41
+ mode: 'file';
42
+ to?: {assetId: string};
43
+ }
44
+
45
+ interface GenericLinkResolvedValue extends LinkResolvedValueBase {
46
+ mode: 'url' | 'phone';
47
+ to?: string;
48
+ }
49
+
50
+ type LinkResolvedValue =
51
+ | PageLinkResolvedValue
52
+ | PageSectionLinkResolvedValue
53
+ | CollectionPageLinkResolvedValue
54
+ | EmailLinkResolvedValue
55
+ | FileLinkResolvedValue
56
+ | GenericLinkResolvedValue;
57
+
23
58
  interface VideoResolvedValue {
24
59
  src?: string;
25
60
  title?: string;
@@ -43,7 +78,7 @@ interface StaticPropValue {
43
78
  value: ResolvedValue | null;
44
79
  }
45
80
 
46
- type BindingPropValue =
81
+ type BindingValue =
47
82
  | {
48
83
  sourceType: 'prop';
49
84
  propId: string;
@@ -79,31 +114,38 @@ type BindingPropValue =
79
114
  | {sourceType: 'conditional'}
80
115
  | {sourceType: 'legacy'};
81
116
 
82
- type InstancePropValue = StaticPropValue | BindingPropValue;
117
+ type SettingValue = StaticPropValue | BindingValue;
83
118
 
84
- interface InstancePropDisplay {
119
+ interface SettingDisplay {
85
120
  label: string;
86
121
  group: string | null;
87
122
  trueLabel?: string;
88
123
  falseLabel?: string;
124
+ /** Available choices for variant props. Each entry is a variant the component author defined. */
125
+ options?: Array<Pick<Variant, 'id' | 'name'>>;
89
126
  }
90
127
 
91
128
  interface InstanceProp {
92
129
  propId: string;
93
130
  valueType: BindableValueType;
94
131
  hasOverride: boolean;
95
- value: InstancePropValue;
132
+ value: SettingValue;
96
133
  resolvedValue: ResolvedValue | null;
97
134
  defaultValue: ResolvedValue | null;
98
- display: InstancePropDisplay;
135
+ display: SettingDisplay;
99
136
  }
100
137
 
101
138
  interface InstancePropSummary {
102
139
  propId: string;
103
- value: ResolvedValue | BindingPropValue | null;
140
+ value: ResolvedValue | BindingValue | null;
104
141
  hasOverride: boolean;
105
142
  }
106
143
 
144
+ interface ResolvedInstanceProp {
145
+ propId: string;
146
+ value: ResolvedValue | null;
147
+ }
148
+
107
149
  interface SearchInstancePropsOptions {
108
150
  /** Filter to props that produce a specific value type (e.g., "string", "boolean") */
109
151
  valueType?: BindableValueType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webflow/designer-extension-typings",
3
- "version": "2.0.31",
3
+ "version": "2.0.34",
4
4
  "license": "MIT",
5
5
  "description": "Typings for the Webflow Designer Extension API",
6
6
  "main": "",
package/styles.d.ts CHANGED
@@ -14,69 +14,139 @@ interface Style {
14
14
  getName(): Promise<string>;
15
15
  /**
16
16
  * Retrieve the properties of the style.
17
- * @param options - Options to filter properties based on breakpoints and pseudo classes / states.
18
- * @returns CSS properties and their values for the given breakpoint and pseudo-state.
17
+ * @param options - Options to filter properties based on breakpoints, pseudo states, and component variants.
18
+ * @returns CSS properties and their values for the given options.
19
19
  * @example
20
20
  * ```ts
21
- * let styleProperties = myStyle.getProperties();
22
- * console.log("Style Properties:", styleProperties);
21
+ * // Get base properties
22
+ * let baseProperties = await myStyle.getProperties();
23
+ *
24
+ * // Get properties for a specific breakpoint and pseudo state
25
+ * let hoverProperties = await myStyle.getProperties({ breakpoint: 'medium', pseudo: 'hover' });
26
+ *
27
+ * // Get properties for a component variant
28
+ * let variantProperties = await myStyle.getProperties({ variantId: 'variant-dark' });
29
+ *
30
+ * // Combine variant with breakpoint and pseudo
31
+ * let combinedProperties = await myStyle.getProperties({
32
+ * variantId: 'variant-dark',
33
+ * breakpoint: 'medium',
34
+ * pseudo: 'hover',
35
+ * });
23
36
  * ```
24
37
  */
25
- getProperties(options?: BreakpointAndPseudo): Promise<PropertyMap>;
38
+ getProperties(options?: StyleOptions): Promise<PropertyMap>;
26
39
  /**
27
- * Sets CSS properties for the Style at the given breakpoint and pseudo-state.
40
+ * Sets CSS properties for the Style.
28
41
  * @param props - The new properties to set for the style. You can use variables here as well.
29
- * @param options - Options to filter properties based on breakpoints and pseudo classes / states.
42
+ * @param options - Options to target specific breakpoints, pseudo states, and component variants.
30
43
  * @example
31
44
  * ```ts
32
- * myStyle.setProperties({ color: 'red', 'font-size': '16px' }, { breakpoint: 'main', pseudo: 'hover' });
45
+ * // Set base properties
46
+ * await myStyle.setProperties({ color: 'red', 'font-size': '16px' });
47
+ *
48
+ * // Set properties for breakpoint and pseudo state
49
+ * await myStyle.setProperties(
50
+ * { color: 'blue', 'font-size': '18px' },
51
+ * { breakpoint: 'medium', pseudo: 'hover' }
52
+ * );
53
+ *
54
+ * // Set properties for a component variant
55
+ * await myStyle.setProperties(
56
+ * { color: 'white', 'background-color': 'black' },
57
+ * { variantId: 'variant-dark' }
58
+ * );
59
+ *
60
+ * // Target variant by name instead of ID
61
+ * await myStyle.setProperties(
62
+ * { 'font-weight': 'bold' },
63
+ * { variantName: 'Dark Mode' }
64
+ * );
65
+ * ```
66
+ */
67
+ setProperties(props: PropertyMap, options?: StyleOptions): Promise<null>;
68
+ /**
69
+ * Removes multiple CSS properties from the Style.
70
+ * @param props - Array of property names to remove.
71
+ * @param options - Options to target specific breakpoints, pseudo states, and component variants.
72
+ * @example
73
+ * ```ts
74
+ * // Remove properties from base styles
75
+ * await myStyle.removeProperties(['color', 'font-size']);
76
+ *
77
+ * // Remove properties from a variant
78
+ * await myStyle.removeProperties(['color', 'background-color'], { variantId: 'variant-dark' });
33
79
  * ```
34
80
  */
35
- setProperties(
36
- props: PropertyMap,
37
- options?: BreakpointAndPseudo
38
- ): Promise<null>;
39
81
  removeProperties(
40
82
  props: Array<StyleProperty>,
41
- options?: BreakpointAndPseudo
83
+ options?: StyleOptions
42
84
  ): Promise<null>;
43
85
  /**
44
86
  * Retrieve the value of a specific property of the style.
45
87
  * @param prop - The name of the property to retrieve.
46
- * @param options - Options to get property based on breakpoints and pseudo classes / states.
47
- * @returns Returns the value of a specific CSS property for the given breakpoint and pseudo-state, or null if the property does not exist.
88
+ * @param options - Options to target specific breakpoints, pseudo states, and component variants.
89
+ * @returns Returns the value of the CSS property, or null if not set.
48
90
  * @example
49
91
  * ```ts
50
- * let color = myStyle.getProperty('color', { breakpoint: 'main', pseudo: 'hover' });
51
- * let fontSize = myStyle.getProperty("fontSize");
52
- * console.log("Font Size:", fontSize);
92
+ * // Get base property
93
+ * let color = await myStyle.getProperty('color');
94
+ *
95
+ * // Get property for breakpoint and pseudo state
96
+ * let hoverColor = await myStyle.getProperty('color', { breakpoint: 'medium', pseudo: 'hover' });
97
+ *
98
+ * // Get property for a component variant
99
+ * let variantColor = await myStyle.getProperty('color', { variantId: 'variant-dark' });
100
+ *
101
+ * // Get property from variant by name
102
+ * let namedVariantColor = await myStyle.getProperty('color', { variantName: 'Dark Mode' });
53
103
  * ```
54
104
  */
55
105
  getProperty<p extends StyleProperty>(
56
106
  prop: p,
57
- options?: BreakpointAndPseudo
107
+ options?: StyleOptions
58
108
  ): Promise<null | PropertyMap[p]>;
59
109
  /**
60
- * Sets a specific CSS property for the Style at the given breakpoint and pseudo-state.
110
+ * Sets a specific CSS property for the Style.
61
111
  * @param prop - The name of the property to set.
62
112
  * @param value - The new value to set for the property.
63
- * @param options - Options to set property based on breakpoints and pseudo classes / states.
113
+ * @param options - Options to target specific breakpoints, pseudo states, and component variants.
64
114
  * @example
65
115
  * ```ts
66
- * myStyle.setProperty('color', 'blue', { breakpoint: 'main', pseudo: 'hover' });
116
+ * // Set base property
117
+ * await myStyle.setProperty('color', 'red');
118
+ *
119
+ * // Set property for breakpoint and pseudo state
120
+ * await myStyle.setProperty('color', 'blue', { breakpoint: 'medium', pseudo: 'hover' });
121
+ *
122
+ * // Set property for a component variant
123
+ * await myStyle.setProperty('color', 'white', { variantId: 'variant-dark' });
124
+ *
125
+ * // Set property on variant by name
126
+ * await myStyle.setProperty('font-weight', 'bold', { variantName: 'Dark Mode' });
67
127
  * ```
68
128
  */
69
129
  setProperty<p extends StyleProperty>(
70
130
  prop: p,
71
131
  value: NonNullable<PropertyMap[p]>,
72
- options?: BreakpointAndPseudo
73
- ): Promise<null>;
74
- removeProperty(
75
- prop: StyleProperty,
76
- options?: BreakpointAndPseudo
132
+ options?: StyleOptions
77
133
  ): Promise<null>;
78
134
  /**
79
- * Removes all CSS properties from the Style.
135
+ * Removes a specific CSS property from the Style.
136
+ * @param prop - The name of the property to remove.
137
+ * @param options - Options to target specific breakpoints, pseudo states, and component variants.
138
+ * @example
139
+ * ```ts
140
+ * // Remove property from base styles
141
+ * await myStyle.removeProperty('color');
142
+ *
143
+ * // Remove property from a variant
144
+ * await myStyle.removeProperty('color', { variantId: 'variant-dark' });
145
+ * ```
146
+ */
147
+ removeProperty(prop: StyleProperty, options?: StyleOptions): Promise<null>;
148
+ /**
149
+ * Removes all CSS properties from the Style, including base styles and all variant styles.
80
150
  * @example
81
151
  * ```ts
82
152
  * await myStyle.removeAllProperties();
@@ -206,6 +276,20 @@ type BreakpointAndPseudo = {
206
276
  pseudo?: PseudoStateKey;
207
277
  };
208
278
 
279
+ /**
280
+ * Options for targeting style properties by breakpoint, pseudo state, and component variant.
281
+ *
282
+ * When no options are provided, the base styles are targeted (main breakpoint, no pseudo, no variant).
283
+ * Specify variantId to target component variant styles.
284
+ */
285
+ type StyleOptions = BreakpointAndPseudo & {
286
+ /**
287
+ * Component variant ID to target.
288
+ * Cannot be 'base' (omit options entirely for base styles).
289
+ */
290
+ variantId?: string;
291
+ };
292
+
209
293
  type BreakpointId =
210
294
  | 'xxl'
211
295
  | 'xl'