native-document 1.0.162 → 1.0.163
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 +78 -20
- package/dist/native-document.dev.js +80 -24
- 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/table/SimpleTable.js +0 -1
- package/src/core/data/Observable.js +4 -4
- package/src/core/wrappers/NDElement.js +1 -0
- package/src/core/wrappers/NdPrototype.js +64 -15
|
@@ -1344,6 +1344,10 @@ var NativeComponents = (function (exports) {
|
|
|
1344
1344
|
return new ObservableArray(this.resolve());
|
|
1345
1345
|
};
|
|
1346
1346
|
|
|
1347
|
+
ObservableArray.prototype.isNotEmpty = function () {
|
|
1348
|
+
return this.is((x) => x.length > 0);
|
|
1349
|
+
};
|
|
1350
|
+
|
|
1347
1351
|
const ObservableObject = function(target, configs) {
|
|
1348
1352
|
ObservableItem.call(this, target);
|
|
1349
1353
|
this.$observables = {};
|
|
@@ -1623,7 +1627,7 @@ var NativeComponents = (function (exports) {
|
|
|
1623
1627
|
};
|
|
1624
1628
|
|
|
1625
1629
|
ObservableItem.prototype.isNotEmpty = function () {
|
|
1626
|
-
return $checker(this, x => x
|
|
1630
|
+
return $checker(this, x => x != null && x !== '' && !(Array.isArray(x) && x.length === 0));
|
|
1627
1631
|
};
|
|
1628
1632
|
|
|
1629
1633
|
ObservableItem.prototype.isIncludes = function (value) {
|
|
@@ -2211,6 +2215,10 @@ var NativeComponents = (function (exports) {
|
|
|
2211
2215
|
});
|
|
2212
2216
|
};
|
|
2213
2217
|
|
|
2218
|
+
Observable.setLocale = function(locale) {
|
|
2219
|
+
Formatters.locale = locale.__$Observable ? locale : Observable(locale);
|
|
2220
|
+
};
|
|
2221
|
+
|
|
2214
2222
|
|
|
2215
2223
|
/**
|
|
2216
2224
|
*
|
|
@@ -2376,10 +2384,6 @@ var NativeComponents = (function (exports) {
|
|
|
2376
2384
|
return data;
|
|
2377
2385
|
};
|
|
2378
2386
|
|
|
2379
|
-
ObservableItem.prototype.resolve = function () {
|
|
2380
|
-
return Observable.value(this);
|
|
2381
|
-
};
|
|
2382
|
-
|
|
2383
2387
|
Observable.object = Observable.init;
|
|
2384
2388
|
Observable.json = Observable.init;
|
|
2385
2389
|
|
|
@@ -2392,6 +2396,10 @@ var NativeComponents = (function (exports) {
|
|
|
2392
2396
|
return new ObservableResource(fn, deps, config);
|
|
2393
2397
|
};
|
|
2394
2398
|
|
|
2399
|
+
ObservableItem.prototype.resolve = function () {
|
|
2400
|
+
return Observable.value(this);
|
|
2401
|
+
};
|
|
2402
|
+
|
|
2395
2403
|
const BOOLEAN_ATTRIBUTES = new Set([
|
|
2396
2404
|
'checked',
|
|
2397
2405
|
'selected',
|
|
@@ -3408,6 +3416,7 @@ var NativeComponents = (function (exports) {
|
|
|
3408
3416
|
return this;
|
|
3409
3417
|
}
|
|
3410
3418
|
this.$element.setAttribute(name, value);
|
|
3419
|
+
return this;
|
|
3411
3420
|
};
|
|
3412
3421
|
|
|
3413
3422
|
NDElement.prototype.attrs = function(attrs) {
|
|
@@ -12119,62 +12128,111 @@ var NativeComponents = (function (exports) {
|
|
|
12119
12128
|
// ----------------------------------------------------------------
|
|
12120
12129
|
EVENTS.forEach(eventSourceName => {
|
|
12121
12130
|
const eventName = eventSourceName.toLowerCase();
|
|
12122
|
-
NDElement.prototype['on'+eventSourceName] = function(callback = null) {
|
|
12123
|
-
this.$element.addEventListener(eventName, callback
|
|
12131
|
+
NDElement.prototype['on'+eventSourceName] = function(callback = null, options = {}) {
|
|
12132
|
+
this.$element.addEventListener(eventName, callback, {
|
|
12133
|
+
signal: this.$getSignal(),
|
|
12134
|
+
...options
|
|
12135
|
+
});
|
|
12124
12136
|
return this;
|
|
12125
12137
|
};
|
|
12126
12138
|
});
|
|
12127
12139
|
|
|
12128
12140
|
EVENTS_WITH_STOP.forEach(eventSourceName => {
|
|
12129
12141
|
const eventName = eventSourceName.toLowerCase();
|
|
12130
|
-
NDElement.prototype['onStop'+eventSourceName] = function(callback = null) {
|
|
12131
|
-
_stop(this.$element, eventName, callback
|
|
12142
|
+
NDElement.prototype['onStop'+eventSourceName] = function(callback = null, options = {}) {
|
|
12143
|
+
_stop(this.$element, eventName, callback, {
|
|
12144
|
+
signal: this.$getSignal(),
|
|
12145
|
+
...options
|
|
12146
|
+
});
|
|
12132
12147
|
return this;
|
|
12133
12148
|
};
|
|
12134
|
-
NDElement.prototype['onPreventStop'+eventSourceName] = function(callback = null) {
|
|
12135
|
-
_preventStop(this.$element, eventName, callback
|
|
12149
|
+
NDElement.prototype['onPreventStop'+eventSourceName] = function(callback = null, options = {}) {
|
|
12150
|
+
_preventStop(this.$element, eventName, callback, {
|
|
12151
|
+
signal: this.$getSignal(),
|
|
12152
|
+
...options
|
|
12153
|
+
});
|
|
12136
12154
|
return this;
|
|
12137
12155
|
};
|
|
12138
12156
|
});
|
|
12139
12157
|
|
|
12140
12158
|
EVENTS_WITH_PREVENT.forEach(eventSourceName => {
|
|
12141
12159
|
const eventName = eventSourceName.toLowerCase();
|
|
12142
|
-
NDElement.prototype['onPrevent'+eventSourceName] = function(callback = null) {
|
|
12143
|
-
_prevent(this.$element, eventName, callback
|
|
12160
|
+
NDElement.prototype['onPrevent'+eventSourceName] = function(callback = null, options = {}) {
|
|
12161
|
+
_prevent(this.$element, eventName, callback, {
|
|
12162
|
+
signal: this.$getSignal(),
|
|
12163
|
+
...options
|
|
12164
|
+
});
|
|
12144
12165
|
return this;
|
|
12145
12166
|
};
|
|
12146
12167
|
});
|
|
12147
12168
|
|
|
12169
|
+
NDElement.prototype.$getSignal = function() {
|
|
12170
|
+
if(!this.$controller) {
|
|
12171
|
+
this.$controller = new AbortController();
|
|
12172
|
+
this.beforeUnmount('abort-controller', () => {
|
|
12173
|
+
this.$controller.abort();
|
|
12174
|
+
this.$controller = null;
|
|
12175
|
+
});
|
|
12176
|
+
}
|
|
12177
|
+
return this.$controller.signal;
|
|
12178
|
+
};
|
|
12179
|
+
|
|
12148
12180
|
NDElement.prototype.on = function(name, callback, options) {
|
|
12149
|
-
this.$element.addEventListener(name.toLowerCase(), callback,
|
|
12181
|
+
this.$element.addEventListener(name.toLowerCase(), callback, {
|
|
12182
|
+
signal: this.$getSignal(),
|
|
12183
|
+
...options
|
|
12184
|
+
});
|
|
12185
|
+
return this;
|
|
12186
|
+
};
|
|
12187
|
+
|
|
12188
|
+
NDElement.prototype.off = function(name, callback) {
|
|
12189
|
+
this.$element.removeEventListener(name.toLowerCase(), callback);
|
|
12190
|
+
return this;
|
|
12191
|
+
};
|
|
12192
|
+
|
|
12193
|
+
NDElement.prototype.once = function(name, callback) {
|
|
12194
|
+
this.$element.addEventListener(name.toLowerCase(), callback, {
|
|
12195
|
+
signal: this.$getSignal(),
|
|
12196
|
+
once: true
|
|
12197
|
+
});
|
|
12198
|
+
return this;
|
|
12199
|
+
};
|
|
12200
|
+
|
|
12201
|
+
NDElement.prototype.emit = function(name, detail = null) {
|
|
12202
|
+
const event = new CustomEvent(name, {
|
|
12203
|
+
detail,
|
|
12204
|
+
bubbles: true,
|
|
12205
|
+
cancelable: true,
|
|
12206
|
+
});
|
|
12207
|
+
this.$element.dispatchEvent(event);
|
|
12150
12208
|
return this;
|
|
12151
12209
|
};
|
|
12152
12210
|
|
|
12153
|
-
const _prevent = function(element, eventName, callback) {
|
|
12211
|
+
const _prevent = function(element, eventName, callback, options) {
|
|
12154
12212
|
const handler = (event) => {
|
|
12155
12213
|
event.preventDefault();
|
|
12156
12214
|
callback && callback.call(element, event);
|
|
12157
12215
|
};
|
|
12158
|
-
element.addEventListener(eventName, handler);
|
|
12216
|
+
element.addEventListener(eventName, handler, options);
|
|
12159
12217
|
return this;
|
|
12160
12218
|
};
|
|
12161
12219
|
|
|
12162
|
-
const _stop = function(element, eventName, callback) {
|
|
12220
|
+
const _stop = function(element, eventName, callback, options) {
|
|
12163
12221
|
const handler = (event) => {
|
|
12164
12222
|
event.stopPropagation();
|
|
12165
12223
|
callback && callback.call(element, event);
|
|
12166
12224
|
};
|
|
12167
|
-
element.addEventListener(eventName, handler);
|
|
12225
|
+
element.addEventListener(eventName, handler, options);
|
|
12168
12226
|
return this;
|
|
12169
12227
|
};
|
|
12170
12228
|
|
|
12171
|
-
const _preventStop = function(element, eventName, callback) {
|
|
12229
|
+
const _preventStop = function(element, eventName, callback, options) {
|
|
12172
12230
|
const handler = (event) => {
|
|
12173
12231
|
event.stopPropagation();
|
|
12174
12232
|
event.preventDefault();
|
|
12175
12233
|
callback && callback.call(element, event);
|
|
12176
12234
|
};
|
|
12177
|
-
element.addEventListener(eventName, handler);
|
|
12235
|
+
element.addEventListener(eventName, handler, options);
|
|
12178
12236
|
return this;
|
|
12179
12237
|
};
|
|
12180
12238
|
|
|
@@ -1797,6 +1797,10 @@ var NativeDocument = (function (exports) {
|
|
|
1797
1797
|
return new ObservableArray(this.resolve());
|
|
1798
1798
|
};
|
|
1799
1799
|
|
|
1800
|
+
ObservableArray.prototype.isNotEmpty = function () {
|
|
1801
|
+
return this.is((x) => x.length > 0);
|
|
1802
|
+
};
|
|
1803
|
+
|
|
1800
1804
|
const ObservableObject = function(target, configs) {
|
|
1801
1805
|
ObservableItem.call(this, target);
|
|
1802
1806
|
this.$observables = {};
|
|
@@ -2076,7 +2080,7 @@ var NativeDocument = (function (exports) {
|
|
|
2076
2080
|
};
|
|
2077
2081
|
|
|
2078
2082
|
ObservableItem.prototype.isNotEmpty = function () {
|
|
2079
|
-
return $checker(this, x => x
|
|
2083
|
+
return $checker(this, x => x != null && x !== '' && !(Array.isArray(x) && x.length === 0));
|
|
2080
2084
|
};
|
|
2081
2085
|
|
|
2082
2086
|
ObservableItem.prototype.isIncludes = function (value) {
|
|
@@ -2676,6 +2680,10 @@ var NativeDocument = (function (exports) {
|
|
|
2676
2680
|
});
|
|
2677
2681
|
};
|
|
2678
2682
|
|
|
2683
|
+
Observable.setLocale = function(locale) {
|
|
2684
|
+
Formatters.locale = locale.__$Observable ? locale : Observable(locale);
|
|
2685
|
+
};
|
|
2686
|
+
|
|
2679
2687
|
|
|
2680
2688
|
/**
|
|
2681
2689
|
*
|
|
@@ -2844,10 +2852,6 @@ var NativeDocument = (function (exports) {
|
|
|
2844
2852
|
return data;
|
|
2845
2853
|
};
|
|
2846
2854
|
|
|
2847
|
-
ObservableItem.prototype.resolve = function () {
|
|
2848
|
-
return Observable.value(this);
|
|
2849
|
-
};
|
|
2850
|
-
|
|
2851
2855
|
Observable.object = Observable.init;
|
|
2852
2856
|
Observable.json = Observable.init;
|
|
2853
2857
|
|
|
@@ -2860,6 +2864,10 @@ var NativeDocument = (function (exports) {
|
|
|
2860
2864
|
return new ObservableResource(fn, deps, config);
|
|
2861
2865
|
};
|
|
2862
2866
|
|
|
2867
|
+
ObservableItem.prototype.resolve = function () {
|
|
2868
|
+
return Observable.value(this);
|
|
2869
|
+
};
|
|
2870
|
+
|
|
2863
2871
|
/**
|
|
2864
2872
|
*
|
|
2865
2873
|
* @param {HTMLElement} element
|
|
@@ -3949,6 +3957,7 @@ var NativeDocument = (function (exports) {
|
|
|
3949
3957
|
return this;
|
|
3950
3958
|
}
|
|
3951
3959
|
this.$element.setAttribute(name, value);
|
|
3960
|
+
return this;
|
|
3952
3961
|
};
|
|
3953
3962
|
|
|
3954
3963
|
NDElement.prototype.attrs = function(attrs) {
|
|
@@ -4203,62 +4212,111 @@ var NativeDocument = (function (exports) {
|
|
|
4203
4212
|
// ----------------------------------------------------------------
|
|
4204
4213
|
EVENTS.forEach(eventSourceName => {
|
|
4205
4214
|
const eventName = eventSourceName.toLowerCase();
|
|
4206
|
-
NDElement.prototype['on'+eventSourceName] = function(callback = null) {
|
|
4207
|
-
this.$element.addEventListener(eventName, callback
|
|
4215
|
+
NDElement.prototype['on'+eventSourceName] = function(callback = null, options = {}) {
|
|
4216
|
+
this.$element.addEventListener(eventName, callback, {
|
|
4217
|
+
signal: this.$getSignal(),
|
|
4218
|
+
...options
|
|
4219
|
+
});
|
|
4208
4220
|
return this;
|
|
4209
4221
|
};
|
|
4210
4222
|
});
|
|
4211
4223
|
|
|
4212
4224
|
EVENTS_WITH_STOP.forEach(eventSourceName => {
|
|
4213
4225
|
const eventName = eventSourceName.toLowerCase();
|
|
4214
|
-
NDElement.prototype['onStop'+eventSourceName] = function(callback = null) {
|
|
4215
|
-
_stop(this.$element, eventName, callback
|
|
4226
|
+
NDElement.prototype['onStop'+eventSourceName] = function(callback = null, options = {}) {
|
|
4227
|
+
_stop(this.$element, eventName, callback, {
|
|
4228
|
+
signal: this.$getSignal(),
|
|
4229
|
+
...options
|
|
4230
|
+
});
|
|
4216
4231
|
return this;
|
|
4217
4232
|
};
|
|
4218
|
-
NDElement.prototype['onPreventStop'+eventSourceName] = function(callback = null) {
|
|
4219
|
-
_preventStop(this.$element, eventName, callback
|
|
4233
|
+
NDElement.prototype['onPreventStop'+eventSourceName] = function(callback = null, options = {}) {
|
|
4234
|
+
_preventStop(this.$element, eventName, callback, {
|
|
4235
|
+
signal: this.$getSignal(),
|
|
4236
|
+
...options
|
|
4237
|
+
});
|
|
4220
4238
|
return this;
|
|
4221
4239
|
};
|
|
4222
4240
|
});
|
|
4223
4241
|
|
|
4224
4242
|
EVENTS_WITH_PREVENT.forEach(eventSourceName => {
|
|
4225
4243
|
const eventName = eventSourceName.toLowerCase();
|
|
4226
|
-
NDElement.prototype['onPrevent'+eventSourceName] = function(callback = null) {
|
|
4227
|
-
_prevent(this.$element, eventName, callback
|
|
4244
|
+
NDElement.prototype['onPrevent'+eventSourceName] = function(callback = null, options = {}) {
|
|
4245
|
+
_prevent(this.$element, eventName, callback, {
|
|
4246
|
+
signal: this.$getSignal(),
|
|
4247
|
+
...options
|
|
4248
|
+
});
|
|
4228
4249
|
return this;
|
|
4229
4250
|
};
|
|
4230
4251
|
});
|
|
4231
4252
|
|
|
4253
|
+
NDElement.prototype.$getSignal = function() {
|
|
4254
|
+
if(!this.$controller) {
|
|
4255
|
+
this.$controller = new AbortController();
|
|
4256
|
+
this.beforeUnmount('abort-controller', () => {
|
|
4257
|
+
this.$controller.abort();
|
|
4258
|
+
this.$controller = null;
|
|
4259
|
+
});
|
|
4260
|
+
}
|
|
4261
|
+
return this.$controller.signal;
|
|
4262
|
+
};
|
|
4263
|
+
|
|
4232
4264
|
NDElement.prototype.on = function(name, callback, options) {
|
|
4233
|
-
this.$element.addEventListener(name.toLowerCase(), callback,
|
|
4265
|
+
this.$element.addEventListener(name.toLowerCase(), callback, {
|
|
4266
|
+
signal: this.$getSignal(),
|
|
4267
|
+
...options
|
|
4268
|
+
});
|
|
4269
|
+
return this;
|
|
4270
|
+
};
|
|
4271
|
+
|
|
4272
|
+
NDElement.prototype.off = function(name, callback) {
|
|
4273
|
+
this.$element.removeEventListener(name.toLowerCase(), callback);
|
|
4274
|
+
return this;
|
|
4275
|
+
};
|
|
4276
|
+
|
|
4277
|
+
NDElement.prototype.once = function(name, callback) {
|
|
4278
|
+
this.$element.addEventListener(name.toLowerCase(), callback, {
|
|
4279
|
+
signal: this.$getSignal(),
|
|
4280
|
+
once: true
|
|
4281
|
+
});
|
|
4234
4282
|
return this;
|
|
4235
4283
|
};
|
|
4236
4284
|
|
|
4237
|
-
|
|
4285
|
+
NDElement.prototype.emit = function(name, detail = null) {
|
|
4286
|
+
const event = new CustomEvent(name, {
|
|
4287
|
+
detail,
|
|
4288
|
+
bubbles: true,
|
|
4289
|
+
cancelable: true,
|
|
4290
|
+
});
|
|
4291
|
+
this.$element.dispatchEvent(event);
|
|
4292
|
+
return this;
|
|
4293
|
+
};
|
|
4294
|
+
|
|
4295
|
+
const _prevent = function(element, eventName, callback, options) {
|
|
4238
4296
|
const handler = (event) => {
|
|
4239
4297
|
event.preventDefault();
|
|
4240
4298
|
callback && callback.call(element, event);
|
|
4241
4299
|
};
|
|
4242
|
-
element.addEventListener(eventName, handler);
|
|
4300
|
+
element.addEventListener(eventName, handler, options);
|
|
4243
4301
|
return this;
|
|
4244
4302
|
};
|
|
4245
4303
|
|
|
4246
|
-
const _stop = function(element, eventName, callback) {
|
|
4304
|
+
const _stop = function(element, eventName, callback, options) {
|
|
4247
4305
|
const handler = (event) => {
|
|
4248
4306
|
event.stopPropagation();
|
|
4249
4307
|
callback && callback.call(element, event);
|
|
4250
4308
|
};
|
|
4251
|
-
element.addEventListener(eventName, handler);
|
|
4309
|
+
element.addEventListener(eventName, handler, options);
|
|
4252
4310
|
return this;
|
|
4253
4311
|
};
|
|
4254
4312
|
|
|
4255
|
-
const _preventStop = function(element, eventName, callback) {
|
|
4313
|
+
const _preventStop = function(element, eventName, callback, options) {
|
|
4256
4314
|
const handler = (event) => {
|
|
4257
4315
|
event.stopPropagation();
|
|
4258
4316
|
event.preventDefault();
|
|
4259
4317
|
callback && callback.call(element, event);
|
|
4260
4318
|
};
|
|
4261
|
-
element.addEventListener(eventName, handler);
|
|
4319
|
+
element.addEventListener(eventName, handler, options);
|
|
4262
4320
|
return this;
|
|
4263
4321
|
};
|
|
4264
4322
|
|
|
@@ -5783,7 +5841,7 @@ var NativeDocument = (function (exports) {
|
|
|
5783
5841
|
}
|
|
5784
5842
|
}
|
|
5785
5843
|
child = null;
|
|
5786
|
-
element.
|
|
5844
|
+
element.appendChildRaw(fragment);
|
|
5787
5845
|
},
|
|
5788
5846
|
removeOne: (element, index) => {
|
|
5789
5847
|
removeCacheItem(element, true);
|
|
@@ -7610,9 +7668,7 @@ var NativeDocument = (function (exports) {
|
|
|
7610
7668
|
};
|
|
7611
7669
|
|
|
7612
7670
|
const removeLastNodeInserted = () => {
|
|
7613
|
-
|
|
7614
|
-
$lastNodeInserted.remove();
|
|
7615
|
-
}
|
|
7671
|
+
$lastNodeInserted?.remove();
|
|
7616
7672
|
};
|
|
7617
7673
|
|
|
7618
7674
|
const cleanContainer = () => {
|