@scopetickets/checkout 0.1.3 → 0.2.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 +3 -3
- package/dist/{chunk-GJZKPJB5.js → chunk-B7AHG2OO.js} +334 -242
- package/dist/chunk-B7AHG2OO.js.map +1 -0
- package/dist/index.cjs +4523 -2628
- package/dist/index.cjs.map +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +218 -189
- package/dist/index.d.ts +218 -189
- package/dist/index.js +3925 -2109
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +109 -68
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.css +20 -2
- package/dist/pickers.css.map +1 -1
- package/dist/pickers.d.cts +45 -37
- package/dist/pickers.d.ts +45 -37
- package/dist/pickers.js +1 -1
- package/dist/styles.css +39 -7
- package/package.json +11 -9
- package/dist/chunk-GJZKPJB5.js.map +0 -1
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
useState
|
|
9
9
|
} from "react";
|
|
10
10
|
|
|
11
|
-
// src/
|
|
11
|
+
// ../checkout-core/src/motion/island-motion.ts
|
|
12
12
|
var SURFACE_MORPH_MS = 250;
|
|
13
13
|
var SURFACE_DAMPING = 0.82;
|
|
14
14
|
var SURFACE_SPRING = {
|
|
@@ -39,18 +39,6 @@ function springAt(spring, t) {
|
|
|
39
39
|
const value = 1 - Math.exp(-z * wn * t) * (Math.cos(wd * t) + z / Math.sqrt(1 - z * z) * Math.sin(wd * t));
|
|
40
40
|
return spring.clampOvershoot ? Math.min(value, 1) : value;
|
|
41
41
|
}
|
|
42
|
-
function springEasing(spring, samples = 40) {
|
|
43
|
-
const duration = settleMs(spring) / 1e3;
|
|
44
|
-
const arrival = Math.min(springAt(spring, duration), 1);
|
|
45
|
-
const points = [];
|
|
46
|
-
for (let i = 0; i <= samples; i += 1) {
|
|
47
|
-
const raw = springAt(spring, i / samples * duration);
|
|
48
|
-
const scaled = arrival <= 0 ? raw : raw / arrival;
|
|
49
|
-
const value = i === samples ? 1 : spring.clampOvershoot ? Math.min(1, scaled) : scaled;
|
|
50
|
-
points.push(Number(value.toFixed(4)).toString());
|
|
51
|
-
}
|
|
52
|
-
return `linear(${points.join(", ")})`;
|
|
53
|
-
}
|
|
54
42
|
var OUTGOING_FADE_MS = 125;
|
|
55
43
|
var SURFACE_MORPH_DELAY_MS = OUTGOING_FADE_MS;
|
|
56
44
|
var INCOMING_FADE_DELAY_MS = SURFACE_MORPH_DELAY_MS + SURFACE_MORPH_MS;
|
|
@@ -60,8 +48,6 @@ var DAY_SWAP_OUT_MS = Math.round(OUTGOING_FADE_MS * DAY_SWAP_STRETCH);
|
|
|
60
48
|
var DAY_SWAP_IN_MS = Math.round(INCOMING_FADE_MS * DAY_SWAP_STRETCH);
|
|
61
49
|
var CARRY_MOVE_DELAY_MS = SURFACE_MORPH_DELAY_MS;
|
|
62
50
|
var CARRY_MOVE_MS = settleMs(CARRY_SPRING);
|
|
63
|
-
var ARC_LEAD_EASING = "cubic-bezier(0.61, 1, 0.88, 1)";
|
|
64
|
-
var ARC_TRAIL_EASING = "cubic-bezier(0.12, 0, 0.39, 0)";
|
|
65
51
|
var POP_SCALE = 0.95;
|
|
66
52
|
var SHIELD_POP_SCALE = 1 - (1 - POP_SCALE) / 2;
|
|
67
53
|
var POP_CONTRACT_MS = OUTGOING_FADE_MS;
|
|
@@ -149,7 +135,225 @@ function useIslandPress(scope = "island") {
|
|
|
149
135
|
return whole || !pressedHere ? handlers : { ...handlers, "data-pressed": "" };
|
|
150
136
|
}
|
|
151
137
|
|
|
152
|
-
// src/
|
|
138
|
+
// ../checkout-core/src/domain/money.ts
|
|
139
|
+
var MONEY_LOCALE = "en-IE";
|
|
140
|
+
function formatterFor(currency) {
|
|
141
|
+
return new Intl.NumberFormat(MONEY_LOCALE, { style: "currency", currency });
|
|
142
|
+
}
|
|
143
|
+
function minorUnitDigits(formatter) {
|
|
144
|
+
return formatter.resolvedOptions().maximumFractionDigits ?? 2;
|
|
145
|
+
}
|
|
146
|
+
function formatMoney(minorUnits, currency) {
|
|
147
|
+
const formatter = formatterFor(currency);
|
|
148
|
+
return formatter.format(minorUnits / 10 ** minorUnitDigits(formatter));
|
|
149
|
+
}
|
|
150
|
+
function moneyParts(minorUnits, currency) {
|
|
151
|
+
const formatter = formatterFor(currency);
|
|
152
|
+
const digits = minorUnitDigits(formatter);
|
|
153
|
+
const plain = new Intl.NumberFormat(MONEY_LOCALE, {
|
|
154
|
+
minimumFractionDigits: digits,
|
|
155
|
+
maximumFractionDigits: digits
|
|
156
|
+
});
|
|
157
|
+
const value = minorUnits / 10 ** digits;
|
|
158
|
+
const magnitude = Math.abs(value);
|
|
159
|
+
const symbol = formatter.format(magnitude).replace(plain.format(magnitude), "").replace(/\s/gu, "");
|
|
160
|
+
return { symbol, amount: plain.format(value) };
|
|
161
|
+
}
|
|
162
|
+
function widestAmount(amounts) {
|
|
163
|
+
return amounts.reduce((widest, amount) => Math.max(widest, amount.length), 0);
|
|
164
|
+
}
|
|
165
|
+
function quoteLines(quote) {
|
|
166
|
+
if (quote.kind === "NONE") return null;
|
|
167
|
+
const headline = formatMoney(quote.minorUnits, quote.currency);
|
|
168
|
+
if (quote.kind === "FROM") return { qualifier: "From", headline };
|
|
169
|
+
if (quote.kind === "SAVING") {
|
|
170
|
+
return { qualifier: `Save ${formatMoney(quote.savedMinorUnits, quote.currency)}`, headline };
|
|
171
|
+
}
|
|
172
|
+
return { qualifier: null, headline };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// ../checkout-core/src/domain/user-types.ts
|
|
176
|
+
var SOLO_KEY = "default";
|
|
177
|
+
function agreed(values) {
|
|
178
|
+
const first = values[0];
|
|
179
|
+
if (first === void 0) return null;
|
|
180
|
+
return values.every((value) => value === first) ? first : null;
|
|
181
|
+
}
|
|
182
|
+
function groupUserTypes(rows) {
|
|
183
|
+
const byName = /* @__PURE__ */ new Map();
|
|
184
|
+
for (const row of rows) {
|
|
185
|
+
if (row.Name === "") continue;
|
|
186
|
+
const group = byName.get(row.Name);
|
|
187
|
+
if (group === void 0) byName.set(row.Name, [row]);
|
|
188
|
+
else group.push(row);
|
|
189
|
+
}
|
|
190
|
+
return [...byName.entries()].map(([name, group]) => ({
|
|
191
|
+
key: name,
|
|
192
|
+
name,
|
|
193
|
+
note: agreed(group.map((row) => row.Note ?? null))
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
function partyTypes(host, fetched, asking) {
|
|
197
|
+
if (host.length > 0) return { status: "KNOWN", types: host };
|
|
198
|
+
if (fetched !== void 0) return { status: "KNOWN", types: fetched };
|
|
199
|
+
return asking ? { status: "ASKING" } : { status: "KNOWN", types: [] };
|
|
200
|
+
}
|
|
201
|
+
function assignmentFor(product, key) {
|
|
202
|
+
if (product.UserTypes === void 0) return key;
|
|
203
|
+
const offered = product.UserTypes ?? [];
|
|
204
|
+
const byName = offered.find((type) => type.Name === key);
|
|
205
|
+
if (byName !== void 0) return byName.AssignmentKey;
|
|
206
|
+
return offered.some((type) => type.AssignmentKey === key) ? key : void 0;
|
|
207
|
+
}
|
|
208
|
+
function userTypeNames(rows) {
|
|
209
|
+
return Object.fromEntries(rows.map((row) => [row.AssignmentKey, row.Name]));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// ../checkout-core/src/domain/island-timeslots.ts
|
|
213
|
+
function slotFullness(remaining, total) {
|
|
214
|
+
if (!Number.isFinite(remaining) || remaining < 0) return null;
|
|
215
|
+
if (remaining <= 1) return remaining;
|
|
216
|
+
if (!Number.isFinite(total) || total <= 0) return null;
|
|
217
|
+
return Math.min(1, remaining / total);
|
|
218
|
+
}
|
|
219
|
+
var MAX_TIME_INPUT = 40;
|
|
220
|
+
var WALL_CLOCK = /^(?:\d{4}-\d{2}-\d{2}[T ])?(\d{2}):(\d{2})(?::\d{2})?/;
|
|
221
|
+
function parseWallClockTime(value) {
|
|
222
|
+
if (typeof value !== "string" || value.length > MAX_TIME_INPUT) return null;
|
|
223
|
+
const match = WALL_CLOCK.exec(value.trim());
|
|
224
|
+
if (!match) return null;
|
|
225
|
+
if (Number(match[1]) > 23 || Number(match[2]) > 59) return null;
|
|
226
|
+
return `${match[1]}:${match[2]}`;
|
|
227
|
+
}
|
|
228
|
+
function timeOfDayInZone(now, timeZone) {
|
|
229
|
+
const read = (zone) => {
|
|
230
|
+
const parts = new Intl.DateTimeFormat("en-GB", {
|
|
231
|
+
timeZone: zone,
|
|
232
|
+
hour: "2-digit",
|
|
233
|
+
minute: "2-digit",
|
|
234
|
+
hourCycle: "h23"
|
|
235
|
+
}).formatToParts(now);
|
|
236
|
+
const hour = parts.find((part) => part.type === "hour")?.value ?? "00";
|
|
237
|
+
const minute = parts.find((part) => part.type === "minute")?.value ?? "00";
|
|
238
|
+
return `${String(Number(hour) % 24).padStart(2, "0")}:${minute}`;
|
|
239
|
+
};
|
|
240
|
+
try {
|
|
241
|
+
return read(timeZone ?? "UTC");
|
|
242
|
+
} catch {
|
|
243
|
+
return read("UTC");
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
function dayInZone(now, timeZone) {
|
|
247
|
+
const read = (zone) => new Intl.DateTimeFormat("en-CA", {
|
|
248
|
+
timeZone: zone,
|
|
249
|
+
year: "numeric",
|
|
250
|
+
month: "2-digit",
|
|
251
|
+
day: "2-digit"
|
|
252
|
+
}).format(now);
|
|
253
|
+
try {
|
|
254
|
+
return read(timeZone ?? "UTC");
|
|
255
|
+
} catch {
|
|
256
|
+
return read("UTC");
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
var PART_OF_DAY_LABELS = {
|
|
260
|
+
OVERNIGHT: "OVERNIGHT",
|
|
261
|
+
PRE_DAWN: "PRE-DAWN",
|
|
262
|
+
EARLY_MORNING: "EARLY MORNING",
|
|
263
|
+
LATE_MORNING: "LATE MORNING",
|
|
264
|
+
EARLY_AFTERNOON: "EARLY AFTERNOON",
|
|
265
|
+
LATE_AFTERNOON: "LATE AFTERNOON",
|
|
266
|
+
EARLY_EVENING: "EARLY EVENING",
|
|
267
|
+
LATE_EVENING: "LATE EVENING"
|
|
268
|
+
};
|
|
269
|
+
function partOfDayLabel(part) {
|
|
270
|
+
return PART_OF_DAY_LABELS[part];
|
|
271
|
+
}
|
|
272
|
+
function partOfDay(time) {
|
|
273
|
+
const hour = Number(time.slice(0, 2));
|
|
274
|
+
if (hour < 3) return "OVERNIGHT";
|
|
275
|
+
if (hour < 6) return "PRE_DAWN";
|
|
276
|
+
if (hour < 9) return "EARLY_MORNING";
|
|
277
|
+
if (hour < 12) return "LATE_MORNING";
|
|
278
|
+
if (hour < 15) return "EARLY_AFTERNOON";
|
|
279
|
+
if (hour < 18) return "LATE_AFTERNOON";
|
|
280
|
+
if (hour < 21) return "EARLY_EVENING";
|
|
281
|
+
return "LATE_EVENING";
|
|
282
|
+
}
|
|
283
|
+
var MINUTES_IN_DAY = 24 * 60;
|
|
284
|
+
function minutesOfDay(time) {
|
|
285
|
+
return Number(time.slice(0, 2)) * 60 + Number(time.slice(3, 5));
|
|
286
|
+
}
|
|
287
|
+
function formatSlotRange(startTime, endTime) {
|
|
288
|
+
return endTime === null ? startTime : `${startTime} - ${endTime}`;
|
|
289
|
+
}
|
|
290
|
+
function formatSlotDuration(startTime, endTime) {
|
|
291
|
+
if (endTime === null) return null;
|
|
292
|
+
const minutes = (minutesOfDay(endTime) - minutesOfDay(startTime) + MINUTES_IN_DAY) % MINUTES_IN_DAY;
|
|
293
|
+
if (!Number.isFinite(minutes) || minutes <= 0) return null;
|
|
294
|
+
const hours = Math.floor(minutes / 60);
|
|
295
|
+
const rest = minutes % 60;
|
|
296
|
+
if (hours === 0) return `${rest}m`;
|
|
297
|
+
return rest === 0 ? `${hours}h` : `${hours}h ${rest}m`;
|
|
298
|
+
}
|
|
299
|
+
function withSelectedDay(selection, day) {
|
|
300
|
+
return selection.day === day ? selection : { day, startTime: null };
|
|
301
|
+
}
|
|
302
|
+
function withSelectedTime(selection, startTime) {
|
|
303
|
+
return { day: selection.day, startTime };
|
|
304
|
+
}
|
|
305
|
+
function hasStarted(slot, options) {
|
|
306
|
+
if (options.selection.day < options.today) return true;
|
|
307
|
+
if (options.selection.day > options.today) return false;
|
|
308
|
+
return slot.startTime <= options.nowTime;
|
|
309
|
+
}
|
|
310
|
+
function timeslotState(slot, options) {
|
|
311
|
+
if (hasStarted(slot, options)) return "PAST_BUT_RELEVANT";
|
|
312
|
+
if (slot.remaining !== null && slot.remaining <= 0) return "UNAVAILABLE";
|
|
313
|
+
return slot.startTime === options.selection.startTime ? "SELECTED" : "AVAILABLE";
|
|
314
|
+
}
|
|
315
|
+
function sameTimeslots(a, b) {
|
|
316
|
+
if (a === b) return true;
|
|
317
|
+
if (a.length !== b.length) return false;
|
|
318
|
+
return a.every((slot, index) => {
|
|
319
|
+
const other = b[index];
|
|
320
|
+
return slot.startTime === other.startTime && slot.endTime === other.endTime && slot.remaining === other.remaining;
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
function buildTimeslotGroups(slots, options) {
|
|
324
|
+
const groups = [];
|
|
325
|
+
const byPart = /* @__PURE__ */ new Map();
|
|
326
|
+
const chronological = [...slots].sort((a, b) => a.startTime.localeCompare(b.startTime));
|
|
327
|
+
const cellFor = (slot) => ({
|
|
328
|
+
slot,
|
|
329
|
+
part: partOfDay(slot.startTime),
|
|
330
|
+
state: timeslotState(slot, options),
|
|
331
|
+
duration: formatSlotDuration(slot.startTime, slot.endTime)
|
|
332
|
+
});
|
|
333
|
+
if ((options.grouping ?? "PART_OF_DAY") === "NONE") {
|
|
334
|
+
return chronological.length === 0 ? [] : [{ part: null, label: null, cells: chronological.map(cellFor) }];
|
|
335
|
+
}
|
|
336
|
+
for (const slot of chronological) {
|
|
337
|
+
const part = partOfDay(slot.startTime);
|
|
338
|
+
let group = byPart.get(part);
|
|
339
|
+
if (!group) {
|
|
340
|
+
group = { part, label: partOfDayLabel(part), cells: [] };
|
|
341
|
+
byPart.set(part, group);
|
|
342
|
+
groups.push(group);
|
|
343
|
+
}
|
|
344
|
+
group.cells.push(cellFor(slot));
|
|
345
|
+
}
|
|
346
|
+
return groups;
|
|
347
|
+
}
|
|
348
|
+
function timeslotRequest(day, startTime, schedule) {
|
|
349
|
+
if (day === void 0 || startTime === void 0 || startTime === "") return void 0;
|
|
350
|
+
const slot = schedule?.slotsByDay?.[day]?.find((candidate) => candidate.startTime === startTime);
|
|
351
|
+
if (slot === void 0) return void 0;
|
|
352
|
+
const ends = slot.endTime ?? slot.startTime;
|
|
353
|
+
return { LocalStartTime: `${slot.startTime}:00`, LocalEndTime: `${ends}:00` };
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// ../checkout-core/src/domain/island-calendar.ts
|
|
153
357
|
var HIGH_FROM = 2 / 3;
|
|
154
358
|
var MEDIUM_FROM = 1 / 3;
|
|
155
359
|
function toAvailabilityLevel(remaining) {
|
|
@@ -364,9 +568,14 @@ function formatDayChip(day) {
|
|
|
364
568
|
const at = /* @__PURE__ */ new Date(`${day}T12:00:00.000Z`);
|
|
365
569
|
return {
|
|
366
570
|
date: at.toLocaleDateString(CALENDAR_LOCALE, { day: "numeric", timeZone: "UTC" }),
|
|
367
|
-
month:
|
|
571
|
+
month: shortMonthLabel(
|
|
572
|
+
at.toLocaleDateString(CALENDAR_LOCALE, { month: "short", timeZone: "UTC" })
|
|
573
|
+
)
|
|
368
574
|
};
|
|
369
575
|
}
|
|
576
|
+
function shortMonthLabel(abbreviation) {
|
|
577
|
+
return abbreviation.replace(/\.$/, "").slice(0, 3).toUpperCase();
|
|
578
|
+
}
|
|
370
579
|
function formatDayWeekday(day) {
|
|
371
580
|
return (/* @__PURE__ */ new Date(`${day}T12:00:00.000Z`)).toLocaleDateString(CALENDAR_LOCALE, {
|
|
372
581
|
weekday: "long",
|
|
@@ -439,176 +648,39 @@ function toggleSelectedDay(selected, day) {
|
|
|
439
648
|
return selected === day ? null : day;
|
|
440
649
|
}
|
|
441
650
|
|
|
442
|
-
// src/island/island-timeslots.ts
|
|
443
|
-
function slotFullness(remaining, total) {
|
|
444
|
-
if (!Number.isFinite(remaining) || remaining < 0) return null;
|
|
445
|
-
if (remaining <= 1) return remaining;
|
|
446
|
-
if (!Number.isFinite(total) || total <= 0) return null;
|
|
447
|
-
return Math.min(1, remaining / total);
|
|
448
|
-
}
|
|
449
|
-
var MAX_TIME_INPUT = 40;
|
|
450
|
-
var WALL_CLOCK = /^(?:\d{4}-\d{2}-\d{2}[T ])?(\d{2}):(\d{2})(?::\d{2})?/;
|
|
451
|
-
function parseWallClockTime(value) {
|
|
452
|
-
if (typeof value !== "string" || value.length > MAX_TIME_INPUT) return null;
|
|
453
|
-
const match = WALL_CLOCK.exec(value.trim());
|
|
454
|
-
if (!match) return null;
|
|
455
|
-
if (Number(match[1]) > 23 || Number(match[2]) > 59) return null;
|
|
456
|
-
return `${match[1]}:${match[2]}`;
|
|
457
|
-
}
|
|
458
|
-
function timeOfDayInZone(now, timeZone) {
|
|
459
|
-
const read = (zone) => {
|
|
460
|
-
const parts = new Intl.DateTimeFormat("en-GB", {
|
|
461
|
-
timeZone: zone,
|
|
462
|
-
hour: "2-digit",
|
|
463
|
-
minute: "2-digit",
|
|
464
|
-
hourCycle: "h23"
|
|
465
|
-
}).formatToParts(now);
|
|
466
|
-
const hour = parts.find((part) => part.type === "hour")?.value ?? "00";
|
|
467
|
-
const minute = parts.find((part) => part.type === "minute")?.value ?? "00";
|
|
468
|
-
return `${String(Number(hour) % 24).padStart(2, "0")}:${minute}`;
|
|
469
|
-
};
|
|
470
|
-
try {
|
|
471
|
-
return read(timeZone ?? "UTC");
|
|
472
|
-
} catch {
|
|
473
|
-
return read("UTC");
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
var PART_OF_DAY_LABELS = {
|
|
477
|
-
OVERNIGHT: "OVERNIGHT",
|
|
478
|
-
PRE_DAWN: "PRE-DAWN",
|
|
479
|
-
EARLY_MORNING: "EARLY MORNING",
|
|
480
|
-
LATE_MORNING: "LATE MORNING",
|
|
481
|
-
EARLY_AFTERNOON: "EARLY AFTERNOON",
|
|
482
|
-
LATE_AFTERNOON: "LATE AFTERNOON",
|
|
483
|
-
EARLY_EVENING: "EARLY EVENING",
|
|
484
|
-
LATE_EVENING: "LATE EVENING"
|
|
485
|
-
};
|
|
486
|
-
function partOfDayLabel(part) {
|
|
487
|
-
return PART_OF_DAY_LABELS[part];
|
|
488
|
-
}
|
|
489
|
-
function partOfDay(time) {
|
|
490
|
-
const hour = Number(time.slice(0, 2));
|
|
491
|
-
if (hour < 3) return "OVERNIGHT";
|
|
492
|
-
if (hour < 6) return "PRE_DAWN";
|
|
493
|
-
if (hour < 9) return "EARLY_MORNING";
|
|
494
|
-
if (hour < 12) return "LATE_MORNING";
|
|
495
|
-
if (hour < 15) return "EARLY_AFTERNOON";
|
|
496
|
-
if (hour < 18) return "LATE_AFTERNOON";
|
|
497
|
-
if (hour < 21) return "EARLY_EVENING";
|
|
498
|
-
return "LATE_EVENING";
|
|
499
|
-
}
|
|
500
|
-
var MINUTES_IN_DAY = 24 * 60;
|
|
501
|
-
function minutesOfDay(time) {
|
|
502
|
-
return Number(time.slice(0, 2)) * 60 + Number(time.slice(3, 5));
|
|
503
|
-
}
|
|
504
|
-
function formatSlotRange(startTime, endTime) {
|
|
505
|
-
return endTime === null ? startTime : `${startTime} - ${endTime}`;
|
|
506
|
-
}
|
|
507
|
-
function formatSlotDuration(startTime, endTime) {
|
|
508
|
-
if (endTime === null) return null;
|
|
509
|
-
const minutes = (minutesOfDay(endTime) - minutesOfDay(startTime) + MINUTES_IN_DAY) % MINUTES_IN_DAY;
|
|
510
|
-
if (!Number.isFinite(minutes) || minutes <= 0) return null;
|
|
511
|
-
const hours = Math.floor(minutes / 60);
|
|
512
|
-
const rest = minutes % 60;
|
|
513
|
-
if (hours === 0) return `${rest}m`;
|
|
514
|
-
return rest === 0 ? `${hours}h` : `${hours}h ${rest}m`;
|
|
515
|
-
}
|
|
516
|
-
function withSelectedDay(selection, day) {
|
|
517
|
-
return selection.day === day ? selection : { day, startTime: null };
|
|
518
|
-
}
|
|
519
|
-
function withSelectedTime(selection, startTime) {
|
|
520
|
-
return { day: selection.day, startTime };
|
|
521
|
-
}
|
|
522
|
-
function hasStarted(slot, options) {
|
|
523
|
-
if (options.selection.day < options.today) return true;
|
|
524
|
-
if (options.selection.day > options.today) return false;
|
|
525
|
-
return slot.startTime <= options.nowTime;
|
|
526
|
-
}
|
|
527
|
-
function timeslotState(slot, options) {
|
|
528
|
-
if (hasStarted(slot, options)) return "PAST_BUT_RELEVANT";
|
|
529
|
-
if (slot.remaining !== null && slot.remaining <= 0) return "UNAVAILABLE";
|
|
530
|
-
return slot.startTime === options.selection.startTime ? "SELECTED" : "AVAILABLE";
|
|
531
|
-
}
|
|
532
|
-
function sameTimeslots(a, b) {
|
|
533
|
-
if (a === b) return true;
|
|
534
|
-
if (a.length !== b.length) return false;
|
|
535
|
-
return a.every((slot, index) => {
|
|
536
|
-
const other = b[index];
|
|
537
|
-
return slot.startTime === other.startTime && slot.endTime === other.endTime && slot.remaining === other.remaining;
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
function buildTimeslotGroups(slots, options) {
|
|
541
|
-
const groups = [];
|
|
542
|
-
const byPart = /* @__PURE__ */ new Map();
|
|
543
|
-
const chronological = [...slots].sort((a, b) => a.startTime.localeCompare(b.startTime));
|
|
544
|
-
const cellFor = (slot) => ({
|
|
545
|
-
slot,
|
|
546
|
-
part: partOfDay(slot.startTime),
|
|
547
|
-
state: timeslotState(slot, options),
|
|
548
|
-
duration: formatSlotDuration(slot.startTime, slot.endTime)
|
|
549
|
-
});
|
|
550
|
-
if ((options.grouping ?? "PART_OF_DAY") === "NONE") {
|
|
551
|
-
return chronological.length === 0 ? [] : [{ part: null, label: null, cells: chronological.map(cellFor) }];
|
|
552
|
-
}
|
|
553
|
-
for (const slot of chronological) {
|
|
554
|
-
const part = partOfDay(slot.startTime);
|
|
555
|
-
let group = byPart.get(part);
|
|
556
|
-
if (!group) {
|
|
557
|
-
group = { part, label: partOfDayLabel(part), cells: [] };
|
|
558
|
-
byPart.set(part, group);
|
|
559
|
-
groups.push(group);
|
|
560
|
-
}
|
|
561
|
-
group.cells.push(cellFor(slot));
|
|
562
|
-
}
|
|
563
|
-
return groups;
|
|
564
|
-
}
|
|
565
|
-
function timeslotRequest(day, startTime, schedule) {
|
|
566
|
-
if (day === void 0 || startTime === void 0 || startTime === "") return void 0;
|
|
567
|
-
const slot = schedule?.slotsByDay?.[day]?.find((candidate) => candidate.startTime === startTime);
|
|
568
|
-
if (slot === void 0) return void 0;
|
|
569
|
-
const ends = slot.endTime ?? slot.startTime;
|
|
570
|
-
return { LocalStartTime: `${slot.startTime}:00`, LocalEndTime: `${ends}:00` };
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
// src/domain/user-types.ts
|
|
574
|
-
function agreed(values) {
|
|
575
|
-
const first = values[0];
|
|
576
|
-
if (first === void 0) return null;
|
|
577
|
-
return values.every((value) => value === first) ? first : null;
|
|
578
|
-
}
|
|
579
|
-
function groupUserTypes(rows) {
|
|
580
|
-
const byName = /* @__PURE__ */ new Map();
|
|
581
|
-
for (const row of rows) {
|
|
582
|
-
if (row.Name === "") continue;
|
|
583
|
-
const group = byName.get(row.Name);
|
|
584
|
-
if (group === void 0) byName.set(row.Name, [row]);
|
|
585
|
-
else group.push(row);
|
|
586
|
-
}
|
|
587
|
-
return [...byName.entries()].map(([name, group]) => ({
|
|
588
|
-
key: name,
|
|
589
|
-
name,
|
|
590
|
-
note: agreed(group.map((row) => row.Note ?? null))
|
|
591
|
-
}));
|
|
592
|
-
}
|
|
593
|
-
function partyTypes(host, fetched, asking) {
|
|
594
|
-
if (host.length > 0) return { status: "KNOWN", types: host };
|
|
595
|
-
if (fetched !== void 0) return { status: "KNOWN", types: fetched };
|
|
596
|
-
return asking ? { status: "ASKING" } : { status: "KNOWN", types: [] };
|
|
597
|
-
}
|
|
598
|
-
function assignmentFor(product, key) {
|
|
599
|
-
if (product.UserTypes === void 0) return key;
|
|
600
|
-
const offered = product.UserTypes ?? [];
|
|
601
|
-
const byName = offered.find((type) => type.Name === key);
|
|
602
|
-
if (byName !== void 0) return byName.AssignmentKey;
|
|
603
|
-
return offered.some((type) => type.AssignmentKey === key) ? key : void 0;
|
|
604
|
-
}
|
|
605
|
-
function userTypeNames(rows) {
|
|
606
|
-
return Object.fromEntries(rows.map((row) => [row.AssignmentKey, row.Name]));
|
|
607
|
-
}
|
|
608
|
-
|
|
609
651
|
// src/island/PartyStepper.tsx
|
|
610
652
|
import { useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
611
653
|
import { MinusMarkIcon, PlusMarkIcon } from "@scopetickets/icons";
|
|
654
|
+
|
|
655
|
+
// ../checkout-core/src/view/component-copy.ts
|
|
656
|
+
var FIELD_COPY = {
|
|
657
|
+
firstName: "First Name",
|
|
658
|
+
lastName: "Last Name",
|
|
659
|
+
email: "Email",
|
|
660
|
+
countryCode: "Country Code",
|
|
661
|
+
phoneNumber: "Phone Number",
|
|
662
|
+
confirmPassword: "Confirm Password",
|
|
663
|
+
verificationCode: "Verification code"
|
|
664
|
+
};
|
|
665
|
+
var PARTY_COPY = {
|
|
666
|
+
remove: (name) => `Remove one ${name}`,
|
|
667
|
+
add: (name) => `Add one ${name}`,
|
|
668
|
+
count: (count, name) => `${count} ${name}. Change the number`,
|
|
669
|
+
field: (name) => `Number of ${name}`
|
|
670
|
+
};
|
|
671
|
+
var ACTION_COPY = {
|
|
672
|
+
cancel: "Cancel",
|
|
673
|
+
confirm: "Confirm",
|
|
674
|
+
returnToOrder: "Return to Order",
|
|
675
|
+
payNow: "Pay Now",
|
|
676
|
+
tryAgain: "Try Again"
|
|
677
|
+
};
|
|
678
|
+
var ISLAND_COPY = {
|
|
679
|
+
order: "Your order",
|
|
680
|
+
runWeeks: "Weeks of the run"
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
// src/island/PartyStepper.tsx
|
|
612
684
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
613
685
|
function UserTypeRow({
|
|
614
686
|
option,
|
|
@@ -661,7 +733,7 @@ function UserTypeStepper({
|
|
|
661
733
|
/* @__PURE__ */ jsx(
|
|
662
734
|
StepperButton,
|
|
663
735
|
{
|
|
664
|
-
label:
|
|
736
|
+
label: PARTY_COPY.remove(name),
|
|
665
737
|
onPress: onRemove,
|
|
666
738
|
kind: "remove",
|
|
667
739
|
state: chosen ? "LIVE" : "CLOSED"
|
|
@@ -686,7 +758,7 @@ function UserTypeStepper({
|
|
|
686
758
|
/* @__PURE__ */ jsx(
|
|
687
759
|
StepperButton,
|
|
688
760
|
{
|
|
689
|
-
label:
|
|
761
|
+
label: PARTY_COPY.add(name),
|
|
690
762
|
onPress: onAdd,
|
|
691
763
|
kind: "add",
|
|
692
764
|
state: atLimit ? "REFUSING" : "LIVE"
|
|
@@ -721,7 +793,7 @@ function SoloPartyStepper({ max, name, count, onSet, onRemove, onRefuse }) {
|
|
|
721
793
|
/* @__PURE__ */ jsx(
|
|
722
794
|
StepperButton,
|
|
723
795
|
{
|
|
724
|
-
label:
|
|
796
|
+
label: PARTY_COPY.remove(name),
|
|
725
797
|
onPress: onRemove,
|
|
726
798
|
kind: "remove",
|
|
727
799
|
state: count === 0 ? "REFUSING" : "LIVE"
|
|
@@ -742,7 +814,7 @@ function SoloPartyStepper({ max, name, count, onSet, onRemove, onRefuse }) {
|
|
|
742
814
|
/* @__PURE__ */ jsx(
|
|
743
815
|
StepperButton,
|
|
744
816
|
{
|
|
745
|
-
label:
|
|
817
|
+
label: PARTY_COPY.add(name),
|
|
746
818
|
onPress: () => onSet(count + 1),
|
|
747
819
|
kind: "add",
|
|
748
820
|
state: count >= max ? "REFUSING" : "LIVE"
|
|
@@ -785,7 +857,7 @@ function TypedCount({
|
|
|
785
857
|
{
|
|
786
858
|
type: "button",
|
|
787
859
|
className: valueClassName,
|
|
788
|
-
"aria-label":
|
|
860
|
+
"aria-label": PARTY_COPY.count(count, name),
|
|
789
861
|
onClick: () => setTyping(String(count)),
|
|
790
862
|
disabled: closed,
|
|
791
863
|
children: count
|
|
@@ -801,7 +873,7 @@ function TypedCount({
|
|
|
801
873
|
pattern: "[0-9]*",
|
|
802
874
|
size: 1,
|
|
803
875
|
ref: field,
|
|
804
|
-
"aria-label":
|
|
876
|
+
"aria-label": PARTY_COPY.field(name),
|
|
805
877
|
value: typing,
|
|
806
878
|
onChange: (event) => setTyping(event.target.value.replace(/\D/g, "")),
|
|
807
879
|
onBlur: commit,
|
|
@@ -867,7 +939,6 @@ function PartyStepper({
|
|
|
867
939
|
option.key
|
|
868
940
|
)) });
|
|
869
941
|
}
|
|
870
|
-
var SOLO_KEY = "default";
|
|
871
942
|
|
|
872
943
|
// src/island/ContentFlag.tsx
|
|
873
944
|
import {
|
|
@@ -912,7 +983,7 @@ function Switch({ checked, onChange, label, size = "wide", disabled = false }) {
|
|
|
912
983
|
// src/island/CounterRing.tsx
|
|
913
984
|
import { IconGlyph } from "@scopetickets/icons";
|
|
914
985
|
|
|
915
|
-
// src/
|
|
986
|
+
// ../checkout-core/src/geometry/island-timer.ts
|
|
916
987
|
var TIMER_GRID = 20;
|
|
917
988
|
var TIMER_CENTRE = TIMER_GRID / 2;
|
|
918
989
|
var RING_OUTER = 10;
|
|
@@ -1034,7 +1105,7 @@ function timerPaths(remaining) {
|
|
|
1034
1105
|
return paths;
|
|
1035
1106
|
}
|
|
1036
1107
|
|
|
1037
|
-
// src/
|
|
1108
|
+
// ../checkout-core/src/geometry/island-counter-ring.ts
|
|
1038
1109
|
var RING_OUTER2 = 10;
|
|
1039
1110
|
var RING_STROKE = 2.5;
|
|
1040
1111
|
var RING_INNER2 = RING_OUTER2 - RING_STROKE;
|
|
@@ -1475,7 +1546,7 @@ function DayPicker({
|
|
|
1475
1546
|
row,
|
|
1476
1547
|
onRowChange: setRow,
|
|
1477
1548
|
onRowPreview: setShownRow,
|
|
1478
|
-
label:
|
|
1549
|
+
label: ISLAND_COPY.runWeeks,
|
|
1479
1550
|
children: /* @__PURE__ */ jsx11(
|
|
1480
1551
|
CalendarRunGrid,
|
|
1481
1552
|
{
|
|
@@ -1504,6 +1575,7 @@ var SELECTED_ARC = "var(--scopetickets-island-timeslot-ring-selected)";
|
|
|
1504
1575
|
var TRACK = "var(--scopetickets-island-timeslot-track)";
|
|
1505
1576
|
var SELECTED_TRACK = "var(--scopetickets-island-timeslot-track-selected)";
|
|
1506
1577
|
var SOLD_OUT = "Sold Out";
|
|
1578
|
+
var FROM = "From";
|
|
1507
1579
|
function Timeslot({ cell, accessory, onSelect }) {
|
|
1508
1580
|
if (isDatePickerCellSelectable(cell.state)) {
|
|
1509
1581
|
return /* @__PURE__ */ jsx12(TimeslotButton, { cell, accessory, onSelect });
|
|
@@ -1511,36 +1583,47 @@ function Timeslot({ cell, accessory, onSelect }) {
|
|
|
1511
1583
|
return /* @__PURE__ */ jsx12(TimeslotFixed, { cell });
|
|
1512
1584
|
}
|
|
1513
1585
|
function TimeslotRow({ cell }) {
|
|
1586
|
+
const price = slotPrice(cell);
|
|
1514
1587
|
return /* @__PURE__ */ jsxs7("span", { className: "scopetickets-island-timeslot__times", children: [
|
|
1515
1588
|
/* @__PURE__ */ jsx12("span", { className: "scopetickets-island-timeslot__time", children: cell.slot.startTime }),
|
|
1516
1589
|
cell.slot.endTime === null ? null : /* @__PURE__ */ jsxs7(Fragment, { children: [
|
|
1517
1590
|
/* @__PURE__ */ jsx12("span", { className: "scopetickets-island-timeslot__dash", "aria-hidden": "true", children: "-" }),
|
|
1518
1591
|
/* @__PURE__ */ jsx12("span", { className: "scopetickets-island-timeslot__time", children: cell.slot.endTime })
|
|
1519
1592
|
] }),
|
|
1520
|
-
|
|
1521
|
-
/*
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
{
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1593
|
+
/* @__PURE__ */ jsxs7("span", { className: "scopetickets-island-timeslot__trailing", children: [
|
|
1594
|
+
price === null ? null : /* @__PURE__ */ jsx12("span", { className: "scopetickets-island-timeslot__price", children: price }),
|
|
1595
|
+
cell.state === "UNAVAILABLE" ? (
|
|
1596
|
+
/*
|
|
1597
|
+
* THE WORDS INSTEAD OF THE MARK, AND ONLY WHERE THE MARK WOULD SAY NOTHING.
|
|
1598
|
+
*
|
|
1599
|
+
* `UNAVAILABLE` is the one state the ring cannot draw: `timeslotState` reaches it
|
|
1600
|
+
* only for `remaining <= 0`, which is an arc of zero length. A slot that has
|
|
1601
|
+
* merely BEGUN keeps its ring — it still has seats, and "Sold Out" over them
|
|
1602
|
+
* would be false.
|
|
1603
|
+
*/
|
|
1604
|
+
/* @__PURE__ */ jsx12("span", { className: "scopetickets-island-timeslot__soldout", children: SOLD_OUT })
|
|
1605
|
+
) : cell.slot.remaining === null ? null : /* @__PURE__ */ jsx12("span", { className: "scopetickets-island-timeslot__remaining", children: /* @__PURE__ */ jsx12(
|
|
1606
|
+
CounterRing,
|
|
1607
|
+
{
|
|
1608
|
+
progress: cell.slot.remaining,
|
|
1609
|
+
color: cell.state === "SELECTED" ? SELECTED_ARC : availabilityColor(cell.slot.remaining),
|
|
1610
|
+
trackColor: cell.state === "SELECTED" ? SELECTED_TRACK : TRACK,
|
|
1611
|
+
size: REMAINING_SIZE
|
|
1612
|
+
}
|
|
1613
|
+
) })
|
|
1614
|
+
] })
|
|
1539
1615
|
] });
|
|
1540
1616
|
}
|
|
1617
|
+
function slotPrice(cell, spoken = false) {
|
|
1618
|
+
if (!isDatePickerCellSelectable(cell.state)) return null;
|
|
1619
|
+
const price = cell.slot.fromPrice;
|
|
1620
|
+
if (price === void 0 || price === null) return null;
|
|
1621
|
+
const money = formatMoney(price.minorUnits, price.currency);
|
|
1622
|
+
return spoken ? `${FROM} ${money}` : money;
|
|
1623
|
+
}
|
|
1541
1624
|
function timeslotLabel(cell, announcement) {
|
|
1542
1625
|
const range = cell.slot.endTime === null ? cell.slot.startTime : `${cell.slot.startTime} - ${cell.slot.endTime}`;
|
|
1543
|
-
return [range, cell.duration, announcement].filter((part) => part !== null).join(", ");
|
|
1626
|
+
return [range, cell.duration, slotPrice(cell, true), announcement].filter((part) => part !== null).join(", ");
|
|
1544
1627
|
}
|
|
1545
1628
|
function TimeslotButton({ cell, accessory, onSelect }) {
|
|
1546
1629
|
const press = useIslandPress("element");
|
|
@@ -1707,7 +1790,7 @@ function SelectedDayHeading({ day }) {
|
|
|
1707
1790
|
] });
|
|
1708
1791
|
}
|
|
1709
1792
|
|
|
1710
|
-
// src/
|
|
1793
|
+
// ../checkout-core/src/motion/island-step-order.ts
|
|
1711
1794
|
function dayDirection(from, to) {
|
|
1712
1795
|
if (from === to) return "NONE";
|
|
1713
1796
|
return to > from ? "FORWARD" : "BACKWARD";
|
|
@@ -1718,9 +1801,7 @@ function stepDirectionSign(direction) {
|
|
|
1718
1801
|
return 0;
|
|
1719
1802
|
}
|
|
1720
1803
|
|
|
1721
|
-
// src/
|
|
1722
|
-
var DAY_SWAP_OUT_ANIMATION = "scopetickets-island-day-swap-out";
|
|
1723
|
-
var DAY_SWAP_IN_ANIMATION = "scopetickets-island-day-swap-in";
|
|
1804
|
+
// ../checkout-core/src/motion/island-day-swap.ts
|
|
1724
1805
|
function daySwapAtRest(content) {
|
|
1725
1806
|
return { phase: "REST", shown: content };
|
|
1726
1807
|
}
|
|
@@ -1750,6 +1831,10 @@ function reduceDaySwap(state, event) {
|
|
|
1750
1831
|
}
|
|
1751
1832
|
}
|
|
1752
1833
|
|
|
1834
|
+
// src/island/island-day-swap-css.ts
|
|
1835
|
+
var DAY_SWAP_OUT_ANIMATION = "scopetickets-island-day-swap-out";
|
|
1836
|
+
var DAY_SWAP_IN_ANIMATION = "scopetickets-island-day-swap-in";
|
|
1837
|
+
|
|
1753
1838
|
// src/island/TimePicker.tsx
|
|
1754
1839
|
import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1755
1840
|
function TimePicker({
|
|
@@ -1900,15 +1985,14 @@ export {
|
|
|
1900
1985
|
SURFACE_SPRING,
|
|
1901
1986
|
CARRY_SPRING,
|
|
1902
1987
|
POP_RETURN_SPRING,
|
|
1903
|
-
|
|
1988
|
+
settleMs,
|
|
1989
|
+
springAt,
|
|
1904
1990
|
OUTGOING_FADE_MS,
|
|
1905
1991
|
SURFACE_MORPH_DELAY_MS,
|
|
1906
1992
|
INCOMING_FADE_DELAY_MS,
|
|
1907
1993
|
INCOMING_FADE_MS,
|
|
1908
1994
|
CARRY_MOVE_DELAY_MS,
|
|
1909
1995
|
CARRY_MOVE_MS,
|
|
1910
|
-
ARC_LEAD_EASING,
|
|
1911
|
-
ARC_TRAIL_EASING,
|
|
1912
1996
|
POP_SCALE,
|
|
1913
1997
|
SHIELD_POP_SCALE,
|
|
1914
1998
|
POP_RETURN_MS,
|
|
@@ -1922,6 +2006,31 @@ export {
|
|
|
1922
2006
|
HOLD_TICK_MS,
|
|
1923
2007
|
PressContext,
|
|
1924
2008
|
useIslandPress,
|
|
2009
|
+
FIELD_COPY,
|
|
2010
|
+
ACTION_COPY,
|
|
2011
|
+
ISLAND_COPY,
|
|
2012
|
+
formatMoney,
|
|
2013
|
+
moneyParts,
|
|
2014
|
+
widestAmount,
|
|
2015
|
+
quoteLines,
|
|
2016
|
+
SOLO_KEY,
|
|
2017
|
+
groupUserTypes,
|
|
2018
|
+
partyTypes,
|
|
2019
|
+
assignmentFor,
|
|
2020
|
+
userTypeNames,
|
|
2021
|
+
slotFullness,
|
|
2022
|
+
parseWallClockTime,
|
|
2023
|
+
timeOfDayInZone,
|
|
2024
|
+
dayInZone,
|
|
2025
|
+
partOfDayLabel,
|
|
2026
|
+
partOfDay,
|
|
2027
|
+
formatSlotRange,
|
|
2028
|
+
formatSlotDuration,
|
|
2029
|
+
withSelectedDay,
|
|
2030
|
+
withSelectedTime,
|
|
2031
|
+
sameTimeslots,
|
|
2032
|
+
buildTimeslotGroups,
|
|
2033
|
+
timeslotRequest,
|
|
1925
2034
|
toAvailabilityLevel,
|
|
1926
2035
|
readAvailability,
|
|
1927
2036
|
availabilityColor,
|
|
@@ -1956,34 +2065,17 @@ export {
|
|
|
1956
2065
|
monthAtRow,
|
|
1957
2066
|
monthOpeningRow,
|
|
1958
2067
|
toggleSelectedDay,
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
partOfDayLabel,
|
|
1963
|
-
partOfDay,
|
|
1964
|
-
formatSlotRange,
|
|
1965
|
-
formatSlotDuration,
|
|
1966
|
-
withSelectedDay,
|
|
1967
|
-
withSelectedTime,
|
|
1968
|
-
sameTimeslots,
|
|
1969
|
-
buildTimeslotGroups,
|
|
1970
|
-
timeslotRequest,
|
|
1971
|
-
groupUserTypes,
|
|
1972
|
-
partyTypes,
|
|
1973
|
-
assignmentFor,
|
|
1974
|
-
userTypeNames,
|
|
2068
|
+
clampRemaining,
|
|
2069
|
+
trackPaths,
|
|
2070
|
+
timerPaths,
|
|
1975
2071
|
PartyStepper,
|
|
1976
|
-
SOLO_KEY,
|
|
1977
2072
|
flagTone,
|
|
1978
2073
|
ContentFlag,
|
|
1979
2074
|
Switch,
|
|
1980
|
-
clampRemaining,
|
|
1981
|
-
trackPaths,
|
|
1982
|
-
timerPaths,
|
|
1983
2075
|
CounterRing,
|
|
1984
2076
|
DayPicker,
|
|
1985
2077
|
TimeslotPicker,
|
|
1986
2078
|
TimePicker,
|
|
1987
2079
|
CalendarGrainButton
|
|
1988
2080
|
};
|
|
1989
|
-
//# sourceMappingURL=chunk-
|
|
2081
|
+
//# sourceMappingURL=chunk-B7AHG2OO.js.map
|