@cimplify/sdk 0.73.0 → 0.75.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.
Files changed (34) hide show
  1. package/dist/advanced.d.mts +3 -3
  2. package/dist/advanced.d.ts +3 -3
  3. package/dist/{client-BvqaIlJ0.d.ts → client--w53owD4.d.ts} +2 -2
  4. package/dist/{client-C7EMuGoz.d.mts → client-D7uHF_jh.d.mts} +2 -2
  5. package/dist/{client-D6CZ2Ggp.d.ts → client-xDpke-KS.d.ts} +2 -2
  6. package/dist/{client-DWA_XIh3.d.mts → client-yFghjc1-.d.mts} +2 -2
  7. package/dist/{index-DIIlPUOC.d.ts → index-DTGS0QC1.d.ts} +3 -3
  8. package/dist/{index-D8vnKlOQ.d.mts → index-lt-fe29V.d.mts} +3 -3
  9. package/dist/index.d.mts +6 -6
  10. package/dist/index.d.ts +6 -6
  11. package/dist/{payment-DVS7ZUEp.d.mts → payment-C-2gApyQ.d.mts} +1 -1
  12. package/dist/{payment-sn-yGL7v.d.ts → payment-CfemTORM.d.ts} +1 -1
  13. package/dist/{price-Cm0tU0V5.d.mts → price-CZBQw-Rh.d.mts} +1 -1
  14. package/dist/{price-9T1Y47oS.d.ts → price-DNeyoO7y.d.ts} +1 -1
  15. package/dist/{product-B_kS4Oxa.d.mts → product-_GFoaPHU.d.mts} +2 -0
  16. package/dist/{product-B_kS4Oxa.d.ts → product-_GFoaPHU.d.ts} +2 -0
  17. package/dist/react.d.mts +39 -5
  18. package/dist/react.d.ts +39 -5
  19. package/dist/react.js +187 -66
  20. package/dist/react.mjs +187 -67
  21. package/dist/{server-DMvQp27Z.d.ts → server-1hXIXH2k.d.ts} +1 -1
  22. package/dist/{server-DDQ1O3XR.d.mts → server-G8I4JtqK.d.mts} +1 -1
  23. package/dist/server.d.mts +4 -4
  24. package/dist/server.d.ts +4 -4
  25. package/dist/testing/msw.d.mts +2 -2
  26. package/dist/testing/msw.d.ts +2 -2
  27. package/dist/testing/suite.d.mts +6 -6
  28. package/dist/testing/suite.d.ts +6 -6
  29. package/dist/testing.d.mts +5 -5
  30. package/dist/testing.d.ts +5 -5
  31. package/dist/utils.d.mts +4 -4
  32. package/dist/utils.d.ts +4 -4
  33. package/package.json +1 -1
  34. package/registry/product-customizer.json +1 -1
package/dist/react.js CHANGED
@@ -7311,6 +7311,144 @@ function formatDuration2(value, unit) {
7311
7311
  const label = value === 1 ? labels.singular : labels.plural;
7312
7312
  return `${value} ${label}`;
7313
7313
  }
7314
+ var ANY_VALUE = "__any__";
7315
+ function StaffPicker({
7316
+ staff,
7317
+ selectedStaffId,
7318
+ onStaffSelect,
7319
+ showAnyOption = true,
7320
+ anyLabel = "Any available",
7321
+ className,
7322
+ classNames
7323
+ }) {
7324
+ const groupValue = selectedStaffId === null ? ANY_VALUE : selectedStaffId ?? "";
7325
+ return /* @__PURE__ */ jsxRuntime.jsxs(
7326
+ radioGroup.RadioGroup,
7327
+ {
7328
+ "data-cimplify-staff-picker": true,
7329
+ className: cn(className, classNames?.root),
7330
+ value: groupValue,
7331
+ onValueChange: (value) => {
7332
+ onStaffSelect?.(value === ANY_VALUE ? null : value);
7333
+ },
7334
+ children: [
7335
+ showAnyOption && /* @__PURE__ */ jsxRuntime.jsx(
7336
+ radio.Radio.Root,
7337
+ {
7338
+ value: ANY_VALUE,
7339
+ "data-cimplify-staff-option": true,
7340
+ "data-selected": selectedStaffId === null || void 0,
7341
+ "data-any": true,
7342
+ className: classNames?.option,
7343
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-staff-name": true, className: classNames?.name, children: anyLabel })
7344
+ }
7345
+ ),
7346
+ staff.map((member) => /* @__PURE__ */ jsxRuntime.jsxs(
7347
+ radio.Radio.Root,
7348
+ {
7349
+ value: member.id,
7350
+ "data-cimplify-staff-option": true,
7351
+ "data-selected": selectedStaffId === member.id || void 0,
7352
+ className: classNames?.option,
7353
+ children: [
7354
+ member.avatar_url && /* @__PURE__ */ jsxRuntime.jsx(
7355
+ "img",
7356
+ {
7357
+ src: member.avatar_url,
7358
+ alt: member.name,
7359
+ "data-cimplify-staff-avatar": true,
7360
+ className: classNames?.avatar
7361
+ }
7362
+ ),
7363
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-staff-name": true, className: classNames?.name, children: member.name }),
7364
+ member.bio && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-staff-bio": true, className: classNames?.bio, children: member.bio })
7365
+ ]
7366
+ },
7367
+ member.id
7368
+ ))
7369
+ ]
7370
+ }
7371
+ );
7372
+ }
7373
+ function formatDate(value) {
7374
+ const date = new Date(value);
7375
+ if (Number.isNaN(date.getTime())) return value;
7376
+ return date.toLocaleDateString(void 0, {
7377
+ weekday: "short",
7378
+ month: "short",
7379
+ day: "numeric"
7380
+ });
7381
+ }
7382
+ function formatTime(value) {
7383
+ const date = new Date(value);
7384
+ if (Number.isNaN(date.getTime())) return value;
7385
+ return date.toLocaleTimeString(void 0, { hour: "numeric", minute: "2-digit" });
7386
+ }
7387
+ function BookingSummary({
7388
+ slot,
7389
+ total,
7390
+ staffName,
7391
+ durationMinutes,
7392
+ depositType,
7393
+ depositAmount,
7394
+ currency,
7395
+ className,
7396
+ classNames
7397
+ }) {
7398
+ const depositValue = depositAmount != null ? chunk7Y2O3E4D_js.parsePrice(depositAmount) : 0;
7399
+ const depositDue = depositType === "percentage" ? total * depositValue / 100 : depositType === "fixed" ? depositValue : 0;
7400
+ const hasDeposit = depositDue > 0;
7401
+ const balance = Math.max(0, total - depositDue);
7402
+ const rowClass = cn("flex items-center justify-between", classNames?.row);
7403
+ const labelClass = cn("text-muted-foreground", classNames?.label);
7404
+ const valueClass = cn("font-medium", classNames?.value);
7405
+ return /* @__PURE__ */ jsxRuntime.jsxs(
7406
+ "div",
7407
+ {
7408
+ "data-cimplify-booking-summary": true,
7409
+ className: cn("rounded-lg border border-border p-4 space-y-3", className, classNames?.root),
7410
+ children: [
7411
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex items-center justify-between", classNames?.header), children: [
7412
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-semibold", children: "Your booking" }),
7413
+ durationMinutes != null && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-muted-foreground", children: [
7414
+ durationMinutes,
7415
+ " min"
7416
+ ] })
7417
+ ] }),
7418
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5 text-sm", children: [
7419
+ staffName && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: rowClass, children: [
7420
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: labelClass, children: "With" }),
7421
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: valueClass, children: staffName })
7422
+ ] }),
7423
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: rowClass, children: [
7424
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: labelClass, children: "Date" }),
7425
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: valueClass, children: formatDate(slot.start_time) })
7426
+ ] }),
7427
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: rowClass, children: [
7428
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: labelClass, children: "Time" }),
7429
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: valueClass, children: formatTime(slot.start_time) })
7430
+ ] })
7431
+ ] }),
7432
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("border-t border-border pt-3 space-y-1.5 text-sm", classNames?.totals), children: [
7433
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: rowClass, children: [
7434
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: labelClass, children: "Subtotal" }),
7435
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold", children: /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: total, currency }) })
7436
+ ] }),
7437
+ hasDeposit && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7438
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(rowClass, classNames?.deposit), children: [
7439
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: labelClass, children: "Due now (deposit)" }),
7440
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold", children: /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: depositDue, currency }) })
7441
+ ] }),
7442
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(rowClass, "text-xs text-muted-foreground", classNames?.balance), children: [
7443
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Balance at appointment" }),
7444
+ /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: balance, currency })
7445
+ ] })
7446
+ ] })
7447
+ ] })
7448
+ ]
7449
+ }
7450
+ );
7451
+ }
7314
7452
  var FREQUENCY_LABELS = {
7315
7453
  weekly: "Weekly",
7316
7454
  biweekly: "Biweekly",
@@ -8675,7 +8813,7 @@ function groupSlots(slots) {
8675
8813
  }
8676
8814
  return ["morning", "afternoon", "evening"].filter((tod) => groups[tod]?.length).map((tod) => ({ label: TIME_OF_DAY_LABELS[tod], slots: groups[tod] }));
8677
8815
  }
8678
- function formatTime(timeStr) {
8816
+ function formatTime2(timeStr) {
8679
8817
  try {
8680
8818
  const date = new Date(timeStr);
8681
8819
  if (!isNaN(date.getTime())) {
@@ -8850,7 +8988,7 @@ function SlotPicker({
8850
8988
  classNames?.slot
8851
8989
  ),
8852
8990
  children: [
8853
- /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-slot-time": true, className: classNames?.slotTime, children: isMultiDay ? formatStaySummary(slot, durationUnit, durationValue) : formatTime(slot.start_time) }),
8991
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-slot-time": true, className: classNames?.slotTime, children: isMultiDay ? formatStaySummary(slot, durationUnit, durationValue) : formatTime2(slot.start_time) }),
8854
8992
  showPrice && slot.price && /* @__PURE__ */ jsxRuntime.jsx(
8855
8993
  "span",
8856
8994
  {
@@ -8884,7 +9022,7 @@ function SlotPicker({
8884
9022
  }
8885
9023
  );
8886
9024
  }
8887
- function formatDate(dateStr) {
9025
+ function formatDate2(dateStr) {
8888
9026
  const date = /* @__PURE__ */ new Date(dateStr + "T00:00:00");
8889
9027
  return date.toLocaleDateString(void 0, { weekday: "short", month: "short", day: "numeric" });
8890
9028
  }
@@ -9029,7 +9167,7 @@ function DateSlotPicker({
9029
9167
  "flex flex-col items-center justify-center rounded-md border border-border bg-background px-1 py-2 text-center text-xs font-medium text-foreground transition-colors hover:border-foreground/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring data-[selected]:border-foreground data-[selected]:bg-foreground data-[selected]:text-background data-[fully-booked]:cursor-not-allowed data-[fully-booked]:opacity-40",
9030
9168
  classNames?.dateButton
9031
9169
  ),
9032
- children: formatDate(date)
9170
+ children: formatDate2(date)
9033
9171
  },
9034
9172
  date
9035
9173
  );
@@ -9089,6 +9227,7 @@ function ProductCustomizer({
9089
9227
  const [customerInputValues, setCustomerInputValues] = React14.useState({});
9090
9228
  const [specialInstructions, setSpecialInstructions] = React14.useState("");
9091
9229
  const [selectedSlot, setSelectedSlot] = React14.useState(null);
9230
+ const [selectedStaffId, setSelectedStaffId] = React14.useState(null);
9092
9231
  const cart = useCart();
9093
9232
  const currency = chunk7Y2O3E4D_js.getProductCurrency(product);
9094
9233
  const productType = product.type || "product";
@@ -9116,7 +9255,16 @@ function ProductCustomizer({
9116
9255
  setCustomerInputValues({});
9117
9256
  setSpecialInstructions("");
9118
9257
  setSelectedSlot(null);
9258
+ setSelectedStaffId(null);
9119
9259
  }, [product.id, product.min_order_quantity]);
9260
+ const slotStaff = React14.useMemo(
9261
+ () => (selectedSlot?.available_staff ?? []).map((member) => ({
9262
+ id: member.staff_id,
9263
+ name: member.name
9264
+ })),
9265
+ [selectedSlot]
9266
+ );
9267
+ const selectedStaffName = selectedStaffId ? slotStaff.find((member) => member.id === selectedStaffId)?.name ?? null : null;
9120
9268
  const selectedAddOnOptions = React14.useMemo(() => {
9121
9269
  if (!product.add_ons) return [];
9122
9270
  const options = [];
@@ -9228,7 +9376,7 @@ function ProductCustomizer({
9228
9376
  ...isService && selectedSlot ? {
9229
9377
  scheduledStart: selectedSlot.start_time,
9230
9378
  scheduledEnd: selectedSlot.end_time,
9231
- staffId: selectedSlot.available_staff?.[0]?.staff_id,
9379
+ staffId: selectedStaffId ?? selectedSlot.available_staff?.[0]?.staff_id,
9232
9380
  resourceId: selectedSlot.available_resources?.[0]?.resource_id
9233
9381
  } : {},
9234
9382
  customerInputs: Object.keys(customerInputValues).length > 0 ? Object.entries(customerInputValues).filter(([, v]) => v !== void 0 && v !== "").map(([fieldId, value]) => ({ field_id: fieldId, value })) : void 0,
@@ -9250,7 +9398,7 @@ function ProductCustomizer({
9250
9398
  } finally {
9251
9399
  setIsSubmitting(false);
9252
9400
  }
9253
- }, [product, quantity, selectedVariantId, selectedVariant, quoteId, normalizedAddOnOptionIds, selectedAddOnOptions, isComposite, compositeSelections, isBundle, bundleSelections, selectedBillingPlan, customerInputValues, specialInstructions, isService, selectedSlot, isSubmitting, onAddToCart, cart]);
9401
+ }, [product, quantity, selectedVariantId, selectedVariant, quoteId, normalizedAddOnOptionIds, selectedAddOnOptions, isComposite, compositeSelections, isBundle, bundleSelections, selectedBillingPlan, customerInputValues, specialInstructions, isService, selectedSlot, selectedStaffId, isSubmitting, onAddToCart, cart]);
9254
9402
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-customizer": true, className: cn("space-y-6", className, classNames?.root), children: [
9255
9403
  isComposite && product.groups && product.composite_id && /* @__PURE__ */ jsxRuntime.jsx(
9256
9404
  CompositeSelector,
@@ -9282,11 +9430,30 @@ function ProductCustomizer({
9282
9430
  {
9283
9431
  serviceId: product.id,
9284
9432
  selectedSlot,
9285
- onSlotSelect: (slot) => setSelectedSlot(slot),
9433
+ onSlotSelect: (slot) => {
9434
+ setSelectedSlot(slot);
9435
+ setSelectedStaffId(null);
9436
+ },
9286
9437
  participantCount: quantity,
9287
9438
  currency
9288
9439
  }
9289
9440
  ),
9441
+ isService && slotStaff.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-customizer-staff": true, children: [
9442
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "block text-xs font-medium uppercase tracking-wider text-muted-foreground mb-3", children: "Choose your specialist" }),
9443
+ /* @__PURE__ */ jsxRuntime.jsx(
9444
+ StaffPicker,
9445
+ {
9446
+ staff: slotStaff,
9447
+ selectedStaffId,
9448
+ onStaffSelect: setSelectedStaffId,
9449
+ className: "flex flex-wrap gap-2",
9450
+ classNames: {
9451
+ option: "inline-flex items-center gap-2 rounded-md border border-border px-3 py-2 text-sm font-medium transition-colors hover:border-foreground/40 cursor-pointer data-[selected]:border-foreground data-[selected]:bg-foreground data-[selected]:text-background",
9452
+ avatar: "w-6 h-6 rounded-full object-cover"
9453
+ }
9454
+ }
9455
+ )
9456
+ ] }),
9290
9457
  hasVariants && /* @__PURE__ */ jsxRuntime.jsx(
9291
9458
  VariantSelector,
9292
9459
  {
@@ -9371,6 +9538,18 @@ function ProductCustomizer({
9371
9538
  )
9372
9539
  }
9373
9540
  ) }),
9541
+ isService && selectedSlot && /* @__PURE__ */ jsxRuntime.jsx(
9542
+ BookingSummary,
9543
+ {
9544
+ slot: selectedSlot,
9545
+ total: displayTotalPrice,
9546
+ staffName: selectedStaffName,
9547
+ durationMinutes: product.duration_minutes,
9548
+ depositType: product.deposit_type,
9549
+ depositAmount: product.deposit_amount,
9550
+ currency
9551
+ }
9552
+ ),
9374
9553
  /* @__PURE__ */ jsxRuntime.jsxs(
9375
9554
  "div",
9376
9555
  {
@@ -12486,65 +12665,6 @@ function StoreNav({
12486
12665
  ] })
12487
12666
  ] });
12488
12667
  }
12489
- var ANY_VALUE = "__any__";
12490
- function StaffPicker({
12491
- staff,
12492
- selectedStaffId,
12493
- onStaffSelect,
12494
- showAnyOption = true,
12495
- anyLabel = "Any available",
12496
- className,
12497
- classNames
12498
- }) {
12499
- const groupValue = selectedStaffId === null ? ANY_VALUE : selectedStaffId ?? "";
12500
- return /* @__PURE__ */ jsxRuntime.jsxs(
12501
- radioGroup.RadioGroup,
12502
- {
12503
- "data-cimplify-staff-picker": true,
12504
- className: cn(className, classNames?.root),
12505
- value: groupValue,
12506
- onValueChange: (value) => {
12507
- onStaffSelect?.(value === ANY_VALUE ? null : value);
12508
- },
12509
- children: [
12510
- showAnyOption && /* @__PURE__ */ jsxRuntime.jsx(
12511
- radio.Radio.Root,
12512
- {
12513
- value: ANY_VALUE,
12514
- "data-cimplify-staff-option": true,
12515
- "data-selected": selectedStaffId === null || void 0,
12516
- "data-any": true,
12517
- className: classNames?.option,
12518
- children: /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-staff-name": true, className: classNames?.name, children: anyLabel })
12519
- }
12520
- ),
12521
- staff.map((member) => /* @__PURE__ */ jsxRuntime.jsxs(
12522
- radio.Radio.Root,
12523
- {
12524
- value: member.id,
12525
- "data-cimplify-staff-option": true,
12526
- "data-selected": selectedStaffId === member.id || void 0,
12527
- className: classNames?.option,
12528
- children: [
12529
- member.avatar_url && /* @__PURE__ */ jsxRuntime.jsx(
12530
- "img",
12531
- {
12532
- src: member.avatar_url,
12533
- alt: member.name,
12534
- "data-cimplify-staff-avatar": true,
12535
- className: classNames?.avatar
12536
- }
12537
- ),
12538
- /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-staff-name": true, className: classNames?.name, children: member.name }),
12539
- member.bio && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-staff-bio": true, className: classNames?.bio, children: member.bio })
12540
- ]
12541
- },
12542
- member.id
12543
- ))
12544
- ]
12545
- }
12546
- );
12547
- }
12548
12668
  var STATUS_LABELS3 = {
12549
12669
  pending: "Pending",
12550
12670
  confirmed: "Confirmed",
@@ -16668,6 +16788,7 @@ exports.BillingPlanSelector = BillingPlanSelector;
16668
16788
  exports.BookingCard = BookingCard;
16669
16789
  exports.BookingList = BookingList;
16670
16790
  exports.BookingPage = BookingPage;
16791
+ exports.BookingSummary = BookingSummary;
16671
16792
  exports.BookingsPage = BookingsPage;
16672
16793
  exports.BoxIcon24 = BoxIcon24;
16673
16794
  exports.BundleProductCard = BundleProductCard;