@scopetickets/checkout 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/pickers.cjs CHANGED
@@ -835,7 +835,8 @@ var PARTY_COPY = {
835
835
  };
836
836
  var ISLAND_COPY = {
837
837
  order: "Your order",
838
- runWeeks: "Weeks of the run"
838
+ runWeeks: "Weeks of the run",
839
+ inventories: "Show sessions"
839
840
  };
840
841
  var TIMESLOT_COPY = {
841
842
  /**
@@ -858,6 +859,7 @@ var TIMESLOT_COPY = {
858
859
  var import_jsx_runtime7 = require("react/jsx-runtime");
859
860
  function DayPicker({
860
861
  series,
862
+ offered = series,
861
863
  today,
862
864
  selectedDay,
863
865
  onSelectDay,
@@ -868,7 +870,7 @@ function DayPicker({
868
870
  const weeks = (0, import_react3.useMemo)(() => weeksInCalendar(series), [series]);
869
871
  const starts = (0, import_react3.useMemo)(() => monthStartRows(weeks), [weeks]);
870
872
  const [row, setRow] = (0, import_react3.useState)(
871
- () => monthOpeningRow(weeks, starts, selectedDay ?? soonestRelevantDay(series, today))
873
+ () => monthOpeningRow(weeks, starts, selectedDay ?? soonestRelevantDay(offered, today))
872
874
  );
873
875
  const [shownRow, setShownRow] = (0, import_react3.useState)(row);
874
876
  const currentMonth = monthAtRow(starts, shownRow);
@@ -902,7 +904,7 @@ function DayPicker({
902
904
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
903
905
  CalendarRunGrid,
904
906
  {
905
- series,
907
+ series: offered,
906
908
  weeks,
907
909
  currentMonth,
908
910
  accessory,
@@ -1357,12 +1359,11 @@ function sameTimeslots(a, b) {
1357
1359
  if (a.length !== b.length) return false;
1358
1360
  return a.every((slot, index) => {
1359
1361
  const other = b[index];
1360
- return slot.startTime === other.startTime && slot.endTime === other.endTime && slot.remaining === other.remaining;
1362
+ return slot.startTime === other.startTime && slot.endTime === other.endTime && slot.remaining === other.remaining && slot.product === other.product;
1361
1363
  });
1362
1364
  }
1363
1365
  function buildTimeslotGroups(slots, options) {
1364
1366
  const groups = [];
1365
- const byPart = /* @__PURE__ */ new Map();
1366
1367
  const chronological = [...slots].sort((a, b) => a.startTime.localeCompare(b.startTime));
1367
1368
  const cellFor = (slot) => ({
1368
1369
  slot,
@@ -1370,15 +1371,25 @@ function buildTimeslotGroups(slots, options) {
1370
1371
  state: timeslotState(slot, options),
1371
1372
  duration: formatSlotDuration(slot.startTime, slot.endTime)
1372
1373
  });
1373
- if ((options.grouping ?? "PART_OF_DAY") === "NONE") {
1374
- return chronological.length === 0 ? [] : [{ part: null, label: null, cells: chronological.map(cellFor) }];
1374
+ const grouping = options.grouping ?? "PART_OF_DAY";
1375
+ if (grouping === "NONE") {
1376
+ return chronological.length === 0 ? [] : [{ key: "ALL", part: null, label: null, cells: chronological.map(cellFor) }];
1375
1377
  }
1376
- for (const slot of chronological) {
1378
+ const byKey = /* @__PURE__ */ new Map();
1379
+ const groupOf = (slot) => {
1380
+ if (grouping === "PRODUCT") {
1381
+ const product = slot.product?.trim() ?? "";
1382
+ return product === "" ? { key: "PRODUCT:", part: null, label: null } : { key: `PRODUCT:${product}`, part: null, label: product };
1383
+ }
1377
1384
  const part = partOfDay(slot.startTime);
1378
- let group = byPart.get(part);
1385
+ return { key: part, part, label: partOfDayLabel(part) };
1386
+ };
1387
+ for (const slot of chronological) {
1388
+ const head = groupOf(slot);
1389
+ let group = byKey.get(head.key);
1379
1390
  if (!group) {
1380
- group = { part, label: partOfDayLabel(part), cells: [] };
1381
- byPart.set(part, group);
1391
+ group = { ...head, cells: [] };
1392
+ byKey.set(head.key, group);
1382
1393
  groups.push(group);
1383
1394
  }
1384
1395
  group.cells.push(cellFor(slot));
@@ -1415,7 +1426,7 @@ function TimeslotPicker({
1415
1426
  accessory,
1416
1427
  onSelect
1417
1428
  },
1418
- group.part ?? "ALL"
1429
+ group.key
1419
1430
  )) });
1420
1431
  }
1421
1432
 
@@ -1476,7 +1487,8 @@ function TimePicker({
1476
1487
  onSelectTime,
1477
1488
  remaining,
1478
1489
  accessory = DATE_PICKER_ACCESSORY,
1479
- onVisibleMonthChange
1490
+ onVisibleMonthChange,
1491
+ grouping
1480
1492
  }) {
1481
1493
  const [swap, dispatch] = (0, import_react6.useReducer)(reduceDaySwap, { day: selection.day, slots }, daySwapAtRest);
1482
1494
  (0, import_react6.useEffect)(() => {
@@ -1520,7 +1532,8 @@ function TimePicker({
1520
1532
  today,
1521
1533
  nowTime,
1522
1534
  onSelect: onSelectTime,
1523
- accessory
1535
+ accessory,
1536
+ grouping
1524
1537
  }
1525
1538
  )
1526
1539
  ]