@sledge-app/react-instant-search 1.0.110 → 1.0.112

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.
@@ -514,6 +514,11 @@ const dispatchCustomEvent = (eventName, detail) => {
514
514
  const customEvent = new CustomEvent(eventName, { bubbles: true, cancelable: true, composed: false, ...detail && { detail } });
515
515
  document.dispatchEvent(customEvent);
516
516
  };
517
+ const setElementAttribute = ({ element, attributeName, value }) => {
518
+ if (element && element.hasAttribute(attributeName)) {
519
+ element.setAttribute(attributeName, value);
520
+ }
521
+ };
517
522
  const root = "";
518
523
  const Loading = "";
519
524
  const ConfirmationPopup = "";
@@ -615,7 +620,7 @@ const Progress = ({ value, total, fillColor = "", outlineColor = "", delay = 150
615
620
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(
616
621
  $67824d98245208a0$export$adb584737d712b70,
617
622
  {
618
- className: "ProgressIndicator",
623
+ className: "sledge__progress-indicator ProgressIndicator",
619
624
  style: {
620
625
  ...{ transform: `translateX(-${100 - progress}%)` },
621
626
  ...fillColor && {
@@ -2955,7 +2960,7 @@ const ProductCard = (props) => {
2955
2960
  product: {
2956
2961
  ...product,
2957
2962
  ...{
2958
- variants: variants.map((variant, index) => {
2963
+ variants: variants == null ? void 0 : variants.map((variant, index) => {
2959
2964
  const isInventoryQuantity = Object.hasOwn(variants[index], "inventory_quantity") ? variants[index].inventory_quantity > 0 : false;
2960
2965
  const isInventoryManagement = Object.hasOwn(variants[index], "inventory_management") ? variants[index].inventory_management === null : false;
2961
2966
  const isInventoryPolicy = Object.hasOwn(variants[index], "inventory_policy") ? variants[index].inventory_policy === "continue" : false;
@@ -3019,10 +3024,11 @@ const ProductCard = (props) => {
3019
3024
  var _a2, _b2, _c2, _d;
3020
3025
  const parentCard = element.target.offsetParent;
3021
3026
  const selectedInput = parentCard.querySelector(`.sledge__product-grid-card-selected-option[data-product-id='${id}']`);
3022
- const setOptionAttribute = () => {
3023
- selectedInput.attributes[`data-selected-option${optionIndex}`].value = value;
3024
- };
3025
- setOptionAttribute();
3027
+ setElementAttribute({
3028
+ element: selectedInput,
3029
+ attributeName: `data-selected-option${optionIndex}`,
3030
+ value
3031
+ });
3026
3032
  const option1 = `[data-option-1="${selectedInput.attributes["data-selected-option1"].value}"]`;
3027
3033
  const option2 = `${selectedInput.attributes["data-selected-option2"] ? `[data-option-2="${selectedInput.attributes["data-selected-option2"].value}"]` : ""}`;
3028
3034
  const selectOption = parentCard.querySelector(`select option${option1}${option2}`);
@@ -3032,10 +3038,27 @@ const ProductCard = (props) => {
3032
3038
  const inventoryManagement = (_c2 = selectOption.attributes["data-inventory-management"]) == null ? void 0 : _c2.value;
3033
3039
  const inventoryPolicy = (_d = selectOption.attributes["data-inventory-policy"]) == null ? void 0 : _d.value;
3034
3040
  const setOther = () => {
3035
- selectedInput.attributes[`data-variant-id`].value = selectOption.attributes["data-graphql-id"].value;
3036
- selectedInput.attributes[`data-inventory-quantity`].value = inventoryQuantity;
3037
- selectedInput.attributes[`data-inventory-management`].value = inventoryManagement;
3038
- selectedInput.attributes[`data-inventory-policy`].value = inventoryPolicy;
3041
+ var _a3, _b3;
3042
+ setElementAttribute({
3043
+ element: selectedInput,
3044
+ attributeName: "data-variant-id",
3045
+ value: ((_b3 = (_a3 = selectOption == null ? void 0 : selectOption.attributes) == null ? void 0 : _a3["data-graphql-id"]) == null ? void 0 : _b3.value) || ""
3046
+ });
3047
+ setElementAttribute({
3048
+ element: selectedInput,
3049
+ attributeName: "data-inventory-quantity",
3050
+ value: inventoryQuantity || ""
3051
+ });
3052
+ setElementAttribute({
3053
+ element: selectedInput,
3054
+ attributeName: "data-inventory-management",
3055
+ value: inventoryManagement || ""
3056
+ });
3057
+ setElementAttribute({
3058
+ element: selectedInput,
3059
+ attributeName: "data-inventory-policy",
3060
+ value: inventoryPolicy || ""
3061
+ });
3039
3062
  if (variantId)
3040
3063
  setSelectedVariantId(variantId);
3041
3064
  if (inventoryQuantity)
@@ -5609,23 +5632,17 @@ const SearchResultWidget = (props) => {
5609
5632
  collections_all_id
5610
5633
  } = response;
5611
5634
  const { limit } = (display == null ? void 0 : display.search) || {};
5612
- let valueAllowedSorts = (allowed_sorts == null ? void 0 : allowed_sorts.length) ? collectionId ? allowed_sorts.map((allowed_sort) => {
5635
+ let valueAllowedSorts = (allowed_sorts == null ? void 0 : allowed_sorts.length) ? collectionId || collections_all_id ? allowed_sorts.map((allowed_sort) => {
5613
5636
  const { value, ...other_allowed_sort } = allowed_sort;
5637
+ const valueReplaced = collectionId ? String(collectionId) : String(collections_all_id);
5614
5638
  return {
5615
5639
  ...other_allowed_sort,
5616
- value: String(value).replaceAll(OBJECT_DATA_STRING_KEY.COLLECTION_ID, String(collectionId))
5640
+ value: String(value).replaceAll(OBJECT_DATA_STRING_KEY.COLLECTION_ID, valueReplaced)
5617
5641
  };
5618
5642
  }) : allowed_sorts.filter((allowed_sort) => {
5619
- const { value, ...other_allowed_sort } = allowed_sort;
5620
- if (collections_all_id) {
5621
- return {
5622
- ...other_allowed_sort,
5623
- value: String(value).replaceAll(OBJECT_DATA_STRING_KEY.COLLECTION_ID, String(collections_all_id))
5624
- };
5625
- } else {
5626
- if (!String(value).includes(OBJECT_DATA_STRING_KEY.COLLECTION_ID))
5627
- return allowed_sort;
5628
- }
5643
+ const { value } = allowed_sort;
5644
+ if (!String(value).includes(OBJECT_DATA_STRING_KEY.COLLECTION_ID))
5645
+ return allowed_sort;
5629
5646
  }) : [];
5630
5647
  setAllowedSorts(valueAllowedSorts);
5631
5648
  setIndexProduct(index_product);
@@ -5633,7 +5650,7 @@ const SearchResultWidget = (props) => {
5633
5650
  setDisplaySettings(display);
5634
5651
  setColorSwatches(colors);
5635
5652
  setDefaultSort(
5636
- (searchParams == null ? void 0 : searchParams.get(querySortBy)) ? searchParams == null ? void 0 : searchParams.get(querySortBy) : collectionId ? String(default_sort).replaceAll(OBJECT_DATA_STRING_KEY.COLLECTION_ID, String(collectionId)) : String(default_sort).includes(OBJECT_DATA_STRING_KEY.COLLECTION_ID) ? (_a2 = valueAllowedSorts[0]) == null ? void 0 : _a2.value : default_sort
5653
+ (searchParams == null ? void 0 : searchParams.get(querySortBy)) ? searchParams == null ? void 0 : searchParams.get(querySortBy) : collectionId ? String(default_sort).replaceAll(OBJECT_DATA_STRING_KEY.COLLECTION_ID, String(collectionId)) : collections_all_id ? String(default_sort).replaceAll(OBJECT_DATA_STRING_KEY.COLLECTION_ID, String(collections_all_id)) : String(default_sort).includes(OBJECT_DATA_STRING_KEY.COLLECTION_ID) ? (_a2 = valueAllowedSorts[0]) == null ? void 0 : _a2.value : default_sort
5637
5654
  );
5638
5655
  setDefaultLimit((localStorage == null ? void 0 : localStorage.getItem(LOCAL_STORAGE_KEY.LIMIT_PRODUCT)) || limit);
5639
5656
  setLanguageSettings(languages);