@punica/components-mcp 0.1.1 → 0.3.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.
- package/dist/bundled.json +1 -1
- package/dist/custom-elements.json +1159 -168
- package/dist/guide.md +29 -1
- package/dist/server.mjs +18 -8
- package/package.json +1 -1
package/dist/guide.md
CHANGED
|
@@ -61,6 +61,12 @@ for a label, help text and an error message:
|
|
|
61
61
|
</form>
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
+
A value set from script (`control.value = 'x'`) reaches the form at the end
|
|
65
|
+
of the current microtask, as every property does. A script that submits in
|
|
66
|
+
the same turn awaits it first: `await control.updateComplete;
|
|
67
|
+
form.requestSubmit()`. Reading the control's `validity`,
|
|
68
|
+
`validationMessage` or `checkValidity()` also brings it up to date at once.
|
|
69
|
+
|
|
64
70
|
## Overlays
|
|
65
71
|
|
|
66
72
|
Dialogs, menus, popovers and drawers open in the browser's top layer: no
|
|
@@ -97,6 +103,25 @@ properties. Right-to-left works with `dir="rtl"` on any ancestor.
|
|
|
97
103
|
elements (`compilerOptions.isCustomElement`).
|
|
98
104
|
- **Angular**: `CUSTOM_ELEMENTS_SCHEMA`, `(punica-change)="…"`, `[value]="…"`.
|
|
99
105
|
|
|
106
|
+
## With the other Punica libraries
|
|
107
|
+
|
|
108
|
+
`@punica/components` is one of three libraries made to be used together:
|
|
109
|
+
Punica Form (`@punica/form`, forms and their rules) and Punica Request
|
|
110
|
+
(`@punica/request`, the HTTP client). Each has an MCP server; when the
|
|
111
|
+
project has them, look their APIs up there instead of guessing.
|
|
112
|
+
|
|
113
|
+
- **Forms**: in a project that has `@punica/form-kit`, do not wire
|
|
114
|
+
`punica-field` and its controls by hand. Describe the form as a class
|
|
115
|
+
(`@TextField`, `@SelectField`, …) and render it with `KitForm`; the kit
|
|
116
|
+
draws these elements, validates and shows the errors. A form whose markup
|
|
117
|
+
is your own (no React) is bound to the engine with `bindForm` of
|
|
118
|
+
`@punica/form-kit/dom` (from form-kit 0.5).
|
|
119
|
+
- **Messages and confirmations**: `toast()` and `confirm()` are what an
|
|
120
|
+
application shows a failed request and asks before a deletion with.
|
|
121
|
+
|
|
122
|
+
A whole application on the three, with its tests:
|
|
123
|
+
https://github.com/punicalab/punica-starter (start with its `AGENTS.md`).
|
|
124
|
+
|
|
100
125
|
## Testing
|
|
101
126
|
|
|
102
127
|
Elements carry their role through `ElementInternals`: a `punica-heading` is
|
|
@@ -114,5 +139,8 @@ element (the `button` in a `punica-button`, the `dialog` in a
|
|
|
114
139
|
|
|
115
140
|
`npx punica-components validate <files>` checks tags, attributes, values,
|
|
116
141
|
slots, events and icon names against this version and exits 1 on an error.
|
|
117
|
-
`npx punica-components info <tag>` prints one element's whole API
|
|
142
|
+
`npx punica-components info <tag>` prints one element's whole API; with
|
|
143
|
+
`--brief` (in the MCP server: `get_component` with `brief: true`) it leaves
|
|
144
|
+
out CSS parts, custom properties and states. Ask for the brief form first
|
|
145
|
+
and for the whole one only when you style the inside of an element.
|
|
118
146
|
Documentation with live examples: https://components.punicalab.com
|
package/dist/server.mjs
CHANGED
|
@@ -255,7 +255,7 @@ function createKnowledge(manifest2) {
|
|
|
255
255
|
}
|
|
256
256
|
return scored.sort((a, b) => b.score - a.score).slice(0, limit);
|
|
257
257
|
}
|
|
258
|
-
function formatMarkdown(tag) {
|
|
258
|
+
function formatMarkdown(tag, { brief = false } = {}) {
|
|
259
259
|
const e = get(tag);
|
|
260
260
|
if (!e) {
|
|
261
261
|
const old = legacy(normalizeTag(tag));
|
|
@@ -268,15 +268,22 @@ function createKnowledge(manifest2) {
|
|
|
268
268
|
if (!rows.length) return;
|
|
269
269
|
lines.push("", `### ${title}`, "", `| ${head.join(" | ")} |`, `|${head.map(() => "---").join("|")}|`, ...rows.map((r) => `| ${r.map(cell).join(" | ")} |`));
|
|
270
270
|
};
|
|
271
|
-
table("Attributes", ["Attribute", "
|
|
271
|
+
if (brief) table("Attributes", ["Attribute", "Type", "Description"], e.attributes.map((a) => [`\`${a.name}\``, `\`${a.type}\``, a.description]));
|
|
272
|
+
else table("Attributes", ["Attribute", "Property", "Type", "Description"], e.attributes.map((a) => [`\`${a.name}\``, `\`${a.property}\``, `\`${a.type}\``, a.description]));
|
|
272
273
|
table("Properties (no attribute)", ["Property", "Type", "Description"], e.properties.map((p) => [`\`${p.name}\``, p.type ? `\`${p.type}\`` : "", (p.readonly ? "Read-only. " : "") + p.description]));
|
|
273
274
|
table("Methods", ["Method", "Description"], e.methods.map((m) => [`\`${m.signature}\``, m.description]));
|
|
274
275
|
table("Events", ["Event", "Description"], e.events.map((ev) => [`\`${ev.name}\``, ev.description]));
|
|
275
276
|
table("Slots", ["Slot", "Description"], e.slots.map((s) => [s.name ? `\`${s.name}\`` : "(default)", s.description]));
|
|
276
|
-
|
|
277
|
-
|
|
277
|
+
if (!brief) {
|
|
278
|
+
table("CSS parts", ["Part", "Description"], e.parts.map((p) => [`\`${p.name}\``, p.description]));
|
|
279
|
+
table("CSS custom properties", ["Property", "Description"], e.cssProperties.map((p) => [`\`${p.name}\``, p.description]));
|
|
280
|
+
}
|
|
278
281
|
if (e.tag === "punica-icon") lines.push("", `### Icon names`, "", icons2.map((i) => `\`${i}\``).join(", ") + ". Any other name draws nothing: slot an `<svg>` instead.");
|
|
279
|
-
table("Custom states", ["State", "Description"], e.states.map((s) => [`\`:state(${s.name})\``, s.description]));
|
|
282
|
+
if (!brief) table("Custom states", ["State", "Description"], e.states.map((s) => [`\`:state(${s.name})\``, s.description]));
|
|
283
|
+
else if (e.parts.length || e.cssProperties.length || e.states.length) {
|
|
284
|
+
const left = [e.parts.length && `${e.parts.length} CSS parts`, e.cssProperties.length && `${e.cssProperties.length} custom properties`, e.states.length && `${e.states.length} states`].filter(Boolean);
|
|
285
|
+
lines.push("", `For styling: ${left.join(", ")}; ask for the whole API to see them.`);
|
|
286
|
+
}
|
|
280
287
|
return lines.join("\n");
|
|
281
288
|
}
|
|
282
289
|
return { elements, tags, allEvents, icons: icons2, list, get, search, legacy, formatMarkdown };
|
|
@@ -674,11 +681,14 @@ function createPunicaServer({ manifest: manifest2, guide: guide2, version: versi
|
|
|
674
681
|
"get_component",
|
|
675
682
|
{
|
|
676
683
|
title: "An element's API",
|
|
677
|
-
description: "The
|
|
678
|
-
inputSchema: {
|
|
684
|
+
description: "The API of one or more punica elements: attributes with their exact values, properties, methods, events, slots, CSS parts, custom properties and states. Pass brief: true when you write markup and do not style the inside of the element: it leaves out the parts, custom properties and states and is about a quarter shorter.",
|
|
685
|
+
inputSchema: {
|
|
686
|
+
tags: z.array(z.string()).min(1).max(12).describe("Tags such as punica-select, or bare names such as select"),
|
|
687
|
+
brief: z.boolean().optional().describe("Leave out CSS parts, custom properties and states")
|
|
688
|
+
},
|
|
679
689
|
annotations: { readOnlyHint: true }
|
|
680
690
|
},
|
|
681
|
-
async ({ tags }) => text(tags.map((tag) => knowledge.formatMarkdown(tag)).join("\n\n"))
|
|
691
|
+
async ({ tags, brief }) => text(tags.map((tag) => knowledge.formatMarkdown(tag, { brief })).join("\n\n"))
|
|
682
692
|
);
|
|
683
693
|
server2.registerTool(
|
|
684
694
|
"get_examples",
|