@anglr/datetime 9.0.0-beta.20241007072706 → 9.0.0-beta.20241007073342

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.
@@ -1 +1 @@
1
- {"version":3,"file":"monthCalendar.component.js","sourceRoot":"","sources":["../../../../../../src/modules/calendar/components/monthCalendar/monthCalendar.component.ts","../../../../../../src/modules/calendar/components/monthCalendar/monthCalendar.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,uBAAuB,EAAE,MAAM,EAAE,WAAW,EAAU,KAAK,EAAe,SAAS,EAAE,YAAY,EAA4B,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AAC/L,OAAO,EAAC,YAAY,EAAE,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAa,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAGpD,OAAO,EAAC,4BAA4B,EAA6B,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAC,sBAAsB,EAAE,sBAAsB,EAAC,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,QAAQ,EAAE,eAAe,EAAC,MAAM,yBAAyB,CAAC;;;AAIlE;;GAEG;AACH,SAAS,uBAAuB,CAAC,KAAiD;IAE9E,IAAG,QAAQ,CAAC,KAAK,CAAC,EAClB,CAAC;QACG,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;GAEG;AAkBH,MAAM,OAAO,sBAAsB;IA0D/B,iEAAiE;IACjE,YAAwC,OAAuB,EAChB,cAA8B,EACvD,WAAuC;QAFrB,YAAO,GAAP,OAAO,CAAgB;QAChB,mBAAc,GAAd,cAAc,CAAgB;QACvD,gBAAW,GAAX,WAAW,CAA4B;QA1C7D,qFAAqF;QAErF;;WAEG;Q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Y;qBACf,aAED;wBACI,WAAW;qBACd,mBACgB,uBAAuB,CAAC,MAAM;;0BA6DlC,MAAM;2BAAC,QAAQ;;0BACf,MAAM;2BAAC,eAAe","sourcesContent":["import {Component, ChangeDetectionStrategy, Inject, TemplateRef, Signal, input, InputSignal, viewChild, contentChild, InputSignalWithTransform, computed, effect, inject} from '@angular/core';\nimport {KeyValuePipe, NgTemplateOutlet} from '@angular/common';\nimport {Dictionary, isString} from '@jscrpt/common';\n\nimport {CalendarDayData, EventData} from '../../interfaces';\nimport {CalendarDayTemplateDirective, CalendarDayTemplateContext} from '../../directives';\nimport {MonthCalendarDayFormat, CalendarDayAspectRatio} from '../../misc';\nimport {EventParser} from '../../services';\nimport {DATE_API, FORMAT_PROVIDER} from '../../../../misc/tokens';\nimport {DateApi} from '../../../../services';\nimport {FormatProvider} from '../../../../interfaces';\n\n/**\n * Transform function for `CalendarDayAspectRatio` allowing enter value as number or member name of `CalendarDayAspectRatio`\n */\nfunction dayAspectRatioAttribute(value: keyof typeof CalendarDayAspectRatio|number): CalendarDayAspectRatio\n{\n if(isString(value))\n {\n return CalendarDayAspectRatio[value];\n }\n\n return value;\n}\n\n/**\n * Component used for displaying month calendar\n */\n@Component(\n{\n selector: 'month-calendar',\n templateUrl: 'monthCalendar.component.html',\n standalone: true,\n imports:\n [\n CalendarDayTemplateDirective,\n NgTemplateOutlet,\n KeyValuePipe,\n ],\n providers:\n [\n EventParser,\n ],\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class MonthCalendarComponent<TDate = unknown, TEvent = unknown>\n{\n //######################### protected properties - template bindings #########################\n\n /**\n * Data that represents calendar data\n */\n protected calendarData: Signal<Dictionary<CalendarDayData<TDate, TEvent>[]>>;\n\n /**\n * Calendar day template to be used\n */\n protected calendarDayTemplate: Signal<TemplateRef<CalendarDayTemplateContext>>;\n\n /**\n * Array of weekday names\n */\n protected weekDayNames: Signal<string[]>;\n\n //######################### protected properties - children #########################\n\n /**\n * Default calendar day template\n */\n protected defaultCalendarDayTemplate: Signal<TemplateRef<CalendarDayTemplateContext>> = viewChild.required(CalendarDayTemplateDirective, {read: TemplateRef});\n\n /**\n * Custom calendar day template\n */\n protected customCalendarDayTemplate: Signal<TemplateRef<CalendarDayTemplateContext>|undefined|null> = contentChild(CalendarDayTemplateDirective, {read: TemplateRef});\n\n //######################### public properties - inputs #########################\n\n /**\n * Indication that week number should be displayed\n */\n public showWeekNumber: InputSignal<boolean> = input(false);\n\n /**\n * Date that should be displayed in month calendar\n */\n public display: InputSignal<TDate> = input(inject<DateApi<TDate>>(DATE_API).now().value);\n\n /**\n * Format for displaying week day names\n */\n public weekDayName: InputSignal<MonthCalendarDayFormat> = input<MonthCalendarDayFormat>(MonthCalendarDayFormat.Short);\n\n /**\n * Aspect ratio for displayed calendar day cell\n */\n public dayAspectRatio: InputSignalWithTransform<CalendarDayAspectRatio, keyof typeof CalendarDayAspectRatio|number> = input<CalendarDayAspectRatio, keyof typeof CalendarDayAspectRatio|number>(CalendarDayAspectRatio.ThreeToTwo, {transform: dayAspectRatioAttribute});\n\n /**\n * Array of events that should be displayed\n */\n public events: InputSignal<EventData<TDate, TEvent>[]> = input<EventData<TDate, TEvent>[]>([]);\n\n //######################### constructor #########################\n constructor(@Inject(DATE_API) protected dateApi: DateApi<TDate>,\n @Inject(FORMAT_PROVIDER) protected formatProvider: FormatProvider,\n protected eventParser: EventParser<TDate, TEvent>,)\n {\n this.calendarDayTemplate = computed(() => this.customCalendarDayTemplate() ?? this.defaultCalendarDayTemplate());\n\n this.weekDayNames = computed(() =>\n {\n const weekDayNames = [];\n\n switch(this.weekDayName())\n {\n default:\n // case MonthCalendarDayFormat.None:\n {\n for(let x = 0; x < 7; x++)\n {\n weekDayNames.push('');\n }\n \n break;\n }\n case MonthCalendarDayFormat.Short:\n {\n const names = this.dateApi.weekdays(true);\n weekDayNames.push(...names);\n \n break;\n }\n case MonthCalendarDayFormat.Full:\n {\n const names = this.dateApi.weekdays();\n weekDayNames.push(...names);\n \n break;\n }\n }\n\n return weekDayNames;\n });\n\n this.calendarData = computed(() =>\n {\n const display = this.display();\n const workDate = this.dateApi.getValue(display);\n\n workDate.startOfMonth()\n .startOfWeek();\n \n const calendarData: Dictionary<CalendarDayData<TDate, TEvent>[]> = {};\n \n do\n {\n const weekData: CalendarDayData<TDate, TEvent>[] = calendarData[workDate.format(this.formatProvider.week)] = [];\n \n for(let x = 0; x < 7; x++)\n {\n weekData.push(\n {\n date: workDate.value,\n day: workDate.dayOfMonth(),\n events: [],\n isCurrentMonth: workDate.isSameMonth(display),\n isWeekend: workDate.isWeekend(),\n week: +workDate.format(this.formatProvider.week),\n });\n \n workDate.addDays(1);\n }\n \n workDate.startOfWeek();\n }\n while(workDate.isSameMonth(display));\n \n return calendarData;\n });\n\n effect(() =>\n {\n const events = this.eventParser.getEventsPerDay(this.events());\n const calendarData = this.calendarData();\n\n for(const week in calendarData)\n {\n const weekData = calendarData[week];\n \n for(const day of weekData)\n {\n const found = events.find(itm => this.dateApi.getValue(itm[0]).isSame(day.date));\n day.events = found?.[1] ?? [];\n }\n }\n //TODO: test whether event are refreshed when changed\n });\n }\n\n //######################### ng language server #########################\n\n /**\n * Custom input type for `weekDayName` input\n */\n public static ngAcceptInputType_weekDayName: keyof typeof MonthCalendarDayFormat;\n\n /**\n * Custom input type for `dayAspectRatio` input\n */\n public static ngAcceptInputType_dayAspectRatio: keyof typeof CalendarDayAspectRatio|number;\n}","<div *calendarDayTemplate=\"let data\" class=\"default-calendar-day\" [class.is-weekend]=\"data.isWeekend\" [class.is-other-month]=\"!data.isCurrentMonth\">{{data.day}}</div>\n\n<div></div>\n\n@for(dayName of weekDayNames(); track dayName)\n{\n <div [class.week-day-name]=\"dayName\">{{dayName}}</div>\n}\n\n@for(weekData of calendarData() | keyvalue; track weekData)\n{\n <div class=\"week-number\">\n @if(showWeekNumber())\n {\n {{weekData.key}}\n }\n </div>\n \n @for(dayData of weekData.value; track dayData)\n {\n <div [style.padding-bottom.%]=\"dayAspectRatio()\" class=\"day-wrapper\">\n <div class=\"day-content\"><ng-container *ngTemplateOutlet=\"calendarDayTemplate(); context: {$implicit: dayData}\"/></div>\n </div>\n }\n}\n"]}
1
+ {"version":3,"file":"monthCalendar.component.js","sourceRoot":"","sources":["../../../../../../src/modules/calendar/components/monthCalendar/monthCalendar.component.ts","../../../../../../src/modules/calendar/components/monthCalendar/monthCalendar.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,uBAAuB,EAAE,MAAM,EAAE,WAAW,EAAU,KAAK,EAAe,SAAS,EAAE,YAAY,EAA4B,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AAC/L,OAAO,EAAC,YAAY,EAAE,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAa,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAGpD,OAAO,EAAC,4BAA4B,EAA6B,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAC,sBAAsB,EAAE,sBAAsB,EAAC,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,QAAQ,EAAE,eAAe,EAAC,MAAM,yBAAyB,CAAC;;;AAIlE;;GAEG;AACH,SAAS,uBAAuB,CAAC,KAAiD;IAE9E,IAAG,QAAQ,CAAC,KAAK,CAAC,EAClB,CAAC;QACG,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;GAEG;AAkBH,MAAM,OAAO,sBAAsB;IA0D/B,iEAAiE;IACjE,YAAwC,OAAuB,EAChB,cAA8B,EACvD,WAAuC;QAFrB,YAAO,GAAP,OAAO,CAAgB;QAChB,mBAAc,GAAd,cAAc,CAAgB;QACvD,gBAAW,GAAX,WAAW,CAA4B;QA1C7D,qFAAqF;QAErF;;WAEG;QACO,+BAA0B,GAAoD,SAAS,CA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ACd,mBACgB,uBAAuB,CAAC,MAAM;;0BA6DlC,MAAM;2BAAC,QAAQ;;0BACf,MAAM;2BAAC,eAAe","sourcesContent":["import {Component, ChangeDetectionStrategy, Inject, TemplateRef, Signal, input, InputSignal, viewChild, contentChild, InputSignalWithTransform, computed, effect, inject} from '@angular/core';\nimport {KeyValuePipe, NgTemplateOutlet} from '@angular/common';\nimport {Dictionary, isString} from '@jscrpt/common';\n\nimport {CalendarDayData, EventData} from '../../interfaces';\nimport {CalendarDayTemplateDirective, CalendarDayTemplateContext} from '../../directives';\nimport {MonthCalendarDayFormat, CalendarDayAspectRatio} from '../../misc';\nimport {EventParser} from '../../services';\nimport {DATE_API, FORMAT_PROVIDER} from '../../../../misc/tokens';\nimport {DateApi} from '../../../../services';\nimport {FormatProvider} from '../../../../interfaces';\n\n/**\n * Transform function for `CalendarDayAspectRatio` allowing enter value as number or member name of `CalendarDayAspectRatio`\n */\nfunction dayAspectRatioAttribute(value: keyof typeof CalendarDayAspectRatio|number): CalendarDayAspectRatio\n{\n if(isString(value))\n {\n return CalendarDayAspectRatio[value];\n }\n\n return value;\n}\n\n/**\n * Component used for displaying month calendar\n */\n@Component(\n{\n selector: 'month-calendar',\n templateUrl: 'monthCalendar.component.html',\n standalone: true,\n imports:\n [\n CalendarDayTemplateDirective,\n NgTemplateOutlet,\n KeyValuePipe,\n ],\n providers:\n [\n EventParser,\n ],\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class MonthCalendarComponent<TDate = unknown, TEvent = unknown>\n{\n //######################### protected properties - template bindings #########################\n\n /**\n * Data that represents calendar data\n */\n protected calendarData: Signal<Dictionary<CalendarDayData<TDate, TEvent>[]>>;\n\n /**\n * Calendar day template to be used\n */\n protected calendarDayTemplate: Signal<TemplateRef<CalendarDayTemplateContext>>;\n\n /**\n * Array of weekday names\n */\n protected weekDayNames: Signal<string[]>;\n\n //######################### protected properties - children #########################\n\n /**\n * Default calendar day template\n */\n protected defaultCalendarDayTemplate: Signal<TemplateRef<CalendarDayTemplateContext>> = viewChild.required(CalendarDayTemplateDirective, {read: TemplateRef});\n\n /**\n * Custom calendar day template\n */\n protected customCalendarDayTemplate: Signal<TemplateRef<CalendarDayTemplateContext>|undefined|null> = contentChild(CalendarDayTemplateDirective, {read: TemplateRef});\n\n //######################### public properties - inputs #########################\n\n /**\n * Indication that week number should be displayed\n */\n public showWeekNumber: InputSignal<boolean> = input(false);\n\n /**\n * Date that should be displayed in month calendar\n */\n public display: InputSignal<TDate> = input(inject<DateApi<TDate>>(DATE_API).now().value);\n\n /**\n * Format for displaying week day names\n */\n public weekDayName: InputSignal<MonthCalendarDayFormat|keyof typeof MonthCalendarDayFormat> = input<MonthCalendarDayFormat|keyof typeof MonthCalendarDayFormat>(MonthCalendarDayFormat.Short);\n\n /**\n * Aspect ratio for displayed calendar day cell\n */\n public dayAspectRatio: InputSignalWithTransform<CalendarDayAspectRatio, keyof typeof CalendarDayAspectRatio|number> = input<CalendarDayAspectRatio, keyof typeof CalendarDayAspectRatio|number>(CalendarDayAspectRatio.ThreeToTwo, {transform: dayAspectRatioAttribute});\n\n /**\n * Array of events that should be displayed\n */\n public events: InputSignal<EventData<TDate, TEvent>[]> = input<EventData<TDate, TEvent>[]>([]);\n\n //######################### constructor #########################\n constructor(@Inject(DATE_API) protected dateApi: DateApi<TDate>,\n @Inject(FORMAT_PROVIDER) protected formatProvider: FormatProvider,\n protected eventParser: EventParser<TDate, TEvent>,)\n {\n this.calendarDayTemplate = computed(() => this.customCalendarDayTemplate() ?? this.defaultCalendarDayTemplate());\n\n this.weekDayNames = computed(() =>\n {\n const weekDayNames = [];\n\n switch(this.weekDayName())\n {\n default:\n // case MonthCalendarDayFormat.None:\n {\n for(let x = 0; x < 7; x++)\n {\n weekDayNames.push('');\n }\n \n break;\n }\n case MonthCalendarDayFormat.Short:\n {\n const names = this.dateApi.weekdays(true);\n weekDayNames.push(...names);\n \n break;\n }\n case MonthCalendarDayFormat.Full:\n {\n const names = this.dateApi.weekdays();\n weekDayNames.push(...names);\n \n break;\n }\n }\n\n return weekDayNames;\n });\n\n this.calendarData = computed(() =>\n {\n const display = this.display();\n const workDate = this.dateApi.getValue(display);\n\n workDate.startOfMonth()\n .startOfWeek();\n \n const calendarData: Dictionary<CalendarDayData<TDate, TEvent>[]> = {};\n \n do\n {\n const weekData: CalendarDayData<TDate, TEvent>[] = calendarData[workDate.format(this.formatProvider.week)] = [];\n \n for(let x = 0; x < 7; x++)\n {\n weekData.push(\n {\n date: workDate.value,\n day: workDate.dayOfMonth(),\n events: [],\n isCurrentMonth: workDate.isSameMonth(display),\n isWeekend: workDate.isWeekend(),\n week: +workDate.format(this.formatProvider.week),\n });\n \n workDate.addDays(1);\n }\n \n workDate.startOfWeek();\n }\n while(workDate.isSameMonth(display));\n \n return calendarData;\n });\n\n effect(() =>\n {\n const events = this.eventParser.getEventsPerDay(this.events());\n const calendarData = this.calendarData();\n\n for(const week in calendarData)\n {\n const weekData = calendarData[week];\n \n for(const day of weekData)\n {\n const found = events.find(itm => this.dateApi.getValue(itm[0]).isSame(day.date));\n day.events = found?.[1] ?? [];\n }\n }\n //TODO: test whether event are refreshed when changed\n });\n }\n}","<div *calendarDayTemplate=\"let data\" class=\"default-calendar-day\" [class.is-weekend]=\"data.isWeekend\" [class.is-other-month]=\"!data.isCurrentMonth\">{{data.day}}</div>\n\n<div></div>\n\n@for(dayName of weekDayNames(); track dayName)\n{\n <div [class.week-day-name]=\"dayName\">{{dayName}}</div>\n}\n\n@for(weekData of calendarData() | keyvalue; track weekData)\n{\n <div class=\"week-number\">\n @if(showWeekNumber())\n {\n {{weekData.key}}\n }\n </div>\n \n @for(dayData of weekData.value; track dayData)\n {\n <div [style.padding-bottom.%]=\"dayAspectRatio()\" class=\"day-wrapper\">\n <div class=\"day-content\"><ng-container *ngTemplateOutlet=\"calendarDayTemplate(); context: {$implicit: dayData}\"/></div>\n </div>\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anglr/datetime",
3
- "version": "9.0.0-beta.20241007072706",
3
+ "version": "9.0.0-beta.20241007073342",
4
4
  "description": "Angular library for datetime manipulation components",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -45,7 +45,7 @@ export declare class MonthCalendarComponent<TDate = unknown, TEvent = unknown> {
45
45
  /**
46
46
  * Format for displaying week day names
47
47
  */
48
- weekDayName: InputSignal<MonthCalendarDayFormat>;
48
+ weekDayName: InputSignal<MonthCalendarDayFormat | keyof typeof MonthCalendarDayFormat>;
49
49
  /**
50
50
  * Aspect ratio for displayed calendar day cell
51
51
  */
@@ -55,14 +55,6 @@ export declare class MonthCalendarComponent<TDate = unknown, TEvent = unknown> {
55
55
  */
56
56
  events: InputSignal<EventData<TDate, TEvent>[]>;
57
57
  constructor(dateApi: DateApi<TDate>, formatProvider: FormatProvider, eventParser: EventParser<TDate, TEvent>);
58
- /**
59
- * Custom input type for `weekDayName` input
60
- */
61
- static ngAcceptInputType_weekDayName: keyof typeof MonthCalendarDayFormat;
62
- /**
63
- * Custom input type for `dayAspectRatio` input
64
- */
65
- static ngAcceptInputType_dayAspectRatio: keyof typeof CalendarDayAspectRatio | number;
66
58
  static ɵfac: i0.ɵɵFactoryDeclaration<MonthCalendarComponent<any, any>, never>;
67
59
  static ɵcmp: i0.ɵɵComponentDeclaration<MonthCalendarComponent<any, any>, "month-calendar", never, { "showWeekNumber": { "alias": "showWeekNumber"; "required": false; "isSignal": true; }; "display": { "alias": "display"; "required": false; "isSignal": true; }; "weekDayName": { "alias": "weekDayName"; "required": false; "isSignal": true; }; "dayAspectRatio": { "alias": "dayAspectRatio"; "required": false; "isSignal": true; }; "events": { "alias": "events"; "required": false; "isSignal": true; }; }, {}, ["customCalendarDayTemplate"], never, true, never>;
68
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"monthCalendar.component.d.ts","sourceRoot":"","sources":["monthCalendar.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6C,WAAW,EAAE,MAAM,EA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