@scopetickets/checkout 0.1.3 → 0.4.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
@@ -82,7 +82,7 @@ module.exports = __toCommonJS(pickers_exports);
82
82
  // src/island/DayPicker.tsx
83
83
  var import_react3 = require("react");
84
84
 
85
- // src/island/island-calendar.ts
85
+ // ../checkout-core/src/domain/island-calendar.ts
86
86
  var HIGH_FROM = 2 / 3;
87
87
  var MEDIUM_FROM = 1 / 3;
88
88
  function toAvailabilityLevel(remaining) {
@@ -104,15 +104,28 @@ var RAMP = [
104
104
  [HIGH_FROM, 67],
105
105
  [1, 100]
106
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);
107
+ function availabilityMix(remaining) {
108
+ const flat = (stop) => ({
109
+ from: stop,
110
+ to: stop,
111
+ towards: 100
112
+ });
113
+ if (remaining === null || !Number.isFinite(remaining) || remaining <= 0) return flat(0);
114
+ if (remaining >= 1) return flat(100);
111
115
  const top = RAMP.findIndex(([at]) => remaining <= at);
112
116
  const [lowAt, lowStop] = RAMP[top - 1];
113
117
  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)})`;
118
+ return {
119
+ from: lowStop,
120
+ to: highStop,
121
+ towards: Math.round((remaining - lowAt) / (highAt - lowAt) * 100)
122
+ };
123
+ }
124
+ function availabilityColor(remaining) {
125
+ const stop = (suffix) => `var(--scopetickets-island-availability-${suffix})`;
126
+ const { from, to, towards } = availabilityMix(remaining);
127
+ if (from === to) return stop(from);
128
+ return `color-mix(in srgb, ${stop(to)} ${towards}%, ${stop(from)})`;
116
129
  }
117
130
  function isDatePickerCellSelectable(state) {
118
131
  return state === "AVAILABLE" || state === "SELECTED";
@@ -399,7 +412,7 @@ function CalendarDayIndicator({ level }) {
399
412
  // src/island/island-press.ts
400
413
  var import_react = require("react");
401
414
 
402
- // src/island/island-motion.ts
415
+ // ../checkout-core/src/motion/island-motion.ts
403
416
  var SURFACE_MORPH_MS = 250;
404
417
  var SURFACE_DAMPING = 0.82;
405
418
  var SURFACE_SPRING = {
@@ -804,6 +817,43 @@ function CalendarWeekdayNames() {
804
817
  );
805
818
  }
806
819
 
820
+ // ../checkout-core/src/view/component-copy.ts
821
+ var PARTY_COPY = {
822
+ remove: (name) => `Remove one ${name}`,
823
+ add: (name) => `Add one ${name}`,
824
+ count: (count, name) => `${count} ${name}. Change the number`,
825
+ field: (name) => `Number of ${name}`,
826
+ /**
827
+ * AND WHAT AN UNDIFFERENTIATED PARTY IS CALLED — a run selling a single UserType has no
828
+ * name worth showing per row, so the one line it draws names the whole party.
829
+ *
830
+ * A PROP DEFAULT ON THE WEB IS INVISIBLE TO THE OTHER RENDERER, which is why this is
831
+ * here: `PartyStepper`'s own `soloName = 'Guests'` could not be read from native, so
832
+ * native re-typed it.
833
+ */
834
+ soloName: "Guests"
835
+ };
836
+ var ISLAND_COPY = {
837
+ order: "Your order",
838
+ runWeeks: "Weeks of the run"
839
+ };
840
+ var TIMESLOT_COPY = {
841
+ /**
842
+ * WHAT A SLOT WITH NOTHING LEFT SAYS, IN WORDS. The ring is a reading of how full a
843
+ * slot is, and at zero it draws nothing — an arc of no length is an absence, not a
844
+ * statement, and a buyer scanning a column for a time cannot be asked to notice an
845
+ * opacity.
846
+ */
847
+ soldOut: "Sold Out",
848
+ /**
849
+ * AND WHAT QUALIFIES THE PRICE — IN THE ROW'S NAME ONLY, not on its face. A column of
850
+ * forty rows each repeating the word says it forty times and the figure once. A screen
851
+ * reader gets one row at a time and no column, so a bare "€17.90" beside a time is a
852
+ * price with no qualifier at all.
853
+ */
854
+ from: "From"
855
+ };
856
+
807
857
  // src/island/DayPicker.tsx
808
858
  var import_jsx_runtime7 = require("react/jsx-runtime");
809
859
  function DayPicker({
@@ -848,7 +898,7 @@ function DayPicker({
848
898
  row,
849
899
  onRowChange: setRow,
850
900
  onRowPreview: setShownRow,
851
- label: "Weeks of the run",
901
+ label: ISLAND_COPY.runWeeks,
852
902
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
853
903
  CalendarRunGrid,
854
904
  {
@@ -971,7 +1021,7 @@ var import_react5 = require("react");
971
1021
  // src/island/CounterRing.tsx
972
1022
  var import_icons2 = require("@scopetickets/icons");
973
1023
 
974
- // src/island/island-timer.ts
1024
+ // ../checkout-core/src/geometry/island-timer.ts
975
1025
  var TIMER_GRID = 20;
976
1026
  var TIMER_CENTRE = TIMER_GRID / 2;
977
1027
  var RING_OUTER = 10;
@@ -1027,7 +1077,7 @@ function ringAnnulus(outer, inner) {
1027
1077
  return { d: annulus(outer, inner), evenodd: true };
1028
1078
  }
1029
1079
 
1030
- // src/island/island-counter-ring.ts
1080
+ // ../checkout-core/src/geometry/island-counter-ring.ts
1031
1081
  var RING_OUTER2 = 10;
1032
1082
  var RING_STROKE = 2.5;
1033
1083
  var RING_INNER2 = RING_OUTER2 - RING_STROKE;
@@ -1108,13 +1158,26 @@ function CounterRing({
1108
1158
  );
1109
1159
  }
1110
1160
 
1161
+ // ../checkout-core/src/domain/money.ts
1162
+ var MONEY_LOCALE = "en-IE";
1163
+ function formatterFor(currency) {
1164
+ return new Intl.NumberFormat(MONEY_LOCALE, { style: "currency", currency });
1165
+ }
1166
+ function minorUnitDigits(formatter) {
1167
+ return formatter.resolvedOptions().maximumFractionDigits ?? 2;
1168
+ }
1169
+ function formatMoney(minorUnits, currency) {
1170
+ const formatter = formatterFor(currency);
1171
+ return formatter.format(minorUnits / 10 ** minorUnitDigits(formatter));
1172
+ }
1173
+
1111
1174
  // src/island/Timeslot.tsx
1112
1175
  var import_jsx_runtime12 = require("react/jsx-runtime");
1113
1176
  var REMAINING_SIZE = "var(--scopetickets-island-space-4)";
1114
1177
  var SELECTED_ARC = "var(--scopetickets-island-timeslot-ring-selected)";
1115
1178
  var TRACK = "var(--scopetickets-island-timeslot-track)";
1116
1179
  var SELECTED_TRACK = "var(--scopetickets-island-timeslot-track-selected)";
1117
- var SOLD_OUT = "Sold Out";
1180
+ var { soldOut: SOLD_OUT, from: FROM } = TIMESLOT_COPY;
1118
1181
  function Timeslot({ cell, accessory, onSelect }) {
1119
1182
  if (isDatePickerCellSelectable(cell.state)) {
1120
1183
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TimeslotButton, { cell, accessory, onSelect });
@@ -1122,36 +1185,47 @@ function Timeslot({ cell, accessory, onSelect }) {
1122
1185
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TimeslotFixed, { cell });
1123
1186
  }
1124
1187
  function TimeslotRow({ cell }) {
1188
+ const price = slotPrice(cell);
1125
1189
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "scopetickets-island-timeslot__times", children: [
1126
1190
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "scopetickets-island-timeslot__time", children: cell.slot.startTime }),
1127
1191
  cell.slot.endTime === null ? null : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
1128
1192
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "scopetickets-island-timeslot__dash", "aria-hidden": "true", children: "-" }),
1129
1193
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "scopetickets-island-timeslot__time", children: cell.slot.endTime })
1130
1194
  ] }),
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
- ) })
1195
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "scopetickets-island-timeslot__trailing", children: [
1196
+ price === null ? null : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "scopetickets-island-timeslot__price", children: price }),
1197
+ cell.state === "UNAVAILABLE" ? (
1198
+ /*
1199
+ * THE WORDS INSTEAD OF THE MARK, AND ONLY WHERE THE MARK WOULD SAY NOTHING.
1200
+ *
1201
+ * `UNAVAILABLE` is the one state the ring cannot draw: `timeslotState` reaches it
1202
+ * only for `remaining <= 0`, which is an arc of zero length. A slot that has
1203
+ * merely BEGUN keeps its ring — it still has seats, and "Sold Out" over them
1204
+ * would be false.
1205
+ */
1206
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "scopetickets-island-timeslot__soldout", children: SOLD_OUT })
1207
+ ) : cell.slot.remaining === null ? null : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "scopetickets-island-timeslot__remaining", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1208
+ CounterRing,
1209
+ {
1210
+ progress: cell.slot.remaining,
1211
+ color: cell.state === "SELECTED" ? SELECTED_ARC : availabilityColor(cell.slot.remaining),
1212
+ trackColor: cell.state === "SELECTED" ? SELECTED_TRACK : TRACK,
1213
+ size: REMAINING_SIZE
1214
+ }
1215
+ ) })
1216
+ ] })
1150
1217
  ] });
1151
1218
  }
1219
+ function slotPrice(cell, spoken = false) {
1220
+ if (!isDatePickerCellSelectable(cell.state)) return null;
1221
+ const price = cell.slot.fromPrice;
1222
+ if (price === void 0 || price === null) return null;
1223
+ const money = formatMoney(price.minorUnits, price.currency);
1224
+ return spoken ? `${FROM} ${money}` : money;
1225
+ }
1152
1226
  function timeslotLabel(cell, announcement) {
1153
1227
  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(", ");
1228
+ return [range, cell.duration, slotPrice(cell, true), announcement].filter((part) => part !== null).join(", ");
1155
1229
  }
1156
1230
  function TimeslotButton({ cell, accessory, onSelect }) {
1157
1231
  const press = useIslandPress("element");
@@ -1194,7 +1268,7 @@ function TimeslotGroupSection({ group, accessory, onSelect }) {
1194
1268
  ] });
1195
1269
  }
1196
1270
 
1197
- // src/island/island-timeslots.ts
1271
+ // ../checkout-core/src/domain/island-timeslots.ts
1198
1272
  var MAX_TIME_INPUT = 40;
1199
1273
  var WALL_CLOCK = /^(?:\d{4}-\d{2}-\d{2}[T ])?(\d{2}):(\d{2})(?::\d{2})?/;
1200
1274
  function parseWallClockTime(value) {
@@ -1345,7 +1419,7 @@ function TimeslotPicker({
1345
1419
  )) });
1346
1420
  }
1347
1421
 
1348
- // src/island/island-step-order.ts
1422
+ // ../checkout-core/src/motion/island-step-order.ts
1349
1423
  function dayDirection(from, to) {
1350
1424
  if (from === to) return "NONE";
1351
1425
  return to > from ? "FORWARD" : "BACKWARD";
@@ -1356,9 +1430,7 @@ function stepDirectionSign(direction) {
1356
1430
  return 0;
1357
1431
  }
1358
1432
 
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";
1433
+ // ../checkout-core/src/motion/island-day-swap.ts
1362
1434
  function daySwapAtRest(content) {
1363
1435
  return { phase: "REST", shown: content };
1364
1436
  }
@@ -1388,6 +1460,10 @@ function reduceDaySwap(state, event) {
1388
1460
  }
1389
1461
  }
1390
1462
 
1463
+ // src/island/island-day-swap-css.ts
1464
+ var DAY_SWAP_OUT_ANIMATION = "scopetickets-island-day-swap-out";
1465
+ var DAY_SWAP_IN_ANIMATION = "scopetickets-island-day-swap-in";
1466
+
1391
1467
  // src/island/TimePicker.tsx
1392
1468
  var import_jsx_runtime15 = require("react/jsx-runtime");
1393
1469
  function TimePicker({
@@ -1456,6 +1532,40 @@ function TimePicker({
1456
1532
  // src/island/PartyStepper.tsx
1457
1533
  var import_react7 = require("react");
1458
1534
  var import_icons3 = require("@scopetickets/icons");
1535
+
1536
+ // ../checkout-core/src/domain/user-types.ts
1537
+ var SOLO_KEY = "default";
1538
+ function agreed(values) {
1539
+ const first = values[0];
1540
+ if (first === void 0) return null;
1541
+ return values.every((value) => value === first) ? first : null;
1542
+ }
1543
+ function groupUserTypes(rows) {
1544
+ const byName = /* @__PURE__ */ new Map();
1545
+ for (const row of rows) {
1546
+ if (row.Name === "") continue;
1547
+ const group = byName.get(row.Name);
1548
+ if (group === void 0) byName.set(row.Name, [row]);
1549
+ else group.push(row);
1550
+ }
1551
+ return [...byName.entries()].map(([name, group]) => ({
1552
+ key: name,
1553
+ name,
1554
+ note: agreed(group.map((row) => row.Note ?? null))
1555
+ }));
1556
+ }
1557
+ function assignmentFor(product, key) {
1558
+ if (product.UserTypes === void 0) return key;
1559
+ const offered = product.UserTypes ?? [];
1560
+ const byName = offered.find((type) => type.Name === key);
1561
+ if (byName !== void 0) return byName.AssignmentKey;
1562
+ return offered.some((type) => type.AssignmentKey === key) ? key : void 0;
1563
+ }
1564
+ function userTypeNames(rows) {
1565
+ return Object.fromEntries(rows.map((row) => [row.AssignmentKey, row.Name]));
1566
+ }
1567
+
1568
+ // src/island/PartyStepper.tsx
1459
1569
  var import_jsx_runtime16 = require("react/jsx-runtime");
1460
1570
  function UserTypeRow({
1461
1571
  option,
@@ -1508,7 +1618,7 @@ function UserTypeStepper({
1508
1618
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1509
1619
  StepperButton,
1510
1620
  {
1511
- label: `Remove one ${name}`,
1621
+ label: PARTY_COPY.remove(name),
1512
1622
  onPress: onRemove,
1513
1623
  kind: "remove",
1514
1624
  state: chosen ? "LIVE" : "CLOSED"
@@ -1533,7 +1643,7 @@ function UserTypeStepper({
1533
1643
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1534
1644
  StepperButton,
1535
1645
  {
1536
- label: `Add one ${name}`,
1646
+ label: PARTY_COPY.add(name),
1537
1647
  onPress: onAdd,
1538
1648
  kind: "add",
1539
1649
  state: atLimit ? "REFUSING" : "LIVE"
@@ -1568,7 +1678,7 @@ function SoloPartyStepper({ max, name, count, onSet, onRemove, onRefuse }) {
1568
1678
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1569
1679
  StepperButton,
1570
1680
  {
1571
- label: `Remove one ${name}`,
1681
+ label: PARTY_COPY.remove(name),
1572
1682
  onPress: onRemove,
1573
1683
  kind: "remove",
1574
1684
  state: count === 0 ? "REFUSING" : "LIVE"
@@ -1589,7 +1699,7 @@ function SoloPartyStepper({ max, name, count, onSet, onRemove, onRefuse }) {
1589
1699
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1590
1700
  StepperButton,
1591
1701
  {
1592
- label: `Add one ${name}`,
1702
+ label: PARTY_COPY.add(name),
1593
1703
  onPress: () => onSet(count + 1),
1594
1704
  kind: "add",
1595
1705
  state: count >= max ? "REFUSING" : "LIVE"
@@ -1632,7 +1742,7 @@ function TypedCount({
1632
1742
  {
1633
1743
  type: "button",
1634
1744
  className: valueClassName,
1635
- "aria-label": `${count} ${name}. Change the number`,
1745
+ "aria-label": PARTY_COPY.count(count, name),
1636
1746
  onClick: () => setTyping(String(count)),
1637
1747
  disabled: closed,
1638
1748
  children: count
@@ -1648,7 +1758,7 @@ function TypedCount({
1648
1758
  pattern: "[0-9]*",
1649
1759
  size: 1,
1650
1760
  ref: field,
1651
- "aria-label": `Number of ${name}`,
1761
+ "aria-label": PARTY_COPY.field(name),
1652
1762
  value: typing,
1653
1763
  onChange: (event) => setTyping(event.target.value.replace(/\D/g, "")),
1654
1764
  onBlur: commit,
@@ -1667,7 +1777,7 @@ function PartyStepper({
1667
1777
  counts,
1668
1778
  onChange,
1669
1779
  max,
1670
- soloName = "Guests",
1780
+ soloName = PARTY_COPY.soloName,
1671
1781
  onRefuse,
1672
1782
  refused = null
1673
1783
  }) {
@@ -1714,7 +1824,6 @@ function PartyStepper({
1714
1824
  option.key
1715
1825
  )) });
1716
1826
  }
1717
- var SOLO_KEY = "default";
1718
1827
 
1719
1828
  // src/island/CalendarGrainButton.tsx
1720
1829
  var import_react8 = require("react");
@@ -1796,37 +1905,6 @@ function CalendarGrainButton({ month, grain, onPress }) {
1796
1905
  );
1797
1906
  }
1798
1907
 
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
1908
  // src/island/Switch.tsx
1831
1909
  var import_jsx_runtime18 = require("react/jsx-runtime");
1832
1910
  function Switch({ checked, onChange, label, size = "wide", disabled = false }) {