nuclo 0.3.24 → 0.3.25
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 +17 -4
- package/package.json +2 -2
- package/types/features/style.d.ts +1 -1
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ render(Counter, document.body);
|
|
|
32
32
|
- **State-Dependent Values** – Pass a function for any text, attribute, condition, or list that depends on state; Nuclo can evaluate it again later
|
|
33
33
|
- **Explicit and Predictable** – Reevaluation doesn't happen on mutation — you trigger it yourself with a simple `update()` call
|
|
34
34
|
- **Real DOM, No Virtual Layer** – Nuclo creates and updates real DOM nodes directly; there's no virtual DOM to diff
|
|
35
|
-
- **Tiny Footprint** –
|
|
35
|
+
- **Tiny Footprint** – ~<!-- size:core-gzip -->18.0<!-- /size --> KB gzipped, zero dependencies
|
|
36
36
|
- **Global Tag Builders** – Natural API with global functions for all HTML and SVG elements
|
|
37
37
|
- **TypeScript-First** – Full type definitions for all 175 HTML and SVG builders
|
|
38
38
|
- **Targeted DOM Updates** – `update()` re-runs registered state-dependent values and only touches DOM where values changed
|
|
@@ -170,7 +170,7 @@ const App = () => div(
|
|
|
170
170
|
// Input
|
|
171
171
|
div(
|
|
172
172
|
input({ value: () => inputValue },
|
|
173
|
-
on('input', e => { inputValue = e.
|
|
173
|
+
on('input', e => { inputValue = e.currentTarget.value; update(); }),
|
|
174
174
|
on('keydown', e => e.key === 'Enter' && addTodo())
|
|
175
175
|
),
|
|
176
176
|
button('Add', { onClick: addTodo })
|
|
@@ -230,7 +230,7 @@ const App = () => div(
|
|
|
230
230
|
value: () => searchQuery
|
|
231
231
|
},
|
|
232
232
|
on('input', e => {
|
|
233
|
-
searchQuery = e.
|
|
233
|
+
searchQuery = e.currentTarget.value;
|
|
234
234
|
update();
|
|
235
235
|
})
|
|
236
236
|
),
|
|
@@ -289,7 +289,7 @@ const App = () => div(
|
|
|
289
289
|
value: () => searchQuery
|
|
290
290
|
},
|
|
291
291
|
on('input', e => {
|
|
292
|
-
searchQuery = e.
|
|
292
|
+
searchQuery = e.currentTarget.value;
|
|
293
293
|
update();
|
|
294
294
|
}),
|
|
295
295
|
on('keydown', e => e.key === 'Enter' && fetchProducts())
|
|
@@ -565,6 +565,17 @@ cartItems.push(nextItem);
|
|
|
565
565
|
update('cart'); // only updates runtimes inside the "cart" scope
|
|
566
566
|
```
|
|
567
567
|
|
|
568
|
+
#### `forceUpdate()`
|
|
569
|
+
|
|
570
|
+
`update()` only runs dynamic values. Static values, such as the text in `h1(labels[lang].title)`, are fixed when the tree is built. `forceUpdate()` calls the components again and patches the live DOM to match, static values included. Use it for rare, app-wide changes, such as switching the language:
|
|
571
|
+
|
|
572
|
+
```ts
|
|
573
|
+
lang = 'pt';
|
|
574
|
+
forceUpdate(); // rebuilds every root rendered with render(App) or hydrate(App)
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
Roots rendered with `render(App())` are skipped, so pass the component. On the server, `forceUpdate()` does nothing.
|
|
578
|
+
|
|
568
579
|
### Tag Builders
|
|
569
580
|
|
|
570
581
|
All HTML and SVG tags are available globally:
|
|
@@ -624,6 +635,8 @@ const el = div(card, 'Hello');
|
|
|
624
635
|
|
|
625
636
|
Every distinct declaration block `css()` ever compiles mints a class that lives for the life of the process (only a manual test reset clears it) — this is what lets identical styles dedupe globally, but it means `css()` is for a bounded design-token vocabulary, not per-instance dynamic values. For data that varies per element instance (a user's chosen color, a computed position), use the `style` prop instead of routing it through `css({ raw: {...} })`.
|
|
626
637
|
|
|
638
|
+
`getCssText()` and `resetStyles()` are named exports. `resetStyles()` is a test helper that removes every rule and the `#nuclo-styles` element. Do not call it in an app or on a server.
|
|
639
|
+
|
|
627
640
|
#### Composing with `cx()`
|
|
628
641
|
|
|
629
642
|
`cx()` composes styles with exact, last-wins conflict resolution. When two generated classes target the same selector context, their declaration blocks are merged and the later value wins per property. It accepts results, raw class strings, falsy values, and nested arrays:
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuclo",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.25",
|
|
5
5
|
"description": "Lightweight, type-safe DOM library with plain mutable state and explicit updates — global tag builders, SSR, hydration, and typed CSS, no virtual DOM, no compiler.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Danilo Celestino de Castro (https://github.com/dan2dev)",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"ui",
|
|
11
11
|
"ssr",
|
|
12
12
|
"hydration",
|
|
13
|
-
"
|
|
13
|
+
"css-in-ts",
|
|
14
14
|
"no-vdom",
|
|
15
15
|
"typescript"
|
|
16
16
|
],
|