native-document 1.0.123 → 1.0.125
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.
- package/dist/native-document.components.min.js +95 -66
- package/dist/native-document.dev.js +102 -99
- package/dist/native-document.dev.js.map +1 -1
- package/dist/native-document.min.js +1 -1
- package/package.json +1 -1
- package/src/components/BaseComponent.js +1 -1
- package/src/components/context-menu/ContextMenu.js +1 -1
- package/src/components/menu/Menu.js +5 -0
- package/src/components/menu/MenuDivider.js +1 -1
- package/src/components/menu/MenuItem.js +20 -0
- package/src/core/elements/anchor/anchor-with-sentinel.js +5 -1
- package/src/core/elements/anchor/anchor.js +2 -5
- package/src/core/elements/control/for-each-array.js +6 -9
- package/src/core/wrappers/AttributesWrapper.js +23 -31
- package/src/core/wrappers/DocumentObserver.js +13 -6
- package/src/core/wrappers/HtmlElementWrapper.js +5 -1
- package/src/router/RouterComponent.js +2 -0
- package/src/ui/components/button/Button.js +8 -0
- package/src/ui/components/button/button.css +0 -0
- package/src/ui/index.js +0 -0
- package/src/ui/theme.js +5 -0
- package/src/ui/tokens/vars.css +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var NativeDocument = (function (exports) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
let DebugManager$
|
|
4
|
+
let DebugManager$2 = {};
|
|
5
5
|
|
|
6
6
|
{
|
|
7
|
-
DebugManager$
|
|
7
|
+
DebugManager$2 = {
|
|
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$
|
|
38
|
+
var DebugManager$1 = DebugManager$2;
|
|
39
39
|
|
|
40
40
|
class NativeDocumentError extends Error {
|
|
41
41
|
constructor(message, context = {}) {
|
|
@@ -146,6 +146,16 @@ var NativeDocument = (function (exports) {
|
|
|
146
146
|
unmounted: new WeakMap(),
|
|
147
147
|
unmountedSupposedSize: 0,
|
|
148
148
|
observer: null,
|
|
149
|
+
initObserver: () => {
|
|
150
|
+
if(DocumentObserver.observer) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
DocumentObserver.observer = new MutationObserver(DocumentObserver.checkMutation);
|
|
154
|
+
DocumentObserver.observer.observe(document.body, {
|
|
155
|
+
childList: true,
|
|
156
|
+
subtree: true,
|
|
157
|
+
});
|
|
158
|
+
},
|
|
149
159
|
|
|
150
160
|
executeMountedCallback(node) {
|
|
151
161
|
const data = DocumentObserver.mounted.get(node);
|
|
@@ -193,6 +203,7 @@ var NativeDocument = (function (exports) {
|
|
|
193
203
|
},
|
|
194
204
|
|
|
195
205
|
checkMutation: function(mutationsList) {
|
|
206
|
+
console.log('mutationsList', mutationsList);
|
|
196
207
|
for(const mutation of mutationsList) {
|
|
197
208
|
if(DocumentObserver.mountedSupposedSize > 0) {
|
|
198
209
|
for(const node of mutation.addedNodes) {
|
|
@@ -231,6 +242,8 @@ var NativeDocument = (function (exports) {
|
|
|
231
242
|
let mountedRegistered = false;
|
|
232
243
|
let unmountedRegistered = false;
|
|
233
244
|
|
|
245
|
+
DocumentObserver.initObserver();
|
|
246
|
+
|
|
234
247
|
let data = {
|
|
235
248
|
inDom,
|
|
236
249
|
mounted: null,
|
|
@@ -308,16 +321,10 @@ var NativeDocument = (function (exports) {
|
|
|
308
321
|
}
|
|
309
322
|
};
|
|
310
323
|
|
|
311
|
-
|
|
312
|
-
DocumentObserver.observer.observe(document.body, {
|
|
313
|
-
childList: true,
|
|
314
|
-
subtree: true,
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
let PluginsManager = null;
|
|
324
|
+
let PluginsManager$1 = null;
|
|
318
325
|
|
|
319
326
|
{
|
|
320
|
-
PluginsManager = (function() {
|
|
327
|
+
PluginsManager$1 = (function() {
|
|
321
328
|
|
|
322
329
|
const $plugins = new Map();
|
|
323
330
|
const $pluginByEvents = new Map();
|
|
@@ -383,7 +390,7 @@ var NativeDocument = (function (exports) {
|
|
|
383
390
|
try{
|
|
384
391
|
callback.call(plugin, ...data);
|
|
385
392
|
} catch (error) {
|
|
386
|
-
DebugManager$
|
|
393
|
+
DebugManager$1.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
|
|
387
394
|
}
|
|
388
395
|
}
|
|
389
396
|
}
|
|
@@ -392,12 +399,12 @@ var NativeDocument = (function (exports) {
|
|
|
392
399
|
}());
|
|
393
400
|
}
|
|
394
401
|
|
|
395
|
-
var PluginsManager
|
|
402
|
+
var PluginsManager = PluginsManager$1;
|
|
396
403
|
|
|
397
404
|
function NDElement(element) {
|
|
398
405
|
this.$element = element;
|
|
399
406
|
{
|
|
400
|
-
PluginsManager
|
|
407
|
+
PluginsManager.emit('NDElementCreated', element, this);
|
|
401
408
|
}
|
|
402
409
|
}
|
|
403
410
|
|
|
@@ -562,7 +569,7 @@ var NativeDocument = (function (exports) {
|
|
|
562
569
|
}
|
|
563
570
|
{
|
|
564
571
|
if (this[name] && !this.$localExtensions.has(name)) {
|
|
565
|
-
DebugManager$
|
|
572
|
+
DebugManager$1.warn('NDElement.extend', `Method "${name}" already exists and will be overwritten`);
|
|
566
573
|
}
|
|
567
574
|
this.$localExtensions.set(name, method);
|
|
568
575
|
}
|
|
@@ -613,23 +620,23 @@ var NativeDocument = (function (exports) {
|
|
|
613
620
|
const method = methods[name];
|
|
614
621
|
|
|
615
622
|
if (typeof method !== 'function') {
|
|
616
|
-
DebugManager$
|
|
623
|
+
DebugManager$1.warn('NDElement.extend', `"${name}" is not a function, skipping`);
|
|
617
624
|
continue;
|
|
618
625
|
}
|
|
619
626
|
|
|
620
627
|
if (protectedMethods.has(name)) {
|
|
621
|
-
DebugManager$
|
|
628
|
+
DebugManager$1.error('NDElement.extend', `Cannot override protected method "${name}"`);
|
|
622
629
|
throw new NativeDocumentError(`Cannot override protected method "${name}"`);
|
|
623
630
|
}
|
|
624
631
|
|
|
625
632
|
if (NDElement.prototype[name]) {
|
|
626
|
-
DebugManager$
|
|
633
|
+
DebugManager$1.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
|
|
627
634
|
}
|
|
628
635
|
|
|
629
636
|
NDElement.prototype[name] = method;
|
|
630
637
|
}
|
|
631
638
|
{
|
|
632
|
-
PluginsManager
|
|
639
|
+
PluginsManager.emit('NDElementExtended', methods);
|
|
633
640
|
}
|
|
634
641
|
|
|
635
642
|
return NDElement;
|
|
@@ -780,7 +787,7 @@ var NativeDocument = (function (exports) {
|
|
|
780
787
|
const foundReserved = Object.keys(attributes).filter(key => reserved.includes(key));
|
|
781
788
|
|
|
782
789
|
if (foundReserved.length > 0) {
|
|
783
|
-
DebugManager$
|
|
790
|
+
DebugManager$1.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
|
|
784
791
|
}
|
|
785
792
|
|
|
786
793
|
return attributes;
|
|
@@ -867,7 +874,7 @@ var NativeDocument = (function (exports) {
|
|
|
867
874
|
}
|
|
868
875
|
}
|
|
869
876
|
if (cleanedCount > 0) {
|
|
870
|
-
DebugManager$
|
|
877
|
+
DebugManager$1.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
|
|
871
878
|
}
|
|
872
879
|
}
|
|
873
880
|
};
|
|
@@ -1178,7 +1185,7 @@ var NativeDocument = (function (exports) {
|
|
|
1178
1185
|
}
|
|
1179
1186
|
}
|
|
1180
1187
|
{
|
|
1181
|
-
PluginsManager
|
|
1188
|
+
PluginsManager.emit('CreateObservable', this);
|
|
1182
1189
|
}
|
|
1183
1190
|
}
|
|
1184
1191
|
|
|
@@ -1285,12 +1292,12 @@ var NativeDocument = (function (exports) {
|
|
|
1285
1292
|
this.$previousValue = this.$currentValue;
|
|
1286
1293
|
this.$currentValue = newValue;
|
|
1287
1294
|
{
|
|
1288
|
-
PluginsManager
|
|
1295
|
+
PluginsManager.emit('ObservableBeforeChange', this);
|
|
1289
1296
|
}
|
|
1290
1297
|
this.trigger($setOperation);
|
|
1291
1298
|
this.$previousValue = null;
|
|
1292
1299
|
{
|
|
1293
|
-
PluginsManager
|
|
1300
|
+
PluginsManager.emit('ObservableAfterChange', this);
|
|
1294
1301
|
}
|
|
1295
1302
|
};
|
|
1296
1303
|
|
|
@@ -1368,7 +1375,7 @@ var NativeDocument = (function (exports) {
|
|
|
1368
1375
|
ObservableItem.prototype.subscribe = function(callback) {
|
|
1369
1376
|
{
|
|
1370
1377
|
if (this.$isCleanedUp) {
|
|
1371
|
-
DebugManager$
|
|
1378
|
+
DebugManager$1.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
|
|
1372
1379
|
return;
|
|
1373
1380
|
}
|
|
1374
1381
|
if (typeof callback !== 'function') {
|
|
@@ -1380,7 +1387,7 @@ var NativeDocument = (function (exports) {
|
|
|
1380
1387
|
this.$listeners.push(callback);
|
|
1381
1388
|
this.assocTrigger();
|
|
1382
1389
|
{
|
|
1383
|
-
PluginsManager
|
|
1390
|
+
PluginsManager.emit('ObservableSubscribe', this);
|
|
1384
1391
|
}
|
|
1385
1392
|
};
|
|
1386
1393
|
|
|
@@ -1491,7 +1498,7 @@ var NativeDocument = (function (exports) {
|
|
|
1491
1498
|
}
|
|
1492
1499
|
this.assocTrigger();
|
|
1493
1500
|
{
|
|
1494
|
-
PluginsManager
|
|
1501
|
+
PluginsManager.emit('ObservableUnsubscribe', this);
|
|
1495
1502
|
}
|
|
1496
1503
|
};
|
|
1497
1504
|
|
|
@@ -1871,35 +1878,6 @@ var NativeDocument = (function (exports) {
|
|
|
1871
1878
|
element.setAttribute(attributeName, value.val());
|
|
1872
1879
|
};
|
|
1873
1880
|
|
|
1874
|
-
|
|
1875
|
-
const AttributeHandlers = {
|
|
1876
|
-
string: (element, attributeName, value) => element.setAttribute(attributeName, value),
|
|
1877
|
-
number: (element, attributeName, value) => element.setAttribute(attributeName, value),
|
|
1878
|
-
boolean: (element, attributeName, value) => bindBooleanAttribute(element, attributeName, value),
|
|
1879
|
-
object: (element, attributeName, value) => {
|
|
1880
|
-
if(value == null) {
|
|
1881
|
-
return;
|
|
1882
|
-
}
|
|
1883
|
-
|
|
1884
|
-
if(value.handleNdAttribute) {
|
|
1885
|
-
value.handleNdAttribute(element, attributeName);
|
|
1886
|
-
return;
|
|
1887
|
-
}
|
|
1888
|
-
|
|
1889
|
-
if(attributeName === 'class') {
|
|
1890
|
-
bindClassAttribute(element, value);
|
|
1891
|
-
return;
|
|
1892
|
-
}
|
|
1893
|
-
if(attributeName === 'style') {
|
|
1894
|
-
bindStyleAttribute(element, value);
|
|
1895
|
-
return;
|
|
1896
|
-
}
|
|
1897
|
-
if(BOOLEAN_ATTRIBUTES.has(attributeName)) {
|
|
1898
|
-
bindBooleanAttribute(element, attributeName, value);
|
|
1899
|
-
}
|
|
1900
|
-
}
|
|
1901
|
-
};
|
|
1902
|
-
|
|
1903
1881
|
/**
|
|
1904
1882
|
*
|
|
1905
1883
|
* @param {HTMLElement} element
|
|
@@ -1914,8 +1892,29 @@ var NativeDocument = (function (exports) {
|
|
|
1914
1892
|
for(const originalAttributeName in attributes) {
|
|
1915
1893
|
const attributeName = originalAttributeName.toLowerCase();
|
|
1916
1894
|
let value = attributes[originalAttributeName];
|
|
1917
|
-
|
|
1918
|
-
|
|
1895
|
+
if(value == null) {
|
|
1896
|
+
continue;
|
|
1897
|
+
}
|
|
1898
|
+
if(value.handleNdAttribute) {
|
|
1899
|
+
value.handleNdAttribute(element, attributeName, value);
|
|
1900
|
+
continue;
|
|
1901
|
+
}
|
|
1902
|
+
if(typeof value === 'object') {
|
|
1903
|
+
if(attributeName === 'class') {
|
|
1904
|
+
bindClassAttribute(element, value);
|
|
1905
|
+
continue;
|
|
1906
|
+
}
|
|
1907
|
+
if(attributeName === 'style') {
|
|
1908
|
+
bindStyleAttribute(element, value);
|
|
1909
|
+
continue;
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
if(BOOLEAN_ATTRIBUTES.has(attributeName)) {
|
|
1913
|
+
bindBooleanAttribute(element, attributeName, value);
|
|
1914
|
+
continue;
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
element.setAttribute(attributeName, value);
|
|
1919
1918
|
}
|
|
1920
1919
|
return element;
|
|
1921
1920
|
};
|
|
@@ -1973,7 +1972,7 @@ var NativeDocument = (function (exports) {
|
|
|
1973
1972
|
Function.prototype.toNdElement = function () {
|
|
1974
1973
|
const child = this;
|
|
1975
1974
|
{
|
|
1976
|
-
PluginsManager
|
|
1975
|
+
PluginsManager.emit('BeforeProcessComponent', child);
|
|
1977
1976
|
}
|
|
1978
1977
|
return ElementCreator.getChild(child());
|
|
1979
1978
|
};
|
|
@@ -2156,14 +2155,14 @@ var NativeDocument = (function (exports) {
|
|
|
2156
2155
|
processChildren: (children, parent) => {
|
|
2157
2156
|
if(children === null) return;
|
|
2158
2157
|
{
|
|
2159
|
-
PluginsManager
|
|
2158
|
+
PluginsManager.emit('BeforeProcessChildren', parent);
|
|
2160
2159
|
}
|
|
2161
2160
|
let child = ElementCreator.getChild(children);
|
|
2162
2161
|
if(child) {
|
|
2163
2162
|
parent.appendChild(child);
|
|
2164
2163
|
}
|
|
2165
2164
|
{
|
|
2166
|
-
PluginsManager
|
|
2165
|
+
PluginsManager.emit('AfterProcessChildren', parent);
|
|
2167
2166
|
}
|
|
2168
2167
|
},
|
|
2169
2168
|
async safeRemove(element) {
|
|
@@ -2208,9 +2207,11 @@ var NativeDocument = (function (exports) {
|
|
|
2208
2207
|
function AnchorWithSentinel(name) {
|
|
2209
2208
|
const instance = Reflect.construct(DocumentFragment, [], AnchorWithSentinel);
|
|
2210
2209
|
const sentinel = document.createComment((name || '') + ' Anchor Sentinel');
|
|
2210
|
+
const anchorStart = document.createComment('Anchor Start : '+name);
|
|
2211
|
+
const anchorEnd = document.createComment('/ Anchor End '+name);
|
|
2211
2212
|
const events = {};
|
|
2212
2213
|
|
|
2213
|
-
instance.
|
|
2214
|
+
instance.append(anchorStart, sentinel, anchorEnd);
|
|
2214
2215
|
|
|
2215
2216
|
const observer = new MutationObserver(() => {
|
|
2216
2217
|
if (sentinel.parentNode !== instance && !(sentinel.parentNode instanceof DocumentFragment)) {
|
|
@@ -2222,6 +2223,8 @@ var NativeDocument = (function (exports) {
|
|
|
2222
2223
|
|
|
2223
2224
|
|
|
2224
2225
|
instance.$sentinel = sentinel;
|
|
2226
|
+
instance.$start = anchorStart;
|
|
2227
|
+
instance.$end = anchorEnd;
|
|
2225
2228
|
instance.$observer = observer;
|
|
2226
2229
|
instance.$events = events;
|
|
2227
2230
|
|
|
@@ -2325,11 +2328,8 @@ var NativeDocument = (function (exports) {
|
|
|
2325
2328
|
|
|
2326
2329
|
anchorFragment.__Anchor__ = true;
|
|
2327
2330
|
|
|
2328
|
-
const anchorStart =
|
|
2329
|
-
const anchorEnd =
|
|
2330
|
-
|
|
2331
|
-
anchorFragment.appendChild(anchorStart);
|
|
2332
|
-
anchorFragment.appendChild(anchorEnd);
|
|
2331
|
+
const anchorStart = anchorFragment.$start;
|
|
2332
|
+
const anchorEnd = anchorFragment.$end;
|
|
2333
2333
|
|
|
2334
2334
|
anchorFragment.nativeInsertBefore = anchorFragment.insertBefore;
|
|
2335
2335
|
anchorFragment.nativeAppendChild = anchorFragment.appendChild;
|
|
@@ -2976,7 +2976,11 @@ var NativeDocument = (function (exports) {
|
|
|
2976
2976
|
|
|
2977
2977
|
return (attr, children) => createElement(attr, children)
|
|
2978
2978
|
}
|
|
2979
|
-
return (
|
|
2979
|
+
return (children, name = '') => {
|
|
2980
|
+
const anchor = Anchor(name);
|
|
2981
|
+
anchor.append(children);
|
|
2982
|
+
return anchor;
|
|
2983
|
+
};
|
|
2980
2984
|
}
|
|
2981
2985
|
|
|
2982
2986
|
function NodeCloner($element) {
|
|
@@ -3848,7 +3852,7 @@ var NativeDocument = (function (exports) {
|
|
|
3848
3852
|
|
|
3849
3853
|
ObservableItem.call(this, target, configs);
|
|
3850
3854
|
{
|
|
3851
|
-
PluginsManager
|
|
3855
|
+
PluginsManager.emit('CreateObservableArray', this);
|
|
3852
3856
|
}
|
|
3853
3857
|
};
|
|
3854
3858
|
|
|
@@ -4482,7 +4486,7 @@ var NativeDocument = (function (exports) {
|
|
|
4482
4486
|
const observable = new ObservableItem(initialValue);
|
|
4483
4487
|
const updatedValue = nextTick(() => observable.set(callback()));
|
|
4484
4488
|
{
|
|
4485
|
-
PluginsManager
|
|
4489
|
+
PluginsManager.emit('CreateObservableComputed', observable, dependencies);
|
|
4486
4490
|
}
|
|
4487
4491
|
|
|
4488
4492
|
if(Validator.isFunction(dependencies)) {
|
|
@@ -4517,7 +4521,7 @@ var NativeDocument = (function (exports) {
|
|
|
4517
4521
|
const $getStoreOrThrow = (method, name) => {
|
|
4518
4522
|
const item = $stores.get(name);
|
|
4519
4523
|
if (!item) {
|
|
4520
|
-
DebugManager$
|
|
4524
|
+
DebugManager$1.error('Store', `Store.${method}('${name}') : store not found. Did you call Store.create('${name}') first?`);
|
|
4521
4525
|
throw new NativeDocumentError(
|
|
4522
4526
|
`Store.${method}('${name}') : store not found.`
|
|
4523
4527
|
);
|
|
@@ -4530,7 +4534,7 @@ var NativeDocument = (function (exports) {
|
|
|
4530
4534
|
*/
|
|
4531
4535
|
const $applyReadOnly = (observer, name, context) => {
|
|
4532
4536
|
const readOnlyError = (method) => () => {
|
|
4533
|
-
DebugManager$
|
|
4537
|
+
DebugManager$1.error('Store', `Store.${context}('${name}') is read-only. '${method}()' is not allowed.`);
|
|
4534
4538
|
throw new NativeDocumentError(
|
|
4535
4539
|
`Store.${context}('${name}') is read-only.`
|
|
4536
4540
|
);
|
|
@@ -4561,7 +4565,7 @@ var NativeDocument = (function (exports) {
|
|
|
4561
4565
|
*/
|
|
4562
4566
|
create(name, value) {
|
|
4563
4567
|
if ($stores.has(name)) {
|
|
4564
|
-
DebugManager$
|
|
4568
|
+
DebugManager$1.warn('Store', `Store.create('${name}') : a store with this name already exists. Use Store.get('${name}') to retrieve it.`);
|
|
4565
4569
|
throw new NativeDocumentError(
|
|
4566
4570
|
`Store.create('${name}') : a store with this name already exists.`
|
|
4567
4571
|
);
|
|
@@ -4582,7 +4586,7 @@ var NativeDocument = (function (exports) {
|
|
|
4582
4586
|
*/
|
|
4583
4587
|
createResettable(name, value) {
|
|
4584
4588
|
if ($stores.has(name)) {
|
|
4585
|
-
DebugManager$
|
|
4589
|
+
DebugManager$1.warn('Store', `Store.createResettable('${name}') : a store with this name already exists.`);
|
|
4586
4590
|
throw new NativeDocumentError(
|
|
4587
4591
|
`Store.createResettable('${name}') : a store with this name already exists.`
|
|
4588
4592
|
);
|
|
@@ -4618,7 +4622,7 @@ var NativeDocument = (function (exports) {
|
|
|
4618
4622
|
*/
|
|
4619
4623
|
createComposed(name, computation, dependencies) {
|
|
4620
4624
|
if ($stores.has(name)) {
|
|
4621
|
-
DebugManager$
|
|
4625
|
+
DebugManager$1.warn('Store', `Store.createComposed('${name}') : a store with this name already exists.`);
|
|
4622
4626
|
throw new NativeDocumentError(
|
|
4623
4627
|
`Store.createComposed('${name}') : a store with this name already exists.`
|
|
4624
4628
|
);
|
|
@@ -4641,7 +4645,7 @@ var NativeDocument = (function (exports) {
|
|
|
4641
4645
|
}
|
|
4642
4646
|
const depItem = $stores.get(depName);
|
|
4643
4647
|
if (!depItem) {
|
|
4644
|
-
DebugManager$
|
|
4648
|
+
DebugManager$1.error('Store', `Store.createComposed('${name}') : dependency '${depName}' not found. Create it first.`);
|
|
4645
4649
|
throw new NativeDocumentError(
|
|
4646
4650
|
`Store.createComposed('${name}') : dependency store '${depName}' not found.`
|
|
4647
4651
|
);
|
|
@@ -4675,13 +4679,13 @@ var NativeDocument = (function (exports) {
|
|
|
4675
4679
|
reset(name) {
|
|
4676
4680
|
const item = $getStoreOrThrow('reset', name);
|
|
4677
4681
|
if (item.composed) {
|
|
4678
|
-
DebugManager$
|
|
4682
|
+
DebugManager$1.error('Store', `Store.reset('${name}') : composed stores cannot be reset. Their value is derived from dependencies.`);
|
|
4679
4683
|
throw new NativeDocumentError(
|
|
4680
4684
|
`Store.reset('${name}') : composed stores cannot be reset.`
|
|
4681
4685
|
);
|
|
4682
4686
|
}
|
|
4683
4687
|
if (!item.resettable) {
|
|
4684
|
-
DebugManager$
|
|
4688
|
+
DebugManager$1.error('Store', `Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`);
|
|
4685
4689
|
throw new NativeDocumentError(
|
|
4686
4690
|
`Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`
|
|
4687
4691
|
);
|
|
@@ -4702,7 +4706,7 @@ var NativeDocument = (function (exports) {
|
|
|
4702
4706
|
const item = $getStoreOrThrow('use', name);
|
|
4703
4707
|
|
|
4704
4708
|
if (item.composed) {
|
|
4705
|
-
DebugManager$
|
|
4709
|
+
DebugManager$1.error('Store', `Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`);
|
|
4706
4710
|
throw new NativeDocumentError(
|
|
4707
4711
|
`Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`
|
|
4708
4712
|
);
|
|
@@ -4769,7 +4773,7 @@ var NativeDocument = (function (exports) {
|
|
|
4769
4773
|
get(name) {
|
|
4770
4774
|
const item = $stores.get(name);
|
|
4771
4775
|
if (!item) {
|
|
4772
|
-
DebugManager$
|
|
4776
|
+
DebugManager$1.warn('Store', `Store.get('${name}') : store not found.`);
|
|
4773
4777
|
return null;
|
|
4774
4778
|
}
|
|
4775
4779
|
return item.observer;
|
|
@@ -4791,7 +4795,7 @@ var NativeDocument = (function (exports) {
|
|
|
4791
4795
|
delete(name) {
|
|
4792
4796
|
const item = $stores.get(name);
|
|
4793
4797
|
if (!item) {
|
|
4794
|
-
DebugManager$
|
|
4798
|
+
DebugManager$1.warn('Store', `Store.delete('${name}') : store not found, nothing to delete.`);
|
|
4795
4799
|
return;
|
|
4796
4800
|
}
|
|
4797
4801
|
item.subscribers.forEach(follower => follower.destroy());
|
|
@@ -4893,7 +4897,7 @@ var NativeDocument = (function (exports) {
|
|
|
4893
4897
|
return undefined;
|
|
4894
4898
|
},
|
|
4895
4899
|
set(target, prop, value) {
|
|
4896
|
-
DebugManager$
|
|
4900
|
+
DebugManager$1.error('Store', `Forbidden: You cannot overwrite the store key '${String(prop)}'. Use .use('${String(prop)}').set(value) instead.`);
|
|
4897
4901
|
throw new NativeDocumentError(`Store structure is immutable. Use .set() on the observable.`);
|
|
4898
4902
|
},
|
|
4899
4903
|
deleteProperty(target, prop) {
|
|
@@ -4981,7 +4985,7 @@ var NativeDocument = (function (exports) {
|
|
|
4981
4985
|
}
|
|
4982
4986
|
cache.set(keyId, { keyId, isNew: true, child: new WeakRef(child), indexObserver});
|
|
4983
4987
|
} catch (e) {
|
|
4984
|
-
DebugManager$
|
|
4988
|
+
DebugManager$1.error('ForEach', `Error creating element for key ${keyId}` , e);
|
|
4985
4989
|
throw e;
|
|
4986
4990
|
}
|
|
4987
4991
|
return keyId;
|
|
@@ -5093,9 +5097,6 @@ var NativeDocument = (function (exports) {
|
|
|
5093
5097
|
|
|
5094
5098
|
const clear = (items) => {
|
|
5095
5099
|
element.removeChildren();
|
|
5096
|
-
clearCacheOnly(items);
|
|
5097
|
-
};
|
|
5098
|
-
const clearCacheOnly = (items) => {
|
|
5099
5100
|
cleanCache(items);
|
|
5100
5101
|
lastNumberOfItems = 0;
|
|
5101
5102
|
};
|
|
@@ -5133,7 +5134,7 @@ var NativeDocument = (function (exports) {
|
|
|
5133
5134
|
};
|
|
5134
5135
|
|
|
5135
5136
|
const createAndCache = (item) => {
|
|
5136
|
-
const child = callback(item, null);
|
|
5137
|
+
const child = ElementCreator.getChild(callback(item, null));
|
|
5137
5138
|
{
|
|
5138
5139
|
if(!child) {
|
|
5139
5140
|
throw new NativeDocumentError("ForEachArray child can't be null or undefined!");
|
|
@@ -5145,7 +5146,7 @@ var NativeDocument = (function (exports) {
|
|
|
5145
5146
|
|
|
5146
5147
|
const createWithIndexAndCache = (item, indexKey) => {
|
|
5147
5148
|
const indexObserver = Observable(indexKey);
|
|
5148
|
-
const child = callback(item, indexObserver);
|
|
5149
|
+
const child = ElementCreator.getChild(callback(item, indexObserver));
|
|
5149
5150
|
{
|
|
5150
5151
|
if(!child) {
|
|
5151
5152
|
throw new NativeDocumentError("ForEachArray child can't be null or undefined!");
|
|
@@ -5222,13 +5223,13 @@ var NativeDocument = (function (exports) {
|
|
|
5222
5223
|
element.appendChildRaw(Actions.toFragment(items));
|
|
5223
5224
|
},
|
|
5224
5225
|
replace: (items) => {
|
|
5225
|
-
|
|
5226
|
-
element.
|
|
5226
|
+
clear(items);
|
|
5227
|
+
element.appendChildRaw(Actions.toFragment(items));
|
|
5227
5228
|
},
|
|
5228
5229
|
set: () => {
|
|
5229
5230
|
const items = data.val();
|
|
5230
|
-
|
|
5231
|
-
element.
|
|
5231
|
+
clear(items);
|
|
5232
|
+
element.appendChildRaw(Actions.toFragment(items));
|
|
5232
5233
|
},
|
|
5233
5234
|
reOrder: (items) => {
|
|
5234
5235
|
let child = null;
|
|
@@ -5354,7 +5355,7 @@ var NativeDocument = (function (exports) {
|
|
|
5354
5355
|
*/
|
|
5355
5356
|
const ShowIf = function(condition, child, { comment = null, shouldKeepInCache = true} = {}) {
|
|
5356
5357
|
if(!(Validator.isObservable(condition)) && !Validator.isObservableWhenResult(condition)) {
|
|
5357
|
-
return DebugManager$
|
|
5358
|
+
return DebugManager$1.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
|
|
5358
5359
|
}
|
|
5359
5360
|
const element = Anchor('Show if : '+(comment || ''));
|
|
5360
5361
|
|
|
@@ -6773,7 +6774,7 @@ var NativeDocument = (function (exports) {
|
|
|
6773
6774
|
window.history.pushState({ name: route.name(), params, path}, route.name() || path , path);
|
|
6774
6775
|
this.handleRouteChange(route, params, query, path);
|
|
6775
6776
|
} catch (e) {
|
|
6776
|
-
DebugManager$
|
|
6777
|
+
DebugManager$1.error('HistoryRouter', 'Error in pushState', e);
|
|
6777
6778
|
}
|
|
6778
6779
|
};
|
|
6779
6780
|
/**
|
|
@@ -6786,7 +6787,7 @@ var NativeDocument = (function (exports) {
|
|
|
6786
6787
|
window.history.replaceState({ name: route.name(), params, path}, route.name() || path , path);
|
|
6787
6788
|
this.handleRouteChange(route, params, {}, path);
|
|
6788
6789
|
} catch(e) {
|
|
6789
|
-
DebugManager$
|
|
6790
|
+
DebugManager$1.error('HistoryRouter', 'Error in replaceState', e);
|
|
6790
6791
|
}
|
|
6791
6792
|
};
|
|
6792
6793
|
this.forward = function() {
|
|
@@ -6813,7 +6814,7 @@ var NativeDocument = (function (exports) {
|
|
|
6813
6814
|
}
|
|
6814
6815
|
this.handleRouteChange(route, params, query, path);
|
|
6815
6816
|
} catch(e) {
|
|
6816
|
-
DebugManager$
|
|
6817
|
+
DebugManager$1.error('HistoryRouter', 'Error in popstate event', e);
|
|
6817
6818
|
}
|
|
6818
6819
|
});
|
|
6819
6820
|
const { route, params, query, path } = this.resolve(defaultPath || (window.location.pathname+window.location.search));
|
|
@@ -6918,6 +6919,7 @@ var NativeDocument = (function (exports) {
|
|
|
6918
6919
|
anchor = Anchor(path);
|
|
6919
6920
|
anchor.appendChild(node);
|
|
6920
6921
|
}
|
|
6922
|
+
console.log(anchor);
|
|
6921
6923
|
$routeInstanceAnchors.set(node, anchor);
|
|
6922
6924
|
return anchor;
|
|
6923
6925
|
};
|
|
@@ -6927,6 +6929,7 @@ var NativeDocument = (function (exports) {
|
|
|
6927
6929
|
$lastNodeInserted.remove();
|
|
6928
6930
|
}
|
|
6929
6931
|
};
|
|
6932
|
+
|
|
6930
6933
|
const cleanContainer = () => {
|
|
6931
6934
|
container.nodeValue = '';
|
|
6932
6935
|
removeLastNodeInserted();
|
|
@@ -7038,7 +7041,7 @@ var NativeDocument = (function (exports) {
|
|
|
7038
7041
|
listener(request);
|
|
7039
7042
|
next && next(request);
|
|
7040
7043
|
} catch (e) {
|
|
7041
|
-
DebugManager$
|
|
7044
|
+
DebugManager$1.warn('Route Listener', 'Error in listener:', e);
|
|
7042
7045
|
}
|
|
7043
7046
|
}
|
|
7044
7047
|
};
|
|
@@ -7216,7 +7219,7 @@ var NativeDocument = (function (exports) {
|
|
|
7216
7219
|
*/
|
|
7217
7220
|
Router.create = function(options, callback) {
|
|
7218
7221
|
if(!Validator.isFunction(callback)) {
|
|
7219
|
-
DebugManager$
|
|
7222
|
+
DebugManager$1.error('Router', 'Callback must be a function');
|
|
7220
7223
|
throw new RouterError('Callback must be a function');
|
|
7221
7224
|
}
|
|
7222
7225
|
const router = new Router(options);
|
|
@@ -7420,7 +7423,7 @@ var NativeDocument = (function (exports) {
|
|
|
7420
7423
|
exports.HtmlElementWrapper = HtmlElementWrapper;
|
|
7421
7424
|
exports.NDElement = NDElement;
|
|
7422
7425
|
exports.Observable = Observable;
|
|
7423
|
-
exports.PluginsManager = PluginsManager
|
|
7426
|
+
exports.PluginsManager = PluginsManager;
|
|
7424
7427
|
exports.SingletonView = SingletonView;
|
|
7425
7428
|
exports.Store = Store;
|
|
7426
7429
|
exports.StoreFactory = StoreFactory;
|