@promptui-lib/core 0.1.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.
Files changed (40) hide show
  1. package/dist/index.d.ts +8 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +10 -0
  4. package/dist/tokens/borders.d.ts +31 -0
  5. package/dist/tokens/borders.d.ts.map +1 -0
  6. package/dist/tokens/borders.js +83 -0
  7. package/dist/tokens/colors.d.ts +23 -0
  8. package/dist/tokens/colors.d.ts.map +1 -0
  9. package/dist/tokens/colors.js +73 -0
  10. package/dist/tokens/index.d.ts +5 -0
  11. package/dist/tokens/index.d.ts.map +1 -0
  12. package/dist/tokens/index.js +4 -0
  13. package/dist/tokens/spacing.d.ts +23 -0
  14. package/dist/tokens/spacing.d.ts.map +1 -0
  15. package/dist/tokens/spacing.js +72 -0
  16. package/dist/tokens/typography.d.ts +41 -0
  17. package/dist/tokens/typography.d.ts.map +1 -0
  18. package/dist/tokens/typography.js +91 -0
  19. package/dist/types/ast.types.d.ts +123 -0
  20. package/dist/types/ast.types.d.ts.map +1 -0
  21. package/dist/types/ast.types.js +5 -0
  22. package/dist/types/config.types.d.ts +115 -0
  23. package/dist/types/config.types.d.ts.map +1 -0
  24. package/dist/types/config.types.js +5 -0
  25. package/dist/types/figma.types.d.ts +157 -0
  26. package/dist/types/figma.types.d.ts.map +1 -0
  27. package/dist/types/figma.types.js +5 -0
  28. package/dist/types/index.d.ts +4 -0
  29. package/dist/types/index.d.ts.map +1 -0
  30. package/dist/types/index.js +3 -0
  31. package/dist/utils/classifiers.d.ts +34 -0
  32. package/dist/utils/classifiers.d.ts.map +1 -0
  33. package/dist/utils/classifiers.js +166 -0
  34. package/dist/utils/index.d.ts +3 -0
  35. package/dist/utils/index.d.ts.map +1 -0
  36. package/dist/utils/index.js +2 -0
  37. package/dist/utils/naming.d.ts +72 -0
  38. package/dist/utils/naming.d.ts.map +1 -0
  39. package/dist/utils/naming.js +126 -0
  40. package/package.json +54 -0
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @promptui-lib/core
3
+ * Core types, tokens and utilities for PromptUI
4
+ */
5
+ export * from './types/index.js';
6
+ export * from './tokens/index.js';
7
+ export * from './utils/index.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAc,kBAAkB,CAAC;AAGjC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,kBAAkB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @promptui-lib/core
3
+ * Core types, tokens and utilities for PromptUI
4
+ */
5
+ // Types
6
+ export * from './types/index.js';
7
+ // Tokens
8
+ export * from './tokens/index.js';
9
+ // Utils
10
+ export * from './utils/index.js';
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Border & Radius Tokens
3
+ * Mapeamento de bordas e radius para tokens SCSS
4
+ */
5
+ export interface IRadiusToken {
6
+ px: number;
7
+ token: string;
8
+ }
9
+ export interface IShadowToken {
10
+ blur: number;
11
+ token: string;
12
+ }
13
+ export declare const DEFAULT_RADIUS_TOKENS: IRadiusToken[];
14
+ export declare const DEFAULT_SHADOW_TOKENS: IShadowToken[];
15
+ /**
16
+ * Encontra token de border-radius
17
+ */
18
+ export declare function findRadiusToken(px: number, customTokens?: Record<number, string>): string;
19
+ /**
20
+ * Gera border-radius a partir de 4 valores
21
+ */
22
+ export declare function generateBorderRadius(topLeft: number, topRight: number, bottomRight: number, bottomLeft: number, customTokens?: Record<number, string>): string;
23
+ /**
24
+ * Encontra token de shadow baseado no blur
25
+ */
26
+ export declare function findShadowToken(blur: number, customTokens?: Record<string, string>): string | null;
27
+ /**
28
+ * Gera box-shadow a partir de effect do Figma
29
+ */
30
+ export declare function generateBoxShadow(offsetX: number, offsetY: number, blur: number, spread: number, color: string): string;
31
+ //# sourceMappingURL=borders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"borders.d.ts","sourceRoot":"","sources":["../../src/tokens/borders.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,qBAAqB,EAAE,YAAY,EAO/C,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,YAAY,EAK/C,CAAC;AAEF;;GAEG;AACH,wBAAgB,eAAe,CAC7B,EAAE,EAAE,MAAM,EACV,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,MAAM,CAYR;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,MAAM,CAiBR;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,MAAM,GAAG,IAAI,CAuBf;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,MAAM,CAQR"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Border & Radius Tokens
3
+ * Mapeamento de bordas e radius para tokens SCSS
4
+ */
5
+ export const DEFAULT_RADIUS_TOKENS = [
6
+ { px: 0, token: '$radius-none' },
7
+ { px: 4, token: '$radius-small' },
8
+ { px: 8, token: '$radius-medium' },
9
+ { px: 12, token: '$radius-large' },
10
+ { px: 16, token: '$radius-xl' },
11
+ { px: 9999, token: '$radius-full' },
12
+ ];
13
+ export const DEFAULT_SHADOW_TOKENS = [
14
+ { blur: 2, token: '$shadow-sm' },
15
+ { blur: 6, token: '$shadow-md' },
16
+ { blur: 15, token: '$shadow-lg' },
17
+ { blur: 16, token: '$shadow-modal' },
18
+ ];
19
+ /**
20
+ * Encontra token de border-radius
21
+ */
22
+ export function findRadiusToken(px, customTokens) {
23
+ if (customTokens?.[px]) {
24
+ return customTokens[px];
25
+ }
26
+ // Verifica se é full/pill
27
+ if (px >= 9999 || px >= 999) {
28
+ return '$radius-full';
29
+ }
30
+ const match = DEFAULT_RADIUS_TOKENS.find((t) => t.px === px);
31
+ return match?.token ?? `${px}px`;
32
+ }
33
+ /**
34
+ * Gera border-radius a partir de 4 valores
35
+ */
36
+ export function generateBorderRadius(topLeft, topRight, bottomRight, bottomLeft, customTokens) {
37
+ // Se todos iguais
38
+ if (topLeft === topRight &&
39
+ topRight === bottomRight &&
40
+ bottomRight === bottomLeft) {
41
+ return findRadiusToken(topLeft, customTokens);
42
+ }
43
+ // Se tem valores diferentes
44
+ const tl = findRadiusToken(topLeft, customTokens);
45
+ const tr = findRadiusToken(topRight, customTokens);
46
+ const br = findRadiusToken(bottomRight, customTokens);
47
+ const bl = findRadiusToken(bottomLeft, customTokens);
48
+ return `${tl} ${tr} ${br} ${bl}`;
49
+ }
50
+ /**
51
+ * Encontra token de shadow baseado no blur
52
+ */
53
+ export function findShadowToken(blur, customTokens) {
54
+ // Verifica tokens customizados primeiro
55
+ if (customTokens) {
56
+ for (const [key, token] of Object.entries(customTokens)) {
57
+ if (key.includes(`blur:${blur}`)) {
58
+ return token;
59
+ }
60
+ }
61
+ }
62
+ // Encontra o mais próximo
63
+ const match = DEFAULT_SHADOW_TOKENS.reduce((prev, curr) => {
64
+ return Math.abs(curr.blur - blur) < Math.abs(prev.blur - blur)
65
+ ? curr
66
+ : prev;
67
+ });
68
+ // Só retorna se for razoavelmente próximo
69
+ if (Math.abs(match.blur - blur) <= 3) {
70
+ return match.token;
71
+ }
72
+ return null;
73
+ }
74
+ /**
75
+ * Gera box-shadow a partir de effect do Figma
76
+ */
77
+ export function generateBoxShadow(offsetX, offsetY, blur, spread, color) {
78
+ const shadowToken = findShadowToken(blur);
79
+ if (shadowToken) {
80
+ return shadowToken;
81
+ }
82
+ return `${offsetX}px ${offsetY}px ${blur}px ${spread}px ${color}`;
83
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Color Tokens
3
+ * Mapeamento de cores hex para tokens SCSS
4
+ */
5
+ export interface IColorToken {
6
+ hex: string;
7
+ token: string;
8
+ category: 'brand' | 'semantic' | 'text' | 'background' | 'border';
9
+ }
10
+ export declare const DEFAULT_COLOR_TOKENS: IColorToken[];
11
+ /**
12
+ * Converte cor RGBA do Figma para hex
13
+ */
14
+ export declare function rgbaToHex(r: number, g: number, b: number, a?: number): string;
15
+ /**
16
+ * Encontra o token mais próximo para uma cor
17
+ */
18
+ export declare function findColorToken(hex: string, customTokens?: Record<string, string>): string | null;
19
+ /**
20
+ * Gera mapa de cores para lookup rápido
21
+ */
22
+ export declare function createColorMap(customTokens?: Record<string, string>): Map<string, string>;
23
+ //# sourceMappingURL=colors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/tokens/colors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,GAAG,UAAU,GAAG,MAAM,GAAG,YAAY,GAAG,QAAQ,CAAC;CACnE;AAED,eAAO,MAAM,oBAAoB,EAAE,WAAW,EA0B7C,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAa7E;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,MAAM,GAAG,IAAI,CAef;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAgBrB"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Color Tokens
3
+ * Mapeamento de cores hex para tokens SCSS
4
+ */
5
+ export const DEFAULT_COLOR_TOKENS = [
6
+ // Brand
7
+ { hex: '#0098f9', token: '$color-primary', category: 'brand' },
8
+ { hex: '#5f6368', token: '$color-secondary', category: 'brand' },
9
+ // Semantic
10
+ { hex: '#34a853', token: '$color-success', category: 'semantic' },
11
+ { hex: '#ea4335', token: '$color-error', category: 'semantic' },
12
+ { hex: '#fbbc04', token: '$color-warning', category: 'semantic' },
13
+ // Text
14
+ { hex: '#000000', token: '$color-text-primary', category: 'text' },
15
+ { hex: '#4f4f4f', token: '$color-text-secondary', category: 'text' },
16
+ { hex: '#9c9c9c', token: '$color-text-tertiary', category: 'text' },
17
+ { hex: '#9aa0a6', token: '$color-text-disabled', category: 'text' },
18
+ { hex: '#ffffff', token: '$color-text-inverse', category: 'text' },
19
+ // Background
20
+ { hex: '#ffffff', token: '$color-bg-primary', category: 'background' },
21
+ { hex: '#f8f9fa', token: '$color-bg-secondary', category: 'background' },
22
+ { hex: '#e8eaed', token: '$color-bg-tertiary', category: 'background' },
23
+ // Border
24
+ { hex: '#dadce0', token: '$color-border', category: 'border' },
25
+ { hex: '#d8d8d8', token: '$color-border-primary', category: 'border' },
26
+ { hex: '#e8eaed', token: '$color-divider', category: 'border' },
27
+ ];
28
+ /**
29
+ * Converte cor RGBA do Figma para hex
30
+ */
31
+ export function rgbaToHex(r, g, b, a) {
32
+ const toHex = (n) => {
33
+ const hex = Math.round(n * 255).toString(16);
34
+ return hex.length === 1 ? '0' + hex : hex;
35
+ };
36
+ const hex = `#${toHex(r)}${toHex(g)}${toHex(b)}`;
37
+ if (a !== undefined && a < 1) {
38
+ return `${hex}${toHex(a)}`;
39
+ }
40
+ return hex;
41
+ }
42
+ /**
43
+ * Encontra o token mais próximo para uma cor
44
+ */
45
+ export function findColorToken(hex, customTokens) {
46
+ const normalizedHex = hex.toLowerCase();
47
+ // Primeiro verifica tokens customizados
48
+ if (customTokens) {
49
+ const customToken = customTokens[normalizedHex];
50
+ if (customToken)
51
+ return customToken;
52
+ }
53
+ // Depois verifica tokens padrão
54
+ const defaultToken = DEFAULT_COLOR_TOKENS.find((t) => t.hex.toLowerCase() === normalizedHex);
55
+ return defaultToken?.token ?? null;
56
+ }
57
+ /**
58
+ * Gera mapa de cores para lookup rápido
59
+ */
60
+ export function createColorMap(customTokens) {
61
+ const map = new Map();
62
+ // Adiciona tokens padrão
63
+ for (const token of DEFAULT_COLOR_TOKENS) {
64
+ map.set(token.hex.toLowerCase(), token.token);
65
+ }
66
+ // Sobrescreve com tokens customizados
67
+ if (customTokens) {
68
+ for (const [hex, token] of Object.entries(customTokens)) {
69
+ map.set(hex.toLowerCase(), token);
70
+ }
71
+ }
72
+ return map;
73
+ }
@@ -0,0 +1,5 @@
1
+ export * from './colors.js';
2
+ export * from './spacing.js';
3
+ export * from './typography.js';
4
+ export * from './borders.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tokens/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './colors.js';
2
+ export * from './spacing.js';
3
+ export * from './typography.js';
4
+ export * from './borders.js';
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Spacing Tokens
3
+ * Mapeamento de valores de espaçamento para tokens SCSS
4
+ */
5
+ export interface ISpacingToken {
6
+ px: number;
7
+ token: string;
8
+ }
9
+ export declare const DEFAULT_SPACING_TOKENS: ISpacingToken[];
10
+ export declare const DEFAULT_GAP_TOKENS: ISpacingToken[];
11
+ /**
12
+ * Encontra o token de spacing mais próximo
13
+ */
14
+ export declare function findSpacingToken(px: number, customTokens?: Record<number, string>): string;
15
+ /**
16
+ * Encontra o token de gap mais próximo
17
+ */
18
+ export declare function findGapToken(px: number, customTokens?: Record<number, string>): string;
19
+ /**
20
+ * Gera string de padding a partir dos 4 valores
21
+ */
22
+ export declare function generatePaddingToken(top: number, right: number, bottom: number, left: number, customTokens?: Record<number, string>): string;
23
+ //# sourceMappingURL=spacing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spacing.d.ts","sourceRoot":"","sources":["../../src/tokens/spacing.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,sBAAsB,EAAE,aAAa,EASjD,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,aAAa,EAK7C,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,MAAM,EACV,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,MAAM,CAcR;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,EAAE,EAAE,MAAM,EACV,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,MAAM,CAcR;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,MAAM,CAoBR"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Spacing Tokens
3
+ * Mapeamento de valores de espaçamento para tokens SCSS
4
+ */
5
+ export const DEFAULT_SPACING_TOKENS = [
6
+ { px: 0, token: '0' },
7
+ { px: 4, token: '$spacing-xs' },
8
+ { px: 8, token: '$spacing-sm' },
9
+ { px: 12, token: '$spacing-md - 4px' },
10
+ { px: 16, token: '$spacing-md' },
11
+ { px: 24, token: '$spacing-lg' },
12
+ { px: 32, token: '$spacing-xl' },
13
+ { px: 48, token: '$spacing-2xl' },
14
+ ];
15
+ export const DEFAULT_GAP_TOKENS = [
16
+ { px: 4, token: '$gap-1' },
17
+ { px: 8, token: '$gap-2' },
18
+ { px: 12, token: '$gap-3' },
19
+ { px: 16, token: '$gap-4' },
20
+ ];
21
+ /**
22
+ * Encontra o token de spacing mais próximo
23
+ */
24
+ export function findSpacingToken(px, customTokens) {
25
+ // Token customizado exato
26
+ if (customTokens?.[px]) {
27
+ return customTokens[px];
28
+ }
29
+ // Token padrão exato
30
+ const exactMatch = DEFAULT_SPACING_TOKENS.find((t) => t.px === px);
31
+ if (exactMatch) {
32
+ return exactMatch.token;
33
+ }
34
+ // Se não encontrou exato, retorna o valor em px
35
+ return `${px}px`;
36
+ }
37
+ /**
38
+ * Encontra o token de gap mais próximo
39
+ */
40
+ export function findGapToken(px, customTokens) {
41
+ // Token customizado exato
42
+ if (customTokens?.[px]) {
43
+ return customTokens[px];
44
+ }
45
+ // Token padrão exato
46
+ const exactMatch = DEFAULT_GAP_TOKENS.find((t) => t.px === px);
47
+ if (exactMatch) {
48
+ return exactMatch.token;
49
+ }
50
+ // Fallback para spacing token
51
+ return findSpacingToken(px, customTokens);
52
+ }
53
+ /**
54
+ * Gera string de padding a partir dos 4 valores
55
+ */
56
+ export function generatePaddingToken(top, right, bottom, left, customTokens) {
57
+ const topToken = findSpacingToken(top, customTokens);
58
+ const rightToken = findSpacingToken(right, customTokens);
59
+ const bottomToken = findSpacingToken(bottom, customTokens);
60
+ const leftToken = findSpacingToken(left, customTokens);
61
+ // Otimiza o output
62
+ if (top === right && right === bottom && bottom === left) {
63
+ return topToken;
64
+ }
65
+ if (top === bottom && left === right) {
66
+ return `${topToken} ${rightToken}`;
67
+ }
68
+ if (left === right) {
69
+ return `${topToken} ${rightToken} ${bottomToken}`;
70
+ }
71
+ return `${topToken} ${rightToken} ${bottomToken} ${leftToken}`;
72
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Typography Tokens
3
+ * Mapeamento de tipografia para tokens SCSS
4
+ */
5
+ export interface IFontSizeToken {
6
+ px: number;
7
+ token: string;
8
+ }
9
+ export interface IFontWeightToken {
10
+ weight: number;
11
+ token: string;
12
+ }
13
+ export interface ILineHeightToken {
14
+ value: number;
15
+ token: string;
16
+ }
17
+ export declare const DEFAULT_FONT_SIZE_TOKENS: IFontSizeToken[];
18
+ export declare const DEFAULT_FONT_WEIGHT_TOKENS: IFontWeightToken[];
19
+ export declare const DEFAULT_LINE_HEIGHT_TOKENS: ILineHeightToken[];
20
+ export declare const DEFAULT_FONT_FAMILY_TOKENS: Record<string, string>;
21
+ /**
22
+ * Encontra token de font-size
23
+ */
24
+ export declare function findFontSizeToken(px: number, customTokens?: Record<number, string>): string;
25
+ /**
26
+ * Encontra token de font-weight
27
+ */
28
+ export declare function findFontWeightToken(weight: number, customTokens?: Record<number, string>): string;
29
+ /**
30
+ * Encontra token de line-height
31
+ */
32
+ export declare function findLineHeightToken(value: number): string;
33
+ /**
34
+ * Encontra token de font-family
35
+ */
36
+ export declare function findFontFamilyToken(fontFamily: string): string;
37
+ /**
38
+ * Gera propriedades de tipografia completas
39
+ */
40
+ export declare function generateTypographyProperties(fontSize: number, fontWeight: number, lineHeight?: number, fontFamily?: string): Record<string, string>;
41
+ //# sourceMappingURL=typography.d.ts.map
@@ -0,0 +1 @@
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
+ /**
2
+ * Typography Tokens
3
+ * Mapeamento de tipografia para tokens SCSS
4
+ */
5
+ export const DEFAULT_FONT_SIZE_TOKENS = [
6
+ { px: 12, token: '$font-size-xs' },
7
+ { px: 14, token: '$font-size-sm' },
8
+ { px: 16, token: '$font-size-md' },
9
+ { px: 18, token: '$font-size-lg' },
10
+ { px: 20, token: '$font-size-xl' },
11
+ { px: 24, token: '$font-size-2xl' },
12
+ { px: 28, token: '$font-size-h1' },
13
+ { px: 32, token: '$font-size-3xl' },
14
+ ];
15
+ export const DEFAULT_FONT_WEIGHT_TOKENS = [
16
+ { weight: 300, token: '$font-weight-light' },
17
+ { weight: 400, token: '$font-weight-regular' },
18
+ { weight: 500, token: '$font-weight-medium' },
19
+ { weight: 600, token: '$font-weight-semibold' },
20
+ { weight: 700, token: '$font-weight-bold' },
21
+ ];
22
+ export const DEFAULT_LINE_HEIGHT_TOKENS = [
23
+ { value: 1.25, token: '$line-height-tight' },
24
+ { value: 1.5, token: '$line-height-normal' },
25
+ { value: 1.75, token: '$line-height-relaxed' },
26
+ ];
27
+ export const DEFAULT_FONT_FAMILY_TOKENS = {
28
+ 'Inter': '$font-family-body',
29
+ 'Objective': '$font-family-heading',
30
+ 'Roboto': '$font-family-body',
31
+ 'SF Pro': '$font-family-body',
32
+ };
33
+ /**
34
+ * Encontra token de font-size
35
+ */
36
+ export function findFontSizeToken(px, customTokens) {
37
+ if (customTokens?.[px]) {
38
+ return customTokens[px];
39
+ }
40
+ const match = DEFAULT_FONT_SIZE_TOKENS.find((t) => t.px === px);
41
+ return match?.token ?? `${px}px`;
42
+ }
43
+ /**
44
+ * Encontra token de font-weight
45
+ */
46
+ export function findFontWeightToken(weight, customTokens) {
47
+ if (customTokens?.[weight]) {
48
+ return customTokens[weight];
49
+ }
50
+ const match = DEFAULT_FONT_WEIGHT_TOKENS.find((t) => t.weight === weight);
51
+ return match?.token ?? `${weight}`;
52
+ }
53
+ /**
54
+ * Encontra token de line-height
55
+ */
56
+ export function findLineHeightToken(value) {
57
+ // Se é valor em pixels, converte para ratio aproximado
58
+ if (value > 3) {
59
+ // Provavelmente é lineHeightPx, precisa do fontSize para calcular
60
+ return `${value}px`;
61
+ }
62
+ const match = DEFAULT_LINE_HEIGHT_TOKENS.find((t) => {
63
+ return Math.abs(t.value - value) < 0.1;
64
+ });
65
+ return match?.token ?? `${value}`;
66
+ }
67
+ /**
68
+ * Encontra token de font-family
69
+ */
70
+ export function findFontFamilyToken(fontFamily) {
71
+ // Normaliza o nome da fonte
72
+ const normalized = fontFamily.split(',')[0].trim().replace(/["']/g, '');
73
+ const token = DEFAULT_FONT_FAMILY_TOKENS[normalized];
74
+ return token ?? `"${fontFamily}"`;
75
+ }
76
+ /**
77
+ * Gera propriedades de tipografia completas
78
+ */
79
+ export function generateTypographyProperties(fontSize, fontWeight, lineHeight, fontFamily) {
80
+ const props = {
81
+ 'font-size': findFontSizeToken(fontSize),
82
+ 'font-weight': findFontWeightToken(fontWeight),
83
+ };
84
+ if (lineHeight) {
85
+ props['line-height'] = findLineHeightToken(lineHeight);
86
+ }
87
+ if (fontFamily) {
88
+ props['font-family'] = findFontFamilyToken(fontFamily);
89
+ }
90
+ return props;
91
+ }
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Component AST Types
3
+ * Representação intermediária do componente antes da geração de código
4
+ */
5
+ export type ComponentLayer = 'atoms' | 'molecules' | 'organisms';
6
+ export interface IComponentAST {
7
+ /** Nome do componente em PascalCase */
8
+ name: string;
9
+ /** Nome do arquivo em kebab-case */
10
+ fileName: string;
11
+ /** Camada do Atomic Design */
12
+ layer: ComponentLayer;
13
+ /** Definições de props */
14
+ props: IPropDefinition[];
15
+ /** Árvore JSX */
16
+ jsx: IJSXNode;
17
+ /** Blocos de estilo */
18
+ styles: IStyleBlock[];
19
+ /** Variantes do componente */
20
+ variants?: IVariant[];
21
+ /** Imports necessários */
22
+ imports?: IImportStatement[];
23
+ }
24
+ export interface IPropDefinition {
25
+ /** Nome da prop */
26
+ name: string;
27
+ /** Tipo TypeScript */
28
+ type: string;
29
+ /** Se é obrigatória */
30
+ required: boolean;
31
+ /** Valor padrão */
32
+ defaultValue?: string | boolean | number;
33
+ /** Descrição para JSDoc */
34
+ description?: string;
35
+ }
36
+ export interface IJSXNode {
37
+ /** Tag HTML ou componente */
38
+ tag: string;
39
+ /** Classe CSS (BEM) */
40
+ className?: string;
41
+ /** Props do elemento */
42
+ props: Record<string, string | boolean | IJSXExpression>;
43
+ /** Filhos: outros nodes ou texto */
44
+ children: Array<IJSXNode | IJSXText | IJSXExpression>;
45
+ /** Se é self-closing */
46
+ selfClosing?: boolean;
47
+ }
48
+ export interface IJSXText {
49
+ type: 'text';
50
+ value: string;
51
+ }
52
+ export interface IJSXExpression {
53
+ type: 'expression';
54
+ value: string;
55
+ }
56
+ export interface IStyleBlock {
57
+ /** Seletor BEM: .component, .component__element, .component--modifier */
58
+ selector: string;
59
+ /** Propriedades CSS */
60
+ properties: IStyleProperty[];
61
+ /** Blocos aninhados (pseudo-elementos, media queries) */
62
+ nested?: IStyleBlock[];
63
+ }
64
+ export interface IStyleProperty {
65
+ /** Propriedade CSS */
66
+ property: string;
67
+ /** Valor (pode ser token ou valor direto) */
68
+ value: string;
69
+ /** Nome do token SCSS se aplicável */
70
+ token?: string;
71
+ /** Comentário explicativo */
72
+ comment?: string;
73
+ }
74
+ export interface IVariant {
75
+ /** Nome da variante */
76
+ name: string;
77
+ /** Valores possíveis */
78
+ values: string[];
79
+ /** Prop associada */
80
+ propName: string;
81
+ /** Modificadores CSS para cada valor */
82
+ modifiers: Record<string, IStyleBlock>;
83
+ }
84
+ export interface IImportStatement {
85
+ /** Módulo/caminho */
86
+ from: string;
87
+ /** Imports nomeados */
88
+ named?: string[];
89
+ /** Import default */
90
+ default?: string;
91
+ /** Se é type-only import */
92
+ typeOnly?: boolean;
93
+ }
94
+ /**
95
+ * Resultado da geração de código
96
+ */
97
+ export interface IGeneratedCode {
98
+ /** Código TSX do componente */
99
+ tsx: string;
100
+ /** Código SCSS */
101
+ scss: string;
102
+ /** Código do index.ts */
103
+ index: string;
104
+ }
105
+ /**
106
+ * Metadados extraídos do nome do frame no Figma
107
+ */
108
+ export interface IParsedFrameName {
109
+ /** Nome base do componente */
110
+ baseName: string;
111
+ /** Variantes extraídas do nome (ex: Primary, Large) */
112
+ variants: string[];
113
+ /** Se tem prefixo # (componente exportável) */
114
+ isExportable: boolean;
115
+ /** Se tem prefixo _ (elemento interno) */
116
+ isInternal: boolean;
117
+ /** Props extraídas (ex: $prop:title) */
118
+ extractedProps: Array<{
119
+ name: string;
120
+ type: string;
121
+ }>;
122
+ }
123
+ //# sourceMappingURL=ast.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast.types.d.ts","sourceRoot":"","sources":["../../src/types/ast.types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,WAAW,GAAG,WAAW,CAAC;AAEjE,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IAEb,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;IAEjB,8BAA8B;IAC9B,KAAK,EAAE,cAAc,CAAC;IAEtB,0BAA0B;IAC1B,KAAK,EAAE,eAAe,EAAE,CAAC;IAEzB,iBAAiB;IACjB,GAAG,EAAE,QAAQ,CAAC;IAEd,uBAAuB;IACvB,MAAM,EAAE,WAAW,EAAE,CAAC;IAEtB,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;IAEtB,0BAA0B;IAC1B,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,eAAe;IAC9B,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IAEb,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IAEb,uBAAuB;IACvB,QAAQ,EAAE,OAAO,CAAC;IAElB,mBAAmB;IACnB,YAAY,CAAC,EA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