@usereactify/search 5.59.1-beta.0 → 5.60.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -2
- package/dist/package.json +5 -7
- package/dist/src/components/ClearAll/ClearAll.d.ts +1 -1
- package/dist/src/components/ClearAll/ClearAll.js +9 -4
- package/dist/src/components/ClearAll/ClearAll.js.map +1 -1
- package/dist/src/components/CustomComponent/CustomComponent.d.ts +1 -1
- package/dist/src/components/CustomComponent/CustomComponent.js +2 -2
- package/dist/src/components/CustomComponent/CustomComponent.js.map +1 -1
- package/dist/src/components/Example/ExampleClearAll.d.ts +2 -2
- package/dist/src/components/Example/ExampleClearAll.js +5 -2
- package/dist/src/components/Example/ExampleClearAll.js.map +1 -1
- package/dist/src/components/Example/ExampleCustomComponent.d.ts +1 -1
- package/dist/src/components/Example/ExampleCustomComponent.js +7 -3
- package/dist/src/components/Example/ExampleCustomComponent.js.map +1 -1
- package/dist/src/components/Example/ExampleFilterList.d.ts +2 -2
- package/dist/src/components/Example/ExampleFilterList.js +66 -31
- package/dist/src/components/Example/ExampleFilterList.js.map +1 -1
- package/dist/src/components/Example/ExampleFilterRange.d.ts +2 -2
- package/dist/src/components/Example/ExampleFilterRange.js +12 -2
- package/dist/src/components/Example/ExampleFilterRange.js.map +1 -1
- package/dist/src/components/Example/ExampleFilterSlider.d.ts +2 -2
- package/dist/src/components/Example/ExampleFilterSlider.js +18 -11
- package/dist/src/components/Example/ExampleFilterSlider.js.map +1 -1
- package/dist/src/components/Example/ExampleFilters.d.ts +1 -1
- package/dist/src/components/Example/ExampleFilters.js +8 -3
- package/dist/src/components/Example/ExampleFilters.js.map +1 -1
- package/dist/src/components/Example/ExampleFiltersSelected.d.ts +2 -2
- package/dist/src/components/Example/ExampleFiltersSelected.js +24 -3
- package/dist/src/components/Example/ExampleFiltersSelected.js.map +1 -1
- package/dist/src/components/Example/ExampleHookUseFilters.d.ts +1 -1
- package/dist/src/components/Example/ExampleHookUseFilters.js +10 -3
- package/dist/src/components/Example/ExampleHookUseFilters.js.map +1 -1
- package/dist/src/components/Example/ExampleHookUseResults.d.ts +1 -1
- package/dist/src/components/Example/ExampleHookUseResults.js +8 -3
- package/dist/src/components/Example/ExampleHookUseResults.js.map +1 -1
- package/dist/src/components/Example/ExampleHookUseSearch.js +2 -2
- package/dist/src/components/Example/ExampleHookUseSearch.js.map +1 -1
- package/dist/src/components/Example/ExampleHookUseSortBy.js +1 -2
- package/dist/src/components/Example/ExampleHookUseSortBy.js.map +1 -1
- package/dist/src/components/Example/ExampleProductCardWeight.d.ts +1 -1
- package/dist/src/components/Example/ExampleProductCardWeight.js +47 -14
- package/dist/src/components/Example/ExampleProductCardWeight.js.map +1 -1
- package/dist/src/components/Example/ExampleReactiveSearchProviderCollection.d.ts +1 -1
- package/dist/src/components/Example/ExampleReactiveSearchProviderCollection.js +6 -2
- package/dist/src/components/Example/ExampleReactiveSearchProviderCollection.js.map +1 -1
- package/dist/src/components/Example/ExampleReactiveSearchProviderInstantSearch.d.ts +1 -1
- package/dist/src/components/Example/ExampleReactiveSearchProviderInstantSearch.js +6 -2
- package/dist/src/components/Example/ExampleReactiveSearchProviderInstantSearch.js.map +1 -1
- package/dist/src/components/Example/ExampleReactiveSearchProviderSearch.d.ts +1 -1
- package/dist/src/components/Example/ExampleReactiveSearchProviderSearch.js +6 -2
- package/dist/src/components/Example/ExampleReactiveSearchProviderSearch.js.map +1 -1
- package/dist/src/components/Example/ExampleResultCardCallout.d.ts +1 -1
- package/dist/src/components/Example/ExampleResultCardCallout.js +4 -2
- package/dist/src/components/Example/ExampleResultCardCallout.js.map +1 -1
- package/dist/src/components/Example/ExampleResultCardProduct.d.ts +2 -2
- package/dist/src/components/Example/ExampleResultCardProduct.js +12 -2
- package/dist/src/components/Example/ExampleResultCardProduct.js.map +1 -1
- package/dist/src/components/Example/ExampleResultPaginationInfiniteScroll.d.ts +2 -2
- package/dist/src/components/Example/ExampleResultPaginationInfiniteScroll.js +5 -2
- package/dist/src/components/Example/ExampleResultPaginationInfiniteScroll.js.map +1 -1
- package/dist/src/components/Example/ExampleResultPaginationLoadMore.d.ts +2 -2
- package/dist/src/components/Example/ExampleResultPaginationLoadMore.js +5 -2
- package/dist/src/components/Example/ExampleResultPaginationLoadMore.js.map +1 -1
- package/dist/src/components/Example/ExampleResultPaginationNextPrev.d.ts +2 -2
- package/dist/src/components/Example/ExampleResultPaginationNextPrev.js +7 -2
- package/dist/src/components/Example/ExampleResultPaginationNextPrev.js.map +1 -1
- package/dist/src/components/Example/ExampleResultPaginationNumbered.d.ts +2 -2
- package/dist/src/components/Example/ExampleResultPaginationNumbered.js +20 -6
- package/dist/src/components/Example/ExampleResultPaginationNumbered.js.map +1 -1
- package/dist/src/components/Example/ExampleResults.d.ts +1 -1
- package/dist/src/components/Example/ExampleResults.js +10 -7
- package/dist/src/components/Example/ExampleResults.js.map +1 -1
- package/dist/src/components/Example/ExampleSearch.d.ts +1 -1
- package/dist/src/components/Example/ExampleSearch.js +2 -2
- package/dist/src/components/Example/ExampleSearch.js.map +1 -1
- package/dist/src/components/Example/ExampleSortBy.d.ts +2 -2
- package/dist/src/components/Example/ExampleSortBy.js +5 -2
- package/dist/src/components/Example/ExampleSortBy.js.map +1 -1
- package/dist/src/components/Example/ExampleStats.d.ts +2 -2
- package/dist/src/components/Example/ExampleStats.js +8 -2
- package/dist/src/components/Example/ExampleStats.js.map +1 -1
- package/dist/src/components/Example/ExampleSuggestions.d.ts +2 -2
- package/dist/src/components/Example/ExampleSuggestions.js +7 -2
- package/dist/src/components/Example/ExampleSuggestions.js.map +1 -1
- package/dist/src/components/Example/index.d.ts +6 -6
- package/dist/src/components/Example/index.js +6 -6
- package/dist/src/components/Example/index.js.map +1 -1
- package/dist/src/components/Filter/Filter.d.ts +1 -1
- package/dist/src/components/Filter/Filter.js +35 -30
- package/dist/src/components/Filter/Filter.js.map +1 -1
- package/dist/src/components/Filter/Filters.d.ts +4 -4
- package/dist/src/components/Filter/Filters.js +6 -3
- package/dist/src/components/Filter/Filters.js.map +1 -1
- package/dist/src/components/Filter/FiltersSelected.d.ts +1 -1
- package/dist/src/components/Filter/FiltersSelected.js +9 -4
- package/dist/src/components/Filter/FiltersSelected.js.map +1 -1
- package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.d.ts +2 -2
- package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.js +8 -20
- package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.js.map +1 -1
- package/dist/src/components/Result/ResultCardCallout.d.ts +2 -2
- package/dist/src/components/Result/ResultCardCallout.js +2 -3
- package/dist/src/components/Result/ResultCardCallout.js.map +1 -1
- package/dist/src/components/Result/ResultCardProduct.d.ts +1 -1
- package/dist/src/components/Result/ResultCardProduct.js +3 -4
- package/dist/src/components/Result/ResultCardProduct.js.map +1 -1
- package/dist/src/components/Result/ResultPaginationInfiniteScroll.d.ts +3 -3
- package/dist/src/components/Result/ResultPaginationInfiniteScroll.js +6 -3
- package/dist/src/components/Result/ResultPaginationInfiniteScroll.js.map +1 -1
- package/dist/src/components/Result/ResultPaginationLoadMore.d.ts +3 -3
- package/dist/src/components/Result/ResultPaginationLoadMore.js +6 -3
- package/dist/src/components/Result/ResultPaginationLoadMore.js.map +1 -1
- package/dist/src/components/Result/ResultPaginationNextPrev.d.ts +3 -3
- package/dist/src/components/Result/ResultPaginationNextPrev.js +6 -3
- package/dist/src/components/Result/ResultPaginationNextPrev.js.map +1 -1
- package/dist/src/components/Result/ResultPaginationNumbered.d.ts +3 -3
- package/dist/src/components/Result/ResultPaginationNumbered.js +6 -3
- package/dist/src/components/Result/ResultPaginationNumbered.js.map +1 -1
- package/dist/src/components/Result/ResultStateProvider.d.ts +2 -2
- package/dist/src/components/Result/ResultStateProvider.js +3 -3
- package/dist/src/components/Result/ResultStateProvider.js.map +1 -1
- package/dist/src/components/Result/Results.d.ts +2 -2
- package/dist/src/components/Result/Results.js +52 -50
- package/dist/src/components/Result/Results.js.map +1 -1
- package/dist/src/components/Result/index.d.ts +4 -4
- package/dist/src/components/Result/index.js +4 -4
- package/dist/src/components/Result/index.js.map +1 -1
- package/dist/src/components/Search/Search.d.ts +1 -1
- package/dist/src/components/Search/Search.js +6 -3
- package/dist/src/components/Search/Search.js.map +1 -1
- package/dist/src/components/Sensor/SensorCollection.d.ts +1 -1
- package/dist/src/components/Sensor/SensorCollection.js +2 -2
- package/dist/src/components/Sensor/SensorCollection.js.map +1 -1
- package/dist/src/components/Sensor/SensorCustom.d.ts +2 -1
- package/dist/src/components/Sensor/SensorCustom.js +6 -5
- package/dist/src/components/Sensor/SensorCustom.js.map +1 -1
- package/dist/src/components/Sensor/SensorExplain.js +2 -2
- package/dist/src/components/Sensor/SensorExplain.js.map +1 -1
- package/dist/src/components/Sensor/SensorInventoryAvailable.d.ts +1 -1
- package/dist/src/components/Sensor/SensorInventoryAvailable.js +2 -2
- package/dist/src/components/Sensor/SensorInventoryAvailable.js.map +1 -1
- package/dist/src/components/Sensor/SensorPublished.d.ts +1 -1
- package/dist/src/components/Sensor/SensorPublished.js +2 -2
- package/dist/src/components/Sensor/SensorPublished.js.map +1 -1
- package/dist/src/components/Sensor/SensorSearchTerm.js +29 -6
- package/dist/src/components/Sensor/SensorSearchTerm.js.map +1 -1
- package/dist/src/components/Sensor/SensorSort.d.ts +1 -1
- package/dist/src/components/Sensor/SensorSort.js +2 -2
- package/dist/src/components/Sensor/SensorSort.js.map +1 -1
- package/dist/src/components/Sensor/Sensors.js +23 -8
- package/dist/src/components/Sensor/Sensors.js.map +1 -1
- package/dist/src/components/Sensor/index.d.ts +7 -7
- package/dist/src/components/Sensor/index.js +6 -6
- package/dist/src/components/Sensor/index.js.map +1 -1
- package/dist/src/components/SortBy/SortBy.d.ts +1 -1
- package/dist/src/components/SortBy/SortBy.js +6 -3
- package/dist/src/components/SortBy/SortBy.js.map +1 -1
- package/dist/src/components/Stats/Stats.d.ts +2 -2
- package/dist/src/components/Stats/Stats.js +5 -2
- package/dist/src/components/Stats/Stats.js.map +1 -1
- package/dist/src/components/Suggestions/Suggestions.d.ts +1 -1
- package/dist/src/components/Suggestions/Suggestions.js +8 -7
- package/dist/src/components/Suggestions/Suggestions.js.map +1 -1
- package/dist/src/components/Utility/UtilityAuthenticatedReactiveBase.d.ts +1 -1
- package/dist/src/components/Utility/UtilityAuthenticatedReactiveBase.js +3 -3
- package/dist/src/components/Utility/UtilityAuthenticatedReactiveBase.js.map +1 -1
- package/dist/src/components/Utility/index.js.map +1 -1
- package/dist/src/components/index.d.ts +2 -2
- package/dist/src/components/index.js +2 -2
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/hooks/index.d.ts +11 -11
- package/dist/src/hooks/index.js +11 -11
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/react-slider/useReactSliderProps.d.ts +2 -2
- package/dist/src/hooks/react-slider/useReactSliderProps.js +6 -6
- package/dist/src/hooks/react-slider/useReactSliderProps.js.map +1 -1
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.d.ts +1 -1
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.js +2 -2
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.js.map +1 -1
- package/dist/src/hooks/useAnalytics.js.map +1 -1
- package/dist/src/hooks/useConfig.d.ts +1 -1
- package/dist/src/hooks/useConfig.js +1 -1
- package/dist/src/hooks/useConfig.js.map +1 -1
- package/dist/src/hooks/useCuration.d.ts +1 -1
- package/dist/src/hooks/useCuration.js +25 -9
- package/dist/src/hooks/useCuration.js.map +1 -1
- package/dist/src/hooks/useDebugger.js +3 -3
- package/dist/src/hooks/useDebugger.js.map +1 -1
- package/dist/src/hooks/useFilterCollapsedState.d.ts +1 -1
- package/dist/src/hooks/useFilterCollapsedState.js.map +1 -1
- package/dist/src/hooks/useFilterListProps.d.ts +2 -2
- package/dist/src/hooks/useFilterListProps.js +11 -7
- package/dist/src/hooks/useFilterListProps.js.map +1 -1
- package/dist/src/hooks/useFilterRangeProps.d.ts +1 -1
- package/dist/src/hooks/useFilterRangeProps.js +14 -11
- package/dist/src/hooks/useFilterRangeProps.js.map +1 -1
- package/dist/src/hooks/useFilterSliderProps.d.ts +1 -1
- package/dist/src/hooks/useFilterSliderProps.js +9 -10
- package/dist/src/hooks/useFilterSliderProps.js.map +1 -1
- package/dist/src/hooks/useFilters.d.ts +1 -1
- package/dist/src/hooks/useFilters.js +7 -4
- package/dist/src/hooks/useFilters.js.map +1 -1
- package/dist/src/hooks/useIndices.js +2 -2
- package/dist/src/hooks/useIndices.js.map +1 -1
- package/dist/src/hooks/usePagination.d.ts +1 -1
- package/dist/src/hooks/usePagination.js +14 -6
- package/dist/src/hooks/usePagination.js.map +1 -1
- package/dist/src/hooks/usePaginationLoadable.d.ts +1 -1
- package/dist/src/hooks/usePaginationLoadable.js +5 -3
- package/dist/src/hooks/usePaginationLoadable.js.map +1 -1
- package/dist/src/hooks/useProductPrice.d.ts +1 -1
- package/dist/src/hooks/useProductPrice.js +1 -3
- package/dist/src/hooks/useProductPrice.js.map +1 -1
- package/dist/src/hooks/useReactifySearchContext.d.ts +1 -1
- package/dist/src/hooks/useReactifySearchContext.js.map +1 -1
- package/dist/src/hooks/useResults.d.ts +1 -1
- package/dist/src/hooks/useResults.js +4 -4
- package/dist/src/hooks/useResults.js.map +1 -1
- package/dist/src/hooks/useSearch.d.ts +1 -1
- package/dist/src/hooks/useSearch.js +9 -8
- package/dist/src/hooks/useSearch.js.map +1 -1
- package/dist/src/hooks/useSortBy.d.ts +1 -1
- package/dist/src/hooks/useSortBy.js +1 -1
- package/dist/src/hooks/useSortBy.js.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/search-request-builder/base-builders.d.ts +2 -2
- package/dist/src/search-request-builder/base-builders.js +2 -2
- package/dist/src/search-request-builder/base-builders.js.map +1 -1
- package/dist/src/search-request-builder/curation-builders.d.ts +1 -1
- package/dist/src/search-request-builder/curation-builders.js +1 -1
- package/dist/src/search-request-builder/curation-builders.js.map +1 -1
- package/dist/src/search-request-builder/index.d.ts +2 -2
- package/dist/src/search-request-builder/index.js +2 -2
- package/dist/src/search-request-builder/index.js.map +1 -1
- package/dist/src/search-request-builder/search-request-builder.d.ts +1 -1
- package/dist/src/search-request-builder/search-request-builder.js.map +1 -1
- package/dist/src/search-request-builder/types.d.ts +3 -3
- package/dist/src/search-request-builder/types.js.map +1 -1
- package/dist/src/search-request-builder/utils.d.ts +2 -2
- package/dist/src/search-request-builder/utils.js +1 -1
- package/dist/src/search-request-builder/utils.js.map +1 -1
- package/dist/src/types/config.d.ts +1 -1
- package/dist/src/types/config.js.map +1 -1
- package/dist/src/types/elastic.d.ts +2 -2
- package/dist/src/types/elastic.js.map +1 -1
- package/dist/src/types/firestore.d.ts +3 -3
- package/dist/src/types/firestore.js.map +1 -1
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/reactivesearch.d.ts +1 -1
- package/dist/src/types/reactivesearch.js.map +1 -1
- package/dist/src/types/shopify.d.ts +1 -1
- package/dist/src/types/shopify.js.map +1 -1
- package/dist/src/utility/config.d.ts +1 -1
- package/dist/src/utility/config.js +1 -1
- package/dist/src/utility/config.js.map +1 -1
- package/dist/src/utility/curation.d.ts +2 -2
- package/dist/src/utility/curation.js +1 -1
- package/dist/src/utility/curation.js.map +1 -1
- package/dist/src/utility/debug.js +1 -1
- package/dist/src/utility/debug.js.map +1 -1
- package/dist/src/utility/filters.d.ts +2 -2
- package/dist/src/utility/filters.js.map +1 -1
- package/dist/src/utility/liquid.d.ts +2 -2
- package/dist/src/utility/liquid.js +5 -2
- package/dist/src/utility/liquid.js.map +1 -1
- package/dist/src/utility/props.d.ts +2 -2
- package/dist/src/utility/props.js +8 -8
- package/dist/src/utility/props.js.map +1 -1
- package/dist/src/utility/server.d.ts +1 -1
- package/dist/src/utility/server.js +3 -3
- package/dist/src/utility/server.js.map +1 -1
- package/dist/src/utility/sortOption.d.ts +2 -2
- package/dist/src/utility/sortOption.js.map +1 -1
- package/package.json +5 -7
|
@@ -15,36 +15,35 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.Filter = void 0;
|
|
18
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
18
|
const react_1 = __importDefault(require("react"));
|
|
20
19
|
const ReactiveComponent_1 = __importDefault(require("@usereactify/search-internals/lib/components/basic/ReactiveComponent"));
|
|
21
20
|
const MultiList_1 = __importDefault(require("@usereactify/search-internals/lib/components/list/MultiList"));
|
|
22
21
|
const SingleList_1 = __importDefault(require("@usereactify/search-internals/lib/components/list/SingleList"));
|
|
23
|
-
const MultiRange_1 = __importDefault(require("@usereactify/search-internals/lib/components/range/MultiRange"));
|
|
24
22
|
const SingleRange_1 = __importDefault(require("@usereactify/search-internals/lib/components/range/SingleRange"));
|
|
25
|
-
const
|
|
23
|
+
const MultiRange_1 = __importDefault(require("@usereactify/search-internals/lib/components/range/MultiRange"));
|
|
26
24
|
const hooks_1 = require("../../hooks");
|
|
27
|
-
const
|
|
25
|
+
const components_1 = require("../../components");
|
|
28
26
|
const props_1 = require("../../utility/props");
|
|
27
|
+
const useReactSliderProps_1 = require("../../hooks/react-slider/useReactSliderProps");
|
|
29
28
|
const Filter = (props) => {
|
|
30
29
|
if ("single" === props.filter.displayType) {
|
|
31
30
|
if ("range" === props.filter.displayView) {
|
|
32
|
-
return
|
|
31
|
+
return react_1.default.createElement(FilterRangeSingle, Object.assign({}, props));
|
|
33
32
|
}
|
|
34
|
-
return
|
|
33
|
+
return react_1.default.createElement(FilterSingleList, Object.assign({}, props));
|
|
35
34
|
}
|
|
36
35
|
if ("multi" === props.filter.displayType) {
|
|
37
36
|
if ("range" === props.filter.displayView) {
|
|
38
|
-
return
|
|
37
|
+
return react_1.default.createElement(FilterRangeMulti, Object.assign({}, props));
|
|
39
38
|
}
|
|
40
|
-
return
|
|
39
|
+
return react_1.default.createElement(FilterMultiList, Object.assign({}, props));
|
|
41
40
|
}
|
|
42
41
|
if ("slider" === props.filter.displayType) {
|
|
43
|
-
return
|
|
42
|
+
return react_1.default.createElement(FilterSlider, Object.assign({}, props));
|
|
44
43
|
}
|
|
45
44
|
// TODO: Legacy range filter, migrate to new single and multi ranges
|
|
46
45
|
if ("range" === props.filter.displayType) {
|
|
47
|
-
return
|
|
46
|
+
return react_1.default.createElement(FilterRangeSingle, Object.assign({}, props));
|
|
48
47
|
}
|
|
49
48
|
console.warn(`filter with display type "${props.filter.displayType}" not yet supported`);
|
|
50
49
|
return null;
|
|
@@ -59,7 +58,7 @@ const FilterSingleList = (props) => {
|
|
|
59
58
|
filterGroup: filtersHook.filterStack,
|
|
60
59
|
}, props.filter);
|
|
61
60
|
const reactiveProps = (0, props_1.getPropsFilterList)(props.filter);
|
|
62
|
-
return (
|
|
61
|
+
return (react_1.default.createElement(SingleList_1.default, Object.assign({}, sharedProps, reactiveProps, { render: (reactivesearchFilterProps) => (react_1.default.createElement(FilterListInner, Object.assign({}, props, { reactivesearchFilterProps: reactivesearchFilterProps }))) })));
|
|
63
62
|
};
|
|
64
63
|
const FilterMultiList = (props) => {
|
|
65
64
|
const reactifySearchContext = (0, hooks_1.useReactifySearchContext)();
|
|
@@ -70,7 +69,7 @@ const FilterMultiList = (props) => {
|
|
|
70
69
|
filterGroup: filtersHook.filterStack,
|
|
71
70
|
}, props.filter);
|
|
72
71
|
const reactiveProps = (0, props_1.getPropsFilterList)(props.filter);
|
|
73
|
-
return (
|
|
72
|
+
return (react_1.default.createElement(MultiList_1.default, Object.assign({}, sharedProps, reactiveProps, { render: (reactivesearchFilterProps) => (react_1.default.createElement(FilterListInner, Object.assign({}, props, { reactivesearchFilterProps: reactivesearchFilterProps }))) })));
|
|
74
73
|
};
|
|
75
74
|
const FilterRangeSingle = (props) => {
|
|
76
75
|
var _a;
|
|
@@ -84,9 +83,12 @@ const FilterRangeSingle = (props) => {
|
|
|
84
83
|
const reactiveProps = (0, props_1.getPropsFilterRange)(props.filter);
|
|
85
84
|
const filterRangeProps = (0, hooks_1.useFilterRangeProps)(props.filter);
|
|
86
85
|
const RenderRangeComponent = (_a = props.renderFilterRange) !== null && _a !== void 0 ? _a : components_1.ExampleFilterRange;
|
|
87
|
-
return (
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
87
|
+
react_1.default.createElement("div", { style: {
|
|
88
|
+
display: "none",
|
|
89
|
+
} },
|
|
90
|
+
react_1.default.createElement(SingleRange_1.default, Object.assign({}, sharedProps, reactiveProps, { value: filterRangeProps.values[0], onChange: filterRangeProps.handleChange }))),
|
|
91
|
+
react_1.default.createElement(RenderRangeComponent, { filterRangeProps: filterRangeProps, filter: props.filter })));
|
|
90
92
|
};
|
|
91
93
|
const FilterRangeMulti = (props) => {
|
|
92
94
|
var _a;
|
|
@@ -100,15 +102,18 @@ const FilterRangeMulti = (props) => {
|
|
|
100
102
|
const reactiveProps = (0, props_1.getPropsFilterRange)(props.filter);
|
|
101
103
|
const filterRangeProps = (0, hooks_1.useFilterRangeProps)(props.filter);
|
|
102
104
|
const RenderRangeComponent = (_a = props.renderFilterRange) !== null && _a !== void 0 ? _a : components_1.ExampleFilterRange;
|
|
103
|
-
return (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
105
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
106
|
+
react_1.default.createElement("div", { style: {
|
|
107
|
+
display: "none",
|
|
108
|
+
} },
|
|
109
|
+
react_1.default.createElement(MultiRange_1.default, Object.assign({}, sharedProps, reactiveProps, { value: filterRangeProps.values,
|
|
110
|
+
// @note: onChange handler must be defined for controlled component to work correctly
|
|
111
|
+
onChange: () => { }, onValueChange: (values) => {
|
|
112
|
+
if (values.length === 0) {
|
|
113
|
+
filterRangeProps.handleClear();
|
|
114
|
+
}
|
|
115
|
+
} }))),
|
|
116
|
+
react_1.default.createElement(RenderRangeComponent, { filterRangeProps: filterRangeProps, filter: props.filter })));
|
|
112
117
|
};
|
|
113
118
|
const FilterSlider = (props) => {
|
|
114
119
|
const reactifySearchContext = (0, hooks_1.useReactifySearchContext)();
|
|
@@ -120,9 +125,9 @@ const FilterSlider = (props) => {
|
|
|
120
125
|
}, props.filter);
|
|
121
126
|
const filterSliderProps = (0, hooks_1.useFilterSliderProps)(props.filter);
|
|
122
127
|
const reactiveProps = (0, props_1.getPropsFilterSlider)(props.filter, "", filterSliderProps.value);
|
|
123
|
-
return (
|
|
124
|
-
return (
|
|
125
|
-
}
|
|
128
|
+
return (react_1.default.createElement(ReactiveComponent_1.default, Object.assign({}, sharedProps, { defaultQuery: () => reactiveProps.defaultQuery, value: filterSliderProps.value, render: (reactivesearchFilterProps) => {
|
|
129
|
+
return (react_1.default.createElement(FilterSliderInner, Object.assign({}, props, { filterSliderProps: filterSliderProps, customQuery: reactiveProps.customQuery, reactivesearchFilterProps: reactivesearchFilterProps })));
|
|
130
|
+
} })));
|
|
126
131
|
};
|
|
127
132
|
// inner component exists only so we can use memos in reactivesearch render functions
|
|
128
133
|
const FilterSliderInner = (props) => {
|
|
@@ -141,9 +146,9 @@ const FilterSliderInner = (props) => {
|
|
|
141
146
|
query: props.customQuery,
|
|
142
147
|
value: filterSliderProps.value,
|
|
143
148
|
});
|
|
144
|
-
}, [filterSliderProps.value
|
|
149
|
+
}, [filterSliderProps.value]);
|
|
145
150
|
const RenderSliderComponent = (_g = props.renderFilterSlider) !== null && _g !== void 0 ? _g : components_1.ExampleFilterSlider;
|
|
146
|
-
return (
|
|
151
|
+
return (react_1.default.createElement(RenderSliderComponent, Object.assign({ filterSliderProps: filterSliderProps, reactSliderProps: reactSliderProps, filter: filter }, otherProps)));
|
|
147
152
|
};
|
|
148
153
|
// inner component exists only so we can use memos in reactivesearch render functions
|
|
149
154
|
const FilterListInner = (props) => {
|
|
@@ -155,6 +160,6 @@ const FilterListInner = (props) => {
|
|
|
155
160
|
return null;
|
|
156
161
|
}
|
|
157
162
|
const RenderListComponent = (_a = props.renderFilterList) !== null && _a !== void 0 ? _a : components_1.ExampleFilterList;
|
|
158
|
-
return (
|
|
163
|
+
return (react_1.default.createElement(RenderListComponent, Object.assign({ filterListProps: filterListProps, filter: filter }, otherProps)));
|
|
159
164
|
};
|
|
160
165
|
//# sourceMappingURL=Filter.js.map
|
|
@@ -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,+GAAuF;AACvF,iHAAyF;AACzF,iDAA8F;AAC9F,uCAMqB;AACrB,sFAAmF;AAEnF,+CAAoH;AA0B7G,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,uBAAC,iBAAiB,oBAAK,KAAK,EAAI,CAAC;QAC1C,CAAC;QACD,OAAO,uBAAC,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,uBAAC,gBAAgB,oBAAK,KAAK,EAAI,CAAC;QACzC,CAAC;QACD,OAAO,uBAAC,eAAe,oBAAK,KAAK,EAAI,CAAC;IACxC,CAAC;IAED,IAAI,QAAQ,KAAK,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QAC1C,OAAO,uBAAC,YAAY,oBAAK,KAAK,EAAI,CAAC;IAC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AAC;IAExE,OAAO,uBAAC,mBAAmB,kBAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,IAAM,UAAU,EAAI,CAAC;AACnG,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 MultiRange from \"@usereactify/search-internals/lib/components/range/MultiRange\";\nimport SingleRange from \"@usereactify/search-internals/lib/components/range/SingleRange\";\nimport { ExampleFilterList, ExampleFilterRange, ExampleFilterSlider } from \"../../components\";\nimport {\n useFilterListProps,\n useFilterRangeProps,\n useFilterSliderProps,\n useFilters,\n useReactifySearchContext,\n} from \"../../hooks\";\nimport { useReactSliderProps } from \"../../hooks/react-slider/useReactSliderProps\";\nimport type { ConfigFilterFacet, ReactivesearchFilterListProps } from \"../../types\";\nimport { getPropsFilterList, getPropsFilterRange, getPropsFilterSlider, 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\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(`filter with display type \"${props.filter.displayType}\" not yet supported`);\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 {\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n },\n props.filter\n );\n const reactiveProps = getPropsFilterList(props.filter);\n\n return (\n <SingleList\n {...sharedProps}\n {...reactiveProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner {...props} reactivesearchFilterProps={reactivesearchFilterProps} />\n )}\n />\n );\n};\n\nconst FilterMultiList: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared(\n {\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n },\n props.filter\n );\n const reactiveProps = getPropsFilterList(props.filter);\n\n return (\n <MultiList\n {...sharedProps}\n {...reactiveProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner {...props} reactivesearchFilterProps={reactivesearchFilterProps} />\n )}\n />\n );\n};\n\nconst FilterRangeSingle: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared(\n {\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n },\n props.filter\n );\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 onChange={filterRangeProps.handleChange}\n value={filterRangeProps.values[0]}\n />\n </div>\n <RenderRangeComponent filter={props.filter} filterRangeProps={filterRangeProps} />\n </>\n );\n};\n\nconst FilterRangeMulti: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared(\n {\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n },\n props.filter\n );\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 onChange={() => {}}\n // @note: onChange handler must be defined for controlled component to work correctly\n onValueChange={(values) => {\n if (values.length === 0) {\n filterRangeProps.handleClear();\n }\n }}\n value={filterRangeProps.values}\n />\n </div>\n <RenderRangeComponent filter={props.filter} filterRangeProps={filterRangeProps} />\n </>\n );\n};\n\nconst FilterSlider: React.FC<FilterProps> = (props) => {\n const reactifySearchContext = useReactifySearchContext();\n const filtersHook = useFilters();\n const sharedProps = getPropsShared(\n {\n provider: reactifySearchContext.options,\n config: reactifySearchContext.config,\n filterGroup: filtersHook.filterStack,\n },\n props.filter\n );\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 render={(reactivesearchFilterProps) => {\n return (\n <FilterSliderInner\n {...props}\n customQuery={reactiveProps.customQuery}\n filterSliderProps={filterSliderProps}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n );\n }}\n value={filterSliderProps.value}\n />\n );\n};\n\n// inner component exists only so we can use memos in reactivesearch render functions\nconst FilterSliderInner: React.FC<\n FilterProps & {\n reactivesearchFilterProps: any;\n filterSliderProps: ReturnType<typeof useFilterSliderProps>;\n customQuery: any;\n }\n> = (props) => {\n const { filter, renderFilterSlider, filterSliderProps, reactivesearchFilterProps, ...otherProps } = 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, props.customQuery, props.reactivesearchFilterProps.setQuery]);\n\n const RenderSliderComponent = props.renderFilterSlider ?? ExampleFilterSlider;\n\n return (\n <RenderSliderComponent\n filter={filter}\n filterSliderProps={filterSliderProps}\n reactSliderProps={reactSliderProps}\n {...otherProps}\n />\n );\n};\n\n// inner component exists only so we can use memos in reactivesearch render functions\nconst FilterListInner: React.FC<FilterProps & { reactivesearchFilterProps: ReactivesearchFilterListProps }> = (\n props\n) => {\n const { filter, renderFilterList, reactivesearchFilterProps, ...otherProps } = 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 <RenderListComponent filter={filter} filterListProps={filterListProps} {...otherProps} />;\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;AA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AAA,KAAK,CAAC,kBAAkB,mCAAI,gCAAmB,CAAC;IAE9E,OAAO,CACL,8BAAC,qBAAqB,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"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useFilterListProps, useFilterRangeProps, useFilterSliderProps } from "../../hooks";
|
|
3
|
+
import { ConfigFilterFacet } from "../../types";
|
|
4
|
+
import { useReactSliderProps } from "../../hooks/react-slider/useReactSliderProps";
|
|
5
5
|
export type FiltersProps = {
|
|
6
6
|
/** Render method for List filters */
|
|
7
7
|
renderFilterList?: React.FC<{
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.Filters = void 0;
|
|
4
|
-
const
|
|
5
|
-
const components_1 = require("../../components");
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
6
8
|
const hooks_1 = require("../../hooks");
|
|
9
|
+
const components_1 = require("../../components");
|
|
7
10
|
const Filters = (props) => {
|
|
8
11
|
var _a;
|
|
9
12
|
const filterStackHook = (0, hooks_1.useFilters)();
|
|
10
|
-
return (
|
|
13
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, (_a = filterStackHook.filters) === null || _a === void 0 ? void 0 : _a.map((filter) => (react_1.default.createElement(components_1.Filter, { key: filter.id, filter: filter, renderFilterList: props.renderFilterList, renderFilterSlider: props.renderFilterSlider, renderFilterRange: props.renderFilterRange, showEmptyFilters: props.showEmptyFilters })))));
|
|
11
14
|
};
|
|
12
15
|
exports.Filters = Filters;
|
|
13
16
|
//# sourceMappingURL=Filters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Filters.js","sourceRoot":"","sources":["../../../../src/components/Filter/Filters.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Filters.js","sourceRoot":"","sources":["../../../../src/components/Filter/Filters.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,uCAKqB;AACrB,iDAA0C;AAyBnC,MAAM,OAAO,GAA2B,CAAC,KAAK,EAAE,EAAE;;IACvD,MAAM,eAAe,GAAG,IAAA,kBAAU,GAAE,CAAC;IAErC,OAAO,CACL,8DACG,MAAA,eAAe,CAAC,OAAO,0CAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACxC,8BAAC,mBAAM,IACL,GAAG,EAAE,MAAM,CAAC,EAAE,EACd,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,EACxC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,EAC5C,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,EAC1C,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,GACxC,CACH,CAAC,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAjBW,QAAA,OAAO,WAiBlB","sourcesContent":["import React from \"react\";\n\nimport {\n useFilterListProps,\n useFilterRangeProps,\n useFilters,\n useFilterSliderProps,\n} from \"../../hooks\";\nimport { Filter } from \"../../components\";\nimport { ConfigFilterFacet } from \"../../types\";\nimport { useReactSliderProps } from \"../../hooks/react-slider/useReactSliderProps\";\n\nexport type FiltersProps = {\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 Filters: React.FC<FiltersProps> = (props) => {\n const filterStackHook = useFilters();\n\n return (\n <>\n {filterStackHook.filters?.map((filter) => (\n <Filter\n key={filter.id}\n filter={filter}\n renderFilterList={props.renderFilterList}\n renderFilterSlider={props.renderFilterSlider}\n renderFilterRange={props.renderFilterRange}\n showEmptyFilters={props.showEmptyFilters}\n />\n ))}\n </>\n );\n};\n"]}
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.FiltersSelected = void 0;
|
|
7
|
-
const
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const SelectedFilters_1 = __importDefault(require("@usereactify/search-internals/lib/components/basic/SelectedFilters"));
|
|
9
9
|
const components_1 = require("../../components");
|
|
10
10
|
const hooks_1 = require("../../hooks");
|
|
@@ -13,9 +13,14 @@ const FiltersSelected = (props) => {
|
|
|
13
13
|
const context = (0, hooks_1.useReactifySearchContext)();
|
|
14
14
|
const filtersHook = (0, hooks_1.useFilters)();
|
|
15
15
|
const RenderComponent = (_a = props.render) !== null && _a !== void 0 ? _a : components_1.ExampleFiltersSelected;
|
|
16
|
-
return (
|
|
16
|
+
return (react_1.default.createElement(SelectedFilters_1.default, { render: ({ selectedValues, setValue }) => {
|
|
17
17
|
const selectedFilters = Object.entries(selectedValues)
|
|
18
|
-
.filter(([
|
|
18
|
+
.filter(([key, item]) => {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
return (item === null || item === void 0 ? void 0 : item.URLParams) &&
|
|
21
|
+
(item === null || item === void 0 ? void 0 : item.showFilter) &&
|
|
22
|
+
(!!((_a = item === null || item === void 0 ? void 0 : item.value) === null || _a === void 0 ? void 0 : _a.length) || !!((_b = item === null || item === void 0 ? void 0 : item.value) === null || _b === void 0 ? void 0 : _b.label));
|
|
23
|
+
})
|
|
19
24
|
.map(([key, item]) => ({
|
|
20
25
|
key: key,
|
|
21
26
|
label: item.label,
|
|
@@ -68,7 +73,7 @@ const FiltersSelected = (props) => {
|
|
|
68
73
|
if (!selectedFilters.length) {
|
|
69
74
|
return null;
|
|
70
75
|
}
|
|
71
|
-
return (
|
|
76
|
+
return (react_1.default.createElement(RenderComponent, { selectedFilters: selectedFilters, handleRemove: handleRemove }));
|
|
72
77
|
} }));
|
|
73
78
|
};
|
|
74
79
|
exports.FiltersSelected = FiltersSelected;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FiltersSelected.js","sourceRoot":"","sources":["../../../../src/components/Filter/FiltersSelected.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FiltersSelected.js","sourceRoot":"","sources":["../../../../src/components/Filter/FiltersSelected.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;AAEjG,iDAA0D;AAC1D,uCAAmE;AAqB5D,MAAM,eAAe,GAAmC,CAAC,KAAK,EAAE,EAAE;;IACvE,MAAM,OAAO,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAC3C,MAAM,WAAW,GAAG,IAAA,kBAAU,GAAE,CAAC;IAEjC,MAAM,eAAe,GAAG,MAAA,KAAK,CAAC,MAAM,mCA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AG,cAAc,CAAC,iBAAiB,CAAC,CAAC,KAAK,CAAC,MAAM,CAC3D,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,KAAK,CAAC,CACzD,CAAC;4BACF,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;wBACtC,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC,CAAC;YAEF,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC;gBAC5B,OAAO,IAAI,CAAC;YACd,CAAC;YAED,OAAO,CACL,8BAAC,eAAe,IACd,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,GAC1B,CACH,CAAC;QACJ,CAAC,GACD,CACH,CAAC;AACJ,CAAC,CAAC;AAvGW,QAAA,eAAe,mBAuG1B","sourcesContent":["import React from \"react\";\nimport SelectedFilters from \"@usereactify/search-internals/lib/components/basic/SelectedFilters\";\n\nimport { ExampleFiltersSelected } from \"../../components\";\nimport { useFilters, useReactifySearchContext } from \"../../hooks\";\n\nexport type FiltersSelectedProps = {\n /** Render method called once for all active filters */\n render?: React.FC<{\n selectedFilters: Array<{\n key: string;\n label: string;\n value:\n | Array<string>\n | string\n | { label: string; start: number; end: number }\n | Array<{ label: string; start: number; end: number }>;\n }>;\n handleRemove: (\n filterKey: string,\n filterValues?: Array<string | number>\n ) => void;\n }>;\n};\n\nexport const FiltersSelected: React.FC<FiltersSelectedProps> = (props) => {\n const context = useReactifySearchContext();\n const filtersHook = useFilters();\n\n const RenderComponent = props.render ?? ExampleFiltersSelected;\n\n return (\n <SelectedFilters\n render={({ selectedValues, setValue }) => {\n const selectedFilters = (\n Object.entries(selectedValues) as Array<[string, any]>\n )\n .filter(\n ([key, item]) =>\n item?.URLParams &&\n item?.showFilter &&\n (!!item?.value?.length || !!item?.value?.label)\n )\n .map(([key, item]) => ({\n key: key,\n label: item.label,\n value: item.value,\n }));\n\n const handleRemove = (\n selectedFilterKey: string,\n selectedFilterValues: Array<string | number> = []\n ) => {\n const filter = filtersHook.filters?.find(\n (filter) => filter.handle === selectedFilterKey\n );\n if (!filter) {\n return;\n }\n\n if (filter.displayType === \"slider\") {\n const event = new CustomEvent<{\n handle: string;\n value: [];\n }>(`@usereactify/search:${context.options.mode}:filter:${filter.handle}:update`, {\n detail: {\n handle: filter.handle,\n value: [],\n },\n });\n window.dispatchEvent(event);\n\n return;\n }\n\n if (selectedFilterValues.length === 0) {\n setValue(selectedFilterKey, null);\n\n return;\n }\n\n if (selectedFilterValues.length > 0) {\n if (filter.displayType === \"single\") {\n setValue(selectedFilterKey, null);\n }\n if (filter.displayType === \"multi\") {\n if (filter.displayView === \"range\") {\n const values = selectedValues[selectedFilterKey].value\n .filter(\n (value: { label: string }) =>\n !selectedFilterValues.includes(value.label)\n )\n .map((value: { label: string }) => value.label);\n\n const event = new CustomEvent<{\n handle: string;\n value: Array<string>;\n }>(`@usereactify/search:${context.options.mode}:filter:${filter.handle}:update`, {\n detail: {\n handle: filter.handle,\n value: values,\n },\n });\n window.dispatchEvent(event);\n }\n if (filter.displayView !== \"range\") {\n const values = selectedValues[selectedFilterKey].value.filter(\n (value: string) => !selectedFilterValues.includes(value)\n );\n setValue(selectedFilterKey, values);\n }\n }\n }\n };\n\n if (!selectedFilters.length) {\n return null;\n }\n\n return (\n <RenderComponent\n selectedFilters={selectedFilters}\n handleRemove={handleRemove}\n />\n );\n }}\n />\n );\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { PropsWithChildren, ReactNode } from "react";
|
|
2
|
+
import { Config } from "../../types";
|
|
3
3
|
export type ReactifySearchProviderProps = {
|
|
4
4
|
/** Standard react children */
|
|
5
5
|
children?: ReactNode | undefined;
|
|
@@ -27,13 +27,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.ReactifySearchProvider = ReactifySearchProvider;
|
|
30
|
-
const
|
|
31
|
-
const react_1 = require("react");
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
32
31
|
// @ts-expect-error missing types
|
|
33
32
|
const GaGtag = __importStar(require("ga-gtag"));
|
|
34
33
|
const package_json_1 = __importDefault(require("../../../package.json"));
|
|
35
|
-
const components_1 = require("../../components");
|
|
36
34
|
const hooks_1 = require("../../hooks");
|
|
35
|
+
const components_1 = require("../../components");
|
|
37
36
|
const utility_1 = require("../../utility");
|
|
38
37
|
const curation_1 = require("../../utility/curation");
|
|
39
38
|
function ReactifySearchProvider(props) {
|
|
@@ -47,7 +46,7 @@ function ReactifySearchProvider(props) {
|
|
|
47
46
|
},
|
|
48
47
|
});
|
|
49
48
|
}, [props]);
|
|
50
|
-
return
|
|
49
|
+
return react_1.default.createElement(ReactifySearchInner, Object.assign({}, props));
|
|
51
50
|
}
|
|
52
51
|
function ReactifySearchInner(props) {
|
|
53
52
|
var _a, _b;
|
|
@@ -75,7 +74,7 @@ function ReactifySearchInner(props) {
|
|
|
75
74
|
if (indexFromURLParam)
|
|
76
75
|
setIndexFromURL(indexFromURLParam);
|
|
77
76
|
}
|
|
78
|
-
}, [
|
|
77
|
+
}, []);
|
|
79
78
|
// results
|
|
80
79
|
const [results, setResults] = (0, react_1.useState)([]);
|
|
81
80
|
// curation
|
|
@@ -112,28 +111,17 @@ function ReactifySearchInner(props) {
|
|
|
112
111
|
},
|
|
113
112
|
curation: curation,
|
|
114
113
|
};
|
|
115
|
-
}, [
|
|
116
|
-
config,
|
|
117
|
-
props,
|
|
118
|
-
searchTerm,
|
|
119
|
-
showInstantSearchResults,
|
|
120
|
-
searchRedirect,
|
|
121
|
-
sortOption,
|
|
122
|
-
results,
|
|
123
|
-
resultStats,
|
|
124
|
-
curation,
|
|
125
|
-
indexFromURL,
|
|
126
|
-
theme,
|
|
127
|
-
]);
|
|
114
|
+
}, [config, props, searchTerm, showInstantSearchResults, searchRedirect, sortOption, results, resultStats, curation]);
|
|
128
115
|
(0, react_1.useEffect)(() => {
|
|
129
116
|
utility_1.debug.log("curation", "content", curation);
|
|
130
|
-
}, [curation === null || curation === void 0 ? void 0 : curation.id
|
|
117
|
+
}, [curation === null || curation === void 0 ? void 0 : curation.id]);
|
|
131
118
|
utility_1.debug.hook("ReactifySearchProvider", "context", contextValue);
|
|
132
119
|
if (!contextValue) {
|
|
133
120
|
if (props.renderBooting)
|
|
134
121
|
return props.renderBooting();
|
|
135
122
|
return null;
|
|
136
123
|
}
|
|
137
|
-
return (
|
|
124
|
+
return (react_1.default.createElement(hooks_1.ReactifySearchContext.Provider, { value: contextValue },
|
|
125
|
+
react_1.default.createElement(components_1.UtilityAuthenticatedReactiveBase, null, props.children)));
|
|
138
126
|
}
|
|
139
127
|
//# sourceMappingURL=ReactifySearchProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactifySearchProvider.js","sourceRoot":"","sources":["../../../../src/components/ReactifySearchProvider/ReactifySearchProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,wDAcC;;AA9ED,iCAA6F;AAC7F,iCAAiC;AACjC,gDAAkC;AAClC,yEAAwC;AACxC,iDAAoE;AACpE,uCAA+D;AAE/D,2CAAsC;AACtC,qDAAqD;AAwDrD,SAAgB,sBAAsB,CAAC,KAAqD;IAC1F,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,eAAK,CAAC,GAAG,CAAC,wBAAwB,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAEpD,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE;YAC7B,aAAa,EAAE,KAAK;YACpB,eAAe,EAAE;gBACf,IAAI,EAAE,KAAK,CAAC,sBAAsB;gBAClC,OAAO,EAAE,sBAAG,CAAC,OAAO;aACrB;SACF,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,uBAAC,mBAAmB,o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K,CAAC,aAAa;YAAE,OAAO,KAAK,CAAC,aAAa,EAAE,CAAC;QACtD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,uBAAC,6BAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YACjD,uBAAC,6CAAgC,cAAE,KAAK,CAAC,QAAQ,GAAoC,GACtD,CAClC,CAAC;AACJ,CAAC","sourcesContent":["import { type PropsWithChildren, type ReactNode, useEffect, useMemo, useState } from \"react\";\n// @ts-expect-error missing types\nimport * as GaGtag from \"ga-gtag\";\nimport pkg from \"../../../package.json\";\nimport { UtilityAuthenticatedReactiveBase } from \"../../components\";\nimport { ReactifySearchContext, useConfig } from \"../../hooks\";\nimport type { Config, ConfigCuration, ConfigRedirect, ReactivesearchResultProps } from \"../../types\";\nimport { debug } from \"../../utility\";\nimport { getCuration } from \"../../utility/curation\";\n\nexport type ReactifySearchProviderProps = {\n /** Standard react children */\n children?: ReactNode | undefined;\n /** The search area the provider will be used in */\n mode: \"search\" | \"collection\" | \"instant-search\";\n /** The variation of the search area the provider will be used in */\n /** Shopify store domain used to resolve the site configuration */\n shopifyPermanentDomain: string;\n /** Market ID used to change merchandising based on market e.g. 7494533198 */\n market?: string;\n /** Callback function for redirects, suitable for headless sites to avoid full page refresh */\n onRedirect?: (type: \"redirect\" | \"search\", url: string) => void;\n /** Render method to display a component when the config is loading */\n renderBooting?: () => JSX.Element | null;\n /** Advanced usage: Override the default Reactify Search id (for telemetry) */\n clientId?: string;\n /** Advanced usage: Override the default Filters selection logic */\n filtersHandle?: string;\n /** Advanced usage: Array of additional component IDs managed outside of Reactify Search */\n additionalComponentIds?: Array<string>;\n /** Advanced usage: Override the default Elasticsearch index */\n index?: string;\n /** Advanced usage: Override the default Reactify Search config (for multi-instance stores) */\n configId?: string;\n /** Advanced usage: Override the default Elasticsearch credentials */\n credentials?: string;\n /** Advanced usage: Override the default ReactiveBase theme */\n theme?: Record<string, unknown>;\n /** Advanced usage: Fields to include in the Elasticsearch response e.g. [\"title\"] */\n includeFields?: Array<string>;\n /** Advanced usage: Fields to exclude from the Elasticsearch response e.g. [\"variant_skus\", \"*price*\"] */\n excludeFields?: Array<string>;\n /** Advanced usage: Server content for SSR */\n query?: Record<string, string>;\n /** Advanced usage: Override the default config base URL for local testing */\n configBaseUrl?: string;\n /** Development mode: enables score breakdown features (default: false) */\n devMode?: boolean;\n preload?: {\n config: Config;\n state: unknown;\n };\n} & (\n | {\n mode: \"search\";\n }\n | {\n mode: \"collection\";\n /** Collection object that includes the handle, used to find curations */\n collectionHandle: string;\n }\n | { mode: \"instant-search\" }\n);\n\nexport function ReactifySearchProvider(props: PropsWithChildren<ReactifySearchProviderProps>) {\n useEffect(() => {\n debug.log(\"ReactifySearchProvider\", \"props\", props);\n\n GaGtag.install(\"G-DV00Z0X5VP\", {\n cookie_prefix: \"_rs\",\n user_properties: {\n shop: props.shopifyPermanentDomain,\n version: pkg.version,\n },\n });\n }, [props]);\n\n return <ReactifySearchInner {...props} />;\n}\n\nfunction ReactifySearchInner(props: PropsWithChildren<ReactifySearchProviderProps>) {\n const { config } = useConfig(props.shopifyPermanentDomain, props.preload?.config, props.configBaseUrl);\n const theme = props.theme ?? { typography: { fontFamily: \"inherit\", fontSize: \"inherit\" } };\n\n // search term\n const [searchTerm, setSearchTerm] = useState<string>(\"\");\n const [showInstantSearchResults, setShowInstantSearchResults] = useState<boolean>(false);\n const [sortOption, setSortOption] = useState<string>(\"\");\n const [indexFromURL, setIndexFromURL] = useState<string | null>(null);\n const searchRedirect = useMemo<ConfigRedirect | undefined>(() => {\n return config?.redirects.find(\n (redirect) => redirect.query.trim().toLowerCase() === searchTerm.trim().toLowerCase()\n );\n }, [config?.redirects, searchTerm]);\n\n // hydration-safe URL param initialization\n useEffect(() => {\n if (typeof window !== \"undefined\") {\n const urlParams = new URLSearchParams(window.location.search);\n const searchTermFromURL = urlParams.get(\"q\");\n const searchSortFromURL = urlParams.get(\"sort\");\n const indexFromURLParam = urlParams.get(\"index\");\n if (searchTermFromURL && searchTermFromURL !== searchTerm) setSearchTerm(searchTermFromURL);\n if (searchSortFromURL && searchSortFromURL !== sortOption) setSortOption(searchSortFromURL);\n if (indexFromURLParam) setIndexFromURL(indexFromURLParam);\n }\n }, [searchTerm, sortOption]);\n\n // results\n const [results, setResults] = useState<ReactivesearchResultProps[\"data\"]>([]);\n\n // curation\n const curation = useMemo<ConfigCuration | undefined>(() => {\n if (!config) return undefined;\n return getCuration({ provider: props, config: config, searchTerm: searchTerm });\n }, [props, config, searchTerm]);\n\n // result stats\n const [resultStats, setResultStats] = useState<ReactivesearchResultProps[\"resultStats\"]>();\n\n const contextValue = useMemo(() => {\n if (!config) return;\n\n return {\n config: config,\n options: {\n ...props,\n clientId: props.clientId ?? \"theme\",\n index: props.index ?? indexFromURL ?? config.index,\n filtersHandle: props.filtersHandle,\n credentials: props.credentials,\n theme: theme,\n configBaseUrl: props.configBaseUrl,\n devMode: props.devMode ?? false,\n },\n search: {\n searchTerm: searchTerm,\n setSearchTerm: setSearchTerm,\n showInstantSearchResults: showInstantSearchResults,\n setShowInstantSearchResults: setShowInstantSearchResults,\n searchRedirect: searchRedirect,\n },\n sortby: {\n sortOption: sortOption,\n setSortOption: setSortOption,\n },\n results: {\n results: results,\n setResults: setResults,\n resultStats: resultStats,\n setResultStats: setResultStats,\n },\n curation: curation,\n };\n }, [\n config,\n props,\n searchTerm,\n showInstantSearchResults,\n searchRedirect,\n sortOption,\n results,\n resultStats,\n curation,\n indexFromURL,\n theme,\n ]);\n\n useEffect(() => {\n debug.log(\"curation\", \"content\", curation);\n }, [curation?.id, curation]);\n\n debug.hook(\"ReactifySearchProvider\", \"context\", contextValue);\n\n if (!contextValue) {\n if (props.renderBooting) return props.renderBooting();\n return null;\n }\n\n return (\n <ReactifySearchContext.Provider value={contextValue}>\n <UtilityAuthenticatedReactiveBase>{props.children}</UtilityAuthenticatedReactiveBase>\n </ReactifySearchContext.Provider>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ReactifySearchProvider.js","sourceRoot":"","sources":["../../../../src/components/ReactifySearchProvider/ReactifySearchProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,wDAcC;AAhFD,+CAA0F;AAC1F,iCAAiC;AACjC,gDAAkC;AAElC,yEAAwC;AAExC,uCAA+D;AAC/D,iDAAoE;AACpE,2CAAsC;AAEtC,qDAAqD;AAwDrD,SAAgB,sBAAsB,CAAC,KAAqD;IAC1F,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,eAAK,CAAC,GAAG,CAAC,wBAAwB,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAEpD,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE;YAC7B,aAAa,EAAE,KAAK;YACpB,eAAe,EAAE;gBACf,IAAI,EAAE,KAAK,CAAC,sBAAsB;gBAClC,OAAO,EAAE,sBAAG,CAAC,OAAO;aACrB;SACF,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,8BAAC,mBAAmB,oBAAK,KAAK,EAAI,CAAC;AAC5C,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAqD;;IAChF,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,iBAAS,EAAC,KAAK,CAAC,sBAAsB,EAAE,MAAA,KAAK,CAAC,OAAO,0CAAE,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IACvG,MAAM,KAAK,GAAG,MAAA,KAAK,CAAC,KAAK,mCAAI,EAAE,UAAU,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,CAAC;IAE5F,cAAc;IACd,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAAS,EAAE,CAAC,CAAC;IACzD,MAAM,CAAC,wBAAwB,EAAE,2BAA2B,CAAC,GAAG,IAAA,gBAAQ,EAAU,KAAK,CAAC,CAAC;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AE;gBACP,OAAO,EAAE,OAAO;gBAChB,UAAU,EAAE,UAAU;gBACtB,WAAW,EAAE,WAAW;gBACxB,cAAc,EAAE,cAAc;aAC/B;YACD,QAAQ,EAAE,QAAQ;SACnB,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,wBAAwB,EAAE,cAAc,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEtH,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,eAAK,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC,EAAE,CAAC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,EAAE,CAAC,CAAC,CAAC;IAEnB,eAAK,CAAC,IAAI,CAAC,wBAAwB,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;IAE9D,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,IAAI,KAAK,CAAC,aAAa;YAAE,OAAO,KAAK,CAAC,aAAa,EAAE,CAAC;QACtD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,8BAAC,6BAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY;QACjD,8BAAC,6CAAgC,QAAE,KAAK,CAAC,QAAQ,CAAoC,CACtD,CAClC,CAAC;AACJ,CAAC","sourcesContent":["import React, { PropsWithChildren, ReactNode, useEffect, useMemo, useState } from \"react\";\n// @ts-expect-error missing types\nimport * as GaGtag from \"ga-gtag\";\n\nimport pkg from \"../../../package.json\";\n\nimport { ReactifySearchContext, useConfig } from \"../../hooks\";\nimport { UtilityAuthenticatedReactiveBase } from \"../../components\";\nimport { debug } from \"../../utility\";\nimport { Config, ConfigCuration, ConfigRedirect, ReactivesearchResultProps } from \"../../types\";\nimport { getCuration } from \"../../utility/curation\";\n\nexport type ReactifySearchProviderProps = {\n /** Standard react children */\n children?: ReactNode | undefined;\n /** The search area the provider will be used in */\n mode: \"search\" | \"collection\" | \"instant-search\";\n /** The variation of the search area the provider will be used in */\n /** Shopify store domain used to resolve the site configuration */\n shopifyPermanentDomain: string;\n /** Market ID used to change merchandising based on market e.g. 7494533198 */\n market?: string;\n /** Callback function for redirects, suitable for headless sites to avoid full page refresh */\n onRedirect?: (type: \"redirect\" | \"search\", url: string) => void;\n /** Render method to display a component when the config is loading */\n renderBooting?: () => JSX.Element | null;\n /** Advanced usage: Override the default Reactify Search id (for telemetry) */\n clientId?: string;\n /** Advanced usage: Override the default Filters selection logic */\n filtersHandle?: string;\n /** Advanced usage: Array of additional component IDs managed outside of Reactify Search */\n additionalComponentIds?: Array<string>;\n /** Advanced usage: Override the default Elasticsearch index */\n index?: string;\n /** Advanced usage: Override the default Reactify Search config (for multi-instance stores) */\n configId?: string;\n /** Advanced usage: Override the default Elasticsearch credentials */\n credentials?: string;\n /** Advanced usage: Override the default ReactiveBase theme */\n theme?: Record<string, unknown>;\n /** Advanced usage: Fields to include in the Elasticsearch response e.g. [\"title\"] */\n includeFields?: Array<string>;\n /** Advanced usage: Fields to exclude from the Elasticsearch response e.g. [\"variant_skus\", \"*price*\"] */\n excludeFields?: Array<string>;\n /** Advanced usage: Server content for SSR */\n query?: Record<string, string>;\n /** Advanced usage: Override the default config base URL for local testing */\n configBaseUrl?: string;\n /** Development mode: enables score breakdown features (default: false) */\n devMode?: boolean;\n preload?: {\n config: Config;\n state: unknown;\n };\n} & (\n | {\n mode: \"search\";\n }\n | {\n mode: \"collection\";\n /** Collection object that includes the handle, used to find curations */\n collectionHandle: string;\n }\n | { mode: \"instant-search\" }\n);\n\nexport function ReactifySearchProvider(props: PropsWithChildren<ReactifySearchProviderProps>) {\n useEffect(() => {\n debug.log(\"ReactifySearchProvider\", \"props\", props);\n\n GaGtag.install(\"G-DV00Z0X5VP\", {\n cookie_prefix: \"_rs\",\n user_properties: {\n shop: props.shopifyPermanentDomain,\n version: pkg.version,\n },\n });\n }, [props]);\n\n return <ReactifySearchInner {...props} />;\n}\n\nfunction ReactifySearchInner(props: PropsWithChildren<ReactifySearchProviderProps>) {\n const { config } = useConfig(props.shopifyPermanentDomain, props.preload?.config, props.configBaseUrl);\n const theme = props.theme ?? { typography: { fontFamily: \"inherit\", fontSize: \"inherit\" } };\n\n // search term\n const [searchTerm, setSearchTerm] = useState<string>(\"\");\n const [showInstantSearchResults, setShowInstantSearchResults] = useState<boolean>(false);\n const [sortOption, setSortOption] = useState<string>(\"\");\n const [indexFromURL, setIndexFromURL] = useState<string | null>(null);\n const searchRedirect = useMemo<ConfigRedirect | undefined>(() => {\n return config?.redirects.find(\n (redirect) => redirect.query.trim().toLowerCase() === searchTerm.trim().toLowerCase()\n );\n }, [config?.redirects, searchTerm]);\n\n // hydration-safe URL param initialization\n useEffect(() => {\n if (typeof window !== \"undefined\") {\n const urlParams = new URLSearchParams(window.location.search);\n const searchTermFromURL = urlParams.get(\"q\");\n const searchSortFromURL = urlParams.get(\"sort\");\n const indexFromURLParam = urlParams.get(\"index\");\n if (searchTermFromURL && searchTermFromURL !== searchTerm) setSearchTerm(searchTermFromURL);\n if (searchSortFromURL && searchSortFromURL !== sortOption) setSortOption(searchSortFromURL);\n if (indexFromURLParam) setIndexFromURL(indexFromURLParam);\n }\n }, []);\n\n // results\n const [results, setResults] = useState<ReactivesearchResultProps[\"data\"]>([]);\n\n // curation\n const curation = useMemo<ConfigCuration | undefined>(() => {\n if (!config) return undefined;\n return getCuration({ provider: props, config: config, searchTerm: searchTerm });\n }, [props, config, searchTerm]);\n\n // result stats\n const [resultStats, setResultStats] = useState<ReactivesearchResultProps[\"resultStats\"]>();\n\n const contextValue = useMemo(() => {\n if (!config) return;\n\n return {\n config: config,\n options: {\n ...props,\n clientId: props.clientId ?? \"theme\",\n index: props.index ?? indexFromURL ?? config.index,\n filtersHandle: props.filtersHandle,\n credentials: props.credentials,\n theme: theme,\n configBaseUrl: props.configBaseUrl,\n devMode: props.devMode ?? false,\n },\n search: {\n searchTerm: searchTerm,\n setSearchTerm: setSearchTerm,\n showInstantSearchResults: showInstantSearchResults,\n setShowInstantSearchResults: setShowInstantSearchResults,\n searchRedirect: searchRedirect,\n },\n sortby: {\n sortOption: sortOption,\n setSortOption: setSortOption,\n },\n results: {\n results: results,\n setResults: setResults,\n resultStats: resultStats,\n setResultStats: setResultStats,\n },\n curation: curation,\n };\n }, [config, props, searchTerm, showInstantSearchResults, searchRedirect, sortOption, results, resultStats, curation]);\n\n useEffect(() => {\n debug.log(\"curation\", \"content\", curation);\n }, [curation?.id]);\n\n debug.hook(\"ReactifySearchProvider\", \"context\", contextValue);\n\n if (!contextValue) {\n if (props.renderBooting) return props.renderBooting();\n return null;\n }\n\n return (\n <ReactifySearchContext.Provider value={contextValue}>\n <UtilityAuthenticatedReactiveBase>{props.children}</UtilityAuthenticatedReactiveBase>\n </ReactifySearchContext.Provider>\n );\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import { ElasticCallout } from "../../types";
|
|
3
|
+
import { ResultsProps } from "..";
|
|
4
4
|
export type ResultCardCalloutProps = {
|
|
5
5
|
pagePosition: number;
|
|
6
6
|
document: ElasticCallout;
|
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ResultCardCallout = void 0;
|
|
7
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
7
|
const react_1 = __importDefault(require("react"));
|
|
9
8
|
const react_intersection_observer_1 = require("react-intersection-observer");
|
|
10
9
|
const hooks_1 = require("../../hooks");
|
|
@@ -40,9 +39,9 @@ const ResultCardCallout = (props) => {
|
|
|
40
39
|
(_a = props.onView) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
41
40
|
handleView();
|
|
42
41
|
}
|
|
43
|
-
}, [inView
|
|
42
|
+
}, [inView]);
|
|
44
43
|
const RenderComponent = (_a = props.render) !== null && _a !== void 0 ? _a : __1.ExampleResultCardCallout;
|
|
45
|
-
return
|
|
44
|
+
return react_1.default.createElement(RenderComponent, Object.assign({}, props, { itemRef: ref, handleClick: handleClick }));
|
|
46
45
|
};
|
|
47
46
|
exports.ResultCardCallout = ResultCardCallout;
|
|
48
47
|
//# sourceMappingURL=ResultCardCallout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResultCardCallout.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultCardCallout.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ResultCardCallout.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultCardCallout.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,6EAAwD;AAGxD,uCAA2C;AAC3C,0BAA4D;AAUrD,MAAM,iBAAiB,GAAqC,CAAC,KAAK,EAAE,EAAE;;IAC3E,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,oBAAY,GAAE,CAAC;IACjC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAA,uCAAS,EAAC;QAChC,SAAS,EAAE,GAAG;QACd,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,eAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QACzC,KAAK,CAAC;YACJ,SAAS,EAAE,gBAAgB;YAC3B,OAAO,EAAE;gBACP,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI;gBACxB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK;aAC3B;SACF,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAE3B,MAAM,UAAU,GAAG,eAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QACxC,KAAK,CAAC;YACJ,SAAS,EAAE,eAAe;YAC1B,OAAO,EAAE;gBACP,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI;gBACxB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK;aAC3B;SACF,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAE3B,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;;QACnB,IAAI,MAAM,EAAE,CAAC;YACX,MAAA,KAAK,CAAC,MAAM,qDAAI,CAAC;YACjB,UAAU,EAAE,CAAC;QACf,CAAC;IACH,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,MAAM,eAAe,GAAG,MAAA,KAAK,CAAC,MAAM,mCAAI,4BAAwB,CAAC;IAEjE,OAAO,8BAAC,eAAe,oBAAK,KAAK,IAAE,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,IAAI,CAAC;AAChF,CAAC,CAAC;AArCW,QAAA,iBAAiB,qBAqC5B","sourcesContent":["import React from \"react\";\nimport { useInView } from \"react-intersection-observer\";\n\nimport { ElasticCallout } from \"../../types\";\nimport { useAnalytics } from \"../../hooks\";\nimport { ResultsProps, ExampleResultCardCallout } from \"..\";\n\nexport type ResultCardCalloutProps = {\n pagePosition: number;\n document: ElasticCallout;\n callout: ElasticCallout[\"callout\"];\n render?: ResultsProps[\"renderResultCardCallout\"];\n onView?: () => void;\n};\n\nexport const ResultCardCallout: React.FC<ResultCardCalloutProps> = (props) => {\n const { track } = useAnalytics();\n const { ref, inView } = useInView({\n threshold: 0.5,\n triggerOnce: true,\n });\n\n const handleClick = React.useCallback(() => {\n track({\n eventName: \"clickPromotion\",\n payload: {\n link: props.callout.link,\n title: props.callout.title,\n },\n });\n }, [track, props.callout]);\n\n const handleView = React.useCallback(() => {\n track({\n eventName: \"viewPromotion\",\n payload: {\n link: props.callout.link,\n title: props.callout.title,\n },\n });\n }, [track, props.callout]);\n\n React.useEffect(() => {\n if (inView) {\n props.onView?.();\n handleView();\n }\n }, [inView]);\n\n const RenderComponent = props.render ?? ExampleResultCardCallout;\n\n return <RenderComponent {...props} itemRef={ref} handleClick={handleClick} />;\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { type ResultsProps } from "../../components";
|
|
3
2
|
import type { ElasticProduct } from "../../types";
|
|
3
|
+
import { ResultsProps } from "../../components";
|
|
4
4
|
export type ResultCardProductProps = {
|
|
5
5
|
pagePosition: number;
|
|
6
6
|
product: ElasticProduct;
|
|
@@ -4,11 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ResultCardProduct = void 0;
|
|
7
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
7
|
const react_1 = __importDefault(require("react"));
|
|
9
8
|
const react_intersection_observer_1 = require("react-intersection-observer");
|
|
10
|
-
const components_1 = require("../../components");
|
|
11
9
|
const hooks_1 = require("../../hooks");
|
|
10
|
+
const components_1 = require("../../components");
|
|
12
11
|
const ResultCardProduct = (props) => {
|
|
13
12
|
var _a;
|
|
14
13
|
const productPrice = (0, hooks_1.useProductPrice)(props.product);
|
|
@@ -45,9 +44,9 @@ const ResultCardProduct = (props) => {
|
|
|
45
44
|
(_a = props.onView) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
46
45
|
handleView();
|
|
47
46
|
}
|
|
48
|
-
}, [inView
|
|
47
|
+
}, [inView]);
|
|
49
48
|
const RenderComponent = (_a = props.render) !== null && _a !== void 0 ? _a : components_1.ExampleResultCardProduct;
|
|
50
|
-
return (
|
|
49
|
+
return (react_1.default.createElement(RenderComponent, Object.assign({}, productPrice, { pagePosition: props.pagePosition, product: props.product, document: props.document, itemRef: ref, handleClick: handleClick })));
|
|
51
50
|
};
|
|
52
51
|
exports.ResultCardProduct = ResultCardProduct;
|
|
53
52
|
//# sourceMappingURL=ResultCardProduct.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResultCardProduct.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultCardProduct.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ResultCardProduct.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultCardProduct.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,6EAAwD;AAGxD,uCAA4D;AAC5D,iDAA0E;AAUnE,MAAM,iBAAiB,GAAqC,CAAC,KAAK,EAAE,EAAE;;IAC3E,MAAM,YAAY,GAAG,IAAA,uBAAe,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAEpD,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,oBAAY,GAAE,CAAC;IACjC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAA,uCAAS,EAAC;QAChC,SAAS,EAAE,GAAG;QACd,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,eAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QACzC,KAAK,CAAC;YACJ,SAAS,EAAE,cAAc;YACzB,OAAO,EAAE;gBACP,cAAc,EAAE;oBACd,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE;oBACpB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK;iBAC3B;aACF;SACF,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAE3B,MAAM,UAAU,GAAG,eAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QACxC,KAAK,CAAC;YACJ,SAAS,EAAE,aAAa;YACxB,OAAO,EAAE;gBACP,cAAc,EAAE;oBACd,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE;oBACpB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK;iBAC3B;aACF;SACF,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAE3B,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;;QACnB,IAAI,MAAM,EAAE,CAAC;YACX,MAAA,KAAK,CAAC,MAAM,qDAAI,CAAC;YACjB,UAAU,EAAE,CAAC;QACf,CAAC;IACH,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,MAAM,eAAe,GAAG,MAAA,KAAK,CAAC,MAAM,mCAAI,qCAAwB,CAAC;IAEjE,OAAO,CACL,8BAAC,eAAe,oBACV,YAAY,IAChB,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,OAAO,EAAE,GAAG,EACZ,WAAW,EAAE,WAAW,IACxB,CACH,CAAC;AACJ,CAAC,CAAC;AApDW,QAAA,iBAAiB,qBAoD5B","sourcesContent":["import React from \"react\";\nimport { useInView } from \"react-intersection-observer\";\n\nimport type { ElasticProduct } from \"../../types\";\nimport { useProductPrice, useAnalytics } from \"../../hooks\";\nimport { ResultsProps, ExampleResultCardProduct } from \"../../components\";\n\nexport type ResultCardProductProps = {\n pagePosition: number;\n product: ElasticProduct;\n document: ElasticProduct;\n render?: ResultsProps[\"renderResultCardProduct\"];\n onView?: () => void;\n};\n\nexport const ResultCardProduct: React.FC<ResultCardProductProps> = (props) => {\n const productPrice = useProductPrice(props.product);\n\n const { track } = useAnalytics();\n const { ref, inView } = useInView({\n threshold: 0.5,\n triggerOnce: true,\n });\n\n const handleClick = React.useCallback(() => {\n track({\n eventName: \"clickProduct\",\n payload: {\n elasticProduct: {\n id: props.product.id,\n title: props.product.title,\n },\n },\n });\n }, [track, props.product]);\n\n const handleView = React.useCallback(() => {\n track({\n eventName: \"viewProduct\",\n payload: {\n elasticProduct: {\n id: props.product.id,\n title: props.product.title,\n },\n },\n });\n }, [track, props.product]);\n\n React.useEffect(() => {\n if (inView) {\n props.onView?.();\n handleView();\n }\n }, [inView]);\n\n const RenderComponent = props.render ?? ExampleResultCardProduct;\n\n return (\n <RenderComponent\n {...productPrice}\n pagePosition={props.pagePosition}\n product={props.product}\n document={props.document}\n itemRef={ref}\n handleClick={handleClick}\n />\n );\n};\n"]}
|