You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This library uses TSDoc to generate documentation. You can find the generated documentation in the `docs` folder.
214
-
215
214
---
216
215
217
216
## 🧩 API Reference
218
217
219
218
### Core Hooks
220
219
221
-
-`useVariables()`: Fetches all local variables for the file key provided to the `FigmaVarsProvider`. Returns an object with `data`, `isLoading`, and `error` properties. The `data` object contains `variables`, `variableCollections`, and `modes` from the Figma API.
220
+
-`useVariables()`: Fetches all local variables for the file key provided to the `FigmaVarsProvider`. Returns a SWR hook state with `data`, `isLoading`, and `error` properties. The actual Figma response is in `data.data`.
222
221
-`useVariableCollections()`: A convenience hook that returns just the variable collections from the main `useVariables` data.
223
222
-`useVariableModes()`: A convenience hook that returns just the variable modes from the main `useVariables` data.
224
223
-`useFigmaToken()`: A simple hook to access the token and file key from the context.
@@ -227,14 +226,14 @@ This library uses TSDoc to generate documentation. You can find the generated do
227
226
228
227
All mutation hooks return an object with the following shape: `{ mutate, data, isLoading, error }`.
229
228
230
-
-`useCreateVariable()`: Creates a new variable. The `mutate` function expects the variable data as its payload.
231
-
-`useUpdateVariable()`: Updates an existing variable. The `mutate` function expects an object with `id` and the `data` to update.
232
-
-`useDeleteVariable()`: Deletes a variable. The `mutate` function expects the `id` of the variable to delete.
233
-
-`useBulkUpdateVariables()`: Updates multiple variables in a single batch operation. The `mutate` function expects an array of variables to update.
229
+
-`useCreateVariable()`: Creates a new variable. The `mutate` function expects a `CreateVariablePayload` object.
230
+
-`useUpdateVariable()`: Updates an existing variable. The `mutate` function expects an object `{ variableId, payload }` where `payload` is an `UpdateVariablePayload`.
231
+
-`useDeleteVariable()`: Deletes a variable. The `mutate` function expects the `variableId` (string) of the variable to delete.
232
+
-`useBulkUpdateVariables()`: Creates, updates, or deletes multiple entities in a single batch operation. The `mutate` function expects a `BulkUpdatePayload` object.
234
233
235
234
### Types
236
235
237
-
All types are exported from `@figma-vars/hooks`. The core response type from Figma for local variables is `Variables_LocalVariablesResponse`.
236
+
All types are exported from `@figma-vars/hooks`. The core response type from Figma for local variables is `LocalVariablesResponse`.
0 commit comments