@ibragim-dev-org/ui-forge-library 1.3.4 → 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -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' });
|
|
@@ -1218,120 +1391,16 @@ class UiDailyCalendarDirective {
|
|
|
1218
1391
|
$onRangeSelect = output();
|
|
1219
1392
|
$onSelect = output();
|
|
1220
1393
|
$calendarDays = computed(() => {
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1394
|
+
return CalendarUtils.generateDays(this.$currentMonth(), this.$currentYear(), {
|
|
1395
|
+
isUsaFormat: this.isUsaDateFormat(),
|
|
1396
|
+
dateStart: this.$dateStart(),
|
|
1397
|
+
dateEnd: this.$dateEnd(),
|
|
1398
|
+
hoverDate: this.$hoverDate(),
|
|
1399
|
+
isRangeSelection: this.$isRangeSelection(),
|
|
1400
|
+
minDate: this.$minDate(),
|
|
1401
|
+
maxDate: this.$maxDate(),
|
|
1402
|
+
});
|
|
1224
1403
|
}, ...(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
1404
|
onHover(date, inHoverRange) {
|
|
1336
1405
|
if (inHoverRange) {
|
|
1337
1406
|
return;
|
|
@@ -1342,7 +1411,7 @@ class UiDailyCalendarDirective {
|
|
|
1342
1411
|
this.$hoverDate.set(null);
|
|
1343
1412
|
return;
|
|
1344
1413
|
}
|
|
1345
|
-
if (
|
|
1414
|
+
if (CalendarUtils.isDisabledDate(date, this.$minDate(), this.$maxDate())) {
|
|
1346
1415
|
this.$hoverDate.set(null);
|
|
1347
1416
|
return;
|
|
1348
1417
|
}
|
|
@@ -1362,7 +1431,7 @@ class UiDailyCalendarDirective {
|
|
|
1362
1431
|
return DateUtils.isUsaDateFormat(this.$dateFormat());
|
|
1363
1432
|
}
|
|
1364
1433
|
select(date) {
|
|
1365
|
-
if (
|
|
1434
|
+
if (CalendarUtils.isDisabledDate(date, this.$minDate(), this.$maxDate())) {
|
|
1366
1435
|
return;
|
|
1367
1436
|
}
|
|
1368
1437
|
this.$hoverDate.set(null);
|
|
@@ -1404,104 +1473,128 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
1404
1473
|
|
|
1405
1474
|
class UiMonthlyCalendarDirective {
|
|
1406
1475
|
$date = model(new Date(), ...(ngDevMode ? [{ debugName: "$date" }] : []));
|
|
1476
|
+
$dateEnd = input(null, ...(ngDevMode ? [{ debugName: "$dateEnd" }] : []));
|
|
1477
|
+
$isRangeSelection = input(false, ...(ngDevMode ? [{ debugName: "$isRangeSelection" }] : []));
|
|
1478
|
+
$minDate = input(undefined, ...(ngDevMode ? [{ debugName: "$minDate" }] : []));
|
|
1479
|
+
$maxDate = input(undefined, ...(ngDevMode ? [{ debugName: "$maxDate" }] : []));
|
|
1480
|
+
$hoverDate = signal(null, ...(ngDevMode ? [{ debugName: "$hoverDate" }] : []));
|
|
1407
1481
|
$onSelect = output();
|
|
1408
1482
|
$currentYear = model.required(...(ngDevMode ? [{ debugName: "$currentYear" }] : []));
|
|
1409
1483
|
$months = computed(() => {
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
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
|
-
};
|
|
1484
|
+
return CalendarUtils.generateMonths(this.$currentYear(), {
|
|
1485
|
+
dateStart: this.$date(),
|
|
1486
|
+
dateEnd: this.$dateEnd(),
|
|
1487
|
+
hoverDate: this.$hoverDate(),
|
|
1488
|
+
isRangeSelection: this.$isRangeSelection(),
|
|
1489
|
+
minDate: this.$minDate(),
|
|
1490
|
+
maxDate: this.$maxDate(),
|
|
1441
1491
|
});
|
|
1442
|
-
|
|
1492
|
+
}, ...(ngDevMode ? [{ debugName: "$months" }] : []));
|
|
1493
|
+
onHover(date, inHoverRange) {
|
|
1494
|
+
if (inHoverRange) {
|
|
1495
|
+
return;
|
|
1496
|
+
}
|
|
1497
|
+
const rangeStart = this.$date();
|
|
1498
|
+
const rangeEnd = this.$dateEnd();
|
|
1499
|
+
if (!date) {
|
|
1500
|
+
this.$hoverDate.set(null);
|
|
1501
|
+
return;
|
|
1502
|
+
}
|
|
1503
|
+
if (CalendarUtils.isDisabledDate(date, this.$minDate(), this.$maxDate())) {
|
|
1504
|
+
this.$hoverDate.set(null);
|
|
1505
|
+
return;
|
|
1506
|
+
}
|
|
1507
|
+
if (!this.$isRangeSelection()) {
|
|
1508
|
+
return;
|
|
1509
|
+
}
|
|
1510
|
+
if (!rangeStart || rangeEnd) {
|
|
1511
|
+
return;
|
|
1512
|
+
}
|
|
1513
|
+
if (date.getTime() < rangeStart.getTime()) {
|
|
1514
|
+
this.$hoverDate.set(null);
|
|
1515
|
+
return;
|
|
1516
|
+
}
|
|
1517
|
+
this.$hoverDate.set(date);
|
|
1443
1518
|
}
|
|
1444
1519
|
select(date) {
|
|
1520
|
+
if (CalendarUtils.isDisabledDate(date, this.$minDate(), this.$maxDate())) {
|
|
1521
|
+
return;
|
|
1522
|
+
}
|
|
1523
|
+
this.$hoverDate.set(null);
|
|
1445
1524
|
this.$onSelect.emit(date);
|
|
1446
1525
|
}
|
|
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
1526
|
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 });
|
|
1527
|
+
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
1528
|
}
|
|
1456
1529
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiMonthlyCalendarDirective, decorators: [{
|
|
1457
1530
|
type: Directive,
|
|
1458
1531
|
args: [{
|
|
1459
1532
|
selector: 'app-ui-monthly-calendar',
|
|
1460
1533
|
}]
|
|
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"] }] } });
|
|
1534
|
+
}], 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
1535
|
|
|
1463
1536
|
class UiYearlyCalendarDirective {
|
|
1464
1537
|
$date = model(new Date(), ...(ngDevMode ? [{ debugName: "$date" }] : []));
|
|
1538
|
+
$dateEnd = input(null, ...(ngDevMode ? [{ debugName: "$dateEnd" }] : []));
|
|
1539
|
+
$isRangeSelection = input(false, ...(ngDevMode ? [{ debugName: "$isRangeSelection" }] : []));
|
|
1540
|
+
$minDate = input(undefined, ...(ngDevMode ? [{ debugName: "$minDate" }] : []));
|
|
1541
|
+
$maxDate = input(undefined, ...(ngDevMode ? [{ debugName: "$maxDate" }] : []));
|
|
1542
|
+
$hoverDate = signal(null, ...(ngDevMode ? [{ debugName: "$hoverDate" }] : []));
|
|
1465
1543
|
$onSelect = output();
|
|
1466
1544
|
$currentYear = model.required(...(ngDevMode ? [{ debugName: "$currentYear" }] : []));
|
|
1467
1545
|
$years = computed(() => {
|
|
1468
|
-
|
|
1469
|
-
|
|
1546
|
+
return CalendarUtils.generateYears(this.$currentYear(), {
|
|
1547
|
+
dateStart: this.$date(),
|
|
1548
|
+
dateEnd: this.$dateEnd(),
|
|
1549
|
+
hoverDate: this.$hoverDate(),
|
|
1550
|
+
isRangeSelection: this.$isRangeSelection(),
|
|
1551
|
+
minDate: this.$minDate(),
|
|
1552
|
+
maxDate: this.$maxDate(),
|
|
1553
|
+
});
|
|
1470
1554
|
}, ...(ngDevMode ? [{ debugName: "$years" }] : []));
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
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
|
-
});
|
|
1555
|
+
onHover(date, inHoverRange) {
|
|
1556
|
+
if (inHoverRange) {
|
|
1557
|
+
return;
|
|
1484
1558
|
}
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1559
|
+
const rangeStart = this.$date();
|
|
1560
|
+
const rangeEnd = this.$dateEnd();
|
|
1561
|
+
if (!date) {
|
|
1562
|
+
this.$hoverDate.set(null);
|
|
1563
|
+
return;
|
|
1564
|
+
}
|
|
1565
|
+
if (CalendarUtils.isDisabledDate(date, this.$minDate(), this.$maxDate())) {
|
|
1566
|
+
this.$hoverDate.set(null);
|
|
1567
|
+
return;
|
|
1568
|
+
}
|
|
1569
|
+
if (!this.$isRangeSelection()) {
|
|
1570
|
+
return;
|
|
1571
|
+
}
|
|
1572
|
+
if (!rangeStart || rangeEnd) {
|
|
1573
|
+
return;
|
|
1574
|
+
}
|
|
1575
|
+
if (date.getTime() < rangeStart.getTime()) {
|
|
1576
|
+
this.$hoverDate.set(null);
|
|
1577
|
+
return;
|
|
1578
|
+
}
|
|
1579
|
+
this.$hoverDate.set(date);
|
|
1491
1580
|
}
|
|
1492
1581
|
select(date) {
|
|
1582
|
+
if (CalendarUtils.isDisabledDate(date, this.$minDate(), this.$maxDate())) {
|
|
1583
|
+
return;
|
|
1584
|
+
}
|
|
1585
|
+
this.$hoverDate.set(null);
|
|
1493
1586
|
this.$date.set(date);
|
|
1494
1587
|
this.$onSelect.emit(date);
|
|
1495
1588
|
}
|
|
1496
1589
|
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 });
|
|
1590
|
+
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
1591
|
}
|
|
1499
1592
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiYearlyCalendarDirective, decorators: [{
|
|
1500
1593
|
type: Directive,
|
|
1501
1594
|
args: [{
|
|
1502
1595
|
selector: 'app-ui-yearly-calendar',
|
|
1503
1596
|
}]
|
|
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"] }] } });
|
|
1597
|
+
}], 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
1598
|
|
|
1506
1599
|
class UiCalendarDropdownDirective {
|
|
1507
1600
|
action = () => { };
|
|
@@ -3401,8 +3494,8 @@ class UIInputDateDirective extends UiInputDirective {
|
|
|
3401
3494
|
$isRangeSelection = input(false, ...(ngDevMode ? [{ debugName: "$isRangeSelection" }] : []));
|
|
3402
3495
|
$dateFormat = input(undefined, ...(ngDevMode ? [{ debugName: "$dateFormat" }] : []));
|
|
3403
3496
|
$dividePattern = input('/', ...(ngDevMode ? [{ debugName: "$dividePattern" }] : []));
|
|
3404
|
-
$minDate = input(
|
|
3405
|
-
$maxDate = input(
|
|
3497
|
+
$minDate = input(new Date(new Date().getFullYear() - 100, 0, 1), ...(ngDevMode ? [{ debugName: "$minDate" }] : []));
|
|
3498
|
+
$maxDate = input(new Date(new Date().getFullYear() + 20, 11, 31), ...(ngDevMode ? [{ debugName: "$maxDate" }] : []));
|
|
3406
3499
|
$inputElement = viewChild('input', ...(ngDevMode ? [{ debugName: "$inputElement" }] : []));
|
|
3407
3500
|
setDate(date) {
|
|
3408
3501
|
const newDate = this.formatDate(date);
|
|
@@ -3443,9 +3536,12 @@ class UIInputDateDirective extends UiInputDirective {
|
|
|
3443
3536
|
const oldPatternCount = (oldValue.match(patternRegex) || []).length;
|
|
3444
3537
|
const newPatternCount = (newValue.match(patternRegex) || []).length;
|
|
3445
3538
|
const patternAdded = newPatternCount > oldPatternCount;
|
|
3539
|
+
const oldHasRangeSep = oldValue.includes(' - ');
|
|
3540
|
+
const newHasRangeSep = newValue.includes(' - ');
|
|
3541
|
+
const rangeSepAdded = !oldHasRangeSep && newHasRangeSep;
|
|
3446
3542
|
super.onInput(newValue);
|
|
3447
3543
|
inputElement.value = newValue;
|
|
3448
|
-
if (patternAdded) {
|
|
3544
|
+
if (patternAdded || rangeSepAdded) {
|
|
3449
3545
|
inputElement.setSelectionRange(newValue.length, newValue.length);
|
|
3450
3546
|
}
|
|
3451
3547
|
else {
|
|
@@ -3471,14 +3567,65 @@ class UIInputDateDirective extends UiInputDirective {
|
|
|
3471
3567
|
}
|
|
3472
3568
|
return res;
|
|
3473
3569
|
};
|
|
3570
|
+
const correctDateString = (str) => {
|
|
3571
|
+
if (str.length < 8)
|
|
3572
|
+
return formatSingle(str);
|
|
3573
|
+
let dayStr = str.substring(0, 2);
|
|
3574
|
+
let monthStr = str.substring(2, 4);
|
|
3575
|
+
let yearStr = str.substring(4, 8);
|
|
3576
|
+
let day = parseInt(dayStr, 10) || 0;
|
|
3577
|
+
let month = parseInt(monthStr, 10) || 0;
|
|
3578
|
+
let year = parseInt(yearStr, 10) || 0;
|
|
3579
|
+
const minDate = this.$minDate() || new Date(new Date().getFullYear() - 100, 0, 1);
|
|
3580
|
+
const maxDate = this.$maxDate() || new Date(new Date().getFullYear() + 20, 11, 31);
|
|
3581
|
+
const minYear = minDate.getFullYear();
|
|
3582
|
+
const maxYear = maxDate.getFullYear();
|
|
3583
|
+
if (year < 1000) {
|
|
3584
|
+
year = maxYear;
|
|
3585
|
+
}
|
|
3586
|
+
else if (year < minYear) {
|
|
3587
|
+
year = minYear;
|
|
3588
|
+
}
|
|
3589
|
+
else if (year > maxYear) {
|
|
3590
|
+
year = maxYear;
|
|
3591
|
+
}
|
|
3592
|
+
if (month < 1 || month > 12) {
|
|
3593
|
+
month = 12;
|
|
3594
|
+
}
|
|
3595
|
+
if (day < 1) {
|
|
3596
|
+
day = 31;
|
|
3597
|
+
}
|
|
3598
|
+
else {
|
|
3599
|
+
const lastDay = new Date(year, month, 0).getDate();
|
|
3600
|
+
if (day > lastDay) {
|
|
3601
|
+
day = lastDay;
|
|
3602
|
+
}
|
|
3603
|
+
}
|
|
3604
|
+
const parsedDate = new Date(year, month - 1, day);
|
|
3605
|
+
if (parsedDate < minDate) {
|
|
3606
|
+
day = minDate.getDate();
|
|
3607
|
+
month = minDate.getMonth() + 1;
|
|
3608
|
+
year = minDate.getFullYear();
|
|
3609
|
+
}
|
|
3610
|
+
else if (parsedDate > maxDate) {
|
|
3611
|
+
day = maxDate.getDate();
|
|
3612
|
+
month = maxDate.getMonth() + 1;
|
|
3613
|
+
year = maxDate.getFullYear();
|
|
3614
|
+
}
|
|
3615
|
+
const correctedDay = String(day).padStart(2, '0');
|
|
3616
|
+
const correctedMonth = String(month).padStart(2, '0');
|
|
3617
|
+
const correctedYear = String(year).padStart(4, '0');
|
|
3618
|
+
const correctedStr = correctedDay + correctedMonth + correctedYear;
|
|
3619
|
+
return formatSingle(correctedStr);
|
|
3620
|
+
};
|
|
3474
3621
|
if (this.$isRangeSelection()) {
|
|
3475
3622
|
const first = limited.substring(0, 8);
|
|
3476
3623
|
const second = limited.substring(8, 16);
|
|
3477
|
-
const firstDate =
|
|
3478
|
-
const secondDate =
|
|
3624
|
+
const firstDate = correctDateString(first);
|
|
3625
|
+
const secondDate = correctDateString(second);
|
|
3479
3626
|
return secondDate ? `${firstDate} - ${secondDate}` : firstDate;
|
|
3480
3627
|
}
|
|
3481
|
-
return
|
|
3628
|
+
return correctDateString(limited);
|
|
3482
3629
|
}
|
|
3483
3630
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UIInputDateDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
3484
3631
|
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 }, $dateFormat: { classPropertyName: "$dateFormat", publicName: "$dateFormat", 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 });
|
|
@@ -4076,5 +4223,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
4076
4223
|
* Generated bundle index. Do not edit.
|
|
4077
4224
|
*/
|
|
4078
4225
|
|
|
4079
|
-
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 };
|
|
4226
|
+
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, stringToHslColor };
|
|
4080
4227
|
//# sourceMappingURL=ibragim-dev-org-ui-forge-library.mjs.map
|