xote 7.0.0 → 7.1.0-beta.2
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 +19 -0
- package/dist/{RuntimeJsxProp.res-A6N-qWoK.js → RuntimeJsxProp.res-gr8AK5hj.js} +1 -1
- package/dist/{RuntimeJsxProp.res-D3W5GXqT.mjs → RuntimeJsxProp.res-k7-PNxKK.mjs} +1 -1
- package/dist/{View.res-SuqJrQPC.mjs → View.res-3LSynUOy.mjs} +260 -207
- package/dist/View.res-DhZkE_sC.js +1 -0
- package/dist/client.cjs +1 -1
- package/dist/client.mjs +2 -2
- package/dist/hydration.cjs +1 -1
- package/dist/hydration.mjs +1 -1
- package/dist/mdx.cjs +1 -1
- package/dist/mdx.mjs +1 -1
- package/dist/router.cjs +1 -1
- package/dist/router.mjs +2 -2
- package/dist/xote.cjs +1 -1
- package/dist/xote.mjs +397 -344
- package/dist/xote.umd.js +1 -1
- package/package.json +9 -3
- package/ppx/LICENSE.OCaml +548 -0
- package/ppx/README.md +308 -0
- package/ppx/build.sh +10 -0
- package/ppx/ppx.ml +1363 -0
- package/src/View.res +69 -0
- package/src/View.res.mjs +68 -0
- package/dist/View.res-C36--SJD.js +0 -1
package/README.md
CHANGED
|
@@ -204,6 +204,25 @@ let todos = Signal.make([
|
|
|
204
204
|
</p>
|
|
205
205
|
```
|
|
206
206
|
|
|
207
|
+
### Auto-tracked Blocks
|
|
208
|
+
|
|
209
|
+
When a block of UI depends on several signals at once, `View.tracked` lets you read them inline — every signal read while the body runs subscribes the block automatically, and the block re-renders when any of them changes:
|
|
210
|
+
|
|
211
|
+
```rescript
|
|
212
|
+
let loggedIn = Signal.make(false)
|
|
213
|
+
let name = Signal.make("Ada")
|
|
214
|
+
|
|
215
|
+
{View.tracked(() =>
|
|
216
|
+
if Signal.get(loggedIn) {
|
|
217
|
+
<p> <View.Text> {`Hello, ${Signal.get(name)}`} </View.Text> </p>
|
|
218
|
+
} else {
|
|
219
|
+
<p> <View.Text> "Please log in" </View.Text> </p>
|
|
220
|
+
}
|
|
221
|
+
)}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Dependencies are re-discovered on every run, so conditional reads work: above, `name` is only tracked while `loggedIn` is true. The tradeoff is granularity — a tracked block replaces its children wholesale (no diffing) when a dependency changes, so keep tracked blocks small and prefer `View.For` with `by` for lists.
|
|
225
|
+
|
|
207
226
|
### Static or Reactive Props
|
|
208
227
|
|
|
209
228
|
Use `Prop` when a component prop can accept either a static value or a signal:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./RuntimeAttr.res-Cr5Qmz0i.js"),t=require("./View.res-
|
|
1
|
+
const e=require("./RuntimeAttr.res-Cr5Qmz0i.js"),t=require("./View.res-DhZkE_sC.js");var n=e.D({a:()=>p,button:()=>a,div:()=>r,h1:()=>s,h2:()=>c,h3:()=>l,input:()=>o,li:()=>f,p:()=>u,span:()=>i,ul:()=>d});function r(e,n,r,i){return t.a(`div`,e,n,r,void 0)}function i(e,n,r,i){return t.a(`span`,e,n,r,void 0)}function a(e,n,r,i){return t.a(`button`,e,n,r,void 0)}function o(e,n,r){return t.a(`input`,e,n,void 0,void 0)}function s(e,n,r,i){return t.a(`h1`,e,n,r,void 0)}function c(e,n,r,i){return t.a(`h2`,e,n,r,void 0)}function l(e,n,r,i){return t.a(`h3`,e,n,r,void 0)}function u(e,n,r,i){return t.a(`p`,e,n,r,void 0)}function d(e,n,r,i){return t.a(`ul`,e,n,r,void 0)}function f(e,n,r,i){return t.a(`li`,e,n,r,void 0)}function p(e,n,r,i){return t.a(`a`,e,n,r,void 0)}function m(e,n){return t.f(n)?n.TAG===`Reactive`?t.s(e,n._0):t.r(e,n._0):t.u(n)?t.i(e,n):t.d(n)?t.s(e,n):t.r(e,n)}function h(n,r){if(t.f(r)){if(r.TAG!==`Reactive`)return t.r(n,e.t(r._0));let i=r._0,a=t.x(()=>e.t(e.l(i)),void 0,void 0);return t.s(n,a)}if(t.u(r))return t.i(n,()=>e.t(r()));if(!t.d(r))return t.r(n,e.t(r));let i=t.x(()=>e.t(e.l(r)),void 0,void 0);return t.s(n,i)}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return h}});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { D as e, l as t, t as n } from "./RuntimeAttr.res-DAZkL5CF.mjs";
|
|
2
|
-
import { a as r, d as i, f as a, i as o, r as s, s as c, u as l, x as u } from "./View.res-
|
|
2
|
+
import { a as r, d as i, f as a, i as o, r as s, s as c, u as l, x as u } from "./View.res-3LSynUOy.mjs";
|
|
3
3
|
//#region src/Html.res.mjs
|
|
4
4
|
var d = /* @__PURE__ */ e({
|
|
5
5
|
a: () => S,
|