@fundamental-ngx/cdk 0.60.1-rc.9 → 0.60.2
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { INJECTOR, ElementRef, isDevMode, InjectionToken, EventEmitter, inject, NgZone, Input, Output, Directive, NgModule, DestroyRef, Injectable, signal, DOCUMENT, Optional, Inject, booleanAttribute, Renderer2, PLATFORM_ID, Self, SkipSelf, computed, ChangeDetectorRef, effect, ContentChildren, forwardRef, HostListener, HostBinding, Injector, ContentChild, QueryList, ViewContainerRef, TemplateRef, ViewChild, Component, NgModuleFactory, Pipe } from '@angular/core';
|
|
3
3
|
import { RIGHT_ARROW, DOWN_ARROW, LEFT_ARROW, UP_ARROW, SPACE, ESCAPE, DELETE, ENTER, MAC_ENTER, TAB, HOME, END, ALT, CONTROL, META, SHIFT, BACKSPACE, A, C, V, X, PAGE_UP, PAGE_DOWN, DASH, NUMPAD_MINUS, NUMPAD_ZERO, NUMPAD_ONE, NUMPAD_TWO, NUMPAD_THREE, NUMPAD_FOUR, NUMPAD_FIVE, NUMPAD_SIX, NUMPAD_SEVEN, NUMPAD_EIGHT, NUMPAD_NINE, F2, F7, hasModifierKey } from '@angular/cdk/keycodes';
|
|
4
|
-
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
4
|
+
import { takeUntilDestroyed, outputToObservable } from '@angular/core/rxjs-interop';
|
|
5
5
|
import { Observable, NEVER, fromEvent, switchMap, map as map$1, Subject, BehaviorSubject, ReplaySubject, merge as merge$1, combineLatest, filter as filter$1, firstValueFrom, debounceTime, distinctUntilChanged as distinctUntilChanged$1, startWith as startWith$1, Subscription, isObservable, of, tap as tap$1, take as take$1 } from 'rxjs';
|
|
6
6
|
import { map, first, distinctUntilChanged, startWith, takeUntil, filter, tap, switchMap as switchMap$1, finalize, take, debounceTime as debounceTime$1, pairwise, shareReplay, delay } from 'rxjs/operators';
|
|
7
7
|
import { coerceElement, coerceBooleanProperty, coerceNumberProperty, coerceArray, coerceCssPixelValue } from '@angular/cdk/coercion';
|
|
@@ -247,43 +247,63 @@ function set(obj, path, value) {
|
|
|
247
247
|
/**
|
|
248
248
|
* Deep clones an object, handling functions and other non-cloneable values.
|
|
249
249
|
* For objects with functions or class instances, it creates a new object and copies properties.
|
|
250
|
+
* Observables and class instances are copied by reference to avoid circular reference issues.
|
|
250
251
|
* @param obj The object to clone
|
|
252
|
+
* @param seen WeakSet to track visited objects and prevent infinite recursion
|
|
251
253
|
* @returns The cloned object
|
|
252
254
|
*/
|
|
253
|
-
function cloneDeep(obj) {
|
|
255
|
+
function cloneDeep(obj, seen = new WeakSet()) {
|
|
254
256
|
// Handle primitives, null, and undefined
|
|
255
257
|
if (obj == null || typeof obj !== 'object') {
|
|
256
258
|
return obj;
|
|
257
259
|
}
|
|
260
|
+
// Detect circular references FIRST
|
|
261
|
+
if (seen.has(obj)) {
|
|
262
|
+
return obj; // Return the object by reference if we've seen it before
|
|
263
|
+
}
|
|
258
264
|
// Handle Date
|
|
259
265
|
if (obj instanceof Date) {
|
|
260
266
|
return new Date(obj.getTime());
|
|
261
267
|
}
|
|
262
|
-
// Handle Array
|
|
263
|
-
if (Array.isArray(obj)) {
|
|
264
|
-
return obj.map((item) => cloneDeep(item));
|
|
265
|
-
}
|
|
266
268
|
// Handle RegExp
|
|
267
269
|
if (obj instanceof RegExp) {
|
|
268
270
|
return new RegExp(obj.source, obj.flags);
|
|
269
271
|
}
|
|
272
|
+
// Check if this is a plain object or array BEFORE processing
|
|
273
|
+
// If it's a class instance (like Observable), return by reference
|
|
274
|
+
const proto = Object.getPrototypeOf(obj);
|
|
275
|
+
const isPlainObject = proto === Object.prototype || proto === null;
|
|
276
|
+
const isArray = Array.isArray(obj);
|
|
277
|
+
// If it's not a plain object or array, and it's not one of the special types below,
|
|
278
|
+
// return by reference (handles Observables, class instances, etc.)
|
|
279
|
+
if (!isPlainObject && !isArray && !(obj instanceof Map) && !(obj instanceof Set)) {
|
|
280
|
+
return obj;
|
|
281
|
+
}
|
|
282
|
+
// Handle Array
|
|
283
|
+
if (isArray) {
|
|
284
|
+
seen.add(obj);
|
|
285
|
+
return obj.map((item) => cloneDeep(item, seen));
|
|
286
|
+
}
|
|
270
287
|
// Handle Map
|
|
271
288
|
if (obj instanceof Map) {
|
|
289
|
+
seen.add(obj);
|
|
272
290
|
const clonedMap = new Map();
|
|
273
291
|
obj.forEach((value, key) => {
|
|
274
|
-
clonedMap.set(cloneDeep(key), cloneDeep(value));
|
|
292
|
+
clonedMap.set(cloneDeep(key, seen), cloneDeep(value, seen));
|
|
275
293
|
});
|
|
276
294
|
return clonedMap;
|
|
277
295
|
}
|
|
278
296
|
// Handle Set
|
|
279
297
|
if (obj instanceof Set) {
|
|
298
|
+
seen.add(obj);
|
|
280
299
|
const clonedSet = new Set();
|
|
281
300
|
obj.forEach((value) => {
|
|
282
|
-
clonedSet.add(cloneDeep(value));
|
|
301
|
+
clonedSet.add(cloneDeep(value, seen));
|
|
283
302
|
});
|
|
284
303
|
return clonedSet;
|
|
285
304
|
}
|
|
286
|
-
// Handle plain objects
|
|
305
|
+
// Handle plain objects only
|
|
306
|
+
seen.add(obj);
|
|
287
307
|
const clonedObj = {};
|
|
288
308
|
for (const key in obj) {
|
|
289
309
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -293,7 +313,7 @@ function cloneDeep(obj) {
|
|
|
293
313
|
clonedObj[key] = value;
|
|
294
314
|
}
|
|
295
315
|
else {
|
|
296
|
-
clonedObj[key] = cloneDeep(value);
|
|
316
|
+
clonedObj[key] = cloneDeep(value, seen);
|
|
297
317
|
}
|
|
298
318
|
}
|
|
299
319
|
}
|
|
@@ -350,7 +370,7 @@ function deepMergeInto(target, source) {
|
|
|
350
370
|
deepMergeInto(targetValue, sourceValue);
|
|
351
371
|
}
|
|
352
372
|
else {
|
|
353
|
-
// Clone plain objects
|
|
373
|
+
// Clone plain objects (cloneDeep handles class instances like Observables)
|
|
354
374
|
target[key] = cloneDeep(sourceValue);
|
|
355
375
|
}
|
|
356
376
|
}
|
|
@@ -382,6 +402,7 @@ function mergeWith(target, source, customizer) {
|
|
|
382
402
|
result[key] = mergeWith(targetValue, sourceValue, customizer);
|
|
383
403
|
}
|
|
384
404
|
else {
|
|
405
|
+
// cloneDeep handles class instances like Observables
|
|
385
406
|
result[key] = cloneDeep(sourceValue);
|
|
386
407
|
}
|
|
387
408
|
}
|
|
@@ -1197,7 +1218,9 @@ class KeyboardSupportService {
|
|
|
1197
1218
|
/** @hidden */
|
|
1198
1219
|
_refreshEscapeLogic(queryList) {
|
|
1199
1220
|
const createEscapeListener = (listItem, onKeyCode, escapeDirection) => {
|
|
1200
|
-
|
|
1221
|
+
// Convert OutputEmitterRef to observable
|
|
1222
|
+
const keyDown$ = outputToObservable(listItem.keyDown);
|
|
1223
|
+
keyDown$
|
|
1201
1224
|
.pipe(takeUntil(unsubscribe$), filter((event) => KeyUtil.isKeyCode(event, onKeyCode)), tap((event) => event.preventDefault()))
|
|
1202
1225
|
.subscribe(() => this.focusEscapeList.next(escapeDirection));
|
|
1203
1226
|
};
|