native-document 1.0.92 → 1.0.94

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 (85) hide show
  1. package/dist/native-document.components.min.js +1088 -65
  2. package/dist/native-document.dev.js +695 -142
  3. package/dist/native-document.dev.js.map +1 -1
  4. package/dist/native-document.devtools.min.js +1 -1
  5. package/dist/native-document.min.js +1 -1
  6. package/docs/advanced-components.md +814 -0
  7. package/docs/anchor.md +71 -11
  8. package/docs/cache.md +888 -0
  9. package/docs/conditional-rendering.md +91 -1
  10. package/docs/core-concepts.md +9 -2
  11. package/docs/elements.md +127 -2
  12. package/docs/extending-native-document-element.md +7 -1
  13. package/docs/filters.md +1216 -0
  14. package/docs/getting-started.md +12 -3
  15. package/docs/lifecycle-events.md +10 -2
  16. package/docs/list-rendering.md +453 -54
  17. package/docs/memory-management.md +9 -7
  18. package/docs/native-document-element.md +30 -9
  19. package/docs/native-fetch.md +744 -0
  20. package/docs/observables.md +135 -6
  21. package/docs/routing.md +7 -1
  22. package/docs/state-management.md +7 -1
  23. package/docs/validation.md +8 -1
  24. package/elements.js +1 -0
  25. package/eslint.config.js +3 -3
  26. package/index.def.js +350 -0
  27. package/package.json +3 -2
  28. package/readme.md +53 -14
  29. package/src/components/$traits/HasItems.js +42 -1
  30. package/src/components/BaseComponent.js +4 -1
  31. package/src/components/accordion/Accordion.js +112 -8
  32. package/src/components/accordion/AccordionItem.js +93 -4
  33. package/src/components/alert/Alert.js +164 -4
  34. package/src/components/avatar/Avatar.js +236 -22
  35. package/src/components/menu/index.js +1 -2
  36. package/src/core/data/ObservableArray.js +120 -2
  37. package/src/core/data/ObservableChecker.js +50 -0
  38. package/src/core/data/ObservableItem.js +124 -4
  39. package/src/core/data/ObservableWhen.js +36 -6
  40. package/src/core/data/observable-helpers/array.js +12 -3
  41. package/src/core/data/observable-helpers/computed.js +17 -4
  42. package/src/core/data/observable-helpers/object.js +19 -3
  43. package/src/core/elements/content-formatter.js +138 -1
  44. package/src/core/elements/control/for-each-array.js +20 -2
  45. package/src/core/elements/control/for-each.js +17 -5
  46. package/src/core/elements/control/show-if.js +31 -15
  47. package/src/core/elements/control/show-when.js +23 -0
  48. package/src/core/elements/control/switch.js +40 -10
  49. package/src/core/elements/description-list.js +14 -0
  50. package/src/core/elements/form.js +188 -4
  51. package/src/core/elements/html5-semantics.js +44 -1
  52. package/src/core/elements/img.js +22 -10
  53. package/src/core/elements/index.js +5 -0
  54. package/src/core/elements/interactive.js +19 -1
  55. package/src/core/elements/list.js +28 -1
  56. package/src/core/elements/medias.js +29 -0
  57. package/src/core/elements/meta-data.js +34 -0
  58. package/src/core/elements/table.js +59 -0
  59. package/src/core/utils/cache.js +5 -0
  60. package/src/core/utils/helpers.js +7 -2
  61. package/src/core/utils/memoize.js +25 -16
  62. package/src/core/utils/prototypes.js +3 -2
  63. package/src/core/wrappers/AttributesWrapper.js +1 -1
  64. package/src/core/wrappers/HtmlElementWrapper.js +2 -2
  65. package/src/core/wrappers/NDElement.js +42 -2
  66. package/src/core/wrappers/NdPrototype.js +4 -0
  67. package/src/core/wrappers/TemplateCloner.js +14 -11
  68. package/src/core/wrappers/prototypes/bind-class-extensions.js +1 -1
  69. package/src/core/wrappers/prototypes/nd-element-extensions.js +3 -0
  70. package/src/router/Route.js +9 -4
  71. package/src/router/Router.js +28 -9
  72. package/src/router/errors/RouterError.js +0 -1
  73. package/types/control-flow.d.ts +9 -6
  74. package/types/elements.d.ts +496 -111
  75. package/types/filters/index.d.ts +4 -0
  76. package/types/forms.d.ts +85 -48
  77. package/types/images.d.ts +16 -9
  78. package/types/nd-element.d.ts +5 -238
  79. package/types/observable.d.ts +9 -3
  80. package/types/router.d.ts +5 -1
  81. package/types/template-cloner.ts +1 -0
  82. package/types/validator.ts +11 -1
  83. package/utils.d.ts +2 -1
  84. package/utils.js +4 -4
  85. package/src/core/utils/service.js +0 -6
package/docs/anchor.md CHANGED
@@ -1,18 +1,19 @@
1
1
  # Anchor
2
2
 
3
- Anchors are a NativeDocument class that enables dynamic DOM manipulation without wrapper elements. They create two invisible comment nodes that act as boundaries, allowing you to insert, remove, and replace content between them.
3
+ Anchors enable dynamic DOM manipulation without wrapper elements. They use two invisible comment nodes as boundaries, allowing you to insert, remove, and replace content between them while keeping your DOM clean.
4
4
 
5
5
  ## What are Anchors?
6
6
 
7
7
  Anchors are instances of the Anchor class that use two comment nodes as invisible markers:
8
+ > **Important:** Anchors must be appended to a parent element to function. The comment markers only exist once the anchor is in the DOM.
8
9
 
9
- `NativeDocumentFragment is an Anchor alias`
10
+ > **Note:** `NativeDocumentFragment` is an alias for `Anchor` - both create the same anchor system.
10
11
 
11
12
  ```javascript
12
13
  // Create an anchor instance
13
14
  const anchor = Anchor("My Content");
14
15
  // Or using the alias
15
- const anchor = new NativeDocumentFragment("My Content");
16
+ const anchor = NativeDocumentFragment("My Content");
16
17
 
17
18
  // In the DOM, this creates:
18
19
  // <!-- Anchor Start : My Content -->
@@ -30,9 +31,12 @@ anchor.appendChild(Div("Dynamic content"));
30
31
  **Fragment** is a wrapper around `document.createDocumentFragment()`:
31
32
 
32
33
  ```javascript
33
- // Fragment is standard DOM DocumentFragment
34
+ // Fragment creates a standard DOM DocumentFragment
34
35
  const fragment = Fragment(); // Wraps document.createDocumentFragment()
35
- fragment.appendChild(Div("Standard fragment content"));
36
+ fragment.appendChild([
37
+ Div("Standard fragment content"),
38
+ Div("Standard fragment content 2"),
39
+ ]); // Returns document.createDocumentFragment() with children
36
40
  ```
37
41
 
38
42
  **Anchor** is a NativeDocument class for dynamic content management:
@@ -43,6 +47,36 @@ const anchor = Anchor("Dynamic Area");
43
47
  anchor.appendChild(Div("Dynamic content")); // Uses comment markers system
44
48
  ```
45
49
 
50
+ ## Anchor vs DOM Elements
51
+
52
+ ### Why Use Anchors?
53
+
54
+ **Without Anchors (wrapper element):**
55
+ ```javascript
56
+ const wrapper = Div({ class: 'wrapper' }); // Extra DOM node
57
+
58
+ if (condition) {
59
+ wrapper.appendChild(Div("Content"));
60
+ }
61
+ // DOM: Content
62
+ ```
63
+
64
+ **With Anchors (no wrapper):**
65
+ ```javascript
66
+ const anchor = Anchor("Content");
67
+
68
+ if (condition) {
69
+ anchor.appendChild(Div("Content"));
70
+ }
71
+ // DOM: Content<!-- / Anchor End Content -->
72
+ ```
73
+
74
+ **Benefits:**
75
+ - ✅ No extra DOM nodes
76
+ - ✅ Cleaner HTML structure
77
+ - ✅ Better semantic markup
78
+ - ✅ Easier CSS targeting (no wrapper interference)
79
+
46
80
  ## Creating and Using Anchors
47
81
 
48
82
  ### Creating Anchors
@@ -77,6 +111,23 @@ anchor.appendChild(Div("Dynamic content 2"));
77
111
  // </div>
78
112
  ```
79
113
 
114
+ ### appendChild() with Arrays
115
+ ```javascript
116
+ const anchor = Anchor("Multi Insert");
117
+
118
+ // Append multiple elements at once
119
+ anchor.appendChild([
120
+ Div("Element 1"),
121
+ Div("Element 2"),
122
+ Div("Element 3")
123
+ ]);
124
+
125
+ // More efficient than multiple calls:
126
+ // anchor.appendChild(Div("Element 1"));
127
+ // anchor.appendChild(Div("Element 2"));
128
+ // anchor.appendChild(Div("Element 3"));
129
+ ```
130
+
80
131
  ### insertBefore() - Positioned Insertion
81
132
 
82
133
  ```javascript
@@ -115,6 +166,7 @@ anchor.clear();
115
166
  ```
116
167
 
117
168
  ### removeWithAnchors() - Complete Removal
169
+ > **Warning:** Once `removeWithAnchors()` is called, the anchor instance becomes unusable. Create a new anchor if you need dynamic content again.
118
170
 
119
171
  ```javascript
120
172
  // Remove markers AND all content permanently
@@ -287,7 +339,8 @@ anchor.appendChild(Div("Item 2"));
287
339
  function ConditionalList(condition, items) {
288
340
  const anchor = Anchor("ConditionalList");
289
341
 
290
- const updateContent = (value) => {
342
+ const updateContent = () => {
343
+ const value = items.val();
291
344
  console.log(value);
292
345
  if (value) {
293
346
  const listItems = items.val().map(item => Li(item));
@@ -299,15 +352,15 @@ function ConditionalList(condition, items) {
299
352
 
300
353
  condition.subscribe(updateContent);
301
354
  items.subscribe(updateContent);
302
- updateContent(condition.val()); // Initial render
355
+ updateContent(); // Initial render
303
356
 
304
357
  return anchor;
305
358
  }
306
359
 
307
- // use ConditionalList
308
- const condition = new Observable(true);
360
+ // Usage example
361
+ const condition = Observable(true);
309
362
  let id = 0;
310
- const items = new Observable.array([]);
363
+ const items = Observable.array([]);
311
364
 
312
365
  document.body.appendChild(Div([
313
366
  ConditionalList(condition, items),
@@ -374,5 +427,12 @@ anchor.replaceContent(content2);
374
427
  - **[State Management](state-management.md)** - Global state patterns
375
428
  - **[NDElement](native-document-element.md)** - Native Document Element
376
429
  - **[Extending NDElement](extending-native-document-element.md)** - Custom Methods Guide
430
+ - **[Advanced Components](advanced-components.md)** - Template caching and singleton views
377
431
  - **[Args Validation](validation.md)** - Function Argument Validation
378
- - **[Memory Management](memory-management.md)** - Memory management
432
+ - **[Memory Management](memory-management.md)** - Memory management
433
+
434
+ ## Utilities
435
+
436
+ - **[Cache](docs/utils/cache.md)** - Lazy initialization and singleton patterns
437
+ - **[NativeFetch](docs/utils/native-fetch.md)** - HTTP client with interceptors
438
+ - **[Filters](docs/utils/filters.md)** - Data filtering helpers