@code-collective/booking-widget 1.0.10 → 1.0.12
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/CHANGELOG.md +46 -0
- package/README.md +500 -388
- package/dist/booking-widget.css +1 -1
- package/dist/booking-widget.js +2415 -1745
- package/dist/booking-widget.min.css +1 -1
- package/dist/booking-widget.min.js +39 -23
- package/dist/booking-widget.umd.cjs +5 -3
- package/package.json +58 -55
- package/src/lib/BookingProvider.svelte +21 -0
- package/src/lib/CartBar.svelte +26 -41
- package/src/lib/CartBarView.svelte +78 -61
- package/src/lib/CartExpiryGuard.svelte +15 -9
- package/src/lib/CartOverview.svelte +30 -20
- package/src/lib/CartOverviewButton.svelte +104 -101
- package/src/lib/Checkout.svelte +141 -128
- package/src/lib/CheckoutModal.svelte +838 -805
- package/src/lib/CheckoutPanel.svelte +121 -0
- package/src/lib/PaymentPage.svelte +191 -177
- package/src/lib/PickupPointPicker.svelte +1 -1
- package/src/lib/TicketConfigurator.svelte +166 -152
- package/src/lib/UnitCounter.svelte +16 -2
- package/src/lib/WizardPage.svelte +102 -35
- package/src/lib/app.css +0 -6
- package/src/lib/booking-context.ts +33 -0
- package/src/lib/cart-overview.svelte.ts +97 -0
- package/src/lib/config.ts +162 -153
- package/src/lib/elements/bw-cart.svelte +49 -35
- package/src/lib/elements/bw-checkout.svelte +97 -97
- package/src/lib/elements/bw-configurator.svelte +72 -56
- package/src/lib/elements/register.ts +171 -196
- package/src/lib/elements/shared.ts +18 -14
- package/src/lib/elements/theme.css +0 -6
- package/src/lib/host.svelte.ts +336 -0
- package/src/lib/index.ts +242 -196
- package/src/lib/layout.svelte.ts +52 -0
- package/src/lib/messages.ts +157 -77
- package/src/lib/peach-sdk.ts +86 -40
- package/src/lib/portal.ts +23 -0
- package/src/lib/CartExpiryGuard.test.ts +0 -331
- package/src/lib/CheckoutModal.confirm-outcome.test.ts +0 -91
- package/src/lib/CheckoutModal.payment-timeout.test.ts +0 -140
- package/src/lib/test/fixtures.ts +0 -107
- package/src/lib/test/messages-mock.ts +0 -34
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// A synchronous, in-memory stand-in for messages.ts, installed with `vi.mock('./messages', ...)` by tests
|
|
2
|
-
// that mount the widget's components. The real module rides window.postMessage, which is asynchronous and
|
|
3
|
-
// which jsdom delivers without the `source`/`origin` the real onWidgetMessage guards on - so under jsdom the
|
|
4
|
-
// components would never hear each other. This keeps the exact same contract (postMessage in, every
|
|
5
|
-
// subscribed handler out) but delivers inline, and records everything posted so a test can assert on it.
|
|
6
|
-
|
|
7
|
-
type Handler = (data: Record<string, unknown>) => void;
|
|
8
|
-
|
|
9
|
-
const handlers = new Set<Handler>();
|
|
10
|
-
|
|
11
|
-
/** Every message posted since the last reset, oldest first. */
|
|
12
|
-
export const posted: Record<string, unknown>[] = [];
|
|
13
|
-
|
|
14
|
-
export function postMessage(data: Record<string, unknown>): void {
|
|
15
|
-
posted.push(data);
|
|
16
|
-
for (const handler of [...handlers]) {
|
|
17
|
-
handler(data);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function onWidgetMessage(handler: Handler): () => void {
|
|
22
|
-
handlers.add(handler);
|
|
23
|
-
return () => handlers.delete(handler);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function resetMessages(): void {
|
|
27
|
-
handlers.clear();
|
|
28
|
-
posted.length = 0;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** The types of every message posted so far, in order - the usual thing a test wants to assert on. */
|
|
32
|
-
export function postedTypes(): string[] {
|
|
33
|
-
return posted.map((m) => String(m.type));
|
|
34
|
-
}
|