@hozu/cli 0.20.2 → 0.21.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.
@@ -13,25 +13,33 @@ export const Board = ui.view({
13
13
  - **Classes:** `class` is a static string of Tailwind classes that must exist (HZ026); conditional classes:
14
14
  `toggle: { 'bg-indigo-600 text-white': ctx.tab === t }`. No `style`.
15
15
  - **Conditions:** `ctx.error !== null && ui.p({ role: 'alert' }, [ctx.error])`, `item.done ? 'done' : 'open'`.
16
- By machine state: `when(['adding', 'saving'], [ui.p({}, ['Saving…'])])`; as a value (attributes): `disabled: is(['saving'])`.
16
+ By machine state: `is(['paused']) ? resume : pause`, `!is(['idle']) && ui.p({}, ['Saving…'])`,
17
+ `disabled: is(['saving'])` (keep a control and disable it rather than hide it while busy: no flash).
17
18
  - **Dialogs, popovers, menus:** native, no machine state: `ui.button({ commandfor: 'd', command: 'show-modal' })` +
18
19
  `ui.dialog({ id: 'd', closedby: 'any' }, [...])`, `popover` / `popovertarget`, `ui.details`.
19
20
  - **Lists:** `ui.each(items, 'id', (item) => ui.li({}, [item.title]))`. Never `.map` over data.
20
21
  - **Numbers and dates:** `ui.format.number(q.price, { style: 'currency', currency: 'USD' })`, `ui.format.date(x,
21
22
  { dateStyle: 'medium' })`, `ui.format.relative(n, 'day')`, `ui.format.list(xs)` (Intl, the page's locale).
22
23
  - **Events:** `on: { click: ui.send(Event, payload) }`; payload fields are literals, data, `ui.dom.value`,
23
- `ui.dom.form('name')` (submit; `hozu docs forms`).
24
+ `ui.dom.form('name')` (submit; `hozu docs forms`). A control that only sets a context field:
25
+ `on: { click: ui.set(ctx.open, !ctx.open) }`, `on: { input: ui.set(ctx.q, ui.dom.value) }` (no event to declare).
24
26
  - **Links:** `ui.a({ href: ui.link(itemPage, { id: item.id }) }, [...])`; never a string path (HZ032).
25
27
  - **Data:** `ui.query(listItems, input, { ready: (items) => …, failed: { NotFound: () => …, Unexpected: () => … } })`;
26
- `failed` lists every declared error plus `Unexpected`.
28
+ `failed` lists every declared error plus `Unexpected`. When the input changes, the rows stay (`aria-busy` on the
29
+ parent) and update by key; `pending` shows only before the first answer.
27
30
  - **Shared UI** (buttons, inputs, fields): `ui.use(Button, { variant, props, on }, ['Save'])` of a kit component
28
31
  (`hozu docs components`).
29
32
 
30
33
  <!-- more -->
31
34
 
35
+ - **Motion:** what an update adds fades in by itself (not with reduced motion); a view two pages show stays still
36
+ across a page change. `hozu browse` reports a flash or a layout shift: fix those.
32
37
  - **Attributes:** HTML names in lower case (`for`, `minlength`, `aria-pressed`, `data-x`), typed per tag. Values are
33
38
  literals or data: `'aria-pressed': ctx.show === 'all'`, `title: ctx.error ?? 'OK'`.
34
- - **CSS variables:** `vars: { '--hue': item.hue }`.
39
+ - **Sizes and colours from data:** `vars` with an arbitrary-value class: `class: 'w-[calc(var(--pct)*1%)]'`,
40
+ `vars: { '--pct': q.share }`; `class: 'bg-(--c)'`, `vars: { '--c': tag.color }`.
41
+ - **Computed attributes:** a `fn` returns any value, an SVG path too: `ui.path({ d: sparkline({ points: q.history }) })`
42
+ (runs on the server, and in the browser inside an island).
35
43
  - **More conditions:** `list.length === 0 ? ui.p({}, ['Empty']) : ui.ul({}, [...])`; a `?:` / `&&` branch may be a list:
36
44
  `open ? [a, b] : null`. A query branch or an each item returns one node: wrap several in an element (HZ014).
37
45
  With an enter/leave animation: `ui.if(cond, [then], [else], 'fade')` (the motion name is required).
@@ -49,5 +57,9 @@ export const Board = ui.view({
49
57
  - **More data:** `pending: ui.p({}, ['Loading…'])` is optional; a branch may return `null` to render nothing.
50
58
  Server-fetched data is sent with the page and never fetched again; after a mutation, queries whose tags it
51
59
  invalidates refresh in place.
60
+ - **From Vue or React:** `computed` → a `fn`; `ref` + `@click` → a context field + `ui.set`; `v-if` → `?:` / `&&`
61
+ (with `is([...])` for a machine state); `v-for` + `:key` → `ui.each(list, 'id', …)`; `setInterval` → `after` with
62
+ `refresh` (`hozu docs machine`); `watch` → a transition's `assign`; DOM libraries (charts, maps) → a client component
63
+ (`hozu docs components`; `examples/showcase` has a Chart.js one).
52
64
  - **Also:** `ui.html(post.html)` (trusted HTML from query data only, HZ030), `ui.asset(new URL('./x.png',
53
65
  import.meta.url))`, `ui.window({ on })` / `ui.document({ on })`, `ui.embed(OtherView)`.