@cimplify/sdk 0.11.0 → 0.12.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/react.mjs CHANGED
@@ -7,6 +7,9 @@ import { twMerge } from 'tailwind-merge';
7
7
  import { RadioGroup } from '@base-ui/react/radio-group';
8
8
  import { Radio } from '@base-ui/react/radio';
9
9
  import { Checkbox } from '@base-ui/react/checkbox';
10
+ import { Field } from '@base-ui/react/field';
11
+ import { Input } from '@base-ui/react/input';
12
+ import { Tabs } from '@base-ui/react/tabs';
10
13
 
11
14
  // src/ads/index.tsx
12
15
 
@@ -9166,33 +9169,45 @@ function ProductImageGallery({
9166
9169
  )
9167
9170
  }
9168
9171
  ),
9169
- normalizedImages.length > 1 && /* @__PURE__ */ jsx("div", { "data-cimplify-image-gallery-thumbnails": true, style: { display: "flex", gap: "0.5rem", marginTop: "0.75rem" }, children: normalizedImages.map((image, index) => /* @__PURE__ */ jsx(
9170
- "button",
9172
+ normalizedImages.length > 1 && /* @__PURE__ */ jsx(
9173
+ RadioGroup,
9171
9174
  {
9172
- type: "button",
9173
- onClick: () => setSelectedImage(index),
9174
- "aria-selected": selectedImage === index,
9175
- "data-cimplify-image-gallery-thumb": true,
9176
- "data-selected": selectedImage === index || void 0,
9177
- style: {
9178
- width: "4rem",
9179
- height: "4rem",
9180
- overflow: "hidden",
9181
- padding: 0,
9182
- border: "none",
9183
- cursor: "pointer"
9184
- },
9185
- children: /* @__PURE__ */ jsx(
9186
- "img",
9187
- {
9188
- src: image,
9189
- alt: "",
9190
- style: { width: "100%", height: "100%", objectFit: "cover" }
9191
- }
9192
- )
9193
- },
9194
- `${image}-${index}`
9195
- )) })
9175
+ "aria-label": `${productName} image thumbnails`,
9176
+ value: String(selectedImage),
9177
+ onValueChange: (value) => setSelectedImage(Number(value)),
9178
+ "data-cimplify-image-gallery-thumbnails": true,
9179
+ style: { display: "flex", gap: "0.5rem", marginTop: "0.75rem" },
9180
+ children: normalizedImages.map((image, index) => {
9181
+ const isSelected = selectedImage === index;
9182
+ return /* @__PURE__ */ jsx(
9183
+ Radio.Root,
9184
+ {
9185
+ value: String(index),
9186
+ render: /* @__PURE__ */ jsx("button", { type: "button" }),
9187
+ "data-cimplify-image-gallery-thumb": true,
9188
+ "data-selected": isSelected || void 0,
9189
+ style: {
9190
+ width: "4rem",
9191
+ height: "4rem",
9192
+ overflow: "hidden",
9193
+ padding: 0,
9194
+ border: "none",
9195
+ cursor: "pointer"
9196
+ },
9197
+ children: /* @__PURE__ */ jsx(
9198
+ "img",
9199
+ {
9200
+ src: image,
9201
+ alt: "",
9202
+ style: { width: "100%", height: "100%", objectFit: "cover" }
9203
+ }
9204
+ )
9205
+ },
9206
+ `${image}-${index}`
9207
+ );
9208
+ })
9209
+ }
9210
+ )
9196
9211
  ] });
9197
9212
  }
9198
9213
  function CartLineItemRow({
@@ -9803,6 +9818,26 @@ function ProductGrid({
9803
9818
  )
9804
9819
  ] });
9805
9820
  }
9821
+ var SearchIcon = () => /* @__PURE__ */ jsxs(
9822
+ "svg",
9823
+ {
9824
+ xmlns: "http://www.w3.org/2000/svg",
9825
+ width: "16",
9826
+ height: "16",
9827
+ viewBox: "0 0 24 24",
9828
+ fill: "none",
9829
+ stroke: "currentColor",
9830
+ strokeWidth: "2",
9831
+ strokeLinecap: "round",
9832
+ strokeLinejoin: "round",
9833
+ "aria-hidden": "true",
9834
+ "data-cimplify-search-icon": true,
9835
+ children: [
9836
+ /* @__PURE__ */ jsx("circle", { cx: "11", cy: "11", r: "8" }),
9837
+ /* @__PURE__ */ jsx("line", { x1: "21", y1: "21", x2: "16.65", y2: "16.65" })
9838
+ ]
9839
+ }
9840
+ );
9806
9841
  function SearchInput({
9807
9842
  placeholder = "Search products...",
9808
9843
  searchOptions,
@@ -9813,42 +9848,58 @@ function SearchInput({
9813
9848
  classNames
9814
9849
  }) {
9815
9850
  const { results, isLoading, query, setQuery, clear } = useSearch(searchOptions);
9816
- const handleChange = useCallback(
9817
- (e) => {
9818
- setQuery(e.target.value);
9851
+ const handleValueChange = useCallback(
9852
+ (value) => {
9853
+ setQuery(value);
9819
9854
  },
9820
9855
  [setQuery]
9821
9856
  );
9822
9857
  return /* @__PURE__ */ jsxs(
9823
- "div",
9858
+ Field.Root,
9824
9859
  {
9825
9860
  "data-cimplify-search": true,
9826
9861
  className: cn(className, classNames?.root),
9827
9862
  style: { position: "relative" },
9828
9863
  children: [
9829
- /* @__PURE__ */ jsx(
9830
- "input",
9831
- {
9832
- type: "search",
9833
- value: query,
9834
- onChange: handleChange,
9835
- placeholder,
9836
- "data-cimplify-search-input": true,
9837
- className: classNames?.input,
9838
- "aria-label": "Search products"
9839
- }
9840
- ),
9841
- query.length > 0 && /* @__PURE__ */ jsx(
9842
- "button",
9843
- {
9844
- type: "button",
9845
- onClick: clear,
9846
- "data-cimplify-search-clear": true,
9847
- className: classNames?.clearButton,
9848
- "aria-label": "Clear search",
9849
- children: "\xD7"
9850
- }
9851
- ),
9864
+ /* @__PURE__ */ jsx(Field.Label, { className: "sr-only", children: "Search products" }),
9865
+ /* @__PURE__ */ jsxs("div", { style: { position: "relative", display: "flex", alignItems: "center" }, children: [
9866
+ /* @__PURE__ */ jsx(
9867
+ "span",
9868
+ {
9869
+ "data-cimplify-search-icon-wrapper": true,
9870
+ style: {
9871
+ position: "absolute",
9872
+ left: "0.5rem",
9873
+ pointerEvents: "none",
9874
+ display: "flex",
9875
+ alignItems: "center"
9876
+ },
9877
+ children: /* @__PURE__ */ jsx(SearchIcon, {})
9878
+ }
9879
+ ),
9880
+ /* @__PURE__ */ jsx(
9881
+ Input,
9882
+ {
9883
+ type: "search",
9884
+ value: query,
9885
+ onValueChange: handleValueChange,
9886
+ placeholder,
9887
+ "data-cimplify-search-input": true,
9888
+ className: classNames?.input
9889
+ }
9890
+ ),
9891
+ query.length > 0 && /* @__PURE__ */ jsx(
9892
+ "button",
9893
+ {
9894
+ type: "button",
9895
+ onClick: clear,
9896
+ "data-cimplify-search-clear": true,
9897
+ className: classNames?.clearButton,
9898
+ "aria-label": "Clear search",
9899
+ children: "\xD7"
9900
+ }
9901
+ )
9902
+ ] }),
9852
9903
  showResults && query.length > 0 && /* @__PURE__ */ jsxs("div", { "data-cimplify-search-results": true, className: classNames?.results, children: [
9853
9904
  isLoading && /* @__PURE__ */ jsx("div", { "data-cimplify-search-loading": true, className: classNames?.loading, "aria-busy": "true", children: "Searching..." }),
9854
9905
  !isLoading && results.length === 0 && query.length >= 2 && /* @__PURE__ */ jsx("div", { "data-cimplify-search-empty": true, className: classNames?.empty, children: "No results found" }),
@@ -9868,6 +9919,7 @@ function SearchInput({
9868
9919
  }
9869
9920
  );
9870
9921
  }
9922
+ var ALL_VALUE = "__all__";
9871
9923
  function CategoryFilter({
9872
9924
  selectedId = null,
9873
9925
  onSelect,
@@ -9877,9 +9929,9 @@ function CategoryFilter({
9877
9929
  classNames
9878
9930
  }) {
9879
9931
  const { categories, isLoading } = useCategories();
9880
- const handleSelect = useCallback(
9881
- (id) => {
9882
- onSelect(id);
9932
+ const handleValueChange = useCallback(
9933
+ (value) => {
9934
+ onSelect(value === ALL_VALUE ? null : String(value));
9883
9935
  },
9884
9936
  [onSelect]
9885
9937
  );
@@ -9893,45 +9945,45 @@ function CategoryFilter({
9893
9945
  }
9894
9946
  );
9895
9947
  }
9896
- return /* @__PURE__ */ jsxs(
9897
- "div",
9948
+ return /* @__PURE__ */ jsx(
9949
+ Tabs.Root,
9898
9950
  {
9899
- "data-cimplify-category-filter": true,
9900
- className: cn(className, classNames?.root),
9901
- role: "tablist",
9902
- "aria-label": "Filter by category",
9903
- children: [
9904
- /* @__PURE__ */ jsx(
9905
- "button",
9906
- {
9907
- type: "button",
9908
- role: "tab",
9909
- "aria-selected": selectedId === null,
9910
- onClick: () => handleSelect(null),
9911
- "data-cimplify-category-filter-item": true,
9912
- "data-selected": selectedId === null || void 0,
9913
- className: cn(classNames?.item, classNames?.allButton),
9914
- children: allLabel
9915
- }
9916
- ),
9917
- categories.map((category) => /* @__PURE__ */ jsxs(
9918
- "button",
9919
- {
9920
- type: "button",
9921
- role: "tab",
9922
- "aria-selected": selectedId === category.id,
9923
- onClick: () => handleSelect(category.id),
9924
- "data-cimplify-category-filter-item": true,
9925
- "data-selected": selectedId === category.id || void 0,
9926
- className: classNames?.item,
9927
- children: [
9928
- category.name,
9929
- showCounts && category.product_count != null && /* @__PURE__ */ jsx("span", { "data-cimplify-category-count": true, className: classNames?.count, children: category.product_count })
9930
- ]
9931
- },
9932
- category.id
9933
- ))
9934
- ]
9951
+ value: selectedId ?? ALL_VALUE,
9952
+ onValueChange: handleValueChange,
9953
+ children: /* @__PURE__ */ jsxs(
9954
+ Tabs.List,
9955
+ {
9956
+ "data-cimplify-category-filter": true,
9957
+ "aria-label": "Filter by category",
9958
+ className: cn(className, classNames?.root),
9959
+ children: [
9960
+ /* @__PURE__ */ jsx(
9961
+ Tabs.Tab,
9962
+ {
9963
+ value: ALL_VALUE,
9964
+ "data-cimplify-category-filter-item": true,
9965
+ "data-selected": selectedId === null || void 0,
9966
+ className: cn(classNames?.item, classNames?.allButton),
9967
+ children: allLabel
9968
+ }
9969
+ ),
9970
+ categories.map((category) => /* @__PURE__ */ jsxs(
9971
+ Tabs.Tab,
9972
+ {
9973
+ value: category.id,
9974
+ "data-cimplify-category-filter-item": true,
9975
+ "data-selected": selectedId === category.id || void 0,
9976
+ className: classNames?.item,
9977
+ children: [
9978
+ category.name,
9979
+ showCounts && category.product_count != null && /* @__PURE__ */ jsx("span", { "data-cimplify-category-count": true, className: classNames?.count, children: category.product_count })
9980
+ ]
9981
+ },
9982
+ category.id
9983
+ ))
9984
+ ]
9985
+ }
9986
+ )
9935
9987
  }
9936
9988
  );
9937
9989
  }
@@ -9974,50 +10026,74 @@ function DiscountInput({
9974
10026
  [handleApply]
9975
10027
  );
9976
10028
  const isApplied = appliedValidation?.is_eligible === true;
9977
- return /* @__PURE__ */ jsxs("div", { "data-cimplify-discount": true, className: cn(className, classNames?.root), children: [
9978
- /* @__PURE__ */ jsxs("div", { "data-cimplify-discount-form": true, children: [
9979
- /* @__PURE__ */ jsx(
9980
- "input",
9981
- {
9982
- type: "text",
9983
- value: code,
9984
- onChange: (e) => setCode(e.target.value),
9985
- onKeyDown: handleKeyDown,
9986
- placeholder,
9987
- disabled: isApplied,
9988
- "data-cimplify-discount-input": true,
9989
- className: classNames?.input,
9990
- "aria-label": "Discount code"
9991
- }
9992
- ),
9993
- isApplied ? /* @__PURE__ */ jsx(
9994
- "button",
9995
- {
9996
- type: "button",
9997
- onClick: handleClear,
9998
- "data-cimplify-discount-clear": true,
9999
- className: classNames?.button,
10000
- children: "Remove"
10001
- }
10002
- ) : /* @__PURE__ */ jsx(
10003
- "button",
10004
- {
10005
- type: "button",
10006
- onClick: handleApply,
10007
- disabled: isValidating || code.trim().length === 0,
10008
- "data-cimplify-discount-apply": true,
10009
- className: classNames?.button,
10010
- children: isValidating ? "Checking..." : "Apply"
10011
- }
10012
- )
10013
- ] }),
10014
- error && /* @__PURE__ */ jsx("div", { "data-cimplify-discount-error": true, className: classNames?.error, children: error.message }),
10015
- appliedValidation && !appliedValidation.is_eligible && /* @__PURE__ */ jsx("div", { "data-cimplify-discount-error": true, className: classNames?.error, children: appliedValidation.ineligibility_reason ?? "This code is not valid." }),
10016
- isApplied && appliedValidation.discount_amount && /* @__PURE__ */ jsxs("div", { "data-cimplify-discount-success": true, className: classNames?.success, children: [
10017
- /* @__PURE__ */ jsx("span", { children: "Discount applied" }),
10018
- /* @__PURE__ */ jsx(Price, { amount: appliedValidation.discount_amount, prefix: "-" })
10019
- ] })
10020
- ] });
10029
+ const hasError = !!error || !!appliedValidation && !appliedValidation.is_eligible;
10030
+ const errorMessage = error ? error.message : appliedValidation && !appliedValidation.is_eligible ? appliedValidation.ineligibility_reason ?? "This code is not valid." : void 0;
10031
+ return /* @__PURE__ */ jsxs(
10032
+ Field.Root,
10033
+ {
10034
+ "data-cimplify-discount": true,
10035
+ invalid: hasError,
10036
+ disabled: isApplied,
10037
+ className: cn(className, classNames?.root),
10038
+ children: [
10039
+ /* @__PURE__ */ jsxs("div", { "data-cimplify-discount-form": true, children: [
10040
+ /* @__PURE__ */ jsx(
10041
+ Input,
10042
+ {
10043
+ type: "text",
10044
+ value: code,
10045
+ onValueChange: (value) => setCode(value),
10046
+ onKeyDown: handleKeyDown,
10047
+ placeholder,
10048
+ "data-cimplify-discount-input": true,
10049
+ className: classNames?.input,
10050
+ "aria-label": "Discount code"
10051
+ }
10052
+ ),
10053
+ isApplied ? /* @__PURE__ */ jsx(
10054
+ "button",
10055
+ {
10056
+ type: "button",
10057
+ onClick: handleClear,
10058
+ "data-cimplify-discount-clear": true,
10059
+ className: classNames?.button,
10060
+ children: "Remove"
10061
+ }
10062
+ ) : /* @__PURE__ */ jsx(
10063
+ "button",
10064
+ {
10065
+ type: "button",
10066
+ onClick: handleApply,
10067
+ disabled: isValidating || code.trim().length === 0,
10068
+ "data-cimplify-discount-apply": true,
10069
+ className: classNames?.button,
10070
+ children: isValidating ? "Checking..." : "Apply"
10071
+ }
10072
+ )
10073
+ ] }),
10074
+ hasError && errorMessage && /* @__PURE__ */ jsx(
10075
+ Field.Error,
10076
+ {
10077
+ match: true,
10078
+ "data-cimplify-discount-error": true,
10079
+ className: classNames?.error,
10080
+ children: errorMessage
10081
+ }
10082
+ ),
10083
+ isApplied && appliedValidation.discount_amount && /* @__PURE__ */ jsxs(
10084
+ Field.Description,
10085
+ {
10086
+ "data-cimplify-discount-success": true,
10087
+ className: classNames?.success,
10088
+ children: [
10089
+ /* @__PURE__ */ jsx("span", { children: "Discount applied" }),
10090
+ /* @__PURE__ */ jsx(Price, { amount: appliedValidation.discount_amount, prefix: "-" })
10091
+ ]
10092
+ }
10093
+ )
10094
+ ]
10095
+ }
10096
+ );
10021
10097
  }
10022
10098
  function CategoryGrid({
10023
10099
  categories: categoriesProp,
@@ -10464,6 +10540,9 @@ function formatTime(timeStr) {
10464
10540
  }
10465
10541
  return timeStr;
10466
10542
  }
10543
+ function slotToValue(slot) {
10544
+ return `${slot.start_time}|${slot.end_time}`;
10545
+ }
10467
10546
  function SlotPicker({
10468
10547
  slots: slotsProp,
10469
10548
  serviceId,
@@ -10508,29 +10587,49 @@ function SlotPicker({
10508
10587
  );
10509
10588
  }
10510
10589
  const groups = groupByTimeOfDay ? groupSlots(slots) : [{ label: "", slots }];
10511
- return /* @__PURE__ */ jsx("div", { "data-cimplify-slot-picker": true, className: cn(className, classNames?.root), children: groups.map((group) => /* @__PURE__ */ jsxs("div", { "data-cimplify-slot-group": true, className: classNames?.group, children: [
10512
- group.label && /* @__PURE__ */ jsx("div", { "data-cimplify-slot-group-label": true, className: classNames?.groupLabel, children: group.label }),
10513
- group.slots.map((slot) => {
10514
- const isSelected = selectedSlot?.start_time === slot.start_time && selectedSlot?.end_time === slot.end_time;
10515
- return /* @__PURE__ */ jsxs(
10516
- "button",
10517
- {
10518
- type: "button",
10519
- disabled: !slot.is_available,
10520
- onClick: () => slot.is_available && onSlotSelect?.(slot),
10521
- "data-cimplify-slot": true,
10522
- "data-selected": isSelected || void 0,
10523
- "data-unavailable": !slot.is_available || void 0,
10524
- className: classNames?.slot,
10525
- children: [
10526
- /* @__PURE__ */ jsx("span", { "data-cimplify-slot-time": true, className: classNames?.slotTime, children: formatTime(slot.start_time) }),
10527
- showPrice && slot.price && /* @__PURE__ */ jsx("span", { "data-cimplify-slot-price": true, className: classNames?.slotPrice, children: /* @__PURE__ */ jsx(Price, { amount: slot.price }) })
10528
- ]
10529
- },
10530
- `${slot.start_time}-${slot.end_time}`
10531
- );
10532
- })
10533
- ] }, group.label || "all")) });
10590
+ const slotsByValue = /* @__PURE__ */ new Map();
10591
+ for (const slot of slots) {
10592
+ slotsByValue.set(slotToValue(slot), slot);
10593
+ }
10594
+ const selectedValue = selectedSlot ? slotToValue(selectedSlot) : "";
10595
+ return /* @__PURE__ */ jsx(
10596
+ RadioGroup,
10597
+ {
10598
+ "data-cimplify-slot-picker": true,
10599
+ className: cn(className, classNames?.root),
10600
+ value: selectedValue,
10601
+ onValueChange: (value) => {
10602
+ const slot = slotsByValue.get(value);
10603
+ if (slot?.is_available) {
10604
+ onSlotSelect?.(slot);
10605
+ }
10606
+ },
10607
+ children: groups.map((group) => /* @__PURE__ */ jsxs("div", { "data-cimplify-slot-group": true, className: classNames?.group, children: [
10608
+ group.label && /* @__PURE__ */ jsx("div", { "data-cimplify-slot-group-label": true, className: classNames?.groupLabel, children: group.label }),
10609
+ group.slots.map((slot) => {
10610
+ const value = slotToValue(slot);
10611
+ const isSelected = selectedSlot?.start_time === slot.start_time && selectedSlot?.end_time === slot.end_time;
10612
+ return /* @__PURE__ */ jsxs(
10613
+ Radio.Root,
10614
+ {
10615
+ value,
10616
+ disabled: !slot.is_available,
10617
+ render: /* @__PURE__ */ jsx("button", { type: "button" }),
10618
+ "data-cimplify-slot": true,
10619
+ "data-selected": isSelected || void 0,
10620
+ "data-unavailable": !slot.is_available || void 0,
10621
+ className: classNames?.slot,
10622
+ children: [
10623
+ /* @__PURE__ */ jsx("span", { "data-cimplify-slot-time": true, className: classNames?.slotTime, children: formatTime(slot.start_time) }),
10624
+ showPrice && slot.price && /* @__PURE__ */ jsx("span", { "data-cimplify-slot-price": true, className: classNames?.slotPrice, children: /* @__PURE__ */ jsx(Price, { amount: slot.price }) })
10625
+ ]
10626
+ },
10627
+ value
10628
+ );
10629
+ })
10630
+ ] }, group.label || "all"))
10631
+ }
10632
+ );
10534
10633
  }
10535
10634
  function formatDate(dateStr) {
10536
10635
  const date = /* @__PURE__ */ new Date(dateStr + "T00:00:00");
@@ -10593,8 +10692,10 @@ function DateSlotPicker({
10593
10692
  const handleNext = useCallback(() => {
10594
10693
  setOffset((prev) => prev + daysToShow);
10595
10694
  }, [daysToShow]);
10596
- const handleDateSelect = useCallback((date) => {
10597
- setSelectedDate(date);
10695
+ const handleDateChange = useCallback((value) => {
10696
+ if (typeof value === "string") {
10697
+ setSelectedDate(value);
10698
+ }
10598
10699
  }, []);
10599
10700
  const handleSlotSelect = useCallback(
10600
10701
  (slot) => {
@@ -10602,72 +10703,79 @@ function DateSlotPicker({
10602
10703
  },
10603
10704
  [onSlotSelect, selectedDate]
10604
10705
  );
10605
- return /* @__PURE__ */ jsxs("div", { "data-cimplify-date-slot-picker": true, className: cn(className, classNames?.root), children: [
10606
- /* @__PURE__ */ jsxs("div", { "data-cimplify-date-nav": true, className: classNames?.nav, children: [
10607
- /* @__PURE__ */ jsx(
10608
- "button",
10609
- {
10610
- type: "button",
10611
- onClick: handlePrev,
10612
- disabled: offset === 0,
10613
- "data-cimplify-date-nav-prev": true,
10614
- className: classNames?.navButton,
10615
- children: "\u2190"
10616
- }
10617
- ),
10618
- /* @__PURE__ */ jsx(
10619
- "button",
10620
- {
10621
- type: "button",
10622
- onClick: handleNext,
10623
- "data-cimplify-date-nav-next": true,
10624
- className: classNames?.navButton,
10625
- children: "\u2192"
10626
- }
10627
- )
10628
- ] }),
10629
- /* @__PURE__ */ jsx("div", { "data-cimplify-date-strip": true, className: classNames?.dateStrip, role: "tablist", children: dateRange.dates.map((date) => {
10630
- const dayInfo = availabilityMap.get(date);
10631
- const hasAvailability = dayInfo?.has_availability !== false;
10632
- const isSelected = selectedDate === date;
10633
- return /* @__PURE__ */ jsx(
10634
- "button",
10635
- {
10636
- type: "button",
10637
- role: "tab",
10638
- "aria-selected": isSelected,
10639
- onClick: () => handleDateSelect(date),
10640
- "data-cimplify-date-button": true,
10641
- "data-selected": isSelected || void 0,
10642
- "data-available": hasAvailability || void 0,
10643
- "data-fully-booked": !hasAvailability || void 0,
10644
- className: classNames?.dateButton,
10645
- children: formatDate(date)
10646
- },
10647
- date
10648
- );
10649
- }) }),
10650
- availabilityLoading && /* @__PURE__ */ jsx(
10651
- "div",
10652
- {
10653
- "data-cimplify-date-slot-loading": true,
10654
- "aria-busy": "true",
10655
- className: classNames?.loading
10656
- }
10657
- ),
10658
- /* @__PURE__ */ jsx("div", { "data-cimplify-date-slots": true, className: classNames?.slots, children: /* @__PURE__ */ jsx(
10659
- SlotPicker,
10660
- {
10661
- serviceId,
10662
- date: selectedDate,
10663
- participantCount,
10664
- selectedSlot,
10665
- onSlotSelect: handleSlotSelect,
10666
- showPrice
10667
- }
10668
- ) })
10669
- ] });
10706
+ return /* @__PURE__ */ jsxs(
10707
+ Tabs.Root,
10708
+ {
10709
+ value: selectedDate,
10710
+ onValueChange: handleDateChange,
10711
+ "data-cimplify-date-slot-picker": true,
10712
+ className: cn(className, classNames?.root),
10713
+ children: [
10714
+ /* @__PURE__ */ jsxs("div", { "data-cimplify-date-nav": true, className: classNames?.nav, children: [
10715
+ /* @__PURE__ */ jsx(
10716
+ "button",
10717
+ {
10718
+ type: "button",
10719
+ onClick: handlePrev,
10720
+ disabled: offset === 0,
10721
+ "data-cimplify-date-nav-prev": true,
10722
+ className: classNames?.navButton,
10723
+ children: "\u2190"
10724
+ }
10725
+ ),
10726
+ /* @__PURE__ */ jsx(
10727
+ "button",
10728
+ {
10729
+ type: "button",
10730
+ onClick: handleNext,
10731
+ "data-cimplify-date-nav-next": true,
10732
+ className: classNames?.navButton,
10733
+ children: "\u2192"
10734
+ }
10735
+ )
10736
+ ] }),
10737
+ /* @__PURE__ */ jsx(Tabs.List, { "data-cimplify-date-strip": true, className: classNames?.dateStrip, children: dateRange.dates.map((date) => {
10738
+ const dayInfo = availabilityMap.get(date);
10739
+ const hasAvailability = dayInfo?.has_availability !== false;
10740
+ const isSelected = selectedDate === date;
10741
+ return /* @__PURE__ */ jsx(
10742
+ Tabs.Tab,
10743
+ {
10744
+ value: date,
10745
+ "data-cimplify-date-button": true,
10746
+ "data-selected": isSelected || void 0,
10747
+ "data-available": hasAvailability || void 0,
10748
+ "data-fully-booked": !hasAvailability || void 0,
10749
+ className: classNames?.dateButton,
10750
+ children: formatDate(date)
10751
+ },
10752
+ date
10753
+ );
10754
+ }) }),
10755
+ availabilityLoading && /* @__PURE__ */ jsx(
10756
+ "div",
10757
+ {
10758
+ "data-cimplify-date-slot-loading": true,
10759
+ "aria-busy": "true",
10760
+ className: classNames?.loading
10761
+ }
10762
+ ),
10763
+ /* @__PURE__ */ jsx("div", { "data-cimplify-date-slots": true, className: classNames?.slots, children: /* @__PURE__ */ jsx(
10764
+ SlotPicker,
10765
+ {
10766
+ serviceId,
10767
+ date: selectedDate,
10768
+ participantCount,
10769
+ selectedSlot,
10770
+ onSlotSelect: handleSlotSelect,
10771
+ showPrice
10772
+ }
10773
+ ) })
10774
+ ]
10775
+ }
10776
+ );
10670
10777
  }
10778
+ var ANY_VALUE = "__any__";
10671
10779
  function StaffPicker({
10672
10780
  staff,
10673
10781
  selectedStaffId,
@@ -10677,44 +10785,56 @@ function StaffPicker({
10677
10785
  className,
10678
10786
  classNames
10679
10787
  }) {
10680
- return /* @__PURE__ */ jsxs("div", { "data-cimplify-staff-picker": true, className: cn(className, classNames?.root), children: [
10681
- showAnyOption && /* @__PURE__ */ jsx(
10682
- "button",
10683
- {
10684
- type: "button",
10685
- onClick: () => onStaffSelect?.(null),
10686
- "data-cimplify-staff-option": true,
10687
- "data-selected": selectedStaffId === null || void 0,
10688
- "data-any": true,
10689
- className: classNames?.option,
10690
- children: /* @__PURE__ */ jsx("span", { "data-cimplify-staff-name": true, className: classNames?.name, children: anyLabel })
10691
- }
10692
- ),
10693
- staff.map((member) => /* @__PURE__ */ jsxs(
10694
- "button",
10695
- {
10696
- type: "button",
10697
- onClick: () => onStaffSelect?.(member.id),
10698
- "data-cimplify-staff-option": true,
10699
- "data-selected": selectedStaffId === member.id || void 0,
10700
- className: classNames?.option,
10701
- children: [
10702
- member.avatar_url && /* @__PURE__ */ jsx(
10703
- "img",
10704
- {
10705
- src: member.avatar_url,
10706
- alt: member.name,
10707
- "data-cimplify-staff-avatar": true,
10708
- className: classNames?.avatar
10709
- }
10710
- ),
10711
- /* @__PURE__ */ jsx("span", { "data-cimplify-staff-name": true, className: classNames?.name, children: member.name }),
10712
- member.bio && /* @__PURE__ */ jsx("span", { "data-cimplify-staff-bio": true, className: classNames?.bio, children: member.bio })
10713
- ]
10788
+ const groupValue = selectedStaffId === null ? ANY_VALUE : selectedStaffId ?? "";
10789
+ return /* @__PURE__ */ jsxs(
10790
+ RadioGroup,
10791
+ {
10792
+ "data-cimplify-staff-picker": true,
10793
+ className: cn(className, classNames?.root),
10794
+ value: groupValue,
10795
+ onValueChange: (value) => {
10796
+ onStaffSelect?.(value === ANY_VALUE ? null : value);
10714
10797
  },
10715
- member.id
10716
- ))
10717
- ] });
10798
+ children: [
10799
+ showAnyOption && /* @__PURE__ */ jsx(
10800
+ Radio.Root,
10801
+ {
10802
+ value: ANY_VALUE,
10803
+ render: /* @__PURE__ */ jsx("button", { type: "button" }),
10804
+ "data-cimplify-staff-option": true,
10805
+ "data-selected": selectedStaffId === null || void 0,
10806
+ "data-any": true,
10807
+ className: classNames?.option,
10808
+ children: /* @__PURE__ */ jsx("span", { "data-cimplify-staff-name": true, className: classNames?.name, children: anyLabel })
10809
+ }
10810
+ ),
10811
+ staff.map((member) => /* @__PURE__ */ jsxs(
10812
+ Radio.Root,
10813
+ {
10814
+ value: member.id,
10815
+ render: /* @__PURE__ */ jsx("button", { type: "button" }),
10816
+ "data-cimplify-staff-option": true,
10817
+ "data-selected": selectedStaffId === member.id || void 0,
10818
+ className: classNames?.option,
10819
+ children: [
10820
+ member.avatar_url && /* @__PURE__ */ jsx(
10821
+ "img",
10822
+ {
10823
+ src: member.avatar_url,
10824
+ alt: member.name,
10825
+ "data-cimplify-staff-avatar": true,
10826
+ className: classNames?.avatar
10827
+ }
10828
+ ),
10829
+ /* @__PURE__ */ jsx("span", { "data-cimplify-staff-name": true, className: classNames?.name, children: member.name }),
10830
+ member.bio && /* @__PURE__ */ jsx("span", { "data-cimplify-staff-bio": true, className: classNames?.bio, children: member.bio })
10831
+ ]
10832
+ },
10833
+ member.id
10834
+ ))
10835
+ ]
10836
+ }
10837
+ );
10718
10838
  }
10719
10839
  var STATUS_LABELS3 = {
10720
10840
  pending: "Pending",
@@ -11386,10 +11506,10 @@ function OrderDetailPage({
11386
11506
  ] });
11387
11507
  }
11388
11508
  var STATUS_FILTERS = [
11389
- { label: "All", value: void 0 },
11390
- { label: "Active", value: "confirmed" },
11391
- { label: "Completed", value: "completed" },
11392
- { label: "Cancelled", value: "cancelled" }
11509
+ { label: "All", value: void 0, tabValue: "all" },
11510
+ { label: "Active", value: "confirmed", tabValue: "confirmed" },
11511
+ { label: "Completed", value: "completed", tabValue: "completed" },
11512
+ { label: "Cancelled", value: "cancelled", tabValue: "cancelled" }
11393
11513
  ];
11394
11514
  function OrderHistoryPage({
11395
11515
  title = "Order History",
@@ -11403,6 +11523,10 @@ function OrderHistoryPage({
11403
11523
  }) {
11404
11524
  const [statusFilter, setStatusFilter] = useState(void 0);
11405
11525
  const [selectedOrder, setSelectedOrder] = useState(null);
11526
+ const handleTabChange = useCallback((value) => {
11527
+ const filter = STATUS_FILTERS.find((f) => f.tabValue === value);
11528
+ setStatusFilter(filter?.value);
11529
+ }, []);
11406
11530
  const handleOrderClick = useCallback(
11407
11531
  (order) => {
11408
11532
  if (onOrderNavigate) {
@@ -11416,6 +11540,7 @@ function OrderHistoryPage({
11416
11540
  const handleBack = useCallback(() => {
11417
11541
  setSelectedOrder(null);
11418
11542
  }, []);
11543
+ const activeTabValue = STATUS_FILTERS.find((f) => f.value === statusFilter)?.tabValue ?? "all";
11419
11544
  if (selectedOrder && !onOrderNavigate) {
11420
11545
  return /* @__PURE__ */ jsx("div", { "data-cimplify-order-history-page": true, className: cn(className, classNames?.root), children: /* @__PURE__ */ jsxs("div", { "data-cimplify-order-history-detail": true, className: classNames?.detail, children: [
11421
11546
  /* @__PURE__ */ jsx(
@@ -11433,20 +11558,17 @@ function OrderHistoryPage({
11433
11558
  }
11434
11559
  return /* @__PURE__ */ jsxs("div", { "data-cimplify-order-history-page": true, className: cn(className, classNames?.root), children: [
11435
11560
  /* @__PURE__ */ jsx("div", { "data-cimplify-order-history-header": true, className: classNames?.header, children: /* @__PURE__ */ jsx("h1", { "data-cimplify-order-history-title": true, className: classNames?.title, children: title }) }),
11436
- showFilters && /* @__PURE__ */ jsx("div", { "data-cimplify-order-history-filters": true, className: classNames?.filters, role: "tablist", children: STATUS_FILTERS.map((filter) => /* @__PURE__ */ jsx(
11437
- "button",
11561
+ showFilters && /* @__PURE__ */ jsx(Tabs.Root, { value: activeTabValue, onValueChange: handleTabChange, children: /* @__PURE__ */ jsx(Tabs.List, { "data-cimplify-order-history-filters": true, className: classNames?.filters, children: STATUS_FILTERS.map((filter) => /* @__PURE__ */ jsx(
11562
+ Tabs.Tab,
11438
11563
  {
11439
- type: "button",
11440
- role: "tab",
11441
- "aria-selected": statusFilter === filter.value,
11442
- onClick: () => setStatusFilter(filter.value),
11564
+ value: filter.tabValue,
11443
11565
  "data-cimplify-order-filter": true,
11444
11566
  "data-selected": statusFilter === filter.value || void 0,
11445
11567
  className: classNames?.filterButton,
11446
11568
  children: filter.label
11447
11569
  },
11448
- filter.label
11449
- )) }),
11570
+ filter.tabValue
11571
+ )) }) }),
11450
11572
  /* @__PURE__ */ jsx("div", { "data-cimplify-order-history-list": true, className: classNames?.list, children: /* @__PURE__ */ jsx(
11451
11573
  OrderHistory,
11452
11574
  {
@@ -11474,7 +11596,7 @@ function SearchPage({
11474
11596
  /* @__PURE__ */ jsx("div", { "data-cimplify-search-page-header": true, className: classNames?.header, children: /* @__PURE__ */ jsx("h1", { "data-cimplify-search-page-title": true, className: classNames?.title, children: title }) }),
11475
11597
  /* @__PURE__ */ jsxs("div", { "data-cimplify-search-page-input": true, className: classNames?.inputContainer, children: [
11476
11598
  /* @__PURE__ */ jsx(
11477
- "input",
11599
+ Input,
11478
11600
  {
11479
11601
  type: "search",
11480
11602
  value: query,
@@ -11816,20 +11938,24 @@ function BookingsPage({
11816
11938
  }
11817
11939
  return /* @__PURE__ */ jsxs("div", { "data-cimplify-bookings-page": true, className: cn(className, classNames?.root), children: [
11818
11940
  /* @__PURE__ */ jsx("div", { "data-cimplify-bookings-header": true, className: classNames?.header, children: /* @__PURE__ */ jsx("h1", { "data-cimplify-bookings-title": true, className: classNames?.title, children: title }) }),
11819
- showFilters && /* @__PURE__ */ jsx("div", { "data-cimplify-bookings-filters": true, className: classNames?.filters, role: "tablist", children: BOOKING_FILTERS.map((f) => /* @__PURE__ */ jsx(
11820
- "button",
11941
+ showFilters && /* @__PURE__ */ jsx(
11942
+ Tabs.Root,
11821
11943
  {
11822
- type: "button",
11823
- role: "tab",
11824
- "aria-selected": filter === f.value,
11825
- onClick: () => setFilter(f.value),
11826
- "data-cimplify-booking-filter": true,
11827
- "data-selected": filter === f.value || void 0,
11828
- className: classNames?.filterButton,
11829
- children: f.label
11830
- },
11831
- f.value
11832
- )) }),
11944
+ value: filter,
11945
+ onValueChange: (value) => setFilter(value),
11946
+ children: /* @__PURE__ */ jsx(Tabs.List, { "data-cimplify-bookings-filters": true, className: classNames?.filters, children: BOOKING_FILTERS.map((f) => /* @__PURE__ */ jsx(
11947
+ Tabs.Tab,
11948
+ {
11949
+ value: f.value,
11950
+ "data-cimplify-booking-filter": true,
11951
+ "data-selected": filter === f.value || void 0,
11952
+ className: classNames?.filterButton,
11953
+ children: f.label
11954
+ },
11955
+ f.value
11956
+ )) })
11957
+ }
11958
+ ),
11833
11959
  /* @__PURE__ */ jsx("div", { "data-cimplify-bookings-list": true, className: classNames?.list, children: /* @__PURE__ */ jsx(
11834
11960
  BookingList,
11835
11961
  {