@yoltra/react 0.2.0 → 0.3.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/LICENSE +0 -0
- package/README.es.md +18 -18
- package/README.md +16 -17
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +15 -16
package/LICENSE
CHANGED
|
File without changes
|
package/README.es.md
CHANGED
|
@@ -77,16 +77,16 @@ export const { store, useAtomicProp, useEmit, StoreProvider } = createYoltra({
|
|
|
77
77
|
### 2. Usa los hooks — sin provider
|
|
78
78
|
|
|
79
79
|
Los hooks usan por defecto el store de arriba, asi que puedes renderizar componentes directamente.
|
|
80
|
-
Suscribete con
|
|
81
|
-
|
|
80
|
+
Suscribete con una spec **`{ reducer, property }`**: el `property` con puntos nombra la ruta exacta
|
|
81
|
+
a leer.
|
|
82
82
|
|
|
83
83
|
```tsx
|
|
84
84
|
// Counter.tsx
|
|
85
85
|
import { useAtomicProp, useEmit } from "./yoltra";
|
|
86
86
|
|
|
87
87
|
export function Counter() {
|
|
88
|
-
//
|
|
89
|
-
const value = useAtomicProp("counter",
|
|
88
|
+
// Forma objeto — se re-renderiza solo cuando counter.value cambia. Sin selectores, sin memo.
|
|
89
|
+
const value = useAtomicProp({ reducer: "counter", property: "value" });
|
|
90
90
|
const emit = useEmit();
|
|
91
91
|
|
|
92
92
|
return (
|
|
@@ -132,21 +132,18 @@ Provee el store con `<AppStoreContext.Provider value={store}>` en tu raiz.
|
|
|
132
132
|
|
|
133
133
|
## API de Hooks
|
|
134
134
|
|
|
135
|
-
### `useAtomicProp(
|
|
135
|
+
### `useAtomicProp({ reducer, property }, map?, isEqual?)`
|
|
136
136
|
|
|
137
|
-
Selector de ruta unica con grano fino. Se re-renderiza solo cuando la hoja especificada cambia.
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
Selector de ruta unica con grano fino. Se re-renderiza solo cuando la hoja especificada cambia. El
|
|
138
|
+
`property` con puntos nombra la ruta exacta — incluyendo rutas dinamicas
|
|
139
|
+
(`` `items.${id}.title` ``) y con comodines.
|
|
140
140
|
|
|
141
141
|
```tsx
|
|
142
|
-
//
|
|
143
|
-
const title = useAtomicProp("todos",
|
|
142
|
+
// Forma objeto (recomendada) — suscribete a la ruta exacta
|
|
143
|
+
const title = useAtomicProp({ reducer: "todos", property: "items.0.title" });
|
|
144
144
|
|
|
145
|
-
//
|
|
146
|
-
const
|
|
147
|
-
reducer: "todos",
|
|
148
|
-
property: "items.0.title",
|
|
149
|
-
});
|
|
145
|
+
// Ruta dinamica — interpola la clave
|
|
146
|
+
const byId = useAtomicProp({ reducer: "todos", property: `items.${id}.title` });
|
|
150
147
|
|
|
151
148
|
// Con mapper — derivar un valor de la ruta
|
|
152
149
|
const count = useAtomicProp({ reducer: "todos", property: "items" }, (items) => items.length);
|
|
@@ -159,6 +156,9 @@ const allTitles = useAtomicProp(
|
|
|
159
156
|
);
|
|
160
157
|
```
|
|
161
158
|
|
|
159
|
+
> Tambien existe una sobrecarga con accessor tipado — `useAtomicProp("todos", (s) => s.items[0].title)`
|
|
160
|
+
> — para rutas estaticas; autocompleta la forma del estado e infiere el tipo de retorno.
|
|
161
|
+
|
|
162
162
|
**Patrones soportados:**
|
|
163
163
|
|
|
164
164
|
- `"items.0.title"` -- ruta exacta (incluyendo indices numericos de array)
|
|
@@ -377,10 +377,10 @@ function TodoItem({ index }: { index: number }) {
|
|
|
377
377
|
## Ejemplos
|
|
378
378
|
|
|
379
379
|
- **[App de Tareas con Profiler](../../examples/v0/yoltra-in-react)** -- CRUD completo con
|
|
380
|
-
comparacion de flamegraph
|
|
380
|
+
comparacion de flamegraph · [▶ Abrir la demo en vivo](https://yoltra.dev/es/demos/in-react)
|
|
381
381
|
- **[Logo Cinetico (3000 particulas)](../../examples/v0/yoltra-kinetic-logo)** -- Suscripciones
|
|
382
|
-
independientes por circulo SVG
|
|
383
|
-
- **[Next.js (Pages Router)](../../examples/v0/yoltra-in-nextjs)** -- estado de cliente + cambio de tema
|
|
382
|
+
independientes por circulo SVG · [▶ Abrir la demo en vivo](https://yoltra.dev/es/demos/kinetic-logo)
|
|
383
|
+
- **[Next.js (Pages Router)](../../examples/v0/yoltra-in-nextjs)** -- estado de cliente + cambio de tema · [▶ Abrir la demo en vivo](https://yoltra.dev/es/demos/in-nextjs)
|
|
384
384
|
|
|
385
385
|
---
|
|
386
386
|
|
package/README.md
CHANGED
|
@@ -77,15 +77,15 @@ export const { store, useAtomicProp, useEmit, StoreProvider } = createYoltra({
|
|
|
77
77
|
### 2. Use the hooks — no provider required
|
|
78
78
|
|
|
79
79
|
The hooks default to the store above, so you can render components directly. Subscribe with a
|
|
80
|
-
|
|
80
|
+
**`{ reducer, property }`** spec: the dotted `property` names the exact path to read.
|
|
81
81
|
|
|
82
82
|
```tsx
|
|
83
83
|
// Counter.tsx
|
|
84
84
|
import { useAtomicProp, useEmit } from "./yoltra";
|
|
85
85
|
|
|
86
86
|
export function Counter() {
|
|
87
|
-
//
|
|
88
|
-
const value = useAtomicProp("counter",
|
|
87
|
+
// Object form — re-renders only when counter.value changes. No selectors, no memo.
|
|
88
|
+
const value = useAtomicProp({ reducer: "counter", property: "value" });
|
|
89
89
|
const emit = useEmit();
|
|
90
90
|
|
|
91
91
|
return (
|
|
@@ -131,21 +131,17 @@ Provide the store with `<AppStoreContext.Provider value={store}>` at your root.
|
|
|
131
131
|
|
|
132
132
|
## Hooks API
|
|
133
133
|
|
|
134
|
-
### `useAtomicProp(
|
|
134
|
+
### `useAtomicProp({ reducer, property }, map?, isEqual?)`
|
|
135
135
|
|
|
136
|
-
Fine-grained single-path selector. Re-renders only when the specified leaf changes.
|
|
137
|
-
|
|
138
|
-
string form for dynamic or wildcard paths.
|
|
136
|
+
Fine-grained single-path selector. Re-renders only when the specified leaf changes. The dotted
|
|
137
|
+
`property` names the exact path — including dynamic (`` `items.${id}.title` ``) and wildcard paths.
|
|
139
138
|
|
|
140
139
|
```tsx
|
|
141
|
-
//
|
|
142
|
-
const title = useAtomicProp("todos",
|
|
140
|
+
// Object form (recommended) — subscribe to the exact path
|
|
141
|
+
const title = useAtomicProp({ reducer: "todos", property: "items.0.title" });
|
|
143
142
|
|
|
144
|
-
//
|
|
145
|
-
const
|
|
146
|
-
reducer: "todos",
|
|
147
|
-
property: "items.0.title",
|
|
148
|
-
});
|
|
143
|
+
// Dynamic path — interpolate the key
|
|
144
|
+
const byId = useAtomicProp({ reducer: "todos", property: `items.${id}.title` });
|
|
149
145
|
|
|
150
146
|
// With mapper — derive a value from the path
|
|
151
147
|
const count = useAtomicProp({ reducer: "todos", property: "items" }, (items) => items.length);
|
|
@@ -158,6 +154,9 @@ const allTitles = useAtomicProp(
|
|
|
158
154
|
);
|
|
159
155
|
```
|
|
160
156
|
|
|
157
|
+
> A typed-accessor overload — `useAtomicProp("todos", (s) => s.items[0].title)` — is also available
|
|
158
|
+
> for static paths; it autocompletes the state shape and infers the return type.
|
|
159
|
+
|
|
161
160
|
**Supported patterns:**
|
|
162
161
|
|
|
163
162
|
- `"items.0.title"` — exact path (including numeric array indices)
|
|
@@ -374,10 +373,10 @@ function TodoItem({ index }: { index: number }) {
|
|
|
374
373
|
## Examples
|
|
375
374
|
|
|
376
375
|
- **[Todo App with Profiler](../../examples/v0/yoltra-in-react)** — Full CRUD with flamegraph
|
|
377
|
-
comparison
|
|
376
|
+
comparison · [▶ Open the live demo](https://yoltra.dev/en/demos/in-react)
|
|
378
377
|
- **[Kinetic Logo (3000 particles)](../../examples/v0/yoltra-kinetic-logo)** — Independent
|
|
379
|
-
subscriptions per circle
|
|
380
|
-
- **[Next.js (Pages Router)](../../examples/v0/yoltra-in-nextjs)** — client-side state + theme switcher
|
|
378
|
+
subscriptions per circle · [▶ Open the live demo](https://yoltra.dev/en/demos/kinetic-logo)
|
|
379
|
+
- **[Next.js (Pages Router)](../../examples/v0/yoltra-in-nextjs)** — client-side state + theme switcher · [▶ Open the live demo](https://yoltra.dev/en/demos/in-nextjs)
|
|
381
380
|
|
|
382
381
|
---
|
|
383
382
|
|
package/dist/index.cjs
CHANGED
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yoltra/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "React bindings for Yoltra",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"build": "tsc -p tsconfig.build.json && vite build",
|
|
7
|
-
"lint": "node ../../tools/repo-tools/bin/repo-eslint.cjs --report-unused-disable-directives --max-warnings 0",
|
|
8
|
-
"lint:fix": "node ../../tools/repo-tools/bin/repo-eslint.cjs --fix",
|
|
9
|
-
"test": "vitest --coverage --watch=false",
|
|
10
|
-
"test:watch": "vitest --coverage",
|
|
11
|
-
"prepublishOnly": "node ../../common/scripts/copy-license.cjs",
|
|
12
|
-
"docs": "rushx docs:js && rushx docs:md",
|
|
13
|
-
"docs:md": "pnpm typedoc --options ./typedoc.react.json",
|
|
14
|
-
"docs:js": "pnpm typedoc --options ./typedoc.react.json --json ./.typedoc/react-en.json"
|
|
15
|
-
},
|
|
16
5
|
"license": "MIT",
|
|
17
6
|
"author": {
|
|
18
7
|
"name": "Manu Ramirez <@pixerael>",
|
|
@@ -51,7 +40,7 @@
|
|
|
51
40
|
"node": ">=18.18"
|
|
52
41
|
},
|
|
53
42
|
"peerDependencies": {
|
|
54
|
-
"@yoltra/core": "^0.
|
|
43
|
+
"@yoltra/core": "^0.3.0",
|
|
55
44
|
"react": "^18 || ^19",
|
|
56
45
|
"react-dom": "^18 || ^19"
|
|
57
46
|
},
|
|
@@ -64,7 +53,6 @@
|
|
|
64
53
|
"tslib": "^2.8.1"
|
|
65
54
|
},
|
|
66
55
|
"devDependencies": {
|
|
67
|
-
"@yoltra/core": "workspace:*",
|
|
68
56
|
"@eslint/js": "^9.30.1",
|
|
69
57
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
70
58
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
@@ -95,7 +83,8 @@
|
|
|
95
83
|
"vite-plugin-dts": "^4.5.4",
|
|
96
84
|
"vite-tsconfig-paths": "^4.3.2",
|
|
97
85
|
"vite": "^7.1.11",
|
|
98
|
-
"vitest": "3.2.4"
|
|
86
|
+
"vitest": "3.2.4",
|
|
87
|
+
"@yoltra/core": "0.3.0"
|
|
99
88
|
},
|
|
100
89
|
"exports": {
|
|
101
90
|
".": {
|
|
@@ -106,5 +95,15 @@
|
|
|
106
95
|
"default": "./dist/index.mjs"
|
|
107
96
|
},
|
|
108
97
|
"./package.json": "./package.json"
|
|
98
|
+
},
|
|
99
|
+
"scripts": {
|
|
100
|
+
"build": "tsc -p tsconfig.build.json && vite build",
|
|
101
|
+
"lint": "node ../../tools/repo-tools/bin/repo-eslint.cjs --report-unused-disable-directives --max-warnings 0",
|
|
102
|
+
"lint:fix": "node ../../tools/repo-tools/bin/repo-eslint.cjs --fix",
|
|
103
|
+
"test": "vitest --coverage --watch=false",
|
|
104
|
+
"test:watch": "vitest --coverage",
|
|
105
|
+
"docs": "rushx docs:js && rushx docs:md",
|
|
106
|
+
"docs:md": "pnpm typedoc --options ./typedoc.react.json",
|
|
107
|
+
"docs:js": "pnpm typedoc --options ./typedoc.react.json --json ./.typedoc/react-en.json"
|
|
109
108
|
}
|
|
110
|
-
}
|
|
109
|
+
}
|