@usereactify/search 5.55.0-beta.2 → 5.55.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 CHANGED
@@ -2,6 +2,24 @@
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.55.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.54.0...release-v5.55.0) (2024-11-25)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * apply global boosting rules to search curations without boosting rules ([8645453](https://bitbucket.org/usereactify/reactify-search-ui/commit/86454531bf134ca01933e03fa234df8d2379ee09))
11
+ * disable URL params analysis when mode is instant-search ([a460a8c](https://bitbucket.org/usereactify/reactify-search-ui/commit/a460a8c56cbeb1352b4a258ee6452d8324f3342a))
12
+ * disable URL params when mode is instant-search ([f1c5906](https://bitbucket.org/usereactify/reactify-search-ui/commit/f1c5906b633ac500b67940305f1f79ab67117f96))
13
+ * isolate window events to specific ReactifySearchProviders, reduce noisy logs ([c736499](https://bitbucket.org/usereactify/reactify-search-ui/commit/c73649997275513bfbbcc6581a7d1dfce4641c91))
14
+ * parse initial query for sliders before page load ([8896226](https://bitbucket.org/usereactify/reactify-search-ui/commit/889622623081121e65af4408983e426b1d1f4b4b))
15
+
16
+ ## [5.55.0-beta.3](https://bitbucket.org/usereactify/reactify-search-ui/compare/beta-v5.55.0-beta.2...beta-v5.55.0-beta.3) (2024-11-21)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * parse initial query for sliders before page load ([8896226](https://bitbucket.org/usereactify/reactify-search-ui/commit/889622623081121e65af4408983e426b1d1f4b4b))
22
+
5
23
  ## [5.55.0-beta.2](https://bitbucket.org/usereactify/reactify-search-ui/compare/beta-v5.55.0-beta.1...beta-v5.55.0-beta.2) (2024-11-20)
6
24
 
7
25
 
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@usereactify/search",
3
3
  "description": "React UI library for Reactify Search",
4
- "version": "5.55.0-beta.2",
4
+ "version": "5.55.0",
5
5
  "license": "MIT",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",
@@ -122,6 +122,7 @@ const FilterSlider = (props) => {
122
122
  config: reactifySearchContext.config,
123
123
  filterGroup: filtersHook.filterStack,
124
124
  }, props.filter);
125
+ const filterSliderProps = (0, hooks_1.useFilterSliderProps)(props.filter);
125
126
  return (react_1.default.createElement(ReactiveComponent_1.default, Object.assign({}, sharedProps, { defaultQuery: () => ({
126
127
  aggs: {
127
128
  min: {
@@ -135,21 +136,20 @@ const FilterSlider = (props) => {
135
136
  },
136
137
  },
137
138
  },
138
- }), render: (reactivesearchFilterProps) => {
139
+ }), customQuery: filterSliderProps.query, render: (reactivesearchFilterProps) => {
139
140
  var _a, _b, _c, _d;
140
141
  if (!props.showEmptyFilters &&
141
142
  ((_b = (_a = reactivesearchFilterProps === null || reactivesearchFilterProps === void 0 ? void 0 : reactivesearchFilterProps.aggregations) === null || _a === void 0 ? void 0 : _a.min) === null || _b === void 0 ? void 0 : _b.value) ===
142
143
  ((_d = (_c = reactivesearchFilterProps === null || reactivesearchFilterProps === void 0 ? void 0 : reactivesearchFilterProps.aggregations) === null || _c === void 0 ? void 0 : _c.max) === null || _d === void 0 ? void 0 : _d.value)) {
143
144
  return null;
144
145
  }
145
- return (react_1.default.createElement(FilterSliderInner, Object.assign({}, props, { reactivesearchFilterProps: reactivesearchFilterProps })));
146
+ return (react_1.default.createElement(FilterSliderInner, Object.assign({}, props, { filterSliderProps: filterSliderProps, reactivesearchFilterProps: reactivesearchFilterProps })));
146
147
  } })));
147
148
  };
148
149
  // inner component exists only so we can use memos in reactivesearch render functions
149
150
  const FilterSliderInner = (props) => {
150
151
  var _a, _b, _c;
151
- const { filter, renderFilterSlider, reactivesearchFilterProps } = props, otherProps = __rest(props, ["filter", "renderFilterSlider", "reactivesearchFilterProps"]);
152
- const filterSliderProps = (0, hooks_1.useFilterSliderProps)(filter);
152
+ const { filter, renderFilterSlider, filterSliderProps, reactivesearchFilterProps } = props, otherProps = __rest(props, ["filter", "renderFilterSlider", "filterSliderProps", "reactivesearchFilterProps"]);
153
153
  react_1.default.useEffect(() => {
154
154
  if (reactivesearchFilterProps.aggregations) {
155
155
  filterSliderProps.handleRange([
@@ -162,43 +162,16 @@ const FilterSliderInner = (props) => {
162
162
  (_b = reactivesearchFilterProps.aggregations) === null || _b === void 0 ? void 0 : _b.max.value,
163
163
  ]);
164
164
  react_1.default.useEffect(() => {
165
- if (filterSliderProps.value[0] === 0 && filterSliderProps.value[1] === 0) {
165
+ if (!filterSliderProps.query) {
166
166
  return;
167
167
  }
168
168
  props.reactivesearchFilterProps.setQuery({
169
- query: {
170
- query: {
171
- bool: {
172
- must: [
173
- {
174
- bool: {
175
- must: [
176
- {
177
- match: {
178
- published: true,
179
- },
180
- },
181
- {
182
- range: {
183
- [props.filter.field]: {
184
- gte: filterSliderProps.value[0],
185
- lte: filterSliderProps.value[1],
186
- boost: 2,
187
- },
188
- },
189
- },
190
- ],
191
- },
192
- },
193
- ],
194
- },
195
- },
196
- },
169
+ query: filterSliderProps.query,
197
170
  value: filterSliderProps.value,
198
171
  });
199
172
  }, [filterSliderProps.value]);
200
- const RenderListComponent = (_c = props.renderFilterSlider) !== null && _c !== void 0 ? _c : components_1.ExampleFilterSlider;
201
- return (react_1.default.createElement(RenderListComponent, Object.assign({ filterSliderProps: filterSliderProps, filter: filter }, otherProps)));
173
+ const RenderSliderComponent = (_c = props.renderFilterSlider) !== null && _c !== void 0 ? _c : components_1.ExampleFilterSlider;
174
+ return (react_1.default.createElement(RenderSliderComponent, Object.assign({ filterSliderProps: filterSliderProps, filter: filter }, otherProps)));
202
175
  };
203
176
  // inner component exists only so we can use memos in reactivesearch render functions
204
177
  const FilterListInner = (props) => {
@@ -1 +1 @@
1
- {"version":3,"file":"Filter.js","sourceRoot":"","sources":["../../../../src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MAAM,EAAE,gBAAgB,EAAE,yBAAyB,KACzD,KAAK,EADyD,UAAU,UACxE,KAAK,EADD,2DAAsE,CACrE,CAAC;IAER,MAAM,eAAe,GAAG,IAAA,0BAAkB,EAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;IAE9E,+CAA+C;IAC/C,IAAI,CAAC,KAAK,CAAC,gBAAgB,IAAI,CAAC,KAAK,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACpE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,mBAAmB,GAAG,MAAA,KAAK,CAAC,gBAAgB,mCAAI,8BAAiB,CAAC;IAExE,OAAO,CACL,8BAAC,mBAAmB,kBAClB,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM,IACV,UAAU,EACd,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@usereactify/search-internals/lib/components/basic/ReactiveComponent\";\nimport MultiList from \"@usereactify/search-internals/lib/components/list/MultiList\";\nimport SingleList from \"@usereactify/search-internals/lib/components/list/SingleList\";\nimport SingleRange from \"@usereactify/search-internals/lib/components/range/SingleRange\";\nimport MultiRange from \"@usereactify/search-internals/lib/components/range/MultiRange\";\n\nimport type {\n ConfigFilterFacet,\n ReactivesearchFilterListProps,\n} from \"../../types\";\nimport {\n useFilterListProps,\n useFilterRangeProps,\n useFilterSliderProps,\n useFilters,\n useReactifySearchContext,\n} from \"../../hooks\";\nimport {\n ExampleFilterList,\n ExampleFilterRange,\n ExampleFilterSlider,\n} from \"../../components\";\nimport { getPropsFilterList, getPropsFilterRange, getPropsShared } from \"../../utility/props\";\n\nexport type FilterProps = {\n /** The filter option being rendered */\n filter: ConfigFilterFacet;\n /** Render method for List filters */\n renderFilterList?: React.FC<{\n filter: ConfigFilterFacet;\n filterListProps: ReturnType<typeof useFilterListProps>;\n }>;\n /** Render method for Range filters */\n renderFilterRange?: React.FC<{\n filter: ConfigFilterFacet;\n filterRangeProps: ReturnType<typeof useFilterRangeProps>;\n }>;\n /** Render method for Slider filters */\n renderFilterSlider?: React.FC<{\n filter: ConfigFilterFacet;\n filterSliderProps: ReturnType<typeof useFilterSliderProps>;\n // reactSliderProps: ReturnType<typeof useReactSliderProps>;\n }>;\n /** Show filters even when no options are available */\n showEmptyFilters?: boolean;\n};\n\nexport const Filter: React.FC<FilterProps> = (props) => {\n if (\"single\" === props.filter.displayType) {\n if (\"range\" === props.filter.displayView) {\n return <FilterRangeSingle {...props} />;\n }\n return <FilterSingleList {...props} />;\n }\n\n if (\"multi\" === props.filter.displayType) {\n if (\"range\" === props.filter.displayView) {\n return <FilterRangeMulti {...props} />;\n }\n return <FilterMultiList {...props} />;\n }\n\n if (\"slider\" === props.filter.displayType) {\n return <FilterSlider {...props} />;\n }\n\n // TODO: Legacy range filter, migrate to new single and multi ranges\n if (\"range\" === props.filter.displayType) {\n return <FilterRangeSingle {...props} />;\n }\n\n console.warn(\n `filter with display type \"${props.filter.displayType}\" not yet supported`\n );\n\n return null;\n};\n\nconst FilterSingleList: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterList(props.filter);\n\n return (\n <SingleList\n {...sharedProps}\n {...reactiveProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n )}\n />\n );\n};\n\nconst FilterMultiList: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterList(props.filter);\n\n return (\n <MultiList\n {...sharedProps}\n {...reactiveProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n )}\n />\n );\n};\n\nconst FilterRangeSingle: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterRange(props.filter);\n\n const filterRangeProps = useFilterRangeProps(props.filter);\n\n const RenderRangeComponent = props.renderFilterRange ?? ExampleFilterRange;\n\n return (\n <>\n <div\n style={{\n display: \"none\",\n }}\n >\n <SingleRange\n {...sharedProps}\n {...reactiveProps}\n value={filterRangeProps.values[0]}\n onChange={filterRangeProps.handleChange}\n />\n </div>\n <RenderRangeComponent\n filterRangeProps={filterRangeProps}\n filter={props.filter}\n />\n </>\n );\n};\n\nconst FilterRangeMulti: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterRange(props.filter);\n\n const filterRangeProps = useFilterRangeProps(props.filter);\n\n const RenderRangeComponent = props.renderFilterRange ?? ExampleFilterRange;\n\n return (\n <>\n <div\n style={{\n display: \"none\",\n }}\n >\n <MultiRange\n {...sharedProps}\n {...reactiveProps}\n value={filterRangeProps.values}\n // @note: onChange handler must be defined for controlled component to work correctly\n onChange={() => {}}\n onValueChange={(values) => {\n if (values.length === 0) {\n filterRangeProps.handleClear();\n }\n }}\n />\n </div>\n <RenderRangeComponent\n filterRangeProps={filterRangeProps}\n filter={props.filter}\n />\n </>\n );\n};\n\nconst FilterSlider: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n\n 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"]}
1
+ {"version":3,"file":"Filter.js","sourceRoot":"","sources":["../../../../src/components/Filter/Filter.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,6HAAqG;AACrG,4GAAoF;AACpF,8GAAsF;AACtF,iHAAyF;AACzF,+GAAuF;AAMvF,uCAMqB;AACrB,iDAI0B;AAC1B,+CAA8F;AAyBvF,MAAM,MAAM,GAA0B,CAAC,KAAK,EAAE,EAAE;IACrD,IAAI,QAAQ,KAAK,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QAC1C,IAAI,OAAO,KAAK,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YACzC,OAAO,8BAAC,iBAAiB,oBAAK,KAAK,EAAI,CAAC;QAC1C,CAAC;QACD,OAAO,8BAAC,gBAAgB,oBAAK,KAAK,EAAI,CAAC;IACzC,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACzC,IAAI,OAAO,KAAK,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YACzC,OAAO,8BAAC,gBAAgB,oBAAK,KAAK,EAAI,CAAC;QACzC,CAAC;QACD,OAAO,8BAAC,eAAe,oBAAK,KAAK,EAAI,CAAC;IACxC,CAAC;IAED,IAAI,QAAQ,KAAK,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QAC1C,O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AE,gBAAgB,EAAE,yBAAyB,KACzD,KAAK,EADyD,UAAU,UACxE,KAAK,EADD,2DAAsE,CACrE,CAAC;IAER,MAAM,eAAe,GAAG,IAAA,0BAAkB,EAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;IAE9E,+CAA+C;IAC/C,IAAI,CAAC,KAAK,CAAC,gBAAgB,IAAI,CAAC,KAAK,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACpE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,mBAAmB,GAAG,MAAA,KAAK,CAAC,gBAAgB,mCAAI,8BAAiB,CAAC;IAExE,OAAO,CACL,8BAAC,mBAAmB,kBAClB,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM,IACV,UAAU,EACd,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@usereactify/search-internals/lib/components/basic/ReactiveComponent\";\nimport MultiList from \"@usereactify/search-internals/lib/components/list/MultiList\";\nimport SingleList from \"@usereactify/search-internals/lib/components/list/SingleList\";\nimport SingleRange from \"@usereactify/search-internals/lib/components/range/SingleRange\";\nimport MultiRange from \"@usereactify/search-internals/lib/components/range/MultiRange\";\n\nimport type {\n ConfigFilterFacet,\n ReactivesearchFilterListProps,\n} from \"../../types\";\nimport {\n useFilterListProps,\n useFilterRangeProps,\n useFilterSliderProps,\n useFilters,\n useReactifySearchContext,\n} from \"../../hooks\";\nimport {\n ExampleFilterList,\n ExampleFilterRange,\n ExampleFilterSlider,\n} from \"../../components\";\nimport { getPropsFilterList, getPropsFilterRange, getPropsShared } from \"../../utility/props\";\n\nexport type FilterProps = {\n /** The filter option being rendered */\n filter: ConfigFilterFacet;\n /** Render method for List filters */\n renderFilterList?: React.FC<{\n filter: ConfigFilterFacet;\n filterListProps: ReturnType<typeof useFilterListProps>;\n }>;\n /** Render method for Range filters */\n renderFilterRange?: React.FC<{\n filter: ConfigFilterFacet;\n filterRangeProps: ReturnType<typeof useFilterRangeProps>;\n }>;\n /** Render method for Slider filters */\n renderFilterSlider?: React.FC<{\n filter: ConfigFilterFacet;\n filterSliderProps: ReturnType<typeof useFilterSliderProps>;\n // reactSliderProps: ReturnType<typeof useReactSliderProps>;\n }>;\n /** Show filters even when no options are available */\n showEmptyFilters?: boolean;\n};\n\nexport const Filter: React.FC<FilterProps> = (props) => {\n if (\"single\" === props.filter.displayType) {\n if (\"range\" === props.filter.displayView) {\n return <FilterRangeSingle {...props} />;\n }\n return <FilterSingleList {...props} />;\n }\n\n if (\"multi\" === props.filter.displayType) {\n if (\"range\" === props.filter.displayView) {\n return <FilterRangeMulti {...props} />;\n }\n return <FilterMultiList {...props} />;\n }\n\n if (\"slider\" === props.filter.displayType) {\n return <FilterSlider {...props} />;\n }\n\n // TODO: Legacy range filter, migrate to new single and multi ranges\n if (\"range\" === props.filter.displayType) {\n return <FilterRangeSingle {...props} />;\n }\n\n console.warn(\n `filter with display type \"${props.filter.displayType}\" not yet supported`\n );\n\n return null;\n};\n\nconst FilterSingleList: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterList(props.filter);\n\n return (\n <SingleList\n {...sharedProps}\n {...reactiveProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n )}\n />\n );\n};\n\nconst FilterMultiList: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterList(props.filter);\n\n return (\n <MultiList\n {...sharedProps}\n {...reactiveProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n )}\n />\n );\n};\n\nconst FilterRangeSingle: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterRange(props.filter);\n\n const filterRangeProps = useFilterRangeProps(props.filter);\n\n const RenderRangeComponent = props.renderFilterRange ?? ExampleFilterRange;\n\n return (\n <>\n <div\n style={{\n display: \"none\",\n }}\n >\n <SingleRange\n {...sharedProps}\n {...reactiveProps}\n value={filterRangeProps.values[0]}\n onChange={filterRangeProps.handleChange}\n />\n </div>\n <RenderRangeComponent\n filterRangeProps={filterRangeProps}\n filter={props.filter}\n />\n </>\n );\n};\n\nconst FilterRangeMulti: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterRange(props.filter);\n\n const filterRangeProps = useFilterRangeProps(props.filter);\n\n const RenderRangeComponent = props.renderFilterRange ?? ExampleFilterRange;\n\n return (\n <>\n <div\n style={{\n display: \"none\",\n }}\n >\n <MultiRange\n {...sharedProps}\n {...reactiveProps}\n value={filterRangeProps.values}\n // @note: onChange handler must be defined for controlled component to work correctly\n onChange={() => {}}\n onValueChange={(values) => {\n if (values.length === 0) {\n filterRangeProps.handleClear();\n }\n }}\n />\n </div>\n <RenderRangeComponent\n filterRangeProps={filterRangeProps}\n filter={props.filter}\n />\n </>\n );\n};\n\nconst FilterSlider: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n\n const filterSliderProps = useFilterSliderProps(props.filter);\n\n return (\n <ReactiveComponent\n {...sharedProps}\n defaultQuery={() => ({\n aggs: {\n min: {\n min: {\n field: props.filter.field,\n },\n },\n max: {\n max: {\n field: props.filter.field,\n },\n },\n },\n })}\n customQuery={filterSliderProps.query}\n render={(reactivesearchFilterProps) => {\n if (\n !props.showEmptyFilters &&\n reactivesearchFilterProps?.aggregations?.min?.value ===\n reactivesearchFilterProps?.aggregations?.max?.value\n ) {\n return null;\n }\n\n return (\n <FilterSliderInner\n {...props}\n filterSliderProps={filterSliderProps}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n );\n }}\n />\n );\n};\n\n// inner component exists only so we can use memos in reactivesearch render functions\nconst FilterSliderInner: React.FC<\n FilterProps & { reactivesearchFilterProps: any; filterSliderProps: ReturnType<typeof useFilterSliderProps> }\n> = (props) => {\n const {\n filter,\n renderFilterSlider,\n filterSliderProps,\n reactivesearchFilterProps,\n ...otherProps\n } = props;\n\n React.useEffect(() => {\n if (reactivesearchFilterProps.aggregations) {\n filterSliderProps.handleRange([\n reactivesearchFilterProps.aggregations.min.value,\n reactivesearchFilterProps.aggregations.max.value,\n ]);\n }\n }, [\n reactivesearchFilterProps.aggregations?.min.value,\n reactivesearchFilterProps.aggregations?.max.value,\n ]);\n\n React.useEffect(() => {\n if (!filterSliderProps.query) {\n return;\n }\n\n props.reactivesearchFilterProps.setQuery({\n query: filterSliderProps.query,\n value: filterSliderProps.value,\n });\n }, [filterSliderProps.value]);\n\n const RenderSliderComponent = props.renderFilterSlider ?? ExampleFilterSlider;\n\n return (\n <RenderSliderComponent\n filterSliderProps={filterSliderProps}\n filter={filter}\n {...otherProps}\n />\n );\n};\n\n// inner component exists only so we can use memos in reactivesearch render functions\nconst FilterListInner: React.FC<\n FilterProps & { reactivesearchFilterProps: ReactivesearchFilterListProps }\n> = (props) => {\n const { filter, renderFilterList, reactivesearchFilterProps, ...otherProps } =\n props;\n\n const filterListProps = useFilterListProps(filter, reactivesearchFilterProps);\n\n // hide entire filter when no options available\n if (!props.showEmptyFilters && 0 === filterListProps.options.length) {\n return null;\n }\n\n const RenderListComponent = props.renderFilterList ?? ExampleFilterList;\n\n return (\n <RenderListComponent\n filterListProps={filterListProps}\n filter={filter}\n {...otherProps}\n />\n );\n};\n"]}
@@ -69,10 +69,6 @@ const useCuration = () => {
69
69
  if (!globalCuration) {
70
70
  return curation;
71
71
  }
72
- const curationIsCollection = curation.type === "collection";
73
- if (!curationIsCollection) {
74
- return curation;
75
- }
76
72
  const curationHasRules = !!curation.boosting.groupings.length ||
77
73
  !!curation.boosting.sortings.length;
78
74
  if (curationHasRules) {
@@ -91,6 +87,7 @@ const useCuration = () => {
91
87
  options.mode === "collection" ? options.collectionHandle : undefined,
92
88
  searchTerm,
93
89
  ]);
90
+ console.log("@@@curation", curation);
94
91
  react_1.default.useEffect(() => {
95
92
  utility_1.debug.log("useCuration", "curation", curation);
96
93
  }, [curation]);
@@ -1 +1 @@
1
- {"version":3,"file":"useCuration.js","sourceRoot":"","sources":["../../../src/hooks/useCuration.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,oCAA+D;AAC/D,wCAAmC;AAE5B,MAAM,WAAW,GAAG,GAEzB,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IACvD,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,iBAAS,GAAE,CAAC;IAEnC,MAAM,QAAQ,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAClC,MAAM,kBAAkB,GACtB,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,UAAU,CAAC;QAExE,MAAM,4BAA4B,GAAG,kBAAkB;aACpD,WAAW,EAAE;aACb,IAAI,EAAE,CAAC;QAE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AA0B,GAAG,gCAC9B,QAAQ,KACX,QAAQ,EAAE,cAAc,CAAC,QAAQ,GAChB,CAAC;YAEpB,OAAO,0BAA0B,CAAC;QACpC,CAAC,CAAC;QAEF,OAAO,QAAQ;YACb,CAAC,CAAC,iBAAiB,CAAC,QAAQ,CAAC;YAC7B,CAAC,CAAC,cAAc;gBAChB,CAAC,CAAC,cAAc;gBAChB,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC,EAAE;QACD,MAAM;QACN,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS;QACpE,UAAU;KACX,CAAC,CAAC;IAEH,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,eAAK,CAAC,GAAG,CAAC,aAAa,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,OAAO;QACL,QAAQ,EAAE,QAAQ;KACnB,CAAC;AACJ,CAAC,CAAC;AAvHW,QAAA,WAAW,eAuHtB","sourcesContent":["import React from \"react\";\n\nimport { ConfigCuration } from \"../types\";\nimport { useReactifySearchContext, useSearch } from \"../hooks\";\nimport { debug } from \"../utility\";\n\nexport const useCuration = (): {\n curation?: ConfigCuration;\n} => {\n const { options, config } = useReactifySearchContext();\n const { searchTerm } = useSearch();\n\n const curation = React.useMemo(() => {\n const handleOrSearchTerm =\n options.mode === \"collection\" ? options.collectionHandle : searchTerm;\n\n const normalisedHandleOrSearchTerm = handleOrSearchTerm\n .toLowerCase()\n .trim();\n\n const globalCuration = config.curations.find((curation) => {\n if (options.mode === \"search\") {\n if (options.market) {\n return curation.id === `global_${options.market}_search`;\n } else {\n return curation.id === \"global_search\";\n }\n }\n if (options.mode === \"instant-search\") {\n if (options.market) {\n return curation.id === `global_${options.market}_search`;\n } else {\n return curation.id === \"global_search\";\n }\n }\n if (options.mode === \"collection\") {\n if (options.market) {\n return curation.id === `global_${options.market}_collection`;\n } else {\n return curation.id === \"global_collection\";\n }\n }\n return false;\n });\n\n const curation = config.curations.find((curation) => {\n if (options.market) {\n if (curation.markets && !curation.markets.includes(options.market)) {\n return false;\n }\n }\n\n const normalisedSearchTerm = curation.searchTerm?.toLowerCase().trim();\n const normalisedCollectionHandle = curation.collectionHandle\n ?.toLowerCase()\n .trim();\n\n if (\"instant-search\" === options.mode) {\n return (\n \"search\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedSearchTerm\n );\n }\n\n if (\"search\" === options.mode) {\n return (\n \"search\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedSearchTerm\n );\n }\n\n if (\"collection\" === options.mode) {\n return (\n \"collection\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedCollectionHandle\n );\n }\n\n return false;\n });\n\n const addGlobalBoosting = (curation: ConfigCuration) => {\n if (!globalCuration) {\n return curation;\n }\n\n const curationIsCollection = curation.type === \"collection\";\n if (!curationIsCollection) {\n return curation;\n }\n\n const curationHasRules =\n !!curation.boosting.groupings.length ||\n !!curation.boosting.sortings.length;\n\n if (curationHasRules) {\n return curation;\n }\n\n const curationWithGlobalBoosting = {\n ...curation,\n boosting: globalCuration.boosting,\n } as ConfigCuration;\n\n return curationWithGlobalBoosting;\n };\n\n return curation\n ? addGlobalBoosting(curation)\n : globalCuration\n ? globalCuration\n : undefined;\n }, [\n config,\n options.mode === \"collection\" ? options.collectionHandle : undefined,\n searchTerm,\n ]);\n\n React.useEffect(() => {\n debug.log(\"useCuration\", \"curation\", curation);\n }, [curation]);\n\n return {\n curation: curation,\n };\n};\n"]}
1
+ {"version":3,"file":"useCuration.js","sourceRoot":"","sources":["../../../src/hooks/useCuration.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,oCAA+D;AAC/D,wCAAmC;AAE5B,MAAM,WAAW,GAAG,GAEzB,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAA,gCAAwB,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AQ,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM;gBACpC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;YAEtC,IAAI,gBAAgB,EAAE,CAAC;gBACrB,OAAO,QAAQ,CAAC;YAClB,CAAC;YAED,MAAM,0BAA0B,GAAG,gCAC9B,QAAQ,KACX,QAAQ,EAAE,cAAc,CAAC,QAAQ,GAChB,CAAC;YAEpB,OAAO,0BAA0B,CAAC;QACpC,CAAC,CAAC;QAEF,OAAO,QAAQ;YACb,CAAC,CAAC,iBAAiB,CAAC,QAAQ,CAAC;YAC7B,CAAC,CAAC,cAAc;gBAChB,CAAC,CAAC,cAAc;gBAChB,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC,EAAE;QACD,MAAM;QACN,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS;QACpE,UAAU;KACX,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IAErC,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,eAAK,CAAC,GAAG,CAAC,aAAa,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,OAAO;QACL,QAAQ,EAAE,QAAQ;KACnB,CAAC;AACJ,CAAC,CAAC;AApHW,QAAA,WAAW,eAoHtB","sourcesContent":["import React from \"react\";\n\nimport { ConfigCuration } from \"../types\";\nimport { useReactifySearchContext, useSearch } from \"../hooks\";\nimport { debug } from \"../utility\";\n\nexport const useCuration = (): {\n curation?: ConfigCuration;\n} => {\n const { options, config } = useReactifySearchContext();\n const { searchTerm } = useSearch();\n\n const curation = React.useMemo(() => {\n const handleOrSearchTerm =\n options.mode === \"collection\" ? options.collectionHandle : searchTerm;\n\n const normalisedHandleOrSearchTerm = handleOrSearchTerm\n .toLowerCase()\n .trim();\n\n const globalCuration = config.curations.find((curation) => {\n if (options.mode === \"search\") {\n if (options.market) {\n return curation.id === `global_${options.market}_search`;\n } else {\n return curation.id === \"global_search\";\n }\n }\n if (options.mode === \"instant-search\") {\n if (options.market) {\n return curation.id === `global_${options.market}_search`;\n } else {\n return curation.id === \"global_search\";\n }\n }\n if (options.mode === \"collection\") {\n if (options.market) {\n return curation.id === `global_${options.market}_collection`;\n } else {\n return curation.id === \"global_collection\";\n }\n }\n return false;\n });\n\n const curation = config.curations.find((curation) => {\n if (options.market) {\n if (curation.markets && !curation.markets.includes(options.market)) {\n return false;\n }\n }\n\n const normalisedSearchTerm = curation.searchTerm?.toLowerCase().trim();\n const normalisedCollectionHandle = curation.collectionHandle\n ?.toLowerCase()\n .trim();\n\n if (\"instant-search\" === options.mode) {\n return (\n \"search\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedSearchTerm\n );\n }\n\n if (\"search\" === options.mode) {\n return (\n \"search\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedSearchTerm\n );\n }\n\n if (\"collection\" === options.mode) {\n return (\n \"collection\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedCollectionHandle\n );\n }\n\n return false;\n });\n\n const addGlobalBoosting = (curation: ConfigCuration) => {\n if (!globalCuration) {\n return curation;\n }\n\n const curationHasRules =\n !!curation.boosting.groupings.length ||\n !!curation.boosting.sortings.length;\n\n if (curationHasRules) {\n return curation;\n }\n\n const curationWithGlobalBoosting = {\n ...curation,\n boosting: globalCuration.boosting,\n } as ConfigCuration;\n\n return curationWithGlobalBoosting;\n };\n\n return curation\n ? addGlobalBoosting(curation)\n : globalCuration\n ? globalCuration\n : undefined;\n }, [\n config,\n options.mode === \"collection\" ? options.collectionHandle : undefined,\n searchTerm,\n ]);\n\n console.log(\"@@@curation\", curation);\n\n React.useEffect(() => {\n debug.log(\"useCuration\", \"curation\", curation);\n }, [curation]);\n\n return {\n curation: curation,\n };\n};\n"]}
@@ -7,4 +7,5 @@ export declare const useFilterSliderProps: (filter: ConfigFilterFacet) => {
7
7
  handleChange: (value: [number | string, number | string]) => void;
8
8
  handleRange: (value: [number, number]) => void;
9
9
  reactSliderProps: ReturnType<typeof useReactSliderProps>;
10
+ query: any;
10
11
  };
@@ -31,6 +31,39 @@ const useFilterSliderProps = (filter) => {
31
31
  const handleRange = react_1.default.useCallback((value) => {
32
32
  setFilterRange([parseInt(`${value[0]}`), parseInt(`${value[1]}`)]);
33
33
  }, [filter]);
34
+ const filterQuery = react_1.default.useMemo(() => {
35
+ if (filterValue[0] === 0 && filterValue[1] === 0) {
36
+ return;
37
+ }
38
+ return {
39
+ query: {
40
+ bool: {
41
+ must: [
42
+ {
43
+ bool: {
44
+ must: [
45
+ {
46
+ match: {
47
+ published: true,
48
+ },
49
+ },
50
+ {
51
+ range: {
52
+ [filter.field]: {
53
+ gte: filterValue[0],
54
+ lte: filterValue[1],
55
+ boost: 2,
56
+ },
57
+ },
58
+ },
59
+ ],
60
+ },
61
+ },
62
+ ],
63
+ },
64
+ }
65
+ };
66
+ }, [filter.field, filterValue[0], filterValue[1]]);
34
67
  react_1.default.useEffect(() => {
35
68
  const handler = (event) => {
36
69
  setFilterValue(event.detail.value);
@@ -47,6 +80,7 @@ const useFilterSliderProps = (filter) => {
47
80
  value: filterValue,
48
81
  range: filterRange,
49
82
  reactSliderProps,
83
+ query: filterQuery,
50
84
  };
51
85
  }, [
52
86
  handleChange,
@@ -55,6 +89,7 @@ const useFilterSliderProps = (filter) => {
55
89
  filterValue,
56
90
  filterRange,
57
91
  reactSliderProps,
92
+ filterQuery,
58
93
  ]);
59
94
  return filterSliderProps;
60
95
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useFilterSliderProps.js","sourceRoot":"","sources":["../../../src/hooks/useFilterSliderProps.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,oCAAkE;AAClE,wCAAmC;AACnC,4EAAyE;AAElE,MAAM,oBAAoB,GAAG,C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CAAC,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,OAAO,GAAG,CACd,KAA+D,EAC/D,EAAE;YACF,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC,CAAC;QACF,MAAM,CAAC,gBAAgB,CACrB,uBAAuB,OAAO,CAAC,OAAO,CAAC,IAAI,WAAW,MAAM,CAAC,MAAM,SAAS,EAC5E,OAAwB,CACzB,CAAC;QAEF,OAAO,GAAG,EAAE,CACV,MAAM,CAAC,mBAAmB,CACxB,uBAAuB,OAAO,CAAC,OAAO,CAAC,IAAI,WAAW,MAAM,CAAC,MAAM,SAAS,EAC5E,OAAwB,CACzB,CAAC;IACN,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAE3B,MAAM,gBAAgB,GAAG,IAAA,yCAAmB,EAC1C,MAAM,EACN,WAAW,EACX,WAAW,EACX,YAAY,CACb,CAAC;IAEF,MAAM,iBAAiB,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAC3C,OAAO;YACL,YAAY;YACZ,WAAW;YACX,MAAM;YACN,KAAK,EAAE,WAAW;YAClB,KAAK,EAAE,WAAW;YAClB,gBAAgB;SACjB,CAAC;IACJ,CAAC,EAAE;QACD,YAAY;QACZ,WAAW;QACX,MAAM;QACN,WAAW;QACX,WAAW;QACX,gBAAgB;KACjB,CAAC,CAAC;IAEH,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAzFW,QAAA,oBAAoB,wBAyF/B","sourcesContent":["import React from \"react\";\nimport { ConfigFilterFacet } from \"../types/config\";\nimport { useAnalytics, useReactifySearchContext } from \"../hooks\";\nimport { debug } from \"../utility\";\nimport { useReactSliderProps } from \"./react-slider/useReactSliderProps\";\n\nexport const useFilterSliderProps = (\n filter: ConfigFilterFacet\n): {\n filter: ConfigFilterFacet;\n value: [number, number];\n range: [number, number];\n handleChange: (value: [number | string, number | string]) => void;\n handleRange: (value: [number, number]) => void;\n reactSliderProps: ReturnType<typeof useReactSliderProps>;\n} => {\n const context = useReactifySearchContext();\n const { track } = useAnalytics();\n\n const urlSearchParam = new URLSearchParams(window.location.search);\n const [filterValue, setFilterValue] = React.useState<[number, number]>(\n JSON.parse(urlSearchParam.get(filter.handle) ?? \"[0,0]\")\n );\n const [filterRange, setFilterRange] = React.useState<[number, number]>([\n 0, 0,\n ]);\n\n const handleChange = React.useCallback(\n (value: [number | string, number | string]) => {\n debug.log(\"useFilterSliderProps\", \"handleChange[value]\", value);\n\n setFilterValue([parseInt(`${value[0]}`), parseInt(`${value[1]}`)]);\n\n track({\n eventName: \"filterChange\",\n payload: {\n name: filter.name,\n value: `${value[0]}:${value[1]}`,\n },\n });\n },\n [filter]\n );\n\n const handleRange = React.useCallback(\n (value: [number | string, number | string]) => {\n setFilterRange([parseInt(`${value[0]}`), parseInt(`${value[1]}`)]);\n },\n [filter]\n );\n\n React.useEffect(() => {\n const handler = (\n event: CustomEvent<{ handle: string; value: [number, number] }>\n ) => {\n setFilterValue(event.detail.value);\n };\n window.addEventListener(\n `@usereactify/search:${context.options.mode}:filter:${filter.handle}:update`,\n handler as EventListener\n );\n\n return () =>\n window.removeEventListener(\n `@usereactify/search:${context.options.mode}:filter:${filter.handle}:update`,\n handler as EventListener\n );\n }, [context.options.mode]);\n\n const reactSliderProps = useReactSliderProps(\n filter,\n filterValue,\n filterRange,\n handleChange\n );\n\n const filterSliderProps = React.useMemo(() => {\n return {\n handleChange,\n handleRange,\n filter,\n value: filterValue,\n range: filterRange,\n reactSliderProps,\n };\n }, [\n handleChange,\n handleRange,\n filter,\n filterValue,\n filterRange,\n reactSliderProps,\n ]);\n\n return filterSliderProps;\n};\n"]}
1
+ {"version":3,"file":"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C,OAAO,CAAC,IAAI,WAAW,MAAM,CAAC,MAAM,SAAS,EAC5E,OAAwB,CACzB,CAAC;QAEF,OAAO,GAAG,EAAE,CACV,MAAM,CAAC,mBAAmB,CACxB,uBAAuB,OAAO,CAAC,OAAO,CAAC,IAAI,WAAW,MAAM,CAAC,MAAM,SAAS,EAC5E,OAAwB,CACzB,CAAC;IACN,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAE3B,MAAM,gBAAgB,GAAG,IAAA,yCAAmB,EAC1C,MAAM,EACN,WAAW,EACX,WAAW,EACX,YAAY,CACb,CAAC;IAEF,MAAM,iBAAiB,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAC3C,OAAO;YACL,YAAY;YACZ,WAAW;YACX,MAAM;YACN,KAAK,EAAE,WAAW;YAClB,KAAK,EAAE,WAAW;YAClB,gBAAgB;YAChB,KAAK,EAAE,WAAW;SACnB,CAAC;IACJ,CAAC,EAAE;QACD,YAAY;QACZ,WAAW;QACX,MAAM;QACN,WAAW;QACX,WAAW;QACX,gBAAgB;QAChB,WAAW;KACZ,CAAC,CAAC;IAEH,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AA/HW,QAAA,oBAAoB,wBA+H/B","sourcesContent":["import React from \"react\";\nimport { ConfigFilterFacet } from \"../types/config\";\nimport { useAnalytics, useReactifySearchContext } from \"../hooks\";\nimport { debug } from \"../utility\";\nimport { useReactSliderProps } from \"./react-slider/useReactSliderProps\";\n\nexport const useFilterSliderProps = (\n filter: ConfigFilterFacet\n): {\n filter: ConfigFilterFacet;\n value: [number, number];\n range: [number, number];\n handleChange: (value: [number | string, number | string]) => void;\n handleRange: (value: [number, number]) => void;\n reactSliderProps: ReturnType<typeof useReactSliderProps>;\n query: any;\n} => {\n const context = useReactifySearchContext();\n const { track } = useAnalytics();\n\n const urlSearchParam = new URLSearchParams(window.location.search);\n const [filterValue, setFilterValue] = React.useState<[number, number]>(\n JSON.parse(urlSearchParam.get(filter.handle) ?? \"[0,0]\")\n );\n const [filterRange, setFilterRange] = React.useState<[number, number]>([\n 0, 0,\n ]);\n\n const handleChange = React.useCallback(\n (value: [number | string, number | string]) => {\n debug.log(\"useFilterSliderProps\", \"handleChange[value]\", value);\n\n setFilterValue([parseInt(`${value[0]}`), parseInt(`${value[1]}`)]);\n\n track({\n eventName: \"filterChange\",\n payload: {\n name: filter.name,\n value: `${value[0]}:${value[1]}`,\n },\n });\n },\n [filter]\n );\n\n const handleRange = React.useCallback(\n (value: [number | string, number | string]) => {\n setFilterRange([parseInt(`${value[0]}`), parseInt(`${value[1]}`)]);\n },\n [filter]\n );\n\n const filterQuery = React.useMemo<any | undefined>(() => {\n if (filterValue[0] === 0 && filterValue[1] === 0) {\n return;\n }\n\n return {\n query: {\n bool: {\n must: [\n {\n bool: {\n must: [\n {\n match: {\n published: true,\n },\n },\n {\n range: {\n [filter.field]: {\n gte: filterValue[0],\n lte: filterValue[1],\n boost: 2,\n },\n },\n },\n ],\n },\n },\n ],\n },\n }\n };\n }, [filter.field, filterValue[0], filterValue[1]]);\n\n React.useEffect(() => {\n const handler = (\n event: CustomEvent<{ handle: string; value: [number, number] }>\n ) => {\n setFilterValue(event.detail.value);\n };\n window.addEventListener(\n `@usereactify/search:${context.options.mode}:filter:${filter.handle}:update`,\n handler as EventListener\n );\n\n return () =>\n window.removeEventListener(\n `@usereactify/search:${context.options.mode}:filter:${filter.handle}:update`,\n handler as EventListener\n );\n }, [context.options.mode]);\n\n const reactSliderProps = useReactSliderProps(\n filter,\n filterValue,\n filterRange,\n handleChange\n );\n\n const filterSliderProps = React.useMemo(() => {\n return {\n handleChange,\n handleRange,\n filter,\n value: filterValue,\n range: filterRange,\n reactSliderProps,\n query: filterQuery,\n };\n }, [\n handleChange,\n handleRange,\n filter,\n filterValue,\n filterRange,\n reactSliderProps,\n filterQuery,\n ]);\n\n return filterSliderProps;\n};\n"]}
@@ -61,10 +61,6 @@ const getCuration = (options) => {
61
61
  if (!globalCuration) {
62
62
  return curation;
63
63
  }
64
- const curationIsCollection = curation.type === "collection";
65
- if (!curationIsCollection) {
66
- return curation;
67
- }
68
64
  const curationHasRules = !!curation.boosting.groupings.length ||
69
65
  !!curation.boosting.sortings.length;
70
66
  if (curationHasRules) {
@@ -1 +1 @@
1
- {"version":3,"file":"curation.js","sourceRoot":"","sources":["../../../src/utility/curation.ts"],"names":[],"mappings":";;;AAGO,MAAM,WAAW,GAAG,CAAC,OAI3B,EAAE,EAAE;;IACH,MAAM,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAA,OAAO,CAAC,UAAU,mCAAI,EAAE,CAAC;IAEjI,MAAM,4BAA4B,GAAG,kBAAkB;SACpD,WAAW,EAAE;SACb,IAAI,EAAE,CAAC;IAEV,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;QAChE,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACvC,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;gBAC5B,OAAO,QAAQ,CAAC,EAAE,KAAK,UAAU,OAAO,CAAC,QAAQ,CAAC,MAAM,SAAS,CAAC;YACpE,CAAC;iBAAM,CAAC;gBACN,OAAO,QAAQ,CAAC,EAAE,KAAK,eAAe,CAAC;YACzC,CAAC;QACH,CAAC;QACD,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;YAC/C,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;gBAC5B,OAAO,QAAQ,CAAC,EAAE,KAAK,UAAU,OAAO,CAAC,QAAQ,CAAC,MAAM,SAAS,CAAC;YACpE,CAAC;iBAAM,CAAC;gB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AAI;gBAC1B,4BAA4B,KAAK,oBAAoB,CACtD,CAAC;QACJ,CAAC;QAED,IAAI,YAAY,KAAK,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YAC3C,OAAO,CACL,YAAY,KAAK,QAAQ,CAAC,IAAI;gBAC9B,4BAA4B,KAAK,0BAA0B,CAC5D,CAAC;QACJ,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,MAAM,iBAAiB,GAAG,CAAC,QAAwB,EAAE,EAAE;QACrD,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,MAAM,oBAAoB,GAAG,QAAQ,CAAC,IAAI,KAAK,YAAY,CAAC;QAC5D,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC1B,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,MAAM,gBAAgB,GACpB,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM;YACpC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;QAEtC,IAAI,gBAAgB,EAAE,CAAC;YACrB,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,MAAM,0BAA0B,GAAG,gCAC9B,QAAQ,KACX,QAAQ,EAAE,cAAc,CAAC,QAAQ,GAChB,CAAC;QAEpB,OAAO,0BAA0B,CAAC;IACpC,CAAC,CAAC;IAEF,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IAED,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAA;AA3GY,QAAA,WAAW,eA2GvB","sourcesContent":["import { ReactifySearchProviderProps } from \"../components\";\nimport { Config, ConfigCuration } from \"../types\";\n\nexport const getCuration = (options: {\n provider: ReactifySearchProviderProps;\n config: Config;\n searchTerm?: string;\n}) => {\n const handleOrSearchTerm = options.provider.mode === \"collection\" ? options.provider.collectionHandle : options.searchTerm ?? \"\";\n\n const normalisedHandleOrSearchTerm = handleOrSearchTerm\n .toLowerCase()\n .trim();\n\n const globalCuration = options.config.curations.find((curation) => {\n if (options.provider.mode === \"search\") {\n if (options.provider.market) {\n return curation.id === `global_${options.provider.market}_search`;\n } else {\n return curation.id === \"global_search\";\n }\n }\n if (options.provider.mode === \"instant-search\") {\n if (options.provider.market) {\n return curation.id === `global_${options.provider.market}_search`;\n } else {\n return curation.id === \"global_search\";\n }\n }\n if (options.provider.mode === \"collection\") {\n if (options.provider.market) {\n return curation.id === `global_${options.provider.market}_collection`;\n } else {\n return curation.id === \"global_collection\";\n }\n }\n return false;\n });\n\n const curation = options.config.curations.find((curation) => {\n if (options.provider.market) {\n if (curation.markets && !curation.markets.includes(options.provider.market)) {\n return false;\n }\n }\n\n const normalisedSearchTerm = curation.searchTerm?.toLowerCase().trim();\n const normalisedCollectionHandle = curation.collectionHandle\n ?.toLowerCase()\n .trim();\n\n if (\"instant-search\" === options.provider.mode) {\n return (\n \"search\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedSearchTerm\n );\n }\n\n if (\"search\" === options.provider.mode) {\n return (\n \"search\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedSearchTerm\n );\n }\n\n if (\"collection\" === options.provider.mode) {\n return (\n \"collection\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedCollectionHandle\n );\n }\n\n return false;\n });\n\n const addGlobalBoosting = (curation: ConfigCuration) => {\n if (!globalCuration) {\n return curation;\n }\n\n const curationIsCollection = curation.type === \"collection\";\n if (!curationIsCollection) {\n return curation;\n }\n\n const curationHasRules =\n !!curation.boosting.groupings.length ||\n !!curation.boosting.sortings.length;\n\n if (curationHasRules) {\n return curation;\n }\n\n const curationWithGlobalBoosting = {\n ...curation,\n boosting: globalCuration.boosting,\n } as ConfigCuration;\n\n return curationWithGlobalBoosting;\n };\n\n if (curation) {\n return addGlobalBoosting(curation);\n }\n\n if (globalCuration) {\n return globalCuration;\n }\n\n return undefined;\n}"]}
1
+ {"version":3,"file":"curation.js","sourceRoot":"","sources":["../../../src/utility/curation.ts"],"names":[],"mappings":";;;AAGO,MAAM,WAAW,GAAG,CAAC,OAI3B,EAAE,EAAE;;IACH,MAAM,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAA,OAAO,CAAC,UAAU,mCAAI,EAAE,CAAC;IAEjI,MAAM,4BAA4B,GAAG,kBAAkB;SACpD,WAAW,EAAE;SACb,IAAI,EAAE,CAAC;IAEV,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;QAChE,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACvC,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;gBAC5B,OAAO,QAAQ,CAAC,EAAE,KAAK,UAAU,OAAO,CAAC,QAAQ,CAAC,MAAM,SAAS,CAAC;YACpE,CAAC;iBAAM,CAAC;gBACN,OAAO,QAAQ,CAAC,EAAE,KAAK,eAAe,CAAC;YACzC,CAAC;QACH,CAAC;QACD,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;YAC/C,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;gBAC5B,OAAO,QAAQ,CAAC,EAAE,KAAK,UAAU,OAAO,CAAC,QAAQ,CAAC,MAAM,SAAS,CAAC;YACpE,CAAC;iBAAM,CAAC;gBACN,OAAO,QAAQ,CAAC,EAAE,KAAK,eAAe,CAAC;YACzC,CAAC;QACH,CAAC;QACD,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI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AI,EAAE,CAAC;YAC3C,OAAO,CACL,YAAY,KAAK,QAAQ,CAAC,IAAI;gBAC9B,4BAA4B,KAAK,0BAA0B,CAC5D,CAAC;QACJ,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,MAAM,iBAAiB,GAAG,CAAC,QAAwB,EAAE,EAAE;QACrD,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,MAAM,gBAAgB,GACpB,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM;YACpC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;QAEtC,IAAI,gBAAgB,EAAE,CAAC;YACrB,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,MAAM,0BAA0B,GAAG,gCAC9B,QAAQ,KACX,QAAQ,EAAE,cAAc,CAAC,QAAQ,GAChB,CAAC;QAEpB,OAAO,0BAA0B,CAAC;IACpC,CAAC,CAAC;IAEF,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IAED,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAA;AAtGY,QAAA,WAAW,eAsGvB","sourcesContent":["import { ReactifySearchProviderProps } from \"../components\";\nimport { Config, ConfigCuration } from \"../types\";\n\nexport const getCuration = (options: {\n provider: ReactifySearchProviderProps;\n config: Config;\n searchTerm?: string;\n}) => {\n const handleOrSearchTerm = options.provider.mode === \"collection\" ? options.provider.collectionHandle : options.searchTerm ?? \"\";\n\n const normalisedHandleOrSearchTerm = handleOrSearchTerm\n .toLowerCase()\n .trim();\n\n const globalCuration = options.config.curations.find((curation) => {\n if (options.provider.mode === \"search\") {\n if (options.provider.market) {\n return curation.id === `global_${options.provider.market}_search`;\n } else {\n return curation.id === \"global_search\";\n }\n }\n if (options.provider.mode === \"instant-search\") {\n if (options.provider.market) {\n return curation.id === `global_${options.provider.market}_search`;\n } else {\n return curation.id === \"global_search\";\n }\n }\n if (options.provider.mode === \"collection\") {\n if (options.provider.market) {\n return curation.id === `global_${options.provider.market}_collection`;\n } else {\n return curation.id === \"global_collection\";\n }\n }\n return false;\n });\n\n const curation = options.config.curations.find((curation) => {\n if (options.provider.market) {\n if (curation.markets && !curation.markets.includes(options.provider.market)) {\n return false;\n }\n }\n\n const normalisedSearchTerm = curation.searchTerm?.toLowerCase().trim();\n const normalisedCollectionHandle = curation.collectionHandle\n ?.toLowerCase()\n .trim();\n\n if (\"instant-search\" === options.provider.mode) {\n return (\n \"search\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedSearchTerm\n );\n }\n\n if (\"search\" === options.provider.mode) {\n return (\n \"search\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedSearchTerm\n );\n }\n\n if (\"collection\" === options.provider.mode) {\n return (\n \"collection\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedCollectionHandle\n );\n }\n\n return false;\n });\n\n const addGlobalBoosting = (curation: ConfigCuration) => {\n if (!globalCuration) {\n return curation;\n }\n\n const curationHasRules =\n !!curation.boosting.groupings.length ||\n !!curation.boosting.sortings.length;\n\n if (curationHasRules) {\n return curation;\n }\n\n const curationWithGlobalBoosting = {\n ...curation,\n boosting: globalCuration.boosting,\n } as ConfigCuration;\n\n return curationWithGlobalBoosting;\n };\n\n if (curation) {\n return addGlobalBoosting(curation);\n }\n\n if (globalCuration) {\n return globalCuration;\n }\n\n return undefined;\n}"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@usereactify/search",
3
3
  "description": "React UI library for Reactify Search",
4
- "version": "5.55.0-beta.2",
4
+ "version": "5.55.0",
5
5
  "license": "MIT",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",