@usereactify/search 5.59.0-beta.3 → 5.59.0-beta.4
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/CHANGELOG.md +7 -0
- package/dist/package.json +5 -4
- package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.d.ts +2 -2
- package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.js +21 -40
- package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.js.map +1 -1
- package/dist/src/components/Result/Results.js +4 -7
- package/dist/src/components/Result/Results.js.map +1 -1
- package/dist/src/components/Sensor/SensorCollection.js +0 -1
- package/dist/src/components/Sensor/SensorCollection.js.map +1 -1
- package/dist/src/components/Sensor/SensorCuratedPageCollection.js +0 -1
- package/dist/src/components/Sensor/SensorCuratedPageCollection.js.map +1 -1
- package/dist/src/components/Sensor/index.d.ts +1 -1
- package/dist/src/components/Sensor/index.js +5 -2
- package/dist/src/components/Sensor/index.js.map +1 -1
- package/dist/src/components/Suggestions/Suggestions.js +2 -1
- package/dist/src/components/Suggestions/Suggestions.js.map +1 -1
- package/dist/src/utility/curation.js +36 -33
- package/dist/src/utility/curation.js.map +1 -1
- package/dist/src/utility/filters.js +6 -3
- package/dist/src/utility/filters.js.map +1 -1
- package/dist/src/utility/props.d.ts +2 -2
- package/dist/src/utility/props.js +16 -19
- package/dist/src/utility/props.js.map +1 -1
- package/dist/src/utility/sortOption.js +64 -129
- package/dist/src/utility/sortOption.js.map +1 -1
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [5.59.0-beta.4](https://bitbucket.org/usereactify/reactify-search-ui/compare/beta-v5.59.0-beta.3...beta-v5.59.0-beta.4) (2025-07-11)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* update filters, sort and others components for new modes ([db29026](https://bitbucket.org/usereactify/reactify-search-ui/commit/db29026ced05522e5d67aaf55d2414b383cd9615))
|
|
11
|
+
|
|
5
12
|
## [5.59.0-beta.3](https://bitbucket.org/usereactify/reactify-search-ui/compare/beta-v5.59.0-beta.2...beta-v5.59.0-beta.3) (2025-07-09)
|
|
6
13
|
|
|
7
14
|
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usereactify/search",
|
|
3
3
|
"description": "React UI library for Reactify Search",
|
|
4
|
-
"version": "5.59.0-beta.
|
|
4
|
+
"version": "5.59.0-beta.4",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
7
7
|
"types": "dist/src/index.d.ts",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
]
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@appbaseio/reactivecore": "9.8.0",
|
|
33
32
|
"@usereactify/search-internals": "1.0.0",
|
|
33
|
+
"@appbaseio/reactivecore": "9.15.2",
|
|
34
34
|
"ahooks": "2.10.11",
|
|
35
|
-
"axios": "
|
|
35
|
+
"axios": "1.10.0",
|
|
36
36
|
"currency.js": "2.0.4",
|
|
37
37
|
"debug": "4.3.2",
|
|
38
38
|
"ga-gtag": "1.1.5",
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"react-slider": "2.0.4"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"react": "
|
|
43
|
+
"react": "^18.2.0",
|
|
44
|
+
"react-dom": "^18.2.0"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@babel/plugin-transform-typescript": "7.18.12",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { PropsWithChildren, ReactNode } from "react";
|
|
2
2
|
import { Config } from "../../types";
|
|
3
3
|
export type ReactifySearchProviderProps = {
|
|
4
4
|
/** Standard react children */
|
|
5
|
-
children?:
|
|
5
|
+
children?: ReactNode | undefined;
|
|
6
6
|
/** The search area the provider will be used in */
|
|
7
7
|
mode: "search" | "collection" | "instant-search" | "curated-page";
|
|
8
8
|
/** The variation of the search area the provider will be used in */
|
|
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.ReactifySearchProvider = ReactifySearchProvider;
|
|
30
|
-
const react_1 =
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
31
|
// @ts-expect-error missing types
|
|
32
32
|
const GaGtag = __importStar(require("ga-gtag"));
|
|
33
33
|
const package_json_1 = __importDefault(require("../../../package.json"));
|
|
@@ -36,7 +36,7 @@ const components_1 = require("../../components");
|
|
|
36
36
|
const utility_1 = require("../../utility");
|
|
37
37
|
const curation_1 = require("../../utility/curation");
|
|
38
38
|
function ReactifySearchProvider(props) {
|
|
39
|
-
react_1.
|
|
39
|
+
(0, react_1.useEffect)(() => {
|
|
40
40
|
utility_1.debug.log("ReactifySearchProvider", "props", props);
|
|
41
41
|
GaGtag.install("G-DV00Z0X5VP", {
|
|
42
42
|
cookie_prefix: "_rs",
|
|
@@ -51,62 +51,44 @@ function ReactifySearchProvider(props) {
|
|
|
51
51
|
function ReactifySearchInner(props) {
|
|
52
52
|
var _a, _b;
|
|
53
53
|
const { config } = (0, hooks_1.useConfig)(props.shopifyPermanentDomain, (_a = props.preload) === null || _a === void 0 ? void 0 : _a.config);
|
|
54
|
-
const theme = (_b = props.theme) !== null && _b !== void 0 ? _b : {
|
|
55
|
-
typography: {
|
|
56
|
-
fontFamily: "inherit",
|
|
57
|
-
fontSize: "inherit",
|
|
58
|
-
},
|
|
59
|
-
};
|
|
54
|
+
const theme = (_b = props.theme) !== null && _b !== void 0 ? _b : { typography: { fontFamily: "inherit", fontSize: "inherit" } };
|
|
60
55
|
// search term
|
|
61
|
-
const [searchTerm, setSearchTerm] = react_1.
|
|
62
|
-
|
|
63
|
-
const
|
|
56
|
+
const [searchTerm, setSearchTerm] = (0, react_1.useState)("");
|
|
57
|
+
const [showInstantSearchResults, setShowInstantSearchResults] = (0, react_1.useState)(false);
|
|
58
|
+
const [sortOption, setSortOption] = (0, react_1.useState)("");
|
|
59
|
+
const [indexFromURL, setIndexFromURL] = (0, react_1.useState)(null);
|
|
60
|
+
const searchRedirect = (0, react_1.useMemo)(() => {
|
|
64
61
|
return config === null || config === void 0 ? void 0 : config.redirects.find((redirect) => redirect.query.trim().toLowerCase() === searchTerm.trim().toLowerCase());
|
|
65
62
|
}, [config === null || config === void 0 ? void 0 : config.redirects, searchTerm]);
|
|
66
|
-
// show instant-search
|
|
67
|
-
const [showInstantSearchResults, setShowInstantSearchResults] = react_1.default.useState(false);
|
|
68
|
-
// sort option
|
|
69
|
-
const [sortOption, setSortOption] = react_1.default.useState("");
|
|
70
|
-
// index from URL
|
|
71
|
-
const [indexFromURL, setIndexFromURL] = react_1.default.useState(null);
|
|
72
63
|
// hydration-safe URL param initialization
|
|
73
|
-
react_1.
|
|
64
|
+
(0, react_1.useEffect)(() => {
|
|
74
65
|
if (typeof window !== "undefined") {
|
|
75
66
|
const urlParams = new URLSearchParams(window.location.search);
|
|
76
67
|
const searchTermFromURL = urlParams.get("q");
|
|
77
68
|
const searchSortFromURL = urlParams.get("sort");
|
|
78
69
|
const indexFromURLParam = urlParams.get("index");
|
|
79
|
-
if (searchTermFromURL && searchTermFromURL !== searchTerm)
|
|
70
|
+
if (searchTermFromURL && searchTermFromURL !== searchTerm)
|
|
80
71
|
setSearchTerm(searchTermFromURL);
|
|
81
|
-
|
|
82
|
-
if (searchSortFromURL && searchSortFromURL !== sortOption) {
|
|
72
|
+
if (searchSortFromURL && searchSortFromURL !== sortOption)
|
|
83
73
|
setSortOption(searchSortFromURL);
|
|
84
|
-
|
|
85
|
-
if (indexFromURLParam) {
|
|
74
|
+
if (indexFromURLParam)
|
|
86
75
|
setIndexFromURL(indexFromURLParam);
|
|
87
|
-
}
|
|
88
76
|
}
|
|
89
77
|
}, []);
|
|
90
78
|
// results
|
|
91
|
-
const [results, setResults] = react_1.
|
|
79
|
+
const [results, setResults] = (0, react_1.useState)([]);
|
|
92
80
|
// curation
|
|
93
|
-
const curation = react_1.
|
|
94
|
-
if (!config)
|
|
81
|
+
const curation = (0, react_1.useMemo)(() => {
|
|
82
|
+
if (!config)
|
|
95
83
|
return undefined;
|
|
96
|
-
}
|
|
97
|
-
return (0, curation_1.getCuration)({
|
|
98
|
-
provider: props,
|
|
99
|
-
config: config,
|
|
100
|
-
searchTerm: searchTerm,
|
|
101
|
-
});
|
|
84
|
+
return (0, curation_1.getCuration)({ provider: props, config: config, searchTerm: searchTerm });
|
|
102
85
|
}, [props, config, searchTerm]);
|
|
103
86
|
// result stats
|
|
104
|
-
const [resultStats, setResultStats] = react_1.
|
|
105
|
-
const contextValue = react_1.
|
|
87
|
+
const [resultStats, setResultStats] = (0, react_1.useState)();
|
|
88
|
+
const contextValue = (0, react_1.useMemo)(() => {
|
|
106
89
|
var _a, _b, _c;
|
|
107
|
-
if (!config)
|
|
90
|
+
if (!config)
|
|
108
91
|
return;
|
|
109
|
-
}
|
|
110
92
|
return {
|
|
111
93
|
config: config,
|
|
112
94
|
options: Object.assign(Object.assign({}, props), { clientId: (_a = props.clientId) !== null && _a !== void 0 ? _a : "theme", index: (_c = (_b = props.index) !== null && _b !== void 0 ? _b : indexFromURL) !== null && _c !== void 0 ? _c : config.index, filtersHandle: props.filtersHandle, credentials: props.credentials, theme: theme }),
|
|
@@ -140,14 +122,13 @@ function ReactifySearchInner(props) {
|
|
|
140
122
|
resultStats,
|
|
141
123
|
curation,
|
|
142
124
|
]);
|
|
143
|
-
react_1.
|
|
125
|
+
(0, react_1.useEffect)(() => {
|
|
144
126
|
utility_1.debug.log("curation", "content", curation);
|
|
145
127
|
}, [curation === null || curation === void 0 ? void 0 : curation.id]);
|
|
146
128
|
utility_1.debug.hook("ReactifySearchProvider", "context", contextValue);
|
|
147
129
|
if (!contextValue) {
|
|
148
|
-
if (props.renderBooting)
|
|
130
|
+
if (props.renderBooting)
|
|
149
131
|
return props.renderBooting();
|
|
150
|
-
}
|
|
151
132
|
return null;
|
|
152
133
|
}
|
|
153
134
|
return (react_1.default.createElement(hooks_1.ReactifySearchContext.Provider, { value: contextValue },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactifySearchProvider.js","sourceRoot":"","sources":["../../../../src/components/ReactifySearchProvider/ReactifySearchProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EA,wDAcC;AAxFD,kDAAiD;AACjD,iCAAiC;AACjC,gDAAkC;AAElC,yEAAwC;AAExC,uCAA+D;AAC/D,iDAAoE;AACpE,2CAAsC;AAEtC,qDAAqD;AAgErD,SAAgB,sBAAsB,CAAC,KAAqD;IAC1F,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,eAAK,CAAC,GAAG,CAAC,wBAAwB,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAEpD,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE;YAC7B,aAAa,EAAE,KAAK;YACpB,eAAe,EAAE;gBACf,IAAI,EAAE,KAAK,CAAC,sBAAsB;gBAClC,OAAO,EAAE,sBAAG,CAAC,OAAO;aACrB;SACF,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,8BAAC,mBAAmB,oBAAK,KAAK,EAAI,CAAC;AAC5C,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAqD;;IAChF,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,iBAAS,EAAC,KAAK,CAAC,sBAAsB,EAAE,MAAA,KAAK,CAAC,OAAO,0CAAE,MAAM,CAAC,CAAC;IAElF,MAAM,KAAK,GAAG,MA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,8BAAC,6CAAgC,QAAE,KAAK,CAAC,QAAQ,CAAoC,CACtD,CAClC,CAAC;AACJ,CAAC","sourcesContent":["import React, { PropsWithChildren } from \"react\";\n// @ts-expect-error missing types\nimport * as GaGtag from \"ga-gtag\";\n\nimport pkg from \"../../../package.json\";\n\nimport { ReactifySearchContext, useConfig } from \"../../hooks\";\nimport { UtilityAuthenticatedReactiveBase } from \"../../components\";\nimport { debug } from \"../../utility\";\nimport { Config, ConfigCuration, ConfigRedirect, ReactivesearchResultProps } from \"../../types\";\nimport { getCuration } from \"../../utility/curation\";\n\nexport type ReactifySearchProviderProps = {\n /** Standard react children */\n children?: React.ReactNode | undefined;\n /** The search area the provider will be used in */\n mode: \"search\" | \"collection\" | \"instant-search\" | \"curated-page\";\n /** The variation of the search area the provider will be used in */\n /** Shopify store domain used to resolve the site configuration */\n shopifyPermanentDomain: string;\n /** Market ID used to change merchandising based on market e.g. 7494533198 */\n market?: string;\n /** Callback function for redirects, suitable for headless sites to avoid full page refresh */\n onRedirect?: (type: \"redirect\" | \"search\", url: string) => void;\n /** Render method to display a component when the config is loading */\n renderBooting?: () => JSX.Element | null;\n /** Advanced usage: Override the default Reactify Search id (for telemetry) */\n clientId?: string;\n /** Advanced usage: Override the default Filters selection logic */\n filtersHandle?: string;\n /** Advanced usage: Array of additional component IDs managed outside of Reactify Search */\n additionalComponentIds?: Array<string>;\n /** Advanced usage: Override the default Elasticsearch index */\n index?: string;\n /** Advanced usage: Override the default Reactify Search config (for multi-instance stores) */\n configId?: string;\n /** Advanced usage: Override the default Elasticsearch credentials */\n credentials?: string;\n /** Advanced usage: Override the default ReactiveBase theme */\n theme?: Record<string, unknown>;\n /** Advanced usage: Fields to include in the Elasticsearch response e.g. [\"title\"] */\n includeFields?: Array<string>;\n /** Advanced usage: Fields to exclude from the Elasticsearch response e.g. [\"variant_skus\", \"*price*\"] */\n excludeFields?: Array<string>;\n /** Advanced usage: Server content for SSR */\n query?: Record<string, string>;\n preload?: {\n config: Config;\n state: unknown;\n };\n} & (\n | {\n mode: \"search\";\n }\n | {\n mode: \"collection\";\n /** Collection object that includes the handle, used to find curations */\n collectionHandle: string;\n }\n | { mode: \"instant-search\" }\n | {\n mode: \"curated-page\";\n variation: \"collection\";\n /** Handle of the collection. The same from Shopify. */\n handle: string;\n }\n | {\n mode: \"curated-page\";\n variation: \"search\";\n /** The merchandising search term from the Shopify App. */\n searchTerm: string;\n }\n);\n\nexport function ReactifySearchProvider(props: PropsWithChildren<ReactifySearchProviderProps>) {\n React.useEffect(() => {\n debug.log(\"ReactifySearchProvider\", \"props\", props);\n\n GaGtag.install(\"G-DV00Z0X5VP\", {\n cookie_prefix: \"_rs\",\n user_properties: {\n shop: props.shopifyPermanentDomain,\n version: pkg.version,\n },\n });\n }, [props]);\n\n return <ReactifySearchInner {...props} />;\n}\n\nfunction ReactifySearchInner(props: PropsWithChildren<ReactifySearchProviderProps>) {\n const { config } = useConfig(props.shopifyPermanentDomain, props.preload?.config);\n\n const theme = props.theme ?? {\n typography: {\n fontFamily: \"inherit\",\n fontSize: \"inherit\",\n },\n };\n\n // search term\n const [searchTerm, setSearchTerm] = React.useState<string>(\"\");\n // search term redirect\n const searchRedirect = React.useMemo<ConfigRedirect | undefined>(() => {\n return config?.redirects.find(\n (redirect) => redirect.query.trim().toLowerCase() === searchTerm.trim().toLowerCase()\n );\n }, [config?.redirects, searchTerm]);\n // show instant-search\n const [showInstantSearchResults, setShowInstantSearchResults] = React.useState<boolean>(false);\n // sort option\n const [sortOption, setSortOption] = React.useState<string>(\"\");\n // index from URL\n const [indexFromURL, setIndexFromURL] = React.useState<string | null>(null);\n\n // hydration-safe URL param initialization\n React.useEffect(() => {\n if (typeof window !== \"undefined\") {\n const urlParams = new URLSearchParams(window.location.search);\n const searchTermFromURL = urlParams.get(\"q\");\n const searchSortFromURL = urlParams.get(\"sort\");\n const indexFromURLParam = urlParams.get(\"index\");\n \n if (searchTermFromURL && searchTermFromURL !== searchTerm) {\n setSearchTerm(searchTermFromURL);\n }\n if (searchSortFromURL && searchSortFromURL !== sortOption) {\n setSortOption(searchSortFromURL);\n }\n if (indexFromURLParam) {\n setIndexFromURL(indexFromURLParam);\n }\n }\n }, []);\n // results\n const [results, setResults] = React.useState<ReactivesearchResultProps[\"data\"]>([]);\n // curation\n const curation = React.useMemo<ConfigCuration | undefined>(() => {\n if (!config) {\n return undefined;\n }\n\n return getCuration({\n provider: props,\n config: config,\n searchTerm: searchTerm,\n });\n }, [props, config, searchTerm]);\n // result stats\n const [resultStats, setResultStats] = React.useState<ReactivesearchResultProps[\"resultStats\"]>();\n\n\n const contextValue = React.useMemo(() => {\n if (!config) {\n return;\n }\n\n return {\n config: config,\n options: {\n ...props,\n clientId: props.clientId ?? \"theme\",\n index: props.index ?? indexFromURL ?? config.index,\n filtersHandle: props.filtersHandle,\n credentials: props.credentials,\n theme: theme,\n },\n search: {\n searchTerm: searchTerm,\n setSearchTerm: setSearchTerm,\n showInstantSearchResults: showInstantSearchResults,\n setShowInstantSearchResults: setShowInstantSearchResults,\n searchRedirect: searchRedirect,\n },\n sortby: {\n sortOption: sortOption,\n setSortOption: setSortOption,\n },\n results: {\n results: results,\n setResults: setResults,\n resultStats: resultStats,\n setResultStats: setResultStats,\n },\n curation: curation,\n };\n }, [\n config,\n props,\n searchTerm,\n showInstantSearchResults,\n searchRedirect,\n sortOption,\n results,\n resultStats,\n curation,\n ]);\n\n React.useEffect(() => {\n debug.log(\"curation\", \"content\", curation);\n }, [curation?.id]);\n\n debug.hook(\"ReactifySearchProvider\", \"context\", contextValue);\n\n if (!contextValue) {\n if (props.renderBooting) {\n return props.renderBooting();\n }\n return null;\n }\n\n return (\n <ReactifySearchContext.Provider value={contextValue}>\n <UtilityAuthenticatedReactiveBase>{props.children}</UtilityAuthenticatedReactiveBase>\n </ReactifySearchContext.Provider>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ReactifySearchProvider.js","sourceRoot":"","sources":["../../../../src/components/ReactifySearchProvider/ReactifySearch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ACL,UAAU;QACV,wBAAwB;QACxB,cAAc;QACd,UAAU;QACV,OAAO;QACP,WAAW;QACX,QAAQ;KACT,CAAC,CAAC;IAEH,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,eAAK,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC,EAAE,CAAC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,EAAE,CAAC,CAAC,CAAC;IAEnB,eAAK,CAAC,IAAI,CAAC,wBAAwB,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;IAE9D,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,IAAI,KAAK,CAAC,aAAa;YAAE,OAAO,KAAK,CAAC,aAAa,EAAE,CAAC;QACtD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,8BAAC,6BAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY;QACjD,8BAAC,6CAAgC,QAAE,KAAK,CAAC,QAAQ,CAAoC,CACtD,CAClC,CAAC;AACJ,CAAC","sourcesContent":["import React, { PropsWithChildren, ReactNode, useEffect, useMemo, useState } from \"react\";\n// @ts-expect-error missing types\nimport * as GaGtag from \"ga-gtag\";\n\nimport pkg from \"../../../package.json\";\n\nimport { ReactifySearchContext, useConfig } from \"../../hooks\";\nimport { UtilityAuthenticatedReactiveBase } from \"../../components\";\nimport { debug } from \"../../utility\";\nimport { Config, ConfigCuration, ConfigRedirect, ReactivesearchResultProps } from \"../../types\";\nimport { getCuration } from \"../../utility/curation\";\n\nexport type ReactifySearchProviderProps = {\n /** Standard react children */\n children?: ReactNode | undefined;\n /** The search area the provider will be used in */\n mode: \"search\" | \"collection\" | \"instant-search\" | \"curated-page\";\n /** The variation of the search area the provider will be used in */\n /** Shopify store domain used to resolve the site configuration */\n shopifyPermanentDomain: string;\n /** Market ID used to change merchandising based on market e.g. 7494533198 */\n market?: string;\n /** Callback function for redirects, suitable for headless sites to avoid full page refresh */\n onRedirect?: (type: \"redirect\" | \"search\", url: string) => void;\n /** Render method to display a component when the config is loading */\n renderBooting?: () => JSX.Element | null;\n /** Advanced usage: Override the default Reactify Search id (for telemetry) */\n clientId?: string;\n /** Advanced usage: Override the default Filters selection logic */\n filtersHandle?: string;\n /** Advanced usage: Array of additional component IDs managed outside of Reactify Search */\n additionalComponentIds?: Array<string>;\n /** Advanced usage: Override the default Elasticsearch index */\n index?: string;\n /** Advanced usage: Override the default Reactify Search config (for multi-instance stores) */\n configId?: string;\n /** Advanced usage: Override the default Elasticsearch credentials */\n credentials?: string;\n /** Advanced usage: Override the default ReactiveBase theme */\n theme?: Record<string, unknown>;\n /** Advanced usage: Fields to include in the Elasticsearch response e.g. [\"title\"] */\n includeFields?: Array<string>;\n /** Advanced usage: Fields to exclude from the Elasticsearch response e.g. [\"variant_skus\", \"*price*\"] */\n excludeFields?: Array<string>;\n /** Advanced usage: Server content for SSR */\n query?: Record<string, string>;\n preload?: {\n config: Config;\n state: unknown;\n };\n} & (\n | {\n mode: \"search\";\n }\n | {\n mode: \"collection\";\n /** Collection object that includes the handle, used to find curations */\n collectionHandle: string;\n }\n | { mode: \"instant-search\" }\n | {\n mode: \"curated-page\";\n variation: \"collection\";\n /** Handle of the collection. The same from Shopify. */\n handle: string;\n }\n | {\n mode: \"curated-page\";\n variation: \"search\";\n /** The merchandising search term from the Shopify App. */\n searchTerm: string;\n }\n);\n\nexport function ReactifySearchProvider(props: PropsWithChildren<ReactifySearchProviderProps>) {\n useEffect(() => {\n debug.log(\"ReactifySearchProvider\", \"props\", props);\n\n GaGtag.install(\"G-DV00Z0X5VP\", {\n cookie_prefix: \"_rs\",\n user_properties: {\n shop: props.shopifyPermanentDomain,\n version: pkg.version,\n },\n });\n }, [props]);\n\n return <ReactifySearchInner {...props} />;\n}\n\nfunction ReactifySearchInner(props: PropsWithChildren<ReactifySearchProviderProps>) {\n const { config } = useConfig(props.shopifyPermanentDomain, props.preload?.config);\n const theme = props.theme ?? { typography: { fontFamily: \"inherit\", fontSize: \"inherit\" } };\n\n // search term\n const [searchTerm, setSearchTerm] = useState<string>(\"\");\n const [showInstantSearchResults, setShowInstantSearchResults] = useState<boolean>(false);\n const [sortOption, setSortOption] = useState<string>(\"\");\n const [indexFromURL, setIndexFromURL] = useState<string | null>(null);\n const searchRedirect = useMemo<ConfigRedirect | undefined>(() => {\n return config?.redirects.find(\n (redirect) => redirect.query.trim().toLowerCase() === searchTerm.trim().toLowerCase()\n );\n }, [config?.redirects, searchTerm]);\n\n // hydration-safe URL param initialization\n useEffect(() => {\n if (typeof window !== \"undefined\") {\n const urlParams = new URLSearchParams(window.location.search);\n const searchTermFromURL = urlParams.get(\"q\");\n const searchSortFromURL = urlParams.get(\"sort\");\n const indexFromURLParam = urlParams.get(\"index\");\n if (searchTermFromURL && searchTermFromURL !== searchTerm) setSearchTerm(searchTermFromURL);\n if (searchSortFromURL && searchSortFromURL !== sortOption) setSortOption(searchSortFromURL);\n if (indexFromURLParam) setIndexFromURL(indexFromURLParam);\n }\n }, []);\n\n // results\n const [results, setResults] = useState<ReactivesearchResultProps[\"data\"]>([]);\n\n // curation\n const curation = useMemo<ConfigCuration | undefined>(() => {\n if (!config) return undefined;\n return getCuration({ provider: props, config: config, searchTerm: searchTerm });\n }, [props, config, searchTerm]);\n\n // result stats\n const [resultStats, setResultStats] = useState<ReactivesearchResultProps[\"resultStats\"]>();\n\n const contextValue = useMemo(() => {\n if (!config) return;\n\n return {\n config: config,\n options: {\n ...props,\n clientId: props.clientId ?? \"theme\",\n index: props.index ?? indexFromURL ?? config.index,\n filtersHandle: props.filtersHandle,\n credentials: props.credentials,\n theme: theme,\n },\n search: {\n searchTerm: searchTerm,\n setSearchTerm: setSearchTerm,\n showInstantSearchResults: showInstantSearchResults,\n setShowInstantSearchResults: setShowInstantSearchResults,\n searchRedirect: searchRedirect,\n },\n sortby: {\n sortOption: sortOption,\n setSortOption: setSortOption,\n },\n results: {\n results: results,\n setResults: setResults,\n resultStats: resultStats,\n setResultStats: setResultStats,\n },\n curation: curation,\n };\n }, [\n config,\n props,\n searchTerm,\n showInstantSearchResults,\n searchRedirect,\n sortOption,\n results,\n resultStats,\n curation,\n ]);\n\n useEffect(() => {\n debug.log(\"curation\", \"content\", curation);\n }, [curation?.id]);\n\n debug.hook(\"ReactifySearchProvider\", \"context\", contextValue);\n\n if (!contextValue) {\n if (props.renderBooting) return props.renderBooting();\n return null;\n }\n\n return (\n <ReactifySearchContext.Provider value={contextValue}>\n <UtilityAuthenticatedReactiveBase>{props.children}</UtilityAuthenticatedReactiveBase>\n </ReactifySearchContext.Provider>\n );\n}\n"]}
|
|
@@ -58,7 +58,7 @@ const ResultsInner = (props) => {
|
|
|
58
58
|
const context = (0, hooks_1.useReactifySearchContext)();
|
|
59
59
|
const filtersHook = (0, hooks_1.useFilters)();
|
|
60
60
|
const resultsHook = (0, hooks_1.useResults)();
|
|
61
|
-
const initialSearchHasRun = react_1.default.useMemo(() =>
|
|
61
|
+
const initialSearchHasRun = react_1.default.useMemo(() => props.reactivesearchResultProps.resultStats.numberOfResults !== undefined, [props.reactivesearchResultProps]);
|
|
62
62
|
const listStyle = react_1.default.useMemo(() => {
|
|
63
63
|
var _a;
|
|
64
64
|
return (_a = props.listStyle) !== null && _a !== void 0 ? _a : {
|
|
@@ -80,6 +80,7 @@ const ResultsInner = (props) => {
|
|
|
80
80
|
props.reactivesearchResultProps.resultStats.displayedResults,
|
|
81
81
|
props.infiniteScrollPosition,
|
|
82
82
|
]);
|
|
83
|
+
// This dependency is inverted. The `useResults` hook depends on the `Results` component.
|
|
83
84
|
react_1.default.useEffect(() => {
|
|
84
85
|
resultsHook.setResults(props.reactivesearchResultProps.data);
|
|
85
86
|
resultsHook.setResultStats(props.reactivesearchResultProps.resultStats);
|
|
@@ -163,16 +164,12 @@ const ResultsInner = (props) => {
|
|
|
163
164
|
react_1.default.createElement("section", { style: listStyle, className: props.listClassName }, results.map((item, key) => {
|
|
164
165
|
if (types_1.ElasticDocumentType.Product === item.type) {
|
|
165
166
|
return (react_1.default.createElement(ResultCardProduct_1.ResultCardProduct, Object.assign({ key: item._id, product: item, document: item, pagePosition: key + 1, render: props.renderResultCardProduct }, (infiniteScrollPosition === key + 1
|
|
166
|
-
? {
|
|
167
|
-
onView: () => props.reactivesearchResultProps.loadMore(),
|
|
168
|
-
}
|
|
167
|
+
? { onView: () => props.reactivesearchResultProps.loadMore() }
|
|
169
168
|
: {}))));
|
|
170
169
|
}
|
|
171
170
|
if (types_1.ElasticDocumentType.Callout === item.type) {
|
|
172
171
|
return (react_1.default.createElement(ResultCardCallout_1.ResultCardCallout, Object.assign({ key: item._id, document: item, pagePosition: key + 1, callout: item.callout, render: props.renderResultCardCallout }, (infiniteScrollPosition === key + 1
|
|
173
|
-
? {
|
|
174
|
-
onView: () => props.reactivesearchResultProps.loadMore(),
|
|
175
|
-
}
|
|
172
|
+
? { onView: () => props.reactivesearchResultProps.loadMore() }
|
|
176
173
|
: {}))));
|
|
177
174
|
}
|
|
178
175
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Results.js","sourceRoot":"","sources":["../../../../src/components/Result/Results.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,oHAA4F;AAE5F,2DAAwD;AACxD,2DAAwD;AACxD,yEAAsE;AACtE,yEAAsE;AACtE,yEAAsE;AACtE,qFAAkF;AAElF,uCAUqB;AACrB,uCASqB;AACrB,+CAAsD;AACtD,qDAA8E;AA0DvE,MAAM,OAAO,GAA2B,CAAC,KAAK,EAAE,EAAE;IACvD,MAAM,qBAAqB,GAAG,IAAA,gCAAwB,GAAE,CAAC;IACzD,MAAM,WAAW,GAAG,IAAA,kBAAU,GAAE,CAAC;IACjC,MAAM,aAAa,GAAG,IAAA,uBAAe,EAAC;QACpC,QAAQ,EAAE,qBAAqB,CAAC,OAAO;QACvC,MAAM,EAAE,qBAAqB,CAAC,MAAM;QACpC,WAAW,EAAE,WAAW,CAAC,WAAW;QAC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MAAK,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,CAAA,EAAE,CAAC;QAChD,OAAO,CACL,8BAAC,mDAAwB,oBACnB,KAAK,CAAC,yBAAyB,IACnC,MAAM,EAAE,KAAK,CAAC,wBAAwB,IACtC,CACH,CAAC;IACJ,CAAC;IAED,IAAI,iBAAiB,MAAK,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,CAAA,EAAE,CAAC;QACtD,OAAO,CACL,8BAAC,+DAA8B,oBACzB,KAAK,CAAC,yBAAyB,IACnC,MAAM,EAAE,KAAK,CAAC,8BAA8B,IAC5C,CACH,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveList from \"@usereactify/search-internals/lib/components/result/ReactiveList\";\n\nimport { ResultCardCallout } from \"./ResultCardCallout\";\nimport { ResultCardProduct } from \"./ResultCardProduct\";\nimport { ResultPaginationNumbered } from \"./ResultPaginationNumbered\";\nimport { ResultPaginationLoadMore } from \"./ResultPaginationLoadMore\";\nimport { ResultPaginationNextPrev } from \"./ResultPaginationNextPrev\";\nimport { ResultPaginationInfiniteScroll } from \"./ResultPaginationInfiniteScroll\";\n\nimport {\n ElasticCallout,\n ElasticProduct,\n ElasticDocumentType,\n ReactivesearchError,\n ReactivesearchResultProps,\n ReactivesearchPaginationProps,\n ElasticHit,\n ElasticDocument,\n ResultsDataListener,\n} from \"../../types\";\nimport {\n useReactifySearchContext,\n useAnalytics,\n useSearch,\n useFilters,\n useProductPrice,\n usePagination,\n usePaginationLoadable,\n useResults,\n} from \"../../hooks\";\nimport { getPropsResults } from \"../../utility/props\";\nimport { MerchandisingCalloutAutofillBehaviour } from \"../../types/firestore\";\n\nexport type ResultProps = ReactivesearchResultProps & {\n callouts: ElasticCallout[];\n products: ElasticProduct[];\n};\n\nexport type ResultsProps = {\n /** Style prop for the list wrapper */\n listStyle?: React.HTMLAttributes<HTMLElement>[\"style\"];\n /** Classname prop for the list wrapper */\n listClassName?: string;\n /** Render method called when an error occurs */\n renderError?: React.FC<{ error: ReactivesearchError }>;\n /** Render method called while loading for the first time */\n renderLoading?: React.FC;\n /** Render method called when no results are found */\n renderNoResults?: React.FC;\n /** Render method called once for each product result */\n renderResultCardProduct?: React.FC<\n ReturnType<typeof useProductPrice> & {\n pagePosition: number;\n product: ElasticProduct;\n document: ElasticProduct;\n itemRef: (node?: Element | null) => void;\n handleClick: () => void;\n }\n >;\n /** Render method called once for each callout result */\n renderResultCardCallout?: React.FC<{\n pagePosition: number;\n document: ElasticCallout;\n callout: ElasticCallout[\"callout\"];\n itemRef: (node?: Element | null) => void;\n handleClick: () => void;\n }>;\n /** Render method called for pagination type \"pagination\" */\n renderPaginationNumbered?: React.FC<ReturnType<typeof usePagination>>;\n /** Render method called for pagination type \"next_prev\" */\n renderPaginationNextPrev?: React.FC<ReturnType<typeof usePagination>>;\n /** Render method called for pagination type \"load_more\" */\n renderPaginationLoadMore?: React.FC<ReturnType<typeof usePaginationLoadable>>;\n /** Render method called for pagination type \"infinite_scroll\" */\n renderPaginationInfiniteScroll?: React.FC<ReturnType<typeof usePaginationLoadable>>;\n /** Used to determine which filler callouts to use when there is an uneven grid */\n gridColumns?: number;\n /** Advanced Usage: Override the default amount of results per page */\n pageSize?: number;\n /** Advanced Usage: Override the default scrollTarget used to determine when infinite load should be triggered (infinite scroll) */\n infiniteScrollContainer?: React.ComponentProps<typeof ReactiveList>[\"scrollTarget\"];\n /** Advanced Usage: Provide a specific result position to trigger loading more results (infinite scroll) */\n infiniteScrollPosition?: number;\n /** Advanced Usage: Shows subsequent loading states after initial results are loaded */\n showSubsequentLoadingStates?: boolean;\n /** Advanced Usage: Provide a function to listen to when a search request is made and new results are returned. */\n onData?: ResultsDataListener;\n};\n\nexport const Results: React.FC<ResultsProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const reactiveProps = getPropsResults({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n scrollTarget: props.infiniteScrollContainer,\n pageSize: props.pageSize,\n onData: props.onData,\n });\n\n const { track } = useAnalytics();\n const { searchTerm } = useSearch();\n\n const handleData: ResultsDataListener = (renderProps) => {\n if (renderProps.resultStats.numberOfResults === 0) {\n let trimmedSearchTerm = searchTerm.trim();\n if (!trimmedSearchTerm || (trimmedSearchTerm && trimmedSearchTerm.length < 3)) return;\n track({ eventName: \"zeroResults\", payload: { searchTerm: trimmedSearchTerm } });\n props.onData?.(renderProps);\n }\n };\n\n return (\n <ReactiveList\n {...reactiveProps}\n render={(reactivesearchResultProps: ReactivesearchResultProps) => (\n <ResultsInner {...props} reactivesearchResultProps={reactivesearchResultProps} />\n )}\n onData={handleData}\n renderPagination={(reactivesearchPaginationProps: ReactivesearchPaginationProps) => (\n <ResultsPaginationStack {...props} {...reactivesearchPaginationProps} />\n )}\n />\n );\n};\n\nconst ResultsRenderErrorComponent: ResultsProps[\"renderError\"] = (props) => {\n return (\n <div>\n {\"Error: \"}\n {props.error.statusText}\n </div>\n );\n};\n\nconst ResultsRenderLoadingComponent: ResultsProps[\"renderLoading\"] = () => {\n return <div>{\"Loading\"}</div>;\n};\n\nconst ResultsRenderNoResultsComponent: ResultsProps[\"renderNoResults\"] = () => {\n return <div>{\"No results\"}</div>;\n};\n\nconst ResultsInner: React.FC<\n ResultsProps & { reactivesearchResultProps: ReactivesearchResultProps }\n> = (props) => {\n const context = useReactifySearchContext();\n const filtersHook = useFilters();\n const resultsHook = useResults();\n const initialSearchHasRun = React.useMemo(\n () => \"undefined\" !== typeof props.reactivesearchResultProps.resultStats.numberOfResults,\n [props.reactivesearchResultProps]\n );\n\n const listStyle = React.useMemo<React.HTMLAttributes<HTMLElement>[\"style\"]>(\n () =>\n props.listStyle ?? {\n display: \"grid\",\n gap: \"8px\",\n gridTemplateColumns: \"repeat(4, minmax(0, 1fr))\",\n },\n [props.listStyle]\n );\n\n const infiniteScrollPosition = React.useMemo<number>(() => {\n if (!props.infiniteScrollPosition) {\n return NaN;\n }\n\n const scrollPositionOffset =\n props.reactivesearchResultProps.resultStats.displayedResults -\n (props.pageSize ?? filtersHook.filterStack?.pageSize ?? 0);\n\n return scrollPositionOffset + (props.infiniteScrollPosition ?? 0);\n }, [\n props.pageSize ?? filtersHook.filterStack?.pageSize,\n props.reactivesearchResultProps.resultStats.displayedResults,\n props.infiniteScrollPosition,\n ]);\n\n React.useEffect(() => {\n resultsHook.setResults(props.reactivesearchResultProps.data);\n resultsHook.setResultStats(props.reactivesearchResultProps.resultStats);\n }, [\n props.reactivesearchResultProps.resultStats.numberOfResults,\n props.reactivesearchResultProps.data.map((item) => item._id).join(\"\"),\n ]);\n\n const calculateGridOverflow = React.useCallback(\n (results: ReactivesearchResultProps[\"data\"]) => {\n if (!props.gridColumns) return;\n let total = results.length;\n for (const result of results) {\n if (result.type === ElasticDocumentType.Product) continue;\n total += parseInt(result.callout.displayColumns) * parseInt(result.callout.displayRows) - 1;\n }\n const overflow = props.gridColumns - (total % props.gridColumns);\n if (overflow === props.gridColumns) return;\n return overflow === props.gridColumns ? undefined : overflow;\n },\n [props.gridColumns]\n );\n\n const gridOverflowCallout = React.useMemo(():\n | (Omit<ElasticHit, \"_source\"> & ElasticCallout)\n | undefined => {\n // check if there are more results\n if (\n props.reactivesearchResultProps.resultStats.displayedResults ===\n props.reactivesearchResultProps.resultStats.numberOfResults\n ) {\n // check if we should only autofill when there are more results\n if (\n context.config.merchandising.calloutAutofillBehaviour ===\n MerchandisingCalloutAutofillBehaviour.MoreResults\n ) {\n return;\n }\n }\n\n const overflow = calculateGridOverflow(props.reactivesearchResultProps.data);\n\n const callout = context.config.callouts.find((item) => item.displayColumns === `${overflow}`);\n if (!callout) {\n return;\n }\n\n return {\n _id: callout.id,\n _score: 0,\n type: ElasticDocumentType.Callout,\n key: callout.id,\n callout: {\n ...callout,\n enabled: true,\n },\n published: true,\n curations: [],\n };\n }, [\n props.reactivesearchResultProps.resultStats,\n props.reactivesearchResultProps.data,\n context.config.callouts,\n ]);\n\n const results = React.useMemo(\n () => [\n ...props.reactivesearchResultProps.data,\n ...(gridOverflowCallout ? [gridOverflowCallout] : []),\n ],\n [props.reactivesearchResultProps.data, gridOverflowCallout]\n );\n\n if (props.reactivesearchResultProps.error) {\n const RenderErrorComponent = props.renderError ?? ResultsRenderErrorComponent;\n\n return <RenderErrorComponent error={props.reactivesearchResultProps.error} />;\n }\n\n if (!initialSearchHasRun) {\n const RenderLoadingComponent = props.renderLoading ?? ResultsRenderLoadingComponent;\n return <RenderLoadingComponent />;\n }\n\n if (props.showSubsequentLoadingStates === true) {\n if (props.reactivesearchResultProps.loading) {\n const RenderLoadingComponent = props.renderLoading ?? ResultsRenderLoadingComponent;\n return <RenderLoadingComponent />;\n }\n }\n\n if (\n !props.reactivesearchResultProps.loading &&\n !props.reactivesearchResultProps.resultStats.numberOfResults\n ) {\n const RenderNoResultsComponent = props.renderNoResults ?? ResultsRenderNoResultsComponent;\n\n return <RenderNoResultsComponent />;\n }\n\n if ([\"search\", \"instant-search\"].includes(context.options.mode)) {\n if (!context.search.searchTerm) {\n const RenderNoResultsComponent = props.renderNoResults ?? ResultsRenderNoResultsComponent;\n\n return <RenderNoResultsComponent />;\n }\n }\n\n return (\n <>\n <section style={listStyle} className={props.listClassName}>\n {results.map((item, key) => {\n if (ElasticDocumentType.Product === item.type) {\n return (\n <ResultCardProduct\n key={item._id}\n product={item}\n document={item}\n pagePosition={key + 1}\n render={props.renderResultCardProduct}\n {...(infiniteScrollPosition === key + 1\n ? {\n onView: () => props.reactivesearchResultProps.loadMore(),\n }\n : {})}\n />\n );\n }\n\n if (ElasticDocumentType.Callout === item.type) {\n return (\n <ResultCardCallout\n key={item._id}\n document={item}\n pagePosition={key + 1}\n callout={item.callout}\n render={props.renderResultCardCallout}\n {...(infiniteScrollPosition === key + 1\n ? {\n onView: () => props.reactivesearchResultProps.loadMore(),\n }\n : {})}\n />\n );\n }\n\n return null;\n })}\n </section>\n <ResultsPaginationStackLoadable {...props} {...props.reactivesearchResultProps} />\n </>\n );\n};\n\n/** Handles rendering pagination for types that use \"pagination props\" */\nconst ResultsPaginationStack: React.FC<ResultsProps & ReactivesearchPaginationProps> = (props) => {\n const { options } = useReactifySearchContext();\n const { filterStack } = useFilters();\n\n if (options.mode === \"instant-search\") {\n return null;\n }\n\n if (\"pagination\" === filterStack?.paginationType) {\n return <ResultPaginationNumbered {...props} render={props.renderPaginationNumbered} />;\n }\n\n if (\"next_prev\" === filterStack?.paginationType) {\n return <ResultPaginationNextPrev {...props} render={props.renderPaginationNextPrev} />;\n }\n\n return null;\n};\n\n/** Handles rendering pagination for types that use \"result props\" */\nconst ResultsPaginationStackLoadable: React.FC<\n ResultsProps & { reactivesearchResultProps: ReactivesearchResultProps }\n> = (props) => {\n const { options } = useReactifySearchContext();\n const { filterStack } = useFilters();\n\n if (options.mode === \"instant-search\") {\n return null;\n }\n\n if (\"load_more\" === filterStack?.paginationType) {\n return (\n <ResultPaginationLoadMore\n {...props.reactivesearchResultProps}\n render={props.renderPaginationLoadMore}\n />\n );\n }\n\n if (\"infinite_scroll\" === filterStack?.paginationType) {\n return (\n <ResultPaginationInfiniteScroll\n {...props.reactivesearchResultProps}\n render={props.renderPaginationInfiniteScroll}\n />\n );\n }\n\n return null;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"Results.js","sourceRoot":"","sources":["../../../../src/components/Result/Results.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,oHAA4F;AAE5F,2DAAwD;AACxD,2DAAwD;AACxD,yEAAsE;AACtE,yEAAsE;AACtE,yEAAsE;AACtE,qFAAkF;AAElF,uCAUqB;AACrB,uCASqB;AACrB,+CAAsD;AACtD,qDAA8E;AA0DvE,MAAM,OAAO,GAA2B,CAAC,KAAK,EAAE,EAAE;IACvD,MAAM,qBAAqB,GAAG,IAAA,gCAAwB,GAAE,CAAC;IACzD,MAAM,WAAW,GAAG,IAAA,kBAAU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B,GAAE,CAAC;IAC/C,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,kBAAU,GAAE,CAAC;IAErC,IAAI,OAAO,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,WAAW,MAAK,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,CAAA,EAAE,CAAC;QAChD,OAAO,CACL,8BAAC,mDAAwB,oBACnB,KAAK,CAAC,yBAAyB,IACnC,MAAM,EAAE,KAAK,CAAC,wBAAwB,IACtC,CACH,CAAC;IACJ,CAAC;IAED,IAAI,iBAAiB,MAAK,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,CAAA,EAAE,CAAC;QACtD,OAAO,CACL,8BAAC,+DAA8B,oBACzB,KAAK,CAAC,yBAAyB,IACnC,MAAM,EAAE,KAAK,CAAC,8BAA8B,IAC5C,CACH,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveList from \"@usereactify/search-internals/lib/components/result/ReactiveList\";\n\nimport { ResultCardCallout } from \"./ResultCardCallout\";\nimport { ResultCardProduct } from \"./ResultCardProduct\";\nimport { ResultPaginationNumbered } from \"./ResultPaginationNumbered\";\nimport { ResultPaginationLoadMore } from \"./ResultPaginationLoadMore\";\nimport { ResultPaginationNextPrev } from \"./ResultPaginationNextPrev\";\nimport { ResultPaginationInfiniteScroll } from \"./ResultPaginationInfiniteScroll\";\n\nimport {\n ElasticCallout,\n ElasticProduct,\n ElasticDocumentType,\n ReactivesearchError,\n ReactivesearchResultProps,\n ReactivesearchPaginationProps,\n ElasticHit,\n ElasticDocument,\n ResultsDataListener,\n} from \"../../types\";\nimport {\n useReactifySearchContext,\n useAnalytics,\n useSearch,\n useFilters,\n useProductPrice,\n usePagination,\n usePaginationLoadable,\n useResults,\n} from \"../../hooks\";\nimport { getPropsResults } from \"../../utility/props\";\nimport { MerchandisingCalloutAutofillBehaviour } from \"../../types/firestore\";\n\nexport type ResultProps = ReactivesearchResultProps & {\n callouts: ElasticCallout[];\n products: ElasticProduct[];\n};\n\nexport type ResultsProps = {\n /** Style prop for the list wrapper */\n listStyle?: React.HTMLAttributes<HTMLElement>[\"style\"];\n /** Classname prop for the list wrapper */\n listClassName?: string;\n /** Render method called when an error occurs */\n renderError?: React.FC<{ error: ReactivesearchError }>;\n /** Render method called while loading for the first time */\n renderLoading?: React.FC;\n /** Render method called when no results are found */\n renderNoResults?: React.FC;\n /** Render method called once for each product result */\n renderResultCardProduct?: React.FC<\n ReturnType<typeof useProductPrice> & {\n pagePosition: number;\n product: ElasticProduct;\n document: ElasticProduct;\n itemRef: (node?: Element | null) => void;\n handleClick: () => void;\n }\n >;\n /** Render method called once for each callout result */\n renderResultCardCallout?: React.FC<{\n pagePosition: number;\n document: ElasticCallout;\n callout: ElasticCallout[\"callout\"];\n itemRef: (node?: Element | null) => void;\n handleClick: () => void;\n }>;\n /** Render method called for pagination type \"pagination\" */\n renderPaginationNumbered?: React.FC<ReturnType<typeof usePagination>>;\n /** Render method called for pagination type \"next_prev\" */\n renderPaginationNextPrev?: React.FC<ReturnType<typeof usePagination>>;\n /** Render method called for pagination type \"load_more\" */\n renderPaginationLoadMore?: React.FC<ReturnType<typeof usePaginationLoadable>>;\n /** Render method called for pagination type \"infinite_scroll\" */\n renderPaginationInfiniteScroll?: React.FC<ReturnType<typeof usePaginationLoadable>>;\n /** Used to determine which filler callouts to use when there is an uneven grid */\n gridColumns?: number;\n /** Advanced Usage: Override the default amount of results per page */\n pageSize?: number;\n /** Advanced Usage: Override the default scrollTarget used to determine when infinite load should be triggered (infinite scroll) */\n infiniteScrollContainer?: React.ComponentProps<typeof ReactiveList>[\"scrollTarget\"];\n /** Advanced Usage: Provide a specific result position to trigger loading more results (infinite scroll) */\n infiniteScrollPosition?: number;\n /** Advanced Usage: Shows subsequent loading states after initial results are loaded */\n showSubsequentLoadingStates?: boolean;\n /** Advanced Usage: Provide a function to listen to when a search request is made and new results are returned. */\n onData?: ResultsDataListener;\n};\n\nexport const Results: React.FC<ResultsProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const reactiveProps = getPropsResults({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n scrollTarget: props.infiniteScrollContainer,\n pageSize: props.pageSize,\n onData: props.onData,\n });\n\n const { track } = useAnalytics();\n const { searchTerm } = useSearch();\n\n const handleData: ResultsDataListener = (renderProps) => {\n if (renderProps.resultStats.numberOfResults === 0) {\n let trimmedSearchTerm = searchTerm.trim();\n if (!trimmedSearchTerm || (trimmedSearchTerm && trimmedSearchTerm.length < 3)) return;\n track({ eventName: \"zeroResults\", payload: { searchTerm: trimmedSearchTerm } });\n props.onData?.(renderProps);\n }\n };\n\n return (\n <ReactiveList\n {...reactiveProps}\n render={(reactivesearchResultProps: ReactivesearchResultProps) => (\n <ResultsInner {...props} reactivesearchResultProps={reactivesearchResultProps} />\n )}\n onData={handleData}\n renderPagination={(reactivesearchPaginationProps: ReactivesearchPaginationProps) => (\n <ResultsPaginationStack {...props} {...reactivesearchPaginationProps} />\n )}\n />\n );\n};\n\nconst ResultsRenderErrorComponent: ResultsProps[\"renderError\"] = (props) => {\n return (\n <div>\n {\"Error: \"}\n {props.error.statusText}\n </div>\n );\n};\n\nconst ResultsRenderLoadingComponent: ResultsProps[\"renderLoading\"] = () => {\n return <div>{\"Loading\"}</div>;\n};\n\nconst ResultsRenderNoResultsComponent: ResultsProps[\"renderNoResults\"] = () => {\n return <div>{\"No results\"}</div>;\n};\n\nconst ResultsInner: React.FC<\n ResultsProps & { reactivesearchResultProps: ReactivesearchResultProps }\n> = (props) => {\n const context = useReactifySearchContext();\n const filtersHook = useFilters();\n const resultsHook = useResults();\n const initialSearchHasRun = React.useMemo(\n () => props.reactivesearchResultProps.resultStats.numberOfResults !== undefined,\n [props.reactivesearchResultProps]\n );\n\n const listStyle = React.useMemo<React.HTMLAttributes<HTMLElement>[\"style\"]>(\n () =>\n props.listStyle ?? {\n display: \"grid\",\n gap: \"8px\",\n gridTemplateColumns: \"repeat(4, minmax(0, 1fr))\",\n },\n [props.listStyle]\n );\n\n const infiniteScrollPosition = React.useMemo<number>(() => {\n if (!props.infiniteScrollPosition) {\n return NaN;\n }\n\n const scrollPositionOffset =\n props.reactivesearchResultProps.resultStats.displayedResults -\n (props.pageSize ?? filtersHook.filterStack?.pageSize ?? 0);\n\n return scrollPositionOffset + (props.infiniteScrollPosition ?? 0);\n }, [\n props.pageSize ?? filtersHook.filterStack?.pageSize,\n props.reactivesearchResultProps.resultStats.displayedResults,\n props.infiniteScrollPosition,\n ]);\n\n // This dependency is inverted. The `useResults` hook depends on the `Results` component.\n React.useEffect(() => {\n resultsHook.setResults(props.reactivesearchResultProps.data);\n resultsHook.setResultStats(props.reactivesearchResultProps.resultStats);\n }, [\n props.reactivesearchResultProps.resultStats.numberOfResults,\n props.reactivesearchResultProps.data.map((item) => item._id).join(\"\"),\n ]);\n\n const calculateGridOverflow = React.useCallback(\n (results: ReactivesearchResultProps[\"data\"]) => {\n if (!props.gridColumns) return;\n let total = results.length;\n for (const result of results) {\n if (result.type === ElasticDocumentType.Product) continue;\n total += parseInt(result.callout.displayColumns) * parseInt(result.callout.displayRows) - 1;\n }\n const overflow = props.gridColumns - (total % props.gridColumns);\n if (overflow === props.gridColumns) return;\n return overflow === props.gridColumns ? undefined : overflow;\n },\n [props.gridColumns]\n );\n\n const gridOverflowCallout = React.useMemo(():\n | (Omit<ElasticHit, \"_source\"> & ElasticCallout)\n | undefined => {\n // check if there are more results\n if (\n props.reactivesearchResultProps.resultStats.displayedResults ===\n props.reactivesearchResultProps.resultStats.numberOfResults\n ) {\n // check if we should only autofill when there are more results\n if (\n context.config.merchandising.calloutAutofillBehaviour ===\n MerchandisingCalloutAutofillBehaviour.MoreResults\n ) {\n return;\n }\n }\n\n const overflow = calculateGridOverflow(props.reactivesearchResultProps.data);\n\n const callout = context.config.callouts.find((item) => item.displayColumns === `${overflow}`);\n if (!callout) {\n return;\n }\n\n return {\n _id: callout.id,\n _score: 0,\n type: ElasticDocumentType.Callout,\n key: callout.id,\n callout: {\n ...callout,\n enabled: true,\n },\n published: true,\n curations: [],\n };\n }, [\n props.reactivesearchResultProps.resultStats,\n props.reactivesearchResultProps.data,\n context.config.callouts,\n ]);\n\n const results = React.useMemo(\n () => [\n ...props.reactivesearchResultProps.data,\n ...(gridOverflowCallout ? [gridOverflowCallout] : []),\n ],\n [props.reactivesearchResultProps.data, gridOverflowCallout]\n );\n\n if (props.reactivesearchResultProps.error) {\n const RenderErrorComponent = props.renderError ?? ResultsRenderErrorComponent;\n\n return <RenderErrorComponent error={props.reactivesearchResultProps.error} />;\n }\n\n if (!initialSearchHasRun) {\n const RenderLoadingComponent = props.renderLoading ?? ResultsRenderLoadingComponent;\n return <RenderLoadingComponent />;\n }\n\n if (props.showSubsequentLoadingStates === true) {\n if (props.reactivesearchResultProps.loading) {\n const RenderLoadingComponent = props.renderLoading ?? ResultsRenderLoadingComponent;\n return <RenderLoadingComponent />;\n }\n }\n\n if (\n !props.reactivesearchResultProps.loading &&\n !props.reactivesearchResultProps.resultStats.numberOfResults\n ) {\n const RenderNoResultsComponent = props.renderNoResults ?? ResultsRenderNoResultsComponent;\n\n return <RenderNoResultsComponent />;\n }\n\n if ([\"search\", \"instant-search\"].includes(context.options.mode)) {\n if (!context.search.searchTerm) {\n const RenderNoResultsComponent = props.renderNoResults ?? ResultsRenderNoResultsComponent;\n\n return <RenderNoResultsComponent />;\n }\n }\n\n return (\n <>\n <section style={listStyle} className={props.listClassName}>\n {results.map((item, key) => {\n if (ElasticDocumentType.Product === item.type) {\n return (\n <ResultCardProduct\n key={item._id}\n product={item}\n document={item}\n pagePosition={key + 1}\n render={props.renderResultCardProduct}\n {...(infiniteScrollPosition === key + 1\n ? { onView: () => props.reactivesearchResultProps.loadMore() }\n : {})}\n />\n );\n }\n\n if (ElasticDocumentType.Callout === item.type) {\n return (\n <ResultCardCallout\n key={item._id}\n document={item}\n pagePosition={key + 1}\n callout={item.callout}\n render={props.renderResultCardCallout}\n {...(infiniteScrollPosition === key + 1\n ? { onView: () => props.reactivesearchResultProps.loadMore() }\n : {})}\n />\n );\n }\n\n return null;\n })}\n </section>\n <ResultsPaginationStackLoadable {...props} {...props.reactivesearchResultProps} />\n </>\n );\n};\n\n/** Handles rendering pagination for types that use \"pagination props\" */\nconst ResultsPaginationStack: React.FC<ResultsProps & ReactivesearchPaginationProps> = (props) => {\n const { options } = useReactifySearchContext();\n const { filterStack } = useFilters();\n\n if (options.mode === \"instant-search\") {\n return null;\n }\n\n if (\"pagination\" === filterStack?.paginationType) {\n return <ResultPaginationNumbered {...props} render={props.renderPaginationNumbered} />;\n }\n\n if (\"next_prev\" === filterStack?.paginationType) {\n return <ResultPaginationNextPrev {...props} render={props.renderPaginationNextPrev} />;\n }\n\n return null;\n};\n\n/** Handles rendering pagination for types that use \"result props\" */\nconst ResultsPaginationStackLoadable: React.FC<\n ResultsProps & { reactivesearchResultProps: ReactivesearchResultProps }\n> = (props) => {\n const { options } = useReactifySearchContext();\n const { filterStack } = useFilters();\n\n if (options.mode === \"instant-search\") {\n return null;\n }\n\n if (\"load_more\" === filterStack?.paginationType) {\n return (\n <ResultPaginationLoadMore\n {...props.reactivesearchResultProps}\n render={props.renderPaginationLoadMore}\n />\n );\n }\n\n if (\"infinite_scroll\" === filterStack?.paginationType) {\n return (\n <ResultPaginationInfiniteScroll\n {...props.reactivesearchResultProps}\n render={props.renderPaginationInfiniteScroll}\n />\n );\n }\n\n return null;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SensorCollection.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorCollection.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,6HAAqG;AAErG,uCAAuD;AACvD,+CAA+D;AAExD,MAAM,gBAAgB,GAAa,GAAG,EAAE;IAC7C,MAAM,qBAAqB,GAAG,IAAA,gCAAwB,GAAE,CAAC;IACzD,MAAM,aAAa,GAAG,IAAA,gCAAwB,EAAC;QAC7C,MAAM,EAAE,qBAAqB,CAAC,MAAM;QACpC,QAAQ,EAAE,qBAAqB,CAAC,OAAO;KACxC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"SensorCollection.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorCollection.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,6HAAqG;AAErG,uCAAuD;AACvD,+CAA+D;AAExD,MAAM,gBAAgB,GAAa,GAAG,EAAE;IAC7C,MAAM,qBAAqB,GAAG,IAAA,gCAAwB,GAAE,CAAC;IACzD,MAAM,aAAa,GAAG,IAAA,gCAAwB,EAAC;QAC7C,MAAM,EAAE,qBAAqB,CAAC,MAAM;QACpC,QAAQ,EAAE,qBAAqB,CAAC,OAAO;KACxC,CAAC,CAAC;IAEH,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,8BAAC,2BAAiB,oBAAK,aAAa,EAAI,CAAC;AAClD,CAAC,CAAC;AAZW,QAAA,gBAAgB,oBAY3B","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@usereactify/search-internals/lib/components/basic/ReactiveComponent\";\n\nimport { useReactifySearchContext } from \"../../hooks\";\nimport { getPropsSensorCollection } from \"../../utility/props\";\n\nexport const SensorCollection: React.FC = () => {\n const reactifySearchContext = useReactifySearchContext();\n const reactiveProps = getPropsSensorCollection({\n config: reactifySearchContext.config,\n provider: reactifySearchContext.options,\n });\n\n if (!reactiveProps) {\n return null;\n }\n\n return <ReactiveComponent {...reactiveProps} />;\n};\n"]}
|
|
@@ -14,7 +14,6 @@ function SensorCuratedPageCollection() {
|
|
|
14
14
|
config: reactifySearchContext.config,
|
|
15
15
|
provider: reactifySearchContext.options,
|
|
16
16
|
});
|
|
17
|
-
console.log("SensorCuratedPageCollection > reactiveProps:", reactiveProps);
|
|
18
17
|
if (!reactiveProps)
|
|
19
18
|
return null;
|
|
20
19
|
return react_1.default.createElement(ReactiveComponent_1.default, Object.assign({}, reactiveProps));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SensorCuratedPageCollection.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorCuratedPageCollection.tsx"],"names":[],"mappings":";;;;;AAKA,
|
|
1
|
+
{"version":3,"file":"SensorCuratedPageCollection.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorCuratedPageCollection.tsx"],"names":[],"mappings":";;;;;AAKA,kEAUC;AAfD,kDAA0B;AAC1B,6HAAqG;AACrG,uCAAuD;AACvD,+CAA0E;AAE1E,SAAgB,2BAA2B;IACzC,MAAM,qBAAqB,GAAG,IAAA,gCAAwB,GAAE,CAAC;IACzD,MAAM,aAAa,GAAG,IAAA,2CAAmC,EAAC;QACxD,MAAM,EAAE,qBAAqB,CAAC,MAAM;QACpC,QAAQ,EAAE,qBAAqB,CAAC,OAAO;KACxC,CAAC,CAAC;IAEH,IAAI,CAAC,aAAa;QAAE,OAAO,IAAI,CAAC;IAEhC,OAAO,8BAAC,2BAAiB,oBAAK,aAAa,EAAI,CAAC;AAClD,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@usereactify/search-internals/lib/components/basic/ReactiveComponent\";\nimport { useReactifySearchContext } from \"../../hooks\";\nimport { getPropsSensorCuratedPageCollection } from \"../../utility/props\";\n\nexport function SensorCuratedPageCollection() {\n const reactifySearchContext = useReactifySearchContext();\n const reactiveProps = getPropsSensorCuratedPageCollection({\n config: reactifySearchContext.config,\n provider: reactifySearchContext.options,\n });\n\n if (!reactiveProps) return null;\n\n return <ReactiveComponent {...reactiveProps} />;\n}\n"]}
|
|
@@ -8,4 +8,4 @@ export * from "./SensorInventoryAvailable";
|
|
|
8
8
|
export * from "./SensorCuratedPageCollection";
|
|
9
9
|
export * from "./SensorCuratedPageSearch";
|
|
10
10
|
export * from "./Sensors";
|
|
11
|
-
export declare const SENSOR_IDS: (mode: ReactifySearchMode, config: Config) => string[];
|
|
11
|
+
export declare const SENSOR_IDS: (mode: ReactifySearchMode, config: Config, variation?: string) => string[];
|
|
@@ -24,7 +24,7 @@ __exportStar(require("./SensorCuratedPageCollection"), exports);
|
|
|
24
24
|
__exportStar(require("./SensorCuratedPageSearch"), exports);
|
|
25
25
|
__exportStar(require("./Sensors"), exports);
|
|
26
26
|
// This is consumed by the react prop in various components
|
|
27
|
-
const SENSOR_IDS = (mode, config) => {
|
|
27
|
+
const SENSOR_IDS = (mode, config, variation) => {
|
|
28
28
|
const sensorIds = [
|
|
29
29
|
"SensorSort",
|
|
30
30
|
"SensorPublished",
|
|
@@ -34,7 +34,10 @@ const SENSOR_IDS = (mode, config) => {
|
|
|
34
34
|
"SensorCuratedPageCollection",
|
|
35
35
|
"SensorCuratedPageSearch",
|
|
36
36
|
];
|
|
37
|
-
const
|
|
37
|
+
const sensorType = mode === "collection" ? "collection" :
|
|
38
|
+
mode === "curated-page" && variation === "collection" ? "collection" :
|
|
39
|
+
"search";
|
|
40
|
+
const customSensors = sensorType === "collection" ? config.sensors.collection : config.sensors.search;
|
|
38
41
|
if (customSensors.length > 0) {
|
|
39
42
|
sensorIds.push(...customSensors.map((item, index) => `SensorCustom_${index}`));
|
|
40
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Sensor/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAGA,+CAA6B;AAC7B,oDAAkC;AAClC,qDAAmC;AACnC,qDAAmC;AACnC,6DAA2C;AAC3C,gEAA8C;AAC9C,4DAA0C;AAE1C,4CAA0B;AAE1B,2DAA2D;AACpD,MAAM,UAAU,GAAG,CAAC,IAAwB,EAAE,MAAc,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Sensor/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAGA,+CAA6B;AAC7B,oDAAkC;AAClC,qDAAmC;AACnC,qDAAmC;AACnC,6DAA2C;AAC3C,gEAA8C;AAC9C,4DAA0C;AAE1C,4CAA0B;AAE1B,2DAA2D;AACpD,MAAM,UAAU,GAAG,CAAC,IAAwB,EAAE,MAAc,EAAE,SAAkB,EAAE,EAAE;IACzF,MAAM,SAAS,GAAG;QAChB,YAAY;QACZ,iBAAiB;QACjB,kBAAkB;QAClB,kBAAkB;QAClB,0BAA0B;QAC1B,6BAA6B;QAC7B,yBAAyB;KAC1B,CAAC;IAEF,MAAM,UAAU,GACd,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;QACtC,IAAI,KAAK,cAAc,IAAI,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;YACtE,QAAQ,CAAC;IAEX,MAAM,aAAa,GAAG,UAAU,KAAK,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;IACtG,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,SAAS,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,gBAAgB,KAAK,EAAE,CAAC,CAAC,CAAC;IACjF,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAtBW,QAAA,UAAU,cAsBrB","sourcesContent":["import { ReactifySearchMode } from \"../../hooks\";\nimport { Config } from \"../../types\";\n\nexport * from \"./SensorSort\";\nexport * from \"./SensorPublished\";\nexport * from \"./SensorCollection\";\nexport * from \"./SensorSearchTerm\";\nexport * from \"./SensorInventoryAvailable\";\nexport * from \"./SensorCuratedPageCollection\";\nexport * from \"./SensorCuratedPageSearch\";\n\nexport * from \"./Sensors\";\n\n// This is consumed by the react prop in various components\nexport const SENSOR_IDS = (mode: ReactifySearchMode, config: Config, variation?: string) => {\n const sensorIds = [\n \"SensorSort\",\n \"SensorPublished\",\n \"SensorCollection\",\n \"SensorSearchTerm\",\n \"SensorInventoryAvailable\",\n \"SensorCuratedPageCollection\",\n \"SensorCuratedPageSearch\",\n ];\n \n const sensorType = \n mode === \"collection\" ? \"collection\" :\n mode === \"curated-page\" && variation === \"collection\" ? \"collection\" :\n \"search\";\n \n const customSensors = sensorType === \"collection\" ? config.sensors.collection : config.sensors.search;\n if (customSensors.length > 0) {\n sensorIds.push(...customSensors.map((item, index) => `SensorCustom_${index}`));\n }\n\n return sensorIds;\n};\n"]}
|
|
@@ -12,7 +12,8 @@ const Suggestions = (props) => {
|
|
|
12
12
|
const RenderComponent = (_a = props.render) !== null && _a !== void 0 ? _a : components_1.ExampleSuggestions;
|
|
13
13
|
const reactifySearchContext = (0, hooks_1.useReactifySearchContext)();
|
|
14
14
|
const { searchTerm } = (0, hooks_1.useSearch)();
|
|
15
|
-
const
|
|
15
|
+
const variation = reactifySearchContext.options.mode === "curated-page" ? reactifySearchContext.options.variation : undefined;
|
|
16
|
+
const sensorIds = (0, components_1.SENSOR_IDS)(reactifySearchContext.options.mode, reactifySearchContext.config, variation);
|
|
16
17
|
return (react_1.default.createElement(components_1.CustomComponent, { componentId: "SensorSuggestions", defaultQuery: () => {
|
|
17
18
|
return {
|
|
18
19
|
suggest: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Suggestions.js","sourceRoot":"","sources":["../../../../src/components/Suggestions/Suggestions.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,iDAI0B;AAC1B,uCAAkE;AAa3D,MAAM,WAAW,GAA+B,CAAC,KAAK,EAAE,EAAE;;IAC/D,MAAM,eAAe,GAAG,MAAA,KAAK,CAAC,MAAM,mCAAI,+BAAkB,CAAC;IAE3D,MAAM,qBAAqB,GAAG,IA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Ae,EAAE,CAAC;iCACnB,CAAC;yBACH;qBACF;iBACF;aACF,CAAC;QACJ,CAAC,EACD,KAAK,EAAE;YACL,GAAG,EAAE,SAAS;SACf,EACD,MAAM,EAAE,CAAC,WAAW,EAAE,EAAE;;YACtB,MAAM,KAAK,GAEP;gBACF,WAAW,EAAE,EAAE;aAChB,CAAC;YAEF,IAAI,MAAA,MAAA,WAAW,CAAC,OAAO,0CAAE,OAAO,0CAAE,WAAW,CAAC,MAAM,EAAE,CAAC;gBACrD,MAAM,OAAO,GAAG,MAAA,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,OAAO,CAAC;gBACrH,KAAK,CAAC,WAAW,GAAI,OAAiD;qBACnE,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC;qBAC9C,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,WAAC,OAAA,CAAC,CAAC,MAAA,qBAAqB,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA,EAAA,CAAC;qBACnG,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;oBAChB,IAAI,EAAE,MAAM,CAAC,IAAI;iBAClB,CAAC,CAAC,CAAC;YACR,CAAC;YAED,OAAO,8BAAC,eAAe,oBAAK,KAAK,EAAI,CAAC;QACxC,CAAC,GACD,CACH,CAAC;AACJ,CAAC,CAAC;AAxDW,QAAA,WAAW,eAwDtB","sourcesContent":["import React from \"react\";\n\nimport {\n CustomComponent,\n ExampleSuggestions,\n SENSOR_IDS,\n} from \"../../components\";\nimport { useReactifySearchContext, useSearch } from \"../../hooks\";\n\nexport type SuggestionsProps = {\n /** The field which should be used for autocompletion */\n field: \"title\";\n /** Render method */\n render?: React.FC<{\n suggestions: Array<{\n text: string;\n }>;\n }>;\n};\n\nexport const Suggestions: React.FC<SuggestionsProps> = (props) => {\n const RenderComponent = props.render ?? ExampleSuggestions;\n\n const reactifySearchContext = useReactifySearchContext();\n\n const { searchTerm } = useSearch();\n\n const variation = reactifySearchContext.options.mode === \"curated-page\" ? reactifySearchContext.options.variation : undefined;\n const sensorIds = SENSOR_IDS(reactifySearchContext.options.mode, reactifySearchContext.config, variation);\n\n return (\n <CustomComponent\n componentId=\"SensorSuggestions\"\n defaultQuery={() => {\n return {\n suggest: {\n suggestions: {\n text: searchTerm,\n phrase: {\n field: props.field,\n gram_size: 2,\n confidence: 0,\n direct_generator: [{\n field: props.field,\n suggest_mode: \"always\",\n min_word_length: 1,\n }],\n },\n },\n },\n };\n }}\n react={{\n and: sensorIds,\n }}\n render={(renderProps) => {\n const props: React.ComponentProps<\n NonNullable<SuggestionsProps[\"render\"]>\n > = {\n suggestions: [],\n };\n\n if (renderProps.rawData?.suggest?.suggestions.length) {\n const options = renderProps.rawData.suggest.suggestions[renderProps.rawData.suggest.suggestions.length - 1]?.options;\n props.suggestions = (options as Array<{ text: string; freq: number }>)\n .filter((option) => option.text !== searchTerm)\n .filter((option) => !(reactifySearchContext.config.suggestions.exclude ?? []).includes(option.text))\n .map((option) => ({\n text: option.text,\n }));\n }\n\n return <RenderComponent {...props} />;\n }}\n />\n );\n};\n"]}
|
|
@@ -3,32 +3,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getCuration = void 0;
|
|
4
4
|
const getCuration = (options) => {
|
|
5
5
|
var _a;
|
|
6
|
-
const handleOrSearchTerm = options.provider.mode === "collection"
|
|
7
|
-
|
|
8
|
-
.
|
|
9
|
-
|
|
6
|
+
const handleOrSearchTerm = options.provider.mode === "collection"
|
|
7
|
+
? options.provider.collectionHandle
|
|
8
|
+
: options.provider.mode === "curated-page" && options.provider.variation === "collection"
|
|
9
|
+
? options.provider.handle
|
|
10
|
+
: (_a = options.searchTerm) !== null && _a !== void 0 ? _a : "";
|
|
11
|
+
const normalisedHandleOrSearchTerm = handleOrSearchTerm.toLowerCase().trim();
|
|
10
12
|
const globalCuration = options.config.curations.find((curation) => {
|
|
11
|
-
if (options.provider.mode === "search") {
|
|
12
|
-
if (options.provider.market)
|
|
13
|
-
return curation.id === `global_${options.provider.market}_search`;
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
return curation.id === "global_search";
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
if (options.provider.mode === "instant-search") {
|
|
20
|
-
if (options.provider.market) {
|
|
13
|
+
if (options.provider.mode === "search" || options.provider.mode === "instant-search") {
|
|
14
|
+
if (options.provider.market)
|
|
21
15
|
return curation.id === `global_${options.provider.market}_search`;
|
|
22
|
-
|
|
23
|
-
else {
|
|
24
|
-
return curation.id === "global_search";
|
|
25
|
-
}
|
|
16
|
+
return curation.id === "global_search";
|
|
26
17
|
}
|
|
27
18
|
if (options.provider.mode === "collection") {
|
|
28
|
-
if (options.provider.market)
|
|
19
|
+
if (options.provider.market)
|
|
29
20
|
return curation.id === `global_${options.provider.market}_collection`;
|
|
21
|
+
return curation.id === "global_collection";
|
|
22
|
+
}
|
|
23
|
+
if (options.provider.mode === "curated-page") {
|
|
24
|
+
if (options.provider.variation === "search") {
|
|
25
|
+
if (options.provider.market)
|
|
26
|
+
return curation.id === `global_${options.provider.market}_search`;
|
|
27
|
+
return curation.id === "global_search";
|
|
30
28
|
}
|
|
31
|
-
|
|
29
|
+
if (options.provider.variation === "collection") {
|
|
30
|
+
if (options.provider.market)
|
|
31
|
+
return curation.id === `global_${options.provider.market}_collection`;
|
|
32
32
|
return curation.id === "global_collection";
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -39,21 +39,24 @@ const getCuration = (options) => {
|
|
|
39
39
|
var _a, _b;
|
|
40
40
|
const normalisedSearchTerm = (_a = curation.searchTerm) === null || _a === void 0 ? void 0 : _a.toLowerCase().trim();
|
|
41
41
|
const normalisedCollectionHandle = (_b = curation.collectionHandle) === null || _b === void 0 ? void 0 : _b.toLowerCase().trim();
|
|
42
|
-
if ("instant-search" === options.provider.mode) {
|
|
43
|
-
return
|
|
44
|
-
normalisedHandleOrSearchTerm === normalisedSearchTerm);
|
|
45
|
-
}
|
|
46
|
-
if ("search" === options.provider.mode) {
|
|
47
|
-
return ("search" === curation.type &&
|
|
48
|
-
normalisedHandleOrSearchTerm === normalisedSearchTerm);
|
|
42
|
+
if ("instant-search" === options.provider.mode || "search" === options.provider.mode) {
|
|
43
|
+
return "search" === curation.type && normalisedHandleOrSearchTerm === normalisedSearchTerm;
|
|
49
44
|
}
|
|
50
45
|
if ("collection" === options.provider.mode) {
|
|
51
|
-
return
|
|
52
|
-
|
|
46
|
+
return "collection" === curation.type && normalisedHandleOrSearchTerm === normalisedCollectionHandle;
|
|
47
|
+
}
|
|
48
|
+
if ("curated-page" === options.provider.mode) {
|
|
49
|
+
if (options.provider.variation === "search") {
|
|
50
|
+
return "search" === curation.type && normalisedHandleOrSearchTerm === normalisedSearchTerm;
|
|
51
|
+
}
|
|
52
|
+
if (options.provider.variation === "collection") {
|
|
53
|
+
return "collection" === curation.type && normalisedHandleOrSearchTerm === normalisedCollectionHandle;
|
|
54
|
+
}
|
|
53
55
|
}
|
|
54
56
|
return false;
|
|
55
57
|
});
|
|
56
|
-
const curationsMatchingMarketOrNoMarket = curationsMatchingQuery
|
|
58
|
+
const curationsMatchingMarketOrNoMarket = curationsMatchingQuery
|
|
59
|
+
.filter((curation) => {
|
|
57
60
|
var _a, _b, _c;
|
|
58
61
|
if (options.provider.market) {
|
|
59
62
|
if (((_a = curation.markets) === null || _a === void 0 ? void 0 : _a.length) === 0) {
|
|
@@ -66,7 +69,8 @@ const getCuration = (options) => {
|
|
|
66
69
|
else {
|
|
67
70
|
return ((_c = curation.markets) === null || _c === void 0 ? void 0 : _c.length) === 0;
|
|
68
71
|
}
|
|
69
|
-
})
|
|
72
|
+
})
|
|
73
|
+
.sort((curationA, curationB) => {
|
|
70
74
|
var _a, _b, _c, _d;
|
|
71
75
|
return ((_b = (_a = curationB.markets) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) - ((_d = (_c = curationA.markets) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0);
|
|
72
76
|
});
|
|
@@ -77,8 +81,7 @@ const getCuration = (options) => {
|
|
|
77
81
|
if (!globalCuration) {
|
|
78
82
|
return curation;
|
|
79
83
|
}
|
|
80
|
-
const curationHasRules = !!curation.boosting.groupings.length ||
|
|
81
|
-
!!curation.boosting.sortings.length;
|
|
84
|
+
const curationHasRules = !!curation.boosting.groupings.length || !!curation.boosting.sortings.length;
|
|
82
85
|
if (curationHasRules) {
|
|
83
86
|
return curation;
|
|
84
87
|
}
|