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
@@ -0,0 +1,215 @@
1
+ import _typeof from "@babel/runtime/helpers/typeof";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ export function createAutocompletePropGetters(_ref) {
4
+ var useEffect = _ref.useEffect,
5
+ useId = _ref.useId,
6
+ useMemo = _ref.useMemo,
7
+ useRef = _ref.useRef,
8
+ useState = _ref.useState;
9
+ return function usePropGetters(_ref2) {
10
+ var indices = _ref2.indices,
11
+ indicesConfig = _ref2.indicesConfig,
12
+ onRefine = _ref2.onRefine,
13
+ globalOnSelect = _ref2.onSelect;
14
+ var getElementId = createGetElementId(useId());
15
+ var rootRef = useRef(null);
16
+ var _useState = useState(false),
17
+ _useState2 = _slicedToArray(_useState, 2),
18
+ isOpen = _useState2[0],
19
+ setIsOpen = _useState2[1];
20
+ var _useState3 = useState(undefined),
21
+ _useState4 = _slicedToArray(_useState3, 2),
22
+ activeDescendant = _useState4[0],
23
+ setActiveDescendant = _useState4[1];
24
+ var _useMemo = useMemo(function () {
25
+ return buildItems({
26
+ indices: indices,
27
+ indicesConfig: indicesConfig,
28
+ getElementId: getElementId
29
+ });
30
+ }, [indices, indicesConfig, getElementId]),
31
+ items = _useMemo.items,
32
+ itemsIds = _useMemo.itemsIds;
33
+ useEffect(function () {
34
+ var onBodyClick = function onBodyClick(event) {
35
+ var _unwrapRef;
36
+ if ((_unwrapRef = unwrapRef(rootRef)) !== null && _unwrapRef !== void 0 && _unwrapRef.contains(event.target)) {
37
+ return;
38
+ }
39
+ setIsOpen(false);
40
+ };
41
+ document.body.addEventListener('click', onBodyClick);
42
+ return function () {
43
+ document.body.removeEventListener('click', onBodyClick);
44
+ };
45
+ }, [rootRef]);
46
+ var getNextActiveDescendent = function getNextActiveDescendent(key) {
47
+ switch (key) {
48
+ case 'ArrowLeft':
49
+ case 'ArrowUp':
50
+ {
51
+ var prevIndex = itemsIds.indexOf(activeDescendant || '') - 1;
52
+ return itemsIds[prevIndex] || itemsIds[itemsIds.length - 1];
53
+ }
54
+ case 'ArrowRight':
55
+ case 'ArrowDown':
56
+ {
57
+ var nextIndex = itemsIds.indexOf(activeDescendant || '') + 1;
58
+ return itemsIds[nextIndex] || itemsIds[0];
59
+ }
60
+ default:
61
+ return undefined;
62
+ }
63
+ };
64
+ var submit = function submit() {
65
+ var actualActiveDescendant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : activeDescendant;
66
+ setIsOpen(false);
67
+ if (actualActiveDescendant && items.has(actualActiveDescendant)) {
68
+ var _getQuery;
69
+ var _ref3 = items.get(actualActiveDescendant),
70
+ _item = _ref3.item,
71
+ _ref3$config = _ref3.config,
72
+ indexOnSelect = _ref3$config.onSelect,
73
+ getQuery = _ref3$config.getQuery,
74
+ getURL = _ref3$config.getURL;
75
+ var actualOnSelect = indexOnSelect !== null && indexOnSelect !== void 0 ? indexOnSelect : globalOnSelect;
76
+ actualOnSelect({
77
+ item: _item,
78
+ query: (_getQuery = getQuery === null || getQuery === void 0 ? void 0 : getQuery(_item)) !== null && _getQuery !== void 0 ? _getQuery : '',
79
+ url: getURL === null || getURL === void 0 ? void 0 : getURL(_item),
80
+ setQuery: function setQuery(query) {
81
+ return onRefine(query);
82
+ }
83
+ });
84
+ setActiveDescendant(undefined);
85
+ }
86
+ };
87
+ return {
88
+ getInputProps: function getInputProps() {
89
+ return {
90
+ id: getElementId('input'),
91
+ role: 'combobox',
92
+ 'aria-autocomplete': 'list',
93
+ 'aria-expanded': isOpen,
94
+ 'aria-haspopup': 'grid',
95
+ 'aria-controls': getElementId('panel'),
96
+ 'aria-activedescendant': activeDescendant,
97
+ onFocus: function onFocus() {
98
+ return setIsOpen(true);
99
+ },
100
+ onKeyDown: function onKeyDown(event) {
101
+ if (event.key === 'Escape') {
102
+ setActiveDescendant(undefined);
103
+ setIsOpen(false);
104
+ return;
105
+ }
106
+ switch (event.key) {
107
+ case 'ArrowLeft':
108
+ case 'ArrowUp':
109
+ case 'ArrowRight':
110
+ case 'ArrowDown':
111
+ {
112
+ var _document$getElementB;
113
+ var nextActiveDescendent = getNextActiveDescendent(event.key);
114
+ setActiveDescendant(nextActiveDescendent);
115
+ (_document$getElementB = document.getElementById(nextActiveDescendent)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.scrollIntoView(false);
116
+ event.preventDefault();
117
+ break;
118
+ }
119
+ case 'Enter':
120
+ {
121
+ submit();
122
+ break;
123
+ }
124
+ case 'Tab':
125
+ setIsOpen(false);
126
+ break;
127
+ default:
128
+ return;
129
+ }
130
+ },
131
+ onKeyUp: function onKeyUp(event) {
132
+ switch (event.key) {
133
+ case 'ArrowLeft':
134
+ case 'ArrowUp':
135
+ case 'ArrowRight':
136
+ case 'ArrowDown':
137
+ case 'Escape':
138
+ case 'Return':
139
+ event.preventDefault();
140
+ return;
141
+ default:
142
+ setActiveDescendant(undefined);
143
+ break;
144
+ }
145
+ }
146
+ };
147
+ },
148
+ getItemProps: function getItemProps(item, index) {
149
+ var id = getElementId('item', item.__indexName, index);
150
+ return {
151
+ id: id,
152
+ role: 'row',
153
+ 'aria-selected': id === activeDescendant,
154
+ onSelect: function onSelect() {
155
+ return submit(id);
156
+ }
157
+ };
158
+ },
159
+ getPanelProps: function getPanelProps() {
160
+ return {
161
+ hidden: !isOpen,
162
+ id: getElementId('panel'),
163
+ role: 'grid',
164
+ 'aria-labelledby': getElementId('input')
165
+ };
166
+ },
167
+ getRootProps: function getRootProps() {
168
+ return {
169
+ ref: rootRef
170
+ };
171
+ }
172
+ };
173
+ };
174
+ }
175
+ function buildItems(_ref4) {
176
+ var indices = _ref4.indices,
177
+ indicesConfig = _ref4.indicesConfig,
178
+ getElementId = _ref4.getElementId;
179
+ var itemsIds = [];
180
+ var items = new Map();
181
+ for (var i = 0; i < indicesConfig.length; i++) {
182
+ var _indices$i;
183
+ var config = indicesConfig[i];
184
+ var hits = ((_indices$i = indices[i]) === null || _indices$i === void 0 ? void 0 : _indices$i.hits) || [];
185
+ for (var position = 0; position < hits.length; position++) {
186
+ var itemId = getElementId('item', config.indexName, position);
187
+ items.set(itemId, {
188
+ item: hits[position],
189
+ config: config
190
+ });
191
+ itemsIds.push(itemId);
192
+ }
193
+ }
194
+ return {
195
+ items: items,
196
+ itemsIds: itemsIds
197
+ };
198
+ }
199
+ function createGetElementId(autocompleteId) {
200
+ return function getElementId() {
201
+ var prefix = 'autocomplete';
202
+ for (var _len = arguments.length, suffixes = new Array(_len), _key = 0; _key < _len; _key++) {
203
+ suffixes[_key] = arguments[_key];
204
+ }
205
+ return "".concat(prefix).concat(autocompleteId).concat(suffixes.join(':'));
206
+ };
207
+ }
208
+
209
+ /**
210
+ * Returns the framework-agnostic value of a ref.
211
+ */
212
+ function unwrapRef(ref) {
213
+ return ref.current && _typeof(ref.current) === 'object' && 'base' in ref.current ? ref.current.base // Preact
214
+ : ref.current; // React
215
+ }
@@ -0,0 +1,63 @@
1
+ import type { UsePropGetters } from './createAutocompletePropGetters';
2
+ type CreateAutocompleteStorageParams = {
3
+ useEffect: (effect: () => void, inputs?: readonly unknown[]) => void;
4
+ useMemo: <TType>(factory: () => TType, inputs: readonly unknown[]) => TType;
5
+ useState: <TType>(initialState: TType) => [TType, (newState: TType) => unknown];
6
+ };
7
+ type UseStorageParams<TItem extends Record<string, unknown>> = {
8
+ showRecent?: boolean | {
9
+ storageKey?: string;
10
+ };
11
+ query?: string;
12
+ } & Pick<Parameters<UsePropGetters<TItem>>[0], 'indices' | 'indicesConfig'>;
13
+ export declare function createAutocompleteStorage({ useEffect, useMemo, useState, }: CreateAutocompleteStorageParams): <TItem extends Record<string, unknown>>({ showRecent, query, indices, indicesConfig, }: UseStorageParams<TItem>) => {
14
+ storage: {
15
+ onAdd: () => void;
16
+ onRemove: () => void;
17
+ };
18
+ storageHits: never[];
19
+ indicesForPropGetters: {
20
+ indexName: string;
21
+ indexId: string;
22
+ hits: Array<{
23
+ [key: string]: unknown;
24
+ }>;
25
+ }[];
26
+ indicesConfigForPropGetters: import("./createAutocompletePropGetters").AutocompleteIndexConfig<TItem>[];
27
+ } | {
28
+ storage: {
29
+ onAdd(query: string): void;
30
+ onRemove(query: string): void;
31
+ registerUpdateListener(callback: () => void): void;
32
+ unregisterUpdateListener(): void;
33
+ getSnapshot(): {
34
+ getAll(query?: string): string[];
35
+ };
36
+ };
37
+ storageHits: {
38
+ objectID: string;
39
+ query: string;
40
+ __indexName: string;
41
+ }[];
42
+ indicesForPropGetters: {
43
+ indexName: string;
44
+ indexId: string;
45
+ hits: Array<{
46
+ [key: string]: unknown;
47
+ }>;
48
+ }[];
49
+ indicesConfigForPropGetters: import("./createAutocompletePropGetters").AutocompleteIndexConfig<TItem>[];
50
+ };
51
+ export declare function createStorage({ limit, storageKey, }: {
52
+ limit: number;
53
+ storageKey?: string;
54
+ }): {
55
+ onAdd(query: string): void;
56
+ onRemove(query: string): void;
57
+ registerUpdateListener(callback: () => void): void;
58
+ unregisterUpdateListener(): void;
59
+ getSnapshot(): {
60
+ getAll(query?: string): string[];
61
+ };
62
+ };
63
+ export {};
@@ -0,0 +1,142 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _typeof from "@babel/runtime/helpers/typeof";
4
+ export function createAutocompleteStorage(_ref) {
5
+ var useEffect = _ref.useEffect,
6
+ useMemo = _ref.useMemo,
7
+ useState = _ref.useState;
8
+ return function useStorage(_ref2) {
9
+ var showRecent = _ref2.showRecent,
10
+ query = _ref2.query,
11
+ indices = _ref2.indices,
12
+ indicesConfig = _ref2.indicesConfig;
13
+ var storageKey = showRecent && _typeof(showRecent) === 'object' ? showRecent.storageKey : undefined;
14
+ var storage = useMemo(function () {
15
+ return createStorage({
16
+ limit: 5,
17
+ storageKey: storageKey
18
+ });
19
+ }, [storageKey]);
20
+ var _useState = useState(storage.getSnapshot()),
21
+ _useState2 = _slicedToArray(_useState, 2),
22
+ snapshot = _useState2[0],
23
+ setSnapshot = _useState2[1];
24
+ useEffect(function () {
25
+ storage.registerUpdateListener(function () {
26
+ setSnapshot(storage.getSnapshot());
27
+ });
28
+ return function () {
29
+ storage.unregisterUpdateListener();
30
+ };
31
+ }, [storage]);
32
+ if (!showRecent) {
33
+ return {
34
+ storage: {
35
+ onAdd: function onAdd() {},
36
+ onRemove: function onRemove() {}
37
+ },
38
+ storageHits: [],
39
+ indicesForPropGetters: indices,
40
+ indicesConfigForPropGetters: indicesConfig
41
+ };
42
+ }
43
+ var storageHits = snapshot.getAll(query).map(function (value) {
44
+ return {
45
+ objectID: value,
46
+ query: value,
47
+ __indexName: 'recent-searches'
48
+ };
49
+ });
50
+ var indicesForPropGetters = _toConsumableArray(indices);
51
+ var indicesConfigForPropGetters = _toConsumableArray(indicesConfig);
52
+ indicesForPropGetters.unshift({
53
+ indexName: 'recent-searches',
54
+ indexId: 'recent-searches',
55
+ hits: storageHits
56
+ });
57
+ indicesConfigForPropGetters.unshift({
58
+ indexName: 'recent-searches',
59
+ // @ts-expect-error - we know it has query as it's generated from storageHits
60
+ getQuery: function getQuery(item) {
61
+ return item.query;
62
+ }
63
+ });
64
+ return {
65
+ storage: storage,
66
+ storageHits: storageHits,
67
+ indicesForPropGetters: indicesForPropGetters,
68
+ indicesConfigForPropGetters: indicesConfigForPropGetters
69
+ };
70
+ };
71
+ }
72
+ var LOCAL_STORAGE_KEY_TEST = 'test-localstorage-support';
73
+ var LOCAL_STORAGE_KEY = 'autocomplete-recent-searches';
74
+ function isLocalStorageSupported() {
75
+ try {
76
+ localStorage.setItem(LOCAL_STORAGE_KEY_TEST, '');
77
+ localStorage.removeItem(LOCAL_STORAGE_KEY_TEST);
78
+ return true;
79
+ } catch (error) {
80
+ return false;
81
+ }
82
+ }
83
+ function getLocalStorage() {
84
+ var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : LOCAL_STORAGE_KEY;
85
+ if (!isLocalStorageSupported()) {
86
+ return {
87
+ setItems: function setItems() {},
88
+ getItems: function getItems() {
89
+ return [];
90
+ }
91
+ };
92
+ }
93
+ return {
94
+ setItems: function setItems(items) {
95
+ try {
96
+ window.localStorage.setItem(key, JSON.stringify(items));
97
+ } catch (_unused) {
98
+ // do nothing, this likely means the storage is full
99
+ }
100
+ },
101
+ getItems: function getItems() {
102
+ var items = window.localStorage.getItem(key);
103
+ return items ? JSON.parse(items) : [];
104
+ }
105
+ };
106
+ }
107
+ export function createStorage(_ref3) {
108
+ var _ref3$limit = _ref3.limit,
109
+ limit = _ref3$limit === void 0 ? 5 : _ref3$limit,
110
+ storageKey = _ref3.storageKey;
111
+ var storage = getLocalStorage(storageKey);
112
+ var updateListener = null;
113
+ return {
114
+ onAdd: function onAdd(query) {
115
+ this.onRemove(query);
116
+ storage.setItems([query].concat(_toConsumableArray(storage.getItems())));
117
+ },
118
+ onRemove: function onRemove(query) {
119
+ var _updateListener;
120
+ storage.setItems(storage.getItems().filter(function (q) {
121
+ return q !== query;
122
+ }));
123
+ (_updateListener = updateListener) === null || _updateListener === void 0 ? void 0 : _updateListener();
124
+ },
125
+ registerUpdateListener: function registerUpdateListener(callback) {
126
+ updateListener = callback;
127
+ },
128
+ unregisterUpdateListener: function unregisterUpdateListener() {
129
+ updateListener = null;
130
+ },
131
+ getSnapshot: function getSnapshot() {
132
+ return {
133
+ getAll: function getAll() {
134
+ var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
135
+ return storage.getItems().filter(function (q) {
136
+ return q.includes(query);
137
+ }).slice(0, limit);
138
+ }
139
+ };
140
+ }
141
+ };
142
+ }
@@ -0,0 +1,9 @@
1
+ /** @jsx createElement */
2
+ import type { Renderer } from '../../types';
3
+ type IconProps = Pick<Renderer, 'createElement'>;
4
+ export declare function AutocompleteSubmitIcon({ createElement }: IconProps): JSX.Element;
5
+ export declare function AutocompleteLoadingIcon({ createElement }: IconProps): JSX.Element;
6
+ export declare function AutocompleteClearIcon({ createElement }: IconProps): JSX.Element;
7
+ export declare function AutocompleteClockIcon({ createElement }: IconProps): JSX.Element;
8
+ export declare function AutocompleteTrashIcon({ createElement }: IconProps): JSX.Element;
9
+ export {};
@@ -0,0 +1,66 @@
1
+ export function AutocompleteSubmitIcon(_ref) {
2
+ var createElement = _ref.createElement;
3
+ return createElement("svg", {
4
+ className: "ais-AutocompleteSubmitIcon",
5
+ viewBox: "0 0 24 24",
6
+ width: "20",
7
+ height: "20",
8
+ fill: "currentColor"
9
+ }, createElement("path", {
10
+ d: "M16.041 15.856c-0.034 0.026-0.067 0.055-0.099 0.087s-0.060 0.064-0.087 0.099c-1.258 1.213-2.969 1.958-4.855 1.958-1.933 0-3.682-0.782-4.95-2.050s-2.050-3.017-2.050-4.95 0.782-3.682 2.050-4.95 3.017-2.050 4.95-2.050 3.682 0.782 4.95 2.050 2.050 3.017 2.050 4.95c0 1.886-0.745 3.597-1.959 4.856zM21.707 20.293l-3.675-3.675c1.231-1.54 1.968-3.493 1.968-5.618 0-2.485-1.008-4.736-2.636-6.364s-3.879-2.636-6.364-2.636-4.736 1.008-6.364 2.636-2.636 3.879-2.636 6.364 1.008 4.736 2.636 6.364 3.879 2.636 6.364 2.636c2.125 0 4.078-0.737 5.618-1.968l3.675 3.675c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414z"
11
+ }));
12
+ }
13
+ export function AutocompleteLoadingIcon(_ref2) {
14
+ var createElement = _ref2.createElement;
15
+ return createElement("svg", {
16
+ className: "ais-AutocompleteLoadingIcon",
17
+ viewBox: "0 0 100 100",
18
+ width: "20",
19
+ height: "20"
20
+ }, createElement("circle", {
21
+ cx: "50",
22
+ cy: "50",
23
+ fill: "none",
24
+ r: "35",
25
+ stroke: "currentColor",
26
+ strokeDasharray: "164.93361431346415 56.97787143782138",
27
+ strokeWidth: "6"
28
+ }, createElement("animateTransform", {
29
+ attributeName: "transform",
30
+ type: "rotate",
31
+ repeatCount: "indefinite",
32
+ dur: "1s",
33
+ values: "0 50 50;90 50 50;180 50 50;360 50 50",
34
+ keyTimes: "0;0.40;0.65;1"
35
+ })));
36
+ }
37
+ export function AutocompleteClearIcon(_ref3) {
38
+ var createElement = _ref3.createElement;
39
+ return createElement("svg", {
40
+ className: "ais-AutocompleteClearIcon",
41
+ viewBox: "0 0 24 24",
42
+ width: "18",
43
+ height: "18",
44
+ fill: "currentColor"
45
+ }, createElement("path", {
46
+ d: "M5.293 6.707l5.293 5.293-5.293 5.293c-0.391 0.391-0.391 1.024 0 1.414s1.024 0.391 1.414 0l5.293-5.293 5.293 5.293c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414l-5.293-5.293 5.293-5.293c0.391-0.391 0.391-1.024 0-1.414s-1.024-0.391-1.414 0l-5.293 5.293-5.293-5.293c-0.391-0.391-1.024-0.391-1.414 0s-0.391 1.024 0 1.414z"
47
+ }));
48
+ }
49
+ export function AutocompleteClockIcon(_ref4) {
50
+ var createElement = _ref4.createElement;
51
+ return createElement("svg", {
52
+ viewBox: "0 0 24 24",
53
+ fill: "currentColor"
54
+ }, createElement("path", {
55
+ d: "M12.516 6.984v5.25l4.5 2.672-0.75 1.266-5.25-3.188v-6h1.5zM12 20.016q3.281 0 5.648-2.367t2.367-5.648-2.367-5.648-5.648-2.367-5.648 2.367-2.367 5.648 2.367 5.648 5.648 2.367zM12 2.016q4.125 0 7.055 2.93t2.93 7.055-2.93 7.055-7.055 2.93-7.055-2.93-2.93-7.055 2.93-7.055 7.055-2.93z"
56
+ }));
57
+ }
58
+ export function AutocompleteTrashIcon(_ref5) {
59
+ var createElement = _ref5.createElement;
60
+ return createElement("svg", {
61
+ viewBox: "0 0 24 24",
62
+ fill: "currentColor"
63
+ }, createElement("path", {
64
+ d: "M18 7v13c0 0.276-0.111 0.525-0.293 0.707s-0.431 0.293-0.707 0.293h-10c-0.276 0-0.525-0.111-0.707-0.293s-0.293-0.431-0.293-0.707v-13zM17 5v-1c0-0.828-0.337-1.58-0.879-2.121s-1.293-0.879-2.121-0.879h-4c-0.828 0-1.58 0.337-2.121 0.879s-0.879 1.293-0.879 2.121v1h-4c-0.552 0-1 0.448-1 1s0.448 1 1 1h1v13c0 0.828 0.337 1.58 0.879 2.121s1.293 0.879 2.121 0.879h10c0.828 0 1.58-0.337 2.121-0.879s0.879-1.293 0.879-2.121v-13h1c0.552 0 1-0.448 1-1s-0.448-1-1-1zM9 5v-1c0-0.276 0.111-0.525 0.293-0.707s0.431-0.293 0.707-0.293h4c0.276 0 0.525 0.111 0.707 0.293s0.293 0.431 0.293 0.707v1zM9 11v6c0 0.552 0.448 1 1 1s1-0.448 1-1v-6c0-0.552-0.448-1-1-1s-1 0.448-1 1zM13 11v6c0 0.552 0.448 1 1 1s1-0.448 1-1v-6c0-0.552-0.448-1-1-1s-1 0.448-1 1z"
65
+ }));
66
+ }
@@ -1,4 +1,8 @@
1
1
  export * from './Autocomplete';
2
2
  export * from './AutocompleteIndex';
3
3
  export * from './AutocompletePanel';
4
+ export * from './AutocompleteRecentSearch';
5
+ export * from './AutocompleteSearch';
4
6
  export * from './AutocompleteSuggestion';
7
+ export * from './createAutocompletePropGetters';
8
+ export * from './createAutocompleteStorage';
@@ -1,4 +1,8 @@
1
1
  export * from "./Autocomplete.js";
2
2
  export * from "./AutocompleteIndex.js";
3
3
  export * from "./AutocompletePanel.js";
4
- export * from "./AutocompleteSuggestion.js";
4
+ export * from "./AutocompleteRecentSearch.js";
5
+ export * from "./AutocompleteSearch.js";
6
+ export * from "./AutocompleteSuggestion.js";
7
+ export * from "./createAutocompletePropGetters.js";
8
+ export * from "./createAutocompleteStorage.js";
@@ -8,6 +8,7 @@ export type ChatClassNames = {
8
8
  container?: string | string[];
9
9
  header?: ChatHeaderProps['classNames'];
10
10
  messages?: ChatMessagesProps['classNames'];
11
+ message?: ChatMessagesProps['messageClassNames'];
11
12
  prompt?: ChatPromptProps['classNames'];
12
13
  toggleButton?: ChatToggleButtonProps['classNames'];
13
14
  };
@@ -52,7 +52,8 @@ export function createChatComponent(_ref) {
52
52
  classNames: classNames.header,
53
53
  maximized: maximized
54
54
  })), createElement(ChatMessages, _extends({}, messagesProps, {
55
- classNames: classNames.messages
55
+ classNames: classNames.messages,
56
+ messageClassNames: classNames.message
56
57
  })), createElement(PromptComponent || ChatPrompt, _objectSpread(_objectSpread({}, promptProps), {}, {
57
58
  classNames: classNames.prompt
58
59
  }))), createElement("div", {
@@ -77,6 +77,9 @@ export function createChatMessageComponent(_ref) {
77
77
  toolCallId: toolMessage.toolCallId
78
78
  });
79
79
  };
80
+ if (!ToolLayoutComponent) {
81
+ return null;
82
+ }
80
83
  return createElement("div", {
81
84
  key: "".concat(message.id, "-").concat(index),
82
85
  className: "ais-ChatMessage-tool"
@@ -1,6 +1,6 @@
1
1
  /** @jsx createElement */
2
2
  import type { ComponentProps, MutableRef, Renderer } from '../../types';
3
- import type { ChatMessageProps } from './ChatMessage';
3
+ import type { ChatMessageProps, ChatMessageClassNames, ChatMessageTranslations } from './ChatMessage';
4
4
  import type { ChatMessageErrorProps } from './ChatMessageError';
5
5
  import type { ChatMessageLoaderProps } from './ChatMessageLoader';
6
6
  import type { ChatMessageBase, ChatStatus, ClientSideTools } from './types';
@@ -99,10 +99,18 @@ export type ChatMessagesProps<TMessage extends ChatMessageBase = ChatMessageBase
99
99
  * Optional class names
100
100
  */
101
101
  classNames?: Partial<ChatMessagesClassNames>;
102
+ /**
103
+ * Optional message class names
104
+ */
105
+ messageClassNames?: Partial<ChatMessageClassNames>;
102
106
  /**
103
107
  * Optional translations
104
108
  */
105
109
  translations?: Partial<ChatMessagesTranslations>;
110
+ /**
111
+ * Optional message translations
112
+ */
113
+ messageTranslations?: Partial<ChatMessageTranslations>;
106
114
  /**
107
115
  * Optional user message props
108
116
  */
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import _extends from "@babel/runtime/helpers/extends";
4
4
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
5
- var _excluded = ["classNames", "messages", "messageComponent", "loaderComponent", "errorComponent", "actionsComponent", "tools", "indexUiState", "setIndexUiState", "status", "hideScrollToBottom", "onReload", "onClose", "translations", "userMessageProps", "assistantMessageProps", "isClearing", "onClearTransitionEnd", "isScrollAtBottom", "scrollRef", "contentRef", "onScrollToBottom"];
5
+ 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"];
6
6
  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; }
7
7
  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) { _defineProperty(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; }
8
8
  import { cx } from "../../lib/index.js";
@@ -38,8 +38,10 @@ function createDefaultMessageComponent(_ref) {
38
38
  setIndexUiState = _ref2.setIndexUiState,
39
39
  onReload = _ref2.onReload,
40
40
  onClose = _ref2.onClose,
41
- translations = _ref2.translations,
42
- actionsComponent = _ref2.actionsComponent;
41
+ actionsComponent = _ref2.actionsComponent,
42
+ classNames = _ref2.classNames,
43
+ messageTranslations = _ref2.messageTranslations,
44
+ translations = _ref2.translations;
43
45
  var defaultAssistantActions = [].concat(_toConsumableArray(hasTextContent(message) ? [{
44
46
  title: translations.copyToClipboardLabel,
45
47
  icon: function icon() {
@@ -71,7 +73,9 @@ function createDefaultMessageComponent(_ref) {
71
73
  onClose: onClose,
72
74
  actions: defaultActions,
73
75
  actionsComponent: actionsComponent,
74
- "data-role": message.role
76
+ "data-role": message.role,
77
+ classNames: classNames,
78
+ translations: messageTranslations
75
79
  }, messageProps));
76
80
  };
77
81
  }
@@ -94,6 +98,9 @@ export function createChatMessagesComponent(_ref3) {
94
98
  return function ChatMessages(userProps) {
95
99
  var _userProps$classNames = userProps.classNames,
96
100
  classNames = _userProps$classNames === void 0 ? {} : _userProps$classNames,
101
+ _userProps$messageCla = userProps.messageClassNames,
102
+ messageClassNames = _userProps$messageCla === void 0 ? {} : _userProps$messageCla,
103
+ messageTranslations = userProps.messageTranslations,
97
104
  _userProps$messages = userProps.messages,
98
105
  messages = _userProps$messages === void 0 ? [] : _userProps$messages,
99
106
  MessageComponent = userProps.messageComponent,
@@ -162,7 +169,9 @@ export function createChatMessagesComponent(_ref3) {
162
169
  onReload: onReload,
163
170
  actionsComponent: ActionsComponent,
164
171
  onClose: onClose,
165
- translations: translations
172
+ translations: translations,
173
+ classNames: messageClassNames,
174
+ messageTranslations: messageTranslations
166
175
  });
167
176
  }), status === 'submitted' && createElement(DefaultLoader, {
168
177
  translations: {