native-document 1.0.94 → 1.0.98

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 (52) hide show
  1. package/{src/devtools/hrm → devtools}/ComponentRegistry.js +2 -2
  2. package/devtools/index.js +8 -0
  3. package/{src/devtools/plugin.js → devtools/plugin/dev-tools-plugin.js} +2 -2
  4. package/{src/devtools/hrm/nd-vite-hot-reload.js → devtools/transformers/nd-vite-devtools.js} +16 -6
  5. package/devtools/transformers/src/transformComponentForHrm.js +74 -0
  6. package/devtools/transformers/src/transformJsFile.js +9 -0
  7. package/devtools/transformers/src/utils.js +79 -0
  8. package/devtools/widget/Widget.js +48 -0
  9. package/devtools/widget/widget.css +81 -0
  10. package/devtools/widget.js +23 -0
  11. package/dist/native-document.components.min.js +2441 -1191
  12. package/dist/native-document.dev.js +2710 -1359
  13. package/dist/native-document.dev.js.map +1 -1
  14. package/dist/native-document.devtools.min.js +1 -1
  15. package/dist/native-document.min.js +1 -1
  16. package/docs/cache.md +1 -1
  17. package/docs/core-concepts.md +1 -1
  18. package/docs/native-document-element.md +51 -15
  19. package/docs/observables.md +310 -306
  20. package/docs/state-management.md +198 -193
  21. package/index.def.js +762 -26
  22. package/package.json +1 -1
  23. package/readme.md +1 -1
  24. package/src/core/data/ObservableChecker.js +2 -0
  25. package/src/core/data/ObservableItem.js +97 -0
  26. package/src/core/data/ObservableObject.js +182 -0
  27. package/src/core/data/Store.js +364 -34
  28. package/src/core/data/observable-helpers/object.js +2 -166
  29. package/src/core/elements/anchor.js +28 -20
  30. package/src/core/elements/control/for-each.js +1 -1
  31. package/src/core/utils/formatters.js +91 -0
  32. package/src/core/utils/localstorage.js +57 -0
  33. package/src/core/utils/validator.js +0 -2
  34. package/src/core/wrappers/DocumentObserver.js +102 -31
  35. package/src/core/wrappers/ElementCreator.js +5 -0
  36. package/src/core/wrappers/NDElement.js +32 -1
  37. package/src/core/wrappers/prototypes/nd-element.transition.extensions.js +83 -0
  38. package/src/devtools.js +9 -0
  39. package/src/fetch/NativeFetch.js +5 -2
  40. package/types/elements.d.ts +580 -2
  41. package/types/nd-element.d.ts +6 -0
  42. package/types/observable.d.ts +71 -15
  43. package/types/plugins-manager.d.ts +1 -1
  44. package/types/store.d.ts +33 -6
  45. package/hrm.js +0 -7
  46. package/src/devtools/app/App.js +0 -66
  47. package/src/devtools/app/app.css +0 -0
  48. package/src/devtools/hrm/transformComponent.js +0 -129
  49. package/src/devtools/index.js +0 -18
  50. package/src/devtools/widget/DevToolsWidget.js +0 -26
  51. /package/{src/devtools/hrm → devtools/transformers/templates}/hrm.hook.template.js +0 -0
  52. /package/{src/devtools/hrm → devtools/transformers/templates}/hrm.orbservable.hook.template.js +0 -0
@@ -172,6 +172,53 @@ Div("Content").nd.mounted(element => {
172
172
  });
173
173
  ```
174
174
 
175
+ ### `unmounted(callback)`
176
+ Shortcut to define only the unmount callback.
177
+ ```javascript
178
+ Div("Content").nd.unmounted(element => {
179
+ console.log("Element removed from DOM!");
180
+ });
181
+ ```
182
+
183
+ ### `beforeUnmount(id, callback)`
184
+ Registers a callback executed before the element is removed from the DOM.
185
+ Useful for exit animations or cleanup before removal.
186
+ ```javascript
187
+ Div("Content").nd.beforeUnmount('my-cleanup', async () => {
188
+ await saveData();
189
+ });
190
+ ```
191
+
192
+ ## Transitions
193
+
194
+ ### `transition(name)`
195
+ Applies both enter and exit transitions using CSS classes.
196
+ ```javascript
197
+ Div("Content").nd.transition('fade');
198
+ // On mount : adds 'fade-enter-from', then 'fade-enter-to'
199
+ // On unmount: adds 'fade-exit'
200
+ ```
201
+
202
+ ### `transitionIn(name)`
203
+ Applies only the enter transition.
204
+ ```javascript
205
+ Div("Content").nd.transitionIn('slide');
206
+ ```
207
+
208
+ ### `transitionOut(name)`
209
+ Applies only the exit transition.
210
+ ```javascript
211
+ Div("Content").nd.transitionOut('slide');
212
+ ```
213
+
214
+ ### `animate(name)`
215
+ Triggers a one-shot CSS animation by adding then automatically removing a class.
216
+ ```javascript
217
+ Button("Click").nd.onClick(function() {
218
+ this.nd.animate('bounce');
219
+ });
220
+ ```
221
+
175
222
  ## Practical Examples
176
223
 
177
224
  ### Custom Event Handler
@@ -210,7 +257,7 @@ const todoForm = Form([
210
257
  Input({ type: 'text', value: newTodo })
211
258
  .nd.onEnter(addTodo),
212
259
 
213
- Button('Add', { type: 'submit' })
260
+ Button({ type: 'submit' }, 'Add')
214
261
  ]).nd.onPreventSubmit(addTodo);
215
262
  ```
216
263
 
@@ -224,19 +271,6 @@ element.nd.on('customEvent', callback, options)
224
271
  element.nd.on('scroll', callback, { passive: true })
225
272
  ```
226
273
 
227
- ### Batch Event Registration
228
-
229
- Register multiple events at once:
230
- ```javascript
231
- // Register multiple events in one call
232
- Input()
233
- .nd.on({
234
- focus: e => console.log('Focused'),
235
- blur: e => console.log('Blurred'),
236
- input: e => console.log('Value:', e.target.value)
237
- });
238
- ```
239
-
240
274
  ### Reference Management
241
275
 
242
276
  ```javascript
@@ -278,7 +312,9 @@ Div([
278
312
 
279
313
  ## Limitations
280
314
 
281
- - Event handlers are not automatically removed (manual management required if needed)
315
+ - Event handlers added via .nd.onXxx() are not automatically removed.
316
+ Use the native removeEventListener() on .$element if needed,
317
+ or rely on .nd.remove() which cleans up the element entirely.
282
318
  - Access to native HTML element is still necessary for advanced APIs
283
319
 
284
320
  NDElement thus provides a practical abstraction layer while preserving the power and performance of native DOM.