instantsearch-ui-components 0.12.0 → 0.14.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.
Files changed (41) hide show
  1. package/dist/cjs/components/autocomplete/AutocompleteIndex.js +6 -1
  2. package/dist/cjs/components/autocomplete/AutocompleteRecentSearch.js +41 -0
  3. package/dist/cjs/components/autocomplete/AutocompleteSearch.js +70 -0
  4. package/dist/cjs/components/autocomplete/AutocompleteSuggestion.js +11 -2
  5. package/dist/cjs/components/autocomplete/createAutocompletePropGetters.js +222 -0
  6. package/dist/cjs/components/autocomplete/createAutocompleteStorage.js +150 -0
  7. package/dist/cjs/components/autocomplete/icons.js +76 -0
  8. package/dist/cjs/components/autocomplete/index.js +44 -0
  9. package/dist/cjs/components/chat/Chat.js +2 -1
  10. package/dist/cjs/components/chat/ChatMessage.js +3 -0
  11. package/dist/cjs/components/chat/ChatMessages.js +14 -5
  12. package/dist/cjs/components/chat/icons.js +36 -36
  13. package/dist/cjs/version.js +1 -1
  14. package/dist/es/components/autocomplete/Autocomplete.d.ts +1 -1
  15. package/dist/es/components/autocomplete/AutocompleteIndex.d.ts +7 -0
  16. package/dist/es/components/autocomplete/AutocompleteIndex.js +6 -1
  17. package/dist/es/components/autocomplete/AutocompletePanel.d.ts +1 -1
  18. package/dist/es/components/autocomplete/AutocompleteRecentSearch.d.ts +37 -0
  19. package/dist/es/components/autocomplete/AutocompleteRecentSearch.js +35 -0
  20. package/dist/es/components/autocomplete/AutocompleteSearch.d.ts +8 -0
  21. package/dist/es/components/autocomplete/AutocompleteSearch.js +63 -0
  22. package/dist/es/components/autocomplete/AutocompleteSuggestion.d.ts +8 -0
  23. package/dist/es/components/autocomplete/AutocompleteSuggestion.js +11 -2
  24. package/dist/es/components/autocomplete/createAutocompletePropGetters.d.ts +49 -0
  25. package/dist/es/components/autocomplete/createAutocompletePropGetters.js +215 -0
  26. package/dist/es/components/autocomplete/createAutocompleteStorage.d.ts +63 -0
  27. package/dist/es/components/autocomplete/createAutocompleteStorage.js +142 -0
  28. package/dist/es/components/autocomplete/icons.d.ts +9 -0
  29. package/dist/es/components/autocomplete/icons.js +66 -0
  30. package/dist/es/components/autocomplete/index.d.ts +4 -0
  31. package/dist/es/components/autocomplete/index.js +5 -1
  32. package/dist/es/components/chat/Chat.d.ts +1 -0
  33. package/dist/es/components/chat/Chat.js +2 -1
  34. package/dist/es/components/chat/ChatMessage.js +3 -0
  35. package/dist/es/components/chat/ChatMessages.d.ts +9 -1
  36. package/dist/es/components/chat/ChatMessages.js +14 -5
  37. package/dist/es/components/chat/icons.js +36 -36
  38. package/dist/es/components/chat/types.d.ts +1 -1
  39. package/dist/es/version.d.ts +1 -1
  40. package/dist/es/version.js +1 -1
  41. package/package.json +2 -2
@@ -15,7 +15,7 @@ var _ChatMessage = require("./ChatMessage");
15
15
  var _ChatMessageError = require("./ChatMessageError");
16
16
  var _ChatMessageLoader = require("./ChatMessageLoader");
17
17
  var _icons = require("./icons");
18
- var _excluded = ["classNames", "messages", "messageComponent", "loaderComponent", "errorComponent", "actionsComponent", "tools", "indexUiState", "setIndexUiState", "status", "hideScrollToBottom", "onReload", "onClose", "translations", "userMessageProps", "assistantMessageProps", "isClearing", "onClearTransitionEnd", "isScrollAtBottom", "scrollRef", "contentRef", "onScrollToBottom"];
18
+ var _excluded = ["classNames", "messageClassNames", "messageTranslations", "messages", "messageComponent", "loaderComponent", "errorComponent", "actionsComponent", "tools", "indexUiState", "setIndexUiState", "status", "hideScrollToBottom", "onReload", "onClose", "translations", "userMessageProps", "assistantMessageProps", "isClearing", "onClearTransitionEnd", "isScrollAtBottom", "scrollRef", "contentRef", "onScrollToBottom"];
19
19
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
20
20
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
21
21
  var getTextContent = function getTextContent(message) {
@@ -45,8 +45,10 @@ function createDefaultMessageComponent(_ref) {
45
45
  setIndexUiState = _ref2.setIndexUiState,
46
46
  onReload = _ref2.onReload,
47
47
  onClose = _ref2.onClose,
48
- translations = _ref2.translations,
49
- actionsComponent = _ref2.actionsComponent;
48
+ actionsComponent = _ref2.actionsComponent,
49
+ classNames = _ref2.classNames,
50
+ messageTranslations = _ref2.messageTranslations,
51
+ translations = _ref2.translations;
50
52
  var defaultAssistantActions = [].concat((0, _toConsumableArray2.default)(hasTextContent(message) ? [{
51
53
  title: translations.copyToClipboardLabel,
52
54
  icon: function icon() {
@@ -78,7 +80,9 @@ function createDefaultMessageComponent(_ref) {
78
80
  onClose: onClose,
79
81
  actions: defaultActions,
80
82
  actionsComponent: actionsComponent,
81
- "data-role": message.role
83
+ "data-role": message.role,
84
+ classNames: classNames,
85
+ translations: messageTranslations
82
86
  }, messageProps));
83
87
  };
84
88
  }
@@ -101,6 +105,9 @@ function createChatMessagesComponent(_ref3) {
101
105
  return function ChatMessages(userProps) {
102
106
  var _userProps$classNames = userProps.classNames,
103
107
  classNames = _userProps$classNames === void 0 ? {} : _userProps$classNames,
108
+ _userProps$messageCla = userProps.messageClassNames,
109
+ messageClassNames = _userProps$messageCla === void 0 ? {} : _userProps$messageCla,
110
+ messageTranslations = userProps.messageTranslations,
104
111
  _userProps$messages = userProps.messages,
105
112
  messages = _userProps$messages === void 0 ? [] : _userProps$messages,
106
113
  MessageComponent = userProps.messageComponent,
@@ -169,7 +176,9 @@ function createChatMessagesComponent(_ref3) {
169
176
  onReload: onReload,
170
177
  actionsComponent: ActionsComponent,
171
178
  onClose: onClose,
172
- translations: translations
179
+ translations: translations,
180
+ classNames: messageClassNames,
181
+ messageTranslations: messageTranslations
173
182
  });
174
183
  }), status === 'submitted' && createElement(DefaultLoader, {
175
184
  translations: {
@@ -228,12 +228,12 @@ function StopIconComponent(_ref9) {
228
228
  rx: "1"
229
229
  }));
230
230
  }
231
- function ReloadIconComponent(_ref10) {
232
- var createElement = _ref10.createElement,
233
- _ref10$width = _ref10.width,
234
- width = _ref10$width === void 0 ? 16 : _ref10$width,
235
- _ref10$height = _ref10.height,
236
- height = _ref10$height === void 0 ? 16 : _ref10$height;
231
+ function ReloadIconComponent(_ref0) {
232
+ var createElement = _ref0.createElement,
233
+ _ref0$width = _ref0.width,
234
+ width = _ref0$width === void 0 ? 16 : _ref0$width,
235
+ _ref0$height = _ref0.height,
236
+ height = _ref0$height === void 0 ? 16 : _ref0$height;
237
237
  return createElement("svg", {
238
238
  xmlns: "http://www.w3.org/2000/svg",
239
239
  width: width,
@@ -254,12 +254,12 @@ function ReloadIconComponent(_ref10) {
254
254
  d: "M3 21v-5h5"
255
255
  }));
256
256
  }
257
- function CopyIconComponent(_ref11) {
258
- var createElement = _ref11.createElement,
259
- _ref11$width = _ref11.width,
260
- width = _ref11$width === void 0 ? 16 : _ref11$width,
261
- _ref11$height = _ref11.height,
262
- height = _ref11$height === void 0 ? 16 : _ref11$height;
257
+ function CopyIconComponent(_ref1) {
258
+ var createElement = _ref1.createElement,
259
+ _ref1$width = _ref1.width,
260
+ width = _ref1$width === void 0 ? 16 : _ref1$width,
261
+ _ref1$height = _ref1.height,
262
+ height = _ref1$height === void 0 ? 16 : _ref1$height;
263
263
  return createElement("svg", {
264
264
  xmlns: "http://www.w3.org/2000/svg",
265
265
  width: width,
@@ -281,12 +281,12 @@ function CopyIconComponent(_ref11) {
281
281
  d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
282
282
  }));
283
283
  }
284
- function MenuIconComponent(_ref12) {
285
- var createElement = _ref12.createElement,
286
- _ref12$width = _ref12.width,
287
- width = _ref12$width === void 0 ? 16 : _ref12$width,
288
- _ref12$height = _ref12.height,
289
- height = _ref12$height === void 0 ? 16 : _ref12$height;
284
+ function MenuIconComponent(_ref10) {
285
+ var createElement = _ref10.createElement,
286
+ _ref10$width = _ref10.width,
287
+ width = _ref10$width === void 0 ? 16 : _ref10$width,
288
+ _ref10$height = _ref10.height,
289
+ height = _ref10$height === void 0 ? 16 : _ref10$height;
290
290
  return createElement("svg", {
291
291
  xmlns: "http://www.w3.org/2000/svg",
292
292
  width: width,
@@ -311,12 +311,12 @@ function MenuIconComponent(_ref12) {
311
311
  r: "1"
312
312
  }));
313
313
  }
314
- function LoadingSpinnerIconComponent(_ref13) {
315
- var createElement = _ref13.createElement,
316
- _ref13$width = _ref13.width,
317
- width = _ref13$width === void 0 ? 24 : _ref13$width,
318
- _ref13$height = _ref13.height,
319
- height = _ref13$height === void 0 ? 24 : _ref13$height;
314
+ function LoadingSpinnerIconComponent(_ref11) {
315
+ var createElement = _ref11.createElement,
316
+ _ref11$width = _ref11.width,
317
+ width = _ref11$width === void 0 ? 24 : _ref11$width,
318
+ _ref11$height = _ref11.height,
319
+ height = _ref11$height === void 0 ? 24 : _ref11$height;
320
320
  return createElement("svg", {
321
321
  viewBox: "12 12 24 24",
322
322
  width: width,
@@ -333,12 +333,12 @@ function LoadingSpinnerIconComponent(_ref13) {
333
333
  stroke: "currentColor"
334
334
  }));
335
335
  }
336
- function ChevronLeftIconComponent(_ref14) {
337
- var createElement = _ref14.createElement,
338
- _ref14$width = _ref14.width,
339
- width = _ref14$width === void 0 ? 16 : _ref14$width,
340
- _ref14$height = _ref14.height,
341
- height = _ref14$height === void 0 ? 16 : _ref14$height;
336
+ function ChevronLeftIconComponent(_ref12) {
337
+ var createElement = _ref12.createElement,
338
+ _ref12$width = _ref12.width,
339
+ width = _ref12$width === void 0 ? 16 : _ref12$width,
340
+ _ref12$height = _ref12.height,
341
+ height = _ref12$height === void 0 ? 16 : _ref12$height;
342
342
  return createElement("svg", {
343
343
  xmlns: "http://www.w3.org/2000/svg",
344
344
  width: width,
@@ -353,12 +353,12 @@ function ChevronLeftIconComponent(_ref14) {
353
353
  d: "m15 18-6-6 6-6"
354
354
  }));
355
355
  }
356
- function ChevronRightIconComponent(_ref15) {
357
- var createElement = _ref15.createElement,
358
- _ref15$width = _ref15.width,
359
- width = _ref15$width === void 0 ? 16 : _ref15$width,
360
- _ref15$height = _ref15.height,
361
- height = _ref15$height === void 0 ? 16 : _ref15$height;
356
+ function ChevronRightIconComponent(_ref13) {
357
+ var createElement = _ref13.createElement,
358
+ _ref13$width = _ref13.width,
359
+ width = _ref13$width === void 0 ? 16 : _ref13$width,
360
+ _ref13$height = _ref13.height,
361
+ height = _ref13$height === void 0 ? 16 : _ref13$height;
362
362
  return createElement("svg", {
363
363
  xmlns: "http://www.w3.org/2000/svg",
364
364
  width: width,
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _default = exports.default = '0.12.0';
7
+ var _default = exports.default = '0.14.0';
@@ -1,6 +1,6 @@
1
1
  /** @jsx createElement */
2
2
  import type { ComponentChildren, ComponentProps, Renderer } from '../../types';
3
- export type AutocompleteProps = ComponentProps<'div'> & {
3
+ export type AutocompleteProps = Omit<ComponentProps<'div'>, 'children'> & {
4
4
  children?: ComponentChildren;
5
5
  classNames?: Partial<AutocompleteClassNames>;
6
6
  };
@@ -5,6 +5,9 @@ export type AutocompleteIndexProps<T = {
5
5
  __indexName: string;
6
6
  } & Record<string, unknown>> = {
7
7
  items: T[];
8
+ HeaderComponent?: (props: {
9
+ items: T[];
10
+ }) => JSX.Element;
8
11
  ItemComponent: (props: {
9
12
  item: T;
10
13
  onSelect: () => void;
@@ -23,6 +26,10 @@ export type AutocompleteIndexClassNames = {
23
26
  * Class names to apply to the list element
24
27
  */
25
28
  list: string | string[];
29
+ /**
30
+ * Class names to apply to the header element
31
+ */
32
+ header: string | string[];
26
33
  /**
27
34
  * Class names to apply to each item element
28
35
  */
@@ -6,13 +6,18 @@ export function createAutocompleteIndexComponent(_ref) {
6
6
  var createElement = _ref.createElement;
7
7
  return function AutocompleteIndex(userProps) {
8
8
  var items = userProps.items,
9
+ HeaderComponent = userProps.HeaderComponent,
9
10
  ItemComponent = userProps.ItemComponent,
10
11
  getItemProps = userProps.getItemProps,
11
12
  _userProps$classNames = userProps.classNames,
12
13
  classNames = _userProps$classNames === void 0 ? {} : _userProps$classNames;
13
14
  return createElement("div", {
14
15
  className: cx('ais-AutocompleteIndex', classNames.root)
15
- }, createElement("ol", {
16
+ }, HeaderComponent && createElement("div", {
17
+ className: cx('ais-AutocompleteIndexHeader', classNames.header)
18
+ }, createElement(HeaderComponent, {
19
+ items: items
20
+ })), createElement("ol", {
16
21
  className: cx('ais-AutocompleteIndexList', classNames.list)
17
22
  }, items.map(function (item, index) {
18
23
  var _getItemProps = getItemProps(item, index),
@@ -1,6 +1,6 @@
1
1
  /** @jsx createElement */
2
2
  import type { ComponentChildren, ComponentProps, Renderer } from '../../types';
3
- export type AutocompletePanelProps = ComponentProps<'div'> & {
3
+ export type AutocompletePanelProps = Omit<ComponentProps<'div'>, 'children'> & {
4
4
  children?: ComponentChildren;
5
5
  classNames?: Partial<AutocompletePanelClassNames>;
6
6
  };
@@ -0,0 +1,37 @@
1
+ /** @jsx createElement */
2
+ import type { Renderer } from '../../types';
3
+ export type AutocompleteRecentSearchProps<T = {
4
+ query: string;
5
+ } & Record<string, unknown>> = {
6
+ item: T;
7
+ onSelect: () => void;
8
+ onRemoveRecentSearch: () => void;
9
+ classNames?: Partial<AutocompleteRecentSearchClassNames>;
10
+ };
11
+ export type AutocompleteRecentSearchClassNames = {
12
+ /**
13
+ * Class names to apply to the root element
14
+ **/
15
+ root: string | string[];
16
+ /**
17
+ * Class names to apply to the content element
18
+ **/
19
+ content: string | string[];
20
+ /**
21
+ * Class names to apply to the actions element
22
+ **/
23
+ actions: string | string[];
24
+ /**
25
+ * Class names to apply to the icon element
26
+ **/
27
+ icon: string | string[];
28
+ /**
29
+ * Class names to apply to the body element
30
+ **/
31
+ body: string | string[];
32
+ /**
33
+ * Class names to apply to the delete button element
34
+ **/
35
+ deleteButton: string | string[];
36
+ };
37
+ export declare function createAutocompleteRecentSearchComponent({ createElement, }: Renderer): ({ item, onSelect, onRemoveRecentSearch, classNames, }: AutocompleteRecentSearchProps) => JSX.Element;
@@ -0,0 +1,35 @@
1
+ import { cx } from "../../lib/index.js";
2
+ import { AutocompleteClockIcon, AutocompleteTrashIcon } from "./icons.js";
3
+ export function createAutocompleteRecentSearchComponent(_ref) {
4
+ var createElement = _ref.createElement;
5
+ return function AutocompleteRecentSearch(_ref2) {
6
+ var item = _ref2.item,
7
+ onSelect = _ref2.onSelect,
8
+ onRemoveRecentSearch = _ref2.onRemoveRecentSearch,
9
+ _ref2$classNames = _ref2.classNames,
10
+ classNames = _ref2$classNames === void 0 ? {} : _ref2$classNames;
11
+ return createElement("div", {
12
+ onClick: onSelect,
13
+ className: cx('ais-AutocompleteItemWrapper ais-AutocompleteRecentSearchWrapper', classNames.root)
14
+ }, createElement("div", {
15
+ className: cx('ais-AutocompleteItemContent', 'ais-AutocompleteRecentSearchItemContent', classNames.content)
16
+ }, createElement("div", {
17
+ className: cx('ais-AutocompleteItemIcon', 'ais-AutocompleteRecentSearchItemIcon', classNames.content)
18
+ }, createElement(AutocompleteClockIcon, {
19
+ createElement: createElement
20
+ })), createElement("div", {
21
+ className: cx('ais-AutocompleteItemContentBody', 'ais-AutocompleteRecentSearchItemContentBody', classNames.content)
22
+ }, item.query)), createElement("div", {
23
+ className: cx('ais-AutocompleteItemActions', 'ais-AutocompleteRecentSearchItemActions', classNames.actions)
24
+ }, createElement("button", {
25
+ className: cx('ais-AutocompleteItemActionButton', 'ais-AutocompleteRecentSearchItemDeleteButton', classNames.deleteButton),
26
+ title: "Remove ".concat(item.query, " from recent searches"),
27
+ onClick: function onClick(evt) {
28
+ evt.stopPropagation();
29
+ onRemoveRecentSearch();
30
+ }
31
+ }, createElement(AutocompleteTrashIcon, {
32
+ createElement: createElement
33
+ }))));
34
+ };
35
+ }
@@ -0,0 +1,8 @@
1
+ import type { ComponentProps, Renderer } from '../..';
2
+ export type AutocompleteSearchProps = {
3
+ inputProps: Partial<ComponentProps<'input'>>;
4
+ onClear: () => void;
5
+ query: string;
6
+ isSearchStalled: boolean;
7
+ };
8
+ export declare function createAutocompleteSearchComponent({ createElement }: Renderer): ({ inputProps, onClear, query, isSearchStalled, }: AutocompleteSearchProps) => JSX.Element;
@@ -0,0 +1,63 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import { AutocompleteClearIcon, AutocompleteLoadingIcon, AutocompleteSubmitIcon } from "./icons.js";
3
+ export function createAutocompleteSearchComponent(_ref) {
4
+ var createElement = _ref.createElement;
5
+ return function AutocompleteSearch(_ref2) {
6
+ var inputProps = _ref2.inputProps,
7
+ onClear = _ref2.onClear,
8
+ query = _ref2.query,
9
+ isSearchStalled = _ref2.isSearchStalled;
10
+ return createElement("form", {
11
+ className: "ais-AutocompleteForm",
12
+ action: "",
13
+ noValidate: true,
14
+ role: "search",
15
+ onSubmit: function onSubmit(e) {
16
+ return e.preventDefault();
17
+ }
18
+ }, createElement("div", {
19
+ className: "ais-AutocompleteInputWrapperPrefix"
20
+ }, createElement("label", {
21
+ className: "ais-AutocompleteLabel",
22
+ "aria-label": "Submit",
23
+ htmlFor: inputProps.id,
24
+ id: "".concat(inputProps.id, "-label")
25
+ }, createElement("button", {
26
+ className: "ais-AutocompleteSubmitButton",
27
+ type: "submit",
28
+ title: "Submit"
29
+ }, createElement(AutocompleteSubmitIcon, {
30
+ createElement: createElement
31
+ }))), createElement("div", {
32
+ className: "ais-AutocompleteLoadingIndicator",
33
+ hidden: !isSearchStalled
34
+ }, createElement(AutocompleteLoadingIcon, {
35
+ createElement: createElement
36
+ }))), createElement("div", {
37
+ className: "ais-AutocompleteInputWrapper"
38
+ }, createElement("input", _extends({
39
+ className: "ais-AutocompleteInput",
40
+ "aria-autocomplete": "both",
41
+ "aria-labelledby": "".concat(inputProps.id, "-label"),
42
+ autoComplete: "off",
43
+ autoCorrect: "off",
44
+ autoCapitalize: "off",
45
+ enterKeyHint: "search",
46
+ spellCheck: "false",
47
+ placeholder: "",
48
+ maxLength: 512,
49
+ type: "search",
50
+ value: query
51
+ }, inputProps))), createElement("div", {
52
+ className: "ais-AutocompleteInputWrapperSuffix"
53
+ }, createElement("button", {
54
+ className: "ais-AutocompleteClearButton",
55
+ type: "reset",
56
+ title: "Clear",
57
+ hidden: query.length === 0 || isSearchStalled,
58
+ onClick: onClear
59
+ }, createElement(AutocompleteClearIcon, {
60
+ createElement: createElement
61
+ }))));
62
+ };
63
+ }
@@ -12,5 +12,13 @@ export type AutocompleteSuggestionClassNames = {
12
12
  * Class names to apply to the root element
13
13
  **/
14
14
  root: string | string[];
15
+ /** Class names to apply to the content element **/
16
+ content: string | string[];
17
+ /** Class names to apply to the actions element **/
18
+ actions: string | string[];
19
+ /** Class names to apply to the icon element **/
20
+ icon: string | string[];
21
+ /** Class names to apply to the body element **/
22
+ body: string | string[];
15
23
  };
16
24
  export declare function createAutocompleteSuggestionComponent({ createElement, }: Renderer): ({ item, onSelect, classNames, }: AutocompleteSuggestionProps) => JSX.Element;
@@ -1,4 +1,5 @@
1
1
  import { cx } from "../../lib/index.js";
2
+ import { AutocompleteSubmitIcon } from "./icons.js";
2
3
  export function createAutocompleteSuggestionComponent(_ref) {
3
4
  var createElement = _ref.createElement;
4
5
  return function AutocompleteSuggestion(_ref2) {
@@ -8,7 +9,15 @@ export function createAutocompleteSuggestionComponent(_ref) {
8
9
  classNames = _ref2$classNames === void 0 ? {} : _ref2$classNames;
9
10
  return createElement("div", {
10
11
  onClick: onSelect,
11
- className: cx('ais-AutocompleteSuggestion', classNames.root)
12
- }, item.query);
12
+ className: cx('ais-AutocompleteItemWrapper', 'ais-AutocompleteSuggestionWrapper', classNames.root)
13
+ }, createElement("div", {
14
+ className: cx('ais-AutocompleteItemContent', 'ais-AutocompleteSuggestionItemContent', classNames.content)
15
+ }, createElement("div", {
16
+ className: cx('ais-AutocompleteItemIcon', 'ais-AutocompleteSuggestionItemIcon', classNames.content)
17
+ }, createElement(AutocompleteSubmitIcon, {
18
+ createElement: createElement
19
+ })), createElement("div", {
20
+ className: cx('ais-AutocompleteItemContentBody', 'ais-AutocompleteSuggestionItemContentBody', classNames.content)
21
+ }, item.query)));
13
22
  };
14
23
  }
@@ -0,0 +1,49 @@
1
+ import type { ComponentProps } from '../../types';
2
+ type BaseHit = Record<string, unknown>;
3
+ export type AutocompleteIndexConfig<TItem extends BaseHit> = {
4
+ indexName: string;
5
+ getQuery?: (item: TItem) => string;
6
+ getURL?: (item: TItem) => string;
7
+ onSelect?: (params: {
8
+ item: TItem;
9
+ query: string;
10
+ setQuery: (query: string) => void;
11
+ url?: string;
12
+ }) => void;
13
+ };
14
+ type GetInputProps = () => Partial<ComponentProps<'input'>>;
15
+ type GetItemProps = (item: {
16
+ __indexName: string;
17
+ } & Record<string, unknown>, index: number) => Pick<ComponentProps<'li'>, 'id' | 'role' | 'aria-selected'> & {
18
+ onSelect: () => void;
19
+ };
20
+ type GetPanelProps = () => Pick<ComponentProps<'div'>, 'id' | 'hidden' | 'role' | 'aria-labelledby'>;
21
+ type GetRootProps = () => Pick<ComponentProps<'div'>, 'ref'>;
22
+ type CreateAutocompletePropGettersParams = {
23
+ useEffect: (effect: () => void, inputs?: readonly unknown[]) => void;
24
+ useId: () => string;
25
+ useMemo: <TType>(factory: () => TType, inputs: readonly unknown[]) => TType;
26
+ useRef: <TType>(initialValue: TType | null) => {
27
+ current: TType | null;
28
+ };
29
+ useState: <TType>(initialState: TType) => [TType, (newState: TType) => unknown];
30
+ };
31
+ export type UsePropGetters<TItem extends BaseHit> = (params: {
32
+ indices: Array<{
33
+ indexName: string;
34
+ indexId: string;
35
+ hits: Array<{
36
+ [key: string]: unknown;
37
+ }>;
38
+ }>;
39
+ indicesConfig: Array<AutocompleteIndexConfig<TItem>>;
40
+ onRefine: (query: string) => void;
41
+ onSelect: NonNullable<AutocompleteIndexConfig<TItem>['onSelect']>;
42
+ }) => {
43
+ getInputProps: GetInputProps;
44
+ getItemProps: GetItemProps;
45
+ getPanelProps: GetPanelProps;
46
+ getRootProps: GetRootProps;
47
+ };
48
+ export declare function createAutocompletePropGetters({ useEffect, useId, useMemo, useRef, useState, }: CreateAutocompletePropGettersParams): <TItem extends BaseHit>({ indices, indicesConfig, onRefine, onSelect: globalOnSelect, }: Parameters<UsePropGetters<TItem>>[0]) => ReturnType<UsePropGetters<TItem>>;
49
+ export {};