native-document 1.0.93 → 1.0.95

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 (37) hide show
  1. package/dist/native-document.components.min.js +667 -62
  2. package/dist/native-document.dev.js +878 -111
  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/elements.js +1 -0
  7. package/index.def.js +1086 -0
  8. package/package.json +1 -1
  9. package/src/core/elements/anchor.js +28 -20
  10. package/src/core/elements/content-formatter.js +138 -1
  11. package/src/core/elements/control/for-each-array.js +1 -1
  12. package/src/core/elements/control/for-each.js +2 -2
  13. package/src/core/elements/control/show-if.js +3 -3
  14. package/src/core/elements/control/show-when.js +2 -2
  15. package/src/core/elements/control/switch.js +1 -1
  16. package/src/core/elements/description-list.js +14 -0
  17. package/src/core/elements/form.js +188 -4
  18. package/src/core/elements/html5-semantics.js +44 -1
  19. package/src/core/elements/img.js +22 -10
  20. package/src/core/elements/index.js +5 -0
  21. package/src/core/elements/interactive.js +19 -1
  22. package/src/core/elements/list.js +28 -1
  23. package/src/core/elements/medias.js +29 -0
  24. package/src/core/elements/meta-data.js +34 -0
  25. package/src/core/elements/table.js +59 -0
  26. package/src/core/utils/helpers.js +7 -2
  27. package/src/core/utils/memoize.js +1 -1
  28. package/src/core/wrappers/DocumentObserver.js +102 -31
  29. package/src/core/wrappers/ElementCreator.js +5 -0
  30. package/src/core/wrappers/HtmlElementWrapper.js +2 -2
  31. package/src/core/wrappers/NDElement.js +33 -2
  32. package/src/core/wrappers/TemplateCloner.js +1 -1
  33. package/src/core/wrappers/prototypes/nd-element.transition.extensions.js +83 -0
  34. package/types/elements.d.ts +1073 -113
  35. package/types/forms.d.ts +85 -48
  36. package/types/images.d.ts +16 -9
  37. package/types/nd-element.d.ts +6 -0
@@ -1,10 +1,10 @@
1
1
  var NativeDocument = (function (exports) {
2
2
  'use strict';
3
3
 
4
- let DebugManager = {};
4
+ let DebugManager$1 = {};
5
5
 
6
6
  {
7
- DebugManager = {
7
+ DebugManager$1 = {
8
8
  enabled: false,
9
9
 
10
10
  enable() {
@@ -35,7 +35,7 @@ var NativeDocument = (function (exports) {
35
35
  };
36
36
 
37
37
  }
38
- var DebugManager$1 = DebugManager;
38
+ var DebugManager = DebugManager$1;
39
39
 
40
40
  const MemoryManager = (function() {
41
41
 
@@ -84,7 +84,7 @@ var NativeDocument = (function (exports) {
84
84
  }
85
85
  }
86
86
  if (cleanedCount > 0) {
87
- DebugManager$1.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
87
+ DebugManager.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
88
88
  }
89
89
  }
90
90
  };
@@ -191,10 +191,10 @@ var NativeDocument = (function (exports) {
191
191
  return this.observable.cleanup();
192
192
  };
193
193
 
194
- let PluginsManager = null;
194
+ let PluginsManager$1 = null;
195
195
 
196
196
  {
197
- PluginsManager = (function() {
197
+ PluginsManager$1 = (function() {
198
198
 
199
199
  const $plugins = new Map();
200
200
  const $pluginByEvents = new Map();
@@ -260,7 +260,7 @@ var NativeDocument = (function (exports) {
260
260
  try{
261
261
  callback.call(plugin, ...data);
262
262
  } catch (error) {
263
- DebugManager$1.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
263
+ DebugManager.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
264
264
  }
265
265
  }
266
266
  }
@@ -269,7 +269,7 @@ var NativeDocument = (function (exports) {
269
269
  }());
270
270
  }
271
271
 
272
- var PluginsManager$1 = PluginsManager;
272
+ var PluginsManager = PluginsManager$1;
273
273
 
274
274
  /**
275
275
  * Creates an ObservableWhen that tracks whether an observable equals a specific value.
@@ -364,7 +364,12 @@ var NativeDocument = (function (exports) {
364
364
  };
365
365
 
366
366
  const deepClone = (value, onObservableFound) => {
367
- // Primitives
367
+ try {
368
+ if(window.structuredClone !== undefined) {
369
+ return window.structuredClone(value);
370
+ }
371
+ } catch (e){}
372
+
368
373
  if (value === null || typeof value !== 'object') {
369
374
  return value;
370
375
  }
@@ -388,7 +393,7 @@ var NativeDocument = (function (exports) {
388
393
  // Objects
389
394
  const cloned = {};
390
395
  for (const key in value) {
391
- if (value.hasOwnProperty(key)) {
396
+ if (Object.hasOwn(value, key)) {
392
397
  cloned[key] = deepClone(value[key]);
393
398
  }
394
399
  }
@@ -423,7 +428,7 @@ var NativeDocument = (function (exports) {
423
428
  }
424
429
  }
425
430
  {
426
- PluginsManager$1.emit('CreateObservable', this);
431
+ PluginsManager.emit('CreateObservable', this);
427
432
  }
428
433
  }
429
434
 
@@ -527,12 +532,12 @@ var NativeDocument = (function (exports) {
527
532
  this.$previousValue = this.$currentValue;
528
533
  this.$currentValue = newValue;
529
534
  {
530
- PluginsManager$1.emit('ObservableBeforeChange', this);
535
+ PluginsManager.emit('ObservableBeforeChange', this);
531
536
  }
532
537
  this.trigger();
533
538
  this.$previousValue = null;
534
539
  {
535
- PluginsManager$1.emit('ObservableAfterChange', this);
540
+ PluginsManager.emit('ObservableAfterChange', this);
536
541
  }
537
542
  };
538
543
 
@@ -619,7 +624,7 @@ var NativeDocument = (function (exports) {
619
624
  ObservableItem.prototype.subscribe = function(callback) {
620
625
  {
621
626
  if (this.$isCleanedUp) {
622
- DebugManager$1.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
627
+ DebugManager.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
623
628
  return;
624
629
  }
625
630
  if (typeof callback !== 'function') {
@@ -631,7 +636,7 @@ var NativeDocument = (function (exports) {
631
636
  this.$listeners.push(callback);
632
637
  this.assocTrigger();
633
638
  {
634
- PluginsManager$1.emit('ObservableSubscribe', this);
639
+ PluginsManager.emit('ObservableSubscribe', this);
635
640
  }
636
641
  };
637
642
 
@@ -742,7 +747,7 @@ var NativeDocument = (function (exports) {
742
747
  }
743
748
  this.assocTrigger();
744
749
  {
745
- PluginsManager$1.emit('ObservableUnsubscribe', this);
750
+ PluginsManager.emit('ObservableUnsubscribe', this);
746
751
  }
747
752
  };
748
753
 
@@ -874,96 +879,168 @@ var NativeDocument = (function (exports) {
874
879
 
875
880
  const DocumentObserver = {
876
881
  mounted: new WeakMap(),
882
+ beforeUnmount: new WeakMap(),
877
883
  mountedSupposedSize: 0,
878
884
  unmounted: new WeakMap(),
879
885
  unmountedSupposedSize: 0,
880
886
  observer: null,
887
+
881
888
  executeMountedCallback(node) {
882
889
  const data = DocumentObserver.mounted.get(node);
883
890
  if(!data) {
884
891
  return;
885
892
  }
886
893
  data.inDom = true;
887
- data.mounted && data.mounted(node);
894
+ if(!data.mounted) {
895
+ return;
896
+ }
897
+ if(Array.isArray(data.mounted)) {
898
+ for(const cb of data.mounted) {
899
+ cb(node);
900
+ }
901
+ return;
902
+ }
903
+ data.mounted(node);
888
904
  },
905
+
889
906
  executeUnmountedCallback(node) {
890
907
  const data = DocumentObserver.unmounted.get(node);
891
908
  if(!data) {
892
909
  return;
893
910
  }
894
-
895
911
  data.inDom = false;
896
- if(data.unmounted && data.unmounted(node) === true) {
912
+ if(!data.unmounted) {
913
+ return;
914
+ }
915
+
916
+ let shouldRemove = false;
917
+ if(Array.isArray(data.unmounted)) {
918
+ for(const cb of data.unmounted) {
919
+ if(cb(node) === true) {
920
+ shouldRemove = true;
921
+ }
922
+ }
923
+ } else {
924
+ shouldRemove = data.unmounted(node) === true;
925
+ }
926
+
927
+ if(shouldRemove) {
897
928
  data.disconnect();
898
929
  node.nd?.remove();
899
930
  }
900
931
  },
932
+
901
933
  checkMutation: function(mutationsList) {
902
934
  for(const mutation of mutationsList) {
903
- if(DocumentObserver.mountedSupposedSize > 0 ) {
935
+ if(DocumentObserver.mountedSupposedSize > 0) {
904
936
  for(const node of mutation.addedNodes) {
905
937
  DocumentObserver.executeMountedCallback(node);
906
938
  if(!node.querySelectorAll) {
907
- return;
939
+ continue;
908
940
  }
909
941
  const children = node.querySelectorAll('[data--nd-mounted]');
910
- if(!children.length) {
911
- return;
912
- }
913
- for(const node of children) {
914
- DocumentObserver.executeMountedCallback(node);
942
+ for(const child of children) {
943
+ DocumentObserver.executeMountedCallback(child);
915
944
  }
916
945
  }
917
946
  }
918
947
 
919
- if(DocumentObserver.unmountedSupposedSize > 0 ) {
920
- for(const node of mutation.removedNodes) {
948
+ if (DocumentObserver.unmountedSupposedSize > 0) {
949
+ for (const node of mutation.removedNodes) {
921
950
  DocumentObserver.executeUnmountedCallback(node);
922
951
  if(!node.querySelectorAll) {
923
- return;
952
+ continue;
924
953
  }
925
954
  const children = node.querySelectorAll('[data--nd-unmounted]');
926
- if(!children.length) {
927
- return;
928
- }
929
- for(const node of children) {
930
- DocumentObserver.executeUnmountedCallback(node);
955
+ for(const child of children) {
956
+ DocumentObserver.executeUnmountedCallback(child);
931
957
  }
932
958
  }
933
959
  }
934
960
  }
935
961
  },
962
+
936
963
  /**
937
- *
938
964
  * @param {HTMLElement} element
939
965
  * @param {boolean} inDom
940
- * @returns {{watch: (function(): Map<any, any>), disconnect: (function(): boolean), mounted: (function(*): Set<any>), unmounted: (function(*): Set<any>)}}
966
+ * @returns {{ disconnect: Function, mounted: Function, unmounted: Function, off: Function }}
941
967
  */
942
968
  watch: function(element, inDom = false) {
969
+ let mountedRegistered = false;
970
+ let unmountedRegistered = false;
971
+
943
972
  let data = {
944
973
  inDom,
945
974
  mounted: null,
946
975
  unmounted: null,
947
976
  disconnect: () => {
948
- DocumentObserver.mounted.delete(element);
949
- DocumentObserver.unmounted.delete(element);
950
- DocumentObserver.mountedSupposedSize--;
951
- DocumentObserver.unmountedSupposedSize--;
977
+ if (mountedRegistered) {
978
+ DocumentObserver.mounted.delete(element);
979
+ DocumentObserver.mountedSupposedSize--;
980
+ }
981
+ if (unmountedRegistered) {
982
+ DocumentObserver.unmounted.delete(element);
983
+ DocumentObserver.unmountedSupposedSize--;
984
+ }
952
985
  data = null;
953
986
  }
954
987
  };
955
988
 
989
+ const addListener = (type, callback) => {
990
+ if (!data[type]) {
991
+ data[type] = callback;
992
+ return;
993
+ }
994
+ if (!Array.isArray(data[type])) {
995
+ data[type] = [data[type], callback];
996
+ return;
997
+ }
998
+ data[type].push(callback);
999
+ };
1000
+
1001
+ const removeListener = (type, callback) => {
1002
+ if(!data?.[type]) {
1003
+ return;
1004
+ }
1005
+ if(Array.isArray(data[type])) {
1006
+ const index = data[type].indexOf(callback);
1007
+ if(index > -1) {
1008
+ data[type].splice(index, 1);
1009
+ }
1010
+ if(data[type].length === 1) {
1011
+ data[type] = data[type][0];
1012
+ }
1013
+ if(data[type].length === 0) {
1014
+ data[type] = null;
1015
+ }
1016
+ return;
1017
+ }
1018
+ data[type] = null;
1019
+ };
1020
+
956
1021
  return {
957
- disconnect: data.disconnect,
1022
+ disconnect: () => data?.disconnect(),
1023
+
958
1024
  mounted: (callback) => {
959
- data.mounted = callback;
1025
+ addListener('mounted', callback);
960
1026
  DocumentObserver.mounted.set(element, data);
961
- DocumentObserver.mountedSupposedSize++;
1027
+ if (!mountedRegistered) {
1028
+ DocumentObserver.mountedSupposedSize++;
1029
+ mountedRegistered = true;
1030
+ }
962
1031
  },
1032
+
963
1033
  unmounted: (callback) => {
964
- data.unmounted = callback;
1034
+ addListener('unmounted', callback);
965
1035
  DocumentObserver.unmounted.set(element, data);
966
- DocumentObserver.unmountedSupposedSize++;
1036
+ if (!unmountedRegistered) {
1037
+ DocumentObserver.unmountedSupposedSize++;
1038
+ unmountedRegistered = true;
1039
+ }
1040
+ },
1041
+
1042
+ off: (type, callback) => {
1043
+ removeListener(type, callback);
967
1044
  }
968
1045
  };
969
1046
  }
@@ -979,7 +1056,7 @@ var NativeDocument = (function (exports) {
979
1056
  this.$element = element;
980
1057
  this.$observer = null;
981
1058
  {
982
- PluginsManager$1.emit('NDElementCreated', element, this);
1059
+ PluginsManager.emit('NDElementCreated', element, this);
983
1060
  }
984
1061
  }
985
1062
 
@@ -1045,6 +1122,37 @@ var NativeDocument = (function (exports) {
1045
1122
  return this.lifecycle({ unmounted: callback });
1046
1123
  };
1047
1124
 
1125
+ NDElement.prototype.beforeUnmount = function(id, callback) {
1126
+ const el = this.$element;
1127
+
1128
+ if(!DocumentObserver.beforeUnmount.has(el)) {
1129
+ DocumentObserver.beforeUnmount.set(el, new Map());
1130
+ const originalRemove = el.remove.bind(el);
1131
+
1132
+ let $isUnmounting = false;
1133
+
1134
+ el.remove = async () => {
1135
+ if($isUnmounting) {
1136
+ return;
1137
+ }
1138
+ $isUnmounting = true;
1139
+
1140
+ try {
1141
+ const callbacks = DocumentObserver.beforeUnmount.get(el);
1142
+ for (const cb of callbacks.values()) {
1143
+ await cb.call(this, el);
1144
+ }
1145
+ } finally {
1146
+ originalRemove();
1147
+ $isUnmounting = false;
1148
+ }
1149
+ };
1150
+ }
1151
+
1152
+ DocumentObserver.beforeUnmount.get(el).set(id, callback);
1153
+ return this;
1154
+ };
1155
+
1048
1156
  NDElement.prototype.htmlElement = function() {
1049
1157
  return this.$element;
1050
1158
  };
@@ -1123,7 +1231,7 @@ var NativeDocument = (function (exports) {
1123
1231
  }
1124
1232
  {
1125
1233
  if (this[name] && !this.$localExtensions.has(name)) {
1126
- DebugManager$1.warn('NDElement.extend', `Method "${name}" already exists and will be overwritten`);
1234
+ DebugManager.warn('NDElement.extend', `Method "${name}" already exists and will be overwritten`);
1127
1235
  }
1128
1236
  this.$localExtensions.set(name, method);
1129
1237
  }
@@ -1167,30 +1275,30 @@ var NativeDocument = (function (exports) {
1167
1275
  ]);
1168
1276
 
1169
1277
  for (const name in methods) {
1170
- if (!methods.hasOwnProperty(name)) {
1278
+ if (!Object.hasOwn(methods, name)) {
1171
1279
  continue;
1172
1280
  }
1173
1281
 
1174
1282
  const method = methods[name];
1175
1283
 
1176
1284
  if (typeof method !== 'function') {
1177
- DebugManager$1.warn('NDElement.extend', `"${name}" is not a function, skipping`);
1285
+ DebugManager.warn('NDElement.extend', `"${name}" is not a function, skipping`);
1178
1286
  continue;
1179
1287
  }
1180
1288
 
1181
1289
  if (protectedMethods.has(name)) {
1182
- DebugManager$1.error('NDElement.extend', `Cannot override protected method "${name}"`);
1290
+ DebugManager.error('NDElement.extend', `Cannot override protected method "${name}"`);
1183
1291
  throw new NativeDocumentError(`Cannot override protected method "${name}"`);
1184
1292
  }
1185
1293
 
1186
1294
  if (NDElement.prototype[name]) {
1187
- DebugManager$1.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
1295
+ DebugManager.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
1188
1296
  }
1189
1297
 
1190
1298
  NDElement.prototype[name] = method;
1191
1299
  }
1192
1300
  {
1193
- PluginsManager$1.emit('NDElementExtended', methods);
1301
+ PluginsManager.emit('NDElementExtended', methods);
1194
1302
  }
1195
1303
 
1196
1304
  return NDElement;
@@ -1343,7 +1451,7 @@ var NativeDocument = (function (exports) {
1343
1451
  const foundReserved = Object.keys(attributes).filter(key => reserved.includes(key));
1344
1452
 
1345
1453
  if (foundReserved.length > 0) {
1346
- DebugManager$1.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
1454
+ DebugManager.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
1347
1455
  }
1348
1456
 
1349
1457
  return attributes;
@@ -1362,6 +1470,7 @@ var NativeDocument = (function (exports) {
1362
1470
 
1363
1471
  anchorFragment.nativeInsertBefore = anchorFragment.insertBefore;
1364
1472
  anchorFragment.nativeAppendChild = anchorFragment.appendChild;
1473
+ anchorFragment.nativeAppend = anchorFragment.append;
1365
1474
 
1366
1475
  const isParentUniqueChild = (parent) => (isUniqueChild || (parent.firstChild === anchorStart && parent.lastChild === anchorEnd));
1367
1476
 
@@ -1391,65 +1500,72 @@ var NativeDocument = (function (exports) {
1391
1500
  anchorFragment.appendChild = function(child, before = null) {
1392
1501
  const parent = anchorEnd.parentNode;
1393
1502
  if(!parent) {
1394
- DebugManager$1.error('Anchor', 'Anchor : parent not found', child);
1503
+ DebugManager.error('Anchor', 'Anchor : parent not found', child);
1395
1504
  return;
1396
1505
  }
1397
1506
  before = before ?? anchorEnd;
1398
1507
  insertBefore(parent, child, before);
1399
1508
  };
1509
+
1400
1510
  anchorFragment.append = function(...args ) {
1401
1511
  return anchorFragment.appendChild(args);
1402
1512
  };
1403
1513
 
1404
- anchorFragment.removeChildren = function() {
1514
+ anchorFragment.removeChildren = async function() {
1405
1515
  const parent = anchorEnd.parentNode;
1406
1516
  if(parent === anchorFragment) {
1407
1517
  return;
1408
1518
  }
1409
- if(isParentUniqueChild(parent)) {
1410
- parent.replaceChildren(anchorStart, anchorEnd);
1411
- return;
1412
- }
1519
+ // if(isParentUniqueChild(parent)) {
1520
+ // parent.replaceChildren(anchorStart, anchorEnd);
1521
+ // return;
1522
+ // }
1413
1523
 
1414
1524
  let itemToRemove = anchorStart.nextSibling, tempItem;
1415
- const fragment = document.createDocumentFragment();
1525
+ const removes = [];
1416
1526
  while(itemToRemove && itemToRemove !== anchorEnd) {
1417
1527
  tempItem = itemToRemove.nextSibling;
1418
- fragment.append(itemToRemove);
1528
+ removes.push(itemToRemove.remove());
1419
1529
  itemToRemove = tempItem;
1420
1530
  }
1421
- fragment.replaceChildren();
1531
+ await Promise.all(removes);
1422
1532
  };
1423
- anchorFragment.remove = function() {
1533
+
1534
+ anchorFragment.remove = async function() {
1424
1535
  const parent = anchorEnd.parentNode;
1425
1536
  if(parent === anchorFragment) {
1426
1537
  return;
1427
1538
  }
1428
1539
  let itemToRemove = anchorStart.nextSibling, tempItem;
1540
+ const allItemToRemove = [];
1541
+ const removes = [];
1429
1542
  while(itemToRemove && itemToRemove !== anchorEnd) {
1430
1543
  tempItem = itemToRemove.nextSibling;
1431
- anchorFragment.nativeAppendChild(itemToRemove);
1544
+ allItemToRemove.push(itemToRemove);
1545
+ removes.push(itemToRemove.remove());
1432
1546
  itemToRemove = tempItem;
1433
1547
  }
1548
+ await Promise.all(removes);
1549
+ anchorFragment.nativeAppend(...allItemToRemove);
1434
1550
  };
1435
1551
 
1436
- anchorFragment.removeWithAnchors = function() {
1437
- anchorFragment.removeChildren();
1552
+ anchorFragment.removeWithAnchors = async function() {
1553
+ await anchorFragment.removeChildren();
1438
1554
  anchorStart.remove();
1439
1555
  anchorEnd.remove();
1440
1556
  };
1441
1557
 
1442
- anchorFragment.replaceContent = function(child) {
1558
+ anchorFragment.replaceContent = async function(child) {
1443
1559
  const childElement = Validator.isElement(child) ? child : ElementCreator.getChild(child);
1444
1560
  const parent = anchorEnd.parentNode;
1445
1561
  if(!parent) {
1446
1562
  return;
1447
1563
  }
1448
- if(isParentUniqueChild(parent)) {
1449
- parent.replaceChildren(anchorStart, childElement, anchorEnd);
1450
- return;
1451
- }
1452
- anchorFragment.removeChildren();
1564
+ // if(isParentUniqueChild(parent)) {
1565
+ // parent.replaceChildren(anchorStart, childElement, anchorEnd);
1566
+ // return;
1567
+ // }
1568
+ await anchorFragment.removeChildren();
1453
1569
  parent.insertBefore(childElement, anchorEnd);
1454
1570
  };
1455
1571
 
@@ -1784,7 +1900,7 @@ var NativeDocument = (function (exports) {
1784
1900
  Function.prototype.toNdElement = function () {
1785
1901
  const child = this;
1786
1902
  {
1787
- PluginsManager$1.emit('BeforeProcessComponent', child);
1903
+ PluginsManager.emit('BeforeProcessComponent', child);
1788
1904
  }
1789
1905
  return ElementCreator.getChild(child());
1790
1906
  };
@@ -1793,6 +1909,88 @@ var NativeDocument = (function (exports) {
1793
1909
  return ElementCreator.createHydratableNode(null, this);
1794
1910
  };
1795
1911
 
1912
+ /**
1913
+ * @param {HTMLElement} el
1914
+ * @param {number} timeout
1915
+ */
1916
+ const waitForVisualEnd = (el, timeout = 1000) => {
1917
+ return new Promise((resolve) => {
1918
+ let isResolved = false;
1919
+
1920
+ const cleanupAndResolve = (e) => {
1921
+ if (e && e.target !== el) return;
1922
+ if (isResolved) return;
1923
+
1924
+ isResolved = true;
1925
+ el.removeEventListener('transitionend', cleanupAndResolve);
1926
+ el.removeEventListener('animationend', cleanupAndResolve);
1927
+ clearTimeout(timer);
1928
+ resolve();
1929
+ };
1930
+
1931
+ el.addEventListener('transitionend', cleanupAndResolve);
1932
+ el.addEventListener('animationend', cleanupAndResolve);
1933
+
1934
+ const timer = setTimeout(cleanupAndResolve, timeout);
1935
+
1936
+ const style = window.getComputedStyle(el);
1937
+ const hasTransition = style.transitionDuration !== '0s';
1938
+ const hasAnimation = style.animationDuration !== '0s';
1939
+
1940
+ if (!hasTransition && !hasAnimation) {
1941
+ cleanupAndResolve();
1942
+ }
1943
+ });
1944
+ };
1945
+
1946
+ NDElement.prototype.transitionOut = function(transitionName) {
1947
+ const exitClass = transitionName + '-exit';
1948
+ this.beforeUnmount('transition-exit', async function() {
1949
+ this.$element.classes.add(exitClass);
1950
+ await waitForVisualEnd(this.$element);
1951
+ this.$element.classes.remove(exitClass);
1952
+ });
1953
+ return this;
1954
+ };
1955
+
1956
+ NDElement.prototype.transitionIn = function(transitionName) {
1957
+ const startClass = transitionName + '-enter-from';
1958
+ const endClass = transitionName + '-enter-to';
1959
+
1960
+ this.$element.classes.add(startClass);
1961
+
1962
+ this.mounted(() => {
1963
+ requestAnimationFrame(() => {
1964
+ requestAnimationFrame(() => {
1965
+ this.$element.classes.remove(startClass);
1966
+ this.$element.classes.add(endClass);
1967
+
1968
+ waitForVisualEnd(this.$element).then(() => {
1969
+ this.$element.classes.remove(endClass);
1970
+ });
1971
+ });
1972
+ });
1973
+ });
1974
+ return this;
1975
+ };
1976
+
1977
+
1978
+ NDElement.prototype.transition = function (transitionName) {
1979
+ this.transitionIn(transitionName);
1980
+ this.transitionOut(transitionName);
1981
+ return this;
1982
+ };
1983
+
1984
+ NDElement.prototype.animate = function(animationName) {
1985
+ this.$element.classes.add(animationName);
1986
+
1987
+ waitForVisualEnd(this.$element).then(() => {
1988
+ this.$element.classes.remove(animationName);
1989
+ });
1990
+
1991
+ return this;
1992
+ };
1993
+
1796
1994
  String.prototype.handleNdAttribute = function(element, attributeName) {
1797
1995
  element.setAttribute(attributeName, this);
1798
1996
  };
@@ -1890,16 +2088,20 @@ var NativeDocument = (function (exports) {
1890
2088
  processChildren(children, parent) {
1891
2089
  if(children === null) return;
1892
2090
  {
1893
- PluginsManager$1.emit('BeforeProcessChildren', parent);
2091
+ PluginsManager.emit('BeforeProcessChildren', parent);
1894
2092
  }
1895
2093
  let child = this.getChild(children);
1896
2094
  if(child) {
1897
2095
  parent.appendChild(child);
1898
2096
  }
1899
2097
  {
1900
- PluginsManager$1.emit('AfterProcessChildren', parent);
2098
+ PluginsManager.emit('AfterProcessChildren', parent);
1901
2099
  }
1902
2100
  },
2101
+ async safeRemove(element) {
2102
+ await element.remove();
2103
+
2104
+ },
1903
2105
  getChild(child) {
1904
2106
  if(child == null) {
1905
2107
  return null;
@@ -2361,10 +2563,10 @@ var NativeDocument = (function (exports) {
2361
2563
  /**
2362
2564
  *
2363
2565
  * @param {string} name
2364
- * @param {?Function} customWrapper
2566
+ * @param {?Function=} customWrapper
2365
2567
  * @returns {Function}
2366
2568
  */
2367
- function HtmlElementWrapper(name, customWrapper) {
2569
+ function HtmlElementWrapper(name, customWrapper = null) {
2368
2570
  return createHtmlElement.bind(null, name, customWrapper);
2369
2571
  }
2370
2572
 
@@ -2418,7 +2620,7 @@ var NativeDocument = (function (exports) {
2418
2620
  hydrationState[targetType][property] = hydrateFunction;
2419
2621
  };
2420
2622
 
2421
- const bindAttachMethods = function(node, bindDingData, data) {
2623
+ const bindAttachMethods = (node, bindDingData, data) => {
2422
2624
  if(!bindDingData.attach) {
2423
2625
  return null;
2424
2626
  }
@@ -2723,7 +2925,7 @@ var NativeDocument = (function (exports) {
2723
2925
  const once$1 = (fn) => {
2724
2926
  let result = null;
2725
2927
  return (...args) => {
2726
- if(result) {
2928
+ if(result != null) {
2727
2929
  return result;
2728
2930
  }
2729
2931
  result = fn(...args);
@@ -3149,7 +3351,7 @@ var NativeDocument = (function (exports) {
3149
3351
 
3150
3352
  ObservableItem.call(this, target, configs);
3151
3353
  {
3152
- PluginsManager$1.emit('CreateObservableArray', this);
3354
+ PluginsManager.emit('CreateObservableArray', this);
3153
3355
  }
3154
3356
  };
3155
3357
 
@@ -3706,7 +3908,7 @@ var NativeDocument = (function (exports) {
3706
3908
  const observable = new ObservableItem(initialValue);
3707
3909
  const updatedValue = nextTick(() => observable.set(callback()));
3708
3910
  {
3709
- PluginsManager$1.emit('CreateObservableComputed', observable, dependencies);
3911
+ PluginsManager.emit('CreateObservableComputed', observable, dependencies);
3710
3912
  }
3711
3913
 
3712
3914
  if(Validator.isFunction(dependencies)) {
@@ -3808,7 +4010,7 @@ var NativeDocument = (function (exports) {
3808
4010
  * Efficiently manages DOM updates by tracking items with keys.
3809
4011
  *
3810
4012
  * @param {ObservableItem<Array|Object>} data - Observable containing array or object to iterate over
3811
- * @param {Function} callback - Function that renders each item (item, index) => ValidChild
4013
+ * @param {(item: *, index: null|ObservableItem) => NdChild} callback - Function that renders each item (item, index) => ValidChild
3812
4014
  * @param {string|Function} [key] - Property name or function to generate unique keys for items
3813
4015
  * @param {Object} [options={}] - Configuration options
3814
4016
  * @param {boolean} [options.shouldKeepItemsInCache=false] - Whether to cache rendered items
@@ -3847,7 +4049,7 @@ var NativeDocument = (function (exports) {
3847
4049
  }
3848
4050
  const child = cacheItem.child?.deref();
3849
4051
  if(parent && child) {
3850
- parent.removeChild(child);
4052
+ child.remove();
3851
4053
  }
3852
4054
  cacheItem.indexObserver?.cleanup();
3853
4055
  cacheItem.child = null;
@@ -3878,7 +4080,7 @@ var NativeDocument = (function (exports) {
3878
4080
  }
3879
4081
  cache.set(keyId, { keyId, isNew: true, child: new WeakRef(child), indexObserver});
3880
4082
  } catch (e) {
3881
- DebugManager$1.error('ForEach', `Error creating element for key ${keyId}` , e);
4083
+ DebugManager.error('ForEach', `Error creating element for key ${keyId}` , e);
3882
4084
  throw e;
3883
4085
  }
3884
4086
  return keyId;
@@ -3965,7 +4167,7 @@ var NativeDocument = (function (exports) {
3965
4167
  * Provides index observables and handles array mutations efficiently.
3966
4168
  *
3967
4169
  * @param {ObservableArray} data - ObservableArray to iterate over
3968
- * @param {Function} callback - Function that renders each item (item, indexObservable) => ValidChild
4170
+ * @param {(item: *, index: null|ObservableItem) => NdChild} callback - Function that renders each item (item, indexObservable) => ValidChild
3969
4171
  * @param {Object} [configs={}] - Configuration options
3970
4172
  * @param {boolean} [configs.shouldKeepItemsInCache] - Whether to cache rendered items
3971
4173
  * @param {boolean} [configs.isParentUniqueChild] - When it's the only child of the parent
@@ -4237,7 +4439,7 @@ var NativeDocument = (function (exports) {
4237
4439
  * The element is mounted/unmounted from the DOM as the condition changes.
4238
4440
  *
4239
4441
  * @param {ObservableItem<boolean>|ObservableChecker<boolean>|ObservableWhen} condition - Observable condition to watch
4240
- * @param {ValidChild} child - Element or content to show/hide
4442
+ * @param {NdChild|(() => NdChild)} child - Element or content to show/hide
4241
4443
  * @param {Object} [options={}] - Configuration options
4242
4444
  * @param {string|null} [options.comment=null] - Comment for debugging
4243
4445
  * @param {boolean} [options.shouldKeepInCache=true] - Whether to cache the element when hidden
@@ -4248,7 +4450,7 @@ var NativeDocument = (function (exports) {
4248
4450
  */
4249
4451
  const ShowIf = function(condition, child, { comment = null, shouldKeepInCache = true} = {}) {
4250
4452
  if(!(Validator.isObservable(condition)) && !Validator.isObservableWhenResult(condition)) {
4251
- return DebugManager$1.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
4453
+ return DebugManager.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
4252
4454
  }
4253
4455
  const element = Anchor('Show if : '+(comment || ''));
4254
4456
 
@@ -4285,7 +4487,7 @@ var NativeDocument = (function (exports) {
4285
4487
  * Inverse of ShowIf - element is shown when condition is false.
4286
4488
  *
4287
4489
  * @param {ObservableItem<boolean>|ObservableChecker<boolean>} condition - Observable condition to watch
4288
- * @param {ValidChild} child - Element or content to show/hide
4490
+ * @param {NdChild|(() => NdChild)} child - Element or content to show/hide
4289
4491
  * @param {Object} [configs] - Configuration options
4290
4492
  * @param {string|null} [configs.comment] - Comment for debugging
4291
4493
  * @param {boolean} [configs.shouldKeepInCache] - Whether to cache element when hidden
@@ -4306,7 +4508,7 @@ var NativeDocument = (function (exports) {
4306
4508
  * Same as ShowIf - element is shown when condition is true.
4307
4509
  *
4308
4510
  * @param {ObservableItem<boolean>|ObservableChecker<boolean>|ObservableWhen} condition - Observable condition to watch
4309
- * @param {ValidChild} child - Element or content to show/hide
4511
+ * @param {NdChild|(() => NdChild)} child - Element or content to show/hide
4310
4512
  * @param {Object} [configs] - Configuration options
4311
4513
  * @param {string|null} [configs.comment] - Comment for debugging
4312
4514
  * @param {boolean} [configs.shouldKeepInCache] - Whether to cache element when hidden
@@ -4322,13 +4524,13 @@ var NativeDocument = (function (exports) {
4322
4524
  *
4323
4525
  * @overload
4324
4526
  * @param {ObservableWhen} observerWhenResult - Result from observable.when(value)
4325
- * @param {ValidChild} view - Content to show when condition matches
4527
+ * @param {NdChild|(() => NdChild)} view - Content to show when condition matches
4326
4528
  * @returns {AnchorDocumentFragment}
4327
4529
  *
4328
4530
  * @overload
4329
4531
  * @param {ObservableItem} observer - Observable to watch
4330
4532
  * @param {*} target - Value to match
4331
- * @param {ValidChild} view - Content to show when observable equals target
4533
+ * @param {NdChild|(() => NdChild)} view - Content to show when observable equals target
4332
4534
  * @returns {AnchorDocumentFragment}
4333
4535
  *
4334
4536
  * @example
@@ -4372,7 +4574,7 @@ var NativeDocument = (function (exports) {
4372
4574
  * Like a switch statement for UI - shows the content corresponding to current value.
4373
4575
  *
4374
4576
  * @param {ObservableItem|ObservableChecker} $condition - Observable to watch
4375
- * @param {Object<string|number, ValidChild>} values - Map of values to their corresponding content
4577
+ * @param {Object<string|number, NdChild|(() => NdChild)>} values - Map of values to their corresponding content
4376
4578
  * @param {boolean} [shouldKeepInCache=true] - Whether to cache rendered views
4377
4579
  * @returns {AnchorDocumentFragment & {add: Function, remove: Function}} Fragment with dynamic methods
4378
4580
  * @example
@@ -4501,41 +4703,202 @@ var NativeDocument = (function (exports) {
4501
4703
  }
4502
4704
  };
4503
4705
 
4706
+ /**
4707
+ * Creates a `<div>` element.
4708
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLDivElement}
4709
+ */
4504
4710
  const Div = HtmlElementWrapper('div');
4711
+
4712
+ /**
4713
+ * Creates a `<span>` element.
4714
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLSpanElement}
4715
+ */
4505
4716
  const Span = HtmlElementWrapper('span');
4717
+
4718
+ /**
4719
+ * Creates a `<label>` element.
4720
+ * @type {function(LabelAttributes=, NdChild|NdChild[]=): HTMLLabelElement}
4721
+ */
4506
4722
  const Label = HtmlElementWrapper('label');
4723
+
4724
+ /**
4725
+ * Creates a `<p>` element.
4726
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLParagraphElement}
4727
+ */
4507
4728
  const P = HtmlElementWrapper('p');
4729
+
4730
+ /**
4731
+ * Alias for {@link P}.
4732
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLParagraphElement}
4733
+ */
4508
4734
  const Paragraph = P;
4735
+
4736
+ /**
4737
+ * Creates a `<strong>` element.
4738
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
4739
+ */
4509
4740
  const Strong = HtmlElementWrapper('strong');
4741
+
4742
+ /**
4743
+ * Creates a `<h1>` element.
4744
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLHeadingElement}
4745
+ */
4510
4746
  const H1 = HtmlElementWrapper('h1');
4747
+
4748
+ /**
4749
+ * Creates a `<h2>` element.
4750
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLHeadingElement}
4751
+ */
4511
4752
  const H2 = HtmlElementWrapper('h2');
4753
+
4754
+ /**
4755
+ * Creates a `<h3>` element.
4756
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLHeadingElement}
4757
+ */
4512
4758
  const H3 = HtmlElementWrapper('h3');
4759
+
4760
+ /**
4761
+ * Creates a `<h4>` element.
4762
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLHeadingElement}
4763
+ */
4513
4764
  const H4 = HtmlElementWrapper('h4');
4765
+
4766
+ /**
4767
+ * Creates a `<h5>` element.
4768
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLHeadingElement}
4769
+ */
4514
4770
  const H5 = HtmlElementWrapper('h5');
4771
+
4772
+ /**
4773
+ * Creates a `<h6>` element.
4774
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLHeadingElement}
4775
+ */
4515
4776
  const H6 = HtmlElementWrapper('h6');
4516
4777
 
4778
+ /**
4779
+ * Creates a `<br>` element.
4780
+ * @type {function(GlobalAttributes=): HTMLBRElement}
4781
+ */
4517
4782
  const Br = HtmlElementWrapper('br');
4518
4783
 
4784
+ /**
4785
+ * Creates an `<a>` element.
4786
+ * @type {function(AnchorAttributes=, NdChild|NdChild[]=): HTMLAnchorElement}
4787
+ */
4519
4788
  const Link$1 = HtmlElementWrapper('a');
4789
+
4790
+ /**
4791
+ * Creates a `<pre>` element.
4792
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLPreElement}
4793
+ */
4520
4794
  const Pre = HtmlElementWrapper('pre');
4795
+
4796
+ /**
4797
+ * Creates a `<code>` element.
4798
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
4799
+ */
4521
4800
  const Code = HtmlElementWrapper('code');
4801
+
4802
+ /**
4803
+ * Creates a `<blockquote>` element.
4804
+ * @type {function(GlobalAttributes & { cite?: string }=, NdChild|NdChild[]=): HTMLQuoteElement}
4805
+ */
4522
4806
  const Blockquote = HtmlElementWrapper('blockquote');
4807
+
4808
+ /**
4809
+ * Creates an `<hr>` element.
4810
+ * @type {function(GlobalAttributes=): HTMLHRElement}
4811
+ */
4523
4812
  const Hr = HtmlElementWrapper('hr');
4813
+
4814
+ /**
4815
+ * Creates an `<em>` element.
4816
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
4817
+ */
4524
4818
  const Em = HtmlElementWrapper('em');
4819
+
4820
+ /**
4821
+ * Creates a `<small>` element.
4822
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
4823
+ */
4525
4824
  const Small = HtmlElementWrapper('small');
4825
+
4826
+ /**
4827
+ * Creates a `<mark>` element.
4828
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
4829
+ */
4526
4830
  const Mark = HtmlElementWrapper('mark');
4831
+
4832
+ /**
4833
+ * Creates a `<del>` element.
4834
+ * @type {function(ModAttributes=, NdChild|NdChild[]=): HTMLModElement}
4835
+ */
4527
4836
  const Del = HtmlElementWrapper('del');
4837
+
4838
+ /**
4839
+ * Creates an `<ins>` element.
4840
+ * @type {function(ModAttributes=, NdChild|NdChild[]=): HTMLModElement}
4841
+ */
4528
4842
  const Ins = HtmlElementWrapper('ins');
4843
+
4844
+ /**
4845
+ * Creates a `<sub>` element.
4846
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
4847
+ */
4529
4848
  const Sub = HtmlElementWrapper('sub');
4849
+
4850
+ /**
4851
+ * Creates a `<sup>` element.
4852
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
4853
+ */
4530
4854
  const Sup = HtmlElementWrapper('sup');
4855
+
4856
+ /**
4857
+ * Creates an `<abbr>` element.
4858
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
4859
+ */
4531
4860
  const Abbr = HtmlElementWrapper('abbr');
4861
+
4862
+ /**
4863
+ * Creates a `<cite>` element.
4864
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
4865
+ */
4532
4866
  const Cite = HtmlElementWrapper('cite');
4867
+
4868
+ /**
4869
+ * Creates a `<q>` element.
4870
+ * @type {function(GlobalAttributes & { cite?: string }=, NdChild|NdChild[]=): HTMLQuoteElement}
4871
+ */
4533
4872
  const Quote = HtmlElementWrapper('q');
4534
4873
 
4874
+ /**
4875
+ * Creates a `<dl>` element.
4876
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLDListElement}
4877
+ */
4535
4878
  const Dl = HtmlElementWrapper('dl');
4879
+
4880
+ /**
4881
+ * Creates a `<dt>` element.
4882
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
4883
+ */
4536
4884
  const Dt = HtmlElementWrapper('dt');
4885
+
4886
+ /**
4887
+ * Creates a `<dd>` element.
4888
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
4889
+ */
4537
4890
  const Dd = HtmlElementWrapper('dd');
4538
4891
 
4892
+ /**
4893
+ * Creates a `<form>` element.
4894
+ * Extended with fluent methods: `.submit()`, `.post()`, `.get()`, `.multipartFormData()`.
4895
+ * @type {function(FormAttributes=, NdChild|NdChild[]=): HTMLFormElement & {
4896
+ * submit: (actionOrFn: string | ((e: SubmitEvent) => void)) => HTMLFormElement,
4897
+ * post: (action: string) => HTMLFormElement,
4898
+ * get: (action: string) => HTMLFormElement,
4899
+ * multipartFormData: () => HTMLFormElement,
4900
+ * }}
4901
+ */
4539
4902
  const Form = HtmlElementWrapper('form', function(el) {
4540
4903
 
4541
4904
  el.submit = function(action) {
@@ -4565,68 +4928,298 @@ var NativeDocument = (function (exports) {
4565
4928
  return el;
4566
4929
  });
4567
4930
 
4931
+ /**
4932
+ * Creates an `<input>` element.
4933
+ * @type {function(InputAttributes=): HTMLInputElement}
4934
+ */
4568
4935
  const Input = HtmlElementWrapper('input');
4569
4936
 
4937
+ /**
4938
+ * Creates a `<textarea>` element.
4939
+ * @type {function(TextAreaAttributes=, NdChild|NdChild[]=): HTMLTextAreaElement}
4940
+ */
4570
4941
  const TextArea = HtmlElementWrapper('textarea');
4942
+
4943
+ /**
4944
+ * Alias for {@link TextArea}.
4945
+ * @type {function(TextAreaAttributes=, NdChild|NdChild[]=): HTMLTextAreaElement}
4946
+ */
4571
4947
  const TextInput = TextArea;
4572
4948
 
4949
+ /**
4950
+ * Creates a `<select>` element.
4951
+ * @type {function(SelectAttributes=, NdChild|NdChild[]=): HTMLSelectElement}
4952
+ */
4573
4953
  const Select = HtmlElementWrapper('select');
4574
- const FieldSet = HtmlElementWrapper('fieldset', );
4954
+
4955
+ /**
4956
+ * Creates a `<fieldset>` element.
4957
+ * @type {function(GlobalAttributes & { disabled?: Observable<boolean>|boolean }=, NdChild|NdChild[]=): HTMLFieldSetElement}
4958
+ */
4959
+ const FieldSet = HtmlElementWrapper('fieldset');
4960
+
4961
+ /**
4962
+ * Creates an `<option>` element.
4963
+ * @type {function(OptionAttributes=, NdChild|NdChild[]=): HTMLOptionElement}
4964
+ */
4575
4965
  const Option = HtmlElementWrapper('option');
4966
+
4967
+ /**
4968
+ * Creates a `<legend>` element.
4969
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLLegendElement}
4970
+ */
4576
4971
  const Legend = HtmlElementWrapper('legend');
4972
+
4973
+ /**
4974
+ * Creates a `<datalist>` element.
4975
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLDataListElement}
4976
+ */
4577
4977
  const Datalist = HtmlElementWrapper('datalist');
4978
+
4979
+ /**
4980
+ * Creates an `<output>` element.
4981
+ * @type {function(OutputAttributes=, NdChild|NdChild[]=): HTMLOutputElement}
4982
+ */
4578
4983
  const Output = HtmlElementWrapper('output');
4984
+
4985
+ /**
4986
+ * Creates a `<progress>` element.
4987
+ * @type {function(ProgressAttributes=, NdChild|NdChild[]=): HTMLProgressElement}
4988
+ */
4579
4989
  const Progress = HtmlElementWrapper('progress');
4990
+
4991
+ /**
4992
+ * Creates a `<meter>` element.
4993
+ * @type {function(MeterAttributes=, NdChild|NdChild[]=): HTMLMeterElement}
4994
+ */
4580
4995
  const Meter = HtmlElementWrapper('meter');
4581
4996
 
4997
+ /**
4998
+ * Creates an `<input readonly>` element.
4999
+ * @param {Omit<InputAttributes, 'type'|'readonly'|'readOnly'>} [attributes]
5000
+ * @returns {HTMLInputElement}
5001
+ */
4582
5002
  const ReadonlyInput = (attributes) => Input({ readonly: true, ...attributes });
4583
- const HiddenInput = (attributes) => Input({type: 'hidden', ...attributes });
5003
+
5004
+ /**
5005
+ * Creates an `<input type="hidden">` element.
5006
+ * @param {Omit<InputAttributes, 'type'>} [attributes]
5007
+ * @returns {HTMLInputElement}
5008
+ */
5009
+ const HiddenInput = (attributes) => Input({ type: 'hidden', ...attributes });
5010
+
5011
+ /**
5012
+ * Creates an `<input type="file">` element.
5013
+ * @param {Omit<InputAttributes, 'type'>} [attributes]
5014
+ * @returns {HTMLInputElement}
5015
+ */
4584
5016
  const FileInput = (attributes) => Input({ type: 'file', ...attributes });
5017
+
5018
+ /**
5019
+ * Creates an `<input type="password">` element.
5020
+ * @param {Omit<InputAttributes, 'type'>} [attributes]
5021
+ * @returns {HTMLInputElement}
5022
+ */
4585
5023
  const PasswordInput = (attributes) => Input({ type: 'password', ...attributes });
5024
+
5025
+ /**
5026
+ * Creates an `<input type="checkbox">` element.
5027
+ * @param {Omit<InputAttributes, 'type'>} [attributes]
5028
+ * @returns {HTMLInputElement}
5029
+ */
4586
5030
  const Checkbox = (attributes) => Input({ type: 'checkbox', ...attributes });
5031
+
5032
+ /**
5033
+ * Creates an `<input type="radio">` element.
5034
+ * @param {Omit<InputAttributes, 'type'>} [attributes]
5035
+ * @returns {HTMLInputElement}
5036
+ */
4587
5037
  const Radio = (attributes) => Input({ type: 'radio', ...attributes });
4588
5038
 
5039
+ /**
5040
+ * Creates an `<input type="range">` element.
5041
+ * @param {Omit<InputAttributes, 'type'>} [attributes]
5042
+ * @returns {HTMLInputElement}
5043
+ */
4589
5044
  const RangeInput = (attributes) => Input({ type: 'range', ...attributes });
5045
+
5046
+ /**
5047
+ * Creates an `<input type="color">` element.
5048
+ * @param {Omit<InputAttributes, 'type'>} [attributes]
5049
+ * @returns {HTMLInputElement}
5050
+ */
4590
5051
  const ColorInput = (attributes) => Input({ type: 'color', ...attributes });
5052
+
5053
+ /**
5054
+ * Creates an `<input type="date">` element.
5055
+ * @param {Omit<InputAttributes, 'type'>} [attributes]
5056
+ * @returns {HTMLInputElement}
5057
+ */
4591
5058
  const DateInput = (attributes) => Input({ type: 'date', ...attributes });
5059
+
5060
+ /**
5061
+ * Creates an `<input type="time">` element.
5062
+ * @param {Omit<InputAttributes, 'type'>} [attributes]
5063
+ * @returns {HTMLInputElement}
5064
+ */
4592
5065
  const TimeInput = (attributes) => Input({ type: 'time', ...attributes });
5066
+
5067
+ /**
5068
+ * Creates an `<input type="datetime-local">` element.
5069
+ * @param {Omit<InputAttributes, 'type'>} [attributes]
5070
+ * @returns {HTMLInputElement}
5071
+ */
4593
5072
  const DateTimeInput = (attributes) => Input({ type: 'datetime-local', ...attributes });
5073
+
5074
+ /**
5075
+ * Creates an `<input type="week">` element.
5076
+ * @param {Omit<InputAttributes, 'type'>} [attributes]
5077
+ * @returns {HTMLInputElement}
5078
+ */
4594
5079
  const WeekInput = (attributes) => Input({ type: 'week', ...attributes });
5080
+
5081
+ /**
5082
+ * Creates an `<input type="month">` element.
5083
+ * @param {Omit<InputAttributes, 'type'>} [attributes]
5084
+ * @returns {HTMLInputElement}
5085
+ */
4595
5086
  const MonthInput = (attributes) => Input({ type: 'month', ...attributes });
5087
+
5088
+ /**
5089
+ * Creates an `<input type="search">` element.
5090
+ * @param {Omit<InputAttributes, 'type'>} [attributes]
5091
+ * @returns {HTMLInputElement}
5092
+ */
4596
5093
  const SearchInput = (attributes) => Input({ type: 'search', ...attributes });
5094
+
5095
+ /**
5096
+ * Creates an `<input type="tel">` element.
5097
+ * @param {Omit<InputAttributes, 'type'>} [attributes]
5098
+ * @returns {HTMLInputElement}
5099
+ */
4597
5100
  const TelInput = (attributes) => Input({ type: 'tel', ...attributes });
5101
+
5102
+ /**
5103
+ * Creates an `<input type="url">` element.
5104
+ * @param {Omit<InputAttributes, 'type'>} [attributes]
5105
+ * @returns {HTMLInputElement}
5106
+ */
4598
5107
  const UrlInput = (attributes) => Input({ type: 'url', ...attributes });
5108
+
5109
+ /**
5110
+ * Creates an `<input type="email">` element.
5111
+ * @param {Omit<InputAttributes, 'type'>} [attributes]
5112
+ * @returns {HTMLInputElement}
5113
+ */
4599
5114
  const EmailInput = (attributes) => Input({ type: 'email', ...attributes });
4600
- const NumberInput = (attributes) => Input({ type: 'number', ...attributes });
4601
5115
 
5116
+ /**
5117
+ * Creates an `<input type="number">` element.
5118
+ * @param {Omit<InputAttributes, 'type'>} [attributes]
5119
+ * @returns {HTMLInputElement}
5120
+ */
5121
+ const NumberInput = (attributes) => Input({ type: 'number', ...attributes });
4602
5122
 
5123
+ /**
5124
+ * Creates a `<button>` element.
5125
+ * @type {function(ButtonAttributes=, NdChild|NdChild[]=): HTMLButtonElement}
5126
+ */
4603
5127
  const Button = HtmlElementWrapper('button');
5128
+
5129
+ /**
5130
+ * Creates a `<button type="button">` element.
5131
+ * @param {NdChild|NdChild[]} [child]
5132
+ * @param {Omit<ButtonAttributes, 'type'>} [attributes]
5133
+ * @returns {HTMLButtonElement}
5134
+ */
4604
5135
  const SimpleButton = (child, attributes) => Button(child, { type: 'button', ...attributes });
5136
+
5137
+ /**
5138
+ * Creates a `<button type="submit">` element.
5139
+ * @param {NdChild|NdChild[]} [child]
5140
+ * @param {Omit<ButtonAttributes, 'type'>} [attributes]
5141
+ * @returns {HTMLButtonElement}
5142
+ */
4605
5143
  const SubmitButton = (child, attributes) => Button(child, { type: 'submit', ...attributes });
4606
5144
 
5145
+ /**
5146
+ * Creates a `<main>` element.
5147
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
5148
+ */
4607
5149
  const Main = HtmlElementWrapper('main');
5150
+
5151
+ /**
5152
+ * Creates a `<section>` element.
5153
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
5154
+ */
4608
5155
  const Section = HtmlElementWrapper('section');
5156
+
5157
+ /**
5158
+ * Creates an `<article>` element.
5159
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
5160
+ */
4609
5161
  const Article = HtmlElementWrapper('article');
5162
+
5163
+ /**
5164
+ * Creates an `<aside>` element.
5165
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
5166
+ */
4610
5167
  const Aside = HtmlElementWrapper('aside');
5168
+
5169
+ /**
5170
+ * Creates a `<nav>` element.
5171
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
5172
+ */
4611
5173
  const Nav = HtmlElementWrapper('nav');
5174
+
5175
+ /**
5176
+ * Creates a `<figure>` element.
5177
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
5178
+ */
4612
5179
  const Figure = HtmlElementWrapper('figure');
5180
+
5181
+ /**
5182
+ * Creates a `<figcaption>` element.
5183
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
5184
+ */
4613
5185
  const FigCaption = HtmlElementWrapper('figcaption');
4614
5186
 
5187
+ /**
5188
+ * Creates a `<header>` element.
5189
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
5190
+ */
4615
5191
  const Header = HtmlElementWrapper('header');
5192
+
5193
+ /**
5194
+ * Creates a `<footer>` element.
5195
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
5196
+ */
4616
5197
  const Footer = HtmlElementWrapper('footer');
4617
5198
 
5199
+ /**
5200
+ * Creates an `<img>` element.
5201
+ * @type {function(ImgAttributes=): HTMLImageElement}
5202
+ */
4618
5203
  const BaseImage = HtmlElementWrapper('img');
5204
+
5205
+ /**
5206
+ * Creates an `<img>` element.
5207
+ * @param {Observable<string>|string} src
5208
+ * @param {Omit<ImgAttributes, 'src'>} [attributes]
5209
+ * @returns {HTMLImageElement}
5210
+ */
4619
5211
  const Img = function(src, attributes) {
4620
5212
  return BaseImage({ src, ...attributes });
4621
5213
  };
4622
5214
 
4623
5215
  /**
4624
- *
4625
- * @param {string} src
4626
- * @param {string|null} defaultImage
4627
- * @param {Object} attributes
4628
- * @param {?Function} callback
4629
- * @returns {Image}
5216
+ * Creates an `<img>` that loads asynchronously, showing a placeholder until the image is ready.
5217
+ * Supports reactive `src` — automatically updates when the observable changes.
5218
+ * @param {Observable<string>|string} src - Final image URL
5219
+ * @param {string|null} defaultImage - Placeholder shown while loading
5220
+ * @param {Omit<ImgAttributes, 'src'>} attributes
5221
+ * @param {(error: NativeDocumentError|null, img: HTMLImageElement) => void} [callback]
5222
+ * @returns {HTMLImageElement}
4630
5223
  */
4631
5224
  const AsyncImg = function(src, defaultImage, attributes, callback) {
4632
5225
  const defaultSrc = Validator.isObservable(src) ? src.val() : src;
@@ -4650,56 +5243,230 @@ var NativeDocument = (function (exports) {
4650
5243
  };
4651
5244
 
4652
5245
  /**
4653
- *
4654
- * @param {string} src
4655
- * @param {Object} attributes
4656
- * @returns {Image}
5246
+ * Creates an `<img loading="lazy">` element.
5247
+ * @param {Observable<string>|string} src
5248
+ * @param {Omit<ImgAttributes, 'src'|'loading'>} [attributes]
5249
+ * @returns {HTMLImageElement}
4657
5250
  */
4658
5251
  const LazyImg = function(src, attributes) {
4659
5252
  return Img(src, { ...attributes, loading: 'lazy' });
4660
5253
  };
4661
5254
 
5255
+ /**
5256
+ * Creates a `<details>` element.
5257
+ * @type {function(DetailsAttributes=, NdChild|NdChild[]=): HTMLDetailsElement}
5258
+ */
4662
5259
  const Details = HtmlElementWrapper('details');
5260
+
5261
+ /**
5262
+ * Creates a `<summary>` element.
5263
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
5264
+ */
4663
5265
  const Summary = HtmlElementWrapper('summary');
5266
+
5267
+ /**
5268
+ * Creates a `<dialog>` element.
5269
+ * @type {function(DialogAttributes=, NdChild|NdChild[]=): HTMLDialogElement}
5270
+ */
4664
5271
  const Dialog = HtmlElementWrapper('dialog');
5272
+
5273
+ /**
5274
+ * Creates a `<menu>` element.
5275
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLMenuElement}
5276
+ */
4665
5277
  const Menu = HtmlElementWrapper('menu');
4666
5278
 
5279
+ /**
5280
+ * Creates an `<ol>` element.
5281
+ * @type {function(OlAttributes=, NdChild|NdChild[]=): HTMLOListElement}
5282
+ */
4667
5283
  const OrderedList = HtmlElementWrapper('ol');
5284
+
5285
+ /**
5286
+ * Creates a `<ul>` element.
5287
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLUListElement}
5288
+ */
4668
5289
  const UnorderedList = HtmlElementWrapper('ul');
5290
+
5291
+ /**
5292
+ * Creates a `<li>` element.
5293
+ * @type {function(GlobalAttributes & { value?: number }=, NdChild|NdChild[]=): HTMLLIElement}
5294
+ */
4669
5295
  const ListItem = HtmlElementWrapper('li');
4670
5296
 
5297
+ /**
5298
+ * Alias for {@link ListItem}.
5299
+ * @type {typeof ListItem}
5300
+ */
4671
5301
  const Li = ListItem;
5302
+
5303
+ /**
5304
+ * Alias for {@link OrderedList}.
5305
+ * @type {typeof OrderedList}
5306
+ */
4672
5307
  const Ol = OrderedList;
5308
+
5309
+ /**
5310
+ * Alias for {@link UnorderedList}.
5311
+ * @type {typeof UnorderedList}
5312
+ */
4673
5313
  const Ul = UnorderedList;
4674
5314
 
5315
+ /**
5316
+ * Creates an `<audio>` element.
5317
+ * @type {function(AudioAttributes=, NdChild|NdChild[]=): HTMLAudioElement}
5318
+ */
4675
5319
  const Audio = HtmlElementWrapper('audio');
5320
+
5321
+ /**
5322
+ * Creates a `<video>` element.
5323
+ * @type {function(VideoAttributes=, NdChild|NdChild[]=): HTMLVideoElement}
5324
+ */
4676
5325
  const Video = HtmlElementWrapper('video');
5326
+
5327
+ /**
5328
+ * Creates a `<source>` element.
5329
+ * @type {function(SourceAttributes=): HTMLSourceElement}
5330
+ */
4677
5331
  const Source = HtmlElementWrapper('source');
5332
+
5333
+ /**
5334
+ * Creates a `<track>` element.
5335
+ * @type {function(TrackAttributes=): HTMLTrackElement}
5336
+ */
4678
5337
  const Track = HtmlElementWrapper('track');
5338
+
5339
+ /**
5340
+ * Creates a `<canvas>` element.
5341
+ * @type {function(CanvasAttributes=, NdChild|NdChild[]=): HTMLCanvasElement}
5342
+ */
4679
5343
  const Canvas = HtmlElementWrapper('canvas');
5344
+
5345
+ /**
5346
+ * Creates an `<svg>` element.
5347
+ * @type {function(SvgAttributes=, NdChild|NdChild[]=): SVGSVGElement}
5348
+ */
4680
5349
  const Svg = HtmlElementWrapper('svg');
4681
5350
 
5351
+ /**
5352
+ * Creates a `<time>` element.
5353
+ * @type {function(TimeAttributes=, NdChild|NdChild[]=): HTMLTimeElement}
5354
+ */
4682
5355
  const Time = HtmlElementWrapper('time');
5356
+
5357
+ /**
5358
+ * Creates a `<data>` element.
5359
+ * @type {function(GlobalAttributes & { value?: Observable<string>|string }=, NdChild|NdChild[]=): HTMLDataElement}
5360
+ */
4683
5361
  const Data = HtmlElementWrapper('data');
5362
+
5363
+ /**
5364
+ * Creates an `<address>` element.
5365
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
5366
+ */
4684
5367
  const Address = HtmlElementWrapper('address');
5368
+
5369
+ /**
5370
+ * Creates a `<kbd>` element.
5371
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
5372
+ */
4685
5373
  const Kbd = HtmlElementWrapper('kbd');
5374
+
5375
+ /**
5376
+ * Creates a `<samp>` element.
5377
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
5378
+ */
4686
5379
  const Samp = HtmlElementWrapper('samp');
5380
+
5381
+ /**
5382
+ * Creates a `<var>` element.
5383
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
5384
+ */
4687
5385
  const Var = HtmlElementWrapper('var');
5386
+
5387
+ /**
5388
+ * Creates a `<wbr>` element.
5389
+ * @type {function(GlobalAttributes=): HTMLElement}
5390
+ */
4688
5391
  const Wbr = HtmlElementWrapper('wbr');
4689
5392
 
5393
+ /**
5394
+ * Creates a `<caption>` element.
5395
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLTableCaptionElement}
5396
+ */
4690
5397
  const Caption = HtmlElementWrapper('caption');
5398
+
5399
+ /**
5400
+ * Creates a `<table>` element.
5401
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLTableElement}
5402
+ */
4691
5403
  const Table = HtmlElementWrapper('table');
5404
+
5405
+ /**
5406
+ * Creates a `<thead>` element.
5407
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLTableSectionElement}
5408
+ */
4692
5409
  const THead = HtmlElementWrapper('thead');
5410
+
5411
+ /**
5412
+ * Creates a `<tfoot>` element.
5413
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLTableSectionElement}
5414
+ */
4693
5415
  const TFoot = HtmlElementWrapper('tfoot');
5416
+
5417
+ /**
5418
+ * Creates a `<tbody>` element.
5419
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLTableSectionElement}
5420
+ */
4694
5421
  const TBody = HtmlElementWrapper('tbody');
5422
+
5423
+ /**
5424
+ * Creates a `<tr>` element.
5425
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLTableRowElement}
5426
+ */
4695
5427
  const Tr = HtmlElementWrapper('tr');
5428
+
5429
+ /**
5430
+ * Alias for {@link Tr}.
5431
+ * @type {typeof Tr}
5432
+ */
4696
5433
  const TRow = Tr;
5434
+
5435
+ /**
5436
+ * Creates a `<th>` element.
5437
+ * @type {function(ThAttributes=, NdChild|NdChild[]=): HTMLTableCellElement}
5438
+ */
4697
5439
  const Th = HtmlElementWrapper('th');
5440
+
5441
+ /**
5442
+ * Alias for {@link Th}.
5443
+ * @type {typeof Th}
5444
+ */
4698
5445
  const THeadCell = Th;
5446
+
5447
+ /**
5448
+ * Alias for {@link Th}.
5449
+ * @type {typeof Th}
5450
+ */
4699
5451
  const TFootCell = Th;
5452
+
5453
+ /**
5454
+ * Creates a `<td>` element.
5455
+ * @type {function(TdAttributes=, NdChild|NdChild[]=): HTMLTableCellElement}
5456
+ */
4700
5457
  const Td = HtmlElementWrapper('td');
5458
+
5459
+ /**
5460
+ * Alias for {@link Td}.
5461
+ * @type {typeof Td}
5462
+ */
4701
5463
  const TBodyCell = Td;
4702
5464
 
5465
+ /**
5466
+ * Creates an empty `DocumentFragment` wrapper.
5467
+ * Useful for grouping elements without adding a DOM node.
5468
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): DocumentFragment}
5469
+ */
4703
5470
  const Fragment = HtmlElementWrapper('');
4704
5471
 
4705
5472
  var elements = /*#__PURE__*/Object.freeze({
@@ -5102,7 +5869,7 @@ var NativeDocument = (function (exports) {
5102
5869
  window.history.pushState({ name: route.name(), params, path}, route.name() || path , path);
5103
5870
  this.handleRouteChange(route, params, query, path);
5104
5871
  } catch (e) {
5105
- DebugManager$1.error('HistoryRouter', 'Error in pushState', e);
5872
+ DebugManager.error('HistoryRouter', 'Error in pushState', e);
5106
5873
  }
5107
5874
  };
5108
5875
  /**
@@ -5115,7 +5882,7 @@ var NativeDocument = (function (exports) {
5115
5882
  window.history.replaceState({ name: route.name(), params, path}, route.name() || path , path);
5116
5883
  this.handleRouteChange(route, params, {}, path);
5117
5884
  } catch(e) {
5118
- DebugManager$1.error('HistoryRouter', 'Error in replaceState', e);
5885
+ DebugManager.error('HistoryRouter', 'Error in replaceState', e);
5119
5886
  }
5120
5887
  };
5121
5888
  this.forward = function() {
@@ -5142,7 +5909,7 @@ var NativeDocument = (function (exports) {
5142
5909
  }
5143
5910
  this.handleRouteChange(route, params, query, path);
5144
5911
  } catch(e) {
5145
- DebugManager$1.error('HistoryRouter', 'Error in popstate event', e);
5912
+ DebugManager.error('HistoryRouter', 'Error in popstate event', e);
5146
5913
  }
5147
5914
  });
5148
5915
  const { route, params, query, path } = this.resolve(defaultPath || (window.location.pathname+window.location.search));
@@ -5367,7 +6134,7 @@ var NativeDocument = (function (exports) {
5367
6134
  listener(request);
5368
6135
  next && next(request);
5369
6136
  } catch (e) {
5370
- DebugManager$1.warn('Route Listener', 'Error in listener:', e);
6137
+ DebugManager.warn('Route Listener', 'Error in listener:', e);
5371
6138
  }
5372
6139
  }
5373
6140
  };
@@ -5545,7 +6312,7 @@ var NativeDocument = (function (exports) {
5545
6312
  */
5546
6313
  Router.create = function(options, callback) {
5547
6314
  if(!Validator.isFunction(callback)) {
5548
- DebugManager$1.error('Router', 'Callback must be a function');
6315
+ DebugManager.error('Router', 'Callback must be a function');
5549
6316
  throw new RouterError('Callback must be a function');
5550
6317
  }
5551
6318
  const router = new Router(options);
@@ -5735,7 +6502,7 @@ var NativeDocument = (function (exports) {
5735
6502
  exports.HtmlElementWrapper = HtmlElementWrapper;
5736
6503
  exports.NDElement = NDElement;
5737
6504
  exports.Observable = Observable;
5738
- exports.PluginsManager = PluginsManager$1;
6505
+ exports.PluginsManager = PluginsManager;
5739
6506
  exports.SingletonView = SingletonView;
5740
6507
  exports.Store = Store;
5741
6508
  exports.TemplateCloner = TemplateCloner;