@sledge-app/react-instant-search 1.0.30 → 1.0.31
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/SearchIconWidget/SearchIconWidgetPopup.d.ts.map +1 -1
- package/dist/components/SearchResultWidget/SearchResultWidget.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 +38 -31
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -148,7 +148,8 @@ const OBJECT_DATA_STRING_KEY = {
|
|
|
148
148
|
},
|
|
149
149
|
CURRENT_PAGE: "{{ current_page }}",
|
|
150
150
|
TOTAL_PAGE: "{{ total_page }}",
|
|
151
|
-
TOTAL_RESULT: "{{ total_result }}"
|
|
151
|
+
TOTAL_RESULT: "{{ total_result }}",
|
|
152
|
+
COLLECTION_NAME: "{{ collection_name }}"
|
|
152
153
|
};
|
|
153
154
|
const ELEMENT_ID = {
|
|
154
155
|
PRODUCT_REVIEW: {
|
|
@@ -3328,7 +3329,7 @@ const Global = {
|
|
|
3328
3329
|
SearchViewMoreResult
|
|
3329
3330
|
};
|
|
3330
3331
|
const SearchIconWidgetPopup = () => {
|
|
3331
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
3332
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
3332
3333
|
const { isRenderApp } = React__default.useContext(SledgeContext);
|
|
3333
3334
|
const { instantSearch: isRenderAppInstantSearch } = isRenderApp || {};
|
|
3334
3335
|
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
@@ -3341,6 +3342,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
3341
3342
|
const [suggestionSettings, setSuggestionSettings] = React__default.useState({});
|
|
3342
3343
|
const [suggestionIndex, setSuggestionIndex] = React__default.useState("");
|
|
3343
3344
|
const [urlSearchResult, setUrlSearchResult] = React__default.useState("");
|
|
3345
|
+
const [languageSettings, setLanguageSettings] = React__default.useState({});
|
|
3344
3346
|
const [handleFunctions, setHandleFunctions] = React__default.useState({
|
|
3345
3347
|
onAfterAddToCart: (state) => {
|
|
3346
3348
|
},
|
|
@@ -3429,9 +3431,10 @@ const SearchIconWidgetPopup = () => {
|
|
|
3429
3431
|
response = JSON.parse(LOCAL_STORAGE_INSTANT_SEARCH_SETTING);
|
|
3430
3432
|
if (!response)
|
|
3431
3433
|
return;
|
|
3432
|
-
const { display } = response;
|
|
3434
|
+
const { display, languages } = response;
|
|
3433
3435
|
setDisplaySettings(display);
|
|
3434
3436
|
setSuggestionSettings((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion);
|
|
3437
|
+
setLanguageSettings(languages);
|
|
3435
3438
|
await handleMultiSearch({
|
|
3436
3439
|
data: response,
|
|
3437
3440
|
withFetchReviewInfo: true
|
|
@@ -3505,7 +3508,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
3505
3508
|
{
|
|
3506
3509
|
type: "text",
|
|
3507
3510
|
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(SearchIcon, { width: 20, height: 20, color: "#000000" }),
|
|
3508
|
-
placeholder: "Search anything...",
|
|
3511
|
+
placeholder: ((_b = languageSettings == null ? void 0 : languageSettings.search_form_placeholder) == null ? void 0 : _b.widget) || "Search anything...",
|
|
3509
3512
|
value: keyword,
|
|
3510
3513
|
fieldRef: searchFieldRef,
|
|
3511
3514
|
onChange: ({ value }) => setKeyword(value),
|
|
@@ -3564,7 +3567,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
3564
3567
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-search-form-result-flex-item-product", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.ProductGrid, { count: 6, type: "medium" }) })
|
|
3565
3568
|
] }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollArea, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-search-form-result-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__icon-widget-search-form-result-flex", children: [
|
|
3566
3569
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__icon-widget-search-form-result-flex-item-other", children: [
|
|
3567
|
-
Object.keys(suggestionSettings).length && ((
|
|
3570
|
+
Object.keys(suggestionSettings).length && ((_d = (_c = suggestionSettings[suggestionIndex]) == null ? void 0 : _c.keywords) == null ? void 0 : _d.active) && ((_g = (_f = (_e = suggestionSettings[suggestionIndex]) == null ? void 0 : _e.keywords) == null ? void 0 : _f.list) == null ? void 0 : _g.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3568
3571
|
Global.SuggestionKeywordLists,
|
|
3569
3572
|
{
|
|
3570
3573
|
listsComponent: handleFunctions.suggestionKeywordListsComponent,
|
|
@@ -3605,9 +3608,9 @@ const SearchIconWidgetPopup = () => {
|
|
|
3605
3608
|
};
|
|
3606
3609
|
}),
|
|
3607
3610
|
setting: {
|
|
3608
|
-
show_vendor: (
|
|
3609
|
-
show_sku: (
|
|
3610
|
-
show_price: (
|
|
3611
|
+
show_vendor: (_h = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _h.show_vendor,
|
|
3612
|
+
show_sku: (_i = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _i.show_sku,
|
|
3613
|
+
show_price: (_j = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _j.show_price
|
|
3611
3614
|
},
|
|
3612
3615
|
showOptionOutOfStock: true,
|
|
3613
3616
|
isComponentJsVersion: handleFunctions.isJsVersion,
|
|
@@ -3620,7 +3623,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
3620
3623
|
setShowPopupComponent: setShowInfo,
|
|
3621
3624
|
dataReviews
|
|
3622
3625
|
}
|
|
3623
|
-
) }) : Object.keys(suggestionSettings).length && ((
|
|
3626
|
+
) }) : Object.keys(suggestionSettings).length && ((_l = (_k = suggestionSettings[suggestionIndex]) == null ? void 0 : _k.products) == null ? void 0 : _l.active) && ((_o = (_n = (_m = suggestionSettings[suggestionIndex]) == null ? void 0 : _m.products) == null ? void 0 : _n.list) == null ? void 0 : _o.length) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3624
3627
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__icon-widget-search-form-result-product-suggestion-no-result-text", children: [
|
|
3625
3628
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Sorry" }),
|
|
3626
3629
|
", nothing found for ",
|
|
@@ -3640,9 +3643,9 @@ const SearchIconWidgetPopup = () => {
|
|
|
3640
3643
|
};
|
|
3641
3644
|
}),
|
|
3642
3645
|
setting: {
|
|
3643
|
-
show_vendor: (
|
|
3644
|
-
show_sku: (
|
|
3645
|
-
show_price: (
|
|
3646
|
+
show_vendor: (_p = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _p.show_vendor,
|
|
3647
|
+
show_sku: (_q = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _q.show_sku,
|
|
3648
|
+
show_price: (_r = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _r.show_price
|
|
3646
3649
|
},
|
|
3647
3650
|
showOptionOutOfStock: true,
|
|
3648
3651
|
isComponentJsVersion: handleFunctions.isJsVersion,
|
|
@@ -3659,7 +3662,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
3659
3662
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-search-form-result-title", children: "Products" }),
|
|
3660
3663
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-search-form-result-item-disabled", children: "No product were found" })
|
|
3661
3664
|
] }),
|
|
3662
|
-
(searchResultProduct == null ? void 0 : searchResultProduct.length) || Object.keys(suggestionSettings).length && ((
|
|
3665
|
+
(searchResultProduct == null ? void 0 : searchResultProduct.length) || Object.keys(suggestionSettings).length && ((_t = (_s = suggestionSettings[suggestionIndex]) == null ? void 0 : _s.products) == null ? void 0 : _t.active) && ((_w = (_v = (_u = suggestionSettings[suggestionIndex]) == null ? void 0 : _u.products) == null ? void 0 : _v.list) == null ? void 0 : _w.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-button-more-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3663
3666
|
Global.SearchViewMoreResult,
|
|
3664
3667
|
{
|
|
3665
3668
|
component: handleFunctions.searchViewMoreResultComponent,
|
|
@@ -4163,6 +4166,7 @@ const SearchResultWidget = (props) => {
|
|
|
4163
4166
|
] })
|
|
4164
4167
|
] })
|
|
4165
4168
|
] }) : React__default.cloneElement(resultComponent, {
|
|
4169
|
+
layoutType,
|
|
4166
4170
|
isLoading,
|
|
4167
4171
|
keyword,
|
|
4168
4172
|
clickedTabIndexId,
|
|
@@ -4218,6 +4222,7 @@ const SearchResultWidget = (props) => {
|
|
|
4218
4222
|
const ResultProduct = (props) => {
|
|
4219
4223
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
|
|
4220
4224
|
const {
|
|
4225
|
+
layoutType,
|
|
4221
4226
|
keyword,
|
|
4222
4227
|
clickedTabIndexId,
|
|
4223
4228
|
isLoadingSetting,
|
|
@@ -4329,7 +4334,8 @@ const ResultProduct = (props) => {
|
|
|
4329
4334
|
add_to_cart: language_add_to_cart,
|
|
4330
4335
|
filter: language_filter,
|
|
4331
4336
|
clear_filter: language_clear_filter,
|
|
4332
|
-
pagination_info: language_pagination_info
|
|
4337
|
+
pagination_info: language_pagination_info,
|
|
4338
|
+
total_result_text: language_total_result_text
|
|
4333
4339
|
} = languageSettings || {};
|
|
4334
4340
|
const filter_title_style = {
|
|
4335
4341
|
...filter_title_color && { color: filter_title_color },
|
|
@@ -5043,7 +5049,7 @@ const ResultCategory = (props) => {
|
|
|
5043
5049
|
const [totalSearchResult, setTotalSearchResult] = React__default.useState(0);
|
|
5044
5050
|
const [summaryText, setSummaryText] = React__default.useState(null);
|
|
5045
5051
|
const previousState = usePrevious({ keyword, clickedTabIndexId });
|
|
5046
|
-
const { pagination_info: language_pagination_info } = languageSettings || {};
|
|
5052
|
+
const { pagination_info: language_pagination_info, search_form_placeholder: language_search_form_placeholder } = languageSettings || {};
|
|
5047
5053
|
const handleSearchResultData = (result) => {
|
|
5048
5054
|
if (!result)
|
|
5049
5055
|
return;
|
|
@@ -5118,7 +5124,7 @@ const ResultCategory = (props) => {
|
|
|
5118
5124
|
{
|
|
5119
5125
|
type: "text",
|
|
5120
5126
|
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(SearchIcon, { width: 18, height: 18, color: "#868686" }),
|
|
5121
|
-
placeholder: `Search ${clickedTabIndexName ? clickedTabIndexName.toLowerCase() : ""}...`,
|
|
5127
|
+
placeholder: clickedTabIndexType && language_search_form_placeholder[clickedTabIndexType] ? language_search_form_placeholder[clickedTabIndexType] : `Search ${clickedTabIndexName ? clickedTabIndexName.toLowerCase() : ""}...`,
|
|
5122
5128
|
value: keyword,
|
|
5123
5129
|
onChange: ({ value }) => setKeyword && setKeyword(value),
|
|
5124
5130
|
onResetField: () => setKeyword && setKeyword(""),
|
|
@@ -5172,7 +5178,7 @@ const ResultEmpty = (props) => {
|
|
|
5172
5178
|
] });
|
|
5173
5179
|
};
|
|
5174
5180
|
const SearchWidget = (props) => {
|
|
5175
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
5181
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
5176
5182
|
const { isRenderApp, isJsVersion } = React__default.useContext(SledgeContext);
|
|
5177
5183
|
const { instantSearch: isRenderAppInstantSearch } = isRenderApp || {};
|
|
5178
5184
|
const { width = "400px", children, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct, urlSearchResult, query } = props;
|
|
@@ -5201,6 +5207,7 @@ const SearchWidget = (props) => {
|
|
|
5201
5207
|
const [suggestionSettings, setSuggestionSettings] = React__default.useState({});
|
|
5202
5208
|
const [suggestionIndex, setSuggestionIndex] = React__default.useState("");
|
|
5203
5209
|
const [showSearchResult, setShowSearchResult] = React__default.useState(false);
|
|
5210
|
+
const [languageSettings, setLanguageSettings] = React__default.useState({});
|
|
5204
5211
|
const previousState = usePrevious({ keyword });
|
|
5205
5212
|
const searchFieldRef = React__default.useRef(null);
|
|
5206
5213
|
const handleMultiSearch = async (data, onSearch = false) => {
|
|
@@ -5261,16 +5268,16 @@ const SearchWidget = (props) => {
|
|
|
5261
5268
|
};
|
|
5262
5269
|
const handleSettings = async (LOCAL_STORAGE_INSTANT_SEARCH_SETTING) => {
|
|
5263
5270
|
var _a2;
|
|
5264
|
-
if (!keyword.length)
|
|
5265
|
-
return;
|
|
5266
5271
|
let response;
|
|
5267
5272
|
response = JSON.parse(LOCAL_STORAGE_INSTANT_SEARCH_SETTING);
|
|
5268
5273
|
if (!response)
|
|
5269
5274
|
return;
|
|
5270
|
-
const { display } = response;
|
|
5275
|
+
const { display, languages } = response;
|
|
5271
5276
|
setDisplaySettings(display);
|
|
5272
5277
|
setSuggestionSettings((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion);
|
|
5273
|
-
|
|
5278
|
+
setLanguageSettings(languages);
|
|
5279
|
+
if (keyword.length)
|
|
5280
|
+
await handleMultiSearch(response);
|
|
5274
5281
|
};
|
|
5275
5282
|
React__default.useEffect(() => {
|
|
5276
5283
|
if (!isRenderAppInstantSearch)
|
|
@@ -5305,7 +5312,7 @@ const SearchWidget = (props) => {
|
|
|
5305
5312
|
type: "text",
|
|
5306
5313
|
fieldRef: searchFieldRef,
|
|
5307
5314
|
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(SearchIcon, { width: 18, height: 18, color: "#868686" }),
|
|
5308
|
-
placeholder: "Search anything",
|
|
5315
|
+
placeholder: ((_a = languageSettings == null ? void 0 : languageSettings.search_form_placeholder) == null ? void 0 : _a.widget) || "Search anything...",
|
|
5309
5316
|
value: keyword,
|
|
5310
5317
|
onChange: ({ value }) => setKeyword(value),
|
|
5311
5318
|
onKeyDown: (event) => {
|
|
@@ -5367,7 +5374,7 @@ const SearchWidget = (props) => {
|
|
|
5367
5374
|
] }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollArea, { isLoading, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
5368
5375
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__widget-search-form-result-flex", children: [
|
|
5369
5376
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__widget-search-form-result-flex-item-other", children: [
|
|
5370
|
-
Object.keys(suggestionSettings).length && ((
|
|
5377
|
+
Object.keys(suggestionSettings).length && ((_c = (_b = suggestionSettings[suggestionIndex]) == null ? void 0 : _b.keywords) == null ? void 0 : _c.active) && ((_f = (_e = (_d = suggestionSettings[suggestionIndex]) == null ? void 0 : _d.keywords) == null ? void 0 : _e.list) == null ? void 0 : _f.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5371
5378
|
Global.SuggestionKeywordLists,
|
|
5372
5379
|
{
|
|
5373
5380
|
listsComponent: suggestionKeywordListsComponent,
|
|
@@ -5397,9 +5404,9 @@ const SearchWidget = (props) => {
|
|
|
5397
5404
|
};
|
|
5398
5405
|
}),
|
|
5399
5406
|
setting: {
|
|
5400
|
-
show_vendor: (
|
|
5401
|
-
show_sku: (
|
|
5402
|
-
show_price: (
|
|
5407
|
+
show_vendor: (_g = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _g.show_vendor,
|
|
5408
|
+
show_sku: (_h = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _h.show_sku,
|
|
5409
|
+
show_price: (_i = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _i.show_price
|
|
5403
5410
|
},
|
|
5404
5411
|
showOptionOutOfStock: true,
|
|
5405
5412
|
isComponentJsVersion: isJsVersion,
|
|
@@ -5409,7 +5416,7 @@ const SearchWidget = (props) => {
|
|
|
5409
5416
|
onAfterRemoveWishlist,
|
|
5410
5417
|
onAfterRenderProduct
|
|
5411
5418
|
}
|
|
5412
|
-
) }) : Object.keys(suggestionSettings).length && ((
|
|
5419
|
+
) }) : Object.keys(suggestionSettings).length && ((_k = (_j = suggestionSettings[suggestionIndex]) == null ? void 0 : _j.products) == null ? void 0 : _k.active) && ((_n = (_m = (_l = suggestionSettings[suggestionIndex]) == null ? void 0 : _l.products) == null ? void 0 : _m.list) == null ? void 0 : _n.length) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
5413
5420
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__widget-search-form-result-product-suggestion-no-result-text", children: [
|
|
5414
5421
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Sorry, nothing found for" }),
|
|
5415
5422
|
" ",
|
|
@@ -5430,9 +5437,9 @@ const SearchWidget = (props) => {
|
|
|
5430
5437
|
};
|
|
5431
5438
|
}),
|
|
5432
5439
|
setting: {
|
|
5433
|
-
show_vendor: (
|
|
5434
|
-
show_sku: (
|
|
5435
|
-
show_price: (
|
|
5440
|
+
show_vendor: (_o = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _o.show_vendor,
|
|
5441
|
+
show_sku: (_p = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _p.show_sku,
|
|
5442
|
+
show_price: (_q = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _q.show_price
|
|
5436
5443
|
},
|
|
5437
5444
|
showOptionOutOfStock: true,
|
|
5438
5445
|
isComponentJsVersion: isJsVersion,
|
|
@@ -5446,7 +5453,7 @@ const SearchWidget = (props) => {
|
|
|
5446
5453
|
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__widget-search-form-result-product-disabled", children: "No product were found" })
|
|
5447
5454
|
] })
|
|
5448
5455
|
] }),
|
|
5449
|
-
(searchResultProduct == null ? void 0 : searchResultProduct.length) || Object.keys(suggestionSettings).length && ((
|
|
5456
|
+
(searchResultProduct == null ? void 0 : searchResultProduct.length) || Object.keys(suggestionSettings).length && ((_s = (_r = suggestionSettings[suggestionIndex]) == null ? void 0 : _r.products) == null ? void 0 : _s.active) && ((_v = (_u = (_t = suggestionSettings[suggestionIndex]) == null ? void 0 : _t.products) == null ? void 0 : _u.list) == null ? void 0 : _v.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__widget-button-more-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5450
5457
|
Global.SearchViewMoreResult,
|
|
5451
5458
|
{
|
|
5452
5459
|
component: searchViewMoreResultComponent,
|