@cimplify/sdk 0.48.1 → 0.49.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.js CHANGED
@@ -6237,6 +6237,8 @@ function SlotPicker({
6237
6237
  schedulingMode = "intraday",
6238
6238
  durationUnit,
6239
6239
  durationValue,
6240
+ hideElapsedSlots = true,
6241
+ minLeadMinutes = 0,
6240
6242
  emptyMessage = "No available slots",
6241
6243
  className,
6242
6244
  classNames
@@ -6250,7 +6252,15 @@ function SlotPicker({
6250
6252
  enabled: slotsProp === void 0 && !!serviceId && !!date
6251
6253
  }
6252
6254
  );
6253
- const slots = slotsProp ?? fetched;
6255
+ const rawSlots = slotsProp ?? fetched;
6256
+ const slots = React10.useMemo(() => {
6257
+ if (!hideElapsedSlots) return rawSlots;
6258
+ const cutoff = Date.now() + minLeadMinutes * 6e4;
6259
+ return rawSlots.filter((slot) => {
6260
+ const start = Date.parse(slot.start_time);
6261
+ return Number.isNaN(start) || start >= cutoff;
6262
+ });
6263
+ }, [rawSlots, hideElapsedSlots, minLeadMinutes]);
6254
6264
  if (isLoading && slots.length === 0) {
6255
6265
  return /* @__PURE__ */ jsxRuntime.jsx(
6256
6266
  "div",
@@ -6376,6 +6386,8 @@ function DateSlotPicker({
6376
6386
  schedulingMode,
6377
6387
  durationUnit,
6378
6388
  durationValue,
6389
+ hideElapsedSlots = true,
6390
+ minLeadMinutes = 0,
6379
6391
  className,
6380
6392
  classNames
6381
6393
  }) {
@@ -6521,7 +6533,9 @@ function DateSlotPicker({
6521
6533
  showPrice,
6522
6534
  schedulingMode,
6523
6535
  durationUnit,
6524
- durationValue
6536
+ durationValue,
6537
+ hideElapsedSlots,
6538
+ minLeadMinutes
6525
6539
  }
6526
6540
  ) })
6527
6541
  ]
@@ -6966,6 +6980,289 @@ function ProductImageGallery({
6966
6980
  )
6967
6981
  ] });
6968
6982
  }
6983
+ var ASPECT_STYLES2 = {
6984
+ square: { aspectRatio: "1/1" },
6985
+ "4/3": { aspectRatio: "4/3" },
6986
+ "16/9": { aspectRatio: "16/9" },
6987
+ "16/10": { aspectRatio: "16/10" },
6988
+ "3/4": { aspectRatio: "3/4" }
6989
+ };
6990
+ function StoreVideo({
6991
+ src,
6992
+ poster,
6993
+ alt,
6994
+ aspectRatio = "16/9",
6995
+ controls = false,
6996
+ autoplay = true,
6997
+ loop = true,
6998
+ muted = true,
6999
+ lazy = true,
7000
+ className
7001
+ }) {
7002
+ const ref = React10.useRef(null);
7003
+ const [inView, setInView] = React10.useState(!lazy);
7004
+ React10.useEffect(() => {
7005
+ if (!lazy || inView) return;
7006
+ const node = ref.current;
7007
+ if (!node || typeof IntersectionObserver === "undefined") {
7008
+ setInView(true);
7009
+ return;
7010
+ }
7011
+ const observer = new IntersectionObserver(
7012
+ (entries) => {
7013
+ if (entries.some((e) => e.isIntersecting)) {
7014
+ setInView(true);
7015
+ observer.disconnect();
7016
+ }
7017
+ },
7018
+ { rootMargin: "200px" }
7019
+ );
7020
+ observer.observe(node);
7021
+ return () => observer.disconnect();
7022
+ }, [lazy, inView]);
7023
+ return /* @__PURE__ */ jsxRuntime.jsx(
7024
+ "div",
7025
+ {
7026
+ "data-cimplify-store-video": true,
7027
+ className,
7028
+ style: { position: "relative", overflow: "hidden", ...ASPECT_STYLES2[aspectRatio] },
7029
+ children: /* @__PURE__ */ jsxRuntime.jsx(
7030
+ "video",
7031
+ {
7032
+ ref,
7033
+ src: inView ? src : void 0,
7034
+ poster,
7035
+ autoPlay: autoplay,
7036
+ loop,
7037
+ muted,
7038
+ playsInline: true,
7039
+ controls,
7040
+ preload: lazy ? "metadata" : "auto",
7041
+ "aria-label": alt,
7042
+ style: { width: "100%", height: "100%", objectFit: "cover", display: "block" },
7043
+ children: poster ? /* @__PURE__ */ jsxRuntime.jsx(
7044
+ "img",
7045
+ {
7046
+ src: poster,
7047
+ alt: alt ?? "",
7048
+ style: { width: "100%", height: "100%", objectFit: "cover" }
7049
+ }
7050
+ ) : null
7051
+ }
7052
+ )
7053
+ }
7054
+ );
7055
+ }
7056
+ var ASPECT_STYLES3 = {
7057
+ square: { aspectRatio: "1/1" },
7058
+ "4/3": { aspectRatio: "4/3" },
7059
+ "16/9": { aspectRatio: "16/9" },
7060
+ "3/4": { aspectRatio: "3/4" }
7061
+ };
7062
+ var MODEL_VIEWER_CDN = "https://unpkg.com/@google/model-viewer@4.0.0/dist/model-viewer.min.js";
7063
+ var modelViewerLoadPromise = null;
7064
+ function ensureModelViewer() {
7065
+ if (typeof window === "undefined") return Promise.resolve();
7066
+ if (modelViewerLoadPromise) return modelViewerLoadPromise;
7067
+ if (window.customElements?.get("model-viewer")) {
7068
+ modelViewerLoadPromise = Promise.resolve();
7069
+ return modelViewerLoadPromise;
7070
+ }
7071
+ modelViewerLoadPromise = new Promise((resolve, reject) => {
7072
+ const script = document.createElement("script");
7073
+ script.type = "module";
7074
+ script.src = MODEL_VIEWER_CDN;
7075
+ script.onload = () => resolve();
7076
+ script.onerror = () => reject(new Error("Failed to load model-viewer"));
7077
+ document.head.appendChild(script);
7078
+ });
7079
+ return modelViewerLoadPromise;
7080
+ }
7081
+ function ProductModel3D({
7082
+ src,
7083
+ iosSrc,
7084
+ poster,
7085
+ alt,
7086
+ aspectRatio = "square",
7087
+ ar = true,
7088
+ autoRotate = true,
7089
+ cameraControls = true,
7090
+ className
7091
+ }) {
7092
+ const [ready, setReady] = React10.useState(false);
7093
+ React10.useEffect(() => {
7094
+ let cancelled = false;
7095
+ ensureModelViewer().then(
7096
+ () => {
7097
+ if (!cancelled) setReady(true);
7098
+ },
7099
+ () => {
7100
+ }
7101
+ );
7102
+ return () => {
7103
+ cancelled = true;
7104
+ };
7105
+ }, []);
7106
+ return /* @__PURE__ */ jsxRuntime.jsx(
7107
+ "div",
7108
+ {
7109
+ "data-cimplify-product-model-3d": true,
7110
+ className,
7111
+ style: { position: "relative", overflow: "hidden", ...ASPECT_STYLES3[aspectRatio] },
7112
+ children: ready ? React10__default.default.createElement("model-viewer", {
7113
+ src,
7114
+ "ios-src": iosSrc,
7115
+ alt,
7116
+ poster,
7117
+ ar: ar || void 0,
7118
+ "ar-modes": ar ? "webxr scene-viewer quick-look" : void 0,
7119
+ "camera-controls": cameraControls || void 0,
7120
+ "auto-rotate": autoRotate || void 0,
7121
+ "shadow-intensity": "1",
7122
+ style: { width: "100%", height: "100%", backgroundColor: "transparent" }
7123
+ }) : poster ? React10__default.default.createElement("img", {
7124
+ src: poster,
7125
+ alt: alt ?? "",
7126
+ "data-cimplify-product-model-3d-loading": true,
7127
+ style: { width: "100%", height: "100%", objectFit: "cover" }
7128
+ }) : React10__default.default.createElement("div", {
7129
+ "data-cimplify-product-model-3d-loading": true,
7130
+ style: { width: "100%", height: "100%", backgroundColor: "var(--muted, #f3f4f6)" }
7131
+ })
7132
+ }
7133
+ );
7134
+ }
7135
+ var ASPECT_STYLES4 = {
7136
+ square: { aspectRatio: "1/1" },
7137
+ "4/3": { aspectRatio: "4/3" },
7138
+ "16/10": { aspectRatio: "16/10" },
7139
+ "3/4": { aspectRatio: "3/4" }
7140
+ };
7141
+ function thumbnailFor(item) {
7142
+ if (item.type === "image") return item.src;
7143
+ return item.poster ?? null;
7144
+ }
7145
+ function thumbIcon(item) {
7146
+ if (item.type === "video") return "\u25B6";
7147
+ if (item.type === "model") return "\u25C6";
7148
+ return null;
7149
+ }
7150
+ function MediaGallery({
7151
+ items,
7152
+ productName,
7153
+ aspectRatio = "4/3",
7154
+ className
7155
+ }) {
7156
+ const validItems = React10.useMemo(
7157
+ () => items.filter((i) => typeof i.src === "string" && i.src.trim().length > 0),
7158
+ [items]
7159
+ );
7160
+ const [selected, setSelected] = React10.useState(0);
7161
+ React10.useEffect(() => {
7162
+ setSelected(0);
7163
+ }, [validItems.length, productName]);
7164
+ if (validItems.length === 0) return null;
7165
+ const active = validItems[selected] ?? validItems[0];
7166
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-media-gallery": true, className, children: [
7167
+ /* @__PURE__ */ jsxRuntime.jsx(
7168
+ "div",
7169
+ {
7170
+ "data-cimplify-media-gallery-main": true,
7171
+ style: { position: "relative", overflow: "hidden", ...ASPECT_STYLES4[aspectRatio] },
7172
+ children: active.type === "image" ? /* @__PURE__ */ jsxRuntime.jsx(
7173
+ "img",
7174
+ {
7175
+ src: active.src,
7176
+ alt: active.alt ?? productName,
7177
+ style: { width: "100%", height: "100%", objectFit: "cover" },
7178
+ "data-cimplify-media-gallery-active": true
7179
+ }
7180
+ ) : active.type === "video" ? /* @__PURE__ */ jsxRuntime.jsx(
7181
+ StoreVideo,
7182
+ {
7183
+ src: active.src,
7184
+ poster: active.poster,
7185
+ alt: active.alt ?? productName,
7186
+ aspectRatio: "square",
7187
+ lazy: false
7188
+ }
7189
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
7190
+ ProductModel3D,
7191
+ {
7192
+ src: active.src,
7193
+ iosSrc: active.iosSrc,
7194
+ poster: active.poster,
7195
+ alt: active.alt ?? productName,
7196
+ aspectRatio: "square"
7197
+ }
7198
+ )
7199
+ }
7200
+ ),
7201
+ validItems.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(
7202
+ radioGroup.RadioGroup,
7203
+ {
7204
+ "aria-label": `${productName} media thumbnails`,
7205
+ value: String(selected),
7206
+ onValueChange: (v) => setSelected(Number(v)),
7207
+ "data-cimplify-media-gallery-thumbnails": true,
7208
+ style: { display: "flex", gap: "0.5rem", marginTop: "0.75rem" },
7209
+ children: validItems.map((item, index) => {
7210
+ const thumb = thumbnailFor(item);
7211
+ const icon = thumbIcon(item);
7212
+ const isSelected = selected === index;
7213
+ return /* @__PURE__ */ jsxRuntime.jsxs(
7214
+ radio.Radio.Root,
7215
+ {
7216
+ value: String(index),
7217
+ "data-cimplify-media-gallery-thumb": true,
7218
+ "data-selected": isSelected || void 0,
7219
+ "data-type": item.type,
7220
+ style: {
7221
+ position: "relative",
7222
+ width: "4rem",
7223
+ height: "4rem",
7224
+ overflow: "hidden",
7225
+ padding: 0,
7226
+ border: "none",
7227
+ cursor: "pointer",
7228
+ backgroundColor: "var(--muted, #f3f4f6)"
7229
+ },
7230
+ children: [
7231
+ thumb ? /* @__PURE__ */ jsxRuntime.jsx(
7232
+ "img",
7233
+ {
7234
+ src: thumb,
7235
+ alt: "",
7236
+ style: { width: "100%", height: "100%", objectFit: "cover" }
7237
+ }
7238
+ ) : null,
7239
+ icon ? /* @__PURE__ */ jsxRuntime.jsx(
7240
+ "span",
7241
+ {
7242
+ "aria-hidden": true,
7243
+ style: {
7244
+ position: "absolute",
7245
+ inset: 0,
7246
+ display: "flex",
7247
+ alignItems: "center",
7248
+ justifyContent: "center",
7249
+ color: "white",
7250
+ fontSize: "0.875rem",
7251
+ textShadow: "0 1px 2px rgba(0,0,0,0.6)",
7252
+ pointerEvents: "none"
7253
+ },
7254
+ children: icon
7255
+ }
7256
+ ) : null
7257
+ ]
7258
+ },
7259
+ `${item.src}-${index}`
7260
+ );
7261
+ })
7262
+ }
7263
+ )
7264
+ ] });
7265
+ }
6969
7266
  function CartLineItemRow({
6970
7267
  item,
6971
7268
  onRemove,
@@ -8372,7 +8669,7 @@ var CardVariant = /* @__PURE__ */ ((CardVariant2) => {
8372
8669
  CardVariant2["Subscription"] = "subscription";
8373
8670
  return CardVariant2;
8374
8671
  })(CardVariant || {});
8375
- var ASPECT_STYLES2 = {
8672
+ var ASPECT_STYLES5 = {
8376
8673
  square: { aspectRatio: "1/1" },
8377
8674
  "4/3": { aspectRatio: "4/3" },
8378
8675
  "16/10": { aspectRatio: "16/10" },
@@ -8481,7 +8778,7 @@ function ProductCard({
8481
8778
  {
8482
8779
  "data-cimplify-product-card-image-container": true,
8483
8780
  className: cn("overflow-hidden rounded-t-xl", classNames?.imageContainer),
8484
- style: ASPECT_STYLES2[aspectRatio],
8781
+ style: ASPECT_STYLES5[aspectRatio],
8485
8782
  children: renderImage ? renderImage({ src: imageUrl, alt: product.name, className: classNames?.image }) : /* @__PURE__ */ jsxRuntime.jsx(
8486
8783
  "img",
8487
8784
  {
@@ -13675,6 +13972,7 @@ exports.FoodProductLayout = FoodProductLayout;
13675
13972
  exports.InventoryBadge = InventoryBadge;
13676
13973
  exports.LeaseServiceCard = LeaseServiceCard;
13677
13974
  exports.LocationPicker = LocationPicker;
13975
+ exports.MediaGallery = MediaGallery;
13678
13976
  exports.MetadataStringList = MetadataStringList;
13679
13977
  exports.OrderDetailPage = OrderDetailPage;
13680
13978
  exports.OrderHistory = OrderHistory;
@@ -13687,6 +13985,7 @@ exports.ProductCard = ProductCard;
13687
13985
  exports.ProductCustomizer = ProductCustomizer;
13688
13986
  exports.ProductGrid = ProductGrid;
13689
13987
  exports.ProductImageGallery = ProductImageGallery;
13988
+ exports.ProductModel3D = ProductModel3D;
13690
13989
  exports.ProductPage = ProductPage;
13691
13990
  exports.ProductSheet = ProductSheet;
13692
13991
  exports.ProductTemplate = ProductTemplate;
@@ -13711,6 +14010,7 @@ exports.SoldOutOverlay = SoldOutOverlay;
13711
14010
  exports.StaffPicker = StaffPicker;
13712
14011
  exports.StandardServiceCard = StandardServiceCard;
13713
14012
  exports.StoreNav = StoreNav;
14013
+ exports.StoreVideo = StoreVideo;
13714
14014
  exports.SubscriptionCard = SubscriptionCard;
13715
14015
  exports.TagPills = TagPills;
13716
14016
  exports.TimePicker = TimePicker;