orbital-ds 0.41.0 → 0.44.1

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 (176) hide show
  1. package/AGENTS.md +28 -9
  2. package/components.manifest.json +6469 -3569
  3. package/dist/auth-form-B1hgbXkI.d.ts +144 -0
  4. package/dist/hooks/use-ds-messages.d.ts +7 -0
  5. package/dist/lib/format.d.ts +57 -0
  6. package/dist/lib/format.js +177 -0
  7. package/dist/lib/i18n.d.ts +14 -2
  8. package/dist/lib/i18n.js +32 -2
  9. package/dist/lib/locales/de.d.ts +7 -0
  10. package/dist/lib/locales/de.js +535 -0
  11. package/dist/lib/locales/fr.d.ts +7 -0
  12. package/dist/lib/locales/fr.js +535 -0
  13. package/dist/lib/locales/he.d.ts +7 -0
  14. package/dist/lib/locales/he.js +535 -0
  15. package/dist/lib/locales/it.d.ts +7 -0
  16. package/dist/lib/locales/it.js +535 -0
  17. package/dist/styles.css +39 -1
  18. package/dist/ui/a2ui-renderer.d.ts +11 -0
  19. package/dist/ui/agent-events.d.ts +17 -0
  20. package/dist/ui/ai-tag.d.ts +16 -0
  21. package/dist/ui/alert-dialog.d.ts +37 -0
  22. package/dist/ui/alert.d.ts +1 -1
  23. package/dist/ui/animated-number.d.ts +11 -0
  24. package/dist/ui/app-bar.d.ts +22 -0
  25. package/dist/ui/attachment.d.ts +3 -3
  26. package/dist/ui/auth-backdrop.d.ts +17 -0
  27. package/dist/ui/auth-form.d.ts +3 -112
  28. package/dist/ui/auth-form.js +13 -6
  29. package/dist/ui/auth-layout.d.ts +38 -0
  30. package/dist/ui/avatar.d.ts +27 -0
  31. package/dist/ui/ayuda.d.ts +1 -1
  32. package/dist/ui/ayuda.js +4 -1
  33. package/dist/ui/banner.d.ts +1 -1
  34. package/dist/ui/bottom-nav.d.ts +22 -0
  35. package/dist/ui/breadcrumb.d.ts +22 -0
  36. package/dist/ui/breadcrumb.js +1 -1
  37. package/dist/ui/bubble.d.ts +1 -1
  38. package/dist/ui/button-group.d.ts +1 -1
  39. package/dist/ui/button.d.ts +2 -2
  40. package/dist/ui/calendar.d.ts +13 -0
  41. package/dist/ui/calendar.js +3 -0
  42. package/dist/ui/card-stack.d.ts +27 -0
  43. package/dist/ui/card.d.ts +33 -0
  44. package/dist/ui/carousel.d.ts +35 -0
  45. package/dist/ui/carousel.js +10 -5
  46. package/dist/ui/chain-of-thought.d.ts +15 -0
  47. package/dist/ui/chart-card.d.ts +19 -0
  48. package/dist/ui/chart.d.ts +19 -0
  49. package/dist/ui/chat-composer.d.ts +19 -0
  50. package/dist/ui/choice-card.d.ts +33 -0
  51. package/dist/ui/code-block.d.ts +15 -0
  52. package/dist/ui/combobox.d.ts +48 -0
  53. package/dist/ui/command-palette.d.ts +18 -0
  54. package/dist/ui/command.d.ts +34 -0
  55. package/dist/ui/confirm-action.d.ts +30 -0
  56. package/dist/ui/confirm-dialog.d.ts +23 -0
  57. package/dist/ui/content-card.d.ts +14 -0
  58. package/dist/ui/context-menu.d.ts +35 -0
  59. package/dist/ui/context-menu.js +1 -1
  60. package/dist/ui/conversation-list.d.ts +20 -0
  61. package/dist/ui/copy-button.d.ts +11 -0
  62. package/dist/ui/date-time.d.ts +40 -0
  63. package/dist/ui/date-time.js +55 -0
  64. package/dist/ui/description-list.d.ts +49 -0
  65. package/dist/ui/description-list.js +86 -0
  66. package/dist/ui/detail-panel.d.ts +22 -0
  67. package/dist/ui/dialog.d.ts +35 -0
  68. package/dist/ui/dock.d.ts +17 -0
  69. package/dist/ui/drawer.d.ts +41 -0
  70. package/dist/ui/dropdown-menu.d.ts +32 -0
  71. package/dist/ui/dropdown-menu.js +1 -1
  72. package/dist/ui/echart.d.ts +15 -0
  73. package/dist/ui/entity-list.d.ts +32 -0
  74. package/dist/ui/field.d.ts +1 -1
  75. package/dist/ui/form-layout.d.ts +24 -0
  76. package/dist/ui/gauge.d.ts +26 -0
  77. package/dist/ui/generated-image.d.ts +19 -0
  78. package/dist/ui/generated-table.d.ts +18 -0
  79. package/dist/ui/heatmap-grid.d.ts +20 -0
  80. package/dist/ui/hero.d.ts +58 -0
  81. package/dist/ui/hero.js +145 -0
  82. package/dist/ui/i18n-provider.d.ts +16 -0
  83. package/dist/ui/input-group.d.ts +1 -1
  84. package/dist/ui/input-otp.d.ts +23 -0
  85. package/dist/ui/input.d.ts +16 -0
  86. package/dist/ui/instruction-editor.d.ts +17 -0
  87. package/dist/ui/item.d.ts +3 -3
  88. package/dist/ui/label.d.ts +17 -0
  89. package/dist/ui/legend.d.ts +25 -0
  90. package/dist/ui/level-meter.d.ts +12 -0
  91. package/dist/ui/load-more.d.ts +17 -0
  92. package/dist/ui/loading-state.d.ts +12 -0
  93. package/dist/ui/markdown.d.ts +15 -0
  94. package/dist/ui/marker.d.ts +1 -1
  95. package/dist/ui/media-card.d.ts +16 -0
  96. package/dist/ui/menubar.d.ts +39 -0
  97. package/dist/ui/message-actions.d.ts +9 -0
  98. package/dist/ui/message-scroller.d.ts +30 -0
  99. package/dist/ui/message.d.ts +33 -0
  100. package/dist/ui/mfa-challenge.d.ts +3 -32
  101. package/dist/ui/mfa-challenge.js +1 -1
  102. package/dist/ui/mfa-setup.d.ts +1 -1
  103. package/dist/ui/mosaic.d.ts +23 -0
  104. package/dist/ui/motion-provider.d.ts +17 -0
  105. package/dist/ui/native-select.d.ts +22 -0
  106. package/dist/ui/next-step-card.d.ts +55 -0
  107. package/dist/ui/next-step-card.js +92 -0
  108. package/dist/ui/notice-review.d.ts +32 -0
  109. package/dist/ui/oauth-consent.d.ts +1 -1
  110. package/dist/ui/page-header.d.ts +46 -4
  111. package/dist/ui/page-header.js +20 -11
  112. package/dist/ui/page-loader.d.ts +17 -0
  113. package/dist/ui/page-shell.d.ts +17 -0
  114. package/dist/ui/pagination.d.ts +20 -0
  115. package/dist/ui/pagination.js +2 -2
  116. package/dist/ui/panel.d.ts +2 -2
  117. package/dist/ui/password-strength.d.ts +14 -0
  118. package/dist/ui/popover.d.ts +32 -0
  119. package/dist/ui/proportion-bar.d.ts +25 -0
  120. package/dist/ui/quantity.d.ts +25 -0
  121. package/dist/ui/quantity.js +27 -0
  122. package/dist/ui/questionnaire.d.ts +38 -0
  123. package/dist/ui/reasoning.d.ts +14 -0
  124. package/dist/ui/reveal.d.ts +17 -0
  125. package/dist/ui/sheet.d.ts +39 -2
  126. package/dist/ui/sheet.js +6 -2
  127. package/dist/ui/shield.d.ts +14 -0
  128. package/dist/ui/show-more.d.ts +14 -0
  129. package/dist/ui/sidebar.d.ts +5 -3
  130. package/dist/ui/sidebar.js +7 -3
  131. package/dist/ui/sparkline.d.ts +1 -1
  132. package/dist/ui/stat-group.d.ts +32 -0
  133. package/dist/ui/status-badge.d.ts +2 -2
  134. package/dist/ui/status-hero.d.ts +18 -0
  135. package/dist/ui/step-dots.d.ts +12 -0
  136. package/dist/ui/step-ring.d.ts +14 -0
  137. package/dist/ui/suggestions.d.ts +9 -0
  138. package/dist/ui/table.d.ts +26 -0
  139. package/dist/ui/tabs.d.ts +1 -1
  140. package/dist/ui/tag-input.d.ts +21 -0
  141. package/dist/ui/tag-input.js +169 -0
  142. package/dist/ui/task-loader.d.ts +15 -0
  143. package/dist/ui/task-progress.d.ts +14 -0
  144. package/dist/ui/textarea.d.ts +22 -1
  145. package/dist/ui/textarea.js +7 -1
  146. package/dist/ui/timeline.d.ts +26 -0
  147. package/dist/ui/toggle-group.d.ts +24 -0
  148. package/dist/ui/toggle.d.ts +1 -1
  149. package/dist/ui/tool-call.d.ts +12 -0
  150. package/dist/ui/usage-meter.d.ts +42 -0
  151. package/dist/ui/usage-meter.js +116 -0
  152. package/dist/ui/week-strip.d.ts +11 -0
  153. package/dist/ui/week-strip.js +2 -2
  154. package/dist/ui/workflow-run.d.ts +28 -0
  155. package/docs/adr/0001-rtl-clases-logicas.md +14 -1
  156. package/docs/designer/flujo.md +1 -1
  157. package/docs/designer/patrones.md +40 -1
  158. package/manifest/actions.json +364 -0
  159. package/manifest/agents.json +399 -0
  160. package/manifest/ai.json +128 -0
  161. package/manifest/auth.json +1547 -0
  162. package/manifest/chat.json +612 -0
  163. package/manifest/content.json +2298 -0
  164. package/manifest/data.json +2904 -0
  165. package/manifest/feedback.json +1005 -0
  166. package/manifest/forms.json +1954 -0
  167. package/manifest/motion.json +196 -0
  168. package/manifest/navigation.json +1792 -0
  169. package/manifest/overlays.json +931 -0
  170. package/package.json +242 -238
  171. package/scripts/cli.mjs +105 -8
  172. package/scripts/doctor.mjs +126 -1
  173. package/scripts/eslint-plugin.mjs +93 -0
  174. package/scripts/i18n.mjs +1 -1
  175. package/scripts/manifest.mjs +159 -7
  176. package/skill/SKILL.md +8 -3
package/scripts/cli.mjs CHANGED
@@ -47,8 +47,9 @@ Uso: orbital-ds <orden> [opciones] (sin orden, un menú)
47
47
  doctor comprobar contrato, contraste, pesos y marca
48
48
  i18n textos de orbital-ds en los idiomas de la app
49
49
  context resumen de esta app para un agente: tema, marca, componentes y patrones
50
+ components catálogo por dominios: resumen, alternativas, props, notas y ejemplos (--search · --group · <nombre>)
50
51
  skill instala o refresca el diseñador de orbital-ds para Claude Code
51
- help esta ayuda · orbital-ds help <orden> para el detalle
52
+ help esta ayuda · orbital-ds help <orden> para el detalle
52
53
 
53
54
  Ejemplos
54
55
  orbital-ds menú
@@ -128,6 +129,18 @@ Lo lee el skill «orbital-ds-designer» antes de diseñar, y vale para cualquier
128
129
  orbital-ds context en texto (markdown)
129
130
  orbital-ds context --json en JSON`,
130
131
 
132
+ components: `orbital-ds components — el catálogo, por páginas de dominio
133
+
134
+ Cada componente pertenece a un dominio (actions, forms, feedback, overlays, navigation, data, content, motion, chat,
135
+ agents, ai, auth). Pide solo lo que necesitas: cada ficha trae resumen (cuándo usarlo), alternativas (cuándo usar
136
+ otro), props tipadas (* = obligatoria), presets, notas de uso y ejemplos mínimos para copiar.
137
+
138
+ orbital-ds components los dominios y sus componentes
139
+ orbital-ds components --group auth todo un dominio
140
+ orbital-ds components --search tabla buscar por intención (nombre, resumen, alternativas y notas)
141
+ orbital-ds components button un componente
142
+ --json en JSON (también en node_modules/orbital-ds/manifest/<dominio>.json)`,
143
+
131
144
  skill: `orbital-ds skill — diseñador de orbital-ds para Claude Code
132
145
 
133
146
  Instala (o refresca) el skill «orbital-ds-designer» en la raíz de la app: .claude/skills/orbital-ds-designer/.
@@ -210,7 +223,7 @@ function contexto(json) {
210
223
  marca: estado.marca?.activa ? estado.marca : null,
211
224
  brandCss: { fichero: existsSync(brand) ? relative(process.cwd(), brand).split(sep).join('/') : null, variables: brandVars, coloresAMano: estado.manual.colores.map((d) => d.name) },
212
225
  extras: { animaciones: estado.animaciones, motion: yaInstalado('motion'), echarts: yaInstalado('echarts'), tablas: yaInstalado('@tanstack/react-table') },
213
- componentes: Object.fromEntries(Object.entries(manifest.components).map(([n, c]) => [n, { import: c.import, exports: c.exports, ...(c.presets ? { presets: c.presets } : {}), ...(c.notes ? { notes: c.notes } : {}) }])),
226
+ componentes: Object.fromEntries(Object.entries(manifest.components).map(([n, c]) => [n, { import: c.import, group: c.group, exports: c.exports, ...(c.summary ? { summary: c.summary } : {}), ...(c.see ? { see: c.see } : {}), ...(c.presets ? { presets: c.presets } : {}), ...(c.notes ? { notes: c.notes } : {}) }])),
214
227
  patrones,
215
228
  documentacion: {
216
229
  reglas: `${docs}/AGENTS.md`,
@@ -220,6 +233,7 @@ function contexto(json) {
220
233
  ux: `${docs}/docs/designer/ux.md`,
221
234
  revision: `${docs}/docs/designer/revision.md`,
222
235
  manifiesto: `${docs}/components.manifest.json`,
236
+ paginas: `${docs}/manifest/<dominio>.json`,
223
237
  },
224
238
  skill: estadoSkill(raizApp()).estado,
225
239
  integracion: avisosIntegracion(estado),
@@ -245,17 +259,20 @@ function contexto(json) {
245
259
  if (estado.manual.colores.length) L.push(`- Colores escritos a mano (ganan al tema): ${estado.manual.colores.map((d) => d.name).join(', ')}`);
246
260
  const sino = (v) => (v ? 'sí' : 'no');
247
261
  L.push('', '## Extras', `- Animaciones del tema: ${sino(datos.extras.animaciones)} · Motion: ${sino(datos.extras.motion)} · ECharts: ${sino(datos.extras.echarts)} · TanStack Table: ${sino(datos.extras.tablas)}`);
248
- L.push('', `## Componentes (${Object.keys(datos.componentes).length}) · import orbital-ds/ui/<nombre>`, Object.keys(datos.componentes).join(', '));
262
+ L.push('', `## Componentes (${Object.keys(datos.componentes).length}) por dominio · import orbital-ds/ui/<nombre> · ficha: orbital-ds components <nombre>`);
263
+ for (const g of Object.keys(manifest.groups ?? {})) {
264
+ const nombres = Object.entries(datos.componentes).filter(([, c]) => c.group === g).map(([n]) => n);
265
+ if (!nombres.length) continue;
266
+ L.push('', `### ${g}`);
267
+ for (const n of nombres) L.push(`- ${n}: ${datos.componentes[n].summary ?? '—'}`);
268
+ }
249
269
  const conPresets = Object.entries(datos.componentes).filter(([, c]) => c.presets);
250
270
  if (conPresets.length) {
251
271
  L.push('', '### Presets (valor por defecto con *)');
252
272
  for (const [n, c] of conPresets) L.push(`- ${n}: ${c.presets.values.map((v) => (v === c.presets.default ? `${v}*` : v)).join(' · ')}`);
253
273
  }
254
- const conNotas = Object.entries(datos.componentes).filter(([, c]) => c.notes);
255
- if (conNotas.length) {
256
- L.push('', '### Notas de uso');
257
- for (const [n, c] of conNotas) for (const x of c.notes) L.push(`- ${n}: ${x}`);
258
- }
274
+ // Notas, alternativas y ejemplos de cada uno: en su ficha (orbital-ds components <nombre>), para no cargar las 160 aquí.
275
+ L.push('', 'Antes de usar un componente, lee su ficha: `orbital-ds components <nombre>` (alternativas, props, notas y ejemplos). Buscar por intención: `orbital-ds components --search <texto>`.');
259
276
  if (datos.integracion.length) L.push('', '## Avisos de integración', ...datos.integracion.map((a) => `- ${a}`));
260
277
  if (patrones.length) L.push('', '## Patrones (docs/designer/patrones.md)', ...patrones.map((p) => `- ${p}`));
261
278
  L.push('', '## Documentación', ...Object.entries(datos.documentacion).map(([k, v]) => `- ${k}: ${v}`));
@@ -269,6 +286,83 @@ function contexto(json) {
269
286
  console.log(L.join('\n'));
270
287
  }
271
288
 
289
+ /**
290
+ * orbital-ds components [<nombre> | --group <dominio>] [--json]: el catálogo por páginas. Sin argumentos, los dominios;
291
+ * con `--group`, sus componentes con props tipadas, presets y notas; con un nombre, solo ese componente.
292
+ */
293
+ function ordenComponentes(args) {
294
+ const json = args.includes('--json');
295
+ const gi = args.indexOf('--group');
296
+ const grupo = gi > -1 ? args[gi + 1] : null;
297
+ const nombre = args.includes('--search') ? null : args.find((a, i) => !a.startsWith('--') && args[i - 1] !== '--group');
298
+ const indice = JSON.parse(readFileSync(join(ROOT, 'components.manifest.json'), 'utf8'));
299
+ const salir = (m) => { console.error(m); process.exit(1); };
300
+ const pagina = (g) => {
301
+ const f = join(ROOT, 'manifest', `${g}.json`);
302
+ return existsSync(f) ? JSON.parse(readFileSync(f, 'utf8')) : salir(`No hay página del dominio «${g}». Dominios: ${Object.keys(indice.groups).join(', ')}`);
303
+ };
304
+ const ficha = (n, c) => {
305
+ const L = [`### ${n} · ${c.import}`];
306
+ if (c.summary) L.push(c.summary);
307
+ for (const s of c.see ?? []) L.push(`en su lugar → ${s.component}: ${s.when}`);
308
+ L.push(`exports: ${c.exports.join(', ')}`);
309
+ if (c.presets) L.push(`presets: ${c.presets.values.map((v) => (v === c.presets.default ? `${v}*` : v)).join(' · ')}`);
310
+ for (const [exp, props] of Object.entries(c.props ?? {})) {
311
+ L.push(`props de ${exp}:`);
312
+ for (const [p, d] of Object.entries(props)) L.push(` - ${p}${d.required ? '*' : ''}: ${d.values ? d.values.map((v) => `"${v}"`).join(' | ') : d.type}${d.doc ? ` — ${d.doc}` : ''}`);
313
+ }
314
+ for (const x of c.notes ?? []) L.push(`nota: ${x}`);
315
+ for (const e of c.examples ?? []) L.push(`ejemplo — ${e.title}:`, '```tsx', e.code, '```');
316
+ return L.join('\n');
317
+ };
318
+ // Búsqueda: por nombre, export, resumen, alternativas y notas (sin acentos ni mayúsculas). Para ELEGIR sin leer todo.
319
+ const si = args.indexOf('--search');
320
+ if (si > -1) {
321
+ const llano = (s) => String(s ?? '').normalize('NFD').replace(/\p{M}/gu, '').toLowerCase();
322
+ const terminos = llano(args.slice(si + 1).filter((a) => !a.startsWith('--')).join(' ')).split(/\s+/)
323
+ .filter((t) => t.length > 2 && !/^(?:una?|unos?|las?|los|del|con|para|por|que|toda?s?|the|and|for|with)$/.test(t));
324
+ if (!terminos.length) salir('Uso: orbital-ds components --search <texto>');
325
+ const hits = Object.entries(indice.components)
326
+ .map(([n, c]) => {
327
+ // Raíz de 5 letras al inicio de palabra: «confirmar» encuentra confirm-action y «borrado», «borrar».
328
+ // Sinónimos frecuentes al describir una intención (un agente no sabe qué palabra usa el resumen).
329
+ const SIN = { archivo: 'fichero', fichero: 'archivo', borrar: 'eliminar', eliminar: 'borrar', borrado: 'eliminar', modal: 'dialogo', ventana: 'dialogo', popup: 'dialogo', notificacion: 'aviso', mensaje: 'aviso', grafico: 'chart', grafica: 'chart', desplegable: 'select', cargando: 'carga', spinner: 'carga', kpi: 'cifra' };
330
+ const corta = (t) => t.slice(0, t.length >= 7 ? 5 : t.length >= 5 ? 4 : t.length).replace(/[^a-z0-9]/g, '');
331
+ const raiz = (t) => new RegExp(`(?:^|[^a-z0-9])(?:${[t, SIN[t]].filter(Boolean).map(corta).join('|')})`);
332
+ const nombreExp = llano([n.replace(/-/g, ' '), ...c.exports.map((e) => e.replace(/([a-z])([A-Z])/g, '$1 $2'))].join(' '));
333
+ const resumen = llano(c.summary);
334
+ const resto = llano([...(c.see ?? []).map((s) => s.when), ...(c.notes ?? [])].join(' '));
335
+ let cubiertos = 0;
336
+ const puntos = terminos.reduce((p, t) => {
337
+ const r = raiz(t);
338
+ const q = (r.test(nombreExp) ? 4 : 0) + (r.test(resumen) ? 2 : 0) + (r.test(resto) ? 1 : 0);
339
+ if (q) cubiertos++;
340
+ return p + q;
341
+ }, 0) + (cubiertos > 1 ? cubiertos * 3 : 0);
342
+ return { n, c, puntos };
343
+ })
344
+ .filter((h) => h.puntos > 0)
345
+ .sort((a, b) => b.puntos - a.puntos || a.n.localeCompare(b.n))
346
+ .slice(0, 12);
347
+ if (json) return console.log(JSON.stringify(hits.map(({ n, c }) => ({ name: n, import: c.import, group: c.group, summary: c.summary ?? null })), null, 2));
348
+ if (!hits.length) return console.log('Sin resultados. Prueba otras palabras o `orbital-ds components` para ver los dominios.');
349
+ return console.log([`# Búsqueda: ${terminos.join(' ')} (detalle: orbital-ds components <nombre>)`, '', ...hits.map(({ n, c }) => `- ${n} (${c.group}): ${c.summary ?? '—'}`)].join('\n'));
350
+ }
351
+ if (nombre) {
352
+ const g = indice.components[nombre]?.group ?? salir(`No existe el componente «${nombre}».`);
353
+ const c = pagina(g).components[nombre];
354
+ return json ? console.log(JSON.stringify({ [nombre]: c }, null, 2)) : console.log(ficha(nombre, c));
355
+ }
356
+ if (grupo) {
357
+ const p = pagina(grupo);
358
+ return json ? console.log(JSON.stringify(p, null, 2)) : console.log([`# ${grupo} — ${p.about}`, '', ...Object.entries(p.components).map(([n, c]) => ficha(n, c))].join('\n\n'));
359
+ }
360
+ const cuenta = {};
361
+ for (const c of Object.values(indice.components)) (cuenta[c.group] ??= []).push(c.import.split('/').pop());
362
+ if (json) return console.log(JSON.stringify(Object.fromEntries(Object.entries(indice.groups).map(([g, about]) => [g, { about, components: cuenta[g] ?? [] }])), null, 2));
363
+ console.log(['# Dominios de orbital-ds (orbital-ds components --group <dominio> · orbital-ds components <nombre>)', '', ...Object.entries(indice.groups).map(([g, about]) => `- ${g} (${(cuenta[g] ?? []).length}): ${about}\n ${(cuenta[g] ?? []).join(', ')}`)].join('\n'));
364
+ }
365
+
272
366
  /** orbital-ds skill [--check | --print] */
273
367
  function ordenSkill(args) {
274
368
  if (args.includes('--print')) return console.log(readFileSync(join(ROOT, 'skill', 'SKILL.md'), 'utf8').replaceAll('{{VERSION}}', version));
@@ -438,6 +532,9 @@ switch (orden) {
438
532
  case 'context':
439
533
  contexto(resto.includes('--json'));
440
534
  break;
535
+ case 'components':
536
+ ordenComponentes(resto);
537
+ break;
441
538
  case 'skill':
442
539
  ordenSkill(resto);
443
540
  break;
@@ -535,7 +535,18 @@ const uiDir = join(ROOT, 'src/ui');
535
535
  if (existsSync(uiDir)) {
536
536
  for (const f of readdirSync(uiDir).filter((n) => n.endsWith('.tsx'))) {
537
537
  const lines = read(join(uiDir, f)).split(/\r?\n/);
538
+ // La ficha (bloque /** … @summary … */) es documentación: sus @example son JSX de la APP (con sus
539
+ // textos), no código del componente. Se salta entera; la comprobación de fichas la valida aparte.
540
+ const ficha = new Set();
541
+ for (let a = 0; a < lines.length; a++) {
542
+ if (!/^\s*\/\*\*/.test(lines[a])) continue;
543
+ let b = a;
544
+ while (b < lines.length && !lines[b].includes('*/')) b++;
545
+ if (lines.slice(a, b + 1).some((l) => /@summary\b/.test(l))) for (let k = a; k <= b; k++) ficha.add(k);
546
+ a = b;
547
+ }
538
548
  lines.forEach((line, i) => {
549
+ if (ficha.has(i)) return;
539
550
  const code = line.replace(/\/\/.*$/, '');
540
551
  for (const rule of NO_HARDCODE) {
541
552
  if (rule.skip?.includes(f)) continue;
@@ -583,6 +594,80 @@ if (existsSync(uiDir)) {
583
594
  }
584
595
  });
585
596
  }
597
+ // Props de los componentes de orbital-ds usados en las vistas, contra las props tipadas del manifiesto por dominio:
598
+ // `asChild` (no existe: es `render`), un valor fuera de la unión (variant="primary") y un nombre casi igual a uno propio.
599
+ const indiceFile = join(ROOT, 'components.manifest.json');
600
+ if (existsSync(indiceFile)) {
601
+ const indice = JSON.parse(read(indiceFile)).components;
602
+ const paginas = {};
603
+ const propsDe = (modulo, exp) => {
604
+ const c = indice[modulo];
605
+ if (!c) return null;
606
+ const f = join(ROOT, 'manifest', `${c.group}.json`);
607
+ if (!(c.group in paginas)) paginas[c.group] = existsSync(f) ? JSON.parse(read(f)).components : null;
608
+ return paginas[c.group]?.[modulo]?.props?.[exp] ?? null;
609
+ };
610
+ const COMUNES = new Set(['className', 'children', 'key', 'ref', 'style', 'id', 'render', 'title', 'role', 'type', 'name', 'value', 'defaultValue', 'disabled', 'hidden', 'tabIndex', 'lang', 'dir', 'slot', 'form', 'href', 'src', 'alt', 'open', 'defaultOpen', 'checked', 'defaultChecked', 'placeholder', 'required', 'readOnly', 'autoFocus', 'autoComplete', 'htmlFor', 'width', 'height', 'target', 'rel']);
611
+ const distancia = (a, b) => {
612
+ const d = Array.from({ length: a.length + 1 }, (_, x) => [x, ...Array(b.length).fill(0)]);
613
+ for (let y = 1; y <= b.length; y++) d[0][y] = y;
614
+ for (let x = 1; x <= a.length; x++) for (let y = 1; y <= b.length; y++) d[x][y] = Math.min(d[x - 1][y] + 1, d[x][y - 1] + 1, d[x - 1][y - 1] + (a[x - 1] === b[y - 1] ? 0 : 1));
615
+ return d[a.length][b.length];
616
+ };
617
+ /** Atributos de una etiqueta JSX a partir de `pos` (tras el nombre): [{nombre, literal}] y la línea. */
618
+ const atributos = (src, pos) => {
619
+ const out = [];
620
+ let k = pos;
621
+ while (k < src.length) {
622
+ const ch = src[k];
623
+ if (ch === '>' || (ch === '/' && src[k + 1] === '>')) break;
624
+ if (ch === '{') { let n = 1; k++; while (k < src.length && n) { if (src[k] === '{') n++; else if (src[k] === '}') n--; k++; } continue; }
625
+ const m = /^[A-Za-z_][\w:-]*/.exec(src.slice(k, k + 80));
626
+ if (!m) { k++; continue; }
627
+ const nombre = m[0];
628
+ k += nombre.length;
629
+ let literal = null;
630
+ if (src[k] === '=') {
631
+ k++;
632
+ if (src[k] === '"' || src[k] === "'") { const q = src[k]; const e = src.indexOf(q, k + 1); literal = src.slice(k + 1, e); k = e + 1; }
633
+ else if (src[k] === '{') { let n = 1, j = k + 1; while (j < src.length && n) { if (src[j] === '{') n++; else if (src[j] === '}') n--; j++; } const lit = /^\{\s*(?:"([^"]*)"|'([^']*)')\s*\}$/.exec(src.slice(k, j)); if (lit) literal = lit[1] ?? lit[2]; k = j; }
634
+ }
635
+ out.push({ nombre, literal, pos: k });
636
+ }
637
+ return out;
638
+ };
639
+ let revisadas = 0;
640
+ for (const f of ficheros) {
641
+ const src = read(f).replace(/\r\n/g, '\n');
642
+ const locales = {};
643
+ for (const m of src.matchAll(/import\s*\{([^}]*)\}\s*from\s*["']orbital-ds\/ui\/([\w-]+)["']/g)) {
644
+ for (const parte of m[1].split(',')) {
645
+ const [orig, alias] = parte.trim().split(/\s+as\s+/);
646
+ if (orig && /^[A-Z]/.test(orig)) locales[alias ?? orig] = { modulo: m[2], exp: orig };
647
+ }
648
+ }
649
+ const donde = (pos) => `${f.replace(process.cwd(), '.').split('\\').join('/')}:${src.slice(0, pos).split('\n').length}`;
650
+ for (const m of src.matchAll(/<([A-Z]\w*)(?=[\s/>])/g)) {
651
+ const def = locales[m[1]];
652
+ if (!def) continue;
653
+ const props = propsDe(def.modulo, def.exp);
654
+ for (const a of atributos(src, m.index + m[0].length)) {
655
+ if (a.nombre === 'asChild') { errors.push(`ui ${donde(a.pos)}: <${m[1]} asChild> no existe en orbital-ds (Base UI usa la prop \`render\`)`); continue; }
656
+ if (!props) continue;
657
+ const d = props[a.nombre];
658
+ if (d) {
659
+ if (a.literal != null && d.values && !d.values.includes(a.literal)) errors.push(`ui ${donde(a.pos)}: <${m[1]} ${a.nombre}="${a.literal}"> no es válido; valores: ${d.values.join(' | ')}`);
660
+ continue;
661
+ }
662
+ if (COMUNES.has(a.nombre) || /^(?:data-|aria-|on[A-Z])/.test(a.nombre)) continue;
663
+ const cerca = Object.keys(props).find((p) => distancia(p.toLowerCase(), a.nombre.toLowerCase()) <= 2);
664
+ if (cerca) warnings.push(`ui ${donde(a.pos)}: <${m[1]} ${a.nombre}> no es una prop de orbital-ds; ¿querías decir «${cerca}»? (orbital-ds components ${def.modulo})`);
665
+ }
666
+ revisadas++;
667
+ }
668
+ }
669
+ if (revisadas) console.log(`ui: ${revisadas} uso(s) de componentes comprobados contra sus props tipadas`);
670
+ }
586
671
  if (ficheros.length) console.log(`ui: ${ficheros.length} fichero(s) revisados en ${process.argv[i + 1]}`);
587
672
  }
588
673
  }
@@ -590,9 +675,41 @@ if (existsSync(uiDir)) {
590
675
  // 6) API pública frente a la huella commiteada
591
676
  const manifestPath = join(ROOT, 'components.manifest.json');
592
677
  if (existsSync(manifestPath) && existsSync(uiDir)) {
593
- const { buildManifest } = await import('./manifest.mjs');
678
+ const { buildManifest, GROUPS } = await import('./manifest.mjs');
594
679
  const before = JSON.parse(read(manifestPath)).components;
595
680
  const now = buildManifest().components;
681
+ // Dominio: cada componente declara `/** @group <dominio> */` y su demo vive en la sección homónima del escaparate.
682
+ for (const [name, comp] of Object.entries(now)) {
683
+ if (!comp.group || !GROUPS[comp.group]) {
684
+ errors.push(`Dominio: «${name}» necesita \`/** @group <dominio> */\` con uno de: ${Object.keys(GROUPS).join(', ')}`);
685
+ continue;
686
+ }
687
+ const demo = join(ROOT, 'showcase/src/demos', `${name}.tsx`);
688
+ const label = existsSync(demo) ? read(demo).match(/group:\s*"([^"]+)"/)?.[1] : null;
689
+ if (label && label !== GROUPS[comp.group].label) {
690
+ errors.push(`Dominio: «${name}» es «${comp.group}» (${GROUPS[comp.group].label}) pero su demo está en «${label}»`);
691
+ }
692
+ }
693
+ // Ficha para agentes (cabecera JSDoc, ver scripts/manifest.mjs › parseDoc): `@summary` para ELEGIR, `@example` para
694
+ // COPIAR bien y `@see` hacia componentes que existen. Sin ella, un agente adivina entre piezas parecidas.
695
+ for (const [name, comp] of Object.entries(now)) {
696
+ if (!comp.summary) errors.push(`Ficha: «${name}» necesita \`@summary\` (una línea: qué es y cuándo usarlo) en su cabecera`);
697
+ else if (comp.summary.length > 220) warnings.push(`Ficha: el @summary de «${name}» pasa de 220 caracteres; el detalle va en @note`);
698
+ if (!comp.examples?.length) errors.push(`Ficha: «${name}» necesita al menos un \`@example <título>\` con JSX mínimo en su cabecera`);
699
+ const tags = comp.exports.filter((e) => /^[A-Z]/.test(e));
700
+ for (const ex of comp.examples ?? []) {
701
+ if (!ex.title) errors.push(`Ficha: un @example de «${name}» no tiene título (una sola idea: «Acción principal y secundaria»)`);
702
+ if (tags.length && !tags.some((t) => new RegExp(`<${t}[\\s/>.]`).test(ex.code) || ex.code.includes(`${t}(`))) {
703
+ errors.push(`Ficha: el @example «${ex.title}» de «${name}» no usa ninguno de sus exports (${tags.join(', ')})`);
704
+ }
705
+ if (/asChild/.test(ex.code)) errors.push(`Ficha: el @example «${ex.title}» de «${name}» usa asChild (es render)`);
706
+ }
707
+ for (const s of comp.see ?? []) {
708
+ if (!now[s.component]) errors.push(`Ficha: «${name}» remite con @see a «${s.component}», que no existe`);
709
+ else if (s.component === name) errors.push(`Ficha: «${name}» se remite a sí mismo con @see`);
710
+ if (!s.when) warnings.push(`Ficha: el @see ${s.component} de «${name}» no dice cuándo usarlo en su lugar`);
711
+ }
712
+ }
596
713
  for (const [name, comp] of Object.entries(before)) {
597
714
  if (!now[name]) {
598
715
  errors.push(`API pública: desaparece el componente «${name}» (¿versión mayor? regenera con pnpm manifest)`);
@@ -604,6 +721,14 @@ if (existsSync(manifestPath) && existsSync(uiDir)) {
604
721
  }
605
722
  }
606
723
  }
724
+ // Páginas por dominio (`manifest/<dominio>.json`): una por dominio y con los mismos componentes que el código.
725
+ for (const [g, nombres] of Object.entries(Object.groupBy(Object.keys(now), (n) => now[n].group))) {
726
+ const f = join(ROOT, 'manifest', `${g}.json`);
727
+ const pagina = existsSync(f) ? Object.keys(JSON.parse(read(f)).components) : null;
728
+ if (!pagina || pagina.length !== nombres.length || nombres.some((n) => !pagina.includes(n))) {
729
+ errors.push(`Manifiesto: la página «manifest/${g}.json» está ${pagina ? 'desfasada' : 'sin generar'}; ejecuta pnpm manifest`);
730
+ }
731
+ }
607
732
  const added = Object.keys(now).filter((n) => !before[n]);
608
733
  if (added.length) warnings.push(`API pública: componentes nuevos sin registrar en el manifiesto (${added.join(', ')}); ejecuta pnpm manifest`);
609
734
  }
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Plugin de ESLint de orbital-ds (config plana, sin dependencias): en la app solo se usan los componentes y las
3
+ * variables del sistema. Es la versión «en el editor» de lo que ya comprueba `orbital-ds doctor --ui`.
4
+ *
5
+ * // eslint.config.js
6
+ * import orbital from "orbital-ds/eslint";
7
+ * export default [orbital.configs.recommended];
8
+ *
9
+ * Reglas:
10
+ * orbital-ds/no-as-child `asChild` no existe (motor Base UI): se usa `render`.
11
+ * orbital-ds/system-styles en `className`, `cn()`, `clsx()` y `cva()`: nada de colores, z-index, duraciones,
12
+ * sombras de la escala Tailwind, paleta Tailwind ni px sueltos; usa tokens (`--ds-*`).
13
+ * orbital-ds/logical-direction clases lógicas (`ms-`, `ps-`, `text-start`…) en lugar de las físicas (RTL).
14
+ */
15
+
16
+ const STYLE_RULES = [
17
+ [/#[0-9a-fA-F]{3,8}\b/, 'color hexadecimal'],
18
+ [/\b(?:rgb|rgba|hsl|hsla|oklch)\((?!from_)/, 'color literal'],
19
+ [/(?<![\w-])z-(?!0(?![\w-]))\d+(?![\w-])/, 'z-index numérico (usa --ds-z-*)'],
20
+ [/(?<![\w-])duration-(?!0(?![\w-]))\d+(?![\w-])/, 'duración fija (usa --ds-motion-*)'],
21
+ [/(?<![\w-])ease-\[(?:cubic-bezier|steps)\(/, 'curva escrita (usa ease-(--ds-ease-*))'],
22
+ [/(?<![\w-])(?:bg|text|border)-(?:black|white)(?:\/\d+)?(?![\w-])/, 'color fijo (usa un token de color)'],
23
+ [/(?<![\w-])shadow-(?:xs|sm|md|lg|xl|2xl)(?![\w-])/, 'sombra de la escala Tailwind (usa shadow-card/control/raised/overlay/popover)'],
24
+ [/(?<![\w-])text-\[\d+px\]/, 'tamaño de texto en px (usa la escala estándar)'],
25
+ [/@\[\d+px\]/, 'container query en px (usa rem)'],
26
+ [/(?<![\w-])(?:bg|text|border|ring|fill|stroke)-(?:red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose|slate|gray|zinc|neutral|stone)-\d{2,3}(?![\w-])/, 'color de la paleta Tailwind (usa tokens de color)'],
27
+ ];
28
+
29
+ const PHYSICAL = /(?<![\w])-?(?:ml|mr|pl|pr)-(?=[\w[(.])|(?<![\w-])text-(?:left|right)(?![\w-])|(?<![\w-])(?:border|rounded)-[lr](?![\w])/;
30
+
31
+ const CLASS_HELPERS = new Set(['cn', 'clsx', 'cva', 'twMerge', 'classNames']);
32
+
33
+ /** ¿Está este literal dentro de un `className` / `class` o de una llamada a `cn()`, `clsx()`…? */
34
+ function inClassContext(node) {
35
+ for (let p = node.parent; p; p = p.parent) {
36
+ if (p.type === 'JSXAttribute') return p.name?.name === 'className' || p.name?.name === 'class';
37
+ if (p.type === 'CallExpression' && p.callee.type === 'Identifier' && CLASS_HELPERS.has(p.callee.name)) return true;
38
+ if (p.type === 'JSXElement' || p.type === 'FunctionDeclaration' || p.type === 'Program') return false;
39
+ }
40
+ return false;
41
+ }
42
+
43
+ /** Regla que busca patrones en los textos de clase. */
44
+ function classRule(patterns, description) {
45
+ return {
46
+ meta: { type: 'problem', docs: { description }, schema: [], messages: { bad: '{{why}}' } },
47
+ create(context) {
48
+ const check = (node, text) => {
49
+ if (!text || !inClassContext(node)) return;
50
+ for (const [re, why] of patterns) if (re.test(text)) context.report({ node, messageId: 'bad', data: { why } });
51
+ };
52
+ return {
53
+ Literal: (n) => typeof n.value === 'string' && check(n, n.value),
54
+ TemplateElement: (n) => check(n, n.value.cooked ?? n.value.raw),
55
+ };
56
+ },
57
+ };
58
+ }
59
+
60
+ const rules = {
61
+ 'no-as-child': {
62
+ meta: {
63
+ type: 'problem',
64
+ docs: { description: '`asChild` no existe en orbital-ds (Base UI): usa `render`.' },
65
+ schema: [],
66
+ messages: { bad: '`asChild` no existe en orbital-ds: usa la prop `render` (p. ej. render={<a href="…" />}).' },
67
+ },
68
+ create: (context) => ({
69
+ JSXAttribute(n) {
70
+ if (n.name?.name === 'asChild') context.report({ node: n, messageId: 'bad' });
71
+ },
72
+ }),
73
+ },
74
+ 'system-styles': classRule(STYLE_RULES, 'Solo variables y utilidades del sistema: sin colores, z-index ni duraciones fijos.'),
75
+ 'logical-direction': classRule(
76
+ [[PHYSICAL, 'clase física de dirección (usa ms-/me-/ps-/pe-, text-start/end, border-s/e, rounded-s/e: soporte RTL)']],
77
+ 'Clases lógicas de dirección para que la interfaz funcione en RTL.',
78
+ ),
79
+ };
80
+
81
+ const plugin = { meta: { name: 'orbital-ds' }, rules, configs: {} };
82
+ plugin.configs.recommended = {
83
+ files: ['**/*.{jsx,tsx}'],
84
+ plugins: { 'orbital-ds': plugin },
85
+ rules: {
86
+ 'orbital-ds/no-as-child': 'error',
87
+ 'orbital-ds/system-styles': 'error',
88
+ 'orbital-ds/logical-direction': 'warn',
89
+ },
90
+ };
91
+
92
+ export default plugin;
93
+ export { rules };
package/scripts/i18n.mjs CHANGED
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * Qué hace, por cada <idioma>.json de la carpeta:
13
13
  * - Añade las claves que FALTEN en su espacio «orbital», con el texto de orbital-ds para ese
14
- * idioma (en, es, pt-BR incluidos; `es-CO` usa `es`). Nunca pisa lo que la app ya tenga.
14
+ * idioma (en, es, pt-BR, fr, it, de y he incluidos; `es-CO` usa `es`). Nunca pisa lo que la app ya tenga.
15
15
  * - Si orbital-ds no trae ese idioma (p. ej. `ru`), pone el inglés y lo lista como
16
16
  * PENDIENTE DE TRADUCIR: el agente o la persona lo traduce en el JSON.
17
17
  * - Avisa de claves que sobran (orbital-ds ya no las usa).
@@ -9,18 +9,43 @@
9
9
  *
10
10
  * node scripts/manifest.mjs # regenera components.manifest.json
11
11
  */
12
- import { readFileSync, readdirSync, writeFileSync, existsSync } from 'node:fs';
12
+ import { readFileSync, readdirSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
13
13
  import { join, dirname, resolve } from 'node:path';
14
14
  import { fileURLToPath } from 'node:url';
15
+ import ts from 'typescript';
15
16
 
16
17
  const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
17
18
  const UI = join(ROOT, 'src/ui');
19
+ const EOL = '\n';
18
20
 
19
21
  // Dependencias que SIEMPRE están (peers obligatorios): no se listan como opcionales.
20
22
  const REQUIRED = new Set([
21
23
  'react', 'react-dom', 'class-variance-authority', 'clsx', 'tailwind-merge', 'lucide-react',
22
24
  ]);
23
25
 
26
+ /**
27
+ * Dominios de los componentes: el `@group` de cada fichero de `src/ui` (obligatorio, uno de estos) y la sección
28
+ * de su demo en el escaparate (`label`). Un agente pide solo el dominio que necesita en vez de leer los 150+.
29
+ */
30
+ export const GROUPS = {
31
+ actions: { label: 'Acciones', about: 'Botones y acciones sueltas.' },
32
+ forms: { label: 'Formularios', about: 'Campos, selectores y envío de datos.' },
33
+ feedback: { label: 'Avisos', about: 'Alertas, toasts, progreso y esperas.' },
34
+ overlays: { label: 'Capas', about: 'Diálogos, menús, popovers y paneles que se superponen.' },
35
+ navigation: { label: 'Navegación', about: 'Cabecera, lateral, pestañas, pasos, paginación y búsqueda de destinos.' },
36
+ data: { label: 'Datos', about: 'Tablas, gráficos, métricas, listas de entidades y estados de carga.' },
37
+ content: { label: 'Contenido', about: 'Tarjetas, texto, media y piezas de maquetación.' },
38
+ motion: { label: 'Movimiento', about: 'Animación y cargadores de página.' },
39
+ chat: { label: 'Chat', about: 'Conversación: mensajes, compositor, adjuntos y sugerencias.' },
40
+ agents: { label: 'Agentes', about: 'Lo que hace un agente: razonamiento, herramientas, eventos, flujos y A2UI.' },
41
+ ai: { label: 'IA', about: 'Piezas de contenido generado.' },
42
+ auth: { label: 'Acceso', about: 'Inicio de sesión, MFA, passkeys, sesiones y consentimiento.' },
43
+ };
44
+
45
+ function parseGroup(src) {
46
+ return src.match(/@group\s+([a-z-]+)/)?.[1] ?? null;
47
+ }
48
+
24
49
  function parseExports(src) {
25
50
  const names = new Set();
26
51
  for (const m of src.matchAll(/export\s*\{([^}]*)\}/g)) {
@@ -34,7 +59,58 @@ function parseExports(src) {
34
59
  }
35
60
 
36
61
  function parseSlots(src) {
37
- return [...new Set([...src.matchAll(/data-slot="([a-z0-9-]+)"/g)].map((m) => m[1]))].sort();
62
+ // `data-slot="x"` en JSX, `"data-slot": "x"` en un objeto de props y `state: { slot: "x" }` de useRender.
63
+ const re = /(?:data-slot"?\s*[=:]\s*|\bslot:\s*)"([a-z0-9-]+)"/g;
64
+ return [...new Set([...src.matchAll(re)].map((m) => m[1]))].sort();
65
+ }
66
+
67
+ /**
68
+ * Ficha para agentes escrita en la cabecera del componente (JSDoc, en español):
69
+ *
70
+ * @summary <una línea: qué es y cuándo usarlo>
71
+ * @see <otro-componente> — <cuándo usar ese en su lugar>
72
+ * @example <título: una sola idea>
73
+ * <JSX mínimo, en las líneas siguientes, hasta la próxima etiqueta o el fin del comentario>
74
+ *
75
+ * Todo en UN bloque `/** … *\/` (el de `@group`). En el JSX de un ejemplo no caben comentarios `{/* … *\/}`.
76
+ *
77
+ * Es lo primero que lee un agente para ELEGIR (summary y see van al índice) y para COPIAR bien (examples).
78
+ */
79
+ export function parseDoc(src) {
80
+ const out = { summary: null, see: [], examples: [] };
81
+ for (const block of src.matchAll(/\/\*\*?([\s\S]*?)\*\//g)) {
82
+ // Solo el bloque de la ficha (el que lleva @summary): un @see o @example en el JSDoc de una prop no cuenta.
83
+ if (!/@summary\b/.test(block[1])) continue;
84
+ const lines = block[1].split(/\r?\n/).map((l) => l.replace(/^\s*\*\s?/, ''));
85
+ let cur = null;
86
+ const flush = () => {
87
+ if (cur?.kind === 'example') {
88
+ while (cur.code.length && !cur.code.at(-1).trim()) cur.code.pop();
89
+ while (cur.code.length && !cur.code[0].trim()) cur.code.shift();
90
+ const indent = Math.min(...cur.code.filter((l) => l.trim()).map((l) => l.match(/^\s*/)[0].length));
91
+ out.examples.push({ title: cur.title, code: cur.code.map((l) => l.slice(indent)).join('\n') });
92
+ }
93
+ cur = null;
94
+ };
95
+ for (const line of lines) {
96
+ const tag = line.match(/^\s*@(\w+)\s*(.*)$/);
97
+ if (tag) {
98
+ flush();
99
+ const [, name, rest] = tag;
100
+ if (name === 'summary') { out.summary = rest.trim(); cur = { kind: 'summary' }; }
101
+ else if (name === 'see') {
102
+ const m = rest.match(/^([a-z0-9-]+)\s*(?:—|-{1,2}|:)?\s*(.*)$/);
103
+ if (m) out.see.push({ component: m[1], when: m[2].trim() });
104
+ } else if (name === 'example') cur = { kind: 'example', title: rest.trim(), code: [] };
105
+ continue;
106
+ }
107
+ if (cur?.kind === 'example') cur.code.push(line);
108
+ else if (cur?.kind === 'summary' && line.trim()) out.summary += ` ${line.trim()}`;
109
+ else cur = null;
110
+ }
111
+ flush();
112
+ }
113
+ return out;
38
114
  }
39
115
 
40
116
  /** Reglas de uso escritas en el componente con `@note …` (una por línea): van al manifiesto. */
@@ -68,18 +144,74 @@ function parseOptionalPeers(src) {
68
144
  return [...peers].sort();
69
145
  }
70
146
 
71
- export function buildManifest() {
147
+ /**
148
+ * Props PROPIAS de cada componente exportado (las declaradas en `src/`, no las del elemento nativo ni las de
149
+ * Base UI): nombre, tipo, si es obligatoria, valores si es una unión de literales y su comentario.
150
+ * Lee los tipos con el compilador de TypeScript, así que nunca se desfasa del código.
151
+ */
152
+ function extractProps() {
153
+ const cfgPath = join(ROOT, 'tsconfig.json');
154
+ const cfg = ts.getParsedCommandLineOfConfigFile(cfgPath, {}, { ...ts.sys, onUnRecoverableConfigFileDiagnostic: () => {} });
155
+ const files = readdirSync(UI).filter((n) => n.endsWith('.tsx')).map((n) => join(UI, n));
156
+ const program = ts.createProgram(files, cfg.options);
157
+ const checker = program.getTypeChecker();
158
+ const own = (sym) => (sym.declarations ?? []).length > 0 && sym.declarations.every((d) => !d.getSourceFile().fileName.includes('node_modules'));
159
+ const out = {};
160
+ for (const file of files) {
161
+ const sf = program.getSourceFile(file);
162
+ const mod = sf && checker.getSymbolAtLocation(sf);
163
+ if (!mod) continue;
164
+ const name = file.slice(UI.length + 1).replace(/\.tsx$/, '').replaceAll('\\', '/');
165
+ const byExport = {};
166
+ for (const exp of checker.getExportsOfModule(mod)) {
167
+ if (!/^[A-Z]/.test(exp.name)) continue;
168
+ const target = exp.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(exp) : exp;
169
+ const decl = target.valueDeclaration ?? target.declarations?.[0];
170
+ if (!decl) continue;
171
+ const sig = checker.getTypeOfSymbolAtLocation(target, decl).getCallSignatures()[0];
172
+ const param = sig?.parameters[0];
173
+ if (!param) continue;
174
+ const props = {};
175
+ for (const p of checker.getTypeOfSymbolAtLocation(param, decl).getProperties()) {
176
+ if (!own(p)) continue;
177
+ const optional = (p.flags & ts.SymbolFlags.Optional) !== 0;
178
+ const type = checker.getNonNullableType(checker.getTypeOfSymbolAtLocation(p, decl));
179
+ const text = checker.typeToString(type, decl, ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope);
180
+ const lits = type.isUnion() ? type.types.filter((t) => t.isStringLiteral()).map((t) => t.value) : [];
181
+ const doc = ts.displayPartsToString(p.getDocumentationComment(checker)).replace(/\s+/g, ' ').trim();
182
+ props[p.name] = {
183
+ type: text.length > 160 ? text.slice(0, 157) + '…' : text,
184
+ ...(optional ? {} : { required: true }),
185
+ ...(lits.length > 1 && lits.length === type.types.length ? { values: lits } : {}),
186
+ ...(doc ? { doc } : {}),
187
+ };
188
+ }
189
+ if (Object.keys(props).length) byExport[exp.name] = props;
190
+ }
191
+ if (Object.keys(byExport).length) out[name] = byExport;
192
+ }
193
+ return out;
194
+ }
195
+
196
+ export function buildManifest({ props = false } = {}) {
197
+ const propsByFile = props ? extractProps() : {};
72
198
  const components = {};
73
199
  for (const f of readdirSync(UI).filter((n) => n.endsWith('.tsx')).sort()) {
74
200
  const src = readFileSync(join(UI, f), 'utf8');
75
201
  const name = f.replace(/\.tsx$/, '');
202
+ const doc = parseDoc(src);
76
203
  components[name] = {
77
204
  import: `orbital-ds/ui/${name}`,
205
+ group: parseGroup(src),
206
+ ...(doc.summary ? { summary: doc.summary } : {}),
207
+ ...(doc.see.length ? { see: doc.see } : {}),
78
208
  exports: parseExports(src),
79
209
  slots: parseSlots(src),
80
210
  optionalPeers: parseOptionalPeers(src),
211
+ ...(propsByFile[name] ? { props: propsByFile[name] } : {}),
81
212
  ...(parsePresets(src) ? { presets: parsePresets(src) } : {}),
82
213
  ...(parseNotes(src).length ? { notes: parseNotes(src) } : {}),
214
+ ...(doc.examples.length ? { examples: doc.examples } : {}),
83
215
  };
84
216
  }
85
217
  const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8'));
@@ -87,14 +219,34 @@ export function buildManifest() {
87
219
  package: pkg.name,
88
220
  version: pkg.version,
89
221
  engine: '@base-ui/react',
222
+ groups: Object.fromEntries(Object.entries(GROUPS).map(([k, v]) => [k, v.about])),
90
223
  docs: ['README.md', 'docs/CONTRACT.md', 'AGENTS.md', 'contract.json'],
91
224
  components,
92
225
  };
93
226
  }
94
227
 
228
+ /** Carpeta de las páginas por dominio (`manifest/<dominio>.json`): componentes con sus props tipadas. */
229
+ export const PAGES_DIR = 'manifest';
230
+
231
+ /** Separa el manifiesto completo en el índice (sin props, ligero) y una página por dominio (con props). */
232
+ export function splitManifest(full) {
233
+ const index = { ...full, pages: Object.fromEntries(Object.keys(GROUPS).map((g) => [g, `${PAGES_DIR}/${g}.json`])), components: {} };
234
+ const pages = {};
235
+ for (const g of Object.keys(GROUPS)) pages[g] = { package: full.package, version: full.version, group: g, about: GROUPS[g].about, components: {} };
236
+ for (const [name, c] of Object.entries(full.components)) {
237
+ // El índice sirve para ELEGIR (resumen, alternativas, notas); las props y los ejemplos, en la página del dominio.
238
+ const { props, examples, ...light } = c;
239
+ index.components[name] = light;
240
+ if (pages[c.group]) pages[c.group].components[name] = c;
241
+ }
242
+ return { index, pages };
243
+ }
244
+
95
245
  if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
96
- const out = join(ROOT, 'components.manifest.json');
97
- const manifest = buildManifest();
98
- writeFileSync(out, JSON.stringify(manifest, null, 2) + '\n');
99
- console.log(`manifest: ${Object.keys(manifest.components).length} componentes → components.manifest.json`);
246
+ const full = buildManifest({ props: true });
247
+ const { index, pages } = splitManifest(full);
248
+ writeFileSync(join(ROOT, 'components.manifest.json'), JSON.stringify(index, null, 2) + EOL);
249
+ mkdirSync(join(ROOT, PAGES_DIR), { recursive: true });
250
+ for (const [g, page] of Object.entries(pages)) writeFileSync(join(ROOT, PAGES_DIR, `${g}.json`), JSON.stringify(page, null, 2) + EOL);
251
+ console.log(`manifest: ${Object.keys(full.components).length} componentes → components.manifest.json + ${PAGES_DIR}/ (${Object.keys(pages).length} dominios)`);
100
252
  }