pdm-ui-kit 0.1.21 → 0.1.22
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.
- package/esm2020/lib/components/calendar/calendar.component.mjs +454 -53
- package/esm2020/lib/components/date-picker/date-picker.component.mjs +252 -34
- package/fesm2015/pdm-ui-kit.mjs +727 -103
- package/fesm2015/pdm-ui-kit.mjs.map +1 -1
- package/fesm2020/pdm-ui-kit.mjs +721 -103
- package/fesm2020/pdm-ui-kit.mjs.map +1 -1
- package/lib/components/calendar/calendar.component.d.ts +137 -18
- package/lib/components/date-picker/date-picker.component.d.ts +61 -17
- package/package.json +2 -1
package/fesm2020/pdm-ui-kit.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import * as i0 from '@angular/core';
|
|
|
4
4
|
import { EventEmitter, Component, ChangeDetectionStrategy, Input, Output, HostListener, ViewChildren, ViewChild, NgModule } from '@angular/core';
|
|
5
5
|
import { icons } from 'lucide';
|
|
6
6
|
import * as i1$1 from '@angular/platform-browser';
|
|
7
|
+
import { format } from 'date-fns';
|
|
7
8
|
|
|
8
9
|
class PdmAccordionComponent {
|
|
9
10
|
constructor() {
|
|
@@ -472,71 +473,472 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
|
|
|
472
473
|
type: Output
|
|
473
474
|
}] } });
|
|
474
475
|
|
|
476
|
+
const DEFAULT_VIEW_MONTH = new Date(2025, 5, 1); // June 2025 (Figma default)
|
|
477
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
475
478
|
class PdmCalendarComponent {
|
|
476
|
-
constructor() {
|
|
477
|
-
this.
|
|
478
|
-
this.
|
|
479
|
-
this.
|
|
480
|
-
this.
|
|
481
|
-
this.
|
|
482
|
-
this.rangeEndDay = 9;
|
|
479
|
+
constructor(cdr) {
|
|
480
|
+
this.cdr = cdr;
|
|
481
|
+
this._value = null;
|
|
482
|
+
this._rangeValue = null;
|
|
483
|
+
this._month = null;
|
|
484
|
+
this.variant = 'single';
|
|
483
485
|
this.className = '';
|
|
486
|
+
this.disabledDates = [];
|
|
487
|
+
this.minDate = null;
|
|
488
|
+
this.maxDate = null;
|
|
489
|
+
this.isDateDisabled = null;
|
|
490
|
+
this.allowSameDayRange = true;
|
|
491
|
+
this.readonly = false;
|
|
492
|
+
this.valueChange = new EventEmitter();
|
|
493
|
+
this.rangeValueChange = new EventEmitter();
|
|
494
|
+
this.monthChange = new EventEmitter();
|
|
495
|
+
this.dateClick = new EventEmitter();
|
|
496
|
+
this.disabledDateClick = new EventEmitter();
|
|
484
497
|
this.weekdays = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
|
|
498
|
+
this.monthOptions = [
|
|
499
|
+
{ value: 0, label: 'Jan' },
|
|
500
|
+
{ value: 1, label: 'Feb' },
|
|
501
|
+
{ value: 2, label: 'Mar' },
|
|
502
|
+
{ value: 3, label: 'Apr' },
|
|
503
|
+
{ value: 4, label: 'May' },
|
|
504
|
+
{ value: 5, label: 'Jun' },
|
|
505
|
+
{ value: 6, label: 'Jul' },
|
|
506
|
+
{ value: 7, label: 'Aug' },
|
|
507
|
+
{ value: 8, label: 'Sep' },
|
|
508
|
+
{ value: 9, label: 'Oct' },
|
|
509
|
+
{ value: 10, label: 'Nov' },
|
|
510
|
+
{ value: 11, label: 'Dec' }
|
|
511
|
+
];
|
|
512
|
+
this.trackByIndex = (index) => {
|
|
513
|
+
return index;
|
|
514
|
+
};
|
|
515
|
+
this.trackByDate = (_index, cell) => {
|
|
516
|
+
return this.dateKey(cell.date);
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
set value(value) {
|
|
520
|
+
this._value = this.normalizeDate(value);
|
|
521
|
+
}
|
|
522
|
+
get value() {
|
|
523
|
+
return this._value;
|
|
524
|
+
}
|
|
525
|
+
set rangeValue(value) {
|
|
526
|
+
this._rangeValue = value
|
|
527
|
+
? {
|
|
528
|
+
start: this.normalizeDate(value.start),
|
|
529
|
+
end: this.normalizeDate(value.end)
|
|
530
|
+
}
|
|
531
|
+
: null;
|
|
532
|
+
}
|
|
533
|
+
get rangeValue() {
|
|
534
|
+
return this._rangeValue;
|
|
535
|
+
}
|
|
536
|
+
set month(value) {
|
|
537
|
+
this._month = value ? this.startOfMonth(value) : null;
|
|
538
|
+
}
|
|
539
|
+
get month() {
|
|
540
|
+
return this._month;
|
|
541
|
+
}
|
|
542
|
+
get resolvedVariant() {
|
|
543
|
+
return this.variant === 'range' ? 'range' : 'single';
|
|
544
|
+
}
|
|
545
|
+
get visibleMonths() {
|
|
546
|
+
const baseMonth = this.getAnchorMonth();
|
|
547
|
+
if (this.resolvedVariant === 'single') {
|
|
548
|
+
return [
|
|
549
|
+
{
|
|
550
|
+
date: baseMonth,
|
|
551
|
+
title: this.formatMonthYear(baseMonth),
|
|
552
|
+
titleStyle: 'dropdowns',
|
|
553
|
+
dropdownMonth: this.formatMonthShort(baseMonth),
|
|
554
|
+
dropdownYear: String(baseMonth.getFullYear()),
|
|
555
|
+
showPrevButton: true,
|
|
556
|
+
showNextButton: true,
|
|
557
|
+
weeks: this.buildMonthWeeks(baseMonth, false)
|
|
558
|
+
}
|
|
559
|
+
];
|
|
560
|
+
}
|
|
561
|
+
const nextMonth = this.addMonths(baseMonth, 1);
|
|
562
|
+
return [
|
|
563
|
+
{
|
|
564
|
+
date: baseMonth,
|
|
565
|
+
title: this.formatMonthYear(baseMonth),
|
|
566
|
+
titleStyle: 'plain',
|
|
567
|
+
showPrevButton: true,
|
|
568
|
+
showNextButton: false,
|
|
569
|
+
weeks: this.buildMonthWeeks(baseMonth, true)
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
date: nextMonth,
|
|
573
|
+
title: this.formatMonthYear(nextMonth),
|
|
574
|
+
titleStyle: 'plain',
|
|
575
|
+
showPrevButton: false,
|
|
576
|
+
showNextButton: true,
|
|
577
|
+
weeks: this.buildMonthWeeks(nextMonth, true)
|
|
578
|
+
}
|
|
579
|
+
];
|
|
580
|
+
}
|
|
581
|
+
get singleHeaderMonth() {
|
|
582
|
+
return this.getAnchorMonth().getMonth();
|
|
583
|
+
}
|
|
584
|
+
get singleHeaderYear() {
|
|
585
|
+
return this.getAnchorMonth().getFullYear();
|
|
586
|
+
}
|
|
587
|
+
get yearOptions() {
|
|
588
|
+
const currentYear = this.singleHeaderYear;
|
|
589
|
+
const minYear = this.minDate ? this.minDate.getFullYear() : currentYear - 100;
|
|
590
|
+
const maxYear = this.maxDate ? this.maxDate.getFullYear() : currentYear + 100;
|
|
591
|
+
const years = [];
|
|
592
|
+
for (let year = minYear; year <= maxYear; year += 1) {
|
|
593
|
+
years.push(year);
|
|
594
|
+
}
|
|
595
|
+
return years;
|
|
596
|
+
}
|
|
597
|
+
get rootClasses() {
|
|
598
|
+
return [
|
|
599
|
+
'border-border bg-background relative rounded-[10px] border p-3 shadow-sm',
|
|
600
|
+
this.resolvedVariant === 'range'
|
|
601
|
+
? 'inline-flex items-start justify-center gap-4 shrink-0 grow-0 basis-auto'
|
|
602
|
+
: 'inline-flex flex-col gap-4 shrink-0 grow-0 basis-auto',
|
|
603
|
+
this.className
|
|
604
|
+
];
|
|
605
|
+
}
|
|
606
|
+
get rootStyle() {
|
|
607
|
+
const width = this.resolvedVariant === 'range' ? '488px' : '250px';
|
|
608
|
+
return {
|
|
609
|
+
width,
|
|
610
|
+
minWidth: width,
|
|
611
|
+
maxWidth: width,
|
|
612
|
+
minHeight: '293px',
|
|
613
|
+
flex: '0 0 auto',
|
|
614
|
+
alignSelf: 'flex-start'
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
monthPanelClasses(_index) {
|
|
618
|
+
return ['flex flex-col items-start', this.resolvedVariant === 'range' ? 'w-[224px] gap-4' : 'w-full gap-0'];
|
|
619
|
+
}
|
|
620
|
+
headerClasses(month) {
|
|
621
|
+
return ['flex w-full items-center justify-between', month.titleStyle === 'dropdowns' ? '' : 'mb-4'];
|
|
485
622
|
}
|
|
486
|
-
|
|
487
|
-
return
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
return
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
}
|
|
519
|
-
|
|
623
|
+
navButtonClasses() {
|
|
624
|
+
return [
|
|
625
|
+
'flex h-8 w-8 items-center justify-center rounded-md text-foreground',
|
|
626
|
+
'disabled:pointer-events-none disabled:opacity-40'
|
|
627
|
+
];
|
|
628
|
+
}
|
|
629
|
+
navPlaceholderClasses() {
|
|
630
|
+
return ['h-7 w-7 shrink-0'];
|
|
631
|
+
}
|
|
632
|
+
dropdownWrapClasses() {
|
|
633
|
+
return ['flex w-40 items-center justify-center gap-2'];
|
|
634
|
+
}
|
|
635
|
+
dropdownClasses(widthClass) {
|
|
636
|
+
return ['flex h-8 items-center justify-center gap-1 px-1', widthClass];
|
|
637
|
+
}
|
|
638
|
+
dropdownSelectClasses() {
|
|
639
|
+
return [
|
|
640
|
+
'text-foreground h-full bg-transparent text-sm font-medium leading-5',
|
|
641
|
+
'appearance-none border-0 outline-none ring-0 focus:outline-none focus:ring-0 text-center cursor-pointer'
|
|
642
|
+
];
|
|
643
|
+
}
|
|
644
|
+
get dropdownSelectStyle() {
|
|
645
|
+
return {
|
|
646
|
+
appearance: 'none',
|
|
647
|
+
WebkitAppearance: 'none',
|
|
648
|
+
MozAppearance: 'none',
|
|
649
|
+
background: 'transparent',
|
|
650
|
+
border: '0',
|
|
651
|
+
boxShadow: 'none',
|
|
652
|
+
outline: '0',
|
|
653
|
+
padding: '0',
|
|
654
|
+
margin: '0'
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
calendarGridWrapClasses() {
|
|
658
|
+
return ['flex w-full flex-col items-start'];
|
|
659
|
+
}
|
|
660
|
+
weekdayRowClasses() {
|
|
661
|
+
return ['flex w-full items-center'];
|
|
662
|
+
}
|
|
663
|
+
weekdayCellClasses() {
|
|
664
|
+
return ['text-muted-foreground flex h-[21px] w-8 items-center justify-center rounded-md text-xs leading-4'];
|
|
665
|
+
}
|
|
666
|
+
weekRowClasses() {
|
|
667
|
+
return ['flex w-full items-start pt-2'];
|
|
668
|
+
}
|
|
669
|
+
dayCellClasses(cell) {
|
|
670
|
+
return [
|
|
671
|
+
'relative flex h-8 w-8 shrink-0 items-center justify-center',
|
|
672
|
+
cell.rangeFill ? 'bg-accent' : '',
|
|
673
|
+
cell.rangeLeftCap ? 'rounded-l-md' : '',
|
|
674
|
+
cell.rangeRightCap ? 'rounded-r-md' : ''
|
|
675
|
+
];
|
|
676
|
+
}
|
|
677
|
+
dayButtonClasses(cell) {
|
|
678
|
+
return [
|
|
679
|
+
'relative z-10 flex h-8 w-8 items-center justify-center rounded-md text-sm leading-5',
|
|
680
|
+
cell.selected ? 'bg-primary text-primary-foreground' : cell.rangeFill ? 'text-accent-foreground' : 'text-foreground',
|
|
681
|
+
cell.muted && !cell.rangeFill ? 'opacity-50' : '',
|
|
682
|
+
cell.disabled ? 'cursor-not-allowed opacity-40' : '',
|
|
683
|
+
!cell.disabled && !this.readonly && !cell.selected ? 'hover:bg-accent/70' : ''
|
|
684
|
+
];
|
|
685
|
+
}
|
|
686
|
+
dayLabelClasses(_cell) {
|
|
687
|
+
return ['font-normal'];
|
|
688
|
+
}
|
|
689
|
+
goToPreviousMonth() {
|
|
690
|
+
this.setAnchorMonth(this.addMonths(this.getAnchorMonth(), -1));
|
|
691
|
+
}
|
|
692
|
+
goToNextMonth() {
|
|
693
|
+
this.setAnchorMonth(this.addMonths(this.getAnchorMonth(), 1));
|
|
694
|
+
}
|
|
695
|
+
onSingleMonthChange(monthValue) {
|
|
696
|
+
const month = Number(monthValue);
|
|
697
|
+
if (Number.isNaN(month) || month < 0 || month > 11) {
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
const anchor = this.getAnchorMonth();
|
|
701
|
+
this.setAnchorMonth(new Date(anchor.getFullYear(), month, 1));
|
|
702
|
+
}
|
|
703
|
+
onSingleYearChange(yearValue) {
|
|
704
|
+
const year = Number(yearValue);
|
|
705
|
+
if (Number.isNaN(year)) {
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
const anchor = this.getAnchorMonth();
|
|
709
|
+
this.setAnchorMonth(new Date(year, anchor.getMonth(), 1));
|
|
710
|
+
}
|
|
711
|
+
onDatePressed(cell) {
|
|
712
|
+
const date = this.cloneDate(cell.date);
|
|
713
|
+
if (cell.disabled) {
|
|
714
|
+
this.disabledDateClick.emit(date);
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
if (this.readonly) {
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
this.dateClick.emit(date);
|
|
721
|
+
if (this.resolvedVariant === 'single') {
|
|
722
|
+
this._value = date;
|
|
723
|
+
this.valueChange.emit(this.cloneDate(date));
|
|
724
|
+
this.syncVisibleMonthToDate(date);
|
|
725
|
+
this.cdr.markForCheck();
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
this.handleRangeSelection(date);
|
|
729
|
+
this.cdr.markForCheck();
|
|
730
|
+
}
|
|
731
|
+
handleRangeSelection(date) {
|
|
732
|
+
const current = this._rangeValue;
|
|
733
|
+
const currentStart = current?.start ? this.cloneDate(current.start) : null;
|
|
734
|
+
const currentEnd = current?.end ? this.cloneDate(current.end) : null;
|
|
735
|
+
if (!currentStart || (currentStart && currentEnd)) {
|
|
736
|
+
this._rangeValue = { start: date, end: null };
|
|
737
|
+
this.rangeValueChange.emit({ start: this.cloneDate(date), end: null });
|
|
738
|
+
this.syncVisibleMonthToDate(date);
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
if (this.isSameDay(currentStart, date) && !this.allowSameDayRange) {
|
|
742
|
+
this._rangeValue = { start: date, end: null };
|
|
743
|
+
this.rangeValueChange.emit({ start: this.cloneDate(date), end: null });
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
const start = this.compareDate(date, currentStart) < 0 ? date : currentStart;
|
|
747
|
+
const end = this.compareDate(date, currentStart) < 0 ? currentStart : date;
|
|
748
|
+
if (this.rangeContainsBlockedDate(start, end)) {
|
|
749
|
+
this.disabledDateClick.emit(this.cloneDate(date));
|
|
750
|
+
return;
|
|
751
|
+
}
|
|
752
|
+
this._rangeValue = { start, end };
|
|
753
|
+
this.rangeValueChange.emit({ start: this.cloneDate(start), end: this.cloneDate(end) });
|
|
754
|
+
this.syncVisibleMonthToDate(start);
|
|
755
|
+
}
|
|
756
|
+
buildMonthWeeks(month, includeRange) {
|
|
757
|
+
const firstOfMonth = this.startOfMonth(month);
|
|
758
|
+
const start = this.startOfWeek(firstOfMonth);
|
|
759
|
+
const end = this.endOfWeek(this.endOfMonth(firstOfMonth));
|
|
760
|
+
const weeks = [];
|
|
761
|
+
let cursor = this.cloneDate(start);
|
|
762
|
+
while (this.compareDate(cursor, end) <= 0) {
|
|
763
|
+
const row = [];
|
|
764
|
+
for (let col = 0; col < 7; col += 1) {
|
|
765
|
+
row.push(this.buildCell(cursor, month, includeRange));
|
|
766
|
+
cursor = this.addDays(cursor, 1);
|
|
767
|
+
}
|
|
768
|
+
weeks.push(row);
|
|
769
|
+
}
|
|
770
|
+
for (const row of weeks) {
|
|
771
|
+
for (let col = 0; col < row.length; col += 1) {
|
|
772
|
+
const cell = row[col];
|
|
773
|
+
if (!cell.inRange) {
|
|
774
|
+
continue;
|
|
775
|
+
}
|
|
776
|
+
const leftInRow = col > 0 ? row[col - 1].inRange : false;
|
|
777
|
+
const rightInRow = col < row.length - 1 ? row[col + 1].inRange : false;
|
|
778
|
+
cell.rangeLeftCap = !leftInRow;
|
|
779
|
+
cell.rangeRightCap = !rightInRow;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
return weeks;
|
|
783
|
+
}
|
|
784
|
+
buildCell(date, visibleMonth, includeRange) {
|
|
785
|
+
const normalized = this.cloneDate(date);
|
|
786
|
+
const inCurrentMonth = normalized.getMonth() === visibleMonth.getMonth() && normalized.getFullYear() === visibleMonth.getFullYear();
|
|
787
|
+
const disabled = this.isBlocked(normalized);
|
|
788
|
+
const selectedSingle = this.resolvedVariant === 'single' && !!this._value && this.isSameDay(normalized, this._value);
|
|
789
|
+
const rangeStart = includeRange && !!this._rangeValue?.start && this.isSameDay(normalized, this._rangeValue.start);
|
|
790
|
+
const rangeEnd = includeRange && !!this._rangeValue?.end && this.isSameDay(normalized, this._rangeValue.end);
|
|
791
|
+
const inRange = includeRange &&
|
|
792
|
+
!!this._rangeValue?.start &&
|
|
793
|
+
!!this._rangeValue?.end &&
|
|
794
|
+
this.compareDate(normalized, this._rangeValue.start) >= 0 &&
|
|
795
|
+
this.compareDate(normalized, this._rangeValue.end) <= 0;
|
|
796
|
+
return {
|
|
797
|
+
date: normalized,
|
|
798
|
+
label: normalized.getDate(),
|
|
799
|
+
muted: !inCurrentMonth,
|
|
800
|
+
disabled,
|
|
801
|
+
selected: selectedSingle || rangeStart || rangeEnd,
|
|
802
|
+
inRange,
|
|
803
|
+
rangeFill: inRange,
|
|
804
|
+
rangeLeftCap: false,
|
|
805
|
+
rangeRightCap: false
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
getAnchorMonth() {
|
|
809
|
+
if (this._month) {
|
|
810
|
+
return this.cloneDate(this._month);
|
|
811
|
+
}
|
|
812
|
+
if (this.resolvedVariant === 'single' && this._value) {
|
|
813
|
+
return this.startOfMonth(this._value);
|
|
814
|
+
}
|
|
815
|
+
if (this.resolvedVariant === 'range' && this._rangeValue?.start) {
|
|
816
|
+
return this.startOfMonth(this._rangeValue.start);
|
|
817
|
+
}
|
|
818
|
+
return this.startOfMonth(DEFAULT_VIEW_MONTH);
|
|
819
|
+
}
|
|
820
|
+
setAnchorMonth(month) {
|
|
821
|
+
this._month = this.startOfMonth(month);
|
|
822
|
+
this.monthChange.emit(this.cloneDate(this._month));
|
|
823
|
+
}
|
|
824
|
+
syncVisibleMonthToDate(date) {
|
|
825
|
+
const nextMonth = this.startOfMonth(date);
|
|
826
|
+
if (!this._month || !this.isSameMonth(this._month, nextMonth)) {
|
|
827
|
+
this._month = nextMonth;
|
|
828
|
+
this.monthChange.emit(this.cloneDate(nextMonth));
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
isBlocked(date) {
|
|
832
|
+
if (this.minDate && this.compareDate(date, this.minDate) < 0) {
|
|
833
|
+
return true;
|
|
834
|
+
}
|
|
835
|
+
if (this.maxDate && this.compareDate(date, this.maxDate) > 0) {
|
|
836
|
+
return true;
|
|
837
|
+
}
|
|
838
|
+
const blockedSet = new Set((this.disabledDates || []).map((item) => this.dateKey(item)));
|
|
839
|
+
if (blockedSet.has(this.dateKey(date))) {
|
|
840
|
+
return true;
|
|
841
|
+
}
|
|
842
|
+
return !!this.isDateDisabled?.(this.cloneDate(date));
|
|
843
|
+
}
|
|
844
|
+
rangeContainsBlockedDate(start, end) {
|
|
845
|
+
let cursor = this.cloneDate(start);
|
|
846
|
+
while (this.compareDate(cursor, end) <= 0) {
|
|
847
|
+
if (this.isBlocked(cursor)) {
|
|
848
|
+
return true;
|
|
849
|
+
}
|
|
850
|
+
cursor = this.addDays(cursor, 1);
|
|
851
|
+
}
|
|
852
|
+
return false;
|
|
853
|
+
}
|
|
854
|
+
normalizeDate(value) {
|
|
855
|
+
if (!(value instanceof Date) || Number.isNaN(value.getTime())) {
|
|
856
|
+
return null;
|
|
857
|
+
}
|
|
858
|
+
return new Date(value.getFullYear(), value.getMonth(), value.getDate());
|
|
859
|
+
}
|
|
860
|
+
cloneDate(date) {
|
|
861
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
862
|
+
}
|
|
863
|
+
startOfMonth(date) {
|
|
864
|
+
return new Date(date.getFullYear(), date.getMonth(), 1);
|
|
865
|
+
}
|
|
866
|
+
endOfMonth(date) {
|
|
867
|
+
return new Date(date.getFullYear(), date.getMonth() + 1, 0);
|
|
868
|
+
}
|
|
869
|
+
startOfWeek(date) {
|
|
870
|
+
return this.addDays(date, -date.getDay());
|
|
871
|
+
}
|
|
872
|
+
endOfWeek(date) {
|
|
873
|
+
return this.addDays(date, 6 - date.getDay());
|
|
874
|
+
}
|
|
875
|
+
addMonths(date, months) {
|
|
876
|
+
return new Date(date.getFullYear(), date.getMonth() + months, 1);
|
|
877
|
+
}
|
|
878
|
+
addDays(date, days) {
|
|
879
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate() + days);
|
|
880
|
+
}
|
|
881
|
+
compareDate(a, b) {
|
|
882
|
+
return this.dateValue(a) - this.dateValue(b);
|
|
883
|
+
}
|
|
884
|
+
dateValue(date) {
|
|
885
|
+
return Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()) / DAY_MS;
|
|
886
|
+
}
|
|
887
|
+
isSameDay(a, b) {
|
|
888
|
+
return this.compareDate(a, b) === 0;
|
|
889
|
+
}
|
|
890
|
+
isSameMonth(a, b) {
|
|
891
|
+
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth();
|
|
892
|
+
}
|
|
893
|
+
dateKey(date) {
|
|
894
|
+
const y = date.getFullYear();
|
|
895
|
+
const m = String(date.getMonth() + 1).padStart(2, '0');
|
|
896
|
+
const d = String(date.getDate()).padStart(2, '0');
|
|
897
|
+
return `${y}-${m}-${d}`;
|
|
898
|
+
}
|
|
899
|
+
formatMonthShort(date) {
|
|
900
|
+
return date.toLocaleString('en-US', { month: 'short' });
|
|
901
|
+
}
|
|
902
|
+
formatMonthYear(date) {
|
|
903
|
+
return date.toLocaleString('en-US', { month: 'long', year: 'numeric' });
|
|
520
904
|
}
|
|
521
905
|
}
|
|
522
|
-
PdmCalendarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: PdmCalendarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
523
|
-
PdmCalendarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: PdmCalendarComponent, selector: "pdm-calendar", inputs: {
|
|
906
|
+
PdmCalendarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: PdmCalendarComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
907
|
+
PdmCalendarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: PdmCalendarComponent, selector: "pdm-calendar", inputs: { variant: "variant", className: "className", disabledDates: "disabledDates", minDate: "minDate", maxDate: "maxDate", isDateDisabled: "isDateDisabled", allowSameDayRange: "allowSameDayRange", readonly: "readonly", value: "value", rangeValue: "rangeValue", month: "month" }, outputs: { valueChange: "valueChange", rangeValueChange: "rangeValueChange", monthChange: "monthChange", dateClick: "dateClick", disabledDateClick: "disabledDateClick" }, ngImport: i0, template: "<div [ngClass]=\"rootClasses\" [ngStyle]=\"rootStyle\">\n <div *ngFor=\"let month of visibleMonths; let monthIndex = index; trackBy: trackByIndex\" [ngClass]=\"monthPanelClasses(monthIndex)\">\n <div [ngClass]=\"headerClasses(month)\">\n <button\n *ngIf=\"month.showPrevButton; else prevPlaceholder\"\n type=\"button\"\n [ngClass]=\"navButtonClasses()\"\n aria-label=\"Previous month\"\n (click)=\"goToPreviousMonth()\"\n [disabled]=\"readonly\"\n >\n <svg viewBox=\"0 0 24 24\" class=\"h-4 w-4\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\">\n <path d=\"m15 18-6-6 6-6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path>\n </svg>\n </button>\n <ng-template #prevPlaceholder>\n <div [ngClass]=\"navPlaceholderClasses()\" aria-hidden=\"true\"></div>\n </ng-template>\n\n <ng-container *ngIf=\"month.titleStyle === 'dropdowns'; else plainTitle\">\n <div [ngClass]=\"dropdownWrapClasses()\">\n <div [ngClass]=\"dropdownClasses('w-[72px]')\">\n <select\n [ngClass]=\"dropdownSelectClasses()\"\n [ngStyle]=\"dropdownSelectStyle\"\n [value]=\"singleHeaderMonth\"\n aria-label=\"Month\"\n (change)=\"onSingleMonthChange($any($event.target).value)\"\n >\n <option *ngFor=\"let monthOption of monthOptions\" [value]=\"monthOption.value\">{{ monthOption.label }}</option>\n </select>\n <svg viewBox=\"0 0 24 24\" class=\"h-3 w-3 text-foreground\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\">\n <path d=\"m6 9 6 6 6-6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path>\n </svg>\n </div>\n <div [ngClass]=\"dropdownClasses('w-[82px]')\">\n <select\n [ngClass]=\"dropdownSelectClasses()\"\n [ngStyle]=\"dropdownSelectStyle\"\n [value]=\"singleHeaderYear\"\n aria-label=\"Year\"\n (change)=\"onSingleYearChange($any($event.target).value)\"\n >\n <option *ngFor=\"let year of yearOptions\" [value]=\"year\">{{ year }}</option>\n </select>\n <svg viewBox=\"0 0 24 24\" class=\"h-3 w-3 text-foreground\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\">\n <path d=\"m6 9 6 6 6-6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path>\n </svg>\n </div>\n </div>\n </ng-container>\n\n <ng-template #plainTitle>\n <div class=\"flex min-w-0 flex-1 items-center justify-center\">\n <p class=\"text-foreground text-center text-sm font-medium leading-5\">\n {{ month.title }}\n </p>\n </div>\n </ng-template>\n\n <button\n *ngIf=\"month.showNextButton; else nextPlaceholder\"\n type=\"button\"\n [ngClass]=\"navButtonClasses()\"\n aria-label=\"Next month\"\n (click)=\"goToNextMonth()\"\n [disabled]=\"readonly\"\n >\n <svg viewBox=\"0 0 24 24\" class=\"h-4 w-4\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\">\n <path d=\"m9 18 6-6-6-6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path>\n </svg>\n </button>\n <ng-template #nextPlaceholder>\n <div [ngClass]=\"navPlaceholderClasses()\" aria-hidden=\"true\"></div>\n </ng-template>\n </div>\n\n <div [ngClass]=\"calendarGridWrapClasses()\">\n <div [ngClass]=\"weekdayRowClasses()\">\n <div *ngFor=\"let day of weekdays; trackBy: trackByIndex\" [ngClass]=\"weekdayCellClasses()\">\n <span>{{ day }}</span>\n </div>\n </div>\n\n <div *ngFor=\"let week of month.weeks; trackBy: trackByIndex\" [ngClass]=\"weekRowClasses()\">\n <div *ngFor=\"let cell of week; trackBy: trackByDate\" [ngClass]=\"dayCellClasses(cell)\">\n <button\n type=\"button\"\n [ngClass]=\"dayButtonClasses(cell)\"\n [disabled]=\"readonly\"\n [attr.aria-selected]=\"cell.selected\"\n [attr.aria-disabled]=\"cell.disabled || readonly\"\n [attr.title]=\"cell.date | date : 'yyyy-MM-dd'\"\n (click)=\"onDatePressed(cell)\"\n >\n <span [ngClass]=\"dayLabelClasses(cell)\">{{ cell.label }}</span>\n </button>\n </div>\n </div>\n </div>\n </div>\n</div>\n", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "pipe", type: i1.DatePipe, name: "date" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
524
908
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: PdmCalendarComponent, decorators: [{
|
|
525
909
|
type: Component,
|
|
526
|
-
args: [{ selector: 'pdm-calendar', changeDetection: ChangeDetectionStrategy.OnPush, template: "<
|
|
527
|
-
}], propDecorators: {
|
|
910
|
+
args: [{ selector: 'pdm-calendar', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div [ngClass]=\"rootClasses\" [ngStyle]=\"rootStyle\">\n <div *ngFor=\"let month of visibleMonths; let monthIndex = index; trackBy: trackByIndex\" [ngClass]=\"monthPanelClasses(monthIndex)\">\n <div [ngClass]=\"headerClasses(month)\">\n <button\n *ngIf=\"month.showPrevButton; else prevPlaceholder\"\n type=\"button\"\n [ngClass]=\"navButtonClasses()\"\n aria-label=\"Previous month\"\n (click)=\"goToPreviousMonth()\"\n [disabled]=\"readonly\"\n >\n <svg viewBox=\"0 0 24 24\" class=\"h-4 w-4\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\">\n <path d=\"m15 18-6-6 6-6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path>\n </svg>\n </button>\n <ng-template #prevPlaceholder>\n <div [ngClass]=\"navPlaceholderClasses()\" aria-hidden=\"true\"></div>\n </ng-template>\n\n <ng-container *ngIf=\"month.titleStyle === 'dropdowns'; else plainTitle\">\n <div [ngClass]=\"dropdownWrapClasses()\">\n <div [ngClass]=\"dropdownClasses('w-[72px]')\">\n <select\n [ngClass]=\"dropdownSelectClasses()\"\n [ngStyle]=\"dropdownSelectStyle\"\n [value]=\"singleHeaderMonth\"\n aria-label=\"Month\"\n (change)=\"onSingleMonthChange($any($event.target).value)\"\n >\n <option *ngFor=\"let monthOption of monthOptions\" [value]=\"monthOption.value\">{{ monthOption.label }}</option>\n </select>\n <svg viewBox=\"0 0 24 24\" class=\"h-3 w-3 text-foreground\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\">\n <path d=\"m6 9 6 6 6-6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path>\n </svg>\n </div>\n <div [ngClass]=\"dropdownClasses('w-[82px]')\">\n <select\n [ngClass]=\"dropdownSelectClasses()\"\n [ngStyle]=\"dropdownSelectStyle\"\n [value]=\"singleHeaderYear\"\n aria-label=\"Year\"\n (change)=\"onSingleYearChange($any($event.target).value)\"\n >\n <option *ngFor=\"let year of yearOptions\" [value]=\"year\">{{ year }}</option>\n </select>\n <svg viewBox=\"0 0 24 24\" class=\"h-3 w-3 text-foreground\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\">\n <path d=\"m6 9 6 6 6-6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path>\n </svg>\n </div>\n </div>\n </ng-container>\n\n <ng-template #plainTitle>\n <div class=\"flex min-w-0 flex-1 items-center justify-center\">\n <p class=\"text-foreground text-center text-sm font-medium leading-5\">\n {{ month.title }}\n </p>\n </div>\n </ng-template>\n\n <button\n *ngIf=\"month.showNextButton; else nextPlaceholder\"\n type=\"button\"\n [ngClass]=\"navButtonClasses()\"\n aria-label=\"Next month\"\n (click)=\"goToNextMonth()\"\n [disabled]=\"readonly\"\n >\n <svg viewBox=\"0 0 24 24\" class=\"h-4 w-4\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\">\n <path d=\"m9 18 6-6-6-6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path>\n </svg>\n </button>\n <ng-template #nextPlaceholder>\n <div [ngClass]=\"navPlaceholderClasses()\" aria-hidden=\"true\"></div>\n </ng-template>\n </div>\n\n <div [ngClass]=\"calendarGridWrapClasses()\">\n <div [ngClass]=\"weekdayRowClasses()\">\n <div *ngFor=\"let day of weekdays; trackBy: trackByIndex\" [ngClass]=\"weekdayCellClasses()\">\n <span>{{ day }}</span>\n </div>\n </div>\n\n <div *ngFor=\"let week of month.weeks; trackBy: trackByIndex\" [ngClass]=\"weekRowClasses()\">\n <div *ngFor=\"let cell of week; trackBy: trackByDate\" [ngClass]=\"dayCellClasses(cell)\">\n <button\n type=\"button\"\n [ngClass]=\"dayButtonClasses(cell)\"\n [disabled]=\"readonly\"\n [attr.aria-selected]=\"cell.selected\"\n [attr.aria-disabled]=\"cell.disabled || readonly\"\n [attr.title]=\"cell.date | date : 'yyyy-MM-dd'\"\n (click)=\"onDatePressed(cell)\"\n >\n <span [ngClass]=\"dayLabelClasses(cell)\">{{ cell.label }}</span>\n </button>\n </div>\n </div>\n </div>\n </div>\n</div>\n" }]
|
|
911
|
+
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { variant: [{
|
|
528
912
|
type: Input
|
|
529
|
-
}],
|
|
913
|
+
}], className: [{
|
|
530
914
|
type: Input
|
|
531
|
-
}],
|
|
915
|
+
}], disabledDates: [{
|
|
532
916
|
type: Input
|
|
533
|
-
}],
|
|
917
|
+
}], minDate: [{
|
|
534
918
|
type: Input
|
|
535
|
-
}],
|
|
919
|
+
}], maxDate: [{
|
|
536
920
|
type: Input
|
|
537
|
-
}],
|
|
921
|
+
}], isDateDisabled: [{
|
|
538
922
|
type: Input
|
|
539
|
-
}],
|
|
923
|
+
}], allowSameDayRange: [{
|
|
924
|
+
type: Input
|
|
925
|
+
}], readonly: [{
|
|
926
|
+
type: Input
|
|
927
|
+
}], valueChange: [{
|
|
928
|
+
type: Output
|
|
929
|
+
}], rangeValueChange: [{
|
|
930
|
+
type: Output
|
|
931
|
+
}], monthChange: [{
|
|
932
|
+
type: Output
|
|
933
|
+
}], dateClick: [{
|
|
934
|
+
type: Output
|
|
935
|
+
}], disabledDateClick: [{
|
|
936
|
+
type: Output
|
|
937
|
+
}], value: [{
|
|
938
|
+
type: Input
|
|
939
|
+
}], rangeValue: [{
|
|
940
|
+
type: Input
|
|
941
|
+
}], month: [{
|
|
540
942
|
type: Input
|
|
541
943
|
}] } });
|
|
542
944
|
|
|
@@ -1390,63 +1792,299 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
|
|
|
1390
1792
|
type: Output
|
|
1391
1793
|
}] } });
|
|
1392
1794
|
|
|
1393
|
-
class
|
|
1795
|
+
class PdmLabelComponent {
|
|
1394
1796
|
constructor() {
|
|
1395
|
-
this.
|
|
1797
|
+
this.forId = '';
|
|
1798
|
+
this.required = false;
|
|
1396
1799
|
this.className = '';
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
PdmLabelComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: PdmLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1803
|
+
PdmLabelComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: PdmLabelComponent, selector: "pdm-label", inputs: { forId: "forId", required: "required", className: "className" }, ngImport: i0, template: "<label\n [attr.for]=\"forId\"\n [ngClass]=\"['text-sm font-medium leading-none text-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70', className]\"\n>\n <ng-content></ng-content>\n <span *ngIf=\"required\" class=\"ml-1 text-destructive\">*</span>\n</label>\n", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1804
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: PdmLabelComponent, decorators: [{
|
|
1805
|
+
type: Component,
|
|
1806
|
+
args: [{ selector: 'pdm-label', changeDetection: ChangeDetectionStrategy.OnPush, template: "<label\n [attr.for]=\"forId\"\n [ngClass]=\"['text-sm font-medium leading-none text-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70', className]\"\n>\n <ng-content></ng-content>\n <span *ngIf=\"required\" class=\"ml-1 text-destructive\">*</span>\n</label>\n" }]
|
|
1807
|
+
}], propDecorators: { forId: [{
|
|
1808
|
+
type: Input
|
|
1809
|
+
}], required: [{
|
|
1810
|
+
type: Input
|
|
1811
|
+
}], className: [{
|
|
1812
|
+
type: Input
|
|
1813
|
+
}] } });
|
|
1814
|
+
|
|
1815
|
+
let nextDatePickerId = 0;
|
|
1816
|
+
class PdmDatePickerComponent {
|
|
1817
|
+
constructor(elementRef, cdr) {
|
|
1818
|
+
this.elementRef = elementRef;
|
|
1819
|
+
this.cdr = cdr;
|
|
1820
|
+
this._value = null;
|
|
1821
|
+
this._rangeValue = null;
|
|
1822
|
+
this._open = false;
|
|
1823
|
+
this.instanceId = `pdm-date-picker-${++nextDatePickerId}`;
|
|
1824
|
+
this.triggerFocused = false;
|
|
1825
|
+
this.id = '';
|
|
1826
|
+
this.variant = 'single';
|
|
1827
|
+
this.label = '';
|
|
1828
|
+
this.labelClassName = '';
|
|
1829
|
+
this.className = '';
|
|
1830
|
+
this.triggerClassName = '';
|
|
1831
|
+
this.panelClassName = '';
|
|
1832
|
+
this.placeholder = 'Pick a date';
|
|
1833
|
+
this.rangePlaceholder = 'Pick a date range';
|
|
1834
|
+
this.format = 'MMM d, yyyy';
|
|
1835
|
+
this.disabled = false;
|
|
1836
|
+
this.readonly = false;
|
|
1837
|
+
this.required = false;
|
|
1838
|
+
this.invalid = false;
|
|
1839
|
+
this.allowSameDayRange = true;
|
|
1840
|
+
this.closeOnSelect = true;
|
|
1841
|
+
this.minDate = null;
|
|
1842
|
+
this.maxDate = null;
|
|
1843
|
+
this.disabledDates = [];
|
|
1844
|
+
this.isDateDisabled = null;
|
|
1407
1845
|
this.valueChange = new EventEmitter();
|
|
1846
|
+
this.rangeValueChange = new EventEmitter();
|
|
1847
|
+
this.openChange = new EventEmitter();
|
|
1848
|
+
this.monthChange = new EventEmitter();
|
|
1408
1849
|
}
|
|
1409
|
-
|
|
1410
|
-
this.
|
|
1850
|
+
set open(value) {
|
|
1851
|
+
this._open = !!value;
|
|
1852
|
+
this.cdr.markForCheck();
|
|
1411
1853
|
}
|
|
1412
|
-
|
|
1413
|
-
this.
|
|
1854
|
+
get open() {
|
|
1855
|
+
return this._open;
|
|
1856
|
+
}
|
|
1857
|
+
set value(value) {
|
|
1858
|
+
this._value = this.normalizeDate(value);
|
|
1859
|
+
this.cdr.markForCheck();
|
|
1860
|
+
}
|
|
1861
|
+
get value() {
|
|
1862
|
+
return this._value;
|
|
1863
|
+
}
|
|
1864
|
+
set rangeValue(value) {
|
|
1865
|
+
this._rangeValue = value
|
|
1866
|
+
? {
|
|
1867
|
+
start: this.normalizeDate(value.start),
|
|
1868
|
+
end: this.normalizeDate(value.end)
|
|
1869
|
+
}
|
|
1870
|
+
: null;
|
|
1871
|
+
this.cdr.markForCheck();
|
|
1872
|
+
}
|
|
1873
|
+
get rangeValue() {
|
|
1874
|
+
return this._rangeValue;
|
|
1875
|
+
}
|
|
1876
|
+
get resolvedVariant() {
|
|
1877
|
+
return this.variant === 'range' ? 'range' : 'single';
|
|
1878
|
+
}
|
|
1879
|
+
get triggerId() {
|
|
1880
|
+
return this.id || `${this.instanceId}-trigger`;
|
|
1881
|
+
}
|
|
1882
|
+
get panelId() {
|
|
1883
|
+
return `${this.id || this.instanceId}-panel`;
|
|
1884
|
+
}
|
|
1885
|
+
get hasSingleValue() {
|
|
1886
|
+
return this.resolvedVariant === 'single' && !!this._value;
|
|
1887
|
+
}
|
|
1888
|
+
get hasRangeValue() {
|
|
1889
|
+
return this.resolvedVariant === 'range' && !!this._rangeValue?.start;
|
|
1890
|
+
}
|
|
1891
|
+
get displayText() {
|
|
1892
|
+
if (this.resolvedVariant === 'single') {
|
|
1893
|
+
return this._value ? this.formatDate(this._value) : this.placeholder;
|
|
1894
|
+
}
|
|
1895
|
+
const start = this._rangeValue?.start ?? null;
|
|
1896
|
+
const end = this._rangeValue?.end ?? null;
|
|
1897
|
+
if (!start) {
|
|
1898
|
+
return this.rangePlaceholder;
|
|
1899
|
+
}
|
|
1900
|
+
if (!end) {
|
|
1901
|
+
return `${this.formatDate(start)} -`;
|
|
1902
|
+
}
|
|
1903
|
+
return `${this.formatDate(start)} - ${this.formatDate(end)}`;
|
|
1904
|
+
}
|
|
1905
|
+
get textClasses() {
|
|
1906
|
+
const hasValue = this.resolvedVariant === 'single' ? this.hasSingleValue : this.hasRangeValue;
|
|
1907
|
+
return [
|
|
1908
|
+
'min-w-0 flex-1 truncate text-left text-sm leading-5',
|
|
1909
|
+
hasValue ? 'text-foreground' : 'text-muted-foreground'
|
|
1910
|
+
];
|
|
1911
|
+
}
|
|
1912
|
+
get rootClasses() {
|
|
1913
|
+
return [
|
|
1914
|
+
'grid gap-2',
|
|
1915
|
+
this.resolvedVariant === 'range' ? 'w-[280px]' : 'w-[197px]',
|
|
1916
|
+
this.className
|
|
1917
|
+
];
|
|
1918
|
+
}
|
|
1919
|
+
get triggerClasses() {
|
|
1920
|
+
const focusStyle = this.open || this.triggerFocused;
|
|
1921
|
+
return [
|
|
1922
|
+
'relative flex w-full items-center gap-2 overflow-hidden rounded-lg border px-3 py-[7.5px] text-left shadow-xs outline-none transition-colors',
|
|
1923
|
+
'min-h-[36px] disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50',
|
|
1924
|
+
focusStyle
|
|
1925
|
+
? 'bg-accent border-neutral-400 ring-3 ring-neutral-300'
|
|
1926
|
+
: 'bg-input border-input',
|
|
1927
|
+
this.invalid ? 'border-destructive ring-destructive/20' : '',
|
|
1928
|
+
this.triggerClassName
|
|
1929
|
+
];
|
|
1930
|
+
}
|
|
1931
|
+
get panelClasses() {
|
|
1932
|
+
return [
|
|
1933
|
+
'absolute left-0 top-full z-30 mt-2',
|
|
1934
|
+
this.panelClassName
|
|
1935
|
+
];
|
|
1936
|
+
}
|
|
1937
|
+
toggleOpen() {
|
|
1938
|
+
if (this.disabled || this.readonly) {
|
|
1939
|
+
return;
|
|
1940
|
+
}
|
|
1941
|
+
this.setOpen(!this.open);
|
|
1942
|
+
}
|
|
1943
|
+
onTriggerFocus() {
|
|
1944
|
+
this.triggerFocused = true;
|
|
1945
|
+
this.cdr.markForCheck();
|
|
1946
|
+
}
|
|
1947
|
+
onTriggerBlur() {
|
|
1948
|
+
this.triggerFocused = false;
|
|
1949
|
+
this.cdr.markForCheck();
|
|
1950
|
+
}
|
|
1951
|
+
onCalendarValueChange(value) {
|
|
1952
|
+
this._value = this.normalizeDate(value);
|
|
1953
|
+
this.valueChange.emit(this._value ? this.cloneDate(this._value) : null);
|
|
1954
|
+
if (this.closeOnSelect && this._value) {
|
|
1955
|
+
this.setOpen(false);
|
|
1956
|
+
}
|
|
1957
|
+
else {
|
|
1958
|
+
this.cdr.markForCheck();
|
|
1959
|
+
}
|
|
1414
1960
|
}
|
|
1415
|
-
|
|
1416
|
-
|
|
1961
|
+
onCalendarRangeValueChange(value) {
|
|
1962
|
+
this._rangeValue = value
|
|
1963
|
+
? {
|
|
1964
|
+
start: this.normalizeDate(value.start),
|
|
1965
|
+
end: this.normalizeDate(value.end)
|
|
1966
|
+
}
|
|
1967
|
+
: null;
|
|
1968
|
+
this.rangeValueChange.emit(this._rangeValue
|
|
1969
|
+
? {
|
|
1970
|
+
start: this._rangeValue.start ? this.cloneDate(this._rangeValue.start) : null,
|
|
1971
|
+
end: this._rangeValue.end ? this.cloneDate(this._rangeValue.end) : null
|
|
1972
|
+
}
|
|
1973
|
+
: null);
|
|
1974
|
+
if (this.closeOnSelect && this._rangeValue?.start && this._rangeValue?.end) {
|
|
1975
|
+
this.setOpen(false);
|
|
1976
|
+
return;
|
|
1977
|
+
}
|
|
1978
|
+
this.cdr.markForCheck();
|
|
1979
|
+
}
|
|
1980
|
+
onCalendarMonthChange(month) {
|
|
1981
|
+
this.monthChange.emit(this.cloneDate(month));
|
|
1982
|
+
}
|
|
1983
|
+
onEscape() {
|
|
1984
|
+
if (this.open) {
|
|
1985
|
+
this.setOpen(false);
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
onDocumentClick(event) {
|
|
1989
|
+
if (!this.open) {
|
|
1990
|
+
return;
|
|
1991
|
+
}
|
|
1992
|
+
const target = event.target;
|
|
1993
|
+
if (target && !this.elementRef.nativeElement.contains(target)) {
|
|
1994
|
+
this.setOpen(false);
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
setOpen(nextOpen) {
|
|
1998
|
+
if (this._open === nextOpen) {
|
|
1999
|
+
return;
|
|
2000
|
+
}
|
|
2001
|
+
this._open = nextOpen;
|
|
2002
|
+
this.openChange.emit(this._open);
|
|
2003
|
+
this.cdr.markForCheck();
|
|
2004
|
+
}
|
|
2005
|
+
formatDate(date) {
|
|
2006
|
+
try {
|
|
2007
|
+
return format(date, this.format || 'MMM d, yyyy');
|
|
2008
|
+
}
|
|
2009
|
+
catch {
|
|
2010
|
+
return format(date, 'MMM d, yyyy');
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
normalizeDate(value) {
|
|
2014
|
+
if (!(value instanceof Date) || Number.isNaN(value.getTime())) {
|
|
2015
|
+
return null;
|
|
2016
|
+
}
|
|
2017
|
+
return new Date(value.getFullYear(), value.getMonth(), value.getDate());
|
|
2018
|
+
}
|
|
2019
|
+
cloneDate(date) {
|
|
2020
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
1417
2021
|
}
|
|
1418
2022
|
}
|
|
1419
|
-
PdmDatePickerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: PdmDatePickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1420
|
-
PdmDatePickerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: PdmDatePickerComponent, selector: "pdm-date-picker", inputs: { variant: "variant", className: "className",
|
|
2023
|
+
PdmDatePickerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: PdmDatePickerComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
2024
|
+
PdmDatePickerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: PdmDatePickerComponent, selector: "pdm-date-picker", inputs: { id: "id", variant: "variant", label: "label", labelClassName: "labelClassName", className: "className", triggerClassName: "triggerClassName", panelClassName: "panelClassName", placeholder: "placeholder", rangePlaceholder: "rangePlaceholder", format: "format", disabled: "disabled", readonly: "readonly", required: "required", invalid: "invalid", allowSameDayRange: "allowSameDayRange", closeOnSelect: "closeOnSelect", minDate: "minDate", maxDate: "maxDate", disabledDates: "disabledDates", isDateDisabled: "isDateDisabled", open: "open", value: "value", rangeValue: "rangeValue" }, outputs: { valueChange: "valueChange", rangeValueChange: "rangeValueChange", openChange: "openChange", monthChange: "monthChange" }, host: { listeners: { "document:keydown.escape": "onEscape()", "document:click": "onDocumentClick($event)" } }, ngImport: i0, template: "<div [ngClass]=\"rootClasses\">\n <pdm-label *ngIf=\"label\" [forId]=\"triggerId\" [required]=\"required\" [className]=\"labelClassName\">\n {{ label }}\n </pdm-label>\n\n <div class=\"relative inline-block w-full\">\n <button\n type=\"button\"\n [id]=\"triggerId\"\n [disabled]=\"disabled\"\n [attr.aria-expanded]=\"open\"\n [attr.aria-controls]=\"panelId\"\n [attr.aria-haspopup]=\"'dialog'\"\n [attr.aria-invalid]=\"invalid\"\n [ngClass]=\"triggerClasses\"\n [attr.title]=\"displayText\"\n (click)=\"toggleOpen()\"\n (focus)=\"onTriggerFocus()\"\n (blur)=\"onTriggerBlur()\"\n >\n <span class=\"flex h-5 w-5 shrink-0 items-center justify-center p-0.5 text-muted-foreground\" aria-hidden=\"true\">\n <svg viewBox=\"0 0 24 24\" class=\"h-4 w-4\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\">\n <path d=\"M8 2v4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path>\n <path d=\"M16 2v4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path>\n <rect x=\"3\" y=\"4.5\" width=\"18\" height=\"16.5\" rx=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></rect>\n <path d=\"M3 9.5h18\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path>\n </svg>\n </span>\n\n <span [ngClass]=\"textClasses\">{{ displayText }}</span>\n </button>\n\n <div *ngIf=\"open\" [id]=\"panelId\" [ngClass]=\"panelClasses\" role=\"dialog\" [attr.aria-labelledby]=\"label ? triggerId : null\">\n <pdm-calendar\n [variant]=\"resolvedVariant\"\n [value]=\"value\"\n [rangeValue]=\"rangeValue\"\n [readonly]=\"readonly\"\n [allowSameDayRange]=\"allowSameDayRange\"\n [minDate]=\"minDate\"\n [maxDate]=\"maxDate\"\n [disabledDates]=\"disabledDates\"\n [isDateDisabled]=\"isDateDisabled\"\n (valueChange)=\"onCalendarValueChange($event)\"\n (rangeValueChange)=\"onCalendarRangeValueChange($event)\"\n (monthChange)=\"onCalendarMonthChange($event)\"\n ></pdm-calendar>\n </div>\n </div>\n</div>\n", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: PdmCalendarComponent, selector: "pdm-calendar", inputs: ["variant", "className", "disabledDates", "minDate", "maxDate", "isDateDisabled", "allowSameDayRange", "readonly", "value", "rangeValue", "month"], outputs: ["valueChange", "rangeValueChange", "monthChange", "dateClick", "disabledDateClick"] }, { kind: "component", type: PdmLabelComponent, selector: "pdm-label", inputs: ["forId", "required", "className"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1421
2025
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: PdmDatePickerComponent, decorators: [{
|
|
1422
2026
|
type: Component,
|
|
1423
|
-
args: [{ selector: 'pdm-date-picker', changeDetection: ChangeDetectionStrategy.OnPush, template: "<
|
|
1424
|
-
}], propDecorators: {
|
|
2027
|
+
args: [{ selector: 'pdm-date-picker', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div [ngClass]=\"rootClasses\">\n <pdm-label *ngIf=\"label\" [forId]=\"triggerId\" [required]=\"required\" [className]=\"labelClassName\">\n {{ label }}\n </pdm-label>\n\n <div class=\"relative inline-block w-full\">\n <button\n type=\"button\"\n [id]=\"triggerId\"\n [disabled]=\"disabled\"\n [attr.aria-expanded]=\"open\"\n [attr.aria-controls]=\"panelId\"\n [attr.aria-haspopup]=\"'dialog'\"\n [attr.aria-invalid]=\"invalid\"\n [ngClass]=\"triggerClasses\"\n [attr.title]=\"displayText\"\n (click)=\"toggleOpen()\"\n (focus)=\"onTriggerFocus()\"\n (blur)=\"onTriggerBlur()\"\n >\n <span class=\"flex h-5 w-5 shrink-0 items-center justify-center p-0.5 text-muted-foreground\" aria-hidden=\"true\">\n <svg viewBox=\"0 0 24 24\" class=\"h-4 w-4\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\">\n <path d=\"M8 2v4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path>\n <path d=\"M16 2v4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path>\n <rect x=\"3\" y=\"4.5\" width=\"18\" height=\"16.5\" rx=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></rect>\n <path d=\"M3 9.5h18\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path>\n </svg>\n </span>\n\n <span [ngClass]=\"textClasses\">{{ displayText }}</span>\n </button>\n\n <div *ngIf=\"open\" [id]=\"panelId\" [ngClass]=\"panelClasses\" role=\"dialog\" [attr.aria-labelledby]=\"label ? triggerId : null\">\n <pdm-calendar\n [variant]=\"resolvedVariant\"\n [value]=\"value\"\n [rangeValue]=\"rangeValue\"\n [readonly]=\"readonly\"\n [allowSameDayRange]=\"allowSameDayRange\"\n [minDate]=\"minDate\"\n [maxDate]=\"maxDate\"\n [disabledDates]=\"disabledDates\"\n [isDateDisabled]=\"isDateDisabled\"\n (valueChange)=\"onCalendarValueChange($event)\"\n (rangeValueChange)=\"onCalendarRangeValueChange($event)\"\n (monthChange)=\"onCalendarMonthChange($event)\"\n ></pdm-calendar>\n </div>\n </div>\n</div>\n" }]
|
|
2028
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { id: [{
|
|
2029
|
+
type: Input
|
|
2030
|
+
}], variant: [{
|
|
2031
|
+
type: Input
|
|
2032
|
+
}], label: [{
|
|
2033
|
+
type: Input
|
|
2034
|
+
}], labelClassName: [{
|
|
1425
2035
|
type: Input
|
|
1426
2036
|
}], className: [{
|
|
1427
2037
|
type: Input
|
|
1428
|
-
}],
|
|
2038
|
+
}], triggerClassName: [{
|
|
1429
2039
|
type: Input
|
|
1430
|
-
}],
|
|
2040
|
+
}], panelClassName: [{
|
|
1431
2041
|
type: Input
|
|
1432
|
-
}],
|
|
2042
|
+
}], placeholder: [{
|
|
1433
2043
|
type: Input
|
|
1434
|
-
}],
|
|
2044
|
+
}], rangePlaceholder: [{
|
|
1435
2045
|
type: Input
|
|
1436
|
-
}],
|
|
2046
|
+
}], format: [{
|
|
1437
2047
|
type: Input
|
|
1438
|
-
}],
|
|
2048
|
+
}], disabled: [{
|
|
1439
2049
|
type: Input
|
|
1440
|
-
}],
|
|
2050
|
+
}], readonly: [{
|
|
2051
|
+
type: Input
|
|
2052
|
+
}], required: [{
|
|
1441
2053
|
type: Input
|
|
1442
|
-
}],
|
|
2054
|
+
}], invalid: [{
|
|
2055
|
+
type: Input
|
|
2056
|
+
}], allowSameDayRange: [{
|
|
2057
|
+
type: Input
|
|
2058
|
+
}], closeOnSelect: [{
|
|
1443
2059
|
type: Input
|
|
1444
|
-
}],
|
|
2060
|
+
}], minDate: [{
|
|
1445
2061
|
type: Input
|
|
2062
|
+
}], maxDate: [{
|
|
2063
|
+
type: Input
|
|
2064
|
+
}], disabledDates: [{
|
|
2065
|
+
type: Input
|
|
2066
|
+
}], isDateDisabled: [{
|
|
2067
|
+
type: Input
|
|
2068
|
+
}], valueChange: [{
|
|
2069
|
+
type: Output
|
|
2070
|
+
}], rangeValueChange: [{
|
|
2071
|
+
type: Output
|
|
1446
2072
|
}], openChange: [{
|
|
1447
2073
|
type: Output
|
|
1448
|
-
}],
|
|
2074
|
+
}], monthChange: [{
|
|
1449
2075
|
type: Output
|
|
2076
|
+
}], open: [{
|
|
2077
|
+
type: Input
|
|
2078
|
+
}], value: [{
|
|
2079
|
+
type: Input
|
|
2080
|
+
}], rangeValue: [{
|
|
2081
|
+
type: Input
|
|
2082
|
+
}], onEscape: [{
|
|
2083
|
+
type: HostListener,
|
|
2084
|
+
args: ['document:keydown.escape']
|
|
2085
|
+
}], onDocumentClick: [{
|
|
2086
|
+
type: HostListener,
|
|
2087
|
+
args: ['document:click', ['$event']]
|
|
1450
2088
|
}] } });
|
|
1451
2089
|
|
|
1452
2090
|
class PdmDialogComponent {
|
|
@@ -2267,26 +2905,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
|
|
|
2267
2905
|
type: Input
|
|
2268
2906
|
}] } });
|
|
2269
2907
|
|
|
2270
|
-
class PdmLabelComponent {
|
|
2271
|
-
constructor() {
|
|
2272
|
-
this.forId = '';
|
|
2273
|
-
this.required = false;
|
|
2274
|
-
this.className = '';
|
|
2275
|
-
}
|
|
2276
|
-
}
|
|
2277
|
-
PdmLabelComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: PdmLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2278
|
-
PdmLabelComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: PdmLabelComponent, selector: "pdm-label", inputs: { forId: "forId", required: "required", className: "className" }, ngImport: i0, template: "<label\n [attr.for]=\"forId\"\n [ngClass]=\"['text-sm font-medium leading-none text-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70', className]\"\n>\n <ng-content></ng-content>\n <span *ngIf=\"required\" class=\"ml-1 text-destructive\">*</span>\n</label>\n", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2279
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: PdmLabelComponent, decorators: [{
|
|
2280
|
-
type: Component,
|
|
2281
|
-
args: [{ selector: 'pdm-label', changeDetection: ChangeDetectionStrategy.OnPush, template: "<label\n [attr.for]=\"forId\"\n [ngClass]=\"['text-sm font-medium leading-none text-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70', className]\"\n>\n <ng-content></ng-content>\n <span *ngIf=\"required\" class=\"ml-1 text-destructive\">*</span>\n</label>\n" }]
|
|
2282
|
-
}], propDecorators: { forId: [{
|
|
2283
|
-
type: Input
|
|
2284
|
-
}], required: [{
|
|
2285
|
-
type: Input
|
|
2286
|
-
}], className: [{
|
|
2287
|
-
type: Input
|
|
2288
|
-
}] } });
|
|
2289
|
-
|
|
2290
2908
|
class PdmMenubarComponent {
|
|
2291
2909
|
constructor() {
|
|
2292
2910
|
this.menus = [];
|