@voidable/ui-liveview 0.8.0 → 0.9.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/README.md +18 -0
- package/dist/index.js +30 -2
- package/llms.txt +25 -0
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -96,6 +96,20 @@ A patch that arrives while the user types (the echo of an earlier
|
|
|
96
96
|
and the clone LiveView patches while it waits for a reply is put back without
|
|
97
97
|
losing a key: nothing typed is lost and focus stays in the field.
|
|
98
98
|
|
|
99
|
+
## Charts and gauges
|
|
100
|
+
|
|
101
|
+
The charts take their data as a property of the element, which markup cannot set. The `bar_chart`, `line_chart`, `donut_chart` and `gauge` components encode `data` (and a gauge's `zones`) as JSON in `data-void-props` and attach the `VoidProps` hook from `VoidHooks`, which assigns each key to the element once it is defined. Render new data and the chart animates to it; an unchanged value assigns nothing. The first, static render is an empty element: the chart draws when the socket connects.
|
|
102
|
+
|
|
103
|
+
```heex
|
|
104
|
+
<.bar_chart id="revenue" data={%{labels: ["Q1", "Q2"], series: [%{name: "2025", values: [4, 8]}]}} aria_label="Revenue by quarter" />
|
|
105
|
+
<.line_chart id="visits" data={@visits} interpolation="step" aria_label="Visitors per day" />
|
|
106
|
+
<.donut_chart id="sources" data={%{segments: [%{name: "Search", value: 40}]}} show_total aria_label="Traffic by source" />
|
|
107
|
+
<.gauge id="disk" value={42} unit="%" aria_label="Disk usage" />
|
|
108
|
+
<.gauge id="storage" data={%{segments: [%{name: "Used", value: 40}]}} aria_label="Storage" />
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
A gauge with a single `value` is plain attributes and needs no hook. Pass an `id` when you render several charts on one page. Set `aria_label` and state the key figures in the text around the chart.
|
|
112
|
+
|
|
99
113
|
## Booleans
|
|
100
114
|
|
|
101
115
|
Every boolean is off when it is absent. Something drawn by default is
|
|
@@ -111,3 +125,7 @@ and `maxlength` (and `pattern` on the single-line inputs); `inputmode`,
|
|
|
111
125
|
`enterkeyhint`, `autocapitalize` and `spellcheck` pass through as global
|
|
112
126
|
attributes. `number_input` accepts `step="any"` and decimal `value`, `min`
|
|
113
127
|
and `max`, and `stat` takes `description`.
|
|
128
|
+
|
|
129
|
+
## For AI agents
|
|
130
|
+
|
|
131
|
+
`@voidable/ui-liveview/llms.txt` (npm) and `llms.txt` in the `live_voidable` Hex package summarise this adapter's API, including every HEEx component. Every element's parts, attributes and events are in `@voidable/ui/reference.md` (`node_modules/@voidable/ui/dist/reference.md`).
|
package/dist/index.js
CHANGED
|
@@ -43,8 +43,36 @@ var a = { VoidEvent: {
|
|
|
43
43
|
destroyed() {
|
|
44
44
|
this._destroyed = !0, i(this);
|
|
45
45
|
}
|
|
46
|
-
} }
|
|
46
|
+
} };
|
|
47
|
+
function o(e) {
|
|
48
|
+
let t = e.el.dataset.voidProps ?? null;
|
|
49
|
+
if (t === e._applied || (e._applied = t, !t)) return;
|
|
50
|
+
let n;
|
|
51
|
+
try {
|
|
52
|
+
n = JSON.parse(t);
|
|
53
|
+
} catch {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
let r = () => {
|
|
57
|
+
if (!(e._destroyed || e._applied !== t)) for (let [t, r] of Object.entries(n)) e.el[t] = r;
|
|
58
|
+
};
|
|
59
|
+
customElements.get(e.el.localName) ? r() : customElements.whenDefined(e.el.localName).then(r);
|
|
60
|
+
}
|
|
61
|
+
a.VoidProps = {
|
|
62
|
+
mounted() {
|
|
63
|
+
this._destroyed = !1, this._applied = void 0, o(this);
|
|
64
|
+
},
|
|
65
|
+
updated() {
|
|
66
|
+
o(this);
|
|
67
|
+
},
|
|
68
|
+
destroyed() {
|
|
69
|
+
this._destroyed = !0;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/dom.ts
|
|
74
|
+
var s = { onBeforeElUpdated(e, t) {
|
|
47
75
|
e.tagName?.startsWith("VOID-") && (t.hasAttribute?.("data-phx-skip") || e.voidBeforeMorph?.(t));
|
|
48
76
|
} };
|
|
49
77
|
//#endregion
|
|
50
|
-
export {
|
|
78
|
+
export { s as VoidDOM, a as VoidHooks };
|
package/llms.txt
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# @voidable/ui-liveview
|
|
2
|
+
|
|
3
|
+
> Phoenix LiveView hooks for Voidable UI web components. The Hex package `live_voidable` renders the elements as HEEx components; this npm package is the client half.
|
|
4
|
+
|
|
5
|
+
## Install and use
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @voidable/ui @voidable/theme @voidable/ui-liveview
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
import { VoidHooks, VoidDOM } from '@voidable/ui-liveview';
|
|
13
|
+
|
|
14
|
+
new LiveSocket('/live', Socket, { hooks: { ...VoidHooks }, dom: VoidDOM });
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## API
|
|
18
|
+
|
|
19
|
+
- `VoidHooks`: LiveView hooks. `VoidProps` sets element properties (such as chart `data`) from JSON the HEEx components render. `VoidEvent` pushes the Voidable events an element opted in to (`events` on the HEEx component) as LiveView events.
|
|
20
|
+
- `VoidDOM`: the `dom` option (`onBeforeElUpdated`); keeps client state across LiveView patches.
|
|
21
|
+
- LiveView's own bindings (`phx-click`, `phx-change`, `phx-submit`) work on the components first; use `events` only for an event no binding covers.
|
|
22
|
+
|
|
23
|
+
## Full reference
|
|
24
|
+
|
|
25
|
+
Every `<void-*>` element (parts, attributes with allowed values, events with `detail`, examples) is in the core package: `@voidable/ui/reference.md` (`node_modules/@voidable/ui/dist/reference.md`), summarised in `@voidable/ui/llms.txt`. Online: https://voidable.dev/llms.txt. Offline per element: `voidable ref <tag>`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voidable/ui-liveview",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Phoenix LiveView hooks for Voidable UI web components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"phoenix",
|
|
@@ -21,14 +21,16 @@
|
|
|
21
21
|
".": {
|
|
22
22
|
"types": "./dist/index.d.ts",
|
|
23
23
|
"default": "./dist/index.js"
|
|
24
|
-
}
|
|
24
|
+
},
|
|
25
|
+
"./llms.txt": "./llms.txt"
|
|
25
26
|
},
|
|
26
27
|
"files": [
|
|
27
|
-
"dist"
|
|
28
|
+
"dist",
|
|
29
|
+
"llms.txt"
|
|
28
30
|
],
|
|
29
31
|
"peerDependencies": {
|
|
30
32
|
"phoenix_live_view": ">=1.0.0",
|
|
31
|
-
"@voidable/ui": "0.
|
|
33
|
+
"@voidable/ui": "0.9.0"
|
|
32
34
|
},
|
|
33
35
|
"devDependencies": {
|
|
34
36
|
"typescript": "^6.0.0",
|
|
@@ -37,7 +39,7 @@
|
|
|
37
39
|
"vitest": "^3.1.0",
|
|
38
40
|
"@vitest/coverage-v8": "3.2.4",
|
|
39
41
|
"happy-dom": "^17.0.0",
|
|
40
|
-
"@voidable/ui": "0.
|
|
42
|
+
"@voidable/ui": "0.9.0"
|
|
41
43
|
},
|
|
42
44
|
"repository": {
|
|
43
45
|
"type": "git",
|