@nuvo-js/core 1.0.1 → 1.0.4

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 (122) hide show
  1. package/README.md +410 -410
  2. package/dist/Element/index.d.ts.map +1 -1
  3. package/dist/Fragment.d.ts.map +1 -1
  4. package/dist/SVGElement/index.d.ts.map +1 -1
  5. package/dist/global.d.ts +2 -2
  6. package/dist/global.d.ts.map +1 -1
  7. package/dist/index.d.ts +3 -3
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +3 -3
  10. package/dist/index.js.map +1 -1
  11. package/dist/store.d.ts.map +1 -1
  12. package/dist/types.d.ts +4 -0
  13. package/dist/types.d.ts.map +1 -0
  14. package/dist/types.js.map +1 -0
  15. package/dist/utils.d.ts.map +1 -1
  16. package/package.json +4 -4
  17. package/dist/example/src/App.d.ts +0 -3
  18. package/dist/example/src/App.d.ts.map +0 -1
  19. package/dist/example/src/App.js +0 -100
  20. package/dist/example/src/App.js.map +0 -1
  21. package/dist/example/src/main.d.ts +0 -2
  22. package/dist/example/src/main.d.ts.map +0 -1
  23. package/dist/example/src/main.js +0 -8
  24. package/dist/example/src/main.js.map +0 -1
  25. package/dist/example/src/uikit/Button/Button.d.ts +0 -7
  26. package/dist/example/src/uikit/Button/Button.d.ts.map +0 -1
  27. package/dist/example/src/uikit/Button/Button.js +0 -26
  28. package/dist/example/src/uikit/Button/Button.js.map +0 -1
  29. package/dist/example/src/uikit/Button/index.d.ts +0 -3
  30. package/dist/example/src/uikit/Button/index.d.ts.map +0 -1
  31. package/dist/example/src/uikit/Button/index.js +0 -3
  32. package/dist/example/src/uikit/Button/index.js.map +0 -1
  33. package/dist/example/src/uikit/Button/types.d.ts +0 -6
  34. package/dist/example/src/uikit/Button/types.d.ts.map +0 -1
  35. package/dist/example/src/uikit/Button/types.js.map +0 -1
  36. package/dist/example/src/uikit/Icon/Icon.d.ts +0 -8
  37. package/dist/example/src/uikit/Icon/Icon.d.ts.map +0 -1
  38. package/dist/example/src/uikit/Icon/Icon.js +0 -29
  39. package/dist/example/src/uikit/Icon/Icon.js.map +0 -1
  40. package/dist/example/src/uikit/Icon/assets/index.d.ts +0 -6
  41. package/dist/example/src/uikit/Icon/assets/index.d.ts.map +0 -1
  42. package/dist/example/src/uikit/Icon/assets/index.js +0 -5
  43. package/dist/example/src/uikit/Icon/assets/index.js.map +0 -1
  44. package/dist/example/src/uikit/Icon/assets/trash.js +0 -35
  45. package/dist/example/src/uikit/Icon/assets/trash.js.map +0 -1
  46. package/dist/example/src/uikit/Icon/index.d.ts +0 -3
  47. package/dist/example/src/uikit/Icon/index.d.ts.map +0 -1
  48. package/dist/example/src/uikit/Icon/index.js +0 -3
  49. package/dist/example/src/uikit/Icon/index.js.map +0 -1
  50. package/dist/example/src/uikit/Icon/types.d.ts +0 -5
  51. package/dist/example/src/uikit/Icon/types.d.ts.map +0 -1
  52. package/dist/example/src/uikit/Icon/types.js +0 -2
  53. package/dist/example/src/uikit/Icon/types.js.map +0 -1
  54. package/dist/example/src/uikit/Input/Input.d.ts +0 -8
  55. package/dist/example/src/uikit/Input/Input.d.ts.map +0 -1
  56. package/dist/example/src/uikit/Input/Input.js +0 -58
  57. package/dist/example/src/uikit/Input/Input.js.map +0 -1
  58. package/dist/example/src/uikit/Input/index.d.ts +0 -3
  59. package/dist/example/src/uikit/Input/index.d.ts.map +0 -1
  60. package/dist/example/src/uikit/Input/index.js +0 -3
  61. package/dist/example/src/uikit/Input/index.js.map +0 -1
  62. package/dist/example/src/uikit/Input/types.d.ts +0 -15
  63. package/dist/example/src/uikit/Input/types.d.ts.map +0 -1
  64. package/dist/example/src/uikit/Input/types.js +0 -2
  65. package/dist/example/src/uikit/Input/types.js.map +0 -1
  66. package/dist/example/src/uikit/index.d.ts +0 -4
  67. package/dist/example/src/uikit/index.d.ts.map +0 -1
  68. package/dist/example/src/uikit/index.js +0 -4
  69. package/dist/example/src/uikit/index.js.map +0 -1
  70. package/dist/example/src/utils.d.ts +0 -2
  71. package/dist/example/src/utils.d.ts.map +0 -1
  72. package/dist/example/src/utils.js +0 -4
  73. package/dist/example/src/utils.js.map +0 -1
  74. package/dist/src/Element/index.d.ts +0 -17
  75. package/dist/src/Element/index.d.ts.map +0 -1
  76. package/dist/src/Element/index.js +0 -118
  77. package/dist/src/Element/index.js.map +0 -1
  78. package/dist/src/Element/types.d.ts +0 -27
  79. package/dist/src/Element/types.d.ts.map +0 -1
  80. package/dist/src/Element/types.js +0 -2
  81. package/dist/src/Element/types.js.map +0 -1
  82. package/dist/src/Element/utils.d.ts +0 -4
  83. package/dist/src/Element/utils.d.ts.map +0 -1
  84. package/dist/src/Element/utils.js +0 -112
  85. package/dist/src/Element/utils.js.map +0 -1
  86. package/dist/src/Fragment.d.ts +0 -4
  87. package/dist/src/Fragment.d.ts.map +0 -1
  88. package/dist/src/Fragment.js +0 -7
  89. package/dist/src/Fragment.js.map +0 -1
  90. package/dist/src/SVGElement/index.d.ts +0 -14
  91. package/dist/src/SVGElement/index.d.ts.map +0 -1
  92. package/dist/src/SVGElement/index.js +0 -74
  93. package/dist/src/SVGElement/index.js.map +0 -1
  94. package/dist/src/SVGElement/types.d.ts +0 -274
  95. package/dist/src/SVGElement/types.d.ts.map +0 -1
  96. package/dist/src/SVGElement/types.js +0 -2
  97. package/dist/src/SVGElement/types.js.map +0 -1
  98. package/dist/src/global.d.ts +0 -8
  99. package/dist/src/global.d.ts.map +0 -1
  100. package/dist/src/global.js +0 -2
  101. package/dist/src/global.js.map +0 -1
  102. package/dist/src/index.d.ts +0 -16
  103. package/dist/src/index.d.ts.map +0 -1
  104. package/dist/src/index.js +0 -26
  105. package/dist/src/index.js.map +0 -1
  106. package/dist/src/store.d.ts +0 -12
  107. package/dist/src/store.d.ts.map +0 -1
  108. package/dist/src/store.js +0 -45
  109. package/dist/src/store.js.map +0 -1
  110. package/dist/src/types/index.d.ts +0 -4
  111. package/dist/src/types/index.d.ts.map +0 -1
  112. package/dist/src/types/index.js +0 -2
  113. package/dist/src/types/index.js.map +0 -1
  114. package/dist/src/utils.d.ts +0 -9
  115. package/dist/src/utils.d.ts.map +0 -1
  116. package/dist/src/utils.js +0 -80
  117. package/dist/src/utils.js.map +0 -1
  118. package/dist/types/index.d.ts +0 -4
  119. package/dist/types/index.d.ts.map +0 -1
  120. package/dist/types/index.js +0 -2
  121. package/dist/types/index.js.map +0 -1
  122. /package/dist/{example/src/uikit/Button/types.js → types.js} +0 -0
package/README.md CHANGED
@@ -1,411 +1,411 @@
1
- # @nuvo-js/core
2
-
3
- **Nuvo** is a lightweight, TypeScript-first UI library built around native DOM APIs.
4
-
5
- Nuvo provides a class-based approach to building web interfaces without JSX or unnecessary rendering abstractions. It gives developers direct control over HTML and SVG elements while providing reactive state management and efficient DOM updates through keyed and unkeyed diffing.
6
-
7
- ## Features
8
-
9
- - **DOM-first architecture** — Direct interaction with native DOM elements.
10
- - **TypeScript support** — Generic types and public type definitions.
11
- - **HTML elements** — Create and configure native HTML elements.
12
- - **SVG elements** — Build SVG graphics using the same architecture.
13
- - **Reactive Store** — Manage application state with subscriptions and effects.
14
- - **DOM Diffing** — Efficiently update existing DOM elements.
15
- - **Keyed Diffing** — Reuse, insert, remove, and reorder elements using unique keys.
16
- - **No Virtual DOM** — Work directly with real DOM elements.
17
- - **No JSX required** — Build interfaces using standard JavaScript and TypeScript.
18
- - **Lightweight** — Built around native browser APIs.
19
-
20
- ## Installation
21
-
22
- Install using npm:
23
-
24
- ```bash
25
- npm install @nuvo-js/core
26
- ```
27
-
28
- ## Usage
29
-
30
- ### Browser Global
31
-
32
- Nuvo is also accessible through the browser global namespace:
33
-
34
- ```javascript
35
- const nuvojs = window['nuvo-js'];
36
-
37
- console.log(nuvojs);
38
- ```
39
-
40
- ### ECMAScript Modules
41
-
42
- Import `createRoot` from the package and mount your application to a DOM element.
43
-
44
- **main.ts**
45
-
46
- ```typescript
47
- import { createRoot } from '@nuvo-js/core';
48
- import App from './App';
49
-
50
- const root = document.getElementById('app');
51
-
52
- createRoot(root!, App());
53
- ```
54
-
55
- **index.html**
56
-
57
- ```html
58
- <div id="app"></div>
59
- ```
60
-
61
- ## HTML Elements
62
-
63
- Create native HTML elements using the `Element` class.
64
-
65
- Each instance accepts a configuration object containing a `tagName` and `props`.
66
-
67
- ```typescript
68
- import { Element } from '@nuvo-js/core';
69
-
70
- const element = new Element<HTMLDivElement>({
71
- tagName: 'div',
72
- props: {
73
- className: 'row',
74
- children: [
75
- 'I am div element.'
76
- ]
77
- }
78
- });
79
-
80
- document.body.append(element.dom);
81
- ```
82
-
83
- The `.dom` property provides access to the underlying native DOM element.
84
-
85
- ### TypeScript Generics
86
-
87
- You can specify the native HTML element type using generics:
88
-
89
- ```typescript
90
- const div = new Element<HTMLDivElement>({
91
- tagName: 'div',
92
- props: {
93
- className: 'container'
94
- }
95
- });
96
-
97
- const button = new Element<HTMLButtonElement>({
98
- tagName: 'button',
99
- props: {
100
- textContent: 'Click me'
101
- }
102
- });
103
- ```
104
-
105
- This provides better TypeScript support when working with native DOM elements.
106
-
107
- ### Updating Properties
108
-
109
- Use `SetProps()` to update element properties:
110
-
111
- ```typescript
112
- div.SetProps({
113
- className: 'container active',
114
- title: 'Updated container'
115
- });
116
- ```
117
-
118
- `SetProps()` updates the existing DOM element rather than requiring a new element instance.
119
-
120
- ## SVG Elements
121
-
122
- Nuvo also provides an `SVGElement` class for creating SVG elements.
123
-
124
- You can use it to build reusable SVG components while maintaining TypeScript support.
125
-
126
- ### Example: Trash Icon
127
-
128
- ```typescript
129
- import { SVGElement } from '@nuvo-js/core';
130
- import type { SVGElementPropsType } from '@nuvo-js/core/types';
131
-
132
- function Trash(props: SVGElementPropsType) {
133
- return new SVGElement({
134
- tagName: 'svg',
135
- props: {
136
- xmlns: 'http://www.w3.org/2000/svg',
137
- width: 24,
138
- height: 24,
139
- viewBox: '0 0 24 24',
140
- fill: 'none',
141
- stroke: 'currentColor',
142
- strokeWidth: 2,
143
- strokeLinecap: 'round',
144
- strokeLinejoin: 'round',
145
- ...props,
146
- children: [
147
- new SVGElement<SVGPolylineElement>({
148
- tagName: 'polyline',
149
- props: {
150
- points: '3 6 5 6 21 6'
151
- }
152
- }).dom,
153
-
154
- new SVGElement<SVGPathElement>({
155
- tagName: 'path',
156
- props: {
157
- d: 'M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2'
158
- }
159
- }).dom
160
- ]
161
- }
162
- }).dom;
163
- }
164
-
165
- export default Trash;
166
- ```
167
-
168
- The component returns a native SVG DOM element and accepts SVG properties through `SVGElementPropsType`.
169
-
170
- ## Fragment
171
-
172
- Nuvo provides `Fragment` for grouping multiple elements without introducing an additional wrapper element into the DOM.
173
-
174
- ```typescript
175
- import { Element, Fragment } from '@nuvo-js/core';
176
-
177
- function App() {
178
- return Fragment([
179
- new Element<HTMLDivElement>({
180
- tagName: 'div',
181
- props: {
182
- children: ['First element']
183
- }
184
- }).dom,
185
-
186
- new Element<HTMLDivElement>({
187
- tagName: 'div',
188
- props: {
189
- children: ['Second element']
190
- }
191
- }).dom
192
- ]);
193
- }
194
- ```
195
-
196
- Fragments are useful for composing UI structures while keeping the resulting DOM hierarchy clean.
197
-
198
- ## Store
199
-
200
- Nuvo includes a reactive `Store` class for application state management.
201
-
202
- Create a store by providing an initial state and its corresponding TypeScript type.
203
-
204
- ### Creating a Store
205
-
206
- ```typescript
207
- import { Store } from '@nuvo-js/core';
208
-
209
- const store = new Store<number[]>([]);
210
- ```
211
-
212
- ### Get State
213
-
214
- Retrieve the current state:
215
-
216
- ```typescript
217
- const state = store.GetState();
218
-
219
- console.log(state);
220
- ```
221
-
222
- ### Set State
223
-
224
- Update the state by providing a new value:
225
-
226
- ```typescript
227
- store.SetState([1, 2, 3]);
228
- ```
229
-
230
- You can also use a callback to update the previous state:
231
-
232
- ```typescript
233
- store.SetState(prev => [
234
- ...prev,
235
- 4
236
- ]);
237
- ```
238
-
239
- ### Subscribe
240
-
241
- Listen for state changes.
242
-
243
- `Subscribe()` executes its callback when the store state changes.
244
-
245
- ```typescript
246
- store.Subscribe(() => {
247
- console.log('Store updated!');
248
- });
249
- ```
250
-
251
- ### Effect
252
-
253
- `Effect()` executes its callback immediately when registered and again whenever the store state changes.
254
-
255
- ```typescript
256
- store.Effect((state) => {
257
- console.log('Current state:', state);
258
- });
259
- ```
260
-
261
- ### Store API Reference
262
-
263
- | Method | Description |
264
- |---|---|
265
- | `GetState()` | Returns the current state. |
266
- | `SetState(value)` | Updates the state with a new value. |
267
- | `SetState(callback)` | Updates the state using the previous value. |
268
- | `Subscribe(callback)` | Listens for state changes. |
269
- | `Effect(callback)` | Executes immediately and listens for subsequent state changes. |
270
-
271
- ## DOM Diffing
272
-
273
- Nuvo provides DOM diffing to update existing elements without unnecessarily replacing the entire DOM structure.
274
-
275
- When updating an element's children through `SetProps()`, Nuvo compares the existing children with the new children.
276
-
277
- Nuvo supports two reconciliation strategies:
278
-
279
- - **Unkeyed Diffing** — Compares children by their position in the DOM.
280
- - **Keyed Diffing** — Identifies children using unique keys and reconciles them independently of their position.
281
-
282
- ### Unkeyed Diffing
283
-
284
- For collections without keys, Nuvo compares elements by their position.
285
-
286
- ```typescript
287
- const list = new Element<HTMLUListElement>({
288
- tagName: 'ul',
289
- props: {
290
- children: [
291
- new Element<HTMLLIElement>({
292
- tagName: 'li',
293
- props: {
294
- children: ['Item 1']
295
- }
296
- }).dom,
297
-
298
- new Element<HTMLLIElement>({
299
- tagName: 'li',
300
- props: {
301
- children: ['Item 2']
302
- }
303
- }).dom
304
- ]
305
- }
306
- });
307
- ```
308
-
309
- ### Keyed Diffing
310
-
311
- When rendering dynamic collections, you can assign a unique `key` to each element.
312
-
313
- ```typescript
314
- key: item.id
315
- ```
316
-
317
- Nuvo uses these keys to identify and reuse existing DOM elements.
318
-
319
- The keyed diffing process:
320
-
321
- - **Reuse** — Reuses existing DOM elements with matching keys.
322
- - **Remove** — Removes elements whose keys no longer exist.
323
- - **Insert** — Inserts newly created elements.
324
- - **Reorder** — Moves existing DOM elements when their order changes.
325
-
326
- ### Example: Reactive Todo List
327
-
328
- ```typescript
329
- import { Element, Store } from '@nuvo-js/core';
330
-
331
- interface Todo {
332
- id: string;
333
- title: string;
334
- }
335
-
336
- const todos = new Store<Todo[]>([]);
337
-
338
- const list = new Element<HTMLOListElement>({
339
- tagName: 'ol',
340
- props: {
341
- children: []
342
- }
343
- });
344
-
345
- todos.Effect((state) => {
346
- list.SetProps({
347
- children: state.map(todo =>
348
- new Element<HTMLLIElement>({
349
- tagName: 'li',
350
- props: {
351
- key: todo.id,
352
- children: [
353
- todo.title
354
- ]
355
- }
356
- }).dom
357
- )
358
- });
359
- });
360
-
361
- // Add a todo
362
- todos.SetState(prev => [
363
- ...prev,
364
- {
365
- id: crypto.randomUUID(),
366
- title: 'Learn Nuvo'
367
- }
368
- ]);
369
-
370
- // Remove a todo
371
- todos.SetState(prev =>
372
- prev.filter(todo => todo.id !== 'some-id')
373
- );
374
- ```
375
-
376
- ### Key Best Practices
377
-
378
- - Always use unique keys among sibling elements.
379
- - Prefer stable identifiers such as database IDs or UUIDs.
380
- - Avoid array indexes as keys when elements can be reordered or removed.
381
- - Use consistent keys when rendering dynamic collections.
382
- - When using keyed diffing, provide keys for all sibling elements.
383
-
384
- ## TypeScript Support
385
-
386
- Nuvo Core is written in TypeScript and provides public type definitions.
387
-
388
- Import types directly from the package:
389
-
390
- ```typescript
391
- import type {
392
- ElementPropsType,
393
- SVGElementPropsType
394
- } from '@nuvo-js/core/types';
395
- ```
396
-
397
- ## Philosophy
398
-
399
- Nuvo focuses on simplicity, control, and native browser capabilities.
400
-
401
- Rather than introducing another abstraction layer between developers and the DOM, Nuvo provides tools to work directly with the platform.
402
-
403
- Inspired by the Italian word nuovo and the French word nouveau, both meaning new, fresh, or recently developed, the name reflects Nuvo's vision of bringing a fresh, simple, and modern approach to building web interfaces.
404
-
405
- Build with JavaScript. Control the DOM. Keep things simple.
406
-
407
- Nuvo — A fresh approach to the DOM.
408
-
409
- ## License
410
-
1
+ # @nuvo-js/core
2
+
3
+ **Nuvo** is a lightweight, TypeScript-first UI library built around native DOM APIs.
4
+
5
+ Nuvo provides a class-based approach to building web interfaces without JSX or unnecessary rendering abstractions. It gives developers direct control over HTML and SVG elements while providing reactive state management and efficient DOM updates through keyed and unkeyed diffing.
6
+
7
+ ## Features
8
+
9
+ - **DOM-first architecture** — Direct interaction with native DOM elements.
10
+ - **TypeScript support** — Generic types and public type definitions.
11
+ - **HTML elements** — Create and configure native HTML elements.
12
+ - **SVG elements** — Build SVG graphics using the same architecture.
13
+ - **Reactive Store** — Manage application state with subscriptions and effects.
14
+ - **DOM Diffing** — Efficiently update existing DOM elements.
15
+ - **Keyed Diffing** — Reuse, insert, remove, and reorder elements using unique keys.
16
+ - **No Virtual DOM** — Work directly with real DOM elements.
17
+ - **No JSX required** — Build interfaces using standard JavaScript and TypeScript.
18
+ - **Lightweight** — Built around native browser APIs.
19
+
20
+ ## Installation
21
+
22
+ Install using npm:
23
+
24
+ ```bash
25
+ npm install @nuvo-js/core
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ### Browser Global
31
+
32
+ Nuvo is also accessible through the browser global namespace:
33
+
34
+ ```javascript
35
+ const nuvojs = window['nuvo-js'];
36
+
37
+ console.log(nuvojs);
38
+ ```
39
+
40
+ ### ECMAScript Modules
41
+
42
+ Import `createRoot` from the package and mount your application to a DOM element.
43
+
44
+ **main.ts**
45
+
46
+ ```typescript
47
+ import { createRoot } from '@nuvo-js/core';
48
+ import App from './App';
49
+
50
+ const root = document.getElementById('app');
51
+
52
+ createRoot(root!, App());
53
+ ```
54
+
55
+ **index.html**
56
+
57
+ ```html
58
+ <div id="app"></div>
59
+ ```
60
+
61
+ ## HTML Elements
62
+
63
+ Create native HTML elements using the `Element` class.
64
+
65
+ Each instance accepts a configuration object containing a `tagName` and `props`.
66
+
67
+ ```typescript
68
+ import { Element } from '@nuvo-js/core';
69
+
70
+ const element = new Element<HTMLDivElement>({
71
+ tagName: 'div',
72
+ props: {
73
+ className: 'row',
74
+ children: [
75
+ 'I am div element.'
76
+ ]
77
+ }
78
+ });
79
+
80
+ document.body.append(element.dom);
81
+ ```
82
+
83
+ The `.dom` property provides access to the underlying native DOM element.
84
+
85
+ ### TypeScript Generics
86
+
87
+ You can specify the native HTML element type using generics:
88
+
89
+ ```typescript
90
+ const div = new Element<HTMLDivElement>({
91
+ tagName: 'div',
92
+ props: {
93
+ className: 'container'
94
+ }
95
+ });
96
+
97
+ const button = new Element<HTMLButtonElement>({
98
+ tagName: 'button',
99
+ props: {
100
+ textContent: 'Click me'
101
+ }
102
+ });
103
+ ```
104
+
105
+ This provides better TypeScript support when working with native DOM elements.
106
+
107
+ ### Updating Properties
108
+
109
+ Use `SetProps()` to update element properties:
110
+
111
+ ```typescript
112
+ div.SetProps({
113
+ className: 'container active',
114
+ title: 'Updated container'
115
+ });
116
+ ```
117
+
118
+ `SetProps()` updates the existing DOM element rather than requiring a new element instance.
119
+
120
+ ## SVG Elements
121
+
122
+ Nuvo also provides an `SVGElement` class for creating SVG elements.
123
+
124
+ You can use it to build reusable SVG components while maintaining TypeScript support.
125
+
126
+ ### Example: Trash Icon
127
+
128
+ ```typescript
129
+ import { SVGElement } from '@nuvo-js/core';
130
+ import type { SVGElementPropsType } from '@nuvo-js/core/types';
131
+
132
+ function Trash(props: SVGElementPropsType) {
133
+ return new SVGElement({
134
+ tagName: 'svg',
135
+ props: {
136
+ xmlns: 'http://www.w3.org/2000/svg',
137
+ width: 24,
138
+ height: 24,
139
+ viewBox: '0 0 24 24',
140
+ fill: 'none',
141
+ stroke: 'currentColor',
142
+ strokeWidth: 2,
143
+ strokeLinecap: 'round',
144
+ strokeLinejoin: 'round',
145
+ ...props,
146
+ children: [
147
+ new SVGElement<SVGPolylineElement>({
148
+ tagName: 'polyline',
149
+ props: {
150
+ points: '3 6 5 6 21 6'
151
+ }
152
+ }).dom,
153
+
154
+ new SVGElement<SVGPathElement>({
155
+ tagName: 'path',
156
+ props: {
157
+ d: 'M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2'
158
+ }
159
+ }).dom
160
+ ]
161
+ }
162
+ }).dom;
163
+ }
164
+
165
+ export default Trash;
166
+ ```
167
+
168
+ The component returns a native SVG DOM element and accepts SVG properties through `SVGElementPropsType`.
169
+
170
+ ## Fragment
171
+
172
+ Nuvo provides `Fragment` for grouping multiple elements without introducing an additional wrapper element into the DOM.
173
+
174
+ ```typescript
175
+ import { Element, Fragment } from '@nuvo-js/core';
176
+
177
+ function App() {
178
+ return Fragment([
179
+ new Element<HTMLDivElement>({
180
+ tagName: 'div',
181
+ props: {
182
+ children: ['First element']
183
+ }
184
+ }).dom,
185
+
186
+ new Element<HTMLDivElement>({
187
+ tagName: 'div',
188
+ props: {
189
+ children: ['Second element']
190
+ }
191
+ }).dom
192
+ ]);
193
+ }
194
+ ```
195
+
196
+ Fragments are useful for composing UI structures while keeping the resulting DOM hierarchy clean.
197
+
198
+ ## Store
199
+
200
+ Nuvo includes a reactive `Store` class for application state management.
201
+
202
+ Create a store by providing an initial state and its corresponding TypeScript type.
203
+
204
+ ### Creating a Store
205
+
206
+ ```typescript
207
+ import { Store } from '@nuvo-js/core';
208
+
209
+ const store = new Store<number[]>([]);
210
+ ```
211
+
212
+ ### Get State
213
+
214
+ Retrieve the current state:
215
+
216
+ ```typescript
217
+ const state = store.GetState();
218
+
219
+ console.log(state);
220
+ ```
221
+
222
+ ### Set State
223
+
224
+ Update the state by providing a new value:
225
+
226
+ ```typescript
227
+ store.SetState([1, 2, 3]);
228
+ ```
229
+
230
+ You can also use a callback to update the previous state:
231
+
232
+ ```typescript
233
+ store.SetState(prev => [
234
+ ...prev,
235
+ 4
236
+ ]);
237
+ ```
238
+
239
+ ### Subscribe
240
+
241
+ Listen for state changes.
242
+
243
+ `Subscribe()` executes its callback when the store state changes.
244
+
245
+ ```typescript
246
+ store.Subscribe(() => {
247
+ console.log('Store updated!');
248
+ });
249
+ ```
250
+
251
+ ### Effect
252
+
253
+ `Effect()` executes its callback immediately when registered and again whenever the store state changes.
254
+
255
+ ```typescript
256
+ store.Effect((state) => {
257
+ console.log('Current state:', state);
258
+ });
259
+ ```
260
+
261
+ ### Store API Reference
262
+
263
+ | Method | Description |
264
+ |---|---|
265
+ | `GetState()` | Returns the current state. |
266
+ | `SetState(value)` | Updates the state with a new value. |
267
+ | `SetState(callback)` | Updates the state using the previous value. |
268
+ | `Subscribe(callback)` | Listens for state changes. |
269
+ | `Effect(callback)` | Executes immediately and listens for subsequent state changes. |
270
+
271
+ ## DOM Diffing
272
+
273
+ Nuvo provides DOM diffing to update existing elements without unnecessarily replacing the entire DOM structure.
274
+
275
+ When updating an element's children through `SetProps()`, Nuvo compares the existing children with the new children.
276
+
277
+ Nuvo supports two reconciliation strategies:
278
+
279
+ - **Unkeyed Diffing** — Compares children by their position in the DOM.
280
+ - **Keyed Diffing** — Identifies children using unique keys and reconciles them independently of their position.
281
+
282
+ ### Unkeyed Diffing
283
+
284
+ For collections without keys, Nuvo compares elements by their position.
285
+
286
+ ```typescript
287
+ const list = new Element<HTMLUListElement>({
288
+ tagName: 'ul',
289
+ props: {
290
+ children: [
291
+ new Element<HTMLLIElement>({
292
+ tagName: 'li',
293
+ props: {
294
+ children: ['Item 1']
295
+ }
296
+ }).dom,
297
+
298
+ new Element<HTMLLIElement>({
299
+ tagName: 'li',
300
+ props: {
301
+ children: ['Item 2']
302
+ }
303
+ }).dom
304
+ ]
305
+ }
306
+ });
307
+ ```
308
+
309
+ ### Keyed Diffing
310
+
311
+ When rendering dynamic collections, you can assign a unique `key` to each element.
312
+
313
+ ```typescript
314
+ key: item.id
315
+ ```
316
+
317
+ Nuvo uses these keys to identify and reuse existing DOM elements.
318
+
319
+ The keyed diffing process:
320
+
321
+ - **Reuse** — Reuses existing DOM elements with matching keys.
322
+ - **Remove** — Removes elements whose keys no longer exist.
323
+ - **Insert** — Inserts newly created elements.
324
+ - **Reorder** — Moves existing DOM elements when their order changes.
325
+
326
+ ### Example: Reactive Todo List
327
+
328
+ ```typescript
329
+ import { Element, Store } from '@nuvo-js/core';
330
+
331
+ interface Todo {
332
+ id: string;
333
+ title: string;
334
+ }
335
+
336
+ const todos = new Store<Todo[]>([]);
337
+
338
+ const list = new Element<HTMLOListElement>({
339
+ tagName: 'ol',
340
+ props: {
341
+ children: []
342
+ }
343
+ });
344
+
345
+ todos.Effect((state) => {
346
+ list.SetProps({
347
+ children: state.map(todo =>
348
+ new Element<HTMLLIElement>({
349
+ tagName: 'li',
350
+ props: {
351
+ key: todo.id,
352
+ children: [
353
+ todo.title
354
+ ]
355
+ }
356
+ }).dom
357
+ )
358
+ });
359
+ });
360
+
361
+ // Add a todo
362
+ todos.SetState(prev => [
363
+ ...prev,
364
+ {
365
+ id: crypto.randomUUID(),
366
+ title: 'Learn Nuvo'
367
+ }
368
+ ]);
369
+
370
+ // Remove a todo
371
+ todos.SetState(prev =>
372
+ prev.filter(todo => todo.id !== 'some-id')
373
+ );
374
+ ```
375
+
376
+ ### Key Best Practices
377
+
378
+ - Always use unique keys among sibling elements.
379
+ - Prefer stable identifiers such as database IDs or UUIDs.
380
+ - Avoid array indexes as keys when elements can be reordered or removed.
381
+ - Use consistent keys when rendering dynamic collections.
382
+ - When using keyed diffing, provide keys for all sibling elements.
383
+
384
+ ## TypeScript Support
385
+
386
+ Nuvo Core is written in TypeScript and provides public type definitions.
387
+
388
+ Import types directly from the package:
389
+
390
+ ```typescript
391
+ import type {
392
+ ElementPropsType,
393
+ SVGElementPropsType
394
+ } from '@nuvo-js/core/types';
395
+ ```
396
+
397
+ ## Philosophy
398
+
399
+ Nuvo focuses on simplicity, control, and native browser capabilities.
400
+
401
+ Rather than introducing another abstraction layer between developers and the DOM, Nuvo provides tools to work directly with the platform.
402
+
403
+ Inspired by the Italian word nuovo and the French word nouveau, both meaning new, fresh, or recently developed, the name reflects Nuvo's vision of bringing a fresh, simple, and modern approach to building web interfaces.
404
+
405
+ Build with JavaScript. Control the DOM. Keep things simple.
406
+
407
+ Nuvo — A fresh approach to the DOM.
408
+
409
+ ## License
410
+
411
411
  MIT