@sledge-app/react-instant-search 0.0.13 → 0.0.15
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/components/ProductFilterWidget/ProductFilterWidget.d.ts +1 -1
- package/dist/components/ProductFilterWidget/ProductFilterWidget.d.ts.map +1 -1
- package/dist/components/ProductFilterWidget/ProductFilterWidgetInitSelector.d.ts.map +1 -1
- package/dist/components/SearchIconWidget/SearchIconWidget.d.ts +1 -1
- package/dist/components/SearchIconWidget/SearchIconWidget.d.ts.map +1 -1
- package/dist/components/SearchIconWidget/SearchIconWidgetInitSelector.d.ts.map +1 -1
- package/dist/components/SearchIconWidget/SearchIconWidgetPopup.d.ts +1 -1
- package/dist/components/SearchIconWidget/SearchIconWidgetPopup.d.ts.map +1 -1
- package/dist/components/SearchResultWidget/SearchResultWidget.d.ts +1 -1
- package/dist/components/SearchResultWidget/SearchResultWidget.d.ts.map +1 -1
- package/dist/components/SearchResultWidget/SearchResultWidgetInitSelector.d.ts.map +1 -1
- package/dist/components/SearchWidget/SearchWidget.d.ts +1 -1
- package/dist/components/SearchWidget/SearchWidget.d.ts.map +1 -1
- package/dist/components/SearchWidget/SearchWidgetInitSelector.d.ts.map +1 -1
- package/dist/sledge-react-instant-search.cjs +1 -1
- package/dist/sledge-react-instant-search.cjs.map +1 -1
- package/dist/sledge-react-instant-search.js +106 -96
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/package.json +1 -1
|
@@ -16,18 +16,9 @@ const LOCAL_STORAGE_KEY = {
|
|
|
16
16
|
INSTANT_SEARCH_SETTING: "sledge-instant-search-setting"
|
|
17
17
|
};
|
|
18
18
|
const SEARCH_RESULT_URL = "/pages/search-result";
|
|
19
|
-
const
|
|
20
|
-
STORE: {
|
|
21
|
-
NAME: "{{ shop.name }}"
|
|
22
|
-
},
|
|
19
|
+
const SEPARATE_COMPONENT_DISPLAY_NAME = {
|
|
23
20
|
PRODUCT: {
|
|
24
|
-
|
|
25
|
-
VARIANT_TITLE: "{ product_variant_title }",
|
|
26
|
-
IMAGE: "{ product_image }",
|
|
27
|
-
CURRENCY: "{ product_currency }",
|
|
28
|
-
PRICE: "{ product_price }",
|
|
29
|
-
VENDOR: "{ product_vendor }",
|
|
30
|
-
SKU: "{ product_sku }"
|
|
21
|
+
CARDS: "ProductCards"
|
|
31
22
|
}
|
|
32
23
|
};
|
|
33
24
|
const sanitizeDataId = (id) => {
|
|
@@ -41,12 +32,7 @@ const sanitizeDataId = (id) => {
|
|
|
41
32
|
return getId;
|
|
42
33
|
}
|
|
43
34
|
};
|
|
44
|
-
const
|
|
45
|
-
for (var i = 0; i < find.length; i++) {
|
|
46
|
-
str = str.replace(new RegExp(find[i], "gi"), replace[i]);
|
|
47
|
-
}
|
|
48
|
-
return str;
|
|
49
|
-
};
|
|
35
|
+
const isFunction = (data) => typeof data === "function";
|
|
50
36
|
const SearchIconWidget$1 = "";
|
|
51
37
|
const root = "";
|
|
52
38
|
const Loading = "";
|
|
@@ -1644,16 +1630,19 @@ const addToCartTrigger = async (data) => {
|
|
|
1644
1630
|
return;
|
|
1645
1631
|
});
|
|
1646
1632
|
};
|
|
1647
|
-
const
|
|
1633
|
+
const ProductGrid = ({
|
|
1634
|
+
type,
|
|
1635
|
+
className = "",
|
|
1648
1636
|
data,
|
|
1649
1637
|
setting,
|
|
1650
|
-
customProductCard,
|
|
1651
1638
|
showOptionOutOfStock = false,
|
|
1652
1639
|
triggerPropAdditional,
|
|
1653
1640
|
sourceApp = null,
|
|
1641
|
+
cards,
|
|
1654
1642
|
onAfterAddToCart,
|
|
1655
1643
|
onAfterAddWishlist,
|
|
1656
|
-
onAfterRemoveWishlist
|
|
1644
|
+
onAfterRemoveWishlist,
|
|
1645
|
+
onAfterRenderProduct
|
|
1657
1646
|
}) => {
|
|
1658
1647
|
const {
|
|
1659
1648
|
show_vendor = true,
|
|
@@ -1666,15 +1655,6 @@ const ProductCards = ({
|
|
|
1666
1655
|
display_price_style = {},
|
|
1667
1656
|
display_button_add_to_cart_style = {}
|
|
1668
1657
|
} = setting || {};
|
|
1669
|
-
let {
|
|
1670
|
-
image: productCardImage = false,
|
|
1671
|
-
outStock: productCardOutStock = "",
|
|
1672
|
-
title: productCardTitle = "",
|
|
1673
|
-
price: productCardPrice = "",
|
|
1674
|
-
text: productCardText = "",
|
|
1675
|
-
rating: productCardRating = false,
|
|
1676
|
-
buttonAddToCart: productCardButtonAddToCart = ""
|
|
1677
|
-
} = customProductCard || {};
|
|
1678
1658
|
const [clickedAddToCartId, setClickedAddToCartId] = React__default.useState(null);
|
|
1679
1659
|
const handleAddToCart = async (data2) => {
|
|
1680
1660
|
var _a;
|
|
@@ -1723,45 +1703,32 @@ const ProductCards = ({
|
|
|
1723
1703
|
}, 1e3);
|
|
1724
1704
|
}
|
|
1725
1705
|
};
|
|
1726
|
-
|
|
1727
|
-
|
|
1706
|
+
React__default.useEffect(() => {
|
|
1707
|
+
onAfterRenderProduct && onAfterRenderProduct("success");
|
|
1708
|
+
}, []);
|
|
1709
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `sledge__product-grid ${className}`, "data-grid-type": type, children: data == null ? void 0 : data.map((item, index) => {
|
|
1728
1710
|
const { product, variants } = item || {};
|
|
1729
1711
|
const { id, title, image, url, vendor = "", currency } = product || {};
|
|
1730
1712
|
const { id: variant_id = "", title: variant_title = "", price = "", sku = "" } = (variants == null ? void 0 : variants.length) ? variants[0] : {};
|
|
1731
|
-
let totalStock = ((_a = variants == null ? void 0 : variants.map(({ inventory_quantity }) => inventory_quantity)) == null ? void 0 : _a.reduce((a, b) => a + b, 0)) || 0;
|
|
1732
1713
|
let isLoadingAddToCart = clickedAddToCartId == variant_id;
|
|
1733
|
-
let isOutOfStock = !
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
<div>${variant_title}</div>
|
|
1749
|
-
<div>Vendor: ${vendor} | SKU: ${sku}</div>`;
|
|
1750
|
-
productCardRating = true;
|
|
1751
|
-
productCardButtonAddToCart = `
|
|
1752
|
-
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1753
|
-
<path
|
|
1754
|
-
fill-rule="evenodd"
|
|
1755
|
-
clip-rule="evenodd"
|
|
1756
|
-
d="M8.83562 1.50023C10.796 1.50023 12.4155 2.99397 12.6152 4.90442L12.6709 4.90507C13.7584 4.90507 15.0806 5.62732 15.5269 7.65307L16.1186 12.2333C16.3309 13.7116 16.0654 14.8973 15.3281 15.7478C14.5946 16.5938 13.4336 17.0416 11.9704 17.0416H5.7094C4.10215 17.0416 2.9824 16.6478 2.28565 15.8386C1.5859 15.0271 1.3519 13.8098 1.5904 12.2213L2.1724 7.70182C2.5549 5.62957 3.95365 4.90507 5.03665 4.90507C5.13014 4.04293 5.51889 3.22275 6.13562 2.60797C6.84437 1.90372 7.82162 1.50023 8.81987 1.50023H8.83562ZM12.6709 6.03007H5.03665C4.7059 6.03007 3.6004 6.16357 3.28315 7.87657L2.70415 12.3766C2.5159 13.6388 2.6614 14.5523 3.13765 15.1051C3.6079 15.6511 4.4494 15.9166 5.7094 15.9166H11.9704C12.7564 15.9166 13.8296 15.7598 14.4776 15.0113C14.9921 14.4181 15.1691 13.5346 15.0041 12.3848L14.4199 7.84582C14.1709 6.72757 13.5139 6.03007 12.6709 6.03007ZM11.023 8.11815C11.3335 8.11815 11.6027 8.37015 11.6027 8.68065C11.6027 8.99115 11.368 9.24315 11.0575 9.24315H11.023C10.7125 9.24315 10.4605 8.99115 10.4605 8.68065C10.4605 8.37015 10.7125 8.11815 11.023 8.11815ZM6.65042 8.11815C6.96092 8.11815 7.23017 8.37015 7.23017 8.68065C7.23017 8.99115 6.99467 9.24315 6.68417 9.24315H6.65042C6.33992 9.24315 6.08792 8.99115 6.08792 8.68065C6.08792 8.37015 6.33992 8.11815 6.65042 8.11815ZM8.83337 2.62522H8.82212C8.11637 2.62522 7.42862 2.90947 6.92987 3.40522C6.5236 3.80967 6.25789 4.34137 6.17193 4.90472L11.4814 4.90493C11.2887 3.61626 10.1743 2.62522 8.83337 2.62522Z"
|
|
1757
|
-
fill="#393D4E"
|
|
1758
|
-
></path></svg
|
|
1759
|
-
><span>Add To Cart</span>`;
|
|
1760
|
-
}
|
|
1761
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card", children: [
|
|
1714
|
+
let isOutOfStock = (variants == null ? void 0 : variants.length) && Object.hasOwn(variants[0], "inventory_quantity") ? !variants[0].inventory_quantity && showOptionOutOfStock : false;
|
|
1715
|
+
return cards ? /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: cards({
|
|
1716
|
+
product: {
|
|
1717
|
+
...product,
|
|
1718
|
+
...{
|
|
1719
|
+
variants: variants.map((variant, index2) => {
|
|
1720
|
+
const { inventory_quantity, ...otherObject } = variant || {};
|
|
1721
|
+
return {
|
|
1722
|
+
...otherObject,
|
|
1723
|
+
is_out_of_stock: Object.hasOwn(variants[index2], "inventory_quantity") ? !inventory_quantity : false
|
|
1724
|
+
};
|
|
1725
|
+
})
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
}) }, index) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card", children: [
|
|
1762
1729
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-content", children: [
|
|
1763
1730
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-image", children: [
|
|
1764
|
-
|
|
1731
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1765
1732
|
"a",
|
|
1766
1733
|
{
|
|
1767
1734
|
href: url,
|
|
@@ -1792,25 +1759,41 @@ const ProductCards = ({
|
|
|
1792
1759
|
/* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: (image == null ? void 0 : image.src) || "", alt: "sledge-product-card-image", loading: "lazy", onError: (event) => event.currentTarget.src = `${API_URL}/img/blank-image.png` })
|
|
1793
1760
|
]
|
|
1794
1761
|
}
|
|
1795
|
-
)
|
|
1796
|
-
isOutOfStock ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-out-of-stock",
|
|
1762
|
+
),
|
|
1763
|
+
isOutOfStock ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-out-of-stock", children: "Sold out" }) : null
|
|
1797
1764
|
] }),
|
|
1798
1765
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-desc", children: [
|
|
1799
1766
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-title", children: [
|
|
1800
|
-
|
|
1767
|
+
title ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1801
1768
|
"a",
|
|
1802
1769
|
{
|
|
1803
1770
|
href: url,
|
|
1804
1771
|
onClick: () => sourceApp === "instant-search" && productClickTrigger({
|
|
1805
1772
|
productId: id
|
|
1806
1773
|
}),
|
|
1807
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { style: display_product_name_style,
|
|
1774
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { style: display_product_name_style, children: title })
|
|
1808
1775
|
}
|
|
1809
|
-
)
|
|
1810
|
-
show_price
|
|
1776
|
+
) : null,
|
|
1777
|
+
show_price ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-price", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { style: display_price_style, children: [
|
|
1778
|
+
currency,
|
|
1779
|
+
price
|
|
1780
|
+
] }) }) : null
|
|
1781
|
+
] }),
|
|
1782
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-text", children: [
|
|
1783
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: variant_title }),
|
|
1784
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
1785
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: show_vendor ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
1786
|
+
"Vendor: ",
|
|
1787
|
+
vendor
|
|
1788
|
+
] }) : null }),
|
|
1789
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: " | " }),
|
|
1790
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: show_sku ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
1791
|
+
"SKU: ",
|
|
1792
|
+
sku
|
|
1793
|
+
] }) : null })
|
|
1794
|
+
] })
|
|
1811
1795
|
] }),
|
|
1812
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-
|
|
1813
|
-
productCardRating ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-rating", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1796
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-rating", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1814
1797
|
Rating,
|
|
1815
1798
|
{
|
|
1816
1799
|
data: {
|
|
@@ -1819,10 +1802,10 @@ const ProductCards = ({
|
|
|
1819
1802
|
size: "xs",
|
|
1820
1803
|
withSkeletonLoading: false
|
|
1821
1804
|
}
|
|
1822
|
-
) })
|
|
1805
|
+
) })
|
|
1823
1806
|
] })
|
|
1824
1807
|
] }),
|
|
1825
|
-
show_add_to_cart
|
|
1808
|
+
show_add_to_cart ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-button-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1826
1809
|
Button,
|
|
1827
1810
|
{
|
|
1828
1811
|
type: "button",
|
|
@@ -1833,7 +1816,6 @@ const ProductCards = ({
|
|
|
1833
1816
|
cursor: "wait"
|
|
1834
1817
|
}
|
|
1835
1818
|
},
|
|
1836
|
-
dangerouslySetInnerHTML: { __html: isLoadingAddToCart ? "Adding..." : isOutOfStock ? "Sold out" : productCardButtonAddToCart },
|
|
1837
1819
|
...isLoadingAddToCart || isOutOfStock ? {
|
|
1838
1820
|
disabled: true
|
|
1839
1821
|
} : {
|
|
@@ -1841,18 +1823,24 @@ const ProductCards = ({
|
|
|
1841
1823
|
id: variant_id,
|
|
1842
1824
|
quantity: 1
|
|
1843
1825
|
})
|
|
1844
|
-
}
|
|
1826
|
+
},
|
|
1827
|
+
children: isLoadingAddToCart ? "Adding..." : isOutOfStock ? "Sold out" : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
1828
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: 18, height: 18, viewBox: "0 0 18 18", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1829
|
+
"path",
|
|
1830
|
+
{
|
|
1831
|
+
fillRule: "evenodd",
|
|
1832
|
+
clipRule: "evenodd",
|
|
1833
|
+
d: "M8.83562 1.50023C10.796 1.50023 12.4155 2.99397 12.6152 4.90442L12.6709 4.90507C13.7584 4.90507 15.0806 5.62732 15.5269 7.65307L16.1186 12.2333C16.3309 13.7116 16.0654 14.8973 15.3281 15.7478C14.5946 16.5938 13.4336 17.0416 11.9704 17.0416H5.7094C4.10215 17.0416 2.9824 16.6478 2.28565 15.8386C1.5859 15.0271 1.3519 13.8098 1.5904 12.2213L2.1724 7.70182C2.5549 5.62957 3.95365 4.90507 5.03665 4.90507C5.13014 4.04293 5.51889 3.22275 6.13562 2.60797C6.84437 1.90372 7.82162 1.50023 8.81987 1.50023H8.83562ZM12.6709 6.03007H5.03665C4.7059 6.03007 3.6004 6.16357 3.28315 7.87657L2.70415 12.3766C2.5159 13.6388 2.6614 14.5523 3.13765 15.1051C3.6079 15.6511 4.4494 15.9166 5.7094 15.9166H11.9704C12.7564 15.9166 13.8296 15.7598 14.4776 15.0113C14.9921 14.4181 15.1691 13.5346 15.0041 12.3848L14.4199 7.84582C14.1709 6.72757 13.5139 6.03007 12.6709 6.03007ZM11.023 8.11815C11.3335 8.11815 11.6027 8.37015 11.6027 8.68065C11.6027 8.99115 11.368 9.24315 11.0575 9.24315H11.023C10.7125 9.24315 10.4605 8.99115 10.4605 8.68065C10.4605 8.37015 10.7125 8.11815 11.023 8.11815ZM6.65042 8.11815C6.96092 8.11815 7.23017 8.37015 7.23017 8.68065C7.23017 8.99115 6.99467 9.24315 6.68417 9.24315H6.65042C6.33992 9.24315 6.08792 8.99115 6.08792 8.68065C6.08792 8.37015 6.33992 8.11815 6.65042 8.11815ZM8.83337 2.62522H8.82212C8.11637 2.62522 7.42862 2.90947 6.92987 3.40522C6.5236 3.80967 6.25789 4.34137 6.17193 4.90472L11.4814 4.90493C11.2887 3.61626 10.1743 2.62522 8.83337 2.62522Z",
|
|
1834
|
+
fill: "#393D4E"
|
|
1835
|
+
}
|
|
1836
|
+
) }),
|
|
1837
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: language_button_add_to_cart ? language_button_add_to_cart : "Add To Cart" })
|
|
1838
|
+
] })
|
|
1845
1839
|
}
|
|
1846
1840
|
) }) : null
|
|
1847
1841
|
] }, index);
|
|
1848
1842
|
}) });
|
|
1849
1843
|
};
|
|
1850
|
-
const ProductGrid = ({ type, className = "", onAfterRenderProduct, ...otherProps }) => {
|
|
1851
|
-
React__default.useEffect(() => {
|
|
1852
|
-
onAfterRenderProduct && onAfterRenderProduct("success");
|
|
1853
|
-
}, []);
|
|
1854
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `sledge__product-grid ${className}`, "data-grid-type": type, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ProductCards, { ...otherProps }) });
|
|
1855
|
-
};
|
|
1856
1844
|
const TextAreaField = "";
|
|
1857
1845
|
const InputField = "";
|
|
1858
1846
|
const CollectionGrid$1 = "";
|
|
@@ -2195,7 +2183,14 @@ const SkeletonLoading = {
|
|
|
2195
2183
|
BlogGrid: SkeletonBlogGrid
|
|
2196
2184
|
};
|
|
2197
2185
|
const SearchIconWidget = (props) => {
|
|
2198
|
-
const { size = "sm",
|
|
2186
|
+
const { size = "sm", children, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct } = props || {};
|
|
2187
|
+
let productCardsComponent = null;
|
|
2188
|
+
React__default.Children.map(children, (child) => {
|
|
2189
|
+
if (React__default.isValidElement(child) && isFunction(child.type) && child.type.name === SEPARATE_COMPONENT_DISPLAY_NAME.PRODUCT.CARDS) {
|
|
2190
|
+
const { component } = (child == null ? void 0 : child.props) || {};
|
|
2191
|
+
productCardsComponent = component;
|
|
2192
|
+
}
|
|
2193
|
+
});
|
|
2199
2194
|
const { isRenderApp } = React__default.useContext(SledgeContext);
|
|
2200
2195
|
const [sizing, setSizing] = React__default.useState({
|
|
2201
2196
|
width: 0,
|
|
@@ -2223,7 +2218,7 @@ const SearchIconWidget = (props) => {
|
|
|
2223
2218
|
}, [isRenderApp]);
|
|
2224
2219
|
const handleShowWidget = () => {
|
|
2225
2220
|
if (typeof window !== "undefined" && window.sledgeInstantSearchIconWidgetPopup)
|
|
2226
|
-
window.sledgeInstantSearchIconWidgetPopup(
|
|
2221
|
+
window.sledgeInstantSearchIconWidgetPopup(onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct, productCardsComponent);
|
|
2227
2222
|
};
|
|
2228
2223
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__icon-widget", onClick: handleShowWidget, children: /* @__PURE__ */ jsxRuntimeExports.jsx(SearchIcon, { ...sizing, color: "currentColor" }) });
|
|
2229
2224
|
};
|
|
@@ -2249,9 +2244,9 @@ const SearchIconWidgetPopup = () => {
|
|
|
2249
2244
|
onAfterRemoveWishlist: (state) => {
|
|
2250
2245
|
},
|
|
2251
2246
|
onAfterRenderProduct: (state) => {
|
|
2252
|
-
}
|
|
2247
|
+
},
|
|
2248
|
+
productCardsComponent: null
|
|
2253
2249
|
});
|
|
2254
|
-
const [customProductCard, setCustomProductCard] = React__default.useState({});
|
|
2255
2250
|
const searchFieldRef = React__default.useRef(null);
|
|
2256
2251
|
const previousState = usePrevious({ keyword });
|
|
2257
2252
|
const handleMultiSearch = async (data, onSearch = false) => {
|
|
@@ -2335,19 +2330,20 @@ const SearchIconWidgetPopup = () => {
|
|
|
2335
2330
|
};
|
|
2336
2331
|
React__default.useEffect(() => {
|
|
2337
2332
|
if (typeof window !== "undefined") {
|
|
2338
|
-
window.sledgeInstantSearchIconWidgetPopup = (
|
|
2333
|
+
window.sledgeInstantSearchIconWidgetPopup = (onAfterAddToCart = () => {
|
|
2339
2334
|
}, onAfterAddWishlist = () => {
|
|
2340
2335
|
}, onAfterRemoveWishlist = () => {
|
|
2341
2336
|
}, onAfterRenderProduct = () => {
|
|
2337
|
+
}, productCardsComponent = () => {
|
|
2342
2338
|
}) => {
|
|
2343
2339
|
setShowInfo(true);
|
|
2344
2340
|
setHandleFunctions({
|
|
2345
2341
|
onAfterAddToCart,
|
|
2346
2342
|
onAfterAddWishlist,
|
|
2347
2343
|
onAfterRemoveWishlist,
|
|
2348
|
-
onAfterRenderProduct
|
|
2344
|
+
onAfterRenderProduct,
|
|
2345
|
+
productCardsComponent
|
|
2349
2346
|
});
|
|
2350
|
-
setCustomProductCard(customProductCard2);
|
|
2351
2347
|
setTimeout(() => {
|
|
2352
2348
|
if (searchFieldRef == null ? void 0 : searchFieldRef.current) {
|
|
2353
2349
|
searchFieldRef.current.focus();
|
|
@@ -2487,8 +2483,8 @@ const SearchIconWidgetPopup = () => {
|
|
|
2487
2483
|
show_sku: (_h = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _h.show_sku,
|
|
2488
2484
|
show_price: (_i = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _i.show_price
|
|
2489
2485
|
},
|
|
2490
|
-
customProductCard,
|
|
2491
2486
|
showOptionOutOfStock: true,
|
|
2487
|
+
cards: handleFunctions.productCardsComponent,
|
|
2492
2488
|
onAfterAddToCart: handleFunctions.onAfterAddToCart,
|
|
2493
2489
|
onAfterAddWishlist: handleFunctions.onAfterAddWishlist,
|
|
2494
2490
|
onAfterRemoveWishlist: handleFunctions.onAfterRemoveWishlist,
|
|
@@ -2528,8 +2524,8 @@ const SearchIconWidgetPopup = () => {
|
|
|
2528
2524
|
show_sku: (_p = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _p.show_sku,
|
|
2529
2525
|
show_price: (_q = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _q.show_price
|
|
2530
2526
|
},
|
|
2531
|
-
customProductCard,
|
|
2532
2527
|
showOptionOutOfStock: true,
|
|
2528
|
+
cards: handleFunctions.productCardsComponent,
|
|
2533
2529
|
onAfterAddToCart: handleFunctions.onAfterAddToCart,
|
|
2534
2530
|
onAfterAddWishlist: handleFunctions.onAfterAddWishlist,
|
|
2535
2531
|
onAfterRemoveWishlist: handleFunctions.onAfterRemoveWishlist,
|
|
@@ -2549,9 +2545,16 @@ const SearchIconWidgetPopup = () => {
|
|
|
2549
2545
|
const SearchResultWidget$1 = "";
|
|
2550
2546
|
const SearchResultWidget = (props) => {
|
|
2551
2547
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2552
|
-
const { layoutType = "default", query, data,
|
|
2548
|
+
const { layoutType = "default", query, data, children, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct } = props;
|
|
2553
2549
|
const { keyword: queryKeyword = "" } = query || {};
|
|
2554
2550
|
const { collectionId } = data || {};
|
|
2551
|
+
let productCardsComponent = null;
|
|
2552
|
+
React__default.Children.map(children, (child) => {
|
|
2553
|
+
if (React__default.isValidElement(child) && isFunction(child.type) && child.type.name === SEPARATE_COMPONENT_DISPLAY_NAME.PRODUCT.CARDS) {
|
|
2554
|
+
const { component } = (child == null ? void 0 : child.props) || {};
|
|
2555
|
+
productCardsComponent = component;
|
|
2556
|
+
}
|
|
2557
|
+
});
|
|
2555
2558
|
const { isRenderApp } = React__default.useContext(SledgeContext);
|
|
2556
2559
|
const [isFirstLoading, setIsFirstLoading] = React__default.useState(true);
|
|
2557
2560
|
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
@@ -3017,7 +3020,7 @@ const SearchResultWidget = (props) => {
|
|
|
3017
3020
|
defaultSort,
|
|
3018
3021
|
showOutOfStock,
|
|
3019
3022
|
data,
|
|
3020
|
-
|
|
3023
|
+
productCardsComponent,
|
|
3021
3024
|
onAfterAddToCart,
|
|
3022
3025
|
onAfterAddWishlist,
|
|
3023
3026
|
onAfterRemoveWishlist,
|
|
@@ -3047,12 +3050,12 @@ const ResultProduct = (props) => {
|
|
|
3047
3050
|
defaultSort,
|
|
3048
3051
|
showOutOfStock,
|
|
3049
3052
|
data,
|
|
3053
|
+
productCardsComponent,
|
|
3050
3054
|
setKeyword,
|
|
3051
3055
|
filterHorizontalSkeleton,
|
|
3052
3056
|
filterVerticalSkeleton,
|
|
3053
3057
|
productGridSkeleton,
|
|
3054
3058
|
searchAndSelectOptionSkeleton,
|
|
3055
|
-
customProductCard,
|
|
3056
3059
|
onAfterAddToCart,
|
|
3057
3060
|
onAfterAddWishlist,
|
|
3058
3061
|
onAfterRemoveWishlist,
|
|
@@ -3620,7 +3623,7 @@ const ResultProduct = (props) => {
|
|
|
3620
3623
|
show_sku: (_s = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _s.show_sku,
|
|
3621
3624
|
show_price: (_t = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _t.show_price
|
|
3622
3625
|
},
|
|
3623
|
-
|
|
3626
|
+
cards: productCardsComponent,
|
|
3624
3627
|
showOptionOutOfStock: true,
|
|
3625
3628
|
onAfterAddToCart,
|
|
3626
3629
|
onAfterAddWishlist,
|
|
@@ -3768,7 +3771,14 @@ const ResultEmpty = (props) => {
|
|
|
3768
3771
|
const SearchWidget$1 = "";
|
|
3769
3772
|
const SearchWidget = (props) => {
|
|
3770
3773
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
3771
|
-
const { width = "400px",
|
|
3774
|
+
const { width = "400px", children, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct } = props;
|
|
3775
|
+
let productCardsComponent = null;
|
|
3776
|
+
React__default.Children.map(children, (child) => {
|
|
3777
|
+
if (React__default.isValidElement(child) && isFunction(child.type) && child.type.name === SEPARATE_COMPONENT_DISPLAY_NAME.PRODUCT.CARDS) {
|
|
3778
|
+
const { component } = (child == null ? void 0 : child.props) || {};
|
|
3779
|
+
productCardsComponent = component;
|
|
3780
|
+
}
|
|
3781
|
+
});
|
|
3772
3782
|
const { isRenderApp } = React__default.useContext(SledgeContext);
|
|
3773
3783
|
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
3774
3784
|
const [keyword, setKeyword] = React__default.useState("");
|
|
@@ -3995,8 +4005,8 @@ const SearchWidget = (props) => {
|
|
|
3995
4005
|
show_sku: (_g = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _g.show_sku,
|
|
3996
4006
|
show_price: (_h = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _h.show_price
|
|
3997
4007
|
},
|
|
3998
|
-
customProductCard,
|
|
3999
4008
|
showOptionOutOfStock: true,
|
|
4009
|
+
cards: productCardsComponent,
|
|
4000
4010
|
onAfterAddToCart,
|
|
4001
4011
|
onAfterAddWishlist,
|
|
4002
4012
|
onAfterRemoveWishlist,
|
|
@@ -4037,8 +4047,8 @@ const SearchWidget = (props) => {
|
|
|
4037
4047
|
show_sku: (_o = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _o.show_sku,
|
|
4038
4048
|
show_price: (_p = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _p.show_price
|
|
4039
4049
|
},
|
|
4040
|
-
customProductCard,
|
|
4041
4050
|
showOptionOutOfStock: true,
|
|
4051
|
+
cards: productCardsComponent,
|
|
4042
4052
|
onAfterAddToCart,
|
|
4043
4053
|
onAfterAddWishlist,
|
|
4044
4054
|
onAfterRemoveWishlist,
|