jsswift 1.0.47 → 1.0.49
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/AI.md +95 -0
- package/README.md +7 -0
- package/dist/documentions/AI.md +12 -2
- package/dist/documentions/README.md +1 -1
- package/dist/documentions/components/input.md +448 -45
- package/dist/documentions/components/select.md +439 -51
- package/dist/documentions/examples/crud.md +62 -0
- package/dist/documentions/knowledge-map.json +17 -2
- package/dist/jsswift.js +26 -0
- package/dist/jsswift.min.js +3 -3
- package/dist/min-jsswift.js +3 -3
- package/package.json +10 -3
package/AI.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# JSswift AI quick start
|
|
2
|
+
|
|
3
|
+
Start here for a small page using Input, Select, Button, Card, Table, and Dialog. The example and callback table below are a supported subset; read a component contract only when using additional APIs. Do not read the whole catalog or search runtime bundles for documentation. Button’s full contract is `components/btn.md`; `components/button.md` redirects to it.
|
|
4
|
+
|
|
5
|
+
## Reading budget and discovery
|
|
6
|
+
|
|
7
|
+
Read this guide alone first and implement its supported APIs directly. Do not pre-read the six linked component contracts to confirm this example. Do not concatenate the guide and the component catalog in one command.
|
|
8
|
+
|
|
9
|
+
If a required API is absent here, consult `knowledge-map.json` to find its exact path, then read only that document. The map routes requests; it does not contain component API definitions. With an already configured MCP, read `guide:AI`, then use `jsswift_search` for the missing feature and `jsswift_read` for its result. MCP setup is optional; local files are sufficient.
|
|
10
|
+
|
|
11
|
+
The installed package exposes this same guide as `AI.md` at its root and through `jsswift/AI.md`. `package.json` includes `jsswiftDocumentation` discovery paths. Do not inspect runtime bundles to discover documented APIs.
|
|
12
|
+
|
|
13
|
+
## Import, create, mount
|
|
14
|
+
|
|
15
|
+
Provide `<div id="app"></div>` in HTML and a module entrypoint. With Vite:
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import 'jsswift';
|
|
19
|
+
import 'jsswift/css/ui.css';
|
|
20
|
+
const _ = window._;
|
|
21
|
+
|
|
22
|
+
const name = _.rod('Prodotto 01');
|
|
23
|
+
const category = _.rod('Casa');
|
|
24
|
+
const nameInput = _.Input({ label: 'Nome prodotto', model: name });
|
|
25
|
+
const categorySelect = _.Select({
|
|
26
|
+
label: 'Categoria', model: category,
|
|
27
|
+
options: [{ value: 'Casa', label: 'Casa' }, { value: 'Ufficio', label: 'Ufficio' }]
|
|
28
|
+
});
|
|
29
|
+
const errors = _.div({ role: 'alert' });
|
|
30
|
+
const dialog = _.Dialog({
|
|
31
|
+
title: 'Modifica prodotto', ariaLabel: 'Modifica prodotto',
|
|
32
|
+
content: _.div({}, nameInput, categorySelect, errors),
|
|
33
|
+
closeOnEsc: true, trapFocus: true, autoFocus: true
|
|
34
|
+
});
|
|
35
|
+
const save = _.Button({ color: 'primary', onClick: () => {
|
|
36
|
+
if (!name.value.trim()) {
|
|
37
|
+
errors.replaceChildren(_.p('Il nome è obbligatorio.'));
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
errors.replaceChildren();
|
|
41
|
+
console.log({ name: name.value, category: category.value });
|
|
42
|
+
dialog.close();
|
|
43
|
+
}}, 'Salva');
|
|
44
|
+
dialog.update({ actions: [
|
|
45
|
+
_.Button({ onClick: () => dialog.close() }, 'Annulla'), save
|
|
46
|
+
] });
|
|
47
|
+
const edit = _.Button({ onClick: () => dialog.open() }, 'Modifica');
|
|
48
|
+
const table = _.Table({
|
|
49
|
+
rows: [{ id: 1, name: 'Prodotto 01', price: 10 }], rowKey: 'id',
|
|
50
|
+
columns: [
|
|
51
|
+
{ key: 'name', label: 'Nome', render: (row, { value }) => _.strong(value) },
|
|
52
|
+
{ key: 'price', label: 'Prezzo', format: value => `${value} EUR` }
|
|
53
|
+
],
|
|
54
|
+
pagination: false, hideFooter: true, minTableWidth: 700
|
|
55
|
+
});
|
|
56
|
+
const page = _.Page({}, _.Card({ title: 'Prodotti' }, edit, table));
|
|
57
|
+
_.mount('#app', page);
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
This demonstrates composition and validation; saving logs the values. Add application persistence and refresh the table when your task requires them. Prefer `_.rod(initial)` for bidirectional field models: read `name.value`, write `name.value = 'Nuovo nome'`; `model` synchronizes the control. Use `_.signal(initial)` when explicit getter/setter functions suit the state, and `_.useForm()` for structured form validation and errors. This avoids reading private `_input` or `_select` references. Input and Select expose `focus(options?)`; read and write values through the rod model. Use `ariaLabel`, `ariaLabelledBy`, `ariaDescribedBy`, `ariaInvalid` and `required` on the control. Input also accepts `min`, `max`, `step`, `pattern`, `minLength` and `maxLength`.
|
|
61
|
+
|
|
62
|
+
## Exact callback arguments
|
|
63
|
+
|
|
64
|
+
| API | Arguments |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| Input `onInput`, `onChange` | `(value)`; text value is a string. No DOM event argument is passed by Input. |
|
|
67
|
+
| Select `onChange` | `(value)`; single selection emits its option value; multiple selection emits an array. |
|
|
68
|
+
| Button `onClick` | DOM click event. |
|
|
69
|
+
| Table column `render` | `(row, cellContext)`; read `cellContext.value`. |
|
|
70
|
+
| Table column `format` | `(value, row, cellContext)`. |
|
|
71
|
+
| Table `actions` | `(row, rowContext)`. |
|
|
72
|
+
| Dialog `onOpen` | Overlay entry. |
|
|
73
|
+
| Dialog `onClose` | No arguments. |
|
|
74
|
+
|
|
75
|
+
Dialog returns an API object, not a node to mount: `open(overrides?)`, `close()`, `toggle(overrides?)`, `update(props)`, `isOpen()`, `entry()`, `props()`.
|
|
76
|
+
|
|
77
|
+
## Existing CSS and optional assets
|
|
78
|
+
|
|
79
|
+
The UI stylesheet includes component styles, theme variables, and responsive rules. Start with native components. Prefer documented `color`, `dense`, `padding`, `radius`, `shadow`, and breakpoint props to overrides of internal `.cms-*` classes. Read [common props](ui/common-props.md) once when styling; component-specific definitions take precedence. Use custom CSS for remaining page requirements.
|
|
80
|
+
|
|
81
|
+
System fonts are the default. Import `jsswift/css/fonts-nunito.css`, `jsswift/css/fonts-material.css`, or `jsswift/tabler` only when required; Material Symbols loads a remote Google font. See [setup](getting-started.md).
|
|
82
|
+
|
|
83
|
+
## Accessibility and verification
|
|
84
|
+
|
|
85
|
+
Input and Select use a string `label` as their default accessible name; use `ariaLabel` for a different name or `ariaLabelledBy` for an external label. Verify rendered names when using custom label nodes. Set Dialog `ariaLabel` explicitly. Dialog normally restores the original focus element; if the app replaces that element, restore focus to its current replacement using a stable application identifier in `onClose`. Do not claim these behaviors were tested from a build alone.
|
|
86
|
+
|
|
87
|
+
Run the app's build after implementation and check values, validation, dialog keyboard behavior, and persistence when required. Start one development server on an explicit available port; with Vite use `npm run dev -- --port <port> --strictPort`. Report checks actually performed.
|
|
88
|
+
|
|
89
|
+
## Read only what the task needs
|
|
90
|
+
|
|
91
|
+
- Exact APIs: [Input](components/input.md), [Select](components/select.md), [Button](components/btn.md), [Card](components/card.md), [Table](components/table.md), [Dialog](components/dialog.md).
|
|
92
|
+
- Extra behavior: [forms](ui/forms.md), [reactivity](reactivity.md), [layout](ui/layout-and-responsive.md), [overlays](ui/data-feedback-overlays.md).
|
|
93
|
+
- Other components: [index](components/README.md). MCP: read `guide:AI`, then search only for additional features.
|
|
94
|
+
|
|
95
|
+
For a complete application flow, read [the compact CRUD example](examples/crud.md) only when the task needs editing, validation, persistence and focus restoration together.
|
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# JSswift
|
|
2
|
+
|
|
3
|
+
Start with [AI.md](AI.md) for imports, field models with `_.rod()`, Input, Select, Button, Card, Table and Dialog. Use its supported examples directly before reading other contracts.
|
|
4
|
+
|
|
5
|
+
For an API absent from that guide, use [knowledge-map.json](dist/documentions/knowledge-map.json) to locate the exact document. Read only the relevant contract; avoid concatenating the component catalog or searching runtime bundles for documentation.
|
|
6
|
+
|
|
7
|
+
Import `jsswift` and `jsswift/css/ui.css`. Component CSS is included; fonts and Tabler are optional. The read-only `@jsswift/knowledge-mcp` is an optional discovery interface when configured in your AI client.
|
package/dist/documentions/AI.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Start here for a small page using Input, Select, Button, Card, Table, and Dialog. The example and callback table below are a supported subset; read a component contract only when using additional APIs. Do not read the whole catalog or search runtime bundles for documentation. Button’s full contract is `components/btn.md`; `components/button.md` redirects to it.
|
|
4
4
|
|
|
5
|
+
## Reading budget and discovery
|
|
6
|
+
|
|
7
|
+
Read this guide alone first and implement its supported APIs directly. Do not pre-read the six linked component contracts to confirm this example. Do not concatenate the guide and the component catalog in one command.
|
|
8
|
+
|
|
9
|
+
If a required API is absent here, consult `knowledge-map.json` to find its exact path, then read only that document. The map routes requests; it does not contain component API definitions. With an already configured MCP, read `guide:AI`, then use `jsswift_search` for the missing feature and `jsswift_read` for its result. MCP setup is optional; local files are sufficient.
|
|
10
|
+
|
|
11
|
+
The installed package exposes this same guide as `AI.md` at its root and through `jsswift/AI.md`. `package.json` includes `jsswiftDocumentation` discovery paths. Do not inspect runtime bundles to discover documented APIs.
|
|
12
|
+
|
|
5
13
|
## Import, create, mount
|
|
6
14
|
|
|
7
15
|
Provide `<div id="app"></div>` in HTML and a module entrypoint. With Vite:
|
|
@@ -49,7 +57,7 @@ const page = _.Page({}, _.Card({ title: 'Prodotti' }, edit, table));
|
|
|
49
57
|
_.mount('#app', page);
|
|
50
58
|
```
|
|
51
59
|
|
|
52
|
-
This demonstrates composition and validation; saving logs the values. Add application persistence and refresh the table when your task requires them. Prefer `_.rod(initial)` for bidirectional field models: read `name.value`, write `name.value = 'Nuovo nome'`; `model` synchronizes the control. Use `_.signal(initial)` when explicit getter/setter functions suit the state, and `_.useForm()` for structured form validation and errors. This avoids reading private `_input` or `_select` references.
|
|
60
|
+
This demonstrates composition and validation; saving logs the values. Add application persistence and refresh the table when your task requires them. Prefer `_.rod(initial)` for bidirectional field models: read `name.value`, write `name.value = 'Nuovo nome'`; `model` synchronizes the control. Use `_.signal(initial)` when explicit getter/setter functions suit the state, and `_.useForm()` for structured form validation and errors. This avoids reading private `_input` or `_select` references. Input and Select expose `focus(options?)`; read and write values through the rod model. Use `ariaLabel`, `ariaLabelledBy`, `ariaDescribedBy`, `ariaInvalid` and `required` on the control. Input also accepts `min`, `max`, `step`, `pattern`, `minLength` and `maxLength`.
|
|
53
61
|
|
|
54
62
|
## Exact callback arguments
|
|
55
63
|
|
|
@@ -74,7 +82,7 @@ System fonts are the default. Import `jsswift/css/fonts-nunito.css`, `jsswift/cs
|
|
|
74
82
|
|
|
75
83
|
## Accessibility and verification
|
|
76
84
|
|
|
77
|
-
|
|
85
|
+
Input and Select use a string `label` as their default accessible name; use `ariaLabel` for a different name or `ariaLabelledBy` for an external label. Verify rendered names when using custom label nodes. Set Dialog `ariaLabel` explicitly. Dialog normally restores the original focus element; if the app replaces that element, restore focus to its current replacement using a stable application identifier in `onClose`. Do not claim these behaviors were tested from a build alone.
|
|
78
86
|
|
|
79
87
|
Run the app's build after implementation and check values, validation, dialog keyboard behavior, and persistence when required. Start one development server on an explicit available port; with Vite use `npm run dev -- --port <port> --strictPort`. Report checks actually performed.
|
|
80
88
|
|
|
@@ -83,3 +91,5 @@ Run the app's build after implementation and check values, validation, dialog ke
|
|
|
83
91
|
- Exact APIs: [Input](components/input.md), [Select](components/select.md), [Button](components/btn.md), [Card](components/card.md), [Table](components/table.md), [Dialog](components/dialog.md).
|
|
84
92
|
- Extra behavior: [forms](ui/forms.md), [reactivity](reactivity.md), [layout](ui/layout-and-responsive.md), [overlays](ui/data-feedback-overlays.md).
|
|
85
93
|
- Other components: [index](components/README.md). MCP: read `guide:AI`, then search only for additional features.
|
|
94
|
+
|
|
95
|
+
For a complete application flow, read [the compact CRUD example](examples/crud.md) only when the task needs editing, validation, persistence and focus restoration together.
|
|
@@ -19,6 +19,6 @@ Build applications with JSswift by reading only the smallest focused guide. Exac
|
|
|
19
19
|
|
|
20
20
|
For styling, begin with [application-rules.md](application-rules.md): JSswift includes component CSS; prefer documented props and theme variables before custom overrides.
|
|
21
21
|
|
|
22
|
-
Rules: use `_` as the single application namespace; prefer documented `_.Component` UI components; use only documented component APIs;
|
|
22
|
+
Rules: use `_` as the single application namespace; prefer documented `_.Component` UI components; use only documented component APIs; prefer `_.rod()` for field models and use documented model contracts; write mobile-first root props with tablet from 768px and pc from 1024px; use raw helpers only for small structural gaps.
|
|
23
23
|
|
|
24
24
|
For framework maintenance, builds, tests, or releases, read [../docDevelop/README.md](../docDevelop/README.md).
|