@algolia/autocomplete-shared 1.8.3 → 1.9.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/esm/core/AutocompleteApi.d.ts +15 -0
- package/dist/esm/core/AutocompleteApi.js +1 -0
- package/dist/esm/core/AutocompleteCollection.d.ts +10 -0
- package/dist/esm/core/AutocompleteCollection.js +1 -0
- package/dist/esm/core/AutocompleteContext.d.ts +3 -0
- package/dist/esm/core/AutocompleteContext.js +1 -0
- package/dist/esm/core/AutocompleteEnvironment.d.ts +13 -0
- package/dist/esm/core/AutocompleteEnvironment.js +1 -0
- package/dist/esm/core/AutocompleteNavigator.d.ts +28 -0
- package/dist/esm/core/AutocompleteNavigator.js +1 -0
- package/dist/esm/core/AutocompleteOptions.d.ts +185 -0
- package/dist/esm/core/AutocompleteOptions.js +1 -0
- package/dist/esm/core/AutocompletePlugin.d.ts +43 -0
- package/dist/esm/core/AutocompletePlugin.js +1 -0
- package/dist/esm/core/AutocompletePropGetters.d.ts +100 -0
- package/dist/esm/core/AutocompletePropGetters.js +1 -0
- package/dist/esm/core/AutocompleteReshape.d.ts +25 -0
- package/dist/esm/core/AutocompleteReshape.js +1 -0
- package/dist/esm/core/AutocompleteSetters.d.ts +46 -0
- package/dist/esm/core/AutocompleteSetters.js +1 -0
- package/dist/esm/core/AutocompleteSource.d.ts +76 -0
- package/dist/esm/core/AutocompleteSource.js +1 -0
- package/dist/esm/core/AutocompleteState.d.ts +12 -0
- package/dist/esm/core/AutocompleteState.js +1 -0
- package/dist/esm/core/index.d.ts +11 -0
- package/dist/esm/core/index.js +11 -0
- package/dist/esm/debounce.js +0 -2
- package/dist/esm/decycle.js +4 -17
- package/dist/esm/getItemsCount.js +0 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +3 -1
- package/dist/esm/invariant.js +0 -1
- package/dist/esm/isEqual.js +0 -7
- package/dist/esm/js/AutocompleteClassNames.d.ts +28 -0
- package/dist/esm/js/AutocompleteClassNames.js +1 -0
- package/dist/esm/js/AutocompleteCollection.d.ts +6 -0
- package/dist/esm/js/AutocompleteCollection.js +1 -0
- package/dist/esm/js/AutocompleteComponents.d.ts +23 -0
- package/dist/esm/js/AutocompleteComponents.js +1 -0
- package/dist/esm/js/AutocompleteOptions.d.ts +106 -0
- package/dist/esm/js/AutocompleteOptions.js +1 -0
- package/dist/esm/js/AutocompletePlugin.d.ts +13 -0
- package/dist/esm/js/AutocompletePlugin.js +1 -0
- package/dist/esm/js/AutocompletePropGetters.d.ts +33 -0
- package/dist/esm/js/AutocompletePropGetters.js +1 -0
- package/dist/esm/js/AutocompleteRender.d.ts +15 -0
- package/dist/esm/js/AutocompleteRender.js +1 -0
- package/dist/esm/js/AutocompleteRenderer.d.ts +33 -0
- package/dist/esm/js/AutocompleteRenderer.js +1 -0
- package/dist/esm/js/AutocompleteSource.d.ts +74 -0
- package/dist/esm/js/AutocompleteSource.js +1 -0
- package/dist/esm/js/AutocompleteState.d.ts +10 -0
- package/dist/esm/js/AutocompleteState.js +1 -0
- package/dist/esm/js/AutocompleteTranslations.d.ts +5 -0
- package/dist/esm/js/AutocompleteTranslations.js +1 -0
- package/dist/esm/js/HighlightHitParams.d.ts +18 -0
- package/dist/esm/js/HighlightHitParams.js +1 -0
- package/dist/esm/js/index.d.ts +12 -0
- package/dist/esm/js/index.js +12 -0
- package/dist/esm/preset-algolia/algoliasearch.d.ts +54 -0
- package/dist/esm/preset-algolia/algoliasearch.js +1 -0
- package/dist/esm/preset-algolia/createRequester.d.ts +89 -0
- package/dist/esm/preset-algolia/createRequester.js +1 -0
- package/dist/esm/safelyRunOnBrowser.d.ts +8 -0
- package/dist/esm/safelyRunOnBrowser.js +11 -0
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/warn.js +3 -5
- package/package.json +9 -1
package/dist/esm/decycle.js
CHANGED
|
@@ -1,45 +1,32 @@
|
|
|
1
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
-
|
|
3
2
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
|
|
5
3
|
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); }
|
|
6
|
-
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
10
|
-
|
|
4
|
+
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; }
|
|
5
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
11
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
-
|
|
13
7
|
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); }
|
|
14
|
-
|
|
15
8
|
/**
|
|
16
9
|
* Decycles objects with circular references.
|
|
17
10
|
* This is used to print cyclic structures in development environment only.
|
|
18
11
|
*/
|
|
19
12
|
export function decycle(obj) {
|
|
20
13
|
var seen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Set();
|
|
21
|
-
|
|
22
14
|
if (!(process.env.NODE_ENV !== 'production') || !obj || _typeof(obj) !== 'object') {
|
|
23
15
|
return obj;
|
|
24
16
|
}
|
|
25
|
-
|
|
26
17
|
if (seen.has(obj)) {
|
|
27
18
|
return '[Circular]';
|
|
28
19
|
}
|
|
29
|
-
|
|
30
20
|
var newSeen = seen.add(obj);
|
|
31
|
-
|
|
32
21
|
if (Array.isArray(obj)) {
|
|
33
22
|
return obj.map(function (x) {
|
|
34
23
|
return decycle(x, newSeen);
|
|
35
24
|
});
|
|
36
25
|
}
|
|
37
|
-
|
|
38
26
|
return Object.fromEntries(Object.entries(obj).map(function (_ref) {
|
|
39
27
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
key = _ref2[0],
|
|
29
|
+
value = _ref2[1];
|
|
43
30
|
return [key, decycle(value, newSeen)];
|
|
44
31
|
}));
|
|
45
32
|
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -9,7 +9,9 @@ export * from './invariant';
|
|
|
9
9
|
export * from './isEqual';
|
|
10
10
|
export * from './MaybePromise';
|
|
11
11
|
export * from './noop';
|
|
12
|
+
export * from './safelyRunOnBrowser';
|
|
12
13
|
export * from './UserAgent';
|
|
13
14
|
export * from './userAgents';
|
|
14
15
|
export * from './version';
|
|
15
16
|
export * from './warn';
|
|
17
|
+
export * from './js';
|
package/dist/esm/index.js
CHANGED
|
@@ -9,7 +9,9 @@ export * from './invariant';
|
|
|
9
9
|
export * from './isEqual';
|
|
10
10
|
export * from './MaybePromise';
|
|
11
11
|
export * from './noop';
|
|
12
|
+
export * from './safelyRunOnBrowser';
|
|
12
13
|
export * from './UserAgent';
|
|
13
14
|
export * from './userAgents';
|
|
14
15
|
export * from './version';
|
|
15
|
-
export * from './warn';
|
|
16
|
+
export * from './warn';
|
|
17
|
+
export * from './js';
|
package/dist/esm/invariant.js
CHANGED
package/dist/esm/isEqual.js
CHANGED
|
@@ -1,31 +1,24 @@
|
|
|
1
1
|
function isPrimitive(obj) {
|
|
2
2
|
return obj !== Object(obj);
|
|
3
3
|
}
|
|
4
|
-
|
|
5
4
|
export function isEqual(first, second) {
|
|
6
5
|
if (first === second) {
|
|
7
6
|
return true;
|
|
8
7
|
}
|
|
9
|
-
|
|
10
8
|
if (isPrimitive(first) || isPrimitive(second) || typeof first === 'function' || typeof second === 'function') {
|
|
11
9
|
return first === second;
|
|
12
10
|
}
|
|
13
|
-
|
|
14
11
|
if (Object.keys(first).length !== Object.keys(second).length) {
|
|
15
12
|
return false;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
for (var _i = 0, _Object$keys = Object.keys(first); _i < _Object$keys.length; _i++) {
|
|
19
15
|
var key = _Object$keys[_i];
|
|
20
|
-
|
|
21
16
|
if (!(key in second)) {
|
|
22
17
|
return false;
|
|
23
18
|
}
|
|
24
|
-
|
|
25
19
|
if (!isEqual(first[key], second[key])) {
|
|
26
20
|
return false;
|
|
27
21
|
}
|
|
28
22
|
}
|
|
29
|
-
|
|
30
23
|
return true;
|
|
31
24
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare type AutocompleteClassNames = {
|
|
2
|
+
detachedCancelButton: string;
|
|
3
|
+
detachedFormContainer: string;
|
|
4
|
+
detachedContainer: string;
|
|
5
|
+
detachedOverlay: string;
|
|
6
|
+
detachedSearchButton: string;
|
|
7
|
+
detachedSearchButtonIcon: string;
|
|
8
|
+
detachedSearchButtonPlaceholder: string;
|
|
9
|
+
detachedSearchButtonQuery: string;
|
|
10
|
+
form: string;
|
|
11
|
+
input: string;
|
|
12
|
+
inputWrapper: string;
|
|
13
|
+
inputWrapperPrefix: string;
|
|
14
|
+
inputWrapperSuffix: string;
|
|
15
|
+
item: string;
|
|
16
|
+
label: string;
|
|
17
|
+
list: string;
|
|
18
|
+
loadingIndicator: string;
|
|
19
|
+
panel: string;
|
|
20
|
+
panelLayout: string;
|
|
21
|
+
clearButton: string;
|
|
22
|
+
root: string;
|
|
23
|
+
source: string;
|
|
24
|
+
sourceFooter: string;
|
|
25
|
+
sourceHeader: string;
|
|
26
|
+
sourceNoResults: string;
|
|
27
|
+
submitButton: string;
|
|
28
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { HighlightHitParams } from './HighlightHitParams';
|
|
3
|
+
declare type AutocompleteHighlightComponent = <THit>({ hit, attribute, tagName, }: HighlightHitParams<THit>) => JSX.Element;
|
|
4
|
+
export declare type PublicAutocompleteComponents = Record<string, (props: any) => JSX.Element>;
|
|
5
|
+
export interface AutocompleteComponents extends PublicAutocompleteComponents {
|
|
6
|
+
/**
|
|
7
|
+
* Highlight matches in an Algolia hit.
|
|
8
|
+
*/
|
|
9
|
+
Highlight: AutocompleteHighlightComponent;
|
|
10
|
+
/**
|
|
11
|
+
* Reverse-highlight matches in an Algolia hit.
|
|
12
|
+
*/
|
|
13
|
+
ReverseHighlight: AutocompleteHighlightComponent;
|
|
14
|
+
/**
|
|
15
|
+
* Reverse-highlight and snippets matches in an Algolia hit.
|
|
16
|
+
*/
|
|
17
|
+
ReverseSnippet: AutocompleteHighlightComponent;
|
|
18
|
+
/**
|
|
19
|
+
* Highlight and snippet matches in an Algolia hit.
|
|
20
|
+
*/
|
|
21
|
+
Snippet: AutocompleteHighlightComponent;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { AutocompleteScopeApi, AutocompleteOptions as AutocompleteCoreOptions, BaseItem, GetSourcesParams } from '../core';
|
|
2
|
+
import { MaybePromise } from '../MaybePromise';
|
|
3
|
+
import { AutocompleteClassNames } from './AutocompleteClassNames';
|
|
4
|
+
import { PublicAutocompleteComponents } from './AutocompleteComponents';
|
|
5
|
+
import { AutocompletePlugin } from './AutocompletePlugin';
|
|
6
|
+
import { AutocompletePropGetters } from './AutocompletePropGetters';
|
|
7
|
+
import { AutocompleteRender } from './AutocompleteRender';
|
|
8
|
+
import { AutocompleteRenderer } from './AutocompleteRenderer';
|
|
9
|
+
import { AutocompleteSource } from './AutocompleteSource';
|
|
10
|
+
import { AutocompleteState } from './AutocompleteState';
|
|
11
|
+
import { AutocompleteTranslations } from './AutocompleteTranslations';
|
|
12
|
+
export interface OnStateChangeProps<TItem extends BaseItem> extends AutocompleteScopeApi<TItem> {
|
|
13
|
+
/**
|
|
14
|
+
* The current Autocomplete state.
|
|
15
|
+
*/
|
|
16
|
+
state: AutocompleteState<TItem>;
|
|
17
|
+
/**
|
|
18
|
+
* The previous Autocomplete state.
|
|
19
|
+
*/
|
|
20
|
+
prevState: AutocompleteState<TItem>;
|
|
21
|
+
}
|
|
22
|
+
export declare type GetSources<TItem extends BaseItem> = (params: GetSourcesParams<TItem>) => MaybePromise<Array<AutocompleteSource<TItem> | boolean | undefined>>;
|
|
23
|
+
export interface AutocompleteOptions<TItem extends BaseItem> extends AutocompleteCoreOptions<TItem>, Partial<AutocompletePropGetters<TItem>> {
|
|
24
|
+
/**
|
|
25
|
+
* The container for the Autocomplete search box.
|
|
26
|
+
*
|
|
27
|
+
* You can either pass a [CSS selector](https://developer.mozilla.org/docs/Web/CSS/CSS_Selectors) or an [Element](https://developer.mozilla.org/docs/Web/API/HTMLElement). If there are several containers matching the selector, Autocomplete picks up the first one.
|
|
28
|
+
*
|
|
29
|
+
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-container
|
|
30
|
+
*/
|
|
31
|
+
container: string | HTMLElement;
|
|
32
|
+
/**
|
|
33
|
+
* The container for the Autocomplete panel.
|
|
34
|
+
*
|
|
35
|
+
* You can either pass a [CSS selector](https://developer.mozilla.org/docs/Web/CSS/CSS_Selectors) or an [Element](https://developer.mozilla.org/docs/Web/API/HTMLElement). If there are several containers matching the selector, Autocomplete picks up the first one.
|
|
36
|
+
*
|
|
37
|
+
* @default document.body
|
|
38
|
+
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-panelcontainer
|
|
39
|
+
*/
|
|
40
|
+
panelContainer?: string | HTMLElement;
|
|
41
|
+
/**
|
|
42
|
+
* The Media Query to turn Autocomplete into a detached experience.
|
|
43
|
+
*
|
|
44
|
+
* @default "(max-width: 680px)"
|
|
45
|
+
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-detachedmediaquery
|
|
46
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries
|
|
47
|
+
*/
|
|
48
|
+
detachedMediaQuery?: string;
|
|
49
|
+
getSources?: GetSources<TItem>;
|
|
50
|
+
/**
|
|
51
|
+
* The panel's horizontal position.
|
|
52
|
+
*
|
|
53
|
+
* @default "input-wrapper-width"
|
|
54
|
+
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-panelplacement
|
|
55
|
+
*/
|
|
56
|
+
panelPlacement?: 'start' | 'end' | 'full-width' | 'input-wrapper-width';
|
|
57
|
+
/**
|
|
58
|
+
* Class names to inject for each created DOM element.
|
|
59
|
+
*
|
|
60
|
+
* This is useful to style your autocomplete with external CSS frameworks.
|
|
61
|
+
*
|
|
62
|
+
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-classnames
|
|
63
|
+
*/
|
|
64
|
+
classNames?: Partial<AutocompleteClassNames>;
|
|
65
|
+
/**
|
|
66
|
+
* The function that renders the autocomplete panel.
|
|
67
|
+
*
|
|
68
|
+
* This is useful to customize the rendering, for example, using multi-row or multi-column layouts.
|
|
69
|
+
*
|
|
70
|
+
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-render
|
|
71
|
+
*/
|
|
72
|
+
render?: AutocompleteRender<TItem>;
|
|
73
|
+
/**
|
|
74
|
+
* The function that renders a no results section when there are no hits.
|
|
75
|
+
*
|
|
76
|
+
* This is useful to let the user know that the query returned no results.
|
|
77
|
+
*
|
|
78
|
+
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-rendernoresults
|
|
79
|
+
*/
|
|
80
|
+
renderNoResults?: AutocompleteRender<TItem>;
|
|
81
|
+
initialState?: Partial<AutocompleteState<TItem>>;
|
|
82
|
+
onStateChange?(props: OnStateChangeProps<TItem>): void;
|
|
83
|
+
/**
|
|
84
|
+
* The virtual DOM implementation to plug to Autocomplete. It defaults to Preact.
|
|
85
|
+
*
|
|
86
|
+
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-renderer
|
|
87
|
+
*/
|
|
88
|
+
renderer?: AutocompleteRenderer;
|
|
89
|
+
plugins?: Array<AutocompletePlugin<any, any>>;
|
|
90
|
+
/**
|
|
91
|
+
* Components to register in the Autocomplete rendering lifecycles.
|
|
92
|
+
*
|
|
93
|
+
* Registered components become available in [`templates`](https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/templates/), [`render`](https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-render), and in [`renderNoResults`](https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-rendernoresults).
|
|
94
|
+
*
|
|
95
|
+
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-components
|
|
96
|
+
*/
|
|
97
|
+
components?: PublicAutocompleteComponents;
|
|
98
|
+
/**
|
|
99
|
+
* A mapping of translation strings.
|
|
100
|
+
*
|
|
101
|
+
* Defaults to English values.
|
|
102
|
+
*
|
|
103
|
+
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-translations
|
|
104
|
+
*/
|
|
105
|
+
translations?: Partial<AutocompleteTranslations>;
|
|
106
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseItem } from '../core';
|
|
2
|
+
import { AutocompletePlugin as AutocompleteCorePlugin } from '../core/AutocompletePlugin';
|
|
3
|
+
import { AutocompleteOptions } from './AutocompleteOptions';
|
|
4
|
+
export declare type AutocompletePlugin<TItem extends BaseItem, TData> = Omit<AutocompleteCorePlugin<TItem, TData>, 'getSources'> & {
|
|
5
|
+
/**
|
|
6
|
+
* The [sources](https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/sources/) to get the suggestions from.
|
|
7
|
+
*
|
|
8
|
+
* When defined, they’re merged with the sources of your Autocomplete instance.
|
|
9
|
+
*
|
|
10
|
+
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/plugins/#param-getsources
|
|
11
|
+
*/
|
|
12
|
+
getSources?: AutocompleteOptions<TItem>['getSources'];
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BaseItem, AutocompleteApi as AutocompleteCoreApi, AutocompleteScopeApi } from '../core';
|
|
2
|
+
import { AutocompleteState } from './AutocompleteState';
|
|
3
|
+
declare type PropsGetterParams<TItem extends BaseItem, TParam> = TParam & {
|
|
4
|
+
state: AutocompleteState<TItem>;
|
|
5
|
+
} & AutocompleteScopeApi<TItem>;
|
|
6
|
+
export declare type AutocompletePropGetters<TItem extends BaseItem> = {
|
|
7
|
+
getEnvironmentProps(params: PropsGetterParams<TItem, {
|
|
8
|
+
props: ReturnType<AutocompleteCoreApi<TItem>['getEnvironmentProps']>;
|
|
9
|
+
}>): ReturnType<AutocompleteCoreApi<TItem>['getEnvironmentProps']>;
|
|
10
|
+
getFormProps(params: PropsGetterParams<TItem, {
|
|
11
|
+
props: ReturnType<AutocompleteCoreApi<TItem>['getFormProps']>;
|
|
12
|
+
}>): ReturnType<AutocompleteCoreApi<TItem>['getFormProps']>;
|
|
13
|
+
getInputProps(params: PropsGetterParams<TItem, {
|
|
14
|
+
props: ReturnType<AutocompleteCoreApi<TItem>['getInputProps']>;
|
|
15
|
+
inputElement: HTMLInputElement;
|
|
16
|
+
}>): ReturnType<AutocompleteCoreApi<TItem>['getInputProps']>;
|
|
17
|
+
getItemProps(params: PropsGetterParams<TItem, {
|
|
18
|
+
props: ReturnType<AutocompleteCoreApi<TItem>['getItemProps']>;
|
|
19
|
+
}>): ReturnType<AutocompleteCoreApi<TItem>['getItemProps']>;
|
|
20
|
+
getLabelProps(params: PropsGetterParams<TItem, {
|
|
21
|
+
props: ReturnType<AutocompleteCoreApi<TItem>['getLabelProps']>;
|
|
22
|
+
}>): ReturnType<AutocompleteCoreApi<TItem>['getLabelProps']>;
|
|
23
|
+
getListProps(params: PropsGetterParams<TItem, {
|
|
24
|
+
props: ReturnType<AutocompleteCoreApi<TItem>['getListProps']>;
|
|
25
|
+
}>): ReturnType<AutocompleteCoreApi<TItem>['getListProps']>;
|
|
26
|
+
getPanelProps(params: PropsGetterParams<TItem, {
|
|
27
|
+
props: ReturnType<AutocompleteCoreApi<TItem>['getPanelProps']>;
|
|
28
|
+
}>): ReturnType<AutocompleteCoreApi<TItem>['getPanelProps']>;
|
|
29
|
+
getRootProps(params: PropsGetterParams<TItem, {
|
|
30
|
+
props: ReturnType<AutocompleteCoreApi<TItem>['getRootProps']>;
|
|
31
|
+
}>): ReturnType<AutocompleteCoreApi<TItem>['getRootProps']>;
|
|
32
|
+
};
|
|
33
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AutocompleteScopeApi, BaseItem } from '../core';
|
|
2
|
+
import { AutocompleteComponents } from './AutocompleteComponents';
|
|
3
|
+
import { HTMLTemplate, Pragma, PragmaFrag, Render, VNode } from './AutocompleteRenderer';
|
|
4
|
+
import { AutocompleteState } from './AutocompleteState';
|
|
5
|
+
export declare type AutocompleteRender<TItem extends BaseItem> = (params: AutocompleteScopeApi<TItem> & {
|
|
6
|
+
children: VNode;
|
|
7
|
+
state: AutocompleteState<TItem>;
|
|
8
|
+
sections: VNode[];
|
|
9
|
+
elements: Record<string, VNode>;
|
|
10
|
+
components: AutocompleteComponents;
|
|
11
|
+
createElement: Pragma;
|
|
12
|
+
Fragment: PragmaFrag;
|
|
13
|
+
html: HTMLTemplate;
|
|
14
|
+
render: Render;
|
|
15
|
+
}, root: HTMLElement) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare type Pragma = (type: any, props: Record<string, any> | null, ...children: ComponentChildren[]) => JSX.Element;
|
|
3
|
+
export declare type PragmaFrag = any;
|
|
4
|
+
declare type ComponentChild = VNode<any> | string | number | boolean | null | undefined;
|
|
5
|
+
declare type ComponentChildren = ComponentChild[] | ComponentChild;
|
|
6
|
+
export declare type VNode<TProps = {}> = {
|
|
7
|
+
type: any;
|
|
8
|
+
key: string | number | any;
|
|
9
|
+
props: TProps & {
|
|
10
|
+
children: ComponentChildren;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare type Render = (vnode: ComponentChild, parent: Element | Document | ShadowRoot | DocumentFragment, replaceNode?: Element | Text | undefined) => void;
|
|
14
|
+
export declare type AutocompleteRenderer = {
|
|
15
|
+
/**
|
|
16
|
+
* The function to create virtual nodes.
|
|
17
|
+
*
|
|
18
|
+
* @default preact.createElement
|
|
19
|
+
*/
|
|
20
|
+
createElement: Pragma;
|
|
21
|
+
/**
|
|
22
|
+
* The component to use to create fragments.
|
|
23
|
+
*
|
|
24
|
+
* @default preact.Fragment
|
|
25
|
+
*/
|
|
26
|
+
Fragment: PragmaFrag;
|
|
27
|
+
/**
|
|
28
|
+
* The function to render children to an element.
|
|
29
|
+
*/
|
|
30
|
+
render?: Render;
|
|
31
|
+
};
|
|
32
|
+
export declare type HTMLTemplate = (strings: TemplateStringsArray, ...values: any[]) => VNode | VNode[];
|
|
33
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { AutocompleteSource as AutocompleteCoreSource, InternalAutocompleteSource as InternalAutocompleteCoreSource, BaseItem } from '../core';
|
|
2
|
+
import { AutocompleteComponents } from './AutocompleteComponents';
|
|
3
|
+
import { AutocompleteRenderer, HTMLTemplate, VNode } from './AutocompleteRenderer';
|
|
4
|
+
import { AutocompleteState } from './AutocompleteState';
|
|
5
|
+
declare type Template<TParams> = (params: TParams & AutocompleteRenderer & {
|
|
6
|
+
components: AutocompleteComponents;
|
|
7
|
+
html: HTMLTemplate;
|
|
8
|
+
}) => VNode | VNode[] | string;
|
|
9
|
+
/**
|
|
10
|
+
* Templates to display in the autocomplete panel.
|
|
11
|
+
*
|
|
12
|
+
* A template can either return a string, or perform DOM mutations (manipulating DOM elements with JavaScript and attaching events) without returning a string.
|
|
13
|
+
*/
|
|
14
|
+
export declare type SourceTemplates<TItem extends BaseItem> = {
|
|
15
|
+
/**
|
|
16
|
+
* A function that returns the template for each item of the source.
|
|
17
|
+
*
|
|
18
|
+
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/templates/#param-item
|
|
19
|
+
*/
|
|
20
|
+
item: Template<{
|
|
21
|
+
item: TItem;
|
|
22
|
+
state: AutocompleteState<TItem>;
|
|
23
|
+
}>;
|
|
24
|
+
/**
|
|
25
|
+
* A function that returns the template for the header (before the list of items).
|
|
26
|
+
*
|
|
27
|
+
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/templates/#param-header
|
|
28
|
+
*/
|
|
29
|
+
header?: Template<{
|
|
30
|
+
state: AutocompleteState<TItem>;
|
|
31
|
+
source: AutocompleteSource<TItem>;
|
|
32
|
+
items: TItem[];
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* A function that returns the template for the footer (after the list of items).
|
|
36
|
+
*
|
|
37
|
+
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/templates/#param-footer
|
|
38
|
+
*/
|
|
39
|
+
footer?: Template<{
|
|
40
|
+
state: AutocompleteState<TItem>;
|
|
41
|
+
source: AutocompleteSource<TItem>;
|
|
42
|
+
items: TItem[];
|
|
43
|
+
}>;
|
|
44
|
+
/**
|
|
45
|
+
* A function that returns the template for when there are no items.
|
|
46
|
+
*
|
|
47
|
+
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/templates/#param-noresults
|
|
48
|
+
*/
|
|
49
|
+
noResults?: Template<{
|
|
50
|
+
state: AutocompleteState<TItem>;
|
|
51
|
+
source: AutocompleteSource<TItem>;
|
|
52
|
+
}>;
|
|
53
|
+
};
|
|
54
|
+
declare type WithTemplates<TType, TItem extends BaseItem> = TType & {
|
|
55
|
+
/**
|
|
56
|
+
* A set of templates to customize how sections and their items are displayed.
|
|
57
|
+
*
|
|
58
|
+
* See [**Displaying items with Templates**](templates) for more information.
|
|
59
|
+
*
|
|
60
|
+
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/sources/#param-templates
|
|
61
|
+
*/
|
|
62
|
+
templates: SourceTemplates<TItem>;
|
|
63
|
+
};
|
|
64
|
+
export interface AutocompleteCoreSourceWithDocs<TItem extends BaseItem> extends AutocompleteCoreSource<TItem> {
|
|
65
|
+
/**
|
|
66
|
+
* Unique identifier for the source.
|
|
67
|
+
*
|
|
68
|
+
* It is used as value for the `data-autocomplete-source-id` attribute of the source `section` container.
|
|
69
|
+
*/
|
|
70
|
+
sourceId: string;
|
|
71
|
+
}
|
|
72
|
+
export declare type AutocompleteSource<TItem extends BaseItem> = WithTemplates<AutocompleteCoreSourceWithDocs<TItem>, TItem>;
|
|
73
|
+
export declare type InternalAutocompleteSource<TItem extends BaseItem> = WithTemplates<InternalAutocompleteCoreSource<TItem>, TItem>;
|
|
74
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AutocompleteState as AutocompleteCoreState, BaseItem } from '../core';
|
|
2
|
+
import { AutocompleteCollection } from './AutocompleteCollection';
|
|
3
|
+
export declare type AutocompleteState<TItem extends BaseItem> = Omit<AutocompleteCoreState<TItem>, 'collections'> & {
|
|
4
|
+
/**
|
|
5
|
+
* The collections of items.
|
|
6
|
+
*
|
|
7
|
+
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/state/#param-collections
|
|
8
|
+
*/
|
|
9
|
+
collections: Array<AutocompleteCollection<TItem>>;
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare type HighlightHitParams<THit> = {
|
|
2
|
+
/**
|
|
3
|
+
* The Algolia hit whose attribute to retrieve the highlighted parts from.
|
|
4
|
+
*/
|
|
5
|
+
hit: THit;
|
|
6
|
+
/**
|
|
7
|
+
* The attribute to retrieve the highlighted parts from.
|
|
8
|
+
*
|
|
9
|
+
* You can use the array syntax to reference nested attributes.
|
|
10
|
+
*/
|
|
11
|
+
attribute: keyof THit | string[];
|
|
12
|
+
/**
|
|
13
|
+
* The tag name to use for highlighted parts.
|
|
14
|
+
*
|
|
15
|
+
* @default "mark"
|
|
16
|
+
*/
|
|
17
|
+
tagName?: string;
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './AutocompleteClassNames';
|
|
2
|
+
export * from './AutocompleteCollection';
|
|
3
|
+
export * from './AutocompleteComponents';
|
|
4
|
+
export * from './AutocompleteOptions';
|
|
5
|
+
export * from './AutocompletePlugin';
|
|
6
|
+
export * from './AutocompletePropGetters';
|
|
7
|
+
export * from './AutocompleteRender';
|
|
8
|
+
export * from './AutocompleteRenderer';
|
|
9
|
+
export * from './AutocompleteSource';
|
|
10
|
+
export * from './AutocompleteState';
|
|
11
|
+
export * from './AutocompleteTranslations';
|
|
12
|
+
export * from './HighlightHitParams';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './AutocompleteClassNames';
|
|
2
|
+
export * from './AutocompleteCollection';
|
|
3
|
+
export * from './AutocompleteComponents';
|
|
4
|
+
export * from './AutocompleteOptions';
|
|
5
|
+
export * from './AutocompletePlugin';
|
|
6
|
+
export * from './AutocompletePropGetters';
|
|
7
|
+
export * from './AutocompleteRender';
|
|
8
|
+
export * from './AutocompleteRenderer';
|
|
9
|
+
export * from './AutocompleteSource';
|
|
10
|
+
export * from './AutocompleteState';
|
|
11
|
+
export * from './AutocompleteTranslations';
|
|
12
|
+
export * from './HighlightHitParams';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as ClientSearch from '@algolia/client-search';
|
|
2
|
+
import type * as AlgoliaSearch from 'algoliasearch/lite';
|
|
3
|
+
declare type AnyToUnknown<TSubject> = (any extends TSubject ? true : false) extends true ? unknown : TSubject;
|
|
4
|
+
declare type SearchClientShape = {
|
|
5
|
+
search: unknown;
|
|
6
|
+
};
|
|
7
|
+
declare type ClientLiteV5 = AnyToUnknown<
|
|
8
|
+
/** @ts-ignore */
|
|
9
|
+
ReturnType<typeof AlgoliaSearch.liteClient>>;
|
|
10
|
+
declare type ClientSearchV5 = AnyToUnknown<
|
|
11
|
+
/** @ts-ignore */
|
|
12
|
+
ReturnType<typeof ClientSearch.searchClient>>;
|
|
13
|
+
declare type ClientV5 = ClientLiteV5 extends SearchClientShape ? ClientLiteV5 : ClientSearchV5 extends SearchClientShape ? ClientSearchV5 : unknown;
|
|
14
|
+
declare type PickForClient<TMapping extends {
|
|
15
|
+
v4: unknown;
|
|
16
|
+
v5: unknown;
|
|
17
|
+
}> = ClientV5 extends SearchClientShape ? TMapping['v5'] : TMapping['v4'];
|
|
18
|
+
export declare type SearchClient = PickForClient<{
|
|
19
|
+
/** @ts-ignore */
|
|
20
|
+
v4: AlgoliaSearch.SearchClient;
|
|
21
|
+
/** @ts-ignore */
|
|
22
|
+
v5: ClientV5;
|
|
23
|
+
}>;
|
|
24
|
+
export declare type MultipleQueriesQuery = PickForClient<{
|
|
25
|
+
/** @ts-ignore */
|
|
26
|
+
v4: ClientSearch.MultipleQueriesQuery;
|
|
27
|
+
/** @ts-ignore */
|
|
28
|
+
v5: AlgoliaSearch.LegacySearchMethodProps[number];
|
|
29
|
+
}>;
|
|
30
|
+
export declare type SearchForFacetValuesResponse = PickForClient<{
|
|
31
|
+
/** @ts-ignore */
|
|
32
|
+
v4: ClientSearch.SearchForFacetValuesResponse;
|
|
33
|
+
/** @ts-ignore */
|
|
34
|
+
v5: AlgoliaSearch.SearchForFacetValuesResponse;
|
|
35
|
+
}>;
|
|
36
|
+
export declare type SearchResponse<THit> = PickForClient<{
|
|
37
|
+
/** @ts-ignore */
|
|
38
|
+
v4: ClientSearch.SearchResponse<THit>;
|
|
39
|
+
/** @ts-ignore */
|
|
40
|
+
v5: AlgoliaSearch.SearchResponse<THit>;
|
|
41
|
+
}>;
|
|
42
|
+
export declare type HighlightResult<THit> = PickForClient<{
|
|
43
|
+
/** @ts-ignore */
|
|
44
|
+
v4: ClientSearch.HighlightResult<THit>;
|
|
45
|
+
/** @ts-ignore */
|
|
46
|
+
v5: AlgoliaSearch.HighlightResult;
|
|
47
|
+
}>;
|
|
48
|
+
export declare type SnippetResult<THit> = PickForClient<{
|
|
49
|
+
/** @ts-ignore */
|
|
50
|
+
v4: ClientSearch.SnippetResult<THit>;
|
|
51
|
+
/** @ts-ignore */
|
|
52
|
+
v5: AlgoliaSearch.SnippetResult;
|
|
53
|
+
}>;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|