@webflow/designer-extension-typings 2.0.13 → 2.0.19

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
@@ -33,6 +33,8 @@ interface WebflowApi {
33
33
  * console.log('Site Name:', siteInfo.siteName);
34
34
  * console.log('Shortened Site Name:', siteInfo.shortName);
35
35
  * console.log('Domains:', siteInfo.domains);
36
+ * console.log('Workspace ID:', siteInfo.workspaceId);
37
+ * console.log('Workspace Slug:', siteInfo.workspaceSlug);
36
38
  * ```
37
39
  */
38
40
  getSiteInfo(): Promise<{
@@ -41,6 +43,8 @@ interface WebflowApi {
41
43
  shortName: string;
42
44
  isPasswordProtected: boolean;
43
45
  isPrivateStaging: boolean;
46
+ workspaceId: string;
47
+ workspaceSlug: string;
44
48
  domains: Array<{
45
49
  url: string;
46
50
  lastPublished: string | null;
@@ -386,8 +390,9 @@ interface WebflowApi {
386
390
  * Notifies the user with a message using a specific style. Error messages provide user's with the opportunity to
387
391
  * close the Designer Extension.
388
392
  * @param opts - An object containing the following notification options:
389
- * - type: The type of notification to display. One of 'Error', 'Info', 'Success'.
393
+ * - type: The type of notification to display. One of 'Error', 'Info', 'Success', 'Warning'.
390
394
  * - message: The message to display in the notification.
395
+ * - dismissAfter: (optional) Number of milliseconds after which the notification will be auto-dismissed. If not provided, uses default 4000ms.
391
396
  * @returns A Promise that resolves when the notification is displayed to the user.
392
397
  * @example
393
398
  * ```ts
@@ -395,11 +400,13 @@ interface WebflowApi {
395
400
  * webflow.notify({ type: 'Error', message: 'Something went wrong, try again!' }); // Error notification
396
401
  * webflow.notify({ type: 'Success', message: 'Successfully did something!' }); // Success notification
397
402
  * webflow.notify({ type: 'Warning', message: 'Something is not right, please check again!' }); // Warning notification
403
+ * webflow.notify({ type: 'Error', message: 'Something went wrong!', dismissAfter: 5000 }); // Error notification with custom dismiss
398
404
  * ```
399
405
  */
400
406
  notify(opts: {
401
407
  type: 'Error' | 'Info' | 'Success' | 'Warning';
402
408
  message: string;
409
+ dismissAfter?: number;
403
410
  }): Promise<void>;
404
411
  /**
405
412
  * Allows you to register your custom functions (callbacks) to be executed when certain events happen. This event
@@ -2817,6 +2817,12 @@ interface FormTextInputElement
2817
2817
  setName(name: string): Promise<null>;
2818
2818
  getRequired(): Promise<boolean>;
2819
2819
  setRequired(value: boolean): Promise<null>;
2820
+ getInputType(): Promise<
2821
+ 'text' | 'email' | 'password' | 'tel' | 'number' | 'url' | null
2822
+ >;
2823
+ setInputType(
2824
+ type: 'text' | 'email' | 'password' | 'tel' | 'number' | 'url'
2825
+ ): Promise<null>;
2820
2826
  }
2821
2827
 
2822
2828
  interface FormWrapperElement
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webflow/designer-extension-typings",
3
- "version": "2.0.13",
3
+ "version": "2.0.19",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "description": "Typings for the Webflow Designer Extension API",
6
6
  "main": "",
package/styles.d.ts CHANGED
@@ -92,6 +92,103 @@ interface Style {
92
92
  * ```
93
93
  */
94
94
  isComboClass(): boolean;
95
+ /**
96
+ * Retrieve a variable mode from the style.
97
+ * @param collection - The collection from which to get the currently applied mode.
98
+ * @param options - Options to get variable mode based on breakpoints and pseudo classes / states.
99
+ * @example
100
+ * ```ts
101
+ * const collection = await webflow.getVariableCollectionById('collection-id');
102
+ * let variableMode = await myStyle.getVariableMode(collection);
103
+ * ```
104
+ */
105
+ getVariableMode(
106
+ collection: VariableCollection,
107
+ options?: BreakpointAndPseudo
108
+ ): Promise<null | VariableMode>;
109
+ /**
110
+ * Sets a variable mode for the style.
111
+ * @param collection - The collection that the mode being set belongs to.
112
+ * @param mode - The variable mode to set.
113
+ * @param options - Options to set variable mode based on breakpoints and pseudo classes / states.
114
+ * @example
115
+ * ```ts
116
+ * const collection = await webflow.getVariableCollectionById('collection-id');
117
+ * const mode = await collection.getVariableModeByName('Dark');
118
+ * await myStyle.setVariableMode(collection, mode);
119
+ * ```
120
+ */
121
+ setVariableMode(
122
+ collection: VariableCollection,
123
+ mode: VariableMode,
124
+ options?: BreakpointAndPseudo
125
+ ): Promise<null>;
126
+ /**
127
+ * Removes a variable mode from the style.
128
+ * @param collection - The collection that the mode being removed belongs to.
129
+ * @param options - Options to remove variable mode based on breakpoints and pseudo classes / states.
130
+ * @example
131
+ * ```ts
132
+ * const collection = await webflow.getVariableCollectionById('collection-id');
133
+ * await myStyle.removeVariableMode(collection)
134
+ * ```
135
+ */
136
+ removeVariableMode(
137
+ collection: VariableCollection,
138
+ options?: BreakpointAndPseudo
139
+ ): Promise<null>;
140
+ /**
141
+ * Retrieve all variable modes applied on the style.
142
+ * @param options - Options to get variable modes based on breakpoints and pseudo classes / states.
143
+ * @example
144
+ * ```ts
145
+ * const modes = await myStyle.getVariableModes();
146
+ * ```
147
+ */
148
+ getVariableModes(
149
+ options?: BreakpointAndPseudo
150
+ ): Promise<VariableModeStylePropertyMap>;
151
+ /**
152
+ * Sets variable modes for the style.
153
+ * @param props - The variable modes to set.
154
+ * @param options - Options to set variable modes based on breakpoints and pseudo classes / states.
155
+ * @example
156
+ * ```ts
157
+ * await myStyle.setVariableModes({
158
+ * 'collection-id-1': 'mode-id-1',
159
+ * 'collection-id-2': 'mode-id-2',
160
+ * });
161
+ * ```
162
+ */
163
+ setVariableModes(
164
+ props: VariableModeStylePropertyMap,
165
+ options?: BreakpointAndPseudo
166
+ ): Promise<null>;
167
+ /**
168
+ * Removes variable modes from the style.
169
+ * @param modes - The variable modes to remove from the style.
170
+ * @param options - Options to remove variable modes based on breakpoints and pseudo classes / states.
171
+ * @example
172
+ * ```ts
173
+ * await myStyle.removeVariableModes({
174
+ * 'collection-id-1': 'mode-id-1',
175
+ * 'collection-id-2': 'mode-id-2',
176
+ * });
177
+ * ```
178
+ */
179
+ removeVariableModes(
180
+ modes: Array<VariableMode>,
181
+ options?: BreakpointAndPseudo
182
+ ): Promise<null>;
183
+ /**
184
+ * Removes all variable modes from the style.
185
+ * @param options - Options to remove all variable modes based on breakpoints and pseudo classes / states.
186
+ * @example
187
+ * ```ts
188
+ * await myStyle.removeAllVariableModes();
189
+ * ```
190
+ */
191
+ removeAllVariableModes(options?: BreakpointAndPseudo): Promise<null>;
95
192
  }
96
193
 
97
194
  type StyleId = string;
@@ -109,3 +206,7 @@ type BreakpointId =
109
206
  | 'medium'
110
207
  | 'small'
111
208
  | 'tiny';
209
+
210
+ type VariableModeStylePropertyMap = {
211
+ [collectionId: VariableCollectionId]: VariableModeId;
212
+ };
package/variables.d.ts CHANGED
@@ -38,7 +38,7 @@ interface ColorVariable {
38
38
  * ```
39
39
  */
40
40
  set(
41
- value: ColorValue | ColorVariable,
41
+ value: ColorValue | ColorVariable | CustomValue,
42
42
  options?: VariableOptions
43
43
  ): Promise<null>;
44
44
  /**
@@ -52,7 +52,9 @@ interface ColorVariable {
52
52
  * console.log(await newVariable1.get());
53
53
  * ```
54
54
  */
55
- get(options?: VariableOptions): Promise<ColorValue | ColorVariable>;
55
+ get(
56
+ options?: VariableOptions
57
+ ): Promise<ColorValue | ColorVariable | CustomValue>;
56
58
  /**
57
59
  * Removes a variable from the default collection.
58
60
  * @returns A Promise that resolves into a boolean indicating whether deleting the variable was successful or not.
@@ -64,6 +66,36 @@ interface ColorVariable {
64
66
  * ```
65
67
  */
66
68
  remove(): Promise<boolean>;
69
+ /**
70
+ * Gets a CSS string representing a binding to the variable.
71
+ *
72
+ * This string can be used in custom CSS values to ensure the binding will not break
73
+ * if the variable is renamed.
74
+ *
75
+ * @returns A Promise that resolves into a string representing the variable's name binding. (e.g. `var(--my-color-variable)`)
76
+ * @example
77
+ * ```ts
78
+ * const collection = await webflow.getDefaultVariableCollection();
79
+ * const variable = await collection.getVariable('id-123')
80
+ * const variableBinding = await variable.getBinding()
81
+ * ```
82
+ */
83
+ getBinding(): Promise<string>;
84
+ /**
85
+ * Gets a CSS string representing the variable's name.
86
+ *
87
+ * This string can be used in custom CSS with a variable (e.g. binding with a fallback value).
88
+ *
89
+ *
90
+ * @returns A Promise that resolves into a string representing the variable's name. (e.g. `--my-color-variable`)
91
+ * @example
92
+ * ```ts
93
+ * const collection = await webflow.getDefaultVariableCollection();
94
+ * const variable = await collection.getVariable('id-123')
95
+ * const variableCSSName = await variable.getCSSName()
96
+ * ```
97
+ */
98
+ getCSSName(): Promise<string>;
67
99
  }
68
100
 
69
101
  interface SizeVariable {
@@ -105,7 +137,7 @@ interface SizeVariable {
105
137
  * ```
106
138
  */
107
139
  set(
108
- value: SizeValue | SizeVariable,
140
+ value: SizeValue | SizeVariable | CustomValue,
109
141
  options?: VariableOptions
110
142
  ): Promise<null>;
111
143
  /**
@@ -119,7 +151,9 @@ interface SizeVariable {
119
151
  * console.log(await newVariable1.get());
120
152
  * ```
121
153
  */
122
- get(options?: VariableOptions): Promise<SizeValue | SizeVariable>;
154
+ get(
155
+ options?: VariableOptions
156
+ ): Promise<SizeValue | SizeVariable | CustomValue>;
123
157
  /**
124
158
  * Removes a variable from the default collection.
125
159
  * @returns A Promise that resolves into a boolean indicating whether deleting the variable was successful or not.
@@ -130,6 +164,35 @@ interface SizeVariable {
130
164
  * ```
131
165
  */
132
166
  remove(): Promise<boolean>;
167
+ /**
168
+ * Gets a CSS string representing a binding to the variable.
169
+ *
170
+ * This string can be used in custom CSS values to ensure the binding will not break
171
+ * if the variable is renamed.
172
+ *
173
+ * @returns A Promise that resolves into a string representing the variable's name binding. (e.g. `var(--my-size-variable)`)
174
+ * @example
175
+ * ```ts
176
+ * const collection = await webflow.getDefaultVariableCollection();
177
+ * const variable = await collection.getVariable('id-123')
178
+ * const variableBinding = await variable.getBinding()
179
+ * ```
180
+ */
181
+ getBinding(): Promise<string>;
182
+ /**
183
+ * Gets a CSS string representing the variable's name.
184
+ *
185
+ * This string can be used in custom CSS with a variable (e.g. binding with a fallback value).
186
+ *
187
+ * @returns A Promise that resolves into a string representing the variable's name. (e.g. `--my-size-variable`)
188
+ * @example
189
+ * ```ts
190
+ * const collection = await webflow.getDefaultVariableCollection();
191
+ * const variable = await collection.getVariable('id-123')
192
+ * const variableCSSName = await variable.getCSSName()
193
+ * ```
194
+ */
195
+ getCSSName(): Promise<string>;
133
196
  }
134
197
 
135
198
  interface NumberVariable {
@@ -174,7 +237,7 @@ interface NumberVariable {
174
237
  * ```
175
238
  */
176
239
  set(
177
- value: NumberValue | NumberVariable,
240
+ value: NumberValue | NumberVariable | CustomValue,
178
241
  options?: VariableOptions
179
242
  ): Promise<null>;
180
243
 
@@ -189,7 +252,9 @@ interface NumberVariable {
189
252
  * console.log(await newVariable.get());
190
253
  * ```
191
254
  */
192
- get(options?: VariableOptions): Promise<NumberValue | NumberVariable>;
255
+ get(
256
+ options?: VariableOptions
257
+ ): Promise<NumberValue | NumberVariable | CustomValue>;
193
258
 
194
259
  /**
195
260
  * Removes the variable from the default collection.
@@ -201,6 +266,35 @@ interface NumberVariable {
201
266
  * ```
202
267
  */
203
268
  remove(): Promise<boolean>;
269
+ /**
270
+ * Gets a CSS string representing a binding to the variable.
271
+ *
272
+ * This string can be used in custom CSS values to ensure the binding will not break
273
+ * if the variable is renamed.
274
+ *
275
+ * @returns A Promise that resolves into a string representing the variable's name binding. (e.g. `var(--my-number-variable)`)
276
+ * @example
277
+ * ```ts
278
+ * const collection = await webflow.getDefaultVariableCollection();
279
+ * const variable = await collection.getVariable('id-123')
280
+ * const variableBinding = await variable.getBinding()
281
+ * ```
282
+ */
283
+ getBinding(): Promise<string>;
284
+ /**
285
+ * Gets a CSS string representing the variable's name.
286
+ *
287
+ * This string can be used in custom CSS with a variable (e.g. binding with a fallback value).
288
+ *
289
+ * @returns A Promise that resolves into a string representing the variable's CSS name. (e.g. `--my-number-variable`)
290
+ * @example
291
+ * ```ts
292
+ * const collection = await webflow.getDefaultVariableCollection();
293
+ * const variable = await collection.getVariable('id-123')
294
+ * const variableCSSName = await variable.getCSSName()
295
+ * ```
296
+ */
297
+ getCSSName(): Promise<string>;
204
298
  }
205
299
 
206
300
  interface PercentageVariable {
@@ -244,7 +338,7 @@ interface PercentageVariable {
244
338
  * ```
245
339
  */
246
340
  set(
247
- value: PercentageValue | PercentageVariable,
341
+ value: PercentageValue | PercentageVariable | CustomValue,
248
342
  options?: VariableOptions
249
343
  ): Promise<null>;
250
344
 
@@ -259,7 +353,9 @@ interface PercentageVariable {
259
353
  * console.log(await newVariable.get());
260
354
  * ```
261
355
  */
262
- get(options?: VariableOptions): Promise<PercentageValue | PercentageVariable>;
356
+ get(
357
+ options?: VariableOptions
358
+ ): Promise<PercentageValue | PercentageVariable | CustomValue>;
263
359
 
264
360
  /**
265
361
  * Removes the variable from the default collection.
@@ -271,6 +367,35 @@ interface PercentageVariable {
271
367
  * ```
272
368
  */
273
369
  remove(): Promise<boolean>;
370
+ /**
371
+ * Gets a CSS string representing a binding to the variable.
372
+ *
373
+ * This string can be used in custom CSS values to ensure the binding will not break
374
+ * if the variable is renamed.
375
+ *
376
+ * @returns A Promise that resolves into a string representing the variable's name binding. (e.g. `var(--my-percentage-variable)`)
377
+ * @example
378
+ * ```ts
379
+ * const collection = await webflow.getDefaultVariableCollection();
380
+ * const variable = await collection.getVariable('id-123')
381
+ * const variableBinding = await variable.getBinding()
382
+ * ```
383
+ */
384
+ getBinding(): Promise<string>;
385
+ /**
386
+ * Gets a CSS string representing the variable's name.
387
+ *
388
+ * This string can be used in custom CSS with a variable (e.g. binding with a fallback value).
389
+ *
390
+ * @returns A Promise that resolves into a string representing the variable's name. (e.g. `--my-percentage-variable`)
391
+ * @example
392
+ * ```ts
393
+ * const collection = await webflow.getDefaultVariableCollection();
394
+ * const variable = await collection.getVariable('id-123')
395
+ * const variableCSSName = await variable.getCSSName()
396
+ * ```
397
+ */
398
+ getCSSName(): Promise<string>;
274
399
  }
275
400
 
276
401
  interface FontFamilyVariable {
@@ -312,7 +437,7 @@ interface FontFamilyVariable {
312
437
  * ```
313
438
  */
314
439
  set(
315
- value: FontFamilyValue | FontFamilyVariable,
440
+ value: FontFamilyValue | FontFamilyVariable | CustomValue,
316
441
  options?: VariableOptions
317
442
  ): Promise<null>;
318
443
  /**
@@ -326,7 +451,9 @@ interface FontFamilyVariable {
326
451
  * console.log(await newVariable1.get());
327
452
  * ```
328
453
  */
329
- get(options?: VariableOptions): Promise<FontFamilyValue | FontFamilyVariable>;
454
+ get(
455
+ options?: VariableOptions
456
+ ): Promise<FontFamilyValue | FontFamilyVariable | CustomValue>;
330
457
  /**
331
458
  * Removes a variable from the default collection.
332
459
  * @returns A Promise that resolves into a boolean indicating whether deleting the variable was successful or not.
@@ -337,6 +464,35 @@ interface FontFamilyVariable {
337
464
  * ```
338
465
  */
339
466
  remove(): Promise<boolean>;
467
+ /**
468
+ * Gets a CSS string representing a binding to the variable.
469
+ *
470
+ * This string can be used in custom CSS values to ensure the binding will not break
471
+ * if the variable is renamed.
472
+ *
473
+ * @returns A Promise that resolves into a string representing the variable's name binding. (e.g. `var(--my-font-family-variable)`)
474
+ * @example
475
+ * ```ts
476
+ * const collection = await webflow.getDefaultVariableCollection();
477
+ * const variable = await collection.getVariable('id-123')
478
+ * const variableBinding = await variable.getBinding()
479
+ * ```
480
+ */
481
+ getBinding(): Promise<string>;
482
+ /**
483
+ * Gets a CSS string representing the variable's name.
484
+ *
485
+ * This string can be used in custom CSS with a variable (e.g. binding with a fallback value).
486
+ *
487
+ * @returns A Promise that resolves into a string representing the variable's name. (e.g. `--my-font-family-variable`)
488
+ * @example
489
+ * ```ts
490
+ * const collection = await webflow.getDefaultVariableCollection();
491
+ * const variable = await collection.getVariable('id-123')
492
+ * const variableCSSName = await variable.getCSSName()
493
+ * ```
494
+ */
495
+ getCSSName(): Promise<string>;
340
496
  }
341
497
 
342
498
  type Variable =
@@ -354,23 +510,23 @@ interface VariableCollection {
354
510
  getAllVariables(): Promise<Array<Variable>>;
355
511
  createColorVariable(
356
512
  name: string,
357
- value: string | ColorVariable
513
+ value: string | ColorVariable | CustomValue
358
514
  ): Promise<ColorVariable>;
359
515
  createSizeVariable(
360
516
  name: string,
361
- value: SizeValue | SizeVariable
517
+ value: SizeValue | SizeVariable | CustomValue
362
518
  ): Promise<SizeVariable>;
363
519
  createNumberVariable(
364
520
  name: string,
365
- value: number | NumberVariable
521
+ value: number | NumberVariable | CustomValue
366
522
  ): Promise<NumberVariable>;
367
523
  createPercentageVariable(
368
524
  name: string,
369
- value: number | PercentageVariable
525
+ value: number | PercentageVariable | CustomValue
370
526
  ): Promise<PercentageVariable>;
371
527
  createFontFamilyVariable(
372
528
  name: string,
373
- value: string | FontFamilyVariable
529
+ value: string | FontFamilyVariable | CustomValue
374
530
  ): Promise<FontFamilyVariable>;
375
531
  /**
376
532
  * Sets the name of the variable collection.
@@ -490,4 +646,10 @@ type SizeUnit =
490
646
  type VariableOptions = {
491
647
  /** The mode to get/set the variable value for. */
492
648
  mode?: VariableMode;
649
+ /** Whether to return custom values. */
650
+ customValues?: boolean;
651
+ };
652
+ type CustomValue = {
653
+ type: 'custom';
654
+ value: string;
493
655
  };