tokvista 1.0.0

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.
@@ -0,0 +1,261 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ /**
4
+ * Type definitions for Tokvista
5
+ */
6
+ interface TokenValue {
7
+ value: string | number;
8
+ type: string;
9
+ }
10
+ interface NestedTokens {
11
+ [key: string]: TokenValue | NestedTokens;
12
+ }
13
+ interface ParsedColorToken {
14
+ name: string;
15
+ value: string;
16
+ cssVariable: string;
17
+ shade?: string;
18
+ family?: string;
19
+ resolvedValue?: string;
20
+ }
21
+ interface ParsedSpacingToken {
22
+ name: string;
23
+ value: string;
24
+ cssVariable: string;
25
+ numericValue: number;
26
+ }
27
+ interface ParsedRadiusToken {
28
+ name: string;
29
+ value: string;
30
+ cssVariable: string;
31
+ numericValue: number;
32
+ }
33
+ interface ParsedSizeToken {
34
+ name: string;
35
+ value: string;
36
+ cssVariable: string;
37
+ numericValue: number;
38
+ }
39
+ interface ColorFamily {
40
+ name: string;
41
+ primaryColor: string;
42
+ shades: ParsedColorToken[];
43
+ }
44
+ interface FigmaTokens {
45
+ global?: Record<string, unknown>;
46
+ $themes?: unknown[];
47
+ $metadata?: {
48
+ tokenSetOrder?: string[];
49
+ };
50
+ [key: string]: any;
51
+ }
52
+ interface TokenDocumentationProps {
53
+ tokens: FigmaTokens;
54
+ title?: string;
55
+ subtitle?: string;
56
+ defaultTab?: string;
57
+ showSearch?: boolean;
58
+ darkMode?: boolean;
59
+ onTokenClick?: (token: ParsedColorToken | ParsedSpacingToken | ParsedRadiusToken | ParsedSizeToken) => void;
60
+ }
61
+ interface ColorDisplayProps {
62
+ baseColors?: NestedTokens;
63
+ fillColors?: NestedTokens;
64
+ strokeColors?: NestedTokens;
65
+ textColors?: NestedTokens;
66
+ tokenMap?: Record<string, string>;
67
+ onColorClick?: (color: ParsedColorToken) => void;
68
+ }
69
+ interface SpacingDisplayProps {
70
+ tokens: NestedTokens;
71
+ onTokenClick?: (token: ParsedSpacingToken) => void;
72
+ }
73
+ interface RadiusDisplayProps {
74
+ tokens: NestedTokens;
75
+ onTokenClick?: (token: ParsedRadiusToken) => void;
76
+ }
77
+ interface SizeDisplayProps {
78
+ tokens: NestedTokens;
79
+ onTokenClick?: (token: ParsedSizeToken) => void;
80
+ }
81
+ interface StandaloneTokenProps {
82
+ tokens: FigmaTokens;
83
+ onTokenClick?: (token: any) => void;
84
+ title?: string;
85
+ }
86
+
87
+ /**
88
+ * TokenDocumentation - Production-ready Design System Documentation
89
+ * Displays tokens in three main tabs: Foundation, Semantic, and Components
90
+ */
91
+ declare function TokenDocumentation({ tokens, title, subtitle, defaultTab, showSearch, darkMode: initialDarkMode, onTokenClick, }: TokenDocumentationProps): react_jsx_runtime.JSX.Element;
92
+
93
+ /**
94
+ * ColorDisplay - Beautiful visualization of color tokens
95
+ */
96
+ declare function ColorDisplay({ baseColors, fillColors, strokeColors, textColors, tokenMap: externalTokenMap, onColorClick, }: ColorDisplayProps): react_jsx_runtime.JSX.Element;
97
+
98
+ /**
99
+ * SpacingDisplay - Visual representation of spacing tokens
100
+ * Shows horizontal bars with proportional widths
101
+ */
102
+ declare function SpacingDisplay({ tokens, onTokenClick }: SpacingDisplayProps): react_jsx_runtime.JSX.Element;
103
+
104
+ /**
105
+ * RadiusDisplay - Visual demonstration of border radius tokens
106
+ * Shows boxes with actual border radius applied
107
+ */
108
+ declare function RadiusDisplay({ tokens, onTokenClick }: RadiusDisplayProps): react_jsx_runtime.JSX.Element;
109
+
110
+ /**
111
+ * SizeDisplay - Visual representation of size tokens
112
+ * Shows vertical bars with proportional heights and horizontal bars
113
+ */
114
+ declare function SizeDisplay({ tokens, onTokenClick }: SizeDisplayProps): react_jsx_runtime.JSX.Element;
115
+
116
+ interface FoundationTabProps {
117
+ tokens: NestedTokens;
118
+ tokenMap: Record<string, string>;
119
+ onTokenClick?: (token: any) => void;
120
+ }
121
+ /**
122
+ * FoundationTab - Displays all foundation tokens with scroll-spy navigation
123
+ */
124
+ declare function FoundationTab({ tokens, tokenMap, onTokenClick }: FoundationTabProps): react_jsx_runtime.JSX.Element;
125
+
126
+ interface SemanticTabProps {
127
+ tokens: NestedTokens;
128
+ tokenMap: Record<string, string>;
129
+ onTokenClick?: (token: any) => void;
130
+ }
131
+ /**
132
+ * SemanticTab - Displays semantic color tokens with scroll-spy navigation
133
+ */
134
+ declare function SemanticTab({ tokens, tokenMap, onTokenClick }: SemanticTabProps): react_jsx_runtime.JSX.Element;
135
+
136
+ interface ComponentsTabProps {
137
+ components: Record<string, ComponentData>;
138
+ tokenMap: Record<string, string>;
139
+ onCopy: (value: string, label: string) => void;
140
+ }
141
+ interface ComponentData {
142
+ variants: Record<string, any>;
143
+ dimensions: Record<string, any>;
144
+ }
145
+ /**
146
+ * ComponentsTab - Displays component tokens with sidebar navigation
147
+ */
148
+ declare function ComponentsTab({ components, tokenMap, onCopy }: ComponentsTabProps): react_jsx_runtime.JSX.Element;
149
+
150
+ interface SearchModalProps {
151
+ isOpen: boolean;
152
+ onClose: () => void;
153
+ tokens: FigmaTokens;
154
+ onTokenClick?: (token: any) => void;
155
+ onNavigateToTab?: (tab: 'foundation' | 'semantic' | 'components') => void;
156
+ onScrollToToken?: (tokenName: string, category: string, cssVariable?: string) => void;
157
+ }
158
+ declare function SearchModal({ isOpen, onClose, tokens, onTokenClick, onNavigateToTab, onScrollToToken }: SearchModalProps): react_jsx_runtime.JSX.Element | null;
159
+
160
+ interface ExportModalProps {
161
+ isOpen: boolean;
162
+ onClose: () => void;
163
+ tokens: FigmaTokens;
164
+ }
165
+ declare function ExportModal({ isOpen, onClose, tokens }: ExportModalProps): react_jsx_runtime.JSX.Element | null;
166
+
167
+ /**
168
+ * Spacing - Standalone component to display spacing tokens
169
+ */
170
+ declare function Spacing({ tokens, onTokenClick, title }: StandaloneTokenProps): react_jsx_runtime.JSX.Element;
171
+ /**
172
+ * Colors - Standalone component to display color tokens
173
+ */
174
+ declare function Colors({ tokens, onTokenClick, title }: StandaloneTokenProps): react_jsx_runtime.JSX.Element;
175
+ /**
176
+ * Sizes - Standalone component to display sizing tokens
177
+ */
178
+ declare function Sizes({ tokens, onTokenClick, title }: StandaloneTokenProps): react_jsx_runtime.JSX.Element;
179
+ /**
180
+ * Radius - Standalone component to display border radius tokens
181
+ */
182
+ declare function Radius({ tokens, onTokenClick, title }: StandaloneTokenProps): react_jsx_runtime.JSX.Element;
183
+
184
+ /**
185
+ * Create a map of token paths to values for resolution
186
+ */
187
+ declare function createTokenMap(tokens: any): Record<string, string>;
188
+ /**
189
+ * Resolve a token value (handles aliases)
190
+ */
191
+ declare function resolveTokenValue(value: string, tokenMap: Record<string, string>, maxDepth?: number): string;
192
+ /**
193
+ * Extract all token groups from a nested object
194
+ * Returns a map of group names to their token contents
195
+ */
196
+ declare function extractTokenGroups(setData: any): Record<string, NestedTokens>;
197
+ /**
198
+ * Detect the primary type of tokens in a group
199
+ */
200
+ declare function detectTokenType(tokens: NestedTokens): 'color' | 'spacing' | 'sizing' | 'radius' | 'typography' | 'other';
201
+
202
+ /**
203
+ * Get text color (black or white) based on background luminance
204
+ */
205
+ declare function getContrastColor(hexColor: string): 'black' | 'white';
206
+ /**
207
+ * Parse base color tokens into color families
208
+ */
209
+ declare function parseBaseColors(tokens: NestedTokens, tokenMap?: Record<string, string>): ColorFamily[];
210
+ /**
211
+ * Parse semantic color tokens (fill, stroke, text)
212
+ */
213
+ declare function parseSemanticColors(tokens: NestedTokens, prefix: string, tokenMap?: Record<string, string>): ParsedColorToken[];
214
+
215
+ /**
216
+ * Parse spacing tokens
217
+ */
218
+ declare function parseSpacingTokens(tokens: NestedTokens): ParsedSpacingToken[];
219
+ /**
220
+ * Parse radius tokens
221
+ */
222
+ declare function parseRadiusTokens(tokens: NestedTokens): ParsedRadiusToken[];
223
+ /**
224
+ * Parse size tokens
225
+ */
226
+ declare function parseSizeTokens(tokens: NestedTokens): ParsedSizeToken[];
227
+
228
+ /**
229
+ * Copy text to clipboard with fallback for older browsers
230
+ */
231
+ declare function copyToClipboard(text: string): Promise<boolean>;
232
+
233
+ interface ExportableToken {
234
+ name: string;
235
+ value: string;
236
+ cssVariable: string;
237
+ type: string;
238
+ category: string;
239
+ }
240
+ /**
241
+ * Flatten all tokens into a single list for easier generation
242
+ */
243
+ declare function getFlattenedTokens(tokens: FigmaTokens): ExportableToken[];
244
+ /**
245
+ * Generate CSS Variables
246
+ */
247
+ declare function generateCSS(tokens: FigmaTokens): string;
248
+ /**
249
+ * Generate SCSS Variables
250
+ */
251
+ declare function generateSCSS(tokens: FigmaTokens): string;
252
+ /**
253
+ * Generate JS Object
254
+ */
255
+ declare function generateJS(tokens: FigmaTokens): string;
256
+ /**
257
+ * Generate Tailwind Config
258
+ */
259
+ declare function generateTailwind(tokens: FigmaTokens): string;
260
+
261
+ export { ColorDisplay, type ColorDisplayProps, type ColorFamily, ColorDisplay as ColorGrid, type ColorDisplayProps as ColorGridProps, Colors, ComponentsTab, ExportModal, type FigmaTokens, FoundationTab, type NestedTokens, type ParsedColorToken, type ParsedRadiusToken, type ParsedSizeToken, type ParsedSpacingToken, Radius, RadiusDisplay, type RadiusDisplayProps, RadiusDisplay as RadiusShowcase, type RadiusDisplayProps as RadiusShowcaseProps, SearchModal, SemanticTab, SizeDisplay, type SizeDisplayProps, SizeDisplay as SizeScale, type SizeDisplayProps as SizeScaleProps, Sizes, Spacing, SpacingDisplay, type SpacingDisplayProps, SpacingDisplay as SpacingScale, type SpacingDisplayProps as SpacingScaleProps, TokenDocumentation, TokenDocumentation as TokenDocumentationDefault, type TokenDocumentationProps, type TokenValue, copyToClipboard, createTokenMap, detectTokenType, extractTokenGroups, generateCSS, generateJS, generateSCSS, generateTailwind, getContrastColor, getFlattenedTokens, parseBaseColors, parseRadiusTokens, parseSemanticColors, parseSizeTokens, parseSpacingTokens, resolveTokenValue };
@@ -0,0 +1,261 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ /**
4
+ * Type definitions for Tokvista
5
+ */
6
+ interface TokenValue {
7
+ value: string | number;
8
+ type: string;
9
+ }
10
+ interface NestedTokens {
11
+ [key: string]: TokenValue | NestedTokens;
12
+ }
13
+ interface ParsedColorToken {
14
+ name: string;
15
+ value: string;
16
+ cssVariable: string;
17
+ shade?: string;
18
+ family?: string;
19
+ resolvedValue?: string;
20
+ }
21
+ interface ParsedSpacingToken {
22
+ name: string;
23
+ value: string;
24
+ cssVariable: string;
25
+ numericValue: number;
26
+ }
27
+ interface ParsedRadiusToken {
28
+ name: string;
29
+ value: string;
30
+ cssVariable: string;
31
+ numericValue: number;
32
+ }
33
+ interface ParsedSizeToken {
34
+ name: string;
35
+ value: string;
36
+ cssVariable: string;
37
+ numericValue: number;
38
+ }
39
+ interface ColorFamily {
40
+ name: string;
41
+ primaryColor: string;
42
+ shades: ParsedColorToken[];
43
+ }
44
+ interface FigmaTokens {
45
+ global?: Record<string, unknown>;
46
+ $themes?: unknown[];
47
+ $metadata?: {
48
+ tokenSetOrder?: string[];
49
+ };
50
+ [key: string]: any;
51
+ }
52
+ interface TokenDocumentationProps {
53
+ tokens: FigmaTokens;
54
+ title?: string;
55
+ subtitle?: string;
56
+ defaultTab?: string;
57
+ showSearch?: boolean;
58
+ darkMode?: boolean;
59
+ onTokenClick?: (token: ParsedColorToken | ParsedSpacingToken | ParsedRadiusToken | ParsedSizeToken) => void;
60
+ }
61
+ interface ColorDisplayProps {
62
+ baseColors?: NestedTokens;
63
+ fillColors?: NestedTokens;
64
+ strokeColors?: NestedTokens;
65
+ textColors?: NestedTokens;
66
+ tokenMap?: Record<string, string>;
67
+ onColorClick?: (color: ParsedColorToken) => void;
68
+ }
69
+ interface SpacingDisplayProps {
70
+ tokens: NestedTokens;
71
+ onTokenClick?: (token: ParsedSpacingToken) => void;
72
+ }
73
+ interface RadiusDisplayProps {
74
+ tokens: NestedTokens;
75
+ onTokenClick?: (token: ParsedRadiusToken) => void;
76
+ }
77
+ interface SizeDisplayProps {
78
+ tokens: NestedTokens;
79
+ onTokenClick?: (token: ParsedSizeToken) => void;
80
+ }
81
+ interface StandaloneTokenProps {
82
+ tokens: FigmaTokens;
83
+ onTokenClick?: (token: any) => void;
84
+ title?: string;
85
+ }
86
+
87
+ /**
88
+ * TokenDocumentation - Production-ready Design System Documentation
89
+ * Displays tokens in three main tabs: Foundation, Semantic, and Components
90
+ */
91
+ declare function TokenDocumentation({ tokens, title, subtitle, defaultTab, showSearch, darkMode: initialDarkMode, onTokenClick, }: TokenDocumentationProps): react_jsx_runtime.JSX.Element;
92
+
93
+ /**
94
+ * ColorDisplay - Beautiful visualization of color tokens
95
+ */
96
+ declare function ColorDisplay({ baseColors, fillColors, strokeColors, textColors, tokenMap: externalTokenMap, onColorClick, }: ColorDisplayProps): react_jsx_runtime.JSX.Element;
97
+
98
+ /**
99
+ * SpacingDisplay - Visual representation of spacing tokens
100
+ * Shows horizontal bars with proportional widths
101
+ */
102
+ declare function SpacingDisplay({ tokens, onTokenClick }: SpacingDisplayProps): react_jsx_runtime.JSX.Element;
103
+
104
+ /**
105
+ * RadiusDisplay - Visual demonstration of border radius tokens
106
+ * Shows boxes with actual border radius applied
107
+ */
108
+ declare function RadiusDisplay({ tokens, onTokenClick }: RadiusDisplayProps): react_jsx_runtime.JSX.Element;
109
+
110
+ /**
111
+ * SizeDisplay - Visual representation of size tokens
112
+ * Shows vertical bars with proportional heights and horizontal bars
113
+ */
114
+ declare function SizeDisplay({ tokens, onTokenClick }: SizeDisplayProps): react_jsx_runtime.JSX.Element;
115
+
116
+ interface FoundationTabProps {
117
+ tokens: NestedTokens;
118
+ tokenMap: Record<string, string>;
119
+ onTokenClick?: (token: any) => void;
120
+ }
121
+ /**
122
+ * FoundationTab - Displays all foundation tokens with scroll-spy navigation
123
+ */
124
+ declare function FoundationTab({ tokens, tokenMap, onTokenClick }: FoundationTabProps): react_jsx_runtime.JSX.Element;
125
+
126
+ interface SemanticTabProps {
127
+ tokens: NestedTokens;
128
+ tokenMap: Record<string, string>;
129
+ onTokenClick?: (token: any) => void;
130
+ }
131
+ /**
132
+ * SemanticTab - Displays semantic color tokens with scroll-spy navigation
133
+ */
134
+ declare function SemanticTab({ tokens, tokenMap, onTokenClick }: SemanticTabProps): react_jsx_runtime.JSX.Element;
135
+
136
+ interface ComponentsTabProps {
137
+ components: Record<string, ComponentData>;
138
+ tokenMap: Record<string, string>;
139
+ onCopy: (value: string, label: string) => void;
140
+ }
141
+ interface ComponentData {
142
+ variants: Record<string, any>;
143
+ dimensions: Record<string, any>;
144
+ }
145
+ /**
146
+ * ComponentsTab - Displays component tokens with sidebar navigation
147
+ */
148
+ declare function ComponentsTab({ components, tokenMap, onCopy }: ComponentsTabProps): react_jsx_runtime.JSX.Element;
149
+
150
+ interface SearchModalProps {
151
+ isOpen: boolean;
152
+ onClose: () => void;
153
+ tokens: FigmaTokens;
154
+ onTokenClick?: (token: any) => void;
155
+ onNavigateToTab?: (tab: 'foundation' | 'semantic' | 'components') => void;
156
+ onScrollToToken?: (tokenName: string, category: string, cssVariable?: string) => void;
157
+ }
158
+ declare function SearchModal({ isOpen, onClose, tokens, onTokenClick, onNavigateToTab, onScrollToToken }: SearchModalProps): react_jsx_runtime.JSX.Element | null;
159
+
160
+ interface ExportModalProps {
161
+ isOpen: boolean;
162
+ onClose: () => void;
163
+ tokens: FigmaTokens;
164
+ }
165
+ declare function ExportModal({ isOpen, onClose, tokens }: ExportModalProps): react_jsx_runtime.JSX.Element | null;
166
+
167
+ /**
168
+ * Spacing - Standalone component to display spacing tokens
169
+ */
170
+ declare function Spacing({ tokens, onTokenClick, title }: StandaloneTokenProps): react_jsx_runtime.JSX.Element;
171
+ /**
172
+ * Colors - Standalone component to display color tokens
173
+ */
174
+ declare function Colors({ tokens, onTokenClick, title }: StandaloneTokenProps): react_jsx_runtime.JSX.Element;
175
+ /**
176
+ * Sizes - Standalone component to display sizing tokens
177
+ */
178
+ declare function Sizes({ tokens, onTokenClick, title }: StandaloneTokenProps): react_jsx_runtime.JSX.Element;
179
+ /**
180
+ * Radius - Standalone component to display border radius tokens
181
+ */
182
+ declare function Radius({ tokens, onTokenClick, title }: StandaloneTokenProps): react_jsx_runtime.JSX.Element;
183
+
184
+ /**
185
+ * Create a map of token paths to values for resolution
186
+ */
187
+ declare function createTokenMap(tokens: any): Record<string, string>;
188
+ /**
189
+ * Resolve a token value (handles aliases)
190
+ */
191
+ declare function resolveTokenValue(value: string, tokenMap: Record<string, string>, maxDepth?: number): string;
192
+ /**
193
+ * Extract all token groups from a nested object
194
+ * Returns a map of group names to their token contents
195
+ */
196
+ declare function extractTokenGroups(setData: any): Record<string, NestedTokens>;
197
+ /**
198
+ * Detect the primary type of tokens in a group
199
+ */
200
+ declare function detectTokenType(tokens: NestedTokens): 'color' | 'spacing' | 'sizing' | 'radius' | 'typography' | 'other';
201
+
202
+ /**
203
+ * Get text color (black or white) based on background luminance
204
+ */
205
+ declare function getContrastColor(hexColor: string): 'black' | 'white';
206
+ /**
207
+ * Parse base color tokens into color families
208
+ */
209
+ declare function parseBaseColors(tokens: NestedTokens, tokenMap?: Record<string, string>): ColorFamily[];
210
+ /**
211
+ * Parse semantic color tokens (fill, stroke, text)
212
+ */
213
+ declare function parseSemanticColors(tokens: NestedTokens, prefix: string, tokenMap?: Record<string, string>): ParsedColorToken[];
214
+
215
+ /**
216
+ * Parse spacing tokens
217
+ */
218
+ declare function parseSpacingTokens(tokens: NestedTokens): ParsedSpacingToken[];
219
+ /**
220
+ * Parse radius tokens
221
+ */
222
+ declare function parseRadiusTokens(tokens: NestedTokens): ParsedRadiusToken[];
223
+ /**
224
+ * Parse size tokens
225
+ */
226
+ declare function parseSizeTokens(tokens: NestedTokens): ParsedSizeToken[];
227
+
228
+ /**
229
+ * Copy text to clipboard with fallback for older browsers
230
+ */
231
+ declare function copyToClipboard(text: string): Promise<boolean>;
232
+
233
+ interface ExportableToken {
234
+ name: string;
235
+ value: string;
236
+ cssVariable: string;
237
+ type: string;
238
+ category: string;
239
+ }
240
+ /**
241
+ * Flatten all tokens into a single list for easier generation
242
+ */
243
+ declare function getFlattenedTokens(tokens: FigmaTokens): ExportableToken[];
244
+ /**
245
+ * Generate CSS Variables
246
+ */
247
+ declare function generateCSS(tokens: FigmaTokens): string;
248
+ /**
249
+ * Generate SCSS Variables
250
+ */
251
+ declare function generateSCSS(tokens: FigmaTokens): string;
252
+ /**
253
+ * Generate JS Object
254
+ */
255
+ declare function generateJS(tokens: FigmaTokens): string;
256
+ /**
257
+ * Generate Tailwind Config
258
+ */
259
+ declare function generateTailwind(tokens: FigmaTokens): string;
260
+
261
+ export { ColorDisplay, type ColorDisplayProps, type ColorFamily, ColorDisplay as ColorGrid, type ColorDisplayProps as ColorGridProps, Colors, ComponentsTab, ExportModal, type FigmaTokens, FoundationTab, type NestedTokens, type ParsedColorToken, type ParsedRadiusToken, type ParsedSizeToken, type ParsedSpacingToken, Radius, RadiusDisplay, type RadiusDisplayProps, RadiusDisplay as RadiusShowcase, type RadiusDisplayProps as RadiusShowcaseProps, SearchModal, SemanticTab, SizeDisplay, type SizeDisplayProps, SizeDisplay as SizeScale, type SizeDisplayProps as SizeScaleProps, Sizes, Spacing, SpacingDisplay, type SpacingDisplayProps, SpacingDisplay as SpacingScale, type SpacingDisplayProps as SpacingScaleProps, TokenDocumentation, TokenDocumentation as TokenDocumentationDefault, type TokenDocumentationProps, type TokenValue, copyToClipboard, createTokenMap, detectTokenType, extractTokenGroups, generateCSS, generateJS, generateSCSS, generateTailwind, getContrastColor, getFlattenedTokens, parseBaseColors, parseRadiusTokens, parseSemanticColors, parseSizeTokens, parseSpacingTokens, resolveTokenValue };