@punica/components-mcp 0.8.0 → 0.9.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.
package/dist/bundled.json CHANGED
@@ -1 +1 @@
1
- {"version":"2.6.0"}
1
+ {"version":"2.6.2"}
@@ -327,6 +327,152 @@
327
327
  }
328
328
  ]
329
329
  },
330
+ {
331
+ "kind": "javascript-module",
332
+ "path": "src/components/alert/alert.js",
333
+ "declarations": [
334
+ {
335
+ "kind": "class",
336
+ "description": "A message about the content beside it: a result, a warning, a tip.\n\nAn error or a warning is `role=alert` and interrupts a screen reader; any\nother colour is `role=status` and waits its turn.",
337
+ "name": "PunicaAlert",
338
+ "cssProperties": [
339
+ {
340
+ "description": "Corner radius.",
341
+ "name": "--punica-alert-radius"
342
+ },
343
+ {
344
+ "description": "Padding.",
345
+ "name": "--punica-alert-padding"
346
+ },
347
+ {
348
+ "description": "Space between icon, message and actions.",
349
+ "name": "--punica-alert-gap"
350
+ }
351
+ ],
352
+ "cssParts": [
353
+ {
354
+ "description": "The default icon.",
355
+ "name": "icon"
356
+ },
357
+ {
358
+ "description": "The wrapper around the message.",
359
+ "name": "content"
360
+ },
361
+ {
362
+ "description": "The wrapper around the actions.",
363
+ "name": "actions"
364
+ },
365
+ {
366
+ "description": "The close button.",
367
+ "name": "close"
368
+ }
369
+ ],
370
+ "slots": [
371
+ {
372
+ "description": "The message.",
373
+ "name": ""
374
+ },
375
+ {
376
+ "description": "An icon in place of the one the colour gives.",
377
+ "name": "icon"
378
+ },
379
+ {
380
+ "description": "Buttons that answer the message.",
381
+ "name": "actions"
382
+ }
383
+ ],
384
+ "members": [
385
+ {
386
+ "kind": "field",
387
+ "name": "properties",
388
+ "type": {
389
+ "text": "object"
390
+ },
391
+ "static": true,
392
+ "default": "{ color: {}, variant: {}, dismissible: { type: Boolean }, labelClose: { default: 'Close' } }"
393
+ },
394
+ {
395
+ "kind": "field",
396
+ "name": "styles",
397
+ "static": true,
398
+ "default": "styles"
399
+ },
400
+ {
401
+ "kind": "field",
402
+ "name": "template",
403
+ "static": true,
404
+ "default": "` <span class=\"icon\"><slot name=\"icon\"><span class=\"default info\">${icons.info}</span><span class=\"default success\">${icons.success}</span><span class=\"default warning\">${icons.warning}</span><span class=\"default error\">${icons.error}</span></slot></span> <div part=\"content\" class=\"content\"><slot></slot></div> <div part=\"actions\" class=\"actions\"><slot name=\"actions\"></slot></div> <button part=\"close\" class=\"close\" type=\"button\" hidden>${icons.close}</button> `"
405
+ },
406
+ {
407
+ "kind": "field",
408
+ "name": "#close",
409
+ "privacy": "private"
410
+ },
411
+ {
412
+ "kind": "method",
413
+ "name": "update"
414
+ },
415
+ {
416
+ "kind": "method",
417
+ "name": "dismiss",
418
+ "description": "Does what the close button does: fires `punica-dismiss` and, unless a\nlistener prevents it, hides the alert."
419
+ }
420
+ ],
421
+ "events": [
422
+ {
423
+ "description": "The user pressed the close button. Cancelable: unless prevented, the alert hides itself with `hidden`.",
424
+ "name": "punica-dismiss"
425
+ }
426
+ ],
427
+ "attributes": [
428
+ {
429
+ "type": {
430
+ "text": "'info' | 'success' | 'warning' | 'error' | 'primary' | 'secondary' | 'neutral'"
431
+ },
432
+ "description": "What the message is, `info` by default.",
433
+ "name": "color"
434
+ },
435
+ {
436
+ "type": {
437
+ "text": "'tinted' | 'outlined' | 'filled'"
438
+ },
439
+ "description": "Visual weight, `tinted` by default.",
440
+ "name": "variant"
441
+ },
442
+ {
443
+ "type": {
444
+ "text": "boolean"
445
+ },
446
+ "description": "Shows a close button.",
447
+ "name": "dismissible"
448
+ },
449
+ {
450
+ "type": {
451
+ "text": "string"
452
+ },
453
+ "description": "Accessible name of the close button, `Close` by default.",
454
+ "name": "label-close"
455
+ }
456
+ ],
457
+ "superclass": {
458
+ "name": "PunicaElement",
459
+ "module": "/src/core/element.js"
460
+ },
461
+ "tagName": "punica-alert",
462
+ "customElement": true
463
+ }
464
+ ],
465
+ "exports": [
466
+ {
467
+ "kind": "js",
468
+ "name": "PunicaAlert",
469
+ "declaration": {
470
+ "name": "PunicaAlert",
471
+ "module": "src/components/alert/alert.js"
472
+ }
473
+ }
474
+ ]
475
+ },
330
476
  {
331
477
  "kind": "javascript-module",
332
478
  "path": "src/components/agenda/agenda.js",
@@ -1180,152 +1326,6 @@
1180
1326
  }
1181
1327
  ]
1182
1328
  },
1183
- {
1184
- "kind": "javascript-module",
1185
- "path": "src/components/alert/alert.js",
1186
- "declarations": [
1187
- {
1188
- "kind": "class",
1189
- "description": "A message about the content beside it: a result, a warning, a tip.\n\nAn error or a warning is `role=alert` and interrupts a screen reader; any\nother colour is `role=status` and waits its turn.",
1190
- "name": "PunicaAlert",
1191
- "cssProperties": [
1192
- {
1193
- "description": "Corner radius.",
1194
- "name": "--punica-alert-radius"
1195
- },
1196
- {
1197
- "description": "Padding.",
1198
- "name": "--punica-alert-padding"
1199
- },
1200
- {
1201
- "description": "Space between icon, message and actions.",
1202
- "name": "--punica-alert-gap"
1203
- }
1204
- ],
1205
- "cssParts": [
1206
- {
1207
- "description": "The default icon.",
1208
- "name": "icon"
1209
- },
1210
- {
1211
- "description": "The wrapper around the message.",
1212
- "name": "content"
1213
- },
1214
- {
1215
- "description": "The wrapper around the actions.",
1216
- "name": "actions"
1217
- },
1218
- {
1219
- "description": "The close button.",
1220
- "name": "close"
1221
- }
1222
- ],
1223
- "slots": [
1224
- {
1225
- "description": "The message.",
1226
- "name": ""
1227
- },
1228
- {
1229
- "description": "An icon in place of the one the colour gives.",
1230
- "name": "icon"
1231
- },
1232
- {
1233
- "description": "Buttons that answer the message.",
1234
- "name": "actions"
1235
- }
1236
- ],
1237
- "members": [
1238
- {
1239
- "kind": "field",
1240
- "name": "properties",
1241
- "type": {
1242
- "text": "object"
1243
- },
1244
- "static": true,
1245
- "default": "{ color: {}, variant: {}, dismissible: { type: Boolean }, labelClose: { default: 'Close' } }"
1246
- },
1247
- {
1248
- "kind": "field",
1249
- "name": "styles",
1250
- "static": true,
1251
- "default": "styles"
1252
- },
1253
- {
1254
- "kind": "field",
1255
- "name": "template",
1256
- "static": true,
1257
- "default": "` <span class=\"icon\"><slot name=\"icon\"><span class=\"default info\">${icons.info}</span><span class=\"default success\">${icons.success}</span><span class=\"default warning\">${icons.warning}</span><span class=\"default error\">${icons.error}</span></slot></span> <div part=\"content\" class=\"content\"><slot></slot></div> <div part=\"actions\" class=\"actions\"><slot name=\"actions\"></slot></div> <button part=\"close\" class=\"close\" type=\"button\" hidden>${icons.close}</button> `"
1258
- },
1259
- {
1260
- "kind": "field",
1261
- "name": "#close",
1262
- "privacy": "private"
1263
- },
1264
- {
1265
- "kind": "method",
1266
- "name": "update"
1267
- },
1268
- {
1269
- "kind": "method",
1270
- "name": "dismiss",
1271
- "description": "Does what the close button does: fires `punica-dismiss` and, unless a\nlistener prevents it, hides the alert."
1272
- }
1273
- ],
1274
- "events": [
1275
- {
1276
- "description": "The user pressed the close button. Cancelable: unless prevented, the alert hides itself with `hidden`.",
1277
- "name": "punica-dismiss"
1278
- }
1279
- ],
1280
- "attributes": [
1281
- {
1282
- "type": {
1283
- "text": "'info' | 'success' | 'warning' | 'error' | 'primary' | 'secondary' | 'neutral'"
1284
- },
1285
- "description": "What the message is, `info` by default.",
1286
- "name": "color"
1287
- },
1288
- {
1289
- "type": {
1290
- "text": "'tinted' | 'outlined' | 'filled'"
1291
- },
1292
- "description": "Visual weight, `tinted` by default.",
1293
- "name": "variant"
1294
- },
1295
- {
1296
- "type": {
1297
- "text": "boolean"
1298
- },
1299
- "description": "Shows a close button.",
1300
- "name": "dismissible"
1301
- },
1302
- {
1303
- "type": {
1304
- "text": "string"
1305
- },
1306
- "description": "Accessible name of the close button, `Close` by default.",
1307
- "name": "label-close"
1308
- }
1309
- ],
1310
- "superclass": {
1311
- "name": "PunicaElement",
1312
- "module": "/src/core/element.js"
1313
- },
1314
- "tagName": "punica-alert",
1315
- "customElement": true
1316
- }
1317
- ],
1318
- "exports": [
1319
- {
1320
- "kind": "js",
1321
- "name": "PunicaAlert",
1322
- "declaration": {
1323
- "name": "PunicaAlert",
1324
- "module": "src/components/alert/alert.js"
1325
- }
1326
- }
1327
- ]
1328
- },
1329
1329
  {
1330
1330
  "kind": "javascript-module",
1331
1331
  "path": "src/components/alertDialog/alertDialog.js",
package/dist/guide.md CHANGED
@@ -6,6 +6,12 @@ break from 1.x: names you may remember from 1.x (`punica-typography`,
6
6
  Use only the tags, attributes, events and slots this document lists; never
7
7
  guess one.
8
8
 
9
+ `get_component` (`brief: true` for markup; on the command line
10
+ `npx punica-components info <tag> --brief`) gives an element's whole API,
11
+ the functions of its module (`confirm()`, `toast()`) and how it is written
12
+ in JSX. Ask it instead of reading the `.d.ts` files in `node_modules`;
13
+ `validate_markup` checks the result.
14
+
9
15
  ## Loading
10
16
 
11
17
  ```html
package/dist/server.mjs CHANGED
@@ -265,7 +265,7 @@ function createKnowledge(manifest2) {
265
265
  const typed = new Set(words.filter((w) => w.weight === 1).map((w) => w.word.replace(/s$/, "")));
266
266
  if (tagWords.every((t) => typed.has(t.replace(/s$/, "")))) score += 5 * tagWords.length;
267
267
  const part = /^(?:the |one |a |an )?[^.]*?\b(?:of|in|for|inside) (?:a|an|the) `punica-/i.test(firstSentence(element.description)) ? 4 : 0;
268
- scored.push({ tag: element.tag, description: firstSentence(element.description), functions: element.functions.map((f) => f.name), score: score - part - tagWords.length * 0.1 });
268
+ scored.push({ tag: element.tag, description: firstSentence(element.description), functions: element.functions.map((f) => f.name), signatures: element.functions.map((f) => f.signature), score: score - part - tagWords.length * 0.1 });
269
269
  }
270
270
  return scored.sort((a, b) => b.score - a.score).slice(0, limit);
271
271
  }
@@ -291,6 +291,7 @@ function createKnowledge(manifest2) {
291
291
  for (const f of e.functions) lines.push("", "```ts", f.signature, "```", "", f.description);
292
292
  }
293
293
  table("Events", ["Event", "Detail", "Description"], e.events.map((ev) => [`\`${ev.name}\``, ev.detail ? `\`${ev.detail}\`` : "", ev.description]));
294
+ lines.push("", "### In React (JSX)", "", ...jsx(e));
294
295
  table("Slots", ["Slot", "Description"], e.slots.map((s) => [s.name ? `\`${s.name}\`` : "(default)", s.description]));
295
296
  if (!brief) {
296
297
  table("CSS parts", ["Part", "Description"], e.parts.map((p) => [`\`${p.name}\``, p.description]));
@@ -306,6 +307,22 @@ function createKnowledge(manifest2) {
306
307
  }
307
308
  return { elements, tags, allEvents, icons: icons2, list, get, search, legacy, formatMarkdown };
308
309
  }
310
+ function jsx(e) {
311
+ const out = [
312
+ "`import type {} from '@punica/components/react';` once, in the entry file, types every punica-* tag in JSX (React 18 and 19)."
313
+ ];
314
+ const dashed = e.attributes.find((a) => a.name.includes("-"));
315
+ const spelled = dashed ? ` (\`${dashed.name}\` or, in React 19, \`${dashed.name.replace(/-([a-z])/g, (_, c) => c.toUpperCase())}\`)` : "";
316
+ out.push(`Attributes are props under their own name${spelled}; \`class\` works as well as \`className\`.`);
317
+ const ev = e.events.find((x) => x.detail) || e.events[0];
318
+ if (ev) {
319
+ const read = ev.detail ? /\bvalue\??:/.test(ev.detail) ? "setValue(event.detail.value)" : "handle(event.detail)" : "handle(event)";
320
+ out.push(
321
+ `Events are \`on\` + the event name, the handler typed with the detail: \`<${e.tag} on${ev.name}={(event) => ${read}} />\`${ev.detail ? `, \`event\` a \`CustomEvent<${ev.detail}>\`` : ""}. \`onChange\`/\`onInput\` never fire. React 18 does not wire custom events: listen through a ref.`
322
+ );
323
+ }
324
+ return [out.join(" ")];
325
+ }
309
326
  function normalizeTag(tag) {
310
327
  const t = String(tag).trim().toLowerCase().replace(/^<|\/?>$/g, "");
311
328
  return t.startsWith("punica-") ? t : `punica-${t}`;
@@ -730,7 +747,7 @@ function createPunicaServer({ manifest: manifest2, guide: guide2, version: versi
730
747
  async ({ query, limit }) => {
731
748
  const results = knowledge.search(query, limit || 10);
732
749
  if (!results.length) return text(`Nothing matches "${query}". Elements: ${knowledge.tags.join(", ")}`);
733
- const also = (r) => r.functions?.length ? ` Script: ${r.functions.map((name) => `\`${name}()\``).join(", ")} from '@punica/components'.` : "";
750
+ const also = (r) => r.signatures?.length ? ` Script: \`import { ${r.functions.join(", ")} } from '@punica/components'\`; ${r.signatures.map((s) => `\`${s}\``).join("; ")}.` : "";
734
751
  return text(results.map((r) => `${r.tag}: ${r.description}${also(r)}`).join("\n"));
735
752
  }
736
753
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@punica/components-mcp",
3
- "version": "0.8.0",
3
+ "version": "0.9.1",
4
4
  "description": "MCP server for @punica/components: find elements, read their API and examples, validate markup.",
5
5
  "keywords": [
6
6
  "mcp",