@ibragim-dev-org/ui-forge-library 1.2.3 → 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 },
@@ -2922,48 +3059,58 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
2922
3059
  }]
2923
3060
  }], propDecorators: { checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }, { type: i0.Output, args: ["checkedChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], $style: [{ type: i0.Input, args: [{ isSignal: true, alias: "$style", required: false }] }], $label: [{ type: i0.Input, args: [{ isSignal: true, alias: "$label", required: false }] }], $hideValidatorErrors: [{ type: i0.Input, args: [{ isSignal: true, alias: "$hideValidatorErrors", required: false }] }], errors: [{ type: i0.Input, args: [{ isSignal: true, alias: "errors", required: false }] }], touched: [{ type: i0.Input, args: [{ isSignal: true, alias: "touched", required: false }] }, { type: i0.Output, args: ["touchedChange"] }], dirty: [{ type: i0.Input, args: [{ isSignal: true, alias: "dirty", required: false }] }, { type: i0.Output, args: ["dirtyChange"] }] } });
2924
3061
 
2925
- const sizes = {
2926
- small: {
2927
- padding: 'padding-xs',
2928
- font: 'paragraph-sm',
2929
- borderRadius: 'border-radius-m',
2930
- },
2931
- medium: {
2932
- padding: 'padding-sm',
2933
- font: 'paragraph-l',
2934
- borderRadius: 'border-radius-m',
2935
- },
2936
- };
3062
+ const sizes = ['small', 'medium', 'large'];
2937
3063
  class UiInputDirective extends UiFieldBaseDirective {
3064
+ elementRef;
3065
+ renderer;
2938
3066
  $size = input('medium', ...(ngDevMode ? [{ debugName: "$size" }] : []));
2939
3067
  $placeholder = input('', ...(ngDevMode ? [{ debugName: "$placeholder" }] : []));
3068
+ $inputMode = input('text', ...(ngDevMode ? [{ debugName: "$inputMode" }] : []));
2940
3069
  $label = input('', ...(ngDevMode ? [{ debugName: "$label" }] : []));
2941
3070
  $shouldFocusedAfterViewInit = input(false, ...(ngDevMode ? [{ debugName: "$shouldFocusedAfterViewInit" }] : []));
3071
+ $isRounded = input(false, ...(ngDevMode ? [{ debugName: "$isRounded" }] : []));
2942
3072
  $hideValidatorErrors = input(false, ...(ngDevMode ? [{ debugName: "$hideValidatorErrors" }] : []));
2943
3073
  $icon = input(null, ...(ngDevMode ? [{ debugName: "$icon" }] : []));
2944
- $layoutSize = computed(() => {
2945
- const size = this.$size();
2946
- return sizes[size];
2947
- }, ...(ngDevMode ? [{ debugName: "$layoutSize" }] : []));
2948
3074
  $isError = computed(() => {
2949
3075
  return (this.touched() || (this.dirty() && this.touched())) && this.invalid();
2950
3076
  }, ...(ngDevMode ? [{ debugName: "$isError" }] : []));
2951
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiInputDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2952
- 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 }, $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 });
3077
+ constructor(elementRef, renderer) {
3078
+ super();
3079
+ this.elementRef = elementRef;
3080
+ this.renderer = renderer;
3081
+ effect(() => {
3082
+ sizes.forEach((size) => {
3083
+ this.renderer.removeClass(this.elementRef.nativeElement, size);
3084
+ });
3085
+ const size = this.$size();
3086
+ this.renderer.addClass(this.elementRef.nativeElement, size);
3087
+ });
3088
+ effect(() => {
3089
+ const isRounded = this.$isRounded();
3090
+ if (isRounded) {
3091
+ this.renderer.addClass(this.elementRef.nativeElement, 'rounded');
3092
+ }
3093
+ else {
3094
+ this.renderer.removeClass(this.elementRef.nativeElement, 'rounded');
3095
+ }
3096
+ });
3097
+ }
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 });
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 });
2953
3100
  }
2954
3101
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiInputDirective, decorators: [{
2955
3102
  type: Directive,
2956
3103
  args: [{
2957
3104
  selector: 'app-ui-input',
2958
3105
  }]
2959
- }], 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 }] }], $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 }] }] } });
2960
3107
 
2961
3108
  class UiInputCountryDirective extends UiInputDirective {
2962
3109
  $selectedCountry = signal(emptyCountry, ...(ngDevMode ? [{ debugName: "$selectedCountry" }] : []));
2963
3110
  $isOpen = signal(false, ...(ngDevMode ? [{ debugName: "$isOpen" }] : []));
2964
3111
  $inputElement = viewChild('input', ...(ngDevMode ? [{ debugName: "$inputElement" }] : []));
2965
- constructor() {
2966
- super();
3112
+ constructor(elementRef, renderer) {
3113
+ super(elementRef, renderer);
2967
3114
  }
2968
3115
  ngAfterViewInit() {
2969
3116
  this.autoSetCountry();
@@ -3006,7 +3153,7 @@ class UiInputCountryDirective extends UiInputDirective {
3006
3153
  this.$selectedCountry.set(country);
3007
3154
  }
3008
3155
  }
3009
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiInputCountryDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
3156
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiInputCountryDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
3010
3157
  static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.1.1", type: UiInputCountryDirective, isStandalone: true, selector: "app-ui-input-country", viewQueries: [{ propertyName: "$inputElement", first: true, predicate: ["input"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0 });
3011
3158
  }
3012
3159
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiInputCountryDirective, decorators: [{
@@ -3014,12 +3161,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
3014
3161
  args: [{
3015
3162
  selector: 'app-ui-input-country',
3016
3163
  }]
3017
- }], ctorParameters: () => [], propDecorators: { $inputElement: [{ type: i0.ViewChild, args: ['input', { isSignal: true }] }] } });
3164
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { $inputElement: [{ type: i0.ViewChild, args: ['input', { isSignal: true }] }] } });
3018
3165
 
3019
3166
  class UIInputDateDirective extends UiInputDirective {
3020
3167
  $isOpen = signal(false, ...(ngDevMode ? [{ debugName: "$isOpen" }] : []));
3021
3168
  $isRangeSelection = input(false, ...(ngDevMode ? [{ debugName: "$isRangeSelection" }] : []));
3022
3169
  $dividePattern = input('/', ...(ngDevMode ? [{ debugName: "$dividePattern" }] : []));
3170
+ $minDate = input(undefined, ...(ngDevMode ? [{ debugName: "$minDate" }] : []));
3171
+ $maxDate = input(undefined, ...(ngDevMode ? [{ debugName: "$maxDate" }] : []));
3023
3172
  $inputElement = viewChild('input', ...(ngDevMode ? [{ debugName: "$inputElement" }] : []));
3024
3173
  setDate(date) {
3025
3174
  const newDate = this.formatDate(date);
@@ -3098,22 +3247,22 @@ class UIInputDateDirective extends UiInputDirective {
3098
3247
  return formatSingle(limited);
3099
3248
  }
3100
3249
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UIInputDateDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
3101
- 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 });
3102
3251
  }
3103
3252
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UIInputDateDirective, decorators: [{
3104
3253
  type: Directive,
3105
3254
  args: [{
3106
3255
  selector: 'app-ui-input-date',
3107
3256
  }]
3108
- }], 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 }] }] } });
3109
3258
 
3110
3259
  class UIPhoneNumberDirective extends UiInputDirective {
3111
3260
  $selectedCountry = signal(emptyCountry, ...(ngDevMode ? [{ debugName: "$selectedCountry" }] : []));
3112
3261
  $isOpen = signal(false, ...(ngDevMode ? [{ debugName: "$isOpen" }] : []));
3113
3262
  $countryCode = signal('', ...(ngDevMode ? [{ debugName: "$countryCode" }] : []));
3114
3263
  $inputElement = viewChild('input', ...(ngDevMode ? [{ debugName: "$inputElement" }] : []));
3115
- constructor() {
3116
- super();
3264
+ constructor(elementRef, renderer) {
3265
+ super(elementRef, renderer);
3117
3266
  }
3118
3267
  ngAfterViewInit() {
3119
3268
  const selectedCountry = CountryService.getCountryByCode('US') ?? emptyCountry;
@@ -3150,7 +3299,7 @@ class UIPhoneNumberDirective extends UiInputDirective {
3150
3299
  inputElement.focus();
3151
3300
  }
3152
3301
  }
3153
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UIPhoneNumberDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
3302
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UIPhoneNumberDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
3154
3303
  static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.1.1", type: UIPhoneNumberDirective, isStandalone: true, selector: "app-ui-input-phone-number", viewQueries: [{ propertyName: "$inputElement", first: true, predicate: ["input"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0 });
3155
3304
  }
3156
3305
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UIPhoneNumberDirective, decorators: [{
@@ -3158,7 +3307,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
3158
3307
  args: [{
3159
3308
  selector: 'app-ui-input-phone-number',
3160
3309
  }]
3161
- }], ctorParameters: () => [], propDecorators: { $inputElement: [{ type: i0.ViewChild, args: ['input', { isSignal: true }] }] } });
3310
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { $inputElement: [{ type: i0.ViewChild, args: ['input', { isSignal: true }] }] } });
3162
3311
 
3163
3312
  class UiInputSelectDirective extends UiInputDirective {
3164
3313
  $items = input.required(...(ngDevMode ? [{ debugName: "$items" }] : []));
@@ -3264,56 +3413,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
3264
3413
  }] } });
3265
3414
 
3266
3415
  class UiInputTimeDirective extends UiInputDirective {
3267
- times = [
3268
- '00:00',
3269
- '00:30',
3270
- '01:00',
3271
- '01:30',
3272
- '02:00',
3273
- '02:30',
3274
- '03:00',
3275
- '03:30',
3276
- '04:00',
3277
- '04:30',
3278
- '05:00',
3279
- '05:30',
3280
- '06:00',
3281
- '06:30',
3282
- '07:00',
3283
- '07:30',
3284
- '08:00',
3285
- '08:30',
3286
- '09:00',
3287
- '09:30',
3288
- '10:00',
3289
- '10:30',
3290
- '11:00',
3291
- '11:30',
3292
- '12:00',
3293
- '12:30',
3294
- '13:00',
3295
- '13:30',
3296
- '14:00',
3297
- '14:30',
3298
- '15:00',
3299
- '15:30',
3300
- '16:00',
3301
- '16:30',
3302
- '17:00',
3303
- '17:30',
3304
- '18:00',
3305
- '18:30',
3306
- '19:00',
3307
- '19:30',
3308
- '20:00',
3309
- '20:30',
3310
- '21:00',
3311
- '21:30',
3312
- '22:00',
3313
- '22:30',
3314
- '23:00',
3315
- '23:30',
3316
- ];
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
+ }
3317
3427
  $inputElement = viewChild('input', ...(ngDevMode ? [{ debugName: "$inputElement" }] : []));
3318
3428
  $isOpen = signal(false, ...(ngDevMode ? [{ debugName: "$isOpen" }] : []));
3319
3429
  onInput(value) {
@@ -3327,9 +3437,13 @@ class UiInputTimeDirective extends UiInputDirective {
3327
3437
  const oldColonCount = (oldValue.match(/:/g) || []).length;
3328
3438
  const newColonCount = (newValue.match(/:/g) || []).length;
3329
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;
3330
3444
  super.onInput(newValue);
3331
3445
  inputElement.value = newValue;
3332
- if (colonAdded) {
3446
+ if (colonAdded || meridiemAdded || meridiemFormatted) {
3333
3447
  inputElement.setSelectionRange(newValue.length, newValue.length);
3334
3448
  }
3335
3449
  else {
@@ -3340,6 +3454,9 @@ class UiInputTimeDirective extends UiInputDirective {
3340
3454
  if (!value) {
3341
3455
  return '';
3342
3456
  }
3457
+ if (this.uses12HourTime()) {
3458
+ return this.mask12HourTime(value);
3459
+ }
3343
3460
  const digits = value.replace(/\D/g, '').slice(0, 4);
3344
3461
  const len = digits.length;
3345
3462
  if (len === 1) {
@@ -3371,6 +3488,72 @@ class UiInputTimeDirective extends UiInputDirective {
3371
3488
  }
3372
3489
  return '';
3373
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
+ }
3374
3557
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiInputTimeDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
3375
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 });
3376
3559
  }
@@ -3394,6 +3577,260 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
3394
3577
  }]
3395
3578
  }], propDecorators: { $isError: [{ type: i0.Input, args: [{ isSignal: true, alias: "$isError", required: false }] }], $errors: [{ type: i0.Input, args: [{ isSignal: true, alias: "$errors", required: true }] }] } });
3396
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
+
3397
3834
  /*
3398
3835
  * Public API Surface of ui-forge-library
3399
3836
  */
@@ -3402,5 +3839,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
3402
3839
  * Generated bundle index. Do not edit.
3403
3840
  */
3404
3841
 
3405
- 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 };
3406
3843
  //# sourceMappingURL=ibragim-dev-org-ui-forge-library.mjs.map