react-instantsearch-core 6.40.4 → 7.0.0
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/README.md +70 -2
- package/dist/cjs/components/Configure.js +13 -0
- package/dist/cjs/components/DynamicWidgets.js +63 -0
- package/dist/cjs/components/Index.js +24 -0
- package/dist/cjs/components/InstantSearch.js +27 -0
- package/dist/cjs/{connectors/connectConfigure.js → components/InstantSearchSSRProvider.js} +27 -63
- package/dist/cjs/components/InstantSearchServerContext.js +12 -0
- package/dist/cjs/connectors/useBreadcrumb.js +12 -0
- package/dist/cjs/connectors/useClearRefinements.js +12 -0
- package/dist/cjs/connectors/useConfigure.js +14 -0
- package/dist/cjs/connectors/useCurrentRefinements.js +12 -0
- package/dist/cjs/connectors/useDynamicWidgets.js +22 -0
- package/dist/cjs/connectors/useGeoSearch.js +12 -0
- package/dist/cjs/connectors/useHierarchicalMenu.js +12 -0
- package/dist/cjs/connectors/useHits.js +12 -0
- package/dist/cjs/connectors/useHitsPerPage.js +12 -0
- package/dist/cjs/connectors/useInfiniteHits.js +12 -0
- package/dist/cjs/connectors/useMenu.js +12 -0
- package/dist/cjs/connectors/useNumericMenu.js +12 -0
- package/dist/cjs/connectors/usePagination.js +12 -0
- package/dist/cjs/connectors/usePoweredBy.js +21 -0
- package/dist/cjs/connectors/useQueryRules.js +12 -0
- package/dist/cjs/connectors/useRange.js +12 -0
- package/dist/cjs/connectors/useRefinementList.js +12 -0
- package/dist/cjs/connectors/useSearchBox.js +12 -0
- package/dist/cjs/connectors/useSortBy.js +12 -0
- package/dist/cjs/connectors/useStats.js +12 -0
- package/dist/cjs/connectors/useToggleRefinement.js +12 -0
- package/dist/cjs/hooks/useConnector.js +136 -0
- package/dist/cjs/hooks/useInstantSearch.js +58 -0
- package/dist/cjs/index.js +328 -320
- package/dist/cjs/lib/IndexContext.js +12 -0
- package/dist/cjs/lib/InstantSearchContext.js +12 -0
- package/dist/cjs/lib/InstantSearchSSRContext.js +12 -0
- package/dist/cjs/lib/createSearchResults.js +27 -0
- package/dist/cjs/lib/dequal.js +53 -0
- package/dist/cjs/lib/getIndexSearchResults.js +32 -0
- package/dist/cjs/lib/invariant.js +25 -0
- package/dist/cjs/lib/noop.js +8 -0
- package/dist/cjs/lib/useForceUpdate.js +25 -0
- package/dist/cjs/lib/useIndex.js +38 -0
- package/dist/cjs/lib/useIndexContext.js +14 -0
- package/dist/cjs/lib/useInstantSearchApi.js +191 -0
- package/dist/cjs/lib/useInstantSearchContext.js +14 -0
- package/dist/cjs/lib/useInstantSearchSSRContext.js +11 -0
- package/dist/cjs/lib/useInstantSearchServerContext.js +11 -0
- package/dist/cjs/lib/useIsomorphicLayoutEffect.js +14 -0
- package/dist/cjs/lib/useSearchResults.js +46 -0
- package/dist/cjs/lib/useSearchState.js +48 -0
- package/dist/cjs/lib/useStableValue.js +26 -0
- package/dist/cjs/lib/useWidget.js +78 -0
- package/dist/cjs/lib/warn.js +41 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/server/getServerState.js +93 -0
- package/dist/cjs/{types → server}/index.js +4 -4
- package/dist/cjs/{core/version.js → version.js} +1 -1
- package/dist/es/components/Configure.d.ts +3 -0
- package/dist/es/components/Configure.js +7 -0
- package/dist/es/components/DynamicWidgets.d.ts +13 -0
- package/dist/es/components/DynamicWidgets.js +55 -0
- package/dist/es/components/Index.d.ts +6 -0
- package/dist/es/components/Index.js +17 -0
- package/dist/es/components/InstantSearch.d.ts +7 -0
- package/dist/es/components/InstantSearch.js +20 -0
- package/dist/es/components/InstantSearchSSRProvider.d.ts +13 -0
- package/dist/es/{connectors/connectConfigure.js → components/InstantSearchSSRProvider.js} +26 -61
- package/dist/es/components/InstantSearchServerContext.d.ts +12 -0
- package/dist/es/components/InstantSearchServerContext.js +5 -0
- package/dist/es/connectors/useBreadcrumb.d.ts +4 -0
- package/dist/es/connectors/useBreadcrumb.js +5 -0
- package/dist/es/connectors/useClearRefinements.d.ts +4 -0
- package/dist/es/connectors/useClearRefinements.js +5 -0
- package/dist/es/connectors/useConfigure.d.ts +4 -0
- package/dist/es/connectors/useConfigure.js +7 -0
- package/dist/es/connectors/useCurrentRefinements.d.ts +4 -0
- package/dist/es/connectors/useCurrentRefinements.js +5 -0
- package/dist/es/connectors/useDynamicWidgets.d.ts +4 -0
- package/dist/es/connectors/useDynamicWidgets.js +15 -0
- package/dist/es/connectors/useGeoSearch.d.ts +6 -0
- package/dist/es/connectors/useGeoSearch.js +5 -0
- package/dist/es/connectors/useHierarchicalMenu.d.ts +4 -0
- package/dist/es/connectors/useHierarchicalMenu.js +5 -0
- package/dist/es/connectors/useHits.d.ts +5 -0
- package/dist/es/connectors/useHits.js +5 -0
- package/dist/es/connectors/useHitsPerPage.d.ts +4 -0
- package/dist/es/connectors/useHitsPerPage.js +5 -0
- package/dist/es/connectors/useInfiniteHits.d.ts +5 -0
- package/dist/es/connectors/useInfiniteHits.js +5 -0
- package/dist/es/connectors/useMenu.d.ts +4 -0
- package/dist/es/connectors/useMenu.js +5 -0
- package/dist/es/connectors/useNumericMenu.d.ts +4 -0
- package/dist/es/connectors/useNumericMenu.js +5 -0
- package/dist/es/connectors/usePagination.d.ts +4 -0
- package/dist/es/connectors/usePagination.js +5 -0
- package/dist/es/connectors/usePoweredBy.d.ts +2 -0
- package/dist/es/connectors/usePoweredBy.js +15 -0
- package/dist/es/connectors/useQueryRules.d.ts +4 -0
- package/dist/es/connectors/useQueryRules.js +5 -0
- package/dist/es/connectors/useRange.d.ts +4 -0
- package/dist/es/connectors/useRange.js +5 -0
- package/dist/es/connectors/useRefinementList.d.ts +4 -0
- package/dist/es/connectors/useRefinementList.js +5 -0
- package/dist/es/connectors/useSearchBox.d.ts +4 -0
- package/dist/es/connectors/useSearchBox.js +5 -0
- package/dist/es/connectors/useSortBy.d.ts +4 -0
- package/dist/es/connectors/useSortBy.js +5 -0
- package/dist/es/connectors/useStats.d.ts +4 -0
- package/dist/es/connectors/useStats.js +5 -0
- package/dist/es/connectors/useToggleRefinement.d.ts +4 -0
- package/dist/es/connectors/useToggleRefinement.js +5 -0
- package/dist/es/hooks/useConnector.d.ts +3 -0
- package/dist/es/hooks/useConnector.js +130 -0
- package/dist/es/hooks/useInstantSearch.d.ts +32 -0
- package/dist/es/hooks/useInstantSearch.js +52 -0
- package/dist/es/index.d.ts +31 -0
- package/dist/es/index.js +31 -87
- package/dist/es/lib/IndexContext.d.ts +3 -0
- package/dist/es/lib/IndexContext.js +5 -0
- package/dist/es/lib/InstantSearchContext.d.ts +3 -0
- package/dist/es/lib/InstantSearchContext.js +5 -0
- package/dist/es/lib/InstantSearchSSRContext.d.ts +8 -0
- package/dist/es/lib/InstantSearchSSRContext.js +5 -0
- package/dist/es/lib/createSearchResults.d.ts +3 -0
- package/dist/es/lib/createSearchResults.js +20 -0
- package/dist/es/lib/dequal.d.ts +1 -0
- package/dist/es/lib/dequal.js +47 -0
- package/dist/es/lib/getIndexSearchResults.d.ts +9 -0
- package/dist/es/lib/getIndexSearchResults.js +26 -0
- package/dist/es/lib/invariant.d.ts +9 -0
- package/dist/es/lib/invariant.js +19 -0
- package/dist/es/lib/noop.d.ts +1 -0
- package/dist/es/lib/noop.js +1 -0
- package/dist/es/lib/useForceUpdate.d.ts +6 -0
- package/dist/es/lib/useForceUpdate.js +20 -0
- package/dist/es/lib/useIndex.d.ts +3 -0
- package/dist/es/lib/useIndex.js +31 -0
- package/dist/es/lib/useIndexContext.d.ts +2 -0
- package/dist/es/lib/useIndexContext.js +8 -0
- package/dist/es/lib/useInstantSearchApi.d.ts +21 -0
- package/dist/es/lib/useInstantSearchApi.js +184 -0
- package/dist/es/lib/useInstantSearchContext.d.ts +3 -0
- package/dist/es/lib/useInstantSearchContext.js +8 -0
- package/dist/es/lib/useInstantSearchSSRContext.d.ts +3 -0
- package/dist/es/lib/useInstantSearchSSRContext.js +5 -0
- package/dist/es/lib/useInstantSearchServerContext.d.ts +3 -0
- package/dist/es/lib/useInstantSearchServerContext.js +5 -0
- package/dist/es/lib/useIsomorphicLayoutEffect.d.ts +7 -0
- package/dist/es/lib/useIsomorphicLayoutEffect.js +8 -0
- package/dist/es/lib/useSearchResults.d.ts +7 -0
- package/dist/es/lib/useSearchResults.js +40 -0
- package/dist/es/lib/useSearchState.d.ts +8 -0
- package/dist/es/lib/useSearchState.js +42 -0
- package/dist/es/lib/useStableValue.d.ts +1 -0
- package/dist/es/lib/useStableValue.js +20 -0
- package/dist/es/lib/useWidget.d.ts +8 -0
- package/dist/es/lib/useWidget.js +72 -0
- package/dist/es/lib/warn.d.ts +10 -0
- package/dist/es/lib/warn.js +33 -0
- package/dist/es/server/getServerState.d.ts +10 -0
- package/dist/es/server/getServerState.js +86 -0
- package/dist/es/server/index.d.ts +1 -0
- package/dist/es/server/index.js +1 -0
- package/dist/es/version.d.ts +2 -0
- package/dist/es/version.js +1 -0
- package/dist/umd/ReactInstantSearchCore.js +14071 -7955
- package/dist/umd/ReactInstantSearchCore.js.map +1 -1
- package/dist/umd/ReactInstantSearchCore.min.js +1 -1
- package/dist/umd/ReactInstantSearchCore.min.js.map +1 -1
- package/package.json +23 -8
- package/dist/cjs/connectors/connectAutoComplete.js +0 -104
- package/dist/cjs/connectors/connectBreadcrumb.js +0 -123
- package/dist/cjs/connectors/connectConfigureRelatedItems.js +0 -127
- package/dist/cjs/connectors/connectCurrentRefinements.js +0 -69
- package/dist/cjs/connectors/connectDynamicWidgets.js +0 -65
- package/dist/cjs/connectors/connectGeoSearch.js +0 -189
- package/dist/cjs/connectors/connectHierarchicalMenu.js +0 -273
- package/dist/cjs/connectors/connectHighlight.js +0 -87
- package/dist/cjs/connectors/connectHitInsights.js +0 -76
- package/dist/cjs/connectors/connectHits.js +0 -88
- package/dist/cjs/connectors/connectHitsPerPage.js +0 -97
- package/dist/cjs/connectors/connectInfiniteHits.js +0 -154
- package/dist/cjs/connectors/connectMenu.js +0 -221
- package/dist/cjs/connectors/connectNumericMenu.js +0 -215
- package/dist/cjs/connectors/connectPagination.js +0 -94
- package/dist/cjs/connectors/connectPoweredBy.js +0 -27
- package/dist/cjs/connectors/connectQueryRules.js +0 -129
- package/dist/cjs/connectors/connectRange.js +0 -287
- package/dist/cjs/connectors/connectRefinementList.js +0 -243
- package/dist/cjs/connectors/connectRelevantSort.js +0 -56
- package/dist/cjs/connectors/connectScrollTo.js +0 -70
- package/dist/cjs/connectors/connectSearchBox.js +0 -104
- package/dist/cjs/connectors/connectSortBy.js +0 -100
- package/dist/cjs/connectors/connectStateResults.js +0 -79
- package/dist/cjs/connectors/connectStats.js +0 -39
- package/dist/cjs/connectors/connectToggleRefinement.js +0 -163
- package/dist/cjs/connectors/connectVoiceSearch.js +0 -124
- package/dist/cjs/core/context.js +0 -37
- package/dist/cjs/core/createConnector.js +0 -268
- package/dist/cjs/core/createInstantSearchManager.d.js +0 -1
- package/dist/cjs/core/createInstantSearchManager.js +0 -541
- package/dist/cjs/core/createStore.js +0 -27
- package/dist/cjs/core/createWidgetsManager.js +0 -39
- package/dist/cjs/core/highlight.js +0 -102
- package/dist/cjs/core/indexUtils.js +0 -214
- package/dist/cjs/core/metadata.js +0 -46
- package/dist/cjs/core/translatable.js +0 -82
- package/dist/cjs/core/utils.js +0 -161
- package/dist/cjs/types/algoliasearch.js +0 -1
- package/dist/cjs/types/translatable.js +0 -1
- package/dist/cjs/widgets/Configure.js +0 -48
- package/dist/cjs/widgets/ConfigureRelatedItems.js +0 -21
- package/dist/cjs/widgets/DynamicWidgets.js +0 -61
- package/dist/cjs/widgets/Index.js +0 -149
- package/dist/cjs/widgets/InstantSearch.js +0 -251
- package/dist/cjs/widgets/QueryRuleContext.js +0 -14
- package/dist/es/connectors/connectAutoComplete.js +0 -96
- package/dist/es/connectors/connectBreadcrumb.js +0 -115
- package/dist/es/connectors/connectConfigureRelatedItems.js +0 -121
- package/dist/es/connectors/connectCurrentRefinements.js +0 -62
- package/dist/es/connectors/connectDynamicWidgets.js +0 -56
- package/dist/es/connectors/connectGeoSearch.js +0 -182
- package/dist/es/connectors/connectHierarchicalMenu.js +0 -264
- package/dist/es/connectors/connectHighlight.js +0 -79
- package/dist/es/connectors/connectHitInsights.js +0 -69
- package/dist/es/connectors/connectHits.js +0 -81
- package/dist/es/connectors/connectHitsPerPage.js +0 -89
- package/dist/es/connectors/connectInfiniteHits.js +0 -146
- package/dist/es/connectors/connectMenu.js +0 -213
- package/dist/es/connectors/connectNumericMenu.js +0 -207
- package/dist/es/connectors/connectPagination.js +0 -86
- package/dist/es/connectors/connectPoweredBy.js +0 -20
- package/dist/es/connectors/connectQueryRules.js +0 -122
- package/dist/es/connectors/connectRange.js +0 -280
- package/dist/es/connectors/connectRefinementList.js +0 -235
- package/dist/es/connectors/connectRelevantSort.js +0 -50
- package/dist/es/connectors/connectScrollTo.js +0 -63
- package/dist/es/connectors/connectSearchBox.js +0 -96
- package/dist/es/connectors/connectSortBy.js +0 -92
- package/dist/es/connectors/connectStateResults.js +0 -72
- package/dist/es/connectors/connectStats.js +0 -32
- package/dist/es/connectors/connectToggleRefinement.js +0 -155
- package/dist/es/connectors/connectVoiceSearch.js +0 -116
- package/dist/es/core/context.js +0 -28
- package/dist/es/core/createConnector.js +0 -257
- package/dist/es/core/createInstantSearchManager.d.js +0 -0
- package/dist/es/core/createInstantSearchManager.js +0 -534
- package/dist/es/core/createStore.js +0 -21
- package/dist/es/core/createWidgetsManager.js +0 -33
- package/dist/es/core/highlight.js +0 -94
- package/dist/es/core/indexUtils.js +0 -203
- package/dist/es/core/metadata.js +0 -38
- package/dist/es/core/translatable.js +0 -74
- package/dist/es/core/utils.js +0 -139
- package/dist/es/core/version.js +0 -1
- package/dist/es/types/algoliasearch.js +0 -1
- package/dist/es/types/index.js +0 -1
- package/dist/es/types/translatable.js +0 -1
- package/dist/es/widgets/Configure.js +0 -42
- package/dist/es/widgets/ConfigureRelatedItems.js +0 -13
- package/dist/es/widgets/DynamicWidgets.js +0 -51
- package/dist/es/widgets/Index.js +0 -138
- package/dist/es/widgets/InstantSearch.js +0 -241
- package/dist/es/widgets/QueryRuleContext.js +0 -6
package/package.json
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-instantsearch-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "⚡ Lightning-fast search for React, by Algolia",
|
|
5
|
+
"source": "src/index.ts",
|
|
6
|
+
"types": "dist/es/index.d.ts",
|
|
5
7
|
"main": "dist/cjs/index.js",
|
|
6
8
|
"module": "dist/es/index.js",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/es/index.js",
|
|
13
|
+
"require": "./dist/cjs/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
7
16
|
"sideEffects": false,
|
|
8
17
|
"license": "MIT",
|
|
9
18
|
"homepage": "https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/react/",
|
|
@@ -30,21 +39,27 @@
|
|
|
30
39
|
"scripts": {
|
|
31
40
|
"clean": "rm -rf dist",
|
|
32
41
|
"watch": "yarn build:cjs --watch",
|
|
33
|
-
"build": "yarn build:cjs && yarn build:es && yarn build:umd",
|
|
34
|
-
"build:cjs": "BABEL_ENV=cjs babel src --root-mode upward --extensions '.js,.ts,.tsx' --out-dir dist/cjs --ignore '**/__tests__/**/*','**/__mocks__/**/*' --quiet",
|
|
42
|
+
"build": "yarn build:cjs && yarn build:es && yarn build:umd && yarn build:types",
|
|
43
|
+
"build:cjs": "BABEL_ENV=cjs babel src --root-mode upward --extensions '.js,.ts,.tsx' --out-dir dist/cjs --ignore '**/__tests__/**/*','**/__mocks__/**/*' --quiet && ../../scripts/prepare-cjs.sh",
|
|
35
44
|
"build:es": "BABEL_ENV=es babel src --root-mode upward --extensions '.js,.ts,.tsx' --out-dir dist/es --ignore '**/__tests__/**/*','**/__mocks__/**/*' --quiet",
|
|
36
45
|
"build:umd": "BABEL_ENV=rollup rollup -c rollup.config.js",
|
|
37
|
-
"
|
|
46
|
+
"build:types": "tsc -p ./tsconfig.declaration.json --outDir ./dist/es",
|
|
47
|
+
"test:exports": "node ./test/module/is-es-module.mjs && node ./test/module/is-cjs-module.cjs",
|
|
48
|
+
"version": "./scripts/version.cjs"
|
|
38
49
|
},
|
|
39
50
|
"dependencies": {
|
|
40
51
|
"@babel/runtime": "^7.1.2",
|
|
41
52
|
"algoliasearch-helper": "3.14.0",
|
|
42
|
-
"
|
|
43
|
-
"
|
|
53
|
+
"instantsearch.js": "4.56.8",
|
|
54
|
+
"use-sync-external-store": "^1.0.0"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@types/use-sync-external-store": "0.0.3",
|
|
58
|
+
"react-instantsearch-core-v6": "npm:react-instantsearch-core@6.40.4"
|
|
44
59
|
},
|
|
45
60
|
"peerDependencies": {
|
|
46
61
|
"algoliasearch": ">= 3.1 < 5",
|
|
47
|
-
"react": ">= 16.
|
|
62
|
+
"react": ">= 16.8.0 < 19"
|
|
48
63
|
},
|
|
49
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "c0a9fe132d2c64939763f64f7c265ed8ceb89ae2"
|
|
50
65
|
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _createConnector = _interopRequireDefault(require("../core/createConnector"));
|
|
9
|
-
var _indexUtils = require("../core/indexUtils");
|
|
10
|
-
var _utils = require("../core/utils");
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
14
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
15
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
16
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
17
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
18
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
19
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
20
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
21
|
-
var getId = function getId() {
|
|
22
|
-
return 'query';
|
|
23
|
-
};
|
|
24
|
-
function getCurrentRefinement(props, searchState, context) {
|
|
25
|
-
var id = getId();
|
|
26
|
-
var currentRefinement = (0, _indexUtils.getCurrentRefinementValue)(props, searchState, context, id, '');
|
|
27
|
-
if (currentRefinement) {
|
|
28
|
-
return currentRefinement;
|
|
29
|
-
}
|
|
30
|
-
return '';
|
|
31
|
-
}
|
|
32
|
-
function getHits(searchResults) {
|
|
33
|
-
if (searchResults.results) {
|
|
34
|
-
if (searchResults.results.hits && Array.isArray(searchResults.results.hits)) {
|
|
35
|
-
return (0, _utils.addAbsolutePositions)((0, _utils.addQueryID)(searchResults.results.hits, searchResults.results.queryID), searchResults.results.hitsPerPage, searchResults.results.page);
|
|
36
|
-
} else {
|
|
37
|
-
return Object.keys(searchResults.results).reduce(function (hits, index) {
|
|
38
|
-
return [].concat(_toConsumableArray(hits), [{
|
|
39
|
-
index: index,
|
|
40
|
-
hits: (0, _utils.addAbsolutePositions)((0, _utils.addQueryID)(searchResults.results[index].hits, searchResults.results[index].queryID), searchResults.results[index].hitsPerPage, searchResults.results[index].page)
|
|
41
|
-
}]);
|
|
42
|
-
}, []);
|
|
43
|
-
}
|
|
44
|
-
} else {
|
|
45
|
-
return [];
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function _refine(props, searchState, nextRefinement, context) {
|
|
49
|
-
var id = getId();
|
|
50
|
-
var nextValue = _defineProperty({}, id, nextRefinement);
|
|
51
|
-
var resetPage = true;
|
|
52
|
-
return (0, _indexUtils.refineValue)(searchState, nextValue, context, resetPage);
|
|
53
|
-
}
|
|
54
|
-
function _cleanUp(props, searchState, context) {
|
|
55
|
-
return (0, _indexUtils.cleanUpValue)(searchState, context, getId());
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* connectAutoComplete connector provides the logic to create connected
|
|
60
|
-
* components that will render the results retrieved from
|
|
61
|
-
* Algolia.
|
|
62
|
-
*
|
|
63
|
-
* To configure the number of hits retrieved, use [HitsPerPage widget](widgets/HitsPerPage.html),
|
|
64
|
-
* [connectHitsPerPage connector](connectors/connectHitsPerPage.html) or pass the hitsPerPage
|
|
65
|
-
* prop to a [Configure](guide/Search_parameters.html) widget.
|
|
66
|
-
* @name connectAutoComplete
|
|
67
|
-
* @kind connector
|
|
68
|
-
* @propType {string} [defaultRefinement] - Provide a default value for the query
|
|
69
|
-
* @providedPropType {array.<object>} hits - the records that matched the search state
|
|
70
|
-
* @providedPropType {function} refine - a function to change the query
|
|
71
|
-
* @providedPropType {string} currentRefinement - the query to search for
|
|
72
|
-
*/
|
|
73
|
-
var _default = (0, _createConnector.default)({
|
|
74
|
-
displayName: 'AlgoliaAutoComplete',
|
|
75
|
-
$$type: 'ais.autoComplete',
|
|
76
|
-
getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
|
|
77
|
-
return {
|
|
78
|
-
hits: getHits(searchResults),
|
|
79
|
-
currentRefinement: getCurrentRefinement(props, searchState, {
|
|
80
|
-
ais: props.contextValue,
|
|
81
|
-
multiIndexContext: props.indexContextValue
|
|
82
|
-
})
|
|
83
|
-
};
|
|
84
|
-
},
|
|
85
|
-
refine: function refine(props, searchState, nextRefinement) {
|
|
86
|
-
return _refine(props, searchState, nextRefinement, {
|
|
87
|
-
ais: props.contextValue,
|
|
88
|
-
multiIndexContext: props.indexContextValue
|
|
89
|
-
});
|
|
90
|
-
},
|
|
91
|
-
cleanUp: function cleanUp(props, searchState) {
|
|
92
|
-
return _cleanUp(props, searchState, {
|
|
93
|
-
ais: props.contextValue,
|
|
94
|
-
multiIndexContext: props.indexContextValue
|
|
95
|
-
});
|
|
96
|
-
},
|
|
97
|
-
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
98
|
-
return searchParameters.setQuery(getCurrentRefinement(props, searchState, {
|
|
99
|
-
ais: props.contextValue,
|
|
100
|
-
multiIndexContext: props.indexContextValue
|
|
101
|
-
}));
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
exports.default = _default;
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getId = exports.default = void 0;
|
|
7
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
-
var _createConnector = _interopRequireDefault(require("../core/createConnector"));
|
|
9
|
-
var _indexUtils = require("../core/indexUtils");
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
12
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
14
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
15
|
-
var getId = function getId(props) {
|
|
16
|
-
return props.attributes[0];
|
|
17
|
-
};
|
|
18
|
-
exports.getId = getId;
|
|
19
|
-
var namespace = 'hierarchicalMenu';
|
|
20
|
-
function _refine(props, searchState, nextRefinement, context) {
|
|
21
|
-
var id = getId(props);
|
|
22
|
-
var nextValue = _defineProperty({}, id, nextRefinement || '');
|
|
23
|
-
var resetPage = true;
|
|
24
|
-
return (0, _indexUtils.refineValue)(searchState, nextValue, context, resetPage, namespace);
|
|
25
|
-
}
|
|
26
|
-
function transformValue(values) {
|
|
27
|
-
return values.reduce(function (acc, item) {
|
|
28
|
-
if (item.isRefined) {
|
|
29
|
-
acc.push({
|
|
30
|
-
label: item.name,
|
|
31
|
-
// If dealing with a nested "items", "value" is equal to the previous value concatenated with the current value
|
|
32
|
-
// If dealing with the first level, "value" is equal to the current value
|
|
33
|
-
value: item.escapedValue
|
|
34
|
-
});
|
|
35
|
-
// Create a variable in order to keep the same acc for the recursion, otherwise "reduce" returns a new one
|
|
36
|
-
if (item.data) {
|
|
37
|
-
acc = acc.concat(transformValue(item.data, acc));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return acc;
|
|
41
|
-
}, []);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* The breadcrumb component is s a type of secondary navigation scheme that
|
|
46
|
-
* reveals the user’s location in a website or web application.
|
|
47
|
-
*
|
|
48
|
-
* @name connectBreadcrumb
|
|
49
|
-
* @requirements To use this widget, your attributes must be formatted in a specific way.
|
|
50
|
-
* If you want for example to have a Breadcrumb of categories, objects in your index
|
|
51
|
-
* should be formatted this way:
|
|
52
|
-
*
|
|
53
|
-
* ```json
|
|
54
|
-
* {
|
|
55
|
-
* "categories.lvl0": "products",
|
|
56
|
-
* "categories.lvl1": "products > fruits",
|
|
57
|
-
* "categories.lvl2": "products > fruits > citrus"
|
|
58
|
-
* }
|
|
59
|
-
* ```
|
|
60
|
-
*
|
|
61
|
-
* It's also possible to provide more than one path for each level:
|
|
62
|
-
*
|
|
63
|
-
* ```json
|
|
64
|
-
* {
|
|
65
|
-
* "categories.lvl0": ["products", "goods"],
|
|
66
|
-
* "categories.lvl1": ["products > fruits", "goods > to eat"]
|
|
67
|
-
* }
|
|
68
|
-
* ```
|
|
69
|
-
*
|
|
70
|
-
* All attributes passed to the `attributes` prop must be present in "attributes for faceting"
|
|
71
|
-
* on the Algolia dashboard or configured as `attributesForFaceting` via a set settings call to the Algolia API.
|
|
72
|
-
*
|
|
73
|
-
* @kind connector
|
|
74
|
-
* @propType {array.<string>} attributes - List of attributes to use to generate the hierarchy of the menu. See the example for the convention to follow.
|
|
75
|
-
* @propType {function} [transformItems] - Function to modify the items being displayed, e.g. for filtering or sorting them. Takes an items as parameter and expects it back in return.
|
|
76
|
-
* @providedPropType {function} refine - a function to toggle a refinement
|
|
77
|
-
* @providedPropType {function} createURL - a function to generate a URL for the corresponding search state
|
|
78
|
-
* @providedPropType {array.<{items: object, count: number, isRefined: boolean, label: string, value: string}>} items - the list of items the Breadcrumb can display.
|
|
79
|
-
*/
|
|
80
|
-
var _default = (0, _createConnector.default)({
|
|
81
|
-
displayName: 'AlgoliaBreadcrumb',
|
|
82
|
-
$$type: 'ais.breadcrumb',
|
|
83
|
-
propTypes: {
|
|
84
|
-
attributes: function attributes(props, propName, componentName) {
|
|
85
|
-
var isNotString = function isNotString(val) {
|
|
86
|
-
return typeof val !== 'string';
|
|
87
|
-
};
|
|
88
|
-
if (!Array.isArray(props[propName]) || props[propName].some(isNotString) || props[propName].length < 1) {
|
|
89
|
-
return new Error("Invalid prop ".concat(propName, " supplied to ").concat(componentName, ". Expected an Array of Strings"));
|
|
90
|
-
}
|
|
91
|
-
return undefined;
|
|
92
|
-
},
|
|
93
|
-
transformItems: _propTypes.default.func
|
|
94
|
-
},
|
|
95
|
-
getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
|
|
96
|
-
var id = getId(props);
|
|
97
|
-
var results = (0, _indexUtils.getResults)(searchResults, {
|
|
98
|
-
ais: props.contextValue,
|
|
99
|
-
multiIndexContext: props.indexContextValue
|
|
100
|
-
});
|
|
101
|
-
var isFacetPresent = Boolean(results) && Boolean(results.getFacetByName(id));
|
|
102
|
-
if (!isFacetPresent) {
|
|
103
|
-
return {
|
|
104
|
-
items: [],
|
|
105
|
-
canRefine: false
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
var values = results.getFacetValues(id);
|
|
109
|
-
var items = values.data ? transformValue(values.data) : [];
|
|
110
|
-
var transformedItems = props.transformItems ? props.transformItems(items) : items;
|
|
111
|
-
return {
|
|
112
|
-
canRefine: transformedItems.length > 0,
|
|
113
|
-
items: transformedItems
|
|
114
|
-
};
|
|
115
|
-
},
|
|
116
|
-
refine: function refine(props, searchState, nextRefinement) {
|
|
117
|
-
return _refine(props, searchState, nextRefinement, {
|
|
118
|
-
ais: props.contextValue,
|
|
119
|
-
multiIndexContext: props.indexContextValue
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
exports.default = _default;
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _algoliasearchHelper = _interopRequireDefault(require("algoliasearch-helper"));
|
|
8
|
-
var _createConnector = _interopRequireDefault(require("../core/createConnector"));
|
|
9
|
-
var _indexUtils = require("../core/indexUtils");
|
|
10
|
-
var _utils = require("../core/utils");
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
13
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
14
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
16
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
17
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
18
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
19
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
22
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
23
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
24
|
-
function createOptionalFilter(_ref) {
|
|
25
|
-
var attributeName = _ref.attributeName,
|
|
26
|
-
attributeValue = _ref.attributeValue,
|
|
27
|
-
attributeScore = _ref.attributeScore;
|
|
28
|
-
return "".concat(attributeName, ":").concat(attributeValue, "<score=").concat(attributeScore || 1, ">");
|
|
29
|
-
}
|
|
30
|
-
var defaultProps = {
|
|
31
|
-
transformSearchParameters: function transformSearchParameters(x) {
|
|
32
|
-
return _objectSpread({}, x);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
function getId() {
|
|
36
|
-
// We store the search state of this widget in `configure`.
|
|
37
|
-
return 'configure';
|
|
38
|
-
}
|
|
39
|
-
function getSearchParametersFromProps(props) {
|
|
40
|
-
var optionalFilters = Object.keys(props.matchingPatterns).reduce(function (acc, attributeName) {
|
|
41
|
-
var attributePattern = props.matchingPatterns[attributeName];
|
|
42
|
-
var attributeValue = (0, _utils.getPropertyByPath)(props.hit, attributeName);
|
|
43
|
-
var attributeScore = attributePattern.score;
|
|
44
|
-
if (Array.isArray(attributeValue)) {
|
|
45
|
-
return [].concat(_toConsumableArray(acc), [attributeValue.map(function (attributeSubValue) {
|
|
46
|
-
return createOptionalFilter({
|
|
47
|
-
attributeName: attributeName,
|
|
48
|
-
attributeValue: attributeSubValue,
|
|
49
|
-
attributeScore: attributeScore
|
|
50
|
-
});
|
|
51
|
-
})]);
|
|
52
|
-
}
|
|
53
|
-
if (typeof attributeValue === 'string') {
|
|
54
|
-
return [].concat(_toConsumableArray(acc), [createOptionalFilter({
|
|
55
|
-
attributeName: attributeName,
|
|
56
|
-
attributeValue: attributeValue,
|
|
57
|
-
attributeScore: attributeScore
|
|
58
|
-
})]);
|
|
59
|
-
}
|
|
60
|
-
if (process.env.NODE_ENV === 'development') {
|
|
61
|
-
// eslint-disable-next-line no-console
|
|
62
|
-
console.warn("The `matchingPatterns` option returned a value of type ".concat((0, _utils.getObjectType)(attributeValue), " for the \"").concat(attributeName, "\" key. This value was not sent to Algolia because `optionalFilters` only supports strings and array of strings.\n\nYou can remove the \"").concat(attributeName, "\" key from the `matchingPatterns` option.\n\nSee https://www.algolia.com/doc/api-reference/api-parameters/optionalFilters/"));
|
|
63
|
-
}
|
|
64
|
-
return acc;
|
|
65
|
-
}, []);
|
|
66
|
-
return props.transformSearchParameters(new _algoliasearchHelper.default.SearchParameters({
|
|
67
|
-
// @ts-ignore @TODO algoliasearch-helper@3.0.1 will contain the type
|
|
68
|
-
// `sumOrFiltersScores`.
|
|
69
|
-
// See https://github.com/algolia/algoliasearch-helper-js/pull/753
|
|
70
|
-
sumOrFiltersScores: true,
|
|
71
|
-
facetFilters: ["objectID:-".concat(props.hit.objectID)],
|
|
72
|
-
optionalFilters: optionalFilters
|
|
73
|
-
}));
|
|
74
|
-
}
|
|
75
|
-
var _default = (0, _createConnector.default)({
|
|
76
|
-
displayName: 'AlgoliaConfigureRelatedItems',
|
|
77
|
-
$$type: 'ais.configureRelatedItems',
|
|
78
|
-
defaultProps: defaultProps,
|
|
79
|
-
getProvidedProps: function getProvidedProps() {
|
|
80
|
-
return {};
|
|
81
|
-
},
|
|
82
|
-
getSearchParameters: function getSearchParameters(searchParameters, props) {
|
|
83
|
-
return searchParameters.setQueryParameters(getSearchParametersFromProps(props));
|
|
84
|
-
},
|
|
85
|
-
transitionState: function transitionState(props, _prevSearchState, nextSearchState) {
|
|
86
|
-
var id = getId();
|
|
87
|
-
// We need to transform the exhaustive search parameters back to clean
|
|
88
|
-
// search parameters without the empty default keys so we don't pollute the
|
|
89
|
-
// `configure` search state.
|
|
90
|
-
var searchParameters = (0, _utils.removeEmptyArraysFromObject)((0, _utils.removeEmptyKey)(getSearchParametersFromProps(props)));
|
|
91
|
-
var searchParametersKeys = Object.keys(searchParameters);
|
|
92
|
-
var nonPresentKeys = this._searchParameters ? Object.keys(this._searchParameters).filter(function (prop) {
|
|
93
|
-
return searchParametersKeys.indexOf(prop) === -1;
|
|
94
|
-
}) : [];
|
|
95
|
-
this._searchParameters = searchParameters;
|
|
96
|
-
var nextValue = _defineProperty({}, id, _objectSpread(_objectSpread({}, (0, _utils.omit)(nextSearchState[id], nonPresentKeys)), searchParameters));
|
|
97
|
-
return (0, _indexUtils.refineValue)(nextSearchState, nextValue, {
|
|
98
|
-
ais: props.contextValue,
|
|
99
|
-
multiIndexContext: props.indexContextValue
|
|
100
|
-
});
|
|
101
|
-
},
|
|
102
|
-
cleanUp: function cleanUp(props, searchState) {
|
|
103
|
-
var _this = this;
|
|
104
|
-
var id = getId();
|
|
105
|
-
var indexId = (0, _indexUtils.getIndexId)({
|
|
106
|
-
ais: props.contextValue,
|
|
107
|
-
multiIndexContext: props.indexContextValue
|
|
108
|
-
});
|
|
109
|
-
var subState = (0, _indexUtils.hasMultipleIndices)({
|
|
110
|
-
ais: props.contextValue,
|
|
111
|
-
multiIndexContext: props.indexContextValue
|
|
112
|
-
}) && searchState.indices ? searchState.indices[indexId] : searchState;
|
|
113
|
-
var configureKeys = subState && subState[id] ? Object.keys(subState[id]) : [];
|
|
114
|
-
var configureState = configureKeys.reduce(function (acc, item) {
|
|
115
|
-
if (!_this._searchParameters[item]) {
|
|
116
|
-
acc[item] = subState[id][item];
|
|
117
|
-
}
|
|
118
|
-
return acc;
|
|
119
|
-
}, {});
|
|
120
|
-
var nextValue = _defineProperty({}, id, configureState);
|
|
121
|
-
return (0, _indexUtils.refineValue)(searchState, nextValue, {
|
|
122
|
-
ais: props.contextValue,
|
|
123
|
-
multiIndexContext: props.indexContextValue
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
exports.default = _default;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
-
var _createConnector = _interopRequireDefault(require("../core/createConnector"));
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
11
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
12
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
13
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
15
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
|
-
/**
|
|
17
|
-
* connectCurrentRefinements connector provides the logic to build a widget that will
|
|
18
|
-
* give the user the ability to remove all or some of the filters that were
|
|
19
|
-
* set.
|
|
20
|
-
* @name connectCurrentRefinements
|
|
21
|
-
* @kind connector
|
|
22
|
-
* @propType {function} [transformItems] - Function to modify the items being displayed, e.g. for filtering or sorting them. Takes an items as parameter and expects it back in return.
|
|
23
|
-
* @propType {function} [clearsQuery=false] - Pass true to also clear the search query
|
|
24
|
-
* @providedPropType {function} refine - a function to remove a single filter
|
|
25
|
-
* @providedPropType {array.<{label: string, attribute: string, currentRefinement: string || object, items: array, value: function}>} items - all the filters, the `value` is to pass to the `refine` function for removing all currentrefinements, `label` is for the display. When existing several refinements for the same atribute name, then you get a nested `items` object that contains a `label` and a `value` function to use to remove a single filter. `attribute` and `currentRefinement` are metadata containing row values.
|
|
26
|
-
* @providedPropType {string} query - the search query
|
|
27
|
-
*/
|
|
28
|
-
var _default = (0, _createConnector.default)({
|
|
29
|
-
displayName: 'AlgoliaCurrentRefinements',
|
|
30
|
-
$$type: 'ais.currentRefinements',
|
|
31
|
-
propTypes: {
|
|
32
|
-
transformItems: _propTypes.default.func
|
|
33
|
-
},
|
|
34
|
-
getProvidedProps: function getProvidedProps(props, searchState, searchResults, metadata) {
|
|
35
|
-
var items = metadata.reduce(function (res, meta) {
|
|
36
|
-
if (typeof meta.items !== 'undefined') {
|
|
37
|
-
if (!props.clearsQuery && meta.id === 'query') {
|
|
38
|
-
return res;
|
|
39
|
-
} else {
|
|
40
|
-
if (props.clearsQuery && meta.id === 'query' && meta.items[0].currentRefinement === '') {
|
|
41
|
-
return res;
|
|
42
|
-
}
|
|
43
|
-
return res.concat(meta.items.map(function (item) {
|
|
44
|
-
return _objectSpread(_objectSpread({}, item), {}, {
|
|
45
|
-
id: meta.id,
|
|
46
|
-
index: meta.index
|
|
47
|
-
});
|
|
48
|
-
}));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return res;
|
|
52
|
-
}, []);
|
|
53
|
-
var transformedItems = props.transformItems ? props.transformItems(items) : items;
|
|
54
|
-
return {
|
|
55
|
-
items: transformedItems,
|
|
56
|
-
canRefine: transformedItems.length > 0
|
|
57
|
-
};
|
|
58
|
-
},
|
|
59
|
-
refine: function refine(props, searchState, items) {
|
|
60
|
-
// `value` corresponds to our internal clear function computed in each connector metadata.
|
|
61
|
-
var refinementsToClear = items instanceof Array ? items.map(function (item) {
|
|
62
|
-
return item.value;
|
|
63
|
-
}) : [items];
|
|
64
|
-
return refinementsToClear.reduce(function (res, clear) {
|
|
65
|
-
return clear(res);
|
|
66
|
-
}, searchState);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
exports.default = _default;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
-
var _createConnector = _interopRequireDefault(require("../core/createConnector"));
|
|
9
|
-
var _indexUtils = require("../core/indexUtils");
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
|
|
13
|
-
var MAX_WILDCARD_FACETS = 20;
|
|
14
|
-
var _default = (0, _createConnector.default)({
|
|
15
|
-
displayName: 'AlgoliaDynamicWidgets',
|
|
16
|
-
$$type: 'ais.dynamicWidgets',
|
|
17
|
-
defaultProps: {
|
|
18
|
-
transformItems: function transformItems(items) {
|
|
19
|
-
return items;
|
|
20
|
-
},
|
|
21
|
-
maxValuesPerFacet: 20
|
|
22
|
-
},
|
|
23
|
-
propTypes: {
|
|
24
|
-
transformItems: _propTypes.default.func,
|
|
25
|
-
facets: _propTypes.default.arrayOf(_propTypes.default.string),
|
|
26
|
-
maxValuesPerFacet: _propTypes.default.number
|
|
27
|
-
},
|
|
28
|
-
getProvidedProps: function getProvidedProps(props, _searchState, searchResults) {
|
|
29
|
-
var results = (0, _indexUtils.getResults)(searchResults, {
|
|
30
|
-
ais: props.contextValue,
|
|
31
|
-
multiIndexContext: props.indexContextValue
|
|
32
|
-
});
|
|
33
|
-
if (props.facets && !(Array.isArray(props.facets) && props.facets.length <= 1 && (props.facets[0] === '*' || props.facets[0] === undefined))) {
|
|
34
|
-
throw new Error("The `facets` prop only accepts [] or [\"*\"], you passed ".concat(JSON.stringify(props.facets)));
|
|
35
|
-
}
|
|
36
|
-
if (!results) {
|
|
37
|
-
return {
|
|
38
|
-
attributesToRender: []
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
var facetOrder = results.renderingContent && results.renderingContent.facetOrdering && results.renderingContent.facetOrdering.facets && results.renderingContent.facetOrdering.facets.order || [];
|
|
42
|
-
var attributesToRender = props.transformItems(facetOrder, {
|
|
43
|
-
results: results
|
|
44
|
-
});
|
|
45
|
-
if (attributesToRender.length > MAX_WILDCARD_FACETS && !props.facets) {
|
|
46
|
-
// eslint-disable-next-line no-console
|
|
47
|
-
console.warn("More than ".concat(MAX_WILDCARD_FACETS, " facets are requested to be displayed without explicitly setting which facets to retrieve. This could have a performance impact. Set \"facets\" to [] to do two smaller network requests, or explicitly to ['*'] to avoid this warning."));
|
|
48
|
-
}
|
|
49
|
-
if (props.maxValuesPerFacet < results._state.maxValuesPerFacet) {
|
|
50
|
-
// eslint-disable-next-line no-console
|
|
51
|
-
console.warn("The maxValuesPerFacet set by dynamic widgets (".concat(props.maxValuesPerFacet, ") is smaller than one of the limits set by a widget (").concat(results._state.maxValuesPerFacet, "). This causes a mismatch in query parameters and thus an extra network request when that widget is mounted."));
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
attributesToRender: attributesToRender
|
|
55
|
-
};
|
|
56
|
-
},
|
|
57
|
-
getSearchParameters: function getSearchParameters(searchParameters, props) {
|
|
58
|
-
return (props.facets || ['*']).reduce(function (acc, curr) {
|
|
59
|
-
return acc.addFacet(curr);
|
|
60
|
-
}, searchParameters.setQueryParameters({
|
|
61
|
-
maxValuesPerFacet: Math.max(props.maxValuesPerFacet || 0, searchParameters.maxValuesPerFacet || 0)
|
|
62
|
-
}));
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
exports.default = _default;
|