@stemy/ngx-utils 19.4.15 → 19.4.17
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/fesm2022/stemy-ngx-utils.mjs +50 -8
- package/fesm2022/stemy-ngx-utils.mjs.map +1 -1
- package/ngx-utils/common-types.d.ts +1 -1
- package/ngx-utils/ngx-utils.imports.d.ts +1 -1
- package/ngx-utils/plugins/resize-detector.d.ts +11 -0
- package/ngx-utils/plugins/resize-event.plugin.d.ts +2 -2
- package/ngx-utils/utils/object.utils.d.ts +3 -1
- package/package.json +1 -1
|
@@ -129,15 +129,22 @@ class ObjectUtils {
|
|
|
129
129
|
return !obj || Object.keys(obj).length == 0;
|
|
130
130
|
}
|
|
131
131
|
static iterate(obj, cb) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
const keys = Array.isArray(obj)
|
|
133
|
+
? Array.from(obj.keys())
|
|
134
|
+
: (ObjectUtils.isObject(obj) ? Object.keys(obj) : []);
|
|
135
135
|
keys.forEach(
|
|
136
136
|
// @dynamic
|
|
137
137
|
key => {
|
|
138
138
|
cb(obj[key], key);
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
|
+
static iterateRecursive(obj, cb, path = "") {
|
|
142
|
+
return ObjectUtils.iterate(obj, (value, key) => {
|
|
143
|
+
const subPath = !path ? key : `${path}.${key}`;
|
|
144
|
+
cb(value, key, subPath, obj);
|
|
145
|
+
ObjectUtils.iterateRecursive(value, cb, subPath);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
141
148
|
static getValue(obj, key, defaultValue, treeFallback = false) {
|
|
142
149
|
key = key || "";
|
|
143
150
|
const keys = key.split(".");
|
|
@@ -4399,6 +4406,43 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
|
|
|
4399
4406
|
args: [DOCUMENT]
|
|
4400
4407
|
}] }, { type: UniversalService }] });
|
|
4401
4408
|
|
|
4409
|
+
class ResizeDetector {
|
|
4410
|
+
constructor(resizeStrategy) {
|
|
4411
|
+
this.resizeStrategy = resizeStrategy;
|
|
4412
|
+
this.detector = elementResizeDetectorMaker({
|
|
4413
|
+
strategy: resizeStrategy === "observer" ? "object" : resizeStrategy
|
|
4414
|
+
});
|
|
4415
|
+
this.isObservable = resizeStrategy === "observer" && typeof ResizeObserver === "function";
|
|
4416
|
+
this.observers = new Map();
|
|
4417
|
+
}
|
|
4418
|
+
listenTo(elem, cb) {
|
|
4419
|
+
if (!this.isObservable) {
|
|
4420
|
+
this.detector.listenTo(elem, cb);
|
|
4421
|
+
return;
|
|
4422
|
+
}
|
|
4423
|
+
if (this.observers.has(elem))
|
|
4424
|
+
return;
|
|
4425
|
+
const observer = new ResizeObserver(() => {
|
|
4426
|
+
requestAnimationFrame(() => {
|
|
4427
|
+
cb(elem);
|
|
4428
|
+
});
|
|
4429
|
+
});
|
|
4430
|
+
observer.observe(elem);
|
|
4431
|
+
this.observers.set(elem, observer);
|
|
4432
|
+
}
|
|
4433
|
+
uninstall(elem) {
|
|
4434
|
+
if (!this.isObservable) {
|
|
4435
|
+
this.detector.uninstall(elem);
|
|
4436
|
+
return;
|
|
4437
|
+
}
|
|
4438
|
+
if (!this.observers.has(elem))
|
|
4439
|
+
return;
|
|
4440
|
+
const observer = this.observers.get(elem);
|
|
4441
|
+
observer.unobserve(elem);
|
|
4442
|
+
this.observers.delete(elem);
|
|
4443
|
+
}
|
|
4444
|
+
}
|
|
4445
|
+
|
|
4402
4446
|
function emptyRemove$1() {
|
|
4403
4447
|
}
|
|
4404
4448
|
function isWindow(el) {
|
|
@@ -4411,9 +4455,7 @@ class ResizeEventPlugin extends _DomEventsPlugin {
|
|
|
4411
4455
|
this.resizeDelay = resizeDelay;
|
|
4412
4456
|
this.resizeStrategy = resizeStrategy;
|
|
4413
4457
|
this.universal = universal;
|
|
4414
|
-
this.detector =
|
|
4415
|
-
strategy: resizeStrategy
|
|
4416
|
-
});
|
|
4458
|
+
this.detector = new ResizeDetector(resizeStrategy);
|
|
4417
4459
|
}
|
|
4418
4460
|
supports(eventName) {
|
|
4419
4461
|
return eventName === ResizeEventPlugin.EVENT_NAME;
|
|
@@ -4424,7 +4466,7 @@ class ResizeEventPlugin extends _DomEventsPlugin {
|
|
|
4424
4466
|
if (this.universal.isServer)
|
|
4425
4467
|
return emptyRemove$1;
|
|
4426
4468
|
const timer = TimerUtils.createTimeout();
|
|
4427
|
-
const cb = el => {
|
|
4469
|
+
const cb = (el) => {
|
|
4428
4470
|
timer.set(() => {
|
|
4429
4471
|
zone.run(() => handler(el));
|
|
4430
4472
|
}, this.resizeDelay);
|
|
@@ -8057,7 +8099,7 @@ class NgxUtilsModule {
|
|
|
8057
8099
|
},
|
|
8058
8100
|
{
|
|
8059
8101
|
provide: RESIZE_STRATEGY,
|
|
8060
|
-
useValue: (!config ? null : config.resizeStrategy) ?? "
|
|
8102
|
+
useValue: (!config ? null : config.resizeStrategy) ?? "observer",
|
|
8061
8103
|
},
|
|
8062
8104
|
{
|
|
8063
8105
|
provide: SOCKET_IO_PATH,
|