@gobrand/calendar-core 0.0.16 → 0.0.17

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/dist/index.cjs CHANGED
@@ -557,7 +557,8 @@ function createCalendar(options) {
557
557
  getWeek: getWeekImpl,
558
558
  getDay: getDayImpl,
559
559
  getTitle(view, locales, options2) {
560
- switch (view) {
560
+ const effectiveView = view ?? store.state.currentView ?? defaultView;
561
+ switch (effectiveView) {
561
562
  case "month": {
562
563
  const month = getMonthImpl();
563
564
  const date = month.month.toPlainDate({ day: 1 });
@@ -594,6 +595,8 @@ function createCalendar(options) {
594
595
  ...options2
595
596
  });
596
597
  }
598
+ default:
599
+ throw new Error(`Unknown view: ${effectiveView}`);
597
600
  }
598
601
  },
599
602
  getState() {
package/dist/index.d.cts CHANGED
@@ -115,7 +115,7 @@ type ValidViews<Options> = Options extends {
115
115
  views: infer V;
116
116
  } ? keyof V & string : never;
117
117
  type BaseCalendarMethods<Options> = {
118
- getTitle(view: ValidViews<Options>, locales?: Temporal.LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string;
118
+ getTitle(view?: ValidViews<Options>, locales?: Temporal.LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string;
119
119
  getState(): CalendarState;
120
120
  setState(updater: CalendarState | ((old: CalendarState) => Partial<CalendarState>)): void;
121
121
  goToToday(): void;
package/dist/index.d.ts CHANGED
@@ -115,7 +115,7 @@ type ValidViews<Options> = Options extends {
115
115
  views: infer V;
116
116
  } ? keyof V & string : never;
117
117
  type BaseCalendarMethods<Options> = {
118
- getTitle(view: ValidViews<Options>, locales?: Temporal.LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string;
118
+ getTitle(view?: ValidViews<Options>, locales?: Temporal.LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string;
119
119
  getState(): CalendarState;
120
120
  setState(updater: CalendarState | ((old: CalendarState) => Partial<CalendarState>)): void;
121
121
  goToToday(): void;
package/dist/index.js CHANGED
@@ -503,7 +503,8 @@ function createCalendar(options) {
503
503
  getWeek: getWeekImpl,
504
504
  getDay: getDayImpl,
505
505
  getTitle(view, locales, options2) {
506
- switch (view) {
506
+ const effectiveView = view ?? store.state.currentView ?? defaultView;
507
+ switch (effectiveView) {
507
508
  case "month": {
508
509
  const month = getMonthImpl();
509
510
  const date = month.month.toPlainDate({ day: 1 });
@@ -540,6 +541,8 @@ function createCalendar(options) {
540
541
  ...options2
541
542
  });
542
543
  }
544
+ default:
545
+ throw new Error(`Unknown view: ${effectiveView}`);
543
546
  }
544
547
  },
545
548
  getState() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gobrand/calendar-core",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "description": "Lightweight utility library for building calendars using the Temporal API",
5
5
  "private": false,
6
6
  "publishConfig": {