@memori.ai/memori-react 2.23.0 → 3.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.
Files changed (71) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/I18nWrapper.d.ts +6 -0
  3. package/dist/I18nWrapper.js +9 -0
  4. package/dist/I18nWrapper.js.map +1 -0
  5. package/dist/components/ChatTextArea/ChatTextArea.js +3 -1
  6. package/dist/components/ChatTextArea/ChatTextArea.js.map +1 -1
  7. package/dist/components/ImageUpload/ImageUpload.js +3 -1
  8. package/dist/components/ImageUpload/ImageUpload.js.map +1 -1
  9. package/dist/i18n.d.ts +1 -1
  10. package/dist/i18n.js +4 -4
  11. package/dist/i18n.js.map +1 -1
  12. package/dist/index.js +7 -2
  13. package/dist/index.js.map +1 -1
  14. package/dist/locales/en.json +1 -0
  15. package/dist/locales/it.json +1 -0
  16. package/esm/I18nWrapper.d.ts +6 -0
  17. package/esm/I18nWrapper.js +6 -0
  18. package/esm/I18nWrapper.js.map +1 -0
  19. package/esm/components/ChatTextArea/ChatTextArea.js +3 -1
  20. package/esm/components/ChatTextArea/ChatTextArea.js.map +1 -1
  21. package/esm/components/ImageUpload/ImageUpload.js +3 -1
  22. package/esm/components/ImageUpload/ImageUpload.js.map +1 -1
  23. package/esm/i18n.d.ts +1 -1
  24. package/esm/i18n.js +3 -3
  25. package/esm/i18n.js.map +1 -1
  26. package/esm/index.js +8 -3
  27. package/esm/index.js.map +1 -1
  28. package/esm/locales/en.json +1 -0
  29. package/esm/locales/it.json +1 -0
  30. package/package.json +1 -1
  31. package/src/I18nWrapper.tsx +13 -0
  32. package/src/components/AgeVerificationModal/AgeVerificationModal.stories.tsx +6 -1
  33. package/src/components/AttachmentLinkModal/AttachmentLinkModal.stories.tsx +6 -1
  34. package/src/components/AttachmentMediaModal/AttachmentMediaModal.stories.tsx +6 -1
  35. package/src/components/Auth/Auth.stories.tsx +16 -11
  36. package/src/components/Avatar/Avatar.stories.tsx +28 -25
  37. package/src/components/AvatarView/AvatarView.stories.tsx +8 -5
  38. package/src/components/Blob/Blob.stories.tsx +6 -3
  39. package/src/components/BlockedMemoriBadge/BlockedMemoriBadge.stories.tsx +6 -1
  40. package/src/components/ChangeMode/ChangeMode.stories.tsx +9 -6
  41. package/src/components/Chat/Chat.stories.tsx +8 -5
  42. package/src/components/Chat/__snapshots__/Chat.test.tsx.snap +11 -0
  43. package/src/components/ChatBubble/ChatBubble.stories.tsx +6 -2
  44. package/src/components/ChatInputs/ChatInputs.stories.tsx +13 -10
  45. package/src/components/ChatInputs/__snapshots__/ChatInputs.test.tsx.snap +6 -0
  46. package/src/components/ChatTextArea/ChatTextArea.stories.tsx +6 -3
  47. package/src/components/ChatTextArea/ChatTextArea.tsx +5 -0
  48. package/src/components/ChatTextArea/__snapshots__/ChatTextArea.test.tsx.snap +3 -0
  49. package/src/components/CompletionProviderStatus/CompletionProviderStatus.stories.tsx +6 -1
  50. package/src/components/DateSelector/DateSelector.stories.tsx +6 -2
  51. package/src/components/ExportHistoryButton/ExportHistoryButton.stories.tsx +11 -6
  52. package/src/components/FeedbackButtons/FeedbackButtons.stories.tsx +6 -2
  53. package/src/components/Header/Header.stories.tsx +4 -3
  54. package/src/components/ImageUpload/ImageUpload.stories.tsx +6 -2
  55. package/src/components/ImageUpload/ImageUpload.tsx +5 -2
  56. package/src/components/MediaWidget/LinkItemWidget.stories.tsx +6 -1
  57. package/src/components/MediaWidget/MediaItemWidget.stories.tsx +6 -1
  58. package/src/components/MediaWidget/MediaWidget.stories.tsx +6 -1
  59. package/src/components/MemoriWidget/MemoriWidget.stories.tsx +6 -2
  60. package/src/components/MicrophoneButton/MicrophoneButton.stories.tsx +11 -8
  61. package/src/components/SendOnEnterMenu/SendOnEnterMenu.stories.tsx +17 -13
  62. package/src/components/SettingsDrawer/SettingsDrawer.stories.tsx +11 -7
  63. package/src/components/ShareButton/ShareButton.stories.tsx +11 -4
  64. package/src/components/Snippet/Snippet.stories.tsx +12 -9
  65. package/src/components/StartPanel/StartPanel.stories.tsx +9 -6
  66. package/src/components/Typing/Typing.stories.tsx +6 -2
  67. package/src/components/UploadMenu/UploadMenu.stories.tsx +16 -13
  68. package/src/i18n.ts +4 -3
  69. package/src/index.tsx +12 -4
  70. package/src/locales/en.json +1 -0
  71. package/src/locales/it.json +1 -0
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Meta, Story } from '@storybook/react';
3
+ import I18nWrapper from '../../I18nWrapper';
3
4
  import MediaWidget, { Props } from './MediaWidget';
4
5
  import {
5
6
  Medium,
@@ -92,7 +93,11 @@ const hints: TranslatedHint[] = [
92
93
  },
93
94
  ];
94
95
 
95
- const Template: Story<Props> = args => <MediaWidget {...args} />;
96
+ const Template: Story<Props> = args => (
97
+ <I18nWrapper>
98
+ <MediaWidget {...args} />
99
+ </I18nWrapper>
100
+ );
96
101
 
97
102
  // By passing using the Args format for exported stories, you can control the props for a component for reuse in a test
98
103
  // https://storybook.js.org/docs/react/workflows/unit-testing
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Meta, Story } from '@storybook/react';
3
3
  import { memori, integration, tenant } from '../../mocks/data';
4
+ import I18nWrapper from '../../I18nWrapper';
4
5
  import MemoriWidget, { Props } from './MemoriWidget';
5
6
 
6
7
  import './MemoriWidget.css';
@@ -33,8 +34,11 @@ const meta: Meta = {
33
34
 
34
35
  export default meta;
35
36
 
36
- const Template: Story<Props> = args => <MemoriWidget {...args} />;
37
-
37
+ const Template: Story<Props> = args => (
38
+ <I18nWrapper>
39
+ <MemoriWidget {...args} />
40
+ </I18nWrapper>
41
+ );
38
42
  // By passing using the Args format for exported stories, you can control the props for a component for reuse in a test
39
43
  // https://storybook.js.org/docs/react/workflows/unit-testing
40
44
  export const Default = Template.bind({});
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Meta, Story } from '@storybook/react';
3
+ import I18nWrapper from '../../I18nWrapper';
3
4
  import MicrophoneButton, { Props } from './MicrophoneButton';
4
5
 
5
6
  import './MicrophoneButton.css';
@@ -27,14 +28,16 @@ const Template: Story<Props> = args => {
27
28
  const stopListening = () => setListening(false);
28
29
 
29
30
  return (
30
- <div style={{ paddingTop: '10rem', textAlign: 'right' }}>
31
- <MicrophoneButton
32
- {...args}
33
- listening={listening}
34
- startListening={startListening}
35
- stopListening={stopListening}
36
- />
37
- </div>
31
+ <I18nWrapper>
32
+ <div style={{ paddingTop: '10rem', textAlign: 'right' }}>
33
+ <MicrophoneButton
34
+ {...args}
35
+ listening={listening}
36
+ startListening={startListening}
37
+ stopListening={stopListening}
38
+ />
39
+ </div>
40
+ </I18nWrapper>
38
41
  );
39
42
  };
40
43
 
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Meta, Story } from '@storybook/react';
3
+ import I18nWrapper from '../../I18nWrapper';
3
4
  import SendOnEnterMenu, { Props } from './SendOnEnterMenu';
4
5
 
5
6
  import './SendOnEnterMenu.css';
@@ -24,20 +25,23 @@ export default meta;
24
25
 
25
26
  const Template: Story<Props> = args => {
26
27
  const [sendOnEnter, setSendOnEnter] = React.useState(args.sendOnEnter);
28
+
27
29
  return (
28
- <div
29
- style={{
30
- minHeight: '200px',
31
- display: 'flex',
32
- alignItems: 'flex-end',
33
- }}
34
- >
35
- <SendOnEnterMenu
36
- {...args}
37
- sendOnEnter={sendOnEnter}
38
- setSendOnEnter={setSendOnEnter}
39
- />
40
- </div>
30
+ <I18nWrapper>
31
+ <div
32
+ style={{
33
+ minHeight: '200px',
34
+ display: 'flex',
35
+ alignItems: 'flex-end',
36
+ }}
37
+ >
38
+ <SendOnEnterMenu
39
+ {...args}
40
+ sendOnEnter={sendOnEnter}
41
+ setSendOnEnter={setSendOnEnter}
42
+ />
43
+ </div>
44
+ </I18nWrapper>
41
45
  );
42
46
  };
43
47
 
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Meta, Story } from '@storybook/react';
3
+ import I18nWrapper from '../../I18nWrapper';
3
4
  import SettingsDrawer, { Props } from './SettingsDrawer';
4
5
  import './SettingsDrawer.css';
5
6
 
@@ -27,14 +28,17 @@ const Template: Story<Props> = args => {
27
28
  const [controlsPosition, setControlsPosition] = React.useState<
28
29
  'bottom' | 'center'
29
30
  >('bottom');
31
+
30
32
  return (
31
- <SettingsDrawer
32
- {...args}
33
- microphoneMode={microphoneMode}
34
- setMicrophoneMode={setMicrophoneMode}
35
- controlsPosition={controlsPosition}
36
- setControlsPosition={setControlsPosition}
37
- />
33
+ <I18nWrapper>
34
+ <SettingsDrawer
35
+ {...args}
36
+ microphoneMode={microphoneMode}
37
+ setMicrophoneMode={setMicrophoneMode}
38
+ controlsPosition={controlsPosition}
39
+ setControlsPosition={setControlsPosition}
40
+ />
41
+ </I18nWrapper>
38
42
  );
39
43
  };
40
44
 
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Meta, Story } from '@storybook/react';
3
+ import I18nWrapper from '../../I18nWrapper';
3
4
  import ShareButton, { Props } from './ShareButton';
4
5
  import { tenant } from '../../mocks/data';
5
6
 
@@ -27,11 +28,17 @@ const meta: Meta = {
27
28
 
28
29
  export default meta;
29
30
 
30
- const Template: Story<Props> = args => <ShareButton {...args} />;
31
- const TemplateRight: Story<Props> = args => (
32
- <div style={{ textAlign: 'right' }}>
31
+ const Template: Story<Props> = args => (
32
+ <I18nWrapper>
33
33
  <ShareButton {...args} />
34
- </div>
34
+ </I18nWrapper>
35
+ );
36
+ const TemplateRight: Story<Props> = args => (
37
+ <I18nWrapper>
38
+ <div style={{ textAlign: 'right' }}>
39
+ <ShareButton {...args} />
40
+ </div>
41
+ </I18nWrapper>
35
42
  );
36
43
 
37
44
  export const Default = Template.bind({});
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Meta, Story } from '@storybook/react';
3
+ import I18nWrapper from '../../I18nWrapper';
3
4
  import Snippet from './Snippet';
4
5
  import { prismSyntaxLangs } from '../../helpers/constants';
5
6
 
@@ -82,15 +83,17 @@ const Template: Story<{
82
83
  content: string;
83
84
  preview?: boolean;
84
85
  }> = args => (
85
- <Snippet
86
- {...args}
87
- medium={{
88
- mediumID: '95226d7e-7bae-465e-8b80-995587bb5971',
89
- mimeType: args.mimeType,
90
- title: 'Snippet',
91
- content: args.content,
92
- }}
93
- />
86
+ <I18nWrapper>
87
+ <Snippet
88
+ {...args}
89
+ medium={{
90
+ mediumID: '95226d7e-7bae-465e-8b80-995587bb5971',
91
+ mimeType: args.mimeType,
92
+ title: 'Snippet',
93
+ content: args.content,
94
+ }}
95
+ />
96
+ </I18nWrapper>
94
97
  );
95
98
 
96
99
  // By passing using the Args format for exported stories, you can control the props for a component for reuse in a test
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Meta, Story } from '@storybook/react';
3
+ import I18nWrapper from '../../I18nWrapper';
3
4
  import { memori, sessionID, integration, tenant } from '../../mocks/data';
4
5
  import StartPanel, { Props } from './StartPanel';
5
6
 
@@ -80,12 +81,14 @@ const integrationStylesheet = `
80
81
  `;
81
82
 
82
83
  const Template: Story<Props> = args => (
83
- <div style={{ maxWidth: '600px', margin: 'auto' }}>
84
- {args.integrationConfig && (
85
- <style dangerouslySetInnerHTML={{ __html: integrationStylesheet }} />
86
- )}
87
- <StartPanel {...args} />
88
- </div>
84
+ <I18nWrapper>
85
+ <div style={{ maxWidth: '600px', margin: 'auto' }}>
86
+ {args.integrationConfig && (
87
+ <style dangerouslySetInnerHTML={{ __html: integrationStylesheet }} />
88
+ )}
89
+ <StartPanel {...args} />
90
+ </div>
91
+ </I18nWrapper>
89
92
  );
90
93
 
91
94
  // By passing using the Args format for exported stories, you can control the props for a component for reuse in a test
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Meta, Story } from '@storybook/react';
3
+ import I18nWrapper from '../../I18nWrapper';
3
4
  import Typing, { Props } from './Typing';
4
5
 
5
6
  const meta: Meta = {
@@ -30,8 +31,11 @@ const meta: Meta = {
30
31
 
31
32
  export default meta;
32
33
 
33
- const Template: Story<Props> = args => <Typing {...args} />;
34
-
34
+ const Template: Story<Props> = args => (
35
+ <I18nWrapper>
36
+ <Typing {...args} />
37
+ </I18nWrapper>
38
+ );
35
39
  // By passing using the Args format for exported stories, you can control the props for a component for reuse in a test
36
40
  // https://storybook.js.org/docs/react/workflows/unit-testing
37
41
  export const Default = Template.bind({});
@@ -1,5 +1,6 @@
1
1
  import React, { useState } from 'react';
2
2
  import { Meta, Story } from '@storybook/react';
3
+ import I18nWrapper from '../../I18nWrapper';
3
4
  import UploadMenu, { Props } from './UploadMenu';
4
5
 
5
6
  import './UploadMenu.css';
@@ -27,19 +28,21 @@ const Template: Story<Props> = args => {
27
28
  'link' | 'media' | undefined
28
29
  >(args.attachmentsMenuOpen);
29
30
  return (
30
- <div
31
- style={{
32
- minHeight: '200px',
33
- display: 'flex',
34
- alignItems: 'flex-end',
35
- }}
36
- >
37
- <UploadMenu
38
- {...args}
39
- attachmentsMenuOpen={attachmentsMenuOpen}
40
- setAttachmentsMenuOpen={setAttachmentsMenuOpen}
41
- />
42
- </div>
31
+ <I18nWrapper>
32
+ <div
33
+ style={{
34
+ minHeight: '200px',
35
+ display: 'flex',
36
+ alignItems: 'flex-end',
37
+ }}
38
+ >
39
+ <UploadMenu
40
+ {...args}
41
+ attachmentsMenuOpen={attachmentsMenuOpen}
42
+ setAttachmentsMenuOpen={setAttachmentsMenuOpen}
43
+ />
44
+ </div>
45
+ </I18nWrapper>
43
46
  );
44
47
  };
45
48
 
package/src/i18n.ts CHANGED
@@ -1,5 +1,4 @@
1
- import i18n from 'i18next';
2
- import { initReactI18next } from 'react-i18next';
1
+ import { createInstance } from 'i18next';
3
2
  import it from './locales/it.json';
4
3
  import en from './locales/en.json';
5
4
 
@@ -12,7 +11,7 @@ const resources = {
12
11
  },
13
12
  };
14
13
 
15
- i18n.use(initReactI18next).init({
14
+ const i18n = createInstance({
16
15
  resources,
17
16
  lng: 'en',
18
17
  fallbackLng: 'it',
@@ -23,4 +22,6 @@ i18n.use(initReactI18next).init({
23
22
  },
24
23
  });
25
24
 
25
+ i18n.init();
26
+
26
27
  export default i18n;
package/src/index.tsx CHANGED
@@ -12,7 +12,7 @@ import MemoriWidget, {
12
12
  import { getTenant } from './helpers/tenant';
13
13
 
14
14
  import i18n from './i18n';
15
- import { useTranslation } from 'react-i18next';
15
+ import { I18nextProvider, useTranslation } from 'react-i18next';
16
16
 
17
17
  export interface Props {
18
18
  memoriName?: string | null;
@@ -202,7 +202,7 @@ const Memori: React.FC<Props> = ({
202
202
  }
203
203
  }, [uiLang]);
204
204
 
205
- return memori ? (
205
+ const renderer = memori ? (
206
206
  <MemoriWidget
207
207
  layout={layout}
208
208
  customLayout={customLayout}
@@ -256,11 +256,19 @@ const Memori: React.FC<Props> = ({
256
256
  justifyContent: 'center',
257
257
  }}
258
258
  >
259
- <p style={{ textAlign: 'center', margin: '2rem auto' }}>
260
- {t('loading')}...
259
+ <p
260
+ style={{
261
+ textAlign: 'center',
262
+ margin: '2rem auto',
263
+ textTransform: 'capitalize',
264
+ }}
265
+ >
266
+ {t('loading') || 'Loading'}...
261
267
  </p>
262
268
  </div>
263
269
  );
270
+
271
+ return <I18nextProvider i18n={i18n}>{renderer}</I18nextProvider>;
264
272
  };
265
273
 
266
274
  Memori.propTypes = {
@@ -12,6 +12,7 @@
12
12
  "delete": "Delete",
13
13
  "loading": "Loading",
14
14
  "expand": "Expand",
15
+ "collapse": "Collapse",
15
16
  "fullscreenEnter": "Enter fullscreen",
16
17
  "fullscreenExit": "Exit fullscreen",
17
18
  "center": "Center",
@@ -12,6 +12,7 @@
12
12
  "delete": "Elimina",
13
13
  "loading": "Caricamento",
14
14
  "expand": "Espandi",
15
+ "collapse": "Riduci",
15
16
  "fullscreenEnter": "Passa a schermo intero",
16
17
  "fullscreenExit": "Esci da schermo intero",
17
18
  "center": "Centro",