@scopetickets/checkout 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-4BOPQURW.js +1989 -0
- package/dist/chunk-4BOPQURW.js.map +1 -0
- package/dist/index.cjs +13790 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.cts +3751 -0
- package/dist/index.d.ts +3751 -0
- package/dist/index.js +11942 -0
- package/dist/index.js.map +1 -0
- package/dist/pickers.cjs +1908 -0
- package/dist/pickers.cjs.map +1 -0
- package/dist/pickers.css +1054 -0
- package/dist/pickers.css.map +1 -0
- package/dist/pickers.d.cts +911 -0
- package/dist/pickers.d.ts +911 -0
- package/dist/pickers.js +117 -0
- package/dist/pickers.js.map +1 -0
- package/dist/styles.css +2925 -0
- package/package.json +1 -1
package/dist/pickers.cjs
ADDED
|
@@ -0,0 +1,1908 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/pickers.ts
|
|
21
|
+
var pickers_exports = {};
|
|
22
|
+
__export(pickers_exports, {
|
|
23
|
+
CalendarGrainButton: () => CalendarGrainButton,
|
|
24
|
+
ContentFlag: () => ContentFlag,
|
|
25
|
+
CounterRing: () => CounterRing,
|
|
26
|
+
DATE_PICKER_ACCESSORY: () => DATE_PICKER_ACCESSORY,
|
|
27
|
+
DayPicker: () => DayPicker,
|
|
28
|
+
PartyStepper: () => PartyStepper,
|
|
29
|
+
SOLO_KEY: () => SOLO_KEY,
|
|
30
|
+
Switch: () => Switch,
|
|
31
|
+
TimePicker: () => TimePicker,
|
|
32
|
+
TimeslotPicker: () => TimeslotPicker,
|
|
33
|
+
addDays: () => addDays,
|
|
34
|
+
assignmentFor: () => assignmentFor,
|
|
35
|
+
availabilityColor: () => availabilityColor,
|
|
36
|
+
buildMonthGrid: () => buildMonthGrid,
|
|
37
|
+
buildTimeslotGroups: () => buildTimeslotGroups,
|
|
38
|
+
buildWeekRow: () => buildWeekRow,
|
|
39
|
+
dateRange: () => dateRange,
|
|
40
|
+
eventKeyForDay: () => eventKeyForDay,
|
|
41
|
+
eventsOn: () => eventsOn,
|
|
42
|
+
formatDayDate: () => formatDayDate,
|
|
43
|
+
formatDayWeekday: () => formatDayWeekday,
|
|
44
|
+
formatMonthName: () => formatMonthName,
|
|
45
|
+
formatMonthNameShort: () => formatMonthNameShort,
|
|
46
|
+
formatMonthYear: () => formatMonthYear,
|
|
47
|
+
formatSlotDuration: () => formatSlotDuration,
|
|
48
|
+
formatSlotRange: () => formatSlotRange,
|
|
49
|
+
formatWeekdayAndDate: () => formatWeekdayAndDate,
|
|
50
|
+
groupUserTypes: () => groupUserTypes,
|
|
51
|
+
isDatePickerCellSelectable: () => isDatePickerCellSelectable,
|
|
52
|
+
isSelectableCalendarCell: () => isSelectableCalendarCell,
|
|
53
|
+
locateDayInMonthStack: () => locateDayInMonthStack,
|
|
54
|
+
monthAtRow: () => monthAtRow,
|
|
55
|
+
monthOfDay: () => monthOfDay,
|
|
56
|
+
monthOfWeek: () => monthOfWeek,
|
|
57
|
+
monthOpeningRow: () => monthOpeningRow,
|
|
58
|
+
monthStartRows: () => monthStartRows,
|
|
59
|
+
monthsInSeries: () => monthsInSeries,
|
|
60
|
+
openingMonth: () => openingMonth,
|
|
61
|
+
parseWallClockTime: () => parseWallClockTime,
|
|
62
|
+
partOfDay: () => partOfDay,
|
|
63
|
+
partOfDayLabel: () => partOfDayLabel,
|
|
64
|
+
readAvailability: () => readAvailability,
|
|
65
|
+
sameTimeslots: () => sameTimeslots,
|
|
66
|
+
soonestRelevantDay: () => soonestRelevantDay,
|
|
67
|
+
startOfWeek: () => startOfWeek,
|
|
68
|
+
stepMonth: () => stepMonth,
|
|
69
|
+
timeOfDayInZone: () => timeOfDayInZone,
|
|
70
|
+
timeslotRequest: () => timeslotRequest,
|
|
71
|
+
toAvailabilityLevel: () => toAvailabilityLevel,
|
|
72
|
+
toggleSelectedDay: () => toggleSelectedDay,
|
|
73
|
+
userTypeNames: () => userTypeNames,
|
|
74
|
+
weekContainingDay: () => weekContainingDay,
|
|
75
|
+
weeksInCalendar: () => weeksInCalendar,
|
|
76
|
+
weeksInSeries: () => weeksInSeries,
|
|
77
|
+
withSelectedDay: () => withSelectedDay,
|
|
78
|
+
withSelectedTime: () => withSelectedTime
|
|
79
|
+
});
|
|
80
|
+
module.exports = __toCommonJS(pickers_exports);
|
|
81
|
+
|
|
82
|
+
// src/island/DayPicker.tsx
|
|
83
|
+
var import_react3 = require("react");
|
|
84
|
+
|
|
85
|
+
// src/island/island-calendar.ts
|
|
86
|
+
var HIGH_FROM = 2 / 3;
|
|
87
|
+
var MEDIUM_FROM = 1 / 3;
|
|
88
|
+
function toAvailabilityLevel(remaining) {
|
|
89
|
+
if (!Number.isFinite(remaining) || remaining <= 0) return null;
|
|
90
|
+
if (remaining > HIGH_FROM) return "HIGH";
|
|
91
|
+
if (remaining > MEDIUM_FROM) return "MEDIUM";
|
|
92
|
+
return "LOW";
|
|
93
|
+
}
|
|
94
|
+
function readAvailability(remaining) {
|
|
95
|
+
if (remaining === null) return null;
|
|
96
|
+
const level = toAvailabilityLevel(remaining);
|
|
97
|
+
if (level === null) return null;
|
|
98
|
+
const percent = Math.round(Math.min(remaining, 1) * 100);
|
|
99
|
+
return { level, announcement: `about ${percent}% availability` };
|
|
100
|
+
}
|
|
101
|
+
var RAMP = [
|
|
102
|
+
[0, 0],
|
|
103
|
+
[MEDIUM_FROM, 33],
|
|
104
|
+
[HIGH_FROM, 67],
|
|
105
|
+
[1, 100]
|
|
106
|
+
];
|
|
107
|
+
function availabilityColor(remaining) {
|
|
108
|
+
const stop = (suffix) => `var(--scopetickets-island-availability-${suffix})`;
|
|
109
|
+
if (remaining === null || !Number.isFinite(remaining) || remaining <= 0) return stop(0);
|
|
110
|
+
if (remaining >= 1) return stop(100);
|
|
111
|
+
const top = RAMP.findIndex(([at]) => remaining <= at);
|
|
112
|
+
const [lowAt, lowStop] = RAMP[top - 1];
|
|
113
|
+
const [highAt, highStop] = RAMP[top];
|
|
114
|
+
const towards = Math.round((remaining - lowAt) / (highAt - lowAt) * 100);
|
|
115
|
+
return `color-mix(in srgb, ${stop(highStop)} ${towards}%, ${stop(lowStop)})`;
|
|
116
|
+
}
|
|
117
|
+
function isDatePickerCellSelectable(state) {
|
|
118
|
+
return state === "AVAILABLE" || state === "SELECTED";
|
|
119
|
+
}
|
|
120
|
+
function isSelectableCalendarCell(cell) {
|
|
121
|
+
return cell.kind !== "EMPTY" && isDatePickerCellSelectable(cell.kind);
|
|
122
|
+
}
|
|
123
|
+
function parseMonth(month) {
|
|
124
|
+
return { year: Number(month.slice(0, 4)), monthIndex: Number(month.slice(5, 7)) - 1 };
|
|
125
|
+
}
|
|
126
|
+
function mondayFirstWeekday(date) {
|
|
127
|
+
return (date.getUTCDay() + 6) % 7;
|
|
128
|
+
}
|
|
129
|
+
function toDay(year, monthIndex, dayOfMonth) {
|
|
130
|
+
const month = String(monthIndex + 1).padStart(2, "0");
|
|
131
|
+
return `${year}-${month}-${String(dayOfMonth).padStart(2, "0")}`;
|
|
132
|
+
}
|
|
133
|
+
function eventsOn(series, day) {
|
|
134
|
+
return series.events.filter((event) => event.day === day);
|
|
135
|
+
}
|
|
136
|
+
function eventKeyForDay(series, day) {
|
|
137
|
+
return series === void 0 ? void 0 : eventsOn(series, day)[0]?.eventKey;
|
|
138
|
+
}
|
|
139
|
+
function dateRange(series) {
|
|
140
|
+
let first = null;
|
|
141
|
+
let last = null;
|
|
142
|
+
for (const event of series.events) {
|
|
143
|
+
if (first === null || event.day < first) first = event.day;
|
|
144
|
+
if (last === null || event.day > last) last = event.day;
|
|
145
|
+
}
|
|
146
|
+
return first === null || last === null ? null : { first, last };
|
|
147
|
+
}
|
|
148
|
+
function soonestRelevantDay(series, today) {
|
|
149
|
+
const days = [...new Set(series.events.map((event) => event.day))].sort();
|
|
150
|
+
return days.find((day) => day >= today) ?? days[days.length - 1] ?? null;
|
|
151
|
+
}
|
|
152
|
+
function classifyDay(series, day, span, today, selectedDay) {
|
|
153
|
+
const dayOfMonth = Number(day.slice(8, 10));
|
|
154
|
+
const events = eventsOn(series, day);
|
|
155
|
+
const elapsed = day < today;
|
|
156
|
+
if (events.length > 0) {
|
|
157
|
+
if (elapsed) return { kind: "PAST_BUT_RELEVANT", day, dayOfMonth, events };
|
|
158
|
+
if (day === selectedDay) return { kind: "SELECTED", day, dayOfMonth, events };
|
|
159
|
+
return { kind: "AVAILABLE", day, dayOfMonth, events };
|
|
160
|
+
}
|
|
161
|
+
const insideSpan = span !== null && day >= span.first && day <= span.last;
|
|
162
|
+
return insideSpan && !elapsed ? { kind: "UNAVAILABLE", day, dayOfMonth } : { kind: "OUT_OF_SERIES", day, dayOfMonth };
|
|
163
|
+
}
|
|
164
|
+
function addDays(day, count) {
|
|
165
|
+
const at = /* @__PURE__ */ new Date(`${day}T00:00:00.000Z`);
|
|
166
|
+
at.setUTCDate(at.getUTCDate() + count);
|
|
167
|
+
return at.toISOString().slice(0, 10);
|
|
168
|
+
}
|
|
169
|
+
function startOfWeek(day) {
|
|
170
|
+
return addDays(day, -mondayFirstWeekday(/* @__PURE__ */ new Date(`${day}T00:00:00.000Z`)));
|
|
171
|
+
}
|
|
172
|
+
function monthOfWeek(weekStart) {
|
|
173
|
+
return monthOfDay(addDays(weekStart, 3));
|
|
174
|
+
}
|
|
175
|
+
function weeksInSeries(series) {
|
|
176
|
+
const span = dateRange(series);
|
|
177
|
+
if (!span) return [];
|
|
178
|
+
const last = startOfWeek(span.last);
|
|
179
|
+
const weeks = [];
|
|
180
|
+
for (let week = startOfWeek(span.first); week <= last; week = addDays(week, 7)) {
|
|
181
|
+
weeks.push(week);
|
|
182
|
+
}
|
|
183
|
+
return weeks;
|
|
184
|
+
}
|
|
185
|
+
function weeksInCalendar(series) {
|
|
186
|
+
const span = dateRange(series);
|
|
187
|
+
if (!span) return [];
|
|
188
|
+
const from = parseMonth(monthOfDay(span.first));
|
|
189
|
+
const to = parseMonth(monthOfDay(span.last));
|
|
190
|
+
const lastOfMonth = new Date(Date.UTC(to.year, to.monthIndex + 1, 0)).getUTCDate();
|
|
191
|
+
const first = startOfWeek(toDay(from.year, from.monthIndex, 1));
|
|
192
|
+
const last = startOfWeek(toDay(to.year, to.monthIndex, lastOfMonth));
|
|
193
|
+
const weeks = [];
|
|
194
|
+
for (let week = first; week <= last; week = addDays(week, 7)) weeks.push(week);
|
|
195
|
+
const finalMonth = monthOfDay(span.last);
|
|
196
|
+
const finalMonthRow = monthStartRows(weeks).find(({ month }) => month === finalMonth)?.row ?? 0;
|
|
197
|
+
while (weeks.length < finalMonthRow + CALENDAR_VIEWPORT_ROWS) {
|
|
198
|
+
weeks.push(addDays(weeks[weeks.length - 1], 7));
|
|
199
|
+
}
|
|
200
|
+
return weeks;
|
|
201
|
+
}
|
|
202
|
+
function buildWeekRow(series, weekStart, { today, selectedDay = null }) {
|
|
203
|
+
const span = dateRange(series);
|
|
204
|
+
return Array.from(
|
|
205
|
+
{ length: 7 },
|
|
206
|
+
(_unused, offset) => classifyDay(series, addDays(weekStart, offset), span, today, selectedDay)
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
function buildMonthGrid(series, month, { today, selectedDay = null }) {
|
|
210
|
+
const { year, monthIndex } = parseMonth(month);
|
|
211
|
+
const first = new Date(Date.UTC(year, monthIndex, 1));
|
|
212
|
+
const dayCount = new Date(Date.UTC(year, monthIndex + 1, 0)).getUTCDate();
|
|
213
|
+
const span = dateRange(series);
|
|
214
|
+
const cells = [];
|
|
215
|
+
for (let i = 0; i < mondayFirstWeekday(first); i += 1) cells.push({ kind: "EMPTY" });
|
|
216
|
+
for (let dayOfMonth = 1; dayOfMonth <= dayCount; dayOfMonth += 1) {
|
|
217
|
+
cells.push(classifyDay(series, toDay(year, monthIndex, dayOfMonth), span, today, selectedDay));
|
|
218
|
+
}
|
|
219
|
+
while (cells.length % 7 !== 0) cells.push({ kind: "EMPTY" });
|
|
220
|
+
const weeks = [];
|
|
221
|
+
for (let i = 0; i < cells.length; i += 7) weeks.push(cells.slice(i, i + 7));
|
|
222
|
+
return weeks;
|
|
223
|
+
}
|
|
224
|
+
function weekContainingDay(weeks, day) {
|
|
225
|
+
return weeks.find((week) => week.some((cell) => cell.kind !== "EMPTY" && cell.day === day)) ?? null;
|
|
226
|
+
}
|
|
227
|
+
function locateDayInMonthStack(series, day, { today }) {
|
|
228
|
+
const months = monthsInSeries(series);
|
|
229
|
+
const monthIndex = months.indexOf(monthOfDay(day));
|
|
230
|
+
if (monthIndex < 0) return null;
|
|
231
|
+
const weeks = buildMonthGrid(series, months[monthIndex] ?? day.slice(0, 7), { today });
|
|
232
|
+
const weekIndex = weeks.findIndex(
|
|
233
|
+
(week) => week.some((cell) => cell.kind !== "EMPTY" && cell.day === day)
|
|
234
|
+
);
|
|
235
|
+
if (weekIndex < 0) return null;
|
|
236
|
+
return { monthIndex, weekIndex };
|
|
237
|
+
}
|
|
238
|
+
function monthOfDay(day) {
|
|
239
|
+
return day.slice(0, 7);
|
|
240
|
+
}
|
|
241
|
+
function monthsInSeries(series) {
|
|
242
|
+
const months = [];
|
|
243
|
+
for (const event of series.events) {
|
|
244
|
+
const month = monthOfDay(event.day);
|
|
245
|
+
if (!months.includes(month)) months.push(month);
|
|
246
|
+
}
|
|
247
|
+
return months.sort();
|
|
248
|
+
}
|
|
249
|
+
function openingMonth(series, today) {
|
|
250
|
+
const day = soonestRelevantDay(series, today);
|
|
251
|
+
if (day) return monthOfDay(day);
|
|
252
|
+
return monthsInSeries(series)[0] ?? null;
|
|
253
|
+
}
|
|
254
|
+
function stepMonth(series, month, step) {
|
|
255
|
+
const months = monthsInSeries(series);
|
|
256
|
+
const index = months.indexOf(month);
|
|
257
|
+
if (index === -1) return null;
|
|
258
|
+
return months[index + step] ?? null;
|
|
259
|
+
}
|
|
260
|
+
var CALENDAR_LOCALE = "en-IE";
|
|
261
|
+
function formatMonthYear(month) {
|
|
262
|
+
return month.slice(0, 4);
|
|
263
|
+
}
|
|
264
|
+
function formatMonthName(month) {
|
|
265
|
+
const { year, monthIndex } = parseMonth(month);
|
|
266
|
+
return new Date(Date.UTC(year, monthIndex, 1, 12)).toLocaleDateString(CALENDAR_LOCALE, {
|
|
267
|
+
month: "long",
|
|
268
|
+
timeZone: "UTC"
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
function formatMonthNameShort(month) {
|
|
272
|
+
const long = formatMonthName(month);
|
|
273
|
+
const { year, monthIndex } = parseMonth(month);
|
|
274
|
+
const short = new Date(Date.UTC(year, monthIndex, 1, 12)).toLocaleDateString(CALENDAR_LOCALE, {
|
|
275
|
+
month: "short",
|
|
276
|
+
timeZone: "UTC"
|
|
277
|
+
});
|
|
278
|
+
return short.length < long.length ? `${short}.` : long;
|
|
279
|
+
}
|
|
280
|
+
function formatDayDate(day) {
|
|
281
|
+
return (/* @__PURE__ */ new Date(`${day}T12:00:00.000Z`)).toLocaleDateString(CALENDAR_LOCALE, {
|
|
282
|
+
day: "numeric",
|
|
283
|
+
month: "long",
|
|
284
|
+
year: "numeric",
|
|
285
|
+
timeZone: "UTC"
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
function formatWeekdayAndDate(day) {
|
|
289
|
+
return (/* @__PURE__ */ new Date(`${day}T12:00:00.000Z`)).toLocaleDateString(CALENDAR_LOCALE, {
|
|
290
|
+
weekday: "long",
|
|
291
|
+
day: "numeric",
|
|
292
|
+
month: "long",
|
|
293
|
+
timeZone: "UTC"
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
function formatDayWeekday(day) {
|
|
297
|
+
return (/* @__PURE__ */ new Date(`${day}T12:00:00.000Z`)).toLocaleDateString(CALENDAR_LOCALE, {
|
|
298
|
+
weekday: "long",
|
|
299
|
+
timeZone: "UTC"
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
var DATE_PICKER_ACCESSORY = "NONE";
|
|
303
|
+
var CALENDAR_VIEWPORT_ROWS = 6;
|
|
304
|
+
function monthStartRows(weeks) {
|
|
305
|
+
if (weeks.length === 0) return [];
|
|
306
|
+
const starts = [{ month: monthOfDay(weeks[0]), row: 0 }];
|
|
307
|
+
weeks.forEach((weekStart, row) => {
|
|
308
|
+
for (let offset = 0; offset < 7; offset += 1) {
|
|
309
|
+
const day = addDays(weekStart, offset);
|
|
310
|
+
if (!day.endsWith("-01")) continue;
|
|
311
|
+
const month = monthOfDay(day);
|
|
312
|
+
if (!starts.some((start) => start.month === month)) starts.push({ month, row });
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
return starts;
|
|
316
|
+
}
|
|
317
|
+
function monthAtRow(starts, topRow) {
|
|
318
|
+
let current = starts[0]?.month ?? null;
|
|
319
|
+
for (const start of starts) {
|
|
320
|
+
if (start.row <= topRow) current = start.month;
|
|
321
|
+
}
|
|
322
|
+
return current;
|
|
323
|
+
}
|
|
324
|
+
function lastTopRow({ rowCount, viewportRows }) {
|
|
325
|
+
return Math.max(0, rowCount - viewportRows);
|
|
326
|
+
}
|
|
327
|
+
function rowAfterDrag(drag) {
|
|
328
|
+
const { row, offset, rowHeight } = drag;
|
|
329
|
+
if (rowHeight <= 0) return clampRow(row, drag);
|
|
330
|
+
return clampRow(Math.round(row - offset / rowHeight), drag);
|
|
331
|
+
}
|
|
332
|
+
var CALENDAR_ROW_OVERSHOOT = 1;
|
|
333
|
+
function resist(overshoot, rowHeight) {
|
|
334
|
+
const limit = rowHeight * CALENDAR_ROW_OVERSHOOT;
|
|
335
|
+
return limit * overshoot / (limit + overshoot);
|
|
336
|
+
}
|
|
337
|
+
function rowDragOffset(drag) {
|
|
338
|
+
const { row, offset, rowHeight } = drag;
|
|
339
|
+
if (rowHeight <= 0) return 0;
|
|
340
|
+
const wanted = row * rowHeight - offset;
|
|
341
|
+
const furthest = lastTopRow(drag) * rowHeight;
|
|
342
|
+
const held = wanted < 0 ? -resist(-wanted, rowHeight) : wanted > furthest ? furthest + resist(wanted - furthest, rowHeight) : wanted;
|
|
343
|
+
return row * rowHeight - held;
|
|
344
|
+
}
|
|
345
|
+
function clampRow(row, drag) {
|
|
346
|
+
return Math.max(0, Math.min(lastTopRow(drag), row));
|
|
347
|
+
}
|
|
348
|
+
function rowContainingDay(weeks, day) {
|
|
349
|
+
if (day === null || weeks.length === 0) return 0;
|
|
350
|
+
const rows = Math.floor(daysBetween(weeks[0], day) / 7);
|
|
351
|
+
const lastTop = Math.max(0, weeks.length - CALENDAR_VIEWPORT_ROWS);
|
|
352
|
+
return Math.max(0, Math.min(lastTop, rows));
|
|
353
|
+
}
|
|
354
|
+
function monthOpeningRow(weeks, starts, day) {
|
|
355
|
+
if (day === null || weeks.length === 0) return 0;
|
|
356
|
+
const start = starts.find((candidate) => candidate.month === monthOfDay(day));
|
|
357
|
+
if (start === void 0) return rowContainingDay(weeks, day);
|
|
358
|
+
return Math.min(Math.max(0, weeks.length - CALENDAR_VIEWPORT_ROWS), start.row);
|
|
359
|
+
}
|
|
360
|
+
function daysBetween(from, to) {
|
|
361
|
+
const ms = Date.parse(`${to}T00:00:00Z`) - Date.parse(`${from}T00:00:00Z`);
|
|
362
|
+
return Math.round(ms / 864e5);
|
|
363
|
+
}
|
|
364
|
+
function toggleSelectedDay(selected, day) {
|
|
365
|
+
return selected === day ? null : day;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// src/island/CalendarMonthHeading.tsx
|
|
369
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
370
|
+
function CalendarMonthHeading({ month }) {
|
|
371
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: "scopetickets-island-calendar__heading", children: formatMonthName(month) });
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// src/island/CalendarDayIndicator.tsx
|
|
375
|
+
var import_jsx_runtime2 = (
|
|
376
|
+
// DECORATIVE, and now correctly so.
|
|
377
|
+
require("react/jsx-runtime")
|
|
378
|
+
);
|
|
379
|
+
var SEGMENTS = 3;
|
|
380
|
+
var FILLED_SEGMENTS = {
|
|
381
|
+
LOW: 1,
|
|
382
|
+
MEDIUM: 2,
|
|
383
|
+
HIGH: 3
|
|
384
|
+
};
|
|
385
|
+
function CalendarDayIndicator({ level }) {
|
|
386
|
+
const filled = FILLED_SEGMENTS[level];
|
|
387
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "scopetickets-island-day-indicator", "aria-hidden": "true", children: [
|
|
388
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
389
|
+
"span",
|
|
390
|
+
{
|
|
391
|
+
className: `scopetickets-island-day-indicator__fill scopetickets-island-day-indicator__fill--${level.toLowerCase()}`,
|
|
392
|
+
style: { flexGrow: filled }
|
|
393
|
+
}
|
|
394
|
+
),
|
|
395
|
+
filled < SEGMENTS ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { flexGrow: SEGMENTS - filled } }) : null
|
|
396
|
+
] });
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// src/island/island-press.ts
|
|
400
|
+
var import_react = require("react");
|
|
401
|
+
|
|
402
|
+
// src/island/island-motion.ts
|
|
403
|
+
var SURFACE_MORPH_MS = 250;
|
|
404
|
+
var SURFACE_DAMPING = 0.82;
|
|
405
|
+
var SURFACE_SPRING = {
|
|
406
|
+
response: responseForSettle(SURFACE_MORPH_MS / 1e3, SURFACE_DAMPING),
|
|
407
|
+
damping: SURFACE_DAMPING,
|
|
408
|
+
clampOvershoot: false
|
|
409
|
+
};
|
|
410
|
+
var CARRY_SPRING = {
|
|
411
|
+
response: responseForSettle(SURFACE_MORPH_MS / 1e3, 0.95),
|
|
412
|
+
damping: 0.95,
|
|
413
|
+
clampOvershoot: true
|
|
414
|
+
};
|
|
415
|
+
var POP_RETURN_SPRING = { ...SURFACE_SPRING, clampOvershoot: true };
|
|
416
|
+
function responseForSettle(settleSeconds, damping) {
|
|
417
|
+
return settleSeconds * damping * 2 * Math.PI / 4;
|
|
418
|
+
}
|
|
419
|
+
function naturalFrequency({ response }) {
|
|
420
|
+
return 2 * Math.PI / response;
|
|
421
|
+
}
|
|
422
|
+
function settleMs(spring) {
|
|
423
|
+
const exact = 4 / (spring.damping * naturalFrequency(spring)) * 1e3;
|
|
424
|
+
return Math.ceil(Number(exact.toFixed(9)));
|
|
425
|
+
}
|
|
426
|
+
var OUTGOING_FADE_MS = 125;
|
|
427
|
+
var SURFACE_MORPH_DELAY_MS = OUTGOING_FADE_MS;
|
|
428
|
+
var INCOMING_FADE_DELAY_MS = SURFACE_MORPH_DELAY_MS + SURFACE_MORPH_MS;
|
|
429
|
+
var INCOMING_FADE_MS = 175;
|
|
430
|
+
var DAY_SWAP_STRETCH = 1.6;
|
|
431
|
+
var DAY_SWAP_OUT_MS = Math.round(OUTGOING_FADE_MS * DAY_SWAP_STRETCH);
|
|
432
|
+
var DAY_SWAP_IN_MS = Math.round(INCOMING_FADE_MS * DAY_SWAP_STRETCH);
|
|
433
|
+
var CARRY_MOVE_DELAY_MS = SURFACE_MORPH_DELAY_MS;
|
|
434
|
+
var CARRY_MOVE_MS = settleMs(CARRY_SPRING);
|
|
435
|
+
var POP_SCALE = 0.95;
|
|
436
|
+
var SHIELD_POP_SCALE = 1 - (1 - POP_SCALE) / 2;
|
|
437
|
+
var POP_CONTRACT_MS = OUTGOING_FADE_MS;
|
|
438
|
+
var POP_RETURN_MS = settleMs(POP_RETURN_SPRING);
|
|
439
|
+
var POP_MS = POP_CONTRACT_MS + POP_RETURN_MS;
|
|
440
|
+
var POP_TURN_PERCENT = Number((POP_CONTRACT_MS / POP_MS * 100).toFixed(3));
|
|
441
|
+
var PRESS_IN_MS = POP_CONTRACT_MS;
|
|
442
|
+
var PRESS_RETURN_MS = SURFACE_MORPH_DELAY_MS + SURFACE_MORPH_MS;
|
|
443
|
+
var ISLAND_TRANSITION_MS = Math.max(
|
|
444
|
+
INCOMING_FADE_DELAY_MS + INCOMING_FADE_MS,
|
|
445
|
+
CARRY_MOVE_DELAY_MS + CARRY_MOVE_MS,
|
|
446
|
+
POP_MS
|
|
447
|
+
);
|
|
448
|
+
var BAY_SWAP_IN_PERCENT = Number(
|
|
449
|
+
(INCOMING_FADE_DELAY_MS / ISLAND_TRANSITION_MS * 100).toFixed(3)
|
|
450
|
+
);
|
|
451
|
+
|
|
452
|
+
// src/island/island-press.ts
|
|
453
|
+
var PressContext = (0, import_react.createContext)(null);
|
|
454
|
+
var primaryHeld = (event) => (event.buttons & 1) === 1;
|
|
455
|
+
var AT_REST = { at: "rest" };
|
|
456
|
+
var RISEN = { at: "rising", timer: null };
|
|
457
|
+
function stopWaiting(sink) {
|
|
458
|
+
if (sink.at === "rising" && sink.timer !== null) window.clearTimeout(sink.timer);
|
|
459
|
+
}
|
|
460
|
+
function useIslandPress(scope = "island") {
|
|
461
|
+
const api = (0, import_react.useContext)(PressContext);
|
|
462
|
+
const [pressedHere, setPressedHere] = (0, import_react.useState)(false);
|
|
463
|
+
const whole = scope === "island";
|
|
464
|
+
const sink = (0, import_react.useRef)(AT_REST);
|
|
465
|
+
(0, import_react.useEffect)(() => () => stopWaiting(sink.current), []);
|
|
466
|
+
const handlers = (0, import_react.useMemo)(() => {
|
|
467
|
+
const letGo = () => {
|
|
468
|
+
if (sink.current.at !== "down") return;
|
|
469
|
+
const left = PRESS_IN_MS - (Date.now() - sink.current.since);
|
|
470
|
+
if (left <= 0) {
|
|
471
|
+
sink.current = RISEN;
|
|
472
|
+
setPressedHere(false);
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
sink.current = {
|
|
476
|
+
at: "rising",
|
|
477
|
+
timer: window.setTimeout(() => {
|
|
478
|
+
sink.current = AT_REST;
|
|
479
|
+
setPressedHere(false);
|
|
480
|
+
}, left)
|
|
481
|
+
};
|
|
482
|
+
};
|
|
483
|
+
const undo = () => {
|
|
484
|
+
if (sink.current.at !== "down") return;
|
|
485
|
+
sink.current = AT_REST;
|
|
486
|
+
setPressedHere(false);
|
|
487
|
+
};
|
|
488
|
+
const begin = whole ? () => api?.press("island") : () => {
|
|
489
|
+
api?.press("element");
|
|
490
|
+
stopWaiting(sink.current);
|
|
491
|
+
sink.current = { at: "down", since: Date.now() };
|
|
492
|
+
setPressedHere(true);
|
|
493
|
+
};
|
|
494
|
+
const end = whole ? () => api?.release() : () => {
|
|
495
|
+
api?.release();
|
|
496
|
+
letGo();
|
|
497
|
+
};
|
|
498
|
+
const cancel = whole ? () => api?.abandon() : () => {
|
|
499
|
+
api?.abandon();
|
|
500
|
+
undo();
|
|
501
|
+
};
|
|
502
|
+
return {
|
|
503
|
+
onPointerDown: (event) => {
|
|
504
|
+
if (primaryHeld(event)) begin();
|
|
505
|
+
},
|
|
506
|
+
onPointerUp: end,
|
|
507
|
+
onPointerLeave: cancel,
|
|
508
|
+
onPointerEnter: (event) => {
|
|
509
|
+
if (primaryHeld(event)) begin();
|
|
510
|
+
},
|
|
511
|
+
onPointerCancel: cancel
|
|
512
|
+
};
|
|
513
|
+
}, [api, whole]);
|
|
514
|
+
return whole || !pressedHere ? handlers : { ...handlers, "data-pressed": "" };
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// src/island/CalendarDay.tsx
|
|
518
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
519
|
+
function CalendarDay({
|
|
520
|
+
cell,
|
|
521
|
+
accessory,
|
|
522
|
+
remaining,
|
|
523
|
+
label,
|
|
524
|
+
outsideMonth = false,
|
|
525
|
+
onSelect
|
|
526
|
+
}) {
|
|
527
|
+
const press = useIslandPress("element");
|
|
528
|
+
const dimmed = outsideMonth ? { "data-outside-month": "" } : null;
|
|
529
|
+
if (cell.kind === "EMPTY") {
|
|
530
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "scopetickets-island-day", "aria-hidden": "true" });
|
|
531
|
+
}
|
|
532
|
+
if (isSelectableCalendarCell(cell)) {
|
|
533
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
534
|
+
CalendarDayButton,
|
|
535
|
+
{
|
|
536
|
+
cell,
|
|
537
|
+
accessory,
|
|
538
|
+
remaining,
|
|
539
|
+
label,
|
|
540
|
+
onSelect,
|
|
541
|
+
outsideMonth,
|
|
542
|
+
press
|
|
543
|
+
}
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
if (cell.kind === "UNAVAILABLE") {
|
|
547
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
548
|
+
CalendarDayButton,
|
|
549
|
+
{
|
|
550
|
+
cell,
|
|
551
|
+
accessory,
|
|
552
|
+
remaining: null,
|
|
553
|
+
label,
|
|
554
|
+
outsideMonth,
|
|
555
|
+
press
|
|
556
|
+
}
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "scopetickets-island-day", ...dimmed, ...press, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "scopetickets-island-day__well", "data-state": cell.kind, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "scopetickets-island-day__number", children: cell.dayOfMonth }) }) });
|
|
560
|
+
}
|
|
561
|
+
function CalendarDayButton({
|
|
562
|
+
cell,
|
|
563
|
+
accessory,
|
|
564
|
+
remaining,
|
|
565
|
+
label,
|
|
566
|
+
outsideMonth = false,
|
|
567
|
+
press,
|
|
568
|
+
onSelect
|
|
569
|
+
}) {
|
|
570
|
+
const selected = cell.kind === "SELECTED";
|
|
571
|
+
const availability = readAvailability(remaining);
|
|
572
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
573
|
+
"button",
|
|
574
|
+
{
|
|
575
|
+
type: "button",
|
|
576
|
+
className: "scopetickets-island-day",
|
|
577
|
+
...outsideMonth ? { "data-outside-month": "" } : null,
|
|
578
|
+
"aria-pressed": onSelect ? selected : void 0,
|
|
579
|
+
"aria-disabled": onSelect ? void 0 : true,
|
|
580
|
+
"aria-label": availability === null ? label : `${label}, ${availability.announcement}`,
|
|
581
|
+
onClick: onSelect ? () => onSelect(cell.day) : void 0,
|
|
582
|
+
...press,
|
|
583
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "scopetickets-island-day__well", "data-state": cell.kind, children: [
|
|
584
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "scopetickets-island-day__number", children: cell.dayOfMonth }),
|
|
585
|
+
cell.kind === "UNAVAILABLE" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "scopetickets-island-day__strike", "aria-hidden": "true" }) : null,
|
|
586
|
+
accessory === "LINE" && availability !== null ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "scopetickets-island-day__accessory", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CalendarDayIndicator, { level: availability.level }) }) : null
|
|
587
|
+
] })
|
|
588
|
+
}
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
// src/island/CalendarRunGrid.tsx
|
|
593
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
594
|
+
function CalendarRunGrid({
|
|
595
|
+
series,
|
|
596
|
+
weeks,
|
|
597
|
+
currentMonth,
|
|
598
|
+
accessory,
|
|
599
|
+
remaining,
|
|
600
|
+
today,
|
|
601
|
+
selectedDay,
|
|
602
|
+
onSelectDay
|
|
603
|
+
}) {
|
|
604
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "scopetickets-island-calendar__grid", children: weeks.map((weekStart) => (
|
|
605
|
+
// A presentational row: the seven columns are a layout, and announcing "row 3
|
|
606
|
+
// of 9" describes the grid rather than the run.
|
|
607
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "scopetickets-island-calendar__week", children: buildWeekRow(series, weekStart, { today, selectedDay }).map((cell, dayIndex) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
608
|
+
CalendarDay,
|
|
609
|
+
{
|
|
610
|
+
cell,
|
|
611
|
+
accessory,
|
|
612
|
+
remaining: cell.kind === "EMPTY" ? null : remaining?.[cell.day] ?? null,
|
|
613
|
+
label: cell.kind === "EMPTY" ? "" : formatDayDate(cell.day),
|
|
614
|
+
outsideMonth: cell.kind !== "EMPTY" && monthOfDay(cell.day) !== currentMonth,
|
|
615
|
+
onSelect: onSelectDay
|
|
616
|
+
},
|
|
617
|
+
cell.kind === "EMPTY" ? `empty-${dayIndex}` : cell.day
|
|
618
|
+
)) }, weekStart)
|
|
619
|
+
)) });
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
// src/island/CalendarScroller.tsx
|
|
623
|
+
var import_react2 = require("react");
|
|
624
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
625
|
+
var WHEEL_IDLE_MS = 200;
|
|
626
|
+
var CALENDAR_DRAG_SLOP = 4;
|
|
627
|
+
function CalendarScroller({
|
|
628
|
+
children,
|
|
629
|
+
rowCount,
|
|
630
|
+
row,
|
|
631
|
+
onRowChange,
|
|
632
|
+
onRowPreview,
|
|
633
|
+
label
|
|
634
|
+
}) {
|
|
635
|
+
const viewportRef = (0, import_react2.useRef)(null);
|
|
636
|
+
const trackRef = (0, import_react2.useRef)(null);
|
|
637
|
+
const startY = (0, import_react2.useRef)(null);
|
|
638
|
+
const [offset, setOffset] = (0, import_react2.useState)(0);
|
|
639
|
+
const [dragging, setDragging] = (0, import_react2.useState)(false);
|
|
640
|
+
const rowRef = (0, import_react2.useRef)(row);
|
|
641
|
+
rowRef.current = row;
|
|
642
|
+
const [rowStep, setRowStep] = (0, import_react2.useState)(0);
|
|
643
|
+
const gapPx = (box) => {
|
|
644
|
+
const gap = Number.parseFloat(
|
|
645
|
+
getComputedStyle(box).getPropertyValue("--scopetickets-island-day-column-gap")
|
|
646
|
+
);
|
|
647
|
+
return Number.isFinite(gap) ? gap : 0;
|
|
648
|
+
};
|
|
649
|
+
(0, import_react2.useEffect)(() => {
|
|
650
|
+
const track = trackRef.current;
|
|
651
|
+
if (!track) return void 0;
|
|
652
|
+
const measure = () => {
|
|
653
|
+
const row2 = track.querySelector(".scopetickets-island-calendar__week");
|
|
654
|
+
if (!row2) return;
|
|
655
|
+
const height = row2.getBoundingClientRect().height;
|
|
656
|
+
if (height <= 0) return;
|
|
657
|
+
const step = height + gapPx(track);
|
|
658
|
+
setRowStep((was) => Math.abs(was - step) < 0.5 ? was : step);
|
|
659
|
+
};
|
|
660
|
+
measure();
|
|
661
|
+
if (typeof ResizeObserver === "undefined") return void 0;
|
|
662
|
+
const observer = new ResizeObserver(measure);
|
|
663
|
+
observer.observe(track);
|
|
664
|
+
return () => observer.disconnect();
|
|
665
|
+
}, [rowCount]);
|
|
666
|
+
const rowHeight = (0, import_react2.useCallback)(() => {
|
|
667
|
+
if (rowStep > 0) return rowStep;
|
|
668
|
+
const box = viewportRef.current;
|
|
669
|
+
if (!box) return 0;
|
|
670
|
+
return (box.clientHeight + gapPx(box)) / CALENDAR_VIEWPORT_ROWS;
|
|
671
|
+
}, [rowStep]);
|
|
672
|
+
const drag = (0, import_react2.useCallback)(
|
|
673
|
+
(dy) => ({
|
|
674
|
+
row: rowRef.current,
|
|
675
|
+
rowCount,
|
|
676
|
+
viewportRows: CALENDAR_VIEWPORT_ROWS,
|
|
677
|
+
offset: dy,
|
|
678
|
+
rowHeight: rowHeight()
|
|
679
|
+
}),
|
|
680
|
+
[rowCount, rowHeight]
|
|
681
|
+
);
|
|
682
|
+
const draw = (0, import_react2.useCallback)(
|
|
683
|
+
(dy) => {
|
|
684
|
+
const moving = drag(dy);
|
|
685
|
+
setOffset(rowDragOffset(moving));
|
|
686
|
+
onRowPreview?.(rowAfterDrag(moving));
|
|
687
|
+
},
|
|
688
|
+
[drag, onRowPreview]
|
|
689
|
+
);
|
|
690
|
+
const settle = (0, import_react2.useCallback)(
|
|
691
|
+
(dy) => {
|
|
692
|
+
setOffset(0);
|
|
693
|
+
const landed = rowAfterDrag(drag(dy));
|
|
694
|
+
if (landed !== rowRef.current) onRowChange(landed);
|
|
695
|
+
},
|
|
696
|
+
[drag, onRowChange]
|
|
697
|
+
);
|
|
698
|
+
const dragged = (0, import_react2.useRef)(false);
|
|
699
|
+
const onPointerDown = (event) => {
|
|
700
|
+
if ((event.buttons & 1) !== 1) return;
|
|
701
|
+
startY.current = event.clientY;
|
|
702
|
+
dragged.current = false;
|
|
703
|
+
};
|
|
704
|
+
const onPointerMove = (event) => {
|
|
705
|
+
if (startY.current === null) return;
|
|
706
|
+
const dy = event.clientY - startY.current;
|
|
707
|
+
if (!dragged.current) {
|
|
708
|
+
if (Math.abs(dy) < CALENDAR_DRAG_SLOP) return;
|
|
709
|
+
dragged.current = true;
|
|
710
|
+
setDragging(true);
|
|
711
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
712
|
+
}
|
|
713
|
+
draw(dy);
|
|
714
|
+
};
|
|
715
|
+
const onPointerUp = (event) => {
|
|
716
|
+
if (startY.current === null) return;
|
|
717
|
+
const dy = event.clientY - startY.current;
|
|
718
|
+
startY.current = null;
|
|
719
|
+
if (!dragged.current) return;
|
|
720
|
+
setDragging(false);
|
|
721
|
+
settle(dy);
|
|
722
|
+
};
|
|
723
|
+
const onClickCapture = (event) => {
|
|
724
|
+
if (!dragged.current) return;
|
|
725
|
+
dragged.current = false;
|
|
726
|
+
event.stopPropagation();
|
|
727
|
+
event.preventDefault();
|
|
728
|
+
};
|
|
729
|
+
const onPointerCancel = () => {
|
|
730
|
+
startY.current = null;
|
|
731
|
+
dragged.current = false;
|
|
732
|
+
setDragging(false);
|
|
733
|
+
setOffset(0);
|
|
734
|
+
};
|
|
735
|
+
const wheel = (0, import_react2.useRef)(0);
|
|
736
|
+
const settleTimer = (0, import_react2.useRef)(null);
|
|
737
|
+
(0, import_react2.useEffect)(() => {
|
|
738
|
+
const viewport = viewportRef.current;
|
|
739
|
+
if (!viewport) return void 0;
|
|
740
|
+
const onWheel = (event) => {
|
|
741
|
+
event.preventDefault();
|
|
742
|
+
wheel.current -= event.deltaY;
|
|
743
|
+
wheel.current = rowDragOffset(drag(wheel.current));
|
|
744
|
+
draw(wheel.current);
|
|
745
|
+
if (settleTimer.current !== null) window.clearTimeout(settleTimer.current);
|
|
746
|
+
settleTimer.current = window.setTimeout(() => {
|
|
747
|
+
settleTimer.current = null;
|
|
748
|
+
const travelled = wheel.current;
|
|
749
|
+
wheel.current = 0;
|
|
750
|
+
settle(travelled);
|
|
751
|
+
}, WHEEL_IDLE_MS);
|
|
752
|
+
};
|
|
753
|
+
viewport.addEventListener("wheel", onWheel, { passive: false });
|
|
754
|
+
return () => viewport.removeEventListener("wheel", onWheel);
|
|
755
|
+
}, [drag, draw, settle]);
|
|
756
|
+
(0, import_react2.useEffect)(
|
|
757
|
+
() => () => {
|
|
758
|
+
if (settleTimer.current !== null) window.clearTimeout(settleTimer.current);
|
|
759
|
+
},
|
|
760
|
+
[]
|
|
761
|
+
);
|
|
762
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
763
|
+
"div",
|
|
764
|
+
{
|
|
765
|
+
ref: viewportRef,
|
|
766
|
+
className: "scopetickets-island-calendar-scroller",
|
|
767
|
+
role: "group",
|
|
768
|
+
"aria-label": label,
|
|
769
|
+
style: {
|
|
770
|
+
"--scopetickets-island-viewport-rows": CALENDAR_VIEWPORT_ROWS,
|
|
771
|
+
...rowStep > 0 ? { "--scopetickets-island-calendar-row-step": `${rowStep}px` } : null
|
|
772
|
+
},
|
|
773
|
+
onPointerDown,
|
|
774
|
+
onPointerMove,
|
|
775
|
+
onPointerUp,
|
|
776
|
+
onPointerCancel,
|
|
777
|
+
onClickCapture,
|
|
778
|
+
children: [
|
|
779
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "scopetickets-island-calendar-scroller__window", "aria-hidden": "true" }),
|
|
780
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
781
|
+
"div",
|
|
782
|
+
{
|
|
783
|
+
ref: trackRef,
|
|
784
|
+
className: "scopetickets-island-calendar-scroller__track",
|
|
785
|
+
"data-dragging": dragging || offset !== 0 ? "" : void 0,
|
|
786
|
+
style: {
|
|
787
|
+
translate: `0 calc(${-row} * var(--scopetickets-island-calendar-row-step) + ${offset}px)`
|
|
788
|
+
},
|
|
789
|
+
children
|
|
790
|
+
}
|
|
791
|
+
)
|
|
792
|
+
]
|
|
793
|
+
}
|
|
794
|
+
);
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
// src/island/CalendarWeekdayNames.tsx
|
|
798
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
799
|
+
var WEEKDAY_NAMES = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
|
|
800
|
+
function CalendarWeekdayNames() {
|
|
801
|
+
return (
|
|
802
|
+
// `aria-hidden`, and it is not a shortcut.
|
|
803
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "scopetickets-island-calendar__weekdays", "aria-hidden": "true", children: WEEKDAY_NAMES.map((name) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "scopetickets-island-calendar__weekday", children: name }, name)) })
|
|
804
|
+
);
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
// src/island/DayPicker.tsx
|
|
808
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
809
|
+
function DayPicker({
|
|
810
|
+
series,
|
|
811
|
+
today,
|
|
812
|
+
selectedDay,
|
|
813
|
+
onSelectDay,
|
|
814
|
+
remaining,
|
|
815
|
+
accessory = DATE_PICKER_ACCESSORY,
|
|
816
|
+
onVisibleMonthChange
|
|
817
|
+
}) {
|
|
818
|
+
const weeks = (0, import_react3.useMemo)(() => weeksInCalendar(series), [series]);
|
|
819
|
+
const starts = (0, import_react3.useMemo)(() => monthStartRows(weeks), [weeks]);
|
|
820
|
+
const [row, setRow] = (0, import_react3.useState)(
|
|
821
|
+
() => monthOpeningRow(weeks, starts, selectedDay ?? soonestRelevantDay(series, today))
|
|
822
|
+
);
|
|
823
|
+
const [shownRow, setShownRow] = (0, import_react3.useState)(row);
|
|
824
|
+
const currentMonth = monthAtRow(starts, shownRow);
|
|
825
|
+
(0, import_react3.useEffect)(() => {
|
|
826
|
+
if (currentMonth !== null) onVisibleMonthChange?.(currentMonth);
|
|
827
|
+
}, [currentMonth, onVisibleMonthChange]);
|
|
828
|
+
const selectDay = (0, import_react3.useCallback)(
|
|
829
|
+
(day) => {
|
|
830
|
+
const month = monthOfDay(day);
|
|
831
|
+
const start = starts.find((candidate) => candidate.month === month);
|
|
832
|
+
if (start !== void 0 && month !== currentMonth) {
|
|
833
|
+
setRow(start.row);
|
|
834
|
+
setShownRow(start.row);
|
|
835
|
+
}
|
|
836
|
+
onSelectDay(day);
|
|
837
|
+
},
|
|
838
|
+
[starts, currentMonth, onSelectDay]
|
|
839
|
+
);
|
|
840
|
+
if (weeks.length === 0) return null;
|
|
841
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "scopetickets-island-calendar", "data-accessory": accessory, children: [
|
|
842
|
+
currentMonth !== null && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CalendarMonthHeading, { month: currentMonth }),
|
|
843
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CalendarWeekdayNames, {}),
|
|
844
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
845
|
+
CalendarScroller,
|
|
846
|
+
{
|
|
847
|
+
rowCount: weeks.length,
|
|
848
|
+
row,
|
|
849
|
+
onRowChange: setRow,
|
|
850
|
+
onRowPreview: setShownRow,
|
|
851
|
+
label: "Weeks of the run",
|
|
852
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
853
|
+
CalendarRunGrid,
|
|
854
|
+
{
|
|
855
|
+
series,
|
|
856
|
+
weeks,
|
|
857
|
+
currentMonth,
|
|
858
|
+
accessory,
|
|
859
|
+
remaining,
|
|
860
|
+
today,
|
|
861
|
+
selectedDay,
|
|
862
|
+
onSelectDay: selectDay
|
|
863
|
+
}
|
|
864
|
+
)
|
|
865
|
+
}
|
|
866
|
+
)
|
|
867
|
+
] });
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
// src/island/TimePicker.tsx
|
|
871
|
+
var import_react6 = require("react");
|
|
872
|
+
|
|
873
|
+
// src/island/CalendarWeekSection.tsx
|
|
874
|
+
var import_react4 = require("react");
|
|
875
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
876
|
+
function CalendarWeekSection({
|
|
877
|
+
series,
|
|
878
|
+
today,
|
|
879
|
+
selectedDay,
|
|
880
|
+
onSelectDay,
|
|
881
|
+
remaining,
|
|
882
|
+
accessory,
|
|
883
|
+
onVisibleMonthChange
|
|
884
|
+
}) {
|
|
885
|
+
const weeks = weeksInSeries(series);
|
|
886
|
+
const selectedWeek = startOfWeek(selectedDay);
|
|
887
|
+
const selectedIndex = Math.max(weeks.indexOf(selectedWeek), 0);
|
|
888
|
+
const pagerRef = (0, import_react4.useRef)(null);
|
|
889
|
+
const pageRefs = (0, import_react4.useRef)([]);
|
|
890
|
+
const [visibleIndex, setVisibleIndex] = (0, import_react4.useState)(selectedIndex);
|
|
891
|
+
(0, import_react4.useEffect)(() => {
|
|
892
|
+
setVisibleIndex(selectedIndex);
|
|
893
|
+
}, [selectedIndex]);
|
|
894
|
+
const strideOf = (pager) => {
|
|
895
|
+
const first = pageRefs.current[0];
|
|
896
|
+
const second = pageRefs.current[1];
|
|
897
|
+
if (first && second) return second.offsetLeft - first.offsetLeft;
|
|
898
|
+
return first?.offsetWidth ?? pager.clientWidth;
|
|
899
|
+
};
|
|
900
|
+
const paint = (0, import_react4.useCallback)(() => {
|
|
901
|
+
const pager = pagerRef.current;
|
|
902
|
+
if (!pager) return;
|
|
903
|
+
const stride = strideOf(pager);
|
|
904
|
+
if (stride <= 0) return;
|
|
905
|
+
const at = pager.scrollLeft / stride;
|
|
906
|
+
pageRefs.current.forEach((page2, index) => {
|
|
907
|
+
if (!page2) return;
|
|
908
|
+
page2.style.setProperty(
|
|
909
|
+
"--scopetickets-island-week-distance",
|
|
910
|
+
String(Math.min(Math.abs(index - at), 1))
|
|
911
|
+
);
|
|
912
|
+
});
|
|
913
|
+
const page = Math.round(at);
|
|
914
|
+
setVisibleIndex(Math.min(Math.max(page, 0), Math.max(weeks.length - 1, 0)));
|
|
915
|
+
}, [weeks.length]);
|
|
916
|
+
(0, import_react4.useLayoutEffect)(() => {
|
|
917
|
+
const pager = pagerRef.current;
|
|
918
|
+
if (!pager) return;
|
|
919
|
+
pager.scrollLeft = selectedIndex * strideOf(pager);
|
|
920
|
+
paint();
|
|
921
|
+
}, [selectedIndex, paint]);
|
|
922
|
+
const visibleWeek = weeks[Math.min(visibleIndex, weeks.length - 1)] ?? selectedWeek;
|
|
923
|
+
(0, import_react4.useEffect)(() => {
|
|
924
|
+
if (weeks.length === 0) return;
|
|
925
|
+
onVisibleMonthChange?.(
|
|
926
|
+
visibleWeek === selectedWeek ? monthOfDay(selectedDay) : monthOfWeek(visibleWeek)
|
|
927
|
+
);
|
|
928
|
+
}, [weeks.length, visibleWeek, selectedWeek, selectedDay, onVisibleMonthChange]);
|
|
929
|
+
if (weeks.length === 0) return null;
|
|
930
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "scopetickets-island-week", children: [
|
|
931
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CalendarWeekdayNames, {}),
|
|
932
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "scopetickets-island-week__pager", ref: pagerRef, onScroll: paint, children: weeks.map((weekStart, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
933
|
+
"div",
|
|
934
|
+
{
|
|
935
|
+
className: "scopetickets-island-week__page",
|
|
936
|
+
ref: (node) => {
|
|
937
|
+
pageRefs.current[index] = node;
|
|
938
|
+
},
|
|
939
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "scopetickets-island-week__row", children: buildWeekRow(series, weekStart, { today, selectedDay }).map((cell, dayIndex) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
940
|
+
CalendarDay,
|
|
941
|
+
{
|
|
942
|
+
cell,
|
|
943
|
+
accessory,
|
|
944
|
+
remaining: cell.kind === "EMPTY" ? null : remaining?.[cell.day] ?? null,
|
|
945
|
+
label: cell.kind === "EMPTY" ? "" : formatDayDate(cell.day),
|
|
946
|
+
onSelect: onSelectDay
|
|
947
|
+
},
|
|
948
|
+
cell.kind === "EMPTY" ? `empty-${dayIndex}` : cell.day
|
|
949
|
+
)) })
|
|
950
|
+
},
|
|
951
|
+
weekStart
|
|
952
|
+
)) })
|
|
953
|
+
] });
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
// src/island/SelectedDayHeading.tsx
|
|
957
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
958
|
+
function SelectedDayHeading({ day }) {
|
|
959
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("h3", { className: "scopetickets-island-day-heading", children: [
|
|
960
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "scopetickets-island-day-heading__weekday", children: [
|
|
961
|
+
formatDayWeekday(day),
|
|
962
|
+
","
|
|
963
|
+
] }),
|
|
964
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "scopetickets-island-day-heading__date", children: formatDayDate(day) })
|
|
965
|
+
] });
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
// src/island/TimeslotPicker.tsx
|
|
969
|
+
var import_react5 = require("react");
|
|
970
|
+
|
|
971
|
+
// src/island/CounterRing.tsx
|
|
972
|
+
var import_icons2 = require("@scopetickets/icons");
|
|
973
|
+
|
|
974
|
+
// src/island/island-timer.ts
|
|
975
|
+
var TIMER_GRID = 20;
|
|
976
|
+
var TIMER_CENTRE = TIMER_GRID / 2;
|
|
977
|
+
var RING_OUTER = 10;
|
|
978
|
+
var RING_INNER = 8;
|
|
979
|
+
var RING_RADIUS = (RING_OUTER + RING_INNER) / 2;
|
|
980
|
+
var RING_WIDTH = RING_OUTER - RING_INNER;
|
|
981
|
+
var TURN_DEGREES = 360;
|
|
982
|
+
var SOURCE_GRID = 100;
|
|
983
|
+
var SOURCE_SCALE = TIMER_GRID / SOURCE_GRID;
|
|
984
|
+
function n(value) {
|
|
985
|
+
const rounded = Number(value.toFixed(3));
|
|
986
|
+
return String(Object.is(rounded, -0) ? 0 : rounded);
|
|
987
|
+
}
|
|
988
|
+
function pointAt(radius, degrees) {
|
|
989
|
+
const radians = degrees * Math.PI / 180;
|
|
990
|
+
return {
|
|
991
|
+
x: TIMER_CENTRE + radius * Math.sin(radians),
|
|
992
|
+
y: TIMER_CENTRE - radius * Math.cos(radians)
|
|
993
|
+
};
|
|
994
|
+
}
|
|
995
|
+
function circlePath(centre, radius) {
|
|
996
|
+
const r = `${n(radius)},${n(radius)}`;
|
|
997
|
+
return `M${n(centre.x - radius)},${n(centre.y)}A${r} 0 1 0 ${n(centre.x + radius)},${n(centre.y)}A${r} 0 1 0 ${n(centre.x - radius)},${n(centre.y)}Z`;
|
|
998
|
+
}
|
|
999
|
+
function clampRemaining(remaining) {
|
|
1000
|
+
if (!Number.isFinite(remaining)) return 0;
|
|
1001
|
+
return Math.min(1, Math.max(0, remaining));
|
|
1002
|
+
}
|
|
1003
|
+
function annulus(outer = RING_OUTER, inner = RING_INNER) {
|
|
1004
|
+
const centre = pointAt(0, 0);
|
|
1005
|
+
return circlePath(centre, outer) + circlePath(centre, inner);
|
|
1006
|
+
}
|
|
1007
|
+
function ringSector(fraction, outer, inner, direction = "cw") {
|
|
1008
|
+
const filled = clampRemaining(fraction);
|
|
1009
|
+
if (filled <= 0 || filled >= 1) return null;
|
|
1010
|
+
const mirrored = direction === "ccw";
|
|
1011
|
+
const sweep = filled * TURN_DEGREES * (mirrored ? -1 : 1);
|
|
1012
|
+
const capRadius = (outer - inner) / 2;
|
|
1013
|
+
const outerStart = pointAt(outer, 0);
|
|
1014
|
+
const outerEnd = pointAt(outer, sweep);
|
|
1015
|
+
const innerEnd = pointAt(inner, sweep);
|
|
1016
|
+
const innerStart = pointAt(inner, 0);
|
|
1017
|
+
const out = mirrored ? 0 : 1;
|
|
1018
|
+
const back = mirrored ? 1 : 0;
|
|
1019
|
+
const large = Math.abs(sweep) > 180 ? 1 : 0;
|
|
1020
|
+
const cap = `${n(capRadius)},${n(capRadius)}`;
|
|
1021
|
+
const at = (p) => `${n(p.x)},${n(p.y)}`;
|
|
1022
|
+
return {
|
|
1023
|
+
d: `M${at(outerStart)}A${n(outer)},${n(outer)} 0 ${large} ${out} ${at(outerEnd)}A${cap} 0 0 ${out} ${at(innerEnd)}A${n(inner)},${n(inner)} 0 ${large} ${back} ${at(innerStart)}A${cap} 0 0 ${out} ${at(outerStart)}Z`
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
1026
|
+
function ringAnnulus(outer, inner) {
|
|
1027
|
+
return { d: annulus(outer, inner), evenodd: true };
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
// src/island/island-counter-ring.ts
|
|
1031
|
+
var RING_OUTER2 = 10;
|
|
1032
|
+
var RING_STROKE = 2.5;
|
|
1033
|
+
var RING_INNER2 = RING_OUTER2 - RING_STROKE;
|
|
1034
|
+
function counterTrackPaths() {
|
|
1035
|
+
return [ringAnnulus(RING_OUTER2, RING_INNER2)];
|
|
1036
|
+
}
|
|
1037
|
+
function counterRingPaths(progress, direction = "cw") {
|
|
1038
|
+
if (progress >= 1) return [ringAnnulus(RING_OUTER2, RING_INNER2)];
|
|
1039
|
+
const sector = ringSector(progress, RING_OUTER2, RING_INNER2, direction);
|
|
1040
|
+
return sector ? [sector] : [];
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
// src/island/ContentFlag.tsx
|
|
1044
|
+
var import_icons = require("@scopetickets/icons");
|
|
1045
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1046
|
+
var GLYPH = {
|
|
1047
|
+
success: import_icons.CheckInCircleFilledIcon,
|
|
1048
|
+
warning: import_icons.ExclamationMarkInCircleFilledIcon,
|
|
1049
|
+
error: import_icons.XMarkInCircleFilledIcon
|
|
1050
|
+
};
|
|
1051
|
+
function ContentFlag({ tone, title }) {
|
|
1052
|
+
const Glyph = GLYPH[tone];
|
|
1053
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: `scopetickets-island-content-flag scopetickets-island-content-flag--${tone}`, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Glyph, { fill: true, color: "currentColor", title }) });
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
// src/island/CounterRing.tsx
|
|
1057
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1058
|
+
var LAYER = { position: "absolute", inset: 0 };
|
|
1059
|
+
var DEFAULT_FILL = "var(--scopetickets-island-counter-ring-fill)";
|
|
1060
|
+
var DEFAULT_TRACK = "var(--scopetickets-island-counter-ring-track)";
|
|
1061
|
+
function CounterRing({
|
|
1062
|
+
progress,
|
|
1063
|
+
complete,
|
|
1064
|
+
size = "1em",
|
|
1065
|
+
title,
|
|
1066
|
+
color = DEFAULT_FILL,
|
|
1067
|
+
trackColor = DEFAULT_TRACK,
|
|
1068
|
+
direction = "cw",
|
|
1069
|
+
track = true
|
|
1070
|
+
}) {
|
|
1071
|
+
if (complete !== void 0) {
|
|
1072
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1073
|
+
"span",
|
|
1074
|
+
{
|
|
1075
|
+
className: "scopetickets-island-counter-ring",
|
|
1076
|
+
style: { width: size, height: size, flex: "none" },
|
|
1077
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ContentFlag, { tone: complete, title })
|
|
1078
|
+
}
|
|
1079
|
+
);
|
|
1080
|
+
}
|
|
1081
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1082
|
+
"span",
|
|
1083
|
+
{
|
|
1084
|
+
className: "scopetickets-island-counter-ring",
|
|
1085
|
+
style: { position: "relative", display: "block", width: size, height: size, flex: "none" },
|
|
1086
|
+
children: [
|
|
1087
|
+
track ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { style: LAYER, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1088
|
+
import_icons2.IconGlyph,
|
|
1089
|
+
{
|
|
1090
|
+
glyph: "StepCompletionProgressRingTrack",
|
|
1091
|
+
paths: counterTrackPaths(),
|
|
1092
|
+
color: trackColor,
|
|
1093
|
+
fill: true
|
|
1094
|
+
}
|
|
1095
|
+
) }) : null,
|
|
1096
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { style: LAYER, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1097
|
+
import_icons2.IconGlyph,
|
|
1098
|
+
{
|
|
1099
|
+
glyph: "StepCompletionProgressRing",
|
|
1100
|
+
paths: counterRingPaths(progress, direction),
|
|
1101
|
+
color,
|
|
1102
|
+
title,
|
|
1103
|
+
fill: true
|
|
1104
|
+
}
|
|
1105
|
+
) })
|
|
1106
|
+
]
|
|
1107
|
+
}
|
|
1108
|
+
);
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
// src/island/Timeslot.tsx
|
|
1112
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1113
|
+
var REMAINING_SIZE = "var(--scopetickets-island-space-4)";
|
|
1114
|
+
var SELECTED_ARC = "var(--scopetickets-island-timeslot-ring-selected)";
|
|
1115
|
+
var TRACK = "var(--scopetickets-island-timeslot-track)";
|
|
1116
|
+
var SELECTED_TRACK = "var(--scopetickets-island-timeslot-track-selected)";
|
|
1117
|
+
var SOLD_OUT = "Sold Out";
|
|
1118
|
+
function Timeslot({ cell, accessory, onSelect }) {
|
|
1119
|
+
if (isDatePickerCellSelectable(cell.state)) {
|
|
1120
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TimeslotButton, { cell, accessory, onSelect });
|
|
1121
|
+
}
|
|
1122
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TimeslotFixed, { cell });
|
|
1123
|
+
}
|
|
1124
|
+
function TimeslotRow({ cell }) {
|
|
1125
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "scopetickets-island-timeslot__times", children: [
|
|
1126
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "scopetickets-island-timeslot__time", children: cell.slot.startTime }),
|
|
1127
|
+
cell.slot.endTime === null ? null : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
1128
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "scopetickets-island-timeslot__dash", "aria-hidden": "true", children: "-" }),
|
|
1129
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "scopetickets-island-timeslot__time", children: cell.slot.endTime })
|
|
1130
|
+
] }),
|
|
1131
|
+
cell.state === "UNAVAILABLE" ? (
|
|
1132
|
+
/*
|
|
1133
|
+
* THE WORDS INSTEAD OF THE MARK, AND ONLY WHERE THE MARK WOULD SAY NOTHING.
|
|
1134
|
+
*
|
|
1135
|
+
* `UNAVAILABLE` is the one state the ring cannot draw: `timeslotState` reaches it
|
|
1136
|
+
* only for `remaining <= 0`, which is an arc of zero length. A slot that has
|
|
1137
|
+
* merely BEGUN keeps its ring — it still has seats, and "Sold Out" over them
|
|
1138
|
+
* would be false.
|
|
1139
|
+
*/
|
|
1140
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "scopetickets-island-timeslot__soldout", children: SOLD_OUT })
|
|
1141
|
+
) : cell.slot.remaining === null ? null : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "scopetickets-island-timeslot__remaining", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1142
|
+
CounterRing,
|
|
1143
|
+
{
|
|
1144
|
+
progress: cell.slot.remaining,
|
|
1145
|
+
color: cell.state === "SELECTED" ? SELECTED_ARC : availabilityColor(cell.slot.remaining),
|
|
1146
|
+
trackColor: cell.state === "SELECTED" ? SELECTED_TRACK : TRACK,
|
|
1147
|
+
size: REMAINING_SIZE
|
|
1148
|
+
}
|
|
1149
|
+
) })
|
|
1150
|
+
] });
|
|
1151
|
+
}
|
|
1152
|
+
function timeslotLabel(cell, announcement) {
|
|
1153
|
+
const range = cell.slot.endTime === null ? cell.slot.startTime : `${cell.slot.startTime} - ${cell.slot.endTime}`;
|
|
1154
|
+
return [range, cell.duration, announcement].filter((part) => part !== null).join(", ");
|
|
1155
|
+
}
|
|
1156
|
+
function TimeslotButton({ cell, accessory, onSelect }) {
|
|
1157
|
+
const press = useIslandPress("element");
|
|
1158
|
+
const selected = cell.state === "SELECTED";
|
|
1159
|
+
const availability = readAvailability(cell.slot.remaining);
|
|
1160
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1161
|
+
"button",
|
|
1162
|
+
{
|
|
1163
|
+
type: "button",
|
|
1164
|
+
className: "scopetickets-island-timeslot",
|
|
1165
|
+
"aria-pressed": selected,
|
|
1166
|
+
"aria-label": timeslotLabel(cell, availability?.announcement ?? null),
|
|
1167
|
+
onClick: () => onSelect(cell.slot.startTime),
|
|
1168
|
+
...press,
|
|
1169
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "scopetickets-island-timeslot__pill", "data-state": cell.state, children: [
|
|
1170
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TimeslotRow, { cell }),
|
|
1171
|
+
accessory === "LINE" && availability !== null ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "scopetickets-island-timeslot__accessory", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CalendarDayIndicator, { level: availability.level }) }) : null
|
|
1172
|
+
] })
|
|
1173
|
+
}
|
|
1174
|
+
);
|
|
1175
|
+
}
|
|
1176
|
+
function TimeslotFixed({ cell }) {
|
|
1177
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "scopetickets-island-timeslot", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "scopetickets-island-timeslot__pill", "data-state": cell.state, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TimeslotRow, { cell }) }) });
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
// src/island/TimeslotGroupSection.tsx
|
|
1181
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1182
|
+
function TimeslotGroupSection({ group, accessory, onSelect }) {
|
|
1183
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: "scopetickets-island-timeslots__group", children: [
|
|
1184
|
+
group.label === null ? null : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h4", { className: "scopetickets-island-timeslots__label", children: group.label }),
|
|
1185
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "scopetickets-island-timeslots__list", children: group.cells.map((cell, index) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1186
|
+
Timeslot,
|
|
1187
|
+
{
|
|
1188
|
+
cell,
|
|
1189
|
+
accessory,
|
|
1190
|
+
onSelect
|
|
1191
|
+
},
|
|
1192
|
+
`${cell.slot.startTime}-${index}`
|
|
1193
|
+
)) })
|
|
1194
|
+
] });
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
// src/island/island-timeslots.ts
|
|
1198
|
+
var MAX_TIME_INPUT = 40;
|
|
1199
|
+
var WALL_CLOCK = /^(?:\d{4}-\d{2}-\d{2}[T ])?(\d{2}):(\d{2})(?::\d{2})?/;
|
|
1200
|
+
function parseWallClockTime(value) {
|
|
1201
|
+
if (typeof value !== "string" || value.length > MAX_TIME_INPUT) return null;
|
|
1202
|
+
const match = WALL_CLOCK.exec(value.trim());
|
|
1203
|
+
if (!match) return null;
|
|
1204
|
+
if (Number(match[1]) > 23 || Number(match[2]) > 59) return null;
|
|
1205
|
+
return `${match[1]}:${match[2]}`;
|
|
1206
|
+
}
|
|
1207
|
+
function timeOfDayInZone(now, timeZone) {
|
|
1208
|
+
const read = (zone) => {
|
|
1209
|
+
const parts = new Intl.DateTimeFormat("en-GB", {
|
|
1210
|
+
timeZone: zone,
|
|
1211
|
+
hour: "2-digit",
|
|
1212
|
+
minute: "2-digit",
|
|
1213
|
+
hourCycle: "h23"
|
|
1214
|
+
}).formatToParts(now);
|
|
1215
|
+
const hour = parts.find((part) => part.type === "hour")?.value ?? "00";
|
|
1216
|
+
const minute = parts.find((part) => part.type === "minute")?.value ?? "00";
|
|
1217
|
+
return `${String(Number(hour) % 24).padStart(2, "0")}:${minute}`;
|
|
1218
|
+
};
|
|
1219
|
+
try {
|
|
1220
|
+
return read(timeZone ?? "UTC");
|
|
1221
|
+
} catch {
|
|
1222
|
+
return read("UTC");
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
var PART_OF_DAY_LABELS = {
|
|
1226
|
+
OVERNIGHT: "OVERNIGHT",
|
|
1227
|
+
PRE_DAWN: "PRE-DAWN",
|
|
1228
|
+
EARLY_MORNING: "EARLY MORNING",
|
|
1229
|
+
LATE_MORNING: "LATE MORNING",
|
|
1230
|
+
EARLY_AFTERNOON: "EARLY AFTERNOON",
|
|
1231
|
+
LATE_AFTERNOON: "LATE AFTERNOON",
|
|
1232
|
+
EARLY_EVENING: "EARLY EVENING",
|
|
1233
|
+
LATE_EVENING: "LATE EVENING"
|
|
1234
|
+
};
|
|
1235
|
+
function partOfDayLabel(part) {
|
|
1236
|
+
return PART_OF_DAY_LABELS[part];
|
|
1237
|
+
}
|
|
1238
|
+
function partOfDay(time) {
|
|
1239
|
+
const hour = Number(time.slice(0, 2));
|
|
1240
|
+
if (hour < 3) return "OVERNIGHT";
|
|
1241
|
+
if (hour < 6) return "PRE_DAWN";
|
|
1242
|
+
if (hour < 9) return "EARLY_MORNING";
|
|
1243
|
+
if (hour < 12) return "LATE_MORNING";
|
|
1244
|
+
if (hour < 15) return "EARLY_AFTERNOON";
|
|
1245
|
+
if (hour < 18) return "LATE_AFTERNOON";
|
|
1246
|
+
if (hour < 21) return "EARLY_EVENING";
|
|
1247
|
+
return "LATE_EVENING";
|
|
1248
|
+
}
|
|
1249
|
+
var MINUTES_IN_DAY = 24 * 60;
|
|
1250
|
+
function minutesOfDay(time) {
|
|
1251
|
+
return Number(time.slice(0, 2)) * 60 + Number(time.slice(3, 5));
|
|
1252
|
+
}
|
|
1253
|
+
function formatSlotRange(startTime, endTime) {
|
|
1254
|
+
return endTime === null ? startTime : `${startTime} - ${endTime}`;
|
|
1255
|
+
}
|
|
1256
|
+
function formatSlotDuration(startTime, endTime) {
|
|
1257
|
+
if (endTime === null) return null;
|
|
1258
|
+
const minutes = (minutesOfDay(endTime) - minutesOfDay(startTime) + MINUTES_IN_DAY) % MINUTES_IN_DAY;
|
|
1259
|
+
if (!Number.isFinite(minutes) || minutes <= 0) return null;
|
|
1260
|
+
const hours = Math.floor(minutes / 60);
|
|
1261
|
+
const rest = minutes % 60;
|
|
1262
|
+
if (hours === 0) return `${rest}m`;
|
|
1263
|
+
return rest === 0 ? `${hours}h` : `${hours}h ${rest}m`;
|
|
1264
|
+
}
|
|
1265
|
+
function withSelectedDay(selection, day) {
|
|
1266
|
+
return selection.day === day ? selection : { day, startTime: null };
|
|
1267
|
+
}
|
|
1268
|
+
function withSelectedTime(selection, startTime) {
|
|
1269
|
+
return { day: selection.day, startTime };
|
|
1270
|
+
}
|
|
1271
|
+
function hasStarted(slot, options) {
|
|
1272
|
+
if (options.selection.day < options.today) return true;
|
|
1273
|
+
if (options.selection.day > options.today) return false;
|
|
1274
|
+
return slot.startTime <= options.nowTime;
|
|
1275
|
+
}
|
|
1276
|
+
function timeslotState(slot, options) {
|
|
1277
|
+
if (hasStarted(slot, options)) return "PAST_BUT_RELEVANT";
|
|
1278
|
+
if (slot.remaining !== null && slot.remaining <= 0) return "UNAVAILABLE";
|
|
1279
|
+
return slot.startTime === options.selection.startTime ? "SELECTED" : "AVAILABLE";
|
|
1280
|
+
}
|
|
1281
|
+
function sameTimeslots(a, b) {
|
|
1282
|
+
if (a === b) return true;
|
|
1283
|
+
if (a.length !== b.length) return false;
|
|
1284
|
+
return a.every((slot, index) => {
|
|
1285
|
+
const other = b[index];
|
|
1286
|
+
return slot.startTime === other.startTime && slot.endTime === other.endTime && slot.remaining === other.remaining;
|
|
1287
|
+
});
|
|
1288
|
+
}
|
|
1289
|
+
function buildTimeslotGroups(slots, options) {
|
|
1290
|
+
const groups = [];
|
|
1291
|
+
const byPart = /* @__PURE__ */ new Map();
|
|
1292
|
+
const chronological = [...slots].sort((a, b) => a.startTime.localeCompare(b.startTime));
|
|
1293
|
+
const cellFor = (slot) => ({
|
|
1294
|
+
slot,
|
|
1295
|
+
part: partOfDay(slot.startTime),
|
|
1296
|
+
state: timeslotState(slot, options),
|
|
1297
|
+
duration: formatSlotDuration(slot.startTime, slot.endTime)
|
|
1298
|
+
});
|
|
1299
|
+
if ((options.grouping ?? "PART_OF_DAY") === "NONE") {
|
|
1300
|
+
return chronological.length === 0 ? [] : [{ part: null, label: null, cells: chronological.map(cellFor) }];
|
|
1301
|
+
}
|
|
1302
|
+
for (const slot of chronological) {
|
|
1303
|
+
const part = partOfDay(slot.startTime);
|
|
1304
|
+
let group = byPart.get(part);
|
|
1305
|
+
if (!group) {
|
|
1306
|
+
group = { part, label: partOfDayLabel(part), cells: [] };
|
|
1307
|
+
byPart.set(part, group);
|
|
1308
|
+
groups.push(group);
|
|
1309
|
+
}
|
|
1310
|
+
group.cells.push(cellFor(slot));
|
|
1311
|
+
}
|
|
1312
|
+
return groups;
|
|
1313
|
+
}
|
|
1314
|
+
function timeslotRequest(day, startTime, schedule) {
|
|
1315
|
+
if (day === void 0 || startTime === void 0 || startTime === "") return void 0;
|
|
1316
|
+
const slot = schedule?.slotsByDay?.[day]?.find((candidate) => candidate.startTime === startTime);
|
|
1317
|
+
if (slot === void 0) return void 0;
|
|
1318
|
+
const ends = slot.endTime ?? slot.startTime;
|
|
1319
|
+
return { LocalStartTime: `${slot.startTime}:00`, LocalEndTime: `${ends}:00` };
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
// src/island/TimeslotPicker.tsx
|
|
1323
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1324
|
+
function TimeslotPicker({
|
|
1325
|
+
slots,
|
|
1326
|
+
selection,
|
|
1327
|
+
today,
|
|
1328
|
+
nowTime,
|
|
1329
|
+
onSelect,
|
|
1330
|
+
accessory,
|
|
1331
|
+
grouping
|
|
1332
|
+
}) {
|
|
1333
|
+
const groups = (0, import_react5.useMemo)(
|
|
1334
|
+
() => buildTimeslotGroups(slots, { selection, today, nowTime, grouping }),
|
|
1335
|
+
[slots, selection, today, nowTime, grouping]
|
|
1336
|
+
);
|
|
1337
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "scopetickets-island-timeslots", children: groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1338
|
+
TimeslotGroupSection,
|
|
1339
|
+
{
|
|
1340
|
+
group,
|
|
1341
|
+
accessory,
|
|
1342
|
+
onSelect
|
|
1343
|
+
},
|
|
1344
|
+
group.part ?? "ALL"
|
|
1345
|
+
)) });
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
// src/island/island-step-order.ts
|
|
1349
|
+
function dayDirection(from, to) {
|
|
1350
|
+
if (from === to) return "NONE";
|
|
1351
|
+
return to > from ? "FORWARD" : "BACKWARD";
|
|
1352
|
+
}
|
|
1353
|
+
function stepDirectionSign(direction) {
|
|
1354
|
+
if (direction === "FORWARD") return 1;
|
|
1355
|
+
if (direction === "BACKWARD") return -1;
|
|
1356
|
+
return 0;
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
// src/island/island-day-swap.ts
|
|
1360
|
+
var DAY_SWAP_OUT_ANIMATION = "scopetickets-island-day-swap-out";
|
|
1361
|
+
var DAY_SWAP_IN_ANIMATION = "scopetickets-island-day-swap-in";
|
|
1362
|
+
function daySwapAtRest(content) {
|
|
1363
|
+
return { phase: "REST", shown: content };
|
|
1364
|
+
}
|
|
1365
|
+
function reduceDaySwap(state, event) {
|
|
1366
|
+
switch (event.type) {
|
|
1367
|
+
case "CONTENT_CHANGED": {
|
|
1368
|
+
const next = event.content;
|
|
1369
|
+
if (next.day === state.shown.day) {
|
|
1370
|
+
const shown = { day: state.shown.day, slots: next.slots };
|
|
1371
|
+
if (state.phase === "LEAVING") {
|
|
1372
|
+
return { phase: "ENTERING", shown, sign: state.sign === 1 ? -1 : 1 };
|
|
1373
|
+
}
|
|
1374
|
+
if (sameTimeslots(next.slots, state.shown.slots)) return state;
|
|
1375
|
+
return { ...state, shown };
|
|
1376
|
+
}
|
|
1377
|
+
if (state.phase === "LEAVING" && state.to === next.day) return state;
|
|
1378
|
+
const sign = stepDirectionSign(dayDirection(state.shown.day, next.day));
|
|
1379
|
+
if (sign === 0) return state;
|
|
1380
|
+
return { phase: "LEAVING", shown: state.shown, to: next.day, sign };
|
|
1381
|
+
}
|
|
1382
|
+
case "LEFT":
|
|
1383
|
+
if (state.phase !== "LEAVING") return state;
|
|
1384
|
+
return { phase: "ENTERING", shown: event.content, sign: state.sign };
|
|
1385
|
+
case "ARRIVED":
|
|
1386
|
+
if (state.phase !== "ENTERING") return state;
|
|
1387
|
+
return { phase: "REST", shown: state.shown };
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
// src/island/TimePicker.tsx
|
|
1392
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1393
|
+
function TimePicker({
|
|
1394
|
+
series,
|
|
1395
|
+
today,
|
|
1396
|
+
nowTime,
|
|
1397
|
+
selection,
|
|
1398
|
+
onSelectDay,
|
|
1399
|
+
slots,
|
|
1400
|
+
onSelectTime,
|
|
1401
|
+
remaining,
|
|
1402
|
+
accessory = DATE_PICKER_ACCESSORY,
|
|
1403
|
+
onVisibleMonthChange
|
|
1404
|
+
}) {
|
|
1405
|
+
const [swap, dispatch] = (0, import_react6.useReducer)(reduceDaySwap, { day: selection.day, slots }, daySwapAtRest);
|
|
1406
|
+
(0, import_react6.useEffect)(() => {
|
|
1407
|
+
dispatch({ type: "CONTENT_CHANGED", content: { day: selection.day, slots } });
|
|
1408
|
+
}, [selection.day, slots]);
|
|
1409
|
+
const onSwapAnimationEnd = (event) => {
|
|
1410
|
+
if (event.animationName === DAY_SWAP_OUT_ANIMATION) {
|
|
1411
|
+
dispatch({ type: "LEFT", content: { day: selection.day, slots } });
|
|
1412
|
+
} else if (event.animationName === DAY_SWAP_IN_ANIMATION) {
|
|
1413
|
+
dispatch({ type: "ARRIVED" });
|
|
1414
|
+
}
|
|
1415
|
+
};
|
|
1416
|
+
const shownSelection = swap.shown.day === selection.day ? selection : { day: swap.shown.day, startTime: null };
|
|
1417
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "scopetickets-island-time", "data-accessory": accessory, children: [
|
|
1418
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1419
|
+
CalendarWeekSection,
|
|
1420
|
+
{
|
|
1421
|
+
series,
|
|
1422
|
+
today,
|
|
1423
|
+
selectedDay: selection.day,
|
|
1424
|
+
onSelectDay,
|
|
1425
|
+
remaining,
|
|
1426
|
+
accessory,
|
|
1427
|
+
onVisibleMonthChange
|
|
1428
|
+
}
|
|
1429
|
+
),
|
|
1430
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1431
|
+
"div",
|
|
1432
|
+
{
|
|
1433
|
+
className: "scopetickets-island-time__swap",
|
|
1434
|
+
"data-day-swap": swap.phase,
|
|
1435
|
+
style: swap.phase === "REST" ? void 0 : { "--scopetickets-island-swap-sign": swap.sign },
|
|
1436
|
+
onAnimationEnd: onSwapAnimationEnd,
|
|
1437
|
+
children: [
|
|
1438
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SelectedDayHeading, { day: swap.shown.day }),
|
|
1439
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1440
|
+
TimeslotPicker,
|
|
1441
|
+
{
|
|
1442
|
+
slots: swap.shown.slots,
|
|
1443
|
+
selection: shownSelection,
|
|
1444
|
+
today,
|
|
1445
|
+
nowTime,
|
|
1446
|
+
onSelect: onSelectTime,
|
|
1447
|
+
accessory
|
|
1448
|
+
}
|
|
1449
|
+
)
|
|
1450
|
+
]
|
|
1451
|
+
}
|
|
1452
|
+
)
|
|
1453
|
+
] });
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
// src/island/PartyStepper.tsx
|
|
1457
|
+
var import_react7 = require("react");
|
|
1458
|
+
var import_icons3 = require("@scopetickets/icons");
|
|
1459
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1460
|
+
function UserTypeRow({
|
|
1461
|
+
option,
|
|
1462
|
+
count,
|
|
1463
|
+
atLimit,
|
|
1464
|
+
onAdd,
|
|
1465
|
+
onRemove,
|
|
1466
|
+
onSet,
|
|
1467
|
+
max,
|
|
1468
|
+
onRefuse
|
|
1469
|
+
}) {
|
|
1470
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "scopetickets-island-party-row", children: [
|
|
1471
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "scopetickets-island-party-row__text", children: [
|
|
1472
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "scopetickets-island-party-row__name", children: option.name }),
|
|
1473
|
+
option.note !== null && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "scopetickets-island-party-row__note", children: option.note })
|
|
1474
|
+
] }),
|
|
1475
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1476
|
+
UserTypeStepper,
|
|
1477
|
+
{
|
|
1478
|
+
name: option.name,
|
|
1479
|
+
count,
|
|
1480
|
+
atLimit,
|
|
1481
|
+
onAdd,
|
|
1482
|
+
onRemove,
|
|
1483
|
+
onSet,
|
|
1484
|
+
max,
|
|
1485
|
+
onRefuse
|
|
1486
|
+
}
|
|
1487
|
+
)
|
|
1488
|
+
] });
|
|
1489
|
+
}
|
|
1490
|
+
function UserTypeStepper({
|
|
1491
|
+
name,
|
|
1492
|
+
count,
|
|
1493
|
+
atLimit,
|
|
1494
|
+
onAdd,
|
|
1495
|
+
onRemove,
|
|
1496
|
+
onSet,
|
|
1497
|
+
max,
|
|
1498
|
+
onRefuse
|
|
1499
|
+
}) {
|
|
1500
|
+
const chosen = count > 0;
|
|
1501
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "scopetickets-island-stepper", "data-expanded": chosen ? "" : void 0, children: [
|
|
1502
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1503
|
+
"span",
|
|
1504
|
+
{
|
|
1505
|
+
className: "scopetickets-island-stepper__opening",
|
|
1506
|
+
"aria-hidden": chosen ? void 0 : "true",
|
|
1507
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "scopetickets-island-stepper__opening-inner", children: [
|
|
1508
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1509
|
+
StepperButton,
|
|
1510
|
+
{
|
|
1511
|
+
label: `Remove one ${name}`,
|
|
1512
|
+
onPress: onRemove,
|
|
1513
|
+
kind: "remove",
|
|
1514
|
+
state: chosen ? "LIVE" : "CLOSED"
|
|
1515
|
+
}
|
|
1516
|
+
),
|
|
1517
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1518
|
+
TypedCount,
|
|
1519
|
+
{
|
|
1520
|
+
count,
|
|
1521
|
+
name,
|
|
1522
|
+
onSet,
|
|
1523
|
+
valueClassName: "scopetickets-island-stepper__value",
|
|
1524
|
+
inputClassName: "scopetickets-island-stepper__input",
|
|
1525
|
+
closed: !chosen,
|
|
1526
|
+
max,
|
|
1527
|
+
onRefuse
|
|
1528
|
+
}
|
|
1529
|
+
)
|
|
1530
|
+
] })
|
|
1531
|
+
}
|
|
1532
|
+
),
|
|
1533
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1534
|
+
StepperButton,
|
|
1535
|
+
{
|
|
1536
|
+
label: `Add one ${name}`,
|
|
1537
|
+
onPress: onAdd,
|
|
1538
|
+
kind: "add",
|
|
1539
|
+
state: atLimit ? "REFUSING" : "LIVE"
|
|
1540
|
+
}
|
|
1541
|
+
)
|
|
1542
|
+
] });
|
|
1543
|
+
}
|
|
1544
|
+
function StepperButton({
|
|
1545
|
+
label,
|
|
1546
|
+
onPress,
|
|
1547
|
+
kind,
|
|
1548
|
+
state = "LIVE"
|
|
1549
|
+
}) {
|
|
1550
|
+
const press = useIslandPress("element");
|
|
1551
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1552
|
+
"button",
|
|
1553
|
+
{
|
|
1554
|
+
type: "button",
|
|
1555
|
+
className: "scopetickets-island-stepper__button",
|
|
1556
|
+
"data-kind": kind,
|
|
1557
|
+
"aria-label": label,
|
|
1558
|
+
"aria-disabled": state === "REFUSING" ? true : void 0,
|
|
1559
|
+
disabled: state === "CLOSED",
|
|
1560
|
+
onClick: state === "LIVE" ? onPress : void 0,
|
|
1561
|
+
...press,
|
|
1562
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "scopetickets-island-stepper__mark", children: kind === "add" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_icons3.PlusMarkIcon, { fill: true, color: "currentColor" }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_icons3.MinusMarkIcon, { fill: true, color: "currentColor" }) })
|
|
1563
|
+
}
|
|
1564
|
+
);
|
|
1565
|
+
}
|
|
1566
|
+
function SoloPartyStepper({ max, name, count, onSet, onRemove, onRefuse }) {
|
|
1567
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "scopetickets-island-party-solo", children: [
|
|
1568
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1569
|
+
StepperButton,
|
|
1570
|
+
{
|
|
1571
|
+
label: `Remove one ${name}`,
|
|
1572
|
+
onPress: onRemove,
|
|
1573
|
+
kind: "remove",
|
|
1574
|
+
state: count === 0 ? "REFUSING" : "LIVE"
|
|
1575
|
+
}
|
|
1576
|
+
),
|
|
1577
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1578
|
+
TypedCount,
|
|
1579
|
+
{
|
|
1580
|
+
count,
|
|
1581
|
+
name,
|
|
1582
|
+
onSet,
|
|
1583
|
+
valueClassName: "scopetickets-island-party-solo__value",
|
|
1584
|
+
inputClassName: "scopetickets-island-party-solo__input",
|
|
1585
|
+
max,
|
|
1586
|
+
onRefuse
|
|
1587
|
+
}
|
|
1588
|
+
),
|
|
1589
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1590
|
+
StepperButton,
|
|
1591
|
+
{
|
|
1592
|
+
label: `Add one ${name}`,
|
|
1593
|
+
onPress: () => onSet(count + 1),
|
|
1594
|
+
kind: "add",
|
|
1595
|
+
state: count >= max ? "REFUSING" : "LIVE"
|
|
1596
|
+
}
|
|
1597
|
+
)
|
|
1598
|
+
] });
|
|
1599
|
+
}
|
|
1600
|
+
function TypedCount({
|
|
1601
|
+
count,
|
|
1602
|
+
name,
|
|
1603
|
+
onSet,
|
|
1604
|
+
valueClassName,
|
|
1605
|
+
inputClassName,
|
|
1606
|
+
onRefuse,
|
|
1607
|
+
closed = false,
|
|
1608
|
+
max
|
|
1609
|
+
}) {
|
|
1610
|
+
const [typing, setTyping] = (0, import_react7.useState)(null);
|
|
1611
|
+
const field = (0, import_react7.useRef)(null);
|
|
1612
|
+
const editing = typing !== null;
|
|
1613
|
+
(0, import_react7.useEffect)(() => {
|
|
1614
|
+
if (!editing) return;
|
|
1615
|
+
field.current?.focus({ preventScroll: true });
|
|
1616
|
+
}, [editing]);
|
|
1617
|
+
const commit = () => {
|
|
1618
|
+
if (typing === null) return;
|
|
1619
|
+
const asked = Number.parseInt(typing, 10);
|
|
1620
|
+
setTyping(null);
|
|
1621
|
+
if (!Number.isFinite(asked)) return;
|
|
1622
|
+
if (max !== void 0 && asked > max) {
|
|
1623
|
+
onRefuse?.(asked);
|
|
1624
|
+
return;
|
|
1625
|
+
}
|
|
1626
|
+
onRefuse?.(null);
|
|
1627
|
+
onSet(Math.max(0, asked));
|
|
1628
|
+
};
|
|
1629
|
+
if (typing === null) {
|
|
1630
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1631
|
+
"button",
|
|
1632
|
+
{
|
|
1633
|
+
type: "button",
|
|
1634
|
+
className: valueClassName,
|
|
1635
|
+
"aria-label": `${count} ${name}. Change the number`,
|
|
1636
|
+
onClick: () => setTyping(String(count)),
|
|
1637
|
+
disabled: closed,
|
|
1638
|
+
children: count
|
|
1639
|
+
}
|
|
1640
|
+
);
|
|
1641
|
+
}
|
|
1642
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1643
|
+
"input",
|
|
1644
|
+
{
|
|
1645
|
+
className: inputClassName,
|
|
1646
|
+
type: "text",
|
|
1647
|
+
inputMode: "numeric",
|
|
1648
|
+
pattern: "[0-9]*",
|
|
1649
|
+
size: 1,
|
|
1650
|
+
ref: field,
|
|
1651
|
+
"aria-label": `Number of ${name}`,
|
|
1652
|
+
value: typing,
|
|
1653
|
+
onChange: (event) => setTyping(event.target.value.replace(/\D/g, "")),
|
|
1654
|
+
onBlur: commit,
|
|
1655
|
+
onKeyDown: (event) => {
|
|
1656
|
+
if (event.key === "Enter") commit();
|
|
1657
|
+
else if (event.key === "Escape") setTyping(null);
|
|
1658
|
+
else return;
|
|
1659
|
+
event.preventDefault();
|
|
1660
|
+
event.stopPropagation();
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
);
|
|
1664
|
+
}
|
|
1665
|
+
function PartyStepper({
|
|
1666
|
+
userTypes,
|
|
1667
|
+
counts,
|
|
1668
|
+
onChange,
|
|
1669
|
+
max,
|
|
1670
|
+
soloName = "Guests",
|
|
1671
|
+
onRefuse,
|
|
1672
|
+
refused = null
|
|
1673
|
+
}) {
|
|
1674
|
+
const headcount = Object.values(counts).reduce((total, n2) => total + n2, 0);
|
|
1675
|
+
const refuse = (asked) => onRefuse?.(asked);
|
|
1676
|
+
const shown = (count) => refused === null ? count : refused;
|
|
1677
|
+
if (userTypes.length === 0) {
|
|
1678
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "scopetickets-island-party", "data-excess": refused === null ? void 0 : "", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1679
|
+
SoloPartyStepper,
|
|
1680
|
+
{
|
|
1681
|
+
max,
|
|
1682
|
+
name: soloName,
|
|
1683
|
+
count: shown(headcount),
|
|
1684
|
+
onSet: (next) => {
|
|
1685
|
+
refuse(null);
|
|
1686
|
+
onChange(SOLO_KEY, next);
|
|
1687
|
+
},
|
|
1688
|
+
onRemove: () => refused === null ? onChange(SOLO_KEY, Math.max(0, headcount - 1)) : (refuse(null), onChange(SOLO_KEY, max)),
|
|
1689
|
+
onRefuse: refuse
|
|
1690
|
+
}
|
|
1691
|
+
) });
|
|
1692
|
+
}
|
|
1693
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "scopetickets-island-party", "data-excess": refused === null ? void 0 : "", children: userTypes.map((option) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1694
|
+
UserTypeRow,
|
|
1695
|
+
{
|
|
1696
|
+
option,
|
|
1697
|
+
count: counts[option.key] ?? 0,
|
|
1698
|
+
atLimit: headcount >= max,
|
|
1699
|
+
onAdd: () => {
|
|
1700
|
+
refuse(null);
|
|
1701
|
+
onChange(option.key, (counts[option.key] ?? 0) + 1);
|
|
1702
|
+
},
|
|
1703
|
+
onRemove: () => {
|
|
1704
|
+
refuse(null);
|
|
1705
|
+
onChange(option.key, Math.max(0, (counts[option.key] ?? 0) - 1));
|
|
1706
|
+
},
|
|
1707
|
+
onSet: (next) => {
|
|
1708
|
+
refuse(null);
|
|
1709
|
+
onChange(option.key, next);
|
|
1710
|
+
},
|
|
1711
|
+
max,
|
|
1712
|
+
onRefuse: refuse
|
|
1713
|
+
},
|
|
1714
|
+
option.key
|
|
1715
|
+
)) });
|
|
1716
|
+
}
|
|
1717
|
+
var SOLO_KEY = "default";
|
|
1718
|
+
|
|
1719
|
+
// src/island/CalendarGrainButton.tsx
|
|
1720
|
+
var import_react8 = require("react");
|
|
1721
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1722
|
+
function useShortenedMonth(long) {
|
|
1723
|
+
const [short, setShort] = (0, import_react8.useState)(false);
|
|
1724
|
+
const title = (0, import_react8.useRef)(null);
|
|
1725
|
+
const probe = (0, import_react8.useRef)(null);
|
|
1726
|
+
const measure = (0, import_react8.useCallback)(() => {
|
|
1727
|
+
const box = title.current;
|
|
1728
|
+
const full = probe.current;
|
|
1729
|
+
if (!box || !full) return;
|
|
1730
|
+
const wanted = Math.ceil(full.getBoundingClientRect().width);
|
|
1731
|
+
box.style.setProperty("--scopetickets-island-grain-width", `${wanted}px`);
|
|
1732
|
+
setShort(box.clientWidth + 1 < wanted);
|
|
1733
|
+
}, []);
|
|
1734
|
+
(0, import_react8.useLayoutEffect)(() => {
|
|
1735
|
+
measure();
|
|
1736
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
1737
|
+
const observer = new ResizeObserver(measure);
|
|
1738
|
+
if (title.current) observer.observe(title.current);
|
|
1739
|
+
return () => observer.disconnect();
|
|
1740
|
+
}, [measure, long]);
|
|
1741
|
+
return {
|
|
1742
|
+
short,
|
|
1743
|
+
titleRef: (0, import_react8.useCallback)(
|
|
1744
|
+
(node) => {
|
|
1745
|
+
title.current = node;
|
|
1746
|
+
measure();
|
|
1747
|
+
},
|
|
1748
|
+
[measure]
|
|
1749
|
+
),
|
|
1750
|
+
probeRef: (0, import_react8.useCallback)(
|
|
1751
|
+
(node) => {
|
|
1752
|
+
probe.current = node;
|
|
1753
|
+
measure();
|
|
1754
|
+
},
|
|
1755
|
+
[measure]
|
|
1756
|
+
)
|
|
1757
|
+
};
|
|
1758
|
+
}
|
|
1759
|
+
function CalendarGrainButton({ month, grain, onPress }) {
|
|
1760
|
+
const press = useIslandPress("element");
|
|
1761
|
+
const long = grain === "YEAR" ? formatMonthYear(month) : formatMonthName(month);
|
|
1762
|
+
const { short, titleRef, probeRef } = useShortenedMonth(long);
|
|
1763
|
+
const shown = grain === "MONTH" && short ? formatMonthNameShort(month) : long;
|
|
1764
|
+
const title = /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
1765
|
+
"span",
|
|
1766
|
+
{
|
|
1767
|
+
className: "scopetickets-island-header-button__title",
|
|
1768
|
+
ref: titleRef,
|
|
1769
|
+
...grain === "MONTH" && short ? { "data-grain-short": "" } : null,
|
|
1770
|
+
children: [
|
|
1771
|
+
shown,
|
|
1772
|
+
grain === "MONTH" ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1773
|
+
"span",
|
|
1774
|
+
{
|
|
1775
|
+
className: "scopetickets-island-header-button__probe",
|
|
1776
|
+
ref: probeRef,
|
|
1777
|
+
"aria-hidden": "true",
|
|
1778
|
+
children: long
|
|
1779
|
+
}
|
|
1780
|
+
) : null
|
|
1781
|
+
]
|
|
1782
|
+
}
|
|
1783
|
+
);
|
|
1784
|
+
if (onPress === void 0) {
|
|
1785
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "scopetickets-island-chrome-pill scopetickets-island-grain-pill", children: title });
|
|
1786
|
+
}
|
|
1787
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1788
|
+
"button",
|
|
1789
|
+
{
|
|
1790
|
+
type: "button",
|
|
1791
|
+
className: "scopetickets-island-chrome-pill scopetickets-island-header-button scopetickets-island-grain-pill",
|
|
1792
|
+
onClick: onPress,
|
|
1793
|
+
...press,
|
|
1794
|
+
children: title
|
|
1795
|
+
}
|
|
1796
|
+
);
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
// src/domain/user-types.ts
|
|
1800
|
+
function agreed(values) {
|
|
1801
|
+
const first = values[0];
|
|
1802
|
+
if (first === void 0) return null;
|
|
1803
|
+
return values.every((value) => value === first) ? first : null;
|
|
1804
|
+
}
|
|
1805
|
+
function groupUserTypes(rows) {
|
|
1806
|
+
const byName = /* @__PURE__ */ new Map();
|
|
1807
|
+
for (const row of rows) {
|
|
1808
|
+
if (row.Name === "") continue;
|
|
1809
|
+
const group = byName.get(row.Name);
|
|
1810
|
+
if (group === void 0) byName.set(row.Name, [row]);
|
|
1811
|
+
else group.push(row);
|
|
1812
|
+
}
|
|
1813
|
+
return [...byName.entries()].map(([name, group]) => ({
|
|
1814
|
+
key: name,
|
|
1815
|
+
name,
|
|
1816
|
+
note: agreed(group.map((row) => row.Note ?? null))
|
|
1817
|
+
}));
|
|
1818
|
+
}
|
|
1819
|
+
function assignmentFor(product, key) {
|
|
1820
|
+
if (product.UserTypes === void 0) return key;
|
|
1821
|
+
const offered = product.UserTypes ?? [];
|
|
1822
|
+
const byName = offered.find((type) => type.Name === key);
|
|
1823
|
+
if (byName !== void 0) return byName.AssignmentKey;
|
|
1824
|
+
return offered.some((type) => type.AssignmentKey === key) ? key : void 0;
|
|
1825
|
+
}
|
|
1826
|
+
function userTypeNames(rows) {
|
|
1827
|
+
return Object.fromEntries(rows.map((row) => [row.AssignmentKey, row.Name]));
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
// src/island/Switch.tsx
|
|
1831
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1832
|
+
function Switch({ checked, onChange, label, size = "wide", disabled = false }) {
|
|
1833
|
+
const press = useIslandPress("element");
|
|
1834
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1835
|
+
"button",
|
|
1836
|
+
{
|
|
1837
|
+
type: "button",
|
|
1838
|
+
role: "switch",
|
|
1839
|
+
"aria-checked": checked,
|
|
1840
|
+
"aria-label": label,
|
|
1841
|
+
disabled,
|
|
1842
|
+
className: `scopetickets-island-switch scopetickets-island-switch--${size}`,
|
|
1843
|
+
onClick: () => onChange(!checked),
|
|
1844
|
+
...disabled ? {} : press,
|
|
1845
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "scopetickets-island-switch__thumb", "aria-hidden": "true" })
|
|
1846
|
+
}
|
|
1847
|
+
);
|
|
1848
|
+
}
|
|
1849
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1850
|
+
0 && (module.exports = {
|
|
1851
|
+
CalendarGrainButton,
|
|
1852
|
+
ContentFlag,
|
|
1853
|
+
CounterRing,
|
|
1854
|
+
DATE_PICKER_ACCESSORY,
|
|
1855
|
+
DayPicker,
|
|
1856
|
+
PartyStepper,
|
|
1857
|
+
SOLO_KEY,
|
|
1858
|
+
Switch,
|
|
1859
|
+
TimePicker,
|
|
1860
|
+
TimeslotPicker,
|
|
1861
|
+
addDays,
|
|
1862
|
+
assignmentFor,
|
|
1863
|
+
availabilityColor,
|
|
1864
|
+
buildMonthGrid,
|
|
1865
|
+
buildTimeslotGroups,
|
|
1866
|
+
buildWeekRow,
|
|
1867
|
+
dateRange,
|
|
1868
|
+
eventKeyForDay,
|
|
1869
|
+
eventsOn,
|
|
1870
|
+
formatDayDate,
|
|
1871
|
+
formatDayWeekday,
|
|
1872
|
+
formatMonthName,
|
|
1873
|
+
formatMonthNameShort,
|
|
1874
|
+
formatMonthYear,
|
|
1875
|
+
formatSlotDuration,
|
|
1876
|
+
formatSlotRange,
|
|
1877
|
+
formatWeekdayAndDate,
|
|
1878
|
+
groupUserTypes,
|
|
1879
|
+
isDatePickerCellSelectable,
|
|
1880
|
+
isSelectableCalendarCell,
|
|
1881
|
+
locateDayInMonthStack,
|
|
1882
|
+
monthAtRow,
|
|
1883
|
+
monthOfDay,
|
|
1884
|
+
monthOfWeek,
|
|
1885
|
+
monthOpeningRow,
|
|
1886
|
+
monthStartRows,
|
|
1887
|
+
monthsInSeries,
|
|
1888
|
+
openingMonth,
|
|
1889
|
+
parseWallClockTime,
|
|
1890
|
+
partOfDay,
|
|
1891
|
+
partOfDayLabel,
|
|
1892
|
+
readAvailability,
|
|
1893
|
+
sameTimeslots,
|
|
1894
|
+
soonestRelevantDay,
|
|
1895
|
+
startOfWeek,
|
|
1896
|
+
stepMonth,
|
|
1897
|
+
timeOfDayInZone,
|
|
1898
|
+
timeslotRequest,
|
|
1899
|
+
toAvailabilityLevel,
|
|
1900
|
+
toggleSelectedDay,
|
|
1901
|
+
userTypeNames,
|
|
1902
|
+
weekContainingDay,
|
|
1903
|
+
weeksInCalendar,
|
|
1904
|
+
weeksInSeries,
|
|
1905
|
+
withSelectedDay,
|
|
1906
|
+
withSelectedTime
|
|
1907
|
+
});
|
|
1908
|
+
//# sourceMappingURL=pickers.cjs.map
|