@lets-ship/site 3.3.0 → 3.5.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/dist/i18n/tables/de.d.ts.map +1 -1
- package/dist/i18n/tables/de.js +23 -0
- package/dist/i18n/tables/de.js.map +1 -1
- package/dist/i18n/tables/en.d.ts.map +1 -1
- package/dist/i18n/tables/en.js +23 -0
- package/dist/i18n/tables/en.js.map +1 -1
- package/dist/i18n/tables/es.d.ts.map +1 -1
- package/dist/i18n/tables/es.js +23 -0
- package/dist/i18n/tables/es.js.map +1 -1
- package/dist/i18n/tables/fr.d.ts.map +1 -1
- package/dist/i18n/tables/fr.js +23 -0
- package/dist/i18n/tables/fr.js.map +1 -1
- package/dist/i18n/tables/nl.d.ts.map +1 -1
- package/dist/i18n/tables/nl.js +23 -0
- package/dist/i18n/tables/nl.js.map +1 -1
- package/dist/i18n/tables/pt.d.ts.map +1 -1
- package/dist/i18n/tables/pt.js +23 -0
- package/dist/i18n/tables/pt.js.map +1 -1
- package/dist/i18n/tables/tr.d.ts.map +1 -1
- package/dist/i18n/tables/tr.js +23 -0
- package/dist/i18n/tables/tr.js.map +1 -1
- package/dist/i18n/types.d.ts +29 -0
- package/dist/i18n/types.d.ts.map +1 -1
- package/dist/mdx/allow-list.d.ts +1 -1
- package/dist/mdx/allow-list.d.ts.map +1 -1
- package/dist/mdx/allow-list.js +4 -0
- package/dist/mdx/allow-list.js.map +1 -1
- package/dist/mdx/components.d.ts.map +1 -1
- package/dist/mdx/components.js +8 -2
- package/dist/mdx/components.js.map +1 -1
- package/dist/website/blocks/app-views.d.ts +32 -0
- package/dist/website/blocks/app-views.d.ts.map +1 -0
- package/dist/website/blocks/app-views.js +42 -0
- package/dist/website/blocks/app-views.js.map +1 -0
- package/dist/website/blocks/app.d.ts +7 -0
- package/dist/website/blocks/app.d.ts.map +1 -0
- package/dist/website/blocks/app.js +7 -0
- package/dist/website/blocks/app.js.map +1 -0
- package/dist/website/blocks/booking-fields.d.ts +39 -0
- package/dist/website/blocks/booking-fields.d.ts.map +1 -0
- package/dist/website/blocks/booking-fields.js +44 -0
- package/dist/website/blocks/booking-fields.js.map +1 -0
- package/dist/website/blocks/booking-request.d.ts +22 -0
- package/dist/website/blocks/booking-request.d.ts.map +1 -0
- package/dist/website/blocks/booking-request.js +42 -0
- package/dist/website/blocks/booking-request.js.map +1 -0
- package/dist/website/blocks/booking-slot-picker.d.ts +23 -0
- package/dist/website/blocks/booking-slot-picker.d.ts.map +1 -0
- package/dist/website/blocks/booking-slot-picker.js +63 -0
- package/dist/website/blocks/booking-slot-picker.js.map +1 -0
- package/dist/website/blocks/booking-slots.d.ts +63 -0
- package/dist/website/blocks/booking-slots.d.ts.map +1 -0
- package/dist/website/blocks/booking-slots.js +127 -0
- package/dist/website/blocks/booking-slots.js.map +1 -0
- package/dist/website/blocks/booking-views.d.ts +42 -0
- package/dist/website/blocks/booking-views.d.ts.map +1 -0
- package/dist/website/blocks/booking-views.js +52 -0
- package/dist/website/blocks/booking-views.js.map +1 -0
- package/dist/website/blocks/call-to-action-views.d.ts.map +1 -1
- package/dist/website/blocks/call-to-action-views.js +1 -1
- package/dist/website/blocks/call-to-action-views.js.map +1 -1
- package/dist/website/blocks/card-grid-views.d.ts +5 -4
- package/dist/website/blocks/card-grid-views.d.ts.map +1 -1
- package/dist/website/blocks/card-grid-views.js +15 -3
- package/dist/website/blocks/card-grid-views.js.map +1 -1
- package/dist/website/blocks/catalog.d.ts +6 -2
- package/dist/website/blocks/catalog.d.ts.map +1 -1
- package/dist/website/blocks/catalog.js +6 -2
- package/dist/website/blocks/catalog.js.map +1 -1
- package/dist/website/blocks/commerce.d.ts.map +1 -1
- package/dist/website/blocks/commerce.js +2 -1
- package/dist/website/blocks/commerce.js.map +1 -1
- package/dist/website/blocks/contact-views.d.ts.map +1 -1
- package/dist/website/blocks/contact-views.js +7 -4
- package/dist/website/blocks/contact-views.js.map +1 -1
- package/dist/website/blocks/empty-state-views.d.ts.map +1 -1
- package/dist/website/blocks/empty-state-views.js +1 -1
- package/dist/website/blocks/empty-state-views.js.map +1 -1
- package/dist/website/blocks/event-dates.d.ts +42 -0
- package/dist/website/blocks/event-dates.d.ts.map +1 -0
- package/dist/website/blocks/event-dates.js +80 -0
- package/dist/website/blocks/event-dates.js.map +1 -0
- package/dist/website/blocks/event-list.d.ts +16 -0
- package/dist/website/blocks/event-list.d.ts.map +1 -0
- package/dist/website/blocks/event-list.js +37 -0
- package/dist/website/blocks/event-list.js.map +1 -0
- package/dist/website/blocks/event-rows.d.ts +9 -0
- package/dist/website/blocks/event-rows.d.ts.map +1 -0
- package/dist/website/blocks/event-rows.js +13 -0
- package/dist/website/blocks/event-rows.js.map +1 -0
- package/dist/website/blocks/event-visitor.d.ts +14 -0
- package/dist/website/blocks/event-visitor.d.ts.map +1 -0
- package/dist/website/blocks/event-visitor.js +16 -0
- package/dist/website/blocks/event-visitor.js.map +1 -0
- package/dist/website/blocks/faq-views.d.ts.map +1 -1
- package/dist/website/blocks/faq-views.js +7 -7
- package/dist/website/blocks/faq-views.js.map +1 -1
- package/dist/website/blocks/hero-views.js +1 -1
- package/dist/website/blocks/hero-views.js.map +1 -1
- package/dist/website/blocks/icons.d.ts +2 -0
- package/dist/website/blocks/icons.d.ts.map +1 -1
- package/dist/website/blocks/icons.js +3 -1
- package/dist/website/blocks/icons.js.map +1 -1
- package/dist/website/blocks/local-views.d.ts +27 -2
- package/dist/website/blocks/local-views.d.ts.map +1 -1
- package/dist/website/blocks/local-views.js +20 -5
- package/dist/website/blocks/local-views.js.map +1 -1
- package/dist/website/blocks/local.d.ts +10 -0
- package/dist/website/blocks/local.d.ts.map +1 -1
- package/dist/website/blocks/local.js +10 -0
- package/dist/website/blocks/local.js.map +1 -1
- package/dist/website/blocks/logo-stats-views.d.ts.map +1 -1
- package/dist/website/blocks/logo-stats-views.js +3 -1
- package/dist/website/blocks/logo-stats-views.js.map +1 -1
- package/dist/website/blocks/media-views.js +1 -1
- package/dist/website/blocks/media-views.js.map +1 -1
- package/dist/website/blocks/menu-views.d.ts +44 -0
- package/dist/website/blocks/menu-views.d.ts.map +1 -0
- package/dist/website/blocks/menu-views.js +47 -0
- package/dist/website/blocks/menu-views.js.map +1 -0
- package/dist/website/blocks/newsletter-views.d.ts +3 -2
- package/dist/website/blocks/newsletter-views.d.ts.map +1 -1
- package/dist/website/blocks/newsletter-views.js +15 -27
- package/dist/website/blocks/newsletter-views.js.map +1 -1
- package/dist/website/blocks/products-views.d.ts +38 -0
- package/dist/website/blocks/products-views.d.ts.map +1 -0
- package/dist/website/blocks/products-views.js +65 -0
- package/dist/website/blocks/products-views.js.map +1 -0
- package/dist/website/blocks/shop.d.ts +7 -0
- package/dist/website/blocks/shop.d.ts.map +1 -0
- package/dist/website/blocks/shop.js +7 -0
- package/dist/website/blocks/shop.js.map +1 -0
- package/dist/website/blocks/signup.d.ts +42 -0
- package/dist/website/blocks/signup.d.ts.map +1 -0
- package/dist/website/blocks/signup.js +39 -0
- package/dist/website/blocks/signup.js.map +1 -0
- package/dist/website/blocks/ticks.d.ts +10 -0
- package/dist/website/blocks/ticks.d.ts.map +1 -0
- package/dist/website/blocks/ticks.js +9 -0
- package/dist/website/blocks/ticks.js.map +1 -0
- package/dist/website/blocks/visitor-date.d.ts +2 -0
- package/dist/website/blocks/visitor-date.d.ts.map +1 -0
- package/dist/website/blocks/visitor-date.js +10 -0
- package/dist/website/blocks/visitor-date.js.map +1 -0
- package/package.json +1 -1
- package/styles.css +1138 -20
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import { type AppDownloadProps, type AppDownloadVariant } from "./app-views.js";
|
|
3
|
+
/** Where to get an app: the official store badges, with phone screenshots of the app. */
|
|
4
|
+
export declare function AppDownload({ variant, ...props }: AppDownloadProps & {
|
|
5
|
+
readonly variant?: AppDownloadVariant;
|
|
6
|
+
}): ReactElement;
|
|
7
|
+
//# sourceMappingURL=app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/website/blocks/app.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAyB,KAAK,gBAAgB,EAAE,KAAK,kBAAkB,EAAmB,MAAM,gBAAgB,CAAC;AAGxH,yFAAyF;AACzF,wBAAgB,WAAW,CAAC,EAC3B,OAAO,EACP,GAAG,KAAK,EACR,EAAE,gBAAgB,GAAG;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAA;CAAE,GAAG,YAAY,CAE7E"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { APP_DOWNLOAD_VARIANTS, appDownloadView } from "./app-views.js";
|
|
2
|
+
import { variantOf } from "./variant.js";
|
|
3
|
+
/** Where to get an app: the official store badges, with phone screenshots of the app. */
|
|
4
|
+
export function AppDownload({ variant, ...props }) {
|
|
5
|
+
return appDownloadView(variantOf("AppDownload", variant, APP_DOWNLOAD_VARIANTS), props);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../../src/website/blocks/app.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAkD,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACxH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,yFAAyF;AACzF,MAAM,UAAU,WAAW,CAAC,EAC3B,OAAO,EACP,GAAG,KAAK,EACsD;IAC9D,OAAO,eAAe,CAAC,SAAS,CAAC,aAAa,EAAE,OAAO,EAAE,qBAAqB,CAAC,EAAE,KAAK,CAAC,CAAC;AACzF,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fields of a booking request, and the line that takes their place once the request is sent.
|
|
3
|
+
* No hooks and no server code: the block's client part renders them in the browser, and a gallery
|
|
4
|
+
* of the form's states renders each state at once.
|
|
5
|
+
*/
|
|
6
|
+
import type { ReactElement, ReactNode } from "react";
|
|
7
|
+
import type { SiteStrings } from "../../i18n/strings.js";
|
|
8
|
+
/** What a visitor picks besides the date and the time. */
|
|
9
|
+
export type BookingChoices = {
|
|
10
|
+
/** The services to pick from, for an appointment. Without them the form asks for none. */
|
|
11
|
+
readonly services?: readonly string[];
|
|
12
|
+
/** The most guests a table takes, for a reservation: the form offers 1 to this many. */
|
|
13
|
+
readonly guests?: number;
|
|
14
|
+
/** The times a visitor may pick, such as "18:00". Without them the visitor types a time. */
|
|
15
|
+
readonly times?: readonly string[];
|
|
16
|
+
};
|
|
17
|
+
export type BookingFieldsProps = BookingChoices & {
|
|
18
|
+
/** The start of every field's id. Two forms on one page need two, or a label names the other's field. */
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly strings: SiteStrings;
|
|
21
|
+
/** The form waits for an answer: the button says so to a screen reader and takes no press. */
|
|
22
|
+
readonly busy?: boolean;
|
|
23
|
+
/** What went wrong, over the button. */
|
|
24
|
+
readonly message?: string;
|
|
25
|
+
/** A calendar that takes the place of the date and time fields: the slots layout's picker. */
|
|
26
|
+
readonly picker?: ReactNode;
|
|
27
|
+
};
|
|
28
|
+
/** The guests a table takes, 1 to `most`, as the options of a select. */
|
|
29
|
+
export declare function guestCounts(most: number): readonly string[];
|
|
30
|
+
/**
|
|
31
|
+
* The request's fields: what the visitor picks, then who they are and a note, then the button.
|
|
32
|
+
* The caller owns the `<form>`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function BookingFields(props: BookingFieldsProps): ReactElement;
|
|
35
|
+
/** What takes the fields' place after the request is sent: a tick and one line. */
|
|
36
|
+
export declare function BookingDone({ text }: {
|
|
37
|
+
readonly text: string;
|
|
38
|
+
}): ReactElement;
|
|
39
|
+
//# sourceMappingURL=booking-fields.d.ts.map
|
|
@@ -0,0 +1 @@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as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { BlockIcon } from "./icons.js";
|
|
3
|
+
import { keyed } from "./list.js";
|
|
4
|
+
function Field({ id, label, wide = false, children, }) {
|
|
5
|
+
return (_jsxs("div", { className: wide ? "site-booking-wide" : undefined, children: [_jsx("label", { htmlFor: id, className: "site-label", children: label }), children] }));
|
|
6
|
+
}
|
|
7
|
+
function Options({ values }) {
|
|
8
|
+
return (_jsx(_Fragment, { children: keyed(values).map(({ key, item }) => (_jsx("option", { children: item }, key))) }));
|
|
9
|
+
}
|
|
10
|
+
/** The guests a table takes, 1 to `most`, as the options of a select. */
|
|
11
|
+
export function guestCounts(most) {
|
|
12
|
+
return Array.from({ length: Math.max(1, Math.floor(most)) }, (_, index) => String(index + 1));
|
|
13
|
+
}
|
|
14
|
+
/** The service to book, when the content lists the services. */
|
|
15
|
+
function Service({ props, id }) {
|
|
16
|
+
if (!props.services || props.services.length === 0)
|
|
17
|
+
return null;
|
|
18
|
+
return (_jsx(Field, { id: id("service"), label: props.strings.bookingService, wide: true, children: _jsx("select", { id: id("service"), name: "service", required: true, className: "site-input", children: _jsx(Options, { values: props.services }) }) }));
|
|
19
|
+
}
|
|
20
|
+
/** The party size of a table, when the content gives the most guests a table takes. */
|
|
21
|
+
function Guests({ props, id }) {
|
|
22
|
+
if (!props.guests)
|
|
23
|
+
return null;
|
|
24
|
+
return (_jsx(Field, { id: id("guests"), label: props.strings.bookingGuests, children: _jsx("select", { id: id("guests"), name: "guests", required: true, defaultValue: props.guests >= 2 ? "2" : "1", className: "site-input", children: _jsx(Options, { values: guestCounts(props.guests) }) }) }));
|
|
25
|
+
}
|
|
26
|
+
/** What the visitor picks: the service, the guests, the date and the time. */
|
|
27
|
+
function Choices({ props, id }) {
|
|
28
|
+
const s = props.strings;
|
|
29
|
+
return (_jsxs(_Fragment, { children: [_jsx(Service, { props: props, id: id }), _jsxs("div", { className: "site-booking-wide site-booking-when", children: [_jsx(Guests, { props: props, id: id }), _jsx(Field, { id: id("date"), label: s.bookingDate, children: _jsx("input", { id: id("date"), name: "date", type: "date", required: true, className: "site-input" }) }), _jsx(Field, { id: id("time"), label: s.bookingTime, children: props.times && props.times.length > 0 ? (_jsx("select", { id: id("time"), name: "time", required: true, className: "site-input", children: _jsx(Options, { values: props.times }) })) : (_jsx("input", { id: id("time"), name: "time", type: "time", required: true, className: "site-input" })) })] })] }));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The request's fields: what the visitor picks, then who they are and a note, then the button.
|
|
33
|
+
* The caller owns the `<form>`.
|
|
34
|
+
*/
|
|
35
|
+
export function BookingFields(props) {
|
|
36
|
+
const s = props.strings;
|
|
37
|
+
const id = (field) => `${props.id}-${field}`;
|
|
38
|
+
return (_jsxs("div", { className: "site-booking-fields", children: [props.picker ? (_jsxs(_Fragment, { children: [_jsx(Service, { props: props, id: id }), _jsx("div", { className: "site-booking-wide", children: props.picker }), _jsx(Guests, { props: props, id: id })] })) : (_jsx(Choices, { props: props, id: id })), _jsx(Field, { id: id("name"), label: s.formName, children: _jsx("input", { id: id("name"), name: "name", type: "text", autoComplete: "name", required: true, className: "site-input" }) }), _jsx(Field, { id: id("email"), label: s.formEmail, children: _jsx("input", { id: id("email"), name: "email", type: "email", autoComplete: "email", required: true, className: "site-input" }) }), _jsx(Field, { id: id("phone"), label: s.formPhone, wide: true, children: _jsx("input", { id: id("phone"), name: "phone", type: "tel", autoComplete: "tel", className: "site-input" }) }), _jsx(Field, { id: id("notes"), label: s.bookingNotes, wide: true, children: _jsx("textarea", { id: id("notes"), name: "notes", rows: 3, className: "site-input resize-y" }) }), _jsxs("div", { className: "site-booking-wide", children: [props.message ? (_jsx("p", { id: id("message"), role: "alert", className: "site-booking-message", children: props.message })) : null, _jsx("button", { type: "submit", className: "site-button site-booking-button", disabled: props.busy, "aria-busy": props.busy ? true : undefined, children: s.bookingSend })] })] }));
|
|
39
|
+
}
|
|
40
|
+
/** What takes the fields' place after the request is sent: a tick and one line. */
|
|
41
|
+
export function BookingDone({ text }) {
|
|
42
|
+
return (_jsxs("p", { role: "status", className: "site-booking-done", children: [_jsx(BlockIcon, { name: "check-circle", className: "site-booking-done-icon" }), _jsx("span", { children: text })] }));
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=booking-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"booking-fields.js","sourceRoot":"","sources":["../../../src/website/blocks/booking-fields.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAwBlC,SAAS,KAAK,CAAC,EACd,EAAE,EACF,KAAK,EACL,IAAI,GAAG,KAAK,EACZ,QAAQ,GAMR;IACA,OAAO,CACN,eAAK,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,aACrD,gBAAO,OAAO,EAAE,EAAE,EAAE,SAAS,EAAC,YAAY,YACxC,KAAK,GACC,EACP,QAAQ,IACJ,CACN,CAAC;AACH,CAAC;AAED,SAAS,OAAO,CAAC,EAAE,MAAM,EAA0C;IAClE,OAAO,CACN,4BACE,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CACrC,2BAAmB,IAAI,IAAV,GAAG,CAAiB,CACjC,CAAC,GACA,CACH,CAAC;AACH,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,WAAW,CAAC,IAAY;IACvC,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;AAC/F,C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,EAAE,CAAC,CAAC,YAAY,EAAE,IAAI,kBAClD,mBAAU,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAC,OAAO,EAAC,IAAI,EAAE,CAAC,EAAE,SAAS,EAAC,qBAAqB,GAAG,GAC5E,EACR,eAAK,SAAS,EAAC,mBAAmB,aAChC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAChB,YAAG,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,sBAAsB,YACjE,KAAK,CAAC,OAAO,GACX,CACJ,CAAC,CAAC,CAAC,IAAI,EACR,iBACC,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,iCAAiC,EAC3C,QAAQ,EAAE,KAAK,CAAC,IAAI,eACT,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,YAEvC,CAAC,CAAC,WAAW,GACN,IACJ,IACD,CACN,CAAC;AACH,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,WAAW,CAAC,EAAE,IAAI,EAA6B;IAC9D,OAAO,CACN,aAAG,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,mBAAmB,aAC7C,KAAC,SAAS,IAAC,IAAI,EAAC,cAAc,EAAC,SAAS,EAAC,wBAAwB,GAAG,EACpE,yBAAO,IAAI,GAAQ,IAChB,CACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The booking request in the browser. It posts to the founder's own form address and shows the
|
|
3
|
+
* answer on the page: the sent line, or what went wrong with the fields still filled in. With no
|
|
4
|
+
* script the form posts as a plain HTML form, and the founder's form service answers.
|
|
5
|
+
*/
|
|
6
|
+
import { type ReactElement } from "react";
|
|
7
|
+
import type { SiteStrings } from "../../i18n/strings.js";
|
|
8
|
+
import { type BookingChoices } from "./booking-fields.js";
|
|
9
|
+
import type { SlotRules, TakenSlot } from "./booking-slots.js";
|
|
10
|
+
export type BookingRequestProps = BookingChoices & {
|
|
11
|
+
/** Where the request posts: the founder's form service or calendar tool. */
|
|
12
|
+
readonly action: string;
|
|
13
|
+
readonly strings: SiteStrings;
|
|
14
|
+
/** The slots layout: the calendar's rules, the places already taken and its first day. */
|
|
15
|
+
readonly slots?: {
|
|
16
|
+
readonly rules: SlotRules;
|
|
17
|
+
readonly taken: readonly TakenSlot[];
|
|
18
|
+
readonly today?: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare function BookingRequest(props: BookingRequestProps): ReactElement;
|
|
22
|
+
//# sourceMappingURL=booking-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"booking-request.d.ts","sourceRoot":"","sources":["../../../src/website/blocks/booking-request.tsx"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,OAAO,EAAkB,KAAK,YAAY,EAAmB,MAAM,OAAO,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,KAAK,cAAc,EAA8B,MAAM,qBAAqB,CAAC;AAEtF,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/D,MAAM,MAAM,mBAAmB,GAAG,cAAc,GAAG;IAClD,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,0FAA0F;IAC1F,QAAQ,CAAC,KAAK,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAC;QAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9G,CAAC;AAiBF,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,YAAY,CAmCvE"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* The booking request in the browser. It posts to the founder's own form address and shows the
|
|
5
|
+
* answer on the page: the sent line, or what went wrong with the fields still filled in. With no
|
|
6
|
+
* script the form posts as a plain HTML form, and the founder's form service answers.
|
|
7
|
+
*/
|
|
8
|
+
import { useId, useState } from "react";
|
|
9
|
+
import { BookingDone, BookingFields } from "./booking-fields.js";
|
|
10
|
+
import { SlotPicker } from "./booking-slot-picker.js";
|
|
11
|
+
async function send(action, form) {
|
|
12
|
+
try {
|
|
13
|
+
const response = await fetch(action, {
|
|
14
|
+
method: "POST",
|
|
15
|
+
body: new FormData(form),
|
|
16
|
+
headers: { Accept: "application/json" },
|
|
17
|
+
});
|
|
18
|
+
if (!response.ok)
|
|
19
|
+
console.error(`booking request refused: ${response.status} from ${action}`);
|
|
20
|
+
return response.ok;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
console.error(`booking request failed: ${action}`, error);
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function BookingRequest(props) {
|
|
28
|
+
const id = useId();
|
|
29
|
+
const [state, setState] = useState("ready");
|
|
30
|
+
if (state === "done")
|
|
31
|
+
return _jsx(BookingDone, { text: props.strings.bookingDone });
|
|
32
|
+
async function submit(event) {
|
|
33
|
+
// A page that already holds the submit, such as a preview that sends no forms, keeps it.
|
|
34
|
+
if (event.defaultPrevented)
|
|
35
|
+
return;
|
|
36
|
+
event.preventDefault();
|
|
37
|
+
setState("sending");
|
|
38
|
+
setState((await send(props.action, event.currentTarget)) ? "done" : "problem");
|
|
39
|
+
}
|
|
40
|
+
return (_jsx("form", { method: "post", action: props.action, onSubmit: submit, className: "site-form", children: _jsx(BookingFields, { id: id, strings: props.strings, services: props.services, guests: props.guests, times: props.times, busy: state === "sending", message: state === "problem" ? props.strings.bookingProblem : undefined, picker: props.slots ? (_jsx(SlotPicker, { id: id, rules: props.slots.rules, taken: props.slots.taken, today: props.slots.today, strings: props.strings })) : undefined }) }));
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=booking-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"booking-request.js","sourceRoot":"","sources":["../../../src/website/blocks/booking-request.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb;;;;GAIG;AACH,OAAO,EAAqC,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE3E,OAAO,EAAuB,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAatD,KAAK,UAAU,IAAI,CAAC,MAAc,EAAE,IAAqB;IACxD,IAAI,CAAC;QACJ,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,MAAM,EAAE;YACpC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,QAAQ,CAAC,IAAI,CAAC;YACxB,OAAO,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE;SACvC,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,EAAE;YAAE,OAAO,CAAC,KAAK,CAAC,4BAA4B,QAAQ,CAAC,MAAM,SAAS,MAAM,EAAE,CAAC,CAAC;QAC9F,OAAO,QAAQ,CAAC,EAAE,CAAC;IACpB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CAAC,2BAA2B,MAAM,EAAE,EAAE,KAAK,CAAC,CAAC;QAC1D,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAA0B;IACxD,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;IACnB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe,OAAO,CAAC,CAAC;IAC1D,IAAI,KAAK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"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The visitor's booking calendar: a month of days, then the times of the day picked. Days and
|
|
3
|
+
* times are radio buttons, so the browser's own form check asks for both and the arrow keys move
|
|
4
|
+
* between them. A day or a time with no place left can be seen and not picked. The words come
|
|
5
|
+
* from the site's table, the month and weekday names from the browser's Intl in its language.
|
|
6
|
+
*/
|
|
7
|
+
import { type ReactElement } from "react";
|
|
8
|
+
import type { SiteStrings } from "../../i18n/strings.js";
|
|
9
|
+
import { type SlotRules, type TakenSlot } from "./booking-slots.js";
|
|
10
|
+
export type SlotPickerProps = {
|
|
11
|
+
readonly id: string;
|
|
12
|
+
readonly rules: SlotRules;
|
|
13
|
+
readonly taken: readonly TakenSlot[];
|
|
14
|
+
/** The first bookable day. Without it the calendar starts on the visitor's own today. */
|
|
15
|
+
readonly today?: string;
|
|
16
|
+
readonly strings: SiteStrings;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* The calendar starts on the first open day. With no `today` it waits for the browser's date, so
|
|
20
|
+
* a page built once shows the right month on any day; the space it takes is kept meanwhile.
|
|
21
|
+
*/
|
|
22
|
+
export declare function SlotPicker(props: SlotPickerProps): ReactElement;
|
|
23
|
+
//# sourceMappingURL=booking-slot-picker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"booking-slot-picker.d.ts","sourceRoot":"","sources":["../../../src/website/blocks/booking-slot-picker.tsx"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,OAAO,EAAE,KAAK,YAAY,EAAuB,MAAM,OAAO,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAQN,KAAK,SAAS,EAEd,KAAK,SAAS,EAEd,MAAM,oBAAoB,CAAC;AAK5B,MAAM,MAAM,eAAe,GAAG;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAC;IACrC,yFAAyF;IACzF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;CAC9B,CAAC;AA6IF;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,YAAY,CAoB/D"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* The visitor's booking calendar: a month of days, then the times of the day picked. Days and
|
|
5
|
+
* times are radio buttons, so the browser's own form check asks for both and the arrow keys move
|
|
6
|
+
* between them. A day or a time with no place left can be seen and not picked. The words come
|
|
7
|
+
* from the site's table, the month and weekday names from the browser's Intl in its language.
|
|
8
|
+
*/
|
|
9
|
+
import { useEffect, useState } from "react";
|
|
10
|
+
import { fill } from "../../i18n/strings.js";
|
|
11
|
+
import { addDays, addMonths, dayState, firstOpenDay, monthWeeks, placesLeft, slotState, timesOn, } from "./booking-slots.js";
|
|
12
|
+
import { BlockIcon } from "./icons.js";
|
|
13
|
+
import { keyed } from "./list.js";
|
|
14
|
+
import { visitorToday } from "./visitor-date.js";
|
|
15
|
+
function dateText(locale, date, options) {
|
|
16
|
+
return new Intl.DateTimeFormat(locale, { ...options, timeZone: "UTC" }).format(new Date(`${date}T00:00:00Z`));
|
|
17
|
+
}
|
|
18
|
+
/** The weekday names, Monday first, from a week that starts on a Monday. */
|
|
19
|
+
const weekdayNames = (locale) => Array.from({ length: 7 }, (_, index) => dateText(locale, addDays("2026-11-16", index), { weekday: "short" }));
|
|
20
|
+
function Day({ date, state, picked, locale, onPick }) {
|
|
21
|
+
return (_jsxs("label", { className: "site-slot-day", "data-state": state, children: [_jsx("input", { type: "radio", name: "date", value: date, required: true, disabled: state !== "open", checked: picked, onChange: () => onPick(date), className: "sr-only" }), _jsx("span", { "aria-hidden": "true", children: Number(date.slice(8)) }), _jsx("span", { className: "sr-only", children: dateText(locale, date, { weekday: "long", day: "numeric", month: "long" }) })] }));
|
|
22
|
+
}
|
|
23
|
+
/** The month with its buttons: never before today's month, never past the last bookable day. */
|
|
24
|
+
function Month({ props, today, picked, onPick }) {
|
|
25
|
+
const s = props.strings;
|
|
26
|
+
const [month, setMonth] = useState((picked ?? today).slice(0, 7));
|
|
27
|
+
const last = addDays(today, props.rules.ahead - 1).slice(0, 7);
|
|
28
|
+
const step = (months) => () => setMonth(addMonths(month, months));
|
|
29
|
+
return (_jsxs("fieldset", { className: "site-slots-days", children: [_jsx("legend", { className: "site-slots-legend", children: s.bookingPickDay }), _jsxs("div", { className: "site-slots-head", children: [_jsxs("button", { type: "button", onClick: step(-1), disabled: month <= today.slice(0, 7), className: "site-slots-step", children: [_jsx(BlockIcon, { name: "arrow-left", className: "size-4 rtl:rotate-180" }), _jsx("span", { className: "sr-only", children: s.bookingPrevMonth })] }), _jsx("p", { className: "site-slots-month", "aria-live": "polite", children: dateText(s.dateLocale, `${month}-01`, { month: "long", year: "numeric" }) }), _jsxs("button", { type: "button", onClick: step(1), disabled: month >= last, className: "site-slots-step", children: [_jsx(BlockIcon, { name: "arrow-right", className: "size-4 rtl:rotate-180" }), _jsx("span", { className: "sr-only", children: s.bookingNextMonth })] })] }), _jsxs("div", { className: "site-slots-grid", children: [keyed(weekdayNames(s.dateLocale)).map(({ key, item }) => (_jsx("span", { className: "site-slots-weekday", "aria-hidden": "true", children: item }, key))), keyed(monthWeeks(month).flat()).map(({ key, item: date }) => date ? (_jsx(Day, { date: date, state: dayState(props.rules, props.taken, date, today), picked: picked === date, locale: s.dateLocale, onPick: onPick }, key)) : (_jsx("span", {}, key)))] })] }));
|
|
30
|
+
}
|
|
31
|
+
/** The times of the day picked, each with its places left; a full one can be seen and not picked. */
|
|
32
|
+
function Times({ props, date, time: picked, onPick }) {
|
|
33
|
+
const s = props.strings;
|
|
34
|
+
const times = date ? timesOn(props.rules, date) : [];
|
|
35
|
+
return (_jsxs("fieldset", { className: "site-slots-times", children: [_jsx("legend", { className: "site-slots-legend", children: date ? dateText(s.dateLocale, date, { weekday: "long", day: "numeric", month: "long" }) : s.bookingPickTime }), date && times.length > 0 ? (_jsx("div", { className: "site-slots-time-list", children: keyed(times).map(({ key, item: time }) => {
|
|
36
|
+
const state = slotState(props.rules, props.taken, date, time);
|
|
37
|
+
const left = placesLeft(props.rules, props.taken, date, time);
|
|
38
|
+
return (_jsxs("label", { className: "site-slot-time", "data-state": state, children: [_jsx("input", { type: "radio", name: "time", value: time, required: true, disabled: state === "full", checked: picked === time, onChange: () => onPick(time), className: "sr-only" }), _jsx("span", { className: "site-slot-time-value", children: time }), state === "free" ? null : (_jsx("span", { className: "site-slot-time-left", children: state === "full" ? s.bookingFull : fill(s.bookingPlacesLeft, String(left)) }))] }, key));
|
|
39
|
+
}) })) : (_jsx("p", { className: "site-slots-empty", children: date ? s.bookingNoTimes : s.bookingPickDay }))] }));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The calendar starts on the first open day. With no `today` it waits for the browser's date, so
|
|
43
|
+
* a page built once shows the right month on any day; the space it takes is kept meanwhile.
|
|
44
|
+
*/
|
|
45
|
+
export function SlotPicker(props) {
|
|
46
|
+
const [today, setToday] = useState(props.today);
|
|
47
|
+
const [picked, setPicked] = useState(undefined);
|
|
48
|
+
const [time, setTime] = useState(undefined);
|
|
49
|
+
// A new day clears the time: the same hour may be full or closed on it.
|
|
50
|
+
const pickDay = (date) => {
|
|
51
|
+
setPicked(date);
|
|
52
|
+
setTime(undefined);
|
|
53
|
+
};
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (!props.today)
|
|
56
|
+
setToday(visitorToday());
|
|
57
|
+
}, [props.today]);
|
|
58
|
+
if (!today)
|
|
59
|
+
return _jsx("div", { className: "site-slots", "aria-busy": "true" });
|
|
60
|
+
const day = picked ?? firstOpenDay(props.rules, props.taken, today);
|
|
61
|
+
return (_jsxs("div", { className: "site-slots", children: [_jsx(Month, { props: props, today: today, picked: day, onPick: pickDay }), _jsx(Times, { props: props, date: day, time: time, onPick: setTime })] }));
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=booking-slot-picker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"booking-slot-picker.js","sourceRoot":"","sources":["../../../src/website/blocks/booking-slot-picker.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb;;;;;GAKG;AACH,OAAO,EAAqB,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE/D,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EACN,OAAO,EACP,SAAS,EAET,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,UAAU,EAEV,SAAS,EAET,OAAO,GACP,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAWjD,SAAS,QAAQ,CAAC,MAAc,EAAE,IAAY,EAAE,OAAmC;IAClF,OAAO,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC;AAC/G,CAAC;AAED,4EAA4E;AAC5E,MAAM,YAAY,GAAG,CAAC,MAAc,EAAqB,EAAE,CAC1D,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,EAAE,KAAK,CAA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MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAqB,SAAS,CAAC,CAAC;IACpE,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAqB,SAAS,CAAC,CAAC;IAChE,wEAAwE;IACxE,MAAM,OAAO,GAAG,CAAC,IAAY,EAAQ,EAAE;QACtC,SAAS,CAAC,IAAI,CAAC,CAAC;QAChB,OAAO,CAAC,SAAS,CAAC,CAAC;IACpB,CAAC,CAAC;IACF,SAAS,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,KAAK,CAAC,KAAK;YAAE,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC;IAC5C,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAClB,IAAI,CAAC,KAAK;QAAE,OAAO,cAAK,SAAS,EAAC,YAAY,eAAW,MAAM,GAAG,CAAC;IACnE,MAAM,GAAG,GAAG,MAAM,IAAI,YAAY,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACpE,OAAO,CACN,eAAK,SAAS,EAAC,YAAY,aAC1B,KAAC,KAAK,IAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAI,EACnE,KAAC,KAAK,IAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAI,IAC1D,CACN,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rules of a booking calendar and the answer to "is this time free?". Pure functions with no
|
|
3
|
+
* clock: the caller passes today. The visitor's calendar and the owner's view read the same
|
|
4
|
+
* answers, so a time the owner sees as full is never offered to a visitor. A static site cannot
|
|
5
|
+
* stop two visitors who book the same place at the same moment; the backend that stores the
|
|
6
|
+
* bookings must check these rules again when it takes a request.
|
|
7
|
+
*
|
|
8
|
+
* A date is "YYYY-MM-DD" and a time is "HH:MM", both in the business's own time zone.
|
|
9
|
+
*/
|
|
10
|
+
/** The hours of some days of the week: 0 is Sunday, 6 is Saturday. */
|
|
11
|
+
export type OpeningSpan = {
|
|
12
|
+
readonly days: readonly number[];
|
|
13
|
+
readonly from: string;
|
|
14
|
+
readonly to: string;
|
|
15
|
+
};
|
|
16
|
+
export type SlotRules = {
|
|
17
|
+
readonly hours: readonly OpeningSpan[];
|
|
18
|
+
/** The length of one slot in minutes: a visit, or the time a table is held. */
|
|
19
|
+
readonly minutes: number;
|
|
20
|
+
/** The bookings one slot takes: 1 for a barber or a coach, the tables of a restaurant. */
|
|
21
|
+
readonly capacity: number;
|
|
22
|
+
/** How many days ahead, today included, a visitor may book. */
|
|
23
|
+
readonly ahead: number;
|
|
24
|
+
/** Dates the business is closed, such as a public holiday. */
|
|
25
|
+
readonly closed?: readonly string[];
|
|
26
|
+
};
|
|
27
|
+
/** A booking that holds one place of a slot. */
|
|
28
|
+
export type TakenSlot = {
|
|
29
|
+
readonly date: string;
|
|
30
|
+
readonly time: string;
|
|
31
|
+
};
|
|
32
|
+
export type SlotState = "free" | "few" | "full";
|
|
33
|
+
export type DayState = "open" | "full" | "closed" | "past";
|
|
34
|
+
/** A slot rule that cannot work. It names the rule and the fix, so a founder can correct it. */
|
|
35
|
+
export declare class SlotRulesError extends Error {
|
|
36
|
+
constructor(rule: string, remedy: string);
|
|
37
|
+
}
|
|
38
|
+
export declare function minutesOf(time: string): number;
|
|
39
|
+
export declare function timeOf(minutes: number): string;
|
|
40
|
+
/** The date `days` after `date` (before it when negative). */
|
|
41
|
+
export declare function addDays(date: string, days: number): string;
|
|
42
|
+
/** 0 for Sunday to 6 for Saturday. */
|
|
43
|
+
export declare function weekdayOf(date: string): number;
|
|
44
|
+
/** Checks the rules once, so a bad rule fails with its name rather than as an empty calendar. */
|
|
45
|
+
export declare function checkRules(rules: SlotRules): SlotRules;
|
|
46
|
+
/** The start times of the slots on a date, in order, with no slot running past closing time. */
|
|
47
|
+
export declare function timesOn(rules: SlotRules, date: string): readonly string[];
|
|
48
|
+
/** The places still free in one slot. */
|
|
49
|
+
export declare function placesLeft(rules: SlotRules, taken: readonly TakenSlot[], date: string, time: string): number;
|
|
50
|
+
/** Full, nearly full (a quarter of the places or fewer, when a slot has more than one) or free. */
|
|
51
|
+
export declare function slotState(rules: SlotRules, taken: readonly TakenSlot[], date: string, time: string): SlotState;
|
|
52
|
+
/** Whether a visitor may pick a date: before today, after the last bookable day, closed, full or open. */
|
|
53
|
+
export declare function dayState(rules: SlotRules, taken: readonly TakenSlot[], date: string, today: string): DayState;
|
|
54
|
+
/** The first open date from today, or nothing when every bookable day is full or closed. */
|
|
55
|
+
export declare function firstOpenDay(rules: SlotRules, taken: readonly TakenSlot[], today: string): string | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* The weeks of a month, Monday first: each week holds seven dates, or null where the day belongs
|
|
58
|
+
* to the month before or after.
|
|
59
|
+
*/
|
|
60
|
+
export declare function monthWeeks(month: string): readonly (readonly (string | null)[])[];
|
|
61
|
+
/** The month before or after "YYYY-MM". */
|
|
62
|
+
export declare function addMonths(month: string, months: number): string;
|
|
63
|
+
//# sourceMappingURL=booking-slots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"booking-slots.d.ts","sourceRoot":"","sources":["../../../src/website/blocks/booking-slots.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,sEAAsE;AACtE,MAAM,MAAM,WAAW,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA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GAAG,SAAS,MAAM,EAAE,CAUzE;AAED,yCAAyC;AACzC,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAG5G;AAED,mGAAmG;AACnG,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,CAK9G;AAED,0GAA0G;AAC1G,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,CAM7G;AAED,4FAA4F;AAC5F,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI7G;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,EAAE,CAajF;AAED,2CAA2C;AAC3C,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAI/D"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rules of a booking calendar and the answer to "is this time free?". Pure functions with no
|
|
3
|
+
* clock: the caller passes today. The visitor's calendar and the owner's view read the same
|
|
4
|
+
* answers, so a time the owner sees as full is never offered to a visitor. A static site cannot
|
|
5
|
+
* stop two visitors who book the same place at the same moment; the backend that stores the
|
|
6
|
+
* bookings must check these rules again when it takes a request.
|
|
7
|
+
*
|
|
8
|
+
* A date is "YYYY-MM-DD" and a time is "HH:MM", both in the business's own time zone.
|
|
9
|
+
*/
|
|
10
|
+
/** A slot rule that cannot work. It names the rule and the fix, so a founder can correct it. */
|
|
11
|
+
export class SlotRulesError extends Error {
|
|
12
|
+
constructor(rule, remedy) {
|
|
13
|
+
super(`Booking slots: ${rule} is not valid: ${remedy}`);
|
|
14
|
+
this.name = "SlotRulesError";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const TIME = /^([01]\d|2[0-3]):([0-5]\d)$/;
|
|
18
|
+
const DATE = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
|
|
19
|
+
export function minutesOf(time) {
|
|
20
|
+
const match = TIME.exec(time);
|
|
21
|
+
if (!match)
|
|
22
|
+
throw new SlotRulesError(`the time "${time}"`, 'write it as "HH:MM", such as "09:30"');
|
|
23
|
+
return Number(match[1]) * 60 + Number(match[2]);
|
|
24
|
+
}
|
|
25
|
+
export function timeOf(minutes) {
|
|
26
|
+
return `${String(Math.floor(minutes / 60)).padStart(2, "0")}:${String(minutes % 60).padStart(2, "0")}`;
|
|
27
|
+
}
|
|
28
|
+
function utcDate(date) {
|
|
29
|
+
if (!DATE.test(date))
|
|
30
|
+
throw new SlotRulesError(`the date "${date}"`, 'write it as "YYYY-MM-DD"');
|
|
31
|
+
return new Date(`${date}T00:00:00Z`);
|
|
32
|
+
}
|
|
33
|
+
/** The date `days` after `date` (before it when negative). */
|
|
34
|
+
export function addDays(date, days) {
|
|
35
|
+
const next = utcDate(date);
|
|
36
|
+
next.setUTCDate(next.getUTCDate() + days);
|
|
37
|
+
return next.toISOString().slice(0, 10);
|
|
38
|
+
}
|
|
39
|
+
/** 0 for Sunday to 6 for Saturday. */
|
|
40
|
+
export function weekdayOf(date) {
|
|
41
|
+
return utcDate(date).getUTCDay();
|
|
42
|
+
}
|
|
43
|
+
/** Checks the rules once, so a bad rule fails with its name rather than as an empty calendar. */
|
|
44
|
+
export function checkRules(rules) {
|
|
45
|
+
if (!Number.isInteger(rules.minutes) || rules.minutes < 5)
|
|
46
|
+
throw new SlotRulesError("minutes", "give the slot length in whole minutes, 5 or more");
|
|
47
|
+
if (!Number.isInteger(rules.capacity) || rules.capacity < 1)
|
|
48
|
+
throw new SlotRulesError("capacity", "give the places of one slot as a whole number, 1 or more");
|
|
49
|
+
if (!Number.isInteger(rules.ahead) || rules.ahead < 1)
|
|
50
|
+
throw new SlotRulesError("ahead", "give the days a visitor may book ahead, 1 or more");
|
|
51
|
+
if (rules.hours.length === 0)
|
|
52
|
+
throw new SlotRulesError("hours", "add the open days and hours");
|
|
53
|
+
for (const span of rules.hours) {
|
|
54
|
+
if (span.days.some((day) => !Number.isInteger(day) || day < 0 || day > 6))
|
|
55
|
+
throw new SlotRulesError("hours.days", "use 0 for Sunday to 6 for Saturday");
|
|
56
|
+
if (minutesOf(span.to) - minutesOf(span.from) < rules.minutes)
|
|
57
|
+
throw new SlotRulesError(`hours ${span.from} to ${span.to}`, "leave room for at least one slot");
|
|
58
|
+
}
|
|
59
|
+
for (const date of rules.closed ?? [])
|
|
60
|
+
utcDate(date);
|
|
61
|
+
return rules;
|
|
62
|
+
}
|
|
63
|
+
/** The start times of the slots on a date, in order, with no slot running past closing time. */
|
|
64
|
+
export function timesOn(rules, date) {
|
|
65
|
+
if (rules.closed?.includes(date))
|
|
66
|
+
return [];
|
|
67
|
+
const weekday = weekdayOf(date);
|
|
68
|
+
const starts = rules.hours
|
|
69
|
+
.filter((span) => span.days.includes(weekday))
|
|
70
|
+
.flatMap((span) => {
|
|
71
|
+
const count = Math.floor((minutesOf(span.to) - minutesOf(span.from)) / rules.minutes);
|
|
72
|
+
return Array.from({ length: count }, (_, index) => minutesOf(span.from) + index * rules.minutes);
|
|
73
|
+
});
|
|
74
|
+
return [...new Set(starts)].sort((a, b) => a - b).map(timeOf);
|
|
75
|
+
}
|
|
76
|
+
/** The places still free in one slot. */
|
|
77
|
+
export function placesLeft(rules, taken, date, time) {
|
|
78
|
+
const booked = taken.filter((slot) => slot.date === date && slot.time === time).length;
|
|
79
|
+
return Math.max(0, rules.capacity - booked);
|
|
80
|
+
}
|
|
81
|
+
/** Full, nearly full (a quarter of the places or fewer, when a slot has more than one) or free. */
|
|
82
|
+
export function slotState(rules, taken, date, time) {
|
|
83
|
+
const left = placesLeft(rules, taken, date, time);
|
|
84
|
+
if (left === 0)
|
|
85
|
+
return "full";
|
|
86
|
+
if (rules.capacity > 1 && left <= Math.max(1, Math.floor(rules.capacity / 4)))
|
|
87
|
+
return "few";
|
|
88
|
+
return "free";
|
|
89
|
+
}
|
|
90
|
+
/** Whether a visitor may pick a date: before today, after the last bookable day, closed, full or open. */
|
|
91
|
+
export function dayState(rules, taken, date, today) {
|
|
92
|
+
if (date < today)
|
|
93
|
+
return "past";
|
|
94
|
+
if (date > addDays(today, rules.ahead - 1))
|
|
95
|
+
return "closed";
|
|
96
|
+
const times = timesOn(rules, date);
|
|
97
|
+
if (times.length === 0)
|
|
98
|
+
return "closed";
|
|
99
|
+
return times.every((time) => placesLeft(rules, taken, date, time) === 0) ? "full" : "open";
|
|
100
|
+
}
|
|
101
|
+
/** The first open date from today, or nothing when every bookable day is full or closed. */
|
|
102
|
+
export function firstOpenDay(rules, taken, today) {
|
|
103
|
+
return Array.from({ length: rules.ahead }, (_, index) => addDays(today, index)).find((date) => dayState(rules, taken, date, today) === "open");
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The weeks of a month, Monday first: each week holds seven dates, or null where the day belongs
|
|
107
|
+
* to the month before or after.
|
|
108
|
+
*/
|
|
109
|
+
export function monthWeeks(month) {
|
|
110
|
+
const first = `${month}-01`;
|
|
111
|
+
const lead = (weekdayOf(first) + 6) % 7;
|
|
112
|
+
const next = `${addDays(first, 31).slice(0, 7)}-01`;
|
|
113
|
+
const length = Math.round((utcDate(next).getTime() - utcDate(first).getTime()) / 86_400_000);
|
|
114
|
+
const cells = [
|
|
115
|
+
...Array.from({ length: lead }, () => null),
|
|
116
|
+
...Array.from({ length }, (_, index) => addDays(first, index)),
|
|
117
|
+
];
|
|
118
|
+
const weeks = Math.ceil(cells.length / 7);
|
|
119
|
+
return Array.from({ length: weeks }, (_, week) => Array.from({ length: 7 }, (_, day) => cells[week * 7 + day] ?? null));
|
|
120
|
+
}
|
|
121
|
+
/** The month before or after "YYYY-MM". */
|
|
122
|
+
export function addMonths(month, months) {
|
|
123
|
+
const date = utcDate(`${month}-01`);
|
|
124
|
+
date.setUTCMonth(date.getUTCMonth() + months);
|
|
125
|
+
return date.toISOString().slice(0, 7);
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=booking-slots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"booking-slots.js","sourceRoot":"","sources":["../../../src/website/blocks/booking-slots.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAuBH,gGAAgG;AAChG,MAAM,OAAO,cAAe,SAAQ,KAAK;IACxC,YAAY,IAAY,EAAE,MAAc;QACvC,KAAK,CAAC,kBAAkB,IAAI,kBAAkB,MAAM,EAAE,CAAC,CAAC;QACxD,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC9B,CAAC;CACD;AAED,MAAM,IAAI,GAAG,6BAA6B,CAAC;AAC3C,MAAM,IAAI,GAAG,+CAA+C,CAAC;AAE7D,MAAM,UAAU,SAAS,CAAC,IAAY;IACrC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,cAAc,CAAC,aAAa,IAAI,GAAG,EAAE,sCAAsC,CAAC,CAAC;IACnG,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,OAAe;IACrC,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EA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,MAAc;IACtD,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,KAAK,KAAK,CAAC,CAAC;IACpC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,CAAC;IAC9C,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Booking: a table at a restaurant, or an appointment at a barber, a salon, a clinic or a coach.
|
|
3
|
+
* The site has no server of its own, so the request goes to the founder's own form service, or
|
|
4
|
+
* the block sends the visitor to the founder's own calendar page.
|
|
5
|
+
*/
|
|
6
|
+
import type { ReactElement, ReactNode } from "react";
|
|
7
|
+
import type { SiteStrings } from "../../i18n/strings.js";
|
|
8
|
+
import type { BookingChoices } from "./booking-fields.js";
|
|
9
|
+
import { type SlotRules, type TakenSlot } from "./booking-slots.js";
|
|
10
|
+
import { type Action, type Anchor } from "./parts.js";
|
|
11
|
+
export declare const BOOKING_VARIANTS: readonly ["form", "split", "calendar", "slots"];
|
|
12
|
+
export type BookingVariant = (typeof BOOKING_VARIANTS)[number];
|
|
13
|
+
export type BookingProps = Anchor & BookingChoices & {
|
|
14
|
+
readonly title?: string;
|
|
15
|
+
readonly intro?: string;
|
|
16
|
+
/** Where the request posts, for the form and split layouts: the founder's form service. */
|
|
17
|
+
readonly action?: string;
|
|
18
|
+
/** The founder's own booking page, for the calendar layout: its button. */
|
|
19
|
+
readonly calendar?: Action;
|
|
20
|
+
/** Facts a visitor reads before booking, such as how long a visit takes or when to cancel. */
|
|
21
|
+
readonly details?: readonly {
|
|
22
|
+
readonly label: string;
|
|
23
|
+
readonly value: string;
|
|
24
|
+
}[];
|
|
25
|
+
/** The slots layout: open days and hours, slot length, places per slot, days ahead. */
|
|
26
|
+
readonly slots?: SlotRules;
|
|
27
|
+
/** The slots already booked. Until a backend serves them, the content or a preview gives them. */
|
|
28
|
+
readonly taken?: readonly TakenSlot[];
|
|
29
|
+
/** The calendar's first day, for a preview. A site leaves it out: the visitor's own today. */
|
|
30
|
+
readonly today?: string;
|
|
31
|
+
/** A line under the form or the button, such as when the founder answers. */
|
|
32
|
+
readonly note?: string;
|
|
33
|
+
readonly strings: SiteStrings;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* The request form under the heading (form), the form beside the heading and the facts (split),
|
|
37
|
+
* one button to the founder's own calendar page (calendar), or a calendar of free days and times
|
|
38
|
+
* over the form (slots). `form` takes the live form's place
|
|
39
|
+
* for a page that shows the form in one state; content never passes it.
|
|
40
|
+
*/
|
|
41
|
+
export declare function bookingView(variant: BookingVariant, props: BookingProps, form?: ReactNode): ReactElement;
|
|
42
|
+
//# sourceMappingURL=booking-views.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"booking-views.d.ts","sourceRoot":"","sources":["../../../src/website/blocks/booking-views.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,EAAc,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGhF,OAAO,EAAE,KAAK,MAAM,EAAc,KAAK,MAAM,EAAkC,MAAM,YAAY,CAAC;AAGlG,eAAO,MAAM,gBAAgB,iDAAyB,CAAC;AACvD,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,MAAM,MAAM,YAAY,GAAG,MAAM,GAChC,cAAc,GAAG;IAChB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,E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