nuclo 0.2.24 → 0.2.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.
Files changed (2) hide show
  1. package/README.md +19 -19
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -17,10 +17,10 @@ let count = 0;
17
17
 
18
18
  const counter = div(
19
19
  h1(() => `Count: ${count}`),
20
- button('Increment', on('click', () => {
20
+ button('Increment', { onClick: () => {
21
21
  count++;
22
22
  update();
23
- }))
23
+ } })
24
24
  );
25
25
 
26
26
  render(counter, document.body);
@@ -92,7 +92,7 @@ import 'nuclo';
92
92
  let count = 0;
93
93
  const app = div(
94
94
  h1(() => `Count: ${count}`),
95
- button('Click', on('click', () => { count++; update(); }))
95
+ button('Click', { onClick: () => { count++; update(); } })
96
96
  );
97
97
  render(app, document.body);
98
98
  ```
@@ -128,8 +128,8 @@ let count = 0;
128
128
 
129
129
  const app = div(
130
130
  h1(() => `Count: ${count}`),
131
- button('Increment', on('click', () => { count++; update(); })),
132
- button('Reset', on('click', () => { count = 0; update(); }))
131
+ button('Increment', { onClick: () => { count++; update(); } }),
132
+ button('Reset', { onClick: () => { count = 0; update(); } })
133
133
  );
134
134
 
135
135
  render(app, document.body);
@@ -162,7 +162,7 @@ const app = div(
162
162
  on('input', e => { inputValue = e.target.value; update(); }),
163
163
  on('keydown', e => e.key === 'Enter' && addTodo())
164
164
  ),
165
- button('Add', on('click', addTodo))
165
+ button('Add', { onClick: addTodo })
166
166
  ),
167
167
 
168
168
  // List
@@ -174,10 +174,10 @@ const app = div(
174
174
  on('change', () => { todo.done = !todo.done; update(); })
175
175
  ),
176
176
  span(() => todo.text),
177
- button('×', on('click', () => {
177
+ button('×', { onClick: () => {
178
178
  todos = todos.filter(t => t.id !== todo.id);
179
179
  update();
180
- }))
180
+ } })
181
181
  )
182
182
  )
183
183
  ).else(
@@ -283,7 +283,7 @@ const app = div(
283
283
  }),
284
284
  on('keydown', e => e.key === 'Enter' && fetchProducts())
285
285
  ),
286
- button('Search', on('click', fetchProducts))
286
+ button('Search', { onClick: fetchProducts })
287
287
  ),
288
288
 
289
289
  when(() => state.status === 'loading',
@@ -445,26 +445,26 @@ when(() => count > 10,
445
445
 
446
446
  First matching condition wins. DOM is preserved if the active branch doesn't change.
447
447
 
448
- #### `on(event, handler, options?)`
448
+ #### Events
449
449
 
450
- Attach event listeners:
450
+ Attach strongly typed handlers directly as camel-cased `on*` attribute props such as `onClick`, `onInput`, and `onChange`. The event and `currentTarget` types are inferred from the attribute and element:
451
451
 
452
452
  ```ts
453
- button('Click me',
454
- on('click', () => console.log('clicked')),
455
- on('mouseenter', handleHover, { passive: true })
456
- )
453
+ button('Remove', { className: 'remove', onClick: () => doDelete(row.id) })
457
454
  ```
458
455
 
459
- Standard names are inferred from the common HTML, media, video, and body event maps. Custom events can provide their event type explicitly with `on<"app:ready", CustomEvent<Detail>>(...)`.
456
+ This is the preferred way to wire up events — it reads naturally inside object literals (e.g. row templates in a `list()`).
460
457
 
461
- You can also attach strongly typed handlers directly as camel-cased `on*` attribute props such as `onClick`, `onInput`, and `onChange`. The event and `currentTarget` types are inferred from the attribute and element:
458
+ Use the `on(event, handler, options?)` helper instead when you need multiple listeners for the same event type on one element, or want to pass listener `options` such as `{ passive: true }`:
462
459
 
463
460
  ```ts
464
- button('Remove', { className: 'remove', onClick: () => doDelete(row.id) })
461
+ button('Click me',
462
+ on('click', trackClick),
463
+ on('click', logClick, { passive: true })
464
+ )
465
465
  ```
466
466
 
467
- This reads naturally inside object literals (e.g. row templates in a `list()`), while `on()` composes better when chaining multiple listeners or passing `options` like `{ passive: true }`.
467
+ Standard names are inferred from the common HTML, media, video, and body event maps. Custom events can provide their event type explicitly with `on<"app:ready", CustomEvent<Detail>>(...)`.
468
468
 
469
469
  #### `scope(...ids)`
470
470
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuclo",
3
3
  "private": false,
4
- "version": "0.2.24",
4
+ "version": "0.2.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)",
@@ -68,7 +68,7 @@
68
68
  "@eslint/markdown": "^8.0.3",
69
69
  "@types/node": "^25.9.5",
70
70
  "@vitest/coverage-v8": "4.1.7",
71
- "eslint": "^10.8.0",
71
+ "eslint": "^10.8.1",
72
72
  "globals": "^17.9.0",
73
73
  "jiti": "^2.7.0",
74
74
  "jsdom": "^29.1.1",