@thalassic/ui 0.18.0 → 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.
@@ -1,11 +1,13 @@
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, Injectable, output, numberAttribute, viewChildren, contentChildren, isDevMode, TemplateRef, ElementRef, Renderer2, makeEnvironmentProviders } from '@angular/core';
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, CdkPortalOutlet, ComponentPortal } from '@angular/cdk/portal';
4
+ import { TemplatePortal, ComponentPortal, CdkPortalOutlet } from '@angular/cdk/portal';
5
5
  import { takeUntilDestroyed, rxResource, toObservable } from '@angular/core/rxjs-interop';
6
- import { filter, takeUntil, throwError, map, shareReplay } from 'rxjs';
7
- import { Router, ActivatedRoute, RouterLink } from '@angular/router';
6
+ import { filter, Subscription, takeUntil, throwError, map, shareReplay } from 'rxjs';
7
+ import { Router, ActivatedRoute, RouterLink, NavigationStart } from '@angular/router';
8
8
  import { LocationStrategy, NgTemplateOutlet } from '@angular/common';
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';
10
12
  import { Directionality } from '@angular/cdk/bidi';
11
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';
@@ -225,7 +227,7 @@ const TRANSPARENT_BACKDROP_CLASS = 'cdk-overlay-transparent-backdrop';
225
227
  // Upper bound for how long to keep a non-reused pane alive after detach so the
226
228
  // panel's `animate.leave` can finish. Disposes on `animationend`; this only
227
229
  // fires when no exit animation runs (e.g. the `none` motion level).
228
- const LEAVE_ANIMATION_FALLBACK_MS$2 = 500;
230
+ const LEAVE_ANIMATION_FALLBACK_MS$3 = 500;
229
231
  /**
230
232
  * Owns the CDK-Overlay lifecycle shared by the library's connected overlay
231
233
  * components (popover, menu, select): create/attach, dismissal wiring
@@ -367,7 +369,7 @@ class OverlayManager {
367
369
  overlayRef.dispose();
368
370
  };
369
371
  paneElement.addEventListener('animationend', finalize);
370
- const timeoutId = window.setTimeout(finalize, LEAVE_ANIMATION_FALLBACK_MS$2);
372
+ const timeoutId = window.setTimeout(finalize, LEAVE_ANIMATION_FALLBACK_MS$3);
371
373
  }
372
374
  _dispose() {
373
375
  this._overlayRef?.dispose();
@@ -904,6 +906,554 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImpor
904
906
  }]
905
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 }] }] } });
906
908
 
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
+ },
1038
+ };
1039
+
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,
1061
+ });
1062
+
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());
1103
+ }
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
+ };
1117
+ }
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"] }] });
1159
+ }
1160
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ConfirmPanel, decorators: [{
1161
+ type: Component,
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"] }] } });
1211
+
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(),
1256
+ });
1257
+ }
1258
+ close() {
1259
+ this._overlay.close();
1260
+ }
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
+
907
1457
  const DEFAULT_DIALOG_CONFIG = {
908
1458
  size: 'md',
909
1459
  closeable: true,
@@ -1462,148 +2012,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImpor
1462
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" }]
1463
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 }] }] } });
1464
2014
 
1465
- const OVERLAY_POSITION_MAP = {
1466
- top: {
1467
- originX: 'center',
1468
- originY: 'top',
1469
- overlayX: 'center',
1470
- overlayY: 'bottom',
1471
- offsetX: 0,
1472
- offsetY: -1,
1473
- },
1474
- right: {
1475
- originX: 'end',
1476
- originY: 'center',
1477
- overlayX: 'start',
1478
- overlayY: 'center',
1479
- offsetX: 1,
1480
- offsetY: 0,
1481
- },
1482
- bottom: {
1483
- originX: 'center',
1484
- originY: 'bottom',
1485
- overlayX: 'center',
1486
- overlayY: 'top',
1487
- offsetX: 1,
1488
- offsetY: 1,
1489
- },
1490
- left: {
1491
- originX: 'start',
1492
- originY: 'center',
1493
- overlayX: 'end',
1494
- overlayY: 'center',
1495
- offsetX: -1,
1496
- offsetY: 0,
1497
- },
1498
- 'top-start': {
1499
- originX: 'start',
1500
- originY: 'top',
1501
- overlayX: 'start',
1502
- overlayY: 'bottom',
1503
- offsetX: 0,
1504
- offsetY: -1,
1505
- },
1506
- 'top-end': {
1507
- originX: 'end',
1508
- originY: 'top',
1509
- overlayX: 'end',
1510
- overlayY: 'bottom',
1511
- offsetX: 0,
1512
- offsetY: -1,
1513
- },
1514
- 'right-start': {
1515
- originX: 'end',
1516
- originY: 'top',
1517
- overlayX: 'start',
1518
- overlayY: 'top',
1519
- offsetX: 1,
1520
- offsetY: 0,
1521
- },
1522
- 'right-end': {
1523
- originX: 'end',
1524
- originY: 'bottom',
1525
- overlayX: 'start',
1526
- overlayY: 'bottom',
1527
- offsetX: 1,
1528
- offsetY: 0,
1529
- },
1530
- 'bottom-start': {
1531
- originX: 'start',
1532
- originY: 'bottom',
1533
- overlayX: 'start',
1534
- overlayY: 'top',
1535
- offsetX: 0,
1536
- offsetY: 1,
1537
- },
1538
- 'bottom-end': {
1539
- originX: 'end',
1540
- originY: 'bottom',
1541
- overlayX: 'end',
1542
- overlayY: 'top',
1543
- offsetX: 0,
1544
- offsetY: 1,
1545
- },
1546
- 'left-start': {
1547
- originX: 'start',
1548
- originY: 'top',
1549
- overlayX: 'end',
1550
- overlayY: 'top',
1551
- offsetX: -1,
1552
- offsetY: 0,
1553
- },
1554
- 'left-end': {
1555
- originX: 'start',
1556
- originY: 'bottom',
1557
- overlayX: 'end',
1558
- overlayY: 'bottom',
1559
- offsetX: -1,
1560
- offsetY: 0,
1561
- },
1562
- 'top-left': {
1563
- originX: 'start',
1564
- originY: 'top',
1565
- overlayX: 'end',
1566
- overlayY: 'bottom',
1567
- offsetX: -1,
1568
- offsetY: -1,
1569
- },
1570
- 'top-right': {
1571
- originX: 'end',
1572
- originY: 'top',
1573
- overlayX: 'start',
1574
- overlayY: 'bottom',
1575
- offsetX: 1,
1576
- offsetY: -1,
1577
- },
1578
- 'bottom-left': {
1579
- originX: 'start',
1580
- originY: 'bottom',
1581
- overlayX: 'end',
1582
- overlayY: 'top',
1583
- offsetX: -1,
1584
- offsetY: 1,
1585
- },
1586
- 'bottom-right': {
1587
- originX: 'end',
1588
- originY: 'bottom',
1589
- overlayX: 'start',
1590
- overlayY: 'top',
1591
- offsetX: 1,
1592
- offsetY: 1,
1593
- },
1594
- };
1595
-
1596
- const buildOverlayPositions = (position, offset) => {
1597
- const preferred = OVERLAY_POSITION_MAP[position];
1598
- const rest = Object.values(OVERLAY_POSITION_MAP).filter(p => p !== preferred);
1599
- const positions = [preferred, ...rest];
1600
- return positions.map(position => ({
1601
- ...position,
1602
- offsetX: Math.sign(position.offsetX ?? 0) * offset.x,
1603
- offsetY: Math.sign(position.offsetY ?? 0) * offset.y,
1604
- }));
1605
- };
1606
-
1607
2015
  const DEFAULT_POPOVER_CONFIG = {
1608
2016
  position: 'bottom',
1609
2017
  offset: { x: 0, y: 4 },
@@ -3209,6 +3617,210 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImpor
3209
3617
  }]
3210
3618
  }], propDecorators: { menu: [{ type: i0.Input, args: [{ isSignal: true, alias: "tlsContextMenu", required: true }] }] } });
3211
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
+
3212
3824
  const DEFAULT_PAGINATION_CONFIG = {
3213
3825
  size: 'md',
3214
3826
  pageSize: 10,
@@ -4154,5 +4766,5 @@ const provideThalassicUIConfig = (config) => {
4154
4766
  * Generated bundle index. Do not edit.
4155
4767
  */
4156
4768
 
4157
- 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_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_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, 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 };
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 };
4158
4770
  //# sourceMappingURL=thalassic-ui.mjs.map