@quadrel-enterprise-ui/framework 21.4.5 → 21.5.1
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/quadrel-enterprise-ui-framework.mjs +153 -11
- package/fesm2022/quadrel-enterprise-ui-framework.mjs.map +1 -1
- package/package.json +1 -1
- package/src/assets/i18n/de.json +5 -0
- package/src/assets/i18n/en.json +5 -0
- package/src/assets/i18n/fr.json +5 -0
- package/src/assets/i18n/it.json +5 -0
- package/types/quadrel-enterprise-ui-framework.d.ts +92 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Directive, InjectionToken, inject, ElementRef, HostBinding, Input, ViewEncapsulation, Component, Injectable, Injector, HostListener, ChangeDetectionStrategy, ChangeDetectorRef, ViewChild, NgModule, EventEmitter, Output, Renderer2, Pipe, ViewContainerRef, NO_ERRORS_SCHEMA, DestroyRef, SecurityContext, NgZone, ViewChildren, afterNextRender, forwardRef, QueryList, ContentChildren, ContentChild, afterEveryRender, isDevMode, TemplateRef, CUSTOM_ELEMENTS_SCHEMA, provideAppInitializer } from '@angular/core';
|
|
3
3
|
import { Dialog, DialogRef, DIALOG_DATA, DialogModule } from '@angular/cdk/dialog';
|
|
4
|
-
import { BehaviorSubject, pairwise, fromEvent, combineLatest, concat, map as map$1, Subject, throwError, of, ReplaySubject, merge, isObservable, NEVER, Observable, EMPTY, shareReplay, Subscription, distinctUntilChanged as distinctUntilChanged$1, debounce, timer, switchMap, asyncScheduler, startWith as startWith$1,
|
|
4
|
+
import { BehaviorSubject, pairwise, fromEvent, combineLatest, concat, map as map$1, Subject, throwError, of, ReplaySubject, merge, isObservable, NEVER, Observable, EMPTY, shareReplay, Subscription, distinctUntilChanged as distinctUntilChanged$1, debounce, timer, switchMap, asyncScheduler, startWith as startWith$1, filter as filter$1, takeUntil as takeUntil$1, debounceTime as debounceTime$1, firstValueFrom, take as take$1, tap as tap$1, from, delay, defer, queueScheduler, concatMap as concatMap$1, exhaustMap, finalize, forkJoin, delayWhen, combineLatestWith, withLatestFrom as withLatestFrom$1, async } from 'rxjs';
|
|
5
5
|
import { map, startWith, take, debounceTime, takeUntil, filter, catchError, distinctUntilChanged, concatMap, skip, throttleTime, tap, auditTime, withLatestFrom, observeOn, switchMap as switchMap$1, pairwise as pairwise$1, mergeMap } from 'rxjs/operators';
|
|
6
6
|
import { v4 } from 'uuid';
|
|
7
7
|
import * as i2 from '@ngx-translate/core';
|
|
@@ -13041,8 +13041,10 @@ class QdDatepickerComponent {
|
|
|
13041
13041
|
timePicker;
|
|
13042
13042
|
_disabledDatesValidator;
|
|
13043
13043
|
_disabledTimesValidator;
|
|
13044
|
+
_dateTimeValidator;
|
|
13044
13045
|
_boundDisabledDates;
|
|
13045
13046
|
_boundDisabledTimes;
|
|
13047
|
+
_boundDateTimeValidation;
|
|
13046
13048
|
_subs = new Subscription();
|
|
13047
13049
|
_onChange = () => { };
|
|
13048
13050
|
_onTouched = () => { };
|
|
@@ -13064,6 +13066,7 @@ class QdDatepickerComponent {
|
|
|
13064
13066
|
ngDoCheck() {
|
|
13065
13067
|
this.rebindDisabledDatesValidatorIfChanged();
|
|
13066
13068
|
this.rebindDisabledTimesValidatorIfChanged();
|
|
13069
|
+
this.rebindDateTimeValidatorIfChanged();
|
|
13067
13070
|
}
|
|
13068
13071
|
ngOnDestroy() {
|
|
13069
13072
|
this._subs.unsubscribe();
|
|
@@ -13272,6 +13275,43 @@ class QdDatepickerComponent {
|
|
|
13272
13275
|
this._boundDisabledTimes = current;
|
|
13273
13276
|
this.validateDisabledTimes();
|
|
13274
13277
|
}
|
|
13278
|
+
rebindDateTimeValidatorIfChanged() {
|
|
13279
|
+
const current = this.dateTimeValidationSignature;
|
|
13280
|
+
if (current === this._boundDateTimeValidation)
|
|
13281
|
+
return;
|
|
13282
|
+
if (!this.control)
|
|
13283
|
+
return;
|
|
13284
|
+
this._boundDateTimeValidation = current;
|
|
13285
|
+
this.validateDateTime();
|
|
13286
|
+
}
|
|
13287
|
+
/**
|
|
13288
|
+
* Identifies the date-time error message the current config asks for. `undefined` means the
|
|
13289
|
+
* picker is date-only and the plain `date` message applies.
|
|
13290
|
+
*/
|
|
13291
|
+
get dateTimeValidationSignature() {
|
|
13292
|
+
if (!this.config?.timePicker)
|
|
13293
|
+
return undefined;
|
|
13294
|
+
return this.config.enableSeconds ? 'withSeconds' : 'withoutSeconds';
|
|
13295
|
+
}
|
|
13296
|
+
/**
|
|
13297
|
+
* Makes the invalid-input message name the date *and time* format the input expects. The
|
|
13298
|
+
* validator reports under the same `date` error key as `QdValidators.date()`, so it replaces
|
|
13299
|
+
* the date-only message instead of adding a second one.
|
|
13300
|
+
*/
|
|
13301
|
+
validateDateTime() {
|
|
13302
|
+
if (!this.control)
|
|
13303
|
+
return;
|
|
13304
|
+
if (this._dateTimeValidator) {
|
|
13305
|
+
this.control.removeValidators(this._dateTimeValidator);
|
|
13306
|
+
this._dateTimeValidator = undefined;
|
|
13307
|
+
this.control.updateValueAndValidity();
|
|
13308
|
+
}
|
|
13309
|
+
if (!this.config?.timePicker)
|
|
13310
|
+
return;
|
|
13311
|
+
this._dateTimeValidator = QdValidators.dateTime(!!this.config.enableSeconds);
|
|
13312
|
+
this.control.addValidators(this._dateTimeValidator);
|
|
13313
|
+
this.control.updateValueAndValidity();
|
|
13314
|
+
}
|
|
13275
13315
|
validateDisabledDates() {
|
|
13276
13316
|
if (!this.control)
|
|
13277
13317
|
return;
|
|
@@ -16211,6 +16251,40 @@ class QdValidators {
|
|
|
16211
16251
|
return this.isValidDate(value) ? null : formattedErrorKey;
|
|
16212
16252
|
};
|
|
16213
16253
|
}
|
|
16254
|
+
/**
|
|
16255
|
+
* Validates that the value is a real, parseable `Date` object and names the **date and time**
|
|
16256
|
+
* format in the error message.
|
|
16257
|
+
*
|
|
16258
|
+
* Behaves exactly like {@link QdValidators.date}, but the message points at the format a
|
|
16259
|
+
* date-time input expects (`DD.MM.YYYY HH:mm`, or `DD.MM.YYYY HH:mm:ss` when seconds are
|
|
16260
|
+
* enabled) instead of the date-only one. The error is reported under the same `date` key as
|
|
16261
|
+
* {@link QdValidators.date}, so adding it to a control that already carries `date()` replaces
|
|
16262
|
+
* that message rather than showing a second one.
|
|
16263
|
+
*
|
|
16264
|
+
* `qd-datepicker` adds this validator on its own whenever a `timePicker` is configured — reach
|
|
16265
|
+
* for it directly only when validating a date-time value outside of the component.
|
|
16266
|
+
*
|
|
16267
|
+
* @param enableSeconds - Whether the input accepts seconds; mirrors the datepicker config of the same name.
|
|
16268
|
+
* @param errorKey - Translation key returned when the value is not a valid date.
|
|
16269
|
+
*
|
|
16270
|
+
* #### **Usage**
|
|
16271
|
+
* ```ts
|
|
16272
|
+
* new QdFormControl(null, QdValidators.dateTime());
|
|
16273
|
+
* new QdFormControl(new Date(), QdValidators.dateTime(true));
|
|
16274
|
+
* new QdFormControl(new Date(), QdValidators.dateTime(false, 'date-time-error'));
|
|
16275
|
+
* ```
|
|
16276
|
+
*/
|
|
16277
|
+
static dateTime(enableSeconds = false, errorKey) {
|
|
16278
|
+
const key = errorKey ?? (enableSeconds ? 'i18n.qd.form.error.dateTimeWithSeconds' : 'i18n.qd.form.error.dateTime');
|
|
16279
|
+
const format = enableSeconds ? 'DD.MM.YYYY HH:mm:ss' : 'DD.MM.YYYY HH:mm';
|
|
16280
|
+
return ({ value }) => {
|
|
16281
|
+
if (!value)
|
|
16282
|
+
return null;
|
|
16283
|
+
const localizedFormat = moment().format(format);
|
|
16284
|
+
const formattedErrorKey = { date: { key, params: { format: localizedFormat } } };
|
|
16285
|
+
return this.isValidDate(value) ? null : formattedErrorKey;
|
|
16286
|
+
};
|
|
16287
|
+
}
|
|
16214
16288
|
/**
|
|
16215
16289
|
* Validates that a date does not fall inside any of the given disabled ranges.
|
|
16216
16290
|
*
|
|
@@ -16282,19 +16356,60 @@ class QdValidators {
|
|
|
16282
16356
|
* ```
|
|
16283
16357
|
*/
|
|
16284
16358
|
static dateRange(partnerControlName, position, errorKey = 'i18n.qd.form.error.dateRange') {
|
|
16285
|
-
const validFn = (control) => {
|
|
16286
|
-
|
|
16287
|
-
|
|
16288
|
-
|
|
16289
|
-
|
|
16290
|
-
|
|
16291
|
-
|
|
16292
|
-
|
|
16293
|
-
|
|
16294
|
-
|
|
16359
|
+
const validFn = (control) => this.isRangeOrderViolated(control, partnerControlName, position, 'day') ? { dateRange: errorKey } : null;
|
|
16360
|
+
validFn.qdRevalidates = partnerControlName;
|
|
16361
|
+
return validFn;
|
|
16362
|
+
}
|
|
16363
|
+
/**
|
|
16364
|
+
* Validates that a date **and time** stays on the correct side of a sibling "range partner"
|
|
16365
|
+
* control.
|
|
16366
|
+
*
|
|
16367
|
+
* The date-time counterpart of {@link QdValidators.dateRange}: identical wiring, but the
|
|
16368
|
+
* comparison includes the time of day instead of stopping at the day. Use it for a from/to
|
|
16369
|
+
* pair of datepickers that have a `timePicker` configured — `dateRange` accepts `10:00` to
|
|
16370
|
+
* `08:00` on the same day, this one rejects it.
|
|
16371
|
+
*
|
|
16372
|
+
* Put it on both ends of the pair, each pointing at the other. A `'start'` control is invalid
|
|
16373
|
+
* when its value lies after the partner; an `'end'` control is invalid when its value lies
|
|
16374
|
+
* before the partner. Equal instants are valid, so a zero-length range passes. The comparison
|
|
16375
|
+
* is exact, which fits both picker precisions on its own: without seconds the entered values
|
|
16376
|
+
* carry `:00` seconds, with `enableSeconds` they carry the entered ones.
|
|
16377
|
+
*
|
|
16378
|
+
* Everything else behaves like {@link QdValidators.dateRange}: the partner value is read live
|
|
16379
|
+
* on every run, empty or invalid own/partner values and a missing partner control all pass,
|
|
16380
|
+
* and `qdRevalidates` keeps both ends in sync inside a `QdFormGroup` — see there for the cases
|
|
16381
|
+
* that still need a manual `updateValueAndValidity`.
|
|
16382
|
+
*
|
|
16383
|
+
* @param partnerControlName - Name of the sibling control holding the other end of the range.
|
|
16384
|
+
* @param position - `'start'` for the from-control, `'end'` for the to-control.
|
|
16385
|
+
* @param errorKey - Translation key returned when the order is violated.
|
|
16386
|
+
*
|
|
16387
|
+
* #### **Usage**
|
|
16388
|
+
* ```ts
|
|
16389
|
+
* new QdFormGroup({
|
|
16390
|
+
* from: new QdFormControl(null, QdValidators.dateTimeRange('to', 'start')),
|
|
16391
|
+
* to: new QdFormControl(null, QdValidators.dateTimeRange('from', 'end'))
|
|
16392
|
+
* });
|
|
16393
|
+
* ```
|
|
16394
|
+
*/
|
|
16395
|
+
static dateTimeRange(partnerControlName, position, errorKey = 'i18n.qd.form.error.dateTimeRange') {
|
|
16396
|
+
const validFn = (control) => this.isRangeOrderViolated(control, partnerControlName, position) ? { dateTimeRange: errorKey } : null;
|
|
16295
16397
|
validFn.qdRevalidates = partnerControlName;
|
|
16296
16398
|
return validFn;
|
|
16297
16399
|
}
|
|
16400
|
+
/**
|
|
16401
|
+
* Compares a control against its range partner. Without a `granularity` the comparison is
|
|
16402
|
+
* exact, which is what a date *and time* range needs; `'day'` ignores the time of day.
|
|
16403
|
+
*/
|
|
16404
|
+
static isRangeOrderViolated(control, partnerControlName, position, granularity) {
|
|
16405
|
+
const ownValue = control.value;
|
|
16406
|
+
const partnerValue = control.parent?.get(partnerControlName)?.value;
|
|
16407
|
+
if (!this.isValidDate(ownValue) || !this.isValidDate(partnerValue))
|
|
16408
|
+
return false;
|
|
16409
|
+
const own = moment(ownValue);
|
|
16410
|
+
const partner = moment(partnerValue);
|
|
16411
|
+
return position === 'start' ? own.isAfter(partner, granularity) : own.isBefore(partner, granularity);
|
|
16412
|
+
}
|
|
16298
16413
|
static isValidDate(value) {
|
|
16299
16414
|
return value instanceof Date && !isNaN(value.getTime());
|
|
16300
16415
|
}
|
|
@@ -17781,6 +17896,7 @@ const MARGIN_PX = 10;
|
|
|
17781
17896
|
* #### **Behavior**
|
|
17782
17897
|
* - Appears in the bottom-right corner.
|
|
17783
17898
|
* - Adapts to the QLS (e.g., stays above a PageFooter).
|
|
17899
|
+
* - Re-enters the top layer whenever a notification arrives, so it stays above dialogs opened before.
|
|
17784
17900
|
* - Behavior is configurable via `snackbarOptions` (e.g., lifetime, close button, handlers).
|
|
17785
17901
|
*
|
|
17786
17902
|
* #### **Usage**
|
|
@@ -17830,6 +17946,32 @@ class QdNotificationsSnackbarListenerDirective {
|
|
|
17830
17946
|
snackbarRef.instance.notifications$ = this.snackbarService.notifications$;
|
|
17831
17947
|
this.snackbarService.overlayRef = this._overlayRef;
|
|
17832
17948
|
this.observeSafeBottomOffset(positionStrategy);
|
|
17949
|
+
this.observeNotificationsToStayOnTop(this._overlayRef.hostElement);
|
|
17950
|
+
}
|
|
17951
|
+
/**
|
|
17952
|
+
* Raises the snackbar back above every other overlay whenever a notification arrives.
|
|
17953
|
+
*
|
|
17954
|
+
* The CDK renders overlays into the browser top layer, where the paint order follows the order
|
|
17955
|
+
* in which the overlays entered that layer and `z-index` has no effect. The snackbar overlay is
|
|
17956
|
+
* created once with this listener, so overlays opened later - a dialog and its backdrop above
|
|
17957
|
+
* all - would cover it. Re-entering the top layer with every arriving notification puts the
|
|
17958
|
+
* snackbar back on top.
|
|
17959
|
+
*
|
|
17960
|
+
* The re-entry is bound to arriving notifications, so a snackbar that is already visible - a
|
|
17961
|
+
* sticky one with `lifeTime: 0` above all - stays covered by a dialog opened afterwards until
|
|
17962
|
+
* the next notification arrives. Closing a notification leaves the top layer untouched.
|
|
17963
|
+
*/
|
|
17964
|
+
observeNotificationsToStayOnTop(host) {
|
|
17965
|
+
this.snackbarService.notifications$
|
|
17966
|
+
.pipe(startWith$1([]), pairwise(), filter$1(([before, after]) => after.length > before.length), takeUntil$1(this._destroyed$))
|
|
17967
|
+
.subscribe(() => this.raiseToTopLayer(host));
|
|
17968
|
+
}
|
|
17969
|
+
raiseToTopLayer(host) {
|
|
17970
|
+
if (!host.hasAttribute('popover'))
|
|
17971
|
+
return;
|
|
17972
|
+
if (host.matches(':popover-open'))
|
|
17973
|
+
host.hidePopover();
|
|
17974
|
+
host.showPopover();
|
|
17833
17975
|
}
|
|
17834
17976
|
observeSafeBottomOffset(strategy) {
|
|
17835
17977
|
this.safeBottomOffset$
|