@sledge-app/react-instant-search 1.0.6 → 1.0.7

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.
@@ -346,9 +346,9 @@ const Progress = ({ value, total, fillColor = "", outlineColor = "" }) => {
346
346
  );
347
347
  };
348
348
  const Checkbox$1 = "";
349
- const Checkbox = ({ id, name, value, required, label, defaultChecked, labelStyle = {}, onClick }) => {
349
+ const Checkbox = ({ id, name, value, required, label, checked, labelStyle = {}, onClick }) => {
350
350
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__checkbox-wrapper", children: [
351
- /* @__PURE__ */ jsxRuntimeExports.jsx($e698a72e93240346$export$be92b6f5f03c0fe9, { className: "sledge__checkbox-root", defaultChecked, id, name, value, required, onClick, children: /* @__PURE__ */ jsxRuntimeExports.jsx($e698a72e93240346$export$adb584737d712b70, { className: "sledge__checkbox-indicator", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: 10, height: 8, viewBox: "0 0 10 8", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
351
+ /* @__PURE__ */ jsxRuntimeExports.jsx($e698a72e93240346$export$be92b6f5f03c0fe9, { className: "sledge__checkbox-root", checked, id, name, value, required, onClick, children: /* @__PURE__ */ jsxRuntimeExports.jsx($e698a72e93240346$export$adb584737d712b70, { className: "sledge__checkbox-indicator", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: 10, height: 8, viewBox: "0 0 10 8", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
352
352
  "path",
353
353
  {
354
354
  fillRule: "evenodd",
@@ -369,7 +369,9 @@ const Slider = (props) => {
369
369
  {
370
370
  className: "sledge__SliderRoot",
371
371
  defaultValue,
372
- min,
372
+ ...typeof min !== "undefined" ? {
373
+ min
374
+ } : {},
373
375
  max,
374
376
  step,
375
377
  "aria-label": "Volume",
@@ -754,7 +756,7 @@ const addToCart = async (data) => {
754
756
  data.map((item) => {
755
757
  const { id, quantity } = item;
756
758
  items.push({
757
- id,
759
+ id: sanitizeDataId(id),
758
760
  quantity
759
761
  });
760
762
  });
@@ -2343,237 +2345,267 @@ const ProductGrid = ({
2343
2345
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `sledge__product-grid ${className}`, "data-grid-type": type, children: data == null ? void 0 : data.map((item, index) => {
2344
2346
  var _a, _b, _c;
2345
2347
  const { product, variants } = item || {};
2346
- const { id, title, image, url, vendor = "", currency } = product || {};
2348
+ const { id, title, image, url, vendor = "", currency, handle } = product || {};
2347
2349
  const { id: variant_id = "", title: variant_title = "", price = "", sku = "" } = (variants == null ? void 0 : variants.length) ? variants[0] : {};
2348
2350
  let isLoadingAddToCart = clickedAddToCartId == variant_id;
2349
2351
  let isOutOfStock = (variants == null ? void 0 : variants.length) && Object.hasOwn(variants[0], "inventory_quantity") ? !variants[0].inventory_quantity && showOptionOutOfStock : false;
2350
- const options = (product == null ? void 0 : product.options) ? Object.entries(product.options) : [];
2351
- const images = (product == null ? void 0 : product.images) ?? [];
2352
- const defaultSelected = {};
2353
- function setDefaultFunction() {
2354
- if (!(variants == null ? void 0 : variants.length))
2355
- return;
2356
- defaultSelected["data-product-handle"] = product.handle;
2357
- defaultSelected["data-selected-option1"] = variants[0].option1;
2358
- if (variants[0].option2) {
2359
- defaultSelected["data-selected-option2"] = variants[0].option2;
2360
- }
2361
- defaultSelected["data-variant-id"] = variants[0].admin_graphql_api_id;
2362
- }
2363
- setDefaultFunction();
2364
- const defaultSelectedVariantId = (variants == null ? void 0 : variants.length) ? variants[0].admin_graphql_api_id : "";
2365
- const [selectedVariantId, setSelectedVariantId] = React__default.useState(defaultSelectedVariantId);
2366
- function setSelectedVariant(element, value, optionIndex) {
2367
- var _a2;
2368
- const selectedInput = element.target.parentNode.parentNode.firstChild;
2369
- const parentCard = element.target.offsetParent;
2370
- const setOptionAttribute = () => {
2371
- selectedInput.attributes[`data-selected-option${optionIndex}`].value = value;
2372
- };
2373
- setOptionAttribute();
2374
- const option1 = `[data-option-1="${selectedInput.attributes["data-selected-option1"].value}"]`;
2375
- const option2 = `${selectedInput.attributes["data-selected-option2"] ? `[data-option-2="${selectedInput.attributes["data-selected-option2"].value}"]` : ""}`;
2376
- const selectOption = parentCard.querySelector(`select option${option1}${option2}`);
2377
- const variantId = selectOption.attributes["data-graphql-id"].value;
2378
- const imageId = (_a2 = selectOption.attributes["data-image-id"]) == null ? void 0 : _a2.value;
2379
- const setOther = () => {
2380
- selectedInput.attributes[`data-variant-id`].value = selectOption.attributes["data-graphql-id"].value;
2381
- if (variantId)
2382
- setSelectedVariantId(variantId);
2383
- if (imageId)
2384
- parentCard.querySelector(`img.sledge__product-grid-card-image-featured-image`).src = parentCard.querySelector(
2385
- `div.sledge__product-grid-card-variant-images img[id="${imageId}"]`
2386
- ).src;
2387
- };
2388
- setOther();
2389
- const result = {
2390
- variantId,
2391
- imageId
2392
- };
2393
- return result;
2394
- }
2395
- const getCards = cards ? cards({
2396
- product: {
2397
- ...product,
2398
- ...{
2399
- variants: variants.map((variant, index2) => {
2400
- const { inventory_quantity } = variant || {};
2401
- return {
2402
- ...variant,
2403
- is_out_of_stock: Object.hasOwn(variants[index2], "inventory_quantity") ? !inventory_quantity : false
2404
- };
2405
- })
2352
+ if (cards) {
2353
+ const getCards = cards({
2354
+ product: {
2355
+ ...product,
2356
+ ...{
2357
+ variants: variants.map((variant, index2) => {
2358
+ const { inventory_quantity } = variant || {};
2359
+ return {
2360
+ ...variant,
2361
+ is_out_of_stock: Object.hasOwn(variants[index2], "inventory_quantity") ? !inventory_quantity : false
2362
+ };
2363
+ })
2364
+ },
2365
+ ...dataReviews && Object.keys(dataReviews).length ? {
2366
+ review: {
2367
+ total: ((_a = dataReviews == null ? void 0 : dataReviews[id]) == null ? void 0 : _a.review_count) ? dataReviews == null ? void 0 : dataReviews[id].review_count : 0,
2368
+ average: ((_c = (_b = dataReviews == null ? void 0 : dataReviews[id]) == null ? void 0 : _b.rating) == null ? void 0 : _c.average) ? dataReviews == null ? void 0 : dataReviews[id].rating.average : 0
2369
+ }
2370
+ } : {}
2406
2371
  },
2407
- ...dataReviews && Object.keys(dataReviews).length ? {
2408
- review: {
2409
- total: ((_a = dataReviews == null ? void 0 : dataReviews[id]) == null ? void 0 : _a.review_count) ? dataReviews == null ? void 0 : dataReviews[id].review_count : 0,
2410
- average: ((_c = (_b = dataReviews == null ? void 0 : dataReviews[id]) == null ? void 0 : _b.rating) == null ? void 0 : _c.average) ? dataReviews == null ? void 0 : dataReviews[id].rating.average : 0
2411
- }
2412
- } : {}
2413
- },
2414
- showPopupComponent,
2415
- setShowPopupComponent,
2416
- sourceApp
2417
- }) : null;
2418
- return cards ? /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: isComponentJsVersion ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: getCards } }) : getCards }, index) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card", children: [
2419
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-content", children: [
2420
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-image", children: [
2421
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
2422
- "a",
2423
- {
2424
- href: url,
2425
- onClick: () => sourceApp === "instant-search" && productClickTrigger({
2426
- productId: id
2427
- }),
2428
- children: [
2429
- /* @__PURE__ */ jsxRuntimeExports.jsx(
2430
- Trigger,
2431
- {
2432
- params: {
2433
- productId: id,
2434
- productVariantId: variant_id,
2435
- productName: title,
2436
- productVendor: vendor,
2437
- productSku: sku,
2438
- productVariantName: variant_title,
2439
- productLink: url,
2440
- productImage: (image == null ? void 0 : image.src) || `${API_URL}/img/blank-image.png`,
2441
- productCurrency: currency,
2442
- productPrice: price
2372
+ showPopupComponent,
2373
+ setShowPopupComponent,
2374
+ sourceApp
2375
+ });
2376
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: isComponentJsVersion ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: getCards } }) : getCards }, index);
2377
+ } else {
2378
+ let setDefaultFunction = function() {
2379
+ if (!(variants == null ? void 0 : variants.length))
2380
+ return;
2381
+ defaultSelected["data-product-id"] = id;
2382
+ defaultSelected["data-product-handle"] = handle;
2383
+ defaultSelected["data-selected-option1"] = variants[0].option1;
2384
+ if (variants[0].option2) {
2385
+ defaultSelected["data-selected-option2"] = variants[0].option2;
2386
+ }
2387
+ defaultSelected["data-variant-id"] = variants[0].admin_graphql_api_id;
2388
+ }, setSelectedOption = function(element, optionName) {
2389
+ const optionsButton = element.target.offsetParent.querySelector(`.options-button-${optionName}`).querySelectorAll(`button`);
2390
+ const defaultSelectedClassChanger = () => {
2391
+ optionsButton.forEach((button, index2) => {
2392
+ button.classList.remove("sledge__product-variant-size-swatch-active");
2393
+ element.target.className += " sledge__product-variant-size-swatch-active";
2394
+ });
2395
+ };
2396
+ const colorSelectedClassChanger = () => {
2397
+ optionsButton.forEach((button, index2) => {
2398
+ button.classList.remove("sledge__product-variant-color-swatch-active");
2399
+ element.target.className += " sledge__product-variant-color-swatch-active";
2400
+ });
2401
+ };
2402
+ switch (optionName) {
2403
+ case "Color":
2404
+ colorSelectedClassChanger();
2405
+ break;
2406
+ case "Size":
2407
+ defaultSelectedClassChanger();
2408
+ break;
2409
+ default:
2410
+ defaultSelectedClassChanger();
2411
+ }
2412
+ }, setSelectedVariant = function(element, value, optionIndex) {
2413
+ var _a2;
2414
+ const parentCard = element.target.offsetParent;
2415
+ const selectedInput = parentCard.querySelector(`.sledge__product-grid-card-selected-option[data-product-id='${id}']`);
2416
+ const setOptionAttribute = () => {
2417
+ selectedInput.attributes[`data-selected-option${optionIndex}`].value = value;
2418
+ };
2419
+ setOptionAttribute();
2420
+ const option1 = `[data-option-1="${selectedInput.attributes["data-selected-option1"].value}"]`;
2421
+ const option2 = `${selectedInput.attributes["data-selected-option2"] ? `[data-option-2="${selectedInput.attributes["data-selected-option2"].value}"]` : ""}`;
2422
+ const selectOption = parentCard.querySelector(`select option${option1}${option2}`);
2423
+ const variantId = selectOption.attributes["data-graphql-id"].value;
2424
+ const imageId = (_a2 = selectOption.attributes["data-image-id"]) == null ? void 0 : _a2.value;
2425
+ const setOther = () => {
2426
+ selectedInput.attributes[`data-variant-id`].value = selectOption.attributes["data-graphql-id"].value;
2427
+ if (imageId)
2428
+ parentCard.querySelector(`img.sledge__product-grid-card-image-featured-image`).src = parentCard.querySelector(
2429
+ `div.sledge__product-grid-card-variant-images img[id="${imageId}"]`
2430
+ ).src;
2431
+ };
2432
+ setOther();
2433
+ const result = {
2434
+ variantId,
2435
+ imageId
2436
+ };
2437
+ return result;
2438
+ };
2439
+ const options = (product == null ? void 0 : product.options) ? Object.entries(product.options) : [];
2440
+ const images = (product == null ? void 0 : product.images) ?? [];
2441
+ const defaultSelected = {};
2442
+ setDefaultFunction();
2443
+ const selectedInputElement = document.querySelector(`.sledge__product-grid-card .sledge__product-grid-card-selected-option[data-product-id='${id}']`);
2444
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card", children: [
2445
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-content", children: [
2446
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-image", children: [
2447
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
2448
+ "a",
2449
+ {
2450
+ href: url,
2451
+ onClick: () => sourceApp === "instant-search" && productClickTrigger({
2452
+ productId: id
2453
+ }),
2454
+ children: [
2455
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
2456
+ Trigger,
2457
+ {
2458
+ params: {
2459
+ productId: id,
2460
+ productVariantId: variant_id,
2461
+ productName: title,
2462
+ productVendor: vendor,
2463
+ productSku: sku,
2464
+ productVariantName: variant_title,
2465
+ productLink: url,
2466
+ productImage: (image == null ? void 0 : image.src) || `${API_URL}/img/blank-image.png`,
2467
+ productCurrency: currency,
2468
+ productPrice: price
2469
+ },
2470
+ ...triggerPropAdditional,
2471
+ onAfterAddWishlist,
2472
+ onAfterRemoveWishlist,
2473
+ wishlistChecked: dataWishlists == null ? void 0 : dataWishlists[id]
2474
+ }
2475
+ ),
2476
+ /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: (image == null ? void 0 : image.src) || `${API_URL}/img/blank-image.png`, alt: "sledge-card-image", loading: "lazy", className: "sledge__product-grid-card-image-featured-image" }),
2477
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-variant-images", children: images == null ? void 0 : images.map((image2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
2478
+ "img",
2479
+ {
2480
+ decoding: "async",
2481
+ id: image2 == null ? void 0 : image2.id,
2482
+ height: "270",
2483
+ loading: "lazy",
2484
+ src: image2 == null ? void 0 : image2.src,
2485
+ alt: product == null ? void 0 : product.title,
2486
+ width: 269.92,
2487
+ style: { aspectRatio: 269.92 / 270 }
2443
2488
  },
2444
- ...triggerPropAdditional,
2445
- onAfterAddWishlist,
2446
- onAfterRemoveWishlist,
2447
- wishlistChecked: dataWishlists == null ? void 0 : dataWishlists[id]
2448
- }
2449
- ),
2450
- /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: (image == null ? void 0 : image.src) || `${API_URL}/img/blank-image.png`, alt: "sledge-card-image", loading: "lazy", className: "sledge__product-grid-card-image-featured-image" }),
2451
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-variant-images", children: images == null ? void 0 : images.map((image2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
2452
- "img",
2453
- {
2454
- decoding: "async",
2455
- id: image2 == null ? void 0 : image2.id,
2456
- height: "270",
2457
- loading: "lazy",
2458
- src: image2 == null ? void 0 : image2.src,
2459
- alt: product == null ? void 0 : product.title,
2460
- width: 269.92,
2461
- style: { aspectRatio: 269.92 / 270 }
2462
- },
2463
- image2 == null ? void 0 : image2.id
2464
- )) })
2465
- ]
2466
- }
2467
- ),
2468
- isOutOfStock ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-out-of-stock", children: "Sold out" }) : null
2469
- ] }),
2470
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-desc", children: [
2471
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-title", children: [
2472
- show_price ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-price", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { style: display_price_style, children: [
2473
- currency,
2474
- price
2475
- ] }) }) : null,
2476
- show_vendor && vendor ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-badge-vendor", title: vendor, children: [
2477
- "Vendor: ",
2478
- vendor
2479
- ] }) : null
2489
+ image2 == null ? void 0 : image2.id
2490
+ )) })
2491
+ ]
2492
+ }
2493
+ ),
2494
+ isOutOfStock ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-out-of-stock", children: "Sold out" }) : null
2480
2495
  ] }),
2481
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-rating", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2482
- Rating,
2483
- {
2484
- params: {
2485
- productId: id
2486
- },
2487
- size: "xs",
2488
- withSkeletonLoading: false,
2489
- isScrollToElementWidget: false,
2490
- data: dataReviews == null ? void 0 : dataReviews[id]
2491
- }
2492
- ) }),
2493
- title ? /* @__PURE__ */ jsxRuntimeExports.jsx(
2494
- "a",
2495
- {
2496
- href: url,
2497
- onClick: () => sourceApp === "instant-search" && productClickTrigger({
2498
- productId: id
2499
- }),
2500
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "sledge__product-grid-card-product-name", style: display_product_name_style, children: title })
2501
- }
2502
- ) : null,
2503
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-text", children: show_sku && sku ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2504
- "SKU: ",
2505
- sku
2506
- ] }) : null }),
2507
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-variant-swatch", children: [
2508
- /* @__PURE__ */ jsxRuntimeExports.jsx("input", { type: "hidden", ...defaultSelected, className: "selected-option" }),
2509
- /* @__PURE__ */ jsxRuntimeExports.jsx("select", { className: "variant-picker sledge__product-grid-card-variant-picker", children: variants == null ? void 0 : variants.map((variant) => {
2510
- const { title: title2, option1, option2, position, id: id2, admin_graphql_api_id, image_id } = variant;
2511
- let optionAttributes = {
2512
- "data-option-1": option1,
2513
- "data-option-2": option2,
2514
- "data-position": position,
2515
- "data-id": id2,
2516
- "data-graphql-id": admin_graphql_api_id,
2517
- "data-image-id": image_id
2518
- };
2519
- return /* @__PURE__ */ jsxRuntimeExports.jsx("option", { ...optionAttributes, children: title2 }, id2);
2520
- }) }),
2521
- options == null ? void 0 : options.map((option, optionParentIndex) => {
2522
- const optionName = option[0];
2523
- const optionValues = option[1];
2524
- const [selectedOption, setSelectedOption] = React__default.useState(optionValues[0]);
2525
- return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: optionValues[0] !== "Default Title" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-variant-size-swatch-flex", children: optionValues.map((item2, index2) => {
2526
- const defaultOptionClass = `
2527
- ${selectedOption === item2 ? "sledge__product-variant-size-swatch-active" : ""} sledge__product-variant-size-swatch`;
2528
- const colorOptionClass = `${selectedOption === item2 ? "sledge__product-variant-color-swatch-active" : ""} sledge__product-variant-color-swatch`;
2529
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
2530
- "button",
2531
- {
2532
- type: "button",
2533
- className: optionName === "Color" ? colorOptionClass : defaultOptionClass,
2534
- style: {
2535
- backgroundColor: optionName === "Color" ? item2 : null
2536
- },
2537
- onClick: (el) => {
2538
- setSelectedVariant(el, item2, optionParentIndex + 1);
2539
- setSelectedOption(item2);
2496
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-desc", children: [
2497
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-title", children: [
2498
+ show_price ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-price", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { style: display_price_style, children: [
2499
+ currency,
2500
+ price
2501
+ ] }) }) : null,
2502
+ show_vendor && vendor ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-badge-vendor", title: vendor, children: [
2503
+ "Vendor: ",
2504
+ vendor
2505
+ ] }) : null
2506
+ ] }),
2507
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-rating", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2508
+ Rating,
2509
+ {
2510
+ params: {
2511
+ productId: id
2512
+ },
2513
+ size: "xs",
2514
+ withSkeletonLoading: false,
2515
+ isScrollToElementWidget: false,
2516
+ data: dataReviews == null ? void 0 : dataReviews[id]
2517
+ }
2518
+ ) }),
2519
+ title ? /* @__PURE__ */ jsxRuntimeExports.jsx(
2520
+ "a",
2521
+ {
2522
+ href: url,
2523
+ onClick: () => sourceApp === "instant-search" && productClickTrigger({
2524
+ productId: id
2525
+ }),
2526
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "sledge__product-grid-card-product-name", style: display_product_name_style, children: title })
2527
+ }
2528
+ ) : null,
2529
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-text", children: show_sku && sku ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2530
+ "SKU: ",
2531
+ sku
2532
+ ] }) : null }),
2533
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-variant-swatch", children: [
2534
+ /* @__PURE__ */ jsxRuntimeExports.jsx("input", { type: "hidden", ...defaultSelected, className: "sledge__product-grid-card-selected-option" }),
2535
+ /* @__PURE__ */ jsxRuntimeExports.jsx("select", { className: "variant-picker sledge__product-grid-card-variant-picker", children: variants == null ? void 0 : variants.map((variant) => {
2536
+ const { title: title2, option1, option2, position, id: id2, admin_graphql_api_id, image_id } = variant;
2537
+ let optionAttributes = {
2538
+ "data-option-1": option1,
2539
+ "data-option-2": option2,
2540
+ "data-position": position,
2541
+ "data-id": id2,
2542
+ "data-graphql-id": admin_graphql_api_id,
2543
+ "data-image-id": image_id
2544
+ };
2545
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("option", { ...optionAttributes, children: title2 }, id2);
2546
+ }) }),
2547
+ options == null ? void 0 : options.map((option, optionParentIndex) => {
2548
+ const optionName = option[0];
2549
+ const optionValues = option[1];
2550
+ let selectedOption = optionValues[0];
2551
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: optionValues[0] !== "Default Title" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `sledge__product-variant-size-swatch-flex options-button-${optionName}`, children: optionValues.map((item2, index2) => {
2552
+ const defaultOptionClass = `
2553
+ ${selectedOption === item2 ? "sledge__product-variant-size-swatch-active" : ""} sledge__product-variant-size-swatch`;
2554
+ const colorOptionClass = `${selectedOption === item2 ? "sledge__product-variant-color-swatch-active" : ""} sledge__product-variant-color-swatch`;
2555
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
2556
+ "button",
2557
+ {
2558
+ type: "button",
2559
+ className: optionName === "Color" ? colorOptionClass : defaultOptionClass,
2560
+ style: {
2561
+ backgroundColor: optionName === "Color" ? item2 : null
2562
+ },
2563
+ onClick: (el) => {
2564
+ setSelectedVariant(el, item2, optionParentIndex + 1);
2565
+ setSelectedOption(el, optionName);
2566
+ },
2567
+ title: optionName === "Color" ? null : item2,
2568
+ children: optionName === "Color" ? null : item2
2540
2569
  },
2541
- title: optionName === "Color" ? null : item2,
2542
- children: optionName === "Color" ? null : item2
2543
- },
2544
- index2
2545
- );
2546
- }) }, optionParentIndex) });
2547
- })
2548
- ] })
2549
- ] })
2550
- ] }),
2551
- show_add_to_cart ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-button-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2552
- Button,
2553
- {
2554
- type: "button",
2555
- colorType: "light",
2556
- style: {
2557
- ...display_button_add_to_cart_style,
2558
- ...isLoadingAddToCart && {
2559
- cursor: "wait"
2560
- }
2561
- },
2562
- ...isLoadingAddToCart || isOutOfStock ? {
2563
- disabled: true
2564
- } : {
2565
- onClick: () => handleAddToCart({
2566
- id: selectedVariantId,
2567
- quantity: 1
2568
- })
2569
- },
2570
- children: isLoadingAddToCart ? "Adding..." : isOutOfStock ? "Sold out" : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
2571
- /* @__PURE__ */ jsxRuntimeExports.jsx(BagIcon, { width: 15, height: 15, color: "#393D4E" }),
2572
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: language_button_add_to_cart ? language_button_add_to_cart : "Add To Cart" })
2570
+ index2
2571
+ );
2572
+ }) }, optionParentIndex) });
2573
+ })
2574
+ ] })
2573
2575
  ] })
2574
- }
2575
- ) }) : null
2576
- ] }, index);
2576
+ ] }),
2577
+ show_add_to_cart ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-button-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2578
+ Button,
2579
+ {
2580
+ type: "button",
2581
+ colorType: "light",
2582
+ style: {
2583
+ ...display_button_add_to_cart_style,
2584
+ ...isLoadingAddToCart && {
2585
+ cursor: "wait"
2586
+ }
2587
+ },
2588
+ ...isLoadingAddToCart || isOutOfStock ? {
2589
+ disabled: true
2590
+ } : {
2591
+ onClick: () => {
2592
+ var _a2;
2593
+ if (!((_a2 = selectedInputElement == null ? void 0 : selectedInputElement.dataset) == null ? void 0 : _a2.variantId))
2594
+ return;
2595
+ handleAddToCart({
2596
+ id: selectedInputElement.dataset.variantId,
2597
+ quantity: 1
2598
+ });
2599
+ }
2600
+ },
2601
+ children: isLoadingAddToCart ? "Adding..." : isOutOfStock ? "Sold out" : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
2602
+ /* @__PURE__ */ jsxRuntimeExports.jsx(BagIcon, { width: 15, height: 15, color: "#393D4E" }),
2603
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: language_button_add_to_cart ? language_button_add_to_cart : "Add To Cart" })
2604
+ ] })
2605
+ }
2606
+ ) }) : null
2607
+ ] }, index);
2608
+ }
2577
2609
  }) });
2578
2610
  };
2579
2611
  const TextAreaField = "";
@@ -3375,9 +3407,6 @@ const SearchIconWidgetPopup = () => {
3375
3407
  };
3376
3408
  const SearchResultWidget = (props) => {
3377
3409
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
3378
- const { isRenderApp, isJsVersion, triggerRenderMultipleComponent } = React__default.useContext(SledgeContext);
3379
- const { instantSearch: isRenderAppInstantSearch } = isRenderApp || {};
3380
- const { value: valueRenderInstantSearchResult, trigger: triggerRenderInstantSearchResult } = ((_a = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.instantSearch) == null ? void 0 : _a.searchResult) || {};
3381
3410
  const {
3382
3411
  layoutType = "default",
3383
3412
  query,
@@ -3396,6 +3425,29 @@ const SearchResultWidget = (props) => {
3396
3425
  } = props;
3397
3426
  const queryKeyword = (query == null ? void 0 : query.keyword) ? query.keyword : "q";
3398
3427
  const { collectionId } = params || {};
3428
+ const searchParams = typeof document !== "undefined" ? new URLSearchParams((_a = document == null ? void 0 : document.location) == null ? void 0 : _a.search) : null;
3429
+ const [settings] = React__default.useState(typeof localStorage !== "undefined" ? JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "{}") : {});
3430
+ const [isFirstLoading, setIsFirstLoading] = React__default.useState(!propsData);
3431
+ const [isLoading, setIsLoading] = React__default.useState(!propsData);
3432
+ const [keyword, setKeyword] = React__default.useState(searchParams == null ? void 0 : searchParams.get(queryKeyword));
3433
+ const [clickedTabIndexId, setClickedTabIndexId] = React__default.useState(null);
3434
+ const [clickedTabIndexName, setClickedTabIndexName] = React__default.useState();
3435
+ const [clickedTabIndexType, setClickedTabIndexType] = React__default.useState();
3436
+ const [resultComponent, setResultComponent] = React__default.useState(/* @__PURE__ */ jsxRuntimeExports.jsx(ResultProduct, {}));
3437
+ const [isLoadingSetting, setIsLoadingSetting] = React__default.useState(!propsData);
3438
+ const [allowedSorts, setAllowedSorts] = React__default.useState(((_b = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _b.allowed_sorts) || []);
3439
+ const [allowedFilters, setAllowedFilters] = React__default.useState(((_c = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _c.filters) || []);
3440
+ const [allowedTabs, setAllowedTabs] = React__default.useState([]);
3441
+ const [facets, setFacets] = React__default.useState([]);
3442
+ const [indexProduct, setIndexProduct] = React__default.useState(((_d = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _d.index_product) || "");
3443
+ const [hiddenTags, setHiddenTags] = React__default.useState(((_e = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _e.hidden_tags) || []);
3444
+ const [displaySettings, setDisplaySettings] = React__default.useState(((_f = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _f.display) || {});
3445
+ const [colorSwatches, setColorSwatches] = React__default.useState(((_g = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _g.colors) || []);
3446
+ const [defaultSort, setDefaultSort] = React__default.useState(((_h = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _h.default_sort) || "");
3447
+ const [showOutOfStock, setShowOutOfStock] = React__default.useState((_i = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _i.show_out_of_stock);
3448
+ const [initStatesFirstTime, setInitStatesFirstTime] = React__default.useState(true);
3449
+ const [defaultFacetStats, setDefaultFacetStats] = React__default.useState({});
3450
+ const [hideFilterWhenOneValue, setHideFilterWhenOneValue] = React__default.useState(false);
3399
3451
  let productCardsComponent = null;
3400
3452
  let collectionCardsComponent = null;
3401
3453
  let pageCardsComponent = null;
@@ -3416,28 +3468,9 @@ const SearchResultWidget = (props) => {
3416
3468
  articleCardsComponent = articleCard;
3417
3469
  }
3418
3470
  });
3419
- const searchParams = typeof document !== "undefined" ? new URLSearchParams((_b = document == null ? void 0 : document.location) == null ? void 0 : _b.search) : null;
3420
- const [settings] = React__default.useState(typeof localStorage !== "undefined" ? JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "{}") : {});
3421
- const [isFirstLoading, setIsFirstLoading] = React__default.useState(!propsData);
3422
- const [isLoading, setIsLoading] = React__default.useState(!propsData);
3423
- const [keyword, setKeyword] = React__default.useState(searchParams == null ? void 0 : searchParams.get(queryKeyword));
3424
- const [clickedTabIndexId, setClickedTabIndexId] = React__default.useState(null);
3425
- const [clickedTabIndexName, setClickedTabIndexName] = React__default.useState();
3426
- const [clickedTabIndexType, setClickedTabIndexType] = React__default.useState();
3427
- const [resultComponent, setResultComponent] = React__default.useState(/* @__PURE__ */ jsxRuntimeExports.jsx(ResultProduct, {}));
3428
- const [isLoadingSetting, setIsLoadingSetting] = React__default.useState(!propsData);
3429
- const [allowedSorts, setAllowedSorts] = React__default.useState(((_c = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _c.allowed_sorts) || []);
3430
- const [allowedFilters, setAllowedFilters] = React__default.useState(((_d = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _d.filters) || []);
3431
- const [allowedTabs, setAllowedTabs] = React__default.useState([]);
3432
- const [facets, setFacets] = React__default.useState([]);
3433
- const [indexProduct, setIndexProduct] = React__default.useState(((_e = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _e.index_product) || "");
3434
- const [searchResultFacets, setSearchResultFacets] = React__default.useState({});
3435
- const [hiddenTags, setHiddenTags] = React__default.useState(((_f = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _f.hidden_tags) || []);
3436
- const [displaySettings, setDisplaySettings] = React__default.useState(((_g = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _g.display) || {});
3437
- const [colorSwatches, setColorSwatches] = React__default.useState(((_h = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _h.colors) || []);
3438
- const [defaultSort, setDefaultSort] = React__default.useState(((_i = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _i.default_sort) || "");
3439
- const [showOutOfStock, setShowOutOfStock] = React__default.useState((_j = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _j.show_out_of_stock);
3440
- const [initStatesFirstTime, setInitStatesFirstTime] = React__default.useState(true);
3471
+ const { isRenderApp, isJsVersion, triggerRenderMultipleComponent } = React__default.useContext(SledgeContext);
3472
+ const { instantSearch: isRenderAppInstantSearch } = isRenderApp || {};
3473
+ const { value: valueRenderInstantSearchResult, trigger: triggerRenderInstantSearchResult } = ((_j = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.instantSearch) == null ? void 0 : _j.searchResult) || {};
3441
3474
  const searchResultContainerRef = React__default.useRef(null);
3442
3475
  const previousState = usePrevious({ keyword });
3443
3476
  const handleChangeTabIndex = (params2) => {
@@ -3448,7 +3481,8 @@ const SearchResultWidget = (props) => {
3448
3481
  setResultComponent(id.includes(indexProduct) ? /* @__PURE__ */ jsxRuntimeExports.jsx(ResultProduct, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(ResultCategory, {}));
3449
3482
  };
3450
3483
  const handleInitStates = async (data, type) => {
3451
- const { filters, index_product, tabs, hidden_tags, show_out_of_stock } = data;
3484
+ var _a2;
3485
+ const { filters, index_product, tabs, hidden_tags, show_out_of_stock, display } = data;
3452
3486
  let getTabs = layoutType === "product-filter" ? tabs.filter(({ index }) => index == null ? void 0 : index.includes(index_product)) : tabs;
3453
3487
  let response;
3454
3488
  let body = {
@@ -3512,37 +3546,9 @@ const SearchResultWidget = (props) => {
3512
3546
  })
3513
3547
  );
3514
3548
  } else {
3515
- const { facetDistribution, facetStats } = (results == null ? void 0 : results.find(({ indexUid }) => indexUid.includes(index_product))) || {};
3516
- setSearchResultFacets(
3517
- facetDistribution ? Object.fromEntries(
3518
- Object.entries(facetDistribution).map((facet) => {
3519
- let value = facet[0];
3520
- let items = [];
3521
- if (value === "variants.inventory_quantity") {
3522
- Object.keys(facetDistribution[value]).map((item) => {
3523
- return Boolean(Number(item)) ? facetDistribution[value][item] : 0;
3524
- });
3525
- items = [
3526
- {
3527
- name: "In Stock",
3528
- value: "> 0"
3529
- }
3530
- ];
3531
- } else if (value === "variants.price") {
3532
- items = facetStats[value];
3533
- } else {
3534
- items = Object.keys(facetDistribution[value]).map((item) => {
3535
- return {
3536
- name: item,
3537
- value: item,
3538
- total: facetDistribution[value][item] || 0
3539
- };
3540
- });
3541
- }
3542
- return [value, items];
3543
- })
3544
- ) : {}
3545
- );
3549
+ const { facetStats, totalHits } = (results == null ? void 0 : results.find(({ indexUid }) => indexUid.includes(index_product))) || {};
3550
+ setDefaultFacetStats(facetStats);
3551
+ setHideFilterWhenOneValue(((_a2 = display == null ? void 0 : display.filter) == null ? void 0 : _a2.hide_when_one_value) && totalHits <= 1);
3546
3552
  }
3547
3553
  };
3548
3554
  const handleSettings = async (LOCAL_STORAGE_INSTANT_SEARCH_SETTING) => {
@@ -3887,7 +3893,8 @@ const SearchResultWidget = (props) => {
3887
3893
  allowedSorts,
3888
3894
  allowedFilters,
3889
3895
  facets,
3890
- searchResultFacets,
3896
+ defaultFacetStats,
3897
+ hideFilterWhenOneValue,
3891
3898
  hiddenTags,
3892
3899
  displaySettings,
3893
3900
  colorSwatches,
@@ -3930,7 +3937,8 @@ const ResultProduct = (props) => {
3930
3937
  allowedSorts,
3931
3938
  allowedFilters,
3932
3939
  facets,
3933
- searchResultFacets,
3940
+ defaultFacetStats,
3941
+ hideFilterWhenOneValue,
3934
3942
  hiddenTags,
3935
3943
  displaySettings,
3936
3944
  colorSwatches,
@@ -3963,6 +3971,7 @@ const ResultProduct = (props) => {
3963
3971
  const [clickedSortName, setClickedSortName] = React__default.useState(allowedSorts && Boolean(allowedSorts == null ? void 0 : allowedSorts.length) ? (_a = allowedSorts.find(({ value }) => value === defaultSort)) == null ? void 0 : _a.label : "");
3964
3972
  const [clickedLimitId, setClickedLimitId] = React__default.useState(((_b = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _b.limit) || 10);
3965
3973
  const [clickedOpenFilterId, setClickedOpenFilterId] = React__default.useState(null);
3974
+ const [clickedOpenFilters, setClickedOpenFilters] = React__default.useState([]);
3966
3975
  const [clickedFacets, setClickedFacets] = React__default.useState({
3967
3976
  ...!showOutOfStock ? {
3968
3977
  "variants.inventory_quantity": "> 0"
@@ -3978,6 +3987,7 @@ const ResultProduct = (props) => {
3978
3987
  const [allowedFilter, setAllowedFilter] = React__default.useState([]);
3979
3988
  const [isFilterChanged, setIsFilterChanged] = React__default.useState(false);
3980
3989
  const [handleSearchResultFirstTime, setHandleSearchResultFirstTime] = React__default.useState(true);
3990
+ const [searchResultFacets, setSearchResultFacets] = React__default.useState({});
3981
3991
  const summaryTextGenerator = () => {
3982
3992
  var _a2;
3983
3993
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary-item", children: ((_a2 = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _a2.show_total_products) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-instant-search__result-data-summary-text", children: [
@@ -4083,8 +4093,17 @@ const ResultProduct = (props) => {
4083
4093
  setIsOpenLimit(false);
4084
4094
  setClickedLimitId(value);
4085
4095
  };
4086
- const handleOpenFilter = (id) => {
4096
+ const handleOpenFilterVertical = (id) => {
4087
4097
  setClickedOpenFilterId(id === clickedOpenFilterId ? "" : id);
4098
+ let valueClickedOpenFilters = clickedOpenFilters;
4099
+ if (valueClickedOpenFilters.includes(id)) {
4100
+ const findIndex = valueClickedOpenFilters.indexOf(id);
4101
+ if (findIndex > -1)
4102
+ valueClickedOpenFilters.splice(findIndex, 1);
4103
+ } else {
4104
+ valueClickedOpenFilters.push(id);
4105
+ }
4106
+ setClickedOpenFilters(valueClickedOpenFilters);
4088
4107
  };
4089
4108
  const handleFilterReset = () => {
4090
4109
  setIsFilterChanged(true);
@@ -4138,7 +4157,7 @@ const ResultProduct = (props) => {
4138
4157
  var _a2;
4139
4158
  if (!result)
4140
4159
  return;
4141
- const { hits, processingTimeMs, totalHits, totalPages } = result;
4160
+ const { hits, processingTimeMs, totalHits, totalPages, facetDistribution } = result;
4142
4161
  if (onSearch && (keyword == null ? void 0 : keyword.length)) {
4143
4162
  searchTrigger({
4144
4163
  keyword,
@@ -4166,6 +4185,34 @@ const ResultProduct = (props) => {
4166
4185
  ] }) : null
4167
4186
  ] }) : null })
4168
4187
  );
4188
+ setSearchResultFacets(
4189
+ facetDistribution ? Object.fromEntries(
4190
+ Object.entries(facetDistribution).map((facet) => {
4191
+ let value = facet[0];
4192
+ let items = [];
4193
+ if (value === "variants.inventory_quantity") {
4194
+ Object.keys(facetDistribution[value]).map((item) => {
4195
+ return Boolean(Number(item)) ? facetDistribution[value][item] : 0;
4196
+ });
4197
+ items = [
4198
+ {
4199
+ name: "In Stock",
4200
+ value: "> 0"
4201
+ }
4202
+ ];
4203
+ } else {
4204
+ items = Object.keys(facetDistribution[value]).map((item) => {
4205
+ return {
4206
+ name: item,
4207
+ value: item,
4208
+ total: facetDistribution[value][item] || 0
4209
+ };
4210
+ });
4211
+ }
4212
+ return [value, items];
4213
+ })
4214
+ ) : {}
4215
+ );
4169
4216
  };
4170
4217
  const handleSearchResult = async (isRefreshPage = false, onSearch = false) => {
4171
4218
  var _a2, _b2;
@@ -4210,8 +4257,8 @@ const ResultProduct = (props) => {
4210
4257
  handleSearchResultData(response, onSearch);
4211
4258
  };
4212
4259
  const handleAllowedFilter = () => {
4213
- var _a2, _b2;
4214
- if (!((_a2 = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _a2.enable_on_search) || ((_b2 = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _b2.hide_when_one_value) && totalSearchResult <= 1)
4260
+ var _a2;
4261
+ if (!((_a2 = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _a2.enable_on_search) || hideFilterWhenOneValue)
4215
4262
  return;
4216
4263
  let isSetFilter = false;
4217
4264
  if (!isSetFilter)
@@ -4289,21 +4336,26 @@ const ResultProduct = (props) => {
4289
4336
  let items = searchResultFacets[value];
4290
4337
  let isShowNumberMatchingProduct = (_a2 = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _a2.show_number_matching_product;
4291
4338
  if (display.toLowerCase() === "slider") {
4339
+ let items2 = defaultFacetStats[value] && Object.keys(defaultFacetStats[value]).length ? defaultFacetStats[value] : {};
4340
+ let defaultValueMin = valueFilterPriceChange[0] || (items2 == null ? void 0 : items2.min);
4341
+ let defaultValueMax = valueFilterPriceChange[1] || (items2 == null ? void 0 : items2.max);
4292
4342
  blockComponent = /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-list-slider", children: [
4293
4343
  /* @__PURE__ */ jsxRuntimeExports.jsx(
4294
4344
  Slider,
4295
4345
  {
4296
- defaultValue: [valueFilterPriceChange[0] || (items == null ? void 0 : items.min), valueFilterPriceChange[1] || (items == null ? void 0 : items.max)],
4297
- min: items == null ? void 0 : items.min,
4298
- max: items == null ? void 0 : items.max,
4346
+ defaultValue: defaultValueMin === defaultValueMax ? [defaultValueMax] : [defaultValueMin, defaultValueMax],
4347
+ ...(items2 == null ? void 0 : items2.min) === (items2 == null ? void 0 : items2.max) ? {} : {
4348
+ min: items2 == null ? void 0 : items2.min
4349
+ },
4350
+ max: items2 == null ? void 0 : items2.max,
4299
4351
  step: 1,
4300
4352
  setValueCommit: (valueCommit) => handleFilterChange(value, valueCommit),
4301
4353
  setValueChange: (valueChange) => setValueFilterPriceChange(valueChange)
4302
4354
  }
4303
4355
  ),
4304
4356
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-list-slider-minmax", children: [
4305
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-minmax-field", children: valueFilterPriceChange[0] || (items == null ? void 0 : items.min) }),
4306
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-minmax-field", children: valueFilterPriceChange[1] || (items == null ? void 0 : items.max) })
4357
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-minmax-field", children: valueFilterPriceChange[0] || (items2 == null ? void 0 : items2.min) }),
4358
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-minmax-field", children: valueFilterPriceChange[1] || (items2 == null ? void 0 : items2.max) })
4307
4359
  ] })
4308
4360
  ] });
4309
4361
  } else if (display.toLowerCase() === "checkbox" && (items == null ? void 0 : items.length)) {
@@ -4317,7 +4369,7 @@ const ResultProduct = (props) => {
4317
4369
  value: item.value,
4318
4370
  label: `${item.name}${item.total !== void 0 && isShowNumberMatchingProduct ? ` (${item.total})` : ""}`,
4319
4371
  onClick: (e) => handleFilterChange(value, e.currentTarget.value),
4320
- defaultChecked: clickedFacets && ((_a3 = clickedFacets[value]) == null ? void 0 : _a3.includes(item.value)),
4372
+ checked: clickedFacets && ((_a3 = clickedFacets[value]) == null ? void 0 : _a3.includes(item.value)),
4321
4373
  labelStyle: filter_option_style
4322
4374
  }
4323
4375
  ) }, index);
@@ -4379,7 +4431,6 @@ const ResultProduct = (props) => {
4379
4431
  };
4380
4432
  const filterVerticalComponents = allowedFilter.map((filter, indexFilter) => {
4381
4433
  const { value, label, display } = filter;
4382
- let isActive = clickedOpenFilterId === value;
4383
4434
  let items = searchResultFacets[value];
4384
4435
  let isRender = Boolean(display.toLowerCase() === "slider" ? items : items == null ? void 0 : items.length);
4385
4436
  let isNotRerender = ["select"].includes(display.toLowerCase()) && (items == null ? void 0 : items.length);
@@ -4389,11 +4440,11 @@ const ResultProduct = (props) => {
4389
4440
  classesUlElement.push("sledge-instant-search__result-filter-item-color-swatches");
4390
4441
  }
4391
4442
  return isRender ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item", children: [
4392
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-title", onClick: () => handleOpenFilter(value), children: [
4443
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-title", onClick: () => handleOpenFilterVertical(value), children: [
4393
4444
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__result-filter-title", style: filter_title_style, children: label }),
4394
- /* @__PURE__ */ jsxRuntimeExports.jsx(motion.div, { initial: false, animate: isActive ? "open" : "closed", variants: ROTATE_FILTER_ARROW_ANIMATION, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronArrowDownIcon, { width: 15, height: 15, color: "#000000" }) })
4445
+ /* @__PURE__ */ jsxRuntimeExports.jsx(motion.div, { initial: false, animate: clickedOpenFilters.includes(value) ? "open" : "closed", variants: ROTATE_FILTER_ARROW_ANIMATION, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronArrowDownIcon, { width: 15, height: 15, color: "#000000" }) })
4395
4446
  ] }),
4396
- isActive && /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: classesUlElement.join(" "), children: isNotRerender ? getFacetComponent : !isFilterChanged ? getFacetComponent : null })
4447
+ clickedOpenFilters.includes(value) && /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: classesUlElement.join(" "), children: isNotRerender ? getFacetComponent : !isFilterChanged ? getFacetComponent : null })
4397
4448
  ] }, indexFilter) : null;
4398
4449
  });
4399
4450
  const filterHorizontalComponents = allowedFilter.map((filter, indexFilter) => {
@@ -4410,7 +4461,7 @@ const ResultProduct = (props) => {
4410
4461
  return isRender ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4411
4462
  Popover,
4412
4463
  {
4413
- trigger: /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { type: "button", onClick: () => handleOpenFilter(value), children: [
4464
+ trigger: /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { type: "button", onClick: () => setClickedOpenFilterId(value), children: [
4414
4465
  label,
4415
4466
  /* @__PURE__ */ jsxRuntimeExports.jsx(motion.div, { initial: "closed", animate: isActive ? "open" : "closed", variants: ROTATE_FILTER_ARROW_ANIMATION, className: "sort-trigger-icon", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronArrowDownIcon, { width: 20, height: 20, color: "#000000" }) })
4416
4467
  ] }),
@@ -4455,9 +4506,9 @@ const ResultProduct = (props) => {
4455
4506
  });
4456
4507
  const paginationComponent = /* @__PURE__ */ jsxRuntimeExports.jsx(Pagination, { currentPage, totalPage, totalResult: totalSearchResult, onChange: (page) => handlePageChange(page) });
4457
4508
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4458
- ((_l = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _l.enable_on_search) && ((_m = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _m.layout) === "horizontal" ? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isFirstLoading && !propsData ? filterHorizontalSkeleton : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isLoadingSetting && !propsData ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal-loading", children: filterHorizontalSkeleton }) : filterHorizontalComponents.every((currentValue) => !currentValue) ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-horizontal-wrapper", children: [
4509
+ ((_l = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _l.enable_on_search) && ((_m = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _m.layout) === "horizontal" ? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isFirstLoading && !propsData ? filterHorizontalSkeleton : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isLoadingSetting && !propsData ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal-loading", children: filterHorizontalSkeleton }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-horizontal-wrapper", children: [
4459
4510
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal", children: filterHorizontalComponents }),
4460
- Boolean((dataClickedFacets == null ? void 0 : dataClickedFacets.length) && ((_n = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _n.show_refine_by_block)) ? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: Boolean(dataClickedFacets.every((currentValue) => !currentValue)) ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-horizontal", children: [
4511
+ Boolean((dataClickedFacets == null ? void 0 : dataClickedFacets.length) && ((_n = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _n.show_refine_by_block)) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-horizontal", children: [
4461
4512
  /* @__PURE__ */ jsxRuntimeExports.jsx(
4462
4513
  "div",
4463
4514
  {
@@ -4475,11 +4526,11 @@ const ResultProduct = (props) => {
4475
4526
  index
4476
4527
  });
4477
4528
  })
4478
- ] }) }) : null
4529
+ ] }) : null
4479
4530
  ] }) }) }) : null,
4480
4531
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-wrapper", "data-filter-layout": (_o = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _o.layout, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4481
- ((_p = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _p.enable_on_search) && ((_q = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _q.layout) === "vertical" ? isFirstLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter", children: filterVerticalSkeleton }) : filterVerticalComponents.every((currentValue) => !currentValue) ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter", children: isLoadingSetting ? filterVerticalSkeleton : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4482
- Boolean((dataClickedFacets == null ? void 0 : dataClickedFacets.length) && ((_r = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _r.show_refine_by_block)) ? Boolean(dataClickedFacets.every((currentValue) => !currentValue)) ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item", children: [
4532
+ ((_p = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _p.enable_on_search) && ((_q = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _q.layout) === "vertical" ? isFirstLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter", children: filterVerticalSkeleton }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter", children: isLoadingSetting ? filterVerticalSkeleton : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4533
+ Boolean((dataClickedFacets == null ? void 0 : dataClickedFacets.length) && ((_r = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _r.show_refine_by_block)) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item", children: [
4483
4534
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-title-refine", children: [
4484
4535
  /* @__PURE__ */ jsxRuntimeExports.jsx("strong", { className: "sledge-instant-search__result-filter-item-title-refine-heading", children: "Filter" }),
4485
4536
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__result-filter-item-title-refine-clear", onClick: handleFilterReset, children: "Clear All" })