native-document 1.0.124 → 1.0.126
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 +75 -45
- package/dist/native-document.dev.js +84 -78
- 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 +5 -15
- package/src/core/elements/control/for-each-array.js +6 -9
- package/src/core/wrappers/DocumentObserver.js +13 -6
- package/src/core/wrappers/HtmlElementWrapper.js +5 -1
- package/src/router/RouterComponent.js +4 -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
|
@@ -14,7 +14,7 @@ var NativeComponents = (function (exports) {
|
|
|
14
14
|
if(this.$element) {
|
|
15
15
|
return this.$element.nd;
|
|
16
16
|
}
|
|
17
|
-
this.$storeElement(this.
|
|
17
|
+
this.$storeElement(this.toNdElement());
|
|
18
18
|
return this.$element?.nd;
|
|
19
19
|
}
|
|
20
20
|
});
|
|
@@ -363,16 +363,16 @@ var NativeComponents = (function (exports) {
|
|
|
363
363
|
// });
|
|
364
364
|
};
|
|
365
365
|
|
|
366
|
-
let DebugManager$
|
|
366
|
+
let DebugManager$1 = {};
|
|
367
367
|
{
|
|
368
|
-
DebugManager$
|
|
368
|
+
DebugManager$1 = {
|
|
369
369
|
log() {},
|
|
370
370
|
warn() {},
|
|
371
371
|
error() {},
|
|
372
372
|
disable() {}
|
|
373
373
|
};
|
|
374
374
|
}
|
|
375
|
-
var DebugManager$
|
|
375
|
+
var DebugManager$2 = DebugManager$1;
|
|
376
376
|
|
|
377
377
|
/**
|
|
378
378
|
*
|
|
@@ -474,6 +474,16 @@ var NativeComponents = (function (exports) {
|
|
|
474
474
|
unmounted: new WeakMap(),
|
|
475
475
|
unmountedSupposedSize: 0,
|
|
476
476
|
observer: null,
|
|
477
|
+
initObserver: () => {
|
|
478
|
+
if(DocumentObserver.observer) {
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
DocumentObserver.observer = new MutationObserver(DocumentObserver.checkMutation);
|
|
482
|
+
DocumentObserver.observer.observe(document.body, {
|
|
483
|
+
childList: true,
|
|
484
|
+
subtree: true,
|
|
485
|
+
});
|
|
486
|
+
},
|
|
477
487
|
|
|
478
488
|
executeMountedCallback(node) {
|
|
479
489
|
const data = DocumentObserver.mounted.get(node);
|
|
@@ -521,6 +531,7 @@ var NativeComponents = (function (exports) {
|
|
|
521
531
|
},
|
|
522
532
|
|
|
523
533
|
checkMutation: function(mutationsList) {
|
|
534
|
+
console.log('mutationsList', mutationsList);
|
|
524
535
|
for(const mutation of mutationsList) {
|
|
525
536
|
if(DocumentObserver.mountedSupposedSize > 0) {
|
|
526
537
|
for(const node of mutation.addedNodes) {
|
|
@@ -559,6 +570,8 @@ var NativeComponents = (function (exports) {
|
|
|
559
570
|
let mountedRegistered = false;
|
|
560
571
|
let unmountedRegistered = false;
|
|
561
572
|
|
|
573
|
+
DocumentObserver.initObserver();
|
|
574
|
+
|
|
562
575
|
let data = {
|
|
563
576
|
inDom,
|
|
564
577
|
mounted: null,
|
|
@@ -636,12 +649,6 @@ var NativeComponents = (function (exports) {
|
|
|
636
649
|
}
|
|
637
650
|
};
|
|
638
651
|
|
|
639
|
-
DocumentObserver.observer = new MutationObserver(DocumentObserver.checkMutation);
|
|
640
|
-
DocumentObserver.observer.observe(document.body, {
|
|
641
|
-
childList: true,
|
|
642
|
-
subtree: true,
|
|
643
|
-
});
|
|
644
|
-
|
|
645
652
|
function NDElement(element) {
|
|
646
653
|
this.$element = element;
|
|
647
654
|
}
|
|
@@ -847,17 +854,17 @@ var NativeComponents = (function (exports) {
|
|
|
847
854
|
const method = methods[name];
|
|
848
855
|
|
|
849
856
|
if (typeof method !== 'function') {
|
|
850
|
-
DebugManager$
|
|
857
|
+
DebugManager$2.warn('NDElement.extend', `"${name}" is not a function, skipping`);
|
|
851
858
|
continue;
|
|
852
859
|
}
|
|
853
860
|
|
|
854
861
|
if (protectedMethods.has(name)) {
|
|
855
|
-
DebugManager$
|
|
862
|
+
DebugManager$2.error('NDElement.extend', `Cannot override protected method "${name}"`);
|
|
856
863
|
throw new NativeDocumentError(`Cannot override protected method "${name}"`);
|
|
857
864
|
}
|
|
858
865
|
|
|
859
866
|
if (NDElement.prototype[name]) {
|
|
860
|
-
DebugManager$
|
|
867
|
+
DebugManager$2.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
|
|
861
868
|
}
|
|
862
869
|
|
|
863
870
|
NDElement.prototype[name] = method;
|
|
@@ -1082,7 +1089,7 @@ var NativeComponents = (function (exports) {
|
|
|
1082
1089
|
}
|
|
1083
1090
|
}
|
|
1084
1091
|
if (cleanedCount > 0) {
|
|
1085
|
-
DebugManager$
|
|
1092
|
+
DebugManager$2.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
|
|
1086
1093
|
}
|
|
1087
1094
|
}
|
|
1088
1095
|
};
|
|
@@ -2354,9 +2361,11 @@ var NativeComponents = (function (exports) {
|
|
|
2354
2361
|
function AnchorWithSentinel(name) {
|
|
2355
2362
|
const instance = Reflect.construct(DocumentFragment, [], AnchorWithSentinel);
|
|
2356
2363
|
const sentinel = document.createComment((name || '') + ' Anchor Sentinel');
|
|
2364
|
+
const anchorStart = document.createComment('Anchor Start : '+name);
|
|
2365
|
+
const anchorEnd = document.createComment('/ Anchor End '+name);
|
|
2357
2366
|
const events = {};
|
|
2358
2367
|
|
|
2359
|
-
instance.
|
|
2368
|
+
instance.append(anchorStart, sentinel, anchorEnd);
|
|
2360
2369
|
|
|
2361
2370
|
const observer = new MutationObserver(() => {
|
|
2362
2371
|
if (sentinel.parentNode !== instance && !(sentinel.parentNode instanceof DocumentFragment)) {
|
|
@@ -2368,6 +2377,8 @@ var NativeComponents = (function (exports) {
|
|
|
2368
2377
|
|
|
2369
2378
|
|
|
2370
2379
|
instance.$sentinel = sentinel;
|
|
2380
|
+
instance.$start = anchorStart;
|
|
2381
|
+
instance.$end = anchorEnd;
|
|
2371
2382
|
instance.$observer = observer;
|
|
2372
2383
|
instance.$events = events;
|
|
2373
2384
|
|
|
@@ -2456,13 +2467,6 @@ var NativeComponents = (function (exports) {
|
|
|
2456
2467
|
function Anchor(name, isUniqueChild = false) {
|
|
2457
2468
|
const anchorFragment = new AnchorWithSentinel(name);
|
|
2458
2469
|
|
|
2459
|
-
/**
|
|
2460
|
-
* State :
|
|
2461
|
-
* 1. Not injected in the DOM
|
|
2462
|
-
* 2. Injected in the DOM and should be the only child of parent
|
|
2463
|
-
* 3. Injected in the DOM and the parent may have other children
|
|
2464
|
-
*/
|
|
2465
|
-
|
|
2466
2470
|
anchorFragment.onConnectedOnce((parent) => {
|
|
2467
2471
|
if(isUniqueChild) {
|
|
2468
2472
|
oneChildAnchorOverwriting(anchorFragment, parent);
|
|
@@ -2471,11 +2475,8 @@ var NativeComponents = (function (exports) {
|
|
|
2471
2475
|
|
|
2472
2476
|
anchorFragment.__Anchor__ = true;
|
|
2473
2477
|
|
|
2474
|
-
const anchorStart =
|
|
2475
|
-
const anchorEnd =
|
|
2476
|
-
|
|
2477
|
-
anchorFragment.appendChild(anchorStart);
|
|
2478
|
-
anchorFragment.appendChild(anchorEnd);
|
|
2478
|
+
const anchorStart = anchorFragment.$start;
|
|
2479
|
+
const anchorEnd = anchorFragment.$end;
|
|
2479
2480
|
|
|
2480
2481
|
anchorFragment.nativeInsertBefore = anchorFragment.insertBefore;
|
|
2481
2482
|
anchorFragment.nativeAppendChild = anchorFragment.appendChild;
|
|
@@ -2572,7 +2573,7 @@ var NativeComponents = (function (exports) {
|
|
|
2572
2573
|
return;
|
|
2573
2574
|
}
|
|
2574
2575
|
if(isParentUniqueChild(parent)) {
|
|
2575
|
-
anchorFragment.
|
|
2576
|
+
anchorFragment.nativeAppend.apply(anchorFragment, parent.childNodes);
|
|
2576
2577
|
parent.replaceChildren(anchorStart, anchorEnd);
|
|
2577
2578
|
return;
|
|
2578
2579
|
}
|
|
@@ -2601,11 +2602,11 @@ var NativeComponents = (function (exports) {
|
|
|
2601
2602
|
return;
|
|
2602
2603
|
}
|
|
2603
2604
|
if(isParentUniqueChild(parent)) {
|
|
2604
|
-
parent.replaceChildren(anchorStart,
|
|
2605
|
+
parent.replaceChildren(anchorStart, child, anchorEnd);
|
|
2605
2606
|
return;
|
|
2606
2607
|
}
|
|
2607
2608
|
anchorFragment.removeChildren();
|
|
2608
|
-
parent.insertBefore(
|
|
2609
|
+
parent.insertBefore(child, anchorEnd);
|
|
2609
2610
|
};
|
|
2610
2611
|
|
|
2611
2612
|
anchorFragment.setContent = anchorFragment.replaceContent;
|
|
@@ -2999,7 +3000,11 @@ var NativeComponents = (function (exports) {
|
|
|
2999
3000
|
|
|
3000
3001
|
return (attr, children) => createElement(attr, children)
|
|
3001
3002
|
}
|
|
3002
|
-
return (
|
|
3003
|
+
return (children, name = '') => {
|
|
3004
|
+
const anchor = Anchor(name);
|
|
3005
|
+
anchor.append(children);
|
|
3006
|
+
return anchor;
|
|
3007
|
+
};
|
|
3003
3008
|
}
|
|
3004
3009
|
|
|
3005
3010
|
function NodeCloner($element) {
|
|
@@ -3940,7 +3945,7 @@ var NativeComponents = (function (exports) {
|
|
|
3940
3945
|
const $getStoreOrThrow = (method, name) => {
|
|
3941
3946
|
const item = $stores.get(name);
|
|
3942
3947
|
if (!item) {
|
|
3943
|
-
DebugManager$
|
|
3948
|
+
DebugManager$2.error('Store', `Store.${method}('${name}') : store not found. Did you call Store.create('${name}') first?`);
|
|
3944
3949
|
throw new NativeDocumentError(
|
|
3945
3950
|
`Store.${method}('${name}') : store not found.`
|
|
3946
3951
|
);
|
|
@@ -3953,7 +3958,7 @@ var NativeComponents = (function (exports) {
|
|
|
3953
3958
|
*/
|
|
3954
3959
|
const $applyReadOnly = (observer, name, context) => {
|
|
3955
3960
|
const readOnlyError = (method) => () => {
|
|
3956
|
-
DebugManager$
|
|
3961
|
+
DebugManager$2.error('Store', `Store.${context}('${name}') is read-only. '${method}()' is not allowed.`);
|
|
3957
3962
|
throw new NativeDocumentError(
|
|
3958
3963
|
`Store.${context}('${name}') is read-only.`
|
|
3959
3964
|
);
|
|
@@ -3984,7 +3989,7 @@ var NativeComponents = (function (exports) {
|
|
|
3984
3989
|
*/
|
|
3985
3990
|
create(name, value) {
|
|
3986
3991
|
if ($stores.has(name)) {
|
|
3987
|
-
DebugManager$
|
|
3992
|
+
DebugManager$2.warn('Store', `Store.create('${name}') : a store with this name already exists. Use Store.get('${name}') to retrieve it.`);
|
|
3988
3993
|
throw new NativeDocumentError(
|
|
3989
3994
|
`Store.create('${name}') : a store with this name already exists.`
|
|
3990
3995
|
);
|
|
@@ -4005,7 +4010,7 @@ var NativeComponents = (function (exports) {
|
|
|
4005
4010
|
*/
|
|
4006
4011
|
createResettable(name, value) {
|
|
4007
4012
|
if ($stores.has(name)) {
|
|
4008
|
-
DebugManager$
|
|
4013
|
+
DebugManager$2.warn('Store', `Store.createResettable('${name}') : a store with this name already exists.`);
|
|
4009
4014
|
throw new NativeDocumentError(
|
|
4010
4015
|
`Store.createResettable('${name}') : a store with this name already exists.`
|
|
4011
4016
|
);
|
|
@@ -4041,7 +4046,7 @@ var NativeComponents = (function (exports) {
|
|
|
4041
4046
|
*/
|
|
4042
4047
|
createComposed(name, computation, dependencies) {
|
|
4043
4048
|
if ($stores.has(name)) {
|
|
4044
|
-
DebugManager$
|
|
4049
|
+
DebugManager$2.warn('Store', `Store.createComposed('${name}') : a store with this name already exists.`);
|
|
4045
4050
|
throw new NativeDocumentError(
|
|
4046
4051
|
`Store.createComposed('${name}') : a store with this name already exists.`
|
|
4047
4052
|
);
|
|
@@ -4064,7 +4069,7 @@ var NativeComponents = (function (exports) {
|
|
|
4064
4069
|
}
|
|
4065
4070
|
const depItem = $stores.get(depName);
|
|
4066
4071
|
if (!depItem) {
|
|
4067
|
-
DebugManager$
|
|
4072
|
+
DebugManager$2.error('Store', `Store.createComposed('${name}') : dependency '${depName}' not found. Create it first.`);
|
|
4068
4073
|
throw new NativeDocumentError(
|
|
4069
4074
|
`Store.createComposed('${name}') : dependency store '${depName}' not found.`
|
|
4070
4075
|
);
|
|
@@ -4098,13 +4103,13 @@ var NativeComponents = (function (exports) {
|
|
|
4098
4103
|
reset(name) {
|
|
4099
4104
|
const item = $getStoreOrThrow('reset', name);
|
|
4100
4105
|
if (item.composed) {
|
|
4101
|
-
DebugManager$
|
|
4106
|
+
DebugManager$2.error('Store', `Store.reset('${name}') : composed stores cannot be reset. Their value is derived from dependencies.`);
|
|
4102
4107
|
throw new NativeDocumentError(
|
|
4103
4108
|
`Store.reset('${name}') : composed stores cannot be reset.`
|
|
4104
4109
|
);
|
|
4105
4110
|
}
|
|
4106
4111
|
if (!item.resettable) {
|
|
4107
|
-
DebugManager$
|
|
4112
|
+
DebugManager$2.error('Store', `Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`);
|
|
4108
4113
|
throw new NativeDocumentError(
|
|
4109
4114
|
`Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`
|
|
4110
4115
|
);
|
|
@@ -4125,7 +4130,7 @@ var NativeComponents = (function (exports) {
|
|
|
4125
4130
|
const item = $getStoreOrThrow('use', name);
|
|
4126
4131
|
|
|
4127
4132
|
if (item.composed) {
|
|
4128
|
-
DebugManager$
|
|
4133
|
+
DebugManager$2.error('Store', `Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`);
|
|
4129
4134
|
throw new NativeDocumentError(
|
|
4130
4135
|
`Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`
|
|
4131
4136
|
);
|
|
@@ -4192,7 +4197,7 @@ var NativeComponents = (function (exports) {
|
|
|
4192
4197
|
get(name) {
|
|
4193
4198
|
const item = $stores.get(name);
|
|
4194
4199
|
if (!item) {
|
|
4195
|
-
DebugManager$
|
|
4200
|
+
DebugManager$2.warn('Store', `Store.get('${name}') : store not found.`);
|
|
4196
4201
|
return null;
|
|
4197
4202
|
}
|
|
4198
4203
|
return item.observer;
|
|
@@ -4214,7 +4219,7 @@ var NativeComponents = (function (exports) {
|
|
|
4214
4219
|
delete(name) {
|
|
4215
4220
|
const item = $stores.get(name);
|
|
4216
4221
|
if (!item) {
|
|
4217
|
-
DebugManager$
|
|
4222
|
+
DebugManager$2.warn('Store', `Store.delete('${name}') : store not found, nothing to delete.`);
|
|
4218
4223
|
return;
|
|
4219
4224
|
}
|
|
4220
4225
|
item.subscribers.forEach(follower => follower.destroy());
|
|
@@ -4316,7 +4321,7 @@ var NativeComponents = (function (exports) {
|
|
|
4316
4321
|
return undefined;
|
|
4317
4322
|
},
|
|
4318
4323
|
set(target, prop, value) {
|
|
4319
|
-
DebugManager$
|
|
4324
|
+
DebugManager$2.error('Store', `Forbidden: You cannot overwrite the store key '${String(prop)}'. Use .use('${String(prop)}').set(value) instead.`);
|
|
4320
4325
|
throw new NativeDocumentError(`Store structure is immutable. Use .set() on the observable.`);
|
|
4321
4326
|
},
|
|
4322
4327
|
deleteProperty(target, prop) {
|
|
@@ -5800,7 +5805,7 @@ var NativeComponents = (function (exports) {
|
|
|
5800
5805
|
};
|
|
5801
5806
|
|
|
5802
5807
|
function MenuDivider() {
|
|
5803
|
-
if(!this instanceof MenuDivider) {
|
|
5808
|
+
if(!(this instanceof MenuDivider)) {
|
|
5804
5809
|
return new MenuDivider();
|
|
5805
5810
|
}
|
|
5806
5811
|
|
|
@@ -5882,6 +5887,11 @@ var NativeComponents = (function (exports) {
|
|
|
5882
5887
|
Menu.defaultTemplate = template.menu;
|
|
5883
5888
|
};
|
|
5884
5889
|
|
|
5890
|
+
Menu.prototype.title = function(title) {
|
|
5891
|
+
this.$description.title = title;
|
|
5892
|
+
return this;
|
|
5893
|
+
};
|
|
5894
|
+
|
|
5885
5895
|
Menu.prototype.orientation = function(orientation) {
|
|
5886
5896
|
this.$description.orientation = orientation;
|
|
5887
5897
|
return this;
|
|
@@ -5936,7 +5946,7 @@ var NativeComponents = (function (exports) {
|
|
|
5936
5946
|
|
|
5937
5947
|
function ContextMenu(config = {}) {
|
|
5938
5948
|
if(!(this instanceof ContextMenu)) {
|
|
5939
|
-
return ContextMenu(config);
|
|
5949
|
+
return new ContextMenu(config);
|
|
5940
5950
|
}
|
|
5941
5951
|
Menu.call(this, config);
|
|
5942
5952
|
|
|
@@ -5999,6 +6009,16 @@ var NativeComponents = (function (exports) {
|
|
|
5999
6009
|
|
|
6000
6010
|
this.$description = {
|
|
6001
6011
|
items: [],
|
|
6012
|
+
link: null,
|
|
6013
|
+
target: null,
|
|
6014
|
+
label: null,
|
|
6015
|
+
icon: null,
|
|
6016
|
+
shortcut: null,
|
|
6017
|
+
disabled: false,
|
|
6018
|
+
selected: false,
|
|
6019
|
+
value: null,
|
|
6020
|
+
data: null,
|
|
6021
|
+
render: null,
|
|
6002
6022
|
...config
|
|
6003
6023
|
};
|
|
6004
6024
|
|
|
@@ -6018,6 +6038,16 @@ var NativeComponents = (function (exports) {
|
|
|
6018
6038
|
return this;
|
|
6019
6039
|
};
|
|
6020
6040
|
|
|
6041
|
+
MenuItem.prototype.link = function(link) {
|
|
6042
|
+
this.$description.link = link;
|
|
6043
|
+
return this;
|
|
6044
|
+
};
|
|
6045
|
+
|
|
6046
|
+
MenuItem.prototype.target = function(target) {
|
|
6047
|
+
this.$description.target = target;
|
|
6048
|
+
return this;
|
|
6049
|
+
};
|
|
6050
|
+
|
|
6021
6051
|
MenuItem.prototype.icon = function(icon) {
|
|
6022
6052
|
this.$description.icon = icon;
|
|
6023
6053
|
return this;
|