@voidable/ui-liveview 0.10.0 → 0.12.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 +23 -1
- package/dist/index.js +2 -30
- package/llms.txt +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -98,7 +98,7 @@ losing a key: nothing typed is lost and focus stays in the field.
|
|
|
98
98
|
|
|
99
99
|
## Charts and gauges
|
|
100
100
|
|
|
101
|
-
The charts take their data as a
|
|
101
|
+
The charts take their data as the JSON `data` attribute (a gauge's `zones` too), so the first, static render already contains it and the chart draws with no script and no hook. The `bar_chart`, `line_chart`, `donut_chart` and `gauge` components encode `data` (and `zones`) for you from maps and lists. Render new data and the chart animates to it; an unchanged value leaves the attribute alone and does not animate again. Each chart carries a visually hidden data table captioned with `aria_label` (the drawing is hidden from assistive technology); `show_table` shows it below the chart.
|
|
102
102
|
|
|
103
103
|
```heex
|
|
104
104
|
<.bar_chart id="revenue" data={%{labels: ["Q1", "Q2"], series: [%{name: "2025", values: [4, 8]}]}} aria_label="Revenue by quarter" />
|
|
@@ -126,6 +126,28 @@ and `maxlength` (and `pattern` on the single-line inputs); `inputmode`,
|
|
|
126
126
|
attributes. `number_input` accepts `step="any"` and decimal `value`, `min`
|
|
127
127
|
and `max`, and `stat` takes `description`.
|
|
128
128
|
|
|
129
|
+
## Testing
|
|
130
|
+
|
|
131
|
+
`Phoenix.LiveViewTest` sees the server-rendered markup before any component script runs, so there is nothing to wait for: assert on markup (`has_element?(view, "void-switch[checked]")`). For behaviour in a browser (Wallaby, Playwright), load `@voidable/ui/testing` in the test build, which sets `data-void-ready` on `<html>` while the components are defined and rendered, and turn motion off with `data-anim-speed="off"` on `<html>`:
|
|
132
|
+
|
|
133
|
+
```elixir
|
|
134
|
+
# config/test.exs
|
|
135
|
+
config :my_app, anim_speed: "off"
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
```heex
|
|
139
|
+
<html lang="en" data-anim-speed={Application.get_env(:my_app, :anim_speed)}>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
```elixir
|
|
143
|
+
session
|
|
144
|
+
|> visit("/settings")
|
|
145
|
+
|> assert_has(Query.css("html[data-void-ready]"))
|
|
146
|
+
|> click(Query.button("Save"))
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
A toast still closes after its `duration` with animation off: it is a timer. See [Testing](https://voidable.dev/guides/testing/).
|
|
150
|
+
|
|
129
151
|
## For AI agents
|
|
130
152
|
|
|
131
153
|
`@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,36 +43,8 @@ var a = { VoidEvent: {
|
|
|
43
43
|
destroyed() {
|
|
44
44
|
this._destroyed = !0, i(this);
|
|
45
45
|
}
|
|
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) {
|
|
46
|
+
} }, o = { onBeforeElUpdated(e, t) {
|
|
75
47
|
e.tagName?.startsWith("VOID-") && (t.hasAttribute?.("data-phx-skip") || e.voidBeforeMorph?.(t));
|
|
76
48
|
} };
|
|
77
49
|
//#endregion
|
|
78
|
-
export {
|
|
50
|
+
export { o as VoidDOM, a as VoidHooks };
|
package/llms.txt
CHANGED
|
@@ -16,7 +16,7 @@ new LiveSocket('/live', Socket, { hooks: { ...VoidHooks }, dom: VoidDOM });
|
|
|
16
16
|
|
|
17
17
|
## API
|
|
18
18
|
|
|
19
|
-
- `VoidHooks`: LiveView hooks. `
|
|
19
|
+
- `VoidHooks`: LiveView hooks. `VoidEvent` pushes the Voidable events an element opted in to (`events` on the HEEx component) as LiveView events. Chart data needs no hook: the HEEx chart components render it as the JSON `data` attribute.
|
|
20
20
|
- `VoidDOM`: the `dom` option (`onBeforeElUpdated`); keeps client state across LiveView patches.
|
|
21
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
22
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voidable/ui-liveview",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Phoenix LiveView hooks for Voidable UI web components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"phoenix",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
],
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"phoenix_live_view": ">=1.0.0",
|
|
33
|
-
"@voidable/ui": "0.
|
|
33
|
+
"@voidable/ui": "0.12.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"typescript": "^6.0.0",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"vitest": "^3.1.0",
|
|
40
40
|
"@vitest/coverage-v8": "3.2.4",
|
|
41
41
|
"happy-dom": "^17.0.0",
|
|
42
|
-
"@voidable/ui": "0.
|
|
42
|
+
"@voidable/ui": "0.12.0"
|
|
43
43
|
},
|
|
44
44
|
"repository": {
|
|
45
45
|
"type": "git",
|