@usereactify/search 5.0.0-beta.0 → 5.0.0-beta.11
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 +67 -0
- package/dist/package.json +8 -3
- package/dist/src/components/{example → Example}/ExampleFilterList.d.ts +1 -1
- package/dist/src/components/Example/ExampleFilterList.js +21 -0
- package/dist/src/components/Example/ExampleFilterList.js.map +1 -0
- package/dist/src/components/{example → Example}/ExampleFilterRange.d.ts +1 -1
- package/dist/src/components/{example → Example}/ExampleFilterRange.js +5 -4
- package/dist/src/components/Example/ExampleFilterRange.js.map +1 -0
- package/dist/src/components/{example → Example}/ExampleFilterSlider.d.ts +1 -1
- package/dist/src/components/{example → Example}/ExampleFilterSlider.js +4 -3
- package/dist/src/components/Example/ExampleFilterSlider.js.map +1 -0
- package/dist/src/components/{example → Example}/ExampleFilterStack.d.ts +1 -1
- package/dist/src/components/{example → Example}/ExampleFilterStack.js +1 -0
- package/dist/src/components/Example/ExampleFilterStack.js.map +1 -0
- package/dist/src/components/{example → Example}/ExampleResultCardCallout.d.ts +1 -1
- package/dist/src/components/{example → Example}/ExampleResultCardCallout.js +5 -4
- package/dist/src/components/Example/ExampleResultCardCallout.js.map +1 -0
- package/dist/src/components/{example → Example}/ExampleResultCardProduct.d.ts +1 -1
- package/dist/src/components/Example/ExampleResultCardProduct.js +19 -0
- package/dist/src/components/Example/ExampleResultCardProduct.js.map +1 -0
- package/dist/src/components/{example → Example}/ExampleResultPaginationLoadMore.d.ts +1 -1
- package/dist/src/components/{example → Example}/ExampleResultPaginationLoadMore.js +2 -1
- package/dist/src/components/Example/ExampleResultPaginationLoadMore.js.map +1 -0
- package/dist/src/components/{example → Example}/ExampleResultPaginationNextPrev.d.ts +1 -1
- package/dist/src/components/{example → Example}/ExampleResultPaginationNextPrev.js +4 -3
- package/dist/src/components/Example/ExampleResultPaginationNextPrev.js.map +1 -0
- package/dist/src/components/{example → Example}/ExampleResultPaginationNumbered.d.ts +1 -1
- package/dist/src/components/Example/ExampleResultPaginationNumbered.js +27 -0
- package/dist/src/components/Example/ExampleResultPaginationNumbered.js.map +1 -0
- package/dist/src/components/{example → Example}/ExampleSortby.d.ts +1 -1
- package/dist/src/components/Example/ExampleSortby.js +13 -0
- package/dist/src/components/Example/ExampleSortby.js.map +1 -0
- package/dist/src/components/{example → Example}/index.d.ts +0 -0
- package/dist/src/components/{example → Example}/index.js +1 -0
- package/dist/src/components/Example/index.js.map +1 -0
- package/dist/src/components/{filter → Filter}/Filter.d.ts +0 -0
- package/dist/src/components/{filter → Filter}/Filter.js +8 -19
- package/dist/src/components/Filter/Filter.js.map +1 -0
- package/dist/src/components/{filter → Filter}/FilterStack.d.ts +0 -0
- package/dist/src/components/{filter → Filter}/FilterStack.js +1 -0
- package/dist/src/components/Filter/FilterStack.js.map +1 -0
- package/dist/src/components/{filter → Filter}/index.d.ts +0 -0
- package/dist/src/components/{filter → Filter}/index.js +1 -0
- package/dist/src/components/Filter/index.js.map +1 -0
- package/dist/src/components/{context → ReactifySearchBase}/ReactifySearchBase.d.ts +0 -0
- package/dist/src/components/{context → ReactifySearchBase}/ReactifySearchBase.js +28 -37
- package/dist/src/components/ReactifySearchBase/ReactifySearchBase.js.map +1 -0
- package/dist/src/components/{context → ReactifySearchBase}/index.d.ts +0 -0
- package/dist/src/components/{context → ReactifySearchBase}/index.js +1 -0
- package/dist/src/components/ReactifySearchBase/index.js.map +1 -0
- package/dist/src/components/{result → Result}/ResultCardCallout.d.ts +0 -0
- package/dist/src/components/{result → Result}/ResultCardCallout.js +4 -5
- package/dist/src/components/Result/ResultCardCallout.js.map +1 -0
- package/dist/src/components/{result → Result}/ResultCardProduct.d.ts +0 -0
- package/dist/src/components/{result → Result}/ResultCardProduct.js +5 -18
- package/dist/src/components/Result/ResultCardProduct.js.map +1 -0
- package/dist/src/components/{result → Result}/ResultPaginationLoadMore.d.ts +0 -0
- package/dist/src/components/{result → Result}/ResultPaginationLoadMore.js +1 -0
- package/dist/src/components/Result/ResultPaginationLoadMore.js.map +1 -0
- package/dist/src/components/{result → Result}/ResultPaginationNextPrev.d.ts +0 -0
- package/dist/src/components/{result → Result}/ResultPaginationNextPrev.js +1 -0
- package/dist/src/components/Result/ResultPaginationNextPrev.js.map +1 -0
- package/dist/src/components/{result → Result}/ResultPaginationNumbered.d.ts +0 -0
- package/dist/src/components/{result → Result}/ResultPaginationNumbered.js +1 -0
- package/dist/src/components/Result/ResultPaginationNumbered.js.map +1 -0
- package/dist/src/components/{result → Result}/ResultStack.d.ts +0 -0
- package/dist/src/components/{result → Result}/ResultStack.js +9 -8
- package/dist/src/components/Result/ResultStack.js.map +1 -0
- package/dist/src/components/{result → Result}/ResultStateProvider.d.ts +1 -1
- package/dist/src/components/{result → Result}/ResultStateProvider.js +5 -1
- package/dist/src/components/Result/ResultStateProvider.js.map +1 -0
- package/dist/src/components/{result → Result}/index.d.ts +0 -0
- package/dist/src/components/{result → Result}/index.js +1 -0
- package/dist/src/components/Result/index.js.map +1 -0
- package/dist/src/components/{search → Search}/SearchInput.d.ts +0 -0
- package/dist/src/components/{search → Search}/SearchInput.js +1 -0
- package/dist/src/components/Search/SearchInput.js.map +1 -0
- package/dist/src/components/{search → Search}/index.d.ts +0 -0
- package/dist/src/components/{search → Search}/index.js +1 -0
- package/dist/src/components/Search/index.js.map +1 -0
- package/dist/src/components/{sensor → Sensor}/SensorCollection.d.ts +0 -0
- package/dist/src/components/{sensor → Sensor}/SensorCollection.js +1 -0
- package/dist/src/components/Sensor/SensorCollection.js.map +1 -0
- package/dist/src/components/{sensor → Sensor}/SensorInventoryAvailable.d.ts +0 -0
- package/dist/src/components/{sensor → Sensor}/SensorInventoryAvailable.js +2 -1
- package/dist/src/components/Sensor/SensorInventoryAvailable.js.map +1 -0
- package/dist/src/components/{sensor → Sensor}/SensorPublished.d.ts +0 -0
- package/dist/src/components/{sensor → Sensor}/SensorPublished.js +1 -0
- package/dist/src/components/Sensor/SensorPublished.js.map +1 -0
- package/dist/src/components/{sensor → Sensor}/SensorSearch.d.ts +0 -0
- package/dist/src/components/{sensor → Sensor}/SensorSearch.js +1 -0
- package/dist/src/components/Sensor/SensorSearch.js.map +1 -0
- package/dist/src/components/{sensor → Sensor}/SensorSort.d.ts +0 -0
- package/dist/src/components/{sensor → Sensor}/SensorSort.js +2 -19
- package/dist/src/components/Sensor/SensorSort.js.map +1 -0
- package/dist/src/components/{sensor → Sensor}/SensorSortScore.d.ts +0 -0
- package/dist/src/components/{sensor → Sensor}/SensorSortScore.js +1 -0
- package/dist/src/components/Sensor/SensorSortScore.js.map +1 -0
- package/dist/src/components/{sensor → Sensor}/SensorStack.d.ts +0 -0
- package/dist/src/components/{sensor → Sensor}/SensorStack.js +1 -0
- package/dist/src/components/Sensor/SensorStack.js.map +1 -0
- package/dist/src/components/{sensor → Sensor}/index.d.ts +0 -0
- package/dist/src/components/{sensor → Sensor}/index.js +1 -0
- package/dist/src/components/Sensor/index.js.map +1 -0
- package/dist/src/components/{sortby → Sortby}/Sortby.d.ts +0 -0
- package/dist/src/components/{sortby → Sortby}/Sortby.js +1 -0
- package/dist/src/components/Sortby/Sortby.js.map +1 -0
- package/dist/src/components/{sortby → Sortby}/index.d.ts +0 -0
- package/dist/src/components/{sortby → Sortby}/index.js +1 -0
- package/dist/src/components/Sortby/index.js.map +1 -0
- package/dist/src/components/{utility → Utility}/UtilityAuthenticatedReactiveBase.d.ts +0 -0
- package/dist/src/components/{utility → Utility}/UtilityAuthenticatedReactiveBase.js +4 -3
- package/dist/src/components/Utility/UtilityAuthenticatedReactiveBase.js.map +1 -0
- package/dist/src/components/{utility → Utility}/index.d.ts +0 -0
- package/dist/src/components/{utility → Utility}/index.js +1 -0
- package/dist/src/components/Utility/index.js.map +1 -0
- package/dist/src/components/index.d.ts +8 -8
- package/dist/src/components/index.js +9 -8
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/hooks/index.d.ts +1 -0
- package/dist/src/hooks/index.js +2 -0
- package/dist/src/hooks/index.js.map +1 -0
- package/dist/src/hooks/reactivesearch/index.d.ts +3 -3
- package/dist/src/hooks/reactivesearch/index.js +4 -3
- package/dist/src/hooks/reactivesearch/index.js.map +1 -0
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.js +3 -1
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.js.map +1 -0
- package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.js +3 -2
- package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.js.map +1 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.js +3 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.js.map +1 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js +3 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js.map +1 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.js +3 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.js.map +1 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js +3 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js.map +1 -0
- package/dist/src/hooks/reactivesearch/useReactiveReactProp.js +1 -0
- package/dist/src/hooks/reactivesearch/useReactiveReactProp.js.map +1 -0
- package/dist/src/hooks/reactivesearch/useReactiveReactiveListProps.d.ts +5 -0
- package/dist/src/hooks/reactivesearch/{useReactiveResultStackProps.js → useReactiveReactiveListProps.js} +7 -5
- package/dist/src/hooks/reactivesearch/useReactiveReactiveListProps.js.map +1 -0
- package/dist/src/hooks/useAnalytics.js +3 -0
- package/dist/src/hooks/useAnalytics.js.map +1 -0
- package/dist/src/hooks/useConfig.js +10 -8
- package/dist/src/hooks/useConfig.js.map +1 -0
- package/dist/src/hooks/useCuration.js +17 -3
- package/dist/src/hooks/useCuration.js.map +1 -0
- package/dist/src/hooks/useDebugger.d.ts +1 -0
- package/dist/src/hooks/useDebugger.js +15 -0
- package/dist/src/hooks/useDebugger.js.map +1 -0
- package/dist/src/hooks/useFilterCollapsedState.js +1 -0
- package/dist/src/hooks/useFilterCollapsedState.js.map +1 -0
- package/dist/src/hooks/useFilterListProps.js +37 -9
- package/dist/src/hooks/useFilterListProps.js.map +1 -0
- package/dist/src/hooks/useFilterStack.d.ts +3 -1
- package/dist/src/hooks/useFilterStack.js +7 -1
- package/dist/src/hooks/useFilterStack.js.map +1 -0
- package/dist/src/hooks/useFilters.js +8 -3
- package/dist/src/hooks/useFilters.js.map +1 -0
- package/dist/src/hooks/usePagination.d.ts +2 -2
- package/dist/src/hooks/usePagination.js +29 -17
- package/dist/src/hooks/usePagination.js.map +1 -0
- package/dist/src/hooks/usePaginationLoadMore.d.ts +3 -2
- package/dist/src/hooks/usePaginationLoadMore.js +15 -12
- package/dist/src/hooks/usePaginationLoadMore.js.map +1 -0
- package/dist/src/hooks/useProductPrice.js +1 -0
- package/dist/src/hooks/useProductPrice.js.map +1 -0
- package/dist/src/hooks/useReactifySearchContext.js +1 -0
- package/dist/src/hooks/useReactifySearchContext.js.map +1 -0
- package/dist/src/hooks/useSearch.d.ts +1 -1
- package/dist/src/hooks/useSearch.js +20 -6
- package/dist/src/hooks/useSearch.js.map +1 -0
- package/dist/src/hooks/useSortby.js +22 -5
- package/dist/src/hooks/useSortby.js.map +1 -0
- package/dist/src/index.js +46 -3
- package/dist/src/index.js.map +1 -0
- package/dist/src/types/config.js +1 -0
- package/dist/src/types/config.js.map +1 -0
- package/dist/src/types/elastic.js +1 -0
- package/dist/src/types/elastic.js.map +1 -0
- package/dist/src/types/firestore.js +1 -0
- package/dist/src/types/firestore.js.map +1 -0
- package/dist/src/types/graphql.js +1 -0
- package/dist/src/types/graphql.js.map +1 -0
- package/dist/src/types/index.js +1 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/reactivesearch.js +1 -0
- package/dist/src/types/reactivesearch.js.map +1 -0
- package/dist/src/types/shopify.js +1 -0
- package/dist/src/types/shopify.js.map +1 -0
- package/dist/src/utility/debug.d.ts +10 -0
- package/dist/src/utility/debug.js +39 -0
- package/dist/src/utility/debug.js.map +1 -0
- package/dist/src/utility/index.d.ts +1 -0
- package/dist/src/utility/index.js +14 -0
- package/dist/src/utility/index.js.map +1 -0
- package/package.json +8 -3
- package/dist/src/components/example/ExampleFilterList.js +0 -19
- package/dist/src/components/example/ExampleResultCardProduct.js +0 -18
- package/dist/src/components/example/ExampleResultPaginationNumbered.js +0 -26
- package/dist/src/components/example/ExampleSortby.js +0 -12
- package/dist/src/hooks/reactivesearch/useReactiveResultStackProps.d.ts +0 -17
|
@@ -25,31 +25,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
25
25
|
exports.ReactifySearchBase = void 0;
|
|
26
26
|
const react_1 = __importDefault(require("react"));
|
|
27
27
|
const Sentry = __importStar(require("@sentry/react"));
|
|
28
|
-
const tracing_1 = require("@sentry/tracing");
|
|
29
28
|
const hooks_1 = require("../../hooks");
|
|
30
29
|
const components_1 = require("../../components");
|
|
31
|
-
const
|
|
32
|
-
Sentry.init({
|
|
33
|
-
dsn: "https://cd8abf47496c4956bd061e461f857319@o301775.ingest.sentry.io/6600694",
|
|
34
|
-
integrations: [new tracing_1.BrowserTracing()],
|
|
35
|
-
tracesSampleRate: 1.0,
|
|
36
|
-
});
|
|
30
|
+
const utility_1 = require("../../utility");
|
|
37
31
|
const ReactifySearchBase = (props) => {
|
|
38
32
|
react_1.default.useEffect(() => {
|
|
39
|
-
debug("
|
|
33
|
+
utility_1.debug.log("ReactifySearchBase", "props", props);
|
|
34
|
+
Sentry.setTags({
|
|
35
|
+
"reactifysearch.index": props.index,
|
|
36
|
+
"reactifysearch.shop": props.shopifyPermanentDomain,
|
|
37
|
+
"reactifysearch.mode": props.mode,
|
|
38
|
+
"reactifysearch.collection": props.mode === "collection" ? props.collection.handle : undefined,
|
|
39
|
+
"reactifysearch.filter": props.filterStackHandle,
|
|
40
|
+
});
|
|
40
41
|
}, [props]);
|
|
41
|
-
return (react_1.default.createElement(Sentry.ErrorBoundary, { fallback: react_1.default.createElement("p", null, "An error has occurred"),
|
|
42
|
-
scope.setTag("index", props.index);
|
|
43
|
-
scope.setTag("shop", props.shopifyPermanentDomain);
|
|
44
|
-
scope.setTag("mode", props.mode);
|
|
45
|
-
if (props.mode === "collection") {
|
|
46
|
-
scope.setTag("collection", props.collection.handle);
|
|
47
|
-
}
|
|
48
|
-
if (props.filterStackHandle) {
|
|
49
|
-
scope.setTag("filter", props.filterStackHandle);
|
|
50
|
-
}
|
|
51
|
-
debug("set sentry scope");
|
|
52
|
-
} },
|
|
42
|
+
return (react_1.default.createElement(Sentry.ErrorBoundary, { fallback: react_1.default.createElement("p", null, "An error has occurred") },
|
|
53
43
|
react_1.default.createElement(ReactifySearchInner, Object.assign({}, props))));
|
|
54
44
|
};
|
|
55
45
|
exports.ReactifySearchBase = ReactifySearchBase;
|
|
@@ -72,18 +62,20 @@ const ReactifySearchInner = (props) => {
|
|
|
72
62
|
};
|
|
73
63
|
const searchQueryFromURL = react_1.default.useMemo(() => {
|
|
74
64
|
var _a;
|
|
75
|
-
if (typeof window === "undefined")
|
|
76
|
-
return
|
|
65
|
+
if (typeof window === "undefined") {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
77
68
|
const urlParams = new URLSearchParams(window.location.search);
|
|
78
69
|
return (_a = urlParams.get("q")) !== null && _a !== void 0 ? _a : undefined;
|
|
79
|
-
}, [window.location.search]);
|
|
70
|
+
}, [typeof window !== "undefined" && window.location.search]);
|
|
80
71
|
const searchSortFromURL = react_1.default.useMemo(() => {
|
|
81
72
|
var _a;
|
|
82
|
-
if (typeof window === "undefined")
|
|
83
|
-
return
|
|
73
|
+
if (typeof window === "undefined") {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
84
76
|
const urlParams = new URLSearchParams(window.location.search);
|
|
85
77
|
return (_a = urlParams.get("sort")) !== null && _a !== void 0 ? _a : undefined;
|
|
86
|
-
}, [window.location.search]);
|
|
78
|
+
}, [typeof window !== "undefined" && window.location.search]);
|
|
87
79
|
react_1.default.useEffect(() => {
|
|
88
80
|
if (searchQueryFromURL && searchQuery !== searchQueryFromURL) {
|
|
89
81
|
setSearchQuery(searchQueryFromURL);
|
|
@@ -95,17 +87,19 @@ const ReactifySearchInner = (props) => {
|
|
|
95
87
|
}
|
|
96
88
|
}, [searchSortFromURL]);
|
|
97
89
|
react_1.default.useEffect(() => {
|
|
90
|
+
if (typeof window == "undefined") {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
98
93
|
if (window.location.search === "" && sortOption) {
|
|
99
94
|
setSortOption(sortOption);
|
|
100
95
|
}
|
|
101
|
-
}, [window.location.
|
|
96
|
+
}, [typeof window !== "undefined" && window.location.search]);
|
|
102
97
|
const contextValue = react_1.default.useMemo(() => {
|
|
103
98
|
var _a;
|
|
104
99
|
if (!config) {
|
|
105
100
|
return;
|
|
106
101
|
}
|
|
107
|
-
|
|
108
|
-
return {
|
|
102
|
+
const memoValue = {
|
|
109
103
|
config: config,
|
|
110
104
|
options: Object.assign(Object.assign({}, props), { index: (_a = props.index) !== null && _a !== void 0 ? _a : config.index, filterStackHandle: props.filterStackHandle, credentials: credentials, theme: theme }),
|
|
111
105
|
search: {
|
|
@@ -117,15 +111,11 @@ const ReactifySearchInner = (props) => {
|
|
|
117
111
|
sortby: {
|
|
118
112
|
sortOption: sortOption,
|
|
119
113
|
setSortOption: setSortOption,
|
|
120
|
-
}
|
|
114
|
+
},
|
|
121
115
|
};
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
searchQuery,
|
|
126
|
-
instantSearchVisible,
|
|
127
|
-
sortOption,
|
|
128
|
-
]);
|
|
116
|
+
utility_1.debug.log("ReactifySearchBase", "context", memoValue);
|
|
117
|
+
return memoValue;
|
|
118
|
+
}, [config, props, searchQuery, instantSearchVisible, sortOption]);
|
|
129
119
|
if (!contextValue) {
|
|
130
120
|
if (props.renderBooting) {
|
|
131
121
|
return props.renderBooting();
|
|
@@ -138,3 +128,4 @@ const ReactifySearchInner = (props) => {
|
|
|
138
128
|
return (react_1.default.createElement(hooks_1.ReactifySearchContext.Provider, { value: contextValue },
|
|
139
129
|
react_1.default.createElement(components_1.UtilityAuthenticatedReactiveBase, null, props.children)));
|
|
140
130
|
};
|
|
131
|
+
//# sourceMappingURL=ReactifySearchBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReactifySearchBase.js","sourceRoot":"","sources":["../../../../src/components/ReactifySearchBase/ReactifySearchBase.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,sDAAwC;AAExC,uCAA+D;AAC/D,iDAAoE;AACpE,2CAAsC;AA+C/B,MAAM,kBAAkB,GAAsC,CACnE,KAAK,EACL,EAAE;IACF,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,eAAK,CAAC,GAAG,CAAC,oBAAoB,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAEhD,MAAM,CAAC,OAAO,CAAC;YACb,sBAAsB,EAAE,KAAK,CAAC,KAAK;YACnC,qBAAqB,EAAE,KAAK,CAAC,sBAAsB;YACnD,qBAAqB,EAAE,KAAK,CAAC,IAAI;YACjC,2BAA2B,EACzB,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;YACnE,uBAAuB,EAAE,KAAK,CAAC,iBAAiB;SACjD,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,CACL,8BAAC,MAAM,CAAC,aAAa,IAAC,QAAQ,EAAE,iEAA4B;QAC1D,8BAAC,mBAAmB,oBAAK,KAAK,EAAI,CACb,CACxB,CAAC;AACJ,CAAC,CAAC;AArBW,QAAA,kBAAkB,sBAqB7B;AAEF,MAAM,mBAAmB,GAAsC,CAAC,KAAK,EAAE,EAAE;;IACvE,MAAM,EAAE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AAE,KAAK,GACb;YACD,MAAM,EAAE;gBACN,WAAW,EAAE,WAAW;gBACxB,cAAc,EAAE,cAAc;gBAC9B,oBAAoB,EAAE,oBAAoB;gBAC1C,uBAAuB,EAAE,uBAAuB;aACjD;YACD,MAAM,EAAE;gBACN,UAAU,EAAE,UAAU;gBACtB,aAAa,EAAE,aAAa;aAC7B;SACF,CAAC;QAEF,eAAK,CAAC,GAAG,CAAC,oBAAoB,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;QAEtD,OAAO,SAAS,CAAC;IACnB,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,UAAU,CAAC,CAAC,CAAC;IAEnE,IAAI,CAAC,YAAY,EAAE;QACjB,IAAI,KAAK,CAAC,aAAa,EAAE;YACvB,OAAO,KAAK,CAAC,aAAa,EAAE,CAAC;SAC9B;QACD,OAAO,IAAI,CAAC;KACb;IAED,IAAI,KAAK,CAAC,cAAc,EAAE;QACxB,OAAO,CACL,8BAAC,6BAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,IAChD,KAAK,CAAC,QAAQ,CACgB,CAClC,CAAC;KACH;IAED,OAAO,CACL,8BAAC,6BAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY;QACjD,8BAAC,6CAAgC,QAC9B,KAAK,CAAC,QAAQ,CACkB,CACJ,CAClC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport * as Sentry from \"@sentry/react\";\n\nimport { ReactifySearchContext, useConfig } from \"../../hooks\";\nimport { UtilityAuthenticatedReactiveBase } from \"../../components\";\nimport { debug } from \"../../utility\";\n\nexport type ReactifySearchBaseProps = {\n /** The search area the provider will be used in */\n mode: \"search\" | \"collection\" | \"instant-search\";\n /** Shopify store domain used to resolve the site configuration */\n shopifyPermanentDomain: string;\n /** Specific filter group handle, used to override automated logic */\n filterStackHandle?: 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: Allows you to wrap the ReactifySearchBase in your own ReactiveBase component */\n noReactiveBase?: boolean;\n /** Advanced usage: Array of additional component IDs managed outside of Reactify Search */\n additionalComponentHandles?: 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?: {\n username: string;\n password: string;\n endpoint: string;\n };\n /** Advanced usage: Override the default ReactiveBase theme */\n theme?: Record<string, unknown>;\n} & (\n | {\n mode: \"search\";\n }\n | {\n mode: \"collection\";\n /** Collection object that includes the handle, used to find curations */\n collection: {\n id: number;\n title: string;\n handle: string;\n };\n }\n | {\n mode: \"instant-search\";\n }\n);\n\nexport const ReactifySearchBase: React.FC<ReactifySearchBaseProps> = (\n props\n) => {\n React.useEffect(() => {\n debug.log(\"ReactifySearchBase\", \"props\", props);\n\n Sentry.setTags({\n \"reactifysearch.index\": props.index,\n \"reactifysearch.shop\": props.shopifyPermanentDomain,\n \"reactifysearch.mode\": props.mode,\n \"reactifysearch.collection\":\n props.mode === \"collection\" ? props.collection.handle : undefined,\n \"reactifysearch.filter\": props.filterStackHandle,\n });\n }, [props]);\n\n return (\n <Sentry.ErrorBoundary fallback={<p>An error has occurred</p>}>\n <ReactifySearchInner {...props} />\n </Sentry.ErrorBoundary>\n );\n};\n\nconst ReactifySearchInner: React.FC<ReactifySearchBaseProps> = (props) => {\n const { config } = useConfig(props.shopifyPermanentDomain, props.configId);\n\n const [searchQuery, setSearchQuery] = React.useState<string>(\"\");\n const [instantSearchVisible, setInstantSearchVisible] =\n React.useState<boolean>(false);\n const [sortOption, setSortOption] = React.useState<string>(\"\");\n\n const credentials = props.credentials ?? {\n username: \"guest\",\n password: \"password\",\n endpoint: \"https://api.search.reactify.app\",\n };\n\n const theme = props.theme ?? {\n typography: {\n fontFamily: \"inherit\",\n fontSize: \"inherit\",\n },\n };\n\n const searchQueryFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"q\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n const searchSortFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"sort\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n React.useEffect(() => {\n if (searchQueryFromURL && searchQuery !== searchQueryFromURL) {\n setSearchQuery(searchQueryFromURL);\n }\n }, [searchQueryFromURL]);\n\n React.useEffect(() => {\n if (searchSortFromURL && sortOption !== searchSortFromURL) {\n setSortOption(searchSortFromURL);\n }\n }, [searchSortFromURL]);\n\n React.useEffect(() => {\n if (typeof window == \"undefined\") {\n return;\n }\n\n if (window.location.search === \"\" && sortOption) {\n setSortOption(sortOption);\n }\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n const contextValue = React.useMemo(() => {\n if (!config) {\n return;\n }\n\n const memoValue = {\n config: config,\n options: {\n ...props,\n index: props.index ?? config.index,\n filterStackHandle: props.filterStackHandle,\n credentials: credentials,\n theme: theme,\n },\n search: {\n searchQuery: searchQuery,\n setSearchQuery: setSearchQuery,\n instantSearchVisible: instantSearchVisible,\n setInstantSearchVisible: setInstantSearchVisible,\n },\n sortby: {\n sortOption: sortOption,\n setSortOption: setSortOption,\n },\n };\n\n debug.log(\"ReactifySearchBase\", \"context\", memoValue);\n\n return memoValue;\n }, [config, props, searchQuery, instantSearchVisible, sortOption]);\n\n if (!contextValue) {\n if (props.renderBooting) {\n return props.renderBooting();\n }\n return null;\n }\n\n if (props.noReactiveBase) {\n return (\n <ReactifySearchContext.Provider value={contextValue}>\n {props.children}\n </ReactifySearchContext.Provider>\n );\n }\n\n return (\n <ReactifySearchContext.Provider value={contextValue}>\n <UtilityAuthenticatedReactiveBase>\n {props.children}\n </UtilityAuthenticatedReactiveBase>\n </ReactifySearchContext.Provider>\n );\n};\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ReactifySearchBase/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAqC","sourcesContent":["export * from \"./ReactifySearchBase\";"]}
|
|
File without changes
|
|
@@ -9,6 +9,7 @@ const react_intersection_observer_1 = require("react-intersection-observer");
|
|
|
9
9
|
const hooks_1 = require("../../hooks");
|
|
10
10
|
const __1 = require("..");
|
|
11
11
|
const ResultCardCallout = (props) => {
|
|
12
|
+
var _a;
|
|
12
13
|
const { track } = (0, hooks_1.useAnalytics)();
|
|
13
14
|
const { ref, inView } = (0, react_intersection_observer_1.useInView)({
|
|
14
15
|
threshold: 0.5,
|
|
@@ -37,10 +38,8 @@ const ResultCardCallout = (props) => {
|
|
|
37
38
|
handleView();
|
|
38
39
|
}
|
|
39
40
|
}, [inView]);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return (react_1.default.createElement(Component, Object.assign({}, props, { itemRef: ref, handleClick: handleClick })));
|
|
43
|
-
}
|
|
44
|
-
return (react_1.default.createElement(__1.ExampleResultCardCallout, Object.assign({}, props, { itemRef: ref, handleClick: handleClick })));
|
|
41
|
+
const RenderComponent = (_a = props.render) !== null && _a !== void 0 ? _a : __1.ExampleResultCardCallout;
|
|
42
|
+
return react_1.default.createElement(RenderComponent, Object.assign({}, props, { itemRef: ref, handleClick: handleClick }));
|
|
45
43
|
};
|
|
46
44
|
exports.ResultCardCallout = ResultCardCallout;
|
|
45
|
+
//# sourceMappingURL=ResultCardCallout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResultCardCallout.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultCardCallout.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,6EAAwD;AA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,CAAC;AApCW,QAAA,iBAAiB,qBAoC5B","sourcesContent":["import React from \"react\";\nimport { useInView } from \"react-intersection-observer\";\n\nimport { ElasticCallout } from \"../../types\";\nimport { useAnalytics } from \"../../hooks\";\nimport { ExampleResultCardCallout } from \"..\";\n\nexport type ResultCardCalloutProps = {\n pagePosition: number;\n document: ElasticCallout;\n callout: ElasticCallout[\"callout\"];\n render?: React.FC<\n Omit<ResultCardCalloutProps, \"render\"> & {\n itemRef: (node?: Element | null) => void;\n handleClick: () => void;\n }\n >;\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 handleView();\n }\n }, [inView]);\n\n const RenderComponent = props.render ?? ExampleResultCardCallout;\n\n return <RenderComponent {...props} itemRef={ref} handleClick={handleClick} />;\n};\n"]}
|
|
File without changes
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
@@ -19,8 +8,8 @@ const react_1 = __importDefault(require("react"));
|
|
|
19
8
|
const react_intersection_observer_1 = require("react-intersection-observer");
|
|
20
9
|
const hooks_1 = require("../../hooks");
|
|
21
10
|
const components_1 = require("../../components");
|
|
22
|
-
const ResultCardProduct = (
|
|
23
|
-
var
|
|
11
|
+
const ResultCardProduct = (props) => {
|
|
12
|
+
var _a;
|
|
24
13
|
const productPrice = (0, hooks_1.useProductPrice)(props.product);
|
|
25
14
|
const { track } = (0, hooks_1.useAnalytics)();
|
|
26
15
|
const { ref, inView } = (0, react_intersection_observer_1.useInView)({
|
|
@@ -54,10 +43,8 @@ const ResultCardProduct = (_a) => {
|
|
|
54
43
|
handleView();
|
|
55
44
|
}
|
|
56
45
|
}, [inView]);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return (react_1.default.createElement(Component, Object.assign({}, props, productPrice, { itemRef: ref, handleClick: handleClick })));
|
|
60
|
-
}
|
|
61
|
-
return (react_1.default.createElement(components_1.ExampleResultCardProduct, Object.assign({}, props, productPrice, { itemRef: ref, handleClick: handleClick })));
|
|
46
|
+
const RenderComponent = (_a = props.render) !== null && _a !== void 0 ? _a : components_1.ExampleResultCardProduct;
|
|
47
|
+
return (react_1.default.createElement(RenderComponent, Object.assign({}, productPrice, { pagePosition: props.pagePosition, product: props.product, document: props.document, itemRef: ref, handleClick: handleClick })));
|
|
62
48
|
};
|
|
63
49
|
exports.ResultCardProduct = ResultCardProduct;
|
|
50
|
+
//# sourceMappingURL=ResultCardProduct.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResultCardProduct.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultCardProduct.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,6EAAwD;AAGxD,uCAA4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E,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;AAnDW,QAAA,iBAAiB,qBAmD5B","sourcesContent":["import React from \"react\";\nimport { useInView } from \"react-intersection-observer\";\n\nimport type { ElasticProduct } from \"../../types\";\nimport { useProductPrice, useAnalytics } from \"../../hooks\";\nimport { ExampleResultCardProduct } from \"../../components\";\n\nexport type ResultCardProductProps = {\n pagePosition: number;\n product: ElasticProduct;\n document: ElasticProduct;\n render?: React.FC<\n Omit<ResultCardProductProps, \"render\"> &\n ReturnType<typeof useProductPrice> & {\n itemRef: (node?: Element | null) => void;\n handleClick: () => void;\n }\n >;\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 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"]}
|
|
File without changes
|
|
@@ -14,3 +14,4 @@ const ResultPaginationLoadMore = (props) => {
|
|
|
14
14
|
return (react_1.default.createElement(RenderPaginationComponent, Object.assign({}, paginationLoadMoreHook)));
|
|
15
15
|
};
|
|
16
16
|
exports.ResultPaginationLoadMore = ResultPaginationLoadMore;
|
|
17
|
+
//# sourceMappingURL=ResultPaginationLoadMore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResultPaginationLoadMore.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultPaginationLoadMore.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,uCAAoD;AACpD,iDAAmE;AAM5D,MAAM,wBAAwB,GAA4C,CAAC,KAAK,EAAE,EAAE;;IACzF,MAAM,sBAAsB,GAAG,IAAA,6BAAqB,EAAC,KAAK,CAAC,CAAC;IAE5D,MAAM,yBAAyB,GAAG,MAAA,KAAK,CAAC,MAAM,mCAAI,4CAA+B,CAAC;IAElF,OAAO,CACL,8BAAC,yBAAyB,oBACpB,sBAAsB,EAC1B,CACH,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,wBAAwB,4BAUnC","sourcesContent":["import React from \"react\";\n\nimport { ReactivesearchResultProps } from \"../../types\";\nimport { usePaginationLoadMore } from \"../../hooks\";\nimport { ExampleResultPaginationLoadMore } from \"../../components\";\n\nexport type ResultPaginationLoadMoreProps = ReactivesearchResultProps & {\n render?: React.FC<ReturnType<typeof usePaginationLoadMore>>;\n};\n\nexport const ResultPaginationLoadMore: React.FC<ResultPaginationLoadMoreProps> = (props) => {\n const paginationLoadMoreHook = usePaginationLoadMore(props);\n\n const RenderPaginationComponent = props.render ?? ExampleResultPaginationLoadMore;\n\n return (\n <RenderPaginationComponent\n {...paginationLoadMoreHook}\n />\n );\n};\n"]}
|
|
File without changes
|
|
@@ -14,3 +14,4 @@ const ResultPaginationNextPrev = (props) => {
|
|
|
14
14
|
return (react_1.default.createElement(RenderPaginationComponent, Object.assign({}, paginationHook)));
|
|
15
15
|
};
|
|
16
16
|
exports.ResultPaginationNextPrev = ResultPaginationNextPrev;
|
|
17
|
+
//# sourceMappingURL=ResultPaginationNextPrev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResultPaginationNextPrev.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultPaginationNextPrev.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,uCAA4C;AAE5C,iDAAmE;AAM5D,MAAM,wBAAwB,GAA4C,CAAC,KAAK,EAAE,EAAE;;IACzF,MAAM,cAAc,GAAG,IAAA,qBAAa,EAAC,KAAK,CAAC,CAAC;IAE5C,MAAM,yBAAyB,GAAG,MAAA,KAAK,CAAC,MAAM,mCAAI,4CAA+B,CAAC;IAElF,OAAO,CACL,8BAAC,yBAAyB,oBACpB,cAAc,EAClB,CACH,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,wBAAwB,4BAUnC","sourcesContent":["import React from \"react\";\n\nimport { usePagination } from \"../../hooks\";\nimport { ReactivesearchPaginationProps } from \"../../types\";\nimport { ExampleResultPaginationNextPrev } from \"../../components\";\n\nexport type ResultPaginationNextPrevProps = ReactivesearchPaginationProps & {\n render?: React.FC<ReturnType<typeof usePagination>>;\n};\n\nexport const ResultPaginationNextPrev: React.FC<ResultPaginationNextPrevProps> = (props) => {\n const paginationHook = usePagination(props);\n\n const RenderPaginationComponent = props.render ?? ExampleResultPaginationNextPrev;\n\n return (\n <RenderPaginationComponent\n {...paginationHook}\n />\n );\n};\n"]}
|
|
File without changes
|
|
@@ -17,3 +17,4 @@ const ResultPaginationNumbered = (props) => {
|
|
|
17
17
|
return (react_1.default.createElement(RenderPaginationComponent, Object.assign({}, paginationHook)));
|
|
18
18
|
};
|
|
19
19
|
exports.ResultPaginationNumbered = ResultPaginationNumbered;
|
|
20
|
+
//# sourceMappingURL=ResultPaginationNumbered.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResultPaginationNumbered.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultPaginationNumbered.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,uCAA4C;AAC5C,iDAAmE;AAM5D,MAAM,wBAAwB,GAA4C,CAAC,KAAK,EAAE,EAAE;;IACzF,MAAM,cAAc,GAAG,IAAA,qBAAa,EAAC,KAAK,CAAC,CAAC;IAE5C,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE;QAC9B,OAAO,IAAI,CAAC;KACb;IAED,MAAM,yBAAyB,GAAG,MAAA,KAAK,CAAC,MAAM,mCAAI,4CAA+B,CAAC;IAElF,OAAO,CACL,8BAAC,yBAAyB,oBACpB,cAAc,EAClB,CACH,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,wBAAwB,4BAcnC","sourcesContent":["import React from \"react\";\n\nimport { ReactivesearchPaginationProps } from \"../../types\";\nimport { usePagination } from \"../../hooks\";\nimport { ExampleResultPaginationNumbered } from \"../../components\";\n\nexport type ResultPaginationNumberedProps = ReactivesearchPaginationProps & {\n render?: React.FC<ReturnType<typeof usePagination>>;\n};\n\nexport const ResultPaginationNumbered: React.FC<ResultPaginationNumberedProps> = (props) => {\n const paginationHook = usePagination(props);\n\n if (!paginationHook.totalPages) {\n return null;\n }\n \n const RenderPaginationComponent = props.render ?? ExampleResultPaginationNumbered;\n\n return (\n <RenderPaginationComponent\n {...paginationHook}\n />\n );\n};\n"]}
|
|
File without changes
|
|
@@ -14,10 +14,10 @@ const ResultPaginationNextPrev_1 = require("./ResultPaginationNextPrev");
|
|
|
14
14
|
const hooks_1 = require("../../hooks");
|
|
15
15
|
const types_1 = require("../../types");
|
|
16
16
|
const ResultStack = (props) => {
|
|
17
|
-
const
|
|
17
|
+
const reactiveReactiveListProps = (0, hooks_1.useReactiveReactiveListProps)({
|
|
18
18
|
pageSize: props.pageSize,
|
|
19
19
|
});
|
|
20
|
-
return (react_1.default.createElement(ReactiveList_1.default, Object.assign({},
|
|
20
|
+
return (react_1.default.createElement(ReactiveList_1.default, Object.assign({}, reactiveReactiveListProps, { render: (reactivesearchResultProps) => (react_1.default.createElement(ResultStackInner, Object.assign({}, props, { reactivesearchResultProps: reactivesearchResultProps }))), renderPagination: (reactivesearchPaginationProps) => (react_1.default.createElement(ResultStackPaginationStack, Object.assign({}, props, reactivesearchPaginationProps))) })));
|
|
21
21
|
};
|
|
22
22
|
exports.ResultStack = ResultStack;
|
|
23
23
|
const ResultStackRenderErrorComponent = (props) => {
|
|
@@ -26,10 +26,10 @@ const ResultStackRenderErrorComponent = (props) => {
|
|
|
26
26
|
props.error.statusText));
|
|
27
27
|
};
|
|
28
28
|
const ResultStackRenderLoadingComponent = () => {
|
|
29
|
-
return
|
|
29
|
+
return react_1.default.createElement("div", null, "Loading");
|
|
30
30
|
};
|
|
31
31
|
const ResultStackRenderNoResultsComponent = () => {
|
|
32
|
-
return
|
|
32
|
+
return react_1.default.createElement("div", null, "No results");
|
|
33
33
|
};
|
|
34
34
|
const ResultStackInner = (props) => {
|
|
35
35
|
var _a, _b, _c;
|
|
@@ -51,7 +51,7 @@ const ResultStackInner = (props) => {
|
|
|
51
51
|
}
|
|
52
52
|
if (!initialSearchHasRun) {
|
|
53
53
|
const RenderLoadingComponent = (_b = props.renderLoading) !== null && _b !== void 0 ? _b : ResultStackRenderLoadingComponent;
|
|
54
|
-
return
|
|
54
|
+
return react_1.default.createElement(RenderLoadingComponent, null);
|
|
55
55
|
}
|
|
56
56
|
if (!props.reactivesearchResultProps.resultStats.numberOfResults) {
|
|
57
57
|
if (searchQuery) {
|
|
@@ -63,7 +63,7 @@ const ResultStackInner = (props) => {
|
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
const RenderNoResultsComponent = (_c = props.renderNoResults) !== null && _c !== void 0 ? _c : ResultStackRenderNoResultsComponent;
|
|
66
|
-
return
|
|
66
|
+
return react_1.default.createElement(RenderNoResultsComponent, null);
|
|
67
67
|
}
|
|
68
68
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
69
69
|
react_1.default.createElement("section", { style: listStyle, className: props.listClassName }, props.reactivesearchResultProps.data.map((item, key) => {
|
|
@@ -81,7 +81,7 @@ const ResultStackInner = (props) => {
|
|
|
81
81
|
/** Handles rendering pagination for types that use "pagination props" */
|
|
82
82
|
const ResultStackPaginationStack = (props) => {
|
|
83
83
|
const { options } = (0, hooks_1.useReactifySearchContext)();
|
|
84
|
-
const filterStack = (0, hooks_1.useFilterStack)();
|
|
84
|
+
const { filterStack } = (0, hooks_1.useFilterStack)();
|
|
85
85
|
if (options.mode === "instant-search") {
|
|
86
86
|
return null;
|
|
87
87
|
}
|
|
@@ -96,7 +96,7 @@ const ResultStackPaginationStack = (props) => {
|
|
|
96
96
|
/** Handles rendering pagination for types that use "result props" */
|
|
97
97
|
const ResultStackPaginationStackLoadMore = (props) => {
|
|
98
98
|
const { options } = (0, hooks_1.useReactifySearchContext)();
|
|
99
|
-
const filterStack = (0, hooks_1.useFilterStack)();
|
|
99
|
+
const { filterStack } = (0, hooks_1.useFilterStack)();
|
|
100
100
|
if (options.mode === "instant-search") {
|
|
101
101
|
return null;
|
|
102
102
|
}
|
|
@@ -105,3 +105,4 @@ const ResultStackPaginationStackLoadMore = (props) => {
|
|
|
105
105
|
}
|
|
106
106
|
return null;
|
|
107
107
|
};
|
|
108
|
+
//# sourceMappingURL=ResultStack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResultStack.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultStack.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,gHAAwF;AAExF,2DAAwD;AACxD,2DAAwD;AACxD,yEAAsE;AACtE,yEAAsE;AACtE,yEAAsE;AAEtE,uCAMqB;AAErB,uCAOqB;AA8Cd,MAAM,WAAW,GAA+B,CAAC,KAAK,EAAE,EAAE;IAC/D,MAAM,yBAAyB,GAAG,IAAA,oCAA4B,EAAC;QAC7D,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB,CAAC,CAAC;IAEH,OAAO,CACL,8BAAC,sBAAY,oBACP,yBAAyB,IAC7B,MAAM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,IAAA,sBAAc,GAAE,CAAC;IAEzC,IAAI,OAAO,CAAC,IAAI,KAAK,gBAAgB,EAAE;QACrC,OAAO,IAAI,CAAC;KACb;IAED,IAAI,WAAW,MAAK,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,CAAA,EAAE;QAC/C,OAAO,CACL,8BAAC,mDAAwB,oBACnB,KAAK,CAAC,yBAAyB,IACnC,MAAM,EAAE,KAAK,CAAC,wBAAwB,IACtC,CACH,CAAC;KACH;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveList from \"@appbaseio/reactivesearch/lib/components/result/ReactiveList\";\n\nimport { ResultCardCallout } from \"./ResultCardCallout\";\nimport { ResultCardProduct } from \"./ResultCardProduct\";\nimport { ResultPaginationNumbered } from \"./ResultPaginationNumbered\";\nimport { ResultPaginationLoadMore } from \"./ResultPaginationLoadMore\";\nimport { ResultPaginationNextPrev } from \"./ResultPaginationNextPrev\";\n\nimport {\n useReactifySearchContext,\n useAnalytics,\n useSearch,\n useFilterStack,\n useReactiveReactiveListProps,\n} from \"../../hooks\";\n\nimport {\n ElasticCallout,\n ElasticProduct,\n ElasticDocumentType,\n ReactivesearchError,\n ReactivesearchResultProps,\n ReactivesearchPaginationProps,\n} from \"../../types\";\n\nexport type ResultProps = ReactivesearchResultProps & {\n callouts: ElasticCallout[];\n products: ElasticProduct[];\n};\n\nexport type ResultStackProps = {\n /** Style prop for the list wrapper */\n listStyle?: React.HTMLAttributes<HTMLElement>[\"style\"];\n /** Classname prop for the list wrapper */\n listClassName?: string;\n /** Render method called when an error occurs */\n renderError?: React.FC<{ error: ReactivesearchError }>;\n /** Render method called while loading for the first time */\n renderLoading?: React.FC;\n /** Render method called when no results are found */\n renderNoResults?: React.FC;\n /** Render method called once for each product result */\n renderResultCardProduct?: React.ComponentProps<\n typeof ResultCardProduct\n >[\"render\"];\n /** Render method called once for each callout result */\n renderResultCardCallout?: React.ComponentProps<\n typeof ResultCardCallout\n >[\"render\"];\n /** Render method called for pagination type \"pagination\" */\n renderPaginationNumbered?: React.ComponentProps<\n typeof ResultPaginationNumbered\n >[\"render\"];\n /** Render method called for pagination type \"next_prev\" */\n renderPaginationNextPrev?: React.ComponentProps<\n typeof ResultPaginationNextPrev\n >[\"render\"];\n /** Render method called for pagination type \"load_more\" */\n renderPaginationLoadMore?: React.ComponentProps<\n typeof ResultPaginationLoadMore\n >[\"render\"];\n /** Render method called for pagination type \"infinite_scroll\" */\n renderPaginationInfiniteScroll?: React.ComponentProps<\n typeof ResultPaginationLoadMore\n >[\"render\"];\n /** Advanced Usage: Override the default amount of results per page */\n pageSize?: number;\n};\n\nexport const ResultStack: React.FC<ResultStackProps> = (props) => {\n const reactiveReactiveListProps = useReactiveReactiveListProps({\n pageSize: props.pageSize,\n });\n\n return (\n <ReactiveList\n {...reactiveReactiveListProps}\n render={(reactivesearchResultProps: ReactivesearchResultProps) => (\n <ResultStackInner\n {...props}\n reactivesearchResultProps={reactivesearchResultProps}\n />\n )}\n renderPagination={(\n reactivesearchPaginationProps: ReactivesearchPaginationProps\n ) => (\n <ResultStackPaginationStack\n {...props}\n {...reactivesearchPaginationProps}\n />\n )}\n />\n );\n};\n\nconst ResultStackRenderErrorComponent: ResultStackProps[\"renderError\"] = (\n props\n) => {\n return (\n <div>\n {\"Error: \"}\n {props.error.statusText}\n </div>\n );\n};\n\nconst ResultStackRenderLoadingComponent: ResultStackProps[\"renderLoading\"] =\n () => {\n return <div>{\"Loading\"}</div>;\n };\n\nconst ResultStackRenderNoResultsComponent: ResultStackProps[\"renderNoResults\"] =\n () => {\n return <div>{\"No results\"}</div>;\n };\n\nconst ResultStackInner: React.FC<\n ResultStackProps & { reactivesearchResultProps: ReactivesearchResultProps }\n> = (props) => {\n const { track } = useAnalytics();\n const { searchQuery } = useSearch();\n\n const initialSearchHasRun = React.useMemo(\n () =>\n \"undefined\" !==\n typeof props.reactivesearchResultProps.resultStats.numberOfResults,\n [props.reactivesearchResultProps]\n );\n\n const listStyle = React.useMemo<React.HTMLAttributes<HTMLElement>[\"style\"]>(\n () =>\n props.listStyle ?? {\n display: \"grid\",\n gap: \"8px\",\n gridTemplateColumns: \"repeat(4, minmax(0, 1fr))\",\n },\n [props.listStyle]\n );\n\n if (props.reactivesearchResultProps.error) {\n const RenderErrorComponent =\n props.renderError ?? ResultStackRenderErrorComponent;\n\n return (\n <RenderErrorComponent error={props.reactivesearchResultProps.error} />\n );\n }\n\n if (!initialSearchHasRun) {\n const RenderLoadingComponent =\n props.renderLoading ?? ResultStackRenderLoadingComponent;\n return <RenderLoadingComponent />;\n }\n\n if (!props.reactivesearchResultProps.resultStats.numberOfResults) {\n if (searchQuery) {\n track({\n eventName: \"zeroResults\",\n payload: {\n searchTerm: searchQuery,\n },\n });\n }\n const RenderNoResultsComponent =\n props.renderNoResults ?? ResultStackRenderNoResultsComponent;\n return <RenderNoResultsComponent />;\n }\n\n return (\n <>\n <section style={listStyle} className={props.listClassName}>\n {props.reactivesearchResultProps.data.map((item, key) => {\n // @todo result.type is missing in v1 indexes, this check ensures that they are assumed to be products\n if (ElasticDocumentType.Product === item.type || !item.type) {\n return (\n <ResultCardProduct\n key={item._id}\n product={item}\n document={item}\n pagePosition={key + 1}\n render={props.renderResultCardProduct}\n />\n );\n }\n\n if (ElasticDocumentType.Callout === item.type) {\n return (\n <ResultCardCallout\n key={item._id}\n document={item}\n pagePosition={key + 1}\n callout={item.callout}\n render={props.renderResultCardCallout}\n />\n );\n }\n\n return null;\n })}\n </section>\n <ResultStackPaginationStackLoadMore\n {...props}\n {...props.reactivesearchResultProps}\n />\n </>\n );\n};\n\n/** Handles rendering pagination for types that use \"pagination props\" */\nconst ResultStackPaginationStack: React.FC<\n ResultStackProps & ReactivesearchPaginationProps\n> = (props) => {\n const { options } = useReactifySearchContext();\n const { filterStack } = useFilterStack();\n\n if (options.mode === \"instant-search\") {\n return null;\n }\n\n if (\"pagination\" === filterStack?.paginationType) {\n return (\n <ResultPaginationNumbered\n {...props}\n render={props.renderPaginationNumbered}\n />\n );\n }\n\n if (\"next_prev\" === filterStack?.paginationType) {\n return (\n <ResultPaginationNextPrev\n {...props}\n render={props.renderPaginationNextPrev}\n />\n );\n }\n\n return null;\n};\n\n/** Handles rendering pagination for types that use \"result props\" */\nconst ResultStackPaginationStackLoadMore: React.FC<\n ResultStackProps & { reactivesearchResultProps: ReactivesearchResultProps }\n> = (props) => {\n const { options } = useReactifySearchContext();\n const { filterStack } = useFilterStack();\n\n if (options.mode === \"instant-search\") {\n return null;\n }\n\n if (\"load_more\" === filterStack?.paginationType) {\n return (\n <ResultPaginationLoadMore\n {...props.reactivesearchResultProps}\n render={props.renderPaginationLoadMore}\n />\n );\n }\n\n return null;\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ReactivesearchSearchStatePage } from "../../types";
|
|
3
3
|
export declare type ResultStateProvidedProps = {
|
|
4
|
-
render:
|
|
4
|
+
render: React.FC<ReactivesearchSearchStatePage>;
|
|
5
5
|
};
|
|
6
6
|
export declare const ResultStateProvider: React.FC<ResultStateProvidedProps>;
|
|
@@ -6,5 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.ResultStateProvider = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const StateProvider_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/StateProvider"));
|
|
9
|
-
const ResultStateProvider = (
|
|
9
|
+
const ResultStateProvider = (props) => (react_1.default.createElement(StateProvider_1.default, { componentIds: ["page"], includeKeys: ["isLoading", "hits", "resultStats", "error"], render: (state) => {
|
|
10
|
+
const RenderComponent = props.render;
|
|
11
|
+
return react_1.default.createElement(RenderComponent, Object.assign({}, state.searchState.page));
|
|
12
|
+
} }));
|
|
10
13
|
exports.ResultStateProvider = ResultStateProvider;
|
|
14
|
+
//# sourceMappingURL=ResultStateProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResultStateProvider.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultStateProvider.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,iHAAyF;AAQlF,MAAM,mBAAmB,GAAuC,CACrE,KAAK,EACL,EAAE,CAAC,CACH,8BAAC,uBAAa,IACZ,YAAY,EAAE,CAAC,MAAM,CAAC,EACtB,WAAW,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC,EAC1D,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;QAChB,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CAAC;QAErC,OAAO,8BAAC,eAAe,oBAAK,KAAK,CAAC,WAAW,CAAC,IAAI,EAAI,CAAC;IACzD,CAAC,GACD,CACH,CAAC;AAZW,QAAA,mBAAmB,uBAY9B","sourcesContent":["import React from \"react\";\nimport StateProvider from \"@appbaseio/reactivesearch/lib/components/basic/StateProvider\";\n\nimport { ReactivesearchSearchStatePage } from \"../../types\";\n\nexport type ResultStateProvidedProps = {\n render: React.FC<ReactivesearchSearchStatePage>;\n};\n\nexport const ResultStateProvider: React.FC<ResultStateProvidedProps> = (\n props\n) => (\n <StateProvider\n componentIds={[\"page\"]}\n includeKeys={[\"isLoading\", \"hits\", \"resultStats\", \"error\"]}\n render={(state) => {\n const RenderComponent = props.render;\n\n return <RenderComponent {...state.searchState.page} />;\n }}\n />\n);\n"]}
|
|
File without changes
|
|
@@ -17,3 +17,4 @@ __exportStar(require("./ResultStateProvider"), exports);
|
|
|
17
17
|
__exportStar(require("./ResultPaginationNumbered"), exports);
|
|
18
18
|
__exportStar(require("./ResultPaginationLoadMore"), exports);
|
|
19
19
|
__exportStar(require("./ResultPaginationNextPrev"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Result/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAA8B;AAC9B,sDAAmC;AACnC,sDAAoC;AACpC,wDAAsC;AACtC,6DAA2C;AAC3C,6DAA2C;AAC3C,6DAA2C","sourcesContent":["export * from \"./ResultStack\";\nexport * from \"./ResultCardCallout\"\nexport * from \"./ResultCardProduct\";\nexport * from \"./ResultStateProvider\";\nexport * from \"./ResultPaginationNumbered\";\nexport * from \"./ResultPaginationLoadMore\";\nexport * from \"./ResultPaginationNextPrev\";\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchInput.js","sourceRoot":"","sources":["../../../../src/components/Search/SearchInput.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,4GAAoF;AAEpF,uCAAyD;AAQlD,MAAM,WAAW,GAA+B,CAAC,KAAK,EAAE,EAAE;IAC/D,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAExD,MAAM,uBAAuB,GAAG,IAAA,kCAA0B,kBACxD,QAAQ;QACR,WAAW;QACX,cAAc,IACX,KAAK,EACR,CAAC;IAEH,OAAO,CACL,8BAAC,oBAAU,oBACL,uBAAuB,EAC3B,CACH,CAAC;AACJ,CAAC,CAAC;AAfW,QAAA,WAAW,eAetB","sourcesContent":["import React from \"react\";\nimport DataSearch from \"@appbaseio/reactivesearch/lib/components/search/DataSearch\";\n\nimport { useReactiveDataSearchProps } from \"../../hooks\";\n\nexport type SearchInputProps = Omit<React.ComponentProps<typeof DataSearch>, \"componentId\"> & {\n debounce?: number;\n placeholder?: string;\n inputClassName?: string;\n};\n\nexport const SearchInput: React.FC<SearchInputProps> = (props) => {\n const { debounce, placeholder, inputClassName } = props;\n\n const reactiveDataSearchProps = useReactiveDataSearchProps({\n debounce,\n placeholder,\n inputClassName,\n ...props,\n });\n\n return (\n <DataSearch\n {...reactiveDataSearchProps}\n />\n );\n};\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Search/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAA8B","sourcesContent":["export * from \"./SearchInput\";\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SensorCollection.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorCollection.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;AAEjG,uCAAuD;AAEhD,MAAM,gBAAgB,GAAa,GAAG,EAAE;IAC7C,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAE/C,IAAI,OAAO,CAAC,IAAI,KAAK,YAAY,EAAE;QACjC,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,8BAAC,2BAAiB,IAChB,WAAW,EAAC,kBAAkB,EAC9B,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;YAClB,KAAK,EAAE;gBACL,IAAI,EAAE;oBACJ,MAAM,EAAE;wBACN;4BACE,MAAM,EAAE;gCACN,IAAI,EAAE,aAAa;gCACnB,KAAK,EAAE;oCACL,IAAI,EAAE;wCACJ,4BAA4B,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM;qCACxD;iCACF;6BACF;yBACF;wBACD;4BACE,MAAM,EAAE;gCACN,IAAI,EAAE,WAAW;gCACjB,KAAK,EAAE;oCACL,IAAI,EAAE;wCACJ,oCAAoC,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM;qCAChE;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;SACF,CAAC,GACF,CACH,CAAC;AACJ,CAAC,CAAC;AAxCW,QAAA,gBAAgB,oBAwC3B","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent\";\n\nimport { useReactifySearchContext } from \"../../hooks\";\n\nexport const SensorCollection: React.FC = () => {\n const { options } = useReactifySearchContext();\n\n if (options.mode !== \"collection\") {\n return null;\n }\n\n return (\n <ReactiveComponent\n componentId=\"SensorCollection\"\n customQuery={() => ({\n query: {\n bool: {\n should: [\n {\n nested: {\n path: \"collections\",\n query: {\n term: {\n \"collections.handle.keyword\": options.collection.handle,\n },\n },\n },\n },\n {\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.collectionHandle.keyword\": options.collection.handle,\n },\n },\n },\n },\n ],\n },\n },\n })}\n />\n );\n};\n"]}
|
|
File without changes
|
|
@@ -8,7 +8,7 @@ const react_1 = __importDefault(require("react"));
|
|
|
8
8
|
const ReactiveComponent_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent"));
|
|
9
9
|
const hooks_1 = require("../../hooks");
|
|
10
10
|
const SensorInventoryAvailable = () => {
|
|
11
|
-
const filterStack = (0, hooks_1.useFilterStack)();
|
|
11
|
+
const { filterStack } = (0, hooks_1.useFilterStack)();
|
|
12
12
|
if (!filterStack || "show_all" === filterStack.inventoryVisibility)
|
|
13
13
|
return null;
|
|
14
14
|
return (react_1.default.createElement(ReactiveComponent_1.default, { componentId: "SensorInventoryAvailable", customQuery: () => ({
|
|
@@ -50,3 +50,4 @@ const SensorInventoryAvailable = () => {
|
|
|
50
50
|
}) }));
|
|
51
51
|
};
|
|
52
52
|
exports.SensorInventoryAvailable = SensorInventoryAvailable;
|
|
53
|
+
//# sourceMappingURL=SensorInventoryAvailable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SensorInventoryAvailable.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorInventoryAvailable.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;AAEjG,uCAA6C;AAEtC,MAAM,wBAAwB,GAAa,GAAG,EAAE;IACrD,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,sBAAc,GAAE,CAAC;IAEzC,IAAI,CAAC,WAAW,IAAI,UAAU,KAAK,WAAW,CAAC,mBAAmB;QAChE,OAAO,IAAI,CAAC;IAEd,OAAO,CACL,8BAAC,2BAAiB,IAChB,WAAW,EAAC,0BAA0B,EACtC,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;YAClB,KAAK,EAAE;gBACL,IAAI,EAAE;oBACJ,MAAM,EAAE;wBACN;4BACE,IAAI,EAAE;gCACJ,IAAI,EAAE;oCACJ;wCACE,IAAI,EAAE;4CACJ,IAAI,EAAE;gDACJ,KAAK,EAAE,SAAS;6CACjB;yCACF;qCACF;oCACD;wCACE,MAAM,EAAE;4CACN,IAAI,EAAE,UAAU;4CAChB,KAAK,EAAE;gDACL,KAAK,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE;6CACtC;yCACF;qCACF;iCACF;6BACF;yBACF;wBACD;4BACE,IAAI,EAAE;gCACJ,IAAI,EAAE;oCACJ,KAAK,EAAE,SAAS;iCACjB;6BACF;yBACF;qBACF;oBACD,oBAAoB,EAAE,GAAG;iBAC1B;aACF;SACF,CAAC,GACF,CACH,CAAC;AACJ,CAAC,CAAC;AAhDW,QAAA,wBAAwB,4BAgDnC","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent\";\n\nimport { useFilterStack } from \"../../hooks\";\n\nexport const SensorInventoryAvailable: React.FC = () => {\n const { filterStack } = useFilterStack();\n\n if (!filterStack || \"show_all\" === filterStack.inventoryVisibility)\n return null;\n\n return (\n <ReactiveComponent\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 {\n term: {\n type: {\n value: \"callout\",\n },\n },\n },\n ],\n minimum_should_match: \"1\",\n },\n },\n })}\n />\n );\n};\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SensorPublished.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorPublished.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;AAE1F,MAAM,eAAe,GAAa,GAAG,EAAE,CAAC,CAC7C,8BAAC,2BAAiB,IAChB,WAAW,EAAC,iBAAiB,EAC7B,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;QAClB,KAAK,EAAE;YACL,KAAK,EAAE;gBACL,SAAS,EAAE,IAAI;aAChB;SACF;KACF,CAAC,GACF,CACH,CAAC;AAXW,QAAA,eAAe,mBAW1B","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent\";\n\nexport const SensorPublished: React.FC = () => (\n <ReactiveComponent\n componentId=\"SensorPublished\"\n customQuery={() => ({\n query: {\n match: {\n published: true,\n },\n },\n })}\n />\n);\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SensorSearch.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorSearch.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,4GAAoF;AAEpF,uCAAkE;AAE3D,MAAM,YAAY,GAAa,GAAG,EAAE;IACzC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAC9C,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,iBAAS,GAAE,CAAC;IAEpC,mDAAmD;IACnD,MAAM,YAAY,GAAG,eAAK,CAAC,OAAO,CAChC,GAAG,EAAE,CACH,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAC7B,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAC5D,EACH,CAAC,MAAM,CAAC,MAAM,CAAC,CAChB,CAAC;IAEF,IAAI,CAAC,WAAW,IAAI,CAAC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AE,WAAW;oCACjB,KAAK,EAAE;wCACL,IAAI,EAAE;4CACJ,8BAA8B,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,WAAW,EAAE;yCACrD;qCACF;iCACF;6BACF;4BACD,GAAG,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC;gCAC9B,CAAC,CAAC;oCACE;wCACE,WAAW,EAAE;4CACX,KAAK,EAAE,KAAK;4CACZ,MAAM,EAAE,iBAAiB;4CACzB,IAAI,EAAE,cAAc;4CACpB,QAAQ,EAAE,KAAK;yCAChB;qCACF;iCACF;gCACH,CAAC,CAAC,EAAE,CAAC;4BACP,GAAG,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC;gCACzB,CAAC,CAAC;oCACE;wCACE,WAAW,EAAE;4CACX,KAAK,EAAE,KAAK;4CACZ,MAAM,EAAE,YAAY;4CACpB,IAAI,EAAE,QAAQ;4CACd,QAAQ,EAAE,KAAK;yCAChB;qCACF;iCACF;gCACH,CAAC,CAAC,EAAE,CAAC;4BACP,GAAG,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC;gCAC/B,CAAC,CAAC;oCACE;wCACE,WAAW,EAAE;4CACX,KAAK,EAAE,KAAK;4CACZ,MAAM,EAAE,kBAAkB;4CAC1B,IAAI,EAAE,eAAe;4CACrB,QAAQ,EAAE,KAAK;yCAChB;qCACF;iCACF;gCACH,CAAC,CAAC,EAAE,CAAC;yBACR;wBACD,oBAAoB,EAAE,GAAG;qBAC1B;iBACF,CAAC;gBACF,OAAO,EAAE,KAAK,EAAE,CAAC;YACnB,CAAC,GACD,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAtGW,QAAA,YAAY,gBAsGvB","sourcesContent":["import React from \"react\";\nimport DataSearch from \"@appbaseio/reactivesearch/lib/components/search/DataSearch\";\n\nimport { useReactifySearchContext, useSearch } from \"../../hooks\";\n\nexport const SensorSearch: React.FC = () => {\n const { config } = useReactifySearchContext();\n const { searchQuery } = useSearch();\n\n // ignore search fields only set for instant search\n const searchFields = React.useMemo(\n () =>\n config.fields.filter((field) =>\n [\"always_search\", \"search_page\"].includes(field.searchType)\n ),\n [config.fields]\n );\n\n if (!searchQuery || !searchFields.length) {\n return null;\n }\n\n return (\n <>\n <DataSearch\n fuzziness={1}\n queryFormat=\"and\"\n autosuggest={false}\n value={searchQuery}\n componentId=\"SensorSearch\"\n style={{ display: \"none\" }}\n dataField={searchFields.map((field) => field.field)}\n fieldWeights={searchFields.map((field) => field.importance)}\n customQuery={(value, props) => {\n const { dataField, fieldWeights } = props;\n\n const fieldsCrossFields = dataField.map(\n (field: string, index: number) => `${field}^${fieldWeights[index]}`\n );\n const fieldsPhrase = dataField.map(\n (field: string, index: number) => `${field}^${fieldWeights[index]}`\n );\n const fieldsPhrasePrefix = dataField\n .filter((field: string) => !field.includes(\".\"))\n .map(\n (field: string, index: number) =>\n `${field}^${fieldWeights[index]}`\n );\n\n const query = {\n bool: {\n should: [\n {\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.searchTerm.keyword\": value?.toLowerCase(),\n },\n },\n },\n },\n ...(fieldsCrossFields.length > 0\n ? [\n {\n multi_match: {\n query: value,\n fields: fieldsCrossFields,\n type: \"cross_fields\",\n operator: \"and\",\n },\n },\n ]\n : []),\n ...(fieldsPhrase.length > 0\n ? [\n {\n multi_match: {\n query: value,\n fields: fieldsPhrase,\n type: \"phrase\",\n operator: \"and\",\n },\n },\n ]\n : []),\n ...(fieldsPhrasePrefix.length > 0\n ? [\n {\n multi_match: {\n query: value,\n fields: fieldsPhrasePrefix,\n type: \"phrase_prefix\",\n operator: \"and\",\n },\n },\n ]\n : []),\n ],\n minimum_should_match: \"1\",\n },\n };\n return { query };\n }}\n />\n </>\n );\n};\n"]}
|
|
File without changes
|
|
@@ -7,22 +7,14 @@ exports.SensorSort = void 0;
|
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const ReactiveComponent_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent"));
|
|
9
9
|
const hooks_1 = require("../../hooks");
|
|
10
|
-
const debug = require("debug")("reactify-search:SensorSort");
|
|
11
10
|
const SensorSort = () => {
|
|
12
11
|
const { options, config } = (0, hooks_1.useReactifySearchContext)();
|
|
13
12
|
const curation = (0, hooks_1.useCuration)();
|
|
14
13
|
const globalCuration = (curation === null || curation === void 0 ? void 0 : curation.id) === "global";
|
|
15
14
|
const { sortOption } = (0, hooks_1.useSortby)();
|
|
16
|
-
const searchQuery = react_1.default.useMemo(() => {
|
|
17
|
-
if (typeof window === "undefined")
|
|
18
|
-
return "";
|
|
19
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
20
|
-
return urlParams.get("q") || "";
|
|
21
|
-
}, []);
|
|
22
15
|
const { sort, query } = react_1.default.useMemo(() => {
|
|
23
16
|
return {
|
|
24
17
|
sort: buildSort({
|
|
25
|
-
config,
|
|
26
18
|
sortOption,
|
|
27
19
|
collection: options.mode === "collection" ? options.collection : undefined,
|
|
28
20
|
curation,
|
|
@@ -35,11 +27,6 @@ const SensorSort = () => {
|
|
|
35
27
|
}),
|
|
36
28
|
};
|
|
37
29
|
}, [config, sortOption, curation]);
|
|
38
|
-
react_1.default.useEffect(() => {
|
|
39
|
-
debug("searchQuery", searchQuery);
|
|
40
|
-
debug("sort", sort);
|
|
41
|
-
debug("query", query);
|
|
42
|
-
}, [searchQuery, sort]);
|
|
43
30
|
return (react_1.default.createElement(ReactiveComponent_1.default, { componentId: "SensorSort", customQuery: () => ({
|
|
44
31
|
sort,
|
|
45
32
|
query,
|
|
@@ -48,12 +35,7 @@ const SensorSort = () => {
|
|
|
48
35
|
exports.SensorSort = SensorSort;
|
|
49
36
|
const buildSort = (args) => {
|
|
50
37
|
var _a;
|
|
51
|
-
const {
|
|
52
|
-
debug("buildSortQuery.start", {
|
|
53
|
-
config,
|
|
54
|
-
curation,
|
|
55
|
-
sortOption,
|
|
56
|
-
});
|
|
38
|
+
const { curation, sortOption, collection, globalCuration } = args;
|
|
57
39
|
// return default sort option if unset
|
|
58
40
|
if (!sortOption) {
|
|
59
41
|
return collection
|
|
@@ -202,3 +184,4 @@ const buildQuery = (args) => {
|
|
|
202
184
|
},
|
|
203
185
|
};
|
|
204
186
|
};
|
|
187
|
+
//# sourceMappingURL=SensorSort.js.map
|