@usereactify/search 5.55.0 → 5.55.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
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.2](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.55.1...release-v5.55.2) (2024-11-27)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * change customQuery from object to function that returns object ([4190604](https://bitbucket.org/usereactify/reactify-search-ui/commit/4190604e1ddc0ad4ffea79ead41580955563c9bc))
11
+
12
+ ### [5.55.1](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.55.0...release-v5.55.1) (2024-11-27)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * prevent call to window on load ([4628557](https://bitbucket.org/usereactify/reactify-search-ui/commit/462855708bddc4ff72003ed5a0b541ed3447e5f2))
18
+
5
19
  ## [5.55.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.54.0...release-v5.55.0) (2024-11-25)
6
20
 
7
21
 
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",
4
+ "version": "5.55.2",
5
5
  "license": "MIT",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",
@@ -136,7 +136,7 @@ const FilterSlider = (props) => {
136
136
  },
137
137
  },
138
138
  },
139
- }), customQuery: filterSliderProps.query, render: (reactivesearchFilterProps) => {
139
+ }), customQuery: () => filterSliderProps.query, render: (reactivesearchFilterProps) => {
140
140
  var _a, _b, _c, _d;
141
141
  if (!props.showEmptyFilters &&
142
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) ===
@@ -1 +1 @@
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,OAAO,8BAAC,YAAY,oBAAK,KAAK,EAAI,CAAC;IACrC,CAAC;IAED,oEAAoE;IACpE,IAAI,OAAO,KAAK,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACzC,OAAO,8BAAC,iBAAiB,oBAAK,KAAK,EAAI,CAAC;IAC1C,CAAC;IAED,OAAO,CAAC,IAAI,CACV,6BAA6B,KAAK,CAAC,MAAM,CAAC,WAAW,qBAAqB,CAC3E,CAAC;I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,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"]}
1
+ {"version":3,"file":"Filter.js","sourceRoot":"","sources":["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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"]}
@@ -87,7 +87,6 @@ const useCuration = () => {
87
87
  options.mode === "collection" ? options.collectionHandle : undefined,
88
88
  searchTerm,
89
89
  ]);
90
- console.log("@@@curation", curation);
91
90
  react_1.default.useEffect(() => {
92
91
  utility_1.debug.log("useCuration", "curation", curation);
93
92
  }, [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;QAEV,MAAM,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;YACxD,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC9B,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;oBACnB,OAAO,QAAQ,CAAC,EAAE,KAAK,UAAU,OAAO,CAAC,MAAM,SAAS,CAAC;gBAC3D,CAAC;qBAAM,CAAC;oBACN,OAAO,QAAQ,CAAC,EAAE,KAAK,eAAe,CAAC;gBACzC,CAAC;YACH,CAAC;YACD,IAAI,OAAO,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;gBACtC,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;oBACnB,OAAO,QAAQ,CAAC,EAAE,KAAK,UAAU,OAAO,CAAC,MAAM,SAAS,CAAC;gBAC3D,CAAC;qBAAM,CAAC;oBACN,OAAO,QAAQ,CAAC,E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A,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"]}
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;QAEV,MAAM,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;YACxD,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC9B,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;oBACnB,OAAO,QAAQ,CAAC,EAAE,KAAK,UAAU,OAAO,CAAC,MAAM,SAAS,CAAC;gBAC3D,CAAC;qBAAM,CAAC;oBACN,OAAO,QAAQ,CAAC,EAAE,KAAK,eAAe,CAAC;gBACzC,CAAC;YACH,CAAC;Y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,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;AAlHW,QAAA,WAAW,eAkHtB","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 React.useEffect(() => {\n debug.log(\"useCuration\", \"curation\", curation);\n }, [curation]);\n\n return {\n curation: curation,\n };\n};\n"]}
@@ -12,7 +12,7 @@ const useFilterSliderProps = (filter) => {
12
12
  var _a;
13
13
  const context = (0, hooks_1.useReactifySearchContext)();
14
14
  const { track } = (0, hooks_1.useAnalytics)();
15
- const urlSearchParam = new URLSearchParams(window.location.search);
15
+ const urlSearchParam = new URLSearchParams(typeof window === "undefined" ? "" : window.location.search);
16
16
  const [filterValue, setFilterValue] = react_1.default.useState(JSON.parse((_a = urlSearchParam.get(filter.handle)) !== null && _a !== void 0 ? _a : "[0,0]"));
17
17
  const [filterRange, setFilterRange] = react_1.default.useState([
18
18
  0, 0,
@@ -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,CAClC,MAAyB,EASzB,EAAE;;IACF,MAAM,OAAO,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAC3C,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,oBAAY,GAAE,CAAC;IAEjC,MAAM,cAAc,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACnE,MAAM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AEF,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"]}
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,CAClC,MAAyB,EASzB,EAAE;;IACF,MAAM,OAAO,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAC3C,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,oBAAY,GAAE,CAAC;IAEjC,MAAM,cAAc,GAAG,IAAI,eAAe,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC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C1C,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(typeof window === \"undefined\" ? \"\" : 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"]}
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",
4
+ "version": "5.55.2",
5
5
  "license": "MIT",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",