@vermeulen.solutions/eventual 0.18.6 → 0.19.0
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 +10 -10
- package/astro/EventList.astro +124 -5
- package/astro/blueprint.d.mts +2 -0
- package/astro/blueprint.mjs +1 -1
- package/astro/events/EventBrowser.astro +261 -0
- package/astro/events/EventDetail.astro +113 -0
- package/astro/events/description.ts +183 -0
- package/astro/events/grid.ts +199 -0
- package/astro/events/i18n.ts +122 -0
- package/astro/events/index.ts +301 -0
- package/astro/events/links.ts +54 -0
- package/astro/events/parts/AgendaItem.astro +74 -0
- package/astro/events/parts/DateTile.astro +24 -0
- package/astro/events/parts/EventCard.astro +63 -0
- package/astro/events/parts/Icon.astro +26 -0
- package/astro/events/parts/StatusBadge.astro +23 -0
- package/astro/events/parts/Styles.astro +1453 -0
- package/astro/events/state.ts +82 -0
- package/dist/index.mjs +1 -11
- package/dist/plugin.mjs +7 -7
- package/docs/collection-setup.md +2 -2
- package/docs/developer-guide.md +76 -2
- package/docs/registry-installation.md +2 -2
- package/docs/release-notes-0.18.7.md +13 -0
- package/docs/release-notes-0.19.0.md +12 -0
- package/docs/user-guide.md +1 -1
- package/emdash-plugin.jsonc +0 -2
- package/package.json +8 -3
- package/scripts/export-native-schema.mjs +7 -3
- package/src/domain/calendar-links.ts +3 -1
- package/src/domain/invocation-budget.ts +12 -7
- package/src/domain/native-calendar.ts +12 -3
- package/src/schema/blueprint.ts +3 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query-string state of the events page and the date range of a detail page.
|
|
3
|
+
* Moved from the Astro showcase (browser-state.ts, event-range.ts).
|
|
4
|
+
*/
|
|
5
|
+
import { addMonths, isMonthKey } from "./grid";
|
|
6
|
+
|
|
7
|
+
export const EVENT_VIEWS = ["list", "timeline", "cards", "schedule", "dates", "month", "locations"] as const;
|
|
8
|
+
|
|
9
|
+
export type EventView = typeof EVENT_VIEWS[number];
|
|
10
|
+
|
|
11
|
+
export interface EventBrowserState {
|
|
12
|
+
month: string;
|
|
13
|
+
view: EventView;
|
|
14
|
+
category: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface EventBrowserStateOptions {
|
|
18
|
+
/** Views the site offers, in this order (default: all seven). */
|
|
19
|
+
views?: readonly EventView[];
|
|
20
|
+
/** View when the address names none, or one the site does not offer (default: the first offered). */
|
|
21
|
+
defaultView?: EventView;
|
|
22
|
+
/** Fixed values instead of the query string. */
|
|
23
|
+
view?: EventView;
|
|
24
|
+
month?: string;
|
|
25
|
+
category?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function offeredViews(options: Pick<EventBrowserStateOptions, "views"> = {}): EventView[] {
|
|
29
|
+
const chosen = (options.views ?? EVENT_VIEWS).filter((view, index, all) => EVENT_VIEWS.includes(view) && all.indexOf(view) === index);
|
|
30
|
+
return chosen.length ? chosen : [...EVENT_VIEWS];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function eventBrowserState(params: URLSearchParams, currentMonth: string, options: EventBrowserStateOptions = {}): EventBrowserState {
|
|
34
|
+
const views = offeredViews(options);
|
|
35
|
+
const fallback = options.defaultView && views.includes(options.defaultView) ? options.defaultView : views[0]!;
|
|
36
|
+
const requestedView = (options.view ?? params.get("view")) as EventView | null;
|
|
37
|
+
const requestedMonth = options.month ?? params.get("month");
|
|
38
|
+
return {
|
|
39
|
+
month: isMonthKey(requestedMonth) ? requestedMonth : currentMonth,
|
|
40
|
+
view: requestedView && views.includes(requestedView) ? requestedView : fallback,
|
|
41
|
+
category: (options.category ?? params.get("category") ?? "").trim().slice(0, 100),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Same-page address for another view, month or category ("?month=…&view=…"). */
|
|
46
|
+
export function eventBrowserHref(state: EventBrowserState, change: Partial<EventBrowserState> = {}): string {
|
|
47
|
+
const next = { ...state, ...change };
|
|
48
|
+
const params = new URLSearchParams({ month: next.month, view: next.view });
|
|
49
|
+
if (next.category) params.set("category", next.category);
|
|
50
|
+
return `?${params.toString()}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function adjacentMonth(state: EventBrowserState, offset: -1 | 1): string {
|
|
54
|
+
return addMonths(state.month, offset);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface EventRange {
|
|
58
|
+
from: string;
|
|
59
|
+
through: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** The detail page's `from`/`through` (default: today and the year after); null when invalid. */
|
|
63
|
+
export function eventRange(searchParams: URLSearchParams, now = new Date()): EventRange | null {
|
|
64
|
+
const from = searchParams.get("from") ?? now.toISOString().slice(0, 10);
|
|
65
|
+
const through = searchParams.get("through") ?? addDays(from, 365);
|
|
66
|
+
if (!isDateOnly(from) || !isDateOnly(through) || from > through) return null;
|
|
67
|
+
const span = (Date.parse(`${through}T00:00:00Z`) - Date.parse(`${from}T00:00:00Z`)) / 86_400_000;
|
|
68
|
+
return Number.isInteger(span) && span < 366 ? { from, through } : null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function isDateOnly(value: string): boolean {
|
|
72
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) return false;
|
|
73
|
+
const date = new Date(`${value}T00:00:00Z`);
|
|
74
|
+
return Number.isFinite(date.getTime()) && date.toISOString().slice(0, 10) === value;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function addDays(value: string, amount: number): string {
|
|
78
|
+
const date = new Date(`${value}T00:00:00Z`);
|
|
79
|
+
if (!isDateOnly(value)) return "";
|
|
80
|
+
date.setUTCDate(date.getUTCDate() + amount);
|
|
81
|
+
return date.toISOString().slice(0, 10);
|
|
82
|
+
}
|
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
/** @type {import("emdash").PluginDescriptor} */
|
|
8
8
|
const descriptor = Object.freeze({
|
|
9
9
|
"id": "eventual",
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.19.0",
|
|
11
11
|
"format": "standard",
|
|
12
12
|
"entrypoint": "@vermeulen.solutions/eventual/sandbox",
|
|
13
13
|
"capabilities": [
|
|
@@ -1549,16 +1549,6 @@ const descriptor = Object.freeze({
|
|
|
1549
1549
|
"label": "Eventual RSVP",
|
|
1550
1550
|
"icon": "calendar"
|
|
1551
1551
|
},
|
|
1552
|
-
{
|
|
1553
|
-
"path": "/venues",
|
|
1554
|
-
"label": "Venues",
|
|
1555
|
-
"icon": "map-pin"
|
|
1556
|
-
},
|
|
1557
|
-
{
|
|
1558
|
-
"path": "/organizers",
|
|
1559
|
-
"label": "Organizers",
|
|
1560
|
-
"icon": "users"
|
|
1561
|
-
},
|
|
1562
1552
|
{
|
|
1563
1553
|
"path": "/settings",
|
|
1564
1554
|
"label": "Event settings",
|