@ibragim-dev-org/ui-forge-library 1.2.4 → 1.2.5
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.
|
@@ -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()) {
|
|
@@ -975,6 +976,8 @@ class UiDailyCalendarDirective {
|
|
|
975
976
|
weekDaysEuropean = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
|
976
977
|
weekDaysUsa = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
977
978
|
$isRangeSelection = input(false, ...(ngDevMode ? [{ debugName: "$isRangeSelection" }] : []));
|
|
979
|
+
$minDate = input(undefined, ...(ngDevMode ? [{ debugName: "$minDate" }] : []));
|
|
980
|
+
$maxDate = input(undefined, ...(ngDevMode ? [{ debugName: "$maxDate" }] : []));
|
|
978
981
|
get weekDays() {
|
|
979
982
|
return this.isUsaDateFormat() ? this.weekDaysUsa : this.weekDaysEuropean;
|
|
980
983
|
}
|
|
@@ -1035,6 +1038,21 @@ class UiDailyCalendarDirective {
|
|
|
1035
1038
|
return false;
|
|
1036
1039
|
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
1037
1040
|
}
|
|
1041
|
+
normalizeDate(date) {
|
|
1042
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
1043
|
+
}
|
|
1044
|
+
isDisabledDate(date) {
|
|
1045
|
+
const currentTimestamp = this.normalizeDate(date).getTime();
|
|
1046
|
+
const minDate = this.$minDate();
|
|
1047
|
+
if (minDate && currentTimestamp < this.normalizeDate(minDate).getTime()) {
|
|
1048
|
+
return true;
|
|
1049
|
+
}
|
|
1050
|
+
const maxDate = this.$maxDate();
|
|
1051
|
+
if (maxDate && currentTimestamp > this.normalizeDate(maxDate).getTime()) {
|
|
1052
|
+
return true;
|
|
1053
|
+
}
|
|
1054
|
+
return false;
|
|
1055
|
+
}
|
|
1038
1056
|
isBetween(date, start, end) {
|
|
1039
1057
|
if (!start || !end)
|
|
1040
1058
|
return false;
|
|
@@ -1044,11 +1062,23 @@ class UiDailyCalendarDirective {
|
|
|
1044
1062
|
return d > s && d < e;
|
|
1045
1063
|
}
|
|
1046
1064
|
getDayState(date) {
|
|
1065
|
+
const isDisabled = this.isDisabledDate(date);
|
|
1066
|
+
if (isDisabled) {
|
|
1067
|
+
return {
|
|
1068
|
+
isDisabled: true,
|
|
1069
|
+
isSelected: false,
|
|
1070
|
+
isStart: false,
|
|
1071
|
+
isEnd: false,
|
|
1072
|
+
inRange: false,
|
|
1073
|
+
inHoverRange: false,
|
|
1074
|
+
};
|
|
1075
|
+
}
|
|
1047
1076
|
const hover = this.$hoverDate();
|
|
1048
1077
|
const start = this.$dateStart();
|
|
1049
1078
|
const end = this.$dateEnd();
|
|
1050
1079
|
if (!this.$isRangeSelection()) {
|
|
1051
1080
|
return {
|
|
1081
|
+
isDisabled: false,
|
|
1052
1082
|
isSelected: this.isSameDay(start, date),
|
|
1053
1083
|
isStart: false,
|
|
1054
1084
|
isEnd: false,
|
|
@@ -1071,7 +1101,7 @@ class UiDailyCalendarDirective {
|
|
|
1071
1101
|
}
|
|
1072
1102
|
const isSingleSelected = this.isSameDay(start, date) || this.isSameDay(end, date);
|
|
1073
1103
|
const isSelected = isStart || isEnd || (!end && isStart) || isSingleSelected;
|
|
1074
|
-
return { isSelected, isStart, isEnd, inRange, inHoverRange };
|
|
1104
|
+
return { isDisabled: false, isSelected, isStart, isEnd, inRange, inHoverRange };
|
|
1075
1105
|
}
|
|
1076
1106
|
onHover(date, inHoverRange) {
|
|
1077
1107
|
if (inHoverRange) {
|
|
@@ -1083,6 +1113,10 @@ class UiDailyCalendarDirective {
|
|
|
1083
1113
|
this.$hoverDate.set(null);
|
|
1084
1114
|
return;
|
|
1085
1115
|
}
|
|
1116
|
+
if (this.isDisabledDate(date)) {
|
|
1117
|
+
this.$hoverDate.set(null);
|
|
1118
|
+
return;
|
|
1119
|
+
}
|
|
1086
1120
|
if (!this.$isRangeSelection()) {
|
|
1087
1121
|
return;
|
|
1088
1122
|
}
|
|
@@ -1099,6 +1133,9 @@ class UiDailyCalendarDirective {
|
|
|
1099
1133
|
return DateUtils.isUsaDateFormat();
|
|
1100
1134
|
}
|
|
1101
1135
|
select(date) {
|
|
1136
|
+
if (this.isDisabledDate(date)) {
|
|
1137
|
+
return;
|
|
1138
|
+
}
|
|
1102
1139
|
this.$hoverDate.set(null);
|
|
1103
1140
|
if (!this.$isRangeSelection()) {
|
|
1104
1141
|
this.$dateStart.set(date);
|
|
@@ -1127,14 +1164,14 @@ class UiDailyCalendarDirective {
|
|
|
1127
1164
|
}
|
|
1128
1165
|
}
|
|
1129
1166
|
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 });
|
|
1167
|
+
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
1168
|
}
|
|
1132
1169
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiDailyCalendarDirective, decorators: [{
|
|
1133
1170
|
type: Directive,
|
|
1134
1171
|
args: [{
|
|
1135
1172
|
selector: 'app-ui-daily-calendar',
|
|
1136
1173
|
}]
|
|
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"] }] } });
|
|
1174
|
+
}], 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
1175
|
|
|
1139
1176
|
class UiMonthlyCalendarDirective {
|
|
1140
1177
|
$date = model(new Date(), ...(ngDevMode ? [{ debugName: "$date" }] : []));
|
|
@@ -1237,6 +1274,106 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
1237
1274
|
}]
|
|
1238
1275
|
}], 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
1276
|
|
|
1277
|
+
class UiCalendarDropdownDirective {
|
|
1278
|
+
action = () => { };
|
|
1279
|
+
rangeSelect = () => { };
|
|
1280
|
+
startDate = null;
|
|
1281
|
+
endDate = null;
|
|
1282
|
+
isRangeSelection = false;
|
|
1283
|
+
minDate = undefined;
|
|
1284
|
+
maxDate = undefined;
|
|
1285
|
+
$close = signal(false, ...(ngDevMode ? [{ debugName: "$close" }] : []));
|
|
1286
|
+
$height = signal(0, ...(ngDevMode ? [{ debugName: "$height" }] : []));
|
|
1287
|
+
$width = signal(0, ...(ngDevMode ? [{ debugName: "$width" }] : []));
|
|
1288
|
+
$currentMonth = signal(this.startDate ? this.startDate.getMonth() : new Date().getMonth(), ...(ngDevMode ? [{ debugName: "$currentMonth" }] : []));
|
|
1289
|
+
$currentYear = signal(this.startDate ? this.startDate.getFullYear() : new Date().getFullYear(), ...(ngDevMode ? [{ debugName: "$currentYear" }] : []));
|
|
1290
|
+
$mode = signal('day', ...(ngDevMode ? [{ debugName: "$mode" }] : []));
|
|
1291
|
+
$view = signal({ key: 'day', state: 'enter-up' }, ...(ngDevMode ? [{ debugName: "$view" }] : []));
|
|
1292
|
+
levels = { day: 1, month: 2, year: 3 };
|
|
1293
|
+
$current = signal('day', ...(ngDevMode ? [{ debugName: "$current" }] : []));
|
|
1294
|
+
ngOnChanges(changes) {
|
|
1295
|
+
if (changes['startDate'] || changes['minDate'] || changes['maxDate']) {
|
|
1296
|
+
const currentDate = this.getInitialViewDate();
|
|
1297
|
+
this.$currentMonth.set(currentDate.getMonth());
|
|
1298
|
+
this.$currentYear.set(currentDate.getFullYear());
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
normalizeDate(date) {
|
|
1302
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
1303
|
+
}
|
|
1304
|
+
getInitialViewDate() {
|
|
1305
|
+
return this.clampToRange(this.startDate ?? new Date());
|
|
1306
|
+
}
|
|
1307
|
+
clampToRange(date) {
|
|
1308
|
+
const normalizedDate = this.normalizeDate(date);
|
|
1309
|
+
const normalizedMin = this.minDate ? this.normalizeDate(this.minDate) : undefined;
|
|
1310
|
+
const normalizedMax = this.maxDate ? this.normalizeDate(this.maxDate) : undefined;
|
|
1311
|
+
if (normalizedMin && normalizedDate.getTime() < normalizedMin.getTime()) {
|
|
1312
|
+
return normalizedMin;
|
|
1313
|
+
}
|
|
1314
|
+
if (normalizedMax && normalizedDate.getTime() > normalizedMax.getTime()) {
|
|
1315
|
+
return normalizedMax;
|
|
1316
|
+
}
|
|
1317
|
+
return normalizedDate;
|
|
1318
|
+
}
|
|
1319
|
+
select(date) {
|
|
1320
|
+
this.action(date);
|
|
1321
|
+
this.startDate = date;
|
|
1322
|
+
}
|
|
1323
|
+
selectMonth(date) {
|
|
1324
|
+
this.$currentMonth.set(date.getMonth());
|
|
1325
|
+
}
|
|
1326
|
+
selectYear(date) {
|
|
1327
|
+
this.$currentYear.set(date.getFullYear());
|
|
1328
|
+
}
|
|
1329
|
+
onRangeSelect(dates) {
|
|
1330
|
+
this.startDate = dates.start ?? new Date();
|
|
1331
|
+
this.rangeSelect(dates);
|
|
1332
|
+
}
|
|
1333
|
+
setToday() {
|
|
1334
|
+
this.startDate = this.clampToRange(new Date());
|
|
1335
|
+
this.action(this.startDate);
|
|
1336
|
+
}
|
|
1337
|
+
setMode(next) {
|
|
1338
|
+
const prev = this.$current();
|
|
1339
|
+
const prevLevel = this.levels[prev];
|
|
1340
|
+
const nextLevel = this.levels[next];
|
|
1341
|
+
const direction = nextLevel > prevLevel ? 'up' : 'down';
|
|
1342
|
+
this.$view.update(() => ({ key: prev, state: `leave-${direction}` }));
|
|
1343
|
+
asyncScheduler.schedule(() => {
|
|
1344
|
+
this.$current.set(next);
|
|
1345
|
+
this.$view.update(() => ({ key: next, state: `enter-${direction}` }));
|
|
1346
|
+
this.$mode.set(next);
|
|
1347
|
+
}, 200);
|
|
1348
|
+
}
|
|
1349
|
+
setSize(size) {
|
|
1350
|
+
this.$height.set(size.height);
|
|
1351
|
+
this.$width.set(size.width);
|
|
1352
|
+
}
|
|
1353
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiCalendarDropdownDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1354
|
+
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 });
|
|
1355
|
+
}
|
|
1356
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiCalendarDropdownDirective, decorators: [{
|
|
1357
|
+
type: Directive,
|
|
1358
|
+
args: [{
|
|
1359
|
+
selector: 'app-ui-calendar-dropdown-calendar',
|
|
1360
|
+
}]
|
|
1361
|
+
}], propDecorators: { action: [{
|
|
1362
|
+
type: Input
|
|
1363
|
+
}], rangeSelect: [{
|
|
1364
|
+
type: Input
|
|
1365
|
+
}], startDate: [{
|
|
1366
|
+
type: Input
|
|
1367
|
+
}], endDate: [{
|
|
1368
|
+
type: Input
|
|
1369
|
+
}], isRangeSelection: [{
|
|
1370
|
+
type: Input
|
|
1371
|
+
}], minDate: [{
|
|
1372
|
+
type: Input
|
|
1373
|
+
}], maxDate: [{
|
|
1374
|
+
type: Input
|
|
1375
|
+
}] } });
|
|
1376
|
+
|
|
1240
1377
|
const typescript = {
|
|
1241
1378
|
comment: { css: 'hl1', regexp: /(\/\/.*|\/\*[\s\S]*?\*\/)/g },
|
|
1242
1379
|
string: { css: 'hl3', regexp: /(["'`].*?["'`])/gs },
|
|
@@ -2928,6 +3065,7 @@ class UiInputDirective extends UiFieldBaseDirective {
|
|
|
2928
3065
|
renderer;
|
|
2929
3066
|
$size = input('medium', ...(ngDevMode ? [{ debugName: "$size" }] : []));
|
|
2930
3067
|
$placeholder = input('', ...(ngDevMode ? [{ debugName: "$placeholder" }] : []));
|
|
3068
|
+
$inputMode = input('text', ...(ngDevMode ? [{ debugName: "$inputMode" }] : []));
|
|
2931
3069
|
$label = input('', ...(ngDevMode ? [{ debugName: "$label" }] : []));
|
|
2932
3070
|
$shouldFocusedAfterViewInit = input(false, ...(ngDevMode ? [{ debugName: "$shouldFocusedAfterViewInit" }] : []));
|
|
2933
3071
|
$isRounded = input(false, ...(ngDevMode ? [{ debugName: "$isRounded" }] : []));
|
|
@@ -2958,14 +3096,14 @@ class UiInputDirective extends UiFieldBaseDirective {
|
|
|
2958
3096
|
});
|
|
2959
3097
|
}
|
|
2960
3098
|
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 });
|
|
3099
|
+
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
3100
|
}
|
|
2963
3101
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiInputDirective, decorators: [{
|
|
2964
3102
|
type: Directive,
|
|
2965
3103
|
args: [{
|
|
2966
3104
|
selector: 'app-ui-input',
|
|
2967
3105
|
}]
|
|
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 }] }] } });
|
|
3106
|
+
}], 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
3107
|
|
|
2970
3108
|
class UiInputCountryDirective extends UiInputDirective {
|
|
2971
3109
|
$selectedCountry = signal(emptyCountry, ...(ngDevMode ? [{ debugName: "$selectedCountry" }] : []));
|
|
@@ -3029,6 +3167,8 @@ class UIInputDateDirective extends UiInputDirective {
|
|
|
3029
3167
|
$isOpen = signal(false, ...(ngDevMode ? [{ debugName: "$isOpen" }] : []));
|
|
3030
3168
|
$isRangeSelection = input(false, ...(ngDevMode ? [{ debugName: "$isRangeSelection" }] : []));
|
|
3031
3169
|
$dividePattern = input('/', ...(ngDevMode ? [{ debugName: "$dividePattern" }] : []));
|
|
3170
|
+
$minDate = input(undefined, ...(ngDevMode ? [{ debugName: "$minDate" }] : []));
|
|
3171
|
+
$maxDate = input(undefined, ...(ngDevMode ? [{ debugName: "$maxDate" }] : []));
|
|
3032
3172
|
$inputElement = viewChild('input', ...(ngDevMode ? [{ debugName: "$inputElement" }] : []));
|
|
3033
3173
|
setDate(date) {
|
|
3034
3174
|
const newDate = this.formatDate(date);
|
|
@@ -3107,14 +3247,14 @@ class UIInputDateDirective extends UiInputDirective {
|
|
|
3107
3247
|
return formatSingle(limited);
|
|
3108
3248
|
}
|
|
3109
3249
|
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 });
|
|
3250
|
+
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
3251
|
}
|
|
3112
3252
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UIInputDateDirective, decorators: [{
|
|
3113
3253
|
type: Directive,
|
|
3114
3254
|
args: [{
|
|
3115
3255
|
selector: 'app-ui-input-date',
|
|
3116
3256
|
}]
|
|
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 }] }] } });
|
|
3257
|
+
}], 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
3258
|
|
|
3119
3259
|
class UIPhoneNumberDirective extends UiInputDirective {
|
|
3120
3260
|
$selectedCountry = signal(emptyCountry, ...(ngDevMode ? [{ debugName: "$selectedCountry" }] : []));
|
|
@@ -3273,56 +3413,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
3273
3413
|
}] } });
|
|
3274
3414
|
|
|
3275
3415
|
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
|
-
];
|
|
3416
|
+
get times() {
|
|
3417
|
+
const items = [];
|
|
3418
|
+
for (let hour = 0; hour < 24; hour++) {
|
|
3419
|
+
items.push(this.formatTime(hour, 0));
|
|
3420
|
+
items.push(this.formatTime(hour, 30));
|
|
3421
|
+
}
|
|
3422
|
+
return items;
|
|
3423
|
+
}
|
|
3424
|
+
get inputMode() {
|
|
3425
|
+
return this.uses12HourTime() ? 'text' : 'numeric';
|
|
3426
|
+
}
|
|
3326
3427
|
$inputElement = viewChild('input', ...(ngDevMode ? [{ debugName: "$inputElement" }] : []));
|
|
3327
3428
|
$isOpen = signal(false, ...(ngDevMode ? [{ debugName: "$isOpen" }] : []));
|
|
3328
3429
|
onInput(value) {
|
|
@@ -3336,9 +3437,13 @@ class UiInputTimeDirective extends UiInputDirective {
|
|
|
3336
3437
|
const oldColonCount = (oldValue.match(/:/g) || []).length;
|
|
3337
3438
|
const newColonCount = (newValue.match(/:/g) || []).length;
|
|
3338
3439
|
const colonAdded = newColonCount > oldColonCount;
|
|
3440
|
+
const oldMeridiemLength = this.extractMeridiem(oldValue).length;
|
|
3441
|
+
const newMeridiemLength = this.extractMeridiem(newValue).length;
|
|
3442
|
+
const meridiemAdded = newMeridiemLength > oldMeridiemLength;
|
|
3443
|
+
const meridiemFormatted = this.uses12HourTime() && oldValue !== newValue;
|
|
3339
3444
|
super.onInput(newValue);
|
|
3340
3445
|
inputElement.value = newValue;
|
|
3341
|
-
if (colonAdded) {
|
|
3446
|
+
if (colonAdded || meridiemAdded || meridiemFormatted) {
|
|
3342
3447
|
inputElement.setSelectionRange(newValue.length, newValue.length);
|
|
3343
3448
|
}
|
|
3344
3449
|
else {
|
|
@@ -3349,6 +3454,9 @@ class UiInputTimeDirective extends UiInputDirective {
|
|
|
3349
3454
|
if (!value) {
|
|
3350
3455
|
return '';
|
|
3351
3456
|
}
|
|
3457
|
+
if (this.uses12HourTime()) {
|
|
3458
|
+
return this.mask12HourTime(value);
|
|
3459
|
+
}
|
|
3352
3460
|
const digits = value.replace(/\D/g, '').slice(0, 4);
|
|
3353
3461
|
const len = digits.length;
|
|
3354
3462
|
if (len === 1) {
|
|
@@ -3380,6 +3488,72 @@ class UiInputTimeDirective extends UiInputDirective {
|
|
|
3380
3488
|
}
|
|
3381
3489
|
return '';
|
|
3382
3490
|
}
|
|
3491
|
+
mask12HourTime(value) {
|
|
3492
|
+
const digits = value.replace(/\D/g, '').slice(0, 4);
|
|
3493
|
+
const meridiem = this.extractMeridiem(value);
|
|
3494
|
+
if (!digits) {
|
|
3495
|
+
return meridiem;
|
|
3496
|
+
}
|
|
3497
|
+
const len = digits.length;
|
|
3498
|
+
if (len === 1) {
|
|
3499
|
+
return this.appendMeridiem(digits, meridiem);
|
|
3500
|
+
}
|
|
3501
|
+
if (len === 2) {
|
|
3502
|
+
const hours = this.clampTwelveHour(digits.slice(0, 2), false);
|
|
3503
|
+
return this.appendMeridiem(hours, meridiem);
|
|
3504
|
+
}
|
|
3505
|
+
if (len === 3) {
|
|
3506
|
+
const hours = this.clampTwelveHour(digits.slice(0, 2), false);
|
|
3507
|
+
return this.appendMeridiem(`${hours}:${digits[2]}`, meridiem);
|
|
3508
|
+
}
|
|
3509
|
+
const hours = this.clampTwelveHour(digits.slice(0, 2), true);
|
|
3510
|
+
const minutes = this.clampMinutes(digits.slice(2, 4));
|
|
3511
|
+
return this.appendMeridiem(`${hours}:${minutes}`, meridiem);
|
|
3512
|
+
}
|
|
3513
|
+
appendMeridiem(time, meridiem) {
|
|
3514
|
+
return meridiem ? `${time} ${meridiem}` : time;
|
|
3515
|
+
}
|
|
3516
|
+
clampTwelveHour(value, fallbackToTwelve) {
|
|
3517
|
+
let hours = Number(value);
|
|
3518
|
+
if (hours > 12) {
|
|
3519
|
+
hours = 12;
|
|
3520
|
+
}
|
|
3521
|
+
if (fallbackToTwelve && hours === 0) {
|
|
3522
|
+
hours = 12;
|
|
3523
|
+
}
|
|
3524
|
+
return hours.toString().padStart(2, '0');
|
|
3525
|
+
}
|
|
3526
|
+
clampMinutes(value) {
|
|
3527
|
+
let minutes = Number(value);
|
|
3528
|
+
if (minutes > 59) {
|
|
3529
|
+
minutes = 59;
|
|
3530
|
+
}
|
|
3531
|
+
return minutes.toString().padStart(2, '0');
|
|
3532
|
+
}
|
|
3533
|
+
extractMeridiem(value) {
|
|
3534
|
+
const normalized = value.toUpperCase().replace(/[^APM]/g, '');
|
|
3535
|
+
if (!normalized) {
|
|
3536
|
+
return '';
|
|
3537
|
+
}
|
|
3538
|
+
if (normalized.startsWith('A')) {
|
|
3539
|
+
return normalized.includes('M') ? 'AM' : 'A';
|
|
3540
|
+
}
|
|
3541
|
+
if (normalized.startsWith('P')) {
|
|
3542
|
+
return normalized.includes('M') ? 'PM' : 'P';
|
|
3543
|
+
}
|
|
3544
|
+
return '';
|
|
3545
|
+
}
|
|
3546
|
+
uses12HourTime() {
|
|
3547
|
+
return new Intl.DateTimeFormat(undefined, { hour: 'numeric' }).resolvedOptions().hour12 ?? false;
|
|
3548
|
+
}
|
|
3549
|
+
formatTime(hour, minute) {
|
|
3550
|
+
if (!this.uses12HourTime()) {
|
|
3551
|
+
return `${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`;
|
|
3552
|
+
}
|
|
3553
|
+
const period = hour >= 12 ? 'PM' : 'AM';
|
|
3554
|
+
const normalizedHour = hour % 12 || 12;
|
|
3555
|
+
return `${normalizedHour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')} ${period}`;
|
|
3556
|
+
}
|
|
3383
3557
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiInputTimeDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
3384
3558
|
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
3559
|
}
|
|
@@ -3403,6 +3577,260 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
3403
3577
|
}]
|
|
3404
3578
|
}], propDecorators: { $isError: [{ type: i0.Input, args: [{ isSignal: true, alias: "$isError", required: false }] }], $errors: [{ type: i0.Input, args: [{ isSignal: true, alias: "$errors", required: true }] }] } });
|
|
3405
3579
|
|
|
3580
|
+
class UiTimeDropdownDirective {
|
|
3581
|
+
$close = signal(false, ...(ngDevMode ? [{ debugName: "$close" }] : []));
|
|
3582
|
+
is12HourFormat = new Intl.DateTimeFormat(undefined, { hour: 'numeric' }).resolvedOptions().hour12 ?? false;
|
|
3583
|
+
$hourForm = signal('', ...(ngDevMode ? [{ debugName: "$hourForm" }] : []));
|
|
3584
|
+
$minuteForm = signal('', ...(ngDevMode ? [{ debugName: "$minuteForm" }] : []));
|
|
3585
|
+
$periodForm = signal('', ...(ngDevMode ? [{ debugName: "$periodForm" }] : []));
|
|
3586
|
+
$hour = form(this.$hourForm);
|
|
3587
|
+
$minute = form(this.$minuteForm);
|
|
3588
|
+
$period = form(this.$periodForm);
|
|
3589
|
+
action = () => { };
|
|
3590
|
+
initialValue = null;
|
|
3591
|
+
ngOnInit() {
|
|
3592
|
+
this.setInitialTime();
|
|
3593
|
+
}
|
|
3594
|
+
onHourInput(event) {
|
|
3595
|
+
const inputElement = event.target;
|
|
3596
|
+
if (!inputElement) {
|
|
3597
|
+
return;
|
|
3598
|
+
}
|
|
3599
|
+
const newValue = this.normalizeHourInput(inputElement.value);
|
|
3600
|
+
inputElement.value = newValue;
|
|
3601
|
+
this.$hour().value.set(newValue);
|
|
3602
|
+
this.emitTime();
|
|
3603
|
+
}
|
|
3604
|
+
onMinuteInput(event) {
|
|
3605
|
+
const inputElement = event.target;
|
|
3606
|
+
if (!inputElement) {
|
|
3607
|
+
return;
|
|
3608
|
+
}
|
|
3609
|
+
const newValue = this.normalizeMinuteInput(inputElement.value);
|
|
3610
|
+
inputElement.value = newValue;
|
|
3611
|
+
this.$minute().value.set(newValue);
|
|
3612
|
+
this.emitTime();
|
|
3613
|
+
}
|
|
3614
|
+
onPeriodInput(event) {
|
|
3615
|
+
if (!this.is12HourFormat) {
|
|
3616
|
+
return;
|
|
3617
|
+
}
|
|
3618
|
+
const inputElement = event.target;
|
|
3619
|
+
if (!inputElement) {
|
|
3620
|
+
return;
|
|
3621
|
+
}
|
|
3622
|
+
const newValue = this.normalizePeriodInput(inputElement.value);
|
|
3623
|
+
inputElement.value = newValue;
|
|
3624
|
+
this.$period().value.set(newValue);
|
|
3625
|
+
this.emitTime();
|
|
3626
|
+
}
|
|
3627
|
+
increaseHour() {
|
|
3628
|
+
const hourValue = this.parseNumber(this.$hour().value());
|
|
3629
|
+
const min = this.is12HourFormat ? 1 : 0;
|
|
3630
|
+
const max = this.is12HourFormat ? 12 : 23;
|
|
3631
|
+
this.$hour().value.set(this.incrementWithinRange(hourValue, min, max));
|
|
3632
|
+
this.emitTime();
|
|
3633
|
+
}
|
|
3634
|
+
decreaseHour() {
|
|
3635
|
+
const hourValue = this.parseNumber(this.$hour().value());
|
|
3636
|
+
const min = this.is12HourFormat ? 1 : 0;
|
|
3637
|
+
const max = this.is12HourFormat ? 12 : 23;
|
|
3638
|
+
this.$hour().value.set(this.decrementWithinRange(hourValue, min, max));
|
|
3639
|
+
this.emitTime();
|
|
3640
|
+
}
|
|
3641
|
+
increaseMinute() {
|
|
3642
|
+
const minuteValue = this.parseNumber(this.$minute().value());
|
|
3643
|
+
this.$minute().value.set(this.incrementWithinRange(minuteValue, 0, 59));
|
|
3644
|
+
this.emitTime();
|
|
3645
|
+
}
|
|
3646
|
+
decreaseMinute() {
|
|
3647
|
+
const minuteValue = this.parseNumber(this.$minute().value());
|
|
3648
|
+
this.$minute().value.set(this.decrementWithinRange(minuteValue, 0, 59));
|
|
3649
|
+
this.emitTime();
|
|
3650
|
+
}
|
|
3651
|
+
increasePeriod() {
|
|
3652
|
+
if (!this.is12HourFormat) {
|
|
3653
|
+
return;
|
|
3654
|
+
}
|
|
3655
|
+
this.$period().value.set(this.$period().value() === 'AM' ? 'PM' : 'AM');
|
|
3656
|
+
this.emitTime();
|
|
3657
|
+
}
|
|
3658
|
+
decreasePeriod() {
|
|
3659
|
+
this.increasePeriod();
|
|
3660
|
+
}
|
|
3661
|
+
incrementWithinRange(value, min, max) {
|
|
3662
|
+
const safeValue = Number.isNaN(value) ? min : value;
|
|
3663
|
+
const nextValue = safeValue >= max ? min : safeValue + 1;
|
|
3664
|
+
return nextValue.toString().padStart(2, '0');
|
|
3665
|
+
}
|
|
3666
|
+
decrementWithinRange(value, min, max) {
|
|
3667
|
+
const safeValue = Number.isNaN(value) ? min : value;
|
|
3668
|
+
const nextValue = safeValue <= min ? max : safeValue - 1;
|
|
3669
|
+
return nextValue.toString().padStart(2, '0');
|
|
3670
|
+
}
|
|
3671
|
+
parseNumber(value) {
|
|
3672
|
+
return Number(value);
|
|
3673
|
+
}
|
|
3674
|
+
normalizeHourInput(value) {
|
|
3675
|
+
const digits = value.replace(/\D/g, '').slice(0, 2);
|
|
3676
|
+
if (!digits) {
|
|
3677
|
+
return '';
|
|
3678
|
+
}
|
|
3679
|
+
const hour = Number(digits);
|
|
3680
|
+
if (Number.isNaN(hour)) {
|
|
3681
|
+
return '';
|
|
3682
|
+
}
|
|
3683
|
+
if (digits.length < 2) {
|
|
3684
|
+
return digits;
|
|
3685
|
+
}
|
|
3686
|
+
if (this.is12HourFormat) {
|
|
3687
|
+
if (hour > 12) {
|
|
3688
|
+
return '12';
|
|
3689
|
+
}
|
|
3690
|
+
return hour.toString().padStart(2, '0');
|
|
3691
|
+
}
|
|
3692
|
+
if (hour > 23) {
|
|
3693
|
+
return '23';
|
|
3694
|
+
}
|
|
3695
|
+
return hour.toString().padStart(2, '0');
|
|
3696
|
+
}
|
|
3697
|
+
normalizeMinuteInput(value) {
|
|
3698
|
+
const digits = value.replace(/\D/g, '').slice(0, 2);
|
|
3699
|
+
if (!digits) {
|
|
3700
|
+
return '';
|
|
3701
|
+
}
|
|
3702
|
+
const minute = Number(digits);
|
|
3703
|
+
if (Number.isNaN(minute)) {
|
|
3704
|
+
return '';
|
|
3705
|
+
}
|
|
3706
|
+
if (digits.length < 2) {
|
|
3707
|
+
return digits;
|
|
3708
|
+
}
|
|
3709
|
+
if (minute > 59) {
|
|
3710
|
+
return '59';
|
|
3711
|
+
}
|
|
3712
|
+
return minute.toString().padStart(2, '0');
|
|
3713
|
+
}
|
|
3714
|
+
normalizePeriodInput(value) {
|
|
3715
|
+
if (!this.is12HourFormat) {
|
|
3716
|
+
return '';
|
|
3717
|
+
}
|
|
3718
|
+
const lettersOnly = value.toUpperCase().replace(/[^APM]/g, '');
|
|
3719
|
+
if (!lettersOnly) {
|
|
3720
|
+
return '';
|
|
3721
|
+
}
|
|
3722
|
+
if (lettersOnly.startsWith('P')) {
|
|
3723
|
+
return 'PM';
|
|
3724
|
+
}
|
|
3725
|
+
if (lettersOnly.startsWith('A')) {
|
|
3726
|
+
return 'AM';
|
|
3727
|
+
}
|
|
3728
|
+
return '';
|
|
3729
|
+
}
|
|
3730
|
+
setInitialTime() {
|
|
3731
|
+
const parsed = this.parseInitialValue(this.initialValue);
|
|
3732
|
+
if (parsed) {
|
|
3733
|
+
this.$hour().value.set(parsed.hour);
|
|
3734
|
+
this.$minute().value.set(parsed.minute);
|
|
3735
|
+
this.$period().value.set(parsed.period);
|
|
3736
|
+
return;
|
|
3737
|
+
}
|
|
3738
|
+
this.$hour().value.set('00');
|
|
3739
|
+
this.$minute().value.set('00');
|
|
3740
|
+
this.$period().value.set('AM');
|
|
3741
|
+
}
|
|
3742
|
+
parseInitialValue(value) {
|
|
3743
|
+
if (!value) {
|
|
3744
|
+
return null;
|
|
3745
|
+
}
|
|
3746
|
+
const raw = value.trim().toUpperCase();
|
|
3747
|
+
if (!raw) {
|
|
3748
|
+
return null;
|
|
3749
|
+
}
|
|
3750
|
+
const matched = raw.match(/^(\d{1,2}):(\d{1,2})(?:\s*(AM|PM))?$/);
|
|
3751
|
+
if (!matched) {
|
|
3752
|
+
return null;
|
|
3753
|
+
}
|
|
3754
|
+
let hour = Number(matched[1]);
|
|
3755
|
+
let minute = Number(matched[2]);
|
|
3756
|
+
const periodFromInput = matched[3];
|
|
3757
|
+
if (Number.isNaN(hour) || Number.isNaN(minute)) {
|
|
3758
|
+
return null;
|
|
3759
|
+
}
|
|
3760
|
+
if (minute < 0 || minute > 59) {
|
|
3761
|
+
minute = Math.min(Math.max(minute, 0), 59);
|
|
3762
|
+
}
|
|
3763
|
+
if (this.is12HourFormat) {
|
|
3764
|
+
let period = periodFromInput === 'PM' ? 'PM' : 'AM';
|
|
3765
|
+
if (!periodFromInput) {
|
|
3766
|
+
if (hour >= 12) {
|
|
3767
|
+
period = 'PM';
|
|
3768
|
+
}
|
|
3769
|
+
hour = hour % 12;
|
|
3770
|
+
}
|
|
3771
|
+
if (hour > 12) {
|
|
3772
|
+
hour = 12;
|
|
3773
|
+
}
|
|
3774
|
+
if (hour < 0) {
|
|
3775
|
+
hour = 0;
|
|
3776
|
+
}
|
|
3777
|
+
return {
|
|
3778
|
+
hour: hour.toString().padStart(2, '0'),
|
|
3779
|
+
minute: minute.toString().padStart(2, '0'),
|
|
3780
|
+
period: period,
|
|
3781
|
+
};
|
|
3782
|
+
}
|
|
3783
|
+
if (periodFromInput) {
|
|
3784
|
+
if (periodFromInput === 'AM') {
|
|
3785
|
+
if (hour === 12) {
|
|
3786
|
+
hour = 0;
|
|
3787
|
+
}
|
|
3788
|
+
}
|
|
3789
|
+
else if (periodFromInput === 'PM') {
|
|
3790
|
+
if (hour < 12) {
|
|
3791
|
+
hour += 12;
|
|
3792
|
+
}
|
|
3793
|
+
}
|
|
3794
|
+
}
|
|
3795
|
+
if (hour < 0) {
|
|
3796
|
+
hour = 0;
|
|
3797
|
+
}
|
|
3798
|
+
if (hour > 23) {
|
|
3799
|
+
hour = 23;
|
|
3800
|
+
}
|
|
3801
|
+
return {
|
|
3802
|
+
hour: hour.toString().padStart(2, '0'),
|
|
3803
|
+
minute: minute.toString().padStart(2, '0'),
|
|
3804
|
+
period: 'AM',
|
|
3805
|
+
};
|
|
3806
|
+
}
|
|
3807
|
+
emitTime() {
|
|
3808
|
+
const hour = this.normalizeHourInput(this.$hour().value()).padStart(2, '0');
|
|
3809
|
+
const minute = this.normalizeMinuteInput(this.$minute().value()).padStart(2, '0');
|
|
3810
|
+
if (this.is12HourFormat) {
|
|
3811
|
+
const period = this.normalizePeriodInput(this.$period().value()) || 'AM';
|
|
3812
|
+
this.onTimeSelect(`${hour}:${minute} ${period}`);
|
|
3813
|
+
return;
|
|
3814
|
+
}
|
|
3815
|
+
this.onTimeSelect(`${hour}:${minute}`);
|
|
3816
|
+
}
|
|
3817
|
+
onTimeSelect(time) {
|
|
3818
|
+
this.action(time);
|
|
3819
|
+
}
|
|
3820
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiTimeDropdownDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
3821
|
+
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 });
|
|
3822
|
+
}
|
|
3823
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiTimeDropdownDirective, decorators: [{
|
|
3824
|
+
type: Directive,
|
|
3825
|
+
args: [{
|
|
3826
|
+
selector: 'app-ui-time-dropdown',
|
|
3827
|
+
}]
|
|
3828
|
+
}], propDecorators: { action: [{
|
|
3829
|
+
type: Input
|
|
3830
|
+
}], initialValue: [{
|
|
3831
|
+
type: Input
|
|
3832
|
+
}] } });
|
|
3833
|
+
|
|
3406
3834
|
/*
|
|
3407
3835
|
* Public API Surface of ui-forge-library
|
|
3408
3836
|
*/
|
|
@@ -3411,5 +3839,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
3411
3839
|
* Generated bundle index. Do not edit.
|
|
3412
3840
|
*/
|
|
3413
3841
|
|
|
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 };
|
|
3842
|
+
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
3843
|
//# sourceMappingURL=ibragim-dev-org-ui-forge-library.mjs.map
|