@usereactify/search 5.55.2 → 5.56.1
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 +19 -0
- package/dist/package.json +1 -1
- package/dist/src/components/Example/ExampleFilterSlider.js +1 -1
- package/dist/src/components/Example/ExampleFilterSlider.js.map +1 -1
- package/dist/src/components/Filter/Filter.d.ts +2 -0
- package/dist/src/components/Filter/Filter.js +14 -37
- package/dist/src/components/Filter/Filter.js.map +1 -1
- package/dist/src/components/Filter/Filters.d.ts +2 -0
- package/dist/src/components/Filter/Filters.js.map +1 -1
- package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.js +14 -0
- package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.js.map +1 -1
- package/dist/src/hooks/useAnalytics.d.ts +10 -3
- package/dist/src/hooks/useAnalytics.js +14 -3
- package/dist/src/hooks/useAnalytics.js.map +1 -1
- package/dist/src/hooks/useFilterSliderProps.d.ts +0 -5
- package/dist/src/hooks/useFilterSliderProps.js +1 -50
- package/dist/src/hooks/useFilterSliderProps.js.map +1 -1
- package/dist/src/hooks/useReactifySearchContext.d.ts +3 -1
- package/dist/src/hooks/useReactifySearchContext.js.map +1 -1
- package/dist/src/utility/curation.js.map +1 -1
- package/dist/src/utility/props.d.ts +41 -1
- package/dist/src/utility/props.js +61 -3
- package/dist/src/utility/props.js.map +1 -1
- package/dist/src/utility/sortOption.d.ts +1 -0
- package/dist/src/utility/sortOption.js +22 -16
- package/dist/src/utility/sortOption.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
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.56.1](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.56.0...release-v5.56.1) (2024-12-20)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* ensure hidden products within curations are separated between markets ([e6d66a0](https://bitbucket.org/usereactify/reactify-search-ui/commit/e6d66a03bc97c44ec37d3fb6d1e87d6a13b62eb1))
|
|
11
|
+
|
|
12
|
+
## [5.56.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.55.2...release-v5.56.0) (2024-12-13)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* track attribution within analytics ([bd9c6b5](https://bitbucket.org/usereactify/reactify-search-ui/commit/bd9c6b588c30e705848315e41ed731a4bc16ebdf))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* correctly parse filter slider value during SSR ([ea8600e](https://bitbucket.org/usereactify/reactify-search-ui/commit/ea8600e9f1f731053fccf09da10b2e0f7b99a8a0))
|
|
23
|
+
|
|
5
24
|
### [5.55.2](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.55.1...release-v5.55.2) (2024-11-27)
|
|
6
25
|
|
|
7
26
|
|
package/dist/package.json
CHANGED
|
@@ -23,7 +23,7 @@ const ExampleFilterSlider = (props) => {
|
|
|
23
23
|
margin: "auto",
|
|
24
24
|
top: "6px",
|
|
25
25
|
} },
|
|
26
|
-
react_1.default.createElement(react_slider_1.default, Object.assign({ thumbClassName: "rs__filter__slider__thumb" }, props.
|
|
26
|
+
react_1.default.createElement(react_slider_1.default, Object.assign({ thumbClassName: "rs__filter__slider__thumb" }, props.reactSliderProps, { renderTrack: (props, state) => (react_1.default.createElement("div", Object.assign({}, props, { style: Object.assign(Object.assign({}, (state.index === 1 ? trackStyleMiddle : trackStyleEnds)), props.style) }))), renderThumb: (renderProps, state) => (react_1.default.createElement("div", Object.assign({}, renderProps, { style: Object.assign({ cursor: "grab", background: "rgb(2, 117, 255)", top: "6px", width: "16px", height: "16px", borderRadius: "100%", outline: "none" }, renderProps.style) }),
|
|
27
27
|
react_1.default.createElement("span", { style: {
|
|
28
28
|
position: "absolute",
|
|
29
29
|
top: "-24px",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExampleFilterSlider.js","sourceRoot":"","sources":["../../../../src/components/Example/ExampleFilterSlider.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,gEAAuC;AAOhC,MAAM,mBAAmB,GAAuC,CACrE,KAAK,EACL,EAAE;IACF,MAAM,cAAc,GAAG;QACrB,GAAG,EAAE,MAAM;QACX,MAAM,EAAE,KAAK;QACb,UAAU,EAAE,oBAAoB;QAChC,MAAM,EAAE,8BAA8B;QACtC,YAAY,EAAE,KAAK;KACpB,CAAC;IACF,MAAM,gBAAgB,mCACjB,cAAc,KACjB,UAAU,EAAE,kBAAkB,EAC9B,MAAM,EAAE,6BAA6B,GACtC,CAAC;IAEF,OAAO,CACL,uCAAK,SAAS,EAAC,YAAY;QACzB,sCAAI,SAAS,EAAC,kBAAkB,IAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAM;QACzD,uCACE,SAAS,EAAC,oBAAoB,EAC9B,KAAK,EAAE;gBACL,QAAQ,EAAE,OAAO;gBACjB,MAAM,EAAE,MAAM;gBACd,MAAM,EAAE,MAAM;gBACd,GAAG,EAAE,KAAK;aACX;YAED,8BAAC,sBAAW,kBACV,cAAc,EAAC,2BAA2B,IACtC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"ExampleFilterSlider.js","sourceRoot":"","sources":["../../../../src/components/Example/ExampleFilterSlider.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,gEAAuC;AAOhC,MAAM,mBAAmB,GAAuC,CACrE,KAAK,EACL,EAAE;IACF,MAAM,cAAc,GAAG;QACrB,GAAG,EAAE,MAAM;QACX,MAAM,EAAE,KAAK;QACb,UAAU,EAAE,oBAAoB;QAChC,MAAM,EAAE,8BAA8B;QACtC,YAAY,EAAE,KAAK;KACpB,CAAC;IAC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mBAAmB,uBAuE9B","sourcesContent":["import React from \"react\";\nimport ReactSlider from \"react-slider\";\nimport { FilterProps } from \"../../components\";\n\nexport type ExampleFilterSliderProps = React.ComponentProps<\n NonNullable<FilterProps[\"renderFilterSlider\"]>\n>;\n\nexport const ExampleFilterSlider: React.FC<ExampleFilterSliderProps> = (\n props\n) => {\n const trackStyleEnds = {\n top: \"10px\",\n height: \"8px\",\n background: \"rgb(239, 239, 239)\",\n border: \"1px solid rgb(179, 179, 179)\",\n borderRadius: \"4px\",\n };\n const trackStyleMiddle = {\n ...trackStyleEnds,\n background: \"rgb(2, 117, 255)\",\n border: \"1px solid rgb(74, 117, 187)\",\n };\n\n return (\n <div className=\"rs__filter\">\n <h3 className=\"rs__filter__name\">{props.filter.name}</h3>\n <div\n className=\"rs__filter__slider\"\n style={{\n maxWidth: \"300px\",\n height: \"26px\",\n margin: \"auto\",\n top: \"6px\",\n }}\n >\n <ReactSlider\n thumbClassName=\"rs__filter__slider__thumb\"\n {...props.reactSliderProps}\n renderTrack={(props, state) => (\n <div\n {...props}\n style={{\n ...(state.index === 1 ? trackStyleMiddle : trackStyleEnds),\n ...props.style,\n }}\n ></div>\n )}\n renderThumb={(renderProps, state) => (\n <div\n {...renderProps}\n style={{\n cursor: \"grab\",\n background: \"rgb(2, 117, 255)\",\n top: \"6px\",\n width: \"16px\",\n height: \"16px\",\n borderRadius: \"100%\",\n outline: \"none\",\n ...renderProps.style,\n }}\n >\n <span\n style={{\n position: \"absolute\",\n top: \"-24px\",\n left: \"-50%\",\n }}\n >\n {props.filter.displaySliderPrefix}\n {state.valueNow}\n {props.filter.displaySliderSuffix}\n </span>\n </div>\n )}\n />\n </div>\n </div>\n );\n};\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { ConfigFilterFacet } from "../../types";
|
|
3
3
|
import { useFilterListProps, useFilterRangeProps, useFilterSliderProps } from "../../hooks";
|
|
4
|
+
import { useReactSliderProps } from "../../hooks/react-slider/useReactSliderProps";
|
|
4
5
|
export type FilterProps = {
|
|
5
6
|
/** The filter option being rendered */
|
|
6
7
|
filter: ConfigFilterFacet;
|
|
@@ -18,6 +19,7 @@ export type FilterProps = {
|
|
|
18
19
|
renderFilterSlider?: React.FC<{
|
|
19
20
|
filter: ConfigFilterFacet;
|
|
20
21
|
filterSliderProps: ReturnType<typeof useFilterSliderProps>;
|
|
22
|
+
reactSliderProps: ReturnType<typeof useReactSliderProps>;
|
|
21
23
|
}>;
|
|
22
24
|
/** Show filters even when no options are available */
|
|
23
25
|
showEmptyFilters?: boolean;
|
|
@@ -24,6 +24,7 @@ const MultiRange_1 = __importDefault(require("@usereactify/search-internals/lib/
|
|
|
24
24
|
const hooks_1 = require("../../hooks");
|
|
25
25
|
const components_1 = require("../../components");
|
|
26
26
|
const props_1 = require("../../utility/props");
|
|
27
|
+
const useReactSliderProps_1 = require("../../hooks/react-slider/useReactSliderProps");
|
|
27
28
|
const Filter = (props) => {
|
|
28
29
|
if ("single" === props.filter.displayType) {
|
|
29
30
|
if ("range" === props.filter.displayView) {
|
|
@@ -123,55 +124,31 @@ const FilterSlider = (props) => {
|
|
|
123
124
|
filterGroup: filtersHook.filterStack,
|
|
124
125
|
}, props.filter);
|
|
125
126
|
const filterSliderProps = (0, hooks_1.useFilterSliderProps)(props.filter);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
min: {
|
|
130
|
-
field: props.filter.field,
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
max: {
|
|
134
|
-
max: {
|
|
135
|
-
field: props.filter.field,
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
}), customQuery: () => filterSliderProps.query, render: (reactivesearchFilterProps) => {
|
|
140
|
-
var _a, _b, _c, _d;
|
|
141
|
-
if (!props.showEmptyFilters &&
|
|
142
|
-
((_b = (_a = reactivesearchFilterProps === null || reactivesearchFilterProps === void 0 ? void 0 : reactivesearchFilterProps.aggregations) === null || _a === void 0 ? void 0 : _a.min) === null || _b === void 0 ? void 0 : _b.value) ===
|
|
143
|
-
((_d = (_c = reactivesearchFilterProps === null || reactivesearchFilterProps === void 0 ? void 0 : reactivesearchFilterProps.aggregations) === null || _c === void 0 ? void 0 : _c.max) === null || _d === void 0 ? void 0 : _d.value)) {
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
return (react_1.default.createElement(FilterSliderInner, Object.assign({}, props, { filterSliderProps: filterSliderProps, reactivesearchFilterProps: reactivesearchFilterProps })));
|
|
127
|
+
const reactiveProps = (0, props_1.getPropsFilterSlider)(props.filter, "", filterSliderProps.value);
|
|
128
|
+
return (react_1.default.createElement(ReactiveComponent_1.default, Object.assign({}, sharedProps, { defaultQuery: () => reactiveProps.defaultQuery, customQuery: () => reactiveProps.customQuery, render: (reactivesearchFilterProps) => {
|
|
129
|
+
return (react_1.default.createElement(FilterSliderInner, Object.assign({}, props, { filterSliderProps: filterSliderProps, customQuery: reactiveProps.customQuery, reactivesearchFilterProps: reactivesearchFilterProps })));
|
|
147
130
|
} })));
|
|
148
131
|
};
|
|
149
132
|
// inner component exists only so we can use memos in reactivesearch render functions
|
|
150
133
|
const FilterSliderInner = (props) => {
|
|
151
|
-
var _a, _b, _c;
|
|
134
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
152
135
|
const { filter, renderFilterSlider, filterSliderProps, reactivesearchFilterProps } = props, otherProps = __rest(props, ["filter", "renderFilterSlider", "filterSliderProps", "reactivesearchFilterProps"]);
|
|
136
|
+
const filterRange = [
|
|
137
|
+
(_c = (_b = (_a = reactivesearchFilterProps.aggregations) === null || _a === void 0 ? void 0 : _a.min) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : 0,
|
|
138
|
+
(_f = (_e = (_d = reactivesearchFilterProps.aggregations) === null || _d === void 0 ? void 0 : _d.max) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : 0,
|
|
139
|
+
];
|
|
140
|
+
const reactSliderProps = (0, useReactSliderProps_1.useReactSliderProps)(filter, filterSliderProps.value, filterRange, filterSliderProps.handleChange);
|
|
153
141
|
react_1.default.useEffect(() => {
|
|
154
|
-
if (
|
|
155
|
-
filterSliderProps.handleRange([
|
|
156
|
-
reactivesearchFilterProps.aggregations.min.value,
|
|
157
|
-
reactivesearchFilterProps.aggregations.max.value,
|
|
158
|
-
]);
|
|
159
|
-
}
|
|
160
|
-
}, [
|
|
161
|
-
(_a = reactivesearchFilterProps.aggregations) === null || _a === void 0 ? void 0 : _a.min.value,
|
|
162
|
-
(_b = reactivesearchFilterProps.aggregations) === null || _b === void 0 ? void 0 : _b.max.value,
|
|
163
|
-
]);
|
|
164
|
-
react_1.default.useEffect(() => {
|
|
165
|
-
if (!filterSliderProps.query) {
|
|
142
|
+
if (!props.customQuery) {
|
|
166
143
|
return;
|
|
167
144
|
}
|
|
168
145
|
props.reactivesearchFilterProps.setQuery({
|
|
169
|
-
query:
|
|
146
|
+
query: props.customQuery,
|
|
170
147
|
value: filterSliderProps.value,
|
|
171
148
|
});
|
|
172
149
|
}, [filterSliderProps.value]);
|
|
173
|
-
const RenderSliderComponent = (
|
|
174
|
-
return (react_1.default.createElement(RenderSliderComponent, Object.assign({ filterSliderProps: filterSliderProps, filter: filter }, otherProps)));
|
|
150
|
+
const RenderSliderComponent = (_g = props.renderFilterSlider) !== null && _g !== void 0 ? _g : components_1.ExampleFilterSlider;
|
|
151
|
+
return (react_1.default.createElement(RenderSliderComponent, Object.assign({ filterSliderProps: filterSliderProps, reactSliderProps: reactSliderProps, filter: filter }, otherProps)));
|
|
175
152
|
};
|
|
176
153
|
// inner component exists only so we can use memos in reactivesearch render functions
|
|
177
154
|
const FilterListInner = (props) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Filter.js","sourceRoot":"","sources":["../../../../src/components/Filter/Filter.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,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AAM,EAAE,MAAM,IACV,UAAU,EACd,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@usereactify/search-internals/lib/components/basic/ReactiveComponent\";\nimport MultiList from \"@usereactify/search-internals/lib/components/list/MultiList\";\nimport SingleList from \"@usereactify/search-internals/lib/components/list/SingleList\";\nimport SingleRange from \"@usereactify/search-internals/lib/components/range/SingleRange\";\nimport MultiRange from \"@usereactify/search-internals/lib/components/range/MultiRange\";\n\nimport type {\n ConfigFilterFacet,\n ReactivesearchFilterListProps,\n} from \"../../types\";\nimport {\n useFilterListProps,\n useFilterRangeProps,\n useFilterSliderProps,\n useFilters,\n useReactifySearchContext,\n} from \"../../hooks\";\nimport {\n ExampleFilterList,\n ExampleFilterRange,\n ExampleFilterSlider,\n} from \"../../components\";\nimport { getPropsFilterList, getPropsFilterRange, getPropsShared } from \"../../utility/props\";\n\nexport type FilterProps = {\n /** The filter option being rendered */\n filter: ConfigFilterFacet;\n /** Render method for List filters */\n renderFilterList?: React.FC<{\n filter: ConfigFilterFacet;\n filterListProps: ReturnType<typeof useFilterListProps>;\n }>;\n /** Render method for Range filters */\n renderFilterRange?: React.FC<{\n filter: ConfigFilterFacet;\n filterRangeProps: ReturnType<typeof useFilterRangeProps>;\n }>;\n /** Render method for Slider filters */\n renderFilterSlider?: React.FC<{\n filter: ConfigFilterFacet;\n filterSliderProps: ReturnType<typeof useFilterSliderProps>;\n // reactSliderProps: ReturnType<typeof useReactSliderProps>;\n }>;\n /** Show filters even when no options are available */\n showEmptyFilters?: boolean;\n};\n\nexport const Filter: React.FC<FilterProps> = (props) => {\n if (\"single\" === props.filter.displayType) {\n if (\"range\" === props.filter.displayView) {\n return <FilterRangeSingle {...props} />;\n }\n return <FilterSingleList {...props} />;\n }\n\n if (\"multi\" === props.filter.displayType) {\n if (\"range\" === props.filter.displayView) {\n return <FilterRangeMulti {...props} />;\n }\n return <FilterMultiList {...props} />;\n }\n\n if (\"slider\" === props.filter.displayType) {\n return <FilterSlider {...props} />;\n }\n\n // TODO: Legacy range filter, migrate to new single and multi ranges\n if (\"range\" === props.filter.displayType) {\n return <FilterRangeSingle {...props} />;\n }\n\n console.warn(\n `filter with display type \"${props.filter.displayType}\" not yet supported`\n );\n\n return null;\n};\n\nconst FilterSingleList: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterList(props.filter);\n\n return (\n <SingleList\n {...sharedProps}\n {...reactiveProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n )}\n />\n );\n};\n\nconst FilterMultiList: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterList(props.filter);\n\n return (\n <MultiList\n {...sharedProps}\n {...reactiveProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n )}\n />\n );\n};\n\nconst FilterRangeSingle: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterRange(props.filter);\n\n const filterRangeProps = useFilterRangeProps(props.filter);\n\n const RenderRangeComponent = props.renderFilterRange ?? ExampleFilterRange;\n\n return (\n <>\n <div\n style={{\n display: \"none\",\n }}\n >\n <SingleRange\n {...sharedProps}\n {...reactiveProps}\n value={filterRangeProps.values[0]}\n onChange={filterRangeProps.handleChange}\n />\n </div>\n <RenderRangeComponent\n filterRangeProps={filterRangeProps}\n filter={props.filter}\n />\n </>\n );\n};\n\nconst FilterRangeMulti: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterRange(props.filter);\n\n const filterRangeProps = useFilterRangeProps(props.filter);\n\n const RenderRangeComponent = props.renderFilterRange ?? ExampleFilterRange;\n\n return (\n <>\n <div\n style={{\n display: \"none\",\n }}\n >\n <MultiRange\n {...sharedProps}\n {...reactiveProps}\n value={filterRangeProps.values}\n // @note: onChange handler must be defined for controlled component to work correctly\n onChange={() => {}}\n onValueChange={(values) => {\n if (values.length === 0) {\n filterRangeProps.handleClear();\n }\n }}\n />\n </div>\n <RenderRangeComponent\n filterRangeProps={filterRangeProps}\n filter={props.filter}\n />\n </>\n );\n};\n\nconst FilterSlider: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n\n const filterSliderProps = useFilterSliderProps(props.filter);\n\n return (\n <ReactiveComponent\n {...sharedProps}\n defaultQuery={() => ({\n aggs: {\n min: {\n min: {\n field: props.filter.field,\n },\n },\n max: {\n max: {\n field: props.filter.field,\n },\n },\n },\n })}\n customQuery={() => filterSliderProps.query}\n render={(reactivesearchFilterProps) => {\n if (\n !props.showEmptyFilters &&\n reactivesearchFilterProps?.aggregations?.min?.value ===\n reactivesearchFilterProps?.aggregations?.max?.value\n ) {\n return null;\n }\n\n return (\n <FilterSliderInner\n {...props}\n filterSliderProps={filterSliderProps}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n );\n }}\n />\n );\n};\n\n// inner component exists only so we can use memos in reactivesearch render functions\nconst FilterSliderInner: React.FC<\n FilterProps & { reactivesearchFilterProps: any; filterSliderProps: ReturnType<typeof useFilterSliderProps> }\n> = (props) => {\n const {\n filter,\n renderFilterSlider,\n filterSliderProps,\n reactivesearchFilterProps,\n ...otherProps\n } = props;\n\n React.useEffect(() => {\n if (reactivesearchFilterProps.aggregations) {\n filterSliderProps.handleRange([\n reactivesearchFilterProps.aggregations.min.value,\n reactivesearchFilterProps.aggregations.max.value,\n ]);\n }\n }, [\n reactivesearchFilterProps.aggregations?.min.value,\n reactivesearchFilterProps.aggregations?.max.value,\n ]);\n\n React.useEffect(() => {\n if (!filterSliderProps.query) {\n return;\n }\n\n props.reactivesearchFilterProps.setQuery({\n query: filterSliderProps.query,\n value: filterSliderProps.value,\n });\n }, [filterSliderProps.value]);\n\n const RenderSliderComponent = props.renderFilterSlider ?? ExampleFilterSlider;\n\n return (\n <RenderSliderComponent\n filterSliderProps={filterSliderProps}\n filter={filter}\n {...otherProps}\n />\n );\n};\n\n// inner component exists only so we can use memos in reactivesearch render functions\nconst FilterListInner: React.FC<\n FilterProps & { reactivesearchFilterProps: ReactivesearchFilterListProps }\n> = (props) => {\n const { filter, renderFilterList, reactivesearchFilterProps, ...otherProps } =\n props;\n\n const filterListProps = useFilterListProps(filter, reactivesearchFilterProps);\n\n // hide entire filter when no options available\n if (!props.showEmptyFilters && 0 === filterListProps.options.length) {\n return null;\n }\n\n const RenderListComponent = props.renderFilterList ?? ExampleFilterList;\n\n return (\n <RenderListComponent\n filterListProps={filterListProps}\n filter={filter}\n {...otherProps}\n />\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"Filter.js","sourceRoot":"","sources":["../../../../src/components/Filter/Filter.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,6HAAqG;AACrG,4GAAoF;AACpF,8GAAsF;AACtF,iHAAyF;AACzF,+GAAuF;AAMvF,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qB,GAAG,MAAA,KAAK,CAAC,kBAAkB,mCAAI,gCAAmB,CAAC;IAE9E,OAAO,CACL,8BAAC,qBAAqB,kBACpB,iBAAiB,EAAE,iBAAiB,EACpC,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,MAAM,IACV,UAAU,EACd,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,qFAAqF;AACrF,MAAM,eAAe,GAEjB,CAAC,KAAK,EAAE,EAAE;;IACZ,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,yBAAyB,KACzD,KAAK,EADyD,UAAU,UACxE,KAAK,EADD,2DAAsE,CACrE,CAAC;IAER,MAAM,eAAe,GAAG,IAAA,0BAAkB,EAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;IAE9E,+CAA+C;IAC/C,IAAI,CAAC,KAAK,CAAC,gBAAgB,IAAI,CAAC,KAAK,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACpE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,mBAAmB,GAAG,MAAA,KAAK,CAAC,gBAAgB,mCAAI,8BAAiB,CAAC;IAExE,OAAO,CACL,8BAAC,mBAAmB,kBAClB,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM,IACV,UAAU,EACd,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@usereactify/search-internals/lib/components/basic/ReactiveComponent\";\nimport MultiList from \"@usereactify/search-internals/lib/components/list/MultiList\";\nimport SingleList from \"@usereactify/search-internals/lib/components/list/SingleList\";\nimport SingleRange from \"@usereactify/search-internals/lib/components/range/SingleRange\";\nimport MultiRange from \"@usereactify/search-internals/lib/components/range/MultiRange\";\n\nimport type {\n ConfigFilterFacet,\n ReactivesearchFilterListProps,\n} from \"../../types\";\nimport {\n useFilterListProps,\n useFilterRangeProps,\n useFilterSliderProps,\n useFilters,\n useReactifySearchContext,\n} from \"../../hooks\";\nimport {\n ExampleFilterList,\n ExampleFilterRange,\n ExampleFilterSlider,\n} from \"../../components\";\nimport { getPropsFilterList, getPropsFilterRange, getPropsFilterSlider, getPropsShared } from \"../../utility/props\";\nimport { useReactSliderProps } from \"../../hooks/react-slider/useReactSliderProps\";\n\nexport type FilterProps = {\n /** The filter option being rendered */\n filter: ConfigFilterFacet;\n /** Render method for List filters */\n renderFilterList?: React.FC<{\n filter: ConfigFilterFacet;\n filterListProps: ReturnType<typeof useFilterListProps>;\n }>;\n /** Render method for Range filters */\n renderFilterRange?: React.FC<{\n filter: ConfigFilterFacet;\n filterRangeProps: ReturnType<typeof useFilterRangeProps>;\n }>;\n\n /** Render method for Slider filters */\n renderFilterSlider?: React.FC<{\n filter: ConfigFilterFacet;\n filterSliderProps: ReturnType<typeof useFilterSliderProps>;\n reactSliderProps: ReturnType<typeof useReactSliderProps>;\n }>;\n /** Show filters even when no options are available */\n showEmptyFilters?: boolean;\n};\n\nexport const Filter: React.FC<FilterProps> = (props) => {\n if (\"single\" === props.filter.displayType) {\n if (\"range\" === props.filter.displayView) {\n return <FilterRangeSingle {...props} />;\n }\n return <FilterSingleList {...props} />;\n }\n\n if (\"multi\" === props.filter.displayType) {\n if (\"range\" === props.filter.displayView) {\n return <FilterRangeMulti {...props} />;\n }\n return <FilterMultiList {...props} />;\n }\n\n if (\"slider\" === props.filter.displayType) {\n return <FilterSlider {...props} />;\n }\n\n // TODO: Legacy range filter, migrate to new single and multi ranges\n if (\"range\" === props.filter.displayType) {\n return <FilterRangeSingle {...props} />;\n }\n\n console.warn(\n `filter with display type \"${props.filter.displayType}\" not yet supported`\n );\n\n return null;\n};\n\nconst FilterSingleList: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterList(props.filter);\n\n return (\n <SingleList\n {...sharedProps}\n {...reactiveProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n )}\n />\n );\n};\n\nconst FilterMultiList: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterList(props.filter);\n\n return (\n <MultiList\n {...sharedProps}\n {...reactiveProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n )}\n />\n );\n};\n\nconst FilterRangeSingle: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterRange(props.filter);\n\n const filterRangeProps = useFilterRangeProps(props.filter);\n\n const RenderRangeComponent = props.renderFilterRange ?? ExampleFilterRange;\n\n return (\n <>\n <div\n style={{\n display: \"none\",\n }}\n >\n <SingleRange\n {...sharedProps}\n {...reactiveProps}\n value={filterRangeProps.values[0]}\n onChange={filterRangeProps.handleChange}\n />\n </div>\n <RenderRangeComponent\n filterRangeProps={filterRangeProps}\n filter={props.filter}\n />\n </>\n );\n};\n\nconst FilterRangeMulti: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterRange(props.filter);\n\n const filterRangeProps = useFilterRangeProps(props.filter);\n\n const RenderRangeComponent = props.renderFilterRange ?? ExampleFilterRange;\n\n return (\n <>\n <div\n style={{\n display: \"none\",\n }}\n >\n <MultiRange\n {...sharedProps}\n {...reactiveProps}\n value={filterRangeProps.values}\n // @note: onChange handler must be defined for controlled component to work correctly\n onChange={() => {}}\n onValueChange={(values) => {\n if (values.length === 0) {\n filterRangeProps.handleClear();\n }\n }}\n />\n </div>\n <RenderRangeComponent\n filterRangeProps={filterRangeProps}\n filter={props.filter}\n />\n </>\n );\n};\n\nconst FilterSlider: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const filterSliderProps = useFilterSliderProps(props.filter);\n const reactiveProps = getPropsFilterSlider(props.filter, \"\", filterSliderProps.value);\n\n return (\n <ReactiveComponent\n {...sharedProps}\n defaultQuery={() => reactiveProps.defaultQuery}\n customQuery={() => reactiveProps.customQuery}\n render={(reactivesearchFilterProps) => {\n return (\n <FilterSliderInner\n {...props}\n filterSliderProps={filterSliderProps}\n customQuery={reactiveProps.customQuery}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n );\n }}\n />\n );\n};\n\n// inner component exists only so we can use memos in reactivesearch render functions\nconst FilterSliderInner: React.FC<\n FilterProps & { reactivesearchFilterProps: any; filterSliderProps: ReturnType<typeof useFilterSliderProps>; customQuery: any; }\n> = (props) => {\n const {\n filter,\n renderFilterSlider,\n filterSliderProps,\n reactivesearchFilterProps,\n ...otherProps\n } = props;\n\n const filterRange: [number, number] = [\n reactivesearchFilterProps.aggregations?.min?.value ?? 0,\n reactivesearchFilterProps.aggregations?.max?.value ?? 0,\n ];\n\n const reactSliderProps = useReactSliderProps(\n filter,\n filterSliderProps.value,\n filterRange,\n filterSliderProps.handleChange,\n );\n\n React.useEffect(() => {\n if (!props.customQuery) {\n return;\n }\n\n props.reactivesearchFilterProps.setQuery({\n query: props.customQuery,\n value: filterSliderProps.value,\n });\n }, [filterSliderProps.value]);\n\n const RenderSliderComponent = props.renderFilterSlider ?? ExampleFilterSlider;\n\n return (\n <RenderSliderComponent\n filterSliderProps={filterSliderProps}\n reactSliderProps={reactSliderProps}\n filter={filter}\n {...otherProps}\n />\n );\n};\n\n// inner component exists only so we can use memos in reactivesearch render functions\nconst FilterListInner: React.FC<\n FilterProps & { reactivesearchFilterProps: ReactivesearchFilterListProps }\n> = (props) => {\n const { filter, renderFilterList, reactivesearchFilterProps, ...otherProps } =\n props;\n\n const filterListProps = useFilterListProps(filter, reactivesearchFilterProps);\n\n // hide entire filter when no options available\n if (!props.showEmptyFilters && 0 === filterListProps.options.length) {\n return null;\n }\n\n const RenderListComponent = props.renderFilterList ?? ExampleFilterList;\n\n return (\n <RenderListComponent\n filterListProps={filterListProps}\n filter={filter}\n {...otherProps}\n />\n );\n};\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { useFilterListProps, useFilterRangeProps, useFilterSliderProps } from "../../hooks";
|
|
3
3
|
import { ConfigFilterFacet } from "../../types";
|
|
4
|
+
import { useReactSliderProps } from "../../hooks/react-slider/useReactSliderProps";
|
|
4
5
|
export type FiltersProps = {
|
|
5
6
|
/** Render method for List filters */
|
|
6
7
|
renderFilterList?: React.FC<{
|
|
@@ -16,6 +17,7 @@ export type FiltersProps = {
|
|
|
16
17
|
renderFilterSlider?: React.FC<{
|
|
17
18
|
filter: ConfigFilterFacet;
|
|
18
19
|
filterSliderProps: ReturnType<typeof useFilterSliderProps>;
|
|
20
|
+
reactSliderProps: ReturnType<typeof useReactSliderProps>;
|
|
19
21
|
}>;
|
|
20
22
|
/** Show filters even when no options are available */
|
|
21
23
|
showEmptyFilters?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Filters.js","sourceRoot":"","sources":["../../../../src/components/Filter/Filters.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,uCAKqB;AACrB,iDAA0C;
|
|
1
|
+
{"version":3,"file":"Filters.js","sourceRoot":"","sources":["../../../../src/components/Filter/Filters.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,uCAKqB;AACrB,iDAA0C;AAyBnC,MAAM,OAAO,GAA2B,CAAC,KAAK,EAAE,EAAE;;IACvD,MAAM,eAAe,GAAG,IAAA,kBAAU,GAAE,CAAC;IAErC,OAAO,CACL,8DACG,MAAA,eAAe,CAAC,OAAO,0CAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACxC,8BAAC,mBAAM,IACL,GAAG,EAAE,MAAM,CAAC,EAAE,EACd,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,EACxC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,EAC5C,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,EAC1C,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,GACxC,CACH,CAAC,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAjBW,QAAA,OAAO,WAiBlB","sourcesContent":["import React from \"react\";\n\nimport {\n useFilterListProps,\n useFilterRangeProps,\n useFilters,\n useFilterSliderProps,\n} from \"../../hooks\";\nimport { Filter } from \"../../components\";\nimport { ConfigFilterFacet } from \"../../types\";\nimport { useReactSliderProps } from \"../../hooks/react-slider/useReactSliderProps\";\n\nexport type FiltersProps = {\n /** Render method for List filters */\n renderFilterList?: React.FC<{\n filter: ConfigFilterFacet;\n filterListProps: ReturnType<typeof useFilterListProps>;\n }>;\n /** Render method for Range filters */\n renderFilterRange?: React.FC<{\n filter: ConfigFilterFacet;\n filterRangeProps: ReturnType<typeof useFilterRangeProps>;\n }>;\n /** Render method for Slider filters */\n renderFilterSlider?: React.FC<{\n filter: ConfigFilterFacet;\n filterSliderProps: ReturnType<typeof useFilterSliderProps>;\n reactSliderProps: ReturnType<typeof useReactSliderProps>;\n }>;\n /** Show filters even when no options are available */\n showEmptyFilters?: boolean;\n};\n\nexport const Filters: React.FC<FiltersProps> = (props) => {\n const filterStackHook = useFilters();\n\n return (\n <>\n {filterStackHook.filters?.map((filter) => (\n <Filter\n key={filter.id}\n filter={filter}\n renderFilterList={props.renderFilterList}\n renderFilterSlider={props.renderFilterSlider}\n renderFilterRange={props.renderFilterRange}\n showEmptyFilters={props.showEmptyFilters}\n />\n ))}\n </>\n );\n};\n"]}
|
|
@@ -34,6 +34,7 @@ const package_json_1 = __importDefault(require("../../../package.json"));
|
|
|
34
34
|
const hooks_1 = require("../../hooks");
|
|
35
35
|
const components_1 = require("../../components");
|
|
36
36
|
const utility_1 = require("../../utility");
|
|
37
|
+
const curation_1 = require("../../utility/curation");
|
|
37
38
|
const ReactifySearchProvider = (props) => {
|
|
38
39
|
react_1.default.useEffect(() => {
|
|
39
40
|
utility_1.debug.log("ReactifySearchProvider", "props", props);
|
|
@@ -96,6 +97,17 @@ const ReactifySearchInner = (props) => {
|
|
|
96
97
|
const [sortOption, setSortOption] = react_1.default.useState(searchSortFromURL !== null && searchSortFromURL !== void 0 ? searchSortFromURL : "");
|
|
97
98
|
// results
|
|
98
99
|
const [results, setResults] = react_1.default.useState([]);
|
|
100
|
+
// curation
|
|
101
|
+
const curation = react_1.default.useMemo(() => {
|
|
102
|
+
if (!config) {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
return (0, curation_1.getCuration)({
|
|
106
|
+
provider: props,
|
|
107
|
+
config: config,
|
|
108
|
+
searchTerm: searchTerm,
|
|
109
|
+
});
|
|
110
|
+
}, [props, config, searchTerm]);
|
|
99
111
|
// result stats
|
|
100
112
|
const [resultStats, setResultStats] = react_1.default.useState();
|
|
101
113
|
react_1.default.useEffect(() => {
|
|
@@ -139,6 +151,7 @@ const ReactifySearchInner = (props) => {
|
|
|
139
151
|
resultStats: resultStats,
|
|
140
152
|
setResultStats: setResultStats,
|
|
141
153
|
},
|
|
154
|
+
curation: curation,
|
|
142
155
|
};
|
|
143
156
|
}, [
|
|
144
157
|
config,
|
|
@@ -149,6 +162,7 @@ const ReactifySearchInner = (props) => {
|
|
|
149
162
|
sortOption,
|
|
150
163
|
results,
|
|
151
164
|
resultStats,
|
|
165
|
+
curation,
|
|
152
166
|
]);
|
|
153
167
|
utility_1.debug.hook("ReactifySearchProvider", "context", contextValue);
|
|
154
168
|
if (!contextValue) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactifySearchProvider.js","sourceRoot":"","sources":["../../../../src/components/ReactifySearchProvider/ReactifySearchProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,iCAAiC;AACjC,gDAAkC;AAElC,yEAAwC;AAExC,uCAA+D;AAC/D,iDAAoE;AACpE,2CAAsC;AAwD/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,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,CAAC;AAhBW,QAAA,sBAAsB,0BAgBjC;AAEF,MAAM,mBAAmB,GAA0C,CAAC,KAAK,EAAE,EAAE;;IAC3E,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,iBAAS,EAAC,KAAK,CAAC,sBAAsB,EAAE,MAAA,KAAK,CAAC,OAAO,0CAAE,MAAM,CAAC,CAAC;IAElF,MAAM,KAAK,GAAG,MAAA,KAAK,CAAC,KAAK,mCAAI;QAC3B,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;SACF,CAAC;IACJ,CAAC,EAAE;QACD,MAAM;QACN,KAAK;QACL,UAAU;QACV,wBAAwB;QACxB,cAAc;QACd,UAAU;QACV,OAAO;QACP,WAAW;KACZ,CAAC,CAAC;IAEH,eAAK,CAAC,IAAI,CAAC,wBAAwB,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;IAE9D,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;YACxB,OAAO,KAAK,CAAC,aAAa,EAAE,CAAC;QAC/B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,8BAAC,6BAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY;QACjD,8BAAC,6CAAgC,QAC9B,KAAK,CAAC,QAAQ,CACkB,CACJ,CAClC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React 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, ConfigRedirect, 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 /** 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: Flags are used to enable or disable specific features within Reactify Search */\n flags?: Record<string, boolean>;\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 | {\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 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\nconst ReactifySearchInner: React.FC<ReactifySearchProviderProps> = (props) => {\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 from url\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 // sort from url\n const searchSortFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return props.query?.sort;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"sort\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n // index from url\n const indexFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"index\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n // search term\n const [searchTerm, setSearchTerm] = React.useState<string>(\n searchTermFromURL ?? \"\"\n );\n // search term redirect\n const searchRedirect = React.useMemo<ConfigRedirect | undefined>(() => {\n return config?.redirects.find((redirect) => redirect.query.trim().toLowerCase() === searchTerm.trim().toLowerCase());\n }, [config?.redirects, searchTerm]);\n // show instant-search\n const [showInstantSearchResults, setShowInstantSearchResults] =\n React.useState<boolean>(false);\n // sort option\n const [sortOption, setSortOption] = React.useState<string>(\n searchSortFromURL ?? \"\"\n );\n // results\n const [results, setResults] = React.useState<\n ReactivesearchResultProps[\"data\"]\n >([]);\n // result stats\n const [resultStats, setResultStats] =\n React.useState<ReactivesearchResultProps[\"resultStats\"]>();\n\n React.useEffect(() => {\n if (props.mode === \"instant-search\") {\n return;\n }\n\n if (searchTermFromURL && searchTerm !== searchTermFromURL) {\n setSearchTerm(searchTermFromURL);\n }\n }, [searchTermFromURL]);\n\n React.useEffect(() => {\n if (props.mode === \"instant-search\") {\n return;\n }\n\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 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 };\n }, [\n config,\n props,\n searchTerm,\n showInstantSearchResults,\n searchRedirect,\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 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,iCAAiC;AACjC,gDAAkC;AAElC,yEAAwC;AAExC,uCAA+D;AAC/D,iDAAoE;AACpE,2CAAsC;AAEtC,qDAAqD;AAuD9C,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,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,CAAC;AAhBW,QAAA,sBAAsB,0BAgBjC;AAEF,MAAM,mBAAmB,GAA0C,CAAC,KAAK,EAAE,EAAE;;IAC3E,MAAM,EAAE,MAAM,EAAE,GAAG,IA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I,YAAY,mCAAI,MAAM,CAAC,KAAK,EAClD,aAAa,EAAE,KAAK,CAAC,aAAa,EAClC,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,KAAK,EAAE,KAAK,GACb;YACD,MAAM,EAAE;gBACN,UAAU,EAAE,UAAU;gBACtB,aAAa,EAAE,aAAa;gBAC5B,wBAAwB,EAAE,wBAAwB;gBAClD,2BAA2B,EAAE,2BAA2B;gBACxD,cAAc,EAAE,cAAc;aAC/B;YACD,MAAM,EAAE;gBACN,UAAU,EAAE,UAAU;gBACtB,aAAa,EAAE,aAAa;aAC7B;YACD,OAAO,EAAE;gBACP,OAAO,EAAE,OAAO;gBAChB,UAAU,EAAE,UAAU;gBACtB,WAAW,EAAE,WAAW;gBACxB,cAAc,EAAE,cAAc;aAC/B;YACD,QAAQ,EAAE,QAAQ;SACnB,CAAC;IACJ,CAAC,EAAE;QACD,MAAM;QACN,KAAK;QACL,UAAU;QACV,wBAAwB;QACxB,cAAc;QACd,UAAU;QACV,OAAO;QACP,WAAW;QACX,QAAQ;KACT,CAAC,CAAC;IAEH,eAAK,CAAC,IAAI,CAAC,wBAAwB,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;IAE9D,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;YACxB,OAAO,KAAK,CAAC,aAAa,EAAE,CAAC;QAC/B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,8BAAC,6BAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY;QACjD,8BAAC,6CAAgC,QAC9B,KAAK,CAAC,QAAQ,CACkB,CACJ,CAClC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React 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\";\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: Flags are used to enable or disable specific features within Reactify Search */\n flags?: Record<string, boolean>;\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 | {\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 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\nconst ReactifySearchInner: React.FC<ReactifySearchProviderProps> = (props) => {\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 from url\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 // sort from url\n const searchSortFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return props.query?.sort;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"sort\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n // index from url\n const indexFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"index\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n // search term\n const [searchTerm, setSearchTerm] = React.useState<string>(\n searchTermFromURL ?? \"\"\n );\n // search term redirect\n const searchRedirect = React.useMemo<ConfigRedirect | undefined>(() => {\n return config?.redirects.find((redirect) => redirect.query.trim().toLowerCase() === searchTerm.trim().toLowerCase());\n }, [config?.redirects, searchTerm]);\n // show instant-search\n const [showInstantSearchResults, setShowInstantSearchResults] =\n React.useState<boolean>(false);\n // sort option\n const [sortOption, setSortOption] = React.useState<string>(\n searchSortFromURL ?? \"\"\n );\n // results\n const [results, setResults] = React.useState<\n ReactivesearchResultProps[\"data\"]\n >([]);\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] =\n React.useState<ReactivesearchResultProps[\"resultStats\"]>();\n\n React.useEffect(() => {\n if (props.mode === \"instant-search\") {\n return;\n }\n\n if (searchTermFromURL && searchTerm !== searchTermFromURL) {\n setSearchTerm(searchTermFromURL);\n }\n }, [searchTermFromURL]);\n\n React.useEffect(() => {\n if (props.mode === \"instant-search\") {\n return;\n }\n\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 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 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>\n {props.children}\n </UtilityAuthenticatedReactiveBase>\n </ReactifySearchContext.Provider>\n );\n};\n"]}
|
|
@@ -28,7 +28,7 @@ export declare namespace TrackEvent {
|
|
|
28
28
|
}
|
|
29
29
|
namespace ViewProductEvent {
|
|
30
30
|
interface Payload {
|
|
31
|
-
elasticProduct:
|
|
31
|
+
elasticProduct: Product;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
interface ClickProductEvent {
|
|
@@ -37,7 +37,7 @@ export declare namespace TrackEvent {
|
|
|
37
37
|
}
|
|
38
38
|
namespace ClickProductEvent {
|
|
39
39
|
interface Payload {
|
|
40
|
-
elasticProduct:
|
|
40
|
+
elasticProduct: Product;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
interface ViewPromotionEvent {
|
|
@@ -89,8 +89,15 @@ export declare namespace TrackEvent {
|
|
|
89
89
|
value: string;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
interface
|
|
92
|
+
interface Product {
|
|
93
93
|
id: number;
|
|
94
94
|
title: string;
|
|
95
95
|
}
|
|
96
|
+
interface Attribution {
|
|
97
|
+
market?: string;
|
|
98
|
+
curation?: string;
|
|
99
|
+
searchTerm?: string;
|
|
100
|
+
collectionHandle?: string;
|
|
101
|
+
recommendation?: string;
|
|
102
|
+
}
|
|
96
103
|
}
|
|
@@ -35,15 +35,26 @@ function getCookie(name) {
|
|
|
35
35
|
return "";
|
|
36
36
|
}
|
|
37
37
|
const useAnalytics = () => {
|
|
38
|
-
const { options } = (0, hooks_1.useReactifySearchContext)();
|
|
38
|
+
const { options, search, curation } = (0, hooks_1.useReactifySearchContext)();
|
|
39
39
|
const track = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
var _a, _b;
|
|
40
41
|
if (!options.shopifyPermanentDomain) {
|
|
41
42
|
console.warn(new Error('Unable to send tracking event, missing value for "shopifyPermanentDomain".'));
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
+
const attribution = {
|
|
46
|
+
market: options.market,
|
|
47
|
+
curation: (_a = curation === null || curation === void 0 ? void 0 : curation.id) !== null && _a !== void 0 ? _a : "",
|
|
48
|
+
searchTerm: (_b = search.searchTerm) !== null && _b !== void 0 ? _b : "",
|
|
49
|
+
collectionHandle: options.mode === "collection" ? options.collectionHandle : "",
|
|
50
|
+
recommendation: "",
|
|
51
|
+
};
|
|
52
|
+
utility_1.debug.log("useAnalytics", "track", event, attribution);
|
|
45
53
|
const events = getTrackEvents(event);
|
|
46
|
-
return axios_1.default.post(`https://analytics.usereactify.com/record/`, {
|
|
54
|
+
return axios_1.default.post(`https://analytics.usereactify.com/record/`, {
|
|
55
|
+
events,
|
|
56
|
+
attribution,
|
|
57
|
+
}, {
|
|
47
58
|
headers: {
|
|
48
59
|
"x-reactify-shop": options.shopifyPermanentDomain,
|
|
49
60
|
"x-reactify-mode": options.mode,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAnalytics.js","sourceRoot":"","sources":["../../../src/hooks/useAnalytics.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useAnalytics.js","sourceRoot":"","sources":["../../../src/hooks/useAnalytics.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAQA,8BAeC;AAvBD,kDAA0B;AAE1B,sEAAqC;AAErC,oCAAoD;AACpD,wCAAmC;AAGnC,SAAgB,SAAS,CAAC,IAAY;;IACpC,IAAI,CAAC;QACH,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;YAClC,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,MAAM,GAAG,KAAK,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC;QAC1D,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO,MAAA,MAAA,MAAM,CAAC,GAAG,EAAE,0CAAE,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,mCAAI,EAAE,CAAC;QAChD,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAEM,MAAM,YAAY,GAAG,GAAG,EAAE;IAC/B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ER,KAAK,cAAc;YACjB,MAAM,GAAG;gBACP;oBACE,SAAS;oBACT,OAAO,EAAE,KAAK,CAAC,OAAO;iBACvB;aACF,CAAC;YAEF,MAAM;IACV,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import axios from \"axios\";\n\nimport pkg from \"../../package.json\";\n\nimport { useReactifySearchContext } from \"../hooks\";\nimport { debug } from \"../utility\";\nimport { getCuration } from \"../utility/curation\";\n\nexport function getCookie(name: string): string {\n try {\n if (typeof window === \"undefined\") {\n return \"\";\n }\n\n const cookie = `; ${document.cookie}`.split(`; ${name}=`);\n if (cookie.length === 2) {\n return cookie.pop()?.split(\";\").shift() ?? \"\";\n }\n } catch (error) {\n console.error(error);\n }\n\n return \"\";\n}\n\nexport const useAnalytics = () => {\n const { options, search, curation } = useReactifySearchContext();\n const track = async (event: TrackEvent) => {\n if (!options.shopifyPermanentDomain) {\n console.warn(\n new Error(\n 'Unable to send tracking event, missing value for \"shopifyPermanentDomain\".'\n )\n );\n\n return;\n }\n\n const attribution: TrackEvent.Attribution = {\n market: options.market,\n curation: curation?.id ?? \"\",\n searchTerm: search.searchTerm ?? \"\",\n collectionHandle: options.mode === \"collection\" ? options.collectionHandle : \"\",\n recommendation: \"\",\n };\n\n debug.log(\"useAnalytics\", \"track\", event, attribution);\n\n const events = getTrackEvents(event);\n return axios.post(\n `https://analytics.usereactify.com/record/`,\n {\n events,\n attribution,\n },\n {\n headers: {\n \"x-reactify-shop\": options.shopifyPermanentDomain,\n \"x-reactify-mode\": options.mode,\n \"x-reactify-client-id\": options.clientId,\n \"x-reactify-client-version\": pkg.version,\n \"x-reactify-ga\": getCookie(\"_rs_ga\"),\n },\n }\n );\n };\n\n return { track };\n};\n\nfunction getTrackEvents(event: TrackEvent): TrackEvent[] {\n const { eventName } = event;\n let events: TrackEvent[] = [];\n\n switch (eventName) {\n case \"search\":\n events = [\n {\n eventName,\n payload: {\n ...event.payload,\n searchTerm: event.payload.searchTerm.trim(),\n },\n },\n ];\n\n break;\n\n case \"zeroResults\":\n events = [\n {\n eventName,\n payload: {\n ...event.payload,\n searchTerm: event.payload.searchTerm.trim(),\n },\n },\n ];\n\n break;\n\n case \"viewProduct\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n\n case \"clickProduct\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n\n case \"viewPromotion\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n\n case \"clickPromotion\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n\n case \"paginationChange\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n\n case \"sortChange\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n\n case \"filterChange\":\n events = [\n {\n eventName,\n payload: event.payload,\n },\n ];\n\n break;\n }\n\n return events;\n}\n\nexport type TrackEvent =\n | TrackEvent.SearchEvent\n | TrackEvent.ZeroResultsEvent\n | TrackEvent.ViewProductEvent\n | TrackEvent.ClickProductEvent\n | TrackEvent.ViewPromotionEvent\n | TrackEvent.ClickPromotionEvent\n | TrackEvent.PaginationChangeEvent\n | TrackEvent.SortChangeEvent\n | TrackEvent.FilterChangeEvent;\n\nexport namespace TrackEvent {\n export interface SearchEvent {\n eventName: \"search\";\n payload: SearchEvent.Payload;\n }\n\n export namespace SearchEvent {\n export interface Payload {\n searchTerm: string;\n }\n }\n\n export interface ZeroResultsEvent {\n eventName: \"zeroResults\";\n payload: ZeroResultsEvent.Payload;\n }\n\n export namespace ZeroResultsEvent {\n export interface Payload {\n searchTerm: string;\n }\n }\n\n export interface ViewProductEvent {\n eventName: \"viewProduct\";\n payload: ViewProductEvent.Payload;\n }\n\n export namespace ViewProductEvent {\n export interface Payload {\n elasticProduct: Product;\n }\n }\n\n export interface ClickProductEvent {\n eventName: \"clickProduct\";\n payload: ClickProductEvent.Payload;\n }\n\n export namespace ClickProductEvent {\n export interface Payload {\n elasticProduct: Product;\n }\n }\n\n export interface ViewPromotionEvent {\n eventName: \"viewPromotion\";\n payload: ViewPromotionEvent.Payload;\n }\n\n export namespace ViewPromotionEvent {\n export interface Payload {\n link: string;\n title: string;\n }\n }\n\n export interface ClickPromotionEvent {\n eventName: \"clickPromotion\";\n payload: ClickPromotionEvent.Payload;\n }\n\n export namespace ClickPromotionEvent {\n export interface Payload {\n link: string;\n title: string;\n }\n }\n\n export interface PaginationChangeEvent {\n eventName: \"paginationChange\";\n payload: PaginationChangeEvent.Payload;\n }\n\n export namespace PaginationChangeEvent {\n export interface Payload {\n page: number;\n source: \"search\" | \"collection\";\n }\n }\n\n export interface SortChangeEvent {\n eventName: \"sortChange\";\n payload: SortChangeEvent.Payload;\n }\n\n export namespace SortChangeEvent {\n export interface Payload {\n type: string;\n }\n }\n\n export interface FilterChangeEvent {\n eventName: \"filterChange\";\n payload: FilterChangeEvent.Payload;\n }\n\n export namespace FilterChangeEvent {\n export interface Payload {\n name: string;\n value: string;\n }\n }\n\n export interface Product {\n id: number;\n title: string;\n }\n export interface Attribution {\n market?: string;\n curation?: string;\n searchTerm?: string;\n collectionHandle?: string;\n recommendation?: string;\n }\n}\n"]}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { ConfigFilterFacet } from "../types/config";
|
|
2
|
-
import { useReactSliderProps } from "./react-slider/useReactSliderProps";
|
|
3
2
|
export declare const useFilterSliderProps: (filter: ConfigFilterFacet) => {
|
|
4
3
|
filter: ConfigFilterFacet;
|
|
5
4
|
value: [number, number];
|
|
6
|
-
range: [number, number];
|
|
7
5
|
handleChange: (value: [number | string, number | string]) => void;
|
|
8
|
-
handleRange: (value: [number, number]) => void;
|
|
9
|
-
reactSliderProps: ReturnType<typeof useReactSliderProps>;
|
|
10
|
-
query: any;
|
|
11
6
|
};
|
|
@@ -7,16 +7,12 @@ exports.useFilterSliderProps = void 0;
|
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const hooks_1 = require("../hooks");
|
|
9
9
|
const utility_1 = require("../utility");
|
|
10
|
-
const useReactSliderProps_1 = require("./react-slider/useReactSliderProps");
|
|
11
10
|
const useFilterSliderProps = (filter) => {
|
|
12
11
|
var _a;
|
|
13
12
|
const context = (0, hooks_1.useReactifySearchContext)();
|
|
14
13
|
const { track } = (0, hooks_1.useAnalytics)();
|
|
15
|
-
const urlSearchParam = new URLSearchParams(typeof window === "undefined" ?
|
|
14
|
+
const urlSearchParam = new URLSearchParams(typeof window === "undefined" ? context.options.query : window.location.search);
|
|
16
15
|
const [filterValue, setFilterValue] = react_1.default.useState(JSON.parse((_a = urlSearchParam.get(filter.handle)) !== null && _a !== void 0 ? _a : "[0,0]"));
|
|
17
|
-
const [filterRange, setFilterRange] = react_1.default.useState([
|
|
18
|
-
0, 0,
|
|
19
|
-
]);
|
|
20
16
|
const handleChange = react_1.default.useCallback((value) => {
|
|
21
17
|
utility_1.debug.log("useFilterSliderProps", "handleChange[value]", value);
|
|
22
18
|
setFilterValue([parseInt(`${value[0]}`), parseInt(`${value[1]}`)]);
|
|
@@ -28,42 +24,6 @@ const useFilterSliderProps = (filter) => {
|
|
|
28
24
|
},
|
|
29
25
|
});
|
|
30
26
|
}, [filter]);
|
|
31
|
-
const handleRange = react_1.default.useCallback((value) => {
|
|
32
|
-
setFilterRange([parseInt(`${value[0]}`), parseInt(`${value[1]}`)]);
|
|
33
|
-
}, [filter]);
|
|
34
|
-
const filterQuery = react_1.default.useMemo(() => {
|
|
35
|
-
if (filterValue[0] === 0 && filterValue[1] === 0) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
query: {
|
|
40
|
-
bool: {
|
|
41
|
-
must: [
|
|
42
|
-
{
|
|
43
|
-
bool: {
|
|
44
|
-
must: [
|
|
45
|
-
{
|
|
46
|
-
match: {
|
|
47
|
-
published: true,
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
range: {
|
|
52
|
-
[filter.field]: {
|
|
53
|
-
gte: filterValue[0],
|
|
54
|
-
lte: filterValue[1],
|
|
55
|
-
boost: 2,
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
},
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
}, [filter.field, filterValue[0], filterValue[1]]);
|
|
67
27
|
react_1.default.useEffect(() => {
|
|
68
28
|
const handler = (event) => {
|
|
69
29
|
setFilterValue(event.detail.value);
|
|
@@ -71,25 +31,16 @@ const useFilterSliderProps = (filter) => {
|
|
|
71
31
|
window.addEventListener(`@usereactify/search:${context.options.mode}:filter:${filter.handle}:update`, handler);
|
|
72
32
|
return () => window.removeEventListener(`@usereactify/search:${context.options.mode}:filter:${filter.handle}:update`, handler);
|
|
73
33
|
}, [context.options.mode]);
|
|
74
|
-
const reactSliderProps = (0, useReactSliderProps_1.useReactSliderProps)(filter, filterValue, filterRange, handleChange);
|
|
75
34
|
const filterSliderProps = react_1.default.useMemo(() => {
|
|
76
35
|
return {
|
|
77
36
|
handleChange,
|
|
78
|
-
handleRange,
|
|
79
37
|
filter,
|
|
80
38
|
value: filterValue,
|
|
81
|
-
range: filterRange,
|
|
82
|
-
reactSliderProps,
|
|
83
|
-
query: filterQuery,
|
|
84
39
|
};
|
|
85
40
|
}, [
|
|
86
41
|
handleChange,
|
|
87
|
-
handleRange,
|
|
88
42
|
filter,
|
|
89
43
|
filterValue,
|
|
90
|
-
filterRange,
|
|
91
|
-
reactSliderProps,
|
|
92
|
-
filterQuery,
|
|
93
44
|
]);
|
|
94
45
|
return filterSliderProps;
|
|
95
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFilterSliderProps.js","sourceRoot":"","sources":["../../../src/hooks/useFilterSliderProps.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,oCAAkE;AAClE,wCAAmC;
|
|
1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EF,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,OAAO,GAAG,CACd,KAA+D,EAC/D,EAAE;YACF,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC,CAAC;QACF,MAAM,CAAC,gBAAgB,CACrB,uBAAuB,OAAO,CAAC,OAAO,CAAC,IAAI,WAAW,MAAM,CAAC,MAAM,SAAS,EAC5E,OAAwB,CACzB,CAAC;QAEF,OAAO,GAAG,EAAE,CACV,MAAM,CAAC,mBAAmB,CACxB,uBAAuB,OAAO,CAAC,OAAO,CAAC,IAAI,WAAW,MAAM,CAAC,MAAM,SAAS,EAC5E,OAAwB,CACzB,CAAC;IACN,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAE3B,MAAM,iBAAiB,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAC3C,OAAO;YACL,YAAY;YACZ,MAAM;YACN,KAAK,EAAE,WAAW;SACnB,CAAC;IACJ,CAAC,EAAE;QACD,YAAY;QACZ,MAAM;QACN,WAAW;KACZ,CAAC,CAAC;IAEH,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AA/DW,QAAA,oBAAoB,wBA+D/B","sourcesContent":["import React from \"react\";\nimport { ConfigFilterFacet } from \"../types/config\";\nimport { useAnalytics, useReactifySearchContext } from \"../hooks\";\nimport { debug } from \"../utility\";\n\nexport const useFilterSliderProps = (\n filter: ConfigFilterFacet\n): {\n filter: ConfigFilterFacet;\n value: [number, number];\n handleChange: (value: [number | string, number | string]) => void;\n} => {\n const context = useReactifySearchContext();\n const { track } = useAnalytics();\n\n const urlSearchParam = new URLSearchParams(typeof window === \"undefined\" ? context.options.query : window.location.search);\n const [filterValue, setFilterValue] = React.useState<[number, number]>(\n JSON.parse(urlSearchParam.get(filter.handle) ?? \"[0,0]\")\n );\n\n const handleChange = React.useCallback(\n (value: [number | string, number | string]) => {\n debug.log(\"useFilterSliderProps\", \"handleChange[value]\", value);\n\n setFilterValue([parseInt(`${value[0]}`), parseInt(`${value[1]}`)]);\n\n track({\n eventName: \"filterChange\",\n payload: {\n name: filter.name,\n value: `${value[0]}:${value[1]}`,\n },\n });\n },\n [filter]\n );\n\n React.useEffect(() => {\n const handler = (\n event: CustomEvent<{ handle: string; value: [number, number] }>\n ) => {\n setFilterValue(event.detail.value);\n };\n window.addEventListener(\n `@usereactify/search:${context.options.mode}:filter:${filter.handle}:update`,\n handler as EventListener\n );\n\n return () =>\n window.removeEventListener(\n `@usereactify/search:${context.options.mode}:filter:${filter.handle}:update`,\n handler as EventListener\n );\n }, [context.options.mode]);\n\n const filterSliderProps = React.useMemo(() => {\n return {\n handleChange,\n filter,\n value: filterValue,\n };\n }, [\n handleChange,\n filter,\n filterValue,\n ]);\n\n return filterSliderProps;\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Config, ConfigRedirect, ReactivesearchResultProps } from "../types";
|
|
2
|
+
import { Config, ConfigCuration, ConfigRedirect, ReactivesearchResultProps } from "../types";
|
|
3
3
|
import { Flags } from "./useFlags";
|
|
4
4
|
export type ReactifySearchMode = "search" | "collection" | "instant-search";
|
|
5
5
|
export declare const ReactifySearchContext: React.Context<{
|
|
@@ -48,6 +48,7 @@ export declare const ReactifySearchContext: React.Context<{
|
|
|
48
48
|
resultStats?: ReactivesearchResultProps["resultStats"];
|
|
49
49
|
setResultStats: React.Dispatch<React.SetStateAction<ReactivesearchResultProps["resultStats"] | undefined>>;
|
|
50
50
|
};
|
|
51
|
+
curation: ConfigCuration | undefined;
|
|
51
52
|
} | undefined>;
|
|
52
53
|
export declare const useReactifySearchContext: () => {
|
|
53
54
|
config: Config;
|
|
@@ -95,4 +96,5 @@ export declare const useReactifySearchContext: () => {
|
|
|
95
96
|
resultStats?: ReactivesearchResultProps["resultStats"];
|
|
96
97
|
setResultStats: React.Dispatch<React.SetStateAction<ReactivesearchResultProps["resultStats"] | undefined>>;
|
|
97
98
|
};
|
|
99
|
+
curation: ConfigCuration | undefined;
|
|
98
100
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReactifySearchContext.js","sourceRoot":"","sources":["../../../src/hooks/useReactifySearchContext.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAOb,QAAA,qBAAqB,GAAG,eAAK,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"useReactifySearchContext.js","sourceRoot":"","sources":["../../../src/hooks/useReactifySearchContext.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAOb,QAAA,qBAAqB,GAAG,eAAK,CAAC,aAAa,CA8DtD,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, ConfigCuration, ConfigRedirect, ReactivesearchResultProps } from \"../types\";\nimport { Flags } from \"./useFlags\";\n\nexport type ReactifySearchMode = \"search\" | \"collection\" | \"instant-search\";\n\nexport const ReactifySearchContext = React.createContext<\n | {\n config: Config;\n options: {\n clientId: string;\n mode: ReactifySearchMode;\n index: string;\n shopifyPermanentDomain: string;\n market?: string;\n filtersHandle?: string;\n credentials?: 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 flags?: Record<Flags, boolean>;\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 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 searchRedirect: ConfigRedirect | undefined;\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 curation: ConfigCuration | undefined;\n }\n | undefined\n>(undefined);\n\nexport const useReactifySearchContext = () =>\n React.useContext(ReactifySearchContext)!;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"curation.js","sourceRoot":"","sources":["../../../src/utility/curation.ts"],"names":[],"mappings":";;;AAGO,MAAM,WAAW,GAAG,CAAC,OAI3B,
|
|
1
|
+
{"version":3,"file":"curation.js","sourceRoot":"","sources":["../../../src/utility/curation.ts"],"names":[],"mappings":";;;AAGO,MAAM,WAAW,GAAG,CAAC,OAI3B,EAA8B,EAAE;;IAC/B,MAAM,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAA,OAAO,CAAC,UAAU,mCAAI,EAAE,CAAC;IAEjI,MAAM,4BAA4B,GAAG,kBAAkB;SACpD,WAAW,EAAE;SACb,IAAI,EAAE,CAAC;IAEV,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;QAChE,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACvC,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;gBAC5B,OAAO,QAAQ,CAAC,EAAE,KAAK,UAAU,OAAO,CAAC,QAAQ,CAAC,MAAM,S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B,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAA;AAtGY,QAAA,WAAW,eAsGvB","sourcesContent":["import { ReactifySearchProviderProps } from \"../components\";\nimport { Config, ConfigCuration } from \"../types\";\n\nexport const getCuration = (options: {\n provider: ReactifySearchProviderProps;\n config: Config;\n searchTerm?: string;\n}): ConfigCuration | undefined => {\n const handleOrSearchTerm = options.provider.mode === \"collection\" ? options.provider.collectionHandle : options.searchTerm ?? \"\";\n\n const normalisedHandleOrSearchTerm = handleOrSearchTerm\n .toLowerCase()\n .trim();\n\n const globalCuration = options.config.curations.find((curation) => {\n if (options.provider.mode === \"search\") {\n if (options.provider.market) {\n return curation.id === `global_${options.provider.market}_search`;\n } else {\n return curation.id === \"global_search\";\n }\n }\n if (options.provider.mode === \"instant-search\") {\n if (options.provider.market) {\n return curation.id === `global_${options.provider.market}_search`;\n } else {\n return curation.id === \"global_search\";\n }\n }\n if (options.provider.mode === \"collection\") {\n if (options.provider.market) {\n return curation.id === `global_${options.provider.market}_collection`;\n } else {\n return curation.id === \"global_collection\";\n }\n }\n return false;\n });\n\n const curation = options.config.curations.find((curation) => {\n if (options.provider.market) {\n if (curation.markets && !curation.markets.includes(options.provider.market)) {\n return false;\n }\n }\n\n const normalisedSearchTerm = curation.searchTerm?.toLowerCase().trim();\n const normalisedCollectionHandle = curation.collectionHandle\n ?.toLowerCase()\n .trim();\n\n if (\"instant-search\" === options.provider.mode) {\n return (\n \"search\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedSearchTerm\n );\n }\n\n if (\"search\" === options.provider.mode) {\n return (\n \"search\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedSearchTerm\n );\n }\n\n if (\"collection\" === options.provider.mode) {\n return (\n \"collection\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedCollectionHandle\n );\n }\n\n return false;\n });\n\n const addGlobalBoosting = (curation: ConfigCuration) => {\n if (!globalCuration) {\n return curation;\n }\n\n const curationHasRules =\n !!curation.boosting.groupings.length ||\n !!curation.boosting.sortings.length;\n\n if (curationHasRules) {\n return curation;\n }\n\n const curationWithGlobalBoosting = {\n ...curation,\n boosting: globalCuration.boosting,\n } as ConfigCuration;\n\n return curationWithGlobalBoosting;\n };\n\n if (curation) {\n return addGlobalBoosting(curation);\n }\n\n if (globalCuration) {\n return globalCuration;\n }\n\n return undefined;\n}"]}
|
|
@@ -444,4 +444,44 @@ export declare const getPropsFilterRange: (filterGroupOption: ConfigFilterFacet)
|
|
|
444
444
|
end: number;
|
|
445
445
|
}[];
|
|
446
446
|
};
|
|
447
|
-
export declare const getPropsFilterSlider: (filterGroupOption: ConfigFilterFacet) => {
|
|
447
|
+
export declare const getPropsFilterSlider: (filterGroupOption: ConfigFilterFacet, query: Record<string, string> | string, value?: [number, number]) => {
|
|
448
|
+
defaultQuery: {
|
|
449
|
+
aggs: {
|
|
450
|
+
min: {
|
|
451
|
+
min: {
|
|
452
|
+
field: string;
|
|
453
|
+
};
|
|
454
|
+
};
|
|
455
|
+
max: {
|
|
456
|
+
max: {
|
|
457
|
+
field: string;
|
|
458
|
+
};
|
|
459
|
+
};
|
|
460
|
+
};
|
|
461
|
+
};
|
|
462
|
+
customQuery: {
|
|
463
|
+
query: {
|
|
464
|
+
bool: {
|
|
465
|
+
must: {
|
|
466
|
+
bool: {
|
|
467
|
+
must: ({
|
|
468
|
+
match: {
|
|
469
|
+
published: boolean;
|
|
470
|
+
};
|
|
471
|
+
range?: undefined;
|
|
472
|
+
} | {
|
|
473
|
+
range: {
|
|
474
|
+
[x: string]: {
|
|
475
|
+
gte: any;
|
|
476
|
+
lte: any;
|
|
477
|
+
boost: number;
|
|
478
|
+
};
|
|
479
|
+
};
|
|
480
|
+
match?: undefined;
|
|
481
|
+
})[];
|
|
482
|
+
};
|
|
483
|
+
}[];
|
|
484
|
+
};
|
|
485
|
+
};
|
|
486
|
+
} | undefined;
|
|
487
|
+
};
|
|
@@ -30,9 +30,14 @@ const getPropsFilterGroup = (options) => {
|
|
|
30
30
|
};
|
|
31
31
|
exports.getPropsFilterGroup = getPropsFilterGroup;
|
|
32
32
|
const getPropsFilterGroupOption = (options, filterGroupOption) => {
|
|
33
|
+
var _a;
|
|
33
34
|
let filterProps = {};
|
|
34
35
|
if (filterGroupOption.displayType === "slider") {
|
|
35
|
-
|
|
36
|
+
const sliderFilterProps = (0, exports.getPropsFilterSlider)(filterGroupOption, (_a = options.provider.query) !== null && _a !== void 0 ? _a : {});
|
|
37
|
+
filterProps = {
|
|
38
|
+
defaultQuery: () => sliderFilterProps.defaultQuery,
|
|
39
|
+
customQuery: () => sliderFilterProps.customQuery,
|
|
40
|
+
};
|
|
36
41
|
}
|
|
37
42
|
if (filterGroupOption.displayType === "single" || filterGroupOption.displayType === "multi") {
|
|
38
43
|
if (filterGroupOption.displayView === "range") {
|
|
@@ -247,6 +252,7 @@ const getPropsSensorSort = (options) => {
|
|
|
247
252
|
sortOption: sortOption,
|
|
248
253
|
});
|
|
249
254
|
const query = (0, sortOption_1.generateSortQuery)({
|
|
255
|
+
provider: options.provider,
|
|
250
256
|
sortOption: sortOption,
|
|
251
257
|
curation: curation,
|
|
252
258
|
});
|
|
@@ -529,8 +535,60 @@ const getPropsFilterRange = (filterGroupOption) => {
|
|
|
529
535
|
};
|
|
530
536
|
};
|
|
531
537
|
exports.getPropsFilterRange = getPropsFilterRange;
|
|
532
|
-
const getPropsFilterSlider = (filterGroupOption) => {
|
|
533
|
-
|
|
538
|
+
const getPropsFilterSlider = (filterGroupOption, query, value) => {
|
|
539
|
+
var _a;
|
|
540
|
+
const filterValue = value !== null && value !== void 0 ? value : JSON.parse((_a = new URLSearchParams(typeof window === "undefined" ? query : window.location.search).get(filterGroupOption.handle)) !== null && _a !== void 0 ? _a : "[0,0]");
|
|
541
|
+
const defaultQuery = {
|
|
542
|
+
aggs: {
|
|
543
|
+
min: {
|
|
544
|
+
min: {
|
|
545
|
+
field: filterGroupOption.field,
|
|
546
|
+
},
|
|
547
|
+
},
|
|
548
|
+
max: {
|
|
549
|
+
max: {
|
|
550
|
+
field: filterGroupOption.field,
|
|
551
|
+
},
|
|
552
|
+
},
|
|
553
|
+
},
|
|
554
|
+
};
|
|
555
|
+
const customQuery = (() => {
|
|
556
|
+
if (filterValue[0] === 0 && filterValue[1] === 0) {
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
return {
|
|
560
|
+
query: {
|
|
561
|
+
bool: {
|
|
562
|
+
must: [
|
|
563
|
+
{
|
|
564
|
+
bool: {
|
|
565
|
+
must: [
|
|
566
|
+
{
|
|
567
|
+
match: {
|
|
568
|
+
published: true,
|
|
569
|
+
},
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
range: {
|
|
573
|
+
[filterGroupOption.field]: {
|
|
574
|
+
gte: filterValue[0],
|
|
575
|
+
lte: filterValue[1],
|
|
576
|
+
boost: 2,
|
|
577
|
+
},
|
|
578
|
+
},
|
|
579
|
+
},
|
|
580
|
+
],
|
|
581
|
+
},
|
|
582
|
+
},
|
|
583
|
+
],
|
|
584
|
+
},
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
})();
|
|
588
|
+
return {
|
|
589
|
+
defaultQuery,
|
|
590
|
+
customQuery,
|
|
591
|
+
};
|
|
534
592
|
};
|
|
535
593
|
exports.getPropsFilterSlider = getPropsFilterSlider;
|
|
536
594
|
//# sourceMappingURL=props.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../src/utility/props.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oEAAgI;AAChI,8CAAwE;AAExE,yCAAyC;AACzC,6CAAkF;AAClF,uCAA2C;AAC3C,oCAAqD;AAErD,sEAAqC;AAqB9B,MAAM,mBAAmB,GAAG,CAAC,OAAwC,EAAE,EAAE;;IAC9E,OAAO;QACL,GAAG,MAAA,MAAA,OAAO,CAAC,WAAW,0CAAE,OAAO,CAAC,GAAG,CAAC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E,KAAK,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9C,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YAClC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB;SACnD,CAAC;IACJ,CAAC,CAAC,mCAAI,EAAE,CAAC;IAET,OAAO;QACL,WAAW,EAAE,MAAA,iBAAiB,CAAC,mBAAmB,mCAAI,IAAI;QAC1D,UAAU,EAAE,MAAA,iBAAiB,CAAC,kBAAkB,mCAAI,IAAI;QACxD,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,KAAK;QACnB,IAAI,EAAE,IAAI;KACX,CAAC;AACJ,CAAC,CAAC;AAjBW,QAAA,mBAAmB,uBAiB9B;AAEK,MAAM,oBAAoB,GAAG,CAAC,iBAAoC,EAAE,EAAE;IAC3E,OAAO,EAAE,CAAA;AACX,CAAC,CAAC;AAFW,QAAA,oBAAoB,wBAE/B","sourcesContent":["import { MultiList, MultiRange, ReactiveComponent, ReactiveList, SingleList, SingleRange } from \"@usereactify/search-internals\";\nimport { ReactifySearchProviderProps, SENSOR_IDS } from \"../components\";\nimport { Config, ConfigFilter, ConfigFilterFacet } from \"../types\";\nimport { getCuration } from \"./curation\";\nimport { generateSortQuery, generateSortSort, getSortOption } from \"./sortOption\";\nimport { getFilterStack } from \"./filters\";\nimport { replaceDocCountWithParent } from \"../hooks\";\n\nimport pkg from \"../../package.json\";\n\nexport type GeneratePropsFilterGroupOptions = {\n provider: ReactifySearchProviderProps;\n config: Config;\n filterGroup?: ConfigFilter;\n query?: Record<string, string>;\n};\n\nexport type GeneratePropsSensorOptions = {\n provider: ReactifySearchProviderProps;\n config: Config;\n query?: Record<string, string>;\n};\n\nexport type GeneratePropsBase = {\n provider: ReactifySearchProviderProps;\n config: Config;\n query?: Record<string, string>;\n};\n\nexport const getPropsFilterGroup = (options: GeneratePropsFilterGroupOptions) => {\n return [\n ...options.filterGroup?.options.map((filterGroupOption) => getPropsFilterGroupOption(options, filterGroupOption)) ?? [],\n ...getPropsSensors(options),\n getPropsResults(options),\n ];\n};\n\nexport const getPropsFilterGroupOption = (options: GeneratePropsFilterGroupOptions, filterGroupOption: ConfigFilterFacet) => {\n let filterProps: Record<string, unknown> = {};\n\n if (filterGroupOption.displayType === \"slider\") {\n filterProps = getPropsFilterSlider(filterGroupOption);\n }\n\n if (filterGroupOption.displayType === \"single\" || filterGroupOption.displayType === \"multi\") {\n if (filterGroupOption.displayView === \"range\") {\n filterProps = getPropsFilterRange(filterGroupOption);\n } else {\n filterProps = getPropsFilterList(filterGroupOption);\n }\n }\n\n const sharedProps = getPropsShared(options, filterGroupOption);\n\n return {\n ...sharedProps,\n ...filterProps,\n };\n};\n\nexport const getPropsSensors = (options: GeneratePropsSensorOptions) => {\n return [\n ...getPropsSensorCustom(options),\n getPropsSensorCollection(options),\n getPropsSensorPublished(options),\n getPropsSensorInventoryAvailable(options),\n getPropsSensorSort(options),\n ].filter(Boolean);\n}\n\nexport const getPropsSensorCustom = (options: GeneratePropsSensorOptions) => {\n const sensors = options.provider.mode === \"collection\" ? options.config.sensors.collection : options.config.sensors.search;\n\n return sensors.map((sensor, index) => ({\n componentId: `SensorCustom_${index}`,\n customQuery: () => sensor,\n source: ReactiveComponent,\n }));\n}\n\nexport const getPropsSensorCollection = (options: GeneratePropsSensorOptions) => {\n if (options.provider.mode !== \"collection\") {\n return null;\n }\n \n return {\n componentId: \"SensorCollection\",\n customQuery: () => {\n if (options.provider.mode !== \"collection\") {\n return null;\n }\n\n const conditions: Array<unknown> = [];\n\n if (options.provider.market) {\n conditions.push({\n nested: {\n path: \"curations\",\n query: {\n bool: {\n should: [\n {\n nested: {\n path: \"collections\",\n query: {\n term: {\n \"collections.handle.keyword\": options.provider.collectionHandle,\n },\n },\n },\n },\n {\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.collectionHandle.keyword\":\n options.provider.collectionHandle,\n },\n },\n },\n },\n ],\n must: [{\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.markets.keyword\": options.provider.market,\n },\n },\n },\n }]\n },\n },\n },\n });\n }\n \n return {\n query: {\n bool: {\n should: [\n {\n nested: {\n path: \"collections\",\n query: {\n term: {\n \"collections.handle.keyword\": options.provider.collectionHandle,\n },\n },\n },\n },\n {\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.collectionHandle.keyword\":\n options.provider.collectionHandle,\n },\n },\n },\n },\n ],\n },\n },\n } \n },\n source: ReactiveComponent,\n };\n}\n\nexport const getPropsSensorPublished = (options: GeneratePropsSensorOptions) => {\n return {\n componentId: \"SensorPublished\",\n customQuery: () => {\n if (options.provider.market) {\n return {\n query: {\n bool: {\n must:[{\n match: {\n markets: options.provider.market,\n },\n },{\n match: {\n published: true,\n },\n }]\n },\n },\n };\n }\n\n return {\n query: {\n match: {\n published: true,\n },\n },\n }\n },\n source: ReactiveComponent,\n }\n}\n\nexport const getPropsSensorInventoryAvailable = (options: GeneratePropsSensorOptions) => {\n const filterStack = getFilterStack(options);\n\n if (!filterStack || \"show_all\" === filterStack.inventoryVisibility) {\n return null;\n }\n\n return {\n componentId: \"SensorInventoryAvailable\",\n customQuery: () => ({\n query: {\n bool: {\n should: [\n {\n bool: {\n must: [\n {\n term: {\n type: {\n value: \"product\",\n },\n },\n },\n {\n nested: {\n path: \"variants\",\n query: {\n match: { \"variants.available\": true },\n },\n },\n },\n ],\n },\n },\n ...(options.provider.mode === \"instant-search\"\n ? []\n : [\n {\n term: {\n type: {\n value: \"callout\",\n },\n },\n },\n ]),\n ],\n minimum_should_match: \"1\",\n },\n },\n }),\n source: ReactiveComponent,\n }\n}\n\nexport const getPropsSensorSort = (options: GeneratePropsSensorOptions & { searchTerm?: string; sortOption?: string; }) => {\n const curation = getCuration(options);\n const sortOption = getSortOption(options);\n\n const sort = generateSortSort({\n provider: options.provider,\n config: options.config,\n curation: curation,\n sortOption: sortOption,\n });\n const query = generateSortQuery({\n sortOption: sortOption,\n curation: curation,\n });\n\n return {\n componentId: \"SensorSort\",\n customQuery: () => ({\n sort,\n query,\n }),\n source: ReactiveComponent,\n }\n}\n\nexport const getPropsBase = (options: GeneratePropsBase) => {\n const props = {\n app: options.config.index,\n url: options.config.endpoint,\n credentials: options.provider.credentials,\n theme: options.provider.theme,\n initialState: options.provider.preload?.state,\n transformSort: () => {\n const sortSensor = getPropsSensorSort(options);\n const customQuery = sortSensor.customQuery();\n\n return customQuery.sort;\n },\n transformRequest: (request: any) => {\n if ((request.url as string).endsWith(\"?\")) {\n request.url = request.url.substring(0, request.url.length - 1);\n }\n return request;\n },\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 replaceDocCountWithParent(\n response?.aggregations?.reactivesearch_nested\n ?.reactify_nested_outer\n );\n }\n\n return response;\n },\n headers: {\n \"x-reactify-shop\": options.provider.shopifyPermanentDomain,\n \"x-reactify-mode\": options.provider.mode,\n \"x-reactify-client-id\": options.provider.clientId,\n \"x-reactify-client-version\": pkg.version,\n },\n };\n\n return props;\n}\n\nexport const getPropsResults = (options: GeneratePropsFilterGroupOptions & { scrollTarget?: string | Element | HTMLDocument; pageSize?: number; }) => {\n const includeFieldsProp = (() => {\n return [\n ...(options.provider.includeFields ?? []),\n \"id\",\n \"title\",\n \"type\",\n \"handle\",\n \"image\",\n \"variants.id\",\n \"variants.presentment_prices\",\n \"callout\",\n ];\n })();\n const excludeFieldsProp = (() => {\n return [...(options.provider.excludeFields ?? [])];\n })();\n\n return {\n size: options.pageSize ?? options.filterGroup?.pageSize ?? 20,\n URLParams: options.provider.mode === \"instant-search\" ? false : true,\n showLoader: false,\n dataField: \"title\",\n showResultStats: false,\n react: getPropsReact(options),\n includeFields: includeFieldsProp,\n excludeFields: excludeFieldsProp,\n scrollTarget: options.scrollTarget,\n componentId: \"page\", // this sets ?page= in the URL\n scrollOnChange: false, // @todo make this better, it's really janky when enabled\n pagination: options.filterGroup?.paginationType !== \"infinite_scroll\",\n infiniteScroll: options.filterGroup?.paginationType === \"infinite_scroll\",\n renderNoResults: () => null, // always use only render, otherwise both are shown\n source: ReactiveList,\n // defaultQuery: () => ({\n // sort: [\"_score\"],\n // query: {\n // match_all: {}\n // }\n // })\n }\n}\n\nexport const getPropsReact = (options: GeneratePropsFilterGroupOptions, filterGroupOption?: ConfigFilterFacet) => {\n const sensorIds = SENSOR_IDS(options.provider.mode, options.config);\n const reactProp = (() => {\n if (filterGroupOption?.settingsShowEmptyValues) {\n return {\n and: sensorIds,\n };\n }\n\n return {\n and: [\n ...sensorIds,\n ...(options.provider.additionalComponentIds ?? []),\n ...(options.filterGroup?.options.map((filter) => filter.handle) ?? []),\n ].filter((handle) => handle !== filterGroupOption?.handle),\n };\n })();\n\n return reactProp;\n};\n\nexport const getPropsShared = (options: GeneratePropsFilterGroupOptions, filterGroupOption: ConfigFilterFacet) => {\n const reactProp = getPropsReact(options, filterGroupOption);\n const nestedFieldProp = (() => {\n const nestedFields = [\"variants\"];\n const topField = filterGroupOption.field.split(\".\")[0];\n if (nestedFields.includes(topField)) {\n return topField;\n }\n return undefined;\n })();\n const customQueryProp = (() => {\n if (\n !filterGroupOption.settingsHideUnavailable ||\n !filterGroupOption.field.startsWith(\"variants.\")\n )\n return undefined;\n\n return (value?: string | string[]) => {\n if (!value) return {};\n\n // reactivesearch sometimes returns string, sometimes string[]\n const valueArray = \"string\" === typeof value ? [value] : value;\n\n if (0 === valueArray.length) return {};\n\n return {\n query: {\n nested: {\n path: \"variants\",\n query: {\n bool: {\n must: [\n {\n match: {\n \"variants.available\": \"true\",\n },\n },\n {\n terms: {\n [filterGroupOption.field]: valueArray,\n },\n },\n ],\n },\n },\n },\n },\n };\n };\n })();\n const defaultQueryProp = (() => {\n if (!filterGroupOption.field.startsWith(\"variants.\")) {\n return undefined;\n }\n\n // override the aggregation query to filter the results by the variants.available attribute\n return () => {\n return {\n aggs: {\n reactivesearch_nested: {\n nested: { path: \"variants\" },\n aggs: {\n reactify_nested_outer: {\n filter: {\n bool: {\n minimum_should_match: 1,\n should: [\n {\n match: {\n \"variants.available\": \"true\",\n },\n },\n {\n match: {\n \"variants.available\": filterGroupOption.settingsHideUnavailable\n ? \"true\"\n : \"false\",\n },\n },\n ],\n },\n },\n aggs: {\n [filterGroupOption.field]: {\n terms: {\n field: filterGroupOption.field,\n size: 100,\n order: { _count: \"desc\" },\n },\n aggs: {\n parent_docs: { reverse_nested: {} },\n },\n },\n },\n },\n },\n },\n },\n };\n };\n })();\n const sourceProp = (() => {\n if (filterGroupOption.displayType === \"slider\") {\n return ReactiveComponent;\n }\n if (filterGroupOption.displayType === \"single\") {\n if (filterGroupOption.displayView === \"range\") {\n return SingleRange;\n }\n return SingleList;\n }\n if (filterGroupOption.displayType === \"multi\") {\n if (filterGroupOption.displayView === \"range\") {\n return MultiRange;\n }\n return MultiList;\n }\n \n return;\n })();\n\n return {\n URLParams: true,\n componentId: filterGroupOption.handle,\n dataField: filterGroupOption.field,\n filterLabel: filterGroupOption.name,\n nestedField: nestedFieldProp,\n customQuery: customQueryProp,\n defaultQuery: defaultQueryProp,\n source: sourceProp,\n react: reactProp,\n }\n};\n\nexport const getPropsFilterList = (filterGroupOption: ConfigFilterFacet) => {\n return {\n size: parseInt(filterGroupOption.displaySize) || undefined,\n queryFormat: filterGroupOption.settingsFilterLogic ?? \"or\",\n showFilter: filterGroupOption.settingsShowFilter ?? true,\n showLoadMore: filterGroupOption.settingsShowMore ?? false,\n showSearch: filterGroupOption.settingsShowSearch ?? false,\n showRadio: false,\n showCheckbox: false,\n };\n};\n\nexport const getPropsFilterRange = (filterGroupOption: ConfigFilterFacet) => {\n const data = filterGroupOption.displayRangeOptions?.map((option) => {\n const [label, start, end] = option.split(\":\");\n return {\n label: label,\n start: start ? parseInt(start) : 0,\n end: end ? parseInt(end) : Number.MAX_SAFE_INTEGER,\n };\n }) ?? [];\n\n return {\n queryFormat: filterGroupOption.settingsFilterLogic ?? \"or\",\n showFilter: filterGroupOption.settingsShowFilter ?? true,\n showRadio: false,\n showCheckbox: false,\n data: data,\n };\n};\n\nexport const getPropsFilterSlider = (filterGroupOption: ConfigFilterFacet) => {\n return {}\n};"]}
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../src/utility/props.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oEAAgI;AAChI,8CAAwE;AAExE,yCAAyC;AACzC,6CAAkF;AAClF,uCAA2C;AAC3C,oCAAqD;AAErD,sEAAqC;AAqB9B,MAAM,mBAAmB,GAAG,CAAC,OAAwC,EAAE,EAAE;;IAC9E,OAAO;QACL,GAAG,MAAA,MAAA,OAAO,CAAC,WAAW,0CAAE,OAAO,CAAC,GAAG,CAAC,CAAC,iBAAiB,EAAE,EAAE,CAAC,IAAA,iCAAyB,EAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC,mCAAI,EAAE;QACvH,GAAG,IAAA,uBAAe,EAAC,OAAO,CAAC;QAC3B,IAAA,uBAAe,EAAC,OAAO,CAAC;KACzB,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B;AAEK,MAAM,yBAAyB,GAAG,CAAC,OAAwC,EAAE,iBAAoC,EAAE,EAAE;;IAC1H,IAAI,WAAW,GAA4B,EAAE,CAAC;IAE9C,IAAI,iBAAiB,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;QAC/C,MAAM,iBAAiB,GAAG,IAAA,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AAI,EAAE;oBACJ,IAAI,EAAE;wBACJ;4BACE,IAAI,EAAE;gCACJ,IAAI,EAAE;oCACJ;wCACE,KAAK,EAAE;4CACL,SAAS,EAAE,IAAI;yCAChB;qCACF;oCACD;wCACE,KAAK,EAAE;4CACL,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE;gDACzB,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC;gDACnB,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC;gDACnB,KAAK,EAAE,CAAC;6CACT;yCACF;qCACF;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC,CAAC,EAAE,CAAC;IAEL,OAAO;QACL,YAAY;QACZ,WAAW;KACZ,CAAC;AACJ,CAAC,CAAC;AAzDW,QAAA,oBAAoB,wBAyD/B","sourcesContent":["import { MultiList, MultiRange, ReactiveComponent, ReactiveList, SingleList, SingleRange } from \"@usereactify/search-internals\";\nimport { ReactifySearchProviderProps, SENSOR_IDS } from \"../components\";\nimport { Config, ConfigFilter, ConfigFilterFacet } from \"../types\";\nimport { getCuration } from \"./curation\";\nimport { generateSortQuery, generateSortSort, getSortOption } from \"./sortOption\";\nimport { getFilterStack } from \"./filters\";\nimport { replaceDocCountWithParent } from \"../hooks\";\n\nimport pkg from \"../../package.json\";\n\nexport type GeneratePropsFilterGroupOptions = {\n provider: ReactifySearchProviderProps;\n config: Config;\n filterGroup?: ConfigFilter;\n query?: Record<string, string>;\n};\n\nexport type GeneratePropsSensorOptions = {\n provider: ReactifySearchProviderProps;\n config: Config;\n query?: Record<string, string>;\n};\n\nexport type GeneratePropsBase = {\n provider: ReactifySearchProviderProps;\n config: Config;\n query?: Record<string, string>;\n};\n\nexport const getPropsFilterGroup = (options: GeneratePropsFilterGroupOptions) => {\n return [\n ...options.filterGroup?.options.map((filterGroupOption) => getPropsFilterGroupOption(options, filterGroupOption)) ?? [],\n ...getPropsSensors(options),\n getPropsResults(options),\n ];\n};\n\nexport const getPropsFilterGroupOption = (options: GeneratePropsFilterGroupOptions, filterGroupOption: ConfigFilterFacet) => {\n let filterProps: Record<string, unknown> = {};\n\n if (filterGroupOption.displayType === \"slider\") {\n const sliderFilterProps = getPropsFilterSlider(filterGroupOption, options.provider.query ?? {});\n filterProps = {\n defaultQuery: () => sliderFilterProps.defaultQuery,\n customQuery: () => sliderFilterProps.customQuery,\n };\n }\n\n if (filterGroupOption.displayType === \"single\" || filterGroupOption.displayType === \"multi\") {\n if (filterGroupOption.displayView === \"range\") {\n filterProps = getPropsFilterRange(filterGroupOption);\n } else {\n filterProps = getPropsFilterList(filterGroupOption);\n }\n }\n\n const sharedProps = getPropsShared(options, filterGroupOption);\n\n return {\n ...sharedProps,\n ...filterProps,\n };\n};\n\nexport const getPropsSensors = (options: GeneratePropsSensorOptions) => {\n return [\n ...getPropsSensorCustom(options),\n getPropsSensorCollection(options),\n getPropsSensorPublished(options),\n getPropsSensorInventoryAvailable(options),\n getPropsSensorSort(options),\n ].filter(Boolean);\n}\n\nexport const getPropsSensorCustom = (options: GeneratePropsSensorOptions) => {\n const sensors = options.provider.mode === \"collection\" ? options.config.sensors.collection : options.config.sensors.search;\n\n return sensors.map((sensor, index) => ({\n componentId: `SensorCustom_${index}`,\n customQuery: () => sensor,\n source: ReactiveComponent,\n }));\n}\n\nexport const getPropsSensorCollection = (options: GeneratePropsSensorOptions) => {\n if (options.provider.mode !== \"collection\") {\n return null;\n }\n \n return {\n componentId: \"SensorCollection\",\n customQuery: () => {\n if (options.provider.mode !== \"collection\") {\n return null;\n }\n\n const conditions: Array<unknown> = [];\n\n if (options.provider.market) {\n conditions.push({\n nested: {\n path: \"curations\",\n query: {\n bool: {\n should: [\n {\n nested: {\n path: \"collections\",\n query: {\n term: {\n \"collections.handle.keyword\": options.provider.collectionHandle,\n },\n },\n },\n },\n {\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.collectionHandle.keyword\":\n options.provider.collectionHandle,\n },\n },\n },\n },\n ],\n must: [{\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.markets.keyword\": options.provider.market,\n },\n },\n },\n }]\n },\n },\n },\n });\n }\n \n return {\n query: {\n bool: {\n should: [\n {\n nested: {\n path: \"collections\",\n query: {\n term: {\n \"collections.handle.keyword\": options.provider.collectionHandle,\n },\n },\n },\n },\n {\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.collectionHandle.keyword\":\n options.provider.collectionHandle,\n },\n },\n },\n },\n ],\n },\n },\n } \n },\n source: ReactiveComponent,\n };\n}\n\nexport const getPropsSensorPublished = (options: GeneratePropsSensorOptions) => {\n return {\n componentId: \"SensorPublished\",\n customQuery: () => {\n if (options.provider.market) {\n return {\n query: {\n bool: {\n must:[{\n match: {\n markets: options.provider.market,\n },\n },{\n match: {\n published: true,\n },\n }]\n },\n },\n };\n }\n\n return {\n query: {\n match: {\n published: true,\n },\n },\n }\n },\n source: ReactiveComponent,\n }\n}\n\nexport const getPropsSensorInventoryAvailable = (options: GeneratePropsSensorOptions) => {\n const filterStack = getFilterStack(options);\n\n if (!filterStack || \"show_all\" === filterStack.inventoryVisibility) {\n return null;\n }\n\n return {\n componentId: \"SensorInventoryAvailable\",\n customQuery: () => ({\n query: {\n bool: {\n should: [\n {\n bool: {\n must: [\n {\n term: {\n type: {\n value: \"product\",\n },\n },\n },\n {\n nested: {\n path: \"variants\",\n query: {\n match: { \"variants.available\": true },\n },\n },\n },\n ],\n },\n },\n ...(options.provider.mode === \"instant-search\"\n ? []\n : [\n {\n term: {\n type: {\n value: \"callout\",\n },\n },\n },\n ]),\n ],\n minimum_should_match: \"1\",\n },\n },\n }),\n source: ReactiveComponent,\n }\n}\n\nexport const getPropsSensorSort = (options: GeneratePropsSensorOptions & { searchTerm?: string; sortOption?: string; }) => {\n const curation = getCuration(options);\n const sortOption = getSortOption(options);\n\n const sort = generateSortSort({\n provider: options.provider,\n config: options.config,\n curation: curation,\n sortOption: sortOption,\n });\n const query = generateSortQuery({\n provider: options.provider,\n sortOption: sortOption,\n curation: curation,\n });\n\n return {\n componentId: \"SensorSort\",\n customQuery: () => ({\n sort,\n query,\n }),\n source: ReactiveComponent,\n }\n}\n\nexport const getPropsBase = (options: GeneratePropsBase) => {\n const props = {\n app: options.config.index,\n url: options.config.endpoint,\n credentials: options.provider.credentials,\n theme: options.provider.theme,\n initialState: options.provider.preload?.state,\n transformSort: () => {\n const sortSensor = getPropsSensorSort(options);\n const customQuery = sortSensor.customQuery();\n\n return customQuery.sort;\n },\n transformRequest: (request: any) => {\n if ((request.url as string).endsWith(\"?\")) {\n request.url = request.url.substring(0, request.url.length - 1);\n }\n return request;\n },\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 replaceDocCountWithParent(\n response?.aggregations?.reactivesearch_nested\n ?.reactify_nested_outer\n );\n }\n\n return response;\n },\n headers: {\n \"x-reactify-shop\": options.provider.shopifyPermanentDomain,\n \"x-reactify-mode\": options.provider.mode,\n \"x-reactify-client-id\": options.provider.clientId,\n \"x-reactify-client-version\": pkg.version,\n },\n };\n\n return props;\n}\n\nexport const getPropsResults = (options: GeneratePropsFilterGroupOptions & { scrollTarget?: string | Element | HTMLDocument; pageSize?: number; }) => {\n const includeFieldsProp = (() => {\n return [\n ...(options.provider.includeFields ?? []),\n \"id\",\n \"title\",\n \"type\",\n \"handle\",\n \"image\",\n \"variants.id\",\n \"variants.presentment_prices\",\n \"callout\",\n ];\n })();\n const excludeFieldsProp = (() => {\n return [...(options.provider.excludeFields ?? [])];\n })();\n\n return {\n size: options.pageSize ?? options.filterGroup?.pageSize ?? 20,\n URLParams: options.provider.mode === \"instant-search\" ? false : true,\n showLoader: false,\n dataField: \"title\",\n showResultStats: false,\n react: getPropsReact(options),\n includeFields: includeFieldsProp,\n excludeFields: excludeFieldsProp,\n scrollTarget: options.scrollTarget,\n componentId: \"page\", // this sets ?page= in the URL\n scrollOnChange: false, // @todo make this better, it's really janky when enabled\n pagination: options.filterGroup?.paginationType !== \"infinite_scroll\",\n infiniteScroll: options.filterGroup?.paginationType === \"infinite_scroll\",\n renderNoResults: () => null, // always use only render, otherwise both are shown\n source: ReactiveList,\n // defaultQuery: () => ({\n // sort: [\"_score\"],\n // query: {\n // match_all: {}\n // }\n // })\n }\n}\n\nexport const getPropsReact = (options: GeneratePropsFilterGroupOptions, filterGroupOption?: ConfigFilterFacet) => {\n const sensorIds = SENSOR_IDS(options.provider.mode, options.config);\n const reactProp = (() => {\n if (filterGroupOption?.settingsShowEmptyValues) {\n return {\n and: sensorIds,\n };\n }\n\n return {\n and: [\n ...sensorIds,\n ...(options.provider.additionalComponentIds ?? []),\n ...(options.filterGroup?.options.map((filter) => filter.handle) ?? []),\n ].filter((handle) => handle !== filterGroupOption?.handle),\n };\n })();\n\n return reactProp;\n};\n\nexport const getPropsShared = (options: GeneratePropsFilterGroupOptions, filterGroupOption: ConfigFilterFacet) => {\n const reactProp = getPropsReact(options, filterGroupOption);\n const nestedFieldProp = (() => {\n const nestedFields = [\"variants\"];\n const topField = filterGroupOption.field.split(\".\")[0];\n if (nestedFields.includes(topField)) {\n return topField;\n }\n return undefined;\n })();\n const customQueryProp = (() => {\n if (\n !filterGroupOption.settingsHideUnavailable ||\n !filterGroupOption.field.startsWith(\"variants.\")\n )\n return undefined;\n\n return (value?: string | string[]) => {\n if (!value) return {};\n\n // reactivesearch sometimes returns string, sometimes string[]\n const valueArray = \"string\" === typeof value ? [value] : value;\n\n if (0 === valueArray.length) return {};\n\n return {\n query: {\n nested: {\n path: \"variants\",\n query: {\n bool: {\n must: [\n {\n match: {\n \"variants.available\": \"true\",\n },\n },\n {\n terms: {\n [filterGroupOption.field]: valueArray,\n },\n },\n ],\n },\n },\n },\n },\n };\n };\n })();\n const defaultQueryProp = (() => {\n if (!filterGroupOption.field.startsWith(\"variants.\")) {\n return undefined;\n }\n\n // override the aggregation query to filter the results by the variants.available attribute\n return () => {\n return {\n aggs: {\n reactivesearch_nested: {\n nested: { path: \"variants\" },\n aggs: {\n reactify_nested_outer: {\n filter: {\n bool: {\n minimum_should_match: 1,\n should: [\n {\n match: {\n \"variants.available\": \"true\",\n },\n },\n {\n match: {\n \"variants.available\": filterGroupOption.settingsHideUnavailable\n ? \"true\"\n : \"false\",\n },\n },\n ],\n },\n },\n aggs: {\n [filterGroupOption.field]: {\n terms: {\n field: filterGroupOption.field,\n size: 100,\n order: { _count: \"desc\" },\n },\n aggs: {\n parent_docs: { reverse_nested: {} },\n },\n },\n },\n },\n },\n },\n },\n };\n };\n })();\n const sourceProp = (() => {\n if (filterGroupOption.displayType === \"slider\") {\n return ReactiveComponent;\n }\n if (filterGroupOption.displayType === \"single\") {\n if (filterGroupOption.displayView === \"range\") {\n return SingleRange;\n }\n return SingleList;\n }\n if (filterGroupOption.displayType === \"multi\") {\n if (filterGroupOption.displayView === \"range\") {\n return MultiRange;\n }\n return MultiList;\n }\n \n return;\n })();\n\n return {\n URLParams: true,\n componentId: filterGroupOption.handle,\n dataField: filterGroupOption.field,\n filterLabel: filterGroupOption.name,\n nestedField: nestedFieldProp,\n customQuery: customQueryProp,\n defaultQuery: defaultQueryProp,\n source: sourceProp,\n react: reactProp,\n }\n};\n\nexport const getPropsFilterList = (filterGroupOption: ConfigFilterFacet) => {\n return {\n size: parseInt(filterGroupOption.displaySize) || undefined,\n queryFormat: filterGroupOption.settingsFilterLogic ?? \"or\",\n showFilter: filterGroupOption.settingsShowFilter ?? true,\n showLoadMore: filterGroupOption.settingsShowMore ?? false,\n showSearch: filterGroupOption.settingsShowSearch ?? false,\n showRadio: false,\n showCheckbox: false,\n };\n};\n\nexport const getPropsFilterRange = (filterGroupOption: ConfigFilterFacet) => {\n const data = filterGroupOption.displayRangeOptions?.map((option) => {\n const [label, start, end] = option.split(\":\");\n return {\n label: label,\n start: start ? parseInt(start) : 0,\n end: end ? parseInt(end) : Number.MAX_SAFE_INTEGER,\n };\n }) ?? [];\n\n return {\n queryFormat: filterGroupOption.settingsFilterLogic ?? \"or\",\n showFilter: filterGroupOption.settingsShowFilter ?? true,\n showRadio: false,\n showCheckbox: false,\n data: data,\n };\n};\n\nexport const getPropsFilterSlider = (filterGroupOption: ConfigFilterFacet, query: Record<string, string> | string, value?: [number, number]) => {\n const filterValue = value ?? JSON.parse(new URLSearchParams(typeof window === \"undefined\" ? query : window.location.search).get(filterGroupOption.handle) ?? \"[0,0]\");\n\n const defaultQuery = {\n aggs: {\n min: {\n min: {\n field: filterGroupOption.field,\n },\n },\n max: {\n max: {\n field: filterGroupOption.field,\n },\n },\n },\n };\n\n const customQuery = (() => {\n if (filterValue[0] === 0 && filterValue[1] === 0) {\n return;\n }\n\n return {\n query: {\n bool: {\n must: [\n {\n bool: {\n must: [\n {\n match: {\n published: true,\n },\n },\n {\n range: {\n [filterGroupOption.field]: {\n gte: filterValue[0],\n lte: filterValue[1],\n boost: 2,\n },\n },\n },\n ],\n },\n },\n ],\n },\n }\n };\n })();\n \n return {\n defaultQuery,\n customQuery,\n };\n};"]}
|
|
@@ -18,6 +18,7 @@ export declare const generateSortSort: (options: {
|
|
|
18
18
|
sortOption?: ConfigSort;
|
|
19
19
|
}) => any[];
|
|
20
20
|
export declare const generateSortQuery: (options: {
|
|
21
|
+
provider: ReactifySearchProviderProps;
|
|
21
22
|
curation?: ConfigCuration;
|
|
22
23
|
sortOption?: ConfigSort;
|
|
23
24
|
}) => Record<string, any> | undefined;
|
|
@@ -151,6 +151,27 @@ const generateSortQuery = (options) => {
|
|
|
151
151
|
if (!options.curation || options.curation.id.includes("global")) {
|
|
152
152
|
return { match_all: {} };
|
|
153
153
|
}
|
|
154
|
+
const queries = [{
|
|
155
|
+
term: {
|
|
156
|
+
[`curations.${"collection" === options.curation.type
|
|
157
|
+
? "collectionHandle"
|
|
158
|
+
: "searchTerm"}.keyword`]: "collection" === options.curation.type
|
|
159
|
+
? options.curation.collectionHandle
|
|
160
|
+
: (_a = options.curation.searchTerm) === null || _a === void 0 ? void 0 : _a.toLowerCase(),
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
term: {
|
|
165
|
+
"curations.hidden": true,
|
|
166
|
+
},
|
|
167
|
+
}];
|
|
168
|
+
if (options.provider.market) {
|
|
169
|
+
queries.push({
|
|
170
|
+
term: {
|
|
171
|
+
"curations.markets.keyword": options.provider.market,
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
}
|
|
154
175
|
return {
|
|
155
176
|
bool: {
|
|
156
177
|
must_not: [
|
|
@@ -159,22 +180,7 @@ const generateSortQuery = (options) => {
|
|
|
159
180
|
path: "curations",
|
|
160
181
|
query: {
|
|
161
182
|
bool: {
|
|
162
|
-
must:
|
|
163
|
-
{
|
|
164
|
-
term: {
|
|
165
|
-
[`curations.${"collection" === options.curation.type
|
|
166
|
-
? "collectionHandle"
|
|
167
|
-
: "searchTerm"}.keyword`]: "collection" === options.curation.type
|
|
168
|
-
? options.curation.collectionHandle
|
|
169
|
-
: (_a = options.curation.searchTerm) === null || _a === void 0 ? void 0 : _a.toLowerCase(),
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
term: {
|
|
174
|
-
"curations.hidden": true,
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
],
|
|
183
|
+
must: queries,
|
|
178
184
|
},
|
|
179
185
|
},
|
|
180
186
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sortOption.js","sourceRoot":"","sources":["../../../src/utility/sortOption.ts"],"names":[],"mappings":";;;AAGO,MAAM,cAAc,GAAG,CAAC,OAI9B,EAAE,EAAE;IACH,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI;SACvB,IAAI,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oBACpE,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;AArDW,QAAA,iBAAiB,qBAqD5B","sourcesContent":["import { ReactifySearchProviderProps } from \"../components\";\nimport { Config, ConfigCuration, ConfigSort } from \"../types\";\n\nexport const getSortOptions = (options: {\n provider: ReactifySearchProviderProps;\n config: Config;\n sortOption?: string;\n}) => {\n return options.config.sort\n .sort((a, b) => {\n const aInt =\n typeof a.position === \"string\"\n ? parseInt(a.position, 10)\n : a.position;\n const bInt =\n typeof b.position === \"string\"\n ? parseInt(b.position, 10)\n : b.position;\n return aInt - bInt;\n })\n .filter(({ visibility }) => [\"all\", options.provider.mode].includes(visibility));\n\n}\n\nexport const getSortOption = (options: {\n provider: ReactifySearchProviderProps;\n config: Config;\n sortOption?: string;\n query?: Record<string, string>;\n}) => {\n const sortOptions = getSortOptions(options);\n\n return sortOptions.find(({ handle }) => handle === options.sortOption || handle === options.query?.sort) ?? sortOptions[0];\n}\n\nexport const generateSortSort = (options: {\n provider: ReactifySearchProviderProps;\n config: Config;\n curation?: ConfigCuration;\n sortOption?: ConfigSort;\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 (options.provider.mode !== \"instant-search\") {\n if (\n options.sortOption &&\n ![\"_score\", \"collections.position\"].includes(options.sortOption.field)\n ) {\n return [{ [options.sortOption.field]: options.sortOption.direction }];\n }\n }\n\n const sorts = [];\n\n // collection curation pin sorting\n if (options.provider.mode === \"collection\" && options.provider.collectionHandle) {\n if (options.curation?.collectionHandle) {\n const queries: Array<unknown> = [{\n term: {\n \"curations.collectionHandle.keyword\": options.curation.collectionHandle,\n },\n }];\n if (options.provider.market) {\n queries.push({\n term: {\n \"curations.markets.keyword\": options.provider.market,\n },\n });\n }\n sorts.push({\n \"curations.position\": {\n unmapped_type: \"long\",\n order: \"asc\",\n nested: {\n path: \"curations\",\n filter: {\n bool: {\n must: queries\n }\n }\n },\n },\n });\n }\n }\n\n // search options.curation pin sorting\n if (options.provider.mode === \"search\" || options.provider.mode === \"instant-search\") {\n if (options.curation?.searchTerm) {\n const queries: Array<unknown> = [{\n term: {\n \"curations.searchTerm.keyword\": options.curation.searchTerm.toLowerCase(),\n },\n }];\n if (options.provider.market) {\n queries.push({\n term: {\n \"curations.markets.keyword\": options.provider.market,\n },\n });\n }\n sorts.push({\n \"curations.position\": {\n unmapped_type: \"long\",\n order: \"asc\",\n nested: {\n path: \"curations\",\n filter: {\n bool: {\n must: queries\n }\n }\n },\n },\n });\n }\n }\n\n // options.curation boost sorting\n if (options.curation) {\n if (0 < options.curation.boosting.groupings.length) {\n const groupings = options.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 < options.curation.boosting.sortings.length) {\n const sortings = options.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(`query could not be parsed for boost sorting`, sorting);\n }\n }\n }\n }\n\n // default collection sorting\n if (options.provider.mode === \"collection\" && options.provider.collectionHandle) {\n sorts.push({\n \"collections.position\": {\n order: \"asc\",\n nested: {\n path: \"collections\",\n filter: {\n term: {\n \"collections.handle.keyword\": options.provider.collectionHandle,\n },\n },\n },\n },\n });\n }\n\n // default search sorting\n if (options.provider.mode === \"search\" || options.provider.mode === \"instant-search\") {\n sorts.push(\"_score\");\n }\n\n return sorts;\n}\n\nexport const generateSortQuery = (options: {\n curation?: ConfigCuration;\n sortOption?: ConfigSort;\n}): Record<string, any> | undefined => {\n if (!options.curation || options.curation.id.includes(\"global\")) {\n return { match_all: {} };\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\" === options.curation.type\n ? \"collectionHandle\"\n : \"searchTerm\"\n }.keyword`]:\n \"collection\" === options.curation.type\n ? options.curation.collectionHandle\n : options.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 ...(options.sortOption &&\n ![\"_score\", \"collections.position\"].includes(options.sortOption.field)\n ? [\n {\n term: {\n type: \"callout\",\n },\n },\n ]\n : []),\n ],\n },\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"sortOption.js","sourceRoot":"","sources":["../../../src/utility/sortOption.ts"],"names":[],"mappings":";;;AAGO,MAAM,cAAc,GAAG,CAAC,OAI9B,EAAE,EAAE;IACH,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI;SACvB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACb,MAAM,IAAI,GACR,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ;YAC5B,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC;YAC1B,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QACjB,MAAM,IAAI,GACR,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ;YAC5B,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC;YAC1B,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QACjB,OAAO,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,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IAAI;oBACpC,CAAC,CAAC,kBAAkB;oBACpB,CAAC,CAAC,YACN,UAAU,CAAC,EACT,YAAY,KAAK,OAAO,CAAC,QAAQ,CAAC,IAAI;oBACpC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB;oBACnC,CAAC,CAAC,MAAA,OAAO,CAAC,QAAQ,CAAC,UAAU,0CAAE,WAAW,EAAE;aACjD;SACF;QACD;YACE,IAAI,EAAE;gBACJ,kBAAkB,EAAE,IAAI;aACzB;SACF,CAAC,CAAC;IAEH,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC5B,OAAO,CAAC,IAAI,CAAC;YACX,IAAI,EAAE;gBACJ,2BAA2B,EAAE,OAAO,CAAC,QAAQ,CAAC,MAAM;aACrD;SACF,CAAC,CAAA;IACJ,CAAC;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,OAAO;6BACd;yBACF;qBACF;iBACF;gBACD,kEAAkE;gBAClE,GAAG,CAAC,OAAO,CAAC,UAAU;oBACtB,CAAC,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC;oBACpE,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;AA9DW,QAAA,iBAAiB,qBA8D5B","sourcesContent":["import { ReactifySearchProviderProps } from \"../components\";\nimport { Config, ConfigCuration, ConfigSort } from \"../types\";\n\nexport const getSortOptions = (options: {\n provider: ReactifySearchProviderProps;\n config: Config;\n sortOption?: string;\n}) => {\n return options.config.sort\n .sort((a, b) => {\n const aInt =\n typeof a.position === \"string\"\n ? parseInt(a.position, 10)\n : a.position;\n const bInt =\n typeof b.position === \"string\"\n ? parseInt(b.position, 10)\n : b.position;\n return aInt - bInt;\n })\n .filter(({ visibility }) => [\"all\", options.provider.mode].includes(visibility));\n\n}\n\nexport const getSortOption = (options: {\n provider: ReactifySearchProviderProps;\n config: Config;\n sortOption?: string;\n query?: Record<string, string>;\n}) => {\n const sortOptions = getSortOptions(options);\n\n return sortOptions.find(({ handle }) => handle === options.sortOption || handle === options.query?.sort) ?? sortOptions[0];\n}\n\nexport const generateSortSort = (options: {\n provider: ReactifySearchProviderProps;\n config: Config;\n curation?: ConfigCuration;\n sortOption?: ConfigSort;\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 (options.provider.mode !== \"instant-search\") {\n if (\n options.sortOption &&\n ![\"_score\", \"collections.position\"].includes(options.sortOption.field)\n ) {\n return [{ [options.sortOption.field]: options.sortOption.direction }];\n }\n }\n\n const sorts = [];\n\n // collection curation pin sorting\n if (options.provider.mode === \"collection\" && options.provider.collectionHandle) {\n if (options.curation?.collectionHandle) {\n const queries: Array<unknown> = [{\n term: {\n \"curations.collectionHandle.keyword\": options.curation.collectionHandle,\n },\n }];\n if (options.provider.market) {\n queries.push({\n term: {\n \"curations.markets.keyword\": options.provider.market,\n },\n });\n }\n sorts.push({\n \"curations.position\": {\n unmapped_type: \"long\",\n order: \"asc\",\n nested: {\n path: \"curations\",\n filter: {\n bool: {\n must: queries\n }\n }\n },\n },\n });\n }\n }\n\n // search options.curation pin sorting\n if (options.provider.mode === \"search\" || options.provider.mode === \"instant-search\") {\n if (options.curation?.searchTerm) {\n const queries: Array<unknown> = [{\n term: {\n \"curations.searchTerm.keyword\": options.curation.searchTerm.toLowerCase(),\n },\n }];\n if (options.provider.market) {\n queries.push({\n term: {\n \"curations.markets.keyword\": options.provider.market,\n },\n });\n }\n sorts.push({\n \"curations.position\": {\n unmapped_type: \"long\",\n order: \"asc\",\n nested: {\n path: \"curations\",\n filter: {\n bool: {\n must: queries\n }\n }\n },\n },\n });\n }\n }\n\n // options.curation boost sorting\n if (options.curation) {\n if (0 < options.curation.boosting.groupings.length) {\n const groupings = options.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 < options.curation.boosting.sortings.length) {\n const sortings = options.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(`query could not be parsed for boost sorting`, sorting);\n }\n }\n }\n }\n\n // default collection sorting\n if (options.provider.mode === \"collection\" && options.provider.collectionHandle) {\n sorts.push({\n \"collections.position\": {\n order: \"asc\",\n nested: {\n path: \"collections\",\n filter: {\n term: {\n \"collections.handle.keyword\": options.provider.collectionHandle,\n },\n },\n },\n },\n });\n }\n\n // default search sorting\n if (options.provider.mode === \"search\" || options.provider.mode === \"instant-search\") {\n sorts.push(\"_score\");\n }\n\n return sorts;\n}\n\nexport const generateSortQuery = (options: {\n provider: ReactifySearchProviderProps;\n curation?: ConfigCuration;\n sortOption?: ConfigSort;\n}): Record<string, any> | undefined => {\n if (!options.curation || options.curation.id.includes(\"global\")) {\n return { match_all: {} };\n }\n\n const queries = [{\n term: {\n [`curations.${\n \"collection\" === options.curation.type\n ? \"collectionHandle\"\n : \"searchTerm\"\n }.keyword`]:\n \"collection\" === options.curation.type\n ? options.curation.collectionHandle\n : options.curation.searchTerm?.toLowerCase(),\n },\n },\n {\n term: {\n \"curations.hidden\": true,\n },\n }];\n\n if (options.provider.market) {\n queries.push({\n term: {\n \"curations.markets.keyword\": options.provider.market,\n },\n })\n }\n\n return {\n bool: {\n must_not: [\n {\n nested: {\n path: \"curations\",\n query: {\n bool: {\n must: queries,\n },\n },\n },\n },\n // hide callout when not sorting by _score or collections.position\n ...(options.sortOption &&\n ![\"_score\", \"collections.position\"].includes(options.sortOption.field)\n ? [\n {\n term: {\n type: \"callout\",\n },\n },\n ]\n : []),\n ],\n },\n };\n};\n"]}
|