@sonic-equipment/ui 220.0.0 → 221.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/dist/algolia/algolia-search-provider.js +2 -2
- package/dist/algolia/use-algolia-search.d.ts +1 -1
- package/dist/global-search/plugins/categories-plugin.d.ts +1 -1
- package/dist/global-search/plugins/categories-plugin.js +1 -1
- package/dist/global-search/plugins/popular-categories-plugin.d.ts +1 -1
- package/dist/global-search/plugins/popular-categories-plugin.js +1 -1
- package/dist/global-search/plugins/popular-searches-plugin.d.ts +1 -1
- package/dist/global-search/plugins/popular-searches-plugin.js +1 -1
- package/dist/global-search/plugins/query-suggestions-plugin.d.ts +1 -1
- package/dist/global-search/plugins/query-suggestions-plugin.js +1 -1
- package/dist/global-search/plugins/quick-access-plugin.d.ts +1 -1
- package/dist/global-search/plugins/quick-access-plugin.js +1 -1
- package/dist/global-search/plugins/recent-searches-plugin.d.ts +1 -1
- package/dist/global-search/plugins/recent-searches-plugin.js +2 -1
- package/dist/global-search/search-highlight/highlight.d.ts +1 -1
- package/dist/global-search/search-highlight/highlight.js +1 -1
- package/dist/global-search/types.d.ts +1 -1
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/checkOptions.js +7 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/createAutocomplete.js +109 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/createStore.js +31 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/getAutocompleteSetters.js +51 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/getCompletion.js +12 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/getDefaultProps.js +135 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/getPropGetters.js +355 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/metadata.js +44 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/onInput.js +148 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/onKeyDown.js +202 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/reshape.js +48 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/resolve.js +119 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/stateReducer.js +149 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/utils/createCancelablePromise.js +50 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/utils/createCancelablePromiseList.js +42 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/utils/createConcurrentSafePromise.js +38 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/utils/getActiveItem.js +79 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/utils/getAutocompleteElementId.js +12 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/utils/getNativeEvent.js +5 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/utils/getNextActiveItemId.js +31 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/utils/getNormalizedSources.js +53 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/utils/getPluginSubmitPromise.js +39 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/utils/isOrContainsNode.js +5 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/utils/isSamsung.js +6 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/utils/mapToAlgoliaResponse.js +25 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-js@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-js/dist/esm/requesters/createAlgoliaRequester.js +16 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-js@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-js/dist/esm/requesters/getAlgoliaResults.js +12 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-js@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-js/dist/esm/userAgents.js +8 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-algolia-insights@1.19.2_@algolia_client-search@4.24.0_algoliasea_57b3nqmtgbeobm4sw3iw2qdpxy/node_modules/@algolia/autocomplete-plugin-algolia-insights/dist/esm/createAlgoliaInsightsPlugin.js +252 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-algolia-insights@1.19.2_@algolia_client-search@4.24.0_algoliasea_57b3nqmtgbeobm4sw3iw2qdpxy/node_modules/@algolia/autocomplete-plugin-algolia-insights/dist/esm/createClickedEvent.js +16 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-algolia-insights@1.19.2_@algolia_client-search@4.24.0_algoliasea_57b3nqmtgbeobm4sw3iw2qdpxy/node_modules/@algolia/autocomplete-plugin-algolia-insights/dist/esm/createSearchInsightsApi.js +209 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-algolia-insights@1.19.2_@algolia_client-search@4.24.0_algoliasea_57b3nqmtgbeobm4sw3iw2qdpxy/node_modules/@algolia/autocomplete-plugin-algolia-insights/dist/esm/createViewedEvents.js +18 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-algolia-insights@1.19.2_@algolia_client-search@4.24.0_algoliasea_57b3nqmtgbeobm4sw3iw2qdpxy/node_modules/@algolia/autocomplete-plugin-algolia-insights/dist/esm/isAlgoliaInsightsHit.js +5 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-algolia-insights@1.19.2_@algolia_client-search@4.24.0_algoliasea_57b3nqmtgbeobm4sw3iw2qdpxy/node_modules/@algolia/autocomplete-plugin-algolia-insights/dist/esm/isModernInsightsClient.js +25 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-query-suggestions@1.19.2_@algolia_client-search@4.24.0_algoliase_q33j3oaxy2utuyscyksb32r6mu/node_modules/@algolia/autocomplete-plugin-query-suggestions/dist/esm/constants.js +7 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-query-suggestions@1.19.2_@algolia_client-search@4.24.0_algoliase_q33j3oaxy2utuyscyksb32r6mu/node_modules/@algolia/autocomplete-plugin-query-suggestions/dist/esm/createQuerySuggestionsPlugin.js +118 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-query-suggestions@1.19.2_@algolia_client-search@4.24.0_algoliase_q33j3oaxy2utuyscyksb32r6mu/node_modules/@algolia/autocomplete-plugin-query-suggestions/dist/esm/getTemplates.js +64 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-recent-searches@1.19.2_@algolia_client-search@4.24.0_algoliasear_fyqsds3bt3rvcvjy7dxjzgxvaa/node_modules/@algolia/autocomplete-plugin-recent-searches/dist/esm/addHighlightedAttribute.js +21 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-recent-searches@1.19.2_@algolia_client-search@4.24.0_algoliasear_fyqsds3bt3rvcvjy7dxjzgxvaa/node_modules/@algolia/autocomplete-plugin-recent-searches/dist/esm/constants.js +10 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-recent-searches@1.19.2_@algolia_client-search@4.24.0_algoliasear_fyqsds3bt3rvcvjy7dxjzgxvaa/node_modules/@algolia/autocomplete-plugin-recent-searches/dist/esm/createLocalStorage.js +36 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-recent-searches@1.19.2_@algolia_client-search@4.24.0_algoliasear_fyqsds3bt3rvcvjy7dxjzgxvaa/node_modules/@algolia/autocomplete-plugin-recent-searches/dist/esm/createLocalStorageRecentSearchesPlugin.js +49 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-recent-searches@1.19.2_@algolia_client-search@4.24.0_algoliasear_fyqsds3bt3rvcvjy7dxjzgxvaa/node_modules/@algolia/autocomplete-plugin-recent-searches/dist/esm/createRecentSearchesPlugin.js +137 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-recent-searches@1.19.2_@algolia_client-search@4.24.0_algoliasear_fyqsds3bt3rvcvjy7dxjzgxvaa/node_modules/@algolia/autocomplete-plugin-recent-searches/dist/esm/createStorageApi.js +16 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-recent-searches@1.19.2_@algolia_client-search@4.24.0_algoliasear_fyqsds3bt3rvcvjy7dxjzgxvaa/node_modules/@algolia/autocomplete-plugin-recent-searches/dist/esm/getLocalStorage.js +33 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-recent-searches@1.19.2_@algolia_client-search@4.24.0_algoliasear_fyqsds3bt3rvcvjy7dxjzgxvaa/node_modules/@algolia/autocomplete-plugin-recent-searches/dist/esm/getTemplates.js +72 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-recent-searches@1.19.2_@algolia_client-search@4.24.0_algoliasear_fyqsds3bt3rvcvjy7dxjzgxvaa/node_modules/@algolia/autocomplete-plugin-recent-searches/dist/esm/search.js +25 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-preset-algolia@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-preset-algolia/dist/esm/constants/index.js +4 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-preset-algolia@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-preset-algolia/dist/esm/highlight/parseAlgoliaHitHighlight.js +25 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-preset-algolia@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-preset-algolia/dist/esm/highlight/parseAttribute.js +51 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-preset-algolia@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-preset-algolia/dist/esm/requester/createAlgoliaRequester.js +6 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-preset-algolia@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-preset-algolia/dist/esm/requester/createRequester.js +37 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-preset-algolia@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-preset-algolia/dist/esm/requester/getAlgoliaResults.js +19 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-preset-algolia@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-preset-algolia/dist/esm/search/fetchAlgoliaResults.js +69 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-preset-algolia@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-preset-algolia/dist/esm/utils/getAppIdAndApiKey.js +16 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/createRef.js +7 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/debounce.js +16 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/decycle.js +34 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/flatten.js +7 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/generateAutocompleteId.js +6 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/getAttributeValueByPath.js +7 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/getItemsCount.js +10 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/invariant.js +15 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/isEqual.js +26 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/noop.js +3 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/safelyRunOnBrowser.js +13 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/userAgents.js +8 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/version.js +3 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/warn.js +26 -0
- package/dist/shared/utils/uuid.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { onInput } from './onInput.js';
|
|
2
|
+
import { getPluginSubmitPromise } from './utils/getPluginSubmitPromise.js';
|
|
3
|
+
import { getAutocompleteElementId } from './utils/getAutocompleteElementId.js';
|
|
4
|
+
import { getActiveItem } from './utils/getActiveItem.js';
|
|
5
|
+
|
|
6
|
+
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); }
|
|
7
|
+
var _excluded = ["event", "props", "refresh", "store"];
|
|
8
|
+
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; }
|
|
9
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), true).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; }
|
|
10
|
+
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; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
|
+
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); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
14
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
15
|
+
function onKeyDown(_ref) {
|
|
16
|
+
var event = _ref.event,
|
|
17
|
+
props = _ref.props,
|
|
18
|
+
refresh = _ref.refresh,
|
|
19
|
+
store = _ref.store,
|
|
20
|
+
setters = _objectWithoutProperties(_ref, _excluded);
|
|
21
|
+
if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
|
|
22
|
+
// eslint-disable-next-line no-inner-declarations
|
|
23
|
+
var triggerScrollIntoView = function triggerScrollIntoView() {
|
|
24
|
+
var highlightedItem = getActiveItem(store.getState());
|
|
25
|
+
var nodeItem = props.environment.document.getElementById(getAutocompleteElementId(props.id, "item-".concat(store.getState().activeItemId), highlightedItem === null || highlightedItem === void 0 ? void 0 : highlightedItem.source));
|
|
26
|
+
if (nodeItem) {
|
|
27
|
+
if (nodeItem.scrollIntoViewIfNeeded) {
|
|
28
|
+
nodeItem.scrollIntoViewIfNeeded(false);
|
|
29
|
+
} else {
|
|
30
|
+
nodeItem.scrollIntoView(false);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}; // eslint-disable-next-line no-inner-declarations
|
|
34
|
+
var triggerOnActive = function triggerOnActive() {
|
|
35
|
+
var highlightedItem = getActiveItem(store.getState());
|
|
36
|
+
if (store.getState().activeItemId !== null && highlightedItem) {
|
|
37
|
+
var item = highlightedItem.item,
|
|
38
|
+
itemInputValue = highlightedItem.itemInputValue,
|
|
39
|
+
itemUrl = highlightedItem.itemUrl,
|
|
40
|
+
source = highlightedItem.source;
|
|
41
|
+
source.onActive(_objectSpread({
|
|
42
|
+
event: event,
|
|
43
|
+
item: item,
|
|
44
|
+
itemInputValue: itemInputValue,
|
|
45
|
+
itemUrl: itemUrl,
|
|
46
|
+
refresh: refresh,
|
|
47
|
+
source: source,
|
|
48
|
+
state: store.getState()
|
|
49
|
+
}, setters));
|
|
50
|
+
}
|
|
51
|
+
}; // Default browser behavior changes the caret placement on ArrowUp and
|
|
52
|
+
// ArrowDown.
|
|
53
|
+
event.preventDefault();
|
|
54
|
+
|
|
55
|
+
// When re-opening the panel, we need to split the logic to keep the actions
|
|
56
|
+
// synchronized as `onInput` returns a promise.
|
|
57
|
+
if (store.getState().isOpen === false && (props.openOnFocus || Boolean(store.getState().query))) {
|
|
58
|
+
onInput(_objectSpread({
|
|
59
|
+
event: event,
|
|
60
|
+
props: props,
|
|
61
|
+
query: store.getState().query,
|
|
62
|
+
refresh: refresh,
|
|
63
|
+
store: store
|
|
64
|
+
}, setters)).then(function () {
|
|
65
|
+
store.dispatch(event.key, {
|
|
66
|
+
nextActiveItemId: props.defaultActiveItemId
|
|
67
|
+
});
|
|
68
|
+
triggerOnActive();
|
|
69
|
+
// Since we rely on the DOM, we need to wait for all the micro tasks to
|
|
70
|
+
// finish (which include re-opening the panel) to make sure all the
|
|
71
|
+
// elements are available.
|
|
72
|
+
setTimeout(triggerScrollIntoView, 0);
|
|
73
|
+
});
|
|
74
|
+
} else {
|
|
75
|
+
store.dispatch(event.key, {});
|
|
76
|
+
triggerOnActive();
|
|
77
|
+
triggerScrollIntoView();
|
|
78
|
+
}
|
|
79
|
+
} else if (event.key === 'Escape') {
|
|
80
|
+
// This prevents the default browser behavior on `input[type="search"]`
|
|
81
|
+
// from removing the query right away because we first want to close the
|
|
82
|
+
// panel.
|
|
83
|
+
event.preventDefault();
|
|
84
|
+
store.dispatch(event.key, null);
|
|
85
|
+
|
|
86
|
+
// Hitting the `Escape` key signals the end of a user interaction with the
|
|
87
|
+
// autocomplete. At this point, we should ignore any requests that are still
|
|
88
|
+
// pending and could reopen the panel once they resolve, because that would
|
|
89
|
+
// result in an unsolicited UI behavior.
|
|
90
|
+
store.pendingRequests.cancelAll();
|
|
91
|
+
} else if (event.key === 'Tab') {
|
|
92
|
+
store.dispatch('blur', null);
|
|
93
|
+
|
|
94
|
+
// Hitting the `Tab` key signals the end of a user interaction with the
|
|
95
|
+
// autocomplete. At this point, we should ignore any requests that are still
|
|
96
|
+
// pending and could reopen the panel once they resolve, because that would
|
|
97
|
+
// result in an unsolicited UI behavior.
|
|
98
|
+
store.pendingRequests.cancelAll();
|
|
99
|
+
} else if (event.key === 'Enter') {
|
|
100
|
+
// No active item, so we let the browser handle the native `onSubmit` form
|
|
101
|
+
// event.
|
|
102
|
+
if (store.getState().activeItemId === null || store.getState().collections.every(function (collection) {
|
|
103
|
+
return collection.items.length === 0;
|
|
104
|
+
})) {
|
|
105
|
+
var waitForSubmit = getPluginSubmitPromise(props.plugins, store.pendingRequests);
|
|
106
|
+
if (waitForSubmit !== undefined) {
|
|
107
|
+
waitForSubmit.then(store.pendingRequests.cancelAll); // Cancel the rest if timeout number is provided
|
|
108
|
+
} else if (!props.debug) {
|
|
109
|
+
// If requests are still pending when the panel closes, they could reopen
|
|
110
|
+
// the panel once they resolve.
|
|
111
|
+
// We want to prevent any subsequent query from reopening the panel
|
|
112
|
+
// because it would result in an unsolicited UI behavior.
|
|
113
|
+
store.pendingRequests.cancelAll();
|
|
114
|
+
}
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// This prevents the `onSubmit` event to be sent because an item is
|
|
119
|
+
// highlighted.
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
var _ref2 = getActiveItem(store.getState()),
|
|
122
|
+
item = _ref2.item,
|
|
123
|
+
itemInputValue = _ref2.itemInputValue,
|
|
124
|
+
itemUrl = _ref2.itemUrl,
|
|
125
|
+
source = _ref2.source;
|
|
126
|
+
if (event.metaKey || event.ctrlKey) {
|
|
127
|
+
if (itemUrl !== undefined) {
|
|
128
|
+
source.onSelect(_objectSpread({
|
|
129
|
+
event: event,
|
|
130
|
+
item: item,
|
|
131
|
+
itemInputValue: itemInputValue,
|
|
132
|
+
itemUrl: itemUrl,
|
|
133
|
+
refresh: refresh,
|
|
134
|
+
source: source,
|
|
135
|
+
state: store.getState()
|
|
136
|
+
}, setters));
|
|
137
|
+
props.navigator.navigateNewTab({
|
|
138
|
+
itemUrl: itemUrl,
|
|
139
|
+
item: item,
|
|
140
|
+
state: store.getState()
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
} else if (event.shiftKey) {
|
|
144
|
+
if (itemUrl !== undefined) {
|
|
145
|
+
source.onSelect(_objectSpread({
|
|
146
|
+
event: event,
|
|
147
|
+
item: item,
|
|
148
|
+
itemInputValue: itemInputValue,
|
|
149
|
+
itemUrl: itemUrl,
|
|
150
|
+
refresh: refresh,
|
|
151
|
+
source: source,
|
|
152
|
+
state: store.getState()
|
|
153
|
+
}, setters));
|
|
154
|
+
props.navigator.navigateNewWindow({
|
|
155
|
+
itemUrl: itemUrl,
|
|
156
|
+
item: item,
|
|
157
|
+
state: store.getState()
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
} else if (event.altKey) ; else {
|
|
161
|
+
if (itemUrl !== undefined) {
|
|
162
|
+
source.onSelect(_objectSpread({
|
|
163
|
+
event: event,
|
|
164
|
+
item: item,
|
|
165
|
+
itemInputValue: itemInputValue,
|
|
166
|
+
itemUrl: itemUrl,
|
|
167
|
+
refresh: refresh,
|
|
168
|
+
source: source,
|
|
169
|
+
state: store.getState()
|
|
170
|
+
}, setters));
|
|
171
|
+
props.navigator.navigate({
|
|
172
|
+
itemUrl: itemUrl,
|
|
173
|
+
item: item,
|
|
174
|
+
state: store.getState()
|
|
175
|
+
});
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
onInput(_objectSpread({
|
|
179
|
+
event: event,
|
|
180
|
+
nextState: {
|
|
181
|
+
isOpen: false
|
|
182
|
+
},
|
|
183
|
+
props: props,
|
|
184
|
+
query: itemInputValue,
|
|
185
|
+
refresh: refresh,
|
|
186
|
+
store: store
|
|
187
|
+
}, setters)).then(function () {
|
|
188
|
+
source.onSelect(_objectSpread({
|
|
189
|
+
event: event,
|
|
190
|
+
item: item,
|
|
191
|
+
itemInputValue: itemInputValue,
|
|
192
|
+
itemUrl: itemUrl,
|
|
193
|
+
refresh: refresh,
|
|
194
|
+
source: source,
|
|
195
|
+
state: store.getState()
|
|
196
|
+
}, setters));
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export { onKeyDown };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { flatten } from '../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/flatten.js';
|
|
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
|
+
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; }
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), true).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; }
|
|
6
|
+
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; }
|
|
7
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
8
|
+
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); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
9
|
+
function reshape(_ref) {
|
|
10
|
+
var collections = _ref.collections,
|
|
11
|
+
props = _ref.props,
|
|
12
|
+
state = _ref.state;
|
|
13
|
+
// Sources are grouped by `sourceId` to conveniently pick them via destructuring.
|
|
14
|
+
// Example: `const { recentSearchesPlugin } = sourcesBySourceId`
|
|
15
|
+
var originalSourcesBySourceId = collections.reduce(function (acc, collection) {
|
|
16
|
+
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, collection.source.sourceId, _objectSpread(_objectSpread({}, collection.source), {}, {
|
|
17
|
+
getItems: function getItems() {
|
|
18
|
+
// We provide the resolved items from the collection to the `reshape` prop.
|
|
19
|
+
return flatten(collection.items);
|
|
20
|
+
}
|
|
21
|
+
})));
|
|
22
|
+
}, {});
|
|
23
|
+
var _props$plugins$reduce = props.plugins.reduce(function (acc, plugin) {
|
|
24
|
+
if (plugin.reshape) {
|
|
25
|
+
return plugin.reshape(acc);
|
|
26
|
+
}
|
|
27
|
+
return acc;
|
|
28
|
+
}, {
|
|
29
|
+
sourcesBySourceId: originalSourcesBySourceId,
|
|
30
|
+
state: state
|
|
31
|
+
}),
|
|
32
|
+
sourcesBySourceId = _props$plugins$reduce.sourcesBySourceId;
|
|
33
|
+
var reshapeSources = props.reshape({
|
|
34
|
+
sourcesBySourceId: sourcesBySourceId,
|
|
35
|
+
sources: Object.values(sourcesBySourceId),
|
|
36
|
+
state: state
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// We reconstruct the collections with the items modified by the `reshape` prop.
|
|
40
|
+
return flatten(reshapeSources).filter(Boolean).map(function (source) {
|
|
41
|
+
return {
|
|
42
|
+
source: source,
|
|
43
|
+
items: source.getItems()
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { reshape };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { mapToAlgoliaResponse } from './utils/mapToAlgoliaResponse.js';
|
|
2
|
+
import { flatten } from '../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/flatten.js';
|
|
3
|
+
import { invariant } from '../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/invariant.js';
|
|
4
|
+
import { decycle } from '../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/decycle.js';
|
|
5
|
+
|
|
6
|
+
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); }
|
|
7
|
+
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; }
|
|
8
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), true).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; }
|
|
9
|
+
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; }
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
11
|
+
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); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
13
|
+
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."); }
|
|
14
|
+
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); }
|
|
15
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
16
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
17
|
+
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; }
|
|
18
|
+
function isDescription(item) {
|
|
19
|
+
return Boolean(item.execute);
|
|
20
|
+
}
|
|
21
|
+
function isRequesterDescription(description) {
|
|
22
|
+
return Boolean(description === null || description === void 0 ? void 0 : description.execute);
|
|
23
|
+
}
|
|
24
|
+
function preResolve(itemsOrDescription, sourceId, state) {
|
|
25
|
+
if (isRequesterDescription(itemsOrDescription)) {
|
|
26
|
+
var contextParameters = itemsOrDescription.requesterId === 'algolia' ? Object.assign.apply(Object, [{}].concat(_toConsumableArray(Object.keys(state.context).map(function (key) {
|
|
27
|
+
var _state$context$key;
|
|
28
|
+
return (_state$context$key = state.context[key]) === null || _state$context$key === void 0 ? void 0 : _state$context$key.__algoliaSearchParameters;
|
|
29
|
+
})))) : {};
|
|
30
|
+
return _objectSpread(_objectSpread({}, itemsOrDescription), {}, {
|
|
31
|
+
requests: itemsOrDescription.queries.map(function (query) {
|
|
32
|
+
return {
|
|
33
|
+
query: itemsOrDescription.requesterId === 'algolia' ? _objectSpread(_objectSpread({}, query), {}, {
|
|
34
|
+
params: _objectSpread(_objectSpread({}, contextParameters), query.params)
|
|
35
|
+
}) : query,
|
|
36
|
+
sourceId: sourceId,
|
|
37
|
+
transformResponse: itemsOrDescription.transformResponse
|
|
38
|
+
};
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
items: itemsOrDescription,
|
|
44
|
+
sourceId: sourceId
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function resolve(items) {
|
|
48
|
+
var packed = items.reduce(function (acc, current) {
|
|
49
|
+
if (!isDescription(current)) {
|
|
50
|
+
acc.push(current);
|
|
51
|
+
return acc;
|
|
52
|
+
}
|
|
53
|
+
var searchClient = current.searchClient,
|
|
54
|
+
execute = current.execute,
|
|
55
|
+
requesterId = current.requesterId,
|
|
56
|
+
requests = current.requests;
|
|
57
|
+
var container = acc.find(function (item) {
|
|
58
|
+
return isDescription(current) && isDescription(item) && item.searchClient === searchClient && Boolean(requesterId) && item.requesterId === requesterId;
|
|
59
|
+
});
|
|
60
|
+
if (container) {
|
|
61
|
+
var _container$items;
|
|
62
|
+
(_container$items = container.items).push.apply(_container$items, _toConsumableArray(requests));
|
|
63
|
+
} else {
|
|
64
|
+
var request = {
|
|
65
|
+
execute: execute,
|
|
66
|
+
requesterId: requesterId,
|
|
67
|
+
items: requests,
|
|
68
|
+
searchClient: searchClient
|
|
69
|
+
};
|
|
70
|
+
acc.push(request);
|
|
71
|
+
}
|
|
72
|
+
return acc;
|
|
73
|
+
}, []);
|
|
74
|
+
var values = packed.map(function (maybeDescription) {
|
|
75
|
+
if (!isDescription(maybeDescription)) {
|
|
76
|
+
return Promise.resolve(maybeDescription);
|
|
77
|
+
}
|
|
78
|
+
var _ref = maybeDescription,
|
|
79
|
+
execute = _ref.execute,
|
|
80
|
+
items = _ref.items,
|
|
81
|
+
searchClient = _ref.searchClient;
|
|
82
|
+
return execute({
|
|
83
|
+
searchClient: searchClient,
|
|
84
|
+
requests: items
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
return Promise.all(values).then(function (responses) {
|
|
88
|
+
return flatten(responses);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function postResolve(responses, sources, store) {
|
|
92
|
+
return sources.map(function (source) {
|
|
93
|
+
var matches = responses.filter(function (response) {
|
|
94
|
+
return response.sourceId === source.sourceId;
|
|
95
|
+
});
|
|
96
|
+
var results = matches.map(function (_ref2) {
|
|
97
|
+
var items = _ref2.items;
|
|
98
|
+
return items;
|
|
99
|
+
});
|
|
100
|
+
var transform = matches[0].transformResponse;
|
|
101
|
+
var items = transform ? transform(mapToAlgoliaResponse(results)) : results;
|
|
102
|
+
source.onResolve({
|
|
103
|
+
source: source,
|
|
104
|
+
results: results,
|
|
105
|
+
items: items,
|
|
106
|
+
state: store.getState()
|
|
107
|
+
});
|
|
108
|
+
invariant(Array.isArray(items), function () {
|
|
109
|
+
return "The `getItems` function from source \"".concat(source.sourceId, "\" must return an array of items but returned type ").concat(JSON.stringify(_typeof(items)), ":\n\n").concat(JSON.stringify(decycle(items), null, 2), ".\n\nSee: https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/sources/#param-getitems");
|
|
110
|
+
});
|
|
111
|
+
invariant(items.every(Boolean), "The `getItems` function from source \"".concat(source.sourceId, "\" must return an array of items but returned ").concat(JSON.stringify(undefined), ".\n\nDid you forget to return items?\n\nSee: https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/sources/#param-getitems"));
|
|
112
|
+
return {
|
|
113
|
+
source: source,
|
|
114
|
+
items: items
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export { postResolve, preResolve, resolve };
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { getCompletion } from './getCompletion.js';
|
|
2
|
+
import { getNextActiveItemId } from './utils/getNextActiveItemId.js';
|
|
3
|
+
import { invariant } from '../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/invariant.js';
|
|
4
|
+
import { getItemsCount } from '../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/getItemsCount.js';
|
|
5
|
+
|
|
6
|
+
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); }
|
|
7
|
+
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; }
|
|
8
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), true).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; }
|
|
9
|
+
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; }
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
11
|
+
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); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
|
+
var stateReducer = function stateReducer(state, action) {
|
|
13
|
+
switch (action.type) {
|
|
14
|
+
case 'setActiveItemId':
|
|
15
|
+
{
|
|
16
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
17
|
+
activeItemId: action.payload
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
case 'setQuery':
|
|
21
|
+
{
|
|
22
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
23
|
+
query: action.payload,
|
|
24
|
+
completion: null
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
case 'setCollections':
|
|
28
|
+
{
|
|
29
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
30
|
+
collections: action.payload
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
case 'setIsOpen':
|
|
34
|
+
{
|
|
35
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
36
|
+
isOpen: action.payload
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
case 'setStatus':
|
|
40
|
+
{
|
|
41
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
42
|
+
status: action.payload
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
case 'setContext':
|
|
46
|
+
{
|
|
47
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
48
|
+
context: _objectSpread(_objectSpread({}, state.context), action.payload)
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
case 'ArrowDown':
|
|
52
|
+
{
|
|
53
|
+
var nextState = _objectSpread(_objectSpread({}, state), {}, {
|
|
54
|
+
activeItemId: action.payload.hasOwnProperty('nextActiveItemId') ? action.payload.nextActiveItemId : getNextActiveItemId(1, state.activeItemId, getItemsCount(state), action.props.defaultActiveItemId)
|
|
55
|
+
});
|
|
56
|
+
return _objectSpread(_objectSpread({}, nextState), {}, {
|
|
57
|
+
completion: getCompletion({
|
|
58
|
+
state: nextState
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
case 'ArrowUp':
|
|
63
|
+
{
|
|
64
|
+
var _nextState = _objectSpread(_objectSpread({}, state), {}, {
|
|
65
|
+
activeItemId: getNextActiveItemId(-1, state.activeItemId, getItemsCount(state), action.props.defaultActiveItemId)
|
|
66
|
+
});
|
|
67
|
+
return _objectSpread(_objectSpread({}, _nextState), {}, {
|
|
68
|
+
completion: getCompletion({
|
|
69
|
+
state: _nextState
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
case 'Escape':
|
|
74
|
+
{
|
|
75
|
+
if (state.isOpen) {
|
|
76
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
77
|
+
activeItemId: null,
|
|
78
|
+
isOpen: false,
|
|
79
|
+
completion: null
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
83
|
+
activeItemId: null,
|
|
84
|
+
query: '',
|
|
85
|
+
status: 'idle',
|
|
86
|
+
collections: []
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
case 'submit':
|
|
90
|
+
{
|
|
91
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
92
|
+
activeItemId: null,
|
|
93
|
+
isOpen: false,
|
|
94
|
+
status: 'idle'
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
case 'reset':
|
|
98
|
+
{
|
|
99
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
100
|
+
activeItemId:
|
|
101
|
+
// Since we open the panel on reset when openOnFocus=true
|
|
102
|
+
// we need to restore the highlighted index to the defaultActiveItemId. (DocSearch use-case)
|
|
103
|
+
|
|
104
|
+
// Since we close the panel when openOnFocus=false
|
|
105
|
+
// we lose track of the highlighted index. (Query-suggestions use-case)
|
|
106
|
+
action.props.openOnFocus === true ? action.props.defaultActiveItemId : null,
|
|
107
|
+
status: 'idle',
|
|
108
|
+
completion: null,
|
|
109
|
+
query: ''
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
case 'focus':
|
|
113
|
+
{
|
|
114
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
115
|
+
activeItemId: action.props.defaultActiveItemId,
|
|
116
|
+
isOpen: (action.props.openOnFocus || Boolean(state.query)) && action.props.shouldPanelOpen({
|
|
117
|
+
state: state
|
|
118
|
+
})
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
case 'blur':
|
|
122
|
+
{
|
|
123
|
+
if (action.props.debug) {
|
|
124
|
+
return state;
|
|
125
|
+
}
|
|
126
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
127
|
+
isOpen: false,
|
|
128
|
+
activeItemId: null
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
case 'mousemove':
|
|
132
|
+
{
|
|
133
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
134
|
+
activeItemId: action.payload
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
case 'mouseleave':
|
|
138
|
+
{
|
|
139
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
140
|
+
activeItemId: action.props.defaultActiveItemId
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
default:
|
|
144
|
+
invariant(false, "The reducer action ".concat(JSON.stringify(action.type), " is not supported."));
|
|
145
|
+
return state;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export { stateReducer };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
function createInternalCancelablePromise(promise, initialState) {
|
|
2
|
+
var state = initialState;
|
|
3
|
+
return {
|
|
4
|
+
then: function then(onfulfilled, onrejected) {
|
|
5
|
+
return createInternalCancelablePromise(promise.then(createCallback(onfulfilled, state, promise), createCallback(onrejected, state, promise)), state);
|
|
6
|
+
},
|
|
7
|
+
catch: function _catch(onrejected) {
|
|
8
|
+
return createInternalCancelablePromise(promise.catch(createCallback(onrejected, state, promise)), state);
|
|
9
|
+
},
|
|
10
|
+
finally: function _finally(onfinally) {
|
|
11
|
+
if (onfinally) {
|
|
12
|
+
state.onCancelList.push(onfinally);
|
|
13
|
+
}
|
|
14
|
+
return createInternalCancelablePromise(promise.finally(createCallback(onfinally && function () {
|
|
15
|
+
state.onCancelList = [];
|
|
16
|
+
return onfinally();
|
|
17
|
+
}, state, promise)), state);
|
|
18
|
+
},
|
|
19
|
+
cancel: function cancel() {
|
|
20
|
+
state.isCanceled = true;
|
|
21
|
+
var callbacks = state.onCancelList;
|
|
22
|
+
state.onCancelList = [];
|
|
23
|
+
callbacks.forEach(function (callback) {
|
|
24
|
+
callback();
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
isCanceled: function isCanceled() {
|
|
28
|
+
return state.isCanceled === true;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function cancelable(promise) {
|
|
33
|
+
return createInternalCancelablePromise(promise, {
|
|
34
|
+
isCanceled: false,
|
|
35
|
+
onCancelList: []
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function createCallback(onResult, state, fallback) {
|
|
39
|
+
if (!onResult) {
|
|
40
|
+
return fallback;
|
|
41
|
+
}
|
|
42
|
+
return function callback(arg) {
|
|
43
|
+
if (state.isCanceled) {
|
|
44
|
+
return arg;
|
|
45
|
+
}
|
|
46
|
+
return onResult(arg);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { cancelable };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Ensures multiple callers sync to the same promise.
|
|
2
|
+
var _hasWaitPromiseResolved = true;
|
|
3
|
+
var _waitPromise;
|
|
4
|
+
function createCancelablePromiseList() {
|
|
5
|
+
var list = [];
|
|
6
|
+
return {
|
|
7
|
+
add: function add(cancelablePromise) {
|
|
8
|
+
list.push(cancelablePromise);
|
|
9
|
+
return cancelablePromise.finally(function () {
|
|
10
|
+
list = list.filter(function (item) {
|
|
11
|
+
return item !== cancelablePromise;
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
},
|
|
15
|
+
cancelAll: function cancelAll() {
|
|
16
|
+
list.forEach(function (promise) {
|
|
17
|
+
return promise.cancel();
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
isEmpty: function isEmpty() {
|
|
21
|
+
return list.length === 0;
|
|
22
|
+
},
|
|
23
|
+
wait: function wait(timeout) {
|
|
24
|
+
// Reuse promise if already exists. Keeps multiple callers subscribed to the same promise.
|
|
25
|
+
if (!_hasWaitPromiseResolved) {
|
|
26
|
+
return _waitPromise;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Creates a promise which either resolves after all pending requests complete
|
|
30
|
+
// or the timeout is reached (if provided). Whichever comes first.
|
|
31
|
+
_hasWaitPromiseResolved = false;
|
|
32
|
+
_waitPromise = !timeout ? Promise.all(list) : Promise.race([Promise.all(list), new Promise(function (resolve) {
|
|
33
|
+
return setTimeout(resolve, timeout);
|
|
34
|
+
})]);
|
|
35
|
+
return _waitPromise.then(function () {
|
|
36
|
+
_hasWaitPromiseResolved = true;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { createCancelablePromiseList };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a runner that executes promises in a concurrent-safe way.
|
|
3
|
+
*
|
|
4
|
+
* This is useful to prevent older promises to resolve after a newer promise,
|
|
5
|
+
* otherwise resulting in stale resolved values.
|
|
6
|
+
*/
|
|
7
|
+
function createConcurrentSafePromise() {
|
|
8
|
+
var basePromiseId = -1;
|
|
9
|
+
var latestResolvedId = -1;
|
|
10
|
+
var latestResolvedValue = undefined;
|
|
11
|
+
return function runConcurrentSafePromise(promise) {
|
|
12
|
+
basePromiseId++;
|
|
13
|
+
var currentPromiseId = basePromiseId;
|
|
14
|
+
return Promise.resolve(promise).then(function (x) {
|
|
15
|
+
// The promise might take too long to resolve and get outdated. This would
|
|
16
|
+
// result in resolving stale values.
|
|
17
|
+
// When this happens, we ignore the promise value and return the one
|
|
18
|
+
// coming from the latest resolved value.
|
|
19
|
+
//
|
|
20
|
+
// +----------------------------------+
|
|
21
|
+
// | 100ms |
|
|
22
|
+
// | run(1) +---> R1 |
|
|
23
|
+
// | 300ms |
|
|
24
|
+
// | run(2) +-------------> R2 (SKIP) |
|
|
25
|
+
// | 200ms |
|
|
26
|
+
// | run(3) +--------> R3 |
|
|
27
|
+
// +----------------------------------+
|
|
28
|
+
if (latestResolvedValue && currentPromiseId < latestResolvedId) {
|
|
29
|
+
return latestResolvedValue;
|
|
30
|
+
}
|
|
31
|
+
latestResolvedId = currentPromiseId;
|
|
32
|
+
latestResolvedValue = x;
|
|
33
|
+
return x;
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { createConcurrentSafePromise };
|