obsidian-calendar-ui
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -0,0 +0,0 @@ module.exports = { |
import type { Moment } from "moment"; | ||
import { SvelteComponentTyped } from "svelte"; | ||
export type ILocaleOverride = "system-default" | string; | ||
export type IWeekStartOption = | ||
| "sunday" | ||
| "monday" | ||
| "tuesday" | ||
| "wednesday" | ||
| "thursday" | ||
| "friday" | ||
| "saturday" | ||
| "locale"; | ||
export interface IDot { | ||
@@ -24,2 +35,6 @@ color: string; | ||
// Localization | ||
localeOverride: ILocaleOverride; | ||
weekStart: IWeekStartOption; | ||
// Event Handlers | ||
@@ -30,2 +45,4 @@ onHoverDay?: (date: Moment, targetEl: EventTarget) => void; | ||
onClickWeek?: (date: Moment, isMetaPressed: boolean) => void; | ||
onContextMenuDay?: (date: Moment, event: MouseEvent) => boolean; | ||
onContextMenuWeek?: (date: Moment, event: MouseEvent) => boolean; | ||
@@ -32,0 +49,0 @@ // External sources |
{ | ||
"name": "obsidian-calendar-ui", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Calendar UI that powers obsidian-calendar-plugin", | ||
@@ -17,3 +17,3 @@ "author": "liamcain", | ||
"dependencies": { | ||
"obsidian-daily-notes-interface": "0.5.0", | ||
"obsidian-daily-notes-interface": "0.5.1", | ||
"svelte": "3.31.0", | ||
@@ -20,0 +20,0 @@ "tslib": "2.0.3" |
@@ -0,0 +0,0 @@ # obsidian-calendar-ui |
@@ -0,0 +0,0 @@ import svelte from "rollup-plugin-svelte"; |
@@ -0,0 +0,0 @@ export class TAbstractFile {} |
@@ -16,5 +16,6 @@ import moment from "moment"; | ||
it("creates correct calendar starting on Sunday", () => { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
(<any>moment.localeData())._week.dow = 0; | ||
const monthData = getMonth(moment({ year: 2020, month: 0, day: 1 })); | ||
const monthData = getMonth( | ||
moment({ year: 2020, month: 0, day: 1 }), | ||
"sunday" | ||
); | ||
@@ -34,5 +35,6 @@ expect( | ||
it("creates correct calendar starting on Monday", () => { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
(<any>moment.localeData())._week.dow = 1; | ||
const monthData = getMonth(moment({ year: 2020, month: 0, day: 1 })); | ||
const monthData = getMonth( | ||
moment({ year: 2020, month: 0, day: 1 }), | ||
"monday" | ||
); | ||
@@ -54,5 +56,6 @@ expect( | ||
it("creates correct calendar starting on Sunday", () => { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
(<any>moment.localeData())._week.dow = 0; | ||
const monthData = getMonth(moment({ year: 2020, month: 1, day: 1 })); | ||
const monthData = getMonth( | ||
moment({ year: 2020, month: 1, day: 1 }), | ||
"sunday" | ||
); | ||
@@ -72,5 +75,6 @@ expect( | ||
it("creates correct calendar starting on Monday", () => { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
(<any>moment.localeData())._week.dow = 1; | ||
const monthData = getMonth(moment({ year: 2020, month: 1, day: 1 })); | ||
const monthData = getMonth( | ||
moment({ year: 2020, month: 1, day: 1 }), | ||
"monday" | ||
); | ||
@@ -77,0 +81,0 @@ expect( |
import Calendar from "./components/Calendar.svelte"; | ||
import type { ICalendarSource, IDot, IDayMetadata } from "./types"; | ||
import type { App } from "obsidian"; | ||
import type { Moment } from "moment"; | ||
import type moment from "moment"; | ||
@@ -9,3 +9,3 @@ declare global { | ||
app: App; | ||
moment: () => Moment; | ||
moment: typeof moment; | ||
} | ||
@@ -12,0 +12,0 @@ } |
@@ -26,3 +26,4 @@ import type { Moment } from "moment"; | ||
sources: ICalendarSource[], | ||
date: Moment | ||
date: Moment, | ||
..._args: unknown[] | ||
): Promise<IDayMetadata> { | ||
@@ -36,3 +37,4 @@ return metadataReducer( | ||
sources: ICalendarSource[], | ||
date: Moment | ||
date: Moment, | ||
..._args: unknown[] | ||
): Promise<IDayMetadata> { | ||
@@ -39,0 +41,0 @@ return metadataReducer( |
@@ -0,0 +0,0 @@ import type { App } from "obsidian"; |
@@ -0,0 +0,0 @@ import type { Moment } from "moment"; |
import type { Moment } from "moment"; | ||
import * as os from "os"; | ||
import { | ||
configureMomentLocale, | ||
overrideMomentWeekStart, | ||
ILocaleOverride, | ||
IWeekStartOption, | ||
} from "./localization"; | ||
import type { IMonth, IWeek } from "./types"; | ||
@@ -14,4 +20,3 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function getDaysOfWeek(..._args: any[]): string[] { | ||
export function getDaysOfWeek(..._args: unknown[]): string[] { | ||
return window.moment.weekdaysShort(true); | ||
@@ -32,3 +37,13 @@ } | ||
*/ | ||
export function getMonth(displayedMonth: Moment): IMonth { | ||
export function getMonth( | ||
displayedMonth: Moment, | ||
weekStart: IWeekStartOption, | ||
localeOverride?: ILocaleOverride | ||
): IMonth { | ||
// These functions mutate the global window.moment object. | ||
// Call them here to make sure the calendar view stays in | ||
// sync with settings. | ||
configureMomentLocale(localeOverride); | ||
overrideMomentWeekStart(weekStart); | ||
const month = []; | ||
@@ -35,0 +50,0 @@ let week: IWeek; |
@@ -0,0 +0,0 @@ { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
25
193629
5425
+ Addedobsidian-daily-notes-interface@0.5.1(transitive)
- Removedobsidian-daily-notes-interface@0.5.0(transitive)