@usereactify/search 5.15.0 → 5.15.2
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 +9 -0
- package/dist/package.json +1 -1
- package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.d.ts +3 -5
- package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.js +4 -9
- package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.js.map +1 -1
- package/dist/src/components/Sensor/SensorSort.js +7 -10
- package/dist/src/components/Sensor/SensorSort.js.map +1 -1
- package/dist/src/components/Sensor/index.d.ts +0 -1
- package/dist/src/components/Sensor/index.js +0 -2
- package/dist/src/components/Sensor/index.js.map +1 -1
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.d.ts +1 -1
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.js +3 -3
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.js.map +1 -1
- package/dist/src/hooks/useReactifySearchContext.d.ts +4 -10
- package/dist/src/hooks/useReactifySearchContext.js.map +1 -1
- package/package.json +1 -1
- package/dist/src/components/Sensor/SensorSortScore.d.ts +0 -2
- package/dist/src/components/Sensor/SensorSortScore.js +0 -13
- package/dist/src/components/Sensor/SensorSortScore.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
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.15.2](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.15.1...release-v5.15.2) (2022-12-07)
|
|
6
|
+
|
|
7
|
+
### [5.15.1](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.15.0...release-v5.15.1) (2022-12-07)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* sort by collection position after curation pin and boost sorting rather than before ([593ee9d](https://bitbucket.org/usereactify/reactify-search-ui/commit/593ee9d2b9e46726a99e20e1e7a9782bf0bc4590))
|
|
13
|
+
|
|
5
14
|
## [5.15.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.14.1...release-v5.15.0) (2022-12-06)
|
|
6
15
|
|
|
7
16
|
|
package/dist/package.json
CHANGED
|
@@ -21,11 +21,9 @@ export declare type ReactifySearchProviderProps = {
|
|
|
21
21
|
/** Advanced usage: Override the default Reactify Search config (for multi-instance stores) */
|
|
22
22
|
configId?: string;
|
|
23
23
|
/** Advanced usage: Override the default Elasticsearch credentials */
|
|
24
|
-
credentials?:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
endpoint: string;
|
|
28
|
-
};
|
|
24
|
+
credentials?: string;
|
|
25
|
+
/** Advanced usage: Override the default Elasticsearch endpoint */
|
|
26
|
+
endpoint?: string;
|
|
29
27
|
/** Advanced usage: Override the default ReactiveBase theme */
|
|
30
28
|
theme?: Record<string, unknown>;
|
|
31
29
|
/** Advanced usage: Fields to include in the Elasticsearch response e.g. ["title"] */
|
|
@@ -44,14 +44,9 @@ const ReactifySearchProvider = (props) => {
|
|
|
44
44
|
};
|
|
45
45
|
exports.ReactifySearchProvider = ReactifySearchProvider;
|
|
46
46
|
const ReactifySearchInner = (props) => {
|
|
47
|
-
var _a
|
|
47
|
+
var _a;
|
|
48
48
|
const { config } = (0, hooks_1.useConfig)(props.shopifyPermanentDomain, props.configId);
|
|
49
|
-
const
|
|
50
|
-
username: "guest",
|
|
51
|
-
password: "password",
|
|
52
|
-
endpoint: "https://api.search.reactify.app",
|
|
53
|
-
};
|
|
54
|
-
const theme = (_b = props.theme) !== null && _b !== void 0 ? _b : {
|
|
49
|
+
const theme = (_a = props.theme) !== null && _a !== void 0 ? _a : {
|
|
55
50
|
typography: {
|
|
56
51
|
fontFamily: "inherit",
|
|
57
52
|
fontSize: "inherit",
|
|
@@ -89,13 +84,13 @@ const ReactifySearchInner = (props) => {
|
|
|
89
84
|
}
|
|
90
85
|
}, [searchSortFromURL]);
|
|
91
86
|
const contextValue = react_1.default.useMemo(() => {
|
|
92
|
-
var _a;
|
|
87
|
+
var _a, _b;
|
|
93
88
|
if (!config) {
|
|
94
89
|
return;
|
|
95
90
|
}
|
|
96
91
|
return {
|
|
97
92
|
config: config,
|
|
98
|
-
options: Object.assign(Object.assign({}, props), { index: (_a = props.index) !== null && _a !== void 0 ? _a : config.index, filtersHandle: props.filtersHandle, credentials: credentials, theme: theme }),
|
|
93
|
+
options: Object.assign(Object.assign({}, props), { index: (_a = props.index) !== null && _a !== void 0 ? _a : config.index, filtersHandle: props.filtersHandle, credentials: props.credentials, endpoint: (_b = props.endpoint) !== null && _b !== void 0 ? _b : "https://api.search.reactify.app", theme: theme }),
|
|
99
94
|
search: {
|
|
100
95
|
searchTerm: searchTerm,
|
|
101
96
|
setSearchTerm: setSearchTerm,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactifySearchProvider.js","sourceRoot":"","sources":["../../../../src/components/ReactifySearchProvider/ReactifySearchProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,sDAAwC;AAExC,uCAA+D;AAC/D,iDAAoE;AACpE,2CAAsC;AAkD/B,MAAM,sBAAsB,GAA0C,CAC3E,KAAK,EACL,EAAE;IACF,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,eAAK,CAAC,GAAG,CAAC,wBAAwB,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAEpD,MAAM,CAAC,OAAO,CAAC;YACb,sBAAsB,EAAE,KAAK,CAAC,KAAK;YACnC,qBAAqB,EAAE,KAAK,CAAC,sBAAsB;YACnD,qBAAqB,EAAE,KAAK,CAAC,IAAI;YACjC,2BAA2B,EACzB,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS;YAClE,uBAA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ACJ,CAClC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport * as Sentry from \"@sentry/react\";\n\nimport { ReactifySearchContext, useConfig } from \"../../hooks\";\nimport { UtilityAuthenticatedReactiveBase } from \"../../components\";\nimport { debug } from \"../../utility\";\nimport { ReactivesearchResultProps } from \"../../types\";\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\";\n /** Shopify store domain used to resolve the site configuration */\n shopifyPermanentDomain: 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 Filters selection logic */\n filtersHandle?: string;\n /** Advanced usage: Allows you to wrap the ReactifySearchProvider in your own ReactiveBase component */\n noReactiveBase?: boolean;\n /** Advanced usage: Array of additional component IDs managed outside of Reactify Search */\n additionalComponentIds?: 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?: {\n username: string;\n password: string;\n endpoint: string;\n };\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?: string[];\n /** Advanced usage: Fields to exclude from the Elasticsearch response e.g. [\"variant_skus\", \"*price*\"] */\n excludeFields?: string[];\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 | {\n mode: \"instant-search\";\n }\n);\n\nexport const ReactifySearchProvider: React.FC<ReactifySearchProviderProps> = (\n props\n) => {\n React.useEffect(() => {\n debug.log(\"ReactifySearchProvider\", \"props\", props);\n\n Sentry.setTags({\n \"reactifysearch.index\": props.index,\n \"reactifysearch.shop\": props.shopifyPermanentDomain,\n \"reactifysearch.mode\": props.mode,\n \"reactifysearch.collection\":\n props.mode === \"collection\" ? props.collectionHandle : undefined,\n \"reactifysearch.filter\": props.filtersHandle,\n });\n }, [props]);\n\n return (\n <Sentry.ErrorBoundary fallback={<p>An error has occurred</p>}>\n <ReactifySearchInner {...props} />\n </Sentry.ErrorBoundary>\n );\n};\n\nconst ReactifySearchInner: React.FC<ReactifySearchProviderProps> = (props) => {\n const { config } = useConfig(props.shopifyPermanentDomain, props.configId);\n\n const credentials = props.credentials ?? {\n username: \"guest\",\n password: \"password\",\n endpoint: \"https://api.search.reactify.app\",\n };\n\n const theme = props.theme ?? {\n typography: {\n fontFamily: \"inherit\",\n fontSize: \"inherit\",\n },\n };\n\n const searchTermFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"q\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n const searchSortFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"sort\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n const [searchTerm, setSearchTerm] = React.useState<string>(\n searchTermFromURL ?? \"\"\n );\n const [showInstantSearchResults, setShowInstantSearchResults] =\n React.useState<boolean>(false);\n const [sortOption, setSortOption] = React.useState<string>(\n searchSortFromURL ?? \"\"\n );\n\n const [results, setResults] = React.useState<\n ReactivesearchResultProps[\"data\"]\n >([]);\n const [resultStats, setResultStats] =\n React.useState<ReactivesearchResultProps[\"resultStats\"]>();\n\n React.useEffect(() => {\n if (searchTermFromURL && searchTerm !== searchTermFromURL) {\n setSearchTerm(searchTermFromURL);\n }\n }, [searchTermFromURL]);\n\n React.useEffect(() => {\n if (searchSortFromURL && sortOption !== searchSortFromURL) {\n setSortOption(searchSortFromURL);\n }\n }, [searchSortFromURL]);\n\n const contextValue = React.useMemo(() => {\n if (!config) {\n return;\n }\n\n return {\n config: config,\n options: {\n ...props,\n index: props.index ?? config.index,\n filtersHandle: props.filtersHandle,\n credentials: credentials,\n theme: theme,\n },\n search: {\n searchTerm: searchTerm,\n setSearchTerm: setSearchTerm,\n showInstantSearchResults: showInstantSearchResults,\n setShowInstantSearchResults: setShowInstantSearchResults,\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 };\n }, [\n config,\n props,\n searchTerm,\n showInstantSearchResults,\n sortOption,\n results,\n resultStats,\n ]);\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 if (props.noReactiveBase) {\n return (\n <ReactifySearchContext.Provider value={contextValue}>\n {props.children}\n </ReactifySearchContext.Provider>\n );\n }\n\n return (\n <ReactifySearchContext.Provider value={contextValue}>\n <UtilityAuthenticatedReactiveBase>\n {props.children}\n </UtilityAuthenticatedReactiveBase>\n </ReactifySearchContext.Provider>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"ReactifySearchProvider.js","sourceRoot":"","sources":["../../../../src/components/ReactifySearchProvider/ReactifySearchProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,sDAAwC;AAExC,uCAA+D;AAC/D,iDAAoE;AACpE,2CAAsC;AAgD/B,MAAM,sBAAsB,GAA0C,CAC3E,KAAK,EACL,EAAE;IACF,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,eAAK,CAAC,GAAG,CAAC,wBAAwB,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAEpD,MAAM,CAAC,OAAO,CAAC;YACb,sBAAsB,EAAE,KAAK,CAAC,KAAK;YACnC,qBAAqB,EAAE,KAAK,CAAC,sBAAsB;Y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C,QAAQ,IAAC,KAAK,EAAE,YAAY;QACjD,8BAAC,6CAAgC,QAC9B,KAAK,CAAC,QAAQ,CACkB,CACJ,CAClC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport * as Sentry from \"@sentry/react\";\n\nimport { ReactifySearchContext, useConfig } from \"../../hooks\";\nimport { UtilityAuthenticatedReactiveBase } from \"../../components\";\nimport { debug } from \"../../utility\";\nimport { ReactivesearchResultProps } from \"../../types\";\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\";\n /** Shopify store domain used to resolve the site configuration */\n shopifyPermanentDomain: 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 Filters selection logic */\n filtersHandle?: string;\n /** Advanced usage: Allows you to wrap the ReactifySearchProvider in your own ReactiveBase component */\n noReactiveBase?: boolean;\n /** Advanced usage: Array of additional component IDs managed outside of Reactify Search */\n additionalComponentIds?: 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 Elasticsearch endpoint */\n endpoint?: 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?: string[];\n /** Advanced usage: Fields to exclude from the Elasticsearch response e.g. [\"variant_skus\", \"*price*\"] */\n excludeFields?: string[];\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 | {\n mode: \"instant-search\";\n }\n);\n\nexport const ReactifySearchProvider: React.FC<ReactifySearchProviderProps> = (\n props\n) => {\n React.useEffect(() => {\n debug.log(\"ReactifySearchProvider\", \"props\", props);\n\n Sentry.setTags({\n \"reactifysearch.index\": props.index,\n \"reactifysearch.shop\": props.shopifyPermanentDomain,\n \"reactifysearch.mode\": props.mode,\n \"reactifysearch.collection\":\n props.mode === \"collection\" ? props.collectionHandle : undefined,\n \"reactifysearch.filter\": props.filtersHandle,\n });\n }, [props]);\n\n return (\n <Sentry.ErrorBoundary fallback={<p>An error has occurred</p>}>\n <ReactifySearchInner {...props} />\n </Sentry.ErrorBoundary>\n );\n};\n\nconst ReactifySearchInner: React.FC<ReactifySearchProviderProps> = (props) => {\n const { config } = useConfig(props.shopifyPermanentDomain, props.configId);\n\n const theme = props.theme ?? {\n typography: {\n fontFamily: \"inherit\",\n fontSize: \"inherit\",\n },\n };\n\n const searchTermFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"q\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n const searchSortFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"sort\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n const [searchTerm, setSearchTerm] = React.useState<string>(\n searchTermFromURL ?? \"\"\n );\n const [showInstantSearchResults, setShowInstantSearchResults] =\n React.useState<boolean>(false);\n const [sortOption, setSortOption] = React.useState<string>(\n searchSortFromURL ?? \"\"\n );\n\n const [results, setResults] = React.useState<\n ReactivesearchResultProps[\"data\"]\n >([]);\n const [resultStats, setResultStats] =\n React.useState<ReactivesearchResultProps[\"resultStats\"]>();\n\n React.useEffect(() => {\n if (searchTermFromURL && searchTerm !== searchTermFromURL) {\n setSearchTerm(searchTermFromURL);\n }\n }, [searchTermFromURL]);\n\n React.useEffect(() => {\n if (searchSortFromURL && sortOption !== searchSortFromURL) {\n setSortOption(searchSortFromURL);\n }\n }, [searchSortFromURL]);\n\n const contextValue = React.useMemo(() => {\n if (!config) {\n return;\n }\n\n return {\n config: config,\n options: {\n ...props,\n index: props.index ?? config.index,\n filtersHandle: props.filtersHandle,\n credentials: props.credentials,\n endpoint: props.endpoint ?? \"https://api.search.reactify.app\",\n theme: theme,\n },\n search: {\n searchTerm: searchTerm,\n setSearchTerm: setSearchTerm,\n showInstantSearchResults: showInstantSearchResults,\n setShowInstantSearchResults: setShowInstantSearchResults,\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 };\n }, [\n config,\n props,\n searchTerm,\n showInstantSearchResults,\n sortOption,\n results,\n resultStats,\n ]);\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 if (props.noReactiveBase) {\n return (\n <ReactifySearchContext.Provider value={contextValue}>\n {props.children}\n </ReactifySearchContext.Provider>\n );\n }\n\n return (\n <ReactifySearchContext.Provider value={contextValue}>\n <UtilityAuthenticatedReactiveBase>\n {props.children}\n </UtilityAuthenticatedReactiveBase>\n </ReactifySearchContext.Provider>\n );\n};\n"]}
|
|
@@ -43,11 +43,8 @@ const buildSort = (args) => {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
const sorts = [];
|
|
46
|
-
// collection
|
|
46
|
+
// collection curation pin sorting
|
|
47
47
|
if (mode === "collection" && collectionHandle) {
|
|
48
|
-
if (!curation || (curation === null || curation === void 0 ? void 0 : curation.id) === "global") {
|
|
49
|
-
sorts.push(...mapCollectionPositionSortClause(collectionHandle));
|
|
50
|
-
}
|
|
51
48
|
if (curation === null || curation === void 0 ? void 0 : curation.collectionHandle) {
|
|
52
49
|
sorts.push({
|
|
53
50
|
"curations.position": {
|
|
@@ -65,7 +62,7 @@ const buildSort = (args) => {
|
|
|
65
62
|
});
|
|
66
63
|
}
|
|
67
64
|
}
|
|
68
|
-
// search
|
|
65
|
+
// search curation pin sorting
|
|
69
66
|
if (mode === "search" || mode === "instant-search") {
|
|
70
67
|
if (curation === null || curation === void 0 ? void 0 : curation.searchTerm) {
|
|
71
68
|
sorts.push({
|
|
@@ -84,7 +81,7 @@ const buildSort = (args) => {
|
|
|
84
81
|
});
|
|
85
82
|
}
|
|
86
83
|
}
|
|
87
|
-
// curation
|
|
84
|
+
// curation boost sorting
|
|
88
85
|
if (curation) {
|
|
89
86
|
if (curation.id !== "global" || mode === "collection") {
|
|
90
87
|
if (0 < curation.boosting.groupings.length) {
|
|
@@ -115,11 +112,11 @@ const buildSort = (args) => {
|
|
|
115
112
|
}
|
|
116
113
|
}
|
|
117
114
|
}
|
|
118
|
-
//
|
|
119
|
-
if (mode === "collection" &&
|
|
120
|
-
sorts.push(
|
|
115
|
+
// default collection sorting
|
|
116
|
+
if (mode === "collection" && collectionHandle) {
|
|
117
|
+
sorts.push(...mapCollectionPositionSortClause(collectionHandle));
|
|
121
118
|
}
|
|
122
|
-
//
|
|
119
|
+
// default search sorting
|
|
123
120
|
if (mode === "search" || mode === "instant-search") {
|
|
124
121
|
sorts.push("_score");
|
|
125
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SensorSort.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorSort.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;AAGjG,uCAKqB;AAEd,MAAM,UAAU,GAAa,GAAG,EAAE;IACvC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IACvD,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAA,mBAAW,GAAE,CAAC;IAEnC,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,iBAAS,GAAE,CAAC;IAEnC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,eAA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CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC;oBAC5D,CAAC,CAAC;wBACE;4BACE,IAAI,EAAE;gCACJ,IAAI,EAAE,SAAS;6BAChB;yBACF;qBACF;oBACH,CAAC,CAAC,EAAE,CAAC;aACR;SACF;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent\";\n\nimport { ConfigCuration, ConfigSort } from \"../../types\";\nimport {\n useReactifySearchContext,\n useSortBy,\n useCuration,\n ReactifySearchMode,\n} from \"../../hooks\";\n\nexport const SensorSort: React.FC = () => {\n const { options, config } = useReactifySearchContext();\n const { curation } = useCuration();\n\n const { sortOption } = useSortBy();\n\n const { sort, query } = React.useMemo(() => {\n return {\n sort: buildSort({\n mode: options.mode,\n curation,\n sortOption,\n collectionHandle:\n options.mode === \"collection\" ? options.collectionHandle : undefined,\n }),\n query: buildQuery({\n sortOption,\n curation,\n }),\n };\n }, [options, config, sortOption, curation]);\n\n return (\n <ReactiveComponent\n componentId=\"SensorSort\"\n customQuery={() => ({\n sort,\n query,\n })}\n />\n );\n};\n\nconst buildSort = (args: {\n mode: ReactifySearchMode;\n curation?: ConfigCuration;\n sortOption?: ConfigSort;\n collectionHandle?: string;\n}): any[] => {\n const { mode, curation, sortOption, collectionHandle } = args;\n\n // curation positions are only applied for the default `collections.position` or `_score` sort\n // if the sort is something else, apply a normal sort which applies what the user has requested\n if (mode !== \"instant-search\") {\n if (\n sortOption &&\n ![\"_score\", \"collections.position\"].includes(sortOption.field)\n ) {\n return [{ [sortOption.field]: sortOption.direction }];\n }\n }\n\n const sorts = [];\n\n // collection specific sorting\n if (mode === \"collection\" && collectionHandle) {\n if (!curation || curation?.id === \"global\") {\n sorts.push(...mapCollectionPositionSortClause(collectionHandle));\n }\n\n if (curation?.collectionHandle) {\n sorts.push({\n \"curations.position\": {\n unmapped_type: \"long\",\n order: \"asc\",\n nested: {\n path: \"curations\",\n filter: {\n term: {\n [`curations.collectionHandle.keyword`]:\n curation.collectionHandle,\n },\n },\n },\n },\n });\n }\n }\n\n // search specific sorting\n if (mode === \"search\" || mode === \"instant-search\") {\n if (curation?.searchTerm) {\n sorts.push({\n \"curations.position\": {\n unmapped_type: \"long\",\n order: \"asc\",\n nested: {\n path: \"curations\",\n filter: {\n term: {\n [`curations.searchTerm.keyword`]:\n curation.searchTerm?.toLowerCase(),\n },\n },\n },\n },\n });\n }\n }\n\n // curation specific sorting\n if (curation) {\n if (curation.id !== \"global\" || mode === \"collection\") {\n if (0 < curation.boosting.groupings.length) {\n const groupings = curation.boosting.groupings.sort((a, b) =>\n a.position > b.position ? 1 : -1\n );\n\n for (const grouping of groupings) {\n try {\n const query = JSON.parse(grouping.query);\n if (query) sorts.push(query);\n } catch {\n console.error(\n `query could not be parsed for boost grouping`,\n grouping\n );\n }\n }\n }\n\n if (0 < curation.boosting.sortings.length) {\n const sortings = curation.boosting.sortings.sort((a, b) =>\n a.position > b.position ? 1 : -1\n );\n\n for (const sorting of sortings) {\n try {\n const query = JSON.parse(sorting.query);\n if (query) sorts.push(query);\n } catch {\n console.error(\n `query could not be parsed for boost sorting`,\n sorting\n );\n }\n }\n }\n }\n }\n\n // finally for collections if no other sorting is defined, sort by index order to provide a consistent order\n if (mode === \"collection\" && sorts.length === 0) {\n sorts.push(\"_doc\");\n }\n\n // finally for search sort by score\n if (mode === \"search\" || mode === \"instant-search\") {\n sorts.push(\"_score\");\n }\n\n return sorts;\n};\n\n/**\n * Return a sort clause which sorts by position within the given collection.\n */\nfunction mapCollectionPositionSortClause(collectionHandle: string) {\n return [\n {\n \"collections.position\": {\n order: \"asc\",\n nested: {\n path: \"collections\",\n filter: {\n term: {\n \"collections.handle.keyword\": collectionHandle,\n },\n },\n },\n },\n },\n ];\n}\n\nconst buildQuery = (args: {\n sortOption?: ConfigSort;\n curation?: ConfigCuration;\n}): Record<string, any> | undefined => {\n const { curation, sortOption } = args;\n\n if (!curation || curation.id === \"global\") {\n return undefined;\n }\n\n return {\n bool: {\n must_not: [\n {\n nested: {\n path: \"curations\",\n query: {\n bool: {\n must: [\n {\n term: {\n [`curations.${\n \"collection\" === curation.type\n ? \"collectionHandle\"\n : \"searchTerm\"\n }.keyword`]:\n \"collection\" === curation.type\n ? curation.collectionHandle\n : curation.searchTerm?.toLowerCase(),\n },\n },\n {\n term: {\n \"curations.hidden\": true,\n },\n },\n ],\n },\n },\n },\n },\n // hide callout when not sorting by _score or collections.position\n ...(sortOption &&\n ![\"_score\", \"collections.position\"].includes(sortOption.field)\n ? [\n {\n term: {\n type: \"callout\",\n },\n },\n ]\n : []),\n ],\n },\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"SensorSort.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorSort.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;AAGjG,uCAKqB;AAEd,MAAM,UAAU,GAAa,GAAG,EAAE;IACvC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IACvD,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAA,mBAAW,GAAE,CAAC;IAEnC,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,iBAAS,GAAE,CAAC;IAEnC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACzC,OAAO;YACL,IAAI,EAAE,SAAS,CAAC;gBACd,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,QAAQ;gBACR,UAAU;gBACV,gBAAgB,EACd,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS;aACvE,CAAC;YACF,KAAK,EAAE,UAAU,CAAC;gBAChB,UAAU;gBACV,QAAQ;aACT,CAAC;SACH,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,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KAAK,QAAQ,EAAE;QACzC,OAAO,SAAS,CAAC;KAClB;IAED,OAAO;QACL,IAAI,EAAE;YACJ,QAAQ,EAAE;gBACR;oBACE,MAAM,EAAE;wBACN,IAAI,EAAE,WAAW;wBACjB,KAAK,EAAE;4BACL,IAAI,EAAE;gCACJ,IAAI,EAAE;oCACJ;wCACE,IAAI,EAAE;4CACJ,CAAC,aACC,YAAY,KAAK,QAAQ,CAAC,IAAI;gDAC5B,CAAC,CAAC,kBAAkB;gDACpB,CAAC,CAAC,YACN,UAAU,CAAC,EACT,YAAY,KAAK,QAAQ,CAAC,IAAI;gDAC5B,CAAC,CAAC,QAAQ,CAAC,gBAAgB;gDAC3B,CAAC,CAAC,MAAA,QAAQ,CAAC,UAAU,0CAAE,WAAW,EAAE;yCACzC;qCACF;oCACD;wCACE,IAAI,EAAE;4CACJ,kBAAkB,EAAE,IAAI;yCACzB;qCACF;iCACF;6BACF;yBACF;qBACF;iBACF;gBACD,kEAAkE;gBAClE,GAAG,CAAC,UAAU;oBACd,CAAC,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC;oBAC5D,CAAC,CAAC;wBACE;4BACE,IAAI,EAAE;gCACJ,IAAI,EAAE,SAAS;6BAChB;yBACF;qBACF;oBACH,CAAC,CAAC,EAAE,CAAC;aACR;SACF;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent\";\n\nimport { ConfigCuration, ConfigSort } from \"../../types\";\nimport {\n useReactifySearchContext,\n useSortBy,\n useCuration,\n ReactifySearchMode,\n} from \"../../hooks\";\n\nexport const SensorSort: React.FC = () => {\n const { options, config } = useReactifySearchContext();\n const { curation } = useCuration();\n\n const { sortOption } = useSortBy();\n\n const { sort, query } = React.useMemo(() => {\n return {\n sort: buildSort({\n mode: options.mode,\n curation,\n sortOption,\n collectionHandle:\n options.mode === \"collection\" ? options.collectionHandle : undefined,\n }),\n query: buildQuery({\n sortOption,\n curation,\n }),\n };\n }, [options, config, sortOption, curation]);\n\n return (\n <ReactiveComponent\n componentId=\"SensorSort\"\n customQuery={() => ({\n sort,\n query,\n })}\n />\n );\n};\n\nconst buildSort = (args: {\n mode: ReactifySearchMode;\n curation?: ConfigCuration;\n sortOption?: ConfigSort;\n collectionHandle?: string;\n}): any[] => {\n const { mode, curation, sortOption, collectionHandle } = args;\n\n // curation positions are only applied for the default `collections.position` or `_score` sort\n // if the sort is something else, apply a normal sort which applies what the user has requested\n if (mode !== \"instant-search\") {\n if (\n sortOption &&\n ![\"_score\", \"collections.position\"].includes(sortOption.field)\n ) {\n return [{ [sortOption.field]: sortOption.direction }];\n }\n }\n\n const sorts = [];\n\n // collection curation pin sorting\n if (mode === \"collection\" && collectionHandle) {\n if (curation?.collectionHandle) {\n sorts.push({\n \"curations.position\": {\n unmapped_type: \"long\",\n order: \"asc\",\n nested: {\n path: \"curations\",\n filter: {\n term: {\n [`curations.collectionHandle.keyword`]:\n curation.collectionHandle,\n },\n },\n },\n },\n });\n }\n }\n\n // search curation pin sorting\n if (mode === \"search\" || mode === \"instant-search\") {\n if (curation?.searchTerm) {\n sorts.push({\n \"curations.position\": {\n unmapped_type: \"long\",\n order: \"asc\",\n nested: {\n path: \"curations\",\n filter: {\n term: {\n [`curations.searchTerm.keyword`]:\n curation.searchTerm?.toLowerCase(),\n },\n },\n },\n },\n });\n }\n }\n\n // curation boost sorting\n if (curation) {\n if (curation.id !== \"global\" || mode === \"collection\") {\n if (0 < curation.boosting.groupings.length) {\n const groupings = curation.boosting.groupings.sort((a, b) =>\n a.position > b.position ? 1 : -1\n );\n\n for (const grouping of groupings) {\n try {\n const query = JSON.parse(grouping.query);\n if (query) sorts.push(query);\n } catch {\n console.error(\n `query could not be parsed for boost grouping`,\n grouping\n );\n }\n }\n }\n\n if (0 < curation.boosting.sortings.length) {\n const sortings = curation.boosting.sortings.sort((a, b) =>\n a.position > b.position ? 1 : -1\n );\n\n for (const sorting of sortings) {\n try {\n const query = JSON.parse(sorting.query);\n if (query) sorts.push(query);\n } catch {\n console.error(\n `query could not be parsed for boost sorting`,\n sorting\n );\n }\n }\n }\n }\n }\n\n // default collection sorting\n if (mode === \"collection\" && collectionHandle) {\n sorts.push(...mapCollectionPositionSortClause(collectionHandle));\n }\n\n // default search sorting\n if (mode === \"search\" || mode === \"instant-search\") {\n sorts.push(\"_score\");\n }\n\n return sorts;\n};\n\n/**\n * Return a sort clause which sorts by position within the given collection.\n */\nfunction mapCollectionPositionSortClause(collectionHandle: string) {\n return [\n {\n \"collections.position\": {\n order: \"asc\",\n nested: {\n path: \"collections\",\n filter: {\n term: {\n \"collections.handle.keyword\": collectionHandle,\n },\n },\n },\n },\n },\n ];\n}\n\nconst buildQuery = (args: {\n sortOption?: ConfigSort;\n curation?: ConfigCuration;\n}): Record<string, any> | undefined => {\n const { curation, sortOption } = args;\n\n if (!curation || curation.id === \"global\") {\n return undefined;\n }\n\n return {\n bool: {\n must_not: [\n {\n nested: {\n path: \"curations\",\n query: {\n bool: {\n must: [\n {\n term: {\n [`curations.${\n \"collection\" === curation.type\n ? \"collectionHandle\"\n : \"searchTerm\"\n }.keyword`]:\n \"collection\" === curation.type\n ? curation.collectionHandle\n : curation.searchTerm?.toLowerCase(),\n },\n },\n {\n term: {\n \"curations.hidden\": true,\n },\n },\n ],\n },\n },\n },\n },\n // hide callout when not sorting by _score or collections.position\n ...(sortOption &&\n ![\"_score\", \"collections.position\"].includes(sortOption.field)\n ? [\n {\n term: {\n type: \"callout\",\n },\n },\n ]\n : []),\n ],\n },\n };\n};\n"]}
|
|
@@ -13,7 +13,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
exports.SENSOR_IDS = void 0;
|
|
14
14
|
__exportStar(require("./SensorSort"), exports);
|
|
15
15
|
__exportStar(require("./SensorPublished"), exports);
|
|
16
|
-
__exportStar(require("./SensorSortScore"), exports);
|
|
17
16
|
__exportStar(require("./SensorCollection"), exports);
|
|
18
17
|
__exportStar(require("./SensorSearchTerm"), exports);
|
|
19
18
|
__exportStar(require("./SensorInventoryAvailable"), exports);
|
|
@@ -21,7 +20,6 @@ __exportStar(require("./Sensors"), exports);
|
|
|
21
20
|
// this is consumed by the react prop in various components
|
|
22
21
|
exports.SENSOR_IDS = [
|
|
23
22
|
"SensorSort",
|
|
24
|
-
"SensorSortScore",
|
|
25
23
|
"SensorPublished",
|
|
26
24
|
"SensorCollection",
|
|
27
25
|
"SensorSearchTerm",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Sensor/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,oDAAkC;AAClC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Sensor/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,oDAAkC;AAClC,qDAAmC;AACnC,qDAAmC;AACnC,6DAA2C;AAE3C,4CAA0B;AAE1B,2DAA2D;AAC9C,QAAA,UAAU,GAAG;IACxB,YAAY;IACZ,iBAAiB;IACjB,kBAAkB;IAClB,kBAAkB;IAClB,0BAA0B;CAC3B,CAAC","sourcesContent":["export * from \"./SensorSort\";\nexport * from \"./SensorPublished\";\nexport * from \"./SensorCollection\";\nexport * from \"./SensorSearchTerm\";\nexport * from \"./SensorInventoryAvailable\";\n\nexport * from \"./Sensors\";\n\n// this is consumed by the react prop in various components\nexport const SENSOR_IDS = [\n \"SensorSort\",\n \"SensorPublished\",\n \"SensorCollection\",\n \"SensorSearchTerm\",\n \"SensorInventoryAvailable\",\n];\n"]}
|
|
@@ -19,8 +19,8 @@ const useReactiveBaseProps = () => {
|
|
|
19
19
|
const { options } = (0, hooks_1.useReactifySearchContext)();
|
|
20
20
|
const reactiveBaseProps = react_1.default.useMemo(() => ({
|
|
21
21
|
app: options.index,
|
|
22
|
-
url: options.
|
|
23
|
-
credentials:
|
|
22
|
+
url: options.endpoint,
|
|
23
|
+
credentials: options.credentials,
|
|
24
24
|
theme: options.theme,
|
|
25
25
|
transformResponse: (response) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
26
|
var _a, _b, _c, _d;
|
|
@@ -38,7 +38,7 @@ const useReactiveBaseProps = () => {
|
|
|
38
38
|
}
|
|
39
39
|
return response;
|
|
40
40
|
}),
|
|
41
|
-
}), [options.credentials, options.theme]);
|
|
41
|
+
}), [options.index, options.endpoint, options.credentials, options.theme]);
|
|
42
42
|
return reactiveBaseProps;
|
|
43
43
|
};
|
|
44
44
|
exports.useReactiveBaseProps = useReactiveBaseProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReactiveBaseProps.js","sourceRoot":"","sources":["../../../../src/hooks/reactivesearch/useReactiveBaseProps.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,uCAAuD;AAEhD,MAAM,oBAAoB,GAAG,GAAG,EAAE;IACvC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAE/C,MAAM,iBAAiB,GAAG,eAAK,CAAC,OAAO,CACrC,GAAG,EAAE,CAAC,CAAC;QACL,GAAG,EAAE,OAAO,CAAC,KAAK;QAClB,GAAG,EAAE,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"useReactiveBaseProps.js","sourceRoot":"","sources":["../../../../src/hooks/reactivesearch/useReactiveBaseProps.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,uCAAuD;AAEhD,MAAM,oBAAoB,GAAG,GAAG,EAAE;IACvC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAE/C,MAAM,iBAAiB,GAAG,eAAK,CAAC,OAAO,CACrC,GAAG,EAAE,CAAC,CAAC;QACL,GAAG,EAAE,OAAO,CAAC,KAAK;QAClB,GAAG,EAAE,OAAO,CAAC,QAAQ;QACrB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,iBAAiB,EAAE,CAAO,QAAa,EAAE,EAAE;;YACzC,+EAA+E;YAC/E,uDAAuD;YACvD,EAAE;YACF,qFAAqF;YACrF,qFAAqF;YACrF,kEAAkE;YAClE,EAAE;YACF,0DAA0D;YAC1D,IACE,MAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,YAAY,0CAAE,qBAAqB,0CAAE,qBAAqB,EACpE;gBACA,QAAQ,CAAC,YAAY,CAAC,qBAAqB;oBACzC,MAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,YAAY,0CAAE,qBAAqB,0CAAE,qBAAqB,CAAC;aACxE;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC,CAAA;KACF,CAAC,EACF,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,CACtE,CAAC;IAEF,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAhCW,QAAA,oBAAoB,wBAgC/B","sourcesContent":["import React from \"react\";\nimport { useReactifySearchContext } from \"../../hooks\";\n\nexport const useReactiveBaseProps = () => {\n const { options } = useReactifySearchContext();\n\n const reactiveBaseProps = React.useMemo(\n () => ({\n app: options.index,\n url: options.endpoint,\n credentials: options.credentials,\n theme: options.theme,\n transformResponse: async (response: any) => {\n // support filtering inside nested aggregations by moving the inner aggregation\n // up one level such that reactivesearch understands it\n //\n // see useReactiveFilterListProps > defaultQuery to see how a filter is being applied\n // to variant aggregations to ensure that only in stock sizes are displayed as filter\n // options, this involves a nested filter, which requires this fix\n //\n // https://github.com/appbaseio/reactivesearch/issues/1530\n if (\n response?.aggregations?.reactivesearch_nested?.reactify_nested_outer\n ) {\n response.aggregations.reactivesearch_nested =\n response?.aggregations?.reactivesearch_nested?.reactify_nested_outer;\n }\n\n return response;\n },\n }),\n [options.index, options.endpoint, options.credentials, options.theme]\n );\n\n return reactiveBaseProps;\n};\n"]}
|
|
@@ -8,11 +8,8 @@ export declare const ReactifySearchContext: React.Context<{
|
|
|
8
8
|
index: string;
|
|
9
9
|
shopifyPermanentDomain: string;
|
|
10
10
|
filtersHandle?: string | undefined;
|
|
11
|
-
credentials
|
|
12
|
-
|
|
13
|
-
password: string;
|
|
14
|
-
endpoint: string;
|
|
15
|
-
};
|
|
11
|
+
credentials?: string | undefined;
|
|
12
|
+
endpoint: string;
|
|
16
13
|
onRedirect?: ((type: "redirect" | "search", url: string) => void) | undefined;
|
|
17
14
|
theme: Record<string, unknown>;
|
|
18
15
|
additionalComponentIds?: string[] | undefined;
|
|
@@ -50,11 +47,8 @@ export declare const useReactifySearchContext: () => {
|
|
|
50
47
|
index: string;
|
|
51
48
|
shopifyPermanentDomain: string;
|
|
52
49
|
filtersHandle?: string | undefined;
|
|
53
|
-
credentials
|
|
54
|
-
|
|
55
|
-
password: string;
|
|
56
|
-
endpoint: string;
|
|
57
|
-
};
|
|
50
|
+
credentials?: string | undefined;
|
|
51
|
+
endpoint: string;
|
|
58
52
|
onRedirect?: ((type: "redirect" | "search", url: string) => void) | undefined;
|
|
59
53
|
theme: Record<string, unknown>;
|
|
60
54
|
additionalComponentIds?: string[] | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReactifySearchContext.js","sourceRoot":"","sources":["../../../src/hooks/useReactifySearchContext.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAMb,QAAA,qBAAqB,GAAG,eAAK,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"useReactifySearchContext.js","sourceRoot":"","sources":["../../../src/hooks/useReactifySearchContext.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAMb,QAAA,qBAAqB,GAAG,eAAK,CAAC,aAAa,CAqDtD,SAAS,CAAC,CAAC;AAEN,MAAM,wBAAwB,GAAG,GAAG,EAAE,CAC3C,eAAK,CAAC,UAAU,CAAC,6BAAqB,CAAE,CAAC;AAD9B,QAAA,wBAAwB,4BACM","sourcesContent":["import React from \"react\";\n\nimport { Config, ReactivesearchResultProps } from \"../types\";\n\nexport type ReactifySearchMode = \"search\" | \"collection\" | \"instant-search\";\n\nexport const ReactifySearchContext = React.createContext<\n | {\n config: Config;\n options: {\n mode: ReactifySearchMode;\n index: string;\n shopifyPermanentDomain: string;\n filtersHandle?: string;\n credentials?: string;\n endpoint: string;\n onRedirect?: (type: \"redirect\" | \"search\", url: string) => void;\n theme: Record<string, unknown>;\n additionalComponentIds?: Array<string>;\n includeFields?: Array<string>;\n excludeFields?: Array<string>;\n } & (\n | {\n mode: \"search\";\n }\n | {\n mode: \"collection\";\n collectionHandle: string;\n }\n | {\n mode: \"instant-search\";\n }\n );\n search: {\n searchTerm: string;\n setSearchTerm: React.Dispatch<React.SetStateAction<string>>;\n showInstantSearchResults: boolean;\n setShowInstantSearchResults: React.Dispatch<\n React.SetStateAction<boolean>\n >;\n };\n sortby: {\n sortOption: string;\n setSortOption: React.Dispatch<React.SetStateAction<string>>;\n };\n results: {\n results: ReactivesearchResultProps[\"data\"];\n setResults: React.Dispatch<\n React.SetStateAction<ReactivesearchResultProps[\"data\"]>\n >;\n resultStats?: ReactivesearchResultProps[\"resultStats\"];\n setResultStats: React.Dispatch<\n React.SetStateAction<\n ReactivesearchResultProps[\"resultStats\"] | undefined\n >\n >;\n };\n }\n | undefined\n>(undefined);\n\nexport const useReactifySearchContext = () =>\n React.useContext(ReactifySearchContext)!;\n"]}
|
package/package.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SensorSortScore = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const ReactiveComponent_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent"));
|
|
9
|
-
const SensorSortScore = () => (react_1.default.createElement(ReactiveComponent_1.default, { componentId: "SensorSortScore", customQuery: () => ({
|
|
10
|
-
sort: { _score: "desc" },
|
|
11
|
-
}) }));
|
|
12
|
-
exports.SensorSortScore = SensorSortScore;
|
|
13
|
-
//# sourceMappingURL=SensorSortScore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SensorSortScore.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorSortScore.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;AAE1F,MAAM,eAAe,GAAa,GAAG,EAAE,CAAC,CAC7C,8BAAC,2BAAiB,IAChB,WAAW,EAAC,iBAAiB,EAC7B,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;QAClB,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;KACzB,CAAC,GACF,CACH,CAAC;AAPW,QAAA,eAAe,mBAO1B","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent\";\n\nexport const SensorSortScore: React.FC = () => (\n <ReactiveComponent\n componentId=\"SensorSortScore\"\n customQuery={() => ({\n sort: { _score: \"desc\" },\n })}\n />\n);\n"]}
|