@usereactify/search 5.60.0-beta.0 → 5.60.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -2
- package/dist/package.json +1 -1
- package/dist/src/components/Example/ExampleProductCardWeight.js +3 -7
- package/dist/src/components/Example/ExampleProductCardWeight.js.map +1 -1
- package/dist/src/components/Sensor/SensorSearchTerm.d.ts +1 -2
- package/dist/src/components/Sensor/SensorSearchTerm.js +38 -120
- package/dist/src/components/Sensor/SensorSearchTerm.js.map +1 -1
- package/dist/src/components/Sensor/Sensors.d.ts +1 -3
- package/dist/src/components/Sensor/Sensors.js +10 -29
- package/dist/src/components/Sensor/Sensors.js.map +1 -1
- package/dist/src/components/Sensor/index.d.ts +0 -2
- package/dist/src/components/Sensor/index.js +0 -4
- package/dist/src/components/Sensor/index.js.map +1 -1
- package/dist/src/search-request-builder/base-builders.d.ts +18 -0
- package/dist/src/search-request-builder/base-builders.js +184 -0
- package/dist/src/search-request-builder/base-builders.js.map +1 -0
- package/dist/src/search-request-builder/curation-builders.d.ts +2 -0
- package/dist/src/search-request-builder/curation-builders.js +44 -0
- package/dist/src/search-request-builder/curation-builders.js.map +1 -0
- package/dist/src/search-request-builder/index.d.ts +3 -0
- package/dist/src/search-request-builder/index.js +12 -0
- package/dist/src/search-request-builder/index.js.map +1 -0
- package/dist/src/search-request-builder/search-request-builder.d.ts +3 -0
- package/dist/src/search-request-builder/search-request-builder.js +54 -0
- package/dist/src/search-request-builder/search-request-builder.js.map +1 -0
- package/dist/src/search-request-builder/types.d.ts +105 -0
- package/dist/src/search-request-builder/types.js +30 -0
- package/dist/src/search-request-builder/types.js.map +1 -0
- package/dist/src/search-request-builder/utils.d.ts +27 -0
- package/dist/src/search-request-builder/utils.js +144 -0
- package/dist/src/search-request-builder/utils.js.map +1 -0
- package/dist/src/types/elastic.d.ts +6 -9
- package/dist/src/types/elastic.js.map +1 -1
- package/dist/src/types/firestore.d.ts +2 -2
- package/dist/src/types/firestore.js.map +1 -1
- package/dist/src/utility/config.d.ts +2 -2
- package/dist/src/utility/config.js +5 -8
- package/dist/src/utility/config.js.map +1 -1
- package/dist/src/utility/props.d.ts +5 -224
- package/dist/src/utility/props.js +54 -101
- package/dist/src/utility/props.js.map +1 -1
- package/dist/src/utility/server.js +1 -1
- package/dist/src/utility/server.js.map +1 -1
- package/dist/src/utility/weight.d.ts +7 -0
- package/dist/src/utility/weight.js +146 -22
- package/dist/src/utility/weight.js.map +1 -1
- package/package.json +1 -1
- package/dist/src/components/Sensor/SensorCollectionWeighted.d.ts +0 -1
- package/dist/src/components/Sensor/SensorCollectionWeighted.js +0 -21
- package/dist/src/components/Sensor/SensorCollectionWeighted.js.map +0 -1
- package/dist/src/components/Sensor/SensorSearchWeighted.d.ts +0 -1
- package/dist/src/components/Sensor/SensorSearchWeighted.js +0 -22
- package/dist/src/components/Sensor/SensorSearchWeighted.js.map +0 -1
- package/dist/src/utility/queries.d.ts +0 -393
- package/dist/src/utility/queries.js +0 -197
- package/dist/src/utility/queries.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,12 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
-
## [5.60.0-beta.
|
|
5
|
+
## [5.60.0-beta.2](///compare/beta-v5.60.0-beta.1...beta-v5.60.0-beta.2) (2026-01-15)
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
### Features
|
|
9
9
|
|
|
10
|
-
* add
|
|
10
|
+
* add term-level tracking and formatting for weight breakdown 949e7e9
|
|
11
|
+
|
|
12
|
+
## [5.60.0-beta.1](///compare/beta-v5.59.0-beta.8...beta-v5.60.0-beta.1) (2026-01-15)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* add configBaseUrl prop to ReactifySearchProvider d585de4
|
|
18
|
+
* Implement modular search request builder 2975d84
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* reposition product card weight component to card level 4a387eb
|
|
24
|
+
|
|
25
|
+
## [5.60.0-beta.0](///compare/beta-v5.59.0-beta.8...beta-v5.60.0-beta.0) (2026-01-15)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
* add configBaseUrl prop to ReactifySearchProvider d585de4
|
|
31
|
+
* Implement modular search request builder 2975d84
|
|
11
32
|
|
|
12
33
|
|
|
13
34
|
### Bug Fixes
|
package/dist/package.json
CHANGED
|
@@ -35,6 +35,8 @@ const ExampleProductCardWeight = ({ document }) => {
|
|
|
35
35
|
const weight = (0, react_1.useMemo)(() => (explanation ? (0, utility_1.getWeight)(explanation) : document._score), [explanation, document._score]);
|
|
36
36
|
// Parse the weight breakdown if available
|
|
37
37
|
const weightBreakdown = (0, react_1.useMemo)(() => (explanation ? (0, utility_1.explainWeight)(explanation) : []), [explanation]);
|
|
38
|
+
// Memoized formatted breakdown for performance
|
|
39
|
+
const formattedBreakdown = (0, react_1.useMemo)(() => (0, utility_1.formatWeightBreakdown)(weightBreakdown), [weightBreakdown]);
|
|
38
40
|
const toggleWeightBreakdown = () => setShowWeightBreakdown(!showWeightBreakdown);
|
|
39
41
|
if (!options.devMode)
|
|
40
42
|
return null;
|
|
@@ -65,13 +67,7 @@ const ExampleProductCardWeight = ({ document }) => {
|
|
|
65
67
|
overflowY: "auto",
|
|
66
68
|
padding: "8px",
|
|
67
69
|
} },
|
|
68
|
-
react_1.default.createElement("
|
|
69
|
-
weightBreakdown.map((item, index) => (react_1.default.createElement("div", { key: index, style: { marginBottom: "2px" } },
|
|
70
|
-
react_1.default.createElement("strong", null,
|
|
71
|
-
item.field,
|
|
72
|
-
":"),
|
|
73
|
-
" ",
|
|
74
|
-
item.weight.toFixed(2))))))));
|
|
70
|
+
react_1.default.createElement("div", { style: { whiteSpace: "pre-line", fontFamily: "monospace" } }, formattedBreakdown)))));
|
|
75
71
|
};
|
|
76
72
|
exports.ExampleProductCardWeight = ExampleProductCardWeight;
|
|
77
73
|
//# sourceMappingURL=ExampleProductCardWeight.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExampleProductCardWeight.js","sourceRoot":"","sources":["../../../../src/components/Example/ExampleProductCardWeight.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiD;AAEjD,uCAAuD;AACvD,
|
|
1
|
+
{"version":3,"file":"ExampleProductCardWeight.js","sourceRoot":"","sources":["../../../../src/components/Example/ExampleProductCardWeight.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiD;AAEjD,uCAAuD;AACvD,2CAMuB;AAOhB,MAAM,wBAAwB,GAAG,CAAC,EAAE,QAAQ,EAAiC,EAAE,EAAE;IACtF,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAC/C,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAEtE,8CAA8C;IAC9C,MAAM,WAAW,GAAG,QAAQ,CAAC,YAAY,CAAC;IAC1C,MAAM,MAAM,GAAG,IAAA,eAAO,EACpB,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAA,mBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAC9D,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,CAC/B,CAAC;IAEF,0CAA0C;IAC1C,MAAM,eAAe,GAA0B,IAAA,eAAO,EACpD,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAA,uBAAa,EAAC,WAAiC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAC3E,CAAC,WAAW,CAAC,CACd,CAAC;IAEF,+CAA+C;IAC/C,MAAM,kBAAkB,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,IAAA,+BAAqB,EAAC,eAAe,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;IAEpG,MAAM,qBAAqB,GAAG,GAAG,EAAE,CAAC,sBAAsB,CAAC,CAAC,mBAAmB,CAAC,CAAC;IAEjF,IAAI,CAAC,OAAO,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAElC,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEzB,OAAO,CACL,uCACE,SAAS,EAAC,iCAAiC,EAC3C,OAAO,EAAE,qBAAqB,EAC9B,KAAK,EAAE;YACL,UAAU,EAAE,oBAAoB;YAChC,YAAY,EAAE,KAAK;YACnB,KAAK,EAAE,OAAO;YACd,MAAM,EAAE,SAAS;YACjB,UAAU,EAAE,WAAW;YACvB,QAAQ,EAAE,MAAM;YAChB,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,MAAM;YAChB,OAAO,EAAE,SAAS;SACnB;QAED;;YAAc,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAO;QAErC,mBAAmB,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,IAAI,CACpD,uCACE,KAAK,EAAE;gBACL,eAAe,EAAE,2BAA2B;gBAC5C,MAAM,EAAE,gBAAgB;gBACxB,YAAY,EAAE,KAAK;gBACnB,KAAK,EAAE,OAAO;gBACd,QAAQ,EAAE,MAAM;gBAChB,SAAS,EAAE,KAAK;gBAChB,SAAS,EAAE,OAAO;gBAClB,SAAS,EAAE,MAAM;gBACjB,OAAO,EAAE,KAAK;aACf;YAED,uCAAK,KAAK,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,IAAG,kBAAkB,CAAO,CACvF,CACP,CACG,CACP,CAAC;AACJ,CAAC,CAAC;AA/DW,QAAA,wBAAwB,4BA+DnC","sourcesContent":["import React, { useState, useMemo } from \"react\";\n\nimport { useReactifySearchContext } from \"../../hooks\";\nimport {\n explainWeight,\n getWeight,\n ExplainScoreDetail,\n ExplainParsedWeight,\n formatWeightBreakdown,\n} from \"../../utility\";\nimport { ElasticProduct } from \"../../types\";\n\nexport interface ExampleProductCardWeightProps {\n document: ElasticProduct;\n}\n\nexport const ExampleProductCardWeight = ({ document }: ExampleProductCardWeightProps) => {\n const { options } = useReactifySearchContext();\n const [showWeightBreakdown, setShowWeightBreakdown] = useState(false);\n\n // Extract score and explanation from document\n const explanation = document._explanation;\n const weight = useMemo(\n () => (explanation ? getWeight(explanation) : document._score),\n [explanation, document._score],\n );\n\n // Parse the weight breakdown if available\n const weightBreakdown: ExplainParsedWeight[] = useMemo(\n () => (explanation ? explainWeight(explanation as ExplainScoreDetail) : []),\n [explanation],\n );\n\n // Memoized formatted breakdown for performance\n const formattedBreakdown = useMemo(() => formatWeightBreakdown(weightBreakdown), [weightBreakdown]);\n\n const toggleWeightBreakdown = () => setShowWeightBreakdown(!showWeightBreakdown);\n\n if (!options.devMode) return null;\n\n if (!weight) return null;\n\n return (\n <div\n className=\"rs__result-card-product__weight\"\n onClick={toggleWeightBreakdown}\n style={{\n background: \"rgba(0, 0, 0, 0.8)\",\n borderRadius: \"4px\",\n color: \"white\",\n cursor: \"pointer\",\n fontFamily: \"monospace\",\n fontSize: \"11px\",\n fontWeight: \"bold\",\n maxWidth: \"100%\",\n padding: \"4px 8px\",\n }}\n >\n <div>Weight: {weight.toFixed(2)}</div>\n\n {showWeightBreakdown && weightBreakdown.length > 0 && (\n <div\n style={{\n backgroundColor: \"rgba(255, 255, 255, 0.95)\",\n border: \"1px solid #ccc\",\n borderRadius: \"4px\",\n color: \"black\",\n fontSize: \"10px\",\n marginTop: \"8px\",\n maxHeight: \"150px\",\n overflowY: \"auto\",\n padding: \"8px\",\n }}\n >\n <div style={{ whiteSpace: \"pre-line\", fontFamily: \"monospace\" }}>{formattedBreakdown}</div>\n </div>\n )}\n </div>\n );\n};\n"]}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const SensorSearchTerm: React.FC;
|
|
1
|
+
export declare function SensorSearchTerm(): JSX.Element | null;
|
|
@@ -1,28 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SensorSearchTerm =
|
|
7
|
-
const react_1 =
|
|
29
|
+
exports.SensorSearchTerm = SensorSearchTerm;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
8
31
|
const ahooks_1 = require("ahooks");
|
|
9
32
|
const DataSearch_1 = __importDefault(require("@usereactify/search-internals/lib/components/search/DataSearch"));
|
|
10
33
|
const hooks_1 = require("../../hooks");
|
|
11
|
-
const
|
|
34
|
+
const props_1 = require("../../utility/props");
|
|
35
|
+
function SensorSearchTerm() {
|
|
12
36
|
const { options, config } = (0, hooks_1.useReactifySearchContext)();
|
|
13
37
|
const { track } = (0, hooks_1.useAnalytics)();
|
|
14
38
|
const { searchTerm } = (0, hooks_1.useSearch)();
|
|
15
|
-
const [searchTermDebounced, setSearchTermDebounced] = react_1.
|
|
16
|
-
// ignore search fields only set for instant search
|
|
17
|
-
const searchFields = react_1.default.useMemo(() => {
|
|
18
|
-
if (options.mode === "search") {
|
|
19
|
-
return config.fields.filter((field) => ["always_search", "search_page"].includes(field.searchType));
|
|
20
|
-
}
|
|
21
|
-
if (options.mode === "instant-search") {
|
|
22
|
-
return config.fields.filter((field) => ["always_search", "instant_search"].includes(field.searchType));
|
|
23
|
-
}
|
|
24
|
-
return [];
|
|
25
|
-
}, [config.fields]);
|
|
39
|
+
const [searchTermDebounced, setSearchTermDebounced] = (0, react_1.useState)(searchTerm);
|
|
26
40
|
const { run: runDebouncedTriggerQuery, cancel: cancelDebouncedTriggerQuery } = (0, ahooks_1.useDebounceFn)((value) => {
|
|
27
41
|
setSearchTermDebounced(value);
|
|
28
42
|
let trimmedSearchTerm = searchTerm.trim();
|
|
@@ -30,114 +44,18 @@ const SensorSearchTerm = () => {
|
|
|
30
44
|
return;
|
|
31
45
|
track({ eventName: "search", payload: { searchTerm: trimmedSearchTerm } });
|
|
32
46
|
}, { wait: 300 });
|
|
33
|
-
react_1.
|
|
47
|
+
(0, react_1.useEffect)(() => {
|
|
34
48
|
runDebouncedTriggerQuery(searchTerm);
|
|
35
49
|
}, [searchTerm]);
|
|
36
|
-
|
|
50
|
+
const reactiveProps = (0, props_1.getPropsSensorSearchTerm)({
|
|
51
|
+
config: config,
|
|
52
|
+
provider: options,
|
|
53
|
+
searchTerm: searchTermDebounced,
|
|
54
|
+
});
|
|
55
|
+
if (!reactiveProps) {
|
|
37
56
|
return null;
|
|
57
|
+
}
|
|
38
58
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
39
|
-
react_1.default.createElement(DataSearch_1.default, { fuzziness: 1, queryFormat: "and", autosuggest: false, value: searchTermDebounced, componentId: "SensorSearchTerm", style: { display: "none" }, dataField:
|
|
40
|
-
|
|
41
|
-
const conditions = [];
|
|
42
|
-
if (valueNormal) {
|
|
43
|
-
if (options.market) {
|
|
44
|
-
conditions.push({
|
|
45
|
-
nested: {
|
|
46
|
-
path: "curations",
|
|
47
|
-
query: {
|
|
48
|
-
bool: {
|
|
49
|
-
must: [
|
|
50
|
-
{
|
|
51
|
-
term: {
|
|
52
|
-
"curations.searchTerm.keyword": valueNormal,
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
term: {
|
|
57
|
-
"curations.markets.keyword": options.market,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
conditions.push({
|
|
68
|
-
nested: {
|
|
69
|
-
path: "curations",
|
|
70
|
-
query: {
|
|
71
|
-
term: {
|
|
72
|
-
"curations.searchTerm.keyword": valueNormal,
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
const fieldsPhrase = props.dataField.map((field, index) => `${field}^${props.fieldWeights[index]}`);
|
|
80
|
-
if (fieldsPhrase.length > 0) {
|
|
81
|
-
conditions.push({
|
|
82
|
-
multi_match: {
|
|
83
|
-
query: valueNormal,
|
|
84
|
-
fields: fieldsPhrase,
|
|
85
|
-
type: "phrase",
|
|
86
|
-
operator: "and",
|
|
87
|
-
},
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
const fieldsPhrasePrefix = props.dataField
|
|
91
|
-
.map((field, index) => `${field}^${props.fieldWeights[index]}`)
|
|
92
|
-
.filter((field) => !field.includes("."));
|
|
93
|
-
if (fieldsPhrasePrefix.length > 0) {
|
|
94
|
-
conditions.push({
|
|
95
|
-
multi_match: {
|
|
96
|
-
query: valueNormal,
|
|
97
|
-
fields: fieldsPhrasePrefix,
|
|
98
|
-
type: "phrase_prefix",
|
|
99
|
-
operator: "and",
|
|
100
|
-
},
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
const fieldsCrossFields = props.dataField.map((field, index) => `${field}^${props.fieldWeights[index]}`);
|
|
104
|
-
if (fieldsCrossFields.length > 0) {
|
|
105
|
-
conditions.push({
|
|
106
|
-
multi_match: {
|
|
107
|
-
query: valueNormal,
|
|
108
|
-
fields: fieldsCrossFields,
|
|
109
|
-
type: "cross_fields",
|
|
110
|
-
operator: "and",
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
const fieldsSpanFirst = props.dataField
|
|
115
|
-
.filter((field) => {
|
|
116
|
-
if (field.endsWith(".keyword")) {
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
return true;
|
|
120
|
-
})
|
|
121
|
-
.map((field) => ({
|
|
122
|
-
span_first: {
|
|
123
|
-
match: {
|
|
124
|
-
span_term: { [`${field}`]: valueNormal },
|
|
125
|
-
},
|
|
126
|
-
end: 1,
|
|
127
|
-
},
|
|
128
|
-
}));
|
|
129
|
-
if (fieldsSpanFirst.length > 0) {
|
|
130
|
-
conditions.push(...fieldsSpanFirst);
|
|
131
|
-
}
|
|
132
|
-
return {
|
|
133
|
-
query: {
|
|
134
|
-
bool: {
|
|
135
|
-
should: conditions,
|
|
136
|
-
minimum_should_match: "1",
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
};
|
|
140
|
-
} })));
|
|
141
|
-
};
|
|
142
|
-
exports.SensorSearchTerm = SensorSearchTerm;
|
|
59
|
+
react_1.default.createElement(DataSearch_1.default, { fuzziness: 1, queryFormat: "and", autosuggest: false, value: searchTermDebounced, componentId: "SensorSearchTerm", style: { display: "none" }, dataField: reactiveProps.dataField, fieldWeights: reactiveProps.fieldWeights, customQuery: reactiveProps.customQuery })));
|
|
60
|
+
}
|
|
143
61
|
//# sourceMappingURL=SensorSearchTerm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SensorSearchTerm.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorSearchTerm.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SensorSearchTerm.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorSearchTerm.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,4CA8CC;AArDD,+CAAmD;AACnD,mCAAuC;AACvC,gHAAwF;AAExF,uCAAgF;AAChF,+CAA+D;AAE/D,SAAgB,gBAAgB;IAC9B,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IACvD,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,oBAAY,GAAE,CAAC;IACjC,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,iBAAS,GAAE,CAAC;IAEnC,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GAAG,IAAA,gBAAQ,EAAS,UAAU,CAAC,CAAC;IAEnF,MAAM,EAAE,GAAG,EAAE,wBAAwB,EAAE,MAAM,EAAE,2BAA2B,EAAE,GAAG,IAAA,sBAAa,EAC1F,CAAC,KAAa,EAAE,EAAE;QAChB,sBAAsB,CAAC,KAAK,CAAC,CAAC;QAC9B,IAAI,iBAAiB,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC;QAC1C,IAAI,CAAC,iBAAiB,IAAI,CAAC,iBAAiB,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC;YAAE,OAAO;QACtF,KAAK,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,iBAAiB,EAAE,EAAE,CAAC,CAAC;IAC7E,CAAC,EACD,EAAE,IAAI,EAAE,GAAG,EAAE,CACd,CAAC;IAEF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,wBAAwB,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,MAAM,aAAa,GAAG,IAAA,gCAAwB,EAAC;QAC7C,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,OAAO;QACjB,UAAU,EAAE,mBAAmB;KAChC,CAAC,CAAC;IAEH,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL;QACE,8BAAC,oBAAU,IACT,SAAS,EAAE,CAAC,EACZ,WAAW,EAAC,KAAK,EACjB,WAAW,EAAE,KAAK,EAClB,KAAK,EAAE,mBAAmB,EAC1B,WAAW,EAAC,kBAAkB,EAC9B,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAC1B,SAAS,EAAE,aAAa,CAAC,SAAS,EAClC,YAAY,EAAE,aAAa,CAAC,YAAY,EACxC,WAAW,EAAE,aAAa,CAAC,WAAW,GACtC,CACD,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport { useDebounceFn } from \"ahooks\";\nimport DataSearch from \"@usereactify/search-internals/lib/components/search/DataSearch\";\n\nimport { useAnalytics, useReactifySearchContext, useSearch } from \"../../hooks\";\nimport { getPropsSensorSearchTerm } from \"../../utility/props\";\n\nexport function SensorSearchTerm() {\n const { options, config } = useReactifySearchContext();\n const { track } = useAnalytics();\n const { searchTerm } = useSearch();\n\n const [searchTermDebounced, setSearchTermDebounced] = useState<string>(searchTerm);\n\n const { run: runDebouncedTriggerQuery, cancel: cancelDebouncedTriggerQuery } = useDebounceFn(\n (value: string) => {\n setSearchTermDebounced(value);\n let trimmedSearchTerm = searchTerm.trim();\n if (!trimmedSearchTerm || (trimmedSearchTerm && trimmedSearchTerm.length < 3)) return;\n track({ eventName: \"search\", payload: { searchTerm: trimmedSearchTerm } });\n },\n { wait: 300 }\n );\n\n useEffect(() => {\n runDebouncedTriggerQuery(searchTerm);\n }, [searchTerm]);\n\n const reactiveProps = getPropsSensorSearchTerm({\n config: config,\n provider: options,\n searchTerm: searchTermDebounced,\n });\n\n if (!reactiveProps) {\n return null;\n }\n\n return (\n <>\n <DataSearch\n fuzziness={1}\n queryFormat=\"and\"\n autosuggest={false}\n value={searchTermDebounced}\n componentId=\"SensorSearchTerm\"\n style={{ display: \"none\" }}\n dataField={reactiveProps.dataField}\n fieldWeights={reactiveProps.fieldWeights}\n customQuery={reactiveProps.customQuery}\n />\n </>\n );\n}\n"]}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Sensors =
|
|
6
|
+
exports.Sensors = Sensors;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const hooks_1 = require("../../hooks");
|
|
9
9
|
const SensorSort_1 = require("./SensorSort");
|
|
@@ -12,49 +12,30 @@ const SensorCollection_1 = require("./SensorCollection");
|
|
|
12
12
|
const SensorSearchTerm_1 = require("./SensorSearchTerm");
|
|
13
13
|
const SensorInventoryAvailable_1 = require("./SensorInventoryAvailable");
|
|
14
14
|
const SensorCustom_1 = require("./SensorCustom");
|
|
15
|
-
const SensorCollectionWeighted_1 = require("./SensorCollectionWeighted");
|
|
16
|
-
const SensorSearchWeighted_1 = require("./SensorSearchWeighted");
|
|
17
15
|
const SensorExplain_1 = require("./SensorExplain");
|
|
18
|
-
|
|
19
|
-
var _a, _b
|
|
16
|
+
function Sensors() {
|
|
17
|
+
var _a, _b;
|
|
20
18
|
const { config, options } = (0, hooks_1.useReactifySearchContext)();
|
|
21
|
-
const
|
|
22
|
-
|
|
19
|
+
const isWeighted = ((_a = config.featureFlags) === null || _a === void 0 ? void 0 : _a.includes("use_weighted_base_search_request")) ||
|
|
20
|
+
((_b = config.featureFlags) === null || _b === void 0 ? void 0 : _b.includes("use_weighted_curation_search_request"));
|
|
23
21
|
if (options.mode === "search" || options.mode === "instant-search") {
|
|
24
|
-
if (useWeightedBaseSearchRequest) {
|
|
25
|
-
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
26
|
-
react_1.default.createElement(SensorSort_1.SensorSort, null),
|
|
27
|
-
react_1.default.createElement(SensorPublished_1.SensorPublished, null),
|
|
28
|
-
react_1.default.createElement(SensorSearchWeighted_1.SensorSearchWeighted, null),
|
|
29
|
-
react_1.default.createElement(SensorInventoryAvailable_1.SensorInventoryAvailable, null),
|
|
30
|
-
react_1.default.createElement(SensorCustom_1.SensorCustom, null),
|
|
31
|
-
react_1.default.createElement(SensorExplain_1.SensorExplain, null)));
|
|
32
|
-
}
|
|
33
22
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
34
23
|
react_1.default.createElement(SensorSort_1.SensorSort, null),
|
|
35
24
|
react_1.default.createElement(SensorPublished_1.SensorPublished, null),
|
|
36
25
|
react_1.default.createElement(SensorSearchTerm_1.SensorSearchTerm, null),
|
|
37
26
|
react_1.default.createElement(SensorInventoryAvailable_1.SensorInventoryAvailable, null),
|
|
38
|
-
react_1.default.createElement(SensorCustom_1.SensorCustom, null)
|
|
27
|
+
react_1.default.createElement(SensorCustom_1.SensorCustom, null),
|
|
28
|
+
isWeighted && react_1.default.createElement(SensorExplain_1.SensorExplain, null)));
|
|
39
29
|
}
|
|
40
30
|
if (options.mode === "collection") {
|
|
41
|
-
if (useWeightedCurationSearchRequest) {
|
|
42
|
-
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
43
|
-
react_1.default.createElement(SensorSort_1.SensorSort, null),
|
|
44
|
-
react_1.default.createElement(SensorPublished_1.SensorPublished, null),
|
|
45
|
-
react_1.default.createElement(SensorCollectionWeighted_1.SensorCollectionWeighted, null),
|
|
46
|
-
react_1.default.createElement(SensorInventoryAvailable_1.SensorInventoryAvailable, null),
|
|
47
|
-
react_1.default.createElement(SensorCustom_1.SensorCustom, null),
|
|
48
|
-
react_1.default.createElement(SensorExplain_1.SensorExplain, null)));
|
|
49
|
-
}
|
|
50
31
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
51
32
|
react_1.default.createElement(SensorSort_1.SensorSort, null),
|
|
52
33
|
react_1.default.createElement(SensorPublished_1.SensorPublished, null),
|
|
53
34
|
react_1.default.createElement(SensorCollection_1.SensorCollection, null),
|
|
54
35
|
react_1.default.createElement(SensorInventoryAvailable_1.SensorInventoryAvailable, null),
|
|
55
|
-
react_1.default.createElement(SensorCustom_1.SensorCustom, null)
|
|
36
|
+
react_1.default.createElement(SensorCustom_1.SensorCustom, null),
|
|
37
|
+
isWeighted && react_1.default.createElement(SensorExplain_1.SensorExplain, null)));
|
|
56
38
|
}
|
|
57
39
|
return null;
|
|
58
|
-
}
|
|
59
|
-
exports.Sensors = Sensors;
|
|
40
|
+
}
|
|
60
41
|
//# sourceMappingURL=Sensors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sensors.js","sourceRoot":"","sources":["../../../../src/components/Sensor/Sensors.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Sensors.js","sourceRoot":"","sources":["../../../../src/components/Sensor/Sensors.tsx"],"names":[],"mappings":";;;;;AAaA,0BAkCC;AA/CD,kDAA0B;AAE1B,uCAAuD;AAEvD,6CAA0C;AAC1C,uDAAoD;AACpD,yDAAsD;AACtD,yDAAsD;AACtD,yEAAsE;AACtE,iDAA8C;AAE9C,mDAAgD;AAEhD,SAAgB,OAAO;;IACrB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAEvD,MAAM,UAAU,GACd,CAAA,MAAA,MAAM,CAAC,YAAY,0CAAE,QAAQ,CAAC,kCAAkC,CAAC;SACjE,MAAA,MAAM,CAAC,YAAY,0CAAE,QAAQ,CAAC,sCAAsC,CAAC,CAAA,CAAC;IAExE,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;QACnE,OAAO,CACL;YACE,8BAAC,uBAAU,OAAG;YACd,8BAAC,iCAAe,OAAG;YACnB,8BAAC,mCAAgB,OAAG;YACpB,8BAAC,mDAAwB,OAAG;YAC5B,8BAAC,2BAAY,OAAG;YACf,UAAU,IAAI,8BAAC,6BAAa,OAAG,CAC/B,CACJ,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QAClC,OAAO,CACL;YACE,8BAAC,uBAAU,OAAG;YACd,8BAAC,iCAAe,OAAG;YACnB,8BAAC,mCAAgB,OAAG;YACpB,8BAAC,mDAAwB,OAAG;YAC5B,8BAAC,2BAAY,OAAG;YACf,UAAU,IAAI,8BAAC,6BAAa,OAAG,CAC/B,CACJ,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import React from \"react\";\n\nimport { useReactifySearchContext } from \"../../hooks\";\n\nimport { SensorSort } from \"./SensorSort\";\nimport { SensorPublished } from \"./SensorPublished\";\nimport { SensorCollection } from \"./SensorCollection\";\nimport { SensorSearchTerm } from \"./SensorSearchTerm\";\nimport { SensorInventoryAvailable } from \"./SensorInventoryAvailable\";\nimport { SensorCustom } from \"./SensorCustom\";\n\nimport { SensorExplain } from \"./SensorExplain\";\n\nexport function Sensors() {\n const { config, options } = useReactifySearchContext();\n\n const isWeighted =\n config.featureFlags?.includes(\"use_weighted_base_search_request\") ||\n config.featureFlags?.includes(\"use_weighted_curation_search_request\");\n\n if (options.mode === \"search\" || options.mode === \"instant-search\") {\n return (\n <>\n <SensorSort />\n <SensorPublished />\n <SensorSearchTerm />\n <SensorInventoryAvailable />\n <SensorCustom />\n {isWeighted && <SensorExplain />}\n </>\n );\n }\n\n if (options.mode === \"collection\") {\n return (\n <>\n <SensorSort />\n <SensorPublished />\n <SensorCollection />\n <SensorInventoryAvailable />\n <SensorCustom />\n {isWeighted && <SensorExplain />}\n </>\n );\n }\n\n return null;\n}\n"]}
|
|
@@ -5,8 +5,6 @@ export * from "./SensorPublished";
|
|
|
5
5
|
export * from "./SensorCollection";
|
|
6
6
|
export * from "./SensorSearchTerm";
|
|
7
7
|
export * from "./SensorInventoryAvailable";
|
|
8
|
-
export * from "./SensorCollectionWeighted";
|
|
9
|
-
export * from "./SensorSearchWeighted";
|
|
10
8
|
export * from "./SensorExplain";
|
|
11
9
|
export * from "./Sensors";
|
|
12
10
|
export declare const SENSOR_IDS: (mode: ReactifySearchMode, config: Config, variation?: string) => string[];
|
|
@@ -20,8 +20,6 @@ __exportStar(require("./SensorPublished"), exports);
|
|
|
20
20
|
__exportStar(require("./SensorCollection"), exports);
|
|
21
21
|
__exportStar(require("./SensorSearchTerm"), exports);
|
|
22
22
|
__exportStar(require("./SensorInventoryAvailable"), exports);
|
|
23
|
-
__exportStar(require("./SensorCollectionWeighted"), exports);
|
|
24
|
-
__exportStar(require("./SensorSearchWeighted"), exports);
|
|
25
23
|
__exportStar(require("./SensorExplain"), exports);
|
|
26
24
|
__exportStar(require("./Sensors"), exports);
|
|
27
25
|
// This is consumed by the react prop in various components
|
|
@@ -32,8 +30,6 @@ const SENSOR_IDS = (mode, config, variation) => {
|
|
|
32
30
|
"SensorCollection",
|
|
33
31
|
"SensorSearchTerm",
|
|
34
32
|
"SensorInventoryAvailable",
|
|
35
|
-
"SensorCollectionWeighted",
|
|
36
|
-
"SensorSearchWeighted",
|
|
37
33
|
"SensorExplain",
|
|
38
34
|
];
|
|
39
35
|
const sensorType = mode === "collection" ? "collection" : "search";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Sensor/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAGA,+CAA6B;AAC7B,oDAAkC;AAClC,qDAAmC;AACnC,qDAAmC;AACnC,6DAA2C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Sensor/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAGA,+CAA6B;AAC7B,oDAAkC;AAClC,qDAAmC;AACnC,qDAAmC;AACnC,6DAA2C;AAE3C,kDAAgC;AAEhC,4CAA0B;AAE1B,2DAA2D;AACpD,MAAM,UAAU,GAAG,CAAC,IAAwB,EAAE,MAAc,EAAE,SAAkB,EAAE,EAAE;IACzF,MAAM,SAAS,GAAG;QAChB,YAAY;QACZ,iBAAiB;QACjB,kBAAkB;QAClB,kBAAkB;QAClB,0BAA0B;QAC1B,eAAe;KAChB,CAAC;IAEF,MAAM,UAAU,GAAG,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC;IAEnE,MAAM,aAAa,GAAG,UAAU,KAAK,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;IACtG,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,SAAS,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,gBAAgB,KAAK,EAAE,CAAC,CAAC,CAAC;IACjF,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAlBW,QAAA,UAAU,cAkBrB","sourcesContent":["import { ReactifySearchMode } from \"../../hooks\";\nimport { Config } from \"../../types\";\n\nexport * from \"./SensorSort\";\nexport * from \"./SensorPublished\";\nexport * from \"./SensorCollection\";\nexport * from \"./SensorSearchTerm\";\nexport * from \"./SensorInventoryAvailable\";\n\nexport * from \"./SensorExplain\";\n\nexport * from \"./Sensors\";\n\n// This is consumed by the react prop in various components\nexport const SENSOR_IDS = (mode: ReactifySearchMode, config: Config, variation?: string) => {\n const sensorIds = [\n \"SensorSort\",\n \"SensorPublished\",\n \"SensorCollection\",\n \"SensorSearchTerm\",\n \"SensorInventoryAvailable\",\n \"SensorExplain\",\n ];\n\n const sensorType = mode === \"collection\" ? \"collection\" : \"search\";\n\n const customSensors = sensorType === \"collection\" ? config.sensors.collection : config.sensors.search;\n if (customSensors.length > 0) {\n sensorIds.push(...customSensors.map((item, index) => `SensorCustom_${index}`));\n }\n\n return sensorIds;\n};\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Boosting, SearchableField } from "../types/firestore";
|
|
2
|
+
import { FunctionScoreQuery, GenerateSearchRequestOptions, QueryContainer, SearchRequest, CollectionSearchRequestOptions } from "./types";
|
|
3
|
+
export declare function generateBaseSearchRequest(options: GenerateSearchRequestOptions): SearchRequest;
|
|
4
|
+
export declare function generateCollectionSearchRequest(options: CollectionSearchRequestOptions): SearchRequest;
|
|
5
|
+
export declare function generateCollectionBaseQuery(options: CollectionSearchRequestOptions): QueryContainer;
|
|
6
|
+
export declare function generateWeightedSearchQuery(options: {
|
|
7
|
+
searchTerm: string;
|
|
8
|
+
searchableFields: SearchableField[];
|
|
9
|
+
boostingRules: Boosting[];
|
|
10
|
+
markets: string[];
|
|
11
|
+
market?: string;
|
|
12
|
+
}): FunctionScoreQuery;
|
|
13
|
+
export declare function generateWeightedCollectionQuery(options: {
|
|
14
|
+
collectionHandle: string;
|
|
15
|
+
boostingRules: Boosting[];
|
|
16
|
+
markets: string[];
|
|
17
|
+
market?: string;
|
|
18
|
+
}): FunctionScoreQuery;
|