@usereactify/search 5.35.0 → 5.36.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 +15 -0
- package/dist/package.json +1 -1
- package/dist/src/components/Filter/Filter.d.ts +2 -0
- package/dist/src/components/Filter/Filter.js +10 -14
- 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 +1 -1
- package/dist/src/components/Filter/Filters.js.map +1 -1
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.js +1 -0
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.js.map +1 -1
- package/dist/src/hooks/useAnalytics.d.ts +1 -0
- package/dist/src/hooks/useAnalytics.js +7 -4
- package/dist/src/hooks/useAnalytics.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
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.36.1](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.36.0...release-v5.36.1) (2023-10-17)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* update showEmptyFilters to also work for slider filters ([d0fc8db](https://bitbucket.org/usereactify/reactify-search-ui/commit/d0fc8db1b3a198b3fe23a205c1ea97b25abb6a61))
|
|
11
|
+
|
|
12
|
+
## [5.36.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.35.0...release-v5.36.0) (2023-10-11)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* add default headers to requests ([a9b6bb9](https://bitbucket.org/usereactify/reactify-search-ui/commit/a9b6bb94ef537e7c42d458653d0d7cf26858bb08))
|
|
18
|
+
* add option to show filters when empty ([1044cbf](https://bitbucket.org/usereactify/reactify-search-ui/commit/1044cbf51a9dd89c72568a7cd8ebc5e7ccd36fa9))
|
|
19
|
+
|
|
5
20
|
## [5.35.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.34.0...release-v5.35.0) (2023-09-26)
|
|
6
21
|
|
|
7
22
|
|
package/dist/package.json
CHANGED
|
@@ -19,5 +19,7 @@ export declare type FilterProps = {
|
|
|
19
19
|
filter: ConfigFilterOption;
|
|
20
20
|
filterSliderProps: ReturnType<typeof useFilterSliderProps>;
|
|
21
21
|
}>;
|
|
22
|
+
/** Show filters even when no options are available */
|
|
23
|
+
showEmptyFilters?: boolean;
|
|
22
24
|
};
|
|
23
25
|
export declare const Filter: React.FC<FilterProps>;
|
|
@@ -102,8 +102,9 @@ const FilterSlider = (props) => {
|
|
|
102
102
|
},
|
|
103
103
|
}), render: (reactivesearchFilterProps) => {
|
|
104
104
|
var _a, _b, _c, _d;
|
|
105
|
-
if (
|
|
106
|
-
((
|
|
105
|
+
if (!props.showEmptyFilters &&
|
|
106
|
+
((_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) ===
|
|
107
|
+
((_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)) {
|
|
107
108
|
return null;
|
|
108
109
|
}
|
|
109
110
|
return (react_1.default.createElement(FilterSliderInner, Object.assign({}, props, { reactivesearchFilterProps: reactivesearchFilterProps })));
|
|
@@ -111,7 +112,7 @@ const FilterSlider = (props) => {
|
|
|
111
112
|
};
|
|
112
113
|
// inner component exists only so we can use memos in reactivesearch render functions
|
|
113
114
|
const FilterSliderInner = (props) => {
|
|
114
|
-
var _a, _b;
|
|
115
|
+
var _a, _b, _c;
|
|
115
116
|
const { filter, renderFilterSlider, reactivesearchFilterProps } = props, otherProps = __rest(props, ["filter", "renderFilterSlider", "reactivesearchFilterProps"]);
|
|
116
117
|
const filterSliderProps = (0, hooks_1.useFilterSliderProps)(filter);
|
|
117
118
|
react_1.default.useEffect(() => {
|
|
@@ -161,24 +162,19 @@ const FilterSliderInner = (props) => {
|
|
|
161
162
|
value: filterSliderProps.value,
|
|
162
163
|
});
|
|
163
164
|
}, [filterSliderProps.value]);
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
return (react_1.default.createElement(Component, Object.assign({ filterSliderProps: filterSliderProps, filter: filter }, otherProps)));
|
|
167
|
-
}
|
|
168
|
-
return (react_1.default.createElement(components_1.ExampleFilterSlider, Object.assign({ filterSliderProps: filterSliderProps, filter: filter }, otherProps)));
|
|
165
|
+
const RenderListComponent = (_c = props.renderFilterSlider) !== null && _c !== void 0 ? _c : components_1.ExampleFilterSlider;
|
|
166
|
+
return (react_1.default.createElement(RenderListComponent, Object.assign({ filterSliderProps: filterSliderProps, filter: filter }, otherProps)));
|
|
169
167
|
};
|
|
170
168
|
// inner component exists only so we can use memos in reactivesearch render functions
|
|
171
169
|
const FilterListInner = (props) => {
|
|
170
|
+
var _a;
|
|
172
171
|
const { filter, renderFilterList, reactivesearchFilterProps } = props, otherProps = __rest(props, ["filter", "renderFilterList", "reactivesearchFilterProps"]);
|
|
173
172
|
const filterListProps = (0, hooks_1.useFilterListProps)(filter, reactivesearchFilterProps);
|
|
174
173
|
// hide entire filter when no options available
|
|
175
|
-
if (0 === filterListProps.options.length) {
|
|
174
|
+
if (!props.showEmptyFilters && 0 === filterListProps.options.length) {
|
|
176
175
|
return null;
|
|
177
176
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
return (react_1.default.createElement(Component, Object.assign({ filterListProps: filterListProps, filter: filter }, otherProps)));
|
|
181
|
-
}
|
|
182
|
-
return (react_1.default.createElement(components_1.ExampleFilterList, Object.assign({ filterListProps: filterListProps, filter: filter }, otherProps)));
|
|
177
|
+
const RenderListComponent = (_a = props.renderFilterList) !== null && _a !== void 0 ? _a : components_1.ExampleFilterList;
|
|
178
|
+
return (react_1.default.createElement(RenderListComponent, Object.assign({ filterListProps: filterListProps, filter: filter }, otherProps)));
|
|
183
179
|
};
|
|
184
180
|
//# sourceMappingURL=Filter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Filter.js","sourceRoot":"","sources":["../../../../src/components/Filter/Filter.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;AACjG,wGAAgF;AAChF,0GAAkF;AAClF,6GAAqF;AACrF,2GAAmF;AAMnF,uCAQqB;AACrB,iDAI0B;AAuBnB,MAAM,MAAM,GAA0B,CAAC,KAAK,EAAE,EAAE;IACrD,IAAI,QAAQ,KAAK,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE;QACzC,IAAI,OAAO,KAAK,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE;YACxC,OAAO,8BAAC,iBAAiB,oBAAK,KAAK,EAAI,CAAC;SACzC;QACD,OAAO,8BAAC,gBAAgB,oBAAK,KAAK,EAAI,CAAC;KACxC;IAED,IAAI,OAAO,KAAK,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE;QACxC,IAAI,OAAO,KAAK,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE;YACxC,OAAO,8BAAC,gBAAgB,oBAAK,KAAK,EAAI,CAAC;SACxC;QACD,OAAO,8BAAC,eAAe,oBAAK,KAAK,EAAI,CAAC;KACvC;IAED,IAAI,QAAQ,KAAK,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE;QACzC,OAAO,8BAAC,YAAY,oBAAK,KAAK,EAAI,CAAC;KACpC;IAED,oEAAoE;IACpE,IAAI,OAAO,KAAK,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE;QACxC,OAAO,8BAAC,iBAAiB,oBAAK,KAAK,EAAI,CAAC;KACzC;IAED,OA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AM,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,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE;QACxC,OAAO,IAAI,CAAC;KACb;IAED,IAAI,gBAAgB,EAAE;QACpB,MAAM,SAAS,GAAG,gBAAgB,CAAC;QACnC,OAAO,CACL,8BAAC,SAAS,kBACR,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM,IACV,UAAU,EACd,CACH,CAAC;KACH;IAED,OAAO,CACL,8BAAC,8BAAiB,kBAChB,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM,IACV,UAAU,EACd,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent\";\nimport MultiList from \"@appbaseio/reactivesearch/lib/components/list/MultiList\";\nimport SingleList from \"@appbaseio/reactivesearch/lib/components/list/SingleList\";\nimport SingleRange from \"@appbaseio/reactivesearch/lib/components/range/SingleRange\";\nimport MultiRange from \"@appbaseio/reactivesearch/lib/components/range/MultiRange\";\n\nimport type {\n ConfigFilterOption,\n ReactivesearchFilterListProps,\n} from \"../../types\";\nimport {\n useFilterListProps,\n useFilterRangeProps,\n useFilterSliderProps,\n useReactiveFilterListProps,\n useReactiveFilterRangeProps,\n useReactiveFilterSharedProps,\n useReactiveFilterSliderProps,\n} from \"../../hooks\";\nimport {\n ExampleFilterList,\n ExampleFilterRange,\n ExampleFilterSlider,\n} from \"../../components\";\n\nexport type FilterProps = {\n /** The filter option being rendered */\n filter: ConfigFilterOption;\n /** Render method for List filters */\n renderFilterList?: React.FC<{\n filter: ConfigFilterOption;\n filterListProps: ReturnType<typeof useFilterListProps>;\n }>;\n /** Render method for Range filters */\n renderFilterRange?: React.FC<{\n filter: ConfigFilterOption;\n filterRangeProps: ReturnType<typeof useFilterRangeProps>;\n }>;\n /** Render method for Slider filters */\n renderFilterSlider?: React.FC<{\n filter: ConfigFilterOption;\n filterSliderProps: ReturnType<typeof useFilterSliderProps>;\n // reactSliderProps: ReturnType<typeof useReactSliderProps>;\n }>;\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 reactiveFilterListProps = useReactiveFilterListProps(props.filter);\n\n return (\n <SingleList\n {...reactiveFilterListProps}\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 reactiveFilterListProps = useReactiveFilterListProps(props.filter);\n\n return (\n <MultiList\n {...reactiveFilterListProps}\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 reactiveFilterRangeProps = useReactiveFilterRangeProps(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 {...reactiveFilterRangeProps}\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 reactiveFilterRangeProps = useReactiveFilterRangeProps(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 {...reactiveFilterRangeProps}\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 reactiveFilterSharedProps = useReactiveFilterSharedProps(props.filter);\n\n return (\n <ReactiveComponent\n {...reactiveFilterSharedProps}\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 render={(reactivesearchFilterProps) => {\n if (\n reactivesearchFilterProps?.aggregations?.min?.value ===\n reactivesearchFilterProps?.aggregations?.max?.value\n ) {\n return null;\n }\n\n return (\n <FilterSliderInner\n {...props}\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 }\n> = (props) => {\n const {\n filter,\n renderFilterSlider,\n reactivesearchFilterProps,\n ...otherProps\n } = props;\n\n const filterSliderProps = useFilterSliderProps(filter);\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.value[0] === 0 && filterSliderProps.value[1] === 0) {\n return;\n }\n\n props.reactivesearchFilterProps.setQuery({\n query: {\n query: {\n bool: {\n must: [\n {\n bool: {\n must: [\n {\n match: {\n published: true,\n },\n },\n {\n range: {\n [props.filter.field]: {\n gte: filterSliderProps.value[0],\n lte: filterSliderProps.value[1],\n boost: 2,\n },\n },\n },\n ],\n },\n },\n ],\n },\n },\n },\n value: filterSliderProps.value,\n });\n }, [filterSliderProps.value]);\n\n if (renderFilterSlider) {\n const Component = renderFilterSlider;\n return (\n <Component\n filterSliderProps={filterSliderProps}\n filter={filter}\n {...otherProps}\n />\n );\n }\n\n return (\n <ExampleFilterSlider\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 (0 === filterListProps.options.length) {\n return null;\n }\n\n if (renderFilterList) {\n const Component = renderFilterList;\n return (\n <Component\n filterListProps={filterListProps}\n filter={filter}\n {...otherProps}\n />\n );\n }\n\n return (\n <ExampleFilterList\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,yHAAiG;AACjG,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,EAChC,MAAM,EAAE,MAAM,IACV,UAAU,EACd,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent\";\nimport MultiList from \"@appbaseio/reactivesearch/lib/components/list/MultiList\";\nimport SingleList from \"@appbaseio/reactivesearch/lib/components/list/SingleList\";\nimport SingleRange from \"@appbaseio/reactivesearch/lib/components/range/SingleRange\";\nimport MultiRange from \"@appbaseio/reactivesearch/lib/components/range/MultiRange\";\n\nimport type {\n ConfigFilterOption,\n ReactivesearchFilterListProps,\n} from \"../../types\";\nimport {\n useFilterListProps,\n useFilterRangeProps,\n useFilterSliderProps,\n useReactiveFilterListProps,\n useReactiveFilterRangeProps,\n useReactiveFilterSharedProps,\n} from \"../../hooks\";\nimport {\n ExampleFilterList,\n ExampleFilterRange,\n ExampleFilterSlider,\n} from \"../../components\";\n\nexport type FilterProps = {\n /** The filter option being rendered */\n filter: ConfigFilterOption;\n /** Render method for List filters */\n renderFilterList?: React.FC<{\n filter: ConfigFilterOption;\n filterListProps: ReturnType<typeof useFilterListProps>;\n }>;\n /** Render method for Range filters */\n renderFilterRange?: React.FC<{\n filter: ConfigFilterOption;\n filterRangeProps: ReturnType<typeof useFilterRangeProps>;\n }>;\n /** Render method for Slider filters */\n renderFilterSlider?: React.FC<{\n filter: ConfigFilterOption;\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 reactiveFilterListProps = useReactiveFilterListProps(props.filter);\n\n return (\n <SingleList\n {...reactiveFilterListProps}\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 reactiveFilterListProps = useReactiveFilterListProps(props.filter);\n\n return (\n <MultiList\n {...reactiveFilterListProps}\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 reactiveFilterRangeProps = useReactiveFilterRangeProps(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 {...reactiveFilterRangeProps}\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 reactiveFilterRangeProps = useReactiveFilterRangeProps(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 {...reactiveFilterRangeProps}\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 reactiveFilterSharedProps = useReactiveFilterSharedProps(props.filter);\n\n return (\n <ReactiveComponent\n {...reactiveFilterSharedProps}\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 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 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 }\n> = (props) => {\n const {\n filter,\n renderFilterSlider,\n reactivesearchFilterProps,\n ...otherProps\n } = props;\n\n const filterSliderProps = useFilterSliderProps(filter);\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.value[0] === 0 && filterSliderProps.value[1] === 0) {\n return;\n }\n\n props.reactivesearchFilterProps.setQuery({\n query: {\n query: {\n bool: {\n must: [\n {\n bool: {\n must: [\n {\n match: {\n published: true,\n },\n },\n {\n range: {\n [props.filter.field]: {\n gte: filterSliderProps.value[0],\n lte: filterSliderProps.value[1],\n boost: 2,\n },\n },\n },\n ],\n },\n },\n ],\n },\n },\n },\n value: filterSliderProps.value,\n });\n }, [filterSliderProps.value]);\n\n const RenderListComponent = props.renderFilterSlider ?? ExampleFilterSlider;\n\n return (\n <RenderListComponent\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"]}
|
|
@@ -17,5 +17,7 @@ export declare type FiltersProps = {
|
|
|
17
17
|
filter: ConfigFilterOption;
|
|
18
18
|
filterSliderProps: ReturnType<typeof useFilterSliderProps>;
|
|
19
19
|
}>;
|
|
20
|
+
/** Show filters even when no options are available */
|
|
21
|
+
showEmptyFilters?: boolean;
|
|
20
22
|
};
|
|
21
23
|
export declare const Filters: React.FC<FiltersProps>;
|
|
@@ -10,7 +10,7 @@ const components_1 = require("../../components");
|
|
|
10
10
|
const Filters = (props) => {
|
|
11
11
|
var _a;
|
|
12
12
|
const filterStackHook = (0, hooks_1.useFilters)();
|
|
13
|
-
return (react_1.default.createElement(react_1.default.Fragment, null, (_a = filterStackHook.filters) === null || _a === void 0 ? void 0 : _a.map((filter) => (react_1.default.createElement(components_1.Filter, { key: filter.id, filter: filter, renderFilterList: props.renderFilterList, renderFilterSlider: props.renderFilterSlider, renderFilterRange: props.renderFilterRange })))));
|
|
13
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, (_a = filterStackHook.filters) === null || _a === void 0 ? void 0 : _a.map((filter) => (react_1.default.createElement(components_1.Filter, { key: filter.id, filter: filter, renderFilterList: props.renderFilterList, renderFilterSlider: props.renderFilterSlider, renderFilterRange: props.renderFilterRange, showEmptyFilters: props.showEmptyFilters })))));
|
|
14
14
|
};
|
|
15
15
|
exports.Filters = Filters;
|
|
16
16
|
//# sourceMappingURL=Filters.js.map
|
|
@@ -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;AAuBnC,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 { ConfigFilterOption } from \"../../types\";\n\nexport type FiltersProps = {\n /** Render method for List filters */\n renderFilterList?: React.FC<{\n filter: ConfigFilterOption;\n filterListProps: ReturnType<typeof useFilterListProps>;\n }>;\n /** Render method for Range filters */\n renderFilterRange?: React.FC<{\n filter: ConfigFilterOption;\n filterRangeProps: ReturnType<typeof useFilterRangeProps>;\n }>;\n /** Render method for Slider filters */\n renderFilterSlider?: React.FC<{\n filter: ConfigFilterOption;\n filterSliderProps: ReturnType<typeof useFilterSliderProps>;\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"]}
|
|
@@ -58,6 +58,7 @@ const useReactiveBaseProps = () => {
|
|
|
58
58
|
"x-reactify-mode": options.mode,
|
|
59
59
|
"x-reactify-client-id": options.clientId,
|
|
60
60
|
"x-reactify-client-version": package_json_1.default.version,
|
|
61
|
+
"x-reactify-ga": (0, hooks_1.getCookie)("_rs_ga"),
|
|
61
62
|
},
|
|
62
63
|
}), [options.index, options.endpoint, options.credentials, options.theme]);
|
|
63
64
|
return reactiveBaseProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReactiveBaseProps.js","sourceRoot":"","sources":["../../../../src/hooks/reactivesearch/useReactiveBaseProps.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAG1B,
|
|
1
|
+
{"version":3,"file":"useReactiveBaseProps.js","sourceRoot":"","sources":["../../../../src/hooks/reactivesearch/useReactiveBaseProps.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAG1B,uCAAkE;AAElE,yEAAwC;AAExC,MAAM,yBAAyB,GAAG,CAAC,QAAa,EAAE,EAAE;IAClD,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;SACrB,MAAM,CAAC,CAAC,CAAC,GAAG,C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AO,EAAE;YACP,iBAAiB,EAAE,OAAO,CAAC,sBAAsB;YACjD,iBAAiB,EAAE,OAAO,CAAC,IAAI;YAC/B,sBAAsB,EAAE,OAAO,CAAC,QAAQ;YACxC,2BAA2B,EAAE,sBAAG,CAAC,OAAO;YACxC,eAAe,EAAE,IAAA,iBAAS,EAAC,QAAQ,CAAC;SACrC;KACF,CAAC,EACF,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,CACtE,CAAC;IAEF,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AA1CW,QAAA,oBAAoB,wBA0C/B","sourcesContent":["import React from \"react\";\nimport { ReactiveBaseProps } from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveBase\";\n\nimport { getCookie, useReactifySearchContext } from \"../../hooks\";\n\nimport pkg from \"../../../package.json\";\n\nconst replaceDocCountWithParent = (response: any) => {\n Object.entries(response)\n .filter(([key]) => key !== \"doc_count\")\n .forEach(([key, value]: [string, any]) => {\n value.buckets?.forEach((bucket: any) => {\n if (bucket.parent_docs) {\n bucket.doc_count = bucket.parent_docs.doc_count;\n delete bucket.parent_docs;\n }\n });\n });\n\n return response;\n};\n\nexport const useReactiveBaseProps = (): ReactiveBaseProps => {\n const { options } = useReactifySearchContext();\n\n const reactiveBaseProps = React.useMemo<ReactiveBaseProps>(\n () => ({\n app: options.index,\n url: options.endpoint,\n credentials: options.credentials,\n theme: options.theme,\n transformResponse: async (response: any) => {\n // support filtering inside nested aggregations by moving the inner aggregation\n // up one level such that reactivesearch understands it\n //\n // see useReactiveFilterListProps > defaultQuery to see how a filter is being applied\n // to variant aggregations to ensure that only in stock sizes are displayed as filter\n // options, this involves a nested filter, which requires this fix\n //\n // https://github.com/appbaseio/reactivesearch/issues/1530\n if (\n response?.aggregations?.reactivesearch_nested?.reactify_nested_outer\n ) {\n response.aggregations.reactivesearch_nested =\n replaceDocCountWithParent(\n response?.aggregations?.reactivesearch_nested\n ?.reactify_nested_outer\n );\n }\n\n return response;\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 [options.index, options.endpoint, options.credentials, options.theme]\n );\n\n return reactiveBaseProps;\n};\n"]}
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.useAnalytics = void 0;
|
|
15
|
+
exports.useAnalytics = exports.getCookie = void 0;
|
|
16
16
|
const axios_1 = __importDefault(require("axios"));
|
|
17
17
|
const package_json_1 = __importDefault(require("../../package.json"));
|
|
18
18
|
const hooks_1 = require("../hooks");
|
|
@@ -30,6 +30,7 @@ function getCookie(name) {
|
|
|
30
30
|
}
|
|
31
31
|
return "";
|
|
32
32
|
}
|
|
33
|
+
exports.getCookie = getCookie;
|
|
33
34
|
const useAnalytics = () => {
|
|
34
35
|
const { options } = (0, hooks_1.useReactifySearchContext)();
|
|
35
36
|
const url = "https://analytics.search.reactify.app/record/";
|
|
@@ -42,9 +43,11 @@ const useAnalytics = () => {
|
|
|
42
43
|
const events = getTrackEvents(event);
|
|
43
44
|
return axios_1.default.post(url, { events }, {
|
|
44
45
|
headers: {
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
46
|
+
"x-reactify-shop": options.shopifyPermanentDomain,
|
|
47
|
+
"x-reactify-mode": options.mode,
|
|
48
|
+
"x-reactify-client-id": options.clientId,
|
|
49
|
+
"x-reactify-client-version": package_json_1.default.version,
|
|
50
|
+
"x-reactify-ga": getCookie("_rs_ga"),
|
|
48
51
|
},
|
|
49
52
|
});
|
|
50
53
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAnalytics.js","sourceRoot":"","sources":["../../../src/hooks/useAnalytics.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAE1B,sEAAqC;AAErC,oCAAoD;AACpD,wCAAmC;AAEnC,
|
|
1
|
+
{"version":3,"file":"useAnalytics.js","sourceRoot":"","sources":["../../../src/hooks/useAnalytics.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAE1B,sEAAqC;AAErC,oCAAoD;AACpD,wCAAmC;AAEnC,SAAgB,SAAS,CAAC,IAAY;;IACpC,IAAI;QACF,MAAM,MAAM,GAAG,KAAK,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC;QAC1D,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACvB,OAAO,MAAA,MAAA,MAAM,CAAC,GAAG,EAAE,0CAAE,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,mCAAI,EAAE,CAAC;SAC/C;KACF;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACtB;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAXD,8BAWC;AAEM,MAAM,YAAY,GAAG,GAAG,EAAE;IAC/B,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAC/C,MAAM,GAAG,GAAG,+CAA+C,CAAC;IAC5D,MAAM,KAAK,GAAG,CAAO,KAAiB,EAAE,EAAE;QACxC,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE;YACnC,OAAO,CAAC,IAAI,CACV,IAAI,KAAK,CACP,4EAA4E,CAC7E,CACF,CAAC;YAEF,OAAO;SACR;QAED,eAAK,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAE1C,MAAM,MAAM,GAAG,cAAc,C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B,MAAM,GAAG;gBACP;oBACE,SAAS;oBACT,OAAO,EAAE,KAAK,CAAC,OAAO;iBACvB;aACF,CAAC;YAEF,MAAM;QAER,KAAK,gBAAgB;YACnB,MAAM,GAAG;gBACP;oBACE,SAAS;oBACT,OAAO,EAAE,KAAK,CAAC,OAAO;iBACvB;aACF,CAAC;YAEF,MAAM;QAER,KAAK,kBAAkB;YACrB,MAAM,GAAG;gBACP;oBACE,SAAS;oBACT,OAAO,EAAE,KAAK,CAAC,OAAO;iBACvB;aACF,CAAC;YAEF,MAAM;QAER,KAAK,YAAY;YACf,MAAM,GAAG;gBACP;oBACE,SAAS;oBACT,OAAO,EAAE,KAAK,CAAC,OAAO;iBACvB;aACF,CAAC;YAEF,MAAM;QAER,KAAK,cAAc;YACjB,MAAM,GAAG;gBACP;oBACE,SAAS;oBACT,OAAO,EAAE,KAAK,CAAC,OAAO;iBACvB;aACF,CAAC;YAEF,MAAM;KACT;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\";\n\nexport function getCookie(name: string): string {\n try {\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 } = useReactifySearchContext();\n const url = \"https://analytics.search.reactify.app/record/\";\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 debug.log(\"useAnalytics\", \"track\", event);\n\n const events = getTrackEvents(event);\n return axios.post(\n url,\n { events },\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: ElasticProduct;\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: ElasticProduct;\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 ElasticProduct {\n id: number;\n title: string;\n }\n}\n"]}
|