@ibragim-dev-org/ui-forge-library 1.2.4 → 1.2.6
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.
|
@@ -2,7 +2,7 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { input, effect, Directive, Injectable, EventEmitter, Output, Input, PLATFORM_ID, Inject, Pipe, Attribute, ChangeDetectionStrategy, Component, signal, model, computed, viewChild, untracked, output, Injector, afterRenderEffect, contentChildren, contentChild, ViewChildren } from '@angular/core';
|
|
3
3
|
import { isPlatformBrowser, DOCUMENT, NgStyle } from '@angular/common';
|
|
4
4
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
5
|
-
import { fromEvent, tap, debounceTime, asyncScheduler, Subscription, timer, switchMap, scheduled, filter, take, BehaviorSubject, Subject, takeUntil } from 'rxjs';
|
|
5
|
+
import { fromEvent, tap, debounceTime, asyncScheduler, Subscription, timer, switchMap, scheduled, filter, take, interval, takeWhile, finalize, BehaviorSubject, Subject, takeUntil } from 'rxjs';
|
|
6
6
|
import * as i2 from '@angular/platform-browser';
|
|
7
7
|
import { PhoneNumberUtil, AsYouTypeFormatter } from 'google-libphonenumber';
|
|
8
8
|
import * as i1 from '@angular/cdk/overlay';
|
|
@@ -11,6 +11,7 @@ import { ComponentPortal } from '@angular/cdk/portal';
|
|
|
11
11
|
import * as i2$1 from '@angular/router';
|
|
12
12
|
import { NavigationEnd } from '@angular/router';
|
|
13
13
|
import { ulid } from 'ulid';
|
|
14
|
+
import { form } from '@angular/forms/signals';
|
|
14
15
|
|
|
15
16
|
class DateUtils {
|
|
16
17
|
static parse(value, isUsaDateFormat = DateUtils.isUsaDateFormat()) {
|
|
@@ -845,6 +846,8 @@ class UiAlertMessagesService {
|
|
|
845
846
|
$alerts = signal([], ...(ngDevMode ? [{ debugName: "$alerts" }] : []));
|
|
846
847
|
overlayRef;
|
|
847
848
|
component = null;
|
|
849
|
+
timerSubscriptions = new Map();
|
|
850
|
+
timerState = new Map();
|
|
848
851
|
constructor(overlay, router) {
|
|
849
852
|
this.overlay = overlay;
|
|
850
853
|
this.router = router;
|
|
@@ -881,7 +884,26 @@ class UiAlertMessagesService {
|
|
|
881
884
|
icon: 'warning.svg',
|
|
882
885
|
}));
|
|
883
886
|
}
|
|
887
|
+
pauseTimer(alert) {
|
|
888
|
+
const state = this.timerState.get(alert.id);
|
|
889
|
+
if (state) {
|
|
890
|
+
state.paused = true;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
resumeTimer(alert) {
|
|
894
|
+
const state = this.timerState.get(alert.id);
|
|
895
|
+
if (state) {
|
|
896
|
+
state.paused = false;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
884
899
|
remove(alert) {
|
|
900
|
+
// Cancel any active timer for this alert
|
|
901
|
+
const subscription = this.timerSubscriptions.get(alert.id);
|
|
902
|
+
if (subscription) {
|
|
903
|
+
subscription.unsubscribe();
|
|
904
|
+
this.timerSubscriptions.delete(alert.id);
|
|
905
|
+
}
|
|
906
|
+
this.timerState.delete(alert.id);
|
|
885
907
|
timer(250)
|
|
886
908
|
.pipe(tap(() => {
|
|
887
909
|
this.$alerts.set(this.$alerts().filter((x) => x !== alert));
|
|
@@ -926,11 +948,25 @@ class UiAlertMessagesService {
|
|
|
926
948
|
}), take(1))
|
|
927
949
|
.subscribe();
|
|
928
950
|
this.$alerts.set([...this.$alerts(), alert]);
|
|
929
|
-
timer
|
|
930
|
-
|
|
951
|
+
// Create pausable timer with 100ms intervals
|
|
952
|
+
this.timerState.set(alert.id, { paused: false, elapsed: 0 });
|
|
953
|
+
const DURATION = 10000; // 10 seconds
|
|
954
|
+
const CHECK_INTERVAL = 100; // Check every 100ms
|
|
955
|
+
const subscription = interval(CHECK_INTERVAL)
|
|
956
|
+
.pipe(takeWhile(() => {
|
|
957
|
+
const state = this.timerState.get(alert.id);
|
|
958
|
+
if (!state)
|
|
959
|
+
return false;
|
|
960
|
+
// Only increment elapsed time if not paused
|
|
961
|
+
if (!state.paused) {
|
|
962
|
+
state.elapsed += CHECK_INTERVAL;
|
|
963
|
+
}
|
|
964
|
+
return state.elapsed < DURATION;
|
|
965
|
+
}), finalize(() => {
|
|
931
966
|
this.remove(alert);
|
|
932
967
|
}))
|
|
933
968
|
.subscribe();
|
|
969
|
+
this.timerSubscriptions.set(alert.id, subscription);
|
|
934
970
|
}
|
|
935
971
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiAlertMessagesService, deps: [{ token: i1.Overlay }, { token: i2$1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
936
972
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiAlertMessagesService, providedIn: 'root' });
|
|
@@ -975,6 +1011,8 @@ class UiDailyCalendarDirective {
|
|
|
975
1011
|
weekDaysEuropean = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
|
976
1012
|
weekDaysUsa = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
977
1013
|
$isRangeSelection = input(false, ...(ngDevMode ? [{ debugName: "$isRangeSelection" }] : []));
|
|
1014
|
+
$minDate = input(undefined, ...(ngDevMode ? [{ debugName: "$minDate" }] : []));
|
|
1015
|
+
$maxDate = input(undefined, ...(ngDevMode ? [{ debugName: "$maxDate" }] : []));
|
|
978
1016
|
get weekDays() {
|
|
979
1017
|
return this.isUsaDateFormat() ? this.weekDaysUsa : this.weekDaysEuropean;
|
|
980
1018
|
}
|
|
@@ -1035,6 +1073,21 @@ class UiDailyCalendarDirective {
|
|
|
1035
1073
|
return false;
|
|
1036
1074
|
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
1037
1075
|
}
|
|
1076
|
+
normalizeDate(date) {
|
|
1077
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
1078
|
+
}
|
|
1079
|
+
isDisabledDate(date) {
|
|
1080
|
+
const currentTimestamp = this.normalizeDate(date).getTime();
|
|
1081
|
+
const minDate = this.$minDate();
|
|
1082
|
+
if (minDate && currentTimestamp < this.normalizeDate(minDate).getTime()) {
|
|
1083
|
+
return true;
|
|
1084
|
+
}
|
|
1085
|
+
const maxDate = this.$maxDate();
|
|
1086
|
+
if (maxDate && currentTimestamp > this.normalizeDate(maxDate).getTime()) {
|
|
1087
|
+
return true;
|
|
1088
|
+
}
|
|
1089
|
+
return false;
|
|
1090
|
+
}
|
|
1038
1091
|
isBetween(date, start, end) {
|
|
1039
1092
|
if (!start || !end)
|
|
1040
1093
|
return false;
|
|
@@ -1044,11 +1097,23 @@ class UiDailyCalendarDirective {
|
|
|
1044
1097
|
return d > s && d < e;
|
|
1045
1098
|
}
|
|
1046
1099
|
getDayState(date) {
|
|
1100
|
+
const isDisabled = this.isDisabledDate(date);
|
|
1101
|
+
if (isDisabled) {
|
|
1102
|
+
return {
|
|
1103
|
+
isDisabled: true,
|
|
1104
|
+
isSelected: false,
|
|
1105
|
+
isStart: false,
|
|
1106
|
+
isEnd: false,
|
|
1107
|
+
inRange: false,
|
|
1108
|
+
inHoverRange: false,
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1047
1111
|
const hover = this.$hoverDate();
|
|
1048
1112
|
const start = this.$dateStart();
|
|
1049
1113
|
const end = this.$dateEnd();
|
|
1050
1114
|
if (!this.$isRangeSelection()) {
|
|
1051
1115
|
return {
|
|
1116
|
+
isDisabled: false,
|
|
1052
1117
|
isSelected: this.isSameDay(start, date),
|
|
1053
1118
|
isStart: false,
|
|
1054
1119
|
isEnd: false,
|
|
@@ -1071,7 +1136,7 @@ class UiDailyCalendarDirective {
|
|
|
1071
1136
|
}
|
|
1072
1137
|
const isSingleSelected = this.isSameDay(start, date) || this.isSameDay(end, date);
|
|
1073
1138
|
const isSelected = isStart || isEnd || (!end && isStart) || isSingleSelected;
|
|
1074
|
-
return { isSelected, isStart, isEnd, inRange, inHoverRange };
|
|
1139
|
+
return { isDisabled: false, isSelected, isStart, isEnd, inRange, inHoverRange };
|
|
1075
1140
|
}
|
|
1076
1141
|
onHover(date, inHoverRange) {
|
|
1077
1142
|
if (inHoverRange) {
|
|
@@ -1083,6 +1148,10 @@ class UiDailyCalendarDirective {
|
|
|
1083
1148
|
this.$hoverDate.set(null);
|
|
1084
1149
|
return;
|
|
1085
1150
|
}
|
|
1151
|
+
if (this.isDisabledDate(date)) {
|
|
1152
|
+
this.$hoverDate.set(null);
|
|
1153
|
+
return;
|
|
1154
|
+
}
|
|
1086
1155
|
if (!this.$isRangeSelection()) {
|
|
1087
1156
|
return;
|
|
1088
1157
|
}
|
|
@@ -1099,6 +1168,9 @@ class UiDailyCalendarDirective {
|
|
|
1099
1168
|
return DateUtils.isUsaDateFormat();
|
|
1100
1169
|
}
|
|
1101
1170
|
select(date) {
|
|
1171
|
+
if (this.isDisabledDate(date)) {
|
|
1172
|
+
return;
|
|
1173
|
+
}
|
|
1102
1174
|
this.$hoverDate.set(null);
|
|
1103
1175
|
if (!this.$isRangeSelection()) {
|
|
1104
1176
|
this.$dateStart.set(date);
|
|
@@ -1127,14 +1199,14 @@ class UiDailyCalendarDirective {
|
|
|
1127
1199
|
}
|
|
1128
1200
|
}
|
|
1129
1201
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiDailyCalendarDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1130
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.1", type: UiDailyCalendarDirective, isStandalone: true, selector: "app-ui-daily-calendar", inputs: { $isRangeSelection: { classPropertyName: "$isRangeSelection", publicName: "$isRangeSelection", isSignal: true, isRequired: false, transformFunction: null }, $dateStart: { classPropertyName: "$dateStart", publicName: "$dateStart", isSignal: true, isRequired: false, transformFunction: null }, $dateEnd: { classPropertyName: "$dateEnd", publicName: "$dateEnd", isSignal: true, isRequired: false, transformFunction: null }, $currentMonth: { classPropertyName: "$currentMonth", publicName: "$currentMonth", isSignal: true, isRequired: true, transformFunction: null }, $currentYear: { classPropertyName: "$currentYear", publicName: "$currentYear", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { $dateStart: "$dateStartChange", $dateEnd: "$dateEndChange", $currentMonth: "$currentMonthChange", $currentYear: "$currentYearChange", $onRangeSelect: "$onRangeSelect", $onSelect: "$onSelect" }, ngImport: i0 });
|
|
1202
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.1", type: UiDailyCalendarDirective, isStandalone: true, selector: "app-ui-daily-calendar", inputs: { $isRangeSelection: { classPropertyName: "$isRangeSelection", publicName: "$isRangeSelection", isSignal: true, isRequired: false, transformFunction: null }, $minDate: { classPropertyName: "$minDate", publicName: "$minDate", isSignal: true, isRequired: false, transformFunction: null }, $maxDate: { classPropertyName: "$maxDate", publicName: "$maxDate", isSignal: true, isRequired: false, transformFunction: null }, $dateStart: { classPropertyName: "$dateStart", publicName: "$dateStart", isSignal: true, isRequired: false, transformFunction: null }, $dateEnd: { classPropertyName: "$dateEnd", publicName: "$dateEnd", isSignal: true, isRequired: false, transformFunction: null }, $currentMonth: { classPropertyName: "$currentMonth", publicName: "$currentMonth", isSignal: true, isRequired: true, transformFunction: null }, $currentYear: { classPropertyName: "$currentYear", publicName: "$currentYear", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { $dateStart: "$dateStartChange", $dateEnd: "$dateEndChange", $currentMonth: "$currentMonthChange", $currentYear: "$currentYearChange", $onRangeSelect: "$onRangeSelect", $onSelect: "$onSelect" }, ngImport: i0 });
|
|
1131
1203
|
}
|
|
1132
1204
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiDailyCalendarDirective, decorators: [{
|
|
1133
1205
|
type: Directive,
|
|
1134
1206
|
args: [{
|
|
1135
1207
|
selector: 'app-ui-daily-calendar',
|
|
1136
1208
|
}]
|
|
1137
|
-
}], propDecorators: { $isRangeSelection: [{ type: i0.Input, args: [{ isSignal: true, alias: "$isRangeSelection", required: false }] }], $dateStart: [{ type: i0.Input, args: [{ isSignal: true, alias: "$dateStart", required: false }] }, { type: i0.Output, args: ["$dateStartChange"] }], $dateEnd: [{ type: i0.Input, args: [{ isSignal: true, alias: "$dateEnd", required: false }] }, { type: i0.Output, args: ["$dateEndChange"] }], $currentMonth: [{ type: i0.Input, args: [{ isSignal: true, alias: "$currentMonth", required: true }] }, { type: i0.Output, args: ["$currentMonthChange"] }], $currentYear: [{ type: i0.Input, args: [{ isSignal: true, alias: "$currentYear", required: true }] }, { type: i0.Output, args: ["$currentYearChange"] }], $onRangeSelect: [{ type: i0.Output, args: ["$onRangeSelect"] }], $onSelect: [{ type: i0.Output, args: ["$onSelect"] }] } });
|
|
1209
|
+
}], propDecorators: { $isRangeSelection: [{ type: i0.Input, args: [{ isSignal: true, alias: "$isRangeSelection", required: false }] }], $minDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "$minDate", required: false }] }], $maxDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "$maxDate", required: false }] }], $dateStart: [{ type: i0.Input, args: [{ isSignal: true, alias: "$dateStart", required: false }] }, { type: i0.Output, args: ["$dateStartChange"] }], $dateEnd: [{ type: i0.Input, args: [{ isSignal: true, alias: "$dateEnd", required: false }] }, { type: i0.Output, args: ["$dateEndChange"] }], $currentMonth: [{ type: i0.Input, args: [{ isSignal: true, alias: "$currentMonth", required: true }] }, { type: i0.Output, args: ["$currentMonthChange"] }], $currentYear: [{ type: i0.Input, args: [{ isSignal: true, alias: "$currentYear", required: true }] }, { type: i0.Output, args: ["$currentYearChange"] }], $onRangeSelect: [{ type: i0.Output, args: ["$onRangeSelect"] }], $onSelect: [{ type: i0.Output, args: ["$onSelect"] }] } });
|
|
1138
1210
|
|
|
1139
1211
|
class UiMonthlyCalendarDirective {
|
|
1140
1212
|
$date = model(new Date(), ...(ngDevMode ? [{ debugName: "$date" }] : []));
|
|
@@ -1237,6 +1309,106 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
1237
1309
|
}]
|
|
1238
1310
|
}], propDecorators: { $date: [{ type: i0.Input, args: [{ isSignal: true, alias: "$date", required: false }] }, { type: i0.Output, args: ["$dateChange"] }], $onSelect: [{ type: i0.Output, args: ["$onSelect"] }], $currentYear: [{ type: i0.Input, args: [{ isSignal: true, alias: "$currentYear", required: true }] }, { type: i0.Output, args: ["$currentYearChange"] }] } });
|
|
1239
1311
|
|
|
1312
|
+
class UiCalendarDropdownDirective {
|
|
1313
|
+
action = () => { };
|
|
1314
|
+
rangeSelect = () => { };
|
|
1315
|
+
startDate = null;
|
|
1316
|
+
endDate = null;
|
|
1317
|
+
isRangeSelection = false;
|
|
1318
|
+
minDate = undefined;
|
|
1319
|
+
maxDate = undefined;
|
|
1320
|
+
$close = signal(false, ...(ngDevMode ? [{ debugName: "$close" }] : []));
|
|
1321
|
+
$height = signal(0, ...(ngDevMode ? [{ debugName: "$height" }] : []));
|
|
1322
|
+
$width = signal(0, ...(ngDevMode ? [{ debugName: "$width" }] : []));
|
|
1323
|
+
$currentMonth = signal(this.startDate ? this.startDate.getMonth() : new Date().getMonth(), ...(ngDevMode ? [{ debugName: "$currentMonth" }] : []));
|
|
1324
|
+
$currentYear = signal(this.startDate ? this.startDate.getFullYear() : new Date().getFullYear(), ...(ngDevMode ? [{ debugName: "$currentYear" }] : []));
|
|
1325
|
+
$mode = signal('day', ...(ngDevMode ? [{ debugName: "$mode" }] : []));
|
|
1326
|
+
$view = signal({ key: 'day', state: 'enter-up' }, ...(ngDevMode ? [{ debugName: "$view" }] : []));
|
|
1327
|
+
levels = { day: 1, month: 2, year: 3 };
|
|
1328
|
+
$current = signal('day', ...(ngDevMode ? [{ debugName: "$current" }] : []));
|
|
1329
|
+
ngOnChanges(changes) {
|
|
1330
|
+
if (changes['startDate'] || changes['minDate'] || changes['maxDate']) {
|
|
1331
|
+
const currentDate = this.getInitialViewDate();
|
|
1332
|
+
this.$currentMonth.set(currentDate.getMonth());
|
|
1333
|
+
this.$currentYear.set(currentDate.getFullYear());
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
normalizeDate(date) {
|
|
1337
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
1338
|
+
}
|
|
1339
|
+
getInitialViewDate() {
|
|
1340
|
+
return this.clampToRange(this.startDate ?? new Date());
|
|
1341
|
+
}
|
|
1342
|
+
clampToRange(date) {
|
|
1343
|
+
const normalizedDate = this.normalizeDate(date);
|
|
1344
|
+
const normalizedMin = this.minDate ? this.normalizeDate(this.minDate) : undefined;
|
|
1345
|
+
const normalizedMax = this.maxDate ? this.normalizeDate(this.maxDate) : undefined;
|
|
1346
|
+
if (normalizedMin && normalizedDate.getTime() < normalizedMin.getTime()) {
|
|
1347
|
+
return normalizedMin;
|
|
1348
|
+
}
|
|
1349
|
+
if (normalizedMax && normalizedDate.getTime() > normalizedMax.getTime()) {
|
|
1350
|
+
return normalizedMax;
|
|
1351
|
+
}
|
|
1352
|
+
return normalizedDate;
|
|
1353
|
+
}
|
|
1354
|
+
select(date) {
|
|
1355
|
+
this.action(date);
|
|
1356
|
+
this.startDate = date;
|
|
1357
|
+
}
|
|
1358
|
+
selectMonth(date) {
|
|
1359
|
+
this.$currentMonth.set(date.getMonth());
|
|
1360
|
+
}
|
|
1361
|
+
selectYear(date) {
|
|
1362
|
+
this.$currentYear.set(date.getFullYear());
|
|
1363
|
+
}
|
|
1364
|
+
onRangeSelect(dates) {
|
|
1365
|
+
this.startDate = dates.start ?? new Date();
|
|
1366
|
+
this.rangeSelect(dates);
|
|
1367
|
+
}
|
|
1368
|
+
setToday() {
|
|
1369
|
+
this.startDate = this.clampToRange(new Date());
|
|
1370
|
+
this.action(this.startDate);
|
|
1371
|
+
}
|
|
1372
|
+
setMode(next) {
|
|
1373
|
+
const prev = this.$current();
|
|
1374
|
+
const prevLevel = this.levels[prev];
|
|
1375
|
+
const nextLevel = this.levels[next];
|
|
1376
|
+
const direction = nextLevel > prevLevel ? 'up' : 'down';
|
|
1377
|
+
this.$view.update(() => ({ key: prev, state: `leave-${direction}` }));
|
|
1378
|
+
asyncScheduler.schedule(() => {
|
|
1379
|
+
this.$current.set(next);
|
|
1380
|
+
this.$view.update(() => ({ key: next, state: `enter-${direction}` }));
|
|
1381
|
+
this.$mode.set(next);
|
|
1382
|
+
}, 200);
|
|
1383
|
+
}
|
|
1384
|
+
setSize(size) {
|
|
1385
|
+
this.$height.set(size.height);
|
|
1386
|
+
this.$width.set(size.width);
|
|
1387
|
+
}
|
|
1388
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiCalendarDropdownDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1389
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.1", type: UiCalendarDropdownDirective, isStandalone: true, selector: "app-ui-calendar-dropdown-calendar", inputs: { action: "action", rangeSelect: "rangeSelect", startDate: "startDate", endDate: "endDate", isRangeSelection: "isRangeSelection", minDate: "minDate", maxDate: "maxDate" }, usesOnChanges: true, ngImport: i0 });
|
|
1390
|
+
}
|
|
1391
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiCalendarDropdownDirective, decorators: [{
|
|
1392
|
+
type: Directive,
|
|
1393
|
+
args: [{
|
|
1394
|
+
selector: 'app-ui-calendar-dropdown-calendar',
|
|
1395
|
+
}]
|
|
1396
|
+
}], propDecorators: { action: [{
|
|
1397
|
+
type: Input
|
|
1398
|
+
}], rangeSelect: [{
|
|
1399
|
+
type: Input
|
|
1400
|
+
}], startDate: [{
|
|
1401
|
+
type: Input
|
|
1402
|
+
}], endDate: [{
|
|
1403
|
+
type: Input
|
|
1404
|
+
}], isRangeSelection: [{
|
|
1405
|
+
type: Input
|
|
1406
|
+
}], minDate: [{
|
|
1407
|
+
type: Input
|
|
1408
|
+
}], maxDate: [{
|
|
1409
|
+
type: Input
|
|
1410
|
+
}] } });
|
|
1411
|
+
|
|
1240
1412
|
const typescript = {
|
|
1241
1413
|
comment: { css: 'hl1', regexp: /(\/\/.*|\/\*[\s\S]*?\*\/)/g },
|
|
1242
1414
|
string: { css: 'hl3', regexp: /(["'`].*?["'`])/gs },
|
|
@@ -2928,6 +3100,7 @@ class UiInputDirective extends UiFieldBaseDirective {
|
|
|
2928
3100
|
renderer;
|
|
2929
3101
|
$size = input('medium', ...(ngDevMode ? [{ debugName: "$size" }] : []));
|
|
2930
3102
|
$placeholder = input('', ...(ngDevMode ? [{ debugName: "$placeholder" }] : []));
|
|
3103
|
+
$inputMode = input('text', ...(ngDevMode ? [{ debugName: "$inputMode" }] : []));
|
|
2931
3104
|
$label = input('', ...(ngDevMode ? [{ debugName: "$label" }] : []));
|
|
2932
3105
|
$shouldFocusedAfterViewInit = input(false, ...(ngDevMode ? [{ debugName: "$shouldFocusedAfterViewInit" }] : []));
|
|
2933
3106
|
$isRounded = input(false, ...(ngDevMode ? [{ debugName: "$isRounded" }] : []));
|
|
@@ -2958,14 +3131,14 @@ class UiInputDirective extends UiFieldBaseDirective {
|
|
|
2958
3131
|
});
|
|
2959
3132
|
}
|
|
2960
3133
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiInputDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2961
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.1", type: UiInputDirective, isStandalone: true, selector: "app-ui-input", inputs: { $size: { classPropertyName: "$size", publicName: "$size", isSignal: true, isRequired: false, transformFunction: null }, $placeholder: { classPropertyName: "$placeholder", publicName: "$placeholder", isSignal: true, isRequired: false, transformFunction: null }, $label: { classPropertyName: "$label", publicName: "$label", isSignal: true, isRequired: false, transformFunction: null }, $shouldFocusedAfterViewInit: { classPropertyName: "$shouldFocusedAfterViewInit", publicName: "$shouldFocusedAfterViewInit", isSignal: true, isRequired: false, transformFunction: null }, $isRounded: { classPropertyName: "$isRounded", publicName: "$isRounded", isSignal: true, isRequired: false, transformFunction: null }, $hideValidatorErrors: { classPropertyName: "$hideValidatorErrors", publicName: "$hideValidatorErrors", isSignal: true, isRequired: false, transformFunction: null }, $icon: { classPropertyName: "$icon", publicName: "$icon", isSignal: true, isRequired: false, transformFunction: null } }, usesInheritance: true, ngImport: i0 });
|
|
3134
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.1", type: UiInputDirective, isStandalone: true, selector: "app-ui-input", inputs: { $size: { classPropertyName: "$size", publicName: "$size", isSignal: true, isRequired: false, transformFunction: null }, $placeholder: { classPropertyName: "$placeholder", publicName: "$placeholder", isSignal: true, isRequired: false, transformFunction: null }, $inputMode: { classPropertyName: "$inputMode", publicName: "$inputMode", isSignal: true, isRequired: false, transformFunction: null }, $label: { classPropertyName: "$label", publicName: "$label", isSignal: true, isRequired: false, transformFunction: null }, $shouldFocusedAfterViewInit: { classPropertyName: "$shouldFocusedAfterViewInit", publicName: "$shouldFocusedAfterViewInit", isSignal: true, isRequired: false, transformFunction: null }, $isRounded: { classPropertyName: "$isRounded", publicName: "$isRounded", isSignal: true, isRequired: false, transformFunction: null }, $hideValidatorErrors: { classPropertyName: "$hideValidatorErrors", publicName: "$hideValidatorErrors", isSignal: true, isRequired: false, transformFunction: null }, $icon: { classPropertyName: "$icon", publicName: "$icon", isSignal: true, isRequired: false, transformFunction: null } }, usesInheritance: true, ngImport: i0 });
|
|
2962
3135
|
}
|
|
2963
3136
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiInputDirective, decorators: [{
|
|
2964
3137
|
type: Directive,
|
|
2965
3138
|
args: [{
|
|
2966
3139
|
selector: 'app-ui-input',
|
|
2967
3140
|
}]
|
|
2968
|
-
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { $size: [{ type: i0.Input, args: [{ isSignal: true, alias: "$size", required: false }] }], $placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "$placeholder", required: false }] }], $label: [{ type: i0.Input, args: [{ isSignal: true, alias: "$label", required: false }] }], $shouldFocusedAfterViewInit: [{ type: i0.Input, args: [{ isSignal: true, alias: "$shouldFocusedAfterViewInit", required: false }] }], $isRounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "$isRounded", required: false }] }], $hideValidatorErrors: [{ type: i0.Input, args: [{ isSignal: true, alias: "$hideValidatorErrors", required: false }] }], $icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "$icon", required: false }] }] } });
|
|
3141
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { $size: [{ type: i0.Input, args: [{ isSignal: true, alias: "$size", required: false }] }], $placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "$placeholder", required: false }] }], $inputMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "$inputMode", required: false }] }], $label: [{ type: i0.Input, args: [{ isSignal: true, alias: "$label", required: false }] }], $shouldFocusedAfterViewInit: [{ type: i0.Input, args: [{ isSignal: true, alias: "$shouldFocusedAfterViewInit", required: false }] }], $isRounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "$isRounded", required: false }] }], $hideValidatorErrors: [{ type: i0.Input, args: [{ isSignal: true, alias: "$hideValidatorErrors", required: false }] }], $icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "$icon", required: false }] }] } });
|
|
2969
3142
|
|
|
2970
3143
|
class UiInputCountryDirective extends UiInputDirective {
|
|
2971
3144
|
$selectedCountry = signal(emptyCountry, ...(ngDevMode ? [{ debugName: "$selectedCountry" }] : []));
|
|
@@ -3029,6 +3202,8 @@ class UIInputDateDirective extends UiInputDirective {
|
|
|
3029
3202
|
$isOpen = signal(false, ...(ngDevMode ? [{ debugName: "$isOpen" }] : []));
|
|
3030
3203
|
$isRangeSelection = input(false, ...(ngDevMode ? [{ debugName: "$isRangeSelection" }] : []));
|
|
3031
3204
|
$dividePattern = input('/', ...(ngDevMode ? [{ debugName: "$dividePattern" }] : []));
|
|
3205
|
+
$minDate = input(undefined, ...(ngDevMode ? [{ debugName: "$minDate" }] : []));
|
|
3206
|
+
$maxDate = input(undefined, ...(ngDevMode ? [{ debugName: "$maxDate" }] : []));
|
|
3032
3207
|
$inputElement = viewChild('input', ...(ngDevMode ? [{ debugName: "$inputElement" }] : []));
|
|
3033
3208
|
setDate(date) {
|
|
3034
3209
|
const newDate = this.formatDate(date);
|
|
@@ -3107,14 +3282,14 @@ class UIInputDateDirective extends UiInputDirective {
|
|
|
3107
3282
|
return formatSingle(limited);
|
|
3108
3283
|
}
|
|
3109
3284
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UIInputDateDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
3110
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.1.1", type: UIInputDateDirective, isStandalone: true, selector: "app-ui-input-date", inputs: { $isRangeSelection: { classPropertyName: "$isRangeSelection", publicName: "$isRangeSelection", isSignal: true, isRequired: false, transformFunction: null }, $dividePattern: { classPropertyName: "$dividePattern", publicName: "$dividePattern", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "$inputElement", first: true, predicate: ["input"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0 });
|
|
3285
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.1.1", type: UIInputDateDirective, isStandalone: true, selector: "app-ui-input-date", inputs: { $isRangeSelection: { classPropertyName: "$isRangeSelection", publicName: "$isRangeSelection", isSignal: true, isRequired: false, transformFunction: null }, $dividePattern: { classPropertyName: "$dividePattern", publicName: "$dividePattern", isSignal: true, isRequired: false, transformFunction: null }, $minDate: { classPropertyName: "$minDate", publicName: "$minDate", isSignal: true, isRequired: false, transformFunction: null }, $maxDate: { classPropertyName: "$maxDate", publicName: "$maxDate", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "$inputElement", first: true, predicate: ["input"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0 });
|
|
3111
3286
|
}
|
|
3112
3287
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UIInputDateDirective, decorators: [{
|
|
3113
3288
|
type: Directive,
|
|
3114
3289
|
args: [{
|
|
3115
3290
|
selector: 'app-ui-input-date',
|
|
3116
3291
|
}]
|
|
3117
|
-
}], propDecorators: { $isRangeSelection: [{ type: i0.Input, args: [{ isSignal: true, alias: "$isRangeSelection", required: false }] }], $dividePattern: [{ type: i0.Input, args: [{ isSignal: true, alias: "$dividePattern", required: false }] }], $inputElement: [{ type: i0.ViewChild, args: ['input', { isSignal: true }] }] } });
|
|
3292
|
+
}], propDecorators: { $isRangeSelection: [{ type: i0.Input, args: [{ isSignal: true, alias: "$isRangeSelection", required: false }] }], $dividePattern: [{ type: i0.Input, args: [{ isSignal: true, alias: "$dividePattern", required: false }] }], $minDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "$minDate", required: false }] }], $maxDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "$maxDate", required: false }] }], $inputElement: [{ type: i0.ViewChild, args: ['input', { isSignal: true }] }] } });
|
|
3118
3293
|
|
|
3119
3294
|
class UIPhoneNumberDirective extends UiInputDirective {
|
|
3120
3295
|
$selectedCountry = signal(emptyCountry, ...(ngDevMode ? [{ debugName: "$selectedCountry" }] : []));
|
|
@@ -3273,56 +3448,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
3273
3448
|
}] } });
|
|
3274
3449
|
|
|
3275
3450
|
class UiInputTimeDirective extends UiInputDirective {
|
|
3276
|
-
times
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
'
|
|
3286
|
-
|
|
3287
|
-
'05:00',
|
|
3288
|
-
'05:30',
|
|
3289
|
-
'06:00',
|
|
3290
|
-
'06:30',
|
|
3291
|
-
'07:00',
|
|
3292
|
-
'07:30',
|
|
3293
|
-
'08:00',
|
|
3294
|
-
'08:30',
|
|
3295
|
-
'09:00',
|
|
3296
|
-
'09:30',
|
|
3297
|
-
'10:00',
|
|
3298
|
-
'10:30',
|
|
3299
|
-
'11:00',
|
|
3300
|
-
'11:30',
|
|
3301
|
-
'12:00',
|
|
3302
|
-
'12:30',
|
|
3303
|
-
'13:00',
|
|
3304
|
-
'13:30',
|
|
3305
|
-
'14:00',
|
|
3306
|
-
'14:30',
|
|
3307
|
-
'15:00',
|
|
3308
|
-
'15:30',
|
|
3309
|
-
'16:00',
|
|
3310
|
-
'16:30',
|
|
3311
|
-
'17:00',
|
|
3312
|
-
'17:30',
|
|
3313
|
-
'18:00',
|
|
3314
|
-
'18:30',
|
|
3315
|
-
'19:00',
|
|
3316
|
-
'19:30',
|
|
3317
|
-
'20:00',
|
|
3318
|
-
'20:30',
|
|
3319
|
-
'21:00',
|
|
3320
|
-
'21:30',
|
|
3321
|
-
'22:00',
|
|
3322
|
-
'22:30',
|
|
3323
|
-
'23:00',
|
|
3324
|
-
'23:30',
|
|
3325
|
-
];
|
|
3451
|
+
get times() {
|
|
3452
|
+
const items = [];
|
|
3453
|
+
for (let hour = 0; hour < 24; hour++) {
|
|
3454
|
+
items.push(this.formatTime(hour, 0));
|
|
3455
|
+
items.push(this.formatTime(hour, 30));
|
|
3456
|
+
}
|
|
3457
|
+
return items;
|
|
3458
|
+
}
|
|
3459
|
+
get inputMode() {
|
|
3460
|
+
return this.uses12HourTime() ? 'text' : 'numeric';
|
|
3461
|
+
}
|
|
3326
3462
|
$inputElement = viewChild('input', ...(ngDevMode ? [{ debugName: "$inputElement" }] : []));
|
|
3327
3463
|
$isOpen = signal(false, ...(ngDevMode ? [{ debugName: "$isOpen" }] : []));
|
|
3328
3464
|
onInput(value) {
|
|
@@ -3336,9 +3472,13 @@ class UiInputTimeDirective extends UiInputDirective {
|
|
|
3336
3472
|
const oldColonCount = (oldValue.match(/:/g) || []).length;
|
|
3337
3473
|
const newColonCount = (newValue.match(/:/g) || []).length;
|
|
3338
3474
|
const colonAdded = newColonCount > oldColonCount;
|
|
3475
|
+
const oldMeridiemLength = this.extractMeridiem(oldValue).length;
|
|
3476
|
+
const newMeridiemLength = this.extractMeridiem(newValue).length;
|
|
3477
|
+
const meridiemAdded = newMeridiemLength > oldMeridiemLength;
|
|
3478
|
+
const meridiemFormatted = this.uses12HourTime() && oldValue !== newValue;
|
|
3339
3479
|
super.onInput(newValue);
|
|
3340
3480
|
inputElement.value = newValue;
|
|
3341
|
-
if (colonAdded) {
|
|
3481
|
+
if (colonAdded || meridiemAdded || meridiemFormatted) {
|
|
3342
3482
|
inputElement.setSelectionRange(newValue.length, newValue.length);
|
|
3343
3483
|
}
|
|
3344
3484
|
else {
|
|
@@ -3349,6 +3489,9 @@ class UiInputTimeDirective extends UiInputDirective {
|
|
|
3349
3489
|
if (!value) {
|
|
3350
3490
|
return '';
|
|
3351
3491
|
}
|
|
3492
|
+
if (this.uses12HourTime()) {
|
|
3493
|
+
return this.mask12HourTime(value);
|
|
3494
|
+
}
|
|
3352
3495
|
const digits = value.replace(/\D/g, '').slice(0, 4);
|
|
3353
3496
|
const len = digits.length;
|
|
3354
3497
|
if (len === 1) {
|
|
@@ -3380,6 +3523,72 @@ class UiInputTimeDirective extends UiInputDirective {
|
|
|
3380
3523
|
}
|
|
3381
3524
|
return '';
|
|
3382
3525
|
}
|
|
3526
|
+
mask12HourTime(value) {
|
|
3527
|
+
const digits = value.replace(/\D/g, '').slice(0, 4);
|
|
3528
|
+
const meridiem = this.extractMeridiem(value);
|
|
3529
|
+
if (!digits) {
|
|
3530
|
+
return meridiem;
|
|
3531
|
+
}
|
|
3532
|
+
const len = digits.length;
|
|
3533
|
+
if (len === 1) {
|
|
3534
|
+
return this.appendMeridiem(digits, meridiem);
|
|
3535
|
+
}
|
|
3536
|
+
if (len === 2) {
|
|
3537
|
+
const hours = this.clampTwelveHour(digits.slice(0, 2), false);
|
|
3538
|
+
return this.appendMeridiem(hours, meridiem);
|
|
3539
|
+
}
|
|
3540
|
+
if (len === 3) {
|
|
3541
|
+
const hours = this.clampTwelveHour(digits.slice(0, 2), false);
|
|
3542
|
+
return this.appendMeridiem(`${hours}:${digits[2]}`, meridiem);
|
|
3543
|
+
}
|
|
3544
|
+
const hours = this.clampTwelveHour(digits.slice(0, 2), true);
|
|
3545
|
+
const minutes = this.clampMinutes(digits.slice(2, 4));
|
|
3546
|
+
return this.appendMeridiem(`${hours}:${minutes}`, meridiem);
|
|
3547
|
+
}
|
|
3548
|
+
appendMeridiem(time, meridiem) {
|
|
3549
|
+
return meridiem ? `${time} ${meridiem}` : time;
|
|
3550
|
+
}
|
|
3551
|
+
clampTwelveHour(value, fallbackToTwelve) {
|
|
3552
|
+
let hours = Number(value);
|
|
3553
|
+
if (hours > 12) {
|
|
3554
|
+
hours = 12;
|
|
3555
|
+
}
|
|
3556
|
+
if (fallbackToTwelve && hours === 0) {
|
|
3557
|
+
hours = 12;
|
|
3558
|
+
}
|
|
3559
|
+
return hours.toString().padStart(2, '0');
|
|
3560
|
+
}
|
|
3561
|
+
clampMinutes(value) {
|
|
3562
|
+
let minutes = Number(value);
|
|
3563
|
+
if (minutes > 59) {
|
|
3564
|
+
minutes = 59;
|
|
3565
|
+
}
|
|
3566
|
+
return minutes.toString().padStart(2, '0');
|
|
3567
|
+
}
|
|
3568
|
+
extractMeridiem(value) {
|
|
3569
|
+
const normalized = value.toUpperCase().replace(/[^APM]/g, '');
|
|
3570
|
+
if (!normalized) {
|
|
3571
|
+
return '';
|
|
3572
|
+
}
|
|
3573
|
+
if (normalized.startsWith('A')) {
|
|
3574
|
+
return normalized.includes('M') ? 'AM' : 'A';
|
|
3575
|
+
}
|
|
3576
|
+
if (normalized.startsWith('P')) {
|
|
3577
|
+
return normalized.includes('M') ? 'PM' : 'P';
|
|
3578
|
+
}
|
|
3579
|
+
return '';
|
|
3580
|
+
}
|
|
3581
|
+
uses12HourTime() {
|
|
3582
|
+
return new Intl.DateTimeFormat(undefined, { hour: 'numeric' }).resolvedOptions().hour12 ?? false;
|
|
3583
|
+
}
|
|
3584
|
+
formatTime(hour, minute) {
|
|
3585
|
+
if (!this.uses12HourTime()) {
|
|
3586
|
+
return `${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`;
|
|
3587
|
+
}
|
|
3588
|
+
const period = hour >= 12 ? 'PM' : 'AM';
|
|
3589
|
+
const normalizedHour = hour % 12 || 12;
|
|
3590
|
+
return `${normalizedHour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')} ${period}`;
|
|
3591
|
+
}
|
|
3383
3592
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiInputTimeDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
3384
3593
|
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.1.1", type: UiInputTimeDirective, isStandalone: true, selector: "app-ui-input-time", viewQueries: [{ propertyName: "$inputElement", first: true, predicate: ["input"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0 });
|
|
3385
3594
|
}
|
|
@@ -3403,6 +3612,260 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
3403
3612
|
}]
|
|
3404
3613
|
}], propDecorators: { $isError: [{ type: i0.Input, args: [{ isSignal: true, alias: "$isError", required: false }] }], $errors: [{ type: i0.Input, args: [{ isSignal: true, alias: "$errors", required: true }] }] } });
|
|
3405
3614
|
|
|
3615
|
+
class UiTimeDropdownDirective {
|
|
3616
|
+
$close = signal(false, ...(ngDevMode ? [{ debugName: "$close" }] : []));
|
|
3617
|
+
is12HourFormat = new Intl.DateTimeFormat(undefined, { hour: 'numeric' }).resolvedOptions().hour12 ?? false;
|
|
3618
|
+
$hourForm = signal('', ...(ngDevMode ? [{ debugName: "$hourForm" }] : []));
|
|
3619
|
+
$minuteForm = signal('', ...(ngDevMode ? [{ debugName: "$minuteForm" }] : []));
|
|
3620
|
+
$periodForm = signal('', ...(ngDevMode ? [{ debugName: "$periodForm" }] : []));
|
|
3621
|
+
$hour = form(this.$hourForm);
|
|
3622
|
+
$minute = form(this.$minuteForm);
|
|
3623
|
+
$period = form(this.$periodForm);
|
|
3624
|
+
action = () => { };
|
|
3625
|
+
initialValue = null;
|
|
3626
|
+
ngOnInit() {
|
|
3627
|
+
this.setInitialTime();
|
|
3628
|
+
}
|
|
3629
|
+
onHourInput(event) {
|
|
3630
|
+
const inputElement = event.target;
|
|
3631
|
+
if (!inputElement) {
|
|
3632
|
+
return;
|
|
3633
|
+
}
|
|
3634
|
+
const newValue = this.normalizeHourInput(inputElement.value);
|
|
3635
|
+
inputElement.value = newValue;
|
|
3636
|
+
this.$hour().value.set(newValue);
|
|
3637
|
+
this.emitTime();
|
|
3638
|
+
}
|
|
3639
|
+
onMinuteInput(event) {
|
|
3640
|
+
const inputElement = event.target;
|
|
3641
|
+
if (!inputElement) {
|
|
3642
|
+
return;
|
|
3643
|
+
}
|
|
3644
|
+
const newValue = this.normalizeMinuteInput(inputElement.value);
|
|
3645
|
+
inputElement.value = newValue;
|
|
3646
|
+
this.$minute().value.set(newValue);
|
|
3647
|
+
this.emitTime();
|
|
3648
|
+
}
|
|
3649
|
+
onPeriodInput(event) {
|
|
3650
|
+
if (!this.is12HourFormat) {
|
|
3651
|
+
return;
|
|
3652
|
+
}
|
|
3653
|
+
const inputElement = event.target;
|
|
3654
|
+
if (!inputElement) {
|
|
3655
|
+
return;
|
|
3656
|
+
}
|
|
3657
|
+
const newValue = this.normalizePeriodInput(inputElement.value);
|
|
3658
|
+
inputElement.value = newValue;
|
|
3659
|
+
this.$period().value.set(newValue);
|
|
3660
|
+
this.emitTime();
|
|
3661
|
+
}
|
|
3662
|
+
increaseHour() {
|
|
3663
|
+
const hourValue = this.parseNumber(this.$hour().value());
|
|
3664
|
+
const min = this.is12HourFormat ? 1 : 0;
|
|
3665
|
+
const max = this.is12HourFormat ? 12 : 23;
|
|
3666
|
+
this.$hour().value.set(this.incrementWithinRange(hourValue, min, max));
|
|
3667
|
+
this.emitTime();
|
|
3668
|
+
}
|
|
3669
|
+
decreaseHour() {
|
|
3670
|
+
const hourValue = this.parseNumber(this.$hour().value());
|
|
3671
|
+
const min = this.is12HourFormat ? 1 : 0;
|
|
3672
|
+
const max = this.is12HourFormat ? 12 : 23;
|
|
3673
|
+
this.$hour().value.set(this.decrementWithinRange(hourValue, min, max));
|
|
3674
|
+
this.emitTime();
|
|
3675
|
+
}
|
|
3676
|
+
increaseMinute() {
|
|
3677
|
+
const minuteValue = this.parseNumber(this.$minute().value());
|
|
3678
|
+
this.$minute().value.set(this.incrementWithinRange(minuteValue, 0, 59));
|
|
3679
|
+
this.emitTime();
|
|
3680
|
+
}
|
|
3681
|
+
decreaseMinute() {
|
|
3682
|
+
const minuteValue = this.parseNumber(this.$minute().value());
|
|
3683
|
+
this.$minute().value.set(this.decrementWithinRange(minuteValue, 0, 59));
|
|
3684
|
+
this.emitTime();
|
|
3685
|
+
}
|
|
3686
|
+
increasePeriod() {
|
|
3687
|
+
if (!this.is12HourFormat) {
|
|
3688
|
+
return;
|
|
3689
|
+
}
|
|
3690
|
+
this.$period().value.set(this.$period().value() === 'AM' ? 'PM' : 'AM');
|
|
3691
|
+
this.emitTime();
|
|
3692
|
+
}
|
|
3693
|
+
decreasePeriod() {
|
|
3694
|
+
this.increasePeriod();
|
|
3695
|
+
}
|
|
3696
|
+
incrementWithinRange(value, min, max) {
|
|
3697
|
+
const safeValue = Number.isNaN(value) ? min : value;
|
|
3698
|
+
const nextValue = safeValue >= max ? min : safeValue + 1;
|
|
3699
|
+
return nextValue.toString().padStart(2, '0');
|
|
3700
|
+
}
|
|
3701
|
+
decrementWithinRange(value, min, max) {
|
|
3702
|
+
const safeValue = Number.isNaN(value) ? min : value;
|
|
3703
|
+
const nextValue = safeValue <= min ? max : safeValue - 1;
|
|
3704
|
+
return nextValue.toString().padStart(2, '0');
|
|
3705
|
+
}
|
|
3706
|
+
parseNumber(value) {
|
|
3707
|
+
return Number(value);
|
|
3708
|
+
}
|
|
3709
|
+
normalizeHourInput(value) {
|
|
3710
|
+
const digits = value.replace(/\D/g, '').slice(0, 2);
|
|
3711
|
+
if (!digits) {
|
|
3712
|
+
return '';
|
|
3713
|
+
}
|
|
3714
|
+
const hour = Number(digits);
|
|
3715
|
+
if (Number.isNaN(hour)) {
|
|
3716
|
+
return '';
|
|
3717
|
+
}
|
|
3718
|
+
if (digits.length < 2) {
|
|
3719
|
+
return digits;
|
|
3720
|
+
}
|
|
3721
|
+
if (this.is12HourFormat) {
|
|
3722
|
+
if (hour > 12) {
|
|
3723
|
+
return '12';
|
|
3724
|
+
}
|
|
3725
|
+
return hour.toString().padStart(2, '0');
|
|
3726
|
+
}
|
|
3727
|
+
if (hour > 23) {
|
|
3728
|
+
return '23';
|
|
3729
|
+
}
|
|
3730
|
+
return hour.toString().padStart(2, '0');
|
|
3731
|
+
}
|
|
3732
|
+
normalizeMinuteInput(value) {
|
|
3733
|
+
const digits = value.replace(/\D/g, '').slice(0, 2);
|
|
3734
|
+
if (!digits) {
|
|
3735
|
+
return '';
|
|
3736
|
+
}
|
|
3737
|
+
const minute = Number(digits);
|
|
3738
|
+
if (Number.isNaN(minute)) {
|
|
3739
|
+
return '';
|
|
3740
|
+
}
|
|
3741
|
+
if (digits.length < 2) {
|
|
3742
|
+
return digits;
|
|
3743
|
+
}
|
|
3744
|
+
if (minute > 59) {
|
|
3745
|
+
return '59';
|
|
3746
|
+
}
|
|
3747
|
+
return minute.toString().padStart(2, '0');
|
|
3748
|
+
}
|
|
3749
|
+
normalizePeriodInput(value) {
|
|
3750
|
+
if (!this.is12HourFormat) {
|
|
3751
|
+
return '';
|
|
3752
|
+
}
|
|
3753
|
+
const lettersOnly = value.toUpperCase().replace(/[^APM]/g, '');
|
|
3754
|
+
if (!lettersOnly) {
|
|
3755
|
+
return '';
|
|
3756
|
+
}
|
|
3757
|
+
if (lettersOnly.startsWith('P')) {
|
|
3758
|
+
return 'PM';
|
|
3759
|
+
}
|
|
3760
|
+
if (lettersOnly.startsWith('A')) {
|
|
3761
|
+
return 'AM';
|
|
3762
|
+
}
|
|
3763
|
+
return '';
|
|
3764
|
+
}
|
|
3765
|
+
setInitialTime() {
|
|
3766
|
+
const parsed = this.parseInitialValue(this.initialValue);
|
|
3767
|
+
if (parsed) {
|
|
3768
|
+
this.$hour().value.set(parsed.hour);
|
|
3769
|
+
this.$minute().value.set(parsed.minute);
|
|
3770
|
+
this.$period().value.set(parsed.period);
|
|
3771
|
+
return;
|
|
3772
|
+
}
|
|
3773
|
+
this.$hour().value.set('00');
|
|
3774
|
+
this.$minute().value.set('00');
|
|
3775
|
+
this.$period().value.set('AM');
|
|
3776
|
+
}
|
|
3777
|
+
parseInitialValue(value) {
|
|
3778
|
+
if (!value) {
|
|
3779
|
+
return null;
|
|
3780
|
+
}
|
|
3781
|
+
const raw = value.trim().toUpperCase();
|
|
3782
|
+
if (!raw) {
|
|
3783
|
+
return null;
|
|
3784
|
+
}
|
|
3785
|
+
const matched = raw.match(/^(\d{1,2}):(\d{1,2})(?:\s*(AM|PM))?$/);
|
|
3786
|
+
if (!matched) {
|
|
3787
|
+
return null;
|
|
3788
|
+
}
|
|
3789
|
+
let hour = Number(matched[1]);
|
|
3790
|
+
let minute = Number(matched[2]);
|
|
3791
|
+
const periodFromInput = matched[3];
|
|
3792
|
+
if (Number.isNaN(hour) || Number.isNaN(minute)) {
|
|
3793
|
+
return null;
|
|
3794
|
+
}
|
|
3795
|
+
if (minute < 0 || minute > 59) {
|
|
3796
|
+
minute = Math.min(Math.max(minute, 0), 59);
|
|
3797
|
+
}
|
|
3798
|
+
if (this.is12HourFormat) {
|
|
3799
|
+
let period = periodFromInput === 'PM' ? 'PM' : 'AM';
|
|
3800
|
+
if (!periodFromInput) {
|
|
3801
|
+
if (hour >= 12) {
|
|
3802
|
+
period = 'PM';
|
|
3803
|
+
}
|
|
3804
|
+
hour = hour % 12;
|
|
3805
|
+
}
|
|
3806
|
+
if (hour > 12) {
|
|
3807
|
+
hour = 12;
|
|
3808
|
+
}
|
|
3809
|
+
if (hour < 0) {
|
|
3810
|
+
hour = 0;
|
|
3811
|
+
}
|
|
3812
|
+
return {
|
|
3813
|
+
hour: hour.toString().padStart(2, '0'),
|
|
3814
|
+
minute: minute.toString().padStart(2, '0'),
|
|
3815
|
+
period: period,
|
|
3816
|
+
};
|
|
3817
|
+
}
|
|
3818
|
+
if (periodFromInput) {
|
|
3819
|
+
if (periodFromInput === 'AM') {
|
|
3820
|
+
if (hour === 12) {
|
|
3821
|
+
hour = 0;
|
|
3822
|
+
}
|
|
3823
|
+
}
|
|
3824
|
+
else if (periodFromInput === 'PM') {
|
|
3825
|
+
if (hour < 12) {
|
|
3826
|
+
hour += 12;
|
|
3827
|
+
}
|
|
3828
|
+
}
|
|
3829
|
+
}
|
|
3830
|
+
if (hour < 0) {
|
|
3831
|
+
hour = 0;
|
|
3832
|
+
}
|
|
3833
|
+
if (hour > 23) {
|
|
3834
|
+
hour = 23;
|
|
3835
|
+
}
|
|
3836
|
+
return {
|
|
3837
|
+
hour: hour.toString().padStart(2, '0'),
|
|
3838
|
+
minute: minute.toString().padStart(2, '0'),
|
|
3839
|
+
period: 'AM',
|
|
3840
|
+
};
|
|
3841
|
+
}
|
|
3842
|
+
emitTime() {
|
|
3843
|
+
const hour = this.normalizeHourInput(this.$hour().value()).padStart(2, '0');
|
|
3844
|
+
const minute = this.normalizeMinuteInput(this.$minute().value()).padStart(2, '0');
|
|
3845
|
+
if (this.is12HourFormat) {
|
|
3846
|
+
const period = this.normalizePeriodInput(this.$period().value()) || 'AM';
|
|
3847
|
+
this.onTimeSelect(`${hour}:${minute} ${period}`);
|
|
3848
|
+
return;
|
|
3849
|
+
}
|
|
3850
|
+
this.onTimeSelect(`${hour}:${minute}`);
|
|
3851
|
+
}
|
|
3852
|
+
onTimeSelect(time) {
|
|
3853
|
+
this.action(time);
|
|
3854
|
+
}
|
|
3855
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiTimeDropdownDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
3856
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.1", type: UiTimeDropdownDirective, isStandalone: true, selector: "app-ui-time-dropdown", inputs: { action: "action", initialValue: "initialValue" }, ngImport: i0 });
|
|
3857
|
+
}
|
|
3858
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiTimeDropdownDirective, decorators: [{
|
|
3859
|
+
type: Directive,
|
|
3860
|
+
args: [{
|
|
3861
|
+
selector: 'app-ui-time-dropdown',
|
|
3862
|
+
}]
|
|
3863
|
+
}], propDecorators: { action: [{
|
|
3864
|
+
type: Input
|
|
3865
|
+
}], initialValue: [{
|
|
3866
|
+
type: Input
|
|
3867
|
+
}] } });
|
|
3868
|
+
|
|
3406
3869
|
/*
|
|
3407
3870
|
* Public API Surface of ui-forge-library
|
|
3408
3871
|
*/
|
|
@@ -3411,5 +3874,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
3411
3874
|
* Generated bundle index. Do not edit.
|
|
3412
3875
|
*/
|
|
3413
3876
|
|
|
3414
|
-
export { Alert, AlertType, AppIconsLibrary, AutoFocusDirective, CenterEllipsisPipe, CountryService, DateUtils, EMAIL, HAS_CAPITAL_CASE, HAS_NUMBER, HAS_SMALL_CASE, HAS_SPECIAL_CHARTERS, HoverTipDirective, IconComponent, LazyImgDirective, MIN_LENGTH, MaskGradientDirective, SkeletonDirective, StickyObserverDirective, ThemeService, TrackLifecycleDirective, UIInputDateDirective, UIPhoneNumberDirective, UiAccordionComponent, UiAlertMessagesService, UiAvatarDirective, UiButtonDirective, UiCodeDirective, UiCopyButtonDirective, UiDailyCalendarDirective, UiDropdownContainerDirective, UiDropdownService, UiFieldBaseDirective, UiImageDirective, UiInputCheckboxDirective, UiInputCountryDirective, UiInputDirective, UiInputSelectDirective, UiInputSequenceDirective, UiInputTimeDirective, UiMonthlyCalendarDirective, UiPaginationDirective, UiPopupBackdropDirective, UiPopupContainerDirective, UiPopupImageDirective, UiPopupInstance, UiPopupService, UiSelectButtonsDirective, UiTabsDirective, UiValidationErrorsDirective, UiYearlyCalendarDirective, emptyCountry, getAspectRatioFit, stringToHslColor };
|
|
3877
|
+
export { Alert, AlertType, AppIconsLibrary, AutoFocusDirective, CenterEllipsisPipe, CountryService, DateUtils, EMAIL, HAS_CAPITAL_CASE, HAS_NUMBER, HAS_SMALL_CASE, HAS_SPECIAL_CHARTERS, HoverTipDirective, IconComponent, LazyImgDirective, MIN_LENGTH, MaskGradientDirective, SkeletonDirective, StickyObserverDirective, ThemeService, TrackLifecycleDirective, UIInputDateDirective, UIPhoneNumberDirective, UiAccordionComponent, UiAlertMessagesService, UiAvatarDirective, UiButtonDirective, UiCalendarDropdownDirective, UiCodeDirective, UiCopyButtonDirective, UiDailyCalendarDirective, UiDropdownContainerDirective, UiDropdownService, UiFieldBaseDirective, UiImageDirective, UiInputCheckboxDirective, UiInputCountryDirective, UiInputDirective, UiInputSelectDirective, UiInputSequenceDirective, UiInputTimeDirective, UiMonthlyCalendarDirective, UiPaginationDirective, UiPopupBackdropDirective, UiPopupContainerDirective, UiPopupImageDirective, UiPopupInstance, UiPopupService, UiSelectButtonsDirective, UiTabsDirective, UiTimeDropdownDirective, UiValidationErrorsDirective, UiYearlyCalendarDirective, emptyCountry, getAspectRatioFit, stringToHslColor };
|
|
3415
3878
|
//# sourceMappingURL=ibragim-dev-org-ui-forge-library.mjs.map
|