@usereactify/search 5.47.1 → 5.48.0
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 +22 -0
- package/dist/package.json +1 -1
- package/dist/src/components/Filter/Filter.js +45 -10
- package/dist/src/components/Filter/Filter.js.map +1 -1
- package/dist/src/components/Result/Results.d.ts +0 -2
- package/dist/src/components/Result/Results.js +9 -21
- package/dist/src/components/Result/Results.js.map +1 -1
- package/dist/src/components/Sensor/SensorCollection.js +8 -80
- package/dist/src/components/Sensor/SensorCollection.js.map +1 -1
- package/dist/src/components/Sensor/SensorCustom.js +6 -2
- package/dist/src/components/Sensor/SensorCustom.js.map +1 -1
- package/dist/src/components/Sensor/SensorInventoryAvailable.js +8 -44
- package/dist/src/components/Sensor/SensorInventoryAvailable.js.map +1 -1
- package/dist/src/components/Sensor/SensorPublished.js +7 -27
- package/dist/src/components/Sensor/SensorPublished.js.map +1 -1
- package/dist/src/components/Sensor/SensorSearchTerm.js +11 -20
- package/dist/src/components/Sensor/SensorSearchTerm.js.map +1 -1
- package/dist/src/components/Sensor/SensorSort.js +10 -203
- package/dist/src/components/Sensor/SensorSort.js.map +1 -1
- package/dist/src/hooks/reactivesearch/index.d.ts +0 -6
- package/dist/src/hooks/reactivesearch/index.js +0 -6
- package/dist/src/hooks/reactivesearch/index.js.map +1 -1
- package/dist/src/hooks/usePagination.js +1 -1
- package/dist/src/hooks/usePagination.js.map +1 -1
- package/dist/src/hooks/useSortBy.js +14 -17
- package/dist/src/hooks/useSortBy.js.map +1 -1
- package/dist/src/utility/curation.d.ts +7 -0
- package/dist/src/utility/curation.js +85 -0
- package/dist/src/utility/curation.js.map +1 -0
- package/dist/src/utility/filters.d.ts +6 -0
- package/dist/src/utility/filters.js +36 -0
- package/dist/src/utility/filters.js.map +1 -0
- package/dist/src/utility/props.d.ts +143 -10
- package/dist/src/utility/props.js +241 -25
- package/dist/src/utility/props.js.map +1 -1
- package/dist/src/utility/server.js +1 -1
- package/dist/src/utility/server.js.map +1 -1
- package/dist/src/utility/sortOption.d.ts +22 -0
- package/dist/src/utility/sortOption.js +198 -0
- package/dist/src/utility/sortOption.js.map +1 -0
- package/package.json +1 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.d.ts +0 -84
- package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.js +0 -21
- package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.js.map +0 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.d.ts +0 -86
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js +0 -32
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js.map +0 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.d.ts +0 -77
- package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.js +0 -124
- package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.js.map +0 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.d.ts +0 -83
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js +0 -28
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js.map +0 -1
- package/dist/src/hooks/reactivesearch/useReactiveReactProp.d.ts +0 -4
- package/dist/src/hooks/reactivesearch/useReactiveReactProp.js +0 -32
- package/dist/src/hooks/reactivesearch/useReactiveReactProp.js.map +0 -1
- package/dist/src/hooks/reactivesearch/useReactiveReactiveListProps.d.ts +0 -6
- package/dist/src/hooks/reactivesearch/useReactiveReactiveListProps.js +0 -38
- package/dist/src/hooks/reactivesearch/useReactiveReactiveListProps.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,28 @@
|
|
|
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.48.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.47.1...release-v5.48.0) (2024-02-14)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* improve sharing of props between server and client, remove dead code ([01d3631](https://bitbucket.org/usereactify/reactify-search-ui/commit/01d3631589efa0203db31f6b7435152f7f147f99))
|
|
11
|
+
* normalise search value and correctly query for search curations ([75be00c](https://bitbucket.org/usereactify/reactify-search-ui/commit/75be00cfee45435be6a802a637e631e8902ae3ef))
|
|
12
|
+
|
|
13
|
+
## [5.48.0-beta.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/beta-v5.46.0-beta.1...beta-v5.48.0-beta.0) (2024-01-25)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* filter products by published market when market active ([333b931](https://bitbucket.org/usereactify/reactify-search-ui/commit/333b931ee3affbbe988b44237b8f1b1e7b858e14))
|
|
19
|
+
* improve sharing of props between server and client, remove dead code ([01d3631](https://bitbucket.org/usereactify/reactify-search-ui/commit/01d3631589efa0203db31f6b7435152f7f147f99))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* bump @appbaseio/reactivesearch ([f7328a9](https://bitbucket.org/usereactify/reactify-search-ui/commit/f7328a9570886bda40a57f72b55de522939e2e1b))
|
|
25
|
+
* use Market ID (number part) instead of Market Handle ([5611219](https://bitbucket.org/usereactify/reactify-search-ui/commit/5611219623b15d4ec6e6a3921e7f64dd1312e1a1))
|
|
26
|
+
|
|
5
27
|
### [5.47.1](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.47.0...release-v5.47.1) (2024-01-17)
|
|
6
28
|
|
|
7
29
|
|
package/dist/package.json
CHANGED
|
@@ -23,6 +23,7 @@ const SingleRange_1 = __importDefault(require("@appbaseio/reactivesearch/lib/com
|
|
|
23
23
|
const MultiRange_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/range/MultiRange"));
|
|
24
24
|
const hooks_1 = require("../../hooks");
|
|
25
25
|
const components_1 = require("../../components");
|
|
26
|
+
const props_1 = require("../../utility/props");
|
|
26
27
|
const Filter = (props) => {
|
|
27
28
|
if ("single" === props.filter.displayType) {
|
|
28
29
|
if ("range" === props.filter.displayView) {
|
|
@@ -48,35 +49,63 @@ const Filter = (props) => {
|
|
|
48
49
|
};
|
|
49
50
|
exports.Filter = Filter;
|
|
50
51
|
const FilterSingleList = (props) => {
|
|
51
|
-
const
|
|
52
|
-
|
|
52
|
+
const reactifySearchContext = (0, hooks_1.useReactifySearchContext)();
|
|
53
|
+
const filtersHook = (0, hooks_1.useFilters)();
|
|
54
|
+
const sharedProps = (0, props_1.getPropsShared)({
|
|
55
|
+
provider: reactifySearchContext.options,
|
|
56
|
+
config: reactifySearchContext.config,
|
|
57
|
+
filterGroup: filtersHook.filterStack,
|
|
58
|
+
}, props.filter);
|
|
59
|
+
const reactiveProps = (0, props_1.getPropsFilterList)(props.filter);
|
|
60
|
+
return (react_1.default.createElement(SingleList_1.default, Object.assign({}, sharedProps, reactiveProps, { render: (reactivesearchFilterProps) => (react_1.default.createElement(FilterListInner, Object.assign({}, props, { reactivesearchFilterProps: reactivesearchFilterProps }))) })));
|
|
53
61
|
};
|
|
54
62
|
const FilterMultiList = (props) => {
|
|
55
|
-
const
|
|
56
|
-
|
|
63
|
+
const reactifySearchContext = (0, hooks_1.useReactifySearchContext)();
|
|
64
|
+
const filtersHook = (0, hooks_1.useFilters)();
|
|
65
|
+
const sharedProps = (0, props_1.getPropsShared)({
|
|
66
|
+
provider: reactifySearchContext.options,
|
|
67
|
+
config: reactifySearchContext.config,
|
|
68
|
+
filterGroup: filtersHook.filterStack,
|
|
69
|
+
}, props.filter);
|
|
70
|
+
const reactiveProps = (0, props_1.getPropsFilterList)(props.filter);
|
|
71
|
+
return (react_1.default.createElement(MultiList_1.default, Object.assign({}, sharedProps, reactiveProps, { render: (reactivesearchFilterProps) => (react_1.default.createElement(FilterListInner, Object.assign({}, props, { reactivesearchFilterProps: reactivesearchFilterProps }))) })));
|
|
57
72
|
};
|
|
58
73
|
const FilterRangeSingle = (props) => {
|
|
59
74
|
var _a;
|
|
60
|
-
const
|
|
75
|
+
const reactifySearchContext = (0, hooks_1.useReactifySearchContext)();
|
|
76
|
+
const filtersHook = (0, hooks_1.useFilters)();
|
|
77
|
+
const sharedProps = (0, props_1.getPropsShared)({
|
|
78
|
+
provider: reactifySearchContext.options,
|
|
79
|
+
config: reactifySearchContext.config,
|
|
80
|
+
filterGroup: filtersHook.filterStack,
|
|
81
|
+
}, props.filter);
|
|
82
|
+
const reactiveProps = (0, props_1.getPropsFilterRange)(props.filter);
|
|
61
83
|
const filterRangeProps = (0, hooks_1.useFilterRangeProps)(props.filter);
|
|
62
84
|
const RenderRangeComponent = (_a = props.renderFilterRange) !== null && _a !== void 0 ? _a : components_1.ExampleFilterRange;
|
|
63
85
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
64
86
|
react_1.default.createElement("div", { style: {
|
|
65
87
|
display: "none",
|
|
66
88
|
} },
|
|
67
|
-
react_1.default.createElement(SingleRange_1.default, Object.assign({},
|
|
89
|
+
react_1.default.createElement(SingleRange_1.default, Object.assign({}, sharedProps, reactiveProps, { value: filterRangeProps.values[0], onChange: filterRangeProps.handleChange }))),
|
|
68
90
|
react_1.default.createElement(RenderRangeComponent, { filterRangeProps: filterRangeProps, filter: props.filter })));
|
|
69
91
|
};
|
|
70
92
|
const FilterRangeMulti = (props) => {
|
|
71
93
|
var _a;
|
|
72
|
-
const
|
|
94
|
+
const reactifySearchContext = (0, hooks_1.useReactifySearchContext)();
|
|
95
|
+
const filtersHook = (0, hooks_1.useFilters)();
|
|
96
|
+
const sharedProps = (0, props_1.getPropsShared)({
|
|
97
|
+
provider: reactifySearchContext.options,
|
|
98
|
+
config: reactifySearchContext.config,
|
|
99
|
+
filterGroup: filtersHook.filterStack,
|
|
100
|
+
}, props.filter);
|
|
101
|
+
const reactiveProps = (0, props_1.getPropsFilterRange)(props.filter);
|
|
73
102
|
const filterRangeProps = (0, hooks_1.useFilterRangeProps)(props.filter);
|
|
74
103
|
const RenderRangeComponent = (_a = props.renderFilterRange) !== null && _a !== void 0 ? _a : components_1.ExampleFilterRange;
|
|
75
104
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
76
105
|
react_1.default.createElement("div", { style: {
|
|
77
106
|
display: "none",
|
|
78
107
|
} },
|
|
79
|
-
react_1.default.createElement(MultiRange_1.default, Object.assign({},
|
|
108
|
+
react_1.default.createElement(MultiRange_1.default, Object.assign({}, sharedProps, reactiveProps, { value: filterRangeProps.values,
|
|
80
109
|
// @note: onChange handler must be defined for controlled component to work correctly
|
|
81
110
|
onChange: () => { }, onValueChange: (values) => {
|
|
82
111
|
if (values.length === 0) {
|
|
@@ -86,8 +115,14 @@ const FilterRangeMulti = (props) => {
|
|
|
86
115
|
react_1.default.createElement(RenderRangeComponent, { filterRangeProps: filterRangeProps, filter: props.filter })));
|
|
87
116
|
};
|
|
88
117
|
const FilterSlider = (props) => {
|
|
89
|
-
const
|
|
90
|
-
|
|
118
|
+
const reactifySearchContext = (0, hooks_1.useReactifySearchContext)();
|
|
119
|
+
const filtersHook = (0, hooks_1.useFilters)();
|
|
120
|
+
const sharedProps = (0, props_1.getPropsShared)({
|
|
121
|
+
provider: reactifySearchContext.options,
|
|
122
|
+
config: reactifySearchContext.config,
|
|
123
|
+
filterGroup: filtersHook.filterStack,
|
|
124
|
+
}, props.filter);
|
|
125
|
+
return (react_1.default.createElement(ReactiveComponent_1.default, Object.assign({}, sharedProps, { defaultQuery: () => ({
|
|
91
126
|
aggs: {
|
|
92
127
|
min: {
|
|
93
128
|
min: {
|
|
@@ -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;AACr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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"]}
|
|
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,uCAMqB;AACrB,iDAI0B;AAC1B,+CAA8F;AAyBvF,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,EAA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aACF;YACD,KAAK,EAAE,iBAAiB,CAAC,KAAK;SAC/B,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;IAE9B,MAAM,mBAAmB,GAAG,MAAA,KAAK,CAAC,kBAAkB,mCAAI,gCAAmB,CAAC;IAE5E,OAAO,CACL,8BAAC,mBAAmB,kBAClB,iBAAiB,EAAE,iBAAiB,EACpC,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;QACnE,OAAO,IAAI,CAAC;KACb;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 \"@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 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: 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 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 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 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"]}
|
|
@@ -44,9 +44,7 @@ export declare type ResultsProps = {
|
|
|
44
44
|
/** Render method called for pagination type "infinite_scroll" */
|
|
45
45
|
renderPaginationInfiniteScroll?: React.FC<ReturnType<typeof usePaginationLoadable>>;
|
|
46
46
|
/** Define which fields should be included in results data */
|
|
47
|
-
includeFields?: Array<string>;
|
|
48
47
|
/** Define which fields should be excluded from results data */
|
|
49
|
-
excludeFields?: Array<string>;
|
|
50
48
|
/** Advanced Usage: Override the default amount of results per page */
|
|
51
49
|
pageSize?: number;
|
|
52
50
|
/** Advanced Usage: Override the default scrollTarget used to determine when infinite load should be triggered (infinite scroll) */
|
|
@@ -14,32 +14,20 @@ const ResultPaginationNextPrev_1 = require("./ResultPaginationNextPrev");
|
|
|
14
14
|
const ResultPaginationInfiniteScroll_1 = require("./ResultPaginationInfiniteScroll");
|
|
15
15
|
const types_1 = require("../../types");
|
|
16
16
|
const hooks_1 = require("../../hooks");
|
|
17
|
+
const props_1 = require("../../utility/props");
|
|
17
18
|
const Results = (props) => {
|
|
18
|
-
const
|
|
19
|
-
|
|
19
|
+
const reactifySearchContext = (0, hooks_1.useReactifySearchContext)();
|
|
20
|
+
const filtersHook = (0, hooks_1.useFilters)();
|
|
21
|
+
const reactiveProps = (0, props_1.getPropsResults)({
|
|
22
|
+
provider: reactifySearchContext.options,
|
|
23
|
+
config: reactifySearchContext.config,
|
|
24
|
+
filterGroup: filtersHook.filterStack,
|
|
20
25
|
scrollTarget: props.infiniteScrollContainer,
|
|
26
|
+
pageSize: props.pageSize
|
|
21
27
|
});
|
|
22
28
|
const { track } = (0, hooks_1.useAnalytics)();
|
|
23
29
|
const { searchTerm } = (0, hooks_1.useSearch)();
|
|
24
|
-
|
|
25
|
-
var _a;
|
|
26
|
-
return [
|
|
27
|
-
...((_a = props.includeFields) !== null && _a !== void 0 ? _a : []),
|
|
28
|
-
"id",
|
|
29
|
-
"title",
|
|
30
|
-
"type",
|
|
31
|
-
"handle",
|
|
32
|
-
"image",
|
|
33
|
-
"variants.id",
|
|
34
|
-
"variants.presentment_prices",
|
|
35
|
-
"callout",
|
|
36
|
-
];
|
|
37
|
-
}, [props.includeFields]);
|
|
38
|
-
const fieldsExclude = react_1.default.useMemo(() => {
|
|
39
|
-
var _a;
|
|
40
|
-
return [...((_a = props.excludeFields) !== null && _a !== void 0 ? _a : [])];
|
|
41
|
-
}, [props.excludeFields]);
|
|
42
|
-
return (react_1.default.createElement(ReactiveList_1.default, Object.assign({}, reactiveReactiveListProps, { includeFields: fieldsInclude, excludeFields: fieldsExclude, render: (reactivesearchResultProps) => (react_1.default.createElement(ResultsInner, Object.assign({}, props, { reactivesearchResultProps: reactivesearchResultProps }))), onData: (renderProps) => {
|
|
30
|
+
return (react_1.default.createElement(ReactiveList_1.default, Object.assign({}, reactiveProps, { render: (reactivesearchResultProps) => (react_1.default.createElement(ResultsInner, Object.assign({}, props, { reactivesearchResultProps: reactivesearchResultProps }))), onData: (renderProps) => {
|
|
43
31
|
if (renderProps.resultStats.numberOfResults === 0) {
|
|
44
32
|
let trimmedSearchTerm = searchTerm.trim();
|
|
45
33
|
if (!trimmedSearchTerm ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Results.js","sourceRoot":"","sources":["../../../../src/components/Result/Results.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,gHAAwF;AAExF,2DAAwD;AACxD,2DAAwD;AACxD,yEAAsE;AACtE,yEAAsE;AACtE,yEAAsE;AACtE,qFAAkF;AAElF,uCAOqB;AACrB,uCAUqB;AA4Dd,MAAM,OAAO,GAA2B,CAAC,KAAK,EAAE,EAAE;IACvD,MAAM,yBAAyB,GAAG,IAAA,oCAA4B,EAAC;QAC7D,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,YAAY,EAAE,KAAK,CAAC,uBAAuB;KAC5C,CAAC,CAAC;IACH,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,oBAAY,GAAE,CAAC;IACjC,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,iBAAS,GAAE,CAAC;IAEnC,MAAM,aAAa,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;;QACvC,OAAO;YACL,GAAG,CAAC,MAAA,KAAK,CAAC,aAAa,mCAAI,EAAE,CAAC;YAC9B,IAAI;YACJ,OAAO;YACP,MAAM;YACN,QAAQ;YACR,OAAO;YACP,aAAa;YACb,6BAA6B;YAC7B,SAAS;SACV,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;IAC1B,MAAM,aAAa,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;;QACvC,OAAO,CAAC,GAAG,CAAC,MAAA,KAAK,CAAC,aAAa,mCAAI,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AED,IAAI,iBAAiB,MAAK,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,CAAA,EAAE;QACrD,OAAO,CACL,8BAAC,+DAA8B,oBACzB,KAAK,CAAC,yBAAyB,IACnC,MAAM,EAAE,KAAK,CAAC,8BAA8B,IAC5C,CACH,CAAC;KACH;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveList from \"@appbaseio/reactivesearch/lib/components/result/ReactiveList\";\n\nimport { ResultCardCallout } from \"./ResultCardCallout\";\nimport { ResultCardProduct } from \"./ResultCardProduct\";\nimport { ResultPaginationNumbered } from \"./ResultPaginationNumbered\";\nimport { ResultPaginationLoadMore } from \"./ResultPaginationLoadMore\";\nimport { ResultPaginationNextPrev } from \"./ResultPaginationNextPrev\";\nimport { ResultPaginationInfiniteScroll } from \"./ResultPaginationInfiniteScroll\";\n\nimport {\n ElasticCallout,\n ElasticProduct,\n ElasticDocumentType,\n ReactivesearchError,\n ReactivesearchResultProps,\n ReactivesearchPaginationProps,\n} from \"../../types\";\nimport {\n useReactifySearchContext,\n useAnalytics,\n useSearch,\n useFilters,\n useReactiveReactiveListProps,\n useProductPrice,\n usePagination,\n usePaginationLoadable,\n useResults,\n} from \"../../hooks\";\n\nexport type ResultProps = ReactivesearchResultProps & {\n callouts: ElasticCallout[];\n products: ElasticProduct[];\n};\n\nexport type ResultsProps = {\n /** Style prop for the list wrapper */\n listStyle?: React.HTMLAttributes<HTMLElement>[\"style\"];\n /** Classname prop for the list wrapper */\n listClassName?: string;\n /** Render method called when an error occurs */\n renderError?: React.FC<{ error: ReactivesearchError }>;\n /** Render method called while loading for the first time */\n renderLoading?: React.FC;\n /** Render method called when no results are found */\n renderNoResults?: React.FC;\n /** Render method called once for each product result */\n renderResultCardProduct?: React.FC<\n ReturnType<typeof useProductPrice> & {\n pagePosition: number;\n product: ElasticProduct;\n document: ElasticProduct;\n itemRef: (node?: Element | null) => void;\n handleClick: () => void;\n }\n >;\n /** Render method called once for each callout result */\n renderResultCardCallout?: React.FC<{\n pagePosition: number;\n document: ElasticCallout;\n callout: ElasticCallout[\"callout\"];\n itemRef: (node?: Element | null) => void;\n handleClick: () => void;\n }>;\n /** Render method called for pagination type \"pagination\" */\n renderPaginationNumbered?: React.FC<ReturnType<typeof usePagination>>;\n /** Render method called for pagination type \"next_prev\" */\n renderPaginationNextPrev?: React.FC<ReturnType<typeof usePagination>>;\n /** Render method called for pagination type \"load_more\" */\n renderPaginationLoadMore?: React.FC<ReturnType<typeof usePaginationLoadable>>;\n /** Render method called for pagination type \"infinite_scroll\" */\n renderPaginationInfiniteScroll?: React.FC<\n ReturnType<typeof usePaginationLoadable>\n >;\n /** Define which fields should be included in results data */\n includeFields?: Array<string>;\n /** Define which fields should be excluded from results data */\n excludeFields?: Array<string>;\n /** Advanced Usage: Override the default amount of results per page */\n pageSize?: number;\n /** Advanced Usage: Override the default scrollTarget used to determine when infinite load should be triggered (infinite scroll) */\n infiniteScrollContainer?: React.ComponentProps<\n typeof ReactiveList\n >[\"scrollTarget\"];\n /** Advanced Usage: Provide a specific result position to trigger loading more results (infinite scroll) */\n infiniteScrollPosition?: number;\n};\n\nexport const Results: React.FC<ResultsProps> = (props) => {\n const reactiveReactiveListProps = useReactiveReactiveListProps({\n pageSize: props.pageSize,\n scrollTarget: props.infiniteScrollContainer,\n });\n const { track } = useAnalytics();\n const { searchTerm } = useSearch();\n\n const fieldsInclude = React.useMemo(() => {\n return [\n ...(props.includeFields ?? []),\n \"id\",\n \"title\",\n \"type\",\n \"handle\",\n \"image\",\n \"variants.id\",\n \"variants.presentment_prices\",\n \"callout\",\n ];\n }, [props.includeFields]);\n const fieldsExclude = React.useMemo(() => {\n return [...(props.excludeFields ?? [])];\n }, [props.excludeFields]);\n\n return (\n <ReactiveList\n {...reactiveReactiveListProps}\n includeFields={fieldsInclude}\n excludeFields={fieldsExclude}\n render={(reactivesearchResultProps: ReactivesearchResultProps) => (\n <ResultsInner\n {...props}\n reactivesearchResultProps={reactivesearchResultProps}\n />\n )}\n onData={(renderProps) => {\n if (renderProps.resultStats.numberOfResults === 0) {\n let trimmedSearchTerm = searchTerm.trim();\n\n if (\n !trimmedSearchTerm ||\n (trimmedSearchTerm && trimmedSearchTerm.length < 3)\n ) {\n return;\n }\n\n track({\n eventName: \"zeroResults\",\n payload: {\n searchTerm: trimmedSearchTerm,\n },\n });\n }\n }}\n renderPagination={(\n reactivesearchPaginationProps: ReactivesearchPaginationProps\n ) => (\n <ResultsPaginationStack {...props} {...reactivesearchPaginationProps} />\n )}\n />\n );\n};\n\nconst ResultsRenderErrorComponent: ResultsProps[\"renderError\"] = (props) => {\n return (\n <div>\n {\"Error: \"}\n {props.error.statusText}\n </div>\n );\n};\n\nconst ResultsRenderLoadingComponent: ResultsProps[\"renderLoading\"] = () => {\n return <div>{\"Loading\"}</div>;\n};\n\nconst ResultsRenderNoResultsComponent: ResultsProps[\"renderNoResults\"] = () => {\n return <div>{\"No results\"}</div>;\n};\n\nconst ResultsInner: React.FC<\n ResultsProps & { reactivesearchResultProps: ReactivesearchResultProps }\n> = (props) => {\n const context = useReactifySearchContext();\n const filtersHook = useFilters();\n const resultsHook = useResults();\n const initialSearchHasRun = React.useMemo(\n () =>\n \"undefined\" !==\n typeof props.reactivesearchResultProps.resultStats.numberOfResults,\n [props.reactivesearchResultProps]\n );\n\n const listStyle = React.useMemo<React.HTMLAttributes<HTMLElement>[\"style\"]>(\n () =>\n props.listStyle ?? {\n display: \"grid\",\n gap: \"8px\",\n gridTemplateColumns: \"repeat(4, minmax(0, 1fr))\",\n },\n [props.listStyle]\n );\n\n const infiniteScrollPosition = React.useMemo<number>(() => {\n if (!props.infiniteScrollPosition) {\n return NaN;\n }\n\n const scrollPositionOffset =\n props.reactivesearchResultProps.resultStats.displayedResults -\n (props.pageSize ?? filtersHook.filterStack?.pageSize ?? 0);\n\n return scrollPositionOffset + (props.infiniteScrollPosition ?? 0);\n }, [\n props.pageSize ?? filtersHook.filterStack?.pageSize,\n props.reactivesearchResultProps.resultStats.displayedResults,\n props.infiniteScrollPosition,\n ]);\n\n React.useEffect(() => {\n resultsHook.setResults(props.reactivesearchResultProps.data);\n resultsHook.setResultStats(props.reactivesearchResultProps.resultStats);\n }, [\n props.reactivesearchResultProps.resultStats.numberOfResults,\n props.reactivesearchResultProps.data.map((item) => item._id).join(\"\"),\n ]);\n\n if (props.reactivesearchResultProps.error) {\n const RenderErrorComponent =\n props.renderError ?? ResultsRenderErrorComponent;\n\n return (\n <RenderErrorComponent error={props.reactivesearchResultProps.error} />\n );\n }\n\n if (!initialSearchHasRun) {\n const RenderLoadingComponent =\n props.renderLoading ?? ResultsRenderLoadingComponent;\n return <RenderLoadingComponent />;\n }\n\n if (\n !props.reactivesearchResultProps.loading &&\n !props.reactivesearchResultProps.resultStats.numberOfResults\n ) {\n const RenderNoResultsComponent =\n props.renderNoResults ?? ResultsRenderNoResultsComponent;\n\n return <RenderNoResultsComponent />;\n }\n\n if ([\"search\", \"instant-search\"].includes(context.options.mode)) {\n if (!context.search.searchTerm) {\n const RenderNoResultsComponent =\n props.renderNoResults ?? ResultsRenderNoResultsComponent;\n\n return <RenderNoResultsComponent />;\n }\n }\n\n return (\n <>\n <section style={listStyle} className={props.listClassName}>\n {props.reactivesearchResultProps.data.map((item, key) => {\n if (ElasticDocumentType.Product === item.type) {\n return (\n <ResultCardProduct\n key={item._id}\n product={item}\n document={item}\n pagePosition={key + 1}\n render={props.renderResultCardProduct}\n {...(infiniteScrollPosition === key + 1\n ? {\n onView: () => props.reactivesearchResultProps.loadMore(),\n }\n : {})}\n />\n );\n }\n\n if (ElasticDocumentType.Callout === item.type) {\n return (\n <ResultCardCallout\n key={item._id}\n document={item}\n pagePosition={key + 1}\n callout={item.callout}\n render={props.renderResultCardCallout}\n {...(infiniteScrollPosition === key + 1\n ? {\n onView: () => props.reactivesearchResultProps.loadMore(),\n }\n : {})}\n />\n );\n }\n\n return null;\n })}\n </section>\n <ResultsPaginationStackLoadable\n {...props}\n {...props.reactivesearchResultProps}\n />\n </>\n );\n};\n\n/** Handles rendering pagination for types that use \"pagination props\" */\nconst ResultsPaginationStack: React.FC<\n ResultsProps & ReactivesearchPaginationProps\n> = (props) => {\n const { options } = useReactifySearchContext();\n const { filterStack } = useFilters();\n\n if (options.mode === \"instant-search\") {\n return null;\n }\n\n if (\"pagination\" === filterStack?.paginationType) {\n return (\n <ResultPaginationNumbered\n {...props}\n render={props.renderPaginationNumbered}\n />\n );\n }\n\n if (\"next_prev\" === filterStack?.paginationType) {\n return (\n <ResultPaginationNextPrev\n {...props}\n render={props.renderPaginationNextPrev}\n />\n );\n }\n\n return null;\n};\n\n/** Handles rendering pagination for types that use \"result props\" */\nconst ResultsPaginationStackLoadable: React.FC<\n ResultsProps & { reactivesearchResultProps: ReactivesearchResultProps }\n> = (props) => {\n const { options } = useReactifySearchContext();\n const { filterStack } = useFilters();\n\n if (options.mode === \"instant-search\") {\n return null;\n }\n\n if (\"load_more\" === filterStack?.paginationType) {\n return (\n <ResultPaginationLoadMore\n {...props.reactivesearchResultProps}\n render={props.renderPaginationLoadMore}\n />\n );\n }\n\n if (\"infinite_scroll\" === filterStack?.paginationType) {\n return (\n <ResultPaginationInfiniteScroll\n {...props.reactivesearchResultProps}\n render={props.renderPaginationInfiniteScroll}\n />\n );\n }\n\n return null;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"Results.js","sourceRoot":"","sources":["../../../../src/components/Result/Results.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,gHAAwF;AAExF,2DAAwD;AACxD,2DAAwD;AACxD,yEAAsE;AACtE,yEAAsE;AACtE,yEAAsE;AACtE,qFAAkF;AAElF,uCAOqB;AACrB,uCASqB;AACrB,+CAAsD;AA4D/C,MAAM,OAAO,GAA2B,CAAC,KAAK,EAAE,EAAE;IACvD,MAAM,qBAAqB,GAAG,IAAA,gCAAwB,GAAE,CAAC;IACzD,MAAM,WAAW,GAAG,IAAA,kBAAU,G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AK,gBAAgB,EAAE;QACrC,OAAO,IAAI,CAAC;KACb;IAED,IAAI,WAAW,MAAK,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,CAAA,EAAE;QAC/C,OAAO,CACL,8BAAC,mDAAwB,oBACnB,KAAK,CAAC,yBAAyB,IACnC,MAAM,EAAE,KAAK,CAAC,wBAAwB,IACtC,CACH,CAAC;KACH;IAED,IAAI,iBAAiB,MAAK,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,CAAA,EAAE;QACrD,OAAO,CACL,8BAAC,+DAA8B,oBACzB,KAAK,CAAC,yBAAyB,IACnC,MAAM,EAAE,KAAK,CAAC,8BAA8B,IAC5C,CACH,CAAC;KACH;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveList from \"@appbaseio/reactivesearch/lib/components/result/ReactiveList\";\n\nimport { ResultCardCallout } from \"./ResultCardCallout\";\nimport { ResultCardProduct } from \"./ResultCardProduct\";\nimport { ResultPaginationNumbered } from \"./ResultPaginationNumbered\";\nimport { ResultPaginationLoadMore } from \"./ResultPaginationLoadMore\";\nimport { ResultPaginationNextPrev } from \"./ResultPaginationNextPrev\";\nimport { ResultPaginationInfiniteScroll } from \"./ResultPaginationInfiniteScroll\";\n\nimport {\n ElasticCallout,\n ElasticProduct,\n ElasticDocumentType,\n ReactivesearchError,\n ReactivesearchResultProps,\n ReactivesearchPaginationProps,\n} from \"../../types\";\nimport {\n useReactifySearchContext,\n useAnalytics,\n useSearch,\n useFilters,\n useProductPrice,\n usePagination,\n usePaginationLoadable,\n useResults,\n} from \"../../hooks\";\nimport { getPropsResults } from \"../../utility/props\";\n\nexport type ResultProps = ReactivesearchResultProps & {\n callouts: ElasticCallout[];\n products: ElasticProduct[];\n};\n\nexport type ResultsProps = {\n /** Style prop for the list wrapper */\n listStyle?: React.HTMLAttributes<HTMLElement>[\"style\"];\n /** Classname prop for the list wrapper */\n listClassName?: string;\n /** Render method called when an error occurs */\n renderError?: React.FC<{ error: ReactivesearchError }>;\n /** Render method called while loading for the first time */\n renderLoading?: React.FC;\n /** Render method called when no results are found */\n renderNoResults?: React.FC;\n /** Render method called once for each product result */\n renderResultCardProduct?: React.FC<\n ReturnType<typeof useProductPrice> & {\n pagePosition: number;\n product: ElasticProduct;\n document: ElasticProduct;\n itemRef: (node?: Element | null) => void;\n handleClick: () => void;\n }\n >;\n /** Render method called once for each callout result */\n renderResultCardCallout?: React.FC<{\n pagePosition: number;\n document: ElasticCallout;\n callout: ElasticCallout[\"callout\"];\n itemRef: (node?: Element | null) => void;\n handleClick: () => void;\n }>;\n /** Render method called for pagination type \"pagination\" */\n renderPaginationNumbered?: React.FC<ReturnType<typeof usePagination>>;\n /** Render method called for pagination type \"next_prev\" */\n renderPaginationNextPrev?: React.FC<ReturnType<typeof usePagination>>;\n /** Render method called for pagination type \"load_more\" */\n renderPaginationLoadMore?: React.FC<ReturnType<typeof usePaginationLoadable>>;\n /** Render method called for pagination type \"infinite_scroll\" */\n renderPaginationInfiniteScroll?: React.FC<\n ReturnType<typeof usePaginationLoadable>\n >;\n /** Define which fields should be included in results data */\n // includeFields?: Array<string>;\n /** Define which fields should be excluded from results data */\n // excludeFields?: Array<string>;\n /** Advanced Usage: Override the default amount of results per page */\n pageSize?: number;\n /** Advanced Usage: Override the default scrollTarget used to determine when infinite load should be triggered (infinite scroll) */\n infiniteScrollContainer?: React.ComponentProps<\n typeof ReactiveList\n >[\"scrollTarget\"];\n /** Advanced Usage: Provide a specific result position to trigger loading more results (infinite scroll) */\n infiniteScrollPosition?: number;\n};\n\nexport const Results: React.FC<ResultsProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const reactiveProps = getPropsResults({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n scrollTarget: props.infiniteScrollContainer,\n pageSize: props.pageSize\n });\n\n const { track } = useAnalytics();\n const { searchTerm } = useSearch();\n\n return (\n <ReactiveList\n {...reactiveProps}\n render={(reactivesearchResultProps: ReactivesearchResultProps) => (\n <ResultsInner\n {...props}\n reactivesearchResultProps={reactivesearchResultProps}\n />\n )}\n onData={(renderProps) => {\n if (renderProps.resultStats.numberOfResults === 0) {\n let trimmedSearchTerm = searchTerm.trim();\n\n if (\n !trimmedSearchTerm ||\n (trimmedSearchTerm && trimmedSearchTerm.length < 3)\n ) {\n return;\n }\n\n track({\n eventName: \"zeroResults\",\n payload: {\n searchTerm: trimmedSearchTerm,\n },\n });\n }\n }}\n renderPagination={(\n reactivesearchPaginationProps: ReactivesearchPaginationProps\n ) => (\n <ResultsPaginationStack {...props} {...reactivesearchPaginationProps} />\n )}\n />\n );\n};\n\nconst ResultsRenderErrorComponent: ResultsProps[\"renderError\"] = (props) => {\n return (\n <div>\n {\"Error: \"}\n {props.error.statusText}\n </div>\n );\n};\n\nconst ResultsRenderLoadingComponent: ResultsProps[\"renderLoading\"] = () => {\n return <div>{\"Loading\"}</div>;\n};\n\nconst ResultsRenderNoResultsComponent: ResultsProps[\"renderNoResults\"] = () => {\n return <div>{\"No results\"}</div>;\n};\n\nconst ResultsInner: React.FC<\n ResultsProps & { reactivesearchResultProps: ReactivesearchResultProps }\n> = (props) => {\n const context = useReactifySearchContext();\n const filtersHook = useFilters();\n const resultsHook = useResults();\n const initialSearchHasRun = React.useMemo(\n () =>\n \"undefined\" !==\n typeof props.reactivesearchResultProps.resultStats.numberOfResults,\n [props.reactivesearchResultProps]\n );\n\n const listStyle = React.useMemo<React.HTMLAttributes<HTMLElement>[\"style\"]>(\n () =>\n props.listStyle ?? {\n display: \"grid\",\n gap: \"8px\",\n gridTemplateColumns: \"repeat(4, minmax(0, 1fr))\",\n },\n [props.listStyle]\n );\n\n const infiniteScrollPosition = React.useMemo<number>(() => {\n if (!props.infiniteScrollPosition) {\n return NaN;\n }\n\n const scrollPositionOffset =\n props.reactivesearchResultProps.resultStats.displayedResults -\n (props.pageSize ?? filtersHook.filterStack?.pageSize ?? 0);\n\n return scrollPositionOffset + (props.infiniteScrollPosition ?? 0);\n }, [\n props.pageSize ?? filtersHook.filterStack?.pageSize,\n props.reactivesearchResultProps.resultStats.displayedResults,\n props.infiniteScrollPosition,\n ]);\n\n React.useEffect(() => {\n resultsHook.setResults(props.reactivesearchResultProps.data);\n resultsHook.setResultStats(props.reactivesearchResultProps.resultStats);\n }, [\n props.reactivesearchResultProps.resultStats.numberOfResults,\n props.reactivesearchResultProps.data.map((item) => item._id).join(\"\"),\n ]);\n\n if (props.reactivesearchResultProps.error) {\n const RenderErrorComponent =\n props.renderError ?? ResultsRenderErrorComponent;\n\n return (\n <RenderErrorComponent error={props.reactivesearchResultProps.error} />\n );\n }\n\n if (!initialSearchHasRun) {\n const RenderLoadingComponent =\n props.renderLoading ?? ResultsRenderLoadingComponent;\n return <RenderLoadingComponent />;\n }\n\n if (\n !props.reactivesearchResultProps.loading &&\n !props.reactivesearchResultProps.resultStats.numberOfResults\n ) {\n const RenderNoResultsComponent =\n props.renderNoResults ?? ResultsRenderNoResultsComponent;\n\n return <RenderNoResultsComponent />;\n }\n\n if ([\"search\", \"instant-search\"].includes(context.options.mode)) {\n if (!context.search.searchTerm) {\n const RenderNoResultsComponent =\n props.renderNoResults ?? ResultsRenderNoResultsComponent;\n\n return <RenderNoResultsComponent />;\n }\n }\n\n return (\n <>\n <section style={listStyle} className={props.listClassName}>\n {props.reactivesearchResultProps.data.map((item, key) => {\n if (ElasticDocumentType.Product === item.type) {\n return (\n <ResultCardProduct\n key={item._id}\n product={item}\n document={item}\n pagePosition={key + 1}\n render={props.renderResultCardProduct}\n {...(infiniteScrollPosition === key + 1\n ? {\n onView: () => props.reactivesearchResultProps.loadMore(),\n }\n : {})}\n />\n );\n }\n\n if (ElasticDocumentType.Callout === item.type) {\n return (\n <ResultCardCallout\n key={item._id}\n document={item}\n pagePosition={key + 1}\n callout={item.callout}\n render={props.renderResultCardCallout}\n {...(infiniteScrollPosition === key + 1\n ? {\n onView: () => props.reactivesearchResultProps.loadMore(),\n }\n : {})}\n />\n );\n }\n\n return null;\n })}\n </section>\n <ResultsPaginationStackLoadable\n {...props}\n {...props.reactivesearchResultProps}\n />\n </>\n );\n};\n\n/** Handles rendering pagination for types that use \"pagination props\" */\nconst ResultsPaginationStack: React.FC<\n ResultsProps & ReactivesearchPaginationProps\n> = (props) => {\n const { options } = useReactifySearchContext();\n const { filterStack } = useFilters();\n\n if (options.mode === \"instant-search\") {\n return null;\n }\n\n if (\"pagination\" === filterStack?.paginationType) {\n return (\n <ResultPaginationNumbered\n {...props}\n render={props.renderPaginationNumbered}\n />\n );\n }\n\n if (\"next_prev\" === filterStack?.paginationType) {\n return (\n <ResultPaginationNextPrev\n {...props}\n render={props.renderPaginationNextPrev}\n />\n );\n }\n\n return null;\n};\n\n/** Handles rendering pagination for types that use \"result props\" */\nconst ResultsPaginationStackLoadable: React.FC<\n ResultsProps & { reactivesearchResultProps: ReactivesearchResultProps }\n> = (props) => {\n const { options } = useReactifySearchContext();\n const { filterStack } = useFilters();\n\n if (options.mode === \"instant-search\") {\n return null;\n }\n\n if (\"load_more\" === filterStack?.paginationType) {\n return (\n <ResultPaginationLoadMore\n {...props.reactivesearchResultProps}\n render={props.renderPaginationLoadMore}\n />\n );\n }\n\n if (\"infinite_scroll\" === filterStack?.paginationType) {\n return (\n <ResultPaginationInfiniteScroll\n {...props.reactivesearchResultProps}\n render={props.renderPaginationInfiniteScroll}\n />\n );\n }\n\n return null;\n};\n"]}
|
|
@@ -7,89 +7,17 @@ exports.SensorCollection = void 0;
|
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const ReactiveComponent_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent"));
|
|
9
9
|
const hooks_1 = require("../../hooks");
|
|
10
|
+
const props_1 = require("../../utility/props");
|
|
10
11
|
const SensorCollection = () => {
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
12
|
+
const reactifySearchContext = (0, hooks_1.useReactifySearchContext)();
|
|
13
|
+
const reactiveProps = (0, props_1.getPropsSensorCollection)({
|
|
14
|
+
config: reactifySearchContext.config,
|
|
15
|
+
provider: reactifySearchContext.options,
|
|
16
|
+
});
|
|
17
|
+
if (!reactiveProps) {
|
|
14
18
|
return null;
|
|
15
19
|
}
|
|
16
|
-
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
return (react_1.default.createElement(ReactiveComponent_1.default, { componentId: "SensorCollection", customQuery: () => {
|
|
20
|
-
const conditions = [];
|
|
21
|
-
if (options.market) {
|
|
22
|
-
conditions.push({
|
|
23
|
-
nested: {
|
|
24
|
-
path: "curations",
|
|
25
|
-
query: {
|
|
26
|
-
bool: {
|
|
27
|
-
should: [
|
|
28
|
-
{
|
|
29
|
-
nested: {
|
|
30
|
-
path: "collections",
|
|
31
|
-
query: {
|
|
32
|
-
term: {
|
|
33
|
-
"collections.handle.keyword": options.collectionHandle,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
nested: {
|
|
40
|
-
path: "curations",
|
|
41
|
-
query: {
|
|
42
|
-
term: {
|
|
43
|
-
"curations.collectionHandle.keyword": options.collectionHandle,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
must: [{
|
|
50
|
-
nested: {
|
|
51
|
-
path: "curations",
|
|
52
|
-
query: {
|
|
53
|
-
term: {
|
|
54
|
-
"curations.markets.keyword": options.market,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
}]
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
return {
|
|
65
|
-
query: {
|
|
66
|
-
bool: {
|
|
67
|
-
should: [
|
|
68
|
-
{
|
|
69
|
-
nested: {
|
|
70
|
-
path: "collections",
|
|
71
|
-
query: {
|
|
72
|
-
term: {
|
|
73
|
-
"collections.handle.keyword": options.collectionHandle,
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
nested: {
|
|
80
|
-
path: "curations",
|
|
81
|
-
query: {
|
|
82
|
-
term: {
|
|
83
|
-
"curations.collectionHandle.keyword": options.collectionHandle,
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
} }));
|
|
20
|
+
return (react_1.default.createElement(ReactiveComponent_1.default, Object.assign({}, reactiveProps)));
|
|
93
21
|
};
|
|
94
22
|
exports.SensorCollection = SensorCollection;
|
|
95
23
|
//# sourceMappingURL=SensorCollection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SensorCollection.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorCollection.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;AAEjG,
|
|
1
|
+
{"version":3,"file":"SensorCollection.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorCollection.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;AAEjG,uCAAuD;AACvD,+CAA+D;AAExD,MAAM,gBAAgB,GAAa,GAAG,EAAE;IAC7C,MAAM,qBAAqB,GAAG,IAAA,gCAAwB,GAAE,CAAC;IACzD,MAAM,aAAa,GAAG,IAAA,gCAAwB,EAAC;QAC7C,MAAM,EAAE,qBAAqB,CAAC,MAAM;QACpC,QAAQ,EAAE,qBAAqB,CAAC,OAAO;KACxC,CAAC,CAAC;IAEH,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,8BAAC,2BAAiB,oBACZ,aAAa,EACjB,CACH,CAAC;AACJ,CAAC,CAAC;AAhBW,QAAA,gBAAgB,oBAgB3B","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent\";\n\nimport { useReactifySearchContext } from \"../../hooks\";\nimport { getPropsSensorCollection } from \"../../utility/props\";\n\nexport const SensorCollection: React.FC = () => {\n const reactifySearchContext = useReactifySearchContext();\n const reactiveProps = getPropsSensorCollection({\n config: reactifySearchContext.config,\n provider: reactifySearchContext.options,\n });\n\n if (!reactiveProps) {\n return null;\n }\n\n return (\n <ReactiveComponent\n {...reactiveProps}\n />\n );\n};\n"]}
|
|
@@ -7,10 +7,14 @@ exports.SensorCustom = void 0;
|
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const ReactiveComponent_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent"));
|
|
9
9
|
const hooks_1 = require("../../hooks");
|
|
10
|
+
const props_1 = require("../../utility/props");
|
|
10
11
|
const SensorCustom = () => {
|
|
11
12
|
const reactifySearchContext = (0, hooks_1.useReactifySearchContext)();
|
|
12
|
-
const
|
|
13
|
-
|
|
13
|
+
const reactiveProps = (0, props_1.getPropsSensorCustom)({
|
|
14
|
+
config: reactifySearchContext.config,
|
|
15
|
+
provider: reactifySearchContext.options,
|
|
16
|
+
});
|
|
17
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, reactiveProps.map((props, index) => react_1.default.createElement(ReactiveComponent_1.default, Object.assign({ key: `SensorCustom_${index}` }, props)))));
|
|
14
18
|
};
|
|
15
19
|
exports.SensorCustom = SensorCustom;
|
|
16
20
|
//# sourceMappingURL=SensorCustom.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SensorCustom.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorCustom.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;AAEjG,uCAAuD;
|
|
1
|
+
{"version":3,"file":"SensorCustom.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorCustom.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;AAEjG,uCAAuD;AACvD,+CAA2D;AAEpD,MAAM,YAAY,GAAa,GAAG,EAAE;IACzC,MAAM,qBAAqB,GAAG,IAAA,gCAAwB,GAAE,CAAC;IACzD,MAAM,aAAa,GAAG,IAAA,4BAAoB,EAAC;QACzC,MAAM,EAAE,qBAAqB,CAAC,MAAM;QACpC,QAAQ,EAAE,qBAAqB,CAAC,OAAO;KACxC,CAAC,CAAC;IAEH,OAAO,CACL,8DACG,aAAa,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAClC,8BAAC,2BAAiB,kBAChB,GAAG,EAAE,gBAAgB,KAAK,EAAE,IACxB,KAAK,EACT,CACH,CACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAjBW,QAAA,YAAY,gBAiBvB","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent\";\n\nimport { useReactifySearchContext } from \"../../hooks\";\nimport { getPropsSensorCustom } from \"../../utility/props\";\n\nexport const SensorCustom: React.FC = () => {\n const reactifySearchContext = useReactifySearchContext();\n const reactiveProps = getPropsSensorCustom({\n config: reactifySearchContext.config,\n provider: reactifySearchContext.options,\n });\n\n return (\n <>\n {reactiveProps.map((props, index) => \n <ReactiveComponent\n key={`SensorCustom_${index}`}\n {...props}\n />\n )}\n </>\n );\n};\n"]}
|
|
@@ -7,57 +7,21 @@ exports.SensorInventoryAvailable = void 0;
|
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const ReactiveComponent_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent"));
|
|
9
9
|
const hooks_1 = require("../../hooks");
|
|
10
|
+
const props_1 = require("../../utility/props");
|
|
10
11
|
const SensorInventoryAvailable = () => {
|
|
11
|
-
const { options } = (0, hooks_1.useReactifySearchContext)();
|
|
12
12
|
const flagsHook = (0, hooks_1.useFlags)();
|
|
13
|
-
const
|
|
14
|
-
|
|
13
|
+
const reactifySearchContext = (0, hooks_1.useReactifySearchContext)();
|
|
14
|
+
const reactiveProps = (0, props_1.getPropsSensorInventoryAvailable)({
|
|
15
|
+
config: reactifySearchContext.config,
|
|
16
|
+
provider: reactifySearchContext.options,
|
|
17
|
+
});
|
|
18
|
+
if (!reactiveProps) {
|
|
15
19
|
return null;
|
|
16
20
|
}
|
|
17
21
|
if (!flagsHook.flags["reactify-search:flag_sensor_inventoryavailable"]) {
|
|
18
22
|
return null;
|
|
19
23
|
}
|
|
20
|
-
return (react_1.default.createElement(ReactiveComponent_1.default, {
|
|
21
|
-
query: {
|
|
22
|
-
bool: {
|
|
23
|
-
should: [
|
|
24
|
-
{
|
|
25
|
-
bool: {
|
|
26
|
-
must: [
|
|
27
|
-
{
|
|
28
|
-
term: {
|
|
29
|
-
type: {
|
|
30
|
-
value: "product",
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
nested: {
|
|
36
|
-
path: "variants",
|
|
37
|
-
query: {
|
|
38
|
-
match: { "variants.available": true },
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
...(options.mode === "instant-search"
|
|
46
|
-
? []
|
|
47
|
-
: [
|
|
48
|
-
{
|
|
49
|
-
term: {
|
|
50
|
-
type: {
|
|
51
|
-
value: "callout",
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
]),
|
|
56
|
-
],
|
|
57
|
-
minimum_should_match: "1",
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
}) }));
|
|
24
|
+
return (react_1.default.createElement(ReactiveComponent_1.default, Object.assign({}, reactiveProps)));
|
|
61
25
|
};
|
|
62
26
|
exports.SensorInventoryAvailable = SensorInventoryAvailable;
|
|
63
27
|
//# sourceMappingURL=SensorInventoryAvailable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SensorInventoryAvailable.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorInventoryAvailable.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;AAEjG,
|
|
1
|
+
{"version":3,"file":"SensorInventoryAvailable.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorInventoryAvailable.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;AAEjG,uCAAiE;AACjE,+CAAuE;AAEhE,MAAM,wBAAwB,GAAa,GAAG,EAAE;IACrD,MAAM,SAAS,GAAG,IAAA,gBAAQ,GAAE,CAAC;IAE7B,MAAM,qBAAqB,GAAG,IAAA,gCAAwB,GAAE,CAAC;IACzD,MAAM,aAAa,GAAG,IAAA,wCAAgC,EAAC;QACrD,MAAM,EAAE,qBAAqB,CAAC,MAAM;QACpC,QAAQ,EAAE,qBAAqB,CAAC,OAAO;KACxC,CAAC,CAAC;IAEH,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO,IAAI,CAAC;KACb;IAED,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,gDAAgD,CAAC,EAAE;QACtE,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,8BAAC,2BAAiB,oBACZ,aAAa,EACjB,CACH,CAAC;AACJ,CAAC,CAAC;AAtBW,QAAA,wBAAwB,4BAsBnC","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent\";\n\nimport { useFlags, useReactifySearchContext } from \"../../hooks\";\nimport { getPropsSensorInventoryAvailable } from \"../../utility/props\";\n\nexport const SensorInventoryAvailable: React.FC = () => {\n const flagsHook = useFlags();\n \n const reactifySearchContext = useReactifySearchContext();\n const reactiveProps = getPropsSensorInventoryAvailable({\n config: reactifySearchContext.config,\n provider: reactifySearchContext.options,\n });\n\n if (!reactiveProps) {\n return null;\n }\n\n if (!flagsHook.flags[\"reactify-search:flag_sensor_inventoryavailable\"]) {\n return null;\n }\n\n return (\n <ReactiveComponent\n {...reactiveProps}\n />\n );\n};\n"]}
|