@promptui-lib/figma-parser 0.1.12 → 0.1.13

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":"semantic-detector.d.ts","sourceRoot":"","sources":["../../src/parser/semantic-detector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAmQrD;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAalD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,UAAU,EAChB,UAAU,CAAC,EAAE,UAAU,EACvB,KAAK,GAAE,MAAU,GAChB,MAAM,CAmKR;AA4JD;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,MAAM,GACrB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAwKxB"}
1
+ {"version":3,"file":"semantic-detector.d.ts","sourceRoot":"","sources":["../../src/parser/semantic-detector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAmQrD;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAalD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,UAAU,EAChB,UAAU,CAAC,EAAE,UAAU,EACvB,KAAK,GAAE,MAAU,GAChB,MAAM,CAqKR;AA+ID;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,MAAM,GACrB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAgLxB"}
@@ -288,7 +288,9 @@ export function detectSemanticTag(node, parentNode, depth = 0) {
288
288
  return 'input'; // type será radio
289
289
  }
290
290
  if (SEMANTIC_PATTERNS.input.test(normalizedName)) {
291
- return hasInputChild(node) ? 'div' : 'input';
291
+ // Se é um campo de input/field, gera input
292
+ // O tipo será determinado pelo nome em getSemanticAttributes
293
+ return 'input';
292
294
  }
293
295
  // Navegação
294
296
  if (SEMANTIC_PATTERNS.nav.test(normalizedName)) {
@@ -495,18 +497,6 @@ function getHeadingLevel(fontSize) {
495
497
  return 'h5';
496
498
  return 'h6';
497
499
  }
498
- /**
499
- * Verifica se um node contém um input como filho
500
- */
501
- function hasInputChild(node) {
502
- if (!node.children)
503
- return false;
504
- return node.children.some(child => {
505
- const childName = normalizeName(child.name);
506
- return SEMANTIC_PATTERNS.input.test(childName) ||
507
- child.name.toLowerCase().includes('input');
508
- });
509
- }
510
500
  /**
511
501
  * Gera atributos adicionais baseado no contexto
512
502
  * Segue boas práticas de SEO e acessibilidade
@@ -524,24 +514,21 @@ export function getSemanticAttributes(node, tag, normalizedName) {
524
514
  .toLowerCase();
525
515
  attrs['href'] = hrefSlug ? `/${hrefSlug}` : '/';
526
516
  }
527
- // Inputs
517
+ // Inputs - detecta tipo baseado no nome, usa nome como placeholder genérico
528
518
  if (tag === 'input') {
529
- // Detecta tipo de input
519
+ // Detecta tipo de input baseado em palavras-chave no nome
520
+ // Apenas tipos que têm comportamento especial do browser
530
521
  if (normalizedName.includes('email')) {
531
522
  attrs['type'] = 'email';
532
- attrs['placeholder'] = 'email@example.com';
533
523
  }
534
524
  else if (normalizedName.includes('password') || normalizedName.includes('senha')) {
535
525
  attrs['type'] = 'password';
536
- attrs['placeholder'] = '********';
537
526
  }
538
- else if (normalizedName.includes('search') || normalizedName.includes('busca')) {
527
+ else if (normalizedName.includes('search') || normalizedName.includes('busca') || normalizedName.includes('pesquisa')) {
539
528
  attrs['type'] = 'search';
540
- attrs['placeholder'] = 'Search...';
541
529
  }
542
- else if (normalizedName.includes('phone') || normalizedName.includes('telefone') || normalizedName.includes('tel')) {
530
+ else if (normalizedName.includes('phone') || normalizedName.includes('telefone') || normalizedName.includes('tel-')) {
543
531
  attrs['type'] = 'tel';
544
- attrs['placeholder'] = '+1 (555) 000-0000';
545
532
  }
546
533
  else if (normalizedName.includes('number') || normalizedName.includes('numero') || normalizedName.includes('quantidade')) {
547
534
  attrs['type'] = 'number';
@@ -563,11 +550,20 @@ export function getSemanticAttributes(node, tag, normalizedName) {
563
550
  }
564
551
  else if (normalizedName.includes('url') || normalizedName.includes('website') || normalizedName.includes('site')) {
565
552
  attrs['type'] = 'url';
566
- attrs['placeholder'] = 'https://';
567
553
  }
568
554
  else {
569
555
  attrs['type'] = 'text';
570
556
  }
557
+ // Gera placeholder genérico baseado no nome do campo (mais legível)
558
+ // Remove prefixos comuns como "field-", "input-", etc.
559
+ const fieldName = normalizedName
560
+ .replace(/^(field|input|campo|entrada)[-_]?/i, '')
561
+ .replace(/-/g, ' ')
562
+ .trim();
563
+ if (fieldName && attrs['type'] !== 'checkbox' && attrs['type'] !== 'radio' && attrs['type'] !== 'file') {
564
+ // Capitaliza primeira letra
565
+ attrs['placeholder'] = fieldName.charAt(0).toUpperCase() + fieldName.slice(1);
566
+ }
571
567
  }
572
568
  // Textarea
573
569
  if (tag === 'textarea') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptui-lib/figma-parser",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
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.12"
33
+ "@promptui-lib/core": "0.1.13"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/node": "^20.0.0",