native-document 1.0.41 → 1.0.43
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.dev.js +16 -5
- package/dist/native-document.dev.js.map +1 -1
- package/dist/native-document.devtools.min.js +1 -1
- package/dist/native-document.min.js +1 -1
- package/index.js +3 -2
- package/package.json +1 -1
- package/src/data/ObservableItem.js +4 -0
- package/src/elements/img.js +5 -3
- package/src/router/Route.js +1 -1
- package/src/router/RouteGroupHelper.js +6 -1
- package/src/utils/fetch/NativeFetch.js +79 -0
- package/types/elements.d.ts +7 -0
- package/utils.d.ts +0 -0
- package/utils.js +6 -0
|
@@ -457,6 +457,10 @@ var NativeDocument = (function (exports) {
|
|
|
457
457
|
return this.$currentValue === other;
|
|
458
458
|
};
|
|
459
459
|
|
|
460
|
+
ObservableItem.prototype.toBool = function() {
|
|
461
|
+
return !!this.$currentValue;
|
|
462
|
+
};
|
|
463
|
+
|
|
460
464
|
ObservableItem.prototype.toggle = function() {
|
|
461
465
|
this.set(!this.$currentValue);
|
|
462
466
|
};
|
|
@@ -3104,11 +3108,13 @@ var NativeDocument = (function (exports) {
|
|
|
3104
3108
|
* @returns {Image}
|
|
3105
3109
|
*/
|
|
3106
3110
|
const AsyncImg = function(src, defaultImage, attributes, callback) {
|
|
3107
|
-
const
|
|
3111
|
+
const defaultSrc = Validator.isObservable(src) ? src.val() : src;
|
|
3112
|
+
const image = Img(defaultImage || defaultSrc, attributes);
|
|
3108
3113
|
const img = new Image();
|
|
3114
|
+
|
|
3109
3115
|
img.onload = () => {
|
|
3110
3116
|
Validator.isFunction(callback) && callback(null, image);
|
|
3111
|
-
image.src = src;
|
|
3117
|
+
image.src = Validator.isObservable(src) ? src.val() : src;
|
|
3112
3118
|
};
|
|
3113
3119
|
img.onerror = () => {
|
|
3114
3120
|
Validator.isFunction(callback) && callback(new NativeDocumentError('Image not found'));
|
|
@@ -3118,7 +3124,7 @@ var NativeDocument = (function (exports) {
|
|
|
3118
3124
|
img.src = newSrc;
|
|
3119
3125
|
});
|
|
3120
3126
|
}
|
|
3121
|
-
img.src =
|
|
3127
|
+
img.src = defaultSrc;
|
|
3122
3128
|
return image;
|
|
3123
3129
|
};
|
|
3124
3130
|
|
|
@@ -3316,7 +3322,7 @@ var NativeDocument = (function (exports) {
|
|
|
3316
3322
|
*/
|
|
3317
3323
|
function Route($path, $component, $options = {}) {
|
|
3318
3324
|
|
|
3319
|
-
$path = '/'+trim($path, '/');
|
|
3325
|
+
$path = '/'+trim($path, '/').replace(/\/+/, '/');
|
|
3320
3326
|
|
|
3321
3327
|
let $pattern = null;
|
|
3322
3328
|
let $name = $options.name || null;
|
|
@@ -3464,7 +3470,12 @@ var NativeDocument = (function (exports) {
|
|
|
3464
3470
|
return fullName.join('.');
|
|
3465
3471
|
},
|
|
3466
3472
|
layout: ($groupTree) => {
|
|
3467
|
-
|
|
3473
|
+
for(let i = $groupTree.length - 1; i >= 0; i--) {
|
|
3474
|
+
if($groupTree[i]?.options?.layout) {
|
|
3475
|
+
return $groupTree[i].options.layout;
|
|
3476
|
+
}
|
|
3477
|
+
}
|
|
3478
|
+
return null;
|
|
3468
3479
|
}
|
|
3469
3480
|
};
|
|
3470
3481
|
|