@memori.ai/memori-react 2.8.3 → 2.9.1
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/CHANGELOG.md +19 -0
- package/README.md +30 -29
- package/dist/components/MemoriWidget/MemoriWidget.d.ts +2 -1
- package/dist/components/MemoriWidget/MemoriWidget.js +2 -2
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/SettingsDrawer/SettingsDrawer.d.ts +2 -1
- package/dist/components/SettingsDrawer/SettingsDrawer.js +2 -2
- package/dist/components/SettingsDrawer/SettingsDrawer.js.map +1 -1
- package/dist/components/SettingsDrawer/SettingsDrawer.test.js +9 -0
- package/dist/components/SettingsDrawer/SettingsDrawer.test.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.d.ts +2 -1
- package/esm/components/MemoriWidget/MemoriWidget.js +2 -2
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/SettingsDrawer/SettingsDrawer.d.ts +2 -1
- package/esm/components/SettingsDrawer/SettingsDrawer.js +2 -2
- package/esm/components/SettingsDrawer/SettingsDrawer.js.map +1 -1
- package/esm/components/SettingsDrawer/SettingsDrawer.test.js +10 -1
- package/esm/components/SettingsDrawer/SettingsDrawer.test.js.map +1 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.js +6 -2
- package/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/MemoriWidget/MemoriWidget.tsx +3 -0
- package/src/components/SettingsDrawer/SettingsDrawer.stories.tsx +28 -0
- package/src/components/SettingsDrawer/SettingsDrawer.test.tsx +37 -0
- package/src/components/SettingsDrawer/SettingsDrawer.tsx +8 -0
- package/src/components/SettingsDrawer/__snapshots__/SettingsDrawer.test.tsx.snap +8 -0
- package/src/index.tsx +10 -1
|
@@ -60,3 +60,31 @@ WithinTotemLayout.args = {
|
|
|
60
60
|
setContinuousSpeech: () => {},
|
|
61
61
|
setContinuousSpeechTimeout: () => {},
|
|
62
62
|
};
|
|
63
|
+
|
|
64
|
+
const AdditionalSettings = () => {
|
|
65
|
+
const [hideEmissions, setHideEmissions] = React.useState(false);
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<div>
|
|
69
|
+
<label htmlFor="#hideEmissions">Hide emissions:</label>
|
|
70
|
+
<input
|
|
71
|
+
id="hideEmissions"
|
|
72
|
+
name="hideEmissions"
|
|
73
|
+
type="checkbox"
|
|
74
|
+
checked={hideEmissions}
|
|
75
|
+
onChange={e => setHideEmissions(e.target.checked)}
|
|
76
|
+
/>
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const WithAdditionalSettings = Template.bind({});
|
|
82
|
+
WithAdditionalSettings.args = {
|
|
83
|
+
open: true,
|
|
84
|
+
onClose: () => {},
|
|
85
|
+
continuousSpeech: false,
|
|
86
|
+
continuousSpeechTimeout: 2,
|
|
87
|
+
setContinuousSpeech: () => {},
|
|
88
|
+
setContinuousSpeechTimeout: () => {},
|
|
89
|
+
additionalSettings: <AdditionalSettings />,
|
|
90
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { render } from '@testing-library/react';
|
|
2
2
|
import SettingsDrawer from './SettingsDrawer';
|
|
3
|
+
import React from 'react';
|
|
3
4
|
|
|
4
5
|
beforeEach(() => {
|
|
5
6
|
// @ts-ignore
|
|
@@ -139,3 +140,39 @@ it('renders SettingsDrawer for totem layout with continuous speech and hide emis
|
|
|
139
140
|
);
|
|
140
141
|
expect(container).toMatchSnapshot();
|
|
141
142
|
});
|
|
143
|
+
|
|
144
|
+
const AdditionalSettings = () => {
|
|
145
|
+
const [hideEmissions, setHideEmissions] = React.useState(false);
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<div>
|
|
149
|
+
<label htmlFor="#hideEmissions">Hide emissions:</label>
|
|
150
|
+
<input
|
|
151
|
+
id="hideEmissions"
|
|
152
|
+
name="hideEmissions"
|
|
153
|
+
type="checkbox"
|
|
154
|
+
checked={hideEmissions}
|
|
155
|
+
onChange={e => setHideEmissions(e.target.checked)}
|
|
156
|
+
/>
|
|
157
|
+
</div>
|
|
158
|
+
);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
it('renders SettingsDrawer with additional custom settings unchanged', () => {
|
|
162
|
+
const { container } = render(
|
|
163
|
+
<SettingsDrawer
|
|
164
|
+
open={true}
|
|
165
|
+
onClose={jest.fn()}
|
|
166
|
+
microphoneMode="HOLD_TO_TALK"
|
|
167
|
+
setMicrophoneMode={jest.fn()}
|
|
168
|
+
continuousSpeechTimeout={2}
|
|
169
|
+
setContinuousSpeechTimeout={jest.fn()}
|
|
170
|
+
controlsPosition="bottom"
|
|
171
|
+
setControlsPosition={jest.fn()}
|
|
172
|
+
hideEmissions={false}
|
|
173
|
+
setHideEmissions={jest.fn()}
|
|
174
|
+
additionalSettings={<AdditionalSettings />}
|
|
175
|
+
/>
|
|
176
|
+
);
|
|
177
|
+
expect(container).toMatchSnapshot();
|
|
178
|
+
});
|
|
@@ -19,6 +19,7 @@ export interface Props {
|
|
|
19
19
|
setControlsPosition: (value: 'center' | 'bottom') => void;
|
|
20
20
|
hideEmissions?: boolean;
|
|
21
21
|
setHideEmissions: (value: boolean) => void;
|
|
22
|
+
additionalSettings?: WidgetProps['additionalSettings'];
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
const silenceSeconds = [2, 3, 5, 10, 15, 20, 30, 60];
|
|
@@ -35,6 +36,7 @@ const SettingsDrawer = ({
|
|
|
35
36
|
setControlsPosition,
|
|
36
37
|
hideEmissions,
|
|
37
38
|
setHideEmissions,
|
|
39
|
+
additionalSettings,
|
|
38
40
|
}: Props) => {
|
|
39
41
|
const { t } = useTranslation();
|
|
40
42
|
|
|
@@ -151,6 +153,12 @@ const SettingsDrawer = ({
|
|
|
151
153
|
</div>
|
|
152
154
|
</>
|
|
153
155
|
)}
|
|
156
|
+
|
|
157
|
+
{additionalSettings && (
|
|
158
|
+
<div className="memori-settings-drawer--field controls">
|
|
159
|
+
{additionalSettings}
|
|
160
|
+
</div>
|
|
161
|
+
)}
|
|
154
162
|
</Drawer>
|
|
155
163
|
);
|
|
156
164
|
};
|
|
@@ -49,3 +49,11 @@ exports[`renders SettingsDrawer open with non-default continuous speech timeout
|
|
|
49
49
|
`;
|
|
50
50
|
|
|
51
51
|
exports[`renders SettingsDrawer unchanged 1`] = `<div />`;
|
|
52
|
+
|
|
53
|
+
exports[`renders SettingsDrawer with additional custom settings unchanged 1`] = `
|
|
54
|
+
<div>
|
|
55
|
+
<div
|
|
56
|
+
style="position: fixed; top: 1px; left: 1px; width: 1px; height: 0px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; border-width: 0px; display: none;"
|
|
57
|
+
/>
|
|
58
|
+
</div>
|
|
59
|
+
`;
|
package/src/index.tsx
CHANGED
|
@@ -41,6 +41,7 @@ export interface Props {
|
|
|
41
41
|
onStateChange?: (state?: DialogState) => void;
|
|
42
42
|
additionalInfo?: WidgetProps['additionalInfo'];
|
|
43
43
|
customMediaRenderer?: WidgetProps['customMediaRenderer'];
|
|
44
|
+
additionalSettings?: WidgetProps['additionalSettings'];
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
const getPreferredLanguages = () => {
|
|
@@ -89,6 +90,7 @@ const Memori: React.FC<Props> = ({
|
|
|
89
90
|
onStateChange,
|
|
90
91
|
additionalInfo,
|
|
91
92
|
customMediaRenderer,
|
|
93
|
+
additionalSettings,
|
|
92
94
|
}) => {
|
|
93
95
|
const [memori, setMemori] = useState<IMemori>();
|
|
94
96
|
const [speechKey, setSpeechKey] = useState<string | undefined>(
|
|
@@ -216,10 +218,17 @@ const Memori: React.FC<Props> = ({
|
|
|
216
218
|
onStateChange={onStateChange}
|
|
217
219
|
additionalInfo={additionalInfo}
|
|
218
220
|
customMediaRenderer={customMediaRenderer}
|
|
221
|
+
additionalSettings={additionalSettings}
|
|
219
222
|
{...(tag && pin ? { personification: { tag, pin } } : {})}
|
|
220
223
|
/>
|
|
221
224
|
) : (
|
|
222
|
-
<div
|
|
225
|
+
<div
|
|
226
|
+
style={{
|
|
227
|
+
display: 'flex',
|
|
228
|
+
alignItems: 'center',
|
|
229
|
+
justifyContent: 'center',
|
|
230
|
+
}}
|
|
231
|
+
>
|
|
223
232
|
<p style={{ textAlign: 'center', margin: '2rem auto' }}>
|
|
224
233
|
{t('loading')}...
|
|
225
234
|
</p>
|