@fundamental-ngx/cdk 0.44.0-rc.6 → 0.44.0
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/esm2022/utils/drag-and-drop/dnd-list/dnd-list.directive.mjs +3 -2
- package/esm2022/utils/helpers/index.mjs +2 -1
- package/esm2022/utils/helpers/warn-once.mjs +9 -0
- package/esm2022/utils/services/content-density.service.mjs +3 -2
- package/esm2022/utils/services/destroyed.service.mjs +3 -2
- package/esm2022/utils/services/themes.service.mjs +3 -2
- package/esm2022/utils/toast/base-toast.service.mjs +3 -2
- package/fesm2022/fundamental-ngx-cdk-utils.mjs +235 -226
- package/fesm2022/fundamental-ngx-cdk-utils.mjs.map +1 -1
- package/fundamental-ngx-cdk-v0.44.0.tgz +0 -0
- package/package.json +2 -2
- package/utils/helpers/index.d.ts +1 -0
- package/utils/helpers/warn-once.d.ts +2 -0
- package/fundamental-ngx-cdk-v0.44.0-rc.6.tgz +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, Injectable, Optional, Inject,
|
|
2
|
+
import { InjectionToken, Injectable, Optional, Inject, ElementRef, inject, DestroyRef, isDevMode, Directive, EventEmitter, Input, Output, HostListener, NgModule, ContentChildren, forwardRef, HostBinding, INJECTOR, ContentChild, NgZone, Renderer2, Self, SkipSelf, PLATFORM_ID, QueryList, ViewContainerRef, Component, Injector, NgModuleFactory, Pipe, TemplateRef, ViewChild } from '@angular/core';
|
|
3
3
|
import { DOCUMENT, CommonModule, AsyncPipe } from '@angular/common';
|
|
4
4
|
import { BehaviorSubject, Subject, map, Observable, fromEvent, NEVER, Subscription, merge, ReplaySubject, startWith as startWith$1, switchMap, combineLatest, firstValueFrom, filter as filter$1, isObservable, of, take as take$1 } from 'rxjs';
|
|
5
5
|
import * as i2 from '@angular/platform-browser';
|
|
6
6
|
import { EVENT_MANAGER_PLUGINS } from '@angular/platform-browser';
|
|
7
7
|
import * as i1 from '@angular/router';
|
|
8
8
|
import { takeUntil, filter, distinctUntilChanged, take, startWith, debounceTime, map as map$1, mapTo, pairwise, tap, finalize, shareReplay, switchMap as switchMap$1, delay } from 'rxjs/operators';
|
|
9
|
+
import { coerceElement, coerceBooleanProperty, coerceNumberProperty, coerceArray, coerceCssPixelValue } from '@angular/cdk/coercion';
|
|
9
10
|
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, hasModifierKey } from '@angular/cdk/keycodes';
|
|
10
|
-
import { coerceBooleanProperty, coerceNumberProperty, coerceElement, coerceArray, coerceCssPixelValue } from '@angular/cdk/coercion';
|
|
11
11
|
import * as i1$1 from '@angular/cdk/a11y';
|
|
12
12
|
import { FocusKeyManager, LiveAnnouncer } from '@angular/cdk/a11y';
|
|
13
13
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
@@ -50,6 +50,233 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.0", ngImpor
|
|
|
50
50
|
args: [RTL_LANGUAGE]
|
|
51
51
|
}] }]; } });
|
|
52
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Helper function check whether passed data is a JS object (including function).
|
|
55
|
+
*/
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
57
|
+
function isJsObject(obj) {
|
|
58
|
+
return obj !== null && (typeof obj === 'function' || typeof obj === 'object');
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Helper function checks whether passed value is not empty.
|
|
62
|
+
*/
|
|
63
|
+
function isPresent(obj) {
|
|
64
|
+
return obj !== undefined && obj !== null;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Helper function check whether passed value is empty.
|
|
68
|
+
*/
|
|
69
|
+
function isBlank(obj) {
|
|
70
|
+
return obj === undefined || obj === null;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Helper function checks whether passed value is a boolean.
|
|
74
|
+
*/
|
|
75
|
+
function isBoolean(obj) {
|
|
76
|
+
return typeof obj === 'boolean';
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Helper function checks whether passed value is a valid number.
|
|
80
|
+
*/
|
|
81
|
+
function isNumber(obj) {
|
|
82
|
+
return typeof obj === 'number';
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Helper function checks whether passed value is a string.
|
|
86
|
+
*/
|
|
87
|
+
function isString(obj) {
|
|
88
|
+
return typeof obj === 'string';
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Helper function checks whether passed value is a function
|
|
92
|
+
*/
|
|
93
|
+
function isFunction(obj) {
|
|
94
|
+
return typeof obj === 'function';
|
|
95
|
+
}
|
|
96
|
+
/** @hidden */
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
98
|
+
function isType(obj) {
|
|
99
|
+
return isFunction(obj);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Helper function checks whether passed value is a record of `T` values.
|
|
103
|
+
*/
|
|
104
|
+
function isStringMap(obj) {
|
|
105
|
+
return typeof obj === 'object' && obj !== null;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Helper function checks whether passed value is an `object`.
|
|
109
|
+
*/
|
|
110
|
+
function isObject(item) {
|
|
111
|
+
return typeof item === 'object' && !Array.isArray(item) && item !== null;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Helper function checks whether passed value is a promise.
|
|
115
|
+
*/
|
|
116
|
+
function isPromise(obj) {
|
|
117
|
+
// allow any Promise/A+ compliant thenable.
|
|
118
|
+
// It's up to the caller to ensure that obj.then conforms to the spec
|
|
119
|
+
return !!obj && isFunction(obj.then);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Helper function checks whether passed value is an Observable/Subscribable.
|
|
123
|
+
*/
|
|
124
|
+
function isSubscribable(obj) {
|
|
125
|
+
return !!obj && isFunction(obj.subscribe);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Utility type, that allows to track and select ranges of elements while using multi-selection.
|
|
130
|
+
*
|
|
131
|
+
* @usage
|
|
132
|
+
* Imagine we have a simple list of checkboxes:
|
|
133
|
+
* ```html
|
|
134
|
+
* <input
|
|
135
|
+
* #checkboxInput
|
|
136
|
+
* *ngFor="let o of options; let idx = index"
|
|
137
|
+
* type="checkbox"
|
|
138
|
+
* [checked]="selectionModel.checked(o)"
|
|
139
|
+
* (click)="toggle(idx, $event)"
|
|
140
|
+
* >
|
|
141
|
+
* ```
|
|
142
|
+
* With the given layout the logic should be as follows:
|
|
143
|
+
* ```typescript
|
|
144
|
+
* export class YourComponent {
|
|
145
|
+
* options = ['a', 'b', 'c'];
|
|
146
|
+
* readonly selectionModel = new SelectionModel(true);
|
|
147
|
+
*
|
|
148
|
+
* private readonly _rangeSelector = new RangeSelector();
|
|
149
|
+
*
|
|
150
|
+
*
|
|
151
|
+
* toggle(idx: number, event: PointerEvent): void {
|
|
152
|
+
* // getting the toggled value of the checkbox
|
|
153
|
+
* const toggledSelection = event.target.value;
|
|
154
|
+
*
|
|
155
|
+
* // registering the selection of current checkbox
|
|
156
|
+
* this._rangeSelector.onRangeElementToggled(idx, event);
|
|
157
|
+
*
|
|
158
|
+
* // Apply value to each element in range.
|
|
159
|
+
* // If checkbox was toggled without shift pressed or without previously selected one,
|
|
160
|
+
* // this method will select only it.
|
|
161
|
+
* this._rangeSelector.applyValueToEachInRange(idx => {
|
|
162
|
+
* if (toggledSelection) {
|
|
163
|
+
* this.selectionModel.select(options[idx]);
|
|
164
|
+
* } else {
|
|
165
|
+
* this.selectionModel.deselect(options[idx]);
|
|
166
|
+
* }
|
|
167
|
+
* });
|
|
168
|
+
* }
|
|
169
|
+
* }
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
class RangeSelector {
|
|
173
|
+
constructor() {
|
|
174
|
+
/** @hidden */
|
|
175
|
+
this._previousSelectedIndex = null;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Last registered selection state (either multiple or single).
|
|
179
|
+
* Is updated on each `onRangeElementClicked` invokation. Will be `null` initially or once `reset()` is called.
|
|
180
|
+
*/
|
|
181
|
+
get lastRangeSelectionState() {
|
|
182
|
+
return this._state ? { ...this._state } : null;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The method that should be used to register each checkbox toggle.
|
|
186
|
+
* Accepts two arguments: `index` and `event`. If none provided, will reset existing state.
|
|
187
|
+
* Otherwise will register current index as last checked.
|
|
188
|
+
*
|
|
189
|
+
* If toggling was done with "shift" pressed and there's a previously registered index, will register a range selection.
|
|
190
|
+
* At the same time if checkbox was toggled without shift pressed or without previously selected one, this method will select only it.
|
|
191
|
+
*
|
|
192
|
+
* After calling this method it's recommended to use `applyValueToEachInRange` to actually toggle each checkbox in range.
|
|
193
|
+
*
|
|
194
|
+
* See usage example on this class itself.
|
|
195
|
+
*/
|
|
196
|
+
onRangeElementToggled(index, event) {
|
|
197
|
+
if (this._isNonNegativeInteger(this._previousSelectedIndex) &&
|
|
198
|
+
this._isNonNegativeInteger(index) &&
|
|
199
|
+
event?.shiftKey) {
|
|
200
|
+
this._state = {
|
|
201
|
+
isRangeSelection: true,
|
|
202
|
+
from: Math.min(this._previousSelectedIndex, index),
|
|
203
|
+
to: Math.max(this._previousSelectedIndex, index)
|
|
204
|
+
};
|
|
205
|
+
this._previousSelectedIndex = index;
|
|
206
|
+
}
|
|
207
|
+
else if (this._isNonNegativeInteger(index)) {
|
|
208
|
+
this._state = { isRangeSelection: false, from: index, to: index };
|
|
209
|
+
this._previousSelectedIndex = index;
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
this.reset();
|
|
213
|
+
}
|
|
214
|
+
return this.lastRangeSelectionState;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Allows to apply selection to each item in selection range.
|
|
218
|
+
* Accepts a function to apply selection to each item by registered index.
|
|
219
|
+
*
|
|
220
|
+
* See usage example on this class itself.
|
|
221
|
+
*/
|
|
222
|
+
applyValueToEachInRange(selectionMethod) {
|
|
223
|
+
const state = this.lastRangeSelectionState;
|
|
224
|
+
if (!state) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (this._isNonNegativeInteger(state?.from) && this._isNonNegativeInteger(state?.to)) {
|
|
228
|
+
for (let index = state.from; index <= state.to; index++) {
|
|
229
|
+
selectionMethod(index);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/** Resets selection state. Useful when the list of selectable items is changed (e.g. by filtering, sorting, page change) */
|
|
234
|
+
reset() {
|
|
235
|
+
this._state = null;
|
|
236
|
+
this._previousSelectedIndex = null;
|
|
237
|
+
}
|
|
238
|
+
/** @hidden */
|
|
239
|
+
_isNonNegativeInteger(num) {
|
|
240
|
+
return isNumber(num) && num >= 0;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Retrieves native element from ElementRef.
|
|
246
|
+
*/
|
|
247
|
+
function getNativeElement(element) {
|
|
248
|
+
let coercible = element;
|
|
249
|
+
if (hasElementRef(element)) {
|
|
250
|
+
coercible = element.elementRef;
|
|
251
|
+
}
|
|
252
|
+
return coerceElement(coercible);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Checks whether object has element reference in it.
|
|
256
|
+
*/
|
|
257
|
+
function hasElementRef(something) {
|
|
258
|
+
return something && something['elementRef'] instanceof ElementRef;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Creates an observable that emits when the component is destroyed.
|
|
263
|
+
* @param destroyRef
|
|
264
|
+
*/
|
|
265
|
+
const destroyObservable = (destroyRef = inject(DestroyRef)) => {
|
|
266
|
+
const destroy$ = new Subject();
|
|
267
|
+
destroyRef.onDestroy(() => destroy$.next());
|
|
268
|
+
return destroy$.asObservable();
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
const messages = new Set();
|
|
272
|
+
/** @hidden */
|
|
273
|
+
function warnOnce(message) {
|
|
274
|
+
if (!messages.has(message)) {
|
|
275
|
+
console.warn(message);
|
|
276
|
+
messages.add(message);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
53
280
|
const MOBILE_CONFIG_ERROR = `Missing configuration object for mobile version of the component.
|
|
54
281
|
Consult the documentation on how to provide MobileModeConfiguration object for this component.
|
|
55
282
|
`;
|
|
@@ -142,7 +369,7 @@ class ThemesService {
|
|
|
142
369
|
this.onThemeQueryParamChange = new Subject();
|
|
143
370
|
/** @hidden **/
|
|
144
371
|
this._onDestroy$ = new Subject();
|
|
145
|
-
|
|
372
|
+
warnOnce('ThemesService is deprecated since 0.35.0 in favor of ThemingService from ThemingModule');
|
|
146
373
|
}
|
|
147
374
|
/**
|
|
148
375
|
* Set theme according to additional URL parameter.
|
|
@@ -2445,7 +2672,7 @@ class ContentDensityService {
|
|
|
2445
2672
|
/** Content Density BehaviourSubject */
|
|
2446
2673
|
this.contentDensity = new BehaviorSubject(DEFAULT_CONTENT_DENSITY);
|
|
2447
2674
|
if (isDevMode()) {
|
|
2448
|
-
|
|
2675
|
+
warnOnce(`[Deprecated] ContentDensityService is deprecated and will be removed in the next major version.
|
|
2449
2676
|
Please use ContentDensityControllerService instead, or use the ContentDensityModule forRoot method.`);
|
|
2450
2677
|
}
|
|
2451
2678
|
}
|
|
@@ -2472,7 +2699,7 @@ class DestroyedService extends ReplaySubject {
|
|
|
2472
2699
|
/** @hidden */
|
|
2473
2700
|
constructor() {
|
|
2474
2701
|
super(1);
|
|
2475
|
-
|
|
2702
|
+
warnOnce(`DestroyedService is deprecated. Use Angular's built-in 'DestroyRef' and 'takeUntilDestroyed' instead.`);
|
|
2476
2703
|
}
|
|
2477
2704
|
/** @hidden */
|
|
2478
2705
|
ngOnDestroy() {
|
|
@@ -2765,23 +2992,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.0", ngImpor
|
|
|
2765
2992
|
args: [{ providedIn: 'root' }]
|
|
2766
2993
|
}], ctorParameters: function () { return [{ type: ResizeObserverFactory }]; } });
|
|
2767
2994
|
|
|
2768
|
-
/**
|
|
2769
|
-
* Retrieves native element from ElementRef.
|
|
2770
|
-
*/
|
|
2771
|
-
function getNativeElement(element) {
|
|
2772
|
-
let coercible = element;
|
|
2773
|
-
if (hasElementRef(element)) {
|
|
2774
|
-
coercible = element.elementRef;
|
|
2775
|
-
}
|
|
2776
|
-
return coerceElement(coercible);
|
|
2777
|
-
}
|
|
2778
|
-
/**
|
|
2779
|
-
* Checks whether object has element reference in it.
|
|
2780
|
-
*/
|
|
2781
|
-
function hasElementRef(something) {
|
|
2782
|
-
return something && something['elementRef'] instanceof ElementRef;
|
|
2783
|
-
}
|
|
2784
|
-
|
|
2785
2995
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2786
2996
|
class AttributeObserver {
|
|
2787
2997
|
/** @hidden */
|
|
@@ -3172,207 +3382,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.0", ngImpor
|
|
|
3172
3382
|
|
|
3173
3383
|
const FDK_FOCUSABLE_LIST_DIRECTIVE = new InjectionToken('Focusable list token');
|
|
3174
3384
|
|
|
3175
|
-
/**
|
|
3176
|
-
* Helper function check whether passed data is a JS object (including function).
|
|
3177
|
-
*/
|
|
3178
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
3179
|
-
function isJsObject(obj) {
|
|
3180
|
-
return obj !== null && (typeof obj === 'function' || typeof obj === 'object');
|
|
3181
|
-
}
|
|
3182
|
-
/**
|
|
3183
|
-
* Helper function checks whether passed value is not empty.
|
|
3184
|
-
*/
|
|
3185
|
-
function isPresent(obj) {
|
|
3186
|
-
return obj !== undefined && obj !== null;
|
|
3187
|
-
}
|
|
3188
|
-
/**
|
|
3189
|
-
* Helper function check whether passed value is empty.
|
|
3190
|
-
*/
|
|
3191
|
-
function isBlank(obj) {
|
|
3192
|
-
return obj === undefined || obj === null;
|
|
3193
|
-
}
|
|
3194
|
-
/**
|
|
3195
|
-
* Helper function checks whether passed value is a boolean.
|
|
3196
|
-
*/
|
|
3197
|
-
function isBoolean(obj) {
|
|
3198
|
-
return typeof obj === 'boolean';
|
|
3199
|
-
}
|
|
3200
|
-
/**
|
|
3201
|
-
* Helper function checks whether passed value is a valid number.
|
|
3202
|
-
*/
|
|
3203
|
-
function isNumber(obj) {
|
|
3204
|
-
return typeof obj === 'number';
|
|
3205
|
-
}
|
|
3206
|
-
/**
|
|
3207
|
-
* Helper function checks whether passed value is a string.
|
|
3208
|
-
*/
|
|
3209
|
-
function isString(obj) {
|
|
3210
|
-
return typeof obj === 'string';
|
|
3211
|
-
}
|
|
3212
|
-
/**
|
|
3213
|
-
* Helper function checks whether passed value is a function
|
|
3214
|
-
*/
|
|
3215
|
-
function isFunction(obj) {
|
|
3216
|
-
return typeof obj === 'function';
|
|
3217
|
-
}
|
|
3218
|
-
/** @hidden */
|
|
3219
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
3220
|
-
function isType(obj) {
|
|
3221
|
-
return isFunction(obj);
|
|
3222
|
-
}
|
|
3223
|
-
/**
|
|
3224
|
-
* Helper function checks whether passed value is a record of `T` values.
|
|
3225
|
-
*/
|
|
3226
|
-
function isStringMap(obj) {
|
|
3227
|
-
return typeof obj === 'object' && obj !== null;
|
|
3228
|
-
}
|
|
3229
|
-
/**
|
|
3230
|
-
* Helper function checks whether passed value is an `object`.
|
|
3231
|
-
*/
|
|
3232
|
-
function isObject(item) {
|
|
3233
|
-
return typeof item === 'object' && !Array.isArray(item) && item !== null;
|
|
3234
|
-
}
|
|
3235
|
-
/**
|
|
3236
|
-
* Helper function checks whether passed value is a promise.
|
|
3237
|
-
*/
|
|
3238
|
-
function isPromise(obj) {
|
|
3239
|
-
// allow any Promise/A+ compliant thenable.
|
|
3240
|
-
// It's up to the caller to ensure that obj.then conforms to the spec
|
|
3241
|
-
return !!obj && isFunction(obj.then);
|
|
3242
|
-
}
|
|
3243
|
-
/**
|
|
3244
|
-
* Helper function checks whether passed value is an Observable/Subscribable.
|
|
3245
|
-
*/
|
|
3246
|
-
function isSubscribable(obj) {
|
|
3247
|
-
return !!obj && isFunction(obj.subscribe);
|
|
3248
|
-
}
|
|
3249
|
-
|
|
3250
|
-
/**
|
|
3251
|
-
* Utility type, that allows to track and select ranges of elements while using multi-selection.
|
|
3252
|
-
*
|
|
3253
|
-
* @usage
|
|
3254
|
-
* Imagine we have a simple list of checkboxes:
|
|
3255
|
-
* ```html
|
|
3256
|
-
* <input
|
|
3257
|
-
* #checkboxInput
|
|
3258
|
-
* *ngFor="let o of options; let idx = index"
|
|
3259
|
-
* type="checkbox"
|
|
3260
|
-
* [checked]="selectionModel.checked(o)"
|
|
3261
|
-
* (click)="toggle(idx, $event)"
|
|
3262
|
-
* >
|
|
3263
|
-
* ```
|
|
3264
|
-
* With the given layout the logic should be as follows:
|
|
3265
|
-
* ```typescript
|
|
3266
|
-
* export class YourComponent {
|
|
3267
|
-
* options = ['a', 'b', 'c'];
|
|
3268
|
-
* readonly selectionModel = new SelectionModel(true);
|
|
3269
|
-
*
|
|
3270
|
-
* private readonly _rangeSelector = new RangeSelector();
|
|
3271
|
-
*
|
|
3272
|
-
*
|
|
3273
|
-
* toggle(idx: number, event: PointerEvent): void {
|
|
3274
|
-
* // getting the toggled value of the checkbox
|
|
3275
|
-
* const toggledSelection = event.target.value;
|
|
3276
|
-
*
|
|
3277
|
-
* // registering the selection of current checkbox
|
|
3278
|
-
* this._rangeSelector.onRangeElementToggled(idx, event);
|
|
3279
|
-
*
|
|
3280
|
-
* // Apply value to each element in range.
|
|
3281
|
-
* // If checkbox was toggled without shift pressed or without previously selected one,
|
|
3282
|
-
* // this method will select only it.
|
|
3283
|
-
* this._rangeSelector.applyValueToEachInRange(idx => {
|
|
3284
|
-
* if (toggledSelection) {
|
|
3285
|
-
* this.selectionModel.select(options[idx]);
|
|
3286
|
-
* } else {
|
|
3287
|
-
* this.selectionModel.deselect(options[idx]);
|
|
3288
|
-
* }
|
|
3289
|
-
* });
|
|
3290
|
-
* }
|
|
3291
|
-
* }
|
|
3292
|
-
* ```
|
|
3293
|
-
*/
|
|
3294
|
-
class RangeSelector {
|
|
3295
|
-
constructor() {
|
|
3296
|
-
/** @hidden */
|
|
3297
|
-
this._previousSelectedIndex = null;
|
|
3298
|
-
}
|
|
3299
|
-
/**
|
|
3300
|
-
* Last registered selection state (either multiple or single).
|
|
3301
|
-
* Is updated on each `onRangeElementClicked` invokation. Will be `null` initially or once `reset()` is called.
|
|
3302
|
-
*/
|
|
3303
|
-
get lastRangeSelectionState() {
|
|
3304
|
-
return this._state ? { ...this._state } : null;
|
|
3305
|
-
}
|
|
3306
|
-
/**
|
|
3307
|
-
* The method that should be used to register each checkbox toggle.
|
|
3308
|
-
* Accepts two arguments: `index` and `event`. If none provided, will reset existing state.
|
|
3309
|
-
* Otherwise will register current index as last checked.
|
|
3310
|
-
*
|
|
3311
|
-
* If toggling was done with "shift" pressed and there's a previously registered index, will register a range selection.
|
|
3312
|
-
* At the same time if checkbox was toggled without shift pressed or without previously selected one, this method will select only it.
|
|
3313
|
-
*
|
|
3314
|
-
* After calling this method it's recommended to use `applyValueToEachInRange` to actually toggle each checkbox in range.
|
|
3315
|
-
*
|
|
3316
|
-
* See usage example on this class itself.
|
|
3317
|
-
*/
|
|
3318
|
-
onRangeElementToggled(index, event) {
|
|
3319
|
-
if (this._isNonNegativeInteger(this._previousSelectedIndex) &&
|
|
3320
|
-
this._isNonNegativeInteger(index) &&
|
|
3321
|
-
event?.shiftKey) {
|
|
3322
|
-
this._state = {
|
|
3323
|
-
isRangeSelection: true,
|
|
3324
|
-
from: Math.min(this._previousSelectedIndex, index),
|
|
3325
|
-
to: Math.max(this._previousSelectedIndex, index)
|
|
3326
|
-
};
|
|
3327
|
-
this._previousSelectedIndex = index;
|
|
3328
|
-
}
|
|
3329
|
-
else if (this._isNonNegativeInteger(index)) {
|
|
3330
|
-
this._state = { isRangeSelection: false, from: index, to: index };
|
|
3331
|
-
this._previousSelectedIndex = index;
|
|
3332
|
-
}
|
|
3333
|
-
else {
|
|
3334
|
-
this.reset();
|
|
3335
|
-
}
|
|
3336
|
-
return this.lastRangeSelectionState;
|
|
3337
|
-
}
|
|
3338
|
-
/**
|
|
3339
|
-
* Allows to apply selection to each item in selection range.
|
|
3340
|
-
* Accepts a function to apply selection to each item by registered index.
|
|
3341
|
-
*
|
|
3342
|
-
* See usage example on this class itself.
|
|
3343
|
-
*/
|
|
3344
|
-
applyValueToEachInRange(selectionMethod) {
|
|
3345
|
-
const state = this.lastRangeSelectionState;
|
|
3346
|
-
if (!state) {
|
|
3347
|
-
return;
|
|
3348
|
-
}
|
|
3349
|
-
if (this._isNonNegativeInteger(state?.from) && this._isNonNegativeInteger(state?.to)) {
|
|
3350
|
-
for (let index = state.from; index <= state.to; index++) {
|
|
3351
|
-
selectionMethod(index);
|
|
3352
|
-
}
|
|
3353
|
-
}
|
|
3354
|
-
}
|
|
3355
|
-
/** Resets selection state. Useful when the list of selectable items is changed (e.g. by filtering, sorting, page change) */
|
|
3356
|
-
reset() {
|
|
3357
|
-
this._state = null;
|
|
3358
|
-
this._previousSelectedIndex = null;
|
|
3359
|
-
}
|
|
3360
|
-
/** @hidden */
|
|
3361
|
-
_isNonNegativeInteger(num) {
|
|
3362
|
-
return isNumber(num) && num >= 0;
|
|
3363
|
-
}
|
|
3364
|
-
}
|
|
3365
|
-
|
|
3366
|
-
/**
|
|
3367
|
-
* Creates an observable that emits when the component is destroyed.
|
|
3368
|
-
* @param destroyRef
|
|
3369
|
-
*/
|
|
3370
|
-
const destroyObservable = (destroyRef = inject(DestroyRef)) => {
|
|
3371
|
-
const destroy$ = new Subject();
|
|
3372
|
-
destroyRef.onDestroy(() => destroy$.next());
|
|
3373
|
-
return destroy$.asObservable();
|
|
3374
|
-
};
|
|
3375
|
-
|
|
3376
3385
|
/** Helper function to scroll to focusable list or its item relatively to the container. */
|
|
3377
3386
|
function scrollIntoView(element, position) {
|
|
3378
3387
|
if (!position || !element) {
|
|
@@ -5326,7 +5335,7 @@ class DndListDirective {
|
|
|
5326
5335
|
* When enabled, the Replace Indicator will appear on a whole element, instead of horizontal/vertical line before/after an element.
|
|
5327
5336
|
*/
|
|
5328
5337
|
set replaceMode(value) {
|
|
5329
|
-
|
|
5338
|
+
warnOnce('`replaceMode` input is deprecated. Use `dropMode` property instead.');
|
|
5330
5339
|
this._replaceMode = value;
|
|
5331
5340
|
this.dropMode = value ? 'group' : 'shift';
|
|
5332
5341
|
this._detectedDropMode = this.dropMode;
|
|
@@ -6850,7 +6859,7 @@ class BaseToastService {
|
|
|
6850
6859
|
* Use `hideAll()` method instead.
|
|
6851
6860
|
*/
|
|
6852
6861
|
dismissAll() {
|
|
6853
|
-
|
|
6862
|
+
warnOnce('dismissAll() is deprecated. Use hideAll() instead.');
|
|
6854
6863
|
this.hideAll();
|
|
6855
6864
|
}
|
|
6856
6865
|
/**
|
|
@@ -7583,5 +7592,5 @@ class BaseToastDurationDismissibleConfig extends BaseToastConfig {
|
|
|
7583
7592
|
* Generated bundle index. Do not edit.
|
|
7584
7593
|
*/
|
|
7585
7594
|
|
|
7586
|
-
export { ANY_LANGUAGE_LETTERS_GROUP_REGEX, ANY_LANGUAGE_LETTERS_REGEX, AbstractFdNgxClass, AsyncOrSyncPipe, AttributeObserver, AutoCompleteDirective, AutoCompleteModule, BaseAnimatedToastConfig, BaseDismissibleToastService, BaseToastActionDismissibleRef, BaseToastConfig, BaseToastContainerComponent, BaseToastDurationDismissibleConfig, BaseToastDurationDismissibleContainerComponent, BaseToastDurationDismissibleRef, BaseToastOverlayContainer, BaseToastPosition, BaseToastRef, BaseToastService, BreakpointDirective, BreakpointModule, ClickedBehaviorModule, ClickedDirective, ContentDensityService, DECIMAL_NUMBER_UNICODE_GROUP_REGEX, DECIMAL_NUMBER_UNICODE_RANGE, DECIMAL_NUMBER_UNICODE_REGEX, DEFAULT_CONTENT_DENSITY, DND_ITEM, DND_LIST, DefaultReadonlyViewModifier, DeprecatedAutoCompleteDirective, DeprecatedClickedDirective, DeprecatedDisabledBehaviorDirective, DeprecatedFocusKeyManagerItemDirective, DeprecatedFocusKeyManagerListDirective, DeprecatedFocusableItemDirective, DeprecatedFocusableListDirective, DeprecatedIgnoreClickOnSelectionDirective, DeprecatedInitialFocusDirective, DeprecatedLineClampDirective, DeprecatedLineClampTargetDirective, DeprecatedOnlyDigitsDirective, DeprecatedOverflowListDirective, DeprecatedOverflowListItemDirective, DeprecatedReadonlyBehaviorDirective, DeprecatedRepeatDirective, DeprecatedResizeDirective, DeprecatedResizeHandleDirective, DeprecatedSelector, DeprecatedTemplateSelectorDirective, DeprecatedTruncateSelectorDirective, DestroyedService, DisabledBehaviorDirective, DisabledBehaviorModule, DisabledObserver, DisplayFnPipe, DndItemDirective, DndKeyboardGroupDirective, DndKeyboardItemDirective, DndListDirective, DragAndDropModule, DynamicComponentContainer, DynamicComponentInjector, DynamicComponentService, DynamicPortalComponent, ELEMENT_REF_EXCEPTION, FDK_DISABLED_DIRECTIVE, FDK_FOCUSABLE_GRID_DIRECTIVE, FDK_FOCUSABLE_ITEM_DIRECTIVE, FDK_FOCUSABLE_LIST_DIRECTIVE, FDK_READONLY_DIRECTIVE, FDK_SELECTABLE_ITEM_PROVIDER, FD_DEPRECATED_DIRECTIVE_SELECTOR, FOCUSABLE_ITEM, FdkClickedProvider, FdkDisabledProvider, FdkReadonlyProvider, FilterStringsPipe, FocusKeyManagerHelpersModule, FocusKeyManagerItemDirective, FocusKeyManagerListDirective, FocusTrapService, FocusableGridDirective, FocusableGridModule, FocusableItemDirective, FocusableItemModule, FocusableListDirective, FocusableListModule, FocusableObserver, FunctionStrategy, INVALID_DATE_ERROR, IgnoreClickOnSelectionDirective, IgnoreClickOnSelectionDirectiveToken, IgnoreClickOnSelectionModule, InitialFocusDirective, InitialFocusModule, IntersectionSpyDirective, IsCompactDensityPipe, KeyUtil, KeyboardSupportService, LETTERS_UNICODE_RANGE, LIST_ITEM_COMPONENT, LineClampDirective, LineClampModule, LineClampTargetDirective, LocalStorageService, MOBILE_CONFIG_ERROR, MakeAsyncPipe, ModuleDeprecations, OVERFLOW_PRIORITY_SCORE, ObservableStrategy, OnlyDigitsDirective, OnlyDigitsModule, OverflowListDirective, OverflowListItemDirective, OverflowListModule, PipeModule, PromiseStrategy, RTL_LANGUAGE, RangeSelector, ReadonlyBehaviorDirective, ReadonlyBehaviorModule, ReadonlyObserver, RepeatDirective, RepeatModule, ResizeDirective, ResizeHandleDirective, ResizeModule, ResizeObserverFactory, ResizeObserverService, ResponsiveBreakpoints, RtlService, SafePipe, SearchHighlightPipe, SelectComponentRootToken, SelectableItemDirective, SelectableItemToken, SelectableListDirective, SelectableListModule, SelectionService, THEME_SWITCHER_ROUTER_MISSING_ERROR, TabbableElementService, TemplateDirective, TemplateModule, ThemesService, ToastBottomCenterPosition, ToastBottomLeftPosition, ToastBottomRightPosition, ToastTopCenterPosition, ToastTopLeftPosition, ToastTopRightPosition, TruncateDirective, TruncateModule, TruncatePipe, TwoDigitsPipe, UtilsModule, ValueByPathPipe, ValueStrategy, ViewportSizeObservable, alternateSetter, applyCssClass, applyCssStyle, baseToastAnimations, coerceArraySafe, coerceBoolean, coerceCssPixel, consumerProviderFactory, deprecatedModelProvider, destroyObservable, getBreakpointName, getDeprecatedModel, getDocumentFontSize, getElementCapacity, getElementWidth, getNativeElement, getRandomColorAccent, hasElementRef, intersectionObservable, isBlank, isBoolean, isCompactDensity, isFunction, isJsObject, isNumber, isObject, isOdd, isPresent, isPromise, isString, isStringMap, isSubscribable, isType, isValidContentDensity, moduleDeprecationsFactory, moduleDeprecationsProvider, parserFileSize, pxToNum, resizeObservable, scrollIntoView, scrollTop, selectStrategy, setDisabledState, setReadonlyState, toNativeElement, toastConnectedBottomLeftPosition, toastConnectedBottomPosition, toastConnectedBottomRightPosition, toastConnectedTopLeftPosition, toastConnectedTopPosition, toastConnectedTopRightPosition, uuidv4 };
|
|
7595
|
+
export { ANY_LANGUAGE_LETTERS_GROUP_REGEX, ANY_LANGUAGE_LETTERS_REGEX, AbstractFdNgxClass, AsyncOrSyncPipe, AttributeObserver, AutoCompleteDirective, AutoCompleteModule, BaseAnimatedToastConfig, BaseDismissibleToastService, BaseToastActionDismissibleRef, BaseToastConfig, BaseToastContainerComponent, BaseToastDurationDismissibleConfig, BaseToastDurationDismissibleContainerComponent, BaseToastDurationDismissibleRef, BaseToastOverlayContainer, BaseToastPosition, BaseToastRef, BaseToastService, BreakpointDirective, BreakpointModule, ClickedBehaviorModule, ClickedDirective, ContentDensityService, DECIMAL_NUMBER_UNICODE_GROUP_REGEX, DECIMAL_NUMBER_UNICODE_RANGE, DECIMAL_NUMBER_UNICODE_REGEX, DEFAULT_CONTENT_DENSITY, DND_ITEM, DND_LIST, DefaultReadonlyViewModifier, DeprecatedAutoCompleteDirective, DeprecatedClickedDirective, DeprecatedDisabledBehaviorDirective, DeprecatedFocusKeyManagerItemDirective, DeprecatedFocusKeyManagerListDirective, DeprecatedFocusableItemDirective, DeprecatedFocusableListDirective, DeprecatedIgnoreClickOnSelectionDirective, DeprecatedInitialFocusDirective, DeprecatedLineClampDirective, DeprecatedLineClampTargetDirective, DeprecatedOnlyDigitsDirective, DeprecatedOverflowListDirective, DeprecatedOverflowListItemDirective, DeprecatedReadonlyBehaviorDirective, DeprecatedRepeatDirective, DeprecatedResizeDirective, DeprecatedResizeHandleDirective, DeprecatedSelector, DeprecatedTemplateSelectorDirective, DeprecatedTruncateSelectorDirective, DestroyedService, DisabledBehaviorDirective, DisabledBehaviorModule, DisabledObserver, DisplayFnPipe, DndItemDirective, DndKeyboardGroupDirective, DndKeyboardItemDirective, DndListDirective, DragAndDropModule, DynamicComponentContainer, DynamicComponentInjector, DynamicComponentService, DynamicPortalComponent, ELEMENT_REF_EXCEPTION, FDK_DISABLED_DIRECTIVE, FDK_FOCUSABLE_GRID_DIRECTIVE, FDK_FOCUSABLE_ITEM_DIRECTIVE, FDK_FOCUSABLE_LIST_DIRECTIVE, FDK_READONLY_DIRECTIVE, FDK_SELECTABLE_ITEM_PROVIDER, FD_DEPRECATED_DIRECTIVE_SELECTOR, FOCUSABLE_ITEM, FdkClickedProvider, FdkDisabledProvider, FdkReadonlyProvider, FilterStringsPipe, FocusKeyManagerHelpersModule, FocusKeyManagerItemDirective, FocusKeyManagerListDirective, FocusTrapService, FocusableGridDirective, FocusableGridModule, FocusableItemDirective, FocusableItemModule, FocusableListDirective, FocusableListModule, FocusableObserver, FunctionStrategy, INVALID_DATE_ERROR, IgnoreClickOnSelectionDirective, IgnoreClickOnSelectionDirectiveToken, IgnoreClickOnSelectionModule, InitialFocusDirective, InitialFocusModule, IntersectionSpyDirective, IsCompactDensityPipe, KeyUtil, KeyboardSupportService, LETTERS_UNICODE_RANGE, LIST_ITEM_COMPONENT, LineClampDirective, LineClampModule, LineClampTargetDirective, LocalStorageService, MOBILE_CONFIG_ERROR, MakeAsyncPipe, ModuleDeprecations, OVERFLOW_PRIORITY_SCORE, ObservableStrategy, OnlyDigitsDirective, OnlyDigitsModule, OverflowListDirective, OverflowListItemDirective, OverflowListModule, PipeModule, PromiseStrategy, RTL_LANGUAGE, RangeSelector, ReadonlyBehaviorDirective, ReadonlyBehaviorModule, ReadonlyObserver, RepeatDirective, RepeatModule, ResizeDirective, ResizeHandleDirective, ResizeModule, ResizeObserverFactory, ResizeObserverService, ResponsiveBreakpoints, RtlService, SafePipe, SearchHighlightPipe, SelectComponentRootToken, SelectableItemDirective, SelectableItemToken, SelectableListDirective, SelectableListModule, SelectionService, THEME_SWITCHER_ROUTER_MISSING_ERROR, TabbableElementService, TemplateDirective, TemplateModule, ThemesService, ToastBottomCenterPosition, ToastBottomLeftPosition, ToastBottomRightPosition, ToastTopCenterPosition, ToastTopLeftPosition, ToastTopRightPosition, TruncateDirective, TruncateModule, TruncatePipe, TwoDigitsPipe, UtilsModule, ValueByPathPipe, ValueStrategy, ViewportSizeObservable, alternateSetter, applyCssClass, applyCssStyle, baseToastAnimations, coerceArraySafe, coerceBoolean, coerceCssPixel, consumerProviderFactory, deprecatedModelProvider, destroyObservable, getBreakpointName, getDeprecatedModel, getDocumentFontSize, getElementCapacity, getElementWidth, getNativeElement, getRandomColorAccent, hasElementRef, intersectionObservable, isBlank, isBoolean, isCompactDensity, isFunction, isJsObject, isNumber, isObject, isOdd, isPresent, isPromise, isString, isStringMap, isSubscribable, isType, isValidContentDensity, moduleDeprecationsFactory, moduleDeprecationsProvider, parserFileSize, pxToNum, resizeObservable, scrollIntoView, scrollTop, selectStrategy, setDisabledState, setReadonlyState, toNativeElement, toastConnectedBottomLeftPosition, toastConnectedBottomPosition, toastConnectedBottomRightPosition, toastConnectedTopLeftPosition, toastConnectedTopPosition, toastConnectedTopRightPosition, uuidv4, warnOnce };
|
|
7587
7596
|
//# sourceMappingURL=fundamental-ngx-cdk-utils.mjs.map
|