@zeyos/zx 2.1.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/CHANGELOG.md +74 -0
- package/LICENSE +21 -0
- package/MIGRATION.md +598 -0
- package/README.md +288 -0
- package/dist/zx-compat.esm.js +16880 -0
- package/dist/zx-compat.esm.min.js +1 -0
- package/dist/zx-compat.global.js +23068 -0
- package/dist/zx-compat.global.min.js +3 -0
- package/dist/zx-zeyos.esm.js +11581 -0
- package/dist/zx-zeyos.esm.min.js +1 -0
- package/dist/zx.css +4946 -0
- package/dist/zx.esm.js +19934 -0
- package/dist/zx.esm.min.js +3 -0
- package/dist/zx.global.js +19958 -0
- package/dist/zx.global.min.js +3 -0
- package/dist/zx.min.css +1 -0
- package/docs/api.json +5248 -0
- package/docs/llms.md +1315 -0
- package/docs/llms.txt +45 -0
- package/package.json +74 -0
package/README.md
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
# Zx
|
|
2
|
+
|
|
3
|
+
Zx is the dependency-free, vanilla-JavaScript component library for ZeyOS business applications:
|
|
4
|
+
ES2022 modules, accessible native controls, semantic design tokens, and lifecycle-safe components.
|
|
5
|
+
Source modules run directly in a browser; the distribution also provides ESM and classic-script
|
|
6
|
+
bundles. An opt-in compatibility layer keeps existing MooTools-era `gx` code running while it is
|
|
7
|
+
modernised.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
Use the ESM bundle when the application already uses modules:
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<link rel="stylesheet" href="/assets/zx.css">
|
|
15
|
+
<div id="notifications"></div>
|
|
16
|
+
|
|
17
|
+
<script type="module">
|
|
18
|
+
import { Toggle } from '/assets/zx.esm.js';
|
|
19
|
+
|
|
20
|
+
const toggle = new Toggle(null, {
|
|
21
|
+
label: 'Notifications',
|
|
22
|
+
value: 'enabled',
|
|
23
|
+
onchange: (event) => console.log(event.detail.checked)
|
|
24
|
+
});
|
|
25
|
+
document.querySelector('#notifications').append(toggle.toElement());
|
|
26
|
+
</script>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
For an application built from classic scripts, the IIFE bundle exposes the same API as
|
|
30
|
+
`window.zx`:
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
<link rel="stylesheet" href="/assets/zx.css">
|
|
34
|
+
<script src="/assets/zx.global.js"></script>
|
|
35
|
+
<script>
|
|
36
|
+
const toggle = new zx.Toggle(null, { label: 'Notifications' });
|
|
37
|
+
document.body.append(toggle.toElement());
|
|
38
|
+
</script>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Components accept an existing element or selector as their first argument. Passing `null` makes
|
|
42
|
+
the component create and own its root. Call `destroy()` when a component is no longer needed; an
|
|
43
|
+
owned root is removed, while an enhanced target is restored.
|
|
44
|
+
|
|
45
|
+
## Component index
|
|
46
|
+
|
|
47
|
+
The groups match the demo sidebar.
|
|
48
|
+
|
|
49
|
+
### Core
|
|
50
|
+
|
|
51
|
+
| API | Description |
|
|
52
|
+
| --- | --- |
|
|
53
|
+
| `Component` | Lifecycle, event, element-registry, and cleanup base class. |
|
|
54
|
+
| `defineElements()` | Registers the light-DOM `<zx-*>` wrappers for the supported declarative components. |
|
|
55
|
+
| `h()`, `icon()` | Safe DOM and icon factories used by applications and custom renderers. |
|
|
56
|
+
| `loadFontAwesome()` | Opts the icon layer into a Font Awesome kit; `useBuiltinIcons()` switches back. |
|
|
57
|
+
| `onBreakpoint()` | Named width bands, observed on an element or the window. |
|
|
58
|
+
|
|
59
|
+
The public core also includes HTTP helpers, i18n, date formatting/parsing, positioning, keyboard
|
|
60
|
+
helpers, and small dependency-free utilities; see the named exports in `src/index.js`. Alongside
|
|
61
|
+
them are locale-aware formatters (`formatNumber`, `formatCurrency`, `formatPercent`,
|
|
62
|
+
`formatFileSize`, `formatRelativeTime`), collection helpers (`groupBy`, `sortBy`, `uniqueBy`),
|
|
63
|
+
`throttle` beside `debounce`, `escapeRegExp` and `highlightMatch` for filtering lists, a
|
|
64
|
+
namespaced `storage()` view that degrades to memory when the browser refuses writes, and
|
|
65
|
+
`toCsv`/`downloadBlob`/`copyToClipboard` for exporting what a table is showing.
|
|
66
|
+
|
|
67
|
+
`icon()` renders the inline SVG glyphs Zx bundles — no webfont, stylesheet, or network request.
|
|
68
|
+
Applications that want Font Awesome call `loadFontAwesome({ kit })` once, and every icon in the
|
|
69
|
+
library follows, including names Zx maps to their Font Awesome counterparts. Names can also pick a
|
|
70
|
+
renderer themselves: `'fa:user'`, `'duotone:user'`, `'kit:zeyos-notes'`, `'builtin:check'`, or a
|
|
71
|
+
literal `'fa-solid fa-user'` class list. ZeyOS module icons and their identity colours live in the
|
|
72
|
+
ZeyOS binding — see `src/zeyos/modules.js`.
|
|
73
|
+
|
|
74
|
+
### Inputs
|
|
75
|
+
|
|
76
|
+
| API | Description |
|
|
77
|
+
| --- | --- |
|
|
78
|
+
| `button()`, `buttonGroup()` | Styled native button and grouped-button factories. |
|
|
79
|
+
| `badge()`, `badgeGroup()` | Status-pill factories with semantic kinds, variants, and sizes. |
|
|
80
|
+
| `CheckButton` | Two-state pressed button with optional state-specific labels. |
|
|
81
|
+
| `Toggle` | Native-button switch with a separate submitted value. |
|
|
82
|
+
| `Search` | Search input with debounced input, submit, and clear events. |
|
|
83
|
+
| `Select` | APG combobox with local or async filtering and a priority preset. |
|
|
84
|
+
| `Checklist` | Searchable checkbox group with optional async loading. |
|
|
85
|
+
| `TagPicker` | Multi-select combobox that keeps its selection as removable tags. |
|
|
86
|
+
| `NumberField` | APG spinbutton with step buttons, ranges, units, and wrapping. |
|
|
87
|
+
| `Rating` | Star rating as a radio group, with optional half steps. |
|
|
88
|
+
| `Slider` | Range control for a bounded numeric value, with marks and an optional number box. |
|
|
89
|
+
| `DatePicker` | APG calendar grid with bounds, week numbers, and optional time selection. |
|
|
90
|
+
| `MonthPicker` | Twelve-month grid with year navigation. |
|
|
91
|
+
| `TimePicker` | Segmented local-time picker. |
|
|
92
|
+
| `Datebox`, `DateTimeBox` | Formatted date input and its date-time factory variant. |
|
|
93
|
+
| `DateRangePicker` | Two-month range calendar with presets, night bounds, and range preview. |
|
|
94
|
+
| `DateRangeBox` | Formatted date-range input with an anchored range calendar. |
|
|
95
|
+
| `Timebox` | Segmented signed or unsigned duration input. |
|
|
96
|
+
| `copyButton()` | Button that copies a string and confirms it in place. |
|
|
97
|
+
| `CopyInput` | Read-only box holding a value to be copied, with the copy button attached. |
|
|
98
|
+
|
|
99
|
+
### Overlays
|
|
100
|
+
|
|
101
|
+
| API | Description |
|
|
102
|
+
| --- | --- |
|
|
103
|
+
| `Message` | Inline messages, floating toasts, and progress status. |
|
|
104
|
+
| `Modal` | Minimal native-dialog overlay with light-dismiss support. |
|
|
105
|
+
| `Dialog` | Titled modal with buttons, named views, alert, confirm, and prompt helpers. |
|
|
106
|
+
| `Dropdown` | Generic anchored popover with placement fallback. |
|
|
107
|
+
| `MenuButton` | APG menu button built on `Dropdown`. |
|
|
108
|
+
| `ContextMenu` | APG right-click menu for a region or, via `selector`, per row. |
|
|
109
|
+
| `Tooltip`, `tooltip()`, `describe()` | Hover/focus description bubble anchored with `position()`. |
|
|
110
|
+
|
|
111
|
+
### Data
|
|
112
|
+
|
|
113
|
+
| API | Description |
|
|
114
|
+
| --- | --- |
|
|
115
|
+
| `Table` | Semantic sortable table with local/server sorting, row selection, and opt-in inline cell/row editing. |
|
|
116
|
+
| `DataFilter` | Declarative select, text, and custom filters for client-side row sets. |
|
|
117
|
+
| `TreeView` | APG tree with lazy children, filtering, and tri-state checkboxes. |
|
|
118
|
+
| `Finder` | Miller-columns hierarchy browser with an optional preview pane. |
|
|
119
|
+
| `Pagination` | Page, page-size, and load-more pager, with the pure `paginationRange()` helper. |
|
|
120
|
+
|
|
121
|
+
### Forms
|
|
122
|
+
|
|
123
|
+
| API | Description |
|
|
124
|
+
| --- | --- |
|
|
125
|
+
| `Permission` | Private, public, or group-level permission selector. |
|
|
126
|
+
| `Field` | Label, description, validation state, and adapter-backed form control. |
|
|
127
|
+
| `Fieldset` | Native fieldset that owns and coordinates fields. |
|
|
128
|
+
| `Form` | Form composition, values, validation, highlighting, and actions. |
|
|
129
|
+
| `ValueList` | Validated, sortable tag/chip editor. |
|
|
130
|
+
| `MultiValueEditor` | Ordered editable rows with add, remove, and move controls. |
|
|
131
|
+
| `FieldUpload` | Click/drop file upload with progress, abort, validation, and preview. |
|
|
132
|
+
|
|
133
|
+
### Layout
|
|
134
|
+
|
|
135
|
+
| API | Description |
|
|
136
|
+
| --- | --- |
|
|
137
|
+
| `Groupbox` | Collapsible section backed by native `<details>`. |
|
|
138
|
+
| `Panel` | Framed, optionally collapsible section with a footer. |
|
|
139
|
+
| `MasterPanel` | Full-height application panel with fixed header actions and footer. |
|
|
140
|
+
| `Tabbox` | APG tabs in four appearances, with lazy content, closing, badges, and disabled states. |
|
|
141
|
+
| `NavigationBar` | Responsive application navigation with optional tab panels and overflow. |
|
|
142
|
+
| `Toolbar` | APG toolbar: one tab stop, arrow-key movement, and overflow into a menu. |
|
|
143
|
+
| `SplitView` | Resizable two-pane split with a keyboard-operable separator. |
|
|
144
|
+
| `Stepper` | Linear multi-step progress with completed, active, and error states. |
|
|
145
|
+
| `Breadcrumb` | Hierarchy trail with middle-collapse, pairing with `Finder` and `TreeView`. |
|
|
146
|
+
| `emptyState()` | Placeholder for an empty list, table, or panel, with optional actions. |
|
|
147
|
+
| `stack()`, `grid()`, `aspect()` | Spacing, an intrinsically reflowing grid, and a fixed-ratio box. |
|
|
148
|
+
| `spinner()` | Indeterminate activity ring for a wait of unknown length. |
|
|
149
|
+
| `ProgressBar` | Determinate progress track, with success and error states. |
|
|
150
|
+
| `InlineLoading` | Status line that resolves a wait into its outcome in place. |
|
|
151
|
+
| `skeleton()`, `skeletonText()`, `skeletonTable()` | Placeholders shaped like the content that is coming. |
|
|
152
|
+
| `truncate()` | Clamps text to a number of lines, with the full value on hover. |
|
|
153
|
+
|
|
154
|
+
## Talking to ZeyOS
|
|
155
|
+
|
|
156
|
+
Use `@zeyos/client` for ZeyOS authentication, transport, generated resource operations, and runtime
|
|
157
|
+
schema introspection. Zx adds `zx-zeyos`, a schema-driven layer above that client: inject an existing
|
|
158
|
+
client into `connect`, `zeyosTable`, `zeyosForm`, or `zeyosSelect` to generate typed tables, forms,
|
|
159
|
+
and async entity selectors from real resource metadata.
|
|
160
|
+
|
|
161
|
+
```js
|
|
162
|
+
import { createZeyosClient } from '@zeyos/client';
|
|
163
|
+
import { zeyosForm, zeyosTable } from '/assets/zx-zeyos.esm.js';
|
|
164
|
+
|
|
165
|
+
const client = createZeyosClient({ platform, auth });
|
|
166
|
+
const list = zeyosTable(client, 'transactions', {
|
|
167
|
+
fields: ['transactionnum', 'account', 'date', 'netamount', 'status']
|
|
168
|
+
});
|
|
169
|
+
await list.load();
|
|
170
|
+
|
|
171
|
+
const editor = zeyosForm(client, 'transactions', {
|
|
172
|
+
fields: ['transactionnum', 'account', 'date', 'netamount', 'status']
|
|
173
|
+
});
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
The injection design means Zx never imports or bundles `@zeyos/client`. The optional binding ships
|
|
177
|
+
separately as `dist/zx-zeyos.esm.js` and is not part of the root `src/index.js` API. See the
|
|
178
|
+
schema-driven `website/layouts/zeyos-invoices.layout.js` for list, filter, sort, edit, and create wiring.
|
|
179
|
+
|
|
180
|
+
The same entry point carries ZeyOS module identity — the icon and colour of every module, keyed by
|
|
181
|
+
module, entity, or API resource name:
|
|
182
|
+
|
|
183
|
+
```js
|
|
184
|
+
import { moduleChip, moduleColor, useZeyosIcons } from '/assets/zx-zeyos.esm.js';
|
|
185
|
+
|
|
186
|
+
await useZeyosIcons(); // loads the ZeyOS Font Awesome kit
|
|
187
|
+
nav.append(moduleChip('tickets', { size: 24, title: true }));
|
|
188
|
+
moduleColor('invoices'); // '#535494'
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
`src/zeyos/modules.js` is the configuration file behind it: one entry per module with its kit icon
|
|
192
|
+
name, identity colour, label, and a stock Font Awesome fallback. The `--zx-module-*` CSS custom
|
|
193
|
+
properties are generated from that file, so CSS and JavaScript cannot disagree about a colour.
|
|
194
|
+
|
|
195
|
+
## Themes and density
|
|
196
|
+
|
|
197
|
+
Load `zx.css` once. Zx components consume semantic `--zx-*` tokens and inherit their values from
|
|
198
|
+
the document. Select a built-in theme and density on any ancestor (normally `<html>`):
|
|
199
|
+
|
|
200
|
+
```html
|
|
201
|
+
<html data-zx-theme="dark" data-zx-density="compact">
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Theme values are `light`, `dark`, and `auto`; density values are `cozy` and `compact`. `auto`
|
|
205
|
+
follows the operating-system color preference. A product theme can override semantic tokens
|
|
206
|
+
without reaching into component CSS:
|
|
207
|
+
|
|
208
|
+
```css
|
|
209
|
+
:root[data-zx-theme="acme"] {
|
|
210
|
+
--zx-color-bg-page: #f4f1eb;
|
|
211
|
+
--zx-color-bg-surface: #fffdf8;
|
|
212
|
+
--zx-color-bg-control: #ffffff;
|
|
213
|
+
--zx-color-border-control: #978e80;
|
|
214
|
+
--zx-color-text: #26221d;
|
|
215
|
+
--zx-color-text-muted: #655e54;
|
|
216
|
+
--zx-color-accent: #176b52;
|
|
217
|
+
--zx-color-on-accent: #ffffff;
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Prefer semantic tokens such as `--zx-color-*`, `--zx-control-*`, `--zx-space-*`,
|
|
222
|
+
`--zx-radius-*`, and `--zx-text-*`. Palette tokens are implementation details and should not be
|
|
223
|
+
used by application or component CSS.
|
|
224
|
+
|
|
225
|
+
## Browser support
|
|
226
|
+
|
|
227
|
+
Zx targets current evergreen Chrome, Edge, Firefox, and Safari with browser capabilities from
|
|
228
|
+
roughly 2023 onward. It uses native `<dialog>`, the Popover API, `:has()`, container queries,
|
|
229
|
+
ES2022 modules, and abortable event listeners. No transpilation or legacy-browser polyfill bundle
|
|
230
|
+
is provided. CSS anchor positioning is used only when supported; the library otherwise uses its
|
|
231
|
+
JavaScript positioning fallback.
|
|
232
|
+
|
|
233
|
+
## Development
|
|
234
|
+
|
|
235
|
+
Install the single development dependency and start the no-build demo server:
|
|
236
|
+
|
|
237
|
+
```sh
|
|
238
|
+
npm install
|
|
239
|
+
npm run serve
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Open <http://127.0.0.1:8321/website/docs.html> for the documentation — getting started, every
|
|
243
|
+
component with a live demo and its JavaScript source, and the application layouts. Also available: <http://127.0.0.1:8321/tests/smoke/smoke.html> for source-module smoke
|
|
244
|
+
tests, or build first and open <http://127.0.0.1:8321/tests/smoke/smoke-dist.html> for
|
|
245
|
+
classic-script distribution tests.
|
|
246
|
+
|
|
247
|
+
```sh
|
|
248
|
+
npm test # Node unit tests plus semantic-token lint
|
|
249
|
+
npm run build # writes ESM, global, compatibility, and CSS assets to dist/
|
|
250
|
+
npm run build:site # assembles the deployable documentation site into site/
|
|
251
|
+
npm run serve:site # serves site/ exactly as it will be deployed
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Installing
|
|
255
|
+
|
|
256
|
+
```sh
|
|
257
|
+
npm install @zeyos/zx
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
```js
|
|
261
|
+
import { Table, Message } from '@zeyos/zx';
|
|
262
|
+
import '@zeyos/zx/zx.css';
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
Additional entry points: `@zeyos/zx/zeyos` (the schema-driven ZeyOS binding), `@zeyos/zx/compat`
|
|
266
|
+
(the gx compatibility namespace), and `@zeyos/zx/global` for classic script tags.
|
|
267
|
+
|
|
268
|
+
Documentation lives at <https://zx.zeyos.com>; see `docs/RELEASING.md` for how the site and the
|
|
269
|
+
package are published.
|
|
270
|
+
|
|
271
|
+
## `gx` compatibility layer
|
|
272
|
+
|
|
273
|
+
During an incremental migration, load the global API before the compatibility bundle:
|
|
274
|
+
|
|
275
|
+
```html
|
|
276
|
+
<link rel="stylesheet" href="/assets/zx.css">
|
|
277
|
+
<script src="/assets/zx.global.js"></script>
|
|
278
|
+
<script src="/assets/zx-compat.global.js"></script>
|
|
279
|
+
<script>
|
|
280
|
+
// Only when old code relies on __(), _(), or prototype conveniences:
|
|
281
|
+
gx.compat.installGlobals();
|
|
282
|
+
</script>
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
The compatibility bundle always exposes `window.gx` and installs only the element
|
|
286
|
+
`store`/`retrieve`/`eliminate` shim automatically. Legacy globals and prototype conveniences are
|
|
287
|
+
an explicit opt-in through `gx.compat.installGlobals()`. See [MIGRATION.md](./MIGRATION.md) for
|
|
288
|
+
class mappings, script replacement, deliberate behavior changes, and unsupported legacy APIs.
|