@imihai/angular-datetime-picker 21.0.2 → 22.0.0
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/.browserslistrc +9 -0
- package/.editorconfig +13 -0
- package/.eslintrc.js +208 -0
- package/.github/workflows/ci_test.yml +35 -0
- package/.prettierrc +2 -0
- package/.travis.yml +16 -0
- package/angular.json +221 -0
- package/e2e/protractor.conf.js +28 -0
- package/e2e/src/app.e2e-spec.ts +14 -0
- package/e2e/src/app.po.ts +11 -0
- package/e2e/tsconfig.e2e.json +13 -0
- package/package.json +77 -33
- package/projects/picker/karma.conf.js +62 -0
- package/projects/picker/ng-package.json +7 -0
- package/projects/picker/package.json +23 -0
- package/projects/picker/src/lib/date-time/adapter/date-time-adapter.class.ts +313 -0
- package/projects/picker/src/lib/date-time/adapter/date-time-format.class.ts +18 -0
- package/projects/picker/src/lib/date-time/adapter/luxon-date-time-adapter.class.ts +307 -0
- package/projects/picker/src/lib/date-time/adapter/luxon-date-time-format.class.ts +11 -0
- package/projects/picker/src/lib/date-time/adapter/luxon-date-time.module.ts +31 -0
- package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time-adapter.class.ts +356 -0
- package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time-format.class.ts +14 -0
- package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time.module.ts +26 -0
- package/projects/picker/src/lib/date-time/calendar-body.component.html +38 -0
- package/projects/picker/src/lib/date-time/calendar-body.component.scss +0 -0
- package/projects/picker/src/lib/date-time/calendar-body.component.spec.ts +120 -0
- package/projects/picker/src/lib/date-time/calendar-body.component.ts +190 -0
- package/projects/picker/src/lib/date-time/calendar-month-view.component.html +47 -0
- package/projects/picker/src/lib/date-time/calendar-month-view.component.scss +16 -0
- package/projects/picker/src/lib/date-time/calendar-month-view.component.spec.ts +394 -0
- package/projects/picker/src/lib/date-time/calendar-month-view.component.ts +705 -0
- package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.html +44 -0
- package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.scss +0 -0
- package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.spec.ts +343 -0
- package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.ts +465 -0
- package/projects/picker/src/lib/date-time/calendar-year-view.component.html +16 -0
- package/projects/picker/src/lib/date-time/calendar-year-view.component.scss +0 -0
- package/projects/picker/src/lib/date-time/calendar-year-view.component.spec.ts +381 -0
- package/projects/picker/src/lib/date-time/calendar-year-view.component.ts +549 -0
- package/projects/picker/src/lib/date-time/calendar.component.html +169 -0
- package/projects/picker/src/lib/date-time/calendar.component.scss +0 -0
- package/projects/picker/src/lib/date-time/calendar.component.spec.ts +592 -0
- package/projects/picker/src/lib/date-time/calendar.component.ts +496 -0
- package/projects/picker/src/lib/date-time/date-time-inline.component.html +1 -0
- package/projects/picker/src/lib/date-time/date-time-inline.component.scss +4 -0
- package/projects/picker/src/lib/date-time/date-time-inline.component.ts +365 -0
- package/projects/picker/src/lib/date-time/date-time-picker-animation-event.ts +4 -0
- package/projects/picker/src/lib/date-time/date-time-picker-container.component.html +126 -0
- package/projects/picker/src/lib/date-time/date-time-picker-container.component.scss +0 -0
- package/projects/picker/src/lib/date-time/date-time-picker-container.component.ts +631 -0
- package/projects/picker/src/lib/date-time/date-time-picker-input.directive.ts +851 -0
- package/projects/picker/src/lib/date-time/date-time-picker-intl.service.ts +76 -0
- package/projects/picker/src/lib/date-time/date-time-picker-trigger.directive.ts +88 -0
- package/projects/picker/src/lib/date-time/date-time-picker.component.html +0 -0
- package/projects/picker/src/lib/date-time/date-time-picker.component.scss +0 -0
- package/projects/picker/src/lib/date-time/date-time-picker.component.spec.ts +2648 -0
- package/projects/picker/src/lib/date-time/date-time-picker.component.ts +731 -0
- package/projects/picker/src/lib/date-time/date-time.class.ts +256 -0
- package/projects/picker/src/lib/date-time/date-time.module.ts +61 -0
- package/projects/picker/src/lib/date-time/numberedFixLen.pipe.ts +28 -0
- package/projects/picker/src/lib/date-time/options-provider.ts +44 -0
- package/projects/picker/src/lib/date-time/timer-box.component.html +79 -0
- package/projects/picker/src/lib/date-time/timer-box.component.scss +0 -0
- package/projects/picker/src/lib/date-time/timer-box.component.ts +175 -0
- package/projects/picker/src/lib/date-time/timer.component.html +58 -0
- package/projects/picker/src/lib/date-time/timer.component.scss +0 -0
- package/projects/picker/src/lib/date-time/timer.component.spec.ts +399 -0
- package/projects/picker/src/lib/date-time/timer.component.ts +371 -0
- package/projects/picker/src/lib/dialog/dialog-config.class.ts +220 -0
- package/projects/picker/src/lib/dialog/dialog-container.component.html +1 -0
- package/projects/picker/src/lib/dialog/dialog-container.component.scss +0 -0
- package/projects/picker/src/lib/dialog/dialog-container.component.ts +231 -0
- package/projects/picker/src/lib/dialog/dialog-ref.class.ts +178 -0
- package/projects/picker/src/lib/dialog/dialog.module.ts +25 -0
- package/projects/picker/src/lib/dialog/dialog.service.ts +353 -0
- package/projects/picker/src/lib/utils/array.utils.ts +12 -0
- package/projects/picker/src/lib/utils/constants.ts +59 -0
- package/projects/picker/src/lib/utils/date.utils.ts +97 -0
- package/projects/picker/src/lib/utils/index.ts +5 -0
- package/projects/picker/src/lib/utils/object.utils.ts +29 -0
- package/projects/picker/src/public_api.ts +56 -0
- package/projects/picker/src/sass/picker.scss +743 -0
- package/projects/picker/src/test-helpers.ts +125 -0
- package/projects/picker/src/test.ts +52 -0
- package/projects/picker/tsconfig.lib.json +19 -0
- package/projects/picker/tsconfig.lib.prod.json +7 -0
- package/projects/picker/tsconfig.spec.json +17 -0
- package/projects/picker/tslint.json +8 -0
- package/src/app/app.component.html +77 -0
- package/src/app/app.component.scss +32 -0
- package/src/app/app.component.spec.ts +16 -0
- package/src/app/app.component.ts +35 -0
- package/src/assets/.gitkeep +0 -0
- package/src/environments/environment.prod.ts +3 -0
- package/src/environments/environment.ts +16 -0
- package/src/favicon.ico +0 -0
- package/src/index.html +14 -0
- package/src/karma.conf.js +31 -0
- package/src/main.ts +16 -0
- package/src/polyfills.ts +53 -0
- package/src/styles.scss +7 -0
- package/src/test.ts +50 -0
- package/src/tsconfig.app.json +16 -0
- package/src/tsconfig.spec.json +18 -0
- package/src/tslint.json +17 -0
- package/tsconfig.base.json +31 -0
- package/tsconfig.json +30 -0
- package/tslint.json +130 -0
- package/assets/style/picker.min.css +0 -1
- package/fesm2022/imihai-angular-datetime-picker.mjs +0 -5845
- package/fesm2022/imihai-angular-datetime-picker.mjs.map +0 -1
- package/imihai-angular-datetime-picker-21.0.2.tgz +0 -0
- package/types/imihai-angular-datetime-picker.d.ts +0 -2193
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* unix-timestamp-date-time.module
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {NgModule} from '@angular/core';
|
|
6
|
+
import {PlatformModule} from '@angular/cdk/platform';
|
|
7
|
+
import {DateTimeAdapter} from '../date-time-adapter.class';
|
|
8
|
+
import {OWL_DATE_TIME_FORMATS} from '../date-time-format.class';
|
|
9
|
+
import {UnixTimestampDateTimeAdapter} from './unix-timestamp-date-time-adapter.class';
|
|
10
|
+
import {OWL_UNIX_TIMESTAMP_DATE_TIME_FORMATS} from './unix-timestamp-date-time-format.class';
|
|
11
|
+
|
|
12
|
+
@NgModule({
|
|
13
|
+
imports: [PlatformModule],
|
|
14
|
+
providers: [
|
|
15
|
+
{provide: DateTimeAdapter, useClass: UnixTimestampDateTimeAdapter},
|
|
16
|
+
],
|
|
17
|
+
})
|
|
18
|
+
export class UnixTimestampDateTimeModule {
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@NgModule({
|
|
22
|
+
imports: [UnixTimestampDateTimeModule],
|
|
23
|
+
providers: [{provide: OWL_DATE_TIME_FORMATS, useValue: OWL_UNIX_TIMESTAMP_DATE_TIME_FORMATS}],
|
|
24
|
+
})
|
|
25
|
+
export class OwlUnixTimestampDateTimeModule {
|
|
26
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
@for (row of rows; track $index; let rowIndex = $index) {
|
|
2
|
+
<tr role="row">
|
|
3
|
+
@for (item of row; track $index; let colIndex = $index) {
|
|
4
|
+
<td
|
|
5
|
+
class="owl-dt-calendar-cell {{ item.cellClass }}"
|
|
6
|
+
[tabindex]="isActiveCell(rowIndex, colIndex) ? 0 : -1"
|
|
7
|
+
[class.owl-dt-calendar-cell-active]="
|
|
8
|
+
isActiveCell(rowIndex, colIndex)
|
|
9
|
+
"
|
|
10
|
+
[class.owl-dt-calendar-cell-disabled]="!item.enabled"
|
|
11
|
+
[class.owl-dt-calendar-cell-in-range]="isInRange(item.value)"
|
|
12
|
+
[class.owl-dt-calendar-cell-range-from]="
|
|
13
|
+
isRangeFrom(item.value)
|
|
14
|
+
"
|
|
15
|
+
[class.owl-dt-calendar-cell-range-to]="isRangeTo(item.value)"
|
|
16
|
+
[attr.aria-label]="item.ariaLabel"
|
|
17
|
+
[attr.aria-disabled]="!item.enabled || null"
|
|
18
|
+
[attr.aria-current]="item.value === todayValue ? 'date' : null"
|
|
19
|
+
[attr.aria-selected]="isSelected(item.value)"
|
|
20
|
+
[style.width.%]="100 / numCols"
|
|
21
|
+
[style.paddingTop.%]="(50 * cellRatio) / numCols"
|
|
22
|
+
[style.paddingBottom.%]="(50 * cellRatio) / numCols"
|
|
23
|
+
(click)="selectCell(item)"
|
|
24
|
+
>
|
|
25
|
+
<span
|
|
26
|
+
class="owl-dt-calendar-cell-content"
|
|
27
|
+
[ngClass]="{
|
|
28
|
+
'owl-dt-calendar-cell-out': item.out,
|
|
29
|
+
'owl-dt-calendar-cell-today': item.value === todayValue,
|
|
30
|
+
'owl-dt-calendar-cell-selected': isSelected(item.value),
|
|
31
|
+
}"
|
|
32
|
+
>
|
|
33
|
+
{{ item.displayValue }}
|
|
34
|
+
</span>
|
|
35
|
+
</td>
|
|
36
|
+
}
|
|
37
|
+
</tr>
|
|
38
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* calendar-body.component.spec
|
|
3
|
+
*/
|
|
4
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
5
|
+
import { CalendarCell, OwlCalendarBodyComponent } from './calendar-body.component';
|
|
6
|
+
import { Component } from '@angular/core';
|
|
7
|
+
import { By } from '@angular/platform-browser';
|
|
8
|
+
|
|
9
|
+
describe('OwlCalendarBodyComponent', () => {
|
|
10
|
+
beforeEach((() => {
|
|
11
|
+
TestBed.configureTestingModule({
|
|
12
|
+
declarations: [
|
|
13
|
+
OwlCalendarBodyComponent,
|
|
14
|
+
|
|
15
|
+
// Test components
|
|
16
|
+
StandardCalendarBodyComponent,
|
|
17
|
+
],
|
|
18
|
+
}).compileComponents();
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
describe('standard CalendarBodyComponent', () => {
|
|
22
|
+
let fixture: ComponentFixture<StandardCalendarBodyComponent>;
|
|
23
|
+
let testComponent: StandardCalendarBodyComponent;
|
|
24
|
+
let calendarBodyNativeElement: Element;
|
|
25
|
+
let rowEls: NodeListOf<Element>;
|
|
26
|
+
let cellEls: NodeListOf<Element>;
|
|
27
|
+
|
|
28
|
+
const refreshElementLists = () => {
|
|
29
|
+
rowEls = calendarBodyNativeElement.querySelectorAll('tr');
|
|
30
|
+
cellEls = calendarBodyNativeElement.querySelectorAll('.owl-dt-calendar-cell');
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
beforeEach(() => {
|
|
34
|
+
fixture = TestBed.createComponent(StandardCalendarBodyComponent);
|
|
35
|
+
fixture.detectChanges();
|
|
36
|
+
|
|
37
|
+
const calendarBodyDebugElement = fixture.debugElement.query(By.directive(OwlCalendarBodyComponent));
|
|
38
|
+
calendarBodyNativeElement = calendarBodyDebugElement.nativeElement;
|
|
39
|
+
testComponent = fixture.componentInstance;
|
|
40
|
+
|
|
41
|
+
refreshElementLists();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should create body', () => {
|
|
45
|
+
expect(rowEls.length).toBe(2);
|
|
46
|
+
expect(cellEls.length).toBe(14);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should highlight today', () => {
|
|
50
|
+
const todayCell = calendarBodyNativeElement.querySelector('.owl-dt-calendar-cell-today');
|
|
51
|
+
expect(todayCell).not.toBeNull();
|
|
52
|
+
expect(todayCell.innerHTML.trim()).toBe('3');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should highlight selected', () => {
|
|
56
|
+
const selectedCell = calendarBodyNativeElement.querySelector('.owl-dt-calendar-cell-selected');
|
|
57
|
+
expect(selectedCell).not.toBeNull();
|
|
58
|
+
expect(selectedCell.innerHTML.trim()).toBe('4');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('cell should be selected on click', () => {
|
|
62
|
+
spyOn(testComponent, 'handleSelect');
|
|
63
|
+
expect(testComponent.handleSelect).not.toHaveBeenCalled();
|
|
64
|
+
const todayElement =
|
|
65
|
+
calendarBodyNativeElement.querySelector('.owl-dt-calendar-cell-today') as HTMLElement;
|
|
66
|
+
todayElement.click();
|
|
67
|
+
fixture.detectChanges();
|
|
68
|
+
|
|
69
|
+
expect(testComponent.handleSelect).toHaveBeenCalled();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('should mark active date', () => {
|
|
73
|
+
expect((cellEls[10] as HTMLElement).innerText.trim()).toBe('11');
|
|
74
|
+
expect(cellEls[10].classList).toContain('owl-dt-calendar-cell-active');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should have aria-current set for today', () => {
|
|
78
|
+
const currentCells = calendarBodyNativeElement.querySelectorAll('.owl-dt-calendar-cell[aria-current]');
|
|
79
|
+
expect(currentCells.length).toBe(1);
|
|
80
|
+
const todayCell = calendarBodyNativeElement.querySelector('.owl-dt-calendar-cell-today');
|
|
81
|
+
expect(currentCells[0].getAttribute('aria-current')).toBe('date');
|
|
82
|
+
expect(currentCells[0].firstChild).toBe(todayCell);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('should have aria-selected set on selected cells', () => {
|
|
86
|
+
const calendarCells = calendarBodyNativeElement.querySelectorAll('.owl-dt-calendar-cell');
|
|
87
|
+
const selectedCells = calendarBodyNativeElement.querySelectorAll('.owl-dt-calendar-cell[aria-selected=true]');
|
|
88
|
+
const nonSelectedCells = calendarBodyNativeElement.querySelectorAll('.owl-dt-calendar-cell[aria-selected=false]');
|
|
89
|
+
expect(nonSelectedCells.length).toBe(calendarCells.length - selectedCells.length);
|
|
90
|
+
const selectedCell = calendarBodyNativeElement.querySelector('.owl-dt-calendar-cell-selected');
|
|
91
|
+
expect(selectedCells[0].firstChild).toBe(selectedCell);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
@Component({
|
|
97
|
+
standalone: false,
|
|
98
|
+
template: `
|
|
99
|
+
<table owl-date-time-calendar-body
|
|
100
|
+
[rows]="rows"
|
|
101
|
+
[todayValue]="todayValue"
|
|
102
|
+
[selectedValues]="selectedValues"
|
|
103
|
+
[selectMode]="'single'"
|
|
104
|
+
[activeCell]="activeCell"
|
|
105
|
+
(select)="handleSelect()">
|
|
106
|
+
</table>`,
|
|
107
|
+
})
|
|
108
|
+
class StandardCalendarBodyComponent {
|
|
109
|
+
rows = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14]].map(r => r.map(createCell));
|
|
110
|
+
todayValue = 3;
|
|
111
|
+
selectedValues = [4];
|
|
112
|
+
activeCell = 10;
|
|
113
|
+
|
|
114
|
+
handleSelect() {
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function createCell( value: number ) {
|
|
119
|
+
return new CalendarCell(value, `${value}`, `${value}-label`, true);
|
|
120
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* calendar-body.component
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
ChangeDetectionStrategy,
|
|
7
|
+
Component,
|
|
8
|
+
ElementRef,
|
|
9
|
+
EventEmitter,
|
|
10
|
+
Input,
|
|
11
|
+
NgZone,
|
|
12
|
+
OnInit,
|
|
13
|
+
Output
|
|
14
|
+
} from '@angular/core';
|
|
15
|
+
import { SelectMode } from './date-time.class';
|
|
16
|
+
import { take } from 'rxjs/operators';
|
|
17
|
+
|
|
18
|
+
export class CalendarCell {
|
|
19
|
+
constructor(
|
|
20
|
+
public value: number,
|
|
21
|
+
public displayValue: string,
|
|
22
|
+
public ariaLabel: string,
|
|
23
|
+
public enabled: boolean,
|
|
24
|
+
public out: boolean = false,
|
|
25
|
+
public cellClass: string = ''
|
|
26
|
+
) {}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Component({
|
|
30
|
+
selector: '[owl-date-time-calendar-body]',
|
|
31
|
+
exportAs: 'owlDateTimeCalendarBody',
|
|
32
|
+
templateUrl: './calendar-body.component.html',
|
|
33
|
+
styleUrls: ['./calendar-body.component.scss'],
|
|
34
|
+
host: {
|
|
35
|
+
'[class.owl-dt-calendar-body]': 'owlDTCalendarBodyClass'
|
|
36
|
+
},
|
|
37
|
+
preserveWhitespaces: false,
|
|
38
|
+
standalone: false,
|
|
39
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
40
|
+
})
|
|
41
|
+
export class OwlCalendarBodyComponent implements OnInit {
|
|
42
|
+
/**
|
|
43
|
+
* The cell number of the active cell in the table.
|
|
44
|
+
*/
|
|
45
|
+
@Input()
|
|
46
|
+
activeCell = 0;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The cells to display in the table.
|
|
50
|
+
* */
|
|
51
|
+
@Input()
|
|
52
|
+
rows: CalendarCell[][];
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The number of columns in the table.
|
|
56
|
+
* */
|
|
57
|
+
@Input()
|
|
58
|
+
numCols = 7;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The ratio (width / height) to use for the cells in the table.
|
|
62
|
+
*/
|
|
63
|
+
@Input()
|
|
64
|
+
cellRatio = 1;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The value in the table that corresponds to today.
|
|
68
|
+
* */
|
|
69
|
+
@Input()
|
|
70
|
+
todayValue: number;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The value in the table that is currently selected.
|
|
74
|
+
* */
|
|
75
|
+
@Input()
|
|
76
|
+
selectedValues: number[];
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Current picker select mode
|
|
80
|
+
*/
|
|
81
|
+
@Input()
|
|
82
|
+
selectMode: SelectMode;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Emit when a calendar cell is selected
|
|
86
|
+
* */
|
|
87
|
+
@Output()
|
|
88
|
+
public readonly select = new EventEmitter<CalendarCell>();
|
|
89
|
+
|
|
90
|
+
get owlDTCalendarBodyClass(): boolean {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
get isInSingleMode(): boolean {
|
|
95
|
+
return this.selectMode === 'single';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
get isInRangeMode(): boolean {
|
|
99
|
+
return (
|
|
100
|
+
this.selectMode === 'range' ||
|
|
101
|
+
this.selectMode === 'rangeFrom' ||
|
|
102
|
+
this.selectMode === 'rangeTo'
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
constructor(private elmRef: ElementRef, private ngZone: NgZone) {}
|
|
107
|
+
|
|
108
|
+
public ngOnInit() {}
|
|
109
|
+
|
|
110
|
+
public selectCell(cell: CalendarCell): void {
|
|
111
|
+
this.select.emit(cell);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public isActiveCell(rowIndex: number, colIndex: number): boolean {
|
|
115
|
+
const cellNumber = rowIndex * this.numCols + colIndex;
|
|
116
|
+
return cellNumber === this.activeCell;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Check if the cell is selected
|
|
121
|
+
*/
|
|
122
|
+
public isSelected(value: number): boolean {
|
|
123
|
+
if (!this.selectedValues || this.selectedValues.length === 0) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (this.isInSingleMode) {
|
|
128
|
+
return value === this.selectedValues[0];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (this.isInRangeMode) {
|
|
132
|
+
const fromValue = this.selectedValues[0];
|
|
133
|
+
const toValue = this.selectedValues[1];
|
|
134
|
+
|
|
135
|
+
return value === fromValue || value === toValue;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Check if the cell in the range
|
|
141
|
+
* */
|
|
142
|
+
public isInRange(value: number): boolean {
|
|
143
|
+
if (this.isInRangeMode) {
|
|
144
|
+
const fromValue = this.selectedValues[0];
|
|
145
|
+
const toValue = this.selectedValues[1];
|
|
146
|
+
|
|
147
|
+
if (fromValue !== null && toValue !== null) {
|
|
148
|
+
return value >= fromValue && value <= toValue;
|
|
149
|
+
} else {
|
|
150
|
+
return value === fromValue || value === toValue;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Check if the cell is the range from
|
|
157
|
+
* */
|
|
158
|
+
public isRangeFrom(value: number): boolean {
|
|
159
|
+
if (this.isInRangeMode) {
|
|
160
|
+
const fromValue = this.selectedValues[0];
|
|
161
|
+
return fromValue !== null && value === fromValue;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Check if the cell is the range to
|
|
167
|
+
* */
|
|
168
|
+
public isRangeTo(value: number): boolean {
|
|
169
|
+
if (this.isInRangeMode) {
|
|
170
|
+
const toValue = this.selectedValues[1];
|
|
171
|
+
return toValue !== null && value === toValue;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Focus to a active cell
|
|
177
|
+
* */
|
|
178
|
+
public focusActiveCell(): void {
|
|
179
|
+
this.ngZone.runOutsideAngular(() => {
|
|
180
|
+
this.ngZone.onStable
|
|
181
|
+
.asObservable()
|
|
182
|
+
.pipe(take(1))
|
|
183
|
+
.subscribe(() => {
|
|
184
|
+
this.elmRef.nativeElement
|
|
185
|
+
.querySelector('.owl-dt-calendar-cell-active')
|
|
186
|
+
.focus();
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
@if (showCalendarWeeks) {
|
|
2
|
+
<ul class="week-number">
|
|
3
|
+
@for (week of weekNumbers; track week) {
|
|
4
|
+
<li>
|
|
5
|
+
<span>{{ week }}</span>
|
|
6
|
+
</li>
|
|
7
|
+
}
|
|
8
|
+
</ul>
|
|
9
|
+
}
|
|
10
|
+
<table
|
|
11
|
+
class="owl-dt-calendar-table owl-dt-calendar-month-table"
|
|
12
|
+
[ngClass]="{ 'owl-calendar-weeks': showCalendarWeeks }"
|
|
13
|
+
[class.owl-dt-calendar-only-current-month]="hideOtherMonths"
|
|
14
|
+
>
|
|
15
|
+
<thead class="owl-dt-calendar-header">
|
|
16
|
+
<tr class="owl-dt-weekdays">
|
|
17
|
+
@for (weekday of weekdays; track weekday.short) {
|
|
18
|
+
<th
|
|
19
|
+
[attr.aria-label]="weekday.long"
|
|
20
|
+
class="owl-dt-weekday"
|
|
21
|
+
scope="col"
|
|
22
|
+
>
|
|
23
|
+
<span>{{ weekday.short }}</span>
|
|
24
|
+
</th>
|
|
25
|
+
}
|
|
26
|
+
</tr>
|
|
27
|
+
<tr>
|
|
28
|
+
<th
|
|
29
|
+
class="owl-dt-calendar-table-divider"
|
|
30
|
+
[ngClass]="{ 'owl-calendar-weeks': showCalendarWeeks }"
|
|
31
|
+
aria-hidden="true"
|
|
32
|
+
colspan="7"
|
|
33
|
+
></th>
|
|
34
|
+
</tr>
|
|
35
|
+
</thead>
|
|
36
|
+
<tbody
|
|
37
|
+
owl-date-time-calendar-body
|
|
38
|
+
role="grid"
|
|
39
|
+
[rows]="days"
|
|
40
|
+
[todayValue]="todayDate"
|
|
41
|
+
[selectedValues]="selectedDates"
|
|
42
|
+
[selectMode]="selectMode"
|
|
43
|
+
[activeCell]="activeCell"
|
|
44
|
+
(keydown)="handleCalendarKeydown($event)"
|
|
45
|
+
(select)="selectCalendarCell($event)"
|
|
46
|
+
></tbody>
|
|
47
|
+
</table>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.week-number {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
justify-content: space-between;
|
|
5
|
+
margin: 0;
|
|
6
|
+
padding: 0;
|
|
7
|
+
list-style: none;
|
|
8
|
+
margin-bottom: 14px;
|
|
9
|
+
margin-top: 46px;
|
|
10
|
+
border-right: 1px solid rgba(0, 0, 0, .12);
|
|
11
|
+
width: 8%;
|
|
12
|
+
font-weight: bold;
|
|
13
|
+
li {
|
|
14
|
+
font-size: .8em;
|
|
15
|
+
}
|
|
16
|
+
}
|