@thalassic/ui 0.17.1 → 0.19.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/fesm2022/thalassic-ui-charts.mjs +18 -15
- package/fesm2022/thalassic-ui-charts.mjs.map +1 -1
- package/fesm2022/thalassic-ui.mjs +1330 -342
- package/fesm2022/thalassic-ui.mjs.map +1 -1
- package/package.json +1 -1
- package/types/thalassic-ui-charts.d.ts +3 -5
- package/types/thalassic-ui.d.ts +335 -3
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { model, input, signal, computed, booleanAttribute, Directive, InjectionToken, inject, ViewContainerRef, DestroyRef, viewChild, Component, contentChild, effect, forwardRef,
|
|
2
|
+
import { model, input, signal, computed, booleanAttribute, Directive, InjectionToken, inject, ViewContainerRef, DestroyRef, viewChild, Component, contentChild, effect, forwardRef, ElementRef, output, afterNextRender, Injectable, numberAttribute, viewChildren, contentChildren, isDevMode, untracked, TemplateRef, Renderer2, makeEnvironmentProviders } from '@angular/core';
|
|
3
3
|
import { Overlay } from '@angular/cdk/overlay';
|
|
4
|
-
import { TemplatePortal,
|
|
4
|
+
import { TemplatePortal, ComponentPortal, CdkPortalOutlet } from '@angular/cdk/portal';
|
|
5
5
|
import { takeUntilDestroyed, rxResource, toObservable } from '@angular/core/rxjs-interop';
|
|
6
|
-
import { filter, throwError, map, shareReplay } from 'rxjs';
|
|
6
|
+
import { filter, Subscription, takeUntil, throwError, map, shareReplay } from 'rxjs';
|
|
7
|
+
import { Router, ActivatedRoute, RouterLink, NavigationStart } from '@angular/router';
|
|
7
8
|
import { LocationStrategy, NgTemplateOutlet } from '@angular/common';
|
|
8
|
-
import {
|
|
9
|
+
import { ConfigurableFocusTrapFactory } from '@angular/cdk/a11y';
|
|
10
|
+
import { filter as filter$1 } from 'rxjs/operators';
|
|
9
11
|
import { CdkDialogContainer, DialogRef, Dialog as Dialog$1 } from '@angular/cdk/dialog';
|
|
12
|
+
import { Directionality } from '@angular/cdk/bidi';
|
|
10
13
|
import { format, startOfMonth, endOfMonth, eachDayOfInterval, endOfWeek, startOfWeek, subMonths, addMonths, isSameDay, isSameMonth, isToday, setMonth, subYears, addYears, getYear, getMonth, getHours, getMinutes, startOfDay, setHours, setMinutes, setYear } from 'date-fns';
|
|
11
14
|
import { HttpClient } from '@angular/common/http';
|
|
12
15
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
@@ -224,7 +227,7 @@ const TRANSPARENT_BACKDROP_CLASS = 'cdk-overlay-transparent-backdrop';
|
|
|
224
227
|
// Upper bound for how long to keep a non-reused pane alive after detach so the
|
|
225
228
|
// panel's `animate.leave` can finish. Disposes on `animationend`; this only
|
|
226
229
|
// fires when no exit animation runs (e.g. the `none` motion level).
|
|
227
|
-
const LEAVE_ANIMATION_FALLBACK_MS = 500;
|
|
230
|
+
const LEAVE_ANIMATION_FALLBACK_MS$3 = 500;
|
|
228
231
|
/**
|
|
229
232
|
* Owns the CDK-Overlay lifecycle shared by the library's connected overlay
|
|
230
233
|
* components (popover, menu, select): create/attach, dismissal wiring
|
|
@@ -366,7 +369,7 @@ class OverlayManager {
|
|
|
366
369
|
overlayRef.dispose();
|
|
367
370
|
};
|
|
368
371
|
paneElement.addEventListener('animationend', finalize);
|
|
369
|
-
const timeoutId = window.setTimeout(finalize, LEAVE_ANIMATION_FALLBACK_MS);
|
|
372
|
+
const timeoutId = window.setTimeout(finalize, LEAVE_ANIMATION_FALLBACK_MS$3);
|
|
370
373
|
}
|
|
371
374
|
_dispose() {
|
|
372
375
|
this._overlayRef?.dispose();
|
|
@@ -560,6 +563,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImpor
|
|
|
560
563
|
|
|
561
564
|
// Form control base classes
|
|
562
565
|
|
|
566
|
+
class QuerySyncDirective {
|
|
567
|
+
_router = inject(Router);
|
|
568
|
+
_route = inject(ActivatedRoute);
|
|
569
|
+
syncToUrl(param, value) {
|
|
570
|
+
void this._router.navigate([], {
|
|
571
|
+
relativeTo: this._route,
|
|
572
|
+
queryParams: { [param]: value },
|
|
573
|
+
queryParamsHandling: 'merge',
|
|
574
|
+
replaceUrl: true,
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
readParam(param) {
|
|
578
|
+
return this._route.snapshot.queryParamMap.get(param);
|
|
579
|
+
}
|
|
580
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: QuerySyncDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
581
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.1", type: QuerySyncDirective, isStandalone: true, ngImport: i0 });
|
|
582
|
+
}
|
|
583
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: QuerySyncDirective, decorators: [{
|
|
584
|
+
type: Directive
|
|
585
|
+
}] });
|
|
586
|
+
|
|
563
587
|
const DEFAULT_ALERT_CONFIG = {
|
|
564
588
|
color: 'primary',
|
|
565
589
|
label: {
|
|
@@ -882,76 +906,624 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImpor
|
|
|
882
906
|
}]
|
|
883
907
|
}], ctorParameters: () => [], propDecorators: { checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }, { type: i0.Output, args: ["checkedChange"] }], checkedColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "checkedColor", required: false }] }], checkedVariant: [{ type: i0.Input, args: [{ isSignal: true, alias: "checkedVariant", required: false }] }] } });
|
|
884
908
|
|
|
885
|
-
const
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
909
|
+
const OVERLAY_POSITION_MAP = {
|
|
910
|
+
top: {
|
|
911
|
+
originX: 'center',
|
|
912
|
+
originY: 'top',
|
|
913
|
+
overlayX: 'center',
|
|
914
|
+
overlayY: 'bottom',
|
|
915
|
+
offsetX: 0,
|
|
916
|
+
offsetY: -1,
|
|
917
|
+
},
|
|
918
|
+
right: {
|
|
919
|
+
originX: 'end',
|
|
920
|
+
originY: 'center',
|
|
921
|
+
overlayX: 'start',
|
|
922
|
+
overlayY: 'center',
|
|
923
|
+
offsetX: 1,
|
|
924
|
+
offsetY: 0,
|
|
925
|
+
},
|
|
926
|
+
bottom: {
|
|
927
|
+
originX: 'center',
|
|
928
|
+
originY: 'bottom',
|
|
929
|
+
overlayX: 'center',
|
|
930
|
+
overlayY: 'top',
|
|
931
|
+
offsetX: 1,
|
|
932
|
+
offsetY: 1,
|
|
933
|
+
},
|
|
934
|
+
left: {
|
|
935
|
+
originX: 'start',
|
|
936
|
+
originY: 'center',
|
|
937
|
+
overlayX: 'end',
|
|
938
|
+
overlayY: 'center',
|
|
939
|
+
offsetX: -1,
|
|
940
|
+
offsetY: 0,
|
|
941
|
+
},
|
|
942
|
+
'top-start': {
|
|
943
|
+
originX: 'start',
|
|
944
|
+
originY: 'top',
|
|
945
|
+
overlayX: 'start',
|
|
946
|
+
overlayY: 'bottom',
|
|
947
|
+
offsetX: 0,
|
|
948
|
+
offsetY: -1,
|
|
949
|
+
},
|
|
950
|
+
'top-end': {
|
|
951
|
+
originX: 'end',
|
|
952
|
+
originY: 'top',
|
|
953
|
+
overlayX: 'end',
|
|
954
|
+
overlayY: 'bottom',
|
|
955
|
+
offsetX: 0,
|
|
956
|
+
offsetY: -1,
|
|
957
|
+
},
|
|
958
|
+
'right-start': {
|
|
959
|
+
originX: 'end',
|
|
960
|
+
originY: 'top',
|
|
961
|
+
overlayX: 'start',
|
|
962
|
+
overlayY: 'top',
|
|
963
|
+
offsetX: 1,
|
|
964
|
+
offsetY: 0,
|
|
965
|
+
},
|
|
966
|
+
'right-end': {
|
|
967
|
+
originX: 'end',
|
|
968
|
+
originY: 'bottom',
|
|
969
|
+
overlayX: 'start',
|
|
970
|
+
overlayY: 'bottom',
|
|
971
|
+
offsetX: 1,
|
|
972
|
+
offsetY: 0,
|
|
973
|
+
},
|
|
974
|
+
'bottom-start': {
|
|
975
|
+
originX: 'start',
|
|
976
|
+
originY: 'bottom',
|
|
977
|
+
overlayX: 'start',
|
|
978
|
+
overlayY: 'top',
|
|
979
|
+
offsetX: 0,
|
|
980
|
+
offsetY: 1,
|
|
981
|
+
},
|
|
982
|
+
'bottom-end': {
|
|
983
|
+
originX: 'end',
|
|
984
|
+
originY: 'bottom',
|
|
985
|
+
overlayX: 'end',
|
|
986
|
+
overlayY: 'top',
|
|
987
|
+
offsetX: 0,
|
|
988
|
+
offsetY: 1,
|
|
989
|
+
},
|
|
990
|
+
'left-start': {
|
|
991
|
+
originX: 'start',
|
|
992
|
+
originY: 'top',
|
|
993
|
+
overlayX: 'end',
|
|
994
|
+
overlayY: 'top',
|
|
995
|
+
offsetX: -1,
|
|
996
|
+
offsetY: 0,
|
|
997
|
+
},
|
|
998
|
+
'left-end': {
|
|
999
|
+
originX: 'start',
|
|
1000
|
+
originY: 'bottom',
|
|
1001
|
+
overlayX: 'end',
|
|
1002
|
+
overlayY: 'bottom',
|
|
1003
|
+
offsetX: -1,
|
|
1004
|
+
offsetY: 0,
|
|
1005
|
+
},
|
|
1006
|
+
'top-left': {
|
|
1007
|
+
originX: 'start',
|
|
1008
|
+
originY: 'top',
|
|
1009
|
+
overlayX: 'end',
|
|
1010
|
+
overlayY: 'bottom',
|
|
1011
|
+
offsetX: -1,
|
|
1012
|
+
offsetY: -1,
|
|
1013
|
+
},
|
|
1014
|
+
'top-right': {
|
|
1015
|
+
originX: 'end',
|
|
1016
|
+
originY: 'top',
|
|
1017
|
+
overlayX: 'start',
|
|
1018
|
+
overlayY: 'bottom',
|
|
1019
|
+
offsetX: 1,
|
|
1020
|
+
offsetY: -1,
|
|
1021
|
+
},
|
|
1022
|
+
'bottom-left': {
|
|
1023
|
+
originX: 'start',
|
|
1024
|
+
originY: 'bottom',
|
|
1025
|
+
overlayX: 'end',
|
|
1026
|
+
overlayY: 'top',
|
|
1027
|
+
offsetX: -1,
|
|
1028
|
+
offsetY: 1,
|
|
1029
|
+
},
|
|
1030
|
+
'bottom-right': {
|
|
1031
|
+
originX: 'end',
|
|
1032
|
+
originY: 'bottom',
|
|
1033
|
+
overlayX: 'start',
|
|
1034
|
+
overlayY: 'top',
|
|
1035
|
+
offsetX: 1,
|
|
1036
|
+
offsetY: 1,
|
|
1037
|
+
},
|
|
889
1038
|
};
|
|
890
1039
|
|
|
891
|
-
const
|
|
892
|
-
|
|
1040
|
+
const buildOverlayPositions = (position, offset) => {
|
|
1041
|
+
const preferred = OVERLAY_POSITION_MAP[position];
|
|
1042
|
+
const rest = Object.values(OVERLAY_POSITION_MAP).filter(p => p !== preferred);
|
|
1043
|
+
const positions = [preferred, ...rest];
|
|
1044
|
+
return positions.map(position => ({
|
|
1045
|
+
...position,
|
|
1046
|
+
offsetX: Math.sign(position.offsetX ?? 0) * offset.x,
|
|
1047
|
+
offsetY: Math.sign(position.offsetY ?? 0) * offset.y,
|
|
1048
|
+
}));
|
|
1049
|
+
};
|
|
1050
|
+
|
|
1051
|
+
const DEFAULT_CONFIRM_CONFIG = {
|
|
1052
|
+
position: 'bottom',
|
|
1053
|
+
offset: { x: 0, y: 4 },
|
|
1054
|
+
confirmButton: { label: 'Confirm' },
|
|
1055
|
+
cancelButton: { label: 'Cancel', variant: 'text' },
|
|
1056
|
+
actionsAlign: 'end',
|
|
1057
|
+
};
|
|
1058
|
+
|
|
1059
|
+
const CONFIRM_CONFIG = new InjectionToken('CONFIRM_CONFIG', {
|
|
1060
|
+
factory: () => DEFAULT_CONFIRM_CONFIG,
|
|
893
1061
|
});
|
|
894
1062
|
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
1063
|
+
/**
|
|
1064
|
+
* Presentational contents of a confirm dialog: an optional title, a message,
|
|
1065
|
+
* and cancel / confirm action buttons. Shared by the declarative `tls-confirm`
|
|
1066
|
+
* component and the imperative `ConfirmService`; it renders the UI and emits
|
|
1067
|
+
* `confirmed` / `cancelled`, but owns no overlay lifecycle.
|
|
1068
|
+
*/
|
|
1069
|
+
class ConfirmPanel {
|
|
1070
|
+
static _counter = 0;
|
|
1071
|
+
// Injections
|
|
1072
|
+
_elementRef = inject(ElementRef);
|
|
1073
|
+
_config = inject(CONFIRM_CONFIG);
|
|
1074
|
+
_buttonConfig = inject(BUTTON_CONFIG);
|
|
1075
|
+
// Inputs
|
|
1076
|
+
title = input(undefined, ...(ngDevMode ? [{ debugName: "title" }] : []));
|
|
1077
|
+
message = input.required(...(ngDevMode ? [{ debugName: "message" }] : []));
|
|
1078
|
+
confirm = input(undefined, ...(ngDevMode ? [{ debugName: "confirm" }] : []));
|
|
1079
|
+
cancel = input(undefined, ...(ngDevMode ? [{ debugName: "cancel" }] : []));
|
|
1080
|
+
ariaLabel = input(undefined, ...(ngDevMode ? [{ debugName: "ariaLabel" }] : []));
|
|
1081
|
+
/** Whether the panel is a focus-trapped modal (`aria-modal="true"`) rather than an anchored popover. */
|
|
1082
|
+
modal = input(false, ...(ngDevMode ? [{ debugName: "modal" }] : []));
|
|
1083
|
+
actionsAlign = input(this._config.actionsAlign, ...(ngDevMode ? [{ debugName: "actionsAlign" }] : []));
|
|
1084
|
+
// Outputs
|
|
1085
|
+
confirmed = output();
|
|
1086
|
+
cancelled = output();
|
|
1087
|
+
// State
|
|
1088
|
+
id = `tls-confirm-${++ConfirmPanel._counter}`;
|
|
1089
|
+
titleId = `${this.id}-title`;
|
|
1090
|
+
messageId = `${this.id}-message`;
|
|
1091
|
+
// Computed
|
|
1092
|
+
resolvedConfirm = computed(() => this._resolve(this.confirm(), this._config.confirmButton), ...(ngDevMode ? [{ debugName: "resolvedConfirm" }] : []));
|
|
1093
|
+
resolvedCancel = computed(() => this._resolve(this.cancel(), this._config.cancelButton), ...(ngDevMode ? [{ debugName: "resolvedCancel" }] : []));
|
|
1094
|
+
actionsClasses = computed(() => [
|
|
1095
|
+
'tls-confirm__actions',
|
|
1096
|
+
`tls-confirm__actions--${this.actionsAlign()}`,
|
|
1097
|
+
], ...(ngDevMode ? [{ debugName: "actionsClasses" }] : []));
|
|
1098
|
+
// Constructor
|
|
1099
|
+
constructor() {
|
|
1100
|
+
// Move focus to the primary action once the panel has rendered, so the
|
|
1101
|
+
// dialog is immediately operable from the keyboard.
|
|
1102
|
+
afterNextRender(() => this._focusConfirm());
|
|
901
1103
|
}
|
|
902
|
-
|
|
903
|
-
|
|
1104
|
+
// Private methods
|
|
1105
|
+
_resolve(button, slotDefault) {
|
|
1106
|
+
const source = button ?? {};
|
|
1107
|
+
return {
|
|
1108
|
+
label: source.label ?? slotDefault.label,
|
|
1109
|
+
color: source.color ?? slotDefault.color ?? this._buttonConfig.color,
|
|
1110
|
+
variant: source.variant ?? slotDefault.variant ?? this._buttonConfig.variant,
|
|
1111
|
+
size: source.size ?? slotDefault.size ?? this._buttonConfig.size,
|
|
1112
|
+
icon: source.icon ?? slotDefault.icon ?? false,
|
|
1113
|
+
rounded: source.rounded ?? slotDefault.rounded ?? false,
|
|
1114
|
+
fluid: source.fluid ?? slotDefault.fluid ?? false,
|
|
1115
|
+
disabled: source.disabled ?? slotDefault.disabled ?? false,
|
|
1116
|
+
};
|
|
904
1117
|
}
|
|
905
|
-
|
|
906
|
-
|
|
1118
|
+
_focusConfirm() {
|
|
1119
|
+
const host = this._elementRef.nativeElement;
|
|
1120
|
+
const buttons = host.querySelectorAll('button');
|
|
1121
|
+
const confirmButton = buttons.item(buttons.length - 1);
|
|
1122
|
+
if (confirmButton)
|
|
1123
|
+
confirmButton.focus();
|
|
1124
|
+
}
|
|
1125
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ConfirmPanel, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1126
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.1", type: ConfirmPanel, isStandalone: true, selector: "tls-confirm-panel", inputs: { title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: true, transformFunction: null }, confirm: { classPropertyName: "confirm", publicName: "confirm", isSignal: true, isRequired: false, transformFunction: null }, cancel: { classPropertyName: "cancel", publicName: "cancel", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, modal: { classPropertyName: "modal", publicName: "modal", isSignal: true, isRequired: false, transformFunction: null }, actionsAlign: { classPropertyName: "actionsAlign", publicName: "actionsAlign", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { confirmed: "confirmed", cancelled: "cancelled" }, host: { attributes: { "role": "alertdialog", "animate.enter": "tls-confirm--enter", "animate.leave": "tls-confirm--leave" }, properties: { "attr.aria-modal": "modal() ? \"true\" : \"false\"", "id": "id", "attr.aria-labelledby": "title() ? titleId : null", "attr.aria-describedby": "messageId", "attr.aria-label": "ariaLabel() ?? null" }, classAttribute: "tls-confirm" }, ngImport: i0, template: `
|
|
1127
|
+
@if (title()) {
|
|
1128
|
+
<h2 class="tls-confirm__title" [id]="titleId">{{ title() }}</h2>
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
<p class="tls-confirm__message" [id]="messageId">{{ message() }}</p>
|
|
1132
|
+
|
|
1133
|
+
<div [class]="actionsClasses()">
|
|
1134
|
+
<tls-button
|
|
1135
|
+
[label]="resolvedCancel().label"
|
|
1136
|
+
[color]="resolvedCancel().color"
|
|
1137
|
+
[variant]="resolvedCancel().variant"
|
|
1138
|
+
[size]="resolvedCancel().size"
|
|
1139
|
+
[icon]="resolvedCancel().icon"
|
|
1140
|
+
[rounded]="resolvedCancel().rounded"
|
|
1141
|
+
[fluid]="resolvedCancel().fluid"
|
|
1142
|
+
[disabled]="resolvedCancel().disabled"
|
|
1143
|
+
(click)="cancelled.emit()"
|
|
1144
|
+
></tls-button>
|
|
1145
|
+
|
|
1146
|
+
<tls-button
|
|
1147
|
+
[label]="resolvedConfirm().label"
|
|
1148
|
+
[color]="resolvedConfirm().color"
|
|
1149
|
+
[variant]="resolvedConfirm().variant"
|
|
1150
|
+
[size]="resolvedConfirm().size"
|
|
1151
|
+
[icon]="resolvedConfirm().icon"
|
|
1152
|
+
[rounded]="resolvedConfirm().rounded"
|
|
1153
|
+
[fluid]="resolvedConfirm().fluid"
|
|
1154
|
+
[disabled]="resolvedConfirm().disabled"
|
|
1155
|
+
(click)="confirmed.emit()"
|
|
1156
|
+
></tls-button>
|
|
1157
|
+
</div>
|
|
1158
|
+
`, isInline: true, dependencies: [{ kind: "component", type: Button, selector: "tls-button", inputs: ["label", "ariaLabel", "ariaLabelledby", "type", "href", "tabindex"] }] });
|
|
907
1159
|
}
|
|
908
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type:
|
|
1160
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ConfirmPanel, decorators: [{
|
|
909
1161
|
type: Component,
|
|
910
|
-
args: [{
|
|
911
|
-
|
|
1162
|
+
args: [{
|
|
1163
|
+
selector: 'tls-confirm-panel',
|
|
1164
|
+
imports: [Button],
|
|
1165
|
+
template: `
|
|
1166
|
+
@if (title()) {
|
|
1167
|
+
<h2 class="tls-confirm__title" [id]="titleId">{{ title() }}</h2>
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
<p class="tls-confirm__message" [id]="messageId">{{ message() }}</p>
|
|
1171
|
+
|
|
1172
|
+
<div [class]="actionsClasses()">
|
|
1173
|
+
<tls-button
|
|
1174
|
+
[label]="resolvedCancel().label"
|
|
1175
|
+
[color]="resolvedCancel().color"
|
|
1176
|
+
[variant]="resolvedCancel().variant"
|
|
1177
|
+
[size]="resolvedCancel().size"
|
|
1178
|
+
[icon]="resolvedCancel().icon"
|
|
1179
|
+
[rounded]="resolvedCancel().rounded"
|
|
1180
|
+
[fluid]="resolvedCancel().fluid"
|
|
1181
|
+
[disabled]="resolvedCancel().disabled"
|
|
1182
|
+
(click)="cancelled.emit()"
|
|
1183
|
+
></tls-button>
|
|
1184
|
+
|
|
1185
|
+
<tls-button
|
|
1186
|
+
[label]="resolvedConfirm().label"
|
|
1187
|
+
[color]="resolvedConfirm().color"
|
|
1188
|
+
[variant]="resolvedConfirm().variant"
|
|
1189
|
+
[size]="resolvedConfirm().size"
|
|
1190
|
+
[icon]="resolvedConfirm().icon"
|
|
1191
|
+
[rounded]="resolvedConfirm().rounded"
|
|
1192
|
+
[fluid]="resolvedConfirm().fluid"
|
|
1193
|
+
[disabled]="resolvedConfirm().disabled"
|
|
1194
|
+
(click)="confirmed.emit()"
|
|
1195
|
+
></tls-button>
|
|
1196
|
+
</div>
|
|
1197
|
+
`,
|
|
1198
|
+
host: {
|
|
1199
|
+
class: 'tls-confirm',
|
|
1200
|
+
role: 'alertdialog',
|
|
1201
|
+
'[attr.aria-modal]': 'modal() ? "true" : "false"',
|
|
1202
|
+
'[id]': 'id',
|
|
1203
|
+
'[attr.aria-labelledby]': 'title() ? titleId : null',
|
|
1204
|
+
'[attr.aria-describedby]': 'messageId',
|
|
1205
|
+
'[attr.aria-label]': 'ariaLabel() ?? null',
|
|
1206
|
+
'animate.enter': 'tls-confirm--enter',
|
|
1207
|
+
'animate.leave': 'tls-confirm--leave',
|
|
1208
|
+
},
|
|
1209
|
+
}]
|
|
1210
|
+
}], ctorParameters: () => [], propDecorators: { title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], message: [{ type: i0.Input, args: [{ isSignal: true, alias: "message", required: true }] }], confirm: [{ type: i0.Input, args: [{ isSignal: true, alias: "confirm", required: false }] }], cancel: [{ type: i0.Input, args: [{ isSignal: true, alias: "cancel", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], modal: [{ type: i0.Input, args: [{ isSignal: true, alias: "modal", required: false }] }], actionsAlign: [{ type: i0.Input, args: [{ isSignal: true, alias: "actionsAlign", required: false }] }], confirmed: [{ type: i0.Output, args: ["confirmed"] }], cancelled: [{ type: i0.Output, args: ["cancelled"] }] } });
|
|
912
1211
|
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
1212
|
+
/**
|
|
1213
|
+
* Declarative confirm dialog anchored to a trigger. Sits in the template
|
|
1214
|
+
* alongside its trigger and is driven imperatively via {@link open} /
|
|
1215
|
+
* {@link toggle}; resolves through the `confirmed` / `cancelled` outputs.
|
|
1216
|
+
* Dismissing via backdrop or Escape counts as `cancelled`. For promise-based
|
|
1217
|
+
* flows in TypeScript, use `ConfirmService` instead.
|
|
1218
|
+
*/
|
|
1219
|
+
class Confirm {
|
|
1220
|
+
// Injections
|
|
1221
|
+
_config = inject(CONFIRM_CONFIG);
|
|
1222
|
+
_overlay = createOverlayManager();
|
|
1223
|
+
_templateRef = viewChild.required('content');
|
|
1224
|
+
// Inputs
|
|
1225
|
+
title = input(undefined, ...(ngDevMode ? [{ debugName: "title" }] : []));
|
|
1226
|
+
message = input.required(...(ngDevMode ? [{ debugName: "message" }] : []));
|
|
1227
|
+
confirm = input(undefined, ...(ngDevMode ? [{ debugName: "confirm" }] : []));
|
|
1228
|
+
cancel = input(undefined, ...(ngDevMode ? [{ debugName: "cancel" }] : []));
|
|
1229
|
+
actionsAlign = input(this._config.actionsAlign, ...(ngDevMode ? [{ debugName: "actionsAlign" }] : []));
|
|
1230
|
+
ariaLabel = input(undefined, ...(ngDevMode ? [{ debugName: "ariaLabel" }] : []));
|
|
1231
|
+
position = input(this._config.position, ...(ngDevMode ? [{ debugName: "position" }] : []));
|
|
1232
|
+
offset = input(this._config.offset, ...(ngDevMode ? [{ debugName: "offset" }] : []));
|
|
1233
|
+
// Outputs
|
|
1234
|
+
confirmed = output();
|
|
1235
|
+
cancelled = output();
|
|
1236
|
+
// State
|
|
1237
|
+
isOpen = this._overlay.isOpen;
|
|
1238
|
+
// Tracks whether the current session ended through an explicit action, so a
|
|
1239
|
+
// backdrop / Escape dismissal is reported as a cancellation exactly once.
|
|
1240
|
+
_resolved = false;
|
|
1241
|
+
// Element focused before opening, restored on close so keyboard focus returns
|
|
1242
|
+
// to the trigger rather than being lost when the panel is removed.
|
|
1243
|
+
_previouslyFocused = null;
|
|
1244
|
+
// Computed
|
|
1245
|
+
_positions = computed(() => buildOverlayPositions(this.position(), this.offset()), ...(ngDevMode ? [{ debugName: "_positions" }] : []));
|
|
1246
|
+
// Public methods
|
|
1247
|
+
open(trigger) {
|
|
1248
|
+
const origin = trigger instanceof MouseEvent ? trigger.currentTarget : trigger;
|
|
1249
|
+
this._resolved = false;
|
|
1250
|
+
this._previouslyFocused = document.activeElement;
|
|
1251
|
+
this._overlay.open({
|
|
1252
|
+
content: this._templateRef(),
|
|
1253
|
+
origin,
|
|
1254
|
+
positions: this._positions(),
|
|
1255
|
+
onClose: () => this._onClose(),
|
|
935
1256
|
});
|
|
936
1257
|
}
|
|
937
|
-
|
|
938
|
-
this.
|
|
1258
|
+
close() {
|
|
1259
|
+
this._overlay.close();
|
|
939
1260
|
}
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
}
|
|
954
|
-
|
|
1261
|
+
toggle(trigger) {
|
|
1262
|
+
if (this.isOpen()) {
|
|
1263
|
+
this.close();
|
|
1264
|
+
}
|
|
1265
|
+
else {
|
|
1266
|
+
this.open(trigger);
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
// Protected methods
|
|
1270
|
+
onConfirm() {
|
|
1271
|
+
this._resolved = true;
|
|
1272
|
+
this.confirmed.emit();
|
|
1273
|
+
this.close();
|
|
1274
|
+
}
|
|
1275
|
+
onCancel() {
|
|
1276
|
+
this._resolved = true;
|
|
1277
|
+
this.cancelled.emit();
|
|
1278
|
+
this.close();
|
|
1279
|
+
}
|
|
1280
|
+
// Private methods
|
|
1281
|
+
_onClose() {
|
|
1282
|
+
if (this._previouslyFocused)
|
|
1283
|
+
this._previouslyFocused.focus();
|
|
1284
|
+
if (this._resolved)
|
|
1285
|
+
return;
|
|
1286
|
+
this.cancelled.emit();
|
|
1287
|
+
}
|
|
1288
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Confirm, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1289
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.2.1", type: Confirm, isStandalone: true, selector: "tls-confirm", inputs: { title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: true, transformFunction: null }, confirm: { classPropertyName: "confirm", publicName: "confirm", isSignal: true, isRequired: false, transformFunction: null }, cancel: { classPropertyName: "cancel", publicName: "cancel", isSignal: true, isRequired: false, transformFunction: null }, actionsAlign: { classPropertyName: "actionsAlign", publicName: "actionsAlign", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null }, offset: { classPropertyName: "offset", publicName: "offset", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { confirmed: "confirmed", cancelled: "cancelled" }, viewQueries: [{ propertyName: "_templateRef", first: true, predicate: ["content"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
1290
|
+
<ng-template #content>
|
|
1291
|
+
<tls-confirm-panel
|
|
1292
|
+
[title]="title()"
|
|
1293
|
+
[message]="message()"
|
|
1294
|
+
[confirm]="confirm()"
|
|
1295
|
+
[cancel]="cancel()"
|
|
1296
|
+
[actionsAlign]="actionsAlign()"
|
|
1297
|
+
[ariaLabel]="ariaLabel()"
|
|
1298
|
+
(confirmed)="onConfirm()"
|
|
1299
|
+
(cancelled)="onCancel()"
|
|
1300
|
+
></tls-confirm-panel>
|
|
1301
|
+
</ng-template>
|
|
1302
|
+
`, isInline: true, dependencies: [{ kind: "component", type: ConfirmPanel, selector: "tls-confirm-panel", inputs: ["title", "message", "confirm", "cancel", "ariaLabel", "modal", "actionsAlign"], outputs: ["confirmed", "cancelled"] }] });
|
|
1303
|
+
}
|
|
1304
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Confirm, decorators: [{
|
|
1305
|
+
type: Component,
|
|
1306
|
+
args: [{
|
|
1307
|
+
selector: 'tls-confirm',
|
|
1308
|
+
imports: [ConfirmPanel],
|
|
1309
|
+
template: `
|
|
1310
|
+
<ng-template #content>
|
|
1311
|
+
<tls-confirm-panel
|
|
1312
|
+
[title]="title()"
|
|
1313
|
+
[message]="message()"
|
|
1314
|
+
[confirm]="confirm()"
|
|
1315
|
+
[cancel]="cancel()"
|
|
1316
|
+
[actionsAlign]="actionsAlign()"
|
|
1317
|
+
[ariaLabel]="ariaLabel()"
|
|
1318
|
+
(confirmed)="onConfirm()"
|
|
1319
|
+
(cancelled)="onCancel()"
|
|
1320
|
+
></tls-confirm-panel>
|
|
1321
|
+
</ng-template>
|
|
1322
|
+
`,
|
|
1323
|
+
}]
|
|
1324
|
+
}], propDecorators: { _templateRef: [{ type: i0.ViewChild, args: ['content', { isSignal: true }] }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], message: [{ type: i0.Input, args: [{ isSignal: true, alias: "message", required: true }] }], confirm: [{ type: i0.Input, args: [{ isSignal: true, alias: "confirm", required: false }] }], cancel: [{ type: i0.Input, args: [{ isSignal: true, alias: "cancel", required: false }] }], actionsAlign: [{ type: i0.Input, args: [{ isSignal: true, alias: "actionsAlign", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], offset: [{ type: i0.Input, args: [{ isSignal: true, alias: "offset", required: false }] }], confirmed: [{ type: i0.Output, args: ["confirmed"] }], cancelled: [{ type: i0.Output, args: ["cancelled"] }] } });
|
|
1325
|
+
|
|
1326
|
+
// Upper bound for how long to keep a detached confirm pane alive so its
|
|
1327
|
+
// `animate.leave` can finish. Disposes on `animationend`; this timeout only
|
|
1328
|
+
// fires when no exit animation runs (e.g. the `none` motion level).
|
|
1329
|
+
const LEAVE_ANIMATION_FALLBACK_MS$2 = 500;
|
|
1330
|
+
// Dimmed backdrop behind a centered modal confirm. Shared with `tls-dialog` so
|
|
1331
|
+
// the two modal surfaces render an identical scrim.
|
|
1332
|
+
const MODAL_BACKDROP_CLASS = 'tls-dialog-backdrop';
|
|
1333
|
+
|
|
1334
|
+
/**
|
|
1335
|
+
* Imperative confirm dialog for `await`-style flows: opens a dialog and resolves
|
|
1336
|
+
* `true` on confirm, `false` on cancel / backdrop / Escape. Anchors to the
|
|
1337
|
+
* `trigger` when given, otherwise opens as a centered modal. For a template-driven
|
|
1338
|
+
* anchored equivalent, use the `tls-confirm` component.
|
|
1339
|
+
*/
|
|
1340
|
+
class ConfirmService {
|
|
1341
|
+
// Injections
|
|
1342
|
+
_overlay = inject(Overlay);
|
|
1343
|
+
_focusTrapFactory = inject(ConfigurableFocusTrapFactory);
|
|
1344
|
+
_router = inject(Router, { optional: true });
|
|
1345
|
+
_config = inject(CONFIRM_CONFIG);
|
|
1346
|
+
// Public methods
|
|
1347
|
+
confirm(options) {
|
|
1348
|
+
const trigger = options.trigger;
|
|
1349
|
+
const modal = !trigger;
|
|
1350
|
+
const overlayRef = modal
|
|
1351
|
+
? this._createModalOverlay()
|
|
1352
|
+
: this._createAnchoredOverlay(trigger, options);
|
|
1353
|
+
const panelRef = overlayRef.attach(new ComponentPortal(ConfirmPanel));
|
|
1354
|
+
this._applyOptions(panelRef, options, modal);
|
|
1355
|
+
return this._wire(overlayRef, panelRef, modal);
|
|
1356
|
+
}
|
|
1357
|
+
// Private methods
|
|
1358
|
+
_createAnchoredOverlay(trigger, options) {
|
|
1359
|
+
const origin = trigger instanceof MouseEvent ? trigger.currentTarget : trigger;
|
|
1360
|
+
const positionStrategy = this._overlay
|
|
1361
|
+
.position()
|
|
1362
|
+
.flexibleConnectedTo(origin)
|
|
1363
|
+
.withPositions(buildOverlayPositions(options.position ?? this._config.position, options.offset ?? this._config.offset));
|
|
1364
|
+
return this._overlay.create({
|
|
1365
|
+
positionStrategy,
|
|
1366
|
+
scrollStrategy: this._overlay.scrollStrategies.reposition(),
|
|
1367
|
+
hasBackdrop: true,
|
|
1368
|
+
backdropClass: 'cdk-overlay-transparent-backdrop',
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
_createModalOverlay() {
|
|
1372
|
+
const positionStrategy = this._overlay
|
|
1373
|
+
.position()
|
|
1374
|
+
.global()
|
|
1375
|
+
.centerHorizontally()
|
|
1376
|
+
.centerVertically();
|
|
1377
|
+
return this._overlay.create({
|
|
1378
|
+
positionStrategy,
|
|
1379
|
+
scrollStrategy: this._overlay.scrollStrategies.block(),
|
|
1380
|
+
hasBackdrop: true,
|
|
1381
|
+
backdropClass: MODAL_BACKDROP_CLASS,
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
_applyOptions(panelRef, options, modal) {
|
|
1385
|
+
panelRef.setInput('message', options.message);
|
|
1386
|
+
panelRef.setInput('title', options.title);
|
|
1387
|
+
panelRef.setInput('confirm', options.confirm);
|
|
1388
|
+
panelRef.setInput('cancel', options.cancel);
|
|
1389
|
+
panelRef.setInput('actionsAlign', options.actionsAlign ?? this._config.actionsAlign);
|
|
1390
|
+
panelRef.setInput('ariaLabel', options.ariaLabel);
|
|
1391
|
+
panelRef.setInput('modal', modal);
|
|
1392
|
+
}
|
|
1393
|
+
_wire(overlayRef, panelRef, modal) {
|
|
1394
|
+
// Capture the pre-open focus so it can be restored on dismissal. The panel
|
|
1395
|
+
// moves initial focus to the primary action; a modal additionally traps
|
|
1396
|
+
// focus for its lifetime, so the trap only constrains tabbing.
|
|
1397
|
+
const previouslyFocused = document.activeElement;
|
|
1398
|
+
const focusTrap = modal
|
|
1399
|
+
? this._focusTrapFactory.create(overlayRef.overlayElement)
|
|
1400
|
+
: null;
|
|
1401
|
+
return new Promise(resolve => {
|
|
1402
|
+
const subscriptions = new Subscription();
|
|
1403
|
+
const settle = (result) => {
|
|
1404
|
+
subscriptions.unsubscribe();
|
|
1405
|
+
if (focusTrap)
|
|
1406
|
+
focusTrap.destroy();
|
|
1407
|
+
this._dismiss(overlayRef);
|
|
1408
|
+
if (previouslyFocused)
|
|
1409
|
+
previouslyFocused.focus();
|
|
1410
|
+
resolve(result);
|
|
1411
|
+
};
|
|
1412
|
+
subscriptions.add(panelRef.instance.confirmed.subscribe(() => settle(true)));
|
|
1413
|
+
subscriptions.add(panelRef.instance.cancelled.subscribe(() => settle(false)));
|
|
1414
|
+
subscriptions.add(overlayRef.backdropClick().subscribe(() => settle(false)));
|
|
1415
|
+
subscriptions.add(overlayRef
|
|
1416
|
+
.keydownEvents()
|
|
1417
|
+
.pipe(filter$1(event => event.key === 'Escape'))
|
|
1418
|
+
.subscribe(() => settle(false)));
|
|
1419
|
+
// The overlay is not tied to a component, so a route change would leave it
|
|
1420
|
+
// orphaned over the next page; dismiss it (as a cancellation) on navigation.
|
|
1421
|
+
if (this._router) {
|
|
1422
|
+
subscriptions.add(this._router.events
|
|
1423
|
+
.pipe(filter$1(event => event instanceof NavigationStart))
|
|
1424
|
+
.subscribe(() => settle(false)));
|
|
1425
|
+
}
|
|
1426
|
+
});
|
|
1427
|
+
}
|
|
1428
|
+
// Detaches the overlay so Angular's `animate.leave` plays the exit animation,
|
|
1429
|
+
// then disposes the pane once that animation finishes.
|
|
1430
|
+
_dismiss(overlayRef) {
|
|
1431
|
+
overlayRef.detach();
|
|
1432
|
+
const paneElement = overlayRef.overlayElement;
|
|
1433
|
+
if (!paneElement) {
|
|
1434
|
+
overlayRef.dispose();
|
|
1435
|
+
return;
|
|
1436
|
+
}
|
|
1437
|
+
let settled = false;
|
|
1438
|
+
const finalize = () => {
|
|
1439
|
+
if (settled)
|
|
1440
|
+
return;
|
|
1441
|
+
settled = true;
|
|
1442
|
+
window.clearTimeout(timeoutId);
|
|
1443
|
+
paneElement.removeEventListener('animationend', finalize);
|
|
1444
|
+
overlayRef.dispose();
|
|
1445
|
+
};
|
|
1446
|
+
paneElement.addEventListener('animationend', finalize);
|
|
1447
|
+
const timeoutId = window.setTimeout(finalize, LEAVE_ANIMATION_FALLBACK_MS$2);
|
|
1448
|
+
}
|
|
1449
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ConfirmService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1450
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ConfirmService, providedIn: 'root' });
|
|
1451
|
+
}
|
|
1452
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ConfirmService, decorators: [{
|
|
1453
|
+
type: Injectable,
|
|
1454
|
+
args: [{ providedIn: 'root' }]
|
|
1455
|
+
}] });
|
|
1456
|
+
|
|
1457
|
+
const DEFAULT_DIALOG_CONFIG = {
|
|
1458
|
+
size: 'md',
|
|
1459
|
+
closeable: true,
|
|
1460
|
+
backdropClose: true,
|
|
1461
|
+
};
|
|
1462
|
+
|
|
1463
|
+
const DIALOG_CONFIG = new InjectionToken('DIALOG_CONFIG', {
|
|
1464
|
+
factory: () => DEFAULT_DIALOG_CONFIG,
|
|
1465
|
+
});
|
|
1466
|
+
|
|
1467
|
+
class Dialog extends CdkDialogContainer {
|
|
1468
|
+
_tlsConfig = inject(DIALOG_CONFIG);
|
|
1469
|
+
_dialogRef = inject(DialogRef);
|
|
1470
|
+
hostClasses = ['tls-dialog', `tls-dialog--${this._tlsConfig.size}`];
|
|
1471
|
+
get config() {
|
|
1472
|
+
return this._tlsConfig;
|
|
1473
|
+
}
|
|
1474
|
+
close() {
|
|
1475
|
+
this._dialogRef.close();
|
|
1476
|
+
}
|
|
1477
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Dialog, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1478
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.1", type: Dialog, isStandalone: true, selector: "tls-dialog", host: { properties: { "class": "hostClasses" } }, usesInheritance: true, ngImport: i0, template: "<ng-template cdkPortalOutlet />\n@if (config.closeable) {\n <button class=\"tls-dialog__close\" type=\"button\" aria-label=\"Close dialog\" (click)=\"close()\">\n <svg viewBox=\"0 0 10 10\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" aria-hidden=\"true\">\n <path d=\"M1 1L9 9M9 1L1 9\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" />\n </svg>\n </button>\n}\n", dependencies: [{ kind: "directive", type: CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }] });
|
|
1479
|
+
}
|
|
1480
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Dialog, decorators: [{
|
|
1481
|
+
type: Component,
|
|
1482
|
+
args: [{ selector: 'tls-dialog', imports: [CdkPortalOutlet], host: { '[class]': 'hostClasses' }, template: "<ng-template cdkPortalOutlet />\n@if (config.closeable) {\n <button class=\"tls-dialog__close\" type=\"button\" aria-label=\"Close dialog\" (click)=\"close()\">\n <svg viewBox=\"0 0 10 10\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" aria-hidden=\"true\">\n <path d=\"M1 1L9 9M9 1L1 9\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" />\n </svg>\n </button>\n}\n" }]
|
|
1483
|
+
}] });
|
|
1484
|
+
|
|
1485
|
+
class DialogService {
|
|
1486
|
+
_dialog = inject(Dialog$1);
|
|
1487
|
+
_config = inject(DIALOG_CONFIG);
|
|
1488
|
+
open(component, config) {
|
|
1489
|
+
const resolvedConfig = {
|
|
1490
|
+
size: config?.size ?? this._config.size,
|
|
1491
|
+
closeable: config?.closeable ?? this._config.closeable,
|
|
1492
|
+
backdropClose: config?.backdropClose ?? this._config.backdropClose,
|
|
1493
|
+
};
|
|
1494
|
+
return this._dialog.open(component, {
|
|
1495
|
+
container: {
|
|
1496
|
+
type: Dialog,
|
|
1497
|
+
providers: () => [{ provide: DIALOG_CONFIG, useValue: resolvedConfig }],
|
|
1498
|
+
},
|
|
1499
|
+
hasBackdrop: true,
|
|
1500
|
+
backdropClass: 'tls-dialog-backdrop',
|
|
1501
|
+
disableClose: !resolvedConfig.backdropClose,
|
|
1502
|
+
role: config?.role ?? 'dialog',
|
|
1503
|
+
ariaLabel: config?.ariaLabel ?? null,
|
|
1504
|
+
ariaLabelledBy: config?.ariaLabelledBy ?? null,
|
|
1505
|
+
ariaDescribedBy: config?.ariaDescribedBy ?? null,
|
|
1506
|
+
data: config?.data,
|
|
1507
|
+
});
|
|
1508
|
+
}
|
|
1509
|
+
closeAll() {
|
|
1510
|
+
this._dialog.closeAll();
|
|
1511
|
+
}
|
|
1512
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: DialogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1513
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: DialogService, providedIn: 'root' });
|
|
1514
|
+
}
|
|
1515
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: DialogService, decorators: [{
|
|
1516
|
+
type: Injectable,
|
|
1517
|
+
args: [{ providedIn: 'root' }]
|
|
1518
|
+
}] });
|
|
1519
|
+
|
|
1520
|
+
const DEFAULT_DIVIDER_CONFIG = {
|
|
1521
|
+
orientation: 'horizontal',
|
|
1522
|
+
position: 'center',
|
|
1523
|
+
variant: 'solid',
|
|
1524
|
+
flush: false,
|
|
1525
|
+
};
|
|
1526
|
+
|
|
955
1527
|
const DIVIDER_CONFIG = new InjectionToken('DIVIDER_CONFIG', {
|
|
956
1528
|
factory: () => DEFAULT_DIVIDER_CONFIG,
|
|
957
1529
|
});
|
|
@@ -984,6 +1556,231 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImpor
|
|
|
984
1556
|
}, template: "<span class=\"tls-divider-line tls-divider-line--start\"></span>\n<div class=\"tls-divider-content\">\n <ng-content></ng-content>\n</div>\n<span class=\"tls-divider-line tls-divider-line--end\"></span>\n" }]
|
|
985
1557
|
}], propDecorators: { orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], flush: [{ type: i0.Input, args: [{ isSignal: true, alias: "flush", required: false }] }] } });
|
|
986
1558
|
|
|
1559
|
+
// Upper bound for how long to keep the drawer alive after a close is requested so
|
|
1560
|
+
// its slide-out (`--leave`) animation can finish before disposal. The `animationend`
|
|
1561
|
+
// listener disposes early; this fallback covers the case where no exit animation
|
|
1562
|
+
// runs (e.g. the `none` motion level, where nothing is emitted).
|
|
1563
|
+
const LEAVE_ANIMATION_FALLBACK_MS$1 = 500;
|
|
1564
|
+
// Named size tokens, used to tell a preset apart from a custom CSS-length string.
|
|
1565
|
+
const DRAWER_NAMED_SIZES = ['sm', 'md', 'lg', 'full'];
|
|
1566
|
+
|
|
1567
|
+
const DEFAULT_DRAWER_CONFIG = {
|
|
1568
|
+
side: 'end',
|
|
1569
|
+
size: 'md',
|
|
1570
|
+
closeable: true,
|
|
1571
|
+
backdropClose: true,
|
|
1572
|
+
rounded: false,
|
|
1573
|
+
};
|
|
1574
|
+
|
|
1575
|
+
const DRAWER_CONFIG = new InjectionToken('DRAWER_CONFIG', {
|
|
1576
|
+
factory: () => DEFAULT_DRAWER_CONFIG,
|
|
1577
|
+
});
|
|
1578
|
+
|
|
1579
|
+
class Drawer extends CdkDialogContainer {
|
|
1580
|
+
// Injections
|
|
1581
|
+
_tlsConfig = inject(DRAWER_CONFIG);
|
|
1582
|
+
_dialogRef = inject(DialogRef);
|
|
1583
|
+
// State
|
|
1584
|
+
_state = signal('enter', ...(ngDevMode ? [{ debugName: "_state" }] : []));
|
|
1585
|
+
_closing = false;
|
|
1586
|
+
// Computed
|
|
1587
|
+
hostClasses = computed(() => {
|
|
1588
|
+
const classes = [
|
|
1589
|
+
'tls-drawer',
|
|
1590
|
+
`tls-drawer--${this._tlsConfig.side}`,
|
|
1591
|
+
`tls-drawer--${this._sizeClass()}`,
|
|
1592
|
+
`tls-drawer--${this._state()}`,
|
|
1593
|
+
];
|
|
1594
|
+
if (this._tlsConfig.rounded)
|
|
1595
|
+
classes.push('tls-drawer--rounded');
|
|
1596
|
+
return classes;
|
|
1597
|
+
}, ...(ngDevMode ? [{ debugName: "hostClasses" }] : []));
|
|
1598
|
+
// Accessors
|
|
1599
|
+
get config() {
|
|
1600
|
+
return this._tlsConfig;
|
|
1601
|
+
}
|
|
1602
|
+
// The custom CSS length applied inline when `size` is not a named token, else
|
|
1603
|
+
// `null` so the attribute is omitted and the size modifier class takes over.
|
|
1604
|
+
get customSize() {
|
|
1605
|
+
return this._isNamedSize(this._tlsConfig.size) ? null : this._tlsConfig.size;
|
|
1606
|
+
}
|
|
1607
|
+
// Public methods
|
|
1608
|
+
// Plays the slide-out animation, then disposes the overlay once it finishes.
|
|
1609
|
+
// Routed through here for every dismissal path (close button, backdrop, Escape)
|
|
1610
|
+
// because `DialogRef.close()` disposes synchronously, which would skip the exit.
|
|
1611
|
+
animatedClose(result) {
|
|
1612
|
+
if (this._closing)
|
|
1613
|
+
return;
|
|
1614
|
+
this._closing = true;
|
|
1615
|
+
this._state.set('leave');
|
|
1616
|
+
this._afterLeaveAnimation(() => this._dialogRef.close(result));
|
|
1617
|
+
}
|
|
1618
|
+
// Protected methods
|
|
1619
|
+
close() {
|
|
1620
|
+
this.animatedClose();
|
|
1621
|
+
}
|
|
1622
|
+
// Private methods
|
|
1623
|
+
_sizeClass() {
|
|
1624
|
+
const size = this._tlsConfig.size;
|
|
1625
|
+
return this._isNamedSize(size) ? size : 'custom';
|
|
1626
|
+
}
|
|
1627
|
+
_isNamedSize(size) {
|
|
1628
|
+
return DRAWER_NAMED_SIZES.includes(size);
|
|
1629
|
+
}
|
|
1630
|
+
// Invokes `onDone` when the leave animation ends, disposing immediately when no
|
|
1631
|
+
// slide-out actually runs (e.g. the `none` motion level, where the motion mixin
|
|
1632
|
+
// emits nothing) so reduced-motion users don't wait out the fallback timeout.
|
|
1633
|
+
_afterLeaveAnimation(onDone) {
|
|
1634
|
+
const element = this._elementRef.nativeElement;
|
|
1635
|
+
let settled = false;
|
|
1636
|
+
const finalize = () => {
|
|
1637
|
+
if (settled)
|
|
1638
|
+
return;
|
|
1639
|
+
settled = true;
|
|
1640
|
+
window.clearTimeout(timeoutId);
|
|
1641
|
+
element.removeEventListener('animationend', onAnimationEnd);
|
|
1642
|
+
onDone();
|
|
1643
|
+
};
|
|
1644
|
+
// Only the host's own slide-out finalizes; ignore `animationend` bubbling up
|
|
1645
|
+
// from animated content inside the drawer.
|
|
1646
|
+
const onAnimationEnd = (event) => {
|
|
1647
|
+
if (event.target === element)
|
|
1648
|
+
finalize();
|
|
1649
|
+
};
|
|
1650
|
+
element.addEventListener('animationend', onAnimationEnd);
|
|
1651
|
+
// Safety net if `animationend` never arrives (e.g. the pane is torn down early).
|
|
1652
|
+
const timeoutId = window.setTimeout(finalize, LEAVE_ANIMATION_FALLBACK_MS$1);
|
|
1653
|
+
// The `--leave` class applies on the next change detection; on the following
|
|
1654
|
+
// frame, close at once if no animation is running. When motion is enabled the
|
|
1655
|
+
// computed `animationName` is never `none`, so this cannot finalize early.
|
|
1656
|
+
requestAnimationFrame(() => {
|
|
1657
|
+
if (getComputedStyle(element).animationName === 'none')
|
|
1658
|
+
finalize();
|
|
1659
|
+
});
|
|
1660
|
+
}
|
|
1661
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Drawer, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1662
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.1", type: Drawer, isStandalone: true, selector: "tls-drawer", host: { properties: { "class": "hostClasses()", "style.--tls-drawer-size": "customSize" } }, usesInheritance: true, ngImport: i0, template: "<ng-template cdkPortalOutlet />\n@if (config.closeable) {\n <button class=\"tls-drawer__close\" type=\"button\" aria-label=\"Close drawer\" (click)=\"close()\">\n <svg viewBox=\"0 0 10 10\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" aria-hidden=\"true\">\n <path d=\"M1 1L9 9M9 1L1 9\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" />\n </svg>\n </button>\n}\n", dependencies: [{ kind: "directive", type: CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }] });
|
|
1663
|
+
}
|
|
1664
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Drawer, decorators: [{
|
|
1665
|
+
type: Component,
|
|
1666
|
+
args: [{ selector: 'tls-drawer', imports: [CdkPortalOutlet], host: {
|
|
1667
|
+
'[class]': 'hostClasses()',
|
|
1668
|
+
'[style.--tls-drawer-size]': 'customSize',
|
|
1669
|
+
}, template: "<ng-template cdkPortalOutlet />\n@if (config.closeable) {\n <button class=\"tls-drawer__close\" type=\"button\" aria-label=\"Close drawer\" (click)=\"close()\">\n <svg viewBox=\"0 0 10 10\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" aria-hidden=\"true\">\n <path d=\"M1 1L9 9M9 1L1 9\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" />\n </svg>\n </button>\n}\n" }]
|
|
1670
|
+
}] });
|
|
1671
|
+
|
|
1672
|
+
/**
|
|
1673
|
+
* Handle to an open drawer. Provided to the drawer's content component (inject it
|
|
1674
|
+
* instead of the CDK `DialogRef`) and returned from {@link DrawerService.open}.
|
|
1675
|
+
*
|
|
1676
|
+
* `close` routes through the container so the slide-out animation plays before the
|
|
1677
|
+
* overlay is disposed, unlike the CDK `DialogRef` which disposes synchronously.
|
|
1678
|
+
*/
|
|
1679
|
+
class DrawerRef {
|
|
1680
|
+
_dialogRef;
|
|
1681
|
+
_container;
|
|
1682
|
+
closed;
|
|
1683
|
+
constructor(_dialogRef, _container) {
|
|
1684
|
+
this._dialogRef = _dialogRef;
|
|
1685
|
+
this._container = _container;
|
|
1686
|
+
this.closed = _dialogRef.closed;
|
|
1687
|
+
}
|
|
1688
|
+
get componentInstance() {
|
|
1689
|
+
return this._dialogRef.componentInstance;
|
|
1690
|
+
}
|
|
1691
|
+
close(result) {
|
|
1692
|
+
this._container.animatedClose(result);
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
class DrawerService {
|
|
1697
|
+
_dialog = inject(Dialog$1);
|
|
1698
|
+
_overlay = inject(Overlay);
|
|
1699
|
+
_directionality = inject(Directionality);
|
|
1700
|
+
_config = inject(DRAWER_CONFIG);
|
|
1701
|
+
// Currently-open drawers, tracked so `closeAll` can play each slide-out and so it
|
|
1702
|
+
// closes drawers only (the CDK `Dialog` is shared with `tls-dialog`).
|
|
1703
|
+
_openDrawers = new Set();
|
|
1704
|
+
open(component, config) {
|
|
1705
|
+
const resolvedConfig = {
|
|
1706
|
+
side: config?.side ?? this._config.side,
|
|
1707
|
+
size: config?.size ?? this._config.size,
|
|
1708
|
+
closeable: config?.closeable ?? this._config.closeable,
|
|
1709
|
+
backdropClose: config?.backdropClose ?? this._config.backdropClose,
|
|
1710
|
+
rounded: config?.rounded ?? this._config.rounded,
|
|
1711
|
+
};
|
|
1712
|
+
let drawerRef;
|
|
1713
|
+
const dialogRef = this._dialog.open(component, {
|
|
1714
|
+
container: {
|
|
1715
|
+
type: Drawer,
|
|
1716
|
+
providers: () => [{ provide: DRAWER_CONFIG, useValue: resolvedConfig }],
|
|
1717
|
+
},
|
|
1718
|
+
// Built against the content injector so the drawer's content can `inject(DrawerRef)`
|
|
1719
|
+
// to close itself. The same instance is returned to the caller below.
|
|
1720
|
+
providers: (cdkRef, _cdkConfig, container) => {
|
|
1721
|
+
drawerRef = new DrawerRef(cdkRef, container);
|
|
1722
|
+
return [{ provide: DrawerRef, useValue: drawerRef }];
|
|
1723
|
+
},
|
|
1724
|
+
positionStrategy: this._buildPositionStrategy(resolvedConfig.side),
|
|
1725
|
+
direction: this._directionality.value,
|
|
1726
|
+
hasBackdrop: true,
|
|
1727
|
+
backdropClass: 'tls-drawer-backdrop',
|
|
1728
|
+
// Suppress CDK's synchronous auto-close so every dismissal routes through
|
|
1729
|
+
// `DrawerRef.close`, which plays the slide-out before disposal.
|
|
1730
|
+
disableClose: true,
|
|
1731
|
+
role: config?.role ?? 'dialog',
|
|
1732
|
+
ariaLabel: config?.ariaLabel ?? null,
|
|
1733
|
+
ariaLabelledBy: config?.ariaLabelledBy ?? null,
|
|
1734
|
+
ariaDescribedBy: config?.ariaDescribedBy ?? null,
|
|
1735
|
+
data: config?.data,
|
|
1736
|
+
});
|
|
1737
|
+
const trackedRef = drawerRef;
|
|
1738
|
+
this._openDrawers.add(trackedRef);
|
|
1739
|
+
dialogRef.closed.subscribe(() => this._openDrawers.delete(trackedRef));
|
|
1740
|
+
this._wireDismissal(dialogRef, drawerRef, resolvedConfig);
|
|
1741
|
+
return drawerRef;
|
|
1742
|
+
}
|
|
1743
|
+
closeAll() {
|
|
1744
|
+
// Iterating a snapshot: `close` is animated, so removal happens later (on
|
|
1745
|
+
// `closed`), but guard against any synchronous mutation regardless.
|
|
1746
|
+
for (const drawerRef of [...this._openDrawers])
|
|
1747
|
+
drawerRef.close();
|
|
1748
|
+
}
|
|
1749
|
+
// Private
|
|
1750
|
+
_buildPositionStrategy(side) {
|
|
1751
|
+
const position = this._overlay.position().global();
|
|
1752
|
+
const isRtl = this._directionality.value === 'rtl';
|
|
1753
|
+
switch (side) {
|
|
1754
|
+
case 'top':
|
|
1755
|
+
return position.top('0').left('0');
|
|
1756
|
+
case 'bottom':
|
|
1757
|
+
return position.bottom('0').left('0');
|
|
1758
|
+
// `start`/`end` are logical: `start` pins to the leading edge (left in LTR,
|
|
1759
|
+
// right in RTL), `end` to the trailing edge.
|
|
1760
|
+
case 'start':
|
|
1761
|
+
return isRtl ? position.top('0').right('0') : position.top('0').left('0');
|
|
1762
|
+
case 'end':
|
|
1763
|
+
return isRtl ? position.top('0').left('0') : position.top('0').right('0');
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
_wireDismissal(dialogRef, drawerRef, config) {
|
|
1767
|
+
if (!config.backdropClose)
|
|
1768
|
+
return;
|
|
1769
|
+
dialogRef.backdropClick
|
|
1770
|
+
.pipe(takeUntil(dialogRef.closed))
|
|
1771
|
+
.subscribe(() => drawerRef.close());
|
|
1772
|
+
dialogRef.keydownEvents
|
|
1773
|
+
.pipe(takeUntil(dialogRef.closed), filter(event => event.key === 'Escape'))
|
|
1774
|
+
.subscribe(() => drawerRef.close());
|
|
1775
|
+
}
|
|
1776
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: DrawerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1777
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: DrawerService, providedIn: 'root' });
|
|
1778
|
+
}
|
|
1779
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: DrawerService, decorators: [{
|
|
1780
|
+
type: Injectable,
|
|
1781
|
+
args: [{ providedIn: 'root' }]
|
|
1782
|
+
}] });
|
|
1783
|
+
|
|
987
1784
|
class FormControlAddon {
|
|
988
1785
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: FormControlAddon, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
989
1786
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.1", type: FormControlAddon, isStandalone: true, selector: "tls-form-control-addon", host: { classAttribute: "tls-form-control-addon" }, ngImport: i0, template: '<ng-content></ng-content>', isInline: true });
|
|
@@ -1089,273 +1886,131 @@ class FormItem {
|
|
|
1089
1886
|
showRequiredMarker = input(this._config.showRequiredMarker, ...(ngDevMode ? [{ debugName: "showRequiredMarker" }] : []));
|
|
1090
1887
|
optionalText = input(this._config.optionalText, ...(ngDevMode ? [{ debugName: "optionalText" }] : []));
|
|
1091
1888
|
isInvalid = computed(() => {
|
|
1092
|
-
const control = this.control();
|
|
1093
|
-
if (!control)
|
|
1094
|
-
return false;
|
|
1095
|
-
return control.invalid() && control.touched();
|
|
1096
|
-
}, ...(ngDevMode ? [{ debugName: "isInvalid" }] : []));
|
|
1097
|
-
showRequired = computed(() => {
|
|
1098
|
-
const control = this.control();
|
|
1099
|
-
if (!control)
|
|
1100
|
-
return false;
|
|
1101
|
-
return this.showRequiredMarker() && control.required();
|
|
1102
|
-
}, ...(ngDevMode ? [{ debugName: "showRequired" }] : []));
|
|
1103
|
-
showOptional = computed(() => {
|
|
1104
|
-
const control = this.control();
|
|
1105
|
-
if (!control)
|
|
1106
|
-
return false;
|
|
1107
|
-
if (!this.optionalText())
|
|
1108
|
-
return false;
|
|
1109
|
-
return !control.required();
|
|
1110
|
-
}, ...(ngDevMode ? [{ debugName: "showOptional" }] : []));
|
|
1111
|
-
labelFor = computed(() => {
|
|
1112
|
-
const control = this.control();
|
|
1113
|
-
if (!control || !control.supportsLabelFor)
|
|
1114
|
-
return null;
|
|
1115
|
-
return control.effectiveInputId();
|
|
1116
|
-
}, ...(ngDevMode ? [{ debugName: "labelFor" }] : []));
|
|
1117
|
-
hostClasses = computed(() => {
|
|
1118
|
-
const className = 'tls-form-item';
|
|
1119
|
-
const array = [className];
|
|
1120
|
-
if (this.isInvalid())
|
|
1121
|
-
array.push(`${className}--invalid`);
|
|
1122
|
-
if (this.reserveErrorSpace())
|
|
1123
|
-
array.push(`${className}--error-space-reserved`);
|
|
1124
|
-
if (this.reserveLabelSpace())
|
|
1125
|
-
array.push(`${className}--label-space-reserved`);
|
|
1126
|
-
return array;
|
|
1127
|
-
}, ...(ngDevMode ? [{ debugName: "hostClasses" }] : []));
|
|
1128
|
-
errorMessages = computed(() => {
|
|
1129
|
-
const control = this.control();
|
|
1130
|
-
if (!control)
|
|
1131
|
-
return [];
|
|
1132
|
-
return this._getErrorMessages(control.errors());
|
|
1133
|
-
}, ...(ngDevMode ? [{ debugName: "errorMessages" }] : []));
|
|
1134
|
-
firstErrorMessage = computed(() => {
|
|
1135
|
-
if (this.errorMessages().length > 0)
|
|
1136
|
-
return this.errorMessages()[0];
|
|
1137
|
-
else
|
|
1138
|
-
return null;
|
|
1139
|
-
}, ...(ngDevMode ? [{ debugName: "firstErrorMessage" }] : []));
|
|
1140
|
-
// constructor
|
|
1141
|
-
constructor() {
|
|
1142
|
-
effect(() => {
|
|
1143
|
-
const control = this.control();
|
|
1144
|
-
if (!control)
|
|
1145
|
-
return;
|
|
1146
|
-
// Point the control's aria-labelledby at the rendered label element so screen readers
|
|
1147
|
-
// announce the visible label text when the control receives focus.
|
|
1148
|
-
control.labelId.set(this.label() ? this.labelId : null);
|
|
1149
|
-
// Assign the stable control id so the label's `for` attribute can target the native element.
|
|
1150
|
-
control.formItemInputId.set(control.supportsLabelFor ? this.controlId : null);
|
|
1151
|
-
// Point the control's aria-describedby at the rendered error element (and clear it when no
|
|
1152
|
-
// error is shown) so screen readers announce the validation message on focus.
|
|
1153
|
-
const describesError = this.displayErrors() && this.isInvalid();
|
|
1154
|
-
control.errorMessageId.set(describesError ? this.errorId : null);
|
|
1155
|
-
});
|
|
1156
|
-
}
|
|
1157
|
-
// Private methods
|
|
1158
|
-
_getErrorMessages(errors) {
|
|
1159
|
-
const array = [];
|
|
1160
|
-
for (const error of errors) {
|
|
1161
|
-
if (error.message)
|
|
1162
|
-
array.push(error.message);
|
|
1163
|
-
else
|
|
1164
|
-
array.push(this._config.errorMessages[error.kind](error.fieldTree));
|
|
1165
|
-
}
|
|
1166
|
-
return array;
|
|
1167
|
-
}
|
|
1168
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: FormItem, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1169
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.1", type: FormItem, isStandalone: true, selector: "tls-form-item", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, reserveErrorSpace: { classPropertyName: "reserveErrorSpace", publicName: "reserveErrorSpace", isSignal: true, isRequired: false, transformFunction: null }, reserveLabelSpace: { classPropertyName: "reserveLabelSpace", publicName: "reserveLabelSpace", isSignal: true, isRequired: false, transformFunction: null }, displayErrors: { classPropertyName: "displayErrors", publicName: "displayErrors", isSignal: true, isRequired: false, transformFunction: null }, showRequiredMarker: { classPropertyName: "showRequiredMarker", publicName: "showRequiredMarker", isSignal: true, isRequired: false, transformFunction: null }, optionalText: { classPropertyName: "optionalText", publicName: "optionalText", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "hostClasses()" } }, queries: [{ propertyName: "control", first: true, predicate: FORM_CONTROL, descendants: true, isSignal: true }], ngImport: i0, template: "@if (label() || reserveLabelSpace()) {\n <label class=\"form-item-label\" [id]=\"labelId\" [attr.for]=\"labelFor()\">\n <span class=\"form-item-label__text\">{{ label() }}</span>\n @if (showRequired()) {\n <span class=\"form-item-label__required\">*</span>\n } @else if (showOptional()) {\n <span class=\"form-item-label__optional\">{{ optionalText() }}</span>\n }\n </label>\n}\n<div class=\"form-item-control\">\n <ng-content></ng-content>\n</div>\n@if (displayErrors()) {\n <small class=\"form-item-error\">\n @if (isInvalid()) {\n <span class=\"form-item-error__text\" [id]=\"errorId\">\n {{ firstErrorMessage() }}\n </span>\n }\n </small>\n}\n" });
|
|
1170
|
-
}
|
|
1171
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: FormItem, decorators: [{
|
|
1172
|
-
type: Component,
|
|
1173
|
-
args: [{ selector: 'tls-form-item', imports: [], host: { '[class]': 'hostClasses()' }, template: "@if (label() || reserveLabelSpace()) {\n <label class=\"form-item-label\" [id]=\"labelId\" [attr.for]=\"labelFor()\">\n <span class=\"form-item-label__text\">{{ label() }}</span>\n @if (showRequired()) {\n <span class=\"form-item-label__required\">*</span>\n } @else if (showOptional()) {\n <span class=\"form-item-label__optional\">{{ optionalText() }}</span>\n }\n </label>\n}\n<div class=\"form-item-control\">\n <ng-content></ng-content>\n</div>\n@if (displayErrors()) {\n <small class=\"form-item-error\">\n @if (isInvalid()) {\n <span class=\"form-item-error__text\" [id]=\"errorId\">\n {{ firstErrorMessage() }}\n </span>\n }\n </small>\n}\n" }]
|
|
1174
|
-
}], ctorParameters: () => [], propDecorators: { control: [{ type: i0.ContentChild, args: [i0.forwardRef(() => FORM_CONTROL), { isSignal: true }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], reserveErrorSpace: [{ type: i0.Input, args: [{ isSignal: true, alias: "reserveErrorSpace", required: false }] }], reserveLabelSpace: [{ type: i0.Input, args: [{ isSignal: true, alias: "reserveLabelSpace", required: false }] }], displayErrors: [{ type: i0.Input, args: [{ isSignal: true, alias: "displayErrors", required: false }] }], showRequiredMarker: [{ type: i0.Input, args: [{ isSignal: true, alias: "showRequiredMarker", required: false }] }], optionalText: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionalText", required: false }] }] } });
|
|
1175
|
-
|
|
1176
|
-
const DEFAULT_CHECKBOX_CONFIG = {};
|
|
1177
|
-
|
|
1178
|
-
const CHECKBOX_CONFIG = new InjectionToken('CHECKBOX_CONFIG', {
|
|
1179
|
-
factory: () => DEFAULT_CHECKBOX_CONFIG,
|
|
1180
|
-
});
|
|
1181
|
-
|
|
1182
|
-
class Checkbox extends CheckboxFormControl {
|
|
1183
|
-
_config = inject(CHECKBOX_CONFIG);
|
|
1184
|
-
CLASS_NAME = 'tls-checkbox';
|
|
1185
|
-
supportsLabelFor = true;
|
|
1186
|
-
indeterminate = model(false, ...(ngDevMode ? [{ debugName: "indeterminate" }] : []));
|
|
1187
|
-
checked = model(false, ...(ngDevMode ? [{ debugName: "checked" }] : []));
|
|
1188
|
-
tabindex = input(0, ...(ngDevMode ? [{ debugName: "tabindex" }] : []));
|
|
1189
|
-
hostClasses = computed(() => {
|
|
1190
|
-
const className = this.CLASS_NAME;
|
|
1191
|
-
const array = [className];
|
|
1192
|
-
if (this.indeterminate())
|
|
1193
|
-
array.push(`${className}--indeterminate`);
|
|
1194
|
-
return array.concat(this.controlClasses());
|
|
1195
|
-
}, ...(ngDevMode ? [{ debugName: "hostClasses" }] : []));
|
|
1196
|
-
// Protected methods
|
|
1197
|
-
toggle() {
|
|
1198
|
-
if (this.notInteractive())
|
|
1199
|
-
return;
|
|
1200
|
-
this.checked.update(prev => !prev);
|
|
1201
|
-
}
|
|
1202
|
-
onKeyboardToggle(event) {
|
|
1203
|
-
event.preventDefault();
|
|
1204
|
-
this.toggle();
|
|
1205
|
-
}
|
|
1206
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Checkbox, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1207
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.1", type: Checkbox, isStandalone: true, selector: "tls-checkbox", inputs: { indeterminate: { classPropertyName: "indeterminate", publicName: "indeterminate", isSignal: true, isRequired: false, transformFunction: null }, checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, tabindex: { classPropertyName: "tabindex", publicName: "tabindex", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { indeterminate: "indeterminateChange", checked: "checkedChange" }, host: { attributes: { "role": "checkbox" }, properties: { "class": "hostClasses()", "tabindex": "-1" } }, usesInheritance: true, ngImport: i0, template: "<input\n type=\"checkbox\"\n class=\"tls-checkbox-input\"\n [attr.id]=\"effectiveInputId()\"\n [name]=\"name()\"\n [attr.aria-label]=\"ariaLabel() ?? null\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [attr.aria-invalid]=\"invalid() ? 'true' : null\"\n [attr.aria-required]=\"required() ? 'true' : null\"\n [attr.aria-describedby]=\"describedBy()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [checked]=\"checked()\"\n (click)=\"toggle()\"\n (blur)=\"touched.set(true)\"\n (keydown.space)=\"onKeyboardToggle($event)\"\n (keydown.enter)=\"onKeyboardToggle($event)\"\n/>\n<div class=\"tls-checkbox-icon\">\n @if (indeterminate()) {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"20px\"\n viewBox=\"0 -960 960 960\"\n width=\"20px\"\n fill=\"currentColor\"\n >\n <path d=\"M288-444v-72h384v72H288Z\" />\n </svg>\n } @else {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"20px\"\n viewBox=\"0 -960 960 960\"\n width=\"20px\"\n fill=\"currentColor\"\n >\n <path d=\"M400-301 240-461l51-51 109 109 269-269 51 51-320 320Z\" />\n </svg>\n }\n</div>\n" });
|
|
1208
|
-
}
|
|
1209
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Checkbox, decorators: [{
|
|
1210
|
-
type: Component,
|
|
1211
|
-
args: [{ selector: 'tls-checkbox', imports: [], host: {
|
|
1212
|
-
role: 'checkbox',
|
|
1213
|
-
'[class]': 'hostClasses()',
|
|
1214
|
-
'[tabindex]': '-1',
|
|
1215
|
-
}, template: "<input\n type=\"checkbox\"\n class=\"tls-checkbox-input\"\n [attr.id]=\"effectiveInputId()\"\n [name]=\"name()\"\n [attr.aria-label]=\"ariaLabel() ?? null\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [attr.aria-invalid]=\"invalid() ? 'true' : null\"\n [attr.aria-required]=\"required() ? 'true' : null\"\n [attr.aria-describedby]=\"describedBy()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [checked]=\"checked()\"\n (click)=\"toggle()\"\n (blur)=\"touched.set(true)\"\n (keydown.space)=\"onKeyboardToggle($event)\"\n (keydown.enter)=\"onKeyboardToggle($event)\"\n/>\n<div class=\"tls-checkbox-icon\">\n @if (indeterminate()) {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"20px\"\n viewBox=\"0 -960 960 960\"\n width=\"20px\"\n fill=\"currentColor\"\n >\n <path d=\"M288-444v-72h384v72H288Z\" />\n </svg>\n } @else {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"20px\"\n viewBox=\"0 -960 960 960\"\n width=\"20px\"\n fill=\"currentColor\"\n >\n <path d=\"M400-301 240-461l51-51 109 109 269-269 51 51-320 320Z\" />\n </svg>\n }\n</div>\n" }]
|
|
1216
|
-
}], propDecorators: { indeterminate: [{ type: i0.Input, args: [{ isSignal: true, alias: "indeterminate", required: false }] }, { type: i0.Output, args: ["indeterminateChange"] }], checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }, { type: i0.Output, args: ["checkedChange"] }], tabindex: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabindex", required: false }] }] } });
|
|
1217
|
-
|
|
1218
|
-
const OVERLAY_POSITION_MAP = {
|
|
1219
|
-
top: {
|
|
1220
|
-
originX: 'center',
|
|
1221
|
-
originY: 'top',
|
|
1222
|
-
overlayX: 'center',
|
|
1223
|
-
overlayY: 'bottom',
|
|
1224
|
-
offsetX: 0,
|
|
1225
|
-
offsetY: -1,
|
|
1226
|
-
},
|
|
1227
|
-
right: {
|
|
1228
|
-
originX: 'end',
|
|
1229
|
-
originY: 'center',
|
|
1230
|
-
overlayX: 'start',
|
|
1231
|
-
overlayY: 'center',
|
|
1232
|
-
offsetX: 1,
|
|
1233
|
-
offsetY: 0,
|
|
1234
|
-
},
|
|
1235
|
-
bottom: {
|
|
1236
|
-
originX: 'center',
|
|
1237
|
-
originY: 'bottom',
|
|
1238
|
-
overlayX: 'center',
|
|
1239
|
-
overlayY: 'top',
|
|
1240
|
-
offsetX: 1,
|
|
1241
|
-
offsetY: 1,
|
|
1242
|
-
},
|
|
1243
|
-
left: {
|
|
1244
|
-
originX: 'start',
|
|
1245
|
-
originY: 'center',
|
|
1246
|
-
overlayX: 'end',
|
|
1247
|
-
overlayY: 'center',
|
|
1248
|
-
offsetX: -1,
|
|
1249
|
-
offsetY: 0,
|
|
1250
|
-
},
|
|
1251
|
-
'top-start': {
|
|
1252
|
-
originX: 'start',
|
|
1253
|
-
originY: 'top',
|
|
1254
|
-
overlayX: 'start',
|
|
1255
|
-
overlayY: 'bottom',
|
|
1256
|
-
offsetX: 0,
|
|
1257
|
-
offsetY: -1,
|
|
1258
|
-
},
|
|
1259
|
-
'top-end': {
|
|
1260
|
-
originX: 'end',
|
|
1261
|
-
originY: 'top',
|
|
1262
|
-
overlayX: 'end',
|
|
1263
|
-
overlayY: 'bottom',
|
|
1264
|
-
offsetX: 0,
|
|
1265
|
-
offsetY: -1,
|
|
1266
|
-
},
|
|
1267
|
-
'right-start': {
|
|
1268
|
-
originX: 'end',
|
|
1269
|
-
originY: 'top',
|
|
1270
|
-
overlayX: 'start',
|
|
1271
|
-
overlayY: 'top',
|
|
1272
|
-
offsetX: 1,
|
|
1273
|
-
offsetY: 0,
|
|
1274
|
-
},
|
|
1275
|
-
'right-end': {
|
|
1276
|
-
originX: 'end',
|
|
1277
|
-
originY: 'bottom',
|
|
1278
|
-
overlayX: 'start',
|
|
1279
|
-
overlayY: 'bottom',
|
|
1280
|
-
offsetX: 1,
|
|
1281
|
-
offsetY: 0,
|
|
1282
|
-
},
|
|
1283
|
-
'bottom-start': {
|
|
1284
|
-
originX: 'start',
|
|
1285
|
-
originY: 'bottom',
|
|
1286
|
-
overlayX: 'start',
|
|
1287
|
-
overlayY: 'top',
|
|
1288
|
-
offsetX: 0,
|
|
1289
|
-
offsetY: 1,
|
|
1290
|
-
},
|
|
1291
|
-
'bottom-end': {
|
|
1292
|
-
originX: 'end',
|
|
1293
|
-
originY: 'bottom',
|
|
1294
|
-
overlayX: 'end',
|
|
1295
|
-
overlayY: 'top',
|
|
1296
|
-
offsetX: 0,
|
|
1297
|
-
offsetY: 1,
|
|
1298
|
-
},
|
|
1299
|
-
'left-start': {
|
|
1300
|
-
originX: 'start',
|
|
1301
|
-
originY: 'top',
|
|
1302
|
-
overlayX: 'end',
|
|
1303
|
-
overlayY: 'top',
|
|
1304
|
-
offsetX: -1,
|
|
1305
|
-
offsetY: 0,
|
|
1306
|
-
},
|
|
1307
|
-
'left-end': {
|
|
1308
|
-
originX: 'start',
|
|
1309
|
-
originY: 'bottom',
|
|
1310
|
-
overlayX: 'end',
|
|
1311
|
-
overlayY: 'bottom',
|
|
1312
|
-
offsetX: -1,
|
|
1313
|
-
offsetY: 0,
|
|
1314
|
-
},
|
|
1315
|
-
'top-left': {
|
|
1316
|
-
originX: 'start',
|
|
1317
|
-
originY: 'top',
|
|
1318
|
-
overlayX: 'end',
|
|
1319
|
-
overlayY: 'bottom',
|
|
1320
|
-
offsetX: -1,
|
|
1321
|
-
offsetY: -1,
|
|
1322
|
-
},
|
|
1323
|
-
'top-right': {
|
|
1324
|
-
originX: 'end',
|
|
1325
|
-
originY: 'top',
|
|
1326
|
-
overlayX: 'start',
|
|
1327
|
-
overlayY: 'bottom',
|
|
1328
|
-
offsetX: 1,
|
|
1329
|
-
offsetY: -1,
|
|
1330
|
-
},
|
|
1331
|
-
'bottom-left': {
|
|
1332
|
-
originX: 'start',
|
|
1333
|
-
originY: 'bottom',
|
|
1334
|
-
overlayX: 'end',
|
|
1335
|
-
overlayY: 'top',
|
|
1336
|
-
offsetX: -1,
|
|
1337
|
-
offsetY: 1,
|
|
1338
|
-
},
|
|
1339
|
-
'bottom-right': {
|
|
1340
|
-
originX: 'end',
|
|
1341
|
-
originY: 'bottom',
|
|
1342
|
-
overlayX: 'start',
|
|
1343
|
-
overlayY: 'top',
|
|
1344
|
-
offsetX: 1,
|
|
1345
|
-
offsetY: 1,
|
|
1346
|
-
},
|
|
1347
|
-
};
|
|
1889
|
+
const control = this.control();
|
|
1890
|
+
if (!control)
|
|
1891
|
+
return false;
|
|
1892
|
+
return control.invalid() && control.touched();
|
|
1893
|
+
}, ...(ngDevMode ? [{ debugName: "isInvalid" }] : []));
|
|
1894
|
+
showRequired = computed(() => {
|
|
1895
|
+
const control = this.control();
|
|
1896
|
+
if (!control)
|
|
1897
|
+
return false;
|
|
1898
|
+
return this.showRequiredMarker() && control.required();
|
|
1899
|
+
}, ...(ngDevMode ? [{ debugName: "showRequired" }] : []));
|
|
1900
|
+
showOptional = computed(() => {
|
|
1901
|
+
const control = this.control();
|
|
1902
|
+
if (!control)
|
|
1903
|
+
return false;
|
|
1904
|
+
if (!this.optionalText())
|
|
1905
|
+
return false;
|
|
1906
|
+
return !control.required();
|
|
1907
|
+
}, ...(ngDevMode ? [{ debugName: "showOptional" }] : []));
|
|
1908
|
+
labelFor = computed(() => {
|
|
1909
|
+
const control = this.control();
|
|
1910
|
+
if (!control || !control.supportsLabelFor)
|
|
1911
|
+
return null;
|
|
1912
|
+
return control.effectiveInputId();
|
|
1913
|
+
}, ...(ngDevMode ? [{ debugName: "labelFor" }] : []));
|
|
1914
|
+
hostClasses = computed(() => {
|
|
1915
|
+
const className = 'tls-form-item';
|
|
1916
|
+
const array = [className];
|
|
1917
|
+
if (this.isInvalid())
|
|
1918
|
+
array.push(`${className}--invalid`);
|
|
1919
|
+
if (this.reserveErrorSpace())
|
|
1920
|
+
array.push(`${className}--error-space-reserved`);
|
|
1921
|
+
if (this.reserveLabelSpace())
|
|
1922
|
+
array.push(`${className}--label-space-reserved`);
|
|
1923
|
+
return array;
|
|
1924
|
+
}, ...(ngDevMode ? [{ debugName: "hostClasses" }] : []));
|
|
1925
|
+
errorMessages = computed(() => {
|
|
1926
|
+
const control = this.control();
|
|
1927
|
+
if (!control)
|
|
1928
|
+
return [];
|
|
1929
|
+
return this._getErrorMessages(control.errors());
|
|
1930
|
+
}, ...(ngDevMode ? [{ debugName: "errorMessages" }] : []));
|
|
1931
|
+
firstErrorMessage = computed(() => {
|
|
1932
|
+
if (this.errorMessages().length > 0)
|
|
1933
|
+
return this.errorMessages()[0];
|
|
1934
|
+
else
|
|
1935
|
+
return null;
|
|
1936
|
+
}, ...(ngDevMode ? [{ debugName: "firstErrorMessage" }] : []));
|
|
1937
|
+
// constructor
|
|
1938
|
+
constructor() {
|
|
1939
|
+
effect(() => {
|
|
1940
|
+
const control = this.control();
|
|
1941
|
+
if (!control)
|
|
1942
|
+
return;
|
|
1943
|
+
// Point the control's aria-labelledby at the rendered label element so screen readers
|
|
1944
|
+
// announce the visible label text when the control receives focus.
|
|
1945
|
+
control.labelId.set(this.label() ? this.labelId : null);
|
|
1946
|
+
// Assign the stable control id so the label's `for` attribute can target the native element.
|
|
1947
|
+
control.formItemInputId.set(control.supportsLabelFor ? this.controlId : null);
|
|
1948
|
+
// Point the control's aria-describedby at the rendered error element (and clear it when no
|
|
1949
|
+
// error is shown) so screen readers announce the validation message on focus.
|
|
1950
|
+
const describesError = this.displayErrors() && this.isInvalid();
|
|
1951
|
+
control.errorMessageId.set(describesError ? this.errorId : null);
|
|
1952
|
+
});
|
|
1953
|
+
}
|
|
1954
|
+
// Private methods
|
|
1955
|
+
_getErrorMessages(errors) {
|
|
1956
|
+
const array = [];
|
|
1957
|
+
for (const error of errors) {
|
|
1958
|
+
if (error.message)
|
|
1959
|
+
array.push(error.message);
|
|
1960
|
+
else
|
|
1961
|
+
array.push(this._config.errorMessages[error.kind](error.fieldTree));
|
|
1962
|
+
}
|
|
1963
|
+
return array;
|
|
1964
|
+
}
|
|
1965
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: FormItem, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1966
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.1", type: FormItem, isStandalone: true, selector: "tls-form-item", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, reserveErrorSpace: { classPropertyName: "reserveErrorSpace", publicName: "reserveErrorSpace", isSignal: true, isRequired: false, transformFunction: null }, reserveLabelSpace: { classPropertyName: "reserveLabelSpace", publicName: "reserveLabelSpace", isSignal: true, isRequired: false, transformFunction: null }, displayErrors: { classPropertyName: "displayErrors", publicName: "displayErrors", isSignal: true, isRequired: false, transformFunction: null }, showRequiredMarker: { classPropertyName: "showRequiredMarker", publicName: "showRequiredMarker", isSignal: true, isRequired: false, transformFunction: null }, optionalText: { classPropertyName: "optionalText", publicName: "optionalText", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "hostClasses()" } }, queries: [{ propertyName: "control", first: true, predicate: FORM_CONTROL, descendants: true, isSignal: true }], ngImport: i0, template: "@if (label() || reserveLabelSpace()) {\n <label class=\"form-item-label\" [id]=\"labelId\" [attr.for]=\"labelFor()\">\n <span class=\"form-item-label__text\">{{ label() }}</span>\n @if (showRequired()) {\n <span class=\"form-item-label__required\">*</span>\n } @else if (showOptional()) {\n <span class=\"form-item-label__optional\">{{ optionalText() }}</span>\n }\n </label>\n}\n<div class=\"form-item-control\">\n <ng-content></ng-content>\n</div>\n@if (displayErrors()) {\n <small class=\"form-item-error\">\n @if (isInvalid()) {\n <span class=\"form-item-error__text\" [id]=\"errorId\">\n {{ firstErrorMessage() }}\n </span>\n }\n </small>\n}\n" });
|
|
1967
|
+
}
|
|
1968
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: FormItem, decorators: [{
|
|
1969
|
+
type: Component,
|
|
1970
|
+
args: [{ selector: 'tls-form-item', imports: [], host: { '[class]': 'hostClasses()' }, template: "@if (label() || reserveLabelSpace()) {\n <label class=\"form-item-label\" [id]=\"labelId\" [attr.for]=\"labelFor()\">\n <span class=\"form-item-label__text\">{{ label() }}</span>\n @if (showRequired()) {\n <span class=\"form-item-label__required\">*</span>\n } @else if (showOptional()) {\n <span class=\"form-item-label__optional\">{{ optionalText() }}</span>\n }\n </label>\n}\n<div class=\"form-item-control\">\n <ng-content></ng-content>\n</div>\n@if (displayErrors()) {\n <small class=\"form-item-error\">\n @if (isInvalid()) {\n <span class=\"form-item-error__text\" [id]=\"errorId\">\n {{ firstErrorMessage() }}\n </span>\n }\n </small>\n}\n" }]
|
|
1971
|
+
}], ctorParameters: () => [], propDecorators: { control: [{ type: i0.ContentChild, args: [i0.forwardRef(() => FORM_CONTROL), { isSignal: true }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], reserveErrorSpace: [{ type: i0.Input, args: [{ isSignal: true, alias: "reserveErrorSpace", required: false }] }], reserveLabelSpace: [{ type: i0.Input, args: [{ isSignal: true, alias: "reserveLabelSpace", required: false }] }], displayErrors: [{ type: i0.Input, args: [{ isSignal: true, alias: "displayErrors", required: false }] }], showRequiredMarker: [{ type: i0.Input, args: [{ isSignal: true, alias: "showRequiredMarker", required: false }] }], optionalText: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionalText", required: false }] }] } });
|
|
1348
1972
|
|
|
1349
|
-
const
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1973
|
+
const DEFAULT_CHECKBOX_CONFIG = {};
|
|
1974
|
+
|
|
1975
|
+
const CHECKBOX_CONFIG = new InjectionToken('CHECKBOX_CONFIG', {
|
|
1976
|
+
factory: () => DEFAULT_CHECKBOX_CONFIG,
|
|
1977
|
+
});
|
|
1978
|
+
|
|
1979
|
+
class Checkbox extends CheckboxFormControl {
|
|
1980
|
+
_config = inject(CHECKBOX_CONFIG);
|
|
1981
|
+
CLASS_NAME = 'tls-checkbox';
|
|
1982
|
+
supportsLabelFor = true;
|
|
1983
|
+
indeterminate = model(false, ...(ngDevMode ? [{ debugName: "indeterminate" }] : []));
|
|
1984
|
+
checked = model(false, ...(ngDevMode ? [{ debugName: "checked" }] : []));
|
|
1985
|
+
tabindex = input(0, ...(ngDevMode ? [{ debugName: "tabindex" }] : []));
|
|
1986
|
+
hostClasses = computed(() => {
|
|
1987
|
+
const className = this.CLASS_NAME;
|
|
1988
|
+
const array = [className];
|
|
1989
|
+
if (this.indeterminate())
|
|
1990
|
+
array.push(`${className}--indeterminate`);
|
|
1991
|
+
return array.concat(this.controlClasses());
|
|
1992
|
+
}, ...(ngDevMode ? [{ debugName: "hostClasses" }] : []));
|
|
1993
|
+
// Protected methods
|
|
1994
|
+
toggle() {
|
|
1995
|
+
if (this.notInteractive())
|
|
1996
|
+
return;
|
|
1997
|
+
this.checked.update(prev => !prev);
|
|
1998
|
+
}
|
|
1999
|
+
onKeyboardToggle(event) {
|
|
2000
|
+
event.preventDefault();
|
|
2001
|
+
this.toggle();
|
|
2002
|
+
}
|
|
2003
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Checkbox, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
2004
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.1", type: Checkbox, isStandalone: true, selector: "tls-checkbox", inputs: { indeterminate: { classPropertyName: "indeterminate", publicName: "indeterminate", isSignal: true, isRequired: false, transformFunction: null }, checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, tabindex: { classPropertyName: "tabindex", publicName: "tabindex", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { indeterminate: "indeterminateChange", checked: "checkedChange" }, host: { attributes: { "role": "checkbox" }, properties: { "class": "hostClasses()", "tabindex": "-1" } }, usesInheritance: true, ngImport: i0, template: "<input\n type=\"checkbox\"\n class=\"tls-checkbox-input\"\n [attr.id]=\"effectiveInputId()\"\n [name]=\"name()\"\n [attr.aria-label]=\"ariaLabel() ?? null\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [attr.aria-invalid]=\"invalid() ? 'true' : null\"\n [attr.aria-required]=\"required() ? 'true' : null\"\n [attr.aria-describedby]=\"describedBy()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [checked]=\"checked()\"\n (click)=\"toggle()\"\n (blur)=\"touched.set(true)\"\n (keydown.space)=\"onKeyboardToggle($event)\"\n (keydown.enter)=\"onKeyboardToggle($event)\"\n/>\n<div class=\"tls-checkbox-icon\">\n @if (indeterminate()) {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"20px\"\n viewBox=\"0 -960 960 960\"\n width=\"20px\"\n fill=\"currentColor\"\n >\n <path d=\"M288-444v-72h384v72H288Z\" />\n </svg>\n } @else {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"20px\"\n viewBox=\"0 -960 960 960\"\n width=\"20px\"\n fill=\"currentColor\"\n >\n <path d=\"M400-301 240-461l51-51 109 109 269-269 51 51-320 320Z\" />\n </svg>\n }\n</div>\n" });
|
|
2005
|
+
}
|
|
2006
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Checkbox, decorators: [{
|
|
2007
|
+
type: Component,
|
|
2008
|
+
args: [{ selector: 'tls-checkbox', imports: [], host: {
|
|
2009
|
+
role: 'checkbox',
|
|
2010
|
+
'[class]': 'hostClasses()',
|
|
2011
|
+
'[tabindex]': '-1',
|
|
2012
|
+
}, template: "<input\n type=\"checkbox\"\n class=\"tls-checkbox-input\"\n [attr.id]=\"effectiveInputId()\"\n [name]=\"name()\"\n [attr.aria-label]=\"ariaLabel() ?? null\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [attr.aria-invalid]=\"invalid() ? 'true' : null\"\n [attr.aria-required]=\"required() ? 'true' : null\"\n [attr.aria-describedby]=\"describedBy()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [checked]=\"checked()\"\n (click)=\"toggle()\"\n (blur)=\"touched.set(true)\"\n (keydown.space)=\"onKeyboardToggle($event)\"\n (keydown.enter)=\"onKeyboardToggle($event)\"\n/>\n<div class=\"tls-checkbox-icon\">\n @if (indeterminate()) {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"20px\"\n viewBox=\"0 -960 960 960\"\n width=\"20px\"\n fill=\"currentColor\"\n >\n <path d=\"M288-444v-72h384v72H288Z\" />\n </svg>\n } @else {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"20px\"\n viewBox=\"0 -960 960 960\"\n width=\"20px\"\n fill=\"currentColor\"\n >\n <path d=\"M400-301 240-461l51-51 109 109 269-269 51 51-320 320Z\" />\n </svg>\n }\n</div>\n" }]
|
|
2013
|
+
}], propDecorators: { indeterminate: [{ type: i0.Input, args: [{ isSignal: true, alias: "indeterminate", required: false }] }, { type: i0.Output, args: ["indeterminateChange"] }], checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }, { type: i0.Output, args: ["checkedChange"] }], tabindex: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabindex", required: false }] }] } });
|
|
1359
2014
|
|
|
1360
2015
|
const DEFAULT_POPOVER_CONFIG = {
|
|
1361
2016
|
position: 'bottom',
|
|
@@ -2202,6 +2857,7 @@ const PIN_INPUT_CONFIG = new InjectionToken('PIN_INPUT_CONFIG', {
|
|
|
2202
2857
|
|
|
2203
2858
|
class PinInput extends ValueFormControl {
|
|
2204
2859
|
_config = inject(PIN_INPUT_CONFIG);
|
|
2860
|
+
_directionality = inject(Directionality);
|
|
2205
2861
|
_inputs = viewChildren('cell', ...(ngDevMode ? [{ debugName: "_inputs" }] : []));
|
|
2206
2862
|
// Inputs
|
|
2207
2863
|
value = model('', ...(ngDevMode ? [{ debugName: "value" }] : []));
|
|
@@ -2245,13 +2901,12 @@ class PinInput extends ValueFormControl {
|
|
|
2245
2901
|
this._focusCell(index - 1);
|
|
2246
2902
|
}
|
|
2247
2903
|
}
|
|
2248
|
-
else if (event.key === 'ArrowLeft') {
|
|
2249
|
-
event.preventDefault();
|
|
2250
|
-
this._focusCell(index - 1);
|
|
2251
|
-
}
|
|
2252
|
-
else if (event.key === 'ArrowRight') {
|
|
2904
|
+
else if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
|
|
2253
2905
|
event.preventDefault();
|
|
2254
|
-
|
|
2906
|
+
// Arrows are physical; map them to previous/next cell per layout direction.
|
|
2907
|
+
const isRtl = this._directionality.value === 'rtl';
|
|
2908
|
+
const goToPrevious = isRtl ? event.key === 'ArrowRight' : event.key === 'ArrowLeft';
|
|
2909
|
+
this._focusCell(goToPrevious ? index - 1 : index + 1);
|
|
2255
2910
|
}
|
|
2256
2911
|
element.value = this.getCellValue(index);
|
|
2257
2912
|
}
|
|
@@ -2962,6 +3617,210 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImpor
|
|
|
2962
3617
|
}]
|
|
2963
3618
|
}], propDecorators: { menu: [{ type: i0.Input, args: [{ isSignal: true, alias: "tlsContextMenu", required: true }] }] } });
|
|
2964
3619
|
|
|
3620
|
+
// A single decimal wheel holds ten digits (0-9).
|
|
3621
|
+
const ODOMETER_DIGITS_PER_REPETITION = 10;
|
|
3622
|
+
// The wheel is rendered three times over so a roll always has a full repetition
|
|
3623
|
+
// of slack on either side of the visible digit. This is what lets the column
|
|
3624
|
+
// cross the 9→0 seam by traveling the short way instead of unwinding all the
|
|
3625
|
+
// way back through 8, 7, 6…
|
|
3626
|
+
const ODOMETER_DIGIT_REPETITIONS = 3;
|
|
3627
|
+
// Row offset of the middle repetition. Every roll re-centers here first, so the
|
|
3628
|
+
// travel afterward is at most five rows in either direction and never runs off
|
|
3629
|
+
// the rendered strip.
|
|
3630
|
+
const ODOMETER_CENTER_OFFSET = ODOMETER_DIGITS_PER_REPETITION;
|
|
3631
|
+
// The stacked digits of a column, from top to bottom: 0-9 repeated three times.
|
|
3632
|
+
const ODOMETER_STRIP = Array.from({ length: ODOMETER_DIGIT_REPETITIONS * ODOMETER_DIGITS_PER_REPETITION }, (_unused, index) => index % ODOMETER_DIGITS_PER_REPETITION);
|
|
3633
|
+
// Typographic minus (U+2212) reads better than a hyphen-minus for a numeric display.
|
|
3634
|
+
const ODOMETER_MINUS_SIGN = '−';
|
|
3635
|
+
|
|
3636
|
+
/**
|
|
3637
|
+
* A single rolling digit column of {@link Odometer}. Renders a vertical strip of
|
|
3638
|
+
* digits and translates it so the current value sits in the viewport; a change
|
|
3639
|
+
* animates the translation, so the digit appears to roll through the values
|
|
3640
|
+
* between the old and the new one — always by the shortest path around the
|
|
3641
|
+
* `0-9` wheel.
|
|
3642
|
+
*
|
|
3643
|
+
* Internal to {@link Odometer}; not part of the public component surface.
|
|
3644
|
+
*/
|
|
3645
|
+
class OdometerDigit {
|
|
3646
|
+
// Inputs
|
|
3647
|
+
digit = input.required(...(ngDevMode ? [{ debugName: "digit" }] : []));
|
|
3648
|
+
duration = input.required(...(ngDevMode ? [{ debugName: "duration" }] : []));
|
|
3649
|
+
// State
|
|
3650
|
+
strip = ODOMETER_STRIP;
|
|
3651
|
+
// Row the strip is translated to. Starts centred on the middle repetition.
|
|
3652
|
+
offset = signal(ODOMETER_CENTER_OFFSET, ...(ngDevMode ? [{ debugName: "offset" }] : []));
|
|
3653
|
+
// Whether the translation transition is armed. Disabled while re-centring so
|
|
3654
|
+
// the invisible jump between repetitions never animates.
|
|
3655
|
+
animating = signal(false, ...(ngDevMode ? [{ debugName: "animating" }] : []));
|
|
3656
|
+
// Digit currently settled in the viewport, tracked to derive the roll direction.
|
|
3657
|
+
_currentDigit = 0;
|
|
3658
|
+
_initialized = false;
|
|
3659
|
+
constructor() {
|
|
3660
|
+
effect(() => {
|
|
3661
|
+
const target = this.digit();
|
|
3662
|
+
untracked(() => this._roll(target));
|
|
3663
|
+
});
|
|
3664
|
+
}
|
|
3665
|
+
// Private methods
|
|
3666
|
+
_roll(target) {
|
|
3667
|
+
// First value paints in place, without a roll.
|
|
3668
|
+
if (!this._initialized) {
|
|
3669
|
+
this._currentDigit = target;
|
|
3670
|
+
this.offset.set(ODOMETER_CENTER_OFFSET + target);
|
|
3671
|
+
this._initialized = true;
|
|
3672
|
+
return;
|
|
3673
|
+
}
|
|
3674
|
+
if (target === this._currentDigit)
|
|
3675
|
+
return;
|
|
3676
|
+
const base = ODOMETER_CENTER_OFFSET + this._currentDigit;
|
|
3677
|
+
const delta = this._shortestDelta(this._currentDigit, target);
|
|
3678
|
+
this._currentDigit = target;
|
|
3679
|
+
// Re-centre onto the middle repetition without motion, then roll the short
|
|
3680
|
+
// way on the next frame. The re-centre keeps the same digit under the
|
|
3681
|
+
// viewport, so the jump is invisible while guaranteeing room to travel.
|
|
3682
|
+
this.animating.set(false);
|
|
3683
|
+
this.offset.set(base);
|
|
3684
|
+
requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
3685
|
+
this.animating.set(true);
|
|
3686
|
+
this.offset.set(base + delta);
|
|
3687
|
+
}));
|
|
3688
|
+
}
|
|
3689
|
+
// Signed number of rows to travel from `from` to `to` around the `0-9` wheel,
|
|
3690
|
+
// taking the shorter arc (range `[-5, 5]`). Positive rolls up (9→0), negative
|
|
3691
|
+
// rolls down (0→9).
|
|
3692
|
+
_shortestDelta(from, to) {
|
|
3693
|
+
const half = ODOMETER_DIGITS_PER_REPETITION / 2;
|
|
3694
|
+
let delta = (to - from) % ODOMETER_DIGITS_PER_REPETITION;
|
|
3695
|
+
if (delta > half)
|
|
3696
|
+
delta -= ODOMETER_DIGITS_PER_REPETITION;
|
|
3697
|
+
if (delta < -half)
|
|
3698
|
+
delta += ODOMETER_DIGITS_PER_REPETITION;
|
|
3699
|
+
return delta;
|
|
3700
|
+
}
|
|
3701
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: OdometerDigit, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3702
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.1", type: OdometerDigit, isStandalone: true, selector: "tls-odometer-digit", inputs: { digit: { classPropertyName: "digit", publicName: "digit", isSignal: true, isRequired: true, transformFunction: null }, duration: { classPropertyName: "duration", publicName: "duration", isSignal: true, isRequired: true, transformFunction: null } }, host: { properties: { "style.--tls-odometer-duration.ms": "duration()" }, classAttribute: "tls-odometer-digit" }, ngImport: i0, template: `
|
|
3703
|
+
<span
|
|
3704
|
+
class="tls-odometer-digit__strip"
|
|
3705
|
+
[class.tls-odometer-digit__strip--animate]="animating()"
|
|
3706
|
+
[style.--tls-odometer-offset]="offset()"
|
|
3707
|
+
>
|
|
3708
|
+
@for (value of strip; track $index) {
|
|
3709
|
+
<span class="tls-odometer-digit__cell">{{ value }}</span>
|
|
3710
|
+
}
|
|
3711
|
+
</span>
|
|
3712
|
+
`, isInline: true });
|
|
3713
|
+
}
|
|
3714
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: OdometerDigit, decorators: [{
|
|
3715
|
+
type: Component,
|
|
3716
|
+
args: [{
|
|
3717
|
+
selector: 'tls-odometer-digit',
|
|
3718
|
+
imports: [],
|
|
3719
|
+
template: `
|
|
3720
|
+
<span
|
|
3721
|
+
class="tls-odometer-digit__strip"
|
|
3722
|
+
[class.tls-odometer-digit__strip--animate]="animating()"
|
|
3723
|
+
[style.--tls-odometer-offset]="offset()"
|
|
3724
|
+
>
|
|
3725
|
+
@for (value of strip; track $index) {
|
|
3726
|
+
<span class="tls-odometer-digit__cell">{{ value }}</span>
|
|
3727
|
+
}
|
|
3728
|
+
</span>
|
|
3729
|
+
`,
|
|
3730
|
+
host: {
|
|
3731
|
+
class: 'tls-odometer-digit',
|
|
3732
|
+
'[style.--tls-odometer-duration.ms]': 'duration()',
|
|
3733
|
+
},
|
|
3734
|
+
}]
|
|
3735
|
+
}], ctorParameters: () => [], propDecorators: { digit: [{ type: i0.Input, args: [{ isSignal: true, alias: "digit", required: true }] }], duration: [{ type: i0.Input, args: [{ isSignal: true, alias: "duration", required: true }] }] } });
|
|
3736
|
+
|
|
3737
|
+
const DEFAULT_ODOMETER_CONFIG = {
|
|
3738
|
+
duration: 600,
|
|
3739
|
+
minIntegerDigits: 1,
|
|
3740
|
+
fractionDigits: 0,
|
|
3741
|
+
decimalSeparator: '.',
|
|
3742
|
+
};
|
|
3743
|
+
|
|
3744
|
+
const ODOMETER_CONFIG = new InjectionToken('ODOMETER_CONFIG', {
|
|
3745
|
+
factory: () => DEFAULT_ODOMETER_CONFIG,
|
|
3746
|
+
});
|
|
3747
|
+
|
|
3748
|
+
/**
|
|
3749
|
+
* Animated number whose digits roll to the new value, like a mechanical
|
|
3750
|
+
* odometer. Each digit column rolls through the values between the old and the
|
|
3751
|
+
* new one by the shortest path, so counting up or down reads naturally.
|
|
3752
|
+
*
|
|
3753
|
+
* The value scales with the surrounding `font-size`. The roll is a functional
|
|
3754
|
+
* cue on the `essential` motion tier, so it is replaced by an instant swap when
|
|
3755
|
+
* the user has reduced motion.
|
|
3756
|
+
*
|
|
3757
|
+
* @example
|
|
3758
|
+
* <!-- a live score -->
|
|
3759
|
+
* <tls-odometer [value]="score()" />
|
|
3760
|
+
*
|
|
3761
|
+
* @example
|
|
3762
|
+
* <!-- fixed-width counter with two decimals -->
|
|
3763
|
+
* <tls-odometer [value]="balance()" [minIntegerDigits]="4" [fractionDigits]="2" />
|
|
3764
|
+
*/
|
|
3765
|
+
class Odometer {
|
|
3766
|
+
// Injections
|
|
3767
|
+
_config = inject(ODOMETER_CONFIG);
|
|
3768
|
+
// Inputs
|
|
3769
|
+
/** The number to display. Changes roll the affected digit columns. */
|
|
3770
|
+
value = input.required(...(ngDevMode ? [{ debugName: "value" }] : []));
|
|
3771
|
+
/** Duration of a single-digit roll, in milliseconds. */
|
|
3772
|
+
duration = input(this._config.duration, ...(ngDevMode ? [{ debugName: "duration" }] : []));
|
|
3773
|
+
/** Minimum number of integer digits, left-padded with zeros (`007`). */
|
|
3774
|
+
minIntegerDigits = input(this._config.minIntegerDigits, ...(ngDevMode ? [{ debugName: "minIntegerDigits" }] : []));
|
|
3775
|
+
/** Number of fraction digits to display. `0` hides the decimal part. */
|
|
3776
|
+
fractionDigits = input(this._config.fractionDigits, ...(ngDevMode ? [{ debugName: "fractionDigits" }] : []));
|
|
3777
|
+
/** Character rendered between the integer and fraction parts. */
|
|
3778
|
+
decimalSeparator = input(this._config.decimalSeparator, ...(ngDevMode ? [{ debugName: "decimalSeparator" }] : []));
|
|
3779
|
+
/** Overrides the text announced to screen readers (defaults to the formatted value). */
|
|
3780
|
+
ariaLabel = input(undefined, ...(ngDevMode ? [{ debugName: "ariaLabel" }] : []));
|
|
3781
|
+
// Computed
|
|
3782
|
+
tokens = computed(() => {
|
|
3783
|
+
const value = this.value();
|
|
3784
|
+
const fractionDigits = this.fractionDigits();
|
|
3785
|
+
const minIntegerDigits = this.minIntegerDigits();
|
|
3786
|
+
const isNegative = value < 0;
|
|
3787
|
+
const [integerText, fractionText = ''] = Math.abs(value).toFixed(fractionDigits).split('.');
|
|
3788
|
+
const paddedInteger = integerText.padStart(minIntegerDigits, '0');
|
|
3789
|
+
const tokens = [];
|
|
3790
|
+
if (isNegative)
|
|
3791
|
+
tokens.push({ key: 'sign', digit: null, symbol: ODOMETER_MINUS_SIGN });
|
|
3792
|
+
const integerLength = paddedInteger.length;
|
|
3793
|
+
for (let index = 0; index < integerLength; index++) {
|
|
3794
|
+
// Key by place value counting from the units digit, so a column keeps its
|
|
3795
|
+
// identity when the number gains or loses leading digits.
|
|
3796
|
+
const place = integerLength - index;
|
|
3797
|
+
tokens.push({ key: `integer-${place}`, digit: Number(paddedInteger[index]), symbol: null });
|
|
3798
|
+
}
|
|
3799
|
+
if (fractionDigits > 0) {
|
|
3800
|
+
tokens.push({ key: 'point', digit: null, symbol: this.decimalSeparator() });
|
|
3801
|
+
for (let index = 0; index < fractionText.length; index++) {
|
|
3802
|
+
tokens.push({
|
|
3803
|
+
key: `fraction-${index + 1}`,
|
|
3804
|
+
digit: Number(fractionText[index]),
|
|
3805
|
+
symbol: null,
|
|
3806
|
+
});
|
|
3807
|
+
}
|
|
3808
|
+
}
|
|
3809
|
+
return tokens;
|
|
3810
|
+
}, ...(ngDevMode ? [{ debugName: "tokens" }] : []));
|
|
3811
|
+
formattedValue = computed(() => this.tokens()
|
|
3812
|
+
.map(token => (token.digit === null ? token.symbol : String(token.digit)))
|
|
3813
|
+
.join(''), ...(ngDevMode ? [{ debugName: "formattedValue" }] : []));
|
|
3814
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Odometer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3815
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.1", type: Odometer, isStandalone: true, selector: "tls-odometer", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, duration: { classPropertyName: "duration", publicName: "duration", isSignal: true, isRequired: false, transformFunction: null }, minIntegerDigits: { classPropertyName: "minIntegerDigits", publicName: "minIntegerDigits", isSignal: true, isRequired: false, transformFunction: null }, fractionDigits: { classPropertyName: "fractionDigits", publicName: "fractionDigits", isSignal: true, isRequired: false, transformFunction: null }, decimalSeparator: { classPropertyName: "decimalSeparator", publicName: "decimalSeparator", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "tls-odometer" }, ngImport: i0, template: "<span class=\"tls-odometer__value\">{{ ariaLabel() ?? formattedValue() }}</span>\n\n<span class=\"tls-odometer__row\" aria-hidden=\"true\">\n @for (token of tokens(); track token.key) {\n @if (token.digit === null) {\n <span class=\"tls-odometer__symbol\">{{ token.symbol }}</span>\n } @else {\n <tls-odometer-digit class=\"tls-odometer__digit\" [digit]=\"token.digit\" [duration]=\"duration()\" />\n }\n }\n</span>\n", dependencies: [{ kind: "component", type: OdometerDigit, selector: "tls-odometer-digit", inputs: ["digit", "duration"] }] });
|
|
3816
|
+
}
|
|
3817
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Odometer, decorators: [{
|
|
3818
|
+
type: Component,
|
|
3819
|
+
args: [{ selector: 'tls-odometer', imports: [OdometerDigit], host: {
|
|
3820
|
+
class: 'tls-odometer',
|
|
3821
|
+
}, template: "<span class=\"tls-odometer__value\">{{ ariaLabel() ?? formattedValue() }}</span>\n\n<span class=\"tls-odometer__row\" aria-hidden=\"true\">\n @for (token of tokens(); track token.key) {\n @if (token.digit === null) {\n <span class=\"tls-odometer__symbol\">{{ token.symbol }}</span>\n } @else {\n <tls-odometer-digit class=\"tls-odometer__digit\" [digit]=\"token.digit\" [duration]=\"duration()\" />\n }\n }\n</span>\n" }]
|
|
3822
|
+
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], duration: [{ type: i0.Input, args: [{ isSignal: true, alias: "duration", required: false }] }], minIntegerDigits: [{ type: i0.Input, args: [{ isSignal: true, alias: "minIntegerDigits", required: false }] }], fractionDigits: [{ type: i0.Input, args: [{ isSignal: true, alias: "fractionDigits", required: false }] }], decimalSeparator: [{ type: i0.Input, args: [{ isSignal: true, alias: "decimalSeparator", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }] } });
|
|
3823
|
+
|
|
2965
3824
|
const DEFAULT_PAGINATION_CONFIG = {
|
|
2966
3825
|
size: 'md',
|
|
2967
3826
|
pageSize: 10,
|
|
@@ -3055,6 +3914,44 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImpor
|
|
|
3055
3914
|
}, template: "@if (showFirstButton()) {\n <button\n id=\"tls-pagination-first\"\n class=\"tls-pagination__button\"\n [disabled]=\"value() === 1\"\n (click)=\"firstPage()\"\n >\n <span class=\"tls-pagination__button-icon\">\n <svg xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\">\n <polyline points=\"11 17 6 12 11 7\" />\n <polyline points=\"18 17 13 12 18 7\" />\n </svg>\n </span>\n </button>\n}\n\n<button\n id=\"tls-pagination-prev\"\n class=\"tls-pagination__button\"\n [disabled]=\"value() === 1\"\n (click)=\"prevPage()\"\n>\n <span class=\"tls-pagination__button-icon\">\n <svg xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\">\n <polyline points=\"15 18 9 12 15 6\" />\n </svg>\n </span>\n</button>\n\n<ul class=\"tls-pagination__list\">\n @for (item of visiblePages(); track $index) {\n <li class=\"tls-pagination__item\">\n @if (item === 'gap') {\n <span class=\"tls-pagination__gap\">...</span>\n } @else {\n <button\n class=\"tls-pagination__item-button\"\n [class.tls-pagination__item-button--active]=\"value() === item\"\n (click)=\"setPage(item)\"\n >\n {{ item }}\n </button>\n }\n </li>\n }\n</ul>\n\n<button\n id=\"tls-pagination-next\"\n class=\"tls-pagination__button\"\n [disabled]=\"value() === pageCount()\"\n (click)=\"nextPage()\"\n>\n <span class=\"tls-pagination__button-icon\">\n <svg xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\">\n <polyline points=\"9 18 15 12 9 6\" />\n </svg>\n </span>\n</button>\n\n@if (showLastButton()) {\n <button\n id=\"tls-pagination-last\"\n class=\"tls-pagination__button\"\n [disabled]=\"value() === pageCount()\"\n (click)=\"lastPage()\"\n >\n <span class=\"tls-pagination__button-icon\">\n <svg xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\">\n <polyline points=\"13 17 18 12 13 7\" />\n <polyline points=\"6 17 11 12 6 7\" />\n </svg>\n </span>\n </button>\n}\n" }]
|
|
3056
3915
|
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], ariaLabelledby: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabelledby", required: false }] }], pageSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "pageSize", required: false }] }], total: [{ type: i0.Input, args: [{ isSignal: true, alias: "total", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], boundaries: [{ type: i0.Input, args: [{ isSignal: true, alias: "boundaries", required: false }] }], siblings: [{ type: i0.Input, args: [{ isSignal: true, alias: "siblings", required: false }] }], showFirstButton: [{ type: i0.Input, args: [{ isSignal: true, alias: "showFirstButton", required: false }] }], showLastButton: [{ type: i0.Input, args: [{ isSignal: true, alias: "showLastButton", required: false }] }] } });
|
|
3057
3916
|
|
|
3917
|
+
const DEFAULT_PAGINATION_QUERY_SYNC_CONFIG = {
|
|
3918
|
+
paramKey: 'page',
|
|
3919
|
+
};
|
|
3920
|
+
|
|
3921
|
+
const PAGINATION_QUERY_SYNC_CONFIG = new InjectionToken('PAGINATION_QUERY_SYNC_CONFIG', { factory: () => DEFAULT_PAGINATION_QUERY_SYNC_CONFIG });
|
|
3922
|
+
|
|
3923
|
+
class PaginationQuerySyncDirective extends QuerySyncDirective {
|
|
3924
|
+
_pagination = inject(Pagination);
|
|
3925
|
+
_config = inject(PAGINATION_QUERY_SYNC_CONFIG);
|
|
3926
|
+
// Inputs
|
|
3927
|
+
tlsPaginationQuerySync = input(this._config.paramKey, ...(ngDevMode ? [{ debugName: "tlsPaginationQuerySync" }] : []));
|
|
3928
|
+
constructor() {
|
|
3929
|
+
super();
|
|
3930
|
+
effect(() => {
|
|
3931
|
+
const page = this._pagination.value();
|
|
3932
|
+
const param = this.tlsPaginationQuerySync();
|
|
3933
|
+
this.syncToUrl(param, page);
|
|
3934
|
+
});
|
|
3935
|
+
}
|
|
3936
|
+
// Lifecycle
|
|
3937
|
+
ngOnInit() {
|
|
3938
|
+
const raw = this.readParam(this.tlsPaginationQuerySync());
|
|
3939
|
+
if (raw === null)
|
|
3940
|
+
return;
|
|
3941
|
+
const page = Number(raw);
|
|
3942
|
+
if (!Number.isNaN(page) && page >= 1)
|
|
3943
|
+
this._pagination.value.set(page);
|
|
3944
|
+
}
|
|
3945
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: PaginationQuerySyncDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
3946
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.1", type: PaginationQuerySyncDirective, isStandalone: true, selector: "tls-pagination[tlsPaginationQuerySync]", inputs: { tlsPaginationQuerySync: { classPropertyName: "tlsPaginationQuerySync", publicName: "tlsPaginationQuerySync", isSignal: true, isRequired: false, transformFunction: null } }, usesInheritance: true, ngImport: i0 });
|
|
3947
|
+
}
|
|
3948
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: PaginationQuerySyncDirective, decorators: [{
|
|
3949
|
+
type: Directive,
|
|
3950
|
+
args: [{
|
|
3951
|
+
selector: 'tls-pagination[tlsPaginationQuerySync]',
|
|
3952
|
+
}]
|
|
3953
|
+
}], ctorParameters: () => [], propDecorators: { tlsPaginationQuerySync: [{ type: i0.Input, args: [{ isSignal: true, alias: "tlsPaginationQuerySync", required: false }] }] } });
|
|
3954
|
+
|
|
3058
3955
|
const DEFAULT_SKELETON_CONFIG = {
|
|
3059
3956
|
size: null,
|
|
3060
3957
|
width: null,
|
|
@@ -3181,6 +4078,7 @@ class Stepper {
|
|
|
3181
4078
|
panelId = `tls-stepper-panel-${++Stepper._counter}`;
|
|
3182
4079
|
_config = inject(STEPPER_CONFIG);
|
|
3183
4080
|
_stepperService = inject(StepperService);
|
|
4081
|
+
_directionality = inject(Directionality);
|
|
3184
4082
|
steps = contentChildren(Step, ...(ngDevMode ? [{ debugName: "steps" }] : []));
|
|
3185
4083
|
completedTemplateRef = contentChild('completedTemplate', ...(ngDevMode ? [{ debugName: "completedTemplateRef" }] : []));
|
|
3186
4084
|
completedIconTemplateRef = contentChild('stepCompletedIcon', ...(ngDevMode ? [{ debugName: "completedIconTemplateRef" }] : []));
|
|
@@ -3220,8 +4118,12 @@ class Stepper {
|
|
|
3220
4118
|
}
|
|
3221
4119
|
onKeydown(event, index) {
|
|
3222
4120
|
const orientation = this.orientation();
|
|
3223
|
-
|
|
3224
|
-
const
|
|
4121
|
+
// Horizontal arrows are physical; swap them in RTL so Next still advances.
|
|
4122
|
+
const isRtl = this._directionality.value === 'rtl';
|
|
4123
|
+
const horizontalNext = isRtl ? 'ArrowLeft' : 'ArrowRight';
|
|
4124
|
+
const horizontalPrev = isRtl ? 'ArrowRight' : 'ArrowLeft';
|
|
4125
|
+
const keyNext = orientation === 'horizontal' ? horizontalNext : 'ArrowDown';
|
|
4126
|
+
const keyPrev = orientation === 'horizontal' ? horizontalPrev : 'ArrowUp';
|
|
3225
4127
|
let target = null;
|
|
3226
4128
|
switch (event.key) {
|
|
3227
4129
|
case keyNext:
|
|
@@ -3470,6 +4372,45 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImpor
|
|
|
3470
4372
|
}, providers: [TabsService], template: "<ul\n class=\"tls-tabs-header\"\n role=\"tablist\"\n [attr.aria-label]=\"ariaLabel() ?? null\"\n [attr.aria-labelledby]=\"ariaLabelledby() ?? null\"\n>\n @for (tab of tabs(); track tab) {\n <li\n class=\"tls-tabs-header__item\"\n [class.tls-tabs-header__item--active]=\"tab.value() === selected()\"\n >\n <button\n class=\"tls-tabs-header__item-button\"\n role=\"tab\"\n (click)=\"selected.set(tab.value())\"\n [attr.aria-selected]=\"tab.value() === selected()\"\n >\n {{ tab.label() }}\n </button>\n </li>\n }\n</ul>\n<div class=\"tls-tabs-content\">\n <ng-content></ng-content>\n</div>\n" }]
|
|
3471
4373
|
}], ctorParameters: () => [], propDecorators: { tabs: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => Tab), { isSignal: true }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], selected: [{ type: i0.Input, args: [{ isSignal: true, alias: "selected", required: false }] }, { type: i0.Output, args: ["selectedChange"] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], ariaLabelledby: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabelledby", required: false }] }] } });
|
|
3472
4374
|
|
|
4375
|
+
const DEFAULT_TABS_QUERY_SYNC_CONFIG = {
|
|
4376
|
+
paramKey: 'tab',
|
|
4377
|
+
};
|
|
4378
|
+
|
|
4379
|
+
const TABS_QUERY_SYNC_CONFIG = new InjectionToken('TABS_QUERY_SYNC_CONFIG', {
|
|
4380
|
+
factory: () => DEFAULT_TABS_QUERY_SYNC_CONFIG,
|
|
4381
|
+
});
|
|
4382
|
+
|
|
4383
|
+
class TabsQuerySyncDirective extends QuerySyncDirective {
|
|
4384
|
+
_tabs = inject(Tabs);
|
|
4385
|
+
_config = inject(TABS_QUERY_SYNC_CONFIG);
|
|
4386
|
+
// Inputs
|
|
4387
|
+
tlsTabsQuerySync = input(this._config.paramKey, ...(ngDevMode ? [{ debugName: "tlsTabsQuerySync" }] : []));
|
|
4388
|
+
constructor() {
|
|
4389
|
+
super();
|
|
4390
|
+
effect(() => {
|
|
4391
|
+
const selected = this._tabs.selected();
|
|
4392
|
+
const param = this.tlsTabsQuerySync();
|
|
4393
|
+
if (selected === null)
|
|
4394
|
+
return;
|
|
4395
|
+
this.syncToUrl(param, selected);
|
|
4396
|
+
});
|
|
4397
|
+
}
|
|
4398
|
+
// Lifecycle
|
|
4399
|
+
ngOnInit() {
|
|
4400
|
+
const value = this.readParam(this.tlsTabsQuerySync());
|
|
4401
|
+
if (value !== null)
|
|
4402
|
+
this._tabs.selected.set(value);
|
|
4403
|
+
}
|
|
4404
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: TabsQuerySyncDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
4405
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.1", type: TabsQuerySyncDirective, isStandalone: true, selector: "tls-tabs[tlsTabsQuerySync]", inputs: { tlsTabsQuerySync: { classPropertyName: "tlsTabsQuerySync", publicName: "tlsTabsQuerySync", isSignal: true, isRequired: false, transformFunction: null } }, usesInheritance: true, ngImport: i0 });
|
|
4406
|
+
}
|
|
4407
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: TabsQuerySyncDirective, decorators: [{
|
|
4408
|
+
type: Directive,
|
|
4409
|
+
args: [{
|
|
4410
|
+
selector: 'tls-tabs[tlsTabsQuerySync]',
|
|
4411
|
+
}]
|
|
4412
|
+
}], ctorParameters: () => [], propDecorators: { tlsTabsQuerySync: [{ type: i0.Input, args: [{ isSignal: true, alias: "tlsTabsQuerySync", required: false }] }] } });
|
|
4413
|
+
|
|
3473
4414
|
class Tooltip {
|
|
3474
4415
|
static _counter = 0;
|
|
3475
4416
|
id = `tls-tooltip-${++Tooltip._counter}`;
|
|
@@ -3489,7 +4430,7 @@ class Tooltip {
|
|
|
3489
4430
|
return array;
|
|
3490
4431
|
}, ...(ngDevMode ? [{ debugName: "hostClasses" }] : []));
|
|
3491
4432
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Tooltip, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3492
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.1", type: Tooltip, isStandalone: true, selector: "tls-tooltip", inputs: { content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: true, transformFunction: null }, templateData: { classPropertyName: "templateData", publicName: "templateData", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { content: "contentChange", templateData: "templateDataChange", color: "colorChange" }, host: { attributes: { "role": "tooltip" }, properties: { "class": "hostClasses()", "id": "id" } }, ngImport: i0, template: `
|
|
4433
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.1", type: Tooltip, isStandalone: true, selector: "tls-tooltip", inputs: { content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: true, transformFunction: null }, templateData: { classPropertyName: "templateData", publicName: "templateData", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { content: "contentChange", templateData: "templateDataChange", color: "colorChange" }, host: { attributes: { "role": "tooltip", "animate.enter": "tls-tooltip--enter", "animate.leave": "tls-tooltip--leave" }, properties: { "class": "hostClasses()", "id": "id" } }, ngImport: i0, template: `
|
|
3493
4434
|
@if (isString()) {
|
|
3494
4435
|
{{ content() }}
|
|
3495
4436
|
} @else {
|
|
@@ -3519,10 +4460,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImpor
|
|
|
3519
4460
|
'[class]': 'hostClasses()',
|
|
3520
4461
|
'role': 'tooltip',
|
|
3521
4462
|
'[id]': 'id',
|
|
4463
|
+
'animate.enter': 'tls-tooltip--enter',
|
|
4464
|
+
'animate.leave': 'tls-tooltip--leave',
|
|
3522
4465
|
},
|
|
3523
4466
|
}]
|
|
3524
4467
|
}], propDecorators: { content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: true }] }, { type: i0.Output, args: ["contentChange"] }], templateData: [{ type: i0.Input, args: [{ isSignal: true, alias: "templateData", required: false }] }, { type: i0.Output, args: ["templateDataChange"] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: true }] }, { type: i0.Output, args: ["colorChange"] }] } });
|
|
3525
4468
|
|
|
4469
|
+
// Upper bound for how long to keep a detached tooltip pane alive so its
|
|
4470
|
+
// `animate.leave` can finish. Disposes on `animationend`; this timeout only
|
|
4471
|
+
// fires when no exit animation runs (e.g. the `none` motion level).
|
|
4472
|
+
const LEAVE_ANIMATION_FALLBACK_MS = 500;
|
|
4473
|
+
|
|
3526
4474
|
class TooltipService {
|
|
3527
4475
|
_overlay = inject(Overlay);
|
|
3528
4476
|
_overlayRef = null;
|
|
@@ -3548,12 +4496,44 @@ class TooltipService {
|
|
|
3548
4496
|
this._overlayRef.updatePositionStrategy(positionStrategy);
|
|
3549
4497
|
}
|
|
3550
4498
|
}
|
|
4499
|
+
// Detaches the tooltip so Angular's `animate.leave` plays the exit animation,
|
|
4500
|
+
// then disposes the pane once that animation finishes. The pane is kept alive
|
|
4501
|
+
// in the meantime so it is not torn down mid-animation.
|
|
4502
|
+
hide() {
|
|
4503
|
+
if (!this._overlayRef)
|
|
4504
|
+
return;
|
|
4505
|
+
const overlayRef = this._overlayRef;
|
|
4506
|
+
this._overlayRef = null;
|
|
4507
|
+
overlayRef.detach();
|
|
4508
|
+
this._disposeAfterAnimation(overlayRef);
|
|
4509
|
+
}
|
|
3551
4510
|
dispose() {
|
|
3552
4511
|
if (!this._overlayRef)
|
|
3553
4512
|
return;
|
|
3554
4513
|
this._overlayRef.dispose();
|
|
3555
4514
|
this._overlayRef = null;
|
|
3556
4515
|
}
|
|
4516
|
+
// Private methods
|
|
4517
|
+
// Disposes a detached overlay once the tooltip's exit animation has finished.
|
|
4518
|
+
// Falls back to a timeout when no animation runs (e.g. the `none` motion level).
|
|
4519
|
+
_disposeAfterAnimation(overlayRef) {
|
|
4520
|
+
const paneElement = overlayRef.overlayElement;
|
|
4521
|
+
if (!paneElement) {
|
|
4522
|
+
overlayRef.dispose();
|
|
4523
|
+
return;
|
|
4524
|
+
}
|
|
4525
|
+
let settled = false;
|
|
4526
|
+
const finalize = () => {
|
|
4527
|
+
if (settled)
|
|
4528
|
+
return;
|
|
4529
|
+
settled = true;
|
|
4530
|
+
window.clearTimeout(timeoutId);
|
|
4531
|
+
paneElement.removeEventListener('animationend', finalize);
|
|
4532
|
+
overlayRef.dispose();
|
|
4533
|
+
};
|
|
4534
|
+
paneElement.addEventListener('animationend', finalize);
|
|
4535
|
+
const timeoutId = window.setTimeout(finalize, LEAVE_ANIMATION_FALLBACK_MS);
|
|
4536
|
+
}
|
|
3557
4537
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: TooltipService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3558
4538
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: TooltipService });
|
|
3559
4539
|
}
|
|
@@ -3603,7 +4583,7 @@ class TooltipDirective {
|
|
|
3603
4583
|
}
|
|
3604
4584
|
}
|
|
3605
4585
|
onMouseLeave() {
|
|
3606
|
-
this.
|
|
4586
|
+
this._hide();
|
|
3607
4587
|
}
|
|
3608
4588
|
onTouchStart(event) {
|
|
3609
4589
|
event.preventDefault();
|
|
@@ -3630,7 +4610,7 @@ class TooltipDirective {
|
|
|
3630
4610
|
this._renderer.setAttribute(this._elementRef.nativeElement, 'aria-describedby', tooltipRef.instance.id);
|
|
3631
4611
|
}
|
|
3632
4612
|
_hide() {
|
|
3633
|
-
this._tooltipService.
|
|
4613
|
+
this._tooltipService.hide();
|
|
3634
4614
|
this._visible.set(false);
|
|
3635
4615
|
this._renderer.removeAttribute(this._elementRef.nativeElement, 'aria-describedby');
|
|
3636
4616
|
}
|
|
@@ -3725,6 +4705,10 @@ const provideThalassicUIConfig = (config) => {
|
|
|
3725
4705
|
provide: PAGINATION_CONFIG,
|
|
3726
4706
|
useValue: deepMerge(DEFAULT_PAGINATION_CONFIG, config.components.pagination),
|
|
3727
4707
|
},
|
|
4708
|
+
{
|
|
4709
|
+
provide: PAGINATION_QUERY_SYNC_CONFIG,
|
|
4710
|
+
useValue: deepMerge(DEFAULT_PAGINATION_QUERY_SYNC_CONFIG, config.components.paginationQuerySync),
|
|
4711
|
+
},
|
|
3728
4712
|
{
|
|
3729
4713
|
provide: PASSWORD_CONFIG,
|
|
3730
4714
|
useValue: deepMerge(DEFAULT_PASSWORD_CONFIG, config.components.password),
|
|
@@ -3759,6 +4743,10 @@ const provideThalassicUIConfig = (config) => {
|
|
|
3759
4743
|
},
|
|
3760
4744
|
{ provide: TABLE_CONFIG, useValue: deepMerge(DEFAULT_TABLE_CONFIG, config.components.table) },
|
|
3761
4745
|
{ provide: TABS_CONFIG, useValue: deepMerge(DEFAULT_TABS_CONFIG, config.components.tabs) },
|
|
4746
|
+
{
|
|
4747
|
+
provide: TABS_QUERY_SYNC_CONFIG,
|
|
4748
|
+
useValue: deepMerge(DEFAULT_TABS_QUERY_SYNC_CONFIG, config.components.tabsQuerySync),
|
|
4749
|
+
},
|
|
3762
4750
|
{
|
|
3763
4751
|
provide: TEXTAREA_CONFIG,
|
|
3764
4752
|
useValue: deepMerge(DEFAULT_TEXTAREA_CONFIG, config.components.textarea),
|
|
@@ -3778,5 +4766,5 @@ const provideThalassicUIConfig = (config) => {
|
|
|
3778
4766
|
* Generated bundle index. Do not edit.
|
|
3779
4767
|
*/
|
|
3780
4768
|
|
|
3781
|
-
export { ALERT_CONFIG, Alert, BUTTON_CONFIG, Button, ButtonDirective, CHECKBOX_CONFIG, CHIP_CONFIG, CHIP_CONTROL_CONFIG, CHIP_GROUP_CONFIG, CHIP_INPUT_CONFIG, Checkbox, CheckboxFormControl, Chip, ChipControl, ChipGroup, ChipInput, ContextMenuDirective, DATE_TIME_PICKER_CONFIG, DEFAULT_ALERT_CONFIG, DEFAULT_BUTTON_CONFIG, DEFAULT_CHECKBOX_CONFIG, DEFAULT_CHIP_CONFIG, DEFAULT_CHIP_CONTROL_CONFIG, DEFAULT_CHIP_GROUP_CONFIG, DEFAULT_CHIP_INPUT_CONFIG, DEFAULT_DATE_TIME_PICKER_CONFIG, DEFAULT_DIALOG_CONFIG, DEFAULT_DIVIDER_CONFIG, DEFAULT_FILE_UPLOADER_CONFIG, DEFAULT_FORM_CONTROL_GROUP_CONFIG, DEFAULT_FORM_ITEM_CONFIG, DEFAULT_ICON_CONFIG, DEFAULT_INPUT_CONFIG, DEFAULT_INPUT_NUMBER_CONFIG, DEFAULT_LOADER_CONFIG, DEFAULT_MENU_CONFIG, DEFAULT_MULTI_SELECT_CONFIG, DEFAULT_PAGINATION_CONFIG, DEFAULT_PASSWORD_CONFIG, DEFAULT_PIN_INPUT_CONFIG, DEFAULT_POPOVER_CONFIG, DEFAULT_RADIO_BUTTON_CONFIG, DEFAULT_SELECT_CONFIG, DEFAULT_SKELETON_CONFIG, DEFAULT_STEPPER_CONFIG, DEFAULT_STEP_CONFIG, DEFAULT_SWITCH_CONFIG, DEFAULT_TABLE_CONFIG, DEFAULT_TABS_CONFIG, DEFAULT_TEXTAREA_CONFIG, DEFAULT_TOGGLE_GROUP_CONFIG, DEFAULT_TOOLTIP_CONFIG, DIALOG_CONFIG, DIVIDER_CONFIG, DateTimePicker, Dialog, DialogService, Divider, FILE_UPLOADER_CONFIG, FORM_CONTROL_GROUP_CONFIG, FORM_ITEM_CONFIG, FileUploader, FormControl, FormControlAddon, FormControlGroup, FormItem, ICON_CONFIG, INPUT_CONFIG, INPUT_NUMBER_CONFIG, Icon, Input, InputDirective, InputNumber, LOADER_CONFIG, Loader, MENU_CONFIG, MULTI_SELECT_CONFIG, Menu, MenuItemComponent, MenuTriggerDirective, MultiSelect, PAGINATION_CONFIG, PASSWORD_CONFIG, PIN_INPUT_CONFIG, POPOVER_CONFIG, Pagination, Password, PinInput, Popover, RADIO_BUTTON_CONFIG, RadioButton, SELECT_CONFIG, SKELETON_CONFIG, STEPPER_CONFIG, SWITCH_CONFIG, Select, Skeleton, Step, Stepper, Switch, TABLE_CONFIG, TABS_CONFIG, TEXTAREA_CONFIG, TOGGLE_GROUP_CONFIG, TOOLTIP_CONFIG, Tab, Table, TableColumn, Tabs, Textarea, ToggleGroup, TooltipDirective, ValueFormControl, provideThalassicUIConfig };
|
|
4769
|
+
export { ALERT_CONFIG, Alert, BUTTON_CONFIG, Button, ButtonDirective, CHECKBOX_CONFIG, CHIP_CONFIG, CHIP_CONTROL_CONFIG, CHIP_GROUP_CONFIG, CHIP_INPUT_CONFIG, CONFIRM_CONFIG, Checkbox, CheckboxFormControl, Chip, ChipControl, ChipGroup, ChipInput, Confirm, ConfirmPanel, ConfirmService, ContextMenuDirective, DATE_TIME_PICKER_CONFIG, DEFAULT_ALERT_CONFIG, DEFAULT_BUTTON_CONFIG, DEFAULT_CHECKBOX_CONFIG, DEFAULT_CHIP_CONFIG, DEFAULT_CHIP_CONTROL_CONFIG, DEFAULT_CHIP_GROUP_CONFIG, DEFAULT_CHIP_INPUT_CONFIG, DEFAULT_CONFIRM_CONFIG, DEFAULT_DATE_TIME_PICKER_CONFIG, DEFAULT_DIALOG_CONFIG, DEFAULT_DIVIDER_CONFIG, DEFAULT_DRAWER_CONFIG, DEFAULT_FILE_UPLOADER_CONFIG, DEFAULT_FORM_CONTROL_GROUP_CONFIG, DEFAULT_FORM_ITEM_CONFIG, DEFAULT_ICON_CONFIG, DEFAULT_INPUT_CONFIG, DEFAULT_INPUT_NUMBER_CONFIG, DEFAULT_LOADER_CONFIG, DEFAULT_MENU_CONFIG, DEFAULT_MULTI_SELECT_CONFIG, DEFAULT_ODOMETER_CONFIG, DEFAULT_PAGINATION_CONFIG, DEFAULT_PAGINATION_QUERY_SYNC_CONFIG, DEFAULT_PASSWORD_CONFIG, DEFAULT_PIN_INPUT_CONFIG, DEFAULT_POPOVER_CONFIG, DEFAULT_RADIO_BUTTON_CONFIG, DEFAULT_SELECT_CONFIG, DEFAULT_SKELETON_CONFIG, DEFAULT_STEPPER_CONFIG, DEFAULT_STEP_CONFIG, DEFAULT_SWITCH_CONFIG, DEFAULT_TABLE_CONFIG, DEFAULT_TABS_CONFIG, DEFAULT_TABS_QUERY_SYNC_CONFIG, DEFAULT_TEXTAREA_CONFIG, DEFAULT_TOGGLE_GROUP_CONFIG, DEFAULT_TOOLTIP_CONFIG, DIALOG_CONFIG, DIVIDER_CONFIG, DRAWER_CONFIG, DateTimePicker, Dialog, DialogService, Divider, Drawer, DrawerRef, DrawerService, FILE_UPLOADER_CONFIG, FORM_CONTROL_GROUP_CONFIG, FORM_ITEM_CONFIG, FileUploader, FormControl, FormControlAddon, FormControlGroup, FormItem, ICON_CONFIG, INPUT_CONFIG, INPUT_NUMBER_CONFIG, Icon, Input, InputDirective, InputNumber, LOADER_CONFIG, Loader, MENU_CONFIG, MULTI_SELECT_CONFIG, Menu, MenuItemComponent, MenuTriggerDirective, MultiSelect, ODOMETER_CONFIG, Odometer, PAGINATION_CONFIG, PAGINATION_QUERY_SYNC_CONFIG, PASSWORD_CONFIG, PIN_INPUT_CONFIG, POPOVER_CONFIG, Pagination, PaginationQuerySyncDirective, Password, PinInput, Popover, RADIO_BUTTON_CONFIG, RadioButton, SELECT_CONFIG, SKELETON_CONFIG, STEPPER_CONFIG, SWITCH_CONFIG, Select, Skeleton, Step, Stepper, Switch, TABLE_CONFIG, TABS_CONFIG, TABS_QUERY_SYNC_CONFIG, TEXTAREA_CONFIG, TOGGLE_GROUP_CONFIG, TOOLTIP_CONFIG, Tab, Table, TableColumn, Tabs, TabsQuerySyncDirective, Textarea, ToggleGroup, TooltipDirective, ValueFormControl, provideThalassicUIConfig };
|
|
3782
4770
|
//# sourceMappingURL=thalassic-ui.mjs.map
|