@weaver-apps/calendar 0.2.0 → 0.3.1

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.
@@ -0,0 +1,47 @@
1
+ import { InjectionToken } from "@angular/core";
2
+ var CalendarHost = class {
3
+ ctx;
4
+ bind(ctx) {
5
+ this.ctx = ctx;
6
+ }
7
+ unbind() {
8
+ this.ctx = void 0;
9
+ }
10
+ get ui() {
11
+ if (!this.ctx) throw new Error("The calendar plugin is not active.");
12
+ return this.ctx.ui;
13
+ }
14
+ navigate(path) {
15
+ this.ctx?.navigateContent(path);
16
+ }
17
+ };
18
+ const calendarHost = new CalendarHost();
19
+ const calendarPluginId = "weaver-apps-calendar";
20
+ const calendarContributionIds = {
21
+ calendars: `${calendarPluginId}.calendars`,
22
+ calendar: `${calendarPluginId}.calendar`,
23
+ rail: `${calendarPluginId}.rail`
24
+ };
25
+ const calendarIconNames = {
26
+ calendar: `${calendarPluginId}.calendar`,
27
+ previous: `${calendarPluginId}.previous`,
28
+ next: `${calendarPluginId}.next`,
29
+ cancel: `${calendarPluginId}.cancel`
30
+ };
31
+ var CalendarGatewayError = class extends Error {
32
+ status;
33
+ constructor(status) {
34
+ super(`The calendar answered ${status}.`);
35
+ this.status = status;
36
+ }
37
+ };
38
+ const CALENDAR_GATEWAY = new InjectionToken("weaver-apps.calendar.gateway");
39
+ function provideCalendarGateway(gateway) {
40
+ return {
41
+ provide: CALENDAR_GATEWAY,
42
+ useValue: gateway
43
+ };
44
+ }
45
+ export { calendarIconNames as a, calendarContributionIds as i, CalendarGatewayError as n, calendarPluginId as o, provideCalendarGateway as r, calendarHost as s, CALENDAR_GATEWAY as t };
46
+
47
+ //# sourceMappingURL=weaver-apps-calendar-calendar-gateway-DqiL9VbI.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"weaver-apps-calendar-calendar-gateway-DqiL9VbI.mjs","names":[],"sources":["../../../../libs/calendar/src/lib/plugin/calendar-host.ts","../../../../libs/calendar/src/lib/plugin/calendar-ids.ts","../../../../libs/calendar/src/lib/gateway/calendar-gateway.ts"],"sourcesContent":["import type { PluginContext } from '@loomweaver/plugin-sdk';\n\ntype HostContext = Pick<PluginContext, 'ui' | 'navigateContent'>;\n\nclass CalendarHost {\n private ctx?: HostContext;\n\n bind(ctx: HostContext): void {\n this.ctx = ctx;\n }\n\n unbind(): void {\n this.ctx = undefined;\n }\n\n get ui(): HostContext['ui'] {\n if (!this.ctx) {\n throw new Error('The calendar plugin is not active.');\n }\n return this.ctx.ui;\n }\n\n navigate(path: string): void {\n this.ctx?.navigateContent(path);\n }\n}\n\nexport const calendarHost = new CalendarHost();\n","export const calendarPluginId = 'weaver-apps-calendar';\n\nexport const calendarContributionIds = {\n calendars: `${calendarPluginId}.calendars`,\n calendar: `${calendarPluginId}.calendar`,\n rail: `${calendarPluginId}.rail`,\n} as const;\n\nexport const calendarIconNames = {\n calendar: `${calendarPluginId}.calendar`,\n previous: `${calendarPluginId}.previous`,\n next: `${calendarPluginId}.next`,\n cancel: `${calendarPluginId}.cancel`,\n} as const;\n","import { InjectionToken, Provider } from '@angular/core';\nimport type { AppointmentRequest, AppointmentResponse, AppointmentStatus, CalendarResponse } from '../api/models';\n\nexport interface CalendarRange {\n readonly from: Date;\n readonly until: Date;\n}\n\nexport interface ConflictingAppointment {\n readonly id: string;\n readonly start: string;\n readonly end: string;\n}\n\nexport type AppointmentOutcome =\n | { readonly kind: 'saved'; readonly appointment: AppointmentResponse }\n | { readonly kind: 'conflict'; readonly conflicts: readonly ConflictingAppointment[] }\n | { readonly kind: 'closed' }\n | { readonly kind: 'changed' }\n | { readonly kind: 'invalid' }\n | { readonly kind: 'missing' };\n\nexport interface CalendarGateway {\n calendars(): Promise<readonly CalendarResponse[]>;\n calendar(calendarId: string): Promise<CalendarResponse | null>;\n saveCalendar(calendarId: string, name: string): Promise<CalendarResponse>;\n appointments(calendarId: string, range: CalendarRange, contact?: string, signal?: AbortSignal): Promise<readonly AppointmentResponse[]>;\n book(calendarId: string, request: AppointmentRequest): Promise<AppointmentOutcome>;\n update(calendarId: string, appointmentId: string, request: AppointmentRequest): Promise<AppointmentOutcome>;\n cancel(calendarId: string, appointmentId: string, reason: string | null): Promise<AppointmentOutcome>;\n setStatus(calendarId: string, appointmentId: string, status: AppointmentStatus): Promise<AppointmentOutcome>;\n remove(calendarId: string, appointmentId: string): Promise<void>;\n}\n\nexport class CalendarGatewayError extends Error {\n constructor(readonly status: number) {\n super(`The calendar answered ${status}.`);\n }\n}\n\nexport const CALENDAR_GATEWAY = new InjectionToken<CalendarGateway>('weaver-apps.calendar.gateway');\n\nexport function provideCalendarGateway(gateway: CalendarGateway): Provider {\n return { provide: CALENDAR_GATEWAY, useValue: gateway };\n}\n"],"mappings":";AAIA,IAAM,eAAN,MAAkB;CACR;CAER,KAAK,KAAgB;EACnB,KAAK,MAAM;CACb;CAEA,SAAM;EACJ,KAAK,MAAM;CACb;CAEA,IAAI,KAAE;EACJ,IAAI,CAAC,KAAK,KACR,MAAM,IAAI,MAAM,oCAAoC;EAEtD,OAAO,KAAK,IAAI;CAClB;CAEA,SAAS,MAAY;EACnB,KAAK,KAAK,gBAAgB,IAAI;CAChC;AACD;AAED,MAAa,eAAe,IAAI,aAAY;AC3B5C,MAAa,mBAAmB;AAEhC,MAAa,0BAA0B;CACrC,WAAW,GAAG,iBAAgB;CAC9B,UAAU,GAAG,iBAAgB;CAC7B,MAAM,GAAG,iBAAgB;AACjB;AAEV,MAAa,oBAAoB;CAC/B,UAAU,GAAG,iBAAgB;CAC7B,UAAU,GAAG,iBAAgB;CAC7B,MAAM,GAAG,iBAAgB;CACzB,QAAQ,GAAG,iBAAgB;AACnB;ACqBV,IAAa,uBAAb,cAA0C,MAAK;CACxB;CAArB,YAAqB,QAAc;EACjC,MAAM,yBAAyB,OAAM,EAAG;EADrB,KAAA,SAAA;CAErB;AACD;AAED,MAAa,mBAAmB,IAAI,eAAgC,8BAA8B;AAElG,SAAgB,uBAAuB,SAAwB;CAC7D,OAAO;EAAE,SAAS;EAAkB,UAAU;CAAO;AACvD"}
@@ -0,0 +1,74 @@
1
+ import { s as calendarHost, t as CALENDAR_GATEWAY } from "./weaver-apps-calendar-calendar-gateway-DqiL9VbI.mjs";
2
+ import { n as calendarPath } from "./weaver-apps-calendar-calendar-paths-AFikgbRs.mjs";
3
+ import * as i0 from "@angular/core";
4
+ import { CUSTOM_ELEMENTS_SCHEMA, ChangeDetectionStrategy, Component, inject, resource } from "@angular/core";
5
+ import { TranslocoPipe } from "@jsverse/transloco";
6
+ var CalendarListPage = class CalendarListPage {
7
+ gateway = inject(CALENDAR_GATEWAY);
8
+ calendars = resource({
9
+ ...ngDevMode ? { debugName: "calendars" } : /* istanbul ignore next */ {},
10
+ loader: () => this.gateway.calendars()
11
+ });
12
+ open(calendarId) {
13
+ calendarHost.navigate(calendarPath(calendarId));
14
+ }
15
+ async create() {
16
+ const name = await calendarHost.ui.prompt({
17
+ title: "weaver-apps-calendar.calendars.create",
18
+ message: "weaver-apps-calendar.calendars.createMessage",
19
+ confirmLabel: "weaver-apps-calendar.calendars.createConfirm"
20
+ });
21
+ if (!name?.trim()) return;
22
+ try {
23
+ const calendar = await this.gateway.saveCalendar(crypto.randomUUID(), name.trim());
24
+ this.open(calendar.id);
25
+ } catch {
26
+ calendarHost.ui.toast({
27
+ message: "weaver-apps-calendar.errors.create",
28
+ kind: "error"
29
+ });
30
+ }
31
+ }
32
+ static ɵfac = i0.ɵɵngDeclareFactory({
33
+ minVersion: "12.0.0",
34
+ version: "22.2.3",
35
+ ngImport: i0,
36
+ type: CalendarListPage,
37
+ deps: [],
38
+ target: i0.ɵɵFactoryTarget.Component
39
+ });
40
+ static ɵcmp = i0.ɵɵngDeclareComponent({
41
+ minVersion: "17.0.0",
42
+ version: "22.2.3",
43
+ type: CalendarListPage,
44
+ isStandalone: true,
45
+ selector: "wa-calendar-list-page",
46
+ ngImport: i0,
47
+ template: "<div class=\"flex h-full flex-col gap-4 overflow-auto p-6\">\n <div class=\"flex items-center justify-between gap-4\">\n <h2 class=\"text-lg font-semibold text-content\">{{ 'weaver-apps-calendar.calendars.title' | transloco }}</h2>\n <button type=\"button\" class=\"lw-btn lw-btn--primary\" (click)=\"create()\">{{ 'weaver-apps-calendar.calendars.create' | transloco }}</button>\n </div>\n @if (calendars.error()) {\n <p class=\"text-sm text-negative\" role=\"alert\">{{ 'weaver-apps-calendar.errors.load' | transloco }}</p>\n } @else if (calendars.hasValue()) {\n <ul role=\"list\" class=\"divide-y divide-border rounded-xl border border-border bg-surface\">\n @for (calendar of calendars.value(); track calendar.id) {\n <li>\n <button type=\"button\" class=\"flex w-full items-center gap-3 px-4 py-3 text-left text-sm text-content hover:bg-surface-overlay\" (click)=\"open(calendar.id)\">\n <lw-icon name=\"weaver-apps-calendar.calendar\" size=\"1.25rem\"></lw-icon>\n <span>{{ calendar.name }}</span>\n </button>\n </li>\n } @empty {\n <li class=\"px-4 py-8 text-center text-sm text-content-faint\">{{ 'weaver-apps-calendar.calendars.empty' | transloco }}</li>\n }\n </ul>\n }\n</div>\n",
48
+ dependencies: [{
49
+ kind: "pipe",
50
+ type: TranslocoPipe,
51
+ name: "transloco"
52
+ }],
53
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
54
+ });
55
+ };
56
+ i0.ɵɵngDeclareClassMetadata({
57
+ minVersion: "12.0.0",
58
+ version: "22.2.3",
59
+ ngImport: i0,
60
+ type: CalendarListPage,
61
+ decorators: [{
62
+ type: Component,
63
+ args: [{
64
+ selector: "wa-calendar-list-page",
65
+ imports: [TranslocoPipe],
66
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
67
+ changeDetection: ChangeDetectionStrategy.OnPush,
68
+ template: "<div class=\"flex h-full flex-col gap-4 overflow-auto p-6\">\n <div class=\"flex items-center justify-between gap-4\">\n <h2 class=\"text-lg font-semibold text-content\">{{ 'weaver-apps-calendar.calendars.title' | transloco }}</h2>\n <button type=\"button\" class=\"lw-btn lw-btn--primary\" (click)=\"create()\">{{ 'weaver-apps-calendar.calendars.create' | transloco }}</button>\n </div>\n @if (calendars.error()) {\n <p class=\"text-sm text-negative\" role=\"alert\">{{ 'weaver-apps-calendar.errors.load' | transloco }}</p>\n } @else if (calendars.hasValue()) {\n <ul role=\"list\" class=\"divide-y divide-border rounded-xl border border-border bg-surface\">\n @for (calendar of calendars.value(); track calendar.id) {\n <li>\n <button type=\"button\" class=\"flex w-full items-center gap-3 px-4 py-3 text-left text-sm text-content hover:bg-surface-overlay\" (click)=\"open(calendar.id)\">\n <lw-icon name=\"weaver-apps-calendar.calendar\" size=\"1.25rem\"></lw-icon>\n <span>{{ calendar.name }}</span>\n </button>\n </li>\n } @empty {\n <li class=\"px-4 py-8 text-center text-sm text-content-faint\">{{ 'weaver-apps-calendar.calendars.empty' | transloco }}</li>\n }\n </ul>\n }\n</div>\n"
69
+ }]
70
+ }]
71
+ });
72
+ export { CalendarListPage };
73
+
74
+ //# sourceMappingURL=weaver-apps-calendar-calendar-list-page-CF8odTAv.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"weaver-apps-calendar-calendar-list-page-CF8odTAv.mjs","names":[],"sources":["../../../../libs/calendar/src/lib/views/calendar-list-page.ts","../../../../libs/calendar/src/lib/views/calendar-list-page.html"],"sourcesContent":["import { ChangeDetectionStrategy, Component, CUSTOM_ELEMENTS_SCHEMA, inject, resource } from '@angular/core';\nimport { TranslocoPipe } from '@jsverse/transloco';\nimport { CALENDAR_GATEWAY } from '../gateway/calendar-gateway';\nimport { calendarHost } from '../plugin/calendar-host';\nimport { calendarPath } from '../plugin/calendar-paths';\n\n@Component({\n selector: 'wa-calendar-list-page',\n imports: [TranslocoPipe],\n schemas: [CUSTOM_ELEMENTS_SCHEMA],\n templateUrl: './calendar-list-page.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class CalendarListPage {\n private readonly gateway = inject(CALENDAR_GATEWAY);\n\n protected readonly calendars = resource({ loader: () => this.gateway.calendars() });\n\n protected open(calendarId: string): void {\n calendarHost.navigate(calendarPath(calendarId));\n }\n\n protected async create(): Promise<void> {\n const name = await calendarHost.ui.prompt({\n title: 'weaver-apps-calendar.calendars.create',\n message: 'weaver-apps-calendar.calendars.createMessage',\n confirmLabel: 'weaver-apps-calendar.calendars.createConfirm',\n });\n if (!name?.trim()) {\n return;\n }\n try {\n const calendar = await this.gateway.saveCalendar(crypto.randomUUID(), name.trim());\n this.open(calendar.id);\n } catch {\n calendarHost.ui.toast({ message: 'weaver-apps-calendar.errors.create', kind: 'error' });\n }\n }\n}\n","<div class=\"flex h-full flex-col gap-4 overflow-auto p-6\">\n <div class=\"flex items-center justify-between gap-4\">\n <h2 class=\"text-lg font-semibold text-content\">{{ 'weaver-apps-calendar.calendars.title' | transloco }}</h2>\n <button type=\"button\" class=\"lw-btn lw-btn--primary\" (click)=\"create()\">{{ 'weaver-apps-calendar.calendars.create' | transloco }}</button>\n </div>\n @if (calendars.error()) {\n <p class=\"text-sm text-negative\" role=\"alert\">{{ 'weaver-apps-calendar.errors.load' | transloco }}</p>\n } @else if (calendars.hasValue()) {\n <ul role=\"list\" class=\"divide-y divide-border rounded-xl border border-border bg-surface\">\n @for (calendar of calendars.value(); track calendar.id) {\n <li>\n <button type=\"button\" class=\"flex w-full items-center gap-3 px-4 py-3 text-left text-sm text-content hover:bg-surface-overlay\" (click)=\"open(calendar.id)\">\n <lw-icon name=\"weaver-apps-calendar.calendar\" size=\"1.25rem\"></lw-icon>\n <span>{{ calendar.name }}</span>\n </button>\n </li>\n } @empty {\n <li class=\"px-4 py-8 text-center text-sm text-content-faint\">{{ 'weaver-apps-calendar.calendars.empty' | transloco }}</li>\n }\n </ul>\n }\n</div>\n"],"mappings":";;;;;AAaA,IAAa,mBAAb,MAAa,iBAAgB;CACV,UAAU,OAAO,gBAAgB;CAE/B,YAAY,SAAQ;EAAA,GAAA,YAAA,EAAA,WAAA,YAAA,+BAAA,CAAA;EAAG,cAAc,KAAK,QAAQ,UAAS;CAAE,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