@figma-vars/hooks 1.5.1 → 2.0.0-beta.2
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/README.md +66 -1
- package/dist/api/fetcher.d.ts +2 -1
- package/dist/api/fetcher.d.ts.map +1 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/mutator.d.ts +2 -1
- package/dist/api/mutator.d.ts.map +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/contexts/FigmaTokenContext.d.ts +3 -0
- package/dist/contexts/FigmaTokenContext.d.ts.map +1 -0
- package/dist/contexts/FigmaVarsProvider.d.ts +3 -33
- package/dist/contexts/FigmaVarsProvider.d.ts.map +1 -0
- package/dist/contexts/index.d.ts +4 -1
- package/dist/contexts/index.d.ts.map +1 -0
- package/dist/contexts/useFigmaTokenContext.d.ts +3 -0
- package/dist/contexts/useFigmaTokenContext.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/useBulkUpdateVariables.d.ts +10 -25
- package/dist/hooks/useBulkUpdateVariables.d.ts.map +1 -0
- package/dist/hooks/useCreateVariable.d.ts +8 -25
- package/dist/hooks/useCreateVariable.d.ts.map +1 -0
- package/dist/hooks/useDeleteVariable.d.ts +9 -17
- package/dist/hooks/useDeleteVariable.d.ts.map +1 -0
- package/dist/hooks/useFigmaToken.d.ts +1 -0
- package/dist/hooks/useFigmaToken.d.ts.map +1 -0
- package/dist/hooks/useMutation.d.ts +1 -52
- package/dist/hooks/useMutation.d.ts.map +1 -0
- package/dist/hooks/useUpdateVariable.d.ts +14 -25
- package/dist/hooks/useUpdateVariable.d.ts.map +1 -0
- package/dist/hooks/useVariableCollections.d.ts +1 -0
- package/dist/hooks/useVariableCollections.d.ts.map +1 -0
- package/dist/hooks/useVariableModes.d.ts +1 -0
- package/dist/hooks/useVariableModes.d.ts.map +1 -0
- package/dist/hooks/useVariables.d.ts +9 -25
- package/dist/hooks/useVariables.d.ts.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +81 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +115 -752
- package/dist/types/contexts.d.ts +11 -0
- package/dist/types/contexts.d.ts.map +1 -0
- package/dist/types/figma.d.ts +4 -3
- package/dist/types/figma.d.ts.map +1 -0
- package/dist/types/hooks.d.ts +1 -0
- package/dist/types/hooks.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/mutations.d.ts +4 -3
- package/dist/types/mutations.d.ts.map +1 -0
- package/dist/utils/filterVariables.d.ts +1 -0
- package/dist/utils/filterVariables.d.ts.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/package.json +43 -15
- package/dist/index.js +0 -17
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* Entry point for **@figma-vars/hooks** — a modern, idiomatic React hooks library for Figma Variables via the REST API.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Exposes all providers, hooks, utilities, and types needed to build robust Figma variable dashboards, plugins, and design system tools.
|
|
8
|
+
* Each export group below has its own summary and real-world usage example for rapid onboarding and type-safe integration.
|
|
9
|
+
*
|
|
10
|
+
* MIT Licensed. Author: Mark Learst.
|
|
11
|
+
* Docs: {@link https://github.com/marklearst/figma-vars-hooks}
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* React context provider for Figma API authentication and file scoping.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* Wrap your app in this provider to supply the Figma Personal Access Token and file key globally—all hooks and utilities will use this context.
|
|
18
|
+
* This ensures seamless, type-safe access to the Figma REST API for all child components.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* import { FigmaVarsProvider } from '@figma-vars/hooks';
|
|
23
|
+
*
|
|
24
|
+
* function App() {
|
|
25
|
+
* return (
|
|
26
|
+
* <FigmaVarsProvider token={process.env.FIGMA_TOKEN} fileKey="your-file-key">
|
|
27
|
+
* <YourComponent />
|
|
28
|
+
* </FigmaVarsProvider>
|
|
29
|
+
* );
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export { FigmaVarsProvider } from 'contexts';
|
|
34
|
+
/**
|
|
35
|
+
* Core React hooks for interacting with Figma Variables.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* Hooks for fetching, creating, updating, deleting, and bulk updating Figma variables—plus selectors for collections and modes.
|
|
39
|
+
* All hooks share idiomatic return shapes and error handling for rapid UI and API integration.
|
|
40
|
+
* Use these hooks to build dashboards, plugins, and design system tools with minimal boilerplate and maximum type safety.
|
|
41
|
+
*
|
|
42
|
+
* @see {@link https://www.figma.com/developers/api#variables | Figma Variables API}
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* import { useVariables, useCreateVariable } from '@figma-vars/hooks';
|
|
47
|
+
*
|
|
48
|
+
* function Example() {
|
|
49
|
+
* const { data, isLoading } = useVariables();
|
|
50
|
+
* const { mutate } = useCreateVariable();
|
|
51
|
+
* // Use the hooks in your component logic
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export { useVariables, useVariableCollections, useVariableModes, useCreateVariable, useUpdateVariable, useDeleteVariable, useBulkUpdateVariables, } from 'hooks';
|
|
56
|
+
/**
|
|
57
|
+
* Utility functions for Figma Variable management.
|
|
58
|
+
*
|
|
59
|
+
* @remarks
|
|
60
|
+
* Helpers like `filterVariables` for searching and filtering variable lists. All utilities are stateless and type-safe—use for UI filtering, scripting, and dashboard logic.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* import { filterVariables } from '@figma-vars/hooks';
|
|
65
|
+
* const filtered = filterVariables(variables, { resolvedType: 'COLOR' });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export { filterVariables } from 'utils';
|
|
69
|
+
/**
|
|
70
|
+
* All official TypeScript types for advanced usage and type-safe integration.
|
|
71
|
+
*
|
|
72
|
+
* @remarks
|
|
73
|
+
* All Figma domain models, mutation payloads/results, and provider context types—imported as needed for advanced TypeScript, API wrappers, plugins, and custom hooks.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* import type { FigmaVariable, CreateVariablePayload } from '@figma-vars/hooks';
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export * from 'types';
|
|
81
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.mts
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,OAAO,CAAC;AAEf;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAExC;;;;;;;;;;GAUG;AACH,cAAc,OAAO,CAAC"}
|