@usereactify/search 5.0.1 → 5.1.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/package.json +1 -1
  3. package/dist/src/components/Example/ExampleCustomComponent.d.ts +1 -1
  4. package/dist/src/components/Example/ExampleCustomComponent.js +5 -21
  5. package/dist/src/components/Example/ExampleCustomComponent.js.map +1 -1
  6. package/dist/src/components/Example/ExampleReactiveSearchProviderCollection.d.ts +1 -1
  7. package/dist/src/components/Example/ExampleReactiveSearchProviderCollection.js +4 -20
  8. package/dist/src/components/Example/ExampleReactiveSearchProviderCollection.js.map +1 -1
  9. package/dist/src/components/Example/ExampleReactiveSearchProviderInstantSearch.d.ts +1 -1
  10. package/dist/src/components/Example/ExampleReactiveSearchProviderInstantSearch.js +4 -20
  11. package/dist/src/components/Example/ExampleReactiveSearchProviderInstantSearch.js.map +1 -1
  12. package/dist/src/components/Example/ExampleReactiveSearchProviderSearch.d.ts +1 -1
  13. package/dist/src/components/Example/ExampleReactiveSearchProviderSearch.js +4 -20
  14. package/dist/src/components/Example/ExampleReactiveSearchProviderSearch.js.map +1 -1
  15. package/dist/src/components/Example/ExampleResults.d.ts +1 -1
  16. package/dist/src/components/Example/ExampleResults.js +4 -20
  17. package/dist/src/components/Example/ExampleResults.js.map +1 -1
  18. package/dist/src/components/Sensor/SensorCollection.js +0 -10
  19. package/dist/src/components/Sensor/SensorCollection.js.map +1 -1
  20. package/dist/src/components/Sensor/SensorCuration.d.ts +2 -0
  21. package/dist/src/components/Sensor/SensorCuration.js +54 -0
  22. package/dist/src/components/Sensor/SensorCuration.js.map +1 -0
  23. package/dist/src/components/Sensor/SensorSearchTerm.d.ts +2 -0
  24. package/dist/src/components/Sensor/{SensorSearch.js → SensorSearchTerm.js} +16 -18
  25. package/dist/src/components/Sensor/SensorSearchTerm.js.map +1 -0
  26. package/dist/src/components/Sensor/SensorSort.js +2 -2
  27. package/dist/src/components/Sensor/SensorSort.js.map +1 -1
  28. package/dist/src/components/Sensor/Sensors.js +20 -9
  29. package/dist/src/components/Sensor/Sensors.js.map +1 -1
  30. package/dist/src/components/Sensor/index.d.ts +2 -1
  31. package/dist/src/components/Sensor/index.js +4 -2
  32. package/dist/src/components/Sensor/index.js.map +1 -1
  33. package/dist/src/hooks/useCuration.d.ts +3 -1
  34. package/dist/src/hooks/useCuration.js +3 -1
  35. package/dist/src/hooks/useCuration.js.map +1 -1
  36. package/package.json +1 -1
  37. package/dist/src/components/Sensor/SensorSearch.d.ts +0 -2
  38. package/dist/src/components/Sensor/SensorSearch.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,29 @@
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.1.1-beta.1](https://bitbucket.org/usereactify/reactify-search-ui/compare/beta-v5.1.1-beta.0...beta-v5.1.1-beta.1) (2022-08-08)
6
+
7
+ ### [5.1.1-beta.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/beta-v5.1.0-beta.0...beta-v5.1.1-beta.0) (2022-08-08)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * prevent sensorsort using global curation ([55cdfaa](https://bitbucket.org/usereactify/reactify-search-ui/commit/55cdfaa8e5fa8b32c3bce111d7a681eb7d7577ae))
13
+
14
+ ## [5.1.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.0.1...release-v5.1.0) (2022-08-07)
15
+
16
+
17
+ ### Features
18
+
19
+ * separate searchTerm sensor for instant-search and search ([37a767a](https://bitbucket.org/usereactify/reactify-search-ui/commit/37a767a8b90d89ca9f7b16cce9783ce045671882))
20
+
21
+ ## [5.1.0-beta.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/beta-v5.0.0-beta.16...beta-v5.1.0-beta.0) (2022-08-07)
22
+
23
+
24
+ ### Features
25
+
26
+ * separate searchTerm sensor for instant-search and search ([37a767a](https://bitbucket.org/usereactify/reactify-search-ui/commit/37a767a8b90d89ca9f7b16cce9783ce045671882))
27
+
5
28
  ### 5.0.1 (2022-08-05)
6
29
 
7
30
 
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@usereactify/search",
3
3
  "description": "React UI library for Reactify Search",
4
- "version": "5.0.1",
4
+ "version": "5.1.1-beta.1",
5
5
  "license": "MIT",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",
@@ -1,2 +1,2 @@
1
- import * as React from "react";
1
+ import React from "react";
2
2
  export declare const ExampleCustomComponent: React.FC;
@@ -1,30 +1,14 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
20
4
  };
21
5
  Object.defineProperty(exports, "__esModule", { value: true });
22
6
  exports.ExampleCustomComponent = void 0;
23
- const React = __importStar(require("react"));
7
+ const react_1 = __importDefault(require("react"));
24
8
  const components_1 = require("../../components");
25
9
  const ExampleCustomComponent = () => {
26
- return (React.createElement(components_1.ReactifySearchProvider, { mode: "search", shopifyPermanentDomain: "reactify-apps.myshopify.com", additionalComponentHandles: ["SensorSpecialProduct"] },
27
- React.createElement(components_1.CustomComponent, { componentId: "SensorSpecialProduct", customQuery: () => ({
10
+ return (react_1.default.createElement(components_1.ReactifySearchProvider, { mode: "search", shopifyPermanentDomain: "reactify-apps.myshopify.com", additionalComponentHandles: ["SensorSpecialProduct"] },
11
+ react_1.default.createElement(components_1.CustomComponent, { componentId: "SensorSpecialProduct", customQuery: () => ({
28
12
  query: {
29
13
  match: {
30
14
  product_type: "Special Product",
@@ -1 +1 @@
1
- {"version":3,"file":"ExampleCustomComponent.js","sourceRoot":"","sources":["../../../../src/components/Example/ExampleCustomComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAE/B,iDAA2E;AAEpE,MAAM,sBAAsB,GAAa,GAAG,EAAE;IACnD,OAAO,CACL,oBAAC,mCAAsB,IACrB,IAAI,EAAC,QAAQ,EACb,sBAAsB,EAAC,6BAA6B,EACpD,0BAA0B,EAAE,CAAC,sBAAsB,CAAC;QAEpD,oBAAC,4BAAe,IACd,WAAW,EAAC,sBAAsB,EAClC,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;gBAClB,KAAK,EAAE;oBACL,KAAK,EAAE;wBACL,YAAY,EAAE,iBAAiB;qBAChC;iBACF;aACF,CAAC,GACF,CACqB,CAC1B,CAAC;AACJ,CAAC,CAAC;AAnBW,QAAA,sBAAsB,0BAmBjC","sourcesContent":["import * as React from \"react\";\n\nimport { ReactifySearchProvider, CustomComponent } from \"../../components\";\n\nexport const ExampleCustomComponent: React.FC = () => {\n return (\n <ReactifySearchProvider\n mode=\"search\"\n shopifyPermanentDomain=\"reactify-apps.myshopify.com\"\n additionalComponentHandles={[\"SensorSpecialProduct\"]}\n >\n <CustomComponent\n componentId=\"SensorSpecialProduct\"\n customQuery={() => ({\n query: {\n match: {\n product_type: \"Special Product\",\n },\n },\n })}\n />\n </ReactifySearchProvider>\n );\n};\n"]}
1
+ {"version":3,"file":"ExampleCustomComponent.js","sourceRoot":"","sources":["../../../../src/components/Example/ExampleCustomComponent.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,iDAA2E;AAEpE,MAAM,sBAAsB,GAAa,GAAG,EAAE;IACnD,OAAO,CACL,8BAAC,mCAAsB,IACrB,IAAI,EAAC,QAAQ,EACb,sBAAsB,EAAC,6BAA6B,EACpD,0BAA0B,EAAE,CAAC,sBAAsB,CAAC;QAEpD,8BAAC,4BAAe,IACd,WAAW,EAAC,sBAAsB,EAClC,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;gBAClB,KAAK,EAAE;oBACL,KAAK,EAAE;wBACL,YAAY,EAAE,iBAAiB;qBAChC;iBACF;aACF,CAAC,GACF,CACqB,CAC1B,CAAC;AACJ,CAAC,CAAC;AAnBW,QAAA,sBAAsB,0BAmBjC","sourcesContent":["import React from \"react\";\n\nimport { ReactifySearchProvider, CustomComponent } from \"../../components\";\n\nexport const ExampleCustomComponent: React.FC = () => {\n return (\n <ReactifySearchProvider\n mode=\"search\"\n shopifyPermanentDomain=\"reactify-apps.myshopify.com\"\n additionalComponentHandles={[\"SensorSpecialProduct\"]}\n >\n <CustomComponent\n componentId=\"SensorSpecialProduct\"\n customQuery={() => ({\n query: {\n match: {\n product_type: \"Special Product\",\n },\n },\n })}\n />\n </ReactifySearchProvider>\n );\n};\n"]}
@@ -1,2 +1,2 @@
1
- import * as React from "react";
1
+ import React from "react";
2
2
  export declare const ExampleReactiveSearchProviderCollection: React.FC;
@@ -1,27 +1,11 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
20
4
  };
21
5
  Object.defineProperty(exports, "__esModule", { value: true });
22
6
  exports.ExampleReactiveSearchProviderCollection = void 0;
23
- const React = __importStar(require("react"));
7
+ const react_1 = __importDefault(require("react"));
24
8
  const components_1 = require("../../components");
25
- const ExampleReactiveSearchProviderCollection = () => (React.createElement(components_1.ReactifySearchProvider, { mode: "collection", shopifyPermanentDomain: "reactify-apps.myshopify.com", collectionHandle: "example-collection" }, "..."));
9
+ const ExampleReactiveSearchProviderCollection = () => (react_1.default.createElement(components_1.ReactifySearchProvider, { mode: "collection", shopifyPermanentDomain: "reactify-apps.myshopify.com", collectionHandle: "example-collection" }, "..."));
26
10
  exports.ExampleReactiveSearchProviderCollection = ExampleReactiveSearchProviderCollection;
27
11
  //# sourceMappingURL=ExampleReactiveSearchProviderCollection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExampleReactiveSearchProviderCollection.js","sourceRoot":"","sources":["../../../../src/components/Example/ExampleReactiveSearchProviderCollection.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAE/B,iDAA0D;AAEnD,MAAM,uCAAuC,GAAa,GAAG,EAAE,CAAC,CACrE,oBAAC,mCAAsB,IACrB,IAAI,EAAC,YAAY,EACjB,sBAAsB,EAAC,6BAA6B,EACpD,gBAAgB,EAAC,oBAAoB,UAGd,CAC1B,CAAC;AARW,QAAA,uCAAuC,2CAQlD","sourcesContent":["import * as React from \"react\";\n\nimport { ReactifySearchProvider } from \"../../components\";\n\nexport const ExampleReactiveSearchProviderCollection: React.FC = () => (\n <ReactifySearchProvider\n mode=\"collection\"\n shopifyPermanentDomain=\"reactify-apps.myshopify.com\"\n collectionHandle=\"example-collection\"\n >\n ...\n </ReactifySearchProvider>\n);\n"]}
1
+ {"version":3,"file":"ExampleReactiveSearchProviderCollection.js","sourceRoot":"","sources":["../../../../src/components/Example/ExampleReactiveSearchProviderCollection.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,iDAA0D;AAEnD,MAAM,uCAAuC,GAAa,GAAG,EAAE,CAAC,CACrE,8BAAC,mCAAsB,IACrB,IAAI,EAAC,YAAY,EACjB,sBAAsB,EAAC,6BAA6B,EACpD,gBAAgB,EAAC,oBAAoB,UAGd,CAC1B,CAAC;AARW,QAAA,uCAAuC,2CAQlD","sourcesContent":["import React from \"react\";\n\nimport { ReactifySearchProvider } from \"../../components\";\n\nexport const ExampleReactiveSearchProviderCollection: React.FC = () => (\n <ReactifySearchProvider\n mode=\"collection\"\n shopifyPermanentDomain=\"reactify-apps.myshopify.com\"\n collectionHandle=\"example-collection\"\n >\n ...\n </ReactifySearchProvider>\n);\n"]}
@@ -1,2 +1,2 @@
1
- import * as React from "react";
1
+ import React from "react";
2
2
  export declare const ExampleReactiveSearchProviderInstantSearch: React.FC;
@@ -1,27 +1,11 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
20
4
  };
21
5
  Object.defineProperty(exports, "__esModule", { value: true });
22
6
  exports.ExampleReactiveSearchProviderInstantSearch = void 0;
23
- const React = __importStar(require("react"));
7
+ const react_1 = __importDefault(require("react"));
24
8
  const components_1 = require("../../components");
25
- const ExampleReactiveSearchProviderInstantSearch = () => (React.createElement(components_1.ReactifySearchProvider, { mode: "instant-search", shopifyPermanentDomain: "reactify-apps.myshopify.com" }, "..."));
9
+ const ExampleReactiveSearchProviderInstantSearch = () => (react_1.default.createElement(components_1.ReactifySearchProvider, { mode: "instant-search", shopifyPermanentDomain: "reactify-apps.myshopify.com" }, "..."));
26
10
  exports.ExampleReactiveSearchProviderInstantSearch = ExampleReactiveSearchProviderInstantSearch;
27
11
  //# sourceMappingURL=ExampleReactiveSearchProviderInstantSearch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExampleReactiveSearchProviderInstantSearch.js","sourceRoot":"","sources":["../../../../src/components/Example/ExampleReactiveSearchProviderInstantSearch.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAE/B,iDAA0D;AAEnD,MAAM,0CAA0C,GAAa,GAAG,EAAE,CAAC,CACxE,oBAAC,mCAAsB,IACrB,IAAI,EAAC,gBAAgB,EACrB,sBAAsB,EAAC,6BAA6B,UAG7B,CAC1B,CAAC;AAPW,QAAA,0CAA0C,8CAOrD","sourcesContent":["import * as React from \"react\";\n\nimport { ReactifySearchProvider } from \"../../components\";\n\nexport const ExampleReactiveSearchProviderInstantSearch: React.FC = () => (\n <ReactifySearchProvider\n mode=\"instant-search\"\n shopifyPermanentDomain=\"reactify-apps.myshopify.com\"\n >\n ...\n </ReactifySearchProvider>\n);\n"]}
1
+ {"version":3,"file":"ExampleReactiveSearchProviderInstantSearch.js","sourceRoot":"","sources":["../../../../src/components/Example/ExampleReactiveSearchProviderInstantSearch.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,iDAA0D;AAEnD,MAAM,0CAA0C,GAAa,GAAG,EAAE,CAAC,CACxE,8BAAC,mCAAsB,IACrB,IAAI,EAAC,gBAAgB,EACrB,sBAAsB,EAAC,6BAA6B,UAG7B,CAC1B,CAAC;AAPW,QAAA,0CAA0C,8CAOrD","sourcesContent":["import React from \"react\";\n\nimport { ReactifySearchProvider } from \"../../components\";\n\nexport const ExampleReactiveSearchProviderInstantSearch: React.FC = () => (\n <ReactifySearchProvider\n mode=\"instant-search\"\n shopifyPermanentDomain=\"reactify-apps.myshopify.com\"\n >\n ...\n </ReactifySearchProvider>\n);\n"]}
@@ -1,2 +1,2 @@
1
- import * as React from "react";
1
+ import React from "react";
2
2
  export declare const ExampleReactiveSearchProviderSearch: React.FC;
@@ -1,27 +1,11 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
20
4
  };
21
5
  Object.defineProperty(exports, "__esModule", { value: true });
22
6
  exports.ExampleReactiveSearchProviderSearch = void 0;
23
- const React = __importStar(require("react"));
7
+ const react_1 = __importDefault(require("react"));
24
8
  const components_1 = require("../../components");
25
- const ExampleReactiveSearchProviderSearch = () => (React.createElement(components_1.ReactifySearchProvider, { mode: "search", shopifyPermanentDomain: "reactify-apps.myshopify.com" }, "..."));
9
+ const ExampleReactiveSearchProviderSearch = () => (react_1.default.createElement(components_1.ReactifySearchProvider, { mode: "search", shopifyPermanentDomain: "reactify-apps.myshopify.com" }, "..."));
26
10
  exports.ExampleReactiveSearchProviderSearch = ExampleReactiveSearchProviderSearch;
27
11
  //# sourceMappingURL=ExampleReactiveSearchProviderSearch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExampleReactiveSearchProviderSearch.js","sourceRoot":"","sources":["../../../../src/components/Example/ExampleReactiveSearchProviderSearch.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAE/B,iDAA0D;AAEnD,MAAM,mCAAmC,GAAa,GAAG,EAAE,CAAC,CACjE,oBAAC,mCAAsB,IACrB,IAAI,EAAC,QAAQ,EACb,sBAAsB,EAAC,6BAA6B,UAG7B,CAC1B,CAAC;AAPW,QAAA,mCAAmC,uCAO9C","sourcesContent":["import * as React from \"react\";\n\nimport { ReactifySearchProvider } from \"../../components\";\n\nexport const ExampleReactiveSearchProviderSearch: React.FC = () => (\n <ReactifySearchProvider\n mode=\"search\"\n shopifyPermanentDomain=\"reactify-apps.myshopify.com\"\n >\n ...\n </ReactifySearchProvider>\n);\n"]}
1
+ {"version":3,"file":"ExampleReactiveSearchProviderSearch.js","sourceRoot":"","sources":["../../../../src/components/Example/ExampleReactiveSearchProviderSearch.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,iDAA0D;AAEnD,MAAM,mCAAmC,GAAa,GAAG,EAAE,CAAC,CACjE,8BAAC,mCAAsB,IACrB,IAAI,EAAC,QAAQ,EACb,sBAAsB,EAAC,6BAA6B,UAG7B,CAC1B,CAAC;AAPW,QAAA,mCAAmC,uCAO9C","sourcesContent":["import React from \"react\";\n\nimport { ReactifySearchProvider } from \"../../components\";\n\nexport const ExampleReactiveSearchProviderSearch: React.FC = () => (\n <ReactifySearchProvider\n mode=\"search\"\n shopifyPermanentDomain=\"reactify-apps.myshopify.com\"\n >\n ...\n </ReactifySearchProvider>\n);\n"]}
@@ -1,2 +1,2 @@
1
- import * as React from "react";
1
+ import React from "react";
2
2
  export declare const Component: React.FC;
@@ -1,26 +1,10 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
20
4
  };
21
5
  Object.defineProperty(exports, "__esModule", { value: true });
22
6
  exports.Component = void 0;
23
- const React = __importStar(require("react"));
7
+ const react_1 = __importDefault(require("react"));
24
8
  const components_1 = require("../../components");
25
9
  const ExampleResultCardProduct_1 = require("./ExampleResultCardProduct");
26
10
  const ExampleResultCardCallout_1 = require("./ExampleResultCardCallout");
@@ -28,7 +12,7 @@ const ExampleResultPaginationNumbered_1 = require("./ExampleResultPaginationNumb
28
12
  const ExampleResultPaginationLoadMore_1 = require("./ExampleResultPaginationLoadMore");
29
13
  const ExampleResultPaginationNextPrev_1 = require("./ExampleResultPaginationNextPrev");
30
14
  const Component = () => {
31
- return (React.createElement(components_1.Results, { listStyle: {
15
+ return (react_1.default.createElement(components_1.Results, { listStyle: {
32
16
  display: "grid",
33
17
  gap: "10px",
34
18
  gridTemplateColumns: "repeat(4, minmax(0, 1fr))",
@@ -1 +1 @@
1
- {"version":3,"file":"ExampleResults.js","sourceRoot":"","sources":["../../../../src/components/Example/ExampleResults.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAE/B,iDAA2C;AAE3C,yEAAsE;AACtE,yEAAsE;AACtE,uFAAoF;AACpF,uFAAoF;AACpF,uFAAoF;AAE7E,MAAM,SAAS,GAAa,GAAG,EAAE;IACtC,OAAO,CACL,oBAAC,oBAAO,IACN,SAAS,EAAE;YACT,OAAO,EAAE,MAAM;YACf,GAAG,EAAE,MAAM;YACX,mBAAmB,EAAE,2BAA2B;SACjD,EACD,uBAAuB,EAAE,mDAAwB,EACjD,uBAAuB,EAAE,mDAAwB,EACjD,wBAAwB,EAAE,iEAA+B,EACzD,wBAAwB,EAAE,iEAA+B,EACzD,wBAAwB,EAAE,iEAA+B,GACzD,CACH,CAAC;AACJ,CAAC,CAAC;AAfW,QAAA,SAAS,aAepB","sourcesContent":["import * as React from \"react\";\n\nimport { Results } from \"../../components\";\n\nimport { ExampleResultCardProduct } from \"./ExampleResultCardProduct\";\nimport { ExampleResultCardCallout } from \"./ExampleResultCardCallout\";\nimport { ExampleResultPaginationNumbered } from \"./ExampleResultPaginationNumbered\";\nimport { ExampleResultPaginationLoadMore } from \"./ExampleResultPaginationLoadMore\";\nimport { ExampleResultPaginationNextPrev } from \"./ExampleResultPaginationNextPrev\";\n\nexport const Component: React.FC = () => {\n return (\n <Results\n listStyle={{\n display: \"grid\",\n gap: \"10px\",\n gridTemplateColumns: \"repeat(4, minmax(0, 1fr))\",\n }}\n renderResultCardProduct={ExampleResultCardProduct}\n renderResultCardCallout={ExampleResultCardCallout}\n renderPaginationNumbered={ExampleResultPaginationNumbered}\n renderPaginationLoadMore={ExampleResultPaginationLoadMore}\n renderPaginationNextPrev={ExampleResultPaginationNextPrev}\n />\n );\n};\n"]}
1
+ {"version":3,"file":"ExampleResults.js","sourceRoot":"","sources":["../../../../src/components/Example/ExampleResults.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,iDAA2C;AAE3C,yEAAsE;AACtE,yEAAsE;AACtE,uFAAoF;AACpF,uFAAoF;AACpF,uFAAoF;AAE7E,MAAM,SAAS,GAAa,GAAG,EAAE;IACtC,OAAO,CACL,8BAAC,oBAAO,IACN,SAAS,EAAE;YACT,OAAO,EAAE,MAAM;YACf,GAAG,EAAE,MAAM;YACX,mBAAmB,EAAE,2BAA2B;SACjD,EACD,uBAAuB,EAAE,mDAAwB,EACjD,uBAAuB,EAAE,mDAAwB,EACjD,wBAAwB,EAAE,iEAA+B,EACzD,wBAAwB,EAAE,iEAA+B,EACzD,wBAAwB,EAAE,iEAA+B,GACzD,CACH,CAAC;AACJ,CAAC,CAAC;AAfW,QAAA,SAAS,aAepB","sourcesContent":["import React from \"react\";\n\nimport { Results } from \"../../components\";\n\nimport { ExampleResultCardProduct } from \"./ExampleResultCardProduct\";\nimport { ExampleResultCardCallout } from \"./ExampleResultCardCallout\";\nimport { ExampleResultPaginationNumbered } from \"./ExampleResultPaginationNumbered\";\nimport { ExampleResultPaginationLoadMore } from \"./ExampleResultPaginationLoadMore\";\nimport { ExampleResultPaginationNextPrev } from \"./ExampleResultPaginationNextPrev\";\n\nexport const Component: React.FC = () => {\n return (\n <Results\n listStyle={{\n display: \"grid\",\n gap: \"10px\",\n gridTemplateColumns: \"repeat(4, minmax(0, 1fr))\",\n }}\n renderResultCardProduct={ExampleResultCardProduct}\n renderResultCardCallout={ExampleResultCardCallout}\n renderPaginationNumbered={ExampleResultPaginationNumbered}\n renderPaginationLoadMore={ExampleResultPaginationLoadMore}\n renderPaginationNextPrev={ExampleResultPaginationNextPrev}\n />\n );\n};\n"]}
@@ -26,16 +26,6 @@ const SensorCollection = () => {
26
26
  },
27
27
  },
28
28
  },
29
- {
30
- nested: {
31
- path: "curations",
32
- query: {
33
- term: {
34
- "curations.collectionHandle.keyword": options.collectionHandle,
35
- },
36
- },
37
- },
38
- },
39
29
  ],
40
30
  },
41
31
  },
@@ -1 +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,gBAAgB;qCACvD;iCACF;6BACF;yBACF;wBACD;4BACE,MAAM,EAAE;gCACN,IAAI,EAAE,WAAW;gCACjB,KAAK,EAAE;oCACL,IAAI,EAAE;wCACJ,oCAAoC,EAClC,OAAO,CAAC,gBAAgB;qCAC3B;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;SACF,CAAC,GACF,CACH,CAAC;AACJ,CAAC,CAAC;AAzCW,QAAA,gBAAgB,oBAyC3B","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.collectionHandle,\n },\n },\n },\n },\n {\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.collectionHandle.keyword\":\n options.collectionHandle,\n },\n },\n },\n },\n ],\n },\n },\n })}\n />\n );\n};\n"]}
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,gBAAgB;qCACvD;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;SACF,CAAC,GACF,CACH,CAAC;AACJ,CAAC,CAAC;AA9BW,QAAA,gBAAgB,oBA8B3B","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.collectionHandle,\n },\n },\n },\n },\n ],\n },\n },\n })}\n />\n );\n};\n"]}
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const SensorCuration: React.FC;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SensorCuration = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const ReactiveComponent_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent"));
9
+ const hooks_1 = require("../../hooks");
10
+ const SensorCuration = () => {
11
+ const { options } = (0, hooks_1.useReactifySearchContext)();
12
+ const { curation } = (0, hooks_1.useCuration)();
13
+ if (!curation || curation.id === "global") {
14
+ return null;
15
+ }
16
+ return (react_1.default.createElement(ReactiveComponent_1.default, { componentId: "SensorCuration", customQuery: () => ({
17
+ query: {
18
+ bool: {
19
+ should: [
20
+ ...(options.mode === "collection"
21
+ ? [
22
+ {
23
+ nested: {
24
+ path: "curations",
25
+ query: {
26
+ term: {
27
+ "curations.collectionHandle.keyword": curation.collectionHandle,
28
+ },
29
+ },
30
+ },
31
+ },
32
+ ]
33
+ : []),
34
+ ...(options.mode === "search"
35
+ ? [
36
+ {
37
+ nested: {
38
+ path: "curations",
39
+ query: {
40
+ term: {
41
+ "curations.searchTerm.keyword": curation.searchTerm,
42
+ },
43
+ },
44
+ },
45
+ },
46
+ ]
47
+ : []),
48
+ ],
49
+ },
50
+ },
51
+ }) }));
52
+ };
53
+ exports.SensorCuration = SensorCuration;
54
+ //# sourceMappingURL=SensorCuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SensorCuration.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorCuration.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;AAEjG,uCAAoE;AAE7D,MAAM,cAAc,GAAa,GAAG,EAAE;IAC3C,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAC/C,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAA,mBAAW,GAAE,CAAC;IAEnC,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,EAAE,KAAK,QAAQ,EAAE;QACzC,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,8BAAC,2BAAiB,IAChB,WAAW,EAAC,gBAAgB,EAC5B,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;YAClB,KAAK,EAAE;gBACL,IAAI,EAAE;oBACJ,MAAM,EAAE;wBACN,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,YAAY;4BAC/B,CAAC,CAAC;gCACE;oCACE,MAAM,EAAE;wCACN,IAAI,EAAE,WAAW;wCACjB,KAAK,EAAE;4CACL,IAAI,EAAE;gDACJ,oCAAoC,EAClC,QAAQ,CAAC,gBAAgB;6CAC5B;yCACF;qCACF;iCACF;6BACF;4BACH,CAAC,CAAC,EAAE,CAAC;wBACP,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ;4BAC3B,CAAC,CAAC;gCACE;oCACE,MAAM,EAAE;wCACN,IAAI,EAAE,WAAW;wCACjB,KAAK,EAAE;4CACL,IAAI,EAAE;gDACJ,8BAA8B,EAAE,QAAQ,CAAC,UAAU;6CACpD;yCACF;qCACF;iCACF;6BACF;4BACH,CAAC,CAAC,EAAE,CAAC;qBACR;iBACF;aACF;SACF,CAAC,GACF,CACH,CAAC;AACJ,CAAC,CAAC;AAlDW,QAAA,cAAc,kBAkDzB","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent\";\n\nimport { useReactifySearchContext, useCuration } from \"../../hooks\";\n\nexport const SensorCuration: React.FC = () => {\n const { options } = useReactifySearchContext();\n const { curation } = useCuration();\n\n if (!curation || curation.id === \"global\") {\n return null;\n }\n\n return (\n <ReactiveComponent\n componentId=\"SensorCuration\"\n customQuery={() => ({\n query: {\n bool: {\n should: [\n ...(options.mode === \"collection\"\n ? [\n {\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.collectionHandle.keyword\":\n curation.collectionHandle,\n },\n },\n },\n },\n ]\n : []),\n ...(options.mode === \"search\"\n ? [\n {\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.searchTerm.keyword\": curation.searchTerm,\n },\n },\n },\n },\n ]\n : []),\n ],\n },\n },\n })}\n />\n );\n};\n"]}
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const SensorSearchTerm: React.FC;
@@ -3,20 +3,28 @@ 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.SensorSearch = void 0;
6
+ exports.SensorSearchTerm = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const DataSearch_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/search/DataSearch"));
9
9
  const hooks_1 = require("../../hooks");
10
- const SensorSearch = () => {
11
- const { config } = (0, hooks_1.useReactifySearchContext)();
10
+ const SensorSearchTerm = () => {
11
+ const { options, config } = (0, hooks_1.useReactifySearchContext)();
12
12
  const { searchTerm } = (0, hooks_1.useSearch)();
13
13
  // ignore search fields only set for instant search
14
- const searchFields = react_1.default.useMemo(() => config.fields.filter((field) => ["always_search", "search_page"].includes(field.searchType)), [config.fields]);
15
- if (!searchTerm || !searchFields.length) {
14
+ const searchFields = react_1.default.useMemo(() => {
15
+ if (options.mode === "search") {
16
+ return config.fields.filter((field) => ["always_search", "search_page"].includes(field.searchType));
17
+ }
18
+ if (options.mode === "instant-search") {
19
+ return config.fields.filter((field) => ["always_search", "instant_search"].includes(field.searchType));
20
+ }
21
+ return [];
22
+ }, [config.fields]);
23
+ if (!searchTerm || searchFields.length === 0) {
16
24
  return null;
17
25
  }
18
26
  return (react_1.default.createElement(react_1.default.Fragment, null,
19
- react_1.default.createElement(DataSearch_1.default, { fuzziness: 1, queryFormat: "and", autosuggest: false, value: searchTerm, componentId: "SensorSearch", style: { display: "none" }, dataField: searchFields.map((field) => field.field), fieldWeights: searchFields.map((field) => field.importance), customQuery: (value, props) => {
27
+ react_1.default.createElement(DataSearch_1.default, { fuzziness: 1, queryFormat: "and", autosuggest: false, value: searchTerm, componentId: "SensorSearchTerm", style: { display: "none" }, dataField: searchFields.map((field) => field.field), fieldWeights: searchFields.map((field) => field.importance), customQuery: (value, props) => {
20
28
  const { dataField, fieldWeights } = props;
21
29
  const fieldsCrossFields = dataField.map((field, index) => `${field}^${fieldWeights[index]}`);
22
30
  const fieldsPhrase = dataField.map((field, index) => `${field}^${fieldWeights[index]}`);
@@ -26,16 +34,6 @@ const SensorSearch = () => {
26
34
  const query = {
27
35
  bool: {
28
36
  should: [
29
- {
30
- nested: {
31
- path: "curations",
32
- query: {
33
- term: {
34
- "curations.searchTerm.keyword": value === null || value === void 0 ? void 0 : value.toLowerCase(),
35
- },
36
- },
37
- },
38
- },
39
37
  ...(fieldsCrossFields.length > 0
40
38
  ? [
41
39
  {
@@ -79,5 +77,5 @@ const SensorSearch = () => {
79
77
  return { query };
80
78
  } })));
81
79
  };
82
- exports.SensorSearch = SensorSearch;
83
- //# sourceMappingURL=SensorSearch.js.map
80
+ exports.SensorSearchTerm = SensorSearchTerm;
81
+ //# sourceMappingURL=SensorSearchTerm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SensorSearchTerm.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorSearchTerm.tsx"],"names":[],"mappings":";;;;;;AA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AE,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;AApGW,QAAA,gBAAgB,oBAoG3B","sourcesContent":["import React from \"react\";\nimport DataSearch from \"@appbaseio/reactivesearch/lib/components/search/DataSearch\";\n\nimport { useReactifySearchContext, useSearch } from \"../../hooks\";\n\nexport const SensorSearchTerm: React.FC = () => {\n const { options, config } = useReactifySearchContext();\n const { searchTerm } = useSearch();\n\n // ignore search fields only set for instant search\n const searchFields = React.useMemo(() => {\n if (options.mode === \"search\") {\n return config.fields.filter((field) =>\n [\"always_search\", \"search_page\"].includes(field.searchType)\n );\n }\n\n if (options.mode === \"instant-search\") {\n return config.fields.filter((field) =>\n [\"always_search\", \"instant_search\"].includes(field.searchType)\n );\n }\n\n return [];\n }, [config.fields]);\n\n if (!searchTerm || searchFields.length === 0) {\n return null;\n }\n\n return (\n <>\n <DataSearch\n fuzziness={1}\n queryFormat=\"and\"\n autosuggest={false}\n value={searchTerm}\n componentId=\"SensorSearchTerm\"\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 ...(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"]}
@@ -9,7 +9,7 @@ const ReactiveComponent_1 = __importDefault(require("@appbaseio/reactivesearch/l
9
9
  const hooks_1 = require("../../hooks");
10
10
  const SensorSort = () => {
11
11
  const { options, config } = (0, hooks_1.useReactifySearchContext)();
12
- const curation = (0, hooks_1.useCuration)();
12
+ const { curation } = (0, hooks_1.useCuration)();
13
13
  const globalCuration = (curation === null || curation === void 0 ? void 0 : curation.id) === "global";
14
14
  const { sortOption } = (0, hooks_1.useSortBy)();
15
15
  const { sort, query } = react_1.default.useMemo(() => {
@@ -58,7 +58,7 @@ const buildSort = (args) => {
58
58
  if (globalCuration && collectionHandle) {
59
59
  sorts.push(...mapCollectionPositionSortClause(collectionHandle));
60
60
  }
61
- else {
61
+ if (!globalCuration && curation.collectionHandle) {
62
62
  sorts.push({
63
63
  "curations.position": {
64
64
  unmapped_type: "long",
@@ -1 +1 @@
1
- {"version":3,"file":"SensorSort.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorSort.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;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oBACd,CAAC,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC;oBAC5D,CAAC,CAAC;wBACE;4BACE,IAAI,EAAE;gCACJ,IAAI,EAAE,SAAS;6BAChB;yBACF;qBACF;oBACH,CAAC,CAAC,EAAE,CAAC;aACR;SACF;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent\";\n\nimport { ConfigCuration, ConfigSort } from \"../../types\";\nimport { useReactifySearchContext, useSortBy, useCuration } from \"../../hooks\";\n\nexport const SensorSort: React.FC = () => {\n const { options, config } = useReactifySearchContext();\n const curation = useCuration();\n const globalCuration = curation?.id === \"global\";\n\n const { sortOption } = useSortBy();\n\n const { sort, query } = React.useMemo(() => {\n return {\n sort: buildSort({\n globalCuration,\n curation,\n sortOption,\n collectionHandle:\n options.mode === \"collection\" ? options.collectionHandle : undefined,\n }),\n query: buildQuery({\n sortOption,\n curation,\n globalCuration,\n }),\n };\n }, [config, sortOption, curation]);\n\n return (\n <ReactiveComponent\n componentId=\"SensorSort\"\n customQuery={() => ({\n sort,\n query,\n })}\n />\n );\n};\n\nconst buildSort = (args: {\n globalCuration?: boolean;\n curation?: ConfigCuration;\n sortOption?: ConfigSort;\n collectionHandle?: string;\n}): any[] => {\n const { curation, sortOption, collectionHandle, globalCuration } = args;\n\n // return default sort option if unset\n if (!sortOption) {\n return collectionHandle\n ? mapCollectionPositionSortClause(collectionHandle)\n : [\"_score\"];\n }\n\n // curation positions are only applied for the default `collections.position` or `_score` sort\n // if the sort is something else, apply a normal sort which applies what the user has requested\n if (![\"_score\", \"collections.position\"].includes(sortOption.field)) {\n return [{ [sortOption.field]: sortOption.direction }];\n }\n\n // no matching curation, return default sort clause\n if (!curation) {\n return collectionHandle\n ? mapCollectionPositionSortClause(collectionHandle)\n : [\"_score\"];\n }\n\n const sorts = [];\n\n // show pins first\n if (globalCuration && collectionHandle) {\n sorts.push(...mapCollectionPositionSortClause(collectionHandle));\n } else {\n sorts.push({\n \"curations.position\": {\n unmapped_type: \"long\",\n order: \"asc\",\n nested: {\n path: \"curations\",\n filter: {\n term: {\n [`curations.${\n \"collection\" === curation.type\n ? \"collectionHandle\"\n : \"searchTerm\"\n }.keyword`]:\n \"collection\" === curation.type\n ? curation.collectionHandle\n : curation.searchTerm?.toLowerCase(),\n },\n },\n },\n },\n });\n }\n\n if (0 < curation.boosting.groupings.length) {\n const groupings = curation.boosting.groupings.sort((a, b) =>\n a.position > b.position ? 1 : -1\n );\n\n for (const grouping of groupings) {\n try {\n const query = JSON.parse(grouping.query);\n if (query) sorts.push(query);\n } catch {\n console.error(`query could not be parsed for boost grouping`, grouping);\n }\n }\n }\n\n if (0 < curation.boosting.sortings.length) {\n const sortings = curation.boosting.sortings.sort((a, b) =>\n a.position > b.position ? 1 : -1\n );\n\n for (const sorting of sortings) {\n try {\n const query = JSON.parse(sorting.query);\n if (query) sorts.push(query);\n } catch {\n console.error(`query could not be parsed for boost sorting`, sorting);\n }\n }\n }\n\n // finally, for collections, if no other sorting is defined, sort by index order to provide\n // a consistent order\n if (\"collection\" === curation.type && sorts.length === 0) {\n sorts.push(\"_doc\");\n }\n\n // finally, for search, sort by score\n if (\"search\" === curation.type) {\n sorts.push(\"_score\");\n }\n\n return sorts;\n};\n\n/**\n * Return a sort clause which sorts by position within the given collection.\n */\nfunction mapCollectionPositionSortClause(collectionHandle: string) {\n return [\n {\n \"collections.position\": {\n order: \"asc\",\n nested: {\n path: \"collections\",\n filter: {\n term: {\n \"collections.handle.keyword\": collectionHandle,\n },\n },\n },\n },\n },\n ];\n}\n\nconst buildQuery = (args: {\n sortOption?: ConfigSort;\n curation?: ConfigCuration;\n globalCuration?: boolean;\n}): Record<string, any> | undefined => {\n const { curation, sortOption, globalCuration } = args;\n\n if (!curation || globalCuration) {\n return undefined;\n }\n\n return {\n bool: {\n must_not: [\n {\n nested: {\n path: \"curations\",\n query: {\n bool: {\n must: [\n {\n term: {\n [`curations.${\n \"collection\" === curation.type\n ? \"collectionHandle\"\n : \"searchTerm\"\n }.keyword`]:\n \"collection\" === curation.type\n ? curation.collectionHandle\n : curation.searchTerm?.toLowerCase(),\n },\n },\n {\n term: {\n \"curations.hidden\": true,\n },\n },\n ],\n },\n },\n },\n },\n // hide callout when not sorting by _score or collections.position\n ...(sortOption &&\n ![\"_score\", \"collections.position\"].includes(sortOption.field)\n ? [\n {\n term: {\n type: \"callout\",\n },\n },\n ]\n : []),\n ],\n },\n };\n};\n"]}
1
+ {"version":3,"file":"SensorSort.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorSort.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yHAAiG;AAGjG,uCAA+E;AAExE,MAAM,UAAU,GAAa,GAAG,EAAE;IACvC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IACvD,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAA,mBAAW,GAAE,CAAC;IACnC,MAAM,cAAc,GAAG,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,EAAE,MAAK,QAAQ,CAAC;IAEjD,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,iBAAS,GAAE,CAAC;IAEnC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACzC,OAAO;YACL,IAAI,EAAE,SAAS,CAAC;gBACd,cAAc;gBACd,QAAQ;gBACR,UAAU;gBACV,gBAAgB,EACd,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS;aACvE,CAAC;YACF,KAAK,EAAE,UAAU,CAAC;gBAChB,UAAU;gBACV,QAAQ;gBACR,cAAc;aACf,CAAC;SACH,CAAC;IACJ,CAAC,EAAE,CA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,QAAQ,EAAE;gBACR;oBACE,MAAM,EAAE;wBACN,IAAI,EAAE,WAAW;wBACjB,KAAK,EAAE;4BACL,IAAI,EAAE;gCACJ,IAAI,EAAE;oCACJ;wCACE,IAAI,EAAE;4CACJ,CAAC,aACC,YAAY,KAAK,QAAQ,CAAC,IAAI;gDAC5B,CAAC,CAAC,kBAAkB;gDACpB,CAAC,CAAC,YACN,UAAU,CAAC,EACT,YAAY,KAAK,QAAQ,CAAC,IAAI;gDAC5B,CAAC,CAAC,QAAQ,CAAC,gBAAgB;gDAC3B,CAAC,CAAC,MAAA,QAAQ,CAAC,UAAU,0CAAE,WAAW,EAAE;yCACzC;qCACF;oCACD;wCACE,IAAI,EAAE;4CACJ,kBAAkB,EAAE,IAAI;yCACzB;qCACF;iCACF;6BACF;yBACF;qBACF;iBACF;gBACD,kEAAkE;gBAClE,GAAG,CAAC,UAAU;oBACd,CAAC,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC;oBAC5D,CAAC,CAAC;wBACE;4BACE,IAAI,EAAE;gCACJ,IAAI,EAAE,SAAS;6BAChB;yBACF;qBACF;oBACH,CAAC,CAAC,EAAE,CAAC;aACR;SACF;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveComponent from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent\";\n\nimport { ConfigCuration, ConfigSort } from \"../../types\";\nimport { useReactifySearchContext, useSortBy, useCuration } from \"../../hooks\";\n\nexport const SensorSort: React.FC = () => {\n const { options, config } = useReactifySearchContext();\n const { curation } = useCuration();\n const globalCuration = curation?.id === \"global\";\n\n const { sortOption } = useSortBy();\n\n const { sort, query } = React.useMemo(() => {\n return {\n sort: buildSort({\n globalCuration,\n curation,\n sortOption,\n collectionHandle:\n options.mode === \"collection\" ? options.collectionHandle : undefined,\n }),\n query: buildQuery({\n sortOption,\n curation,\n globalCuration,\n }),\n };\n }, [config, sortOption, curation]);\n\n return (\n <ReactiveComponent\n componentId=\"SensorSort\"\n customQuery={() => ({\n sort,\n query,\n })}\n />\n );\n};\n\nconst buildSort = (args: {\n globalCuration?: boolean;\n curation?: ConfigCuration;\n sortOption?: ConfigSort;\n collectionHandle?: string;\n}): any[] => {\n const { curation, sortOption, collectionHandle, globalCuration } = args;\n\n // return default sort option if unset\n if (!sortOption) {\n return collectionHandle\n ? mapCollectionPositionSortClause(collectionHandle)\n : [\"_score\"];\n }\n\n // curation positions are only applied for the default `collections.position` or `_score` sort\n // if the sort is something else, apply a normal sort which applies what the user has requested\n if (![\"_score\", \"collections.position\"].includes(sortOption.field)) {\n return [{ [sortOption.field]: sortOption.direction }];\n }\n\n // no matching curation, return default sort clause\n if (!curation) {\n return collectionHandle\n ? mapCollectionPositionSortClause(collectionHandle)\n : [\"_score\"];\n }\n\n const sorts = [];\n\n // show pins first\n if (globalCuration && collectionHandle) {\n sorts.push(...mapCollectionPositionSortClause(collectionHandle));\n }\n if (!globalCuration && curation.collectionHandle) {\n sorts.push({\n \"curations.position\": {\n unmapped_type: \"long\",\n order: \"asc\",\n nested: {\n path: \"curations\",\n filter: {\n term: {\n [`curations.${\n \"collection\" === curation.type\n ? \"collectionHandle\"\n : \"searchTerm\"\n }.keyword`]:\n \"collection\" === curation.type\n ? curation.collectionHandle\n : curation.searchTerm?.toLowerCase(),\n },\n },\n },\n },\n });\n }\n\n if (0 < curation.boosting.groupings.length) {\n const groupings = curation.boosting.groupings.sort((a, b) =>\n a.position > b.position ? 1 : -1\n );\n\n for (const grouping of groupings) {\n try {\n const query = JSON.parse(grouping.query);\n if (query) sorts.push(query);\n } catch {\n console.error(`query could not be parsed for boost grouping`, grouping);\n }\n }\n }\n\n if (0 < curation.boosting.sortings.length) {\n const sortings = curation.boosting.sortings.sort((a, b) =>\n a.position > b.position ? 1 : -1\n );\n\n for (const sorting of sortings) {\n try {\n const query = JSON.parse(sorting.query);\n if (query) sorts.push(query);\n } catch {\n console.error(`query could not be parsed for boost sorting`, sorting);\n }\n }\n }\n\n // finally, for collections, if no other sorting is defined, sort by index order to provide\n // a consistent order\n if (\"collection\" === curation.type && sorts.length === 0) {\n sorts.push(\"_doc\");\n }\n\n // finally, for search, sort by score\n if (\"search\" === curation.type) {\n sorts.push(\"_score\");\n }\n\n return sorts;\n};\n\n/**\n * Return a sort clause which sorts by position within the given collection.\n */\nfunction mapCollectionPositionSortClause(collectionHandle: string) {\n return [\n {\n \"collections.position\": {\n order: \"asc\",\n nested: {\n path: \"collections\",\n filter: {\n term: {\n \"collections.handle.keyword\": collectionHandle,\n },\n },\n },\n },\n },\n ];\n}\n\nconst buildQuery = (args: {\n sortOption?: ConfigSort;\n curation?: ConfigCuration;\n globalCuration?: boolean;\n}): Record<string, any> | undefined => {\n const { curation, sortOption, globalCuration } = args;\n\n if (!curation || globalCuration) {\n return undefined;\n }\n\n return {\n bool: {\n must_not: [\n {\n nested: {\n path: \"curations\",\n query: {\n bool: {\n must: [\n {\n term: {\n [`curations.${\n \"collection\" === curation.type\n ? \"collectionHandle\"\n : \"searchTerm\"\n }.keyword`]:\n \"collection\" === curation.type\n ? curation.collectionHandle\n : curation.searchTerm?.toLowerCase(),\n },\n },\n {\n term: {\n \"curations.hidden\": true,\n },\n },\n ],\n },\n },\n },\n },\n // hide callout when not sorting by _score or collections.position\n ...(sortOption &&\n ![\"_score\", \"collections.position\"].includes(sortOption.field)\n ? [\n {\n term: {\n type: \"callout\",\n },\n },\n ]\n : []),\n ],\n },\n };\n};\n"]}
@@ -7,26 +7,37 @@ exports.Sensors = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const hooks_1 = require("../../hooks");
9
9
  const SensorSort_1 = require("./SensorSort");
10
- const SensorSearch_1 = require("./SensorSearch");
11
10
  const SensorSortScore_1 = require("./SensorSortScore");
12
11
  const SensorPublished_1 = require("./SensorPublished");
12
+ const SensorCuration_1 = require("./SensorCuration");
13
13
  const SensorCollection_1 = require("./SensorCollection");
14
+ const SensorSearchTerm_1 = require("./SensorSearchTerm");
14
15
  const SensorInventoryAvailable_1 = require("./SensorInventoryAvailable");
15
16
  const Sensors = () => {
16
17
  const { options } = (0, hooks_1.useReactifySearchContext)();
17
- // instant search mode
18
+ if (options.mode === "search") {
19
+ return (react_1.default.createElement(react_1.default.Fragment, null,
20
+ react_1.default.createElement(SensorSort_1.SensorSort, null),
21
+ react_1.default.createElement(SensorCuration_1.SensorCuration, null),
22
+ react_1.default.createElement(SensorPublished_1.SensorPublished, null),
23
+ react_1.default.createElement(SensorSearchTerm_1.SensorSearchTerm, null),
24
+ react_1.default.createElement(SensorInventoryAvailable_1.SensorInventoryAvailable, null)));
25
+ }
26
+ if (options.mode === "collection") {
27
+ return (react_1.default.createElement(react_1.default.Fragment, null,
28
+ react_1.default.createElement(SensorSort_1.SensorSort, null),
29
+ react_1.default.createElement(SensorCuration_1.SensorCuration, null),
30
+ react_1.default.createElement(SensorPublished_1.SensorPublished, null),
31
+ react_1.default.createElement(SensorCollection_1.SensorCollection, null),
32
+ react_1.default.createElement(SensorInventoryAvailable_1.SensorInventoryAvailable, null)));
33
+ }
18
34
  if (options.mode === "instant-search") {
19
35
  return (react_1.default.createElement(react_1.default.Fragment, null,
36
+ react_1.default.createElement(SensorSearchTerm_1.SensorSearchTerm, null),
20
37
  react_1.default.createElement(SensorPublished_1.SensorPublished, null),
21
38
  react_1.default.createElement(SensorSortScore_1.SensorSortScore, null)));
22
39
  }
23
- // result grid mode
24
- return (react_1.default.createElement(react_1.default.Fragment, null,
25
- react_1.default.createElement(SensorSort_1.SensorSort, null),
26
- react_1.default.createElement(SensorSearch_1.SensorSearch, null),
27
- react_1.default.createElement(SensorPublished_1.SensorPublished, null),
28
- react_1.default.createElement(SensorCollection_1.SensorCollection, null),
29
- react_1.default.createElement(SensorInventoryAvailable_1.SensorInventoryAvailable, null)));
40
+ return null;
30
41
  };
31
42
  exports.Sensors = Sensors;
32
43
  //# sourceMappingURL=Sensors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Sensors.js","sourceRoot":"","sources":["../../../../src/components/Sensor/Sensors.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,uCAAuD;AAEvD,6CAA0C;AAC1C,iDAA8C;AAC9C,uDAAoD;AACpD,uDAAoD;AACpD,yDAAsD;AACtD,yEAAsE;AAM/D,MAAM,OAAO,GAA2B,GAAG,EAAE;IAClD,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAE/C,sBAAsB;IACtB,IAAI,OAAO,CAAC,IAAI,KAAK,gBAAgB,EAAE;QACrC,OAAO,CACL;YACE,8BAAC,iCAAe,OAAG;YACnB,8BAAC,iCAAe,OAAG,CAClB,CACJ,CAAC;KACH;IAED,mBAAmB;IACnB,OAAO,CACL;QACE,8BAAC,uBAAU,OAAG;QACd,8BAAC,2BAAY,OAAG;QAChB,8BAAC,iCAAe,OAAG;QACnB,8BAAC,mCAAgB,OAAG;QACpB,8BAAC,mDAAwB,OAAG,CAC3B,CACJ,CAAC;AACJ,CAAC,CAAC;AAvBW,QAAA,OAAO,WAuBlB","sourcesContent":["import React from \"react\";\n\nimport { useReactifySearchContext } from \"../../hooks\";\n\nimport { SensorSort } from \"./SensorSort\";\nimport { SensorSearch } from \"./SensorSearch\";\nimport { SensorSortScore } from \"./SensorSortScore\";\nimport { SensorPublished } from \"./SensorPublished\";\nimport { SensorCollection } from \"./SensorCollection\";\nimport { SensorInventoryAvailable } from \"./SensorInventoryAvailable\";\n\nexport type SensorsProps = {\n /** This component does not support any props */\n};\n\nexport const Sensors: React.FC<SensorsProps> = () => {\n const { options } = useReactifySearchContext();\n\n // instant search mode\n if (options.mode === \"instant-search\") {\n return (\n <>\n <SensorPublished />\n <SensorSortScore />\n </>\n );\n }\n\n // result grid mode\n return (\n <>\n <SensorSort />\n <SensorSearch />\n <SensorPublished />\n <SensorCollection />\n <SensorInventoryAvailable />\n </>\n );\n};\n"]}
1
+ {"version":3,"file":"Sensors.js","sourceRoot":"","sources":["../../../../src/components/Sensor/Sensors.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,uCAAuD;AAEvD,6CAA0C;AAC1C,uDAAoD;AACpD,uDAAoD;AACpD,qDAAkD;AAClD,yDAAsD;AACtD,yDAAsD;AACtD,yEAAsE;AAM/D,MAAM,OAAO,GAA2B,GAAG,EAAE;IAClD,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAE/C,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE;QAC7B,OAAO,CACL;YACE,8BAAC,uBAAU,OAAG;YACd,8BAAC,+BAAc,OAAG;YAClB,8BAAC,iCAAe,OAAG;YACnB,8BAAC,mCAAgB,OAAG;YACpB,8BAAC,mDAAwB,OAAG,CAC3B,CACJ,CAAC;KACH;IAED,IAAI,OAAO,CAAC,IAAI,KAAK,YAAY,EAAE;QACjC,OAAO,CACL;YACE,8BAAC,uBAAU,OAAG;YACd,8BAAC,+BAAc,OAAG;YAClB,8BAAC,iCAAe,OAAG;YACnB,8BAAC,mCAAgB,OAAG;YACpB,8BAAC,mDAAwB,OAAG,CAC3B,CACJ,CAAC;KACH;IAED,IAAI,OAAO,CAAC,IAAI,KAAK,gBAAgB,EAAE;QACrC,OAAO,CACL;YACE,8BAAC,mCAAgB,OAAG;YACpB,8BAAC,iCAAe,OAAG;YACnB,8BAAC,iCAAe,OAAG,CAClB,CACJ,CAAC;KACH;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAtCW,QAAA,OAAO,WAsClB","sourcesContent":["import React from \"react\";\n\nimport { useReactifySearchContext } from \"../../hooks\";\n\nimport { SensorSort } from \"./SensorSort\";\nimport { SensorSortScore } from \"./SensorSortScore\";\nimport { SensorPublished } from \"./SensorPublished\";\nimport { SensorCuration } from \"./SensorCuration\";\nimport { SensorCollection } from \"./SensorCollection\";\nimport { SensorSearchTerm } from \"./SensorSearchTerm\";\nimport { SensorInventoryAvailable } from \"./SensorInventoryAvailable\";\n\nexport type SensorsProps = {\n /** This component does not support any props */\n};\n\nexport const Sensors: React.FC<SensorsProps> = () => {\n const { options } = useReactifySearchContext();\n\n if (options.mode === \"search\") {\n return (\n <>\n <SensorSort />\n <SensorCuration />\n <SensorPublished />\n <SensorSearchTerm />\n <SensorInventoryAvailable />\n </>\n );\n }\n\n if (options.mode === \"collection\") {\n return (\n <>\n <SensorSort />\n <SensorCuration />\n <SensorPublished />\n <SensorCollection />\n <SensorInventoryAvailable />\n </>\n );\n }\n\n if (options.mode === \"instant-search\") {\n return (\n <>\n <SensorSearchTerm />\n <SensorPublished />\n <SensorSortScore />\n </>\n );\n }\n\n return null;\n};\n"]}
@@ -1,8 +1,9 @@
1
1
  export * from "./SensorSort";
2
- export * from "./SensorSearch";
2
+ export * from "./SensorCuration";
3
3
  export * from "./SensorPublished";
4
4
  export * from "./SensorSortScore";
5
5
  export * from "./SensorCollection";
6
+ export * from "./SensorSearchTerm";
6
7
  export * from "./SensorInventoryAvailable";
7
8
  export * from "./Sensors";
8
9
  export declare const SENSOR_IDS: string[];
@@ -12,19 +12,21 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.SENSOR_IDS = void 0;
14
14
  __exportStar(require("./SensorSort"), exports);
15
- __exportStar(require("./SensorSearch"), exports);
15
+ __exportStar(require("./SensorCuration"), exports);
16
16
  __exportStar(require("./SensorPublished"), exports);
17
17
  __exportStar(require("./SensorSortScore"), exports);
18
18
  __exportStar(require("./SensorCollection"), exports);
19
+ __exportStar(require("./SensorSearchTerm"), exports);
19
20
  __exportStar(require("./SensorInventoryAvailable"), exports);
20
21
  __exportStar(require("./Sensors"), exports);
21
22
  // this is consumed by the react prop in various components
22
23
  exports.SENSOR_IDS = [
23
24
  "SensorSort",
24
- "SensorSearch",
25
+ "SensorCuration",
25
26
  "SensorSortScore",
26
27
  "SensorPublished",
27
28
  "SensorCollection",
29
+ "SensorSearchTerm",
28
30
  "SensorInventoryAvailable",
29
31
  ];
30
32
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Sensor/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,iDAA+B;AAC/B,oDAAkC;AAClC,oDAAkC;AAClC,qDAAmC;AACnC,6DAA2C;AAE3C,4CAA0B;AAE1B,2DAA2D;AAC9C,QAAA,UAAU,GAAG;IACxB,YAAY;IACZ,cAAc;IACd,iBAAiB;IACjB,iBAAiB;IACjB,kBAAkB;IAClB,0BAA0B;CAC3B,CAAC","sourcesContent":["export * from \"./SensorSort\";\nexport * from \"./SensorSearch\";\nexport * from \"./SensorPublished\";\nexport * from \"./SensorSortScore\";\nexport * from \"./SensorCollection\";\nexport * from \"./SensorInventoryAvailable\";\n\nexport * from \"./Sensors\";\n\n// this is consumed by the react prop in various components\nexport const SENSOR_IDS = [\n \"SensorSort\",\n \"SensorSearch\",\n \"SensorSortScore\",\n \"SensorPublished\",\n \"SensorCollection\",\n \"SensorInventoryAvailable\",\n];\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Sensor/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,mDAAiC;AACjC,oDAAkC;AAClC,oDAAkC;AAClC,qDAAmC;AACnC,qDAAmC;AACnC,6DAA2C;AAE3C,4CAA0B;AAE1B,2DAA2D;AAC9C,QAAA,UAAU,GAAG;IACxB,YAAY;IACZ,gBAAgB;IAChB,iBAAiB;IACjB,iBAAiB;IACjB,kBAAkB;IAClB,kBAAkB;IAClB,0BAA0B;CAC3B,CAAC","sourcesContent":["export * from \"./SensorSort\";\nexport * from \"./SensorCuration\";\nexport * from \"./SensorPublished\";\nexport * from \"./SensorSortScore\";\nexport * from \"./SensorCollection\";\nexport * from \"./SensorSearchTerm\";\nexport * from \"./SensorInventoryAvailable\";\n\nexport * from \"./Sensors\";\n\n// this is consumed by the react prop in various components\nexport const SENSOR_IDS = [\n \"SensorSort\",\n \"SensorCuration\",\n \"SensorSortScore\",\n \"SensorPublished\",\n \"SensorCollection\",\n \"SensorSearchTerm\",\n \"SensorInventoryAvailable\",\n];\n"]}
@@ -1,2 +1,4 @@
1
1
  import { ConfigCuration } from "../types";
2
- export declare const useCuration: () => ConfigCuration | undefined;
2
+ export declare const useCuration: () => {
3
+ curation?: ConfigCuration | undefined;
4
+ };
@@ -56,7 +56,9 @@ const useCuration = () => {
56
56
  react_1.default.useEffect(() => {
57
57
  utility_1.debug.log("useCuration", "curation", curation);
58
58
  }, [curation]);
59
- return curation;
59
+ return {
60
+ curation: curation,
61
+ };
60
62
  };
61
63
  exports.useCuration = useCuration;
62
64
  //# sourceMappingURL=useCuration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCuration.js","sourceRoot":"","sources":["../../../src/hooks/useCuration.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,oCAA+D;AAC/D,wCAAmC;AAE5B,MAAM,WAAW,GAAG,GAA+B,EAAE;IAC1D,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IACvD,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,iBAAS,GAAE,CAAC;IAEnC,MAAM,QAAQ,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAClC,MAAM,kBAAkB,GACtB,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,UAAU,CAAC;QAExE,MAAM,4BAA4B,GAAG,kBAAkB;aACpD,WAAW,EAAE;aACb,IAAI,EAAE,CAAC;QAEV,MAAM,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAC1C,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,QAAQ,IAAI,QAAQ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CAAC,CAAC,iBAAiB,CAAC,QAAQ,CAAC;YAC7B,CAAC,CAAC,cAAc;gBAChB,CAAC,CAAC,cAAc;gBAChB,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC,EAAE;QACD,MAAM;QACN,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS;QACpE,UAAU;KACX,CAAC,CAAC;IAEH,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,eAAK,CAAC,GAAG,CAAC,aAAa,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AA7EW,QAAA,WAAW,eA6EtB","sourcesContent":["import React from \"react\";\n\nimport { ConfigCuration } from \"../types\";\nimport { useReactifySearchContext, useSearch } from \"../hooks\";\nimport { debug } from \"../utility\";\n\nexport const useCuration = (): ConfigCuration | undefined => {\n const { options, config } = useReactifySearchContext();\n const { searchTerm } = useSearch();\n\n const curation = React.useMemo(() => {\n const handleOrSearchTerm =\n options.mode === \"collection\" ? options.collectionHandle : searchTerm;\n\n const normalisedHandleOrSearchTerm = handleOrSearchTerm\n .toLowerCase()\n .trim();\n\n const globalCuration = config.curations.find(\n (curation) => curation.id === \"global\" && curation.type === options.mode\n );\n\n const curation = config.curations.find((curation) => {\n const normalisedSearchTerm = curation.searchTerm?.toLowerCase().trim();\n const normalisedCollectionHandle = curation.collectionHandle\n ?.toLowerCase()\n .trim();\n\n if (\"search\" === options.mode) {\n return (\n \"search\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedSearchTerm\n );\n }\n\n if (\"collection\" === options.mode) {\n return (\n \"collection\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedCollectionHandle\n );\n }\n\n return false;\n });\n\n const addGlobalBoosting = (curation: ConfigCuration) => {\n const curationIsCollection = curation.type === \"collection\";\n if (!curationIsCollection) {\n return curation;\n }\n\n const curationHasRules =\n !!curation.boosting.groupings.length ||\n !!curation.boosting.sortings.length;\n\n if (curationHasRules || !globalCuration) {\n return curation;\n }\n\n const curationWithGlobalBoosting = {\n ...curation,\n boosting: globalCuration.boosting,\n } as ConfigCuration;\n\n return curationWithGlobalBoosting;\n };\n\n return curation\n ? addGlobalBoosting(curation)\n : globalCuration\n ? globalCuration\n : undefined;\n }, [\n config,\n options.mode === \"collection\" ? options.collectionHandle : undefined,\n searchTerm,\n ]);\n\n React.useEffect(() => {\n debug.log(\"useCuration\", \"curation\", curation);\n }, [curation]);\n\n return curation;\n};\n"]}
1
+ {"version":3,"file":"useCuration.js","sourceRoot":"","sources":["../../../src/hooks/useCuration.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,oCAA+D;AAC/D,wCAAmC;AAE5B,MAAM,WAAW,GAAG,GAEzB,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IACvD,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,iBAAS,GAAE,CAAC;IAEnC,MAAM,QAAQ,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAClC,MAAM,kBAAkB,GACtB,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,UAAU,CAAC;QAExE,MAAM,4BAA4B,GAAG,kBAAkB;aACpD,WAAW,EAAE;aACb,IAAI,EAAE,CAAC;QAEV,MAAM,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAC1C,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,CACzE,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,QAA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IAChB,CAAC,EAAE;QACD,MAAM;QACN,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS;QACpE,UAAU;KACX,CAAC,CAAC;IAEH,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,eAAK,CAAC,GAAG,CAAC,aAAa,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,OAAO;QACL,QAAQ,EAAE,QAAQ;KACnB,CAAC;AACJ,CAAC,CAAC;AAjFW,QAAA,WAAW,eAiFtB","sourcesContent":["import React from \"react\";\n\nimport { ConfigCuration } from \"../types\";\nimport { useReactifySearchContext, useSearch } from \"../hooks\";\nimport { debug } from \"../utility\";\n\nexport const useCuration = (): {\n curation?: ConfigCuration;\n} => {\n const { options, config } = useReactifySearchContext();\n const { searchTerm } = useSearch();\n\n const curation = React.useMemo(() => {\n const handleOrSearchTerm =\n options.mode === \"collection\" ? options.collectionHandle : searchTerm;\n\n const normalisedHandleOrSearchTerm = handleOrSearchTerm\n .toLowerCase()\n .trim();\n\n const globalCuration = config.curations.find(\n (curation) => curation.id === \"global\" && curation.type === options.mode\n );\n\n const curation = config.curations.find((curation) => {\n const normalisedSearchTerm = curation.searchTerm?.toLowerCase().trim();\n const normalisedCollectionHandle = curation.collectionHandle\n ?.toLowerCase()\n .trim();\n\n if (\"search\" === options.mode) {\n return (\n \"search\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedSearchTerm\n );\n }\n\n if (\"collection\" === options.mode) {\n return (\n \"collection\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedCollectionHandle\n );\n }\n\n return false;\n });\n\n const addGlobalBoosting = (curation: ConfigCuration) => {\n const curationIsCollection = curation.type === \"collection\";\n if (!curationIsCollection) {\n return curation;\n }\n\n const curationHasRules =\n !!curation.boosting.groupings.length ||\n !!curation.boosting.sortings.length;\n\n if (curationHasRules || !globalCuration) {\n return curation;\n }\n\n const curationWithGlobalBoosting = {\n ...curation,\n boosting: globalCuration.boosting,\n } as ConfigCuration;\n\n return curationWithGlobalBoosting;\n };\n\n return curation\n ? addGlobalBoosting(curation)\n : globalCuration\n ? globalCuration\n : undefined;\n }, [\n config,\n options.mode === \"collection\" ? options.collectionHandle : undefined,\n searchTerm,\n ]);\n\n React.useEffect(() => {\n debug.log(\"useCuration\", \"curation\", curation);\n }, [curation]);\n\n return {\n curation: curation,\n };\n};\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@usereactify/search",
3
3
  "description": "React UI library for Reactify Search",
4
- "version": "5.0.1",
4
+ "version": "5.1.1-beta.1",
5
5
  "license": "MIT",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",
@@ -1,2 +0,0 @@
1
- import React from "react";
2
- export declare const SensorSearch: React.FC;
@@ -1 +0,0 @@
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,UAAU,EAAE,GAAG,IAAA,iBAAS,GAAE,CAAC;IAEnC,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,UAAU,IAAI,CAAC,YAAY,CAAC,MAAM,EA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,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 { searchTerm } = 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 (!searchTerm || !searchFields.length) {\n return null;\n }\n\n return (\n <>\n <DataSearch\n fuzziness={1}\n queryFormat=\"and\"\n autosuggest={false}\n value={searchTerm}\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"]}