@ibragim-dev-org/ui-forge-library 1.3.5 → 1.3.7

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.
@@ -183,6 +183,179 @@ function createNavigation(from, moduleRoot, overrides) {
183
183
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
184
184
  const extractParam = (key) => `:${key}`;
185
185
 
186
+ class CalendarUtils {
187
+ static monthNames = [
188
+ 'January',
189
+ 'February',
190
+ 'March',
191
+ 'April',
192
+ 'May',
193
+ 'June',
194
+ 'July',
195
+ 'August',
196
+ 'September',
197
+ 'October',
198
+ 'November',
199
+ 'December',
200
+ ];
201
+ static isSameDay(a, b) {
202
+ if (!a || !b)
203
+ return false;
204
+ return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
205
+ }
206
+ static normalizeDate(date) {
207
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
208
+ }
209
+ static isDisabledDate(date, minDate, maxDate) {
210
+ const currentTimestamp = CalendarUtils.normalizeDate(date).getTime();
211
+ if (minDate && currentTimestamp < CalendarUtils.normalizeDate(minDate).getTime()) {
212
+ return true;
213
+ }
214
+ if (maxDate && currentTimestamp > CalendarUtils.normalizeDate(maxDate).getTime()) {
215
+ return true;
216
+ }
217
+ return false;
218
+ }
219
+ static isBetween(date, start, end) {
220
+ if (!start || !end)
221
+ return false;
222
+ const d = new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();
223
+ const s = new Date(start.getFullYear(), start.getMonth(), start.getDate()).getTime();
224
+ const e = new Date(end.getFullYear(), end.getMonth(), end.getDate()).getTime();
225
+ return d > s && d < e;
226
+ }
227
+ static createSafeDate(year, month, day) {
228
+ const lastDay = new Date(year, month + 1, 0).getDate();
229
+ const safeDay = Math.min(day, lastDay);
230
+ return new Date(year, month, safeDay);
231
+ }
232
+ static mapCalendarDaysData(calendarDays, items) {
233
+ const itemsByDate = new Map();
234
+ for (const item of items) {
235
+ itemsByDate.set(CalendarUtils.getTime(item.date), item);
236
+ }
237
+ return calendarDays.map((day) => {
238
+ const matchedItem = itemsByDate.get(CalendarUtils.getTime(day.date));
239
+ return {
240
+ ...day,
241
+ data: matchedItem,
242
+ };
243
+ });
244
+ }
245
+ static getTime(date) {
246
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();
247
+ }
248
+ static getDayState(date, options) {
249
+ return CalendarUtils.getPeriodState(date, options);
250
+ }
251
+ static getPeriodState(date, options) {
252
+ const { dateStart, dateEnd, hoverDate, isRangeSelection, minDate, maxDate } = options;
253
+ const isDisabled = CalendarUtils.isDisabledDate(date, minDate, maxDate);
254
+ if (isDisabled) {
255
+ return { isDisabled: true, isSelected: false, isStart: false, isEnd: false, inRange: false, inHoverRange: false };
256
+ }
257
+ if (!isRangeSelection) {
258
+ return {
259
+ isDisabled: false,
260
+ isSelected: CalendarUtils.isSameDay(dateStart, date),
261
+ isStart: false,
262
+ isEnd: false,
263
+ inRange: false,
264
+ inHoverRange: false,
265
+ };
266
+ }
267
+ const isStart = CalendarUtils.isSameDay(dateStart, date);
268
+ const isEnd = CalendarUtils.isSameDay(dateEnd, date);
269
+ const inRange = CalendarUtils.isBetween(date, dateStart, dateEnd);
270
+ let inHoverRange = false;
271
+ if (dateStart && !dateEnd && hoverDate) {
272
+ const d = CalendarUtils.getTime(date);
273
+ const s = CalendarUtils.getTime(dateStart);
274
+ const h = CalendarUtils.getTime(hoverDate);
275
+ if (h > s) {
276
+ inHoverRange = d > s && d <= h;
277
+ }
278
+ }
279
+ const isSelected = isStart || isEnd || (!dateEnd && isStart);
280
+ return { isDisabled: false, isSelected, isStart, isEnd, inRange, inHoverRange };
281
+ }
282
+ static generateWeek(referenceDate, options) {
283
+ const { isUsaFormat } = options;
284
+ const nativeDay = referenceDate.getDay(); // 0=Sun … 6=Sat
285
+ const startOffset = isUsaFormat ? nativeDay : nativeDay === 0 ? 6 : nativeDay - 1;
286
+ const weekStart = new Date(referenceDate.getFullYear(), referenceDate.getMonth(), referenceDate.getDate() - startOffset);
287
+ const days = [];
288
+ for (let i = 0; i < 7; i++) {
289
+ const date = new Date(weekStart.getFullYear(), weekStart.getMonth(), weekStart.getDate() + i);
290
+ days.push({
291
+ date,
292
+ ...CalendarUtils.getDayState(date, options),
293
+ inCurrentMonth: date.getMonth() === referenceDate.getMonth(),
294
+ });
295
+ }
296
+ return days;
297
+ }
298
+ static generateDays(month, year, options) {
299
+ const { isUsaFormat } = options;
300
+ const firstDayOfMonth = new Date(year, month, 1);
301
+ const nativeStartDayOfWeek = firstDayOfMonth.getDay();
302
+ const startDayOfWeek = isUsaFormat
303
+ ? nativeStartDayOfWeek
304
+ : nativeStartDayOfWeek === 0
305
+ ? 6
306
+ : nativeStartDayOfWeek - 1;
307
+ const daysInMonth = new Date(year, month + 1, 0).getDate();
308
+ const daysInPrevMonth = new Date(year, month, 0).getDate();
309
+ const days = [];
310
+ for (let i = startDayOfWeek - 1; i >= 0; i--) {
311
+ const day = daysInPrevMonth - i;
312
+ const newDate = new Date(year, month - 1, day);
313
+ days.push({ date: newDate, ...CalendarUtils.getDayState(newDate, options), inCurrentMonth: false });
314
+ }
315
+ for (let d = 1; d <= daysInMonth; d++) {
316
+ const newDate = new Date(year, month, d);
317
+ days.push({ date: newDate, ...CalendarUtils.getDayState(newDate, options), inCurrentMonth: true });
318
+ }
319
+ const totalCells = 42;
320
+ let nextDay = 1;
321
+ while (days.length < totalCells) {
322
+ const newDate = new Date(year, month + 1, nextDay++);
323
+ days.push({ date: newDate, ...CalendarUtils.getDayState(newDate, options), inCurrentMonth: false });
324
+ }
325
+ return days;
326
+ }
327
+ static generateMonths(year, options) {
328
+ const current = options.dateStart ?? new Date();
329
+ const anchorDay = current.getDate();
330
+ return CalendarUtils.monthNames.map((name, index) => {
331
+ const newDate = CalendarUtils.createSafeDate(year, index, anchorDay);
332
+ return {
333
+ index,
334
+ name,
335
+ short: name.substring(0, 3),
336
+ date: newDate,
337
+ ...CalendarUtils.getPeriodState(newDate, options),
338
+ };
339
+ });
340
+ }
341
+ static generateYears(startYear, options) {
342
+ const current = options.dateStart ?? new Date();
343
+ const month = current.getMonth();
344
+ const day = current.getDate();
345
+ const years = [];
346
+ for (let i = 0; i < 20; i++) {
347
+ const year = startYear + i;
348
+ const newDate = CalendarUtils.createSafeDate(year, month, day);
349
+ years.push({
350
+ year,
351
+ date: newDate,
352
+ ...CalendarUtils.getPeriodState(newDate, options),
353
+ });
354
+ }
355
+ return years;
356
+ }
357
+ }
358
+
186
359
  class AutoFocusDirective {
187
360
  el;
188
361
  $shouldFocus = input.required({ debugName: 'appAutoFocus' });
@@ -613,78 +786,74 @@ function getAspectRatioFit(maxWidth, maxHeight, srcWidth, srcHeight) {
613
786
  return { width: maxWidth, height: maxHeight };
614
787
  }
615
788
 
616
- const stringToHslColor = (value) => {
617
- const MIN_CONTRAST_WITH_WHITE_TEXT = 3;
618
- const hslToRgb = (h, s, l) => {
619
- const sn = s / 100;
620
- const ln = l / 100;
621
- const c = (1 - Math.abs(2 * ln - 1)) * sn;
622
- const x = c * (1 - Math.abs(((h / 60) % 2) - 1));
623
- const m = ln - c / 2;
624
- let r1 = 0, g1 = 0, b1 = 0;
625
- if (h < 60) {
626
- r1 = c;
627
- g1 = x;
628
- }
629
- else if (h < 120) {
630
- r1 = x;
631
- g1 = c;
632
- }
633
- else if (h < 180) {
634
- g1 = c;
635
- b1 = x;
636
- }
637
- else if (h < 240) {
638
- g1 = x;
639
- b1 = c;
640
- }
641
- else if (h < 300) {
642
- r1 = x;
643
- b1 = c;
644
- }
645
- else {
646
- r1 = c;
647
- b1 = x;
648
- }
649
- return [Math.round((r1 + m) * 255), Math.round((g1 + m) * 255), Math.round((b1 + m) * 255)];
650
- };
651
- const linearize = (channel) => {
652
- const normalized = channel / 255;
653
- return normalized <= 0.03928 ? normalized / 12.92 : ((normalized + 0.055) / 1.055) ** 2.4;
654
- };
655
- const contrastWithWhiteText = (h, s, l) => {
656
- const [r, g, b] = hslToRgb(h, s, l);
657
- const luminance = 0.2126 * linearize(r) + 0.7152 * linearize(g) + 0.0722 * linearize(b);
658
- return (1.05 + 0.05) / (luminance + 0.05);
659
- };
660
- // Hash the text → deterministic number
789
+ const COLOR_FAMILIES = [
790
+ // Same style as requested references: vivid top color + deeper companion.
791
+ { solid: '#FF7A7A', gradientStart: '#FF7A7A', gradientEnd: '#D74A59' }, // Red
792
+ { solid: '#FFB357', gradientStart: '#FFB357', gradientEnd: '#F47D3D' }, // Orange
793
+ { solid: '#E6D24A', gradientStart: '#D4C32A', gradientEnd: '#FFAA55' }, // Yellow (exact)
794
+ { solid: '#A8DF4A', gradientStart: '#A8DF4A', gradientEnd: '#72BD45' }, // Lime
795
+ { solid: '#57D88B', gradientStart: '#57D88B', gradientEnd: '#1FA96E' }, // Green
796
+ { solid: '#55DAF5', gradientStart: '#55DAF5', gradientEnd: '#1EA9C8' }, // Light Blue (exact)
797
+ { solid: '#4F9BFF', gradientStart: '#4F9BFF', gradientEnd: '#1D6DD6' }, // Blue (exact)
798
+ { solid: '#7D84FF', gradientStart: '#7D84FF', gradientEnd: '#5A60D9' }, // Indigo
799
+ { solid: '#B979FF', gradientStart: '#B979FF', gradientEnd: '#8D57D6' }, // Violet
800
+ { solid: '#FF86E4', gradientStart: '#FF64DD', gradientEnd: '#F599C4' }, // Pink (exact)
801
+ ];
802
+ const hashValue = (value) => {
661
803
  let hash = 0;
662
804
  for (let i = 0; i < value.length; i++) {
663
805
  hash = value.charCodeAt(i) + ((hash << 5) - hash);
664
- hash &= hash;
665
- }
666
- const absHash = Math.abs(hash);
667
- // Rainbow hue families: Red, Orange, Yellow, Green, Blue, Indigo, Violet
668
- const HUE_RANGES = [
669
- [0, 20], // Red
670
- [25, 40], // Orange
671
- [50, 65], // Yellow
672
- [110, 140], // Green
673
- [200, 230], // Blue
674
- [240, 260], // Indigo
675
- [270, 300], // Violet
806
+ hash |= 0;
807
+ }
808
+ return Math.abs(hash);
809
+ };
810
+ const pickColorFamily = (value) => {
811
+ const absHash = hashValue(value);
812
+ return COLOR_FAMILIES[absHash % COLOR_FAMILIES.length];
813
+ };
814
+ const hexToRgb = (hex) => {
815
+ const value = hex.replace('#', '');
816
+ const normalized = value.length === 3
817
+ ? value
818
+ .split('')
819
+ .map((c) => c + c)
820
+ .join('')
821
+ : value;
822
+ return [
823
+ Number.parseInt(normalized.slice(0, 2), 16),
824
+ Number.parseInt(normalized.slice(2, 4), 16),
825
+ Number.parseInt(normalized.slice(4, 6), 16),
676
826
  ];
677
- const [minHue, maxHue] = HUE_RANGES[absHash % HUE_RANGES.length];
678
- const hueSpan = maxHue - minHue;
679
- const hue = minHue + ((absHash >> 3) % (hueSpan + 1));
680
- // Vivid saturation/lightness
681
- const saturation = 80; // fixed vivid
682
- let lightness = 50; // balanced
683
- // Adjust lightness until white text is readable
684
- while (lightness > 30 && contrastWithWhiteText(hue, saturation, lightness) < MIN_CONTRAST_WITH_WHITE_TEXT) {
685
- lightness -= 2;
686
- }
687
- return `hsl(${hue}, ${saturation}%, ${lightness}%)`;
827
+ };
828
+ const rgbToHex = (r, g, b) => {
829
+ const channelToHex = (channel) => Math.max(0, Math.min(255, Math.round(channel)))
830
+ .toString(16)
831
+ .padStart(2, '0');
832
+ return `#${channelToHex(r)}${channelToHex(g)}${channelToHex(b)}`;
833
+ };
834
+ const mixHex = (first, second, amount) => {
835
+ const ratio = Math.max(0, Math.min(1, amount));
836
+ const [r1, g1, b1] = hexToRgb(first);
837
+ const [r2, g2, b2] = hexToRgb(second);
838
+ return rgbToHex(r1 + (r2 - r1) * ratio, g1 + (g2 - g1) * ratio, b1 + (b2 - b1) * ratio);
839
+ };
840
+ const hexToRgba = (hex, alpha) => {
841
+ const [r, g, b] = hexToRgb(hex);
842
+ const opacity = Math.max(0, Math.min(1, alpha));
843
+ return `rgba(${r}, ${g}, ${b}, ${opacity})`;
844
+ };
845
+ const stringToHslColor = (value) => {
846
+ const family = pickColorFamily(value);
847
+ return family.solid;
848
+ };
849
+ const stringToColorGradient = (value) => {
850
+ const family = pickColorFamily(value);
851
+ const start = family.gradientStart;
852
+ const end = family.gradientEnd;
853
+ const mid = mixHex(start, end, 0.45);
854
+ const glow = mixHex(start, '#FFFFFF', 0.18);
855
+ const shadow = mixHex(end, '#000000', 0.12);
856
+ return `linear-gradient(135deg, ${start} 0%, ${mid} 54%, ${end} 100%), radial-gradient(circle at 78% 82%, ${hexToRgba(shadow, 0.4)} 0%, transparent 58%), radial-gradient(circle at 26% 8%, ${hexToRgba(glow, 0.35)} 0%, transparent 52%)`;
688
857
  };
689
858
 
690
859
  class AppIconsLibrary {
@@ -1171,7 +1340,7 @@ class UiAvatarDirective {
1171
1340
  .forEach((v) => {
1172
1341
  acronym = acronym + v[0];
1173
1342
  });
1174
- this.renderer.setStyle(this.elementRef.nativeElement, 'background-color', stringToHslColor(acronym[0]));
1343
+ this.renderer.setStyle(this.elementRef.nativeElement, 'background', stringToColorGradient(acronym[0]));
1175
1344
  this.$text.set(acronym);
1176
1345
  });
1177
1346
  effect(() => {
@@ -1218,120 +1387,16 @@ class UiDailyCalendarDirective {
1218
1387
  $onRangeSelect = output();
1219
1388
  $onSelect = output();
1220
1389
  $calendarDays = computed(() => {
1221
- const year = this.$currentYear();
1222
- const month = this.$currentMonth();
1223
- return this.generateCalendar(month, year);
1390
+ return CalendarUtils.generateDays(this.$currentMonth(), this.$currentYear(), {
1391
+ isUsaFormat: this.isUsaDateFormat(),
1392
+ dateStart: this.$dateStart(),
1393
+ dateEnd: this.$dateEnd(),
1394
+ hoverDate: this.$hoverDate(),
1395
+ isRangeSelection: this.$isRangeSelection(),
1396
+ minDate: this.$minDate(),
1397
+ maxDate: this.$maxDate(),
1398
+ });
1224
1399
  }, ...(ngDevMode ? [{ debugName: "$calendarDays" }] : []));
1225
- generateCalendar(month, year) {
1226
- const firstDayOfMonth = new Date(year, month, 1);
1227
- const nativeStartDayOfWeek = firstDayOfMonth.getDay();
1228
- const startDayOfWeek = this.isUsaDateFormat()
1229
- ? nativeStartDayOfWeek
1230
- : nativeStartDayOfWeek === 0
1231
- ? 6
1232
- : nativeStartDayOfWeek - 1;
1233
- const daysInMonth = new Date(year, month + 1, 0).getDate();
1234
- const daysInPrevMonth = new Date(year, month, 0).getDate();
1235
- const days = [];
1236
- for (let i = startDayOfWeek - 1; i >= 0; i--) {
1237
- const day = daysInPrevMonth - i;
1238
- const newDate = new Date(year, month - 1, day);
1239
- days.push({
1240
- date: newDate,
1241
- ...this.getDayState(newDate),
1242
- inCurrentMonth: false,
1243
- });
1244
- }
1245
- for (let d = 1; d <= daysInMonth; d++) {
1246
- const newDate = new Date(year, month, d);
1247
- days.push({
1248
- date: newDate,
1249
- ...this.getDayState(newDate),
1250
- inCurrentMonth: true,
1251
- });
1252
- }
1253
- const totalCells = 42;
1254
- let nextDay = 1;
1255
- while (days.length < totalCells) {
1256
- const newDate = new Date(year, month + 1, nextDay++);
1257
- days.push({
1258
- date: newDate,
1259
- ...this.getDayState(newDate),
1260
- inCurrentMonth: false,
1261
- });
1262
- }
1263
- return days;
1264
- }
1265
- isSameDay(a, b) {
1266
- if (!a || !b)
1267
- return false;
1268
- return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
1269
- }
1270
- normalizeDate(date) {
1271
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
1272
- }
1273
- isDisabledDate(date) {
1274
- const currentTimestamp = this.normalizeDate(date).getTime();
1275
- const minDate = this.$minDate();
1276
- if (minDate && currentTimestamp < this.normalizeDate(minDate).getTime()) {
1277
- return true;
1278
- }
1279
- const maxDate = this.$maxDate();
1280
- if (maxDate && currentTimestamp > this.normalizeDate(maxDate).getTime()) {
1281
- return true;
1282
- }
1283
- return false;
1284
- }
1285
- isBetween(date, start, end) {
1286
- if (!start || !end)
1287
- return false;
1288
- const d = new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();
1289
- const s = new Date(start.getFullYear(), start.getMonth(), start.getDate()).getTime();
1290
- const e = new Date(end.getFullYear(), end.getMonth(), end.getDate()).getTime();
1291
- return d > s && d < e;
1292
- }
1293
- getDayState(date) {
1294
- const isDisabled = this.isDisabledDate(date);
1295
- if (isDisabled) {
1296
- return {
1297
- isDisabled: true,
1298
- isSelected: false,
1299
- isStart: false,
1300
- isEnd: false,
1301
- inRange: false,
1302
- inHoverRange: false,
1303
- };
1304
- }
1305
- const hover = this.$hoverDate();
1306
- const start = this.$dateStart();
1307
- const end = this.$dateEnd();
1308
- if (!this.$isRangeSelection()) {
1309
- return {
1310
- isDisabled: false,
1311
- isSelected: this.isSameDay(start, date),
1312
- isStart: false,
1313
- isEnd: false,
1314
- inRange: false,
1315
- inHoverRange: false,
1316
- };
1317
- }
1318
- // Range mode
1319
- const isStart = this.isSameDay(start, date);
1320
- const isEnd = this.isSameDay(end, date);
1321
- const inRange = this.isBetween(date, start, end);
1322
- let inHoverRange = false;
1323
- if (start && !end && hover) {
1324
- const d = date.getTime();
1325
- const s = start.getTime();
1326
- const h = hover.getTime();
1327
- if (h > s) {
1328
- inHoverRange = d > s && d <= h;
1329
- }
1330
- }
1331
- const isSingleSelected = this.isSameDay(start, date) || this.isSameDay(end, date);
1332
- const isSelected = isStart || isEnd || (!end && isStart) || isSingleSelected;
1333
- return { isDisabled: false, isSelected, isStart, isEnd, inRange, inHoverRange };
1334
- }
1335
1400
  onHover(date, inHoverRange) {
1336
1401
  if (inHoverRange) {
1337
1402
  return;
@@ -1342,7 +1407,7 @@ class UiDailyCalendarDirective {
1342
1407
  this.$hoverDate.set(null);
1343
1408
  return;
1344
1409
  }
1345
- if (this.isDisabledDate(date)) {
1410
+ if (CalendarUtils.isDisabledDate(date, this.$minDate(), this.$maxDate())) {
1346
1411
  this.$hoverDate.set(null);
1347
1412
  return;
1348
1413
  }
@@ -1362,7 +1427,7 @@ class UiDailyCalendarDirective {
1362
1427
  return DateUtils.isUsaDateFormat(this.$dateFormat());
1363
1428
  }
1364
1429
  select(date) {
1365
- if (this.isDisabledDate(date)) {
1430
+ if (CalendarUtils.isDisabledDate(date, this.$minDate(), this.$maxDate())) {
1366
1431
  return;
1367
1432
  }
1368
1433
  this.$hoverDate.set(null);
@@ -1404,104 +1469,128 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
1404
1469
 
1405
1470
  class UiMonthlyCalendarDirective {
1406
1471
  $date = model(new Date(), ...(ngDevMode ? [{ debugName: "$date" }] : []));
1472
+ $dateEnd = input(null, ...(ngDevMode ? [{ debugName: "$dateEnd" }] : []));
1473
+ $isRangeSelection = input(false, ...(ngDevMode ? [{ debugName: "$isRangeSelection" }] : []));
1474
+ $minDate = input(undefined, ...(ngDevMode ? [{ debugName: "$minDate" }] : []));
1475
+ $maxDate = input(undefined, ...(ngDevMode ? [{ debugName: "$maxDate" }] : []));
1476
+ $hoverDate = signal(null, ...(ngDevMode ? [{ debugName: "$hoverDate" }] : []));
1407
1477
  $onSelect = output();
1408
1478
  $currentYear = model.required(...(ngDevMode ? [{ debugName: "$currentYear" }] : []));
1409
1479
  $months = computed(() => {
1410
- const year = this.$currentYear();
1411
- return this.generateMonths(year);
1412
- }, ...(ngDevMode ? [{ debugName: "$months" }] : []));
1413
- generateMonths(year) {
1414
- const current = this.$date() ?? new Date();
1415
- const day = current.getDate();
1416
- const monthNames = [
1417
- 'January',
1418
- 'February',
1419
- 'March',
1420
- 'April',
1421
- 'May',
1422
- 'June',
1423
- 'July',
1424
- 'August',
1425
- 'September',
1426
- 'October',
1427
- 'November',
1428
- 'December',
1429
- ];
1430
- const months = monthNames.map((name, index) => {
1431
- const lastDay = new Date(year, index + 1, 0).getDate();
1432
- const safeDay = Math.min(day, lastDay);
1433
- const newDate = new Date(year, index, safeDay);
1434
- return {
1435
- index,
1436
- name,
1437
- short: name.substring(0, 3),
1438
- date: newDate,
1439
- isSelected: this.isSelected(newDate),
1440
- };
1480
+ return CalendarUtils.generateMonths(this.$currentYear(), {
1481
+ dateStart: this.$date(),
1482
+ dateEnd: this.$dateEnd(),
1483
+ hoverDate: this.$hoverDate(),
1484
+ isRangeSelection: this.$isRangeSelection(),
1485
+ minDate: this.$minDate(),
1486
+ maxDate: this.$maxDate(),
1441
1487
  });
1442
- return months;
1488
+ }, ...(ngDevMode ? [{ debugName: "$months" }] : []));
1489
+ onHover(date, inHoverRange) {
1490
+ if (inHoverRange) {
1491
+ return;
1492
+ }
1493
+ const rangeStart = this.$date();
1494
+ const rangeEnd = this.$dateEnd();
1495
+ if (!date) {
1496
+ this.$hoverDate.set(null);
1497
+ return;
1498
+ }
1499
+ if (CalendarUtils.isDisabledDate(date, this.$minDate(), this.$maxDate())) {
1500
+ this.$hoverDate.set(null);
1501
+ return;
1502
+ }
1503
+ if (!this.$isRangeSelection()) {
1504
+ return;
1505
+ }
1506
+ if (!rangeStart || rangeEnd) {
1507
+ return;
1508
+ }
1509
+ if (date.getTime() < rangeStart.getTime()) {
1510
+ this.$hoverDate.set(null);
1511
+ return;
1512
+ }
1513
+ this.$hoverDate.set(date);
1443
1514
  }
1444
1515
  select(date) {
1516
+ if (CalendarUtils.isDisabledDate(date, this.$minDate(), this.$maxDate())) {
1517
+ return;
1518
+ }
1519
+ this.$hoverDate.set(null);
1445
1520
  this.$onSelect.emit(date);
1446
1521
  }
1447
- isSelected(date) {
1448
- const selected = this.$date() ?? new Date();
1449
- return (date.getFullYear() === selected.getFullYear() &&
1450
- date.getMonth() === selected.getMonth() &&
1451
- date.getDate() === selected.getDate());
1452
- }
1453
1522
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiMonthlyCalendarDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1454
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.1", type: UiMonthlyCalendarDirective, isStandalone: true, selector: "app-ui-monthly-calendar", inputs: { $date: { classPropertyName: "$date", publicName: "$date", isSignal: true, isRequired: false, transformFunction: null }, $currentYear: { classPropertyName: "$currentYear", publicName: "$currentYear", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { $date: "$dateChange", $onSelect: "$onSelect", $currentYear: "$currentYearChange" }, ngImport: i0 });
1523
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.1", type: UiMonthlyCalendarDirective, isStandalone: true, selector: "app-ui-monthly-calendar", inputs: { $date: { classPropertyName: "$date", publicName: "$date", isSignal: true, isRequired: false, transformFunction: null }, $dateEnd: { classPropertyName: "$dateEnd", publicName: "$dateEnd", isSignal: true, isRequired: false, transformFunction: null }, $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 }, $currentYear: { classPropertyName: "$currentYear", publicName: "$currentYear", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { $date: "$dateChange", $onSelect: "$onSelect", $currentYear: "$currentYearChange" }, ngImport: i0 });
1455
1524
  }
1456
1525
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiMonthlyCalendarDirective, decorators: [{
1457
1526
  type: Directive,
1458
1527
  args: [{
1459
1528
  selector: 'app-ui-monthly-calendar',
1460
1529
  }]
1461
- }], 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"] }] } });
1530
+ }], propDecorators: { $date: [{ type: i0.Input, args: [{ isSignal: true, alias: "$date", required: false }] }, { type: i0.Output, args: ["$dateChange"] }], $dateEnd: [{ type: i0.Input, args: [{ isSignal: true, alias: "$dateEnd", required: false }] }], $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 }] }], $onSelect: [{ type: i0.Output, args: ["$onSelect"] }], $currentYear: [{ type: i0.Input, args: [{ isSignal: true, alias: "$currentYear", required: true }] }, { type: i0.Output, args: ["$currentYearChange"] }] } });
1462
1531
 
1463
1532
  class UiYearlyCalendarDirective {
1464
1533
  $date = model(new Date(), ...(ngDevMode ? [{ debugName: "$date" }] : []));
1534
+ $dateEnd = input(null, ...(ngDevMode ? [{ debugName: "$dateEnd" }] : []));
1535
+ $isRangeSelection = input(false, ...(ngDevMode ? [{ debugName: "$isRangeSelection" }] : []));
1536
+ $minDate = input(undefined, ...(ngDevMode ? [{ debugName: "$minDate" }] : []));
1537
+ $maxDate = input(undefined, ...(ngDevMode ? [{ debugName: "$maxDate" }] : []));
1538
+ $hoverDate = signal(null, ...(ngDevMode ? [{ debugName: "$hoverDate" }] : []));
1465
1539
  $onSelect = output();
1466
1540
  $currentYear = model.required(...(ngDevMode ? [{ debugName: "$currentYear" }] : []));
1467
1541
  $years = computed(() => {
1468
- const year = this.$currentYear();
1469
- return this.generateYears(year);
1542
+ return CalendarUtils.generateYears(this.$currentYear(), {
1543
+ dateStart: this.$date(),
1544
+ dateEnd: this.$dateEnd(),
1545
+ hoverDate: this.$hoverDate(),
1546
+ isRangeSelection: this.$isRangeSelection(),
1547
+ minDate: this.$minDate(),
1548
+ maxDate: this.$maxDate(),
1549
+ });
1470
1550
  }, ...(ngDevMode ? [{ debugName: "$years" }] : []));
1471
- generateYears(startYear) {
1472
- const current = this.$date() ?? new Date();
1473
- const month = current.getMonth();
1474
- const day = current.getDate();
1475
- const selectedYear = current.getFullYear();
1476
- const years = [];
1477
- for (let i = 0; i < 20; i++) {
1478
- const year = startYear + i;
1479
- years.push({
1480
- year,
1481
- date: this.createSafeDate(year, month, day),
1482
- isSelected: year === selectedYear,
1483
- });
1551
+ onHover(date, inHoverRange) {
1552
+ if (inHoverRange) {
1553
+ return;
1484
1554
  }
1485
- return years;
1486
- }
1487
- createSafeDate(year, month, day) {
1488
- const lastDay = new Date(year, month + 1, 0).getDate();
1489
- const safeDay = Math.min(day, lastDay);
1490
- return new Date(year, month, safeDay);
1555
+ const rangeStart = this.$date();
1556
+ const rangeEnd = this.$dateEnd();
1557
+ if (!date) {
1558
+ this.$hoverDate.set(null);
1559
+ return;
1560
+ }
1561
+ if (CalendarUtils.isDisabledDate(date, this.$minDate(), this.$maxDate())) {
1562
+ this.$hoverDate.set(null);
1563
+ return;
1564
+ }
1565
+ if (!this.$isRangeSelection()) {
1566
+ return;
1567
+ }
1568
+ if (!rangeStart || rangeEnd) {
1569
+ return;
1570
+ }
1571
+ if (date.getTime() < rangeStart.getTime()) {
1572
+ this.$hoverDate.set(null);
1573
+ return;
1574
+ }
1575
+ this.$hoverDate.set(date);
1491
1576
  }
1492
1577
  select(date) {
1578
+ if (CalendarUtils.isDisabledDate(date, this.$minDate(), this.$maxDate())) {
1579
+ return;
1580
+ }
1581
+ this.$hoverDate.set(null);
1493
1582
  this.$date.set(date);
1494
1583
  this.$onSelect.emit(date);
1495
1584
  }
1496
1585
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiYearlyCalendarDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1497
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.1", type: UiYearlyCalendarDirective, isStandalone: true, selector: "app-ui-yearly-calendar", inputs: { $date: { classPropertyName: "$date", publicName: "$date", isSignal: true, isRequired: false, transformFunction: null }, $currentYear: { classPropertyName: "$currentYear", publicName: "$currentYear", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { $date: "$dateChange", $onSelect: "$onSelect", $currentYear: "$currentYearChange" }, ngImport: i0 });
1586
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.1", type: UiYearlyCalendarDirective, isStandalone: true, selector: "app-ui-yearly-calendar", inputs: { $date: { classPropertyName: "$date", publicName: "$date", isSignal: true, isRequired: false, transformFunction: null }, $dateEnd: { classPropertyName: "$dateEnd", publicName: "$dateEnd", isSignal: true, isRequired: false, transformFunction: null }, $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 }, $currentYear: { classPropertyName: "$currentYear", publicName: "$currentYear", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { $date: "$dateChange", $onSelect: "$onSelect", $currentYear: "$currentYearChange" }, ngImport: i0 });
1498
1587
  }
1499
1588
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiYearlyCalendarDirective, decorators: [{
1500
1589
  type: Directive,
1501
1590
  args: [{
1502
1591
  selector: 'app-ui-yearly-calendar',
1503
1592
  }]
1504
- }], 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"] }] } });
1593
+ }], propDecorators: { $date: [{ type: i0.Input, args: [{ isSignal: true, alias: "$date", required: false }] }, { type: i0.Output, args: ["$dateChange"] }], $dateEnd: [{ type: i0.Input, args: [{ isSignal: true, alias: "$dateEnd", required: false }] }], $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 }] }], $onSelect: [{ type: i0.Output, args: ["$onSelect"] }], $currentYear: [{ type: i0.Input, args: [{ isSignal: true, alias: "$currentYear", required: true }] }, { type: i0.Output, args: ["$currentYearChange"] }] } });
1505
1594
 
1506
1595
  class UiCalendarDropdownDirective {
1507
1596
  action = () => { };
@@ -4130,5 +4219,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
4130
4219
  * Generated bundle index. Do not edit.
4131
4220
  */
4132
4221
 
4133
- export { Alert, AlertType, AppIconsLibrary, AutoFocusDirective, CenterEllipsisPipe, ContainerSizeDirective, CountryService, DateUtils, EMAIL, HAS_CAPITAL_CASE, HAS_NUMBER, HAS_SMALL_CASE, HAS_SPECIAL_CHARTERS, HoverTipDirective, IconComponent, LazyImgDirective, MIN_LENGTH, MaskGradientDirective, RouterBehavior, 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, createNavigation, createUrl, createUrlTree, emptyCountry, extractParam, getAspectRatioFit, navigateByUrl, stringToHslColor };
4222
+ export { Alert, AlertType, AppIconsLibrary, AutoFocusDirective, CalendarUtils, CenterEllipsisPipe, ContainerSizeDirective, CountryService, DateUtils, EMAIL, HAS_CAPITAL_CASE, HAS_NUMBER, HAS_SMALL_CASE, HAS_SPECIAL_CHARTERS, HoverTipDirective, IconComponent, LazyImgDirective, MIN_LENGTH, MaskGradientDirective, RouterBehavior, 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, createNavigation, createUrl, createUrlTree, emptyCountry, extractParam, getAspectRatioFit, navigateByUrl, stringToColorGradient, stringToHslColor };
4134
4223
  //# sourceMappingURL=ibragim-dev-org-ui-forge-library.mjs.map