@usereactify/search 5.56.2 → 5.56.3
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 +7 -0
- package/dist/package.json +1 -1
- package/dist/src/components/Filter/Filter.js +1 -1
- package/dist/src/components/Filter/Filter.js.map +1 -1
- package/dist/src/hooks/useFilterSliderProps.js +1 -1
- package/dist/src/hooks/useFilterSliderProps.js.map +1 -1
- package/dist/src/utility/props.js +1 -1
- package/dist/src/utility/props.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [5.56.3](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.56.2...release-v5.56.3) (2025-01-01)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* generate query for sliders using custom query for SSR loading and native query for realtime ([d5f36bb](https://bitbucket.org/usereactify/reactify-search-ui/commit/d5f36bb34901c4a0258555385fe9f95260f1c615))
|
|
11
|
+
|
|
5
12
|
### [5.56.2](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.56.1...release-v5.56.2) (2025-01-01)
|
|
6
13
|
|
|
7
14
|
|
package/dist/package.json
CHANGED
|
@@ -125,7 +125,7 @@ const FilterSlider = (props) => {
|
|
|
125
125
|
}, props.filter);
|
|
126
126
|
const filterSliderProps = (0, hooks_1.useFilterSliderProps)(props.filter);
|
|
127
127
|
const reactiveProps = (0, props_1.getPropsFilterSlider)(props.filter, "", filterSliderProps.value);
|
|
128
|
-
return (react_1.default.createElement(ReactiveComponent_1.default, Object.assign({}, sharedProps, { defaultQuery: () => reactiveProps.defaultQuery,
|
|
128
|
+
return (react_1.default.createElement(ReactiveComponent_1.default, Object.assign({}, sharedProps, { defaultQuery: () => reactiveProps.defaultQuery, value: filterSliderProps.value, render: (reactivesearchFilterProps) => {
|
|
129
129
|
return (react_1.default.createElement(FilterSliderInner, Object.assign({}, props, { filterSliderProps: filterSliderProps, customQuery: reactiveProps.customQuery, reactivesearchFilterProps: reactivesearchFilterProps })));
|
|
130
130
|
} })));
|
|
131
131
|
};
|
|
@@ -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,+CAAoH;AACpH,sFAAmF;AA0B5E,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,K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CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@usereactify/search-internals/lib/components/basic/ReactiveComponent\";\nimport MultiList from \"@usereactify/search-internals/lib/components/list/MultiList\";\nimport SingleList from \"@usereactify/search-internals/lib/components/list/SingleList\";\nimport SingleRange from \"@usereactify/search-internals/lib/components/range/SingleRange\";\nimport MultiRange from \"@usereactify/search-internals/lib/components/range/MultiRange\";\n\nimport type {\n ConfigFilterFacet,\n ReactivesearchFilterListProps,\n} from \"../../types\";\nimport {\n useFilterListProps,\n useFilterRangeProps,\n useFilterSliderProps,\n useFilters,\n useReactifySearchContext,\n} from \"../../hooks\";\nimport {\n ExampleFilterList,\n ExampleFilterRange,\n ExampleFilterSlider,\n} from \"../../components\";\nimport { getPropsFilterList, getPropsFilterRange, getPropsFilterSlider, getPropsShared } from \"../../utility/props\";\nimport { useReactSliderProps } from \"../../hooks/react-slider/useReactSliderProps\";\n\nexport type FilterProps = {\n /** The filter option being rendered */\n filter: ConfigFilterFacet;\n /** Render method for List filters */\n renderFilterList?: React.FC<{\n filter: ConfigFilterFacet;\n filterListProps: ReturnType<typeof useFilterListProps>;\n }>;\n /** Render method for Range filters */\n renderFilterRange?: React.FC<{\n filter: ConfigFilterFacet;\n filterRangeProps: ReturnType<typeof useFilterRangeProps>;\n }>;\n\n /** Render method for Slider filters */\n renderFilterSlider?: React.FC<{\n filter: ConfigFilterFacet;\n filterSliderProps: ReturnType<typeof useFilterSliderProps>;\n reactSliderProps: ReturnType<typeof useReactSliderProps>;\n }>;\n /** Show filters even when no options are available */\n showEmptyFilters?: boolean;\n};\n\nexport const Filter: React.FC<FilterProps> = (props) => {\n if (\"single\" === props.filter.displayType) {\n if (\"range\" === props.filter.displayView) {\n return <FilterRangeSingle {...props} />;\n }\n return <FilterSingleList {...props} />;\n }\n\n if (\"multi\" === props.filter.displayType) {\n if (\"range\" === props.filter.displayView) {\n return <FilterRangeMulti {...props} />;\n }\n return <FilterMultiList {...props} />;\n }\n\n if (\"slider\" === props.filter.displayType) {\n return <FilterSlider {...props} />;\n }\n\n // TODO: Legacy range filter, migrate to new single and multi ranges\n if (\"range\" === props.filter.displayType) {\n return <FilterRangeSingle {...props} />;\n }\n\n console.warn(\n `filter with display type \"${props.filter.displayType}\" not yet supported`\n );\n\n return null;\n};\n\nconst FilterSingleList: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterList(props.filter);\n\n return (\n <SingleList\n {...sharedProps}\n {...reactiveProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n )}\n />\n );\n};\n\nconst FilterMultiList: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterList(props.filter);\n\n return (\n <MultiList\n {...sharedProps}\n {...reactiveProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n )}\n />\n );\n};\n\nconst FilterRangeSingle: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterRange(props.filter);\n\n const filterRangeProps = useFilterRangeProps(props.filter);\n\n const RenderRangeComponent = props.renderFilterRange ?? ExampleFilterRange;\n\n return (\n <>\n <div\n style={{\n display: \"none\",\n }}\n >\n <SingleRange\n {...sharedProps}\n {...reactiveProps}\n value={filterRangeProps.values[0]}\n onChange={filterRangeProps.handleChange}\n />\n </div>\n <RenderRangeComponent\n filterRangeProps={filterRangeProps}\n filter={props.filter}\n />\n </>\n );\n};\n\nconst FilterRangeMulti: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterRange(props.filter);\n\n const filterRangeProps = useFilterRangeProps(props.filter);\n\n const RenderRangeComponent = props.renderFilterRange ?? ExampleFilterRange;\n\n return (\n <>\n <div\n style={{\n display: \"none\",\n }}\n >\n <MultiRange\n {...sharedProps}\n {...reactiveProps}\n value={filterRangeProps.values}\n // @note: onChange handler must be defined for controlled component to work correctly\n onChange={() => {}}\n onValueChange={(values) => {\n if (values.length === 0) {\n filterRangeProps.handleClear();\n }\n }}\n />\n </div>\n <RenderRangeComponent\n filterRangeProps={filterRangeProps}\n filter={props.filter}\n />\n </>\n );\n};\n\nconst FilterSlider: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const filterSliderProps = useFilterSliderProps(props.filter);\n const reactiveProps = getPropsFilterSlider(props.filter, \"\", filterSliderProps.value);\n\n return (\n <ReactiveComponent\n {...sharedProps}\n defaultQuery={() => reactiveProps.defaultQuery}\n customQuery={() => reactiveProps.customQuery}\n render={(reactivesearchFilterProps) => {\n return (\n <FilterSliderInner\n {...props}\n filterSliderProps={filterSliderProps}\n customQuery={reactiveProps.customQuery}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n );\n }}\n />\n );\n};\n\n// inner component exists only so we can use memos in reactivesearch render functions\nconst FilterSliderInner: React.FC<\n FilterProps & { reactivesearchFilterProps: any; filterSliderProps: ReturnType<typeof useFilterSliderProps>; customQuery: any; }\n> = (props) => {\n const {\n filter,\n renderFilterSlider,\n filterSliderProps,\n reactivesearchFilterProps,\n ...otherProps\n } = props;\n\n const filterRange: [number, number] = [\n reactivesearchFilterProps.aggregations?.min?.value ?? 0,\n reactivesearchFilterProps.aggregations?.max?.value ?? 0,\n ];\n\n const reactSliderProps = useReactSliderProps(\n filter,\n filterSliderProps.value,\n filterRange,\n filterSliderProps.handleChange,\n );\n\n React.useEffect(() => {\n if (!props.customQuery) {\n return;\n }\n\n props.reactivesearchFilterProps.setQuery({\n query: props.customQuery,\n value: filterSliderProps.value,\n });\n }, [filterSliderProps.value]);\n\n const RenderSliderComponent = props.renderFilterSlider ?? ExampleFilterSlider;\n\n return (\n <RenderSliderComponent\n filterSliderProps={filterSliderProps}\n reactSliderProps={reactSliderProps}\n filter={filter}\n {...otherProps}\n />\n );\n};\n\n// inner component exists only so we can use memos in reactivesearch render functions\nconst FilterListInner: React.FC<\n FilterProps & { reactivesearchFilterProps: ReactivesearchFilterListProps }\n> = (props) => {\n const { filter, renderFilterList, reactivesearchFilterProps, ...otherProps } =\n props;\n\n const filterListProps = useFilterListProps(filter, reactivesearchFilterProps);\n\n // hide entire filter when no options available\n if (!props.showEmptyFilters && 0 === filterListProps.options.length) {\n return null;\n }\n\n const RenderListComponent = props.renderFilterList ?? ExampleFilterList;\n\n return (\n <RenderListComponent\n filterListProps={filterListProps}\n filter={filter}\n {...otherProps}\n />\n );\n};\n"]}
|
|
1
|
+
{"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,+CAAoH;AACpH,sFAAmF;AA0B5E,MAAM,MA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AAqB,kBACpB,iBAAiB,EAAE,iBAAiB,EACpC,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,MAAM,IACV,UAAU,EACd,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,qFAAqF;AACrF,MAAM,eAAe,GAEjB,CAAC,KAAK,EAAE,EAAE;;IACZ,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,yBAAyB,KACzD,KAAK,EADyD,UAAU,UACxE,KAAK,EADD,2DAAsE,CACrE,CAAC;IAER,MAAM,eAAe,GAAG,IAAA,0BAAkB,EAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;IAE9E,+CAA+C;IAC/C,IAAI,CAAC,KAAK,CAAC,gBAAgB,IAAI,CAAC,KAAK,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACpE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,mBAAmB,GAAG,MAAA,KAAK,CAAC,gBAAgB,mCAAI,8BAAiB,CAAC;IAExE,OAAO,CACL,8BAAC,mBAAmB,kBAClB,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM,IACV,UAAU,EACd,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@usereactify/search-internals/lib/components/basic/ReactiveComponent\";\nimport MultiList from \"@usereactify/search-internals/lib/components/list/MultiList\";\nimport SingleList from \"@usereactify/search-internals/lib/components/list/SingleList\";\nimport SingleRange from \"@usereactify/search-internals/lib/components/range/SingleRange\";\nimport MultiRange from \"@usereactify/search-internals/lib/components/range/MultiRange\";\n\nimport type {\n ConfigFilterFacet,\n ReactivesearchFilterListProps,\n} from \"../../types\";\nimport {\n useFilterListProps,\n useFilterRangeProps,\n useFilterSliderProps,\n useFilters,\n useReactifySearchContext,\n} from \"../../hooks\";\nimport {\n ExampleFilterList,\n ExampleFilterRange,\n ExampleFilterSlider,\n} from \"../../components\";\nimport { getPropsFilterList, getPropsFilterRange, getPropsFilterSlider, getPropsShared } from \"../../utility/props\";\nimport { useReactSliderProps } from \"../../hooks/react-slider/useReactSliderProps\";\n\nexport type FilterProps = {\n /** The filter option being rendered */\n filter: ConfigFilterFacet;\n /** Render method for List filters */\n renderFilterList?: React.FC<{\n filter: ConfigFilterFacet;\n filterListProps: ReturnType<typeof useFilterListProps>;\n }>;\n /** Render method for Range filters */\n renderFilterRange?: React.FC<{\n filter: ConfigFilterFacet;\n filterRangeProps: ReturnType<typeof useFilterRangeProps>;\n }>;\n\n /** Render method for Slider filters */\n renderFilterSlider?: React.FC<{\n filter: ConfigFilterFacet;\n filterSliderProps: ReturnType<typeof useFilterSliderProps>;\n reactSliderProps: ReturnType<typeof useReactSliderProps>;\n }>;\n /** Show filters even when no options are available */\n showEmptyFilters?: boolean;\n};\n\nexport const Filter: React.FC<FilterProps> = (props) => {\n if (\"single\" === props.filter.displayType) {\n if (\"range\" === props.filter.displayView) {\n return <FilterRangeSingle {...props} />;\n }\n return <FilterSingleList {...props} />;\n }\n\n if (\"multi\" === props.filter.displayType) {\n if (\"range\" === props.filter.displayView) {\n return <FilterRangeMulti {...props} />;\n }\n return <FilterMultiList {...props} />;\n }\n\n if (\"slider\" === props.filter.displayType) {\n return <FilterSlider {...props} />;\n }\n\n // TODO: Legacy range filter, migrate to new single and multi ranges\n if (\"range\" === props.filter.displayType) {\n return <FilterRangeSingle {...props} />;\n }\n\n console.warn(\n `filter with display type \"${props.filter.displayType}\" not yet supported`\n );\n\n return null;\n};\n\nconst FilterSingleList: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterList(props.filter);\n\n return (\n <SingleList\n {...sharedProps}\n {...reactiveProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n )}\n />\n );\n};\n\nconst FilterMultiList: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterList(props.filter);\n\n return (\n <MultiList\n {...sharedProps}\n {...reactiveProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n )}\n />\n );\n};\n\nconst FilterRangeSingle: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterRange(props.filter);\n\n const filterRangeProps = useFilterRangeProps(props.filter);\n\n const RenderRangeComponent = props.renderFilterRange ?? ExampleFilterRange;\n\n return (\n <>\n <div\n style={{\n display: \"none\",\n }}\n >\n <SingleRange\n {...sharedProps}\n {...reactiveProps}\n value={filterRangeProps.values[0]}\n onChange={filterRangeProps.handleChange}\n />\n </div>\n <RenderRangeComponent\n filterRangeProps={filterRangeProps}\n filter={props.filter}\n />\n </>\n );\n};\n\nconst FilterRangeMulti: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const reactiveProps = getPropsFilterRange(props.filter);\n\n const filterRangeProps = useFilterRangeProps(props.filter);\n\n const RenderRangeComponent = props.renderFilterRange ?? ExampleFilterRange;\n\n return (\n <>\n <div\n style={{\n display: \"none\",\n }}\n >\n <MultiRange\n {...sharedProps}\n {...reactiveProps}\n value={filterRangeProps.values}\n // @note: onChange handler must be defined for controlled component to work correctly\n onChange={() => {}}\n onValueChange={(values) => {\n if (values.length === 0) {\n filterRangeProps.handleClear();\n }\n }}\n />\n </div>\n <RenderRangeComponent\n filterRangeProps={filterRangeProps}\n filter={props.filter}\n />\n </>\n );\n};\n\nconst FilterSlider: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared({\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n }, props.filter);\n const filterSliderProps = useFilterSliderProps(props.filter);\n const reactiveProps = getPropsFilterSlider(props.filter, \"\", filterSliderProps.value);\n\n return (\n <ReactiveComponent\n {...sharedProps}\n defaultQuery={() => reactiveProps.defaultQuery}\n value={filterSliderProps.value}\n render={(reactivesearchFilterProps) => {\n return (\n <FilterSliderInner\n {...props}\n filterSliderProps={filterSliderProps}\n customQuery={reactiveProps.customQuery}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n );\n }}\n />\n );\n};\n\n// inner component exists only so we can use memos in reactivesearch render functions\nconst FilterSliderInner: React.FC<\n FilterProps & { reactivesearchFilterProps: any; filterSliderProps: ReturnType<typeof useFilterSliderProps>; customQuery: any; }\n> = (props) => {\n const {\n filter,\n renderFilterSlider,\n filterSliderProps,\n reactivesearchFilterProps,\n ...otherProps\n } = props;\n\n const filterRange: [number, number] = [\n reactivesearchFilterProps.aggregations?.min?.value ?? 0,\n reactivesearchFilterProps.aggregations?.max?.value ?? 0,\n ];\n\n const reactSliderProps = useReactSliderProps(\n filter,\n filterSliderProps.value,\n filterRange,\n filterSliderProps.handleChange,\n );\n\n React.useEffect(() => {\n if (!props.customQuery) {\n return;\n }\n\n props.reactivesearchFilterProps.setQuery({\n query: props.customQuery,\n value: filterSliderProps.value,\n });\n }, [filterSliderProps.value]);\n\n const RenderSliderComponent = props.renderFilterSlider ?? ExampleFilterSlider;\n\n return (\n <RenderSliderComponent\n filterSliderProps={filterSliderProps}\n reactSliderProps={reactSliderProps}\n filter={filter}\n {...otherProps}\n />\n );\n};\n\n// inner component exists only so we can use memos in reactivesearch render functions\nconst FilterListInner: React.FC<\n FilterProps & { reactivesearchFilterProps: ReactivesearchFilterListProps }\n> = (props) => {\n const { filter, renderFilterList, reactivesearchFilterProps, ...otherProps } =\n props;\n\n const filterListProps = useFilterListProps(filter, reactivesearchFilterProps);\n\n // hide entire filter when no options available\n if (!props.showEmptyFilters && 0 === filterListProps.options.length) {\n return null;\n }\n\n const RenderListComponent = props.renderFilterList ?? ExampleFilterList;\n\n return (\n <RenderListComponent\n filterListProps={filterListProps}\n filter={filter}\n {...otherProps}\n />\n );\n};\n"]}
|
|
@@ -12,7 +12,7 @@ const useFilterSliderProps = (filter) => {
|
|
|
12
12
|
const context = (0, hooks_1.useReactifySearchContext)();
|
|
13
13
|
const { track } = (0, hooks_1.useAnalytics)();
|
|
14
14
|
const urlSearchParam = new URLSearchParams(typeof window === "undefined" ? context.options.query : window.location.search);
|
|
15
|
-
const [filterValue, setFilterValue] = react_1.default.useState(JSON.parse((_a = urlSearchParam.get(filter.handle)) !== null && _a !== void 0 ? _a : "[
|
|
15
|
+
const [filterValue, setFilterValue] = react_1.default.useState(JSON.parse((_a = urlSearchParam.get(filter.handle)) !== null && _a !== void 0 ? _a : "[]"));
|
|
16
16
|
const handleChange = react_1.default.useCallback((value) => {
|
|
17
17
|
utility_1.debug.log("useFilterSliderProps", "handleChange[value]", value);
|
|
18
18
|
setFilterValue([parseInt(`${value[0]}`), parseInt(`${value[1]}`)]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFilterSliderProps.js","sourceRoot":"","sources":["../../../src/hooks/useFilterSliderProps.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,oCAAkE;AAClE,wCAAmC;AAE5B,MAAM,oBAAoB,GAAG,CAClC,MAAyB,EAKzB,EAAE;;IACF,MAAM,OAAO,GAAG,IAAA,gCAAwB,GA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nimport { ConfigFilterFacet } from \"../types/config\";\nimport { useAnalytics, useReactifySearchContext } from \"../hooks\";\nimport { debug } from \"../utility\";\n\nexport const useFilterSliderProps = (\n filter: ConfigFilterFacet\n): {\n filter: ConfigFilterFacet;\n value: [number, number];\n handleChange: (value: [number | string, number | string]) => void;\n} => {\n const context = useReactifySearchContext();\n const { track } = useAnalytics();\n\n const urlSearchParam = new URLSearchParams(typeof window === \"undefined\" ? context.options.query : window.location.search);\n const [filterValue, setFilterValue] = React.useState<[number, number]>(\n JSON.parse(urlSearchParam.get(filter.handle) ?? \"[]\")\n );\n\n const handleChange = React.useCallback(\n (value: [number | string, number | string]) => {\n debug.log(\"useFilterSliderProps\", \"handleChange[value]\", value);\n\n setFilterValue([parseInt(`${value[0]}`), parseInt(`${value[1]}`)]);\n\n track({\n eventName: \"filterChange\",\n payload: {\n name: filter.name,\n value: `${value[0]}:${value[1]}`,\n },\n });\n },\n [filter]\n );\n\n React.useEffect(() => {\n const handler = (\n event: CustomEvent<{ handle: string; value: [number, number] }>\n ) => {\n setFilterValue(event.detail.value);\n };\n window.addEventListener(\n `@usereactify/search:${context.options.mode}:filter:${filter.handle}:update`,\n handler as EventListener\n );\n\n return () =>\n window.removeEventListener(\n `@usereactify/search:${context.options.mode}:filter:${filter.handle}:update`,\n handler as EventListener\n );\n }, [context.options.mode]);\n\n const filterSliderProps = React.useMemo(() => {\n return {\n handleChange,\n filter,\n value: filterValue,\n };\n }, [\n handleChange,\n filter,\n filterValue,\n ]);\n\n return filterSliderProps;\n};\n"]}
|
|
@@ -537,7 +537,7 @@ const getPropsFilterRange = (filterGroupOption) => {
|
|
|
537
537
|
exports.getPropsFilterRange = getPropsFilterRange;
|
|
538
538
|
const getPropsFilterSlider = (filterGroupOption, query, value) => {
|
|
539
539
|
var _a;
|
|
540
|
-
const filterValue = value !== null && value !== void 0 ? value : JSON.parse((_a = new URLSearchParams(typeof window === "undefined" ? query : window.location.search).get(filterGroupOption.handle)) !== null && _a !== void 0 ? _a : "[
|
|
540
|
+
const filterValue = value !== null && value !== void 0 ? value : JSON.parse((_a = new URLSearchParams(typeof window === "undefined" ? query : window.location.search).get(filterGroupOption.handle)) !== null && _a !== void 0 ? _a : "[]");
|
|
541
541
|
const defaultQuery = {
|
|
542
542
|
aggs: {
|
|
543
543
|
min: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../src/utility/props.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oEAAgI;AAChI,8CAAwE;AAExE,yCAAyC;AACzC,6CAAkF;AAClF,uCAA2C;AAC3C,oCAAqD;AAErD,sEAAqC;AAqB9B,MAAM,mBAAmB,GAAG,CAAC,OAAwC,EAAE,EAAE;;IAC9E,OAAO;QACL,GAAG,MAAA,MAAA,OAAO,CAAC,WAAW,0CAAE,OAAO,CAAC,GAAG,CAAC,CAAC,iBAAiB,EAAE,EAAE,CAAC,IAAA,iCAAyB,EAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC,mCAAI,EAAE;QACvH,GAAG,IAAA,uBAAe,EAAC,OAAO,CAAC;QAC3B,IAAA,uBAAe,EAAC,OAAO,CAAC;KACzB,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B;AAEK,MAAM,yBAAyB,GAAG,CAAC,OAAwC,EAAE,iBAAoC,EAAE,EAAE;;IAC1H,IAAI,WAAW,GAA4B,EAAE,CAAC;IAE9C,IAAI,iBAAiB,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;QAC/C,MAAM,iBAAiB,GAAG,IAAA,4BAAoB,EAAC,iBAAiB,EAAE,MAAA,OAAO,CAAC,QAAQ,CAAC,KAAK,mCAAI,EAAE,CAAC,CAAC;QAChG,WAAW,GAAG;YACZ,YAAY,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,YAAY;YAClD,WAAW,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,WAAW;SACjD,CAAC;IACJ,C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,CAAC;gDACnB,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC;gDACnB,KAAK,EAAE,CAAC;6CACT;yCACF;qCACF;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC,CAAC,EAAE,CAAC;IAEL,OAAO;QACL,YAAY;QACZ,WAAW;KACZ,CAAC;AACJ,CAAC,CAAC;AAzDW,QAAA,oBAAoB,wBAyD/B","sourcesContent":["import { MultiList, MultiRange, ReactiveComponent, ReactiveList, SingleList, SingleRange } from \"@usereactify/search-internals\";\nimport { ReactifySearchProviderProps, SENSOR_IDS } from \"../components\";\nimport { Config, ConfigFilter, ConfigFilterFacet } from \"../types\";\nimport { getCuration } from \"./curation\";\nimport { generateSortQuery, generateSortSort, getSortOption } from \"./sortOption\";\nimport { getFilterStack } from \"./filters\";\nimport { replaceDocCountWithParent } from \"../hooks\";\n\nimport pkg from \"../../package.json\";\n\nexport type GeneratePropsFilterGroupOptions = {\n provider: ReactifySearchProviderProps;\n config: Config;\n filterGroup?: ConfigFilter;\n query?: Record<string, string>;\n};\n\nexport type GeneratePropsSensorOptions = {\n provider: ReactifySearchProviderProps;\n config: Config;\n query?: Record<string, string>;\n};\n\nexport type GeneratePropsBase = {\n provider: ReactifySearchProviderProps;\n config: Config;\n query?: Record<string, string>;\n};\n\nexport const getPropsFilterGroup = (options: GeneratePropsFilterGroupOptions) => {\n return [\n ...options.filterGroup?.options.map((filterGroupOption) => getPropsFilterGroupOption(options, filterGroupOption)) ?? [],\n ...getPropsSensors(options),\n getPropsResults(options),\n ];\n};\n\nexport const getPropsFilterGroupOption = (options: GeneratePropsFilterGroupOptions, filterGroupOption: ConfigFilterFacet) => {\n let filterProps: Record<string, unknown> = {};\n\n if (filterGroupOption.displayType === \"slider\") {\n const sliderFilterProps = getPropsFilterSlider(filterGroupOption, options.provider.query ?? {});\n filterProps = {\n defaultQuery: () => sliderFilterProps.defaultQuery,\n customQuery: () => sliderFilterProps.customQuery,\n };\n }\n\n if (filterGroupOption.displayType === \"single\" || filterGroupOption.displayType === \"multi\") {\n if (filterGroupOption.displayView === \"range\") {\n filterProps = getPropsFilterRange(filterGroupOption);\n } else {\n filterProps = getPropsFilterList(filterGroupOption);\n }\n }\n\n const sharedProps = getPropsShared(options, filterGroupOption);\n\n return {\n ...sharedProps,\n ...filterProps,\n };\n};\n\nexport const getPropsSensors = (options: GeneratePropsSensorOptions) => {\n return [\n ...getPropsSensorCustom(options),\n getPropsSensorCollection(options),\n getPropsSensorPublished(options),\n getPropsSensorInventoryAvailable(options),\n getPropsSensorSort(options),\n ].filter(Boolean);\n}\n\nexport const getPropsSensorCustom = (options: GeneratePropsSensorOptions) => {\n const sensors = options.provider.mode === \"collection\" ? options.config.sensors.collection : options.config.sensors.search;\n\n return sensors.map((sensor, index) => ({\n componentId: `SensorCustom_${index}`,\n customQuery: () => sensor,\n source: ReactiveComponent,\n }));\n}\n\nexport const getPropsSensorCollection = (options: GeneratePropsSensorOptions) => {\n if (options.provider.mode !== \"collection\") {\n return null;\n }\n \n return {\n componentId: \"SensorCollection\",\n customQuery: () => {\n if (options.provider.mode !== \"collection\") {\n return null;\n }\n\n const conditions: Array<unknown> = [];\n\n if (options.provider.market) {\n conditions.push({\n nested: {\n path: \"curations\",\n query: {\n bool: {\n should: [\n {\n nested: {\n path: \"collections\",\n query: {\n term: {\n \"collections.handle.keyword\": options.provider.collectionHandle,\n },\n },\n },\n },\n {\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.collectionHandle.keyword\":\n options.provider.collectionHandle,\n },\n },\n },\n },\n ],\n must: [{\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.markets.keyword\": options.provider.market,\n },\n },\n },\n }]\n },\n },\n },\n });\n }\n \n return {\n query: {\n bool: {\n should: [\n {\n nested: {\n path: \"collections\",\n query: {\n term: {\n \"collections.handle.keyword\": options.provider.collectionHandle,\n },\n },\n },\n },\n {\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.collectionHandle.keyword\":\n options.provider.collectionHandle,\n },\n },\n },\n },\n ],\n },\n },\n } \n },\n source: ReactiveComponent,\n };\n}\n\nexport const getPropsSensorPublished = (options: GeneratePropsSensorOptions) => {\n return {\n componentId: \"SensorPublished\",\n customQuery: () => {\n if (options.provider.market) {\n return {\n query: {\n bool: {\n must:[{\n match: {\n markets: options.provider.market,\n },\n },{\n match: {\n published: true,\n },\n }]\n },\n },\n };\n }\n\n return {\n query: {\n match: {\n published: true,\n },\n },\n }\n },\n source: ReactiveComponent,\n }\n}\n\nexport const getPropsSensorInventoryAvailable = (options: GeneratePropsSensorOptions) => {\n const filterStack = getFilterStack(options);\n\n if (!filterStack || \"show_all\" === filterStack.inventoryVisibility) {\n return null;\n }\n\n return {\n componentId: \"SensorInventoryAvailable\",\n customQuery: () => ({\n query: {\n bool: {\n should: [\n {\n bool: {\n must: [\n {\n term: {\n type: {\n value: \"product\",\n },\n },\n },\n {\n nested: {\n path: \"variants\",\n query: {\n match: { \"variants.available\": true },\n },\n },\n },\n ],\n },\n },\n ...(options.provider.mode === \"instant-search\"\n ? []\n : [\n {\n term: {\n type: {\n value: \"callout\",\n },\n },\n },\n ]),\n ],\n minimum_should_match: \"1\",\n },\n },\n }),\n source: ReactiveComponent,\n }\n}\n\nexport const getPropsSensorSort = (options: GeneratePropsSensorOptions & { searchTerm?: string; sortOption?: string; }) => {\n const curation = getCuration(options);\n const sortOption = getSortOption(options);\n\n const sort = generateSortSort({\n provider: options.provider,\n config: options.config,\n curation: curation,\n sortOption: sortOption,\n });\n const query = generateSortQuery({\n provider: options.provider,\n sortOption: sortOption,\n curation: curation,\n });\n\n return {\n componentId: \"SensorSort\",\n customQuery: () => ({\n sort,\n query,\n }),\n source: ReactiveComponent,\n }\n}\n\nexport const getPropsBase = (options: GeneratePropsBase) => {\n const props = {\n app: options.config.index,\n url: options.config.endpoint,\n credentials: options.provider.credentials,\n theme: options.provider.theme,\n initialState: options.provider.preload?.state,\n transformSort: () => {\n const sortSensor = getPropsSensorSort(options);\n const customQuery = sortSensor.customQuery();\n\n return customQuery.sort;\n },\n transformRequest: (request: any) => {\n if ((request.url as string).endsWith(\"?\")) {\n request.url = request.url.substring(0, request.url.length - 1);\n }\n return request;\n },\n transformResponse: async (response: any) => {\n // support filtering inside nested aggregations by moving the inner aggregation\n // up one level such that reactivesearch understands it\n //\n // see useReactiveFilterListProps > defaultQuery to see how a filter is being applied\n // to variant aggregations to ensure that only in stock sizes are displayed as filter\n // options, this involves a nested filter, which requires this fix\n //\n // https://github.com/appbaseio/reactivesearch/issues/1530\n if (\n response?.aggregations?.reactivesearch_nested?.reactify_nested_outer\n ) {\n response.aggregations.reactivesearch_nested =\n replaceDocCountWithParent(\n response?.aggregations?.reactivesearch_nested\n ?.reactify_nested_outer\n );\n }\n\n return response;\n },\n headers: {\n \"x-reactify-shop\": options.provider.shopifyPermanentDomain,\n \"x-reactify-mode\": options.provider.mode,\n \"x-reactify-client-id\": options.provider.clientId,\n \"x-reactify-client-version\": pkg.version,\n },\n };\n\n return props;\n}\n\nexport const getPropsResults = (options: GeneratePropsFilterGroupOptions & { scrollTarget?: string | Element | HTMLDocument; pageSize?: number; }) => {\n const includeFieldsProp = (() => {\n return [\n ...(options.provider.includeFields ?? []),\n \"id\",\n \"title\",\n \"type\",\n \"handle\",\n \"image\",\n \"variants.id\",\n \"variants.presentment_prices\",\n \"callout\",\n ];\n })();\n const excludeFieldsProp = (() => {\n return [...(options.provider.excludeFields ?? [])];\n })();\n\n return {\n size: options.pageSize ?? options.filterGroup?.pageSize ?? 20,\n URLParams: options.provider.mode === \"instant-search\" ? false : true,\n showLoader: false,\n dataField: \"title\",\n showResultStats: false,\n react: getPropsReact(options),\n includeFields: includeFieldsProp,\n excludeFields: excludeFieldsProp,\n scrollTarget: options.scrollTarget,\n componentId: \"page\", // this sets ?page= in the URL\n scrollOnChange: false, // @todo make this better, it's really janky when enabled\n pagination: options.filterGroup?.paginationType !== \"infinite_scroll\",\n infiniteScroll: options.filterGroup?.paginationType === \"infinite_scroll\",\n renderNoResults: () => null, // always use only render, otherwise both are shown\n source: ReactiveList,\n // defaultQuery: () => ({\n // sort: [\"_score\"],\n // query: {\n // match_all: {}\n // }\n // })\n }\n}\n\nexport const getPropsReact = (options: GeneratePropsFilterGroupOptions, filterGroupOption?: ConfigFilterFacet) => {\n const sensorIds = SENSOR_IDS(options.provider.mode, options.config);\n const reactProp = (() => {\n if (filterGroupOption?.settingsShowEmptyValues) {\n return {\n and: sensorIds,\n };\n }\n\n return {\n and: [\n ...sensorIds,\n ...(options.provider.additionalComponentIds ?? []),\n ...(options.filterGroup?.options.map((filter) => filter.handle) ?? []),\n ].filter((handle) => handle !== filterGroupOption?.handle),\n };\n })();\n\n return reactProp;\n};\n\nexport const getPropsShared = (options: GeneratePropsFilterGroupOptions, filterGroupOption: ConfigFilterFacet) => {\n const reactProp = getPropsReact(options, filterGroupOption);\n const nestedFieldProp = (() => {\n const nestedFields = [\"variants\"];\n const topField = filterGroupOption.field.split(\".\")[0];\n if (nestedFields.includes(topField)) {\n return topField;\n }\n return undefined;\n })();\n const customQueryProp = (() => {\n if (\n !filterGroupOption.settingsHideUnavailable ||\n !filterGroupOption.field.startsWith(\"variants.\")\n )\n return undefined;\n\n return (value?: string | string[]) => {\n if (!value) return {};\n\n // reactivesearch sometimes returns string, sometimes string[]\n const valueArray = \"string\" === typeof value ? [value] : value;\n\n if (0 === valueArray.length) return {};\n\n return {\n query: {\n nested: {\n path: \"variants\",\n query: {\n bool: {\n must: [\n {\n match: {\n \"variants.available\": \"true\",\n },\n },\n {\n terms: {\n [filterGroupOption.field]: valueArray,\n },\n },\n ],\n },\n },\n },\n },\n };\n };\n })();\n const defaultQueryProp = (() => {\n if (!filterGroupOption.field.startsWith(\"variants.\")) {\n return undefined;\n }\n\n // override the aggregation query to filter the results by the variants.available attribute\n return () => {\n return {\n aggs: {\n reactivesearch_nested: {\n nested: { path: \"variants\" },\n aggs: {\n reactify_nested_outer: {\n filter: {\n bool: {\n minimum_should_match: 1,\n should: [\n {\n match: {\n \"variants.available\": \"true\",\n },\n },\n {\n match: {\n \"variants.available\": filterGroupOption.settingsHideUnavailable\n ? \"true\"\n : \"false\",\n },\n },\n ],\n },\n },\n aggs: {\n [filterGroupOption.field]: {\n terms: {\n field: filterGroupOption.field,\n size: 100,\n order: { _count: \"desc\" },\n },\n aggs: {\n parent_docs: { reverse_nested: {} },\n },\n },\n },\n },\n },\n },\n },\n };\n };\n })();\n const sourceProp = (() => {\n if (filterGroupOption.displayType === \"slider\") {\n return ReactiveComponent;\n }\n if (filterGroupOption.displayType === \"single\") {\n if (filterGroupOption.displayView === \"range\") {\n return SingleRange;\n }\n return SingleList;\n }\n if (filterGroupOption.displayType === \"multi\") {\n if (filterGroupOption.displayView === \"range\") {\n return MultiRange;\n }\n return MultiList;\n }\n \n return;\n })();\n\n return {\n URLParams: true,\n componentId: filterGroupOption.handle,\n dataField: filterGroupOption.field,\n filterLabel: filterGroupOption.name,\n nestedField: nestedFieldProp,\n customQuery: customQueryProp,\n defaultQuery: defaultQueryProp,\n source: sourceProp,\n react: reactProp,\n }\n};\n\nexport const getPropsFilterList = (filterGroupOption: ConfigFilterFacet) => {\n return {\n size: parseInt(filterGroupOption.displaySize) || undefined,\n queryFormat: filterGroupOption.settingsFilterLogic ?? \"or\",\n showFilter: filterGroupOption.settingsShowFilter ?? true,\n showLoadMore: filterGroupOption.settingsShowMore ?? false,\n showSearch: filterGroupOption.settingsShowSearch ?? false,\n showRadio: false,\n showCheckbox: false,\n };\n};\n\nexport const getPropsFilterRange = (filterGroupOption: ConfigFilterFacet) => {\n const data = filterGroupOption.displayRangeOptions?.map((option) => {\n const [label, start, end] = option.split(\":\");\n return {\n label: label,\n start: start ? parseInt(start) : 0,\n end: end ? parseInt(end) : Number.MAX_SAFE_INTEGER,\n };\n }) ?? [];\n\n return {\n queryFormat: filterGroupOption.settingsFilterLogic ?? \"or\",\n showFilter: filterGroupOption.settingsShowFilter ?? true,\n showRadio: false,\n showCheckbox: false,\n data: data,\n };\n};\n\nexport const getPropsFilterSlider = (filterGroupOption: ConfigFilterFacet, query: Record<string, string> | string, value?: [number, number]) => {\n const filterValue = value ?? JSON.parse(new URLSearchParams(typeof window === \"undefined\" ? query : window.location.search).get(filterGroupOption.handle) ?? \"[0,0]\");\n\n const defaultQuery = {\n aggs: {\n min: {\n min: {\n field: filterGroupOption.field,\n },\n },\n max: {\n max: {\n field: filterGroupOption.field,\n },\n },\n },\n };\n\n const customQuery = (() => {\n if (filterValue[0] === 0 && filterValue[1] === 0) {\n return;\n }\n\n return {\n query: {\n bool: {\n must: [\n {\n bool: {\n must: [\n {\n match: {\n published: true,\n },\n },\n {\n range: {\n [filterGroupOption.field]: {\n gte: filterValue[0],\n lte: filterValue[1],\n boost: 2,\n },\n },\n },\n ],\n },\n },\n ],\n },\n }\n };\n })();\n \n return {\n defaultQuery,\n customQuery,\n };\n};"]}
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../src/utility/props.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oEAAgI;AAChI,8CAAwE;AAExE,yCAAyC;AACzC,6CAAkF;AAClF,uCAA2C;AAC3C,oCAAqD;AAErD,sEAAqC;AAqB9B,MAAM,mBAAmB,GAAG,CAAC,OAAwC,EAAE,EAAE;;IAC9E,OAAO;QACL,GAAG,MAAA,MAAA,OAAO,CAAC,WAAW,0CAAE,OAAO,CAAC,GAAG,CAAC,CAAC,iBAAiB,EAAE,EAAE,CAAC,IAAA,iCAAyB,EAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC,mCAAI,EAAE;QACvH,GAAG,IAAA,uBAAe,EAAC,OAAO,CAAC;QAC3B,IAAA,uBAAe,EAAC,OAAO,CAAC;KACzB,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B;AAEK,MAAM,yBAAyB,GAAG,CAAC,OAAwC,EAAE,iBAAoC,EAAE,EAAE;;IAC1H,IAAI,WAAW,GAA4B,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AAW,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YACjD,OAAO;QACT,CAAC;QAED,OAAO;YACL,KAAK,EAAE;gBACL,IAAI,EAAE;oBACJ,IAAI,EAAE;wBACJ;4BACE,IAAI,EAAE;gCACJ,IAAI,EAAE;oCACJ;wCACE,KAAK,EAAE;4CACL,SAAS,EAAE,IAAI;yCAChB;qCACF;oCACD;wCACE,KAAK,EAAE;4CACL,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE;gDACzB,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC;gDACnB,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC;gDACnB,KAAK,EAAE,CAAC;6CACT;yCACF;qCACF;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC,CAAC,EAAE,CAAC;IAEL,OAAO;QACL,YAAY;QACZ,WAAW;KACZ,CAAC;AACJ,CAAC,CAAC;AAzDW,QAAA,oBAAoB,wBAyD/B","sourcesContent":["import { MultiList, MultiRange, ReactiveComponent, ReactiveList, SingleList, SingleRange } from \"@usereactify/search-internals\";\nimport { ReactifySearchProviderProps, SENSOR_IDS } from \"../components\";\nimport { Config, ConfigFilter, ConfigFilterFacet } from \"../types\";\nimport { getCuration } from \"./curation\";\nimport { generateSortQuery, generateSortSort, getSortOption } from \"./sortOption\";\nimport { getFilterStack } from \"./filters\";\nimport { replaceDocCountWithParent } from \"../hooks\";\n\nimport pkg from \"../../package.json\";\n\nexport type GeneratePropsFilterGroupOptions = {\n provider: ReactifySearchProviderProps;\n config: Config;\n filterGroup?: ConfigFilter;\n query?: Record<string, string>;\n};\n\nexport type GeneratePropsSensorOptions = {\n provider: ReactifySearchProviderProps;\n config: Config;\n query?: Record<string, string>;\n};\n\nexport type GeneratePropsBase = {\n provider: ReactifySearchProviderProps;\n config: Config;\n query?: Record<string, string>;\n};\n\nexport const getPropsFilterGroup = (options: GeneratePropsFilterGroupOptions) => {\n return [\n ...options.filterGroup?.options.map((filterGroupOption) => getPropsFilterGroupOption(options, filterGroupOption)) ?? [],\n ...getPropsSensors(options),\n getPropsResults(options),\n ];\n};\n\nexport const getPropsFilterGroupOption = (options: GeneratePropsFilterGroupOptions, filterGroupOption: ConfigFilterFacet) => {\n let filterProps: Record<string, unknown> = {};\n\n if (filterGroupOption.displayType === \"slider\") {\n const sliderFilterProps = getPropsFilterSlider(filterGroupOption, options.provider.query ?? {});\n filterProps = {\n defaultQuery: () => sliderFilterProps.defaultQuery,\n customQuery: () => sliderFilterProps.customQuery,\n };\n }\n\n if (filterGroupOption.displayType === \"single\" || filterGroupOption.displayType === \"multi\") {\n if (filterGroupOption.displayView === \"range\") {\n filterProps = getPropsFilterRange(filterGroupOption);\n } else {\n filterProps = getPropsFilterList(filterGroupOption);\n }\n }\n\n const sharedProps = getPropsShared(options, filterGroupOption);\n\n return {\n ...sharedProps,\n ...filterProps,\n };\n};\n\nexport const getPropsSensors = (options: GeneratePropsSensorOptions) => {\n return [\n ...getPropsSensorCustom(options),\n getPropsSensorCollection(options),\n getPropsSensorPublished(options),\n getPropsSensorInventoryAvailable(options),\n getPropsSensorSort(options),\n ].filter(Boolean);\n}\n\nexport const getPropsSensorCustom = (options: GeneratePropsSensorOptions) => {\n const sensors = options.provider.mode === \"collection\" ? options.config.sensors.collection : options.config.sensors.search;\n\n return sensors.map((sensor, index) => ({\n componentId: `SensorCustom_${index}`,\n customQuery: () => sensor,\n source: ReactiveComponent,\n }));\n}\n\nexport const getPropsSensorCollection = (options: GeneratePropsSensorOptions) => {\n if (options.provider.mode !== \"collection\") {\n return null;\n }\n \n return {\n componentId: \"SensorCollection\",\n customQuery: () => {\n if (options.provider.mode !== \"collection\") {\n return null;\n }\n\n const conditions: Array<unknown> = [];\n\n if (options.provider.market) {\n conditions.push({\n nested: {\n path: \"curations\",\n query: {\n bool: {\n should: [\n {\n nested: {\n path: \"collections\",\n query: {\n term: {\n \"collections.handle.keyword\": options.provider.collectionHandle,\n },\n },\n },\n },\n {\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.collectionHandle.keyword\":\n options.provider.collectionHandle,\n },\n },\n },\n },\n ],\n must: [{\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.markets.keyword\": options.provider.market,\n },\n },\n },\n }]\n },\n },\n },\n });\n }\n \n return {\n query: {\n bool: {\n should: [\n {\n nested: {\n path: \"collections\",\n query: {\n term: {\n \"collections.handle.keyword\": options.provider.collectionHandle,\n },\n },\n },\n },\n {\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.collectionHandle.keyword\":\n options.provider.collectionHandle,\n },\n },\n },\n },\n ],\n },\n },\n } \n },\n source: ReactiveComponent,\n };\n}\n\nexport const getPropsSensorPublished = (options: GeneratePropsSensorOptions) => {\n return {\n componentId: \"SensorPublished\",\n customQuery: () => {\n if (options.provider.market) {\n return {\n query: {\n bool: {\n must:[{\n match: {\n markets: options.provider.market,\n },\n },{\n match: {\n published: true,\n },\n }]\n },\n },\n };\n }\n\n return {\n query: {\n match: {\n published: true,\n },\n },\n }\n },\n source: ReactiveComponent,\n }\n}\n\nexport const getPropsSensorInventoryAvailable = (options: GeneratePropsSensorOptions) => {\n const filterStack = getFilterStack(options);\n\n if (!filterStack || \"show_all\" === filterStack.inventoryVisibility) {\n return null;\n }\n\n return {\n componentId: \"SensorInventoryAvailable\",\n customQuery: () => ({\n query: {\n bool: {\n should: [\n {\n bool: {\n must: [\n {\n term: {\n type: {\n value: \"product\",\n },\n },\n },\n {\n nested: {\n path: \"variants\",\n query: {\n match: { \"variants.available\": true },\n },\n },\n },\n ],\n },\n },\n ...(options.provider.mode === \"instant-search\"\n ? []\n : [\n {\n term: {\n type: {\n value: \"callout\",\n },\n },\n },\n ]),\n ],\n minimum_should_match: \"1\",\n },\n },\n }),\n source: ReactiveComponent,\n }\n}\n\nexport const getPropsSensorSort = (options: GeneratePropsSensorOptions & { searchTerm?: string; sortOption?: string; }) => {\n const curation = getCuration(options);\n const sortOption = getSortOption(options);\n\n const sort = generateSortSort({\n provider: options.provider,\n config: options.config,\n curation: curation,\n sortOption: sortOption,\n });\n const query = generateSortQuery({\n provider: options.provider,\n sortOption: sortOption,\n curation: curation,\n });\n\n return {\n componentId: \"SensorSort\",\n customQuery: () => ({\n sort,\n query,\n }),\n source: ReactiveComponent,\n }\n}\n\nexport const getPropsBase = (options: GeneratePropsBase) => {\n const props = {\n app: options.config.index,\n url: options.config.endpoint,\n credentials: options.provider.credentials,\n theme: options.provider.theme,\n initialState: options.provider.preload?.state,\n transformSort: () => {\n const sortSensor = getPropsSensorSort(options);\n const customQuery = sortSensor.customQuery();\n\n return customQuery.sort;\n },\n transformRequest: (request: any) => {\n if ((request.url as string).endsWith(\"?\")) {\n request.url = request.url.substring(0, request.url.length - 1);\n }\n return request;\n },\n transformResponse: async (response: any) => {\n // support filtering inside nested aggregations by moving the inner aggregation\n // up one level such that reactivesearch understands it\n //\n // see useReactiveFilterListProps > defaultQuery to see how a filter is being applied\n // to variant aggregations to ensure that only in stock sizes are displayed as filter\n // options, this involves a nested filter, which requires this fix\n //\n // https://github.com/appbaseio/reactivesearch/issues/1530\n if (\n response?.aggregations?.reactivesearch_nested?.reactify_nested_outer\n ) {\n response.aggregations.reactivesearch_nested =\n replaceDocCountWithParent(\n response?.aggregations?.reactivesearch_nested\n ?.reactify_nested_outer\n );\n }\n\n return response;\n },\n headers: {\n \"x-reactify-shop\": options.provider.shopifyPermanentDomain,\n \"x-reactify-mode\": options.provider.mode,\n \"x-reactify-client-id\": options.provider.clientId,\n \"x-reactify-client-version\": pkg.version,\n },\n };\n\n return props;\n}\n\nexport const getPropsResults = (options: GeneratePropsFilterGroupOptions & { scrollTarget?: string | Element | HTMLDocument; pageSize?: number; }) => {\n const includeFieldsProp = (() => {\n return [\n ...(options.provider.includeFields ?? []),\n \"id\",\n \"title\",\n \"type\",\n \"handle\",\n \"image\",\n \"variants.id\",\n \"variants.presentment_prices\",\n \"callout\",\n ];\n })();\n const excludeFieldsProp = (() => {\n return [...(options.provider.excludeFields ?? [])];\n })();\n\n return {\n size: options.pageSize ?? options.filterGroup?.pageSize ?? 20,\n URLParams: options.provider.mode === \"instant-search\" ? false : true,\n showLoader: false,\n dataField: \"title\",\n showResultStats: false,\n react: getPropsReact(options),\n includeFields: includeFieldsProp,\n excludeFields: excludeFieldsProp,\n scrollTarget: options.scrollTarget,\n componentId: \"page\", // this sets ?page= in the URL\n scrollOnChange: false, // @todo make this better, it's really janky when enabled\n pagination: options.filterGroup?.paginationType !== \"infinite_scroll\",\n infiniteScroll: options.filterGroup?.paginationType === \"infinite_scroll\",\n renderNoResults: () => null, // always use only render, otherwise both are shown\n source: ReactiveList,\n // defaultQuery: () => ({\n // sort: [\"_score\"],\n // query: {\n // match_all: {}\n // }\n // })\n }\n}\n\nexport const getPropsReact = (options: GeneratePropsFilterGroupOptions, filterGroupOption?: ConfigFilterFacet) => {\n const sensorIds = SENSOR_IDS(options.provider.mode, options.config);\n const reactProp = (() => {\n if (filterGroupOption?.settingsShowEmptyValues) {\n return {\n and: sensorIds,\n };\n }\n\n return {\n and: [\n ...sensorIds,\n ...(options.provider.additionalComponentIds ?? []),\n ...(options.filterGroup?.options.map((filter) => filter.handle) ?? []),\n ].filter((handle) => handle !== filterGroupOption?.handle),\n };\n })();\n\n return reactProp;\n};\n\nexport const getPropsShared = (options: GeneratePropsFilterGroupOptions, filterGroupOption: ConfigFilterFacet) => {\n const reactProp = getPropsReact(options, filterGroupOption);\n const nestedFieldProp = (() => {\n const nestedFields = [\"variants\"];\n const topField = filterGroupOption.field.split(\".\")[0];\n if (nestedFields.includes(topField)) {\n return topField;\n }\n return undefined;\n })();\n const customQueryProp = (() => {\n if (\n !filterGroupOption.settingsHideUnavailable ||\n !filterGroupOption.field.startsWith(\"variants.\")\n )\n return undefined;\n\n return (value?: string | string[]) => {\n if (!value) return {};\n\n // reactivesearch sometimes returns string, sometimes string[]\n const valueArray = \"string\" === typeof value ? [value] : value;\n\n if (0 === valueArray.length) return {};\n\n return {\n query: {\n nested: {\n path: \"variants\",\n query: {\n bool: {\n must: [\n {\n match: {\n \"variants.available\": \"true\",\n },\n },\n {\n terms: {\n [filterGroupOption.field]: valueArray,\n },\n },\n ],\n },\n },\n },\n },\n };\n };\n })();\n const defaultQueryProp = (() => {\n if (!filterGroupOption.field.startsWith(\"variants.\")) {\n return undefined;\n }\n\n // override the aggregation query to filter the results by the variants.available attribute\n return () => {\n return {\n aggs: {\n reactivesearch_nested: {\n nested: { path: \"variants\" },\n aggs: {\n reactify_nested_outer: {\n filter: {\n bool: {\n minimum_should_match: 1,\n should: [\n {\n match: {\n \"variants.available\": \"true\",\n },\n },\n {\n match: {\n \"variants.available\": filterGroupOption.settingsHideUnavailable\n ? \"true\"\n : \"false\",\n },\n },\n ],\n },\n },\n aggs: {\n [filterGroupOption.field]: {\n terms: {\n field: filterGroupOption.field,\n size: 100,\n order: { _count: \"desc\" },\n },\n aggs: {\n parent_docs: { reverse_nested: {} },\n },\n },\n },\n },\n },\n },\n },\n };\n };\n })();\n const sourceProp = (() => {\n if (filterGroupOption.displayType === \"slider\") {\n return ReactiveComponent;\n }\n if (filterGroupOption.displayType === \"single\") {\n if (filterGroupOption.displayView === \"range\") {\n return SingleRange;\n }\n return SingleList;\n }\n if (filterGroupOption.displayType === \"multi\") {\n if (filterGroupOption.displayView === \"range\") {\n return MultiRange;\n }\n return MultiList;\n }\n \n return;\n })();\n\n return {\n URLParams: true,\n componentId: filterGroupOption.handle,\n dataField: filterGroupOption.field,\n filterLabel: filterGroupOption.name,\n nestedField: nestedFieldProp,\n customQuery: customQueryProp,\n defaultQuery: defaultQueryProp,\n source: sourceProp,\n react: reactProp,\n }\n};\n\nexport const getPropsFilterList = (filterGroupOption: ConfigFilterFacet) => {\n return {\n size: parseInt(filterGroupOption.displaySize) || undefined,\n queryFormat: filterGroupOption.settingsFilterLogic ?? \"or\",\n showFilter: filterGroupOption.settingsShowFilter ?? true,\n showLoadMore: filterGroupOption.settingsShowMore ?? false,\n showSearch: filterGroupOption.settingsShowSearch ?? false,\n showRadio: false,\n showCheckbox: false,\n };\n};\n\nexport const getPropsFilterRange = (filterGroupOption: ConfigFilterFacet) => {\n const data = filterGroupOption.displayRangeOptions?.map((option) => {\n const [label, start, end] = option.split(\":\");\n return {\n label: label,\n start: start ? parseInt(start) : 0,\n end: end ? parseInt(end) : Number.MAX_SAFE_INTEGER,\n };\n }) ?? [];\n\n return {\n queryFormat: filterGroupOption.settingsFilterLogic ?? \"or\",\n showFilter: filterGroupOption.settingsShowFilter ?? true,\n showRadio: false,\n showCheckbox: false,\n data: data,\n };\n};\n\nexport const getPropsFilterSlider = (filterGroupOption: ConfigFilterFacet, query: Record<string, string> | string, value?: [number, number]) => {\n const filterValue = value ?? JSON.parse(new URLSearchParams(typeof window === \"undefined\" ? query : window.location.search).get(filterGroupOption.handle) ?? \"[]\");\n\n const defaultQuery = {\n aggs: {\n min: {\n min: {\n field: filterGroupOption.field,\n },\n },\n max: {\n max: {\n field: filterGroupOption.field,\n },\n },\n },\n };\n\n const customQuery = (() => {\n if (filterValue[0] === 0 && filterValue[1] === 0) {\n return;\n }\n\n return {\n query: {\n bool: {\n must: [\n {\n bool: {\n must: [\n {\n match: {\n published: true,\n },\n },\n {\n range: {\n [filterGroupOption.field]: {\n gte: filterValue[0],\n lte: filterValue[1],\n boost: 2,\n },\n },\n },\n ],\n },\n },\n ],\n },\n }\n };\n })();\n \n return {\n defaultQuery,\n customQuery,\n };\n};"]}
|