native-document 1.0.92 → 1.0.93

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 (68) 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/eslint.config.js +3 -3
  25. package/package.json +3 -2
  26. package/readme.md +53 -14
  27. package/src/components/$traits/HasItems.js +42 -1
  28. package/src/components/BaseComponent.js +4 -1
  29. package/src/components/accordion/Accordion.js +112 -8
  30. package/src/components/accordion/AccordionItem.js +93 -4
  31. package/src/components/alert/Alert.js +164 -4
  32. package/src/components/avatar/Avatar.js +236 -22
  33. package/src/components/menu/index.js +1 -2
  34. package/src/core/data/ObservableArray.js +120 -2
  35. package/src/core/data/ObservableChecker.js +50 -0
  36. package/src/core/data/ObservableItem.js +124 -4
  37. package/src/core/data/ObservableWhen.js +36 -6
  38. package/src/core/data/observable-helpers/array.js +12 -3
  39. package/src/core/data/observable-helpers/computed.js +17 -4
  40. package/src/core/data/observable-helpers/object.js +19 -3
  41. package/src/core/elements/control/for-each-array.js +20 -2
  42. package/src/core/elements/control/for-each.js +17 -5
  43. package/src/core/elements/control/show-if.js +31 -15
  44. package/src/core/elements/control/show-when.js +23 -0
  45. package/src/core/elements/control/switch.js +40 -10
  46. package/src/core/utils/cache.js +5 -0
  47. package/src/core/utils/memoize.js +25 -16
  48. package/src/core/utils/prototypes.js +3 -2
  49. package/src/core/wrappers/AttributesWrapper.js +1 -1
  50. package/src/core/wrappers/NDElement.js +41 -1
  51. package/src/core/wrappers/NdPrototype.js +4 -0
  52. package/src/core/wrappers/TemplateCloner.js +13 -10
  53. package/src/core/wrappers/prototypes/bind-class-extensions.js +1 -1
  54. package/src/core/wrappers/prototypes/nd-element-extensions.js +3 -0
  55. package/src/router/Route.js +9 -4
  56. package/src/router/Router.js +28 -9
  57. package/src/router/errors/RouterError.js +0 -1
  58. package/types/control-flow.d.ts +9 -6
  59. package/types/elements.d.ts +6 -3
  60. package/types/filters/index.d.ts +4 -0
  61. package/types/nd-element.d.ts +5 -238
  62. package/types/observable.d.ts +9 -3
  63. package/types/router.d.ts +5 -1
  64. package/types/template-cloner.ts +1 -0
  65. package/types/validator.ts +11 -1
  66. package/utils.d.ts +2 -1
  67. package/utils.js +4 -4
  68. package/src/core/utils/service.js +0 -6
@@ -1,6 +1,10 @@
1
1
  var NativeComponents = (function (exports) {
2
2
  'use strict';
3
3
 
4
+ /**
5
+ *
6
+ * @class
7
+ */
4
8
  function BaseComponent() {
5
9
 
6
10
  }
@@ -125,6 +129,17 @@ var NativeComponents = (function (exports) {
125
129
  };
126
130
  EventEmitter.prototype.emit = EventEmitter.prototype.trigger;
127
131
 
132
+ /**
133
+ * Valid children types that can be rendered in the DOM
134
+ * @typedef {HTMLElement|Text|DocumentFragment|string|Array<ValidChildren>} ValidChildren
135
+ */
136
+
137
+ /**
138
+ * Component for creating accordion interfaces with expandable/collapsible items
139
+ * @param {{ items?: Array<AccordionItem>, multiple?: boolean, variant?: string, renderContent?: (field: Accordion) => HTMLElement }} config
140
+ * @returns {Accordion}
141
+ * @class
142
+ */
128
143
  function Accordion(config = {}) {
129
144
  if (!(this instanceof Accordion)) {
130
145
  return new Accordion(config);
@@ -143,20 +158,47 @@ var NativeComponents = (function (exports) {
143
158
 
144
159
  Accordion.defaultTemplate = null;
145
160
 
146
- Accordion.use = function(template) {};
147
161
 
162
+ /**
163
+ * Sets the default template for all Accordion instances
164
+ * @param {{accordion: (accordion: Accordion) => ValidChildren}} template - Template object containing accordion factory function
165
+ */
166
+ Accordion.use = function(template) {
167
+ Accordion.defaultTemplate = template.accordion;
168
+ };
169
+
170
+ /**
171
+ * Adds an accordion item to the collection
172
+ * @param {AccordionItem} accordionItem - The accordion item to add
173
+ * @returns {Accordion}
174
+ */
148
175
  Accordion.prototype.item = function(accordionItem) {
149
176
  this.$description.items.push(accordionItem);
150
177
  return this;
151
178
  };
152
179
 
180
+ /**
181
+ * Sets the accordion items collection
182
+ * @param {Array<AccordionItem>} items - Array of accordion items
183
+ * @returns {Accordion}
184
+ */
153
185
  Accordion.prototype.items = function(items) {
154
186
  this.$description.items = items;
155
187
  return this;
156
188
  };
157
189
 
190
+ /**
191
+ * Alias for item method
192
+ * @param {AccordionItem} accordionItem - The accordion item to add
193
+ * @returns {Accordion}
194
+ */
158
195
  Accordion.prototype.addItem = Accordion.prototype.item;
159
196
 
197
+ /**
198
+ * Removes an item by its id
199
+ * @param {string} id - The id of the item to remove
200
+ * @returns {Accordion}
201
+ */
160
202
  Accordion.prototype.removeItemById = function(id) {
161
203
  if (this.$description.items) {
162
204
  this.$description.items = this.$description.items.filter(item => item.id !== id);
@@ -164,40 +206,77 @@ var NativeComponents = (function (exports) {
164
206
  return this;
165
207
  };
166
208
 
167
- Accordion.prototype.removeItem = function(item) {
209
+ /**
210
+ * Removes items matching the filter function
211
+ * @param {Function} filter - Filter function to determine which items to keep
212
+ * @returns {Accordion}
213
+ */
214
+ Accordion.prototype.remove = function(filter) {
168
215
  if (this.$description.items) {
169
- this.$description.items = this.$description.items.filter(item);
216
+ this.$description.items = this.$description.items.filter(filter);
170
217
  }
171
218
  return this;
172
219
  };
173
220
 
174
-
221
+ /**
222
+ * Enables or disables multiple items expansion
223
+ * @param {boolean} [enabled=true] - Whether multiple items can be expanded simultaneously
224
+ * @returns {Accordion}
225
+ */
175
226
  Accordion.prototype.multiple = function(enabled = true) {
176
227
  this.$description.multiple = enabled;
177
228
  return this;
178
229
  };
179
230
 
231
+ /**
232
+ * Sets the variant style for the accordion
233
+ * @param {string} name - The variant name
234
+ * @returns {Accordion}
235
+ */
180
236
  Accordion.prototype.variant = function(name) {
181
237
  this.$description.variant = name;
182
238
  return this;
183
239
  };
184
240
 
241
+ /**
242
+ * Sets the accordion variant to 'bordered'
243
+ * @returns {Accordion}
244
+ */
185
245
  Accordion.prototype.bordered = function() {
186
246
  return this.variant('bordered');
187
247
  };
188
248
 
249
+ /**
250
+ * Sets the accordion variant to 'separated'
251
+ * @returns {Accordion}
252
+ */
189
253
  Accordion.prototype.separated = function() {
190
254
  return this.variant('separated');
191
255
  };
192
256
 
257
+ /**
258
+ * Sets the accordion variant to 'flush'
259
+ * @returns {Accordion}
260
+ */
193
261
  Accordion.prototype.flush = function() {
194
262
  return this.variant('flush');
195
263
  };
196
264
 
265
+ /**
266
+ * Retrieves an accordion item by its key
267
+ * @param {string} key - The key of the item to retrieve
268
+ * @returns {AccordionItem|undefined}
269
+ */
197
270
  Accordion.prototype.getByKey = function(key) {
198
271
  return this.$description.items.find(item => item.key === key);
199
272
  };
200
273
 
274
+ /**
275
+ * Expands or collapses an accordion item by key
276
+ * @param {string} key - The key of the item
277
+ * @param {boolean} [state=true] - Whether to expand (true) or collapse (false)
278
+ * @returns {Accordion}
279
+ */
201
280
  Accordion.prototype.expanded = function(key, state = true) {
202
281
  const item = this.getByKey(key);
203
282
  if(item) {
@@ -210,35 +289,67 @@ var NativeComponents = (function (exports) {
210
289
  return this;
211
290
  };
212
291
 
292
+ /**
293
+ * Expands all accordion items
294
+ * @returns {Accordion}
295
+ */
213
296
  Accordion.prototype.expandAll = function() {
214
297
  this.$description.items.forEach(item => item.expanded(true));
215
298
  return this;
216
299
  };
217
300
 
301
+ /**
302
+ * Collapses all accordion items
303
+ * @returns {Accordion}
304
+ */
218
305
  Accordion.prototype.collapseAll = function() {
219
306
  this.$description.items.forEach(item => item.expanded(false));
220
307
  return this;
221
308
  };
222
309
 
310
+ /**
311
+ * Checks if an accordion item is expanded
312
+ * @param {string} key - The key of the item to check
313
+ * @returns {boolean|undefined}
314
+ */
223
315
  Accordion.prototype.isExpanded = function(key) {
224
316
  return this.getByKey(key)?.isExpanded?.();
225
317
  };
226
318
 
319
+ /**
320
+ * Registers a handler for the expand event
321
+ * @param {Function} handler - The event handler
322
+ * @returns {Accordion}
323
+ */
227
324
  Accordion.prototype.onExpand = function(handler) {
228
325
  this.on('expand', handler);
229
326
  return this;
230
327
  };
231
328
 
329
+ /**
330
+ * Registers a handler for the collapse event
331
+ * @param {Function} handler - The event handler
332
+ * @returns {Accordion}
333
+ */
232
334
  Accordion.prototype.onCollapse = function(handler) {
233
335
  this.on('collapse', handler);
234
336
  return this;
235
337
  };
236
338
 
339
+ /**
340
+ * Sets the content render function
341
+ * @param {Function} renderFn - Function to render content
342
+ * @returns {Accordion}
343
+ */
237
344
  Accordion.prototype.renderContent = function(renderFn) {
238
345
  this.$description.renderContent = renderFn;
239
346
  return this;
240
347
  };
241
348
 
349
+ /**
350
+ * Builds the accordion component
351
+ * @private
352
+ */
242
353
  Accordion.prototype.$build = function() {
243
354
  // TODO: Implementation
244
355
  // this.$description.items.forEach(item => {
@@ -252,10 +363,6 @@ var NativeComponents = (function (exports) {
252
363
  // });
253
364
  };
254
365
 
255
- Accordion.prototype.toNdElement = function() {
256
- return this.$build();
257
- };
258
-
259
366
  let DebugManager$1 = {};
260
367
  {
261
368
  DebugManager$1 = {
@@ -334,6 +441,16 @@ var NativeComponents = (function (exports) {
334
441
 
335
442
  ObservableChecker.prototype.__$isObservableChecker = true;
336
443
 
444
+ /**
445
+ * Subscribes to changes in the checked/transformed value.
446
+ *
447
+ * @param {Function} callback - Function called with the transformed value when observable changes
448
+ * @returns {Function} Unsubscribe function
449
+ * @example
450
+ * const count = Observable(5);
451
+ * const doubled = count.check(n => n * 2);
452
+ * doubled.subscribe(value => console.log(value)); // Logs: 10
453
+ */
337
454
  ObservableChecker.prototype.subscribe = function(callback) {
338
455
  const unSubscribe = this.observable.subscribe((value) => {
339
456
  callback && callback(this.checker(value));
@@ -342,26 +459,73 @@ var NativeComponents = (function (exports) {
342
459
  return unSubscribe;
343
460
  };
344
461
 
462
+ /**
463
+ * Creates a new ObservableChecker by applying another transformation.
464
+ * Allows chaining transformations.
465
+ *
466
+ * @param {(value: *) => *} callback - Transformation function to apply to the current checked value
467
+ * @returns {ObservableChecker} New ObservableChecker with chained transformation
468
+ * @example
469
+ * const count = Observable(5);
470
+ * const result = count.check(n => n * 2).check(n => n + 1);
471
+ * result.val(); // 11
472
+ */
345
473
  ObservableChecker.prototype.check = function(callback) {
346
474
  return this.observable.check(() => callback(this.val()));
347
475
  };
348
476
 
477
+ /**
478
+ * Gets the current transformed/checked value.
479
+ *
480
+ * @returns {*} The result of applying the checker function to the observable's current value
481
+ * @example
482
+ * const count = Observable(5);
483
+ * const doubled = count.check(n => n * 2);
484
+ * doubled.val(); // 10
485
+ */
349
486
  ObservableChecker.prototype.val = function() {
350
487
  return this.checker && this.checker(this.observable.val());
351
488
  };
352
489
 
490
+ /**
491
+ * Sets the value of the underlying observable (not the transformed value).
492
+ *
493
+ * @param {*} value - New value for the underlying observable
494
+ * @example
495
+ * const count = Observable(5);
496
+ * const doubled = count.check(n => n * 2);
497
+ * doubled.set(10); // Sets count to 10, doubled.val() returns 20
498
+ */
353
499
  ObservableChecker.prototype.set = function(value) {
354
500
  return this.observable.set(value);
355
501
  };
356
502
 
503
+ /**
504
+ * Manually triggers the underlying observable to notify subscribers.
505
+ *
506
+ * @example
507
+ * const count = Observable(5);
508
+ * const doubled = count.check(n => n * 2);
509
+ * doubled.trigger(); // Notifies all subscribers
510
+ */
357
511
  ObservableChecker.prototype.trigger = function() {
358
512
  return this.observable.trigger();
359
513
  };
360
514
 
515
+ /**
516
+ * Cleans up the underlying observable and all its subscriptions.
517
+ */
361
518
  ObservableChecker.prototype.cleanup = function() {
362
519
  return this.observable.cleanup();
363
520
  };
364
521
 
522
+ /**
523
+ * Creates an ObservableWhen that tracks whether an observable equals a specific value.
524
+ *
525
+ * @param {ObservableItem} observer - The observable to watch
526
+ * @param {*} value - The value to compare against
527
+ * @class ObservableWhen
528
+ */
365
529
  const ObservableWhen = function(observer, value) {
366
530
  this.$target = value;
367
531
  this.$observer = observer;
@@ -369,21 +533,44 @@ var NativeComponents = (function (exports) {
369
533
 
370
534
  ObservableWhen.prototype.__$isObservableWhen = true;
371
535
 
536
+ /**
537
+ * Subscribes to changes in the match status (true when observable equals target value).
538
+ *
539
+ * @param {Function} callback - Function called with boolean indicating if values match
540
+ * @returns {Function} Unsubscribe function
541
+ * @example
542
+ * const status = Observable('idle');
543
+ * const isLoading = status.when('loading');
544
+ * isLoading.subscribe(active => console.log('Loading:', active));
545
+ */
372
546
  ObservableWhen.prototype.subscribe = function(callback) {
373
547
  return this.$observer.on(this.$target, callback);
374
548
  };
375
549
 
550
+ /**
551
+ * Returns true if the observable's current value equals the target value.
552
+ *
553
+ * @returns {boolean} True if observable value matches target value
554
+ */
376
555
  ObservableWhen.prototype.val = function() {
377
556
  return this.$observer.$currentValue === this.$target;
378
557
  };
379
558
 
380
- ObservableWhen.prototype.isMath = function() {
381
- return this.$observer.$currentValue === this.$target;
382
- };
559
+ /**
560
+ * Returns true if the observable's current value equals the target value.
561
+ * Alias for val().
562
+ *
563
+ * @returns {boolean} True if observable value matches target value
564
+ */
565
+ ObservableWhen.prototype.isMatch = ObservableWhen.prototype.val;
383
566
 
384
- ObservableWhen.prototype.isActive = function() {
385
- return this.$observer.$currentValue === this.$target;
386
- };
567
+ /**
568
+ * Returns true if the observable's current value equals the target value.
569
+ * Alias for val().
570
+ *
571
+ * @returns {boolean} True if observable value matches target value
572
+ */
573
+ ObservableWhen.prototype.isActive = ObservableWhen.prototype.val;
387
574
 
388
575
  const invoke = function(fn, args, context) {
389
576
  if(context) {
@@ -500,6 +687,16 @@ var NativeComponents = (function (exports) {
500
687
  ObservableItem.prototype.__$isObservable = true;
501
688
  const noneTrigger = function() {};
502
689
 
690
+ /**
691
+ * Intercepts and transforms values before they are set on the observable.
692
+ * The interceptor can modify the value or return undefined to use the original value.
693
+ *
694
+ * @param {(value) => any} callback - Interceptor function that receives (newValue, currentValue) and returns the transformed value or undefined
695
+ * @returns {ObservableItem} The observable instance for chaining
696
+ * @example
697
+ * const count = Observable(0);
698
+ * count.intercept((newVal, oldVal) => Math.max(0, newVal)); // Prevent negative values
699
+ */
503
700
  ObservableItem.prototype.intercept = function(callback) {
504
701
  this.$interceptor = callback;
505
702
  this.set = this.$setWithInterceptor;
@@ -625,6 +822,16 @@ var NativeComponents = (function (exports) {
625
822
  this.trigger = noneTrigger;
626
823
  };
627
824
 
825
+ /**
826
+ * Registers a cleanup callback that will be executed when the observable is cleaned up.
827
+ * Useful for disposing resources, removing event listeners, or other cleanup tasks.
828
+ *
829
+ * @param {Function} callback - Cleanup function to execute on observable disposal
830
+ * @example
831
+ * const obs = Observable(0);
832
+ * obs.onCleanup(() => console.log('Cleaned up!'));
833
+ * obs.cleanup(); // Logs: "Cleaned up!"
834
+ */
628
835
  ObservableItem.prototype.onCleanup = function(callback) {
629
836
  this.$cleanupListeners = this.$cleanupListeners ?? [];
630
837
  this.$cleanupListeners.push(callback);
@@ -654,6 +861,17 @@ var NativeComponents = (function (exports) {
654
861
  this.assocTrigger();
655
862
  };
656
863
 
864
+ /**
865
+ * Watches for a specific value and executes callback when the observable equals that value.
866
+ * Creates a watcher that only triggers when the observable changes to the specified value.
867
+ *
868
+ * @param {*} value - The value to watch for
869
+ * @param {(value) => void|ObservableItem} callback - Callback function or observable to set when value matches
870
+ * @example
871
+ * const status = Observable('idle');
872
+ * status.on('loading', () => console.log('Started loading'));
873
+ * status.on('error', isError); // Set another observable
874
+ */
657
875
  ObservableItem.prototype.on = function(value, callback) {
658
876
  this.$watchers = this.$watchers ?? new Map();
659
877
 
@@ -683,8 +901,16 @@ var NativeComponents = (function (exports) {
683
901
  };
684
902
 
685
903
  /**
686
- * @param {*} value
687
- * @param {Function} callback - if omitted, removes all watchers for this value
904
+ * Removes a watcher for a specific value. If no callback is provided, removes all watchers for that value.
905
+ *
906
+ * @param {*} value - The value to stop watching
907
+ * @param {Function} [callback] - Specific callback to remove. If omitted, removes all watchers for this value
908
+ * @example
909
+ * const status = Observable('idle');
910
+ * const handler = () => console.log('Loading');
911
+ * status.on('loading', handler);
912
+ * status.off('loading', handler); // Remove specific handler
913
+ * status.off('loading'); // Remove all handlers for 'loading'
688
914
  */
689
915
  ObservableItem.prototype.off = function(value, callback) {
690
916
  if(!this.$watchers) return;
@@ -704,11 +930,20 @@ var NativeComponents = (function (exports) {
704
930
  }
705
931
  else if(watchValueList.length === 0) {
706
932
  this.$watchers?.delete(value);
707
- watchValueList = null;
708
933
  }
709
934
  this.assocTrigger();
710
935
  };
711
936
 
937
+ /**
938
+ * Subscribes to the observable but automatically unsubscribes after the first time the predicate matches.
939
+ *
940
+ * @param {(value) => Boolean|any} predicate - Value to match or function that returns true when condition is met
941
+ * @param {(value) => void} callback - Callback to execute when predicate matches, receives the matched value
942
+ * @example
943
+ * const status = Observable('loading');
944
+ * status.once('ready', (val) => console.log('Ready!'));
945
+ * status.once(val => val === 'error', (val) => console.log('Error occurred'));
946
+ */
712
947
  ObservableItem.prototype.once = function(predicate, callback) {
713
948
  const fn = typeof predicate === 'function' ? predicate : (v) => v === predicate;
714
949
 
@@ -743,15 +978,50 @@ var NativeComponents = (function (exports) {
743
978
  return new ObservableChecker(this, callback)
744
979
  };
745
980
 
981
+ /**
982
+ * Gets a property value from the observable's current value.
983
+ * If the property is an observable, returns its value.
984
+ *
985
+ * @param {string|number} key - Property key to retrieve
986
+ * @returns {*} The value of the property, unwrapped if it's an observable
987
+ * @example
988
+ * const user = Observable({ name: 'John', age: Observable(25) });
989
+ * user.get('name'); // 'John'
990
+ * user.get('age'); // 25 (unwrapped from observable)
991
+ */
746
992
  ObservableItem.prototype.get = function(key) {
747
993
  const item = this.$currentValue[key];
748
994
  return Validator.isObservable(item) ? item.val() : item;
749
995
  };
750
996
 
997
+ /**
998
+ * Creates an ObservableWhen that represents whether the observable equals a specific value.
999
+ * Returns an object that can be subscribed to and will emit true/false.
1000
+ *
1001
+ * @param {*} value - The value to compare against
1002
+ * @returns {ObservableWhen} An ObservableWhen instance that tracks when the observable equals the value
1003
+ * @example
1004
+ * const status = Observable('idle');
1005
+ * const isLoading = status.when('loading');
1006
+ * isLoading.subscribe(active => console.log('Loading:', active));
1007
+ * status.set('loading'); // Logs: "Loading: true"
1008
+ */
751
1009
  ObservableItem.prototype.when = function(value) {
752
1010
  return new ObservableWhen(this, value);
753
1011
  };
754
1012
 
1013
+ /**
1014
+ * Compares the observable's current value with another value or observable.
1015
+ *
1016
+ * @param {*|ObservableItem} other - Value or observable to compare against
1017
+ * @returns {boolean} True if values are equal
1018
+ * @example
1019
+ * const a = Observable(5);
1020
+ * const b = Observable(5);
1021
+ * a.equals(5); // true
1022
+ * a.equals(b); // true
1023
+ * a.equals(10); // false
1024
+ */
755
1025
  ObservableItem.prototype.equals = function(other) {
756
1026
  if(Validator.isObservable(other)) {
757
1027
  return this.$currentValue === other.$currentValue;
@@ -759,14 +1029,41 @@ var NativeComponents = (function (exports) {
759
1029
  return this.$currentValue === other;
760
1030
  };
761
1031
 
1032
+ /**
1033
+ * Converts the observable's current value to a boolean.
1034
+ *
1035
+ * @returns {boolean} The boolean representation of the current value
1036
+ * @example
1037
+ * const count = Observable(0);
1038
+ * count.toBool(); // false
1039
+ * count.set(5);
1040
+ * count.toBool(); // true
1041
+ */
762
1042
  ObservableItem.prototype.toBool = function() {
763
1043
  return !!this.$currentValue;
764
1044
  };
765
1045
 
1046
+ /**
1047
+ * Toggles the boolean value of the observable (false becomes true, true becomes false).
1048
+ *
1049
+ * @example
1050
+ * const isOpen = Observable(false);
1051
+ * isOpen.toggle(); // Now true
1052
+ * isOpen.toggle(); // Now false
1053
+ */
766
1054
  ObservableItem.prototype.toggle = function() {
767
1055
  this.set(!this.$currentValue);
768
1056
  };
769
1057
 
1058
+ /**
1059
+ * Resets the observable to its initial value.
1060
+ * Only works if the observable was created with { reset: true } config.
1061
+ *
1062
+ * @example
1063
+ * const count = Observable(0, { reset: true });
1064
+ * count.set(10);
1065
+ * count.reset(); // Back to 0
1066
+ */
770
1067
  ObservableItem.prototype.reset = function() {
771
1068
  if(!this.configs?.reset) {
772
1069
  return;
@@ -779,11 +1076,21 @@ var NativeComponents = (function (exports) {
779
1076
  this.set(resetValue);
780
1077
  };
781
1078
 
782
-
1079
+ /**
1080
+ * Returns a string representation of the observable's current value.
1081
+ *
1082
+ * @returns {string} String representation of the current value
1083
+ */
783
1084
  ObservableItem.prototype.toString = function() {
784
1085
  return String(this.$currentValue);
785
1086
  };
786
1087
 
1088
+ /**
1089
+ * Returns the primitive value of the observable (its current value).
1090
+ * Called automatically in type coercion contexts.
1091
+ *
1092
+ * @returns {*} The current value of the observable
1093
+ */
787
1094
  ObservableItem.prototype.valueOf = function() {
788
1095
  return this.$currentValue;
789
1096
  };
@@ -988,12 +1295,35 @@ var NativeComponents = (function (exports) {
988
1295
  return this.shadow('closed', style);
989
1296
  };
990
1297
 
1298
+ /**
1299
+ * Attaches a template binding to the element by hydrating it with the specified method.
1300
+ *
1301
+ * @param {string} methodName - Name of the hydration method to call
1302
+ * @param {BindingHydrator} bindingHydrator - Template binding with $hydrate method
1303
+ * @returns {HTMLElement} The underlying HTML element
1304
+ * @example
1305
+ * const onClick = $binder.attach((event, data) => console.log(data));
1306
+ * element.nd.attach('onClick', onClick);
1307
+ */
991
1308
  NDElement.prototype.attach = function(methodName, bindingHydrator) {
992
1309
  bindingHydrator.$hydrate(this.$element, methodName);
993
1310
  return this.$element;
994
1311
  };
995
1312
 
996
-
1313
+ /**
1314
+ * Extends the current NDElement instance with custom methods.
1315
+ * Methods are bound to the instance and available for chaining.
1316
+ *
1317
+ * @param {Object} methods - Object containing method definitions
1318
+ * @returns {this} The NDElement instance with added methods for chaining
1319
+ * @example
1320
+ * element.nd.with({
1321
+ * highlight() {
1322
+ * this.$element.style.background = 'yellow';
1323
+ * return this;
1324
+ * }
1325
+ * }).highlight().onClick(() => console.log('Clicked'));
1326
+ */
997
1327
  NDElement.prototype.with = function(methods) {
998
1328
  if (!methods || typeof methods !== 'object') {
999
1329
  throw new NativeDocumentError('extend() requires an object of methods');
@@ -1013,6 +1343,23 @@ var NativeComponents = (function (exports) {
1013
1343
  return this;
1014
1344
  };
1015
1345
 
1346
+ /**
1347
+ * Extends the NDElement prototype with new methods available to all NDElement instances.
1348
+ * Use this to add global methods to all NDElements.
1349
+ *
1350
+ * @param {Object} methods - Object containing method definitions to add to prototype
1351
+ * @returns {typeof NDElement} The NDElement constructor
1352
+ * @throws {NativeDocumentError} If methods is not an object or contains non-function values
1353
+ * @example
1354
+ * NDElement.extend({
1355
+ * fadeIn() {
1356
+ * this.$element.style.opacity = '1';
1357
+ * return this;
1358
+ * }
1359
+ * });
1360
+ * // Now all NDElements have .fadeIn() method
1361
+ * Div().nd.fadeIn();
1362
+ */
1016
1363
  NDElement.extend = function(methods) {
1017
1364
  if (!methods || typeof methods !== 'object') {
1018
1365
  throw new NativeDocumentError('NDElement.extend() requires an object of methods');
@@ -1441,7 +1788,7 @@ var NativeComponents = (function (exports) {
1441
1788
  continue;
1442
1789
  }
1443
1790
  if(value.__$isObservableWhen) {
1444
- element.classes.toggle(className, value.isMath());
1791
+ element.classes.toggle(className, value.isActive());
1445
1792
  value.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
1446
1793
  continue;
1447
1794
  }
@@ -1585,6 +1932,8 @@ var NativeComponents = (function (exports) {
1585
1932
  return ElementCreator.createObservableNode(null, this);
1586
1933
  };
1587
1934
 
1935
+ ObservableChecker.prototype.toNdElement = ObservableItem.prototype.toNdElement;
1936
+
1588
1937
  NDElement.prototype.toNdElement = function () {
1589
1938
  return this.$element ?? this.$build?.() ?? this.build?.() ?? null;
1590
1939
  };
@@ -1914,6 +2263,10 @@ var NativeComponents = (function (exports) {
1914
2263
  _stop(this.$element, eventName, callback);
1915
2264
  return this;
1916
2265
  };
2266
+ NDElement.prototype['onPreventStop'+eventSourceName] = function(callback = null) {
2267
+ _preventStop(this.$element, eventName, callback);
2268
+ return this;
2269
+ };
1917
2270
  });
1918
2271
 
1919
2272
  EVENTS_WITH_PREVENT.forEach(eventSourceName => {
@@ -1947,6 +2300,16 @@ var NativeComponents = (function (exports) {
1947
2300
  return this;
1948
2301
  };
1949
2302
 
2303
+ const _preventStop = function(element, eventName, callback) {
2304
+ const handler = (event) => {
2305
+ event.stopPropagation();
2306
+ event.preventDefault();
2307
+ callback && callback.call(element, event);
2308
+ };
2309
+ element.addEventListener(eventName, handler);
2310
+ return this;
2311
+ };
2312
+
1950
2313
 
1951
2314
 
1952
2315
  // ----------------------------------------------------------------
@@ -2057,13 +2420,14 @@ var NativeComponents = (function (exports) {
2057
2420
  };
2058
2421
 
2059
2422
  Function.prototype.errorBoundary = function(callback) {
2060
- return (...args) => {
2423
+ const handler = (...args) => {
2061
2424
  try {
2062
2425
  return this.apply(this, args);
2063
2426
  } catch(e) {
2064
- return callback(e);
2427
+ return callback(e, {caller: handler, args: args });
2065
2428
  }
2066
2429
  };
2430
+ return handler;
2067
2431
  };
2068
2432
 
2069
2433
  String.prototype.use = function(args) {
@@ -2173,6 +2537,14 @@ var NativeComponents = (function (exports) {
2173
2537
  };
2174
2538
  });
2175
2539
 
2540
+ /**
2541
+ * Removes all items from the array and triggers an update.
2542
+ *
2543
+ * @returns {boolean} True if array was cleared, false if it was already empty
2544
+ * @example
2545
+ * const items = Observable.array([1, 2, 3]);
2546
+ * items.clear(); // []
2547
+ */
2176
2548
  ObservableArray.prototype.clear = function() {
2177
2549
  if(this.$currentValue.length === 0) {
2178
2550
  return;
@@ -2182,19 +2554,42 @@ var NativeComponents = (function (exports) {
2182
2554
  return true;
2183
2555
  };
2184
2556
 
2557
+ /**
2558
+ * Returns the element at the specified index in the array.
2559
+ *
2560
+ * @param {number} index - Zero-based index of the element to retrieve
2561
+ * @returns {*} The element at the specified index
2562
+ * @example
2563
+ * const items = Observable.array(['a', 'b', 'c']);
2564
+ * items.at(1); // 'b'
2565
+ */
2185
2566
  ObservableArray.prototype.at = function(index) {
2186
2567
  return this.$currentValue[index];
2187
2568
  };
2188
2569
 
2570
+
2571
+ /**
2572
+ * Merges multiple values into the array and triggers an update.
2573
+ * Similar to push but with a different operation name.
2574
+ *
2575
+ * @param {Array} values - Array of values to merge
2576
+ * @example
2577
+ * const items = Observable.array([1, 2]);
2578
+ * items.merge([3, 4]); // [1, 2, 3, 4]
2579
+ */
2189
2580
  ObservableArray.prototype.merge = function(values) {
2190
2581
  this.$currentValue.push.apply(this.$currentValue, values);
2191
2582
  this.trigger({ action: 'merge', args: values });
2192
2583
  };
2193
2584
 
2194
2585
  /**
2586
+ * Counts the number of elements that satisfy the provided condition.
2195
2587
  *
2196
- * @param {Function} condition
2197
- * @returns {number}
2588
+ * @param {(value: *, index: number) => Boolean} condition - Function that tests each element (item, index) => boolean
2589
+ * @returns {number} The count of elements that satisfy the condition
2590
+ * @example
2591
+ * const numbers = Observable.array([1, 2, 3, 4, 5]);
2592
+ * numbers.count(n => n > 3); // 2
2198
2593
  */
2199
2594
  ObservableArray.prototype.count = function(condition) {
2200
2595
  let count = 0;
@@ -2206,6 +2601,16 @@ var NativeComponents = (function (exports) {
2206
2601
  return count;
2207
2602
  };
2208
2603
 
2604
+ /**
2605
+ * Swaps two elements at the specified indices and triggers an update.
2606
+ *
2607
+ * @param {number} indexA - Index of the first element
2608
+ * @param {number} indexB - Index of the second element
2609
+ * @returns {boolean} True if swap was successful, false if indices are out of bounds
2610
+ * @example
2611
+ * const items = Observable.array(['a', 'b', 'c']);
2612
+ * items.swap(0, 2); // ['c', 'b', 'a']
2613
+ */
2209
2614
  ObservableArray.prototype.swap = function(indexA, indexB) {
2210
2615
  const value = this.$currentValue;
2211
2616
  const length = value.length;
@@ -2226,6 +2631,15 @@ var NativeComponents = (function (exports) {
2226
2631
  return true;
2227
2632
  };
2228
2633
 
2634
+ /**
2635
+ * Removes the element at the specified index and triggers an update.
2636
+ *
2637
+ * @param {number} index - Index of the element to remove
2638
+ * @returns {Array} Array containing the removed element, or empty array if index is invalid
2639
+ * @example
2640
+ * const items = Observable.array(['a', 'b', 'c']);
2641
+ * items.remove(1); // ['b'] - Array is now ['a', 'c']
2642
+ */
2229
2643
  ObservableArray.prototype.remove = function(index) {
2230
2644
  const deleted = this.$currentValue.splice(index, 1);
2231
2645
  if(deleted.length === 0) {
@@ -2235,20 +2649,60 @@ var NativeComponents = (function (exports) {
2235
2649
  return deleted;
2236
2650
  };
2237
2651
 
2652
+ /**
2653
+ * Removes the first occurrence of the specified item from the array.
2654
+ *
2655
+ * @param {*} item - The item to remove
2656
+ * @returns {Array} Array containing the removed element, or empty array if item not found
2657
+ * @example
2658
+ * const items = Observable.array(['a', 'b', 'c']);
2659
+ * items.removeItem('b'); // ['b'] - Array is now ['a', 'c']
2660
+ */
2238
2661
  ObservableArray.prototype.removeItem = function(item) {
2239
2662
  const indexOfItem = this.$currentValue.indexOf(item);
2663
+ if(indexOfItem === -1) {
2664
+ return [];
2665
+ }
2240
2666
  return this.remove(indexOfItem);
2241
2667
  };
2242
2668
 
2669
+ /**
2670
+ * Checks if the array is empty.
2671
+ *
2672
+ * @returns {boolean} True if array has no elements
2673
+ * @example
2674
+ * const items = Observable.array([]);
2675
+ * items.isEmpty(); // true
2676
+ */
2243
2677
  ObservableArray.prototype.isEmpty = function() {
2244
2678
  return this.$currentValue.length === 0;
2245
2679
  };
2246
2680
 
2681
+ /**
2682
+ * Triggers a populate operation with the current array, iteration count, and callback.
2683
+ * Used internally for rendering optimizations.
2684
+ *
2685
+ * @param {number} iteration - Iteration count for rendering
2686
+ * @param {Function} callback - Callback function for rendering items
2687
+ */
2247
2688
  ObservableArray.prototype.populateAndRender = function(iteration, callback) {
2248
2689
  this.trigger({ action: 'populate', args: [this.$currentValue, iteration, callback] });
2249
2690
  };
2250
2691
 
2251
2692
 
2693
+ /**
2694
+ * Creates a filtered view of the array based on predicates.
2695
+ * The filtered array updates automatically when source data or predicates change.
2696
+ *
2697
+ * @param {Object} predicates - Object mapping property names to filter conditions or functions
2698
+ * @returns {ObservableArray} A new observable array containing filtered items
2699
+ * @example
2700
+ * const users = Observable.array([
2701
+ * { name: 'John', age: 25 },
2702
+ * { name: 'Jane', age: 30 }
2703
+ * ]);
2704
+ * const adults = users.where({ age: (val) => val >= 18 });
2705
+ */
2252
2706
  ObservableArray.prototype.where = function(predicates) {
2253
2707
  const sourceArray = this;
2254
2708
  const observableDependencies = [sourceArray];
@@ -2297,6 +2751,20 @@ var NativeComponents = (function (exports) {
2297
2751
  return viewArray;
2298
2752
  };
2299
2753
 
2754
+ /**
2755
+ * Creates a filtered view where at least one of the specified fields matches the filter.
2756
+ *
2757
+ * @param {Array<string>} fields - Array of field names to check
2758
+ * @param {FilterResult} filter - Filter condition with callback and dependencies
2759
+ * @returns {ObservableArray} A new observable array containing filtered items
2760
+ * @example
2761
+ * const products = Observable.array([
2762
+ * { name: 'Apple', category: 'Fruit' },
2763
+ * { name: 'Carrot', category: 'Vegetable' }
2764
+ * ]);
2765
+ * const searchTerm = Observable('App');
2766
+ * const filtered = products.whereSome(['name', 'category'], match(searchTerm));
2767
+ */
2300
2768
  ObservableArray.prototype.whereSome = function(fields, filter) {
2301
2769
  return this.where({
2302
2770
  _: {
@@ -2306,6 +2774,20 @@ var NativeComponents = (function (exports) {
2306
2774
  });
2307
2775
  };
2308
2776
 
2777
+ /**
2778
+ * Creates a filtered view where all specified fields match the filter.
2779
+ *
2780
+ * @param {Array<string>} fields - Array of field names to check
2781
+ * @param {FilterResult} filter - Filter condition with callback and dependencies
2782
+ * @returns {ObservableArray} A new observable array containing filtered items
2783
+ * @example
2784
+ * const items = Observable.array([
2785
+ * { status: 'active', verified: true },
2786
+ * { status: 'active', verified: false }
2787
+ * ]);
2788
+ * const activeFilter = equals('active');
2789
+ * const filtered = items.whereEvery(['status', 'verified'], activeFilter);
2790
+ */
2309
2791
  ObservableArray.prototype.whereEvery = function(fields, filter) {
2310
2792
  return this.where({
2311
2793
  _: {
@@ -2316,10 +2798,19 @@ var NativeComponents = (function (exports) {
2316
2798
  };
2317
2799
 
2318
2800
  /**
2801
+ * Creates an observable array with reactive array methods.
2802
+ * All mutations trigger updates automatically.
2319
2803
  *
2320
- * @param {Array} target
2321
- * @param {{propagation: boolean, deep: boolean, reset: boolean}|null} configs
2322
- * @returns {ObservableArray}
2804
+ * @param {Array} [target=[]] - Initial array value
2805
+ * @param {Object|null} [configs=null] - Configuration options
2806
+ * // @param {boolean} [configs.propagation=true] - Whether to propagate changes to parent observables
2807
+ * // @param {boolean} [configs.deep=false] - Whether to make nested objects observable
2808
+ * @param {boolean} [configs.reset=false] - Whether to store initial value for reset()
2809
+ * @returns {ObservableArray} An observable array with reactive methods
2810
+ * @example
2811
+ * const items = Observable.array([1, 2, 3]);
2812
+ * items.push(4); // Triggers update
2813
+ * items.subscribe((arr) => console.log(arr));
2323
2814
  */
2324
2815
  Observable.array = function(target = [], configs = null) {
2325
2816
  return new ObservableArray(target, configs);
@@ -2384,10 +2875,26 @@ var NativeComponents = (function (exports) {
2384
2875
  };
2385
2876
 
2386
2877
  /**
2878
+ * Creates an observable proxy for an object where each property becomes an observable.
2879
+ * Properties can be accessed directly or via getter methods.
2387
2880
  *
2388
- * @param {Object} initialValue
2389
- * @param {{propagation: boolean, deep: boolean, reset: boolean}|null} configs
2390
- * @returns {Proxy}
2881
+ * @param {Object} initialValue - Initial object value
2882
+ * @param {Object|null} [configs=null] - Configuration options
2883
+ * // @param {boolean} [configs.propagation=true] - Whether changes propagate to parent
2884
+ * @param {boolean} [configs.deep=false] - Whether to make nested objects observable
2885
+ * @param {boolean} [configs.reset=false] - Whether to enable reset() method
2886
+ * @returns {ObservableProxy} A proxy where each property is an observable
2887
+ * @example
2888
+ * const user = Observable.init({
2889
+ * name: 'John',
2890
+ * age: 25,
2891
+ * address: { city: 'NYC' }
2892
+ * }, { deep: true });
2893
+ *
2894
+ * user.name.val(); // 'John'
2895
+ * user.name.set('Jane');
2896
+ * user.name = 'Jane X'
2897
+ * user.age.subscribe(val => console.log('Age:', val));
2391
2898
  */
2392
2899
  Observable.init = function(initialValue, configs = null) {
2393
2900
  const data = {};
@@ -2535,11 +3042,24 @@ var NativeComponents = (function (exports) {
2535
3042
  Observable.json = Observable.init;
2536
3043
 
2537
3044
  /**
3045
+ * Creates a computed observable that automatically updates when its dependencies change.
3046
+ * The callback is re-executed whenever any dependency observable changes.
2538
3047
  *
2539
- * @param {Function} callback
2540
- * @param {Array|Function} dependencies
2541
- * @returns {ObservableItem}
2542
- */
3048
+ * @param {Function} callback - Function that returns the computed value
3049
+ * @param {Array<ObservableItem|ObservableChecker|ObservableProxy>|Function} [dependencies=[]] - Array of observables to watch, or batch function
3050
+ * @returns {ObservableItem} A new observable that updates automatically
3051
+ * @example
3052
+ * const firstName = Observable('John');
3053
+ * const lastName = Observable('Doe');
3054
+ * const fullName = Observable.computed(
3055
+ * () => `${firstName.val()} ${lastName.val()}`,
3056
+ * [firstName, lastName]
3057
+ * );
3058
+ *
3059
+ * // With batch function
3060
+ * const batch = Observable.batch(() => { ... });
3061
+ * const computed = Observable.computed(() => { ... }, batch);
3062
+ */
2543
3063
  Observable.computed = function(callback, dependencies = []) {
2544
3064
  const initialValue = callback();
2545
3065
  const observable = new ObservableItem(initialValue);
@@ -2695,6 +3215,11 @@ var NativeComponents = (function (exports) {
2695
3215
 
2696
3216
  HtmlElementWrapper('');
2697
3217
 
3218
+ /**
3219
+ * Represents an individual item within an Accordion component
3220
+ * @param {{ id?: string|number, title?: string, icon?: string, collapsible?: boolean, content?: ValidChildren, renderHeader?: Function, renderContent?: Function, render?: Function, expanded?: Observable<boolean>, disabled?: boolean }} config - Configuration object
3221
+ * @class
3222
+ */
2698
3223
  function AccordionItem(config = {}) {
2699
3224
  if(!(this instanceof AccordionItem)){
2700
3225
  return new AccordionItem()
@@ -2717,42 +3242,81 @@ var NativeComponents = (function (exports) {
2717
3242
 
2718
3243
  BaseComponent.extends(AccordionItem);
2719
3244
 
3245
+ /**
3246
+ * Gets the id of the accordion item
3247
+ * @type {string}
3248
+ */
2720
3249
  Object.defineProperty(AccordionItem.prototype, 'id', {
2721
3250
  get() {
2722
3251
  this.$description.id;
2723
3252
  }
2724
3253
  });
2725
3254
 
3255
+ /**
3256
+ * Sets the identifier for the accordion item
3257
+ * @param {string|number} id - The unique identifier
3258
+ * @returns {AccordionItem}
3259
+ */
2726
3260
  AccordionItem.prototype.identifyBy = function(id) {
2727
3261
  this.$description.id = id;
2728
3262
  return this;
2729
3263
  };
2730
3264
 
3265
+ /**
3266
+ * Sets the content of the accordion item
3267
+ * @param {ValidChildren} content - The content to display
3268
+ * @returns {AccordionItem}
3269
+ */
2731
3270
  AccordionItem.prototype.content = function(content) {
2732
3271
  this.$description.content = content;
2733
3272
  return this;
2734
3273
  };
2735
3274
 
3275
+ /**
3276
+ * Sets the title of the accordion item
3277
+ * @param {ValidChildren} title
3278
+ * @returns {AccordionItem}
3279
+ */
2736
3280
  AccordionItem.prototype.title = function(title) {
2737
3281
  this.$description.title = title;
2738
3282
  return this;
2739
3283
  };
2740
3284
 
3285
+ /**
3286
+ * Sets the icon for the accordion item
3287
+ * @param {ValidChildren} icon - The icon identifier or element
3288
+ * @returns {AccordionItem}
3289
+ */
2741
3290
  AccordionItem.prototype.icon = function(icon) {
2742
3291
  this.$description.icon = icon;
2743
3292
  return this;
2744
3293
  };
2745
3294
 
3295
+ /**
3296
+ * Shows or hides the expansion indicator
3297
+ * @param {boolean} [show=true] - Whether to show the indicator
3298
+ * @returns {AccordionItem}
3299
+ */
2746
3300
  AccordionItem.prototype.showIndicator = function(show = true) {
2747
3301
  this.$description.showIndicator = show;
2748
3302
  return this;
2749
3303
  };
2750
3304
 
3305
+ /**
3306
+ * Sets whether the item can be collapsed
3307
+ * @param {boolean} [collapsible=true] - Whether the item is collapsible
3308
+ * @returns {AccordionItem}
3309
+ */
2751
3310
  AccordionItem.prototype.collapsible = function(collapsible = true) {
2752
3311
  this.$description.collapsible = collapsible;
2753
3312
  return this;
2754
3313
  };
2755
3314
 
3315
+ /**
3316
+ * Expands or collapses the accordion item
3317
+ * @param {boolean} [expanded=true] - Whether to expand the item
3318
+ * @returns {AccordionItem}
3319
+ */
2756
3320
  AccordionItem.prototype.expanded = function(expanded = true) {
2757
3321
  this.$description.expanded.set(expanded);
2758
3322
  if (this.$description.expanded.val()) {
@@ -2763,62 +3327,113 @@ var NativeComponents = (function (exports) {
2763
3327
  return this;
2764
3328
  };
2765
3329
 
3330
+ /**
3331
+ * Toggles the expanded state of the accordion item
3332
+ * @returns {AccordionItem}
3333
+ */
2766
3334
  AccordionItem.prototype.toggle = function() {
2767
3335
  return this.expanded(!this.$description.expanded.val());
2768
3336
  };
2769
3337
 
3338
+
3339
+ /**
3340
+ * Sets the disabled state of the accordion item
3341
+ * @param {boolean} [disabled=true] - Whether the item is disabled
3342
+ * @returns {AccordionItem}
3343
+ */
2770
3344
  AccordionItem.prototype.disabled = function(disabled = true) {
2771
3345
  this.$description.disabled = disabled;
2772
3346
  return this;
2773
3347
  };
2774
3348
 
3349
+ /**
3350
+ * Checks if the accordion item is currently expanded
3351
+ * @returns {boolean}
3352
+ */
2775
3353
  AccordionItem.prototype.isExpanded = function() {
2776
3354
  return this.$description.expanded.val();
2777
3355
  };
3356
+
3357
+ /**
3358
+ * Registers a handler for the expand event
3359
+ * @param {Function} handler - The event handler
3360
+ * @returns {AccordionItem}
3361
+ */
2778
3362
  AccordionItem.prototype.onExpand = function(handler) {
2779
3363
  this.on('expand', handler );
2780
3364
  return this;
2781
3365
  };
2782
3366
 
3367
+ /**
3368
+ * Registers a handler for the collapse event
3369
+ * @param {Function} handler - The event handler
3370
+ * @returns {AccordionItem}
3371
+ */
2783
3372
  AccordionItem.prototype.onCollapse = function(handler) {
2784
3373
  this.on('collapse', handler);
2785
3374
  return this;
2786
3375
  };
2787
3376
 
3377
+ /**
3378
+ * Sets the header render function
3379
+ * @param {Function} renderFn - Function to render the header
3380
+ * @returns {AccordionItem}
3381
+ */
2788
3382
  AccordionItem.prototype.renderHeader = function(renderFn) {
2789
3383
  this.$description.renderHeader = renderFn;
2790
3384
  return this;
2791
3385
  };
2792
3386
 
3387
+ /**
3388
+ * Sets the content render function
3389
+ * @param {Function} renderFn - Function to render the content
3390
+ * @returns {AccordionItem}
3391
+ */
2793
3392
  AccordionItem.prototype.renderContent = function(renderFn) {
2794
3393
  this.$description.renderContent = renderFn;
2795
3394
  };
2796
3395
 
3396
+ /**
3397
+ * Sets the indicator render function
3398
+ * @param {Function} renderFn - Function to render the indicator
3399
+ * @returns {AccordionItem}
3400
+ */
2797
3401
  AccordionItem.prototype.renderIndicator = function(renderFn) {
2798
3402
  this.$description.renderIndicator = renderFn;
2799
3403
  return this;
2800
3404
  };
2801
3405
 
3406
+ /**
3407
+ * Sets the render function for the entire item
3408
+ * @param {Function} renderFn - Function to render the item
3409
+ * @returns {AccordionItem}
3410
+ */
2802
3411
  AccordionItem.prototype.render = function(renderFn) {
2803
3412
  this.$description.render = renderFn;
2804
3413
  return this;
2805
3414
  };
2806
3415
 
3416
+ /**
3417
+ * Builds the accordion item component
3418
+ * @private
3419
+ */
2807
3420
  AccordionItem.prototype.$build = function() {
2808
3421
 
2809
3422
  };
2810
3423
 
2811
- AccordionItem.prototype.toNdElement = function() {
2812
-
2813
- };
2814
-
3424
+ /**
3425
+ * Component for displaying alert messages with various styles and variants
3426
+ * @param {ValidChildren} message - The alert message content
3427
+ * @param {{ title?: ValidChildren, content?: ValidChildren, outline?: boolean, style?: string, variant?: string, closable?: boolean, autoDismiss?: number, icon?: ValidChildren, showIcon?: boolean }} config - Configuration object
3428
+ * @class
3429
+ */
2815
3430
  function Alert(message, config = {}) {
2816
3431
  if(!(this instanceof Alert)) {
2817
3432
  return new Alert(message, config);
2818
3433
  }
2819
3434
  this.$description = {
2820
3435
  title: null,
2821
- content: null,
3436
+ content: message,
2822
3437
  outline: null,
2823
3438
  style: null,
2824
3439
  variant: 'info',
@@ -2835,139 +3450,299 @@ var NativeComponents = (function (exports) {
2835
3450
  Alert.defaultButtonsTemplate = null;
2836
3451
  Alert.defaultContentTemplate = null;
2837
3452
 
2838
- Alert.use = function(template) {};
3453
+ /**
3454
+ * Sets the default template for all Alert instances
3455
+ * @param {{alert: (alert: Alert) => ValidChildren, alertContent: (alert: Alert) => ValidChildren, alertButtons: (alert: Alert) => ValidChildren, alertTitle: (alert: Alert) => ValidChildren}} template - Template object containing alert factory function
3456
+ */
3457
+ Alert.use = function(template) {
3458
+ Alert.defaultTemplate = template.alert;
3459
+ Alert.defaultTitleTemplate = template.alertTitle;
3460
+ Alert.defaultButtonsTemplate = template.alertButtons;
3461
+ Alert.defaultContentTemplate = template.alertContent;
3462
+ };
2839
3463
 
2840
3464
  BaseComponent.extends(Alert, EventEmitter);
2841
3465
 
3466
+ /**
3467
+ * Sets the variant style for the alert
3468
+ * @param {string} variant - The variant name (info, success, warning, error, danger)
3469
+ * @returns {Alert}
3470
+ */
2842
3471
  Alert.prototype.variant = function(variant) {
2843
3472
  this.$description.variant = variant;
2844
3473
  return this;
2845
3474
  };
2846
3475
 
3476
+ /**
3477
+ * Sets the alert variant to 'info'
3478
+ * @returns {Alert}
3479
+ */
2847
3480
  Alert.prototype.info = function() {
2848
3481
  return this.variant('info');
2849
3482
  };
3483
+
3484
+ /**
3485
+ * Sets the alert variant to 'success'
3486
+ * @returns {Alert}
3487
+ */
2850
3488
  Alert.prototype.success = function() {
2851
3489
  return this.variant('success');
2852
3490
  };
3491
+
3492
+ /**
3493
+ * Sets the alert variant to 'warning'
3494
+ * @returns {Alert}
3495
+ */
2853
3496
  Alert.prototype.warning = function() {
2854
3497
  return this.variant('warning');
2855
3498
  };
3499
+
3500
+ /**
3501
+ * Sets the alert variant to 'error'
3502
+ * @returns {Alert}
3503
+ */
2856
3504
  Alert.prototype.error = function() {
2857
3505
  return this.variant('error');
2858
3506
  };
3507
+
3508
+ /**
3509
+ * Sets the alert variant to 'danger'
3510
+ * @returns {Alert}
3511
+ */
2859
3512
  Alert.prototype.danger = function() {
2860
3513
  return this.variant('danger');
2861
3514
  };
2862
3515
 
3516
+ /**
3517
+ * Sets the style type for the alert
3518
+ * @param {string} style - The style name (filled, bordered, outline)
3519
+ * @returns {Alert}
3520
+ */
2863
3521
  Alert.prototype.style = function(style) {
2864
3522
  this.$description.style = style;
2865
3523
  return this;
2866
3524
  };
3525
+
3526
+ /**
3527
+ * Sets the alert style to 'filled'
3528
+ * @returns {Alert}
3529
+ */
2867
3530
  Alert.prototype.filled = function() {
2868
3531
  return this.style('filled');
2869
3532
  };
3533
+
3534
+ /**
3535
+ * Sets the alert style to 'bordered'
3536
+ * @returns {Alert}
3537
+ */
2870
3538
  Alert.prototype.bordered = function() {
2871
3539
  return this.style('bordered');
2872
3540
  };
3541
+
3542
+ /**
3543
+ * Sets the alert style to 'outline'
3544
+ * @param {boolean} [outline=true] - Whether to use outline style
3545
+ * @returns {Alert}
3546
+ */
2873
3547
  Alert.prototype.outline = function(outline = true) {
2874
3548
  return this.style('outline');
2875
3549
  };
2876
3550
 
3551
+ /**
3552
+ * Sets the title of the alert
3553
+ * @param {ValidChildren} title - The title content
3554
+ * @returns {Alert}
3555
+ */
2877
3556
  Alert.prototype.title = function(title) {
2878
3557
  this.$description.title = title;
2879
3558
  return this;
2880
3559
  };
3560
+
3561
+ /**
3562
+ * Sets the content of the alert
3563
+ * @param {ValidChildren} content - The content to display
3564
+ * @returns {Alert}
3565
+ */
2881
3566
  Alert.prototype.content = function(content) {
2882
3567
  this.$description.content = content;
2883
3568
  return this;
2884
3569
  };
2885
3570
 
3571
+ /**
3572
+ * Sets the title render function
3573
+ * @param {Function} callback - Function to render the title
3574
+ * @returns {Alert}
3575
+ */
2886
3576
  Alert.prototype.renderTitle = function(callback) {
2887
3577
  this.$description.renderTitle = callback;
2888
3578
  return this;
2889
3579
  };
3580
+
3581
+ /**
3582
+ * Sets the content render function
3583
+ * @param {Function} callback - Function to render the content
3584
+ * @returns {Alert}
3585
+ */
2890
3586
  Alert.prototype.renderContent = function(callback) {
2891
3587
  this.$description.renderContent = callback;
2892
3588
  return this;
2893
3589
  };
3590
+
3591
+ /**
3592
+ * Clears all actions from the alert
3593
+ * @returns {Alert}
3594
+ */
2894
3595
  Alert.prototype.renderFooter = function(callback) {
2895
3596
  this.$description.renderFooter = callback;
2896
3597
  return this;
2897
3598
  };
2898
3599
 
3600
+ /**
3601
+ * Adds an action button to the alert
3602
+ * @param {string} label - The button label
3603
+ * @param {Function} handler - The click handler
3604
+ * @returns {Alert}
3605
+ */
2899
3606
  Alert.prototype.clearActions = function(label, handler) {
2900
3607
  this.$description.actions = [];
2901
3608
  return this;
2902
3609
  };
2903
3610
 
3611
+ /**
3612
+ * Adds an action button to the alert
3613
+ * @param {string} label - The button label
3614
+ * @param {Function} handler - The click handler
3615
+ * @returns {Alert}
3616
+ */
2904
3617
  Alert.prototype.action = function(label, handler) {
2905
3618
  this.$description.actions.push({label, handler});
2906
3619
  return this;
2907
3620
  };
2908
3621
 
3622
+ /**
3623
+ * Sets the layout function for the alert
3624
+ * @param {Function} layoutFn - Function to layout the alert
3625
+ * @returns {Alert}
3626
+ */
2909
3627
  Alert.prototype.layout = function(layoutFn) {
2910
3628
  this.$description.layout = layoutFn;
2911
3629
  return this;
2912
3630
  };
2913
3631
 
3632
+ /**
3633
+ * Sets the icon for the alert
3634
+ * @param {ValidChildren} icon - The icon to display
3635
+ * @returns {Alert}
3636
+ */
2914
3637
  Alert.prototype.icon = function(icon) {
2915
3638
  this.$description.icon = icon;
2916
3639
  return this;
2917
3640
  };
2918
3641
 
3642
+ /**
3643
+ * Shows or hides the icon
3644
+ * @param {boolean} [show=true] - Whether to show the icon
3645
+ * @returns {Alert}
3646
+ */
2919
3647
  Alert.prototype.showIcon = function(show = true) {
2920
3648
  this.$description.showIcon = show;
2921
3649
  };
2922
3650
 
3651
+ /**
3652
+ * Sets whether the alert can be closed
3653
+ * @param {boolean} [closable=true] - Whether the alert is closable
3654
+ * @returns {Alert}
3655
+ */
2923
3656
  Alert.prototype.closable = function(closable = true) {
2924
3657
  this.$description.closable = closable;
2925
3658
  return this;
2926
3659
  };
2927
3660
 
3661
+ /**
3662
+ * Sets whether the alert is dismissible (alias for closable)
3663
+ * @param {boolean} [dismissible=true] - Whether the alert is dismissible
3664
+ * @returns {Alert}
3665
+ */
2928
3666
  Alert.prototype.dismissible = function(dismissible = true) {
2929
3667
  return this.closable(dismissible);
2930
3668
  };
3669
+
3670
+ /**
3671
+ * Sets auto-dismiss delay for the alert
3672
+ * @param {number} delay - Delay in milliseconds before auto-dismissing
3673
+ * @returns {Alert}
3674
+ */
2931
3675
  Alert.prototype.autoDismiss = function(delay) {
2932
3676
  this.$description.autoDismiss = delay;
2933
3677
  return this;
2934
3678
  };
2935
3679
 
2936
-
2937
-
3680
+ /**
3681
+ * Closes the alert
3682
+ */
2938
3683
  Alert.prototype.close = function() {
2939
3684
 
2940
3685
  };
2941
3686
 
3687
+ /**
3688
+ * Shows the alert
3689
+ */
2942
3690
  Alert.prototype.show = function() {
2943
3691
 
2944
3692
  };
2945
3693
 
3694
+ /**
3695
+ * Hides the alert
3696
+ */
2946
3697
  Alert.prototype.hide = function() {
2947
3698
 
2948
3699
  };
2949
3700
 
3701
+ /**
3702
+ * Registers a handler for the close event
3703
+ * @param {(element: Alert) => void} handler - The event handler
3704
+ * @returns {Alert}
3705
+ */
2950
3706
  Alert.prototype.onClose = function(handler) {
2951
3707
  this.on('close', handler);
2952
3708
  return this;
2953
3709
  };
3710
+
3711
+ /**
3712
+ * Registers a handler for the show event
3713
+ * @param {(element: Alert) => void} handler - The event handler
3714
+ * @returns {Alert}
3715
+ */
2954
3716
  Alert.prototype.onShow = function(handler) {
2955
3717
  this.on('show', handler);
2956
3718
  return this;
2957
3719
  };
2958
3720
 
3721
+ /**
3722
+ * Sets the render function for the entire alert
3723
+ * @param {(alert: Alert, sections: {title: ValidChildren, content: ValidChildren, footer: ValidChildren, icon: ValidChildren}) => ValidChildren} renderFn - Function to render the alert
3724
+ * @returns {Alert}
3725
+ */
2959
3726
  Alert.prototype.render = function(renderFn) {
2960
3727
  this.$description.render = renderFn;
2961
3728
  return this;
2962
3729
  };
3730
+
2963
3731
  Alert.prototype.$build = function() {
2964
3732
 
2965
3733
  };
3734
+
2966
3735
  Alert.prototype.toNdElement = function() {};
2967
3736
 
3737
+ /**
3738
+ * Component for displaying user avatars with images, initials, or icons
3739
+ * @param {Observable<string>|string} source - The avatar source (image URL or observable)
3740
+ * @param {{ src?: Observable<string>|string, alt?: string, name?: string, initials?: string, icon?: ValidChildren, size?: string|number, shape?: string, variant?: string, color?: string, textColor?: string, status?: string, render?: Function }} config - Configuration object
3741
+ * @class
3742
+ */
2968
3743
  function Avatar(source, config = {}) {
2969
3744
  if (!(this instanceof Avatar)) {
2970
- return new Avatar(config);
3745
+ return new Avatar(source, config);
2971
3746
  }
2972
3747
 
2973
3748
  this.$description = {
@@ -2990,156 +3765,363 @@ var NativeComponents = (function (exports) {
2990
3765
  BaseComponent.extends(Avatar);
2991
3766
 
2992
3767
  Avatar.defaultTemplate = null;
2993
- Avatar.use = function(template) {};
2994
3768
 
3769
+ /**
3770
+ * Sets the default template for all Avatar instances
3771
+ * @param {{avatar: (avatar: Avatar) => ValidChildren}} template - Template object containing avatar factory function
3772
+ */
3773
+ Avatar.use = function(template) {
3774
+ Avatar.defaultTemplate = template.avatar;
3775
+ };
3776
+
3777
+ /**
3778
+ * Registers a handler for the error event
3779
+ * @param {(error: Error, avatar: Avatar) => void} handler - The event handler
3780
+ * @returns {Avatar}
3781
+ */
2995
3782
  Avatar.prototype.onError = function(handler) {};
2996
3783
 
3784
+ /**
3785
+ * Sets the source URL for the avatar image
3786
+ * @param {string} src - The image source URL
3787
+ * @returns {Avatar}
3788
+ */
2997
3789
  Avatar.prototype.src = function(src) {
2998
3790
  this.$description.src.set(src);
2999
3791
  return this;
3000
3792
  };
3793
+
3794
+ /**
3795
+ * Sets the alt text for the avatar image
3796
+ * @param {string} alt - The alt text
3797
+ * @returns {Avatar}
3798
+ */
3001
3799
  Avatar.prototype.alt = function(alt) {
3002
3800
  this.$description.alt = alt;
3003
3801
  return this;
3004
3802
  };
3803
+
3804
+ /**
3805
+ * Sets the name associated with the avatar
3806
+ * @param {string} name - The name
3807
+ * @returns {Avatar}
3808
+ */
3005
3809
  Avatar.prototype.name = function(name) {
3006
3810
  this.$description.name = name;
3007
3811
  return this;
3008
3812
  };
3813
+
3814
+ /**
3815
+ * Sets the initials to display
3816
+ * @param {string} initials - The initials text
3817
+ * @returns {Avatar}
3818
+ */
3009
3819
  Avatar.prototype.initials = function(initials) {
3010
3820
  this.$description.initials = initials;
3011
3821
  return this;
3012
3822
  };
3823
+
3824
+ /**
3825
+ * Sets the icon for the avatar
3826
+ * @param {ValidChildren} icon - The icon to display
3827
+ * @returns {Avatar}
3828
+ */
3013
3829
  Avatar.prototype.icon = function(icon) {
3014
3830
  this.$description.icon = icon;
3015
3831
  return this;
3016
3832
  };
3017
3833
 
3018
3834
  /**
3019
- * @param {string|int} size
3835
+ * Sets the size of the avatar
3836
+ * @param {string|number} size - The size value (preset name or custom value)
3020
3837
  * @returns {Avatar}
3021
3838
  */
3022
3839
  Avatar.prototype.size = function(size) {
3023
3840
  this.$description.size = size;
3024
3841
  return this;
3025
3842
  };
3843
+
3844
+ /**
3845
+ * Sets the avatar size to 'extra-small'
3846
+ * @returns {Avatar}
3847
+ */
3026
3848
  Avatar.prototype.extraSmall = function() {
3027
3849
  return this.size('extra-small');
3028
3850
  };
3851
+
3852
+ /**
3853
+ * Sets the avatar size to 'small'
3854
+ * @returns {Avatar}
3855
+ */
3029
3856
  Avatar.prototype.small = function() {
3030
3857
  return this.size('small');
3031
3858
  };
3859
+
3860
+ /**
3861
+ * Sets the avatar size to 'medium'
3862
+ * @returns {Avatar}
3863
+ */
3032
3864
  Avatar.prototype.medium = function() {
3033
3865
  return this.size('medium');
3034
3866
  };
3867
+
3868
+ /**
3869
+ * Sets the avatar size to 'large'
3870
+ * @returns {Avatar}
3871
+ */
3035
3872
  Avatar.prototype.large = function() {
3036
3873
  return this.size('large');
3037
3874
  };
3875
+
3876
+ /**
3877
+ * Sets the avatar size to 'extra-large'
3878
+ * @returns {Avatar}
3879
+ */
3038
3880
  Avatar.prototype.extraLarge = function() {
3039
3881
  return this.size('extra-large');
3040
3882
  };
3041
3883
 
3884
+ /**
3885
+ * Sets the shape of the avatar
3886
+ * @param {string} shape - The shape name (circle, square, rounded)
3887
+ * @returns {Avatar}
3888
+ */
3042
3889
  Avatar.prototype.shape = function(shape) {
3043
3890
  this.$description.shape = shape;
3044
3891
  return this;
3045
3892
  };
3893
+
3894
+ /**
3895
+ * Sets the avatar shape to 'circle'
3896
+ * @returns {Avatar}
3897
+ */
3046
3898
  Avatar.prototype.circle = function() {
3047
3899
  return this.shape('circle');
3048
3900
  };
3901
+
3902
+ /**
3903
+ * Sets the avatar shape to 'square'
3904
+ * @returns {Avatar}
3905
+ */
3049
3906
  Avatar.prototype.square = function() {
3050
3907
  return this.shape('square');
3051
3908
  };
3909
+
3910
+ /**
3911
+ * Sets the avatar shape to 'rounded'
3912
+ * @returns {Avatar}
3913
+ */
3052
3914
  Avatar.prototype.rounded = function() {
3053
3915
  return this.shape('rounded');
3054
3916
  };
3055
3917
 
3918
+ /**
3919
+ * Sets the variant style for the avatar
3920
+ * @param {string} variant - The variant name (primary, secondary, success, danger, warning, info)
3921
+ * @returns {Avatar}
3922
+ */
3056
3923
  Avatar.prototype.variant = function(variant) {
3057
3924
  this.$description.variant = variant;
3058
3925
  }; // 'primary' | 'secondary' | 'success' | etc.
3926
+
3927
+ /**
3928
+ * Sets the avatar variant to 'primary'
3929
+ * @returns {Avatar}
3930
+ */
3059
3931
  Avatar.prototype.primary = function() {
3060
3932
  return this.variant('primary');
3061
3933
  };
3934
+
3935
+ /**
3936
+ * Sets the avatar variant to 'secondary'
3937
+ * @returns {Avatar}
3938
+ */
3062
3939
  Avatar.prototype.secondary = function() {
3063
3940
  return this.variant('secondary');
3064
3941
  };
3942
+
3943
+ /**
3944
+ * Sets the avatar variant to 'success'
3945
+ * @returns {Avatar}
3946
+ */
3065
3947
  Avatar.prototype.success = function() {
3066
3948
  return this.variant('success');
3067
3949
  };
3950
+
3951
+ /**
3952
+ * Sets the avatar variant to 'danger'
3953
+ * @returns {Avatar}
3954
+ */
3068
3955
  Avatar.prototype.danger = function() {
3069
3956
  return this.variant('danger');
3070
3957
  };
3958
+
3959
+ /**
3960
+ * Sets the avatar variant to 'warning'
3961
+ * @returns {Avatar}
3962
+ */
3071
3963
  Avatar.prototype.warning = function() {
3072
3964
  return this.variant('warning');
3073
3965
  };
3966
+
3967
+ /**
3968
+ * Sets the avatar variant to 'info'
3969
+ * @returns {Avatar}
3970
+ */
3074
3971
  Avatar.prototype.info = function() {
3075
3972
  return this.variant('info');
3076
3973
  };
3974
+
3975
+ /**
3976
+ * Sets the background color of the avatar
3977
+ * @param {string} color - The color value
3978
+ * @returns {Avatar}
3979
+ */
3077
3980
  Avatar.prototype.color = function(color) {
3078
3981
  this.$description.color = color;
3079
3982
  return this;
3080
3983
  };
3984
+
3985
+ /**
3986
+ * Sets the text color of the avatar
3987
+ * @param {string} color - The color value
3988
+ * @returns {Avatar}
3989
+ */
3081
3990
  Avatar.prototype.textColor = function(color) {
3082
3991
  this.$description.textColor = color;
3083
3992
  return this;
3084
3993
  };
3085
3994
 
3995
+ /**
3996
+ * Sets the status indicator for the avatar
3997
+ * @param {string} status - The status value
3998
+ * @returns {Avatar}
3999
+ */
3086
4000
  Avatar.prototype.status = function(status) {
3087
4001
  this.$description.status = status;
3088
4002
  return this;
3089
4003
  };
4004
+
4005
+ /**
4006
+ * Sets the position of the status indicator
4007
+ * @param {string} position - The position (top-right, bottom-right, top-left, bottom-left)
4008
+ * @returns {Avatar}
4009
+ */
3090
4010
  Avatar.prototype.statusPosition = function(position) {
3091
4011
  this.$description.statusPosition = position;
3092
4012
  }; // 'top-right' | 'bottom-right' | etc.
3093
- Avatar.prototype.statusAtTopEnd = function() {
3094
- return this.statusPosition('top-end');
4013
+
4014
+ /**
4015
+ * Positions the status indicator at top-leading
4016
+ * @returns {Avatar}
4017
+ */
4018
+ Avatar.prototype.statusAtTopLeading = function() {
4019
+ return this.statusPosition('top-leading');
3095
4020
  };
3096
- Avatar.prototype.statusAtBottomEnd = function() {
3097
- return this.statusPosition('bottom-end');
4021
+
4022
+ /**
4023
+ * Positions the status indicator at bottom-leading
4024
+ * @returns {Avatar}
4025
+ */
4026
+ Avatar.prototype.statusAtBottomLeading = function() {
4027
+ return this.statusPosition('bottom-leading');
3098
4028
  };
3099
- Avatar.prototype.statusAtTopStart = function() {
3100
- return this.statusPosition('top-start');
4029
+
4030
+ /**
4031
+ * Positions the status indicator at top-trailing
4032
+ * @returns {Avatar}
4033
+ */
4034
+ Avatar.prototype.statusAtTopTrailing = function() {
4035
+ return this.statusPosition('top-trailing');
3101
4036
  };
3102
- Avatar.prototype.statusAtBottomStart = function() {
3103
- return this.statusPosition('bottom-start');
4037
+
4038
+ /**
4039
+ * Positions the status indicator at bottom-trailing
4040
+ * @returns {Avatar}
4041
+ */
4042
+ Avatar.prototype.statusAtBottomTrailing = function() {
4043
+ return this.statusPosition('bottom-trailing');
3104
4044
  };
3105
4045
 
4046
+ /**
4047
+ * Shows or hides the status indicator
4048
+ * @param {boolean} [show=true] - Whether to show the status
4049
+ * @returns {Avatar}
4050
+ */
3106
4051
  Avatar.prototype.showStatus = function(show = true) {
3107
4052
  this.$description.showStatus = show;
3108
4053
  return this;
3109
4054
  };
3110
4055
 
3111
- // Badge
4056
+ /**
4057
+ * Sets the badge content for the avatar
4058
+ * @param {ValidChildren} content - The badge content
4059
+ * @returns {Avatar}
4060
+ */
3112
4061
  Avatar.prototype.badge = function(content) {
3113
4062
  this.$description.badge = content;
3114
4063
  return this;
3115
4064
  };
4065
+
4066
+ /**
4067
+ * Sets the position of the badge
4068
+ * @param {string} position - The position (top-leading, bottom-leading, top-trailing, bottom-trailing)
4069
+ * @returns {Avatar}
4070
+ */
3116
4071
  Avatar.prototype.badgePosition = function(position) {
3117
4072
  this.$description.badgePosition = position;
3118
4073
  return this;
3119
4074
  };
3120
- Avatar.prototype.badgeAtTopEnd = function() {
3121
- return this.badgePosition('top-end');
3122
- };
3123
- Avatar.prototype.badgeAtBottomEnd = function() {
3124
- return this.badgePosition('bottom-end');
4075
+
4076
+ /**
4077
+ * Positions the badge at top-leading
4078
+ * @returns {Avatar}
4079
+ */
4080
+ Avatar.prototype.badgeAtTopLeading = function() {
4081
+ return this.badgePosition('top-leading');
3125
4082
  };
3126
- Avatar.prototype.badgeAtTopStart = function() {
3127
- return this.badgePosition('top-start');
4083
+
4084
+ /**
4085
+ * Positions the badge at bottom-leading
4086
+ * @returns {Avatar}
4087
+ */
4088
+ Avatar.prototype.badgeAtBottomLeading = function() {
4089
+ return this.badgePosition('bottom-leading');
3128
4090
  };
3129
- Avatar.prototype.badgeAtBottomStart = function() {
3130
- return this.badgePosition('bottom-start');
4091
+
4092
+ /**
4093
+ * Positions the badge at top-trailing
4094
+ * @returns {Avatar}
4095
+ */
4096
+ Avatar.prototype.badgeAtTopTrailing = function() {
4097
+ return this.badgePosition('top-trailing');
3131
4098
  };
3132
4099
 
4100
+ /**
4101
+ * Positions the badge at bottom-trailing
4102
+ * @returns {Avatar}
4103
+ */
4104
+ Avatar.prototype.badgeAtBottomTrailing = function() {
4105
+ return this.badgePosition('bottom-trailing');
4106
+ };
3133
4107
 
4108
+ /**
4109
+ * Sets the render function for the entire avatar
4110
+ * @param {(avatar: Avatar, sections: {image: ValidChildren, initials: ValidChildren, icon: ValidChildren, status: ValidChildren, badge: ValidChildren}) => ValidChildren} renderFn - Function to render the avatar
4111
+ * @returns {Avatar}
4112
+ */
3134
4113
  Avatar.prototype.render = function(renderFn) {
3135
4114
  this.$description.render = renderFn;
3136
4115
  return this;
3137
4116
  };
3138
4117
 
4118
+ /**
4119
+ * Builds the avatar component
4120
+ * @private
4121
+ */
3139
4122
  Avatar.prototype.$build = function() {
3140
4123
 
3141
4124
  };
3142
- Avatar.prototype.toNdElement = function() {};
3143
4125
 
3144
4126
  function Badge(config = {}) {
3145
4127
  if(!(this instanceof Badge)) {
@@ -3589,23 +4571,46 @@ var NativeComponents = (function (exports) {
3589
4571
  return this;
3590
4572
  };
3591
4573
 
4574
+ /**
4575
+ * Mixin for managing a collection of items with manipulation methods
4576
+ * @class
4577
+ */
3592
4578
  function HasItems() {}
3593
4579
 
4580
+ /**
4581
+ * Sets a dynamic observable array to store items
4582
+ * @param {ObservableArray?} [observableArray=null] - Observable array to use, or creates a new one if null
4583
+ * @returns {HasItems}
4584
+ */
3594
4585
  HasItems.prototype.dynamic = function(observableArray = null) {
3595
4586
  this.$description.items = observableArray || $$1.array([]);
3596
4587
  return this;
3597
4588
  };
3598
4589
 
4590
+ /**
4591
+ * Replaces all existing items with a new array of items
4592
+ * @param {Array} items - Array of new items
4593
+ * @returns {HasItems}
4594
+ */
3599
4595
  HasItems.prototype.items = function(items) {
3600
4596
  this.$description.items.splice(0, this.$description.items.length, ...items);
3601
4597
  return this;
3602
4598
  };
3603
4599
 
4600
+ /**
4601
+ * Adds an item to the collection
4602
+ * @param {*} item - The item to add
4603
+ * @returns {HasItems}
4604
+ */
3604
4605
  HasItems.prototype.item = function(item) {
3605
4606
  this.$description.items.push(item);
3606
4607
  return this;
3607
4608
  };
3608
4609
 
4610
+ /**
4611
+ * Clears all items from the collection
4612
+ * @returns {HasItems}
4613
+ */
3609
4614
  HasItems.prototype.clear = function() {
3610
4615
  const items = this.$description.items;
3611
4616
  if(Array.isArray(items)) {
@@ -3616,11 +4621,29 @@ var NativeComponents = (function (exports) {
3616
4621
  return this;
3617
4622
  };
3618
4623
 
4624
+ /**
4625
+ * Removes a specific item from the collection
4626
+ * @param {*} item - The item to remove
4627
+ * @returns {HasItems}
4628
+ */
3619
4629
  HasItems.prototype.removeItem = function(item) {
3620
- // TODO: implement this method
4630
+ const items = this.$description.items;
4631
+ if(Array.isArray(items)) {
4632
+ const index = items.indexOf(item);
4633
+ if(index > -1) {
4634
+ items.splice(index, 1);
4635
+ return this;
4636
+ }
4637
+ }
4638
+ items.removeItem(item);
3621
4639
  return this;
3622
4640
  };
3623
4641
 
4642
+ /**
4643
+ * Sets the render function for items
4644
+ * @param {(element: *) => ValidChildren} renderFn - Render function to apply
4645
+ * @returns {HasItems}
4646
+ */
3624
4647
  HasItems.prototype.render = function(renderFn) {
3625
4648
  this.$description.render = renderFn;
3626
4649
  return this;