@webflow/designer-extension-typings 2.0.33 → 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/api.d.ts CHANGED
@@ -345,7 +345,13 @@ interface SharedApi {
345
345
  * const heroComponent = await webflow.getComponent('4a669354-353a-97eb-795c-4471b406e043');
346
346
  * await webflow.openCanvas(heroComponent);
347
347
  *
348
- * // Open a component canvas by page
348
+ * // Open a component canvas by component instance (ComponentElement)
349
+ * const selectedElement = await webflow.getSelectedElement();
350
+ * if (selectedElement?.type === 'ComponentInstance') {
351
+ * await webflow.openCanvas(selectedElement);
352
+ * }
353
+ *
354
+ * // Open a page canvas by page
349
355
  * const myPage = await webflow.getPage('123');
350
356
  * await webflow.openCanvas(myPage);
351
357
  * ```
package/components.d.ts CHANGED
@@ -249,6 +249,30 @@ interface Component {
249
249
  */
250
250
  getProps(): Promise<Prop[]>;
251
251
 
252
+ /**
253
+ * * Get a single prop definition by its ID.
254
+ * @param propId - The unique ID of the prop.
255
+ * @returns A Promise resolving to the prop definition.
256
+ */
257
+ getProp(propId: string): Promise<Prop>;
258
+
259
+ /**
260
+ * Get a prop definition by its display name.
261
+ * Matches only ungrouped props.
262
+ * Use the `groupName` overload for grouped props.
263
+ * @param name - The display name of the prop.
264
+ * @returns A Promise resolving to the prop definition.
265
+ */
266
+ getPropByName(name: string): Promise<Prop>;
267
+
268
+ /**
269
+ * Get a prop definition by its group and display name.
270
+ * @param groupName - The group the prop belongs to.
271
+ * @param name - The display name of the prop within that group.
272
+ * @returns A Promise resolving to the prop definition.
273
+ */
274
+ getPropByName(groupName: string, name: string): Promise<Prop>;
275
+
252
276
  /**
253
277
  * Create a new prop on this component.
254
278
  *
@@ -279,6 +303,19 @@ interface Component {
279
303
  * @returns A Promise resolving to an array of created props, in the same order as the input.
280
304
  */
281
305
  createProps(options: CreatePropOptions[]): Promise<Prop[]>;
306
+
307
+ /**
308
+ * Remove a prop from this component.
309
+ * @param propId - The ID of the prop to remove.
310
+ * @returns A Promise that resolves when the prop has been removed.
311
+ * @example
312
+ * ```ts
313
+ * const props = await component.getProps();
314
+ * const unused = props.find(p => p.name === 'Old Heading');
315
+ * await component.removeProp(unused.id);
316
+ * ```
317
+ */
318
+ removeProp(propId: string): Promise<null>;
282
319
  }
283
320
 
284
321
  /**
@@ -74,32 +74,66 @@ interface SearchBindableSourcesOptions {
74
74
  valueType?: BindableValueType;
75
75
  }
76
76
 
77
+ /** An attribute on an element, as returned by `getSettings()`. */
78
+ interface ElementAttribute {
79
+ /** The attribute name — a plain string, or binding metadata if bound to a data source. Null when the underlying binding can't be resolved. */
80
+ name: string | BindingValue | null;
81
+ /** The attribute's value — a plain string, or binding metadata if bound to a data source. Null when the underlying binding can't be resolved. */
82
+ value: string | BindingValue | null;
83
+ }
84
+
85
+ /** An attribute on an element, as returned by `getResolvedSettings()`. */
86
+ interface ResolvedElementAttribute {
87
+ /** The evaluated string name. Null when a binding can't be resolved at design time. */
88
+ name: string | null;
89
+ /** The evaluated string value. Null when a binding can't be resolved at design time. */
90
+ value: string | null;
91
+ }
92
+
93
+ /** An attribute to set on an element via `setSettings()`. */
94
+ interface SetElementAttribute {
95
+ /** A plain string name, or a binding descriptor. Name bindings are only supported on DOM elements. */
96
+ name: string | BindingInput;
97
+ /** A plain string value, or a binding descriptor to bind to a data source. */
98
+ value: string | BindingInput;
99
+ }
100
+
77
101
  /**
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
102
+ * Input to `element.setSettings()`.
103
+ *
104
+ * Each key is a setting (e.g., `domId`, `tag`, `assetId`). Values can be a
105
+ * static value, a binding descriptor, or `null` to reset to default.
106
+ *
107
+ * The `attributes` key is special: it takes a `SetElementAttribute[]` that
108
+ * replaces all attributes on the element (pass an empty array to remove
109
+ * them all). Only `attributes` accepts `SetElementAttribute[]` — other
110
+ * setting keys expect a value, binding descriptor, or `null`.
84
111
  */
85
- type SetSettingsInput = Record<string, ResolvedValue | BindingInput | null>;
112
+ interface SetSettingsInput {
113
+ [key: string]: ResolvedValue | BindingInput | SetElementAttribute[] | null;
114
+ }
86
115
 
87
116
  /**
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.
117
+ * Return type for `element.getSettings()`.
118
+ *
119
+ * Each key is a setting (e.g., `domId`, `tag`, `visibility`). Static values
120
+ * are returned as-is. Bound values include binding metadata. Null means the
121
+ * setting has no value and no default.
122
+ *
123
+ * `attributes` (when present) is the element's full attribute list.
93
124
  */
94
- type ElementSettingSummaries = Record<
95
- string,
96
- ResolvedValue | BindingValue | null
97
- >;
125
+ interface ElementSettingSummaries {
126
+ [key: string]: ResolvedValue | BindingValue | ElementAttribute[] | null;
127
+ }
98
128
 
99
129
  /**
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.
130
+ * Return type for `element.getResolvedSettings()`.
131
+ *
132
+ * Same keys as `getSettings()`, but every value is fully evaluated.
133
+ * Bindings that can't be resolved at design time are null.
134
+ *
135
+ * `attributes` (when present) contains the resolved attribute values.
104
136
  */
105
- type ResolvedElementSettings = Record<string, ResolvedValue | null>;
137
+ interface ResolvedElementSettings {
138
+ [key: string]: ResolvedValue | ResolvedElementAttribute[] | null;
139
+ }