native-document 1.0.68 → 1.0.70
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/.npmrc.example +0 -0
- package/components.js +0 -0
- package/dist/native-document.dev.js +480 -59
- 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/hrm.js +0 -0
- package/package.json +1 -1
- package/src/data/ObservableArray.js +68 -1
- package/src/data/ObservableItem.js +3 -1
- package/src/data/ObservableWhen.js +0 -0
- package/src/data/observable-helpers/array.js +1 -1
- package/src/devtools/hrm/ComponentRegistry.js +0 -0
- package/src/devtools/hrm/hrm.hook.template.js +0 -0
- package/src/devtools/hrm/hrm.orbservable.hook.template.js +0 -0
- package/src/devtools/hrm/nd-vite-hot-reload.js +0 -0
- package/src/devtools/hrm/transformComponent.js +0 -0
- package/src/elements/control/show-when.js +0 -0
- package/src/utils/filters/date.js +97 -0
- package/src/utils/filters/index.js +4 -0
- package/src/utils/filters/standard.js +137 -0
- package/src/utils/filters/strings.js +35 -0
- package/src/utils/filters/utils.js +41 -0
- package/src/utils/memoize.js +0 -0
- package/src/utils/service.js +0 -0
- package/types/filters/dates.d.ts +43 -0
- package/types/filters/standard.d.ts +71 -0
- package/types/filters/strings.d.ts +21 -0
- package/types/filters/types.d.ts +20 -0
- package/types/memoize.d.ts +0 -0
- package/types/native-fetch.d.ts +0 -0
- package/types/observable.d.ts +7 -1
- package/types/service.d.ts +0 -0
- package/utils.js +3 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var NativeDocument = (function (exports) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
let DebugManager
|
|
4
|
+
let DebugManager = {};
|
|
5
5
|
|
|
6
6
|
{
|
|
7
|
-
DebugManager
|
|
7
|
+
DebugManager = {
|
|
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 = DebugManager
|
|
38
|
+
var DebugManager$1 = DebugManager;
|
|
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.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
|
|
87
|
+
DebugManager$1.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
};
|
|
@@ -207,7 +207,7 @@ var NativeDocument = (function (exports) {
|
|
|
207
207
|
try{
|
|
208
208
|
callback.call(plugin, ...data);
|
|
209
209
|
} catch (error) {
|
|
210
|
-
DebugManager.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
|
|
210
|
+
DebugManager$1.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
}
|
|
@@ -343,6 +343,7 @@ var NativeDocument = (function (exports) {
|
|
|
343
343
|
|
|
344
344
|
operations = operations || DEFAULT_OPERATIONS;
|
|
345
345
|
for(let i = 0, length = $listeners.length; i < length; i++) {
|
|
346
|
+
$listeners[i];
|
|
346
347
|
$listeners[i]($currentValue, $previousValue, operations);
|
|
347
348
|
}
|
|
348
349
|
};
|
|
@@ -360,6 +361,7 @@ var NativeDocument = (function (exports) {
|
|
|
360
361
|
callback.set ? callback.set(value) : callback(value);
|
|
361
362
|
});
|
|
362
363
|
};
|
|
364
|
+
|
|
363
365
|
ObservableItem.prototype.triggerWatchers = function() {
|
|
364
366
|
if(!this.$watchers) {
|
|
365
367
|
return;
|
|
@@ -459,7 +461,7 @@ var NativeDocument = (function (exports) {
|
|
|
459
461
|
ObservableItem.prototype.subscribe = function(callback, target = null) {
|
|
460
462
|
this.$listeners = this.$listeners ?? [];
|
|
461
463
|
if (this.$isCleanedUp) {
|
|
462
|
-
DebugManager.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
|
|
464
|
+
DebugManager$1.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
|
|
463
465
|
return () => {};
|
|
464
466
|
}
|
|
465
467
|
if (typeof callback !== 'function') {
|
|
@@ -1000,7 +1002,7 @@ var NativeDocument = (function (exports) {
|
|
|
1000
1002
|
}
|
|
1001
1003
|
{
|
|
1002
1004
|
if (this[name] && !this.$localExtensions.has(name)) {
|
|
1003
|
-
DebugManager.warn('NDElement.extend', `Method "${name}" already exists and will be overwritten`);
|
|
1005
|
+
DebugManager$1.warn('NDElement.extend', `Method "${name}" already exists and will be overwritten`);
|
|
1004
1006
|
}
|
|
1005
1007
|
this.$localExtensions.set(name, method);
|
|
1006
1008
|
}
|
|
@@ -1034,17 +1036,17 @@ var NativeDocument = (function (exports) {
|
|
|
1034
1036
|
const method = methods[name];
|
|
1035
1037
|
|
|
1036
1038
|
if (typeof method !== 'function') {
|
|
1037
|
-
DebugManager.warn('NDElement.extend', `"${name}" is not a function, skipping`);
|
|
1039
|
+
DebugManager$1.warn('NDElement.extend', `"${name}" is not a function, skipping`);
|
|
1038
1040
|
continue;
|
|
1039
1041
|
}
|
|
1040
1042
|
|
|
1041
1043
|
if (protectedMethods.has(name)) {
|
|
1042
|
-
DebugManager.error('NDElement.extend', `Cannot override protected method "${name}"`);
|
|
1044
|
+
DebugManager$1.error('NDElement.extend', `Cannot override protected method "${name}"`);
|
|
1043
1045
|
throw new NativeDocumentError(`Cannot override protected method "${name}"`);
|
|
1044
1046
|
}
|
|
1045
1047
|
|
|
1046
1048
|
if (NDElement.prototype[name]) {
|
|
1047
|
-
DebugManager.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
|
|
1049
|
+
DebugManager$1.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
|
|
1048
1050
|
}
|
|
1049
1051
|
|
|
1050
1052
|
NDElement.prototype[name] = method;
|
|
@@ -1190,7 +1192,7 @@ var NativeDocument = (function (exports) {
|
|
|
1190
1192
|
const foundReserved = Object.keys(attributes).filter(key => reserved.includes(key));
|
|
1191
1193
|
|
|
1192
1194
|
if (foundReserved.length > 0) {
|
|
1193
|
-
DebugManager.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
|
|
1195
|
+
DebugManager$1.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
|
|
1194
1196
|
}
|
|
1195
1197
|
|
|
1196
1198
|
return attributes;
|
|
@@ -1238,7 +1240,7 @@ var NativeDocument = (function (exports) {
|
|
|
1238
1240
|
element.appendChild = function(child, before = null) {
|
|
1239
1241
|
const parent = anchorEnd.parentNode;
|
|
1240
1242
|
if(!parent) {
|
|
1241
|
-
DebugManager.error('Anchor', 'Anchor : parent not found', child);
|
|
1243
|
+
DebugManager$1.error('Anchor', 'Anchor : parent not found', child);
|
|
1242
1244
|
return;
|
|
1243
1245
|
}
|
|
1244
1246
|
before = before ?? anchorEnd;
|
|
@@ -1356,18 +1358,18 @@ var NativeDocument = (function (exports) {
|
|
|
1356
1358
|
* @returns {ObservableItem}
|
|
1357
1359
|
* @constructor
|
|
1358
1360
|
*/
|
|
1359
|
-
function Observable(value, configs = null) {
|
|
1361
|
+
function Observable$1(value, configs = null) {
|
|
1360
1362
|
return new ObservableItem(value, configs);
|
|
1361
1363
|
}
|
|
1362
1364
|
|
|
1363
|
-
const $ = Observable;
|
|
1364
|
-
const obs = Observable;
|
|
1365
|
+
const $ = Observable$1;
|
|
1366
|
+
const obs = Observable$1;
|
|
1365
1367
|
|
|
1366
1368
|
/**
|
|
1367
1369
|
*
|
|
1368
1370
|
* @param {string} propertyName
|
|
1369
1371
|
*/
|
|
1370
|
-
Observable.useValueProperty = function(propertyName = 'value') {
|
|
1372
|
+
Observable$1.useValueProperty = function(propertyName = 'value') {
|
|
1371
1373
|
Object.defineProperty(ObservableItem.prototype, propertyName, {
|
|
1372
1374
|
get() {
|
|
1373
1375
|
return this.$currentValue;
|
|
@@ -1385,7 +1387,7 @@ var NativeDocument = (function (exports) {
|
|
|
1385
1387
|
* @param id
|
|
1386
1388
|
* @returns {ObservableItem|null}
|
|
1387
1389
|
*/
|
|
1388
|
-
Observable.getById = function(id) {
|
|
1390
|
+
Observable$1.getById = function(id) {
|
|
1389
1391
|
const item = MemoryManager.getObservableById(parseInt(id));
|
|
1390
1392
|
if(!item) {
|
|
1391
1393
|
throw new NativeDocumentError('Observable.getById : No observable found with id ' + id);
|
|
@@ -1397,7 +1399,7 @@ var NativeDocument = (function (exports) {
|
|
|
1397
1399
|
*
|
|
1398
1400
|
* @param {ObservableItem} observable
|
|
1399
1401
|
*/
|
|
1400
|
-
Observable.cleanup = function(observable) {
|
|
1402
|
+
Observable$1.cleanup = function(observable) {
|
|
1401
1403
|
observable.cleanup();
|
|
1402
1404
|
};
|
|
1403
1405
|
|
|
@@ -1406,7 +1408,7 @@ var NativeDocument = (function (exports) {
|
|
|
1406
1408
|
* @param {Boolean} enable
|
|
1407
1409
|
* @param {{interval:Boolean, threshold:number}} options
|
|
1408
1410
|
*/
|
|
1409
|
-
Observable.autoCleanup = function(enable = false, options = {}) {
|
|
1411
|
+
Observable$1.autoCleanup = function(enable = false, options = {}) {
|
|
1410
1412
|
if(!enable) {
|
|
1411
1413
|
return;
|
|
1412
1414
|
}
|
|
@@ -1554,7 +1556,7 @@ var NativeDocument = (function (exports) {
|
|
|
1554
1556
|
continue;
|
|
1555
1557
|
}
|
|
1556
1558
|
const observables = value.filter(item => Validator.isObservable(item));
|
|
1557
|
-
value = Observable.computed(() => {
|
|
1559
|
+
value = Observable$1.computed(() => {
|
|
1558
1560
|
return value.map(item => Validator.isObservable(item) ? item.val() : item).join(' ') || ' ';
|
|
1559
1561
|
}, observables);
|
|
1560
1562
|
}
|
|
@@ -2203,7 +2205,7 @@ var NativeDocument = (function (exports) {
|
|
|
2203
2205
|
String.prototype.use = function(args) {
|
|
2204
2206
|
const value = this;
|
|
2205
2207
|
|
|
2206
|
-
return Observable.computed(() => {
|
|
2208
|
+
return Observable$1.computed(() => {
|
|
2207
2209
|
return value.replace(/\$\{(.*?)}/g, (match, key) => {
|
|
2208
2210
|
const data = args[key];
|
|
2209
2211
|
if(Validator.isObservable(data)) {
|
|
@@ -2223,7 +2225,7 @@ var NativeDocument = (function (exports) {
|
|
|
2223
2225
|
return value;
|
|
2224
2226
|
}
|
|
2225
2227
|
const [_, id] = value.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);
|
|
2226
|
-
return Observable.getById(id);
|
|
2228
|
+
return Observable$1.getById(id);
|
|
2227
2229
|
});
|
|
2228
2230
|
};
|
|
2229
2231
|
|
|
@@ -2321,6 +2323,357 @@ var NativeDocument = (function (exports) {
|
|
|
2321
2323
|
});
|
|
2322
2324
|
};
|
|
2323
2325
|
|
|
2326
|
+
function toDate(value) {
|
|
2327
|
+
if (value instanceof Date) return value;
|
|
2328
|
+
return new Date(value);
|
|
2329
|
+
}
|
|
2330
|
+
|
|
2331
|
+
function isSameDay(date1, date2) {
|
|
2332
|
+
const d1 = toDate(date1);
|
|
2333
|
+
const d2 = toDate(date2);
|
|
2334
|
+
return d1.getFullYear() === d2.getFullYear() &&
|
|
2335
|
+
d1.getMonth() === d2.getMonth() &&
|
|
2336
|
+
d1.getDate() === d2.getDate();
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2339
|
+
function getSecondsOfDay(date) {
|
|
2340
|
+
const d = toDate(date);
|
|
2341
|
+
return (d.getHours() * 3600) + (d.getMinutes() * 60) + d.getSeconds();
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
function createFilter(observableOrValue, callbackFn){
|
|
2345
|
+
const isObservable = Validator.isObservable(observableOrValue);
|
|
2346
|
+
|
|
2347
|
+
return {
|
|
2348
|
+
dependencies: isObservable ? observableOrValue : null,
|
|
2349
|
+
callback: (value) => callbackFn(value, isObservable ? observableOrValue.val() : observableOrValue)
|
|
2350
|
+
};
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2353
|
+
function createMultiSourceFilter(sources, callbackFn){
|
|
2354
|
+
const observables = sources.filter(Validator.isObservable);
|
|
2355
|
+
|
|
2356
|
+
const getValues = () => sources.map(src =>
|
|
2357
|
+
Validator.isObservable(src) ? src.val() : src
|
|
2358
|
+
);
|
|
2359
|
+
|
|
2360
|
+
return {
|
|
2361
|
+
dependencies: observables.length > 0 ? observables : null,
|
|
2362
|
+
callback: (value) => callbackFn(value, getValues())
|
|
2363
|
+
};
|
|
2364
|
+
}
|
|
2365
|
+
|
|
2366
|
+
function equals(observableOrValue){
|
|
2367
|
+
return createFilter(observableOrValue, (value, target) => value === target);
|
|
2368
|
+
}
|
|
2369
|
+
|
|
2370
|
+
function notEquals(observableOrValue){
|
|
2371
|
+
return createFilter(observableOrValue, (value, target) => value !== target);
|
|
2372
|
+
}
|
|
2373
|
+
|
|
2374
|
+
function greaterThan(observableOrValue){
|
|
2375
|
+
return createFilter(observableOrValue, (value, target) => value > target);
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
function greaterThanOrEqual(observableOrValue){
|
|
2379
|
+
return createFilter(observableOrValue, (value, target) => value >= target);
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2382
|
+
function lessThan(observableOrValue){
|
|
2383
|
+
return createFilter(observableOrValue, (value, target) => value < target);
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
function lessThanOrEqual(observableOrValue){
|
|
2387
|
+
return createFilter(observableOrValue, (value, target) => value <= target);
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2390
|
+
function between(minObservableOrValue, maxObservableOrValue){
|
|
2391
|
+
return createMultiSourceFilter(
|
|
2392
|
+
[minObservableOrValue, maxObservableOrValue],
|
|
2393
|
+
(value, [min, max]) => value >= min && value <= max
|
|
2394
|
+
);
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
function inArray(observableOrArray){
|
|
2398
|
+
return createFilter(observableOrArray, (value, arr) => arr.includes(value));
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
function notIn(observableOrArray){
|
|
2402
|
+
return createFilter(observableOrArray, (value, arr) => !arr.includes(value));
|
|
2403
|
+
}
|
|
2404
|
+
|
|
2405
|
+
function isEmpty(observableOrValue = true){
|
|
2406
|
+
return createFilter(observableOrValue, (value, shouldBeEmpty) => {
|
|
2407
|
+
const isActuallyEmpty = !value || value === '' ||
|
|
2408
|
+
(Array.isArray(value) && value.length === 0);
|
|
2409
|
+
|
|
2410
|
+
return shouldBeEmpty ? isActuallyEmpty : !isActuallyEmpty;
|
|
2411
|
+
});
|
|
2412
|
+
}
|
|
2413
|
+
|
|
2414
|
+
function isNotEmpty(observableOrValue = true){
|
|
2415
|
+
return createFilter(observableOrValue, (value, shouldBeNotEmpty) => {
|
|
2416
|
+
const isActuallyNotEmpty = !!value && value !== '' &&
|
|
2417
|
+
(!Array.isArray(value) || value.length > 0);
|
|
2418
|
+
|
|
2419
|
+
return shouldBeNotEmpty ? isActuallyNotEmpty : !isActuallyNotEmpty;
|
|
2420
|
+
});
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
function match(patternObservableOrValue, asRegexObservableOrValue = true, flagsObservableOrValue = ''){
|
|
2424
|
+
return createMultiSourceFilter(
|
|
2425
|
+
[patternObservableOrValue, asRegexObservableOrValue, flagsObservableOrValue],
|
|
2426
|
+
(value, [pattern, asRegex, flags]) => {
|
|
2427
|
+
if (!pattern) return true;
|
|
2428
|
+
|
|
2429
|
+
if (asRegex){
|
|
2430
|
+
try {
|
|
2431
|
+
const regex = new RegExp(pattern, flags);
|
|
2432
|
+
return regex.test(String(value));
|
|
2433
|
+
} catch (error){
|
|
2434
|
+
console.warn('Invalid regex pattern:', pattern, error);
|
|
2435
|
+
return false;
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
|
|
2439
|
+
if (!flags || flags === ''){
|
|
2440
|
+
return String(value).toLowerCase().includes(String(pattern).toLowerCase());
|
|
2441
|
+
}
|
|
2442
|
+
return String(value).includes(String(pattern));
|
|
2443
|
+
}
|
|
2444
|
+
);
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
function and(...filters){
|
|
2448
|
+
const dependencies = filters
|
|
2449
|
+
.flatMap(f => f.dependencies ? (Array.isArray(f.dependencies) ? f.dependencies : [f.dependencies]) : [])
|
|
2450
|
+
.filter(Validator.isObservable);
|
|
2451
|
+
|
|
2452
|
+
return {
|
|
2453
|
+
dependencies: dependencies.length > 0 ? dependencies : null,
|
|
2454
|
+
callback: (value) => filters.every(f => f.callback(value))
|
|
2455
|
+
};
|
|
2456
|
+
}
|
|
2457
|
+
|
|
2458
|
+
function or(...filters){
|
|
2459
|
+
const dependencies = filters
|
|
2460
|
+
.flatMap(f => f.dependencies ? (Array.isArray(f.dependencies) ? f.dependencies : [f.dependencies]) : [])
|
|
2461
|
+
.filter(Validator.isObservable);
|
|
2462
|
+
|
|
2463
|
+
return {
|
|
2464
|
+
dependencies: dependencies.length > 0 ? dependencies : null,
|
|
2465
|
+
callback: (value) => filters.some(f => f.callback(value))
|
|
2466
|
+
};
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
function not(filter){
|
|
2470
|
+
return {
|
|
2471
|
+
dependencies: filter.dependencies,
|
|
2472
|
+
callback: (value) => !filter.callback(value)
|
|
2473
|
+
};
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2476
|
+
function custom(callbackFn, ...observables){
|
|
2477
|
+
const dependencies = observables.filter(Validator.isObservable);
|
|
2478
|
+
|
|
2479
|
+
return {
|
|
2480
|
+
dependencies: dependencies.length > 0 ? dependencies : null,
|
|
2481
|
+
callback: (value) => {
|
|
2482
|
+
const values = observables.map(o =>
|
|
2483
|
+
Validator.isObservable(o) ? o.val() : o
|
|
2484
|
+
);
|
|
2485
|
+
return callbackFn(value, ...values);
|
|
2486
|
+
}
|
|
2487
|
+
};
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
const gt = greaterThan;
|
|
2491
|
+
const gte = greaterThanOrEqual;
|
|
2492
|
+
const lt = lessThan;
|
|
2493
|
+
const lte = lessThanOrEqual;
|
|
2494
|
+
const eq = equals;
|
|
2495
|
+
const neq = notEquals;
|
|
2496
|
+
const all = and;
|
|
2497
|
+
const any = or;
|
|
2498
|
+
|
|
2499
|
+
const dateEquals = (observableOrValue) => {
|
|
2500
|
+
return createFilter(observableOrValue, (value, target) => {
|
|
2501
|
+
if (!value || !target) return false;
|
|
2502
|
+
return isSameDay(value, target);
|
|
2503
|
+
});
|
|
2504
|
+
};
|
|
2505
|
+
|
|
2506
|
+
const dateBefore = (observableOrValue) => {
|
|
2507
|
+
return createFilter(observableOrValue, (value, target) => {
|
|
2508
|
+
if (!value || !target) return false;
|
|
2509
|
+
return toDate(value) < toDate(target);
|
|
2510
|
+
});
|
|
2511
|
+
};
|
|
2512
|
+
|
|
2513
|
+
const dateAfter = (observableOrValue) => {
|
|
2514
|
+
return createFilter(observableOrValue, (value, target) => {
|
|
2515
|
+
if (!value || !target) return false;
|
|
2516
|
+
return toDate(value) > toDate(target);
|
|
2517
|
+
});
|
|
2518
|
+
};
|
|
2519
|
+
|
|
2520
|
+
const dateBetween = (startObservableOrValue, endObservableOrValue) => {
|
|
2521
|
+
return createMultiSourceFilter(
|
|
2522
|
+
[startObservableOrValue, endObservableOrValue],
|
|
2523
|
+
(value, [start, end]) => {
|
|
2524
|
+
if (!value || !start || !end) return false;
|
|
2525
|
+
const date = toDate(value);
|
|
2526
|
+
return date >= toDate(start) && date <= toDate(end);
|
|
2527
|
+
}
|
|
2528
|
+
);
|
|
2529
|
+
};
|
|
2530
|
+
|
|
2531
|
+
const timeEquals = (observableOrValue) => {
|
|
2532
|
+
return createFilter(observableOrValue, (value, target) => {
|
|
2533
|
+
if (!value || !target) return false;
|
|
2534
|
+
const d1 = toDate(value);
|
|
2535
|
+
const d2 = toDate(target);
|
|
2536
|
+
return d1.getHours() === d2.getHours() &&
|
|
2537
|
+
d1.getMinutes() === d2.getMinutes() &&
|
|
2538
|
+
d1.getSeconds() === d2.getSeconds();
|
|
2539
|
+
});
|
|
2540
|
+
};
|
|
2541
|
+
|
|
2542
|
+
const timeAfter = (observableOrValue) => {
|
|
2543
|
+
return createFilter(observableOrValue, (value, target) => {
|
|
2544
|
+
if (!value || !target) return false;
|
|
2545
|
+
return getSecondsOfDay(value) > getSecondsOfDay(target);
|
|
2546
|
+
});
|
|
2547
|
+
};
|
|
2548
|
+
|
|
2549
|
+
const timeBefore = (observableOrValue) => {
|
|
2550
|
+
return createFilter(observableOrValue, (value, target) => {
|
|
2551
|
+
if (!value || !target) return false;
|
|
2552
|
+
return getSecondsOfDay(value) < getSecondsOfDay(target);
|
|
2553
|
+
});
|
|
2554
|
+
};
|
|
2555
|
+
|
|
2556
|
+
const timeBetween = (startObservableOrValue, endObservableOrValue) => {
|
|
2557
|
+
return createMultiSourceFilter([startObservableOrValue, endObservableOrValue],
|
|
2558
|
+
(value, [start, end]) => {
|
|
2559
|
+
if (!value || !start || !end) return false;
|
|
2560
|
+
const date = getSecondsOfDay(value);
|
|
2561
|
+
return date >= getSecondsOfDay(start) && date <= getSecondsOfDay(end);
|
|
2562
|
+
}
|
|
2563
|
+
);
|
|
2564
|
+
};
|
|
2565
|
+
|
|
2566
|
+
const dateTimeEquals = (observableOrValue) => {
|
|
2567
|
+
return createFilter(observableOrValue, (value, target) => {
|
|
2568
|
+
if (!value || !target) return false;
|
|
2569
|
+
return toDate(value).getTime() === toDate(target).getTime();
|
|
2570
|
+
});
|
|
2571
|
+
};
|
|
2572
|
+
|
|
2573
|
+
const dateTimeAfter = (observableOrValue) => {
|
|
2574
|
+
return createFilter(observableOrValue, (value, target) => {
|
|
2575
|
+
if (!value || !target) return false;
|
|
2576
|
+
return toDate(value) > toDate(target);
|
|
2577
|
+
});
|
|
2578
|
+
};
|
|
2579
|
+
|
|
2580
|
+
const dateTimeBefore = (observableOrValue) => {
|
|
2581
|
+
return createFilter(observableOrValue, (value, target) => {
|
|
2582
|
+
if (!value || !target) return false;
|
|
2583
|
+
return toDate(value) < toDate(target);
|
|
2584
|
+
});
|
|
2585
|
+
};
|
|
2586
|
+
|
|
2587
|
+
const dateTimeBetween = (startObservableOrValue, endObservableOrValue) => {
|
|
2588
|
+
return createMultiSourceFilter([startObservableOrValue, endObservableOrValue], (value, [start, end]) => {
|
|
2589
|
+
if (!value || !start || !end) return false;
|
|
2590
|
+
const date = toDate(value);
|
|
2591
|
+
return date >= toDate(start) && date <= toDate(end);
|
|
2592
|
+
});
|
|
2593
|
+
};
|
|
2594
|
+
|
|
2595
|
+
function includes(observableOrValue, caseSensitive = false){
|
|
2596
|
+
return createFilter(observableOrValue, (value, query) => {
|
|
2597
|
+
if (!value) return false;
|
|
2598
|
+
if (!query) return true;
|
|
2599
|
+
if (!caseSensitive){
|
|
2600
|
+
return String(value).toLowerCase().includes(String(query).toLowerCase());
|
|
2601
|
+
}
|
|
2602
|
+
return String(value).includes(String(query));
|
|
2603
|
+
});
|
|
2604
|
+
}
|
|
2605
|
+
|
|
2606
|
+
const contains = includes;
|
|
2607
|
+
|
|
2608
|
+
function startsWith(observableOrValue, caseSensitive = false){
|
|
2609
|
+
return createFilter(observableOrValue, (value, query) => {
|
|
2610
|
+
if (!query) return true;
|
|
2611
|
+
if (!caseSensitive){
|
|
2612
|
+
return String(value).toLowerCase().startsWith(String(query).toLowerCase());
|
|
2613
|
+
}
|
|
2614
|
+
return String(value).startsWith(String(query));
|
|
2615
|
+
});
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
function endsWith(observableOrValue, caseSensitive = false){
|
|
2619
|
+
return createFilter(observableOrValue, (value, query) => {
|
|
2620
|
+
if (!query) return true;
|
|
2621
|
+
if (!caseSensitive){
|
|
2622
|
+
return String(value).toLowerCase().endsWith(String(query).toLowerCase());
|
|
2623
|
+
}
|
|
2624
|
+
return String(value).endsWith(String(query));
|
|
2625
|
+
});
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2628
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
2629
|
+
__proto__: null,
|
|
2630
|
+
all: all,
|
|
2631
|
+
and: and,
|
|
2632
|
+
any: any,
|
|
2633
|
+
between: between,
|
|
2634
|
+
contains: contains,
|
|
2635
|
+
createFilter: createFilter,
|
|
2636
|
+
createMultiSourceFilter: createMultiSourceFilter,
|
|
2637
|
+
custom: custom,
|
|
2638
|
+
dateAfter: dateAfter,
|
|
2639
|
+
dateBefore: dateBefore,
|
|
2640
|
+
dateBetween: dateBetween,
|
|
2641
|
+
dateEquals: dateEquals,
|
|
2642
|
+
dateTimeAfter: dateTimeAfter,
|
|
2643
|
+
dateTimeBefore: dateTimeBefore,
|
|
2644
|
+
dateTimeBetween: dateTimeBetween,
|
|
2645
|
+
dateTimeEquals: dateTimeEquals,
|
|
2646
|
+
endsWith: endsWith,
|
|
2647
|
+
eq: eq,
|
|
2648
|
+
equals: equals,
|
|
2649
|
+
getSecondsOfDay: getSecondsOfDay,
|
|
2650
|
+
greaterThan: greaterThan,
|
|
2651
|
+
greaterThanOrEqual: greaterThanOrEqual,
|
|
2652
|
+
gt: gt,
|
|
2653
|
+
gte: gte,
|
|
2654
|
+
inArray: inArray,
|
|
2655
|
+
includes: includes,
|
|
2656
|
+
isEmpty: isEmpty,
|
|
2657
|
+
isNotEmpty: isNotEmpty,
|
|
2658
|
+
isSameDay: isSameDay,
|
|
2659
|
+
lessThan: lessThan,
|
|
2660
|
+
lessThanOrEqual: lessThanOrEqual,
|
|
2661
|
+
lt: lt,
|
|
2662
|
+
lte: lte,
|
|
2663
|
+
match: match,
|
|
2664
|
+
neq: neq,
|
|
2665
|
+
not: not,
|
|
2666
|
+
notEquals: notEquals,
|
|
2667
|
+
notIn: notIn,
|
|
2668
|
+
or: or,
|
|
2669
|
+
startsWith: startsWith,
|
|
2670
|
+
timeAfter: timeAfter,
|
|
2671
|
+
timeBefore: timeBefore,
|
|
2672
|
+
timeBetween: timeBetween,
|
|
2673
|
+
timeEquals: timeEquals,
|
|
2674
|
+
toDate: toDate
|
|
2675
|
+
});
|
|
2676
|
+
|
|
2324
2677
|
const mutationMethods = ['push', 'pop', 'shift', 'unshift', 'reverse', 'sort', 'splice'];
|
|
2325
2678
|
const noMutationMethods = ['map', 'forEach', 'filter', 'reduce', 'some', 'every', 'find', 'findIndex', 'concat', 'includes', 'indexOf'];
|
|
2326
2679
|
|
|
@@ -2331,7 +2684,7 @@ var NativeDocument = (function (exports) {
|
|
|
2331
2684
|
* @param {{propagation: boolean, deep: boolean, reset: boolean}|null} configs
|
|
2332
2685
|
* @constructor
|
|
2333
2686
|
*/
|
|
2334
|
-
const ObservableArray = function (target, configs) {
|
|
2687
|
+
const ObservableArray = function (target, configs = null) {
|
|
2335
2688
|
if(!Array.isArray(target)) {
|
|
2336
2689
|
throw new NativeDocumentError('Observable.array : target must be an array');
|
|
2337
2690
|
}
|
|
@@ -2433,13 +2786,80 @@ var NativeDocument = (function (exports) {
|
|
|
2433
2786
|
this.trigger({ action: 'populate', args: [this.$currentValue, iteration, callback] });
|
|
2434
2787
|
};
|
|
2435
2788
|
|
|
2789
|
+
|
|
2790
|
+
ObservableArray.prototype.where = function(predicates) {
|
|
2791
|
+
const sourceArray = this;
|
|
2792
|
+
const observableDependencies = [sourceArray];
|
|
2793
|
+
const filterCallbacks = {};
|
|
2794
|
+
|
|
2795
|
+
for (const [key, rawPredicate] of Object.entries(predicates)) {
|
|
2796
|
+
const predicate = Validator.isObservable(rawPredicate) ? match(rawPredicate, false) : rawPredicate;
|
|
2797
|
+
if (predicate && typeof predicate === 'object' && 'callback' in predicate) {
|
|
2798
|
+
filterCallbacks[key] = predicate.callback;
|
|
2799
|
+
|
|
2800
|
+
if (predicate.dependencies) {
|
|
2801
|
+
const deps = Array.isArray(predicate.dependencies)
|
|
2802
|
+
? predicate.dependencies
|
|
2803
|
+
: [predicate.dependencies];
|
|
2804
|
+
observableDependencies.push(...deps);
|
|
2805
|
+
}
|
|
2806
|
+
} else if(typeof predicate === 'function') {
|
|
2807
|
+
filterCallbacks[key] = predicate;
|
|
2808
|
+
} else {
|
|
2809
|
+
filterCallbacks[key] = (value) => value === predicate;
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2812
|
+
|
|
2813
|
+
const viewArray = Observable.array();
|
|
2814
|
+
|
|
2815
|
+
const filters = Object.entries(filterCallbacks);
|
|
2816
|
+
const updateView = () => {
|
|
2817
|
+
const filtered = sourceArray.val().filter(item => {
|
|
2818
|
+
for (const [key, callback] of filters) {
|
|
2819
|
+
if(key === '_') {
|
|
2820
|
+
if (!callback(item)) return false;
|
|
2821
|
+
} else {
|
|
2822
|
+
if (!callback(item[key])) return false;
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
return true;
|
|
2826
|
+
});
|
|
2827
|
+
|
|
2828
|
+
viewArray.set(filtered);
|
|
2829
|
+
};
|
|
2830
|
+
|
|
2831
|
+
observableDependencies.forEach(dep => dep.subscribe(updateView));
|
|
2832
|
+
|
|
2833
|
+
updateView();
|
|
2834
|
+
|
|
2835
|
+
return viewArray;
|
|
2836
|
+
};
|
|
2837
|
+
|
|
2838
|
+
ObservableArray.prototype.whereSome = function(fields, filter) {
|
|
2839
|
+
return this.where({
|
|
2840
|
+
_: {
|
|
2841
|
+
dependencies: filter.dependencies,
|
|
2842
|
+
callback: (item) => fields.some(field => filter.callback(item[field]))
|
|
2843
|
+
}
|
|
2844
|
+
});
|
|
2845
|
+
};
|
|
2846
|
+
|
|
2847
|
+
ObservableArray.prototype.whereEvery = function(fields, filter) {
|
|
2848
|
+
return this.where({
|
|
2849
|
+
_: {
|
|
2850
|
+
dependencies: filter.dependencies,
|
|
2851
|
+
callback: (item) => fields.every(field => filter.callback(item[field]))
|
|
2852
|
+
}
|
|
2853
|
+
});
|
|
2854
|
+
};
|
|
2855
|
+
|
|
2436
2856
|
/**
|
|
2437
2857
|
*
|
|
2438
2858
|
* @param {Array} target
|
|
2439
2859
|
* @param {{propagation: boolean, deep: boolean, reset: boolean}|null} configs
|
|
2440
2860
|
* @returns {ObservableArray}
|
|
2441
2861
|
*/
|
|
2442
|
-
Observable.array = function(target, configs = null) {
|
|
2862
|
+
Observable$1.array = function(target = [], configs = null) {
|
|
2443
2863
|
return new ObservableArray(target, configs);
|
|
2444
2864
|
};
|
|
2445
2865
|
|
|
@@ -2448,8 +2868,8 @@ var NativeDocument = (function (exports) {
|
|
|
2448
2868
|
* @param {Function} callback
|
|
2449
2869
|
* @returns {Function}
|
|
2450
2870
|
*/
|
|
2451
|
-
Observable.batch = function(callback) {
|
|
2452
|
-
const $observer = Observable(0);
|
|
2871
|
+
Observable$1.batch = function(callback) {
|
|
2872
|
+
const $observer = Observable$1(0);
|
|
2453
2873
|
const batch = function() {
|
|
2454
2874
|
if(Validator.isAsyncFunction(callback)) {
|
|
2455
2875
|
return (callback(...arguments)).then(() => {
|
|
@@ -2507,7 +2927,7 @@ var NativeDocument = (function (exports) {
|
|
|
2507
2927
|
* @param {{propagation: boolean, deep: boolean, reset: boolean}|null} configs
|
|
2508
2928
|
* @returns {Proxy}
|
|
2509
2929
|
*/
|
|
2510
|
-
Observable.init = function(initialValue, configs = null) {
|
|
2930
|
+
Observable$1.init = function(initialValue, configs = null) {
|
|
2511
2931
|
const data = {};
|
|
2512
2932
|
for(const key in initialValue) {
|
|
2513
2933
|
const itemValue = initialValue[key];
|
|
@@ -2515,24 +2935,24 @@ var NativeDocument = (function (exports) {
|
|
|
2515
2935
|
if(configs?.deep !== false) {
|
|
2516
2936
|
const mappedItemValue = itemValue.map(item => {
|
|
2517
2937
|
if(Validator.isJson(item)) {
|
|
2518
|
-
return Observable.json(item, configs);
|
|
2938
|
+
return Observable$1.json(item, configs);
|
|
2519
2939
|
}
|
|
2520
2940
|
if(Validator.isArray(item)) {
|
|
2521
|
-
return Observable.array(item, configs);
|
|
2941
|
+
return Observable$1.array(item, configs);
|
|
2522
2942
|
}
|
|
2523
|
-
return Observable(item, configs);
|
|
2943
|
+
return Observable$1(item, configs);
|
|
2524
2944
|
});
|
|
2525
|
-
data[key] = Observable.array(mappedItemValue, configs);
|
|
2945
|
+
data[key] = Observable$1.array(mappedItemValue, configs);
|
|
2526
2946
|
continue;
|
|
2527
2947
|
}
|
|
2528
|
-
data[key] = Observable.array(itemValue, configs);
|
|
2948
|
+
data[key] = Observable$1.array(itemValue, configs);
|
|
2529
2949
|
continue;
|
|
2530
2950
|
}
|
|
2531
2951
|
if(Validator.isObservable(itemValue) || Validator.isProxy(itemValue)) {
|
|
2532
2952
|
data[key] = itemValue;
|
|
2533
2953
|
continue;
|
|
2534
2954
|
}
|
|
2535
|
-
data[key] = Observable(itemValue, configs);
|
|
2955
|
+
data[key] = Observable$1(itemValue, configs);
|
|
2536
2956
|
}
|
|
2537
2957
|
|
|
2538
2958
|
const $reset = () => {
|
|
@@ -2544,10 +2964,10 @@ var NativeDocument = (function (exports) {
|
|
|
2544
2964
|
|
|
2545
2965
|
const $val = () => ObservableObjectValue(data);
|
|
2546
2966
|
|
|
2547
|
-
const $clone = () => Observable.init($val(), configs);
|
|
2967
|
+
const $clone = () => Observable$1.init($val(), configs);
|
|
2548
2968
|
|
|
2549
2969
|
const $updateWith = (values) => {
|
|
2550
|
-
Observable.update(proxy, values);
|
|
2970
|
+
Observable$1.update(proxy, values);
|
|
2551
2971
|
};
|
|
2552
2972
|
|
|
2553
2973
|
const $get = (key) => ObservableGet(data, key);
|
|
@@ -2585,8 +3005,8 @@ var NativeDocument = (function (exports) {
|
|
|
2585
3005
|
* @param {any[]} data
|
|
2586
3006
|
* @return Proxy[]
|
|
2587
3007
|
*/
|
|
2588
|
-
Observable.arrayOfObject = function(data) {
|
|
2589
|
-
return data.map(item => Observable.object(item));
|
|
3008
|
+
Observable$1.arrayOfObject = function(data) {
|
|
3009
|
+
return data.map(item => Observable$1.object(item));
|
|
2590
3010
|
};
|
|
2591
3011
|
|
|
2592
3012
|
/**
|
|
@@ -2594,7 +3014,7 @@ var NativeDocument = (function (exports) {
|
|
|
2594
3014
|
* @param {ObservableItem|Object<ObservableItem>} data
|
|
2595
3015
|
* @returns {{}|*|null}
|
|
2596
3016
|
*/
|
|
2597
|
-
Observable.value = function(data) {
|
|
3017
|
+
Observable$1.value = function(data) {
|
|
2598
3018
|
if(Validator.isObservable(data)) {
|
|
2599
3019
|
return data.val();
|
|
2600
3020
|
}
|
|
@@ -2605,7 +3025,7 @@ var NativeDocument = (function (exports) {
|
|
|
2605
3025
|
const result = [];
|
|
2606
3026
|
for(let i = 0, length = data.length; i < length; i++) {
|
|
2607
3027
|
const item = data[i];
|
|
2608
|
-
result.push(Observable.value(item));
|
|
3028
|
+
result.push(Observable$1.value(item));
|
|
2609
3029
|
}
|
|
2610
3030
|
return result;
|
|
2611
3031
|
}
|
|
@@ -2613,7 +3033,7 @@ var NativeDocument = (function (exports) {
|
|
|
2613
3033
|
};
|
|
2614
3034
|
|
|
2615
3035
|
|
|
2616
|
-
Observable.update = function($target, newData) {
|
|
3036
|
+
Observable$1.update = function($target, newData) {
|
|
2617
3037
|
const data = Validator.isProxy(newData) ? newData.$value : newData;
|
|
2618
3038
|
const configs = $target.configs;
|
|
2619
3039
|
|
|
@@ -2628,9 +3048,9 @@ var NativeDocument = (function (exports) {
|
|
|
2628
3048
|
if(Validator.isObservable(firstElementFromOriginalValue) || Validator.isProxy(firstElementFromOriginalValue)) {
|
|
2629
3049
|
const newValues = newValue.map(item => {
|
|
2630
3050
|
if(Validator.isProxy(firstElementFromOriginalValue)) {
|
|
2631
|
-
return Observable.init(item, configs);
|
|
3051
|
+
return Observable$1.init(item, configs);
|
|
2632
3052
|
}
|
|
2633
|
-
return Observable(item, configs);
|
|
3053
|
+
return Observable$1(item, configs);
|
|
2634
3054
|
});
|
|
2635
3055
|
targetItem.set(newValues);
|
|
2636
3056
|
continue;
|
|
@@ -2642,15 +3062,15 @@ var NativeDocument = (function (exports) {
|
|
|
2642
3062
|
continue;
|
|
2643
3063
|
}
|
|
2644
3064
|
if(Validator.isProxy(targetItem)) {
|
|
2645
|
-
Observable.update(targetItem, newValue);
|
|
3065
|
+
Observable$1.update(targetItem, newValue);
|
|
2646
3066
|
continue;
|
|
2647
3067
|
}
|
|
2648
3068
|
$target[key] = newValue;
|
|
2649
3069
|
}
|
|
2650
3070
|
};
|
|
2651
3071
|
|
|
2652
|
-
Observable.object = Observable.init;
|
|
2653
|
-
Observable.json = Observable.init;
|
|
3072
|
+
Observable$1.object = Observable$1.init;
|
|
3073
|
+
Observable$1.json = Observable$1.init;
|
|
2654
3074
|
|
|
2655
3075
|
/**
|
|
2656
3076
|
*
|
|
@@ -2658,7 +3078,7 @@ var NativeDocument = (function (exports) {
|
|
|
2658
3078
|
* @param {Array|Function} dependencies
|
|
2659
3079
|
* @returns {ObservableItem}
|
|
2660
3080
|
*/
|
|
2661
|
-
Observable.computed = function(callback, dependencies = []) {
|
|
3081
|
+
Observable$1.computed = function(callback, dependencies = []) {
|
|
2662
3082
|
const initialValue = callback();
|
|
2663
3083
|
const observable = new ObservableItem(initialValue);
|
|
2664
3084
|
const updatedValue = () => observable.set(callback());
|
|
@@ -2698,7 +3118,7 @@ var NativeDocument = (function (exports) {
|
|
|
2698
3118
|
*/
|
|
2699
3119
|
use(name) {
|
|
2700
3120
|
const {observer: originalObserver, subscribers } = $stores.get(name);
|
|
2701
|
-
const observerFollower = Observable(originalObserver.val());
|
|
3121
|
+
const observerFollower = Observable$1(originalObserver.val());
|
|
2702
3122
|
const unSubscriber = originalObserver.subscribe(value => observerFollower.set(value));
|
|
2703
3123
|
const updaterUnsubscriber = observerFollower.subscribe(value => originalObserver.set(value));
|
|
2704
3124
|
observerFollower.destroy = () => {
|
|
@@ -2724,7 +3144,7 @@ var NativeDocument = (function (exports) {
|
|
|
2724
3144
|
* @returns {ObservableItem}
|
|
2725
3145
|
*/
|
|
2726
3146
|
create(name, value) {
|
|
2727
|
-
const observer = Observable(value);
|
|
3147
|
+
const observer = Observable$1(value);
|
|
2728
3148
|
$stores.set(name, { observer, subscribers: new Set()});
|
|
2729
3149
|
return observer;
|
|
2730
3150
|
},
|
|
@@ -2815,14 +3235,14 @@ var NativeDocument = (function (exports) {
|
|
|
2815
3235
|
}
|
|
2816
3236
|
|
|
2817
3237
|
try {
|
|
2818
|
-
const indexObserver = callback.length >= 2 ? Observable(indexKey) : null;
|
|
3238
|
+
const indexObserver = callback.length >= 2 ? Observable$1(indexKey) : null;
|
|
2819
3239
|
let child = ElementCreator.getChild(callback(item, indexObserver));
|
|
2820
3240
|
if(!child) {
|
|
2821
3241
|
throw new NativeDocumentError("ForEach child can't be null or undefined!");
|
|
2822
3242
|
}
|
|
2823
3243
|
cache.set(keyId, { keyId, isNew: true, child: new WeakRef(child), indexObserver});
|
|
2824
3244
|
} catch (e) {
|
|
2825
|
-
DebugManager.error('ForEach', `Error creating element for key ${keyId}` , e);
|
|
3245
|
+
DebugManager$1.error('ForEach', `Error creating element for key ${keyId}` , e);
|
|
2826
3246
|
throw e;
|
|
2827
3247
|
}
|
|
2828
3248
|
return keyId;
|
|
@@ -2988,7 +3408,7 @@ var NativeDocument = (function (exports) {
|
|
|
2988
3408
|
cache.delete(keyId);
|
|
2989
3409
|
}
|
|
2990
3410
|
|
|
2991
|
-
const indexObserver = isIndexRequired ? Observable(indexKey) : null;
|
|
3411
|
+
const indexObserver = isIndexRequired ? Observable$1(indexKey) : null;
|
|
2992
3412
|
let child = ElementCreator.getChild(callback(item, indexObserver));
|
|
2993
3413
|
if(!child) {
|
|
2994
3414
|
throw new NativeDocumentError("ForEachArray child can't be null or undefined!");
|
|
@@ -3194,7 +3614,7 @@ var NativeDocument = (function (exports) {
|
|
|
3194
3614
|
*/
|
|
3195
3615
|
const ShowIf = function(condition, child, { comment = null, shouldKeepInCache = true} = {}) {
|
|
3196
3616
|
if(!(Validator.isObservable(condition)) && !Validator.isObservableWhenResult(condition)) {
|
|
3197
|
-
return DebugManager.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
|
|
3617
|
+
return DebugManager$1.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
|
|
3198
3618
|
}
|
|
3199
3619
|
const element = Anchor('Show if : '+(comment || ''));
|
|
3200
3620
|
|
|
@@ -3234,7 +3654,7 @@ var NativeDocument = (function (exports) {
|
|
|
3234
3654
|
* @returns {DocumentFragment}
|
|
3235
3655
|
*/
|
|
3236
3656
|
const HideIf = function(condition, child, configs) {
|
|
3237
|
-
const hideCondition = Observable(!condition.val());
|
|
3657
|
+
const hideCondition = Observable$1(!condition.val());
|
|
3238
3658
|
condition.subscribe(value => hideCondition.set(!value));
|
|
3239
3659
|
|
|
3240
3660
|
return ShowIf(hideCondition, child, configs);
|
|
@@ -3981,7 +4401,7 @@ var NativeDocument = (function (exports) {
|
|
|
3981
4401
|
window.history.pushState({ name: route.name(), params, path}, route.name() || path , path);
|
|
3982
4402
|
this.handleRouteChange(route, params, query, path);
|
|
3983
4403
|
} catch (e) {
|
|
3984
|
-
DebugManager.error('HistoryRouter', 'Error in pushState', e);
|
|
4404
|
+
DebugManager$1.error('HistoryRouter', 'Error in pushState', e);
|
|
3985
4405
|
}
|
|
3986
4406
|
};
|
|
3987
4407
|
/**
|
|
@@ -3994,7 +4414,7 @@ var NativeDocument = (function (exports) {
|
|
|
3994
4414
|
window.history.replaceState({ name: route.name(), params, path}, route.name() || path , path);
|
|
3995
4415
|
this.handleRouteChange(route, params, {}, path);
|
|
3996
4416
|
} catch(e) {
|
|
3997
|
-
DebugManager.error('HistoryRouter', 'Error in replaceState', e);
|
|
4417
|
+
DebugManager$1.error('HistoryRouter', 'Error in replaceState', e);
|
|
3998
4418
|
}
|
|
3999
4419
|
};
|
|
4000
4420
|
this.forward = function() {
|
|
@@ -4021,7 +4441,7 @@ var NativeDocument = (function (exports) {
|
|
|
4021
4441
|
}
|
|
4022
4442
|
this.handleRouteChange(route, params, query, path);
|
|
4023
4443
|
} catch(e) {
|
|
4024
|
-
DebugManager.error('HistoryRouter', 'Error in popstate event', e);
|
|
4444
|
+
DebugManager$1.error('HistoryRouter', 'Error in popstate event', e);
|
|
4025
4445
|
}
|
|
4026
4446
|
});
|
|
4027
4447
|
const { route, params, query, path } = this.resolve(defaultPath || (window.location.pathname+window.location.search));
|
|
@@ -4175,7 +4595,7 @@ var NativeDocument = (function (exports) {
|
|
|
4175
4595
|
listener(request);
|
|
4176
4596
|
next && next(request);
|
|
4177
4597
|
} catch (e) {
|
|
4178
|
-
DebugManager.warn('Route Listener', 'Error in listener:', e);
|
|
4598
|
+
DebugManager$1.warn('Route Listener', 'Error in listener:', e);
|
|
4179
4599
|
}
|
|
4180
4600
|
}
|
|
4181
4601
|
};
|
|
@@ -4334,7 +4754,7 @@ var NativeDocument = (function (exports) {
|
|
|
4334
4754
|
*/
|
|
4335
4755
|
Router.create = function(options, callback) {
|
|
4336
4756
|
if(!Validator.isFunction(callback)) {
|
|
4337
|
-
DebugManager.error('Router', 'Callback must be a function', e);
|
|
4757
|
+
DebugManager$1.error('Router', 'Callback must be a function', e);
|
|
4338
4758
|
throw new RouterError('Callback must be a function');
|
|
4339
4759
|
}
|
|
4340
4760
|
const router = new Router(options);
|
|
@@ -4508,6 +4928,7 @@ var NativeDocument = (function (exports) {
|
|
|
4508
4928
|
|
|
4509
4929
|
var utils = /*#__PURE__*/Object.freeze({
|
|
4510
4930
|
__proto__: null,
|
|
4931
|
+
Filters: index,
|
|
4511
4932
|
NativeFetch: NativeFetch,
|
|
4512
4933
|
Service: Service
|
|
4513
4934
|
});
|
|
@@ -4516,7 +4937,7 @@ var NativeDocument = (function (exports) {
|
|
|
4516
4937
|
exports.ElementCreator = ElementCreator;
|
|
4517
4938
|
exports.HtmlElementWrapper = HtmlElementWrapper;
|
|
4518
4939
|
exports.NDElement = NDElement;
|
|
4519
|
-
exports.Observable = Observable;
|
|
4940
|
+
exports.Observable = Observable$1;
|
|
4520
4941
|
exports.PluginsManager = PluginsManager;
|
|
4521
4942
|
exports.SingletonView = SingletonView;
|
|
4522
4943
|
exports.Store = Store;
|