@promptui-lib/figma-parser 0.1.10 → 0.1.12
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-parser.d.ts","sourceRoot":"","sources":["../../src/parser/node-parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,aAAa,
|
|
1
|
+
{"version":3,"file":"node-parser.d.ts","sourceRoot":"","sources":["../../src/parser/node-parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,aAAa,EAMb,cAAc,EACd,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAiB5B,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAwB7D;AAkND;;GAEG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,UAAU,EAChB,OAAO,GAAE,aAAkB,GAC1B,aAAa,CA6Cf;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,UAAU,EAAE,EACnB,OAAO,GAAE,aAAkB,GAC1B,aAAa,EAAE,CAEjB"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Node Parser
|
|
3
3
|
* Parser principal que converte node do Figma em AST do componente
|
|
4
4
|
*/
|
|
5
|
-
import { generateComponentName, generateFileName, generateBEMBlock, generateBEMElement, classifyComponent, extractBaseName, extractVariants, } from '@promptui-lib/core';
|
|
5
|
+
import { generateComponentName, generateFileName, generateBEMBlock, generateBEMElement, classifyComponent, extractBaseName, extractVariants, isComponentNode, } from '@promptui-lib/core';
|
|
6
6
|
import { parseLayoutAndSizing, parseSizing } from './layout-parser.js';
|
|
7
7
|
import { parseStyles } from './style-parser.js';
|
|
8
8
|
import { parseTextStyles } from './text-parser.js';
|
|
@@ -34,6 +34,7 @@ export function parseFrameName(name) {
|
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Converte um node em elemento JSX
|
|
37
|
+
* Se o filho for um componente (marcado com #), retorna IJSXComponent em vez de JSX inline
|
|
37
38
|
*/
|
|
38
39
|
function nodeToJSX(node, blockName, depth = 0, parentNode) {
|
|
39
40
|
const isRoot = depth === 0;
|
|
@@ -58,7 +59,21 @@ function nodeToJSX(node, blockName, depth = 0, parentNode) {
|
|
|
58
59
|
if (child.visible === false || child.name.startsWith('_')) {
|
|
59
60
|
continue;
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
+
// Se o filho é um componente (marcado com #), cria referência ao componente
|
|
63
|
+
if (isComponentNode(child.name)) {
|
|
64
|
+
const childComponentName = generateComponentName(child.name);
|
|
65
|
+
const childFileName = generateFileName(childComponentName);
|
|
66
|
+
const childLayer = classifyComponent(child);
|
|
67
|
+
children.push({
|
|
68
|
+
type: 'component',
|
|
69
|
+
componentName: childComponentName,
|
|
70
|
+
layer: childLayer,
|
|
71
|
+
fileName: childFileName,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
children.push(nodeToJSX(child, blockName, depth + 1, node));
|
|
76
|
+
}
|
|
62
77
|
}
|
|
63
78
|
}
|
|
64
79
|
// Tags self-closing
|
|
@@ -137,11 +152,16 @@ function collectStyles(node, blockName, depth = 0, parentNode) {
|
|
|
137
152
|
});
|
|
138
153
|
}
|
|
139
154
|
// Processa filhos (passa o node atual como pai)
|
|
155
|
+
// Ignora filhos marcados com # pois são componentes com seus próprios estilos
|
|
140
156
|
if (node.children) {
|
|
141
157
|
for (const child of node.children) {
|
|
142
158
|
if (child.visible === false || child.name.startsWith('_')) {
|
|
143
159
|
continue;
|
|
144
160
|
}
|
|
161
|
+
// Ignora componentes filhos - eles têm seus próprios estilos
|
|
162
|
+
if (isComponentNode(child.name)) {
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
145
165
|
blocks.push(...collectStyles(child, blockName, depth + 1, node));
|
|
146
166
|
}
|
|
147
167
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptui-lib/figma-parser",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Figma API client and parser for PromptUI",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@promptui-lib/core": "0.1.
|
|
33
|
+
"@promptui-lib/core": "0.1.12"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^20.0.0",
|