@figma-vars/hooks 1.3.3 → 1.4.3

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.
Files changed (46) hide show
  1. package/README.md +85 -19
  2. package/dist/figma-vars-hooks.js +312 -296
  3. package/dist/figma-vars-hooks.umd.cjs +3 -3
  4. package/dist/src/api/fetcher.d.ts +28 -0
  5. package/dist/src/api/index.d.ts +25 -0
  6. package/dist/src/api/mutator.d.ts +33 -0
  7. package/dist/src/api/mutator.test.d.ts +1 -0
  8. package/dist/src/constants/index.d.ts +89 -0
  9. package/dist/src/contexts/FigmaVarsProvider.d.ts +56 -0
  10. package/dist/src/contexts/index.d.ts +21 -0
  11. package/dist/src/hooks/index.d.ts +143 -0
  12. package/dist/src/hooks/useBulkUpdateVariables.d.ts +46 -0
  13. package/dist/src/hooks/useCreateVariable.d.ts +45 -0
  14. package/dist/src/hooks/useDeleteVariable.d.ts +33 -0
  15. package/dist/src/hooks/useFigmaToken.d.ts +21 -0
  16. package/dist/src/hooks/useMutation.d.ts +53 -0
  17. package/dist/src/hooks/useUpdateVariable.d.ts +40 -0
  18. package/dist/src/hooks/useVariableCollections.d.ts +35 -0
  19. package/dist/src/hooks/useVariableModes.d.ts +32 -0
  20. package/dist/src/hooks/useVariables.d.ts +32 -0
  21. package/dist/src/index.d.ts +80 -0
  22. package/dist/src/types/contexts.d.ts +77 -0
  23. package/dist/src/types/figma.d.ts +244 -0
  24. package/dist/src/types/hooks.d.ts +67 -0
  25. package/dist/src/types/index.d.ts +30 -0
  26. package/dist/src/types/mutations.d.ts +314 -0
  27. package/dist/src/utils/filterVariables.d.ts +31 -0
  28. package/dist/src/utils/index.d.ts +21 -0
  29. package/dist/tests/FigmaVarsProvider.test.d.ts +1 -0
  30. package/dist/tests/api/fetcher.test.d.ts +1 -0
  31. package/dist/tests/api/mutator.test.d.ts +1 -0
  32. package/dist/tests/constants/index.test.d.ts +1 -0
  33. package/dist/tests/hooks/useBulkUpdateVariables.test.d.ts +1 -0
  34. package/dist/tests/hooks/useCreateVariable.test.d.ts +1 -0
  35. package/dist/tests/hooks/useDeleteVariable.test.d.ts +1 -0
  36. package/dist/tests/hooks/useMutation.test.d.ts +1 -0
  37. package/dist/tests/hooks/useUpdateVariable.test.d.ts +1 -0
  38. package/dist/tests/hooks/useVariableCollections.test.d.ts +1 -0
  39. package/dist/tests/hooks/useVariableModes.test.d.ts +1 -0
  40. package/dist/tests/hooks/useVariables.test.d.ts +1 -0
  41. package/dist/tests/mocks/variables.d.ts +2 -0
  42. package/dist/tests/setup.d.ts +0 -0
  43. package/dist/tests/test-utils.d.ts +10 -0
  44. package/dist/tests/test-utils.test.d.ts +1 -0
  45. package/package.json +4 -2
  46. package/dist/index.d.ts +0 -1221
package/dist/index.d.ts DELETED
@@ -1,1221 +0,0 @@
1
- import { JSX as JSX_2 } from 'react/jsx-runtime';
2
- import { MutationResult as MutationResult_2 } from '../types/mutations';
3
- import { MutationResult as MutationResult_3 } from '..';
4
- import { ReactNode } from 'react';
5
-
6
- /**
7
- * The payload for the `bulkUpdateVariables` function.
8
- * Allows creating, updating, and deleting multiple variables, collections, and modes in one call.
9
- * This corresponds to the `POST /v1/files/:file_key/variables` endpoint.
10
- * Note: Figma has deprecated this complex endpoint in favor of simpler, more granular ones.
11
- * This type is kept for legacy purposes but its usage is not recommended.
12
- *
13
- * @typedef {Object} BulkUpdatePayload
14
- * @memberof Types
15
- * @since 1.0.0
16
- * @see {@link https://www.figma.com/developers/api#post-variables|Figma API - Bulk Update Variables}
17
- * @property {VariableCollectionChange[]} [variableCollections] A list of changes to variable collections.
18
- * @property {VariableModeChange[]} [variableModes] A list of changes to variable modes.
19
- * @property {VariableChange[]} [variables] A list of changes to variables.
20
- * @property {VariableModeValue[]} [variableModeValues] A list of changes to variable values in specific modes.
21
- */
22
- export declare interface BulkUpdatePayload {
23
- /** A list of changes to variable collections. */
24
- variableCollections?: VariableCollectionChange[]
25
- /** A list of changes to variable modes. */
26
- variableModes?: VariableModeChange[]
27
- /** A list of changes to variables. */
28
- variables?: VariableChange[]
29
- /** A list of changes to variable values in specific modes. */
30
- variableModeValues?: VariableModeValue[]
31
- }
32
-
33
- /**
34
- * The payload for the `bulkUpdateVariables` function.
35
- * Allows creating, updating, and deleting multiple variables, collections, and modes in one call.
36
- * This corresponds to the `POST /v1/files/:file_key/variables` endpoint.
37
- * Note: Figma has deprecated this complex endpoint in favor of simpler, more granular ones.
38
- * This type is kept for legacy purposes but its usage is not recommended.
39
- *
40
- * @typedef {Object} BulkUpdatePayload
41
- * @memberof Types
42
- * @since 1.0.0
43
- * @see {@link https://www.figma.com/developers/api#post-variables|Figma API - Bulk Update Variables}
44
- * @property {VariableCollectionChange[]} [variableCollections] A list of changes to variable collections.
45
- * @property {VariableModeChange[]} [variableModes] A list of changes to variable modes.
46
- * @property {VariableChange[]} [variables] A list of changes to variables.
47
- * @property {VariableModeValue[]} [variableModeValues] A list of changes to variable values in specific modes.
48
- */
49
- declare interface BulkUpdatePayload_2 {
50
- /** A list of changes to variable collections. */
51
- variableCollections?: VariableCollectionChange_2[];
52
- /** A list of changes to variable modes. */
53
- variableModes?: VariableModeChange_2[];
54
- /** A list of changes to variables. */
55
- variables?: VariableChange_2[];
56
- /** A list of changes to variable values in specific modes. */
57
- variableModeValues?: VariableModeValue_2[];
58
- }
59
-
60
- /**
61
- * The response object returned by the `bulkUpdateVariables` function.
62
- *
63
- * @typedef {Object} BulkUpdateResponse
64
- * @memberof Types
65
- * @since 1.0.0
66
- * @see {@link https://www.figma.com/developers/api#post-variables|Figma API - Bulk Update Variables}
67
- * @property {boolean} error Whether an error occurred during the bulk update.
68
- * @property {number} status The HTTP status code of the response.
69
- * @property {string} [message] A message describing the result of the bulk update.
70
- * @property {Object} [meta] Additional metadata about the bulk update.
71
- * @property {Record<string, string>} [meta.tempIdToRealId] A mapping of temporary IDs to real IDs for created variables.
72
- */
73
- export declare interface BulkUpdateResponse {
74
- error: boolean
75
- status: number
76
- message?: string
77
- meta?: {
78
- tempIdToRealId: Record<string, string>
79
- }
80
- }
81
-
82
- /**
83
- * Represents a color in RGBA format.
84
- *
85
- * @typedef {Object} Color
86
- * @memberof Types
87
- * @since 1.0.0
88
- * @see {@link https://www.figma.com/developers/api#color-object|Figma Color Object}
89
- * @property {number} r The red channel value (0-1).
90
- * @property {number} g The green channel value (0-1).
91
- * @property {number} b The blue channel value (0-1).
92
- * @property {number} a The alpha (opacity) channel value (0-1).
93
- */
94
- export declare interface Color {
95
- /** The red channel value (0-1). */
96
- r: number
97
- /** The green channel value (0-1). */
98
- g: number
99
- /** The blue channel value (0-1). */
100
- b: number
101
- /** The alpha (opacity) channel value (0-1). */
102
- a: number
103
- }
104
-
105
- /**
106
- * Represents a color in RGBA format.
107
- *
108
- * @typedef {Object} Color
109
- * @memberof Types
110
- * @since 1.0.0
111
- * @see {@link https://www.figma.com/developers/api#color-object|Figma Color Object}
112
- * @property {number} r The red channel value (0-1).
113
- * @property {number} g The green channel value (0-1).
114
- * @property {number} b The blue channel value (0-1).
115
- * @property {number} a The alpha (opacity) channel value (0-1).
116
- */
117
- declare interface Color_2 {
118
- /** The red channel value (0-1). */
119
- r: number;
120
- /** The green channel value (0-1). */
121
- g: number;
122
- /** The blue channel value (0-1). */
123
- b: number;
124
- /** The alpha (opacity) channel value (0-1). */
125
- a: number;
126
- }
127
-
128
- /**
129
- * The payload for the `createVariable` function.
130
- * Defines the properties for a new variable.
131
- *
132
- * @typedef {Object} CreateVariablePayload
133
- * @memberof Types
134
- * @since 1.0.0
135
- * @see {@link https://www.figma.com/developers/api#post-variables|Figma API - Create Variable}
136
- * @property {string} name The name of the new variable.
137
- * @property {string} variableCollectionId The ID of the collection the new variable should be added to.
138
- * @property {ResolvedType} resolvedType The underlying data type for the new variable.
139
- * @property {string} [description] An optional description for the new variable.
140
- * @property {boolean} [hiddenFromPublishing] Whether the new variable should be hidden when publishing. Defaults to `false`.
141
- * @property {VariableScope[]} [scopes] The scopes in which this variable can be used.
142
- * @property {Record<string, string>} [codeSyntax] Platform-specific code syntax for this variable.
143
- * @property {Record<string, VariableValue>} [valuesByMode] Initial values for the variable by mode ID.
144
- */
145
- export declare interface CreateVariablePayload {
146
- /** The name of the new variable. */
147
- name: string
148
- /** The ID of the collection the new variable should be added to. */
149
- variableCollectionId: string
150
- /** The underlying data type for the new variable. */
151
- resolvedType: ResolvedType
152
- /** An optional description for the new variable. */
153
- description?: string
154
- /** Whether the new variable should be hidden when publishing. Defaults to `false`. */
155
- hiddenFromPublishing?: boolean
156
- /** The scopes in which this variable can be used. */
157
- scopes?: VariableScope[]
158
- /** Platform-specific code syntax for this variable. */
159
- codeSyntax?: Record<string, string>
160
- }
161
-
162
- /**
163
- * The payload for the `createVariable` function.
164
- * Defines the properties for a new variable.
165
- *
166
- * @typedef {Object} CreateVariablePayload
167
- * @memberof Types
168
- * @since 1.0.0
169
- * @see {@link https://www.figma.com/developers/api#post-variables|Figma API - Create Variable}
170
- * @property {string} name The name of the new variable.
171
- * @property {string} variableCollectionId The ID of the collection the new variable should be added to.
172
- * @property {ResolvedType} resolvedType The underlying data type for the new variable.
173
- * @property {string} [description] An optional description for the new variable.
174
- * @property {boolean} [hiddenFromPublishing] Whether the new variable should be hidden when publishing. Defaults to `false`.
175
- * @property {VariableScope[]} [scopes] The scopes in which this variable can be used.
176
- * @property {Record<string, string>} [codeSyntax] Platform-specific code syntax for this variable.
177
- * @property {Record<string, VariableValue>} [valuesByMode] Initial values for the variable by mode ID.
178
- */
179
- declare interface CreateVariablePayload_2 {
180
- /** The name of the new variable. */
181
- name: string;
182
- /** The ID of the collection the new variable should be added to. */
183
- variableCollectionId: string;
184
- /** The underlying data type for the new variable. */
185
- resolvedType: ResolvedType_2;
186
- /** An optional description for the new variable. */
187
- description?: string;
188
- /** Whether the new variable should be hidden when publishing. Defaults to `false`. */
189
- hiddenFromPublishing?: boolean;
190
- /** The scopes in which this variable can be used. */
191
- scopes?: VariableScope_2[];
192
- /** Platform-specific code syntax for this variable. */
193
- codeSyntax?: Record<string, string>;
194
- }
195
-
196
- /**
197
- * Represents a collection of Figma variables, which can contain multiple modes.
198
- *
199
- * @typedef {Object} FigmaCollection
200
- * @memberof Types
201
- * @since 1.0.0
202
- * @see {@link https://www.figma.com/developers/api#variable-collection-object|Figma Variable Collection Object}
203
- * @property {string} id The unique identifier for the collection.
204
- * @property {string} name The name of the collection (e.g., "Brand Colors").
205
- * @property {VariableMode[]} modes An array of modes available in this collection.
206
- * @property {string} defaultModeId The ID of the default mode for this collection.
207
- * @property {string[]} variableIds An array of variable IDs that belong to this collection.
208
- * @property {boolean} hiddenFromPublishing Whether the collection is hidden when publishing the library.
209
- * @property {string} updatedAt The timestamp of the last update.
210
- */
211
- export declare interface FigmaCollection {
212
- /** The unique identifier for the collection. */
213
- id: string
214
- /** The name of the collection (e.g., "Brand Colors"). */
215
- name: string
216
- /** An array of modes available in this collection. */
217
- modes: VariableMode[]
218
- /** The ID of the default mode for this collection. */
219
- defaultModeId: string
220
- /** An array of variable IDs that belong to this collection. */
221
- variableIds: string[]
222
- /** Whether the collection is hidden when publishing the library. */
223
- hiddenFromPublishing: boolean
224
- /** The timestamp of the last update. */
225
- updatedAt: string
226
- }
227
-
228
- /**
229
- * A generic error shape for failed Figma API requests.
230
- *
231
- * @typedef {Object} FigmaError
232
- * @memberof Types
233
- * @since 1.0.0
234
- * @see {@link https://www.figma.com/developers/api#error-handling|Figma API Error Handling}
235
- * @property {number} statusCode The HTTP status code of the error.
236
- * @property {string} message The error message from the API.
237
- */
238
- export declare interface FigmaError {
239
- /** The HTTP status code of the error. */
240
- statusCode: number
241
- /** The error message from the API. */
242
- message: string
243
- }
244
-
245
- /* Excluded from this release type: FigmaTokenContextType */
246
-
247
- /**
248
- * Represents a single Figma variable.
249
- *
250
- * @typedef {Object} FigmaVariable
251
- * @memberof Types
252
- * @since 1.0.0
253
- * @see {@link https://www.figma.com/developers/api#variable-object|Figma Variable Object}
254
- * @property {string} id The unique identifier for the variable.
255
- * @property {string} name The name of the variable.
256
- * @property {string} variableCollectionId The ID of the collection this variable belongs to.
257
- * @property {ResolvedType} resolvedType The underlying data type of the variable.
258
- * @property {Record<string, VariableValue>} valuesByMode A map of mode IDs to the variable's value in that mode.
259
- * @property {string} description The description of the variable, as set in Figma.
260
- * @property {boolean} hiddenFromPublishing Whether the variable is hidden when publishing the library.
261
- * @property {VariableScope[]} scopes The scopes in which this variable can be used.
262
- * @property {Record<string, string>} codeSyntax Platform-specific code syntax for this variable (e.g., for Web, iOS, Android).
263
- * @property {string} updatedAt The timestamp of the last update.
264
- */
265
- export declare interface FigmaVariable {
266
- /** The unique identifier for the variable. */
267
- id: string
268
- /** The name of the variable. */
269
- name: string
270
- /** The ID of the collection this variable belongs to. */
271
- variableCollectionId: string
272
- /** The underlying data type of the variable. */
273
- resolvedType: ResolvedType
274
- /** A map of mode IDs to the variable's value in that mode. */
275
- valuesByMode: Record<string, VariableValue>
276
- /** The description of the variable, as set in Figma. */
277
- description: string
278
- /** Whether the variable is hidden when publishing the library. */
279
- hiddenFromPublishing: boolean
280
- /** The scopes in which this variable can be used. */
281
- scopes: VariableScope[]
282
- /** Platform-specific code syntax for this variable (e.g., for Web, iOS, Android). */
283
- codeSyntax: Record<string, string>
284
- /** The timestamp of the last update. */
285
- updatedAt: string
286
- }
287
-
288
- /**
289
- * Provides the Figma token and file key to all descendant hooks.
290
- * This component should be placed at the root of your application or any component tree
291
- * that needs to interact with the Figma Variables API.
292
- *
293
- * @function FigmaVarsProvider
294
- * @memberof Providers
295
- * @since 1.0.0
296
- * @param {FigmaVarsProviderProps} props - The provider props
297
- * @param {string} props.token - The Figma Personal Access Token
298
- * @param {string} props.fileKey - The Figma file key from the file URL
299
- * @param {React.ReactNode} props.children - The child components that will have access to the context
300
- * @returns {JSX.Element} The provider component
301
- * @see {@link https://www.figma.com/developers/api#authentication|Figma API Authentication}
302
- *
303
- * @example
304
- * ```tsx
305
- * import { FigmaVarsProvider } from '@figma-vars/hooks';
306
- *
307
- * function App() {
308
- * const token = process.env.REACT_APP_FIGMA_TOKEN;
309
- * const fileKey = 'abc123def456'; // From Figma file URL
310
- *
311
- * return (
312
- * <FigmaVarsProvider token={token} fileKey={fileKey}>
313
- * <Dashboard />
314
- * <VariableEditor />
315
- * </FigmaVarsProvider>
316
- * );
317
- * }
318
- * ```
319
- *
320
- * @example
321
- * ```tsx
322
- * // With Next.js and environment variables
323
- * import { FigmaVarsProvider } from '@figma-vars/hooks';
324
- *
325
- * export default function MyApp({ Component, pageProps }) {
326
- * return (
327
- * <FigmaVarsProvider
328
- * token={process.env.NEXT_PUBLIC_FIGMA_TOKEN}
329
- * fileKey={process.env.NEXT_PUBLIC_FIGMA_FILE_KEY}
330
- * >
331
- * <Component {...pageProps} />
332
- * </FigmaVarsProvider>
333
- * );
334
- * }
335
- * ```
336
- */
337
- export declare const FigmaVarsProvider: ({ children, token, fileKey, }: FigmaVarsProviderProps_2) => JSX_2.Element;
338
-
339
- /**
340
- * Props for the `FigmaVarsProvider` component.
341
- *
342
- * @typedef {Object} FigmaVarsProviderProps
343
- * @memberof Types
344
- * @since 1.0.0
345
- * @property {ReactNode} children The child components that will have access to the context.
346
- * @property {string | null} token The Figma Personal Access Token for API authentication.
347
- * @property {string | null} fileKey The Figma file key extracted from the file URL.
348
- */
349
- export declare interface FigmaVarsProviderProps {
350
- /** The child components that will have access to the context. */
351
- children: ReactNode
352
- /**
353
- * Your Figma Personal Access Token.
354
- * @see https://www.figma.com/developers/api#authentication
355
- */
356
- token: string | null
357
- /**
358
- * The unique identifier of the Figma file you want to access.
359
- * You can get this from the file's URL.
360
- */
361
- fileKey: string | null
362
- }
363
-
364
- /**
365
- * Props for the `FigmaVarsProvider` component.
366
- *
367
- * @typedef {Object} FigmaVarsProviderProps
368
- * @memberof Types
369
- * @since 1.0.0
370
- * @property {ReactNode} children The child components that will have access to the context.
371
- * @property {string | null} token The Figma Personal Access Token for API authentication.
372
- * @property {string | null} fileKey The Figma file key extracted from the file URL.
373
- */
374
- declare interface FigmaVarsProviderProps_2 {
375
- /** The child components that will have access to the context. */
376
- children: ReactNode;
377
- /**
378
- * Your Figma Personal Access Token.
379
- * @see https://www.figma.com/developers/api#authentication
380
- */
381
- token: string | null;
382
- /**
383
- * The unique identifier of the Figma file you want to access.
384
- * You can get this from the file's URL.
385
- */
386
- fileKey: string | null;
387
- }
388
-
389
- /**
390
- * Filters an array of Figma variables based on specified criteria.
391
- * This utility can filter by variable type, a partial name match, or both.
392
- *
393
- * @function filterVariables
394
- * @memberof Utils
395
- * @since 1.0.0
396
- * @param {FigmaVariable[]} variables The array of `FigmaVariable` objects to filter.
397
- * @param {Object} criteria An object specifying the filter criteria.
398
- * @param {ResolvedType} [criteria.resolvedType] The variable type (e.g., 'COLOR', 'FLOAT') to filter by.
399
- * @param {string} [criteria.name] A string to search for within the variable names (case-sensitive).
400
- * @returns {FigmaVariable[]} A new array containing only the variables that match the criteria.
401
- * @see {@link https://www.figma.com/developers/api#variable-object|Figma Variable Object}
402
- *
403
- * @example
404
- * ```typescript
405
- * import { filterVariables } from 'utils/filterVariables';
406
- *
407
- * const allVariables = [
408
- * { name: 'primary-color', resolvedType: 'COLOR', id: '1:1', ... },
409
- * { name: 'font-size-large', resolvedType: 'FLOAT', id: '1:2', ... },
410
- * { name: 'secondary-color', resolvedType: 'COLOR', id: '1:3', ... }
411
- * ];
412
- *
413
- * // Filter by type
414
- * const colorVariables = filterVariables(allVariables, {
415
- * resolvedType: 'COLOR'
416
- * });
417
- * // Returns: [primary-color, secondary-color]
418
- *
419
- * // Filter by name (partial match)
420
- * const fontVariables = filterVariables(allVariables, {
421
- * name: 'font'
422
- * });
423
- * // Returns: [font-size-large]
424
- *
425
- * // Filter by both type and name
426
- * const primaryColors = filterVariables(allVariables, {
427
- * resolvedType: 'COLOR',
428
- * name: 'primary'
429
- * });
430
- * // Returns: [primary-color]
431
- * ```
432
- *
433
- * @example
434
- * ```typescript
435
- * // Use with the useVariables hook
436
- * import { useVariables, filterVariables } from 'utils';
437
- *
438
- * function ColorVariablesList() {
439
- * const { variables } = useVariables();
440
- *
441
- * const colorVariables = filterVariables(variables, {
442
- * resolvedType: 'COLOR'
443
- * });
444
- *
445
- * return (
446
- * <ul>
447
- * {colorVariables.map(variable => (
448
- * <li key={variable.id}>{variable.name}</li>
449
- * ))}
450
- * </ul>
451
- * );
452
- * }
453
- * ```
454
- */
455
- export declare function filterVariables(variables: FigmaVariable[], criteria: {
456
- resolvedType?: ResolvedType;
457
- name?: string;
458
- }): FigmaVariable[];
459
-
460
- /**
461
- * The structure of the successful response from the Figma API's `/v1/files/{file_key}/variables/local` endpoint.
462
- *
463
- * @typedef {Object} LocalVariablesResponse
464
- * @memberof Types
465
- * @since 1.0.0
466
- * @see {@link https://www.figma.com/developers/api#variables-endpoint|Figma Variables Endpoint}
467
- * @property {Object} meta Contains the metadata about the variables and collections.
468
- * @property {Record<string, FigmaCollection>} meta.variableCollections A map of collection IDs to `FigmaCollection` objects.
469
- * @property {Record<string, FigmaVariable>} meta.variables A map of variable IDs to `FigmaVariable` objects.
470
- */
471
- export declare interface LocalVariablesResponse {
472
- /** Contains the metadata about the variables and collections. */
473
- meta: {
474
- /** A map of collection IDs to `FigmaCollection` objects. */
475
- variableCollections: Record<string, FigmaCollection>
476
- /** A map of variable IDs to `FigmaVariable` objects. */
477
- variables: Record<string, FigmaVariable>
478
- }
479
- }
480
-
481
- /**
482
- * The result object returned by the `useMutation` hook.
483
- * @template TData The type of data returned by the mutation.
484
- * @template TPayload The type of the payload passed to the mutate function.
485
- *
486
- * @typedef {Object} MutationResult
487
- * @memberof Types
488
- * @since 1.0.0
489
- * @property {(payload: TPayload) => Promise<TData | undefined>} mutate A function to trigger the mutation.
490
- * @property {'idle' | 'loading' | 'success' | 'error'} status The current status of the mutation.
491
- * @property {TData | null} data The data returned by the mutation, or null if the mutation has not completed.
492
- * @property {Error | null} error The error returned by the mutation, or null if the mutation was successful.
493
- * @property {boolean} isLoading Whether the mutation is currently loading.
494
- * @property {boolean} isSuccess Whether the mutation was successful.
495
- * @property {boolean} isError Whether the mutation resulted in an error.
496
- */
497
- export declare interface MutationResult<TData, TPayload> {
498
- mutate: (payload: TPayload) => Promise<TData | undefined>
499
- status: 'idle' | 'loading' | 'success' | 'error'
500
- data: TData | null
501
- error: Error | null
502
- isLoading: boolean
503
- isSuccess: boolean
504
- isError: boolean
505
- }
506
-
507
- /**
508
- * Represents the state of a mutation operation.
509
- * @template TData The type of data returned by the mutation.
510
- * @template TError The type of error returned by the mutation.
511
- *
512
- * @typedef {Object} MutationState
513
- * @memberof Types
514
- * @since 1.0.0
515
- * @property {'idle' | 'loading' | 'success' | 'error'} status The current status of the mutation.
516
- * @property {TData | null} data The data returned by the mutation, or null if the mutation has not completed.
517
- * @property {Error | null} error The error returned by the mutation, or null if the mutation was successful.
518
- */
519
- export declare interface MutationState<TData> {
520
- status: 'idle' | 'loading' | 'success' | 'error'
521
- data: TData | null
522
- error: Error | null
523
- }
524
-
525
- /**
526
- * @fileoverview TypeScript type definitions for the Figma Variables REST API.
527
- * These types match the official Figma API specification for variables, collections, and modes.
528
- * @see {@link https://www.figma.com/developers/api#variables|Figma Variables API Documentation}
529
- * @since 1.0.0
530
- */
531
-
532
- /**
533
- * The resolved type of a Figma variable.
534
- * Determines what kind of value the variable can hold.
535
- *
536
- * @typedef {string} ResolvedType
537
- * @memberof Types
538
- * @since 1.0.0
539
- * @see {@link https://www.figma.com/developers/api#variable-object|Figma Variable Object}
540
- */
541
- export declare type ResolvedType = 'BOOLEAN' | 'FLOAT' | 'STRING' | 'COLOR'
542
-
543
- /**
544
- * @fileoverview TypeScript type definitions for the Figma Variables REST API.
545
- * These types match the official Figma API specification for variables, collections, and modes.
546
- * @see {@link https://www.figma.com/developers/api#variables|Figma Variables API Documentation}
547
- * @since 1.0.0
548
- */
549
- /**
550
- * The resolved type of a Figma variable.
551
- * Determines what kind of value the variable can hold.
552
- *
553
- * @typedef {string} ResolvedType
554
- * @memberof Types
555
- * @since 1.0.0
556
- * @see {@link https://www.figma.com/developers/api#variable-object|Figma Variable Object}
557
- */
558
- declare type ResolvedType_2 = 'BOOLEAN' | 'FLOAT' | 'STRING' | 'COLOR';
559
-
560
- declare type UpdateVariableArgs = {
561
- variableId: string;
562
- payload: UpdateVariablePayload_2;
563
- };
564
-
565
- /**
566
- * The payload for the `updateVariable` function.
567
- * All properties are optional.
568
- *
569
- * @typedef {Object} UpdateVariablePayload
570
- * @memberof Types
571
- * @since 1.0.0
572
- * @see {@link https://www.figma.com/developers/api#patch-variables|Figma API - Update Variable}
573
- * @property {string} [name] The new name for the variable.
574
- * @property {string} [description] The new description for the variable.
575
- * @property {boolean} [hiddenFromPublishing] The new hidden status for the variable.
576
- * @property {VariableScope[]} [scopes] The new scopes for the variable.
577
- * @property {Record<string, string>} [codeSyntax] The new code syntax for the variable.
578
- * @property {Record<string, VariableValue>} [valuesByMode] New values for the variable by mode ID.
579
- */
580
- export declare interface UpdateVariablePayload {
581
- /** The new name for the variable. */
582
- name?: string
583
- /** The new description for the variable. */
584
- description?: string
585
- /** The new hidden status for the variable. */
586
- hiddenFromPublishing?: boolean
587
- /** The new scopes for the variable. */
588
- scopes?: VariableScope[]
589
- /** The new code syntax for the variable. */
590
- codeSyntax?: Record<string, string>
591
- }
592
-
593
- /**
594
- * The payload for the `updateVariable` function.
595
- * All properties are optional.
596
- *
597
- * @typedef {Object} UpdateVariablePayload
598
- * @memberof Types
599
- * @since 1.0.0
600
- * @see {@link https://www.figma.com/developers/api#patch-variables|Figma API - Update Variable}
601
- * @property {string} [name] The new name for the variable.
602
- * @property {string} [description] The new description for the variable.
603
- * @property {boolean} [hiddenFromPublishing] The new hidden status for the variable.
604
- * @property {VariableScope[]} [scopes] The new scopes for the variable.
605
- * @property {Record<string, string>} [codeSyntax] The new code syntax for the variable.
606
- * @property {Record<string, VariableValue>} [valuesByMode] New values for the variable by mode ID.
607
- */
608
- declare interface UpdateVariablePayload_2 {
609
- /** The new name for the variable. */
610
- name?: string;
611
- /** The new description for the variable. */
612
- description?: string;
613
- /** The new hidden status for the variable. */
614
- hiddenFromPublishing?: boolean;
615
- /** The new scopes for the variable. */
616
- scopes?: VariableScope_2[];
617
- /** The new code syntax for the variable. */
618
- codeSyntax?: Record<string, string>;
619
- }
620
-
621
- /**
622
- * Updates multiple variables in the Figma file in a single request.
623
- *
624
- * This hook provides a stateful API to perform a bulk update, returning the mutation's
625
- * current state including `isLoading`, `isSuccess`, and `isError`.
626
- *
627
- * @function useBulkUpdateVariables
628
- * @memberof Hooks
629
- * @since 1.0.0
630
- * @returns {MutationResult<any, BulkUpdatePayload>} The mutation object with state and trigger function.
631
- * @see {@link https://www.figma.com/developers/api#post-variables|Figma Variables API - Bulk Update Variables}
632
- * @see {@link useMutation} - The underlying mutation hook
633
- *
634
- * @example
635
- * ```tsx
636
- * import { useBulkUpdateVariables } from '@figma-vars/hooks';
637
- *
638
- * function BulkVariableEditor() {
639
- * const { mutate, isLoading, isSuccess, error } = useBulkUpdateVariables();
640
- *
641
- * const handleBulkUpdate = () => {
642
- * mutate({
643
- * variableIds: ['VariableID:123:456', 'VariableID:123:457'],
644
- * variableCollectionId: 'VariableCollectionId:123:456',
645
- * updates: {
646
- * 'VariableID:123:456': {
647
- * name: 'Primary Color Updated',
648
- * description: 'Updated primary brand color'
649
- * },
650
- * 'VariableID:123:457': {
651
- * name: 'Secondary Color Updated',
652
- * description: 'Updated secondary brand color'
653
- * }
654
- * }
655
- * });
656
- * };
657
- *
658
- * if (isLoading) return <div>Updating variables...</div>;
659
- * if (error) return <div>Error: {error.message}</div>;
660
- * if (isSuccess) return <div>Variables updated successfully!</div>;
661
- *
662
- * return <button onClick={handleBulkUpdate}>Update All Variables</button>;
663
- * }
664
- * ```
665
- *
666
- * @example
667
- * ```tsx
668
- * // Bulk update color variables with new values
669
- * const { mutate } = useBulkUpdateVariables();
670
- *
671
- * mutate({
672
- * variableIds: ['VariableID:123:456', 'VariableID:123:457'],
673
- * variableCollectionId: 'VariableCollectionId:123:456',
674
- * updates: {
675
- * 'VariableID:123:456': {
676
- * valuesByMode: {
677
- * '42:0': { r: 0.2, g: 0.4, b: 0.8, a: 1 }
678
- * }
679
- * },
680
- * 'VariableID:123:457': {
681
- * valuesByMode: {
682
- * '42:0': { r: 0.8, g: 0.4, b: 0.2, a: 1 }
683
- * }
684
- * }
685
- * }
686
- * });
687
- * ```
688
- */
689
- export declare const useBulkUpdateVariables: () => MutationResult_2<any, BulkUpdatePayload_2>;
690
-
691
- /**
692
- * Creates a new variable in the Figma file.
693
- *
694
- * This hook provides a stateful API to create a new variable, returning the mutation's
695
- * current state including `isLoading`, `isSuccess`, `isError`, and the created data.
696
- *
697
- * @function useCreateVariable
698
- * @memberof Hooks
699
- * @since 1.0.0
700
- * @returns {MutationResult<any, CreateVariablePayload>} The mutation object with state and trigger function.
701
- * @see {@link https://www.figma.com/developers/api#post-variables|Figma Variables API - Create Variable}
702
- * @see {@link useMutation} - The underlying mutation hook
703
- *
704
- * @example
705
- * ```tsx
706
- * import { useCreateVariable } from '@figma-vars/hooks';
707
- *
708
- * function VariableCreator() {
709
- * const { mutate, isLoading, isSuccess, error, data } = useCreateVariable();
710
- *
711
- * const handleCreate = () => {
712
- * mutate({
713
- * name: 'Primary Color',
714
- * variableCollectionId: 'VariableCollectionId:123:456',
715
- * resolvedType: 'COLOR',
716
- * valuesByMode: {
717
- * '42:0': { r: 0.2, g: 0.4, b: 0.8, a: 1 }
718
- * }
719
- * });
720
- * };
721
- *
722
- * if (isLoading) return <div>Creating variable...</div>;
723
- * if (error) return <div>Error: {error.message}</div>;
724
- * if (isSuccess) return <div>Variable created: {data?.name}</div>;
725
- *
726
- * return <button onClick={handleCreate}>Create Variable</button>;
727
- * }
728
- * ```
729
- *
730
- * @example
731
- * ```tsx
732
- * // Create a string variable
733
- * const { mutate } = useCreateVariable();
734
- *
735
- * mutate({
736
- * name: 'Button Text',
737
- * variableCollectionId: 'VariableCollectionId:123:456',
738
- * resolvedType: 'STRING',
739
- * description: 'Default button text content',
740
- * valuesByMode: {
741
- * '42:0': 'Click me'
742
- * },
743
- * scopes: ['TEXT_CONTENT']
744
- * });
745
- * ```
746
- */
747
- export declare const useCreateVariable: () => MutationResult_2<any, CreateVariablePayload_2>;
748
-
749
- /**
750
- * Deletes a variable from the Figma file by its ID.
751
- *
752
- * This hook provides a stateful API to delete a variable, returning the mutation's
753
- * current state including `isLoading`, `isSuccess`, and `isError`.
754
- *
755
- * @function useDeleteVariable
756
- * @memberof Hooks
757
- * @since 1.0.0
758
- * @returns {MutationResult<void, string>} The mutation object with state and trigger function.
759
- * @see {@link https://www.figma.com/developers/api#delete-variables|Figma Variables API - Delete Variable}
760
- * @see {@link useMutation} - The underlying mutation hook
761
- *
762
- * @example
763
- * ```tsx
764
- * import { useDeleteVariable } from '@figma-vars/hooks';
765
- *
766
- * function VariableDeleter({ variableId }) {
767
- * const { mutate, isLoading, isSuccess, error } = useDeleteVariable();
768
- *
769
- * const handleDelete = () => {
770
- * if (confirm('Are you sure you want to delete this variable?')) {
771
- * mutate(variableId);
772
- * }
773
- * };
774
- *
775
- * if (isLoading) return <div>Deleting variable...</div>;
776
- * if (error) return <div>Error: {error.message}</div>;
777
- * if (isSuccess) return <div>Variable deleted successfully!</div>;
778
- *
779
- * return <button onClick={handleDelete}>Delete Variable</button>;
780
- * }
781
- * ```
782
- *
783
- * @example
784
- * ```tsx
785
- * // Delete a variable by ID
786
- * const { mutate, isLoading } = useDeleteVariable();
787
- *
788
- * const deleteVariable = (id: string) => {
789
- * mutate(id); // Pass the variable ID directly
790
- * };
791
- *
792
- * // Usage
793
- * deleteVariable('VariableID:123:456');
794
- * ```
795
- */
796
- export declare const useDeleteVariable: () => MutationResult_3<any, string>;
797
-
798
- /**
799
- * Retrieves the Figma API token from the FigmaVarsProvider.
800
- * This hook must be used within a component wrapped by FigmaVarsProvider.
801
- *
802
- * @function useFigmaToken
803
- * @memberof Hooks
804
- * @since 1.0.0
805
- * @returns {string | null} The Figma Personal Access Token, or `null` if it has not been provided.
806
- * @see {@link https://www.figma.com/developers/api#authentication|Figma API Authentication}
807
- * @see {@link FigmaVarsProvider} - The provider component that supplies the token
808
- *
809
- * @example
810
- * ```tsx
811
- * import { useFigmaToken } from '@figma-vars/hooks';
812
- *
813
- * function CustomAPIComponent() {
814
- * const figmaToken = useFigmaToken();
815
- *
816
- * const makeCustomAPICall = async () => {
817
- * if (!figmaToken) {
818
- * console.error('No Figma token available');
819
- * return;
820
- * }
821
- *
822
- * // Use token for custom API calls
823
- * const response = await fetch('https://api.figma.com/v1/me', {
824
- * headers: {
825
- * 'X-FIGMA-TOKEN': figmaToken
826
- * }
827
- * });
828
- * };
829
- *
830
- * return (
831
- * <div>
832
- * {figmaToken ? 'Token available' : 'No token provided'}
833
- * </div>
834
- * );
835
- * }
836
- * ```
837
- *
838
- * @example
839
- * ```tsx
840
- * // Check token availability before making API calls
841
- * const MyComponent = () => {
842
- * const figmaToken = useFigmaToken();
843
- *
844
- * if (!figmaToken) {
845
- * return <div>Please provide a Figma token</div>;
846
- * }
847
- *
848
- * return <div>Ready to interact with Figma API</div>;
849
- * };
850
- * ```
851
- */
852
- export declare const useFigmaToken: () => string | null;
853
-
854
- /**
855
- * Updates an existing Figma variable.
856
- *
857
- * This hook provides a stateful API to update a variable, returning the mutation's
858
- * current state including `isLoading`, `isSuccess`, `isError`, and the updated data.
859
- *
860
- * @function useUpdateVariable
861
- * @memberof Hooks
862
- * @since 1.0.0
863
- * @returns {MutationResult<any, UpdateVariableArgs>} The mutation object with state and trigger function.
864
- * @see {@link https://www.figma.com/developers/api#put-variables|Figma Variables API - Update Variable}
865
- * @see {@link useMutation} - The underlying mutation hook
866
- *
867
- * @example
868
- * ```tsx
869
- * import { useUpdateVariable } from '@figma-vars/hooks';
870
- *
871
- * function VariableEditor() {
872
- * const { mutate, isLoading, isSuccess, error } = useUpdateVariable();
873
- *
874
- * const handleUpdate = () => {
875
- * mutate({
876
- * variableId: 'VariableID:123:456',
877
- * payload: {
878
- * name: 'Updated Variable Name',
879
- * description: 'Updated description'
880
- * }
881
- * });
882
- * };
883
- *
884
- * if (isLoading) return <div>Updating variable...</div>;
885
- * if (error) return <div>Error: {error.message}</div>;
886
- * if (isSuccess) return <div>Variable updated successfully!</div>;
887
- *
888
- * return <button onClick={handleUpdate}>Update Variable</button>;
889
- * }
890
- * ```
891
- *
892
- * @example
893
- * ```tsx
894
- * // Update variable with new values
895
- * const { mutate } = useUpdateVariable();
896
- *
897
- * mutate({
898
- * variableId: 'VariableID:123:456',
899
- * payload: {
900
- * name: 'Primary Color',
901
- * description: 'Main brand color',
902
- * valuesByMode: {
903
- * '42:0': { r: 0.2, g: 0.4, b: 0.8, a: 1 }
904
- * }
905
- * }
906
- * });
907
- * ```
908
- */
909
- export declare const useUpdateVariable: () => MutationResult_2<unknown, UpdateVariableArgs>;
910
-
911
- /**
912
- * A memoized selector hook to access variable collections from the data fetched by `useVariables`.
913
- *
914
- * This hook is a lightweight, performant way to get only collection data. It avoids
915
- * unnecessary re-renders in components that only care about collections, as it will only
916
- * update when the collection data itself changes.
917
- *
918
- * @returns {{collections: FigmaCollection[], collectionsById: Record<string, FigmaCollection>}} An object containing the collections in different formats.
919
- *
920
- * @example
921
- * ```tsx
922
- * const { collectionsById } = useVariableCollections();
923
- * const collection = collectionsById['VariableCollectionId:123:456'];
924
- *
925
- * if (!collection) return <div>Collection not found.</div>;
926
- *
927
- * return <div>{collection.name}</div>
928
- * ```
929
- */
930
- export declare const useVariableCollections: () => {
931
- collections: FigmaCollection[];
932
- collectionsById: Record<string, FigmaCollection>;
933
- };
934
-
935
- /**
936
- * A memoized selector hook to access and process variable modes from the data fetched by `useVariables`.
937
- *
938
- * This hook is a lightweight, performant way to get only mode data. It avoids
939
- * unnecessary re-renders in components that only care about modes, as it will only
940
- * update when the mode data itself changes. It provides modes in several useful formats.
941
- *
942
- * @returns {UseVariableModesResult} An object containing the modes in different formats.
943
- *
944
- * @example
945
- * ```tsx
946
- * const { modesById, modesByCollectionId } = useVariableModes();
947
- * const lightMode = modesById['42:0'];
948
- * const collectionModes = modesByCollectionId['VariableCollectionId:123:456'];
949
- *
950
- * if (!lightMode) return <div>Mode not found.</div>;
951
- *
952
- * return <div>Mode: {lightMode.name}</div>
953
- * ```
954
- */
955
- export declare const useVariableModes: () => UseVariableModesResult_2;
956
-
957
- /**
958
- * The return type for the `useVariableModes` hook.
959
- * Provides multiple ways to access and organize variable modes from Figma collections.
960
- *
961
- * @typedef {Object} UseVariableModesResult
962
- * @memberof Types
963
- * @since 1.0.0
964
- * @see {@link useVariableModes} - The hook that returns this type
965
- * @property {VariableMode[]} modes A flat array of all modes across all collections.
966
- * @property {Record<string, VariableMode[]>} modesByCollectionId A map of collection IDs to an array of modes belonging to that collection.
967
- * @property {Record<string, VariableMode>} modesById A map of mode IDs to the corresponding mode object for quick lookups.
968
- */
969
- export declare interface UseVariableModesResult {
970
- /** A flat array of all modes across all collections. */
971
- modes: VariableMode[]
972
- /** A map of collection IDs to an array of modes belonging to that collection. */
973
- modesByCollectionId: Record<string, VariableMode[]>
974
- /** A map of mode IDs to the corresponding mode object for quick lookups. */
975
- modesById: Record<string, VariableMode>
976
- }
977
-
978
- /**
979
- * The return type for the `useVariableModes` hook.
980
- * Provides multiple ways to access and organize variable modes from Figma collections.
981
- *
982
- * @typedef {Object} UseVariableModesResult
983
- * @memberof Types
984
- * @since 1.0.0
985
- * @see {@link useVariableModes} - The hook that returns this type
986
- * @property {VariableMode[]} modes A flat array of all modes across all collections.
987
- * @property {Record<string, VariableMode[]>} modesByCollectionId A map of collection IDs to an array of modes belonging to that collection.
988
- * @property {Record<string, VariableMode>} modesById A map of mode IDs to the corresponding mode object for quick lookups.
989
- */
990
- declare interface UseVariableModesResult_2 {
991
- /** A flat array of all modes across all collections. */
992
- modes: VariableMode_2[];
993
- /** A map of collection IDs to an array of modes belonging to that collection. */
994
- modesByCollectionId: Record<string, VariableMode_2[]>;
995
- /** A map of mode IDs to the corresponding mode object for quick lookups. */
996
- modesById: Record<string, VariableMode_2>;
997
- }
998
-
999
- /**
1000
- * Fetches all local variables, collections, and modes for the file specified in the `FigmaVarsProvider`.
1001
- * This is the primary data-fetching hook and serves as the foundation for other hooks like `useVariableCollections` and `useVariableModes`.
1002
- *
1003
- * "Local variables" are all variables and collections defined in the current file.
1004
- *
1005
- * It uses `swr` for efficient data fetching, caching, and revalidation.
1006
- *
1007
- * @returns {{data: LocalVariablesResponse | undefined, isLoading: boolean, isValidating: boolean, error: Error | undefined}} The response from `useSWR` for the local variables endpoint.
1008
- * @see {@link https://www.figma.com/developers/api#get-local-variables-v1|Figma Variables API Documentation}
1009
- *
1010
- * @example
1011
- * ```tsx
1012
- * const { data, isLoading, error } = useVariables();
1013
- *
1014
- * if (isLoading) return <div>Loading variables...</div>;
1015
- * if (error) return <div>Error fetching variables: {error.message}</div>;
1016
- *
1017
- * const collections = data ? Object.values(data.meta.variableCollections) : [];
1018
- * console.log(collections);
1019
- * ```
1020
- */
1021
- export declare const useVariables: () => {
1022
- data: LocalVariablesResponse | undefined;
1023
- isLoading: boolean;
1024
- isValidating: boolean;
1025
- error: any;
1026
- };
1027
-
1028
- /* Excluded from this release type: VariableAction */
1029
-
1030
- /* Excluded from this release type: VariableAction_2 */
1031
-
1032
- /**
1033
- * Represents an alias to another Figma variable.
1034
- * This is used when a variable's value is set to reference another variable.
1035
- *
1036
- * @typedef {Object} VariableAlias
1037
- * @memberof Types
1038
- * @since 1.0.0
1039
- * @see {@link https://www.figma.com/developers/api#variable-object|Figma Variable Object}
1040
- * @property {string} type The type of the value, indicating it's a variable alias.
1041
- * @property {string} id The ID of the variable being referenced.
1042
- */
1043
- export declare interface VariableAlias {
1044
- /** The type of the value, indicating it's a variable alias. */
1045
- type: 'VARIABLE_ALIAS'
1046
- /** The ID of the variable being referenced. */
1047
- id: string
1048
- }
1049
-
1050
- /**
1051
- * Represents an alias to another Figma variable.
1052
- * This is used when a variable's value is set to reference another variable.
1053
- *
1054
- * @typedef {Object} VariableAlias
1055
- * @memberof Types
1056
- * @since 1.0.0
1057
- * @see {@link https://www.figma.com/developers/api#variable-object|Figma Variable Object}
1058
- * @property {string} type The type of the value, indicating it's a variable alias.
1059
- * @property {string} id The ID of the variable being referenced.
1060
- */
1061
- declare interface VariableAlias_2 {
1062
- /** The type of the value, indicating it's a variable alias. */
1063
- type: 'VARIABLE_ALIAS';
1064
- /** The ID of the variable being referenced. */
1065
- id: string;
1066
- }
1067
-
1068
- /* Excluded from this release type: VariableChange */
1069
-
1070
- /* Excluded from this release type: VariableChange_2 */
1071
-
1072
- /* Excluded from this release type: VariableCollectionChange */
1073
-
1074
- /* Excluded from this release type: VariableCollectionChange_2 */
1075
-
1076
- /**
1077
- * Represents a single mode within a variable collection.
1078
- *
1079
- * @typedef {Object} VariableMode
1080
- * @memberof Types
1081
- * @since 1.0.0
1082
- * @see {@link https://www.figma.com/developers/api#variable-collection-object|Figma Variable Collection Object}
1083
- * @property {string} modeId The unique identifier for the mode.
1084
- * @property {string} name The name of the mode (e.g., "Light", "Dark").
1085
- */
1086
- export declare interface VariableMode {
1087
- /** The unique identifier for the mode. */
1088
- modeId: string
1089
- /** The name of the mode (e.g., "Light", "Dark"). */
1090
- name: string
1091
- }
1092
-
1093
- /**
1094
- * Represents a single mode within a variable collection.
1095
- *
1096
- * @typedef {Object} VariableMode
1097
- * @memberof Types
1098
- * @since 1.0.0
1099
- * @see {@link https://www.figma.com/developers/api#variable-collection-object|Figma Variable Collection Object}
1100
- * @property {string} modeId The unique identifier for the mode.
1101
- * @property {string} name The name of the mode (e.g., "Light", "Dark").
1102
- */
1103
- declare interface VariableMode_2 {
1104
- /** The unique identifier for the mode. */
1105
- modeId: string;
1106
- /** The name of the mode (e.g., "Light", "Dark"). */
1107
- name: string;
1108
- }
1109
-
1110
- /* Excluded from this release type: VariableModeChange */
1111
-
1112
- /* Excluded from this release type: VariableModeChange_2 */
1113
-
1114
- /**
1115
- * A change to a variable's value in a specific mode in a bulk update.
1116
- *
1117
- * @typedef {Object} VariableModeValue
1118
- * @memberof Types
1119
- * @since 1.0.0
1120
- * @see {@link https://www.figma.com/developers/api#patch-variables|Figma API - Update Variable Value}
1121
- * @property {string} variableId The ID of the variable to update.
1122
- * @property {string} modeId The ID of the mode to update.
1123
- * @property {VariableValue} value The new value for the variable in this mode.
1124
- */
1125
- export declare interface VariableModeValue {
1126
- /** The ID of the variable to update. */
1127
- variableId: string
1128
- /** The ID of the mode to update. */
1129
- modeId: string
1130
- /** The new value for the variable in this mode. */
1131
- value: VariableValue
1132
- }
1133
-
1134
- /**
1135
- * A change to a variable's value in a specific mode in a bulk update.
1136
- *
1137
- * @typedef {Object} VariableModeValue
1138
- * @memberof Types
1139
- * @since 1.0.0
1140
- * @see {@link https://www.figma.com/developers/api#patch-variables|Figma API - Update Variable Value}
1141
- * @property {string} variableId The ID of the variable to update.
1142
- * @property {string} modeId The ID of the mode to update.
1143
- * @property {VariableValue} value The new value for the variable in this mode.
1144
- */
1145
- declare interface VariableModeValue_2 {
1146
- /** The ID of the variable to update. */
1147
- variableId: string;
1148
- /** The ID of the mode to update. */
1149
- modeId: string;
1150
- /** The new value for the variable in this mode. */
1151
- value: VariableValue_2;
1152
- }
1153
-
1154
- /**
1155
- * The scopes where a Figma variable can be applied.
1156
- * `ALL_SCOPES` is a general-purpose scope. Other values restrict the variable to specific properties.
1157
- *
1158
- * @typedef {string} VariableScope
1159
- * @memberof Types
1160
- * @since 1.0.0
1161
- * @see {@link https://www.figma.com/developers/api#variable-object|Figma Variable Object}
1162
- */
1163
- export declare type VariableScope =
1164
- | 'ALL_SCOPES'
1165
- | 'TEXT_CONTENT'
1166
- | 'CORNER_RADIUS'
1167
- | 'WIDTH_HEIGHT'
1168
- | 'GAP'
1169
- | 'STROKE_FLOAT'
1170
- | 'OPACITY'
1171
- | 'EFFECT_FLOAT'
1172
- | 'FONT_WEIGHT'
1173
- | 'FONT_SIZE'
1174
- | 'LINE_HEIGHT'
1175
- | 'LETTER_SPACING'
1176
- | 'PARAGRAPH_SPACING'
1177
- | 'PARAGRAPH_INDENT'
1178
- | 'FONT_FAMILY'
1179
- | 'FONT_STYLE'
1180
- | 'FONT_VARIATIONS'
1181
- | 'ALL_FILLS'
1182
- | 'FRAME_FILL'
1183
- | 'SHAPE_FILL'
1184
- | 'TEXT_FILL'
1185
- | 'STROKE_COLOR'
1186
- | 'EFFECT_COLOR'
1187
-
1188
- /**
1189
- * The scopes where a Figma variable can be applied.
1190
- * `ALL_SCOPES` is a general-purpose scope. Other values restrict the variable to specific properties.
1191
- *
1192
- * @typedef {string} VariableScope
1193
- * @memberof Types
1194
- * @since 1.0.0
1195
- * @see {@link https://www.figma.com/developers/api#variable-object|Figma Variable Object}
1196
- */
1197
- declare type VariableScope_2 = 'ALL_SCOPES' | 'TEXT_CONTENT' | 'CORNER_RADIUS' | 'WIDTH_HEIGHT' | 'GAP' | 'STROKE_FLOAT' | 'OPACITY' | 'EFFECT_FLOAT' | 'FONT_WEIGHT' | 'FONT_SIZE' | 'LINE_HEIGHT' | 'LETTER_SPACING' | 'PARAGRAPH_SPACING' | 'PARAGRAPH_INDENT' | 'FONT_FAMILY' | 'FONT_STYLE' | 'FONT_VARIATIONS' | 'ALL_FILLS' | 'FRAME_FILL' | 'SHAPE_FILL' | 'TEXT_FILL' | 'STROKE_COLOR' | 'EFFECT_COLOR';
1198
-
1199
- /**
1200
- * The possible value types for a variable in a specific mode.
1201
- * It can be a primitive value, a color object, or an alias to another variable.
1202
- *
1203
- * @typedef {(string|boolean|number|Color|VariableAlias)} VariableValue
1204
- * @memberof Types
1205
- * @since 1.0.0
1206
- * @see {@link https://www.figma.com/developers/api#variable-object|Figma Variable Object}
1207
- */
1208
- export declare type VariableValue = string | boolean | number | Color | VariableAlias
1209
-
1210
- /**
1211
- * The possible value types for a variable in a specific mode.
1212
- * It can be a primitive value, a color object, or an alias to another variable.
1213
- *
1214
- * @typedef {(string|boolean|number|Color|VariableAlias)} VariableValue
1215
- * @memberof Types
1216
- * @since 1.0.0
1217
- * @see {@link https://www.figma.com/developers/api#variable-object|Figma Variable Object}
1218
- */
1219
- declare type VariableValue_2 = string | boolean | number | Color_2 | VariableAlias_2;
1220
-
1221
- export { }