ngx-mat-tui-calendar 12.0.12 → 12.1.3
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/README.md +21 -1
- package/bundles/ngx-mat-tui-calendar.umd.js +63 -46
- package/bundles/ngx-mat-tui-calendar.umd.js.map +1 -1
- package/esm2015/lib/calendar-options.js +1 -1
- package/esm2015/lib/ngx-mat-tui-calendar.component.js +56 -38
- package/esm2015/lib/ngx-mat-tui-calendar.module.js +6 -6
- package/fesm2015/ngx-mat-tui-calendar.js +60 -43
- package/fesm2015/ngx-mat-tui-calendar.js.map +1 -1
- package/lib/calendar-options.d.ts +10 -0
- package/lib/ngx-mat-tui-calendar.component.d.ts +4 -4
- package/lib/ngx-mat-tui-calendar.module.d.ts +2 -2
- package/package.json +2 -4
@@ -1,5 +1,6 @@
|
|
1
1
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
2
|
-
import
|
2
|
+
import * as i9 from '@angular/common';
|
3
|
+
import { CommonModule } from '@angular/common';
|
3
4
|
import { FlexLayoutModule, FlexModule } from '@angular/flex-layout';
|
4
5
|
import * as i7 from '@angular/forms';
|
5
6
|
import { FormGroup, FormControl, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
@@ -37,7 +38,6 @@ import distinctColors from 'distinct-colors';
|
|
37
38
|
import { v4 } from 'uuid';
|
38
39
|
import { faCalendarCheck, faCaretLeft, faCaretRight, faBackward, faForward, faTable, faColumns, faListAlt } from '@fortawesome/free-solid-svg-icons';
|
39
40
|
import Calendar from 'tui-calendar';
|
40
|
-
import * as i9 from '@angular/common';
|
41
41
|
|
42
42
|
// import { TZDate } from 'tui-calendar';
|
43
43
|
class LocalDate {
|
@@ -310,23 +310,22 @@ class NgxMatTuiCalendarComponent {
|
|
310
310
|
// we slice off the first color since it is gray
|
311
311
|
this.colors = distinctColors({ lightMin: 70, count: 15 }).slice(1);
|
312
312
|
this.colorIndex = 0;
|
313
|
-
this.
|
314
|
-
this.appliedOptions = this.getDefaultOptions();
|
313
|
+
this.calendarIdDefault = "main";
|
315
314
|
}
|
316
315
|
ngOnInit() {
|
317
316
|
// console.warn(`calendar.component.ts: ngOnit`)
|
318
|
-
this.
|
317
|
+
this.setOptions(this.options);
|
318
|
+
this.createTUICalendar(this.appliedOptions.ioptions);
|
319
319
|
this.bindCallbacks();
|
320
|
+
this.calendar.toggleScheduleView(true);
|
321
|
+
this.calendar.render(true);
|
322
|
+
this.calendar.toggleScheduleView(true);
|
320
323
|
}
|
321
324
|
ngOnChanges(changes) {
|
322
|
-
// console.warn(changes);
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
let options = changes.options.currentValue;
|
327
|
-
this.setOptions(options);
|
328
|
-
}
|
329
|
-
}
|
325
|
+
// console.warn(`ngOnChanges: `, changes);
|
326
|
+
// console.warn(`change.option:`, changes.options);
|
327
|
+
let options = changes.options.currentValue;
|
328
|
+
this.setOptions(options);
|
330
329
|
}
|
331
330
|
ngOnDestroy() {
|
332
331
|
this.calendar.destroy();
|
@@ -389,14 +388,16 @@ class NgxMatTuiCalendarComponent {
|
|
389
388
|
}
|
390
389
|
onMonthView() {
|
391
390
|
this.calendar.changeView('month');
|
391
|
+
this.calendar.render(true); // <-- so that selection is cleared
|
392
392
|
}
|
393
393
|
onWeekView() {
|
394
|
-
console.log(`onWeekView`)
|
394
|
+
// console.log(`onWeekView`)
|
395
395
|
this.calendar.changeView('week');
|
396
396
|
this.calendar.render(true); // <-- so that selection is cleared
|
397
397
|
}
|
398
398
|
onDayView() {
|
399
399
|
this.calendar.changeView('day');
|
400
|
+
this.calendar.render(true); // <-- so that selection is cleared
|
400
401
|
}
|
401
402
|
getDate() {
|
402
403
|
let date = this.calendar.getDate();
|
@@ -406,8 +407,8 @@ class NgxMatTuiCalendarComponent {
|
|
406
407
|
});
|
407
408
|
return str;
|
408
409
|
}
|
409
|
-
createTUICalendar() {
|
410
|
-
let ioptions = this.preprocessIOptions(
|
410
|
+
createTUICalendar(iopts) {
|
411
|
+
let ioptions = this.preprocessIOptions(iopts);
|
411
412
|
// console.warn(`calendar.component.ts: createTUICalendar: ioptions:`, ioptions);
|
412
413
|
this.calendar = new Calendar('#calendar', ioptions);
|
413
414
|
// console.warn(`calendar.component.ts: createTUICalendar: this.calendar:`, this.calendar);
|
@@ -521,7 +522,7 @@ class NgxMatTuiCalendarComponent {
|
|
521
522
|
let end = LocalDate.convertToJsDate(args.end);
|
522
523
|
let schedule = {
|
523
524
|
id,
|
524
|
-
calendarId: (args.calendarId == null) ? this.
|
525
|
+
calendarId: (args.calendarId == null) ? this.calendarIdDefault : args.calendarId,
|
525
526
|
title: args.title,
|
526
527
|
start: start,
|
527
528
|
end: end,
|
@@ -541,23 +542,23 @@ class NgxMatTuiCalendarComponent {
|
|
541
542
|
}
|
542
543
|
updateSchedule(schedule) {
|
543
544
|
// console.log(`event-calendar.component.ts: updateSchedule:`, schedule);
|
544
|
-
let calendarId = (schedule.calendarId == null) ? this.
|
545
|
+
let calendarId = (schedule.calendarId == null) ? this.calendarIdDefault : schedule.calendarId;
|
545
546
|
this.calendar.updateSchedule(schedule.id, calendarId, schedule, false);
|
546
547
|
return this.calendar.getSchedule(schedule.id, calendarId);
|
547
548
|
}
|
548
549
|
getSchedule(args) {
|
549
550
|
// console.log(`event-calendar.component.ts: getSchedule:`, schedule);
|
550
|
-
let calendarId = (args.calendarId == null) ? this.
|
551
|
+
let calendarId = (args.calendarId == null) ? this.calendarIdDefault : args.calendarId;
|
551
552
|
return this.calendar.getSchedule(args.id, calendarId);
|
552
553
|
}
|
553
554
|
deleteScheduleAndNotifyParent(args) {
|
554
555
|
this.deleteSchedule(args);
|
555
|
-
let calendarId = (args.calendarId == null) ? this.
|
556
|
+
let calendarId = (args.calendarId == null) ? this.calendarIdDefault : args.calendarId;
|
556
557
|
this.userDeletedSchedule.emit({ id: args.id, calendarId });
|
557
558
|
}
|
558
559
|
deleteSchedule(args) {
|
559
560
|
// console.log(`event-calendar.component.ts: deleteSchedule:`, schedule);
|
560
|
-
let calendarId = (args.calendarId == null) ? this.
|
561
|
+
let calendarId = (args.calendarId == null) ? this.calendarIdDefault : args.calendarId;
|
561
562
|
this.calendar.deleteSchedule(args.id, calendarId, false);
|
562
563
|
}
|
563
564
|
deleteAllSchedules() {
|
@@ -597,19 +598,42 @@ class NgxMatTuiCalendarComponent {
|
|
597
598
|
}
|
598
599
|
});
|
599
600
|
}
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
601
|
+
setDefaultOptions() {
|
602
|
+
this.setOptions();
|
603
|
+
}
|
604
|
+
setOptions(o) {
|
605
|
+
const get = (object, path, defaultValue) => {
|
606
|
+
let value = path
|
607
|
+
.split('.')
|
608
|
+
.reduce((o, p) => o == null ? undefined : o[p], object);
|
609
|
+
return (value !== undefined) ? value : defaultValue;
|
610
|
+
};
|
611
|
+
let options = {
|
612
|
+
darkMode: get(o, "darkMode", false),
|
613
|
+
themeClass: get(o, "themeClass", null),
|
614
|
+
ioptions: (o && o.ioptions) ? this.setIOptions(o.ioptions) : this.getDefaultIOptions(),
|
615
|
+
buttons: {
|
616
|
+
previous: get(o, "buttons.previous", true),
|
617
|
+
next: get(o, "buttons.next", true),
|
618
|
+
today: get(o, "buttons.today", true),
|
619
|
+
longPrevious: get(o, "buttons.longPrevious", true),
|
620
|
+
longNext: get(o, "buttons.longNext", true),
|
621
|
+
month: get(o, "buttons.month", true),
|
622
|
+
week: get(o, "buttons.week", true),
|
623
|
+
day: get(o, "buttons.day", true),
|
624
|
+
}
|
625
|
+
};
|
626
|
+
this.appliedOptions = options;
|
627
|
+
// console.warn(`setOptions: `, this.appliedOptions);
|
606
628
|
}
|
607
629
|
setIOptions(ioptionsIn) {
|
608
630
|
let ioptions = this.preprocessIOptions(ioptionsIn);
|
609
|
-
this.calendar
|
610
|
-
|
611
|
-
|
612
|
-
|
631
|
+
if (this.calendar) {
|
632
|
+
this.calendar.setOptions(ioptions);
|
633
|
+
this.calendar.setTheme(ioptions.theme);
|
634
|
+
this.calendar.render(true);
|
635
|
+
this.calendar.toggleScheduleView(true);
|
636
|
+
}
|
613
637
|
return ioptions;
|
614
638
|
}
|
615
639
|
preprocessIOptions(ioptions) {
|
@@ -627,13 +651,6 @@ class NgxMatTuiCalendarComponent {
|
|
627
651
|
}
|
628
652
|
return ioptions;
|
629
653
|
}
|
630
|
-
getDefaultOptions() {
|
631
|
-
return {
|
632
|
-
darkMode: false,
|
633
|
-
themeClass: null,
|
634
|
-
ioptions: this.getDefaultIOptions(),
|
635
|
-
};
|
636
|
-
}
|
637
654
|
getDefaultIOptions() {
|
638
655
|
return {
|
639
656
|
defaultView: 'month',
|
@@ -792,7 +809,7 @@ class NgxMatTuiCalendarComponent {
|
|
792
809
|
}
|
793
810
|
}
|
794
811
|
NgxMatTuiCalendarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0, type: NgxMatTuiCalendarComponent, deps: [{ token: i1.MatDialog }], target: i0.ɵɵFactoryTarget.Component });
|
795
|
-
NgxMatTuiCalendarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.13", type: NgxMatTuiCalendarComponent, selector: "ngx-mat-tui-calendar", inputs: { options: "options" }, outputs: { userCreatedSchedule: "userCreatedSchedule", userUpdatedSchedule: "userUpdatedSchedule", userDeletedSchedule: "userDeletedSchedule" }, usesOnChanges: true, ngImport: i0, template: "<section class=\"content-container\">\r\n <!-- These divs are here so that we can read the theme colors for the tui theme -->\r\n <!-- The outer div gives the default color for when user does not provide an Angular theme -->\r\n <div style=\"color: blue;\"> <div id=\"theme-primary\"></div></div>\r\n <div style=\"color: blue;\"> <div id=\"theme-highlight\"></div></div>\r\n <div style=\"color: blue;\"> <div id=\"theme-accent\"></div></div>\r\n <div style=\"color: red;\"> <div id=\"theme-warn\"></div></div>\r\n <div style=\"color: rgba(0, 0, 255, 0.2);\"> <div id=\"theme-primary-shaded\"></div></div>\r\n <div style=\"color: #3e3e3e;\"> <div id=\"theme-foreground\"></div></div>\r\n <div style=\"color: #e0e0e0;\"> <div id=\"theme-divider\"></div></div>\r\n <div style=\"color: white;\"> <div id=\"theme-background\"></div></div>\r\n \r\n <div class=\"calendar-container\">\r\n <!-- calendar titlebar -->\r\n <mat-toolbar class=\"menu-bar\" color=\"primary\">\r\n <!-- <div style=\"align-self: center;display: flex;\r\n align-items: center;\r\n justify-content: flex-start;\"> -->\r\n <div style=\"display: flex;\r\n flex-direction: row;\r\n justify-content: space-between;\r\n width: 100%; \">\r\n <div class=\"left-div\">\r\n <!-- LEFT -->\r\n <button mat-button \r\n class=\"navigation-button\"\r\n style=\"margin-left: 0px; margin-right: 0px; font-size: 1.5rem !important;\" \r\n (click)=\"onCalendarLongPrev()\">\r\n <fa-icon [icon]=\"iconLongPrev\"></fa-icon>\r\n </button>\r\n <button mat-button
|
812
|
+
NgxMatTuiCalendarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.13", type: NgxMatTuiCalendarComponent, selector: "ngx-mat-tui-calendar", inputs: { options: "options" }, outputs: { userCreatedSchedule: "userCreatedSchedule", userUpdatedSchedule: "userUpdatedSchedule", userDeletedSchedule: "userDeletedSchedule" }, usesOnChanges: true, ngImport: i0, template: "<section class=\"content-container\">\r\n <!-- These divs are here so that we can read the theme colors for the tui theme -->\r\n <!-- The outer div gives the default color for when user does not provide an Angular theme -->\r\n <div style=\"color: blue;\"> <div id=\"theme-primary\"></div></div>\r\n <div style=\"color: blue;\"> <div id=\"theme-highlight\"></div></div>\r\n <div style=\"color: blue;\"> <div id=\"theme-accent\"></div></div>\r\n <div style=\"color: red;\"> <div id=\"theme-warn\"></div></div>\r\n <div style=\"color: rgba(0, 0, 255, 0.2);\"> <div id=\"theme-primary-shaded\"></div></div>\r\n <div style=\"color: #3e3e3e;\"> <div id=\"theme-foreground\"></div></div>\r\n <div style=\"color: #e0e0e0;\"> <div id=\"theme-divider\"></div></div>\r\n <div style=\"color: white;\"> <div id=\"theme-background\"></div></div>\r\n \r\n <div class=\"calendar-container\">\r\n <!-- calendar titlebar -->\r\n <mat-toolbar class=\"menu-bar\" color=\"primary\">\r\n <!-- <div style=\"align-self: center;display: flex;\r\n align-items: center;\r\n justify-content: flex-start;\"> -->\r\n <div style=\"display: flex;\r\n flex-direction: row;\r\n justify-content: space-between;\r\n width: 100%; \">\r\n <div class=\"left-div\">\r\n <!-- LEFT -->\r\n <button mat-button *ngIf=\"appliedOptions.buttons.longPrevious\"\r\n class=\"navigation-button\"\r\n style=\"margin-left: 0px; margin-right: 0px; font-size: 1.5rem !important;\" \r\n (click)=\"onCalendarLongPrev()\">\r\n <fa-icon [icon]=\"iconLongPrev\"></fa-icon>\r\n </button>\r\n <button mat-button *ngIf=\"appliedOptions.buttons.previous\"\r\n class=\"navigation-button\" \r\n style=\"margin-left: 0px; margin-right: 0px; font-size: 2rem !important;\" \r\n (click)=\"onCalendarPrev()\">\r\n <fa-icon [icon]=\"iconPrev\"></fa-icon>\r\n </button>\r\n <button mat-button *ngIf=\"appliedOptions.buttons.today\"\r\n class=\"navigation-button\"\r\n style=\"margin-left: 0px; margin-right: 0px; font-size: 1.7rem !important;\" \r\n (click)=\"onCalendarToday()\">\r\n <fa-icon [icon]=\"iconToday\"></fa-icon>\r\n </button>\r\n <button mat-button *ngIf=\"appliedOptions.buttons.next\"\r\n class=\"navigation-button\" \r\n style=\"margin-left: 0px; margin-right: 0px; font-size: 2rem !important;\" \r\n (click)=\"onCalendarNext()\">\r\n <fa-icon [icon]=\"iconNext\"></fa-icon>\r\n </button>\r\n <button mat-button *ngIf=\"appliedOptions.buttons.longNext\"\r\n class=\"navigation-button\"\r\n style=\"margin-left: 0px; margin-right: 0px; font-size: 1.5rem !important;\" \r\n (click)=\"onCalendarLongNext()\">\r\n <fa-icon [icon]=\"iconLongNext\"></fa-icon>\r\n </button>\r\n </div>\r\n <div class=\"center-div\">\r\n <!-- CENTER -->\r\n <span class=\"event-calendar-title\">{{ getDate() }}</span>\r\n </div>\r\n <div class=\"right-div\">\r\n \r\n <!-- RIGHT -->\r\n <mat-button-toggle-group [hidden]=\"!appliedOptions.buttons.month && !appliedOptions.buttons.week && !appliedOptions.buttons.day\"\r\n class=\"view-button\" value=\"month\" id=\"@+id/toggleButton\" layout_width=\"wrap_content\"\r\n layout_height=\"wrap_content\">\r\n <mat-button-toggle *ngIf=\"appliedOptions.buttons.month\" mat-button value=\"month\" class=\"view-button\" (click)=\"onMonthView()\">\r\n <fa-icon [icon]=\"iconByMonth\"></fa-icon>\r\n </mat-button-toggle>\r\n <mat-button-toggle *ngIf=\"appliedOptions.buttons.week\" mat-button value=\"week\" class=\"view-button\" (click)=\"onWeekView()\">\r\n <fa-icon [icon]=\"iconByWeek\"></fa-icon>\r\n </mat-button-toggle>\r\n <mat-button-toggle *ngIf=\"appliedOptions.buttons.day\" mat-button value=\"day\" class=\"view-button\" (click)=\"onDayView()\">\r\n <fa-icon [icon]=\"iconByDay\"></fa-icon>\r\n </mat-button-toggle>\r\n </mat-button-toggle-group>\r\n </div>\r\n </div>\r\n </mat-toolbar>\r\n <ngx-mat-tui-calendar-wrapper></ngx-mat-tui-calendar-wrapper>\r\n </div>\r\n \r\n </section>\r\n", styles: [".calendar-container{transform-origin:top left}.menu-bar{display:flex;flex-direction:column;align-items:center;justify-content:center;font-size:2rem!important}.mat-button{font-size:1.1rem!important}.mat-button.navigation-button{padding:0;min-width:32px}.left-div{width:33%;float:left;display:flex;white-space:nowrap;vertical-align:middle}.center-div{width:33%;float:right;text-align:center;white-space:nowrap;vertical-align:middle}.event-calendar-title{font-size:2rem;vertical-align:middle}.right-div{width:33%;display:flex;white-space:nowrap;vertical-align:middle;flex-flow:row-reverse}@media screen and (max-width: 599px){.left-div{transform:scale(.75);transform-origin:center left}.center-div{transform:scale(.5)}.right-div{transform:scale(1);transform-origin:center right}.right-div .mat-button-toggle-group.view-button{font-size:1.1rem!important}.right-div ::ng-deep .mat-button-toggle-label-content{padding:0 8px!important}}.mat-button-toggle-group.view-button{height:36px;font-size:1.25rem!important}.view-button{align-items:center}::ng-deep .mat-button-toggle-label-content{padding:0 10px!important}\n"], components: [{ type: i2$1.MatToolbar, selector: "mat-toolbar", inputs: ["color"], exportAs: ["matToolbar"] }, { type: i6.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i4$1.FaIconComponent, selector: "fa-icon", inputs: ["classes", "icon", "title", "spin", "pulse", "mask", "styles", "flip", "size", "pull", "border", "inverse", "symbol", "rotate", "fixedWidth", "transform", "a11yRole"] }, { type: i5$1.MatButtonToggle, selector: "mat-button-toggle", inputs: ["disableRipple", "aria-labelledby", "tabIndex", "appearance", "checked", "disabled", "id", "name", "aria-label", "value"], outputs: ["change"], exportAs: ["matButtonToggle"] }, { type: NgxMatTuiCalendarWrapperComponent, selector: "ngx-mat-tui-calendar-wrapper" }], directives: [{ type: i9.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5$1.MatButtonToggleGroup, selector: "mat-button-toggle-group", inputs: ["appearance", "name", "vertical", "value", "multiple", "disabled"], outputs: ["valueChange", "change"], exportAs: ["matButtonToggleGroup"] }] });
|
796
813
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0, type: NgxMatTuiCalendarComponent, decorators: [{
|
797
814
|
type: Component,
|
798
815
|
args: [{
|
@@ -816,7 +833,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.13", ngImpo
|
|
816
833
|
// collect all of the above modules into an array
|
817
834
|
const importedModules = [
|
818
835
|
BrowserAnimationsModule,
|
819
|
-
|
836
|
+
CommonModule,
|
820
837
|
FlexLayoutModule,
|
821
838
|
FlexModule,
|
822
839
|
FormsModule,
|
@@ -851,7 +868,7 @@ NgxMatTuiCalendarModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0",
|
|
851
868
|
NgxMatTuiCalendarModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0, type: NgxMatTuiCalendarModule, declarations: [NgxMatTuiCalendarComponent,
|
852
869
|
NgxMatTuiCalendarWrapperComponent,
|
853
870
|
NgxMatTuiCalendarEditorDialogComponent], imports: [BrowserAnimationsModule,
|
854
|
-
|
871
|
+
CommonModule,
|
855
872
|
FlexLayoutModule,
|
856
873
|
FlexModule,
|
857
874
|
FormsModule,
|
@@ -874,7 +891,7 @@ NgxMatTuiCalendarModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0",
|
|
874
891
|
MatToolbarModule,
|
875
892
|
FontAwesomeModule,
|
876
893
|
MatTimepickerModule], exports: [BrowserAnimationsModule,
|
877
|
-
|
894
|
+
CommonModule,
|
878
895
|
FlexLayoutModule,
|
879
896
|
FlexModule,
|
880
897
|
FormsModule,
|
@@ -902,7 +919,7 @@ NgxMatTuiCalendarModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0",
|
|
902
919
|
NgxMatTuiCalendarModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0, type: NgxMatTuiCalendarModule, imports: [[
|
903
920
|
...importedModules,
|
904
921
|
], BrowserAnimationsModule,
|
905
|
-
|
922
|
+
CommonModule,
|
906
923
|
FlexLayoutModule,
|
907
924
|
FlexModule,
|
908
925
|
FormsModule,
|