@memori.ai/memori-react 6.4.0 → 6.4.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 +17 -0
- package/dist/components/WhyThisAnswer/WhyThisAnswer.css +58 -3
- package/dist/components/WhyThisAnswer/WhyThisAnswer.d.ts +2 -1
- package/dist/components/WhyThisAnswer/WhyThisAnswer.js +9 -10
- package/dist/components/WhyThisAnswer/WhyThisAnswer.js.map +1 -1
- package/dist/components/ui/Expandable.d.ts +2 -1
- package/dist/components/ui/Expandable.js +2 -2
- package/dist/components/ui/Expandable.js.map +1 -1
- package/esm/components/WhyThisAnswer/WhyThisAnswer.css +58 -3
- package/esm/components/WhyThisAnswer/WhyThisAnswer.d.ts +2 -1
- package/esm/components/WhyThisAnswer/WhyThisAnswer.js +9 -10
- package/esm/components/WhyThisAnswer/WhyThisAnswer.js.map +1 -1
- package/esm/components/ui/Expandable.d.ts +2 -1
- package/esm/components/ui/Expandable.js +2 -2
- package/esm/components/ui/Expandable.js.map +1 -1
- package/package.json +1 -1
- package/src/components/WhyThisAnswer/WhyThisAnswer.css +58 -3
- package/src/components/WhyThisAnswer/WhyThisAnswer.stories.tsx +43 -20
- package/src/components/WhyThisAnswer/WhyThisAnswer.tsx +67 -17
- package/src/components/ui/Expandable.tsx +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
## [6.4.1](https://github.com/memori-ai/memori-react/compare/v6.4.0...v6.4.1) (2024-04-30)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* why this answer loading spin with skeleton ([45ecf68](https://github.com/memori-ai/memori-react/commit/45ecf68463cab21e775bebd42733333936f8b60c))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Maintenance
|
|
12
|
+
|
|
13
|
+
* show max 3 contents in why this answer ([29c9114](https://github.com/memori-ai/memori-react/commit/29c91148eba5f14b5a51cc00b22ec6b7f1cc0464))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Changes
|
|
17
|
+
|
|
18
|
+
* why this answer links + multiline source with expand ([10ff06d](https://github.com/memori-ai/memori-react/commit/10ff06de610aafec725965106902133cae0e45f2))
|
|
19
|
+
|
|
3
20
|
## [6.4.0](https://github.com/memori-ai/memori-react/compare/v6.3.1...v6.4.0) (2024-04-29)
|
|
4
21
|
|
|
5
22
|
|
|
@@ -64,10 +64,65 @@ ul.memori--whythisanswer-list li:last-child {
|
|
|
64
64
|
margin: 0;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
.memori-whythisanswer-drawer .memori-
|
|
67
|
+
.memori-whythisanswer-drawer .memori-snippet--content {
|
|
68
|
+
font-size: 0.75rem;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.memori-whythisanswer-drawer .memori-card--content {
|
|
72
|
+
padding: 1rem;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.memori-whythisanswer-drawer .memori-card--cover {
|
|
68
76
|
display: none;
|
|
69
77
|
}
|
|
70
78
|
|
|
71
|
-
.memori-whythisanswer-drawer .memori-
|
|
72
|
-
|
|
79
|
+
.memori-whythisanswer-drawer .memori-card--title {
|
|
80
|
+
margin-bottom: 0;
|
|
81
|
+
font-size: 1rem;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.memori--whythisanswer-snippet-expandable {
|
|
85
|
+
min-height: 54px;
|
|
86
|
+
line-height: 40px;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.memori-whythisanswer-drawer .memori-card--description {
|
|
90
|
+
display: none;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.memori--whythisanswer-skeleton {
|
|
94
|
+
min-height: 12rem;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.memori--whythisanswer-skeleton-text {
|
|
98
|
+
padding: 0.5rem;
|
|
99
|
+
border-radius: var(--memori-border-radius);
|
|
100
|
+
margin-bottom: 0.5rem;
|
|
101
|
+
background: #ccc;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
span.memori--whythisanswer-skeleton-text {
|
|
105
|
+
display: inline;
|
|
106
|
+
width: 3rem;
|
|
107
|
+
padding: 0 1rem;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
p.memori--whythisanswer-skeleton-text {
|
|
111
|
+
display: block;
|
|
112
|
+
width: 100%;
|
|
113
|
+
min-width: 6rem;
|
|
114
|
+
margin-bottom: 0.5rem;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
div.memori--whythisanswer-skeleton-text {
|
|
118
|
+
display: block;
|
|
119
|
+
width: 75%;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.memori--whythisanswer-skeleton-block {
|
|
123
|
+
height: 3rem;
|
|
124
|
+
padding: 0.5rem;
|
|
125
|
+
border-radius: var(--memori-border-radius);
|
|
126
|
+
margin-bottom: 0.5rem;
|
|
127
|
+
background: #ccc;
|
|
73
128
|
}
|
|
@@ -6,6 +6,7 @@ export interface Props {
|
|
|
6
6
|
initialMatches?: SearchMatches[];
|
|
7
7
|
visible?: boolean;
|
|
8
8
|
closeDrawer: () => void;
|
|
9
|
+
_TEST_loading?: boolean;
|
|
9
10
|
}
|
|
10
|
-
declare const WhyThisAnswer: ({ message, apiURL, sessionID, visible, initialMatches, closeDrawer, }: Props) => JSX.Element;
|
|
11
|
+
declare const WhyThisAnswer: ({ message, apiURL, sessionID, visible, initialMatches, closeDrawer, _TEST_loading, }: Props) => JSX.Element;
|
|
11
12
|
export default WhyThisAnswer;
|
|
@@ -11,19 +11,22 @@ const react_hot_toast_1 = tslib_1.__importDefault(require("react-hot-toast"));
|
|
|
11
11
|
const error_1 = require("../../helpers/error");
|
|
12
12
|
const react_i18next_1 = require("react-i18next");
|
|
13
13
|
const Snippet_1 = tslib_1.__importDefault(require("../Snippet/Snippet"));
|
|
14
|
+
const MediaWidget_1 = tslib_1.__importDefault(require("../MediaWidget/MediaWidget"));
|
|
14
15
|
const addQuestionMark = (question) => question.endsWith('?') ? question : `${question}?`;
|
|
15
|
-
const WhyThisAnswer = ({ message, apiURL, sessionID, visible = true, initialMatches = [], closeDrawer, }) => {
|
|
16
|
+
const WhyThisAnswer = ({ message, apiURL, sessionID, visible = true, initialMatches = [], closeDrawer, _TEST_loading = false, }) => {
|
|
16
17
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
17
18
|
const client = (0, memori_api_client_1.default)(apiURL);
|
|
18
19
|
const searchMemory = client.search.searchMemory;
|
|
19
20
|
const [matches, setMatches] = (0, react_1.useState)(initialMatches);
|
|
20
|
-
const [loading, setLoading] = (0, react_1.useState)(
|
|
21
|
+
const [loading, setLoading] = (0, react_1.useState)(_TEST_loading);
|
|
21
22
|
const fetchMemories = (0, react_1.useCallback)(async () => {
|
|
22
23
|
setLoading(true);
|
|
24
|
+
if (_TEST_loading)
|
|
25
|
+
return;
|
|
23
26
|
try {
|
|
24
27
|
const { matches, ...response } = await searchMemory(sessionID, {
|
|
25
28
|
searchType: 'Semantic',
|
|
26
|
-
numberOfResults:
|
|
29
|
+
numberOfResults: 3,
|
|
27
30
|
text: message.questionAnswered,
|
|
28
31
|
date: message.date,
|
|
29
32
|
placeName: message.placeName,
|
|
@@ -49,13 +52,9 @@ const WhyThisAnswer = ({ message, apiURL, sessionID, visible = true, initialMatc
|
|
|
49
52
|
(0, react_1.useEffect)(() => {
|
|
50
53
|
fetchMemories();
|
|
51
54
|
}, [fetchMemories, message, sessionID]);
|
|
52
|
-
return ((0, jsx_runtime_1.jsxs)(Drawer_1.default, { open: visible, width: "80%", animated: false, className: "memori-whythisanswer-drawer", onClose: () => closeDrawer(), title: t('whyThisAnswer'), children: [(0, jsx_runtime_1.jsx)("p", { children: t('whyThisAnswerHelper') }), message.questionAnswered && ((0, jsx_runtime_1.jsxs)("p", { className: "memori--whythisanswer-question-answered", children: [(0, jsx_runtime_1.jsxs)("strong", { children: [t('question') || 'Question', ":"] }), ' ', message.questionAnswered] })), (0, jsx_runtime_1.jsxs)(Spin_1.default, { spinning: loading, children: [!loading && matches.length === 0 && ((0, jsx_runtime_1.jsx)("p", { role: "info", className: "memori--whythisanswer-no-results", children: t('nothingFound') })), matches.length > 0 && ((0, jsx_runtime_1.jsx)("ul", { className: "memori--whythisanswer-list", children: matches.map(m => {
|
|
53
|
-
var _a, _b, _c, _d, _e, _f;
|
|
54
|
-
return ((0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsxs)("div", { className: "memori--whythisanswer-title", children: [(0, jsx_runtime_1.jsx)("span", { className: "memori--whythisanswer-confidence", children: m.confidenceLevel }), (0, jsx_runtime_1.jsxs)("div", { className: "memori--whythisanswer-title-text", children: [(0, jsx_runtime_1.jsx)("p", { children: (0, jsx_runtime_1.jsx)("strong", { children: addQuestionMark((_a = m.memory.title) !== null && _a !== void 0 ? _a : '') }) }), (0, jsx_runtime_1.jsx)("p", { children: (_c = (_b = m.memory.titleVariants) === null || _b === void 0 ? void 0 : _b.map(t => addQuestionMark(t))) === null || _c === void 0 ? void 0 : _c.join(' | ') })] })] }), (_d = m.memory.answers) === null || _d === void 0 ? void 0 : _d.map((a, i) => ((0, jsx_runtime_1.jsx)("p", { className: "memori--whythisanswer-answer", children: (0, jsx_runtime_1.jsx)(Expandable_1.default, { rows: 3, children: a.text }) }, i))),
|
|
55
|
-
mediumID: m.memory.memoryID,
|
|
56
|
-
mimeType: 'text/plain',
|
|
57
|
-
content: m.memory.media.filter(m => m.mimeType === 'text/plain')[0].content,
|
|
58
|
-
}, showCopyButton: false, showLineNumbers: false }))] }, m.memory.memoryID));
|
|
55
|
+
return ((0, jsx_runtime_1.jsxs)(Drawer_1.default, { open: visible, width: "80%", animated: false, className: "memori-whythisanswer-drawer", onClose: () => closeDrawer(), title: t('whyThisAnswer'), children: [(0, jsx_runtime_1.jsx)("p", { children: t('whyThisAnswerHelper') }), message.questionAnswered && ((0, jsx_runtime_1.jsxs)("p", { className: "memori--whythisanswer-question-answered", children: [(0, jsx_runtime_1.jsxs)("strong", { children: [t('question') || 'Question', ":"] }), ' ', message.questionAnswered] })), (0, jsx_runtime_1.jsxs)(Spin_1.default, { primary: true, spinning: loading, children: [!loading && matches.length === 0 && ((0, jsx_runtime_1.jsx)("p", { role: "info", className: "memori--whythisanswer-no-results", children: t('nothingFound') })), loading && matches.length === 0 && ((0, jsx_runtime_1.jsxs)("ul", { className: "memori--whythisanswer-list memori--whythisanswer-skeleton", children: [(0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsxs)("div", { className: "memori--whythisanswer-title", children: [(0, jsx_runtime_1.jsx)("span", { className: "memori--whythisanswer-confidence", children: (0, jsx_runtime_1.jsx)("span", { className: "memori--whythisanswer-skeleton-text" }) }), (0, jsx_runtime_1.jsx)("div", { className: "memori--whythisanswer-title-text", children: (0, jsx_runtime_1.jsx)("p", { className: "memori--whythisanswer-skeleton-text" }) })] }), (0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)("div", { className: "memori--whythisanswer-skeleton-text" }), (0, jsx_runtime_1.jsx)("div", { className: "memori--whythisanswer-skeleton-text" }), (0, jsx_runtime_1.jsx)("div", { className: "memori--whythisanswer-skeleton-text" })] }), (0, jsx_runtime_1.jsx)("div", { className: "memori--whythisanswer-skeleton-block" })] }), (0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsxs)("div", { className: "memori--whythisanswer-title", children: [(0, jsx_runtime_1.jsx)("span", { className: "memori--whythisanswer-confidence", children: (0, jsx_runtime_1.jsx)("span", { className: "memori--whythisanswer-skeleton-text" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "memori--whythisanswer-title-text", children: [(0, jsx_runtime_1.jsx)("p", { className: "memori--whythisanswer-skeleton-text" }), (0, jsx_runtime_1.jsx)("p", { className: "memori--whythisanswer-skeleton-text" })] })] }), (0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)("div", { className: "memori--whythisanswer-skeleton-text" }), (0, jsx_runtime_1.jsx)("div", { className: "memori--whythisanswer-skeleton-text" })] }), (0, jsx_runtime_1.jsx)("div", { className: "memori--whythisanswer-skeleton-block" })] })] })), matches.length > 0 && ((0, jsx_runtime_1.jsx)("ul", { className: "memori--whythisanswer-list", children: matches.map(m => {
|
|
56
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
57
|
+
return ((0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsxs)("div", { className: "memori--whythisanswer-title", children: [(0, jsx_runtime_1.jsx)("span", { className: "memori--whythisanswer-confidence", children: m.confidenceLevel }), (0, jsx_runtime_1.jsxs)("div", { className: "memori--whythisanswer-title-text", children: [(0, jsx_runtime_1.jsx)("p", { children: (0, jsx_runtime_1.jsx)("strong", { children: addQuestionMark((_a = m.memory.title) !== null && _a !== void 0 ? _a : '') }) }), (0, jsx_runtime_1.jsx)("p", { children: (_c = (_b = m.memory.titleVariants) === null || _b === void 0 ? void 0 : _b.map(t => addQuestionMark(t))) === null || _c === void 0 ? void 0 : _c.join(' | ') })] })] }), (_d = m.memory.answers) === null || _d === void 0 ? void 0 : _d.map((a, i) => ((0, jsx_runtime_1.jsx)("p", { className: "memori--whythisanswer-answer", children: (0, jsx_runtime_1.jsx)(Expandable_1.default, { rows: 3, children: a.text }) }, i))), (0, jsx_runtime_1.jsx)(MediaWidget_1.default, { links: (_e = m.memory.media) === null || _e === void 0 ? void 0 : _e.filter(m => m.mimeType === 'text/html') }), (_g = (_f = m.memory.media) === null || _f === void 0 ? void 0 : _f.filter(m => m.mimeType === 'text/plain')) === null || _g === void 0 ? void 0 : _g.map(m => ((0, jsx_runtime_1.jsx)(Expandable_1.default, { rows: 2, lineHeightMultiplier: 2, innerClassName: "memori--whythisanswer-snippet-expandable", children: (0, jsx_runtime_1.jsx)(Snippet_1.default, { medium: m, showCopyButton: false, showLineNumbers: false }, m.mediumID) }, m.mediumID)))] }, m.memory.memoryID));
|
|
59
58
|
}) }))] })] }));
|
|
60
59
|
};
|
|
61
60
|
exports.default = WhyThisAnswer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WhyThisAnswer.js","sourceRoot":"","sources":["../../../src/components/WhyThisAnswer/WhyThisAnswer.tsx"],"names":[],"mappings":";;;;AAIA,iCAAyD;AACzD,6FAA2D;AAC3D,kEAAkC;AAClC,8DAA8B;AAC9B,0EAA0C;AAC1C,8EAAoC;AACpC,+CAAsD;AACtD,iDAA+C;AAC/C,yEAAyC;
|
|
1
|
+
{"version":3,"file":"WhyThisAnswer.js","sourceRoot":"","sources":["../../../src/components/WhyThisAnswer/WhyThisAnswer.tsx"],"names":[],"mappings":";;;;AAIA,iCAAyD;AACzD,6FAA2D;AAC3D,kEAAkC;AAClC,8DAA8B;AAC9B,0EAA0C;AAC1C,8EAAoC;AACpC,+CAAsD;AACtD,iDAA+C;AAC/C,yEAAyC;AACzC,qFAAqD;AAYrD,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAE,EAAE,CAC3C,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,CAAC;AAErD,MAAM,aAAa,GAAG,CAAC,EACrB,OAAO,EACP,MAAM,EACN,SAAS,EACT,OAAO,GAAG,IAAI,EACd,cAAc,GAAG,EAAE,EACnB,WAAW,EACX,aAAa,GAAG,KAAK,GACf,EAAE,EAAE;IACV,MAAM,EAAE,CAAC,EAAE,GAAG,IAAA,8BAAc,GAAE,CAAC;IAE/B,MAAM,MAAM,GAAG,IAAA,2BAAe,EAAC,MAAM,CAAC,CAAC;IACvC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC;IAEhD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAkB,cAAc,CAAC,CAAC;IACxE,MAAM,CAAC,OAAO,EAAE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C,KAAK,0CAAE,MAAM,CAC3B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,WAAW,CAChC,GACD,EAED,MAAA,MAAA,CAAC,CAAC,MAAM,CAAC,KAAK,0CACX,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,YAAY,CAAC,0CACxC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CACT,uBAAC,oBAAU,IACT,IAAI,EAAE,CAAC,EAEP,oBAAoB,EAAE,CAAC,EACvB,cAAc,EAAC,0CAA0C,YAEzD,uBAAC,iBAAO,IAEN,MAAM,EAAE,CAAC,EACT,cAAc,EAAE,KAAK,EACrB,eAAe,EAAE,KAAK,IAHjB,CAAC,CAAC,QAAQ,CAIf,IATG,CAAC,CAAC,QAAQ,CAUJ,CACd,CAAC,KA5CG,CAAC,CAAC,MAAM,CAAC,QAAQ,CA6CrB,CACN,CAAA;yBAAA,CAAC,GACC,CACN,IACI,IACA,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,aAAa,CAAC"}
|
|
@@ -4,10 +4,11 @@ export interface Props {
|
|
|
4
4
|
className?: string;
|
|
5
5
|
innerClassName?: string;
|
|
6
6
|
btnClassName?: string;
|
|
7
|
+
lineHeightMultiplier?: number;
|
|
7
8
|
defaultExpanded?: boolean;
|
|
8
9
|
expandSymbol?: (lang: string) => React.ReactNode;
|
|
9
10
|
collapseSymbol?: (lang: string) => React.ReactNode;
|
|
10
11
|
children: React.ReactNode;
|
|
11
12
|
}
|
|
12
|
-
declare const Expandable: ({ rows, className, innerClassName, btnClassName, defaultExpanded, expandSymbol, collapseSymbol, children, }: Props) => JSX.Element;
|
|
13
|
+
declare const Expandable: ({ rows, className, innerClassName, btnClassName, lineHeightMultiplier, defaultExpanded, expandSymbol, collapseSymbol, children, }: Props) => JSX.Element;
|
|
13
14
|
export default Expandable;
|
|
@@ -6,7 +6,7 @@ const react_1 = require("react");
|
|
|
6
6
|
const Button_1 = tslib_1.__importDefault(require("./Button"));
|
|
7
7
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
8
8
|
const react_i18next_1 = require("react-i18next");
|
|
9
|
-
const Expandable = ({ rows, className, innerClassName, btnClassName, defaultExpanded = false, expandSymbol = () => '...', collapseSymbol = (lang) => lang === 'it' ? 'Mostra meno' : 'Show less', children, }) => {
|
|
9
|
+
const Expandable = ({ rows, className, innerClassName, btnClassName, lineHeightMultiplier = 1.2, defaultExpanded = false, expandSymbol = () => '...', collapseSymbol = (lang) => lang === 'it' ? 'Mostra meno' : 'Show less', children, }) => {
|
|
10
10
|
const { i18n } = (0, react_i18next_1.useTranslation)();
|
|
11
11
|
const lang = i18n.language;
|
|
12
12
|
const collapseSymbolText = collapseSymbol(lang);
|
|
@@ -21,7 +21,7 @@ const Expandable = ({ rows, className, innerClassName, btnClassName, defaultExpa
|
|
|
21
21
|
let computedStyle = getComputedStyle(ref.current);
|
|
22
22
|
let elLineHeight = computedStyle.lineHeight;
|
|
23
23
|
let lineHeight = elLineHeight === 'normal' || !(elLineHeight === null || elLineHeight === void 0 ? void 0 : elLineHeight.length)
|
|
24
|
-
?
|
|
24
|
+
? lineHeightMultiplier * parseInt(computedStyle.fontSize, 10)
|
|
25
25
|
: parseInt(elLineHeight, 10);
|
|
26
26
|
console.table({
|
|
27
27
|
rows,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Expandable.js","sourceRoot":"","sources":["../../../src/components/ui/Expandable.tsx"],"names":[],"mappings":";;;;AAAA,iCAA2D;AAC3D,8DAA8B;AAC9B,oEAA4B;AAC5B,iDAA+C;
|
|
1
|
+
{"version":3,"file":"Expandable.js","sourceRoot":"","sources":["../../../src/components/ui/Expandable.tsx"],"names":[],"mappings":";;;;AAAA,iCAA2D;AAC3D,8DAA8B;AAC9B,oEAA4B;AAC5B,iDAA+C;AAc/C,MAAM,UAAU,GAAG,CAAC,EAClB,IAAI,EACJ,SAAS,EACT,cAAc,E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P,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,UAAU,CAAC"}
|
|
@@ -64,10 +64,65 @@ ul.memori--whythisanswer-list li:last-child {
|
|
|
64
64
|
margin: 0;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
.memori-whythisanswer-drawer .memori-
|
|
67
|
+
.memori-whythisanswer-drawer .memori-snippet--content {
|
|
68
|
+
font-size: 0.75rem;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.memori-whythisanswer-drawer .memori-card--content {
|
|
72
|
+
padding: 1rem;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.memori-whythisanswer-drawer .memori-card--cover {
|
|
68
76
|
display: none;
|
|
69
77
|
}
|
|
70
78
|
|
|
71
|
-
.memori-whythisanswer-drawer .memori-
|
|
72
|
-
|
|
79
|
+
.memori-whythisanswer-drawer .memori-card--title {
|
|
80
|
+
margin-bottom: 0;
|
|
81
|
+
font-size: 1rem;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.memori--whythisanswer-snippet-expandable {
|
|
85
|
+
min-height: 54px;
|
|
86
|
+
line-height: 40px;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.memori-whythisanswer-drawer .memori-card--description {
|
|
90
|
+
display: none;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.memori--whythisanswer-skeleton {
|
|
94
|
+
min-height: 12rem;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.memori--whythisanswer-skeleton-text {
|
|
98
|
+
padding: 0.5rem;
|
|
99
|
+
border-radius: var(--memori-border-radius);
|
|
100
|
+
margin-bottom: 0.5rem;
|
|
101
|
+
background: #ccc;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
span.memori--whythisanswer-skeleton-text {
|
|
105
|
+
display: inline;
|
|
106
|
+
width: 3rem;
|
|
107
|
+
padding: 0 1rem;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
p.memori--whythisanswer-skeleton-text {
|
|
111
|
+
display: block;
|
|
112
|
+
width: 100%;
|
|
113
|
+
min-width: 6rem;
|
|
114
|
+
margin-bottom: 0.5rem;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
div.memori--whythisanswer-skeleton-text {
|
|
118
|
+
display: block;
|
|
119
|
+
width: 75%;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.memori--whythisanswer-skeleton-block {
|
|
123
|
+
height: 3rem;
|
|
124
|
+
padding: 0.5rem;
|
|
125
|
+
border-radius: var(--memori-border-radius);
|
|
126
|
+
margin-bottom: 0.5rem;
|
|
127
|
+
background: #ccc;
|
|
73
128
|
}
|
|
@@ -6,6 +6,7 @@ export interface Props {
|
|
|
6
6
|
initialMatches?: SearchMatches[];
|
|
7
7
|
visible?: boolean;
|
|
8
8
|
closeDrawer: () => void;
|
|
9
|
+
_TEST_loading?: boolean;
|
|
9
10
|
}
|
|
10
|
-
declare const WhyThisAnswer: ({ message, apiURL, sessionID, visible, initialMatches, closeDrawer, }: Props) => JSX.Element;
|
|
11
|
+
declare const WhyThisAnswer: ({ message, apiURL, sessionID, visible, initialMatches, closeDrawer, _TEST_loading, }: Props) => JSX.Element;
|
|
11
12
|
export default WhyThisAnswer;
|
|
@@ -8,19 +8,22 @@ import toast from 'react-hot-toast';
|
|
|
8
8
|
import { getErrori18nKey } from '../../helpers/error';
|
|
9
9
|
import { useTranslation } from 'react-i18next';
|
|
10
10
|
import Snippet from '../Snippet/Snippet';
|
|
11
|
+
import MediaWidget from '../MediaWidget/MediaWidget';
|
|
11
12
|
const addQuestionMark = (question) => question.endsWith('?') ? question : `${question}?`;
|
|
12
|
-
const WhyThisAnswer = ({ message, apiURL, sessionID, visible = true, initialMatches = [], closeDrawer, }) => {
|
|
13
|
+
const WhyThisAnswer = ({ message, apiURL, sessionID, visible = true, initialMatches = [], closeDrawer, _TEST_loading = false, }) => {
|
|
13
14
|
const { t } = useTranslation();
|
|
14
15
|
const client = memoriApiClient(apiURL);
|
|
15
16
|
const searchMemory = client.search.searchMemory;
|
|
16
17
|
const [matches, setMatches] = useState(initialMatches);
|
|
17
|
-
const [loading, setLoading] = useState(
|
|
18
|
+
const [loading, setLoading] = useState(_TEST_loading);
|
|
18
19
|
const fetchMemories = useCallback(async () => {
|
|
19
20
|
setLoading(true);
|
|
21
|
+
if (_TEST_loading)
|
|
22
|
+
return;
|
|
20
23
|
try {
|
|
21
24
|
const { matches, ...response } = await searchMemory(sessionID, {
|
|
22
25
|
searchType: 'Semantic',
|
|
23
|
-
numberOfResults:
|
|
26
|
+
numberOfResults: 3,
|
|
24
27
|
text: message.questionAnswered,
|
|
25
28
|
date: message.date,
|
|
26
29
|
placeName: message.placeName,
|
|
@@ -46,13 +49,9 @@ const WhyThisAnswer = ({ message, apiURL, sessionID, visible = true, initialMatc
|
|
|
46
49
|
useEffect(() => {
|
|
47
50
|
fetchMemories();
|
|
48
51
|
}, [fetchMemories, message, sessionID]);
|
|
49
|
-
return (_jsxs(Drawer, { open: visible, width: "80%", animated: false, className: "memori-whythisanswer-drawer", onClose: () => closeDrawer(), title: t('whyThisAnswer'), children: [_jsx("p", { children: t('whyThisAnswerHelper') }), message.questionAnswered && (_jsxs("p", { className: "memori--whythisanswer-question-answered", children: [_jsxs("strong", { children: [t('question') || 'Question', ":"] }), ' ', message.questionAnswered] })), _jsxs(Spin, { spinning: loading, children: [!loading && matches.length === 0 && (_jsx("p", { role: "info", className: "memori--whythisanswer-no-results", children: t('nothingFound') })), matches.length > 0 && (_jsx("ul", { className: "memori--whythisanswer-list", children: matches.map(m => {
|
|
50
|
-
var _a, _b, _c, _d, _e, _f;
|
|
51
|
-
return (_jsxs("li", { children: [_jsxs("div", { className: "memori--whythisanswer-title", children: [_jsx("span", { className: "memori--whythisanswer-confidence", children: m.confidenceLevel }), _jsxs("div", { className: "memori--whythisanswer-title-text", children: [_jsx("p", { children: _jsx("strong", { children: addQuestionMark((_a = m.memory.title) !== null && _a !== void 0 ? _a : '') }) }), _jsx("p", { children: (_c = (_b = m.memory.titleVariants) === null || _b === void 0 ? void 0 : _b.map(t => addQuestionMark(t))) === null || _c === void 0 ? void 0 : _c.join(' | ') })] })] }), (_d = m.memory.answers) === null || _d === void 0 ? void 0 : _d.map((a, i) => (_jsx("p", { className: "memori--whythisanswer-answer", children: _jsx(Expandable, { rows: 3, children: a.text }) }, i))),
|
|
52
|
-
mediumID: m.memory.memoryID,
|
|
53
|
-
mimeType: 'text/plain',
|
|
54
|
-
content: m.memory.media.filter(m => m.mimeType === 'text/plain')[0].content,
|
|
55
|
-
}, showCopyButton: false, showLineNumbers: false }))] }, m.memory.memoryID));
|
|
52
|
+
return (_jsxs(Drawer, { open: visible, width: "80%", animated: false, className: "memori-whythisanswer-drawer", onClose: () => closeDrawer(), title: t('whyThisAnswer'), children: [_jsx("p", { children: t('whyThisAnswerHelper') }), message.questionAnswered && (_jsxs("p", { className: "memori--whythisanswer-question-answered", children: [_jsxs("strong", { children: [t('question') || 'Question', ":"] }), ' ', message.questionAnswered] })), _jsxs(Spin, { primary: true, spinning: loading, children: [!loading && matches.length === 0 && (_jsx("p", { role: "info", className: "memori--whythisanswer-no-results", children: t('nothingFound') })), loading && matches.length === 0 && (_jsxs("ul", { className: "memori--whythisanswer-list memori--whythisanswer-skeleton", children: [_jsxs("li", { children: [_jsxs("div", { className: "memori--whythisanswer-title", children: [_jsx("span", { className: "memori--whythisanswer-confidence", children: _jsx("span", { className: "memori--whythisanswer-skeleton-text" }) }), _jsx("div", { className: "memori--whythisanswer-title-text", children: _jsx("p", { className: "memori--whythisanswer-skeleton-text" }) })] }), _jsxs("p", { children: [_jsx("div", { className: "memori--whythisanswer-skeleton-text" }), _jsx("div", { className: "memori--whythisanswer-skeleton-text" }), _jsx("div", { className: "memori--whythisanswer-skeleton-text" })] }), _jsx("div", { className: "memori--whythisanswer-skeleton-block" })] }), _jsxs("li", { children: [_jsxs("div", { className: "memori--whythisanswer-title", children: [_jsx("span", { className: "memori--whythisanswer-confidence", children: _jsx("span", { className: "memori--whythisanswer-skeleton-text" }) }), _jsxs("div", { className: "memori--whythisanswer-title-text", children: [_jsx("p", { className: "memori--whythisanswer-skeleton-text" }), _jsx("p", { className: "memori--whythisanswer-skeleton-text" })] })] }), _jsxs("p", { children: [_jsx("div", { className: "memori--whythisanswer-skeleton-text" }), _jsx("div", { className: "memori--whythisanswer-skeleton-text" })] }), _jsx("div", { className: "memori--whythisanswer-skeleton-block" })] })] })), matches.length > 0 && (_jsx("ul", { className: "memori--whythisanswer-list", children: matches.map(m => {
|
|
53
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
54
|
+
return (_jsxs("li", { children: [_jsxs("div", { className: "memori--whythisanswer-title", children: [_jsx("span", { className: "memori--whythisanswer-confidence", children: m.confidenceLevel }), _jsxs("div", { className: "memori--whythisanswer-title-text", children: [_jsx("p", { children: _jsx("strong", { children: addQuestionMark((_a = m.memory.title) !== null && _a !== void 0 ? _a : '') }) }), _jsx("p", { children: (_c = (_b = m.memory.titleVariants) === null || _b === void 0 ? void 0 : _b.map(t => addQuestionMark(t))) === null || _c === void 0 ? void 0 : _c.join(' | ') })] })] }), (_d = m.memory.answers) === null || _d === void 0 ? void 0 : _d.map((a, i) => (_jsx("p", { className: "memori--whythisanswer-answer", children: _jsx(Expandable, { rows: 3, children: a.text }) }, i))), _jsx(MediaWidget, { links: (_e = m.memory.media) === null || _e === void 0 ? void 0 : _e.filter(m => m.mimeType === 'text/html') }), (_g = (_f = m.memory.media) === null || _f === void 0 ? void 0 : _f.filter(m => m.mimeType === 'text/plain')) === null || _g === void 0 ? void 0 : _g.map(m => (_jsx(Expandable, { rows: 2, lineHeightMultiplier: 2, innerClassName: "memori--whythisanswer-snippet-expandable", children: _jsx(Snippet, { medium: m, showCopyButton: false, showLineNumbers: false }, m.mediumID) }, m.mediumID)))] }, m.memory.memoryID));
|
|
56
55
|
}) }))] })] }));
|
|
57
56
|
};
|
|
58
57
|
export default WhyThisAnswer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WhyThisAnswer.js","sourceRoot":"","sources":["../../../src/components/WhyThisAnswer/WhyThisAnswer.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAC3D,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,OAAO,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"WhyThisAnswer.js","sourceRoot":"","sources":["../../../src/components/WhyThisAnswer/WhyThisAnswer.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAC3D,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,OAAO,MAAM,oBAAoB,CAAC;AACzC,OAAO,WAAW,MAAM,4BAA4B,CAAC;AAYrD,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAE,EAAE,CAC3C,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,CAAC;AAErD,MAAM,aAAa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,CAAC,0CAC5B,IAAI,CAAC,KAAK,CAAC,GACb,IACA,IACF,EACL,MAAA,CAAC,CAAC,MAAM,CAAC,OAAO,0CAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAC/B,YAAW,SAAS,EAAC,8BAA8B,YACjD,KAAC,UAAU,IAAC,IAAI,EAAE,CAAC,YAAG,CAAC,CAAC,IAAI,GAAc,IADpC,CAAC,CAEL,CACL,CAAC,EAEF,KAAC,WAAW,IACV,KAAK,EAAE,MAAA,CAAC,CAAC,MAAM,CAAC,KAAK,0CAAE,MAAM,CAC3B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,WAAW,CAChC,GACD,EAED,MAAA,MAAA,CAAC,CAAC,MAAM,CAAC,KAAK,0CACX,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,YAAY,CAAC,0CACxC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CACT,KAAC,UAAU,IACT,IAAI,EAAE,CAAC,EAEP,oBAAoB,EAAE,CAAC,EACvB,cAAc,EAAC,0CAA0C,YAEzD,KAAC,OAAO,IAEN,MAAM,EAAE,CAAC,EACT,cAAc,EAAE,KAAK,EACrB,eAAe,EAAE,KAAK,IAHjB,CAAC,CAAC,QAAQ,CAIf,IATG,CAAC,CAAC,QAAQ,CAUJ,CACd,CAAC,KA5CG,CAAC,CAAC,MAAM,CAAC,QAAQ,CA6CrB,CACN,CAAA;yBAAA,CAAC,GACC,CACN,IACI,IACA,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -4,10 +4,11 @@ export interface Props {
|
|
|
4
4
|
className?: string;
|
|
5
5
|
innerClassName?: string;
|
|
6
6
|
btnClassName?: string;
|
|
7
|
+
lineHeightMultiplier?: number;
|
|
7
8
|
defaultExpanded?: boolean;
|
|
8
9
|
expandSymbol?: (lang: string) => React.ReactNode;
|
|
9
10
|
collapseSymbol?: (lang: string) => React.ReactNode;
|
|
10
11
|
children: React.ReactNode;
|
|
11
12
|
}
|
|
12
|
-
declare const Expandable: ({ rows, className, innerClassName, btnClassName, defaultExpanded, expandSymbol, collapseSymbol, children, }: Props) => JSX.Element;
|
|
13
|
+
declare const Expandable: ({ rows, className, innerClassName, btnClassName, lineHeightMultiplier, defaultExpanded, expandSymbol, collapseSymbol, children, }: Props) => JSX.Element;
|
|
13
14
|
export default Expandable;
|
|
@@ -3,7 +3,7 @@ import { useEffect, useRef, useState } from 'react';
|
|
|
3
3
|
import Button from './Button';
|
|
4
4
|
import cx from 'classnames';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
|
-
const Expandable = ({ rows, className, innerClassName, btnClassName, defaultExpanded = false, expandSymbol = () => '...', collapseSymbol = (lang) => lang === 'it' ? 'Mostra meno' : 'Show less', children, }) => {
|
|
6
|
+
const Expandable = ({ rows, className, innerClassName, btnClassName, lineHeightMultiplier = 1.2, defaultExpanded = false, expandSymbol = () => '...', collapseSymbol = (lang) => lang === 'it' ? 'Mostra meno' : 'Show less', children, }) => {
|
|
7
7
|
const { i18n } = useTranslation();
|
|
8
8
|
const lang = i18n.language;
|
|
9
9
|
const collapseSymbolText = collapseSymbol(lang);
|
|
@@ -18,7 +18,7 @@ const Expandable = ({ rows, className, innerClassName, btnClassName, defaultExpa
|
|
|
18
18
|
let computedStyle = getComputedStyle(ref.current);
|
|
19
19
|
let elLineHeight = computedStyle.lineHeight;
|
|
20
20
|
let lineHeight = elLineHeight === 'normal' || !(elLineHeight === null || elLineHeight === void 0 ? void 0 : elLineHeight.length)
|
|
21
|
-
?
|
|
21
|
+
? lineHeightMultiplier * parseInt(computedStyle.fontSize, 10)
|
|
22
22
|
: parseInt(elLineHeight, 10);
|
|
23
23
|
console.table({
|
|
24
24
|
rows,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Expandable.js","sourceRoot":"","sources":["../../../src/components/ui/Expandable.ts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cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,IAAI;iBACnE,YAEA,QAAQ,GACL,EACL,cAAc,IAAI,CAAC,QAAQ,IAAI,CAC9B,KAAC,MAAM,IACL,KAAK,QACL,MAAM,EAAE,KAAK,EACb,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,YAE/B,gBAAgB,GACV,CACV,EACA,cAAc,IAAI,QAAQ,IAAI,CAC7B,KAAC,MAAM,IACL,KAAK,QACL,MAAM,EAAE,KAAK,EACb,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,YAEhC,kBAAkB,GACZ,CACV,IACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -64,10 +64,65 @@ ul.memori--whythisanswer-list li:last-child {
|
|
|
64
64
|
margin: 0;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
.memori-whythisanswer-drawer .memori-
|
|
67
|
+
.memori-whythisanswer-drawer .memori-snippet--content {
|
|
68
|
+
font-size: 0.75rem;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.memori-whythisanswer-drawer .memori-card--content {
|
|
72
|
+
padding: 1rem;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.memori-whythisanswer-drawer .memori-card--cover {
|
|
68
76
|
display: none;
|
|
69
77
|
}
|
|
70
78
|
|
|
71
|
-
.memori-whythisanswer-drawer .memori-
|
|
72
|
-
|
|
79
|
+
.memori-whythisanswer-drawer .memori-card--title {
|
|
80
|
+
margin-bottom: 0;
|
|
81
|
+
font-size: 1rem;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.memori--whythisanswer-snippet-expandable {
|
|
85
|
+
min-height: 54px;
|
|
86
|
+
line-height: 40px;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.memori-whythisanswer-drawer .memori-card--description {
|
|
90
|
+
display: none;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.memori--whythisanswer-skeleton {
|
|
94
|
+
min-height: 12rem;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.memori--whythisanswer-skeleton-text {
|
|
98
|
+
padding: 0.5rem;
|
|
99
|
+
border-radius: var(--memori-border-radius);
|
|
100
|
+
margin-bottom: 0.5rem;
|
|
101
|
+
background: #ccc;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
span.memori--whythisanswer-skeleton-text {
|
|
105
|
+
display: inline;
|
|
106
|
+
width: 3rem;
|
|
107
|
+
padding: 0 1rem;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
p.memori--whythisanswer-skeleton-text {
|
|
111
|
+
display: block;
|
|
112
|
+
width: 100%;
|
|
113
|
+
min-width: 6rem;
|
|
114
|
+
margin-bottom: 0.5rem;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
div.memori--whythisanswer-skeleton-text {
|
|
118
|
+
display: block;
|
|
119
|
+
width: 75%;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.memori--whythisanswer-skeleton-block {
|
|
123
|
+
height: 3rem;
|
|
124
|
+
padding: 0.5rem;
|
|
125
|
+
border-radius: var(--memori-border-radius);
|
|
126
|
+
margin-bottom: 0.5rem;
|
|
127
|
+
background: #ccc;
|
|
73
128
|
}
|
|
@@ -54,6 +54,12 @@ Default.args = {
|
|
|
54
54
|
visible: true,
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
+
export const Loading = Template.bind({});
|
|
58
|
+
Loading.args = {
|
|
59
|
+
visible: true,
|
|
60
|
+
_TEST_loading: true,
|
|
61
|
+
};
|
|
62
|
+
|
|
57
63
|
export const WithData = Template.bind({});
|
|
58
64
|
WithData.args = {
|
|
59
65
|
visible: true,
|
|
@@ -62,7 +68,7 @@ WithData.args = {
|
|
|
62
68
|
confidence: 0.8,
|
|
63
69
|
confidenceLevel: 'HIGH',
|
|
64
70
|
memory: {
|
|
65
|
-
|
|
71
|
+
memoryID: '1',
|
|
66
72
|
title: 'This is the title of the content',
|
|
67
73
|
titleVariants: [
|
|
68
74
|
"This is a variant of the content's title",
|
|
@@ -72,24 +78,22 @@ WithData.args = {
|
|
|
72
78
|
{
|
|
73
79
|
text: 'This is a test answer',
|
|
74
80
|
},
|
|
81
|
+
{
|
|
82
|
+
text: 'This is another answer',
|
|
83
|
+
},
|
|
75
84
|
],
|
|
76
|
-
memoryID: '1',
|
|
77
85
|
},
|
|
78
86
|
} as SearchMatches,
|
|
79
87
|
{
|
|
80
|
-
confidence: 0.
|
|
81
|
-
confidenceLevel: '
|
|
88
|
+
confidence: 0.5,
|
|
89
|
+
confidenceLevel: 'LOW',
|
|
82
90
|
memory: {
|
|
83
|
-
...memoryQuestion,
|
|
84
91
|
memoryID: '2',
|
|
85
|
-
title: '
|
|
92
|
+
title: 'Content with a long answer',
|
|
86
93
|
titleVariants: undefined,
|
|
87
94
|
answers: [
|
|
88
95
|
{
|
|
89
|
-
text: '
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
text: 'This is another answer',
|
|
96
|
+
text: 'Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales nulla, sed semper nisi.',
|
|
93
97
|
},
|
|
94
98
|
],
|
|
95
99
|
},
|
|
@@ -98,36 +102,55 @@ WithData.args = {
|
|
|
98
102
|
confidence: 0.5,
|
|
99
103
|
confidenceLevel: 'LOW',
|
|
100
104
|
memory: {
|
|
101
|
-
...memoryQuestion,
|
|
102
105
|
memoryID: '3',
|
|
103
|
-
title: 'Content with
|
|
106
|
+
title: 'Content with sources',
|
|
104
107
|
titleVariants: undefined,
|
|
105
108
|
answers: [
|
|
106
109
|
{
|
|
107
|
-
text: '
|
|
110
|
+
text: 'This is a test answer',
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
media: [
|
|
114
|
+
{
|
|
115
|
+
mediumID: '1',
|
|
116
|
+
mimeType: 'text/plain',
|
|
117
|
+
content:
|
|
118
|
+
'This is a source. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales nulla, sed semper nisi.',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
mediumID: '2',
|
|
122
|
+
mimeType: 'text/plain',
|
|
123
|
+
content:
|
|
124
|
+
'This is a source.\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit.\nCras lobortis volutpat nunc.\nProin tincidunt enim in felis aliquet, a ultricies purus bibendum.\n\nQuisque in ultrices lectus.\nNulla at urna diam.\n\nProin sodales lobortis libero eu facilisis.',
|
|
108
125
|
},
|
|
109
126
|
],
|
|
110
127
|
},
|
|
111
128
|
} as SearchMatches,
|
|
112
129
|
{
|
|
113
|
-
confidence: 0.
|
|
114
|
-
confidenceLevel: '
|
|
130
|
+
confidence: 0.7,
|
|
131
|
+
confidenceLevel: 'MEDIUM',
|
|
115
132
|
memory: {
|
|
116
133
|
...memoryQuestion,
|
|
117
134
|
memoryID: '4',
|
|
118
|
-
title: 'Content with
|
|
135
|
+
title: 'Content with links',
|
|
119
136
|
titleVariants: undefined,
|
|
120
137
|
answers: [
|
|
121
138
|
{
|
|
122
|
-
text: 'This is a
|
|
139
|
+
text: 'This is a an answer',
|
|
123
140
|
},
|
|
124
141
|
],
|
|
125
142
|
media: [
|
|
126
143
|
{
|
|
127
144
|
mediumID: '1',
|
|
128
|
-
mimeType: 'text/
|
|
129
|
-
|
|
130
|
-
|
|
145
|
+
mimeType: 'text/html',
|
|
146
|
+
url: 'https://memori.ai',
|
|
147
|
+
title: 'Memori.AI',
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
mediumID: '2',
|
|
151
|
+
mimeType: 'text/html',
|
|
152
|
+
url: 'https://nzambello.dev',
|
|
153
|
+
title: 'Nicola Zambello',
|
|
131
154
|
},
|
|
132
155
|
],
|
|
133
156
|
},
|
|
@@ -11,6 +11,7 @@ import toast from 'react-hot-toast';
|
|
|
11
11
|
import { getErrori18nKey } from '../../helpers/error';
|
|
12
12
|
import { useTranslation } from 'react-i18next';
|
|
13
13
|
import Snippet from '../Snippet/Snippet';
|
|
14
|
+
import MediaWidget from '../MediaWidget/MediaWidget';
|
|
14
15
|
|
|
15
16
|
export interface Props {
|
|
16
17
|
apiURL: string;
|
|
@@ -19,6 +20,7 @@ export interface Props {
|
|
|
19
20
|
initialMatches?: SearchMatches[];
|
|
20
21
|
visible?: boolean;
|
|
21
22
|
closeDrawer: () => void;
|
|
23
|
+
_TEST_loading?: boolean;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
const addQuestionMark = (question: string) =>
|
|
@@ -31,6 +33,7 @@ const WhyThisAnswer = ({
|
|
|
31
33
|
visible = true,
|
|
32
34
|
initialMatches = [],
|
|
33
35
|
closeDrawer,
|
|
36
|
+
_TEST_loading = false,
|
|
34
37
|
}: Props) => {
|
|
35
38
|
const { t } = useTranslation();
|
|
36
39
|
|
|
@@ -38,7 +41,7 @@ const WhyThisAnswer = ({
|
|
|
38
41
|
const searchMemory = client.search.searchMemory;
|
|
39
42
|
|
|
40
43
|
const [matches, setMatches] = useState<SearchMatches[]>(initialMatches);
|
|
41
|
-
const [loading, setLoading] = useState(
|
|
44
|
+
const [loading, setLoading] = useState(_TEST_loading);
|
|
42
45
|
|
|
43
46
|
/**
|
|
44
47
|
* Fetch matching memories
|
|
@@ -46,10 +49,12 @@ const WhyThisAnswer = ({
|
|
|
46
49
|
const fetchMemories = useCallback(async () => {
|
|
47
50
|
setLoading(true);
|
|
48
51
|
|
|
52
|
+
if (_TEST_loading) return;
|
|
53
|
+
|
|
49
54
|
try {
|
|
50
55
|
const { matches, ...response } = await searchMemory(sessionID, {
|
|
51
56
|
searchType: 'Semantic',
|
|
52
|
-
numberOfResults:
|
|
57
|
+
numberOfResults: 3,
|
|
53
58
|
text: message.questionAnswered,
|
|
54
59
|
date: message.date,
|
|
55
60
|
placeName: message.placeName,
|
|
@@ -94,12 +99,48 @@ const WhyThisAnswer = ({
|
|
|
94
99
|
</p>
|
|
95
100
|
)}
|
|
96
101
|
|
|
97
|
-
<Spin spinning={loading}>
|
|
102
|
+
<Spin primary spinning={loading}>
|
|
98
103
|
{!loading && matches.length === 0 && (
|
|
99
104
|
<p role="info" className="memori--whythisanswer-no-results">
|
|
100
105
|
{t('nothingFound')}
|
|
101
106
|
</p>
|
|
102
107
|
)}
|
|
108
|
+
{loading && matches.length === 0 && (
|
|
109
|
+
<ul className="memori--whythisanswer-list memori--whythisanswer-skeleton">
|
|
110
|
+
<li>
|
|
111
|
+
<div className="memori--whythisanswer-title">
|
|
112
|
+
<span className="memori--whythisanswer-confidence">
|
|
113
|
+
<span className="memori--whythisanswer-skeleton-text"></span>
|
|
114
|
+
</span>
|
|
115
|
+
<div className="memori--whythisanswer-title-text">
|
|
116
|
+
<p className="memori--whythisanswer-skeleton-text"></p>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
<p>
|
|
120
|
+
<div className="memori--whythisanswer-skeleton-text"></div>
|
|
121
|
+
<div className="memori--whythisanswer-skeleton-text"></div>
|
|
122
|
+
<div className="memori--whythisanswer-skeleton-text"></div>
|
|
123
|
+
</p>
|
|
124
|
+
<div className="memori--whythisanswer-skeleton-block"></div>
|
|
125
|
+
</li>
|
|
126
|
+
<li>
|
|
127
|
+
<div className="memori--whythisanswer-title">
|
|
128
|
+
<span className="memori--whythisanswer-confidence">
|
|
129
|
+
<span className="memori--whythisanswer-skeleton-text"></span>
|
|
130
|
+
</span>
|
|
131
|
+
<div className="memori--whythisanswer-title-text">
|
|
132
|
+
<p className="memori--whythisanswer-skeleton-text"></p>
|
|
133
|
+
<p className="memori--whythisanswer-skeleton-text"></p>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
<p>
|
|
137
|
+
<div className="memori--whythisanswer-skeleton-text"></div>
|
|
138
|
+
<div className="memori--whythisanswer-skeleton-text"></div>
|
|
139
|
+
</p>
|
|
140
|
+
<div className="memori--whythisanswer-skeleton-block"></div>
|
|
141
|
+
</li>
|
|
142
|
+
</ul>
|
|
143
|
+
)}
|
|
103
144
|
{matches.length > 0 && (
|
|
104
145
|
<ul className="memori--whythisanswer-list">
|
|
105
146
|
{matches.map(m => (
|
|
@@ -125,20 +166,29 @@ const WhyThisAnswer = ({
|
|
|
125
166
|
</p>
|
|
126
167
|
))}
|
|
127
168
|
|
|
128
|
-
|
|
129
|
-
?.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
169
|
+
<MediaWidget
|
|
170
|
+
links={m.memory.media?.filter(
|
|
171
|
+
m => m.mimeType === 'text/html'
|
|
172
|
+
)}
|
|
173
|
+
/>
|
|
174
|
+
|
|
175
|
+
{m.memory.media
|
|
176
|
+
?.filter(m => m.mimeType === 'text/plain')
|
|
177
|
+
?.map(m => (
|
|
178
|
+
<Expandable
|
|
179
|
+
rows={2}
|
|
180
|
+
key={m.mediumID}
|
|
181
|
+
lineHeightMultiplier={2}
|
|
182
|
+
innerClassName="memori--whythisanswer-snippet-expandable"
|
|
183
|
+
>
|
|
184
|
+
<Snippet
|
|
185
|
+
key={m.mediumID}
|
|
186
|
+
medium={m}
|
|
187
|
+
showCopyButton={false}
|
|
188
|
+
showLineNumbers={false}
|
|
189
|
+
/>
|
|
190
|
+
</Expandable>
|
|
191
|
+
))}
|
|
142
192
|
</li>
|
|
143
193
|
))}
|
|
144
194
|
</ul>
|
|
@@ -8,6 +8,7 @@ export interface Props {
|
|
|
8
8
|
className?: string;
|
|
9
9
|
innerClassName?: string;
|
|
10
10
|
btnClassName?: string;
|
|
11
|
+
lineHeightMultiplier?: number;
|
|
11
12
|
defaultExpanded?: boolean;
|
|
12
13
|
expandSymbol?: (lang: string) => React.ReactNode;
|
|
13
14
|
collapseSymbol?: (lang: string) => React.ReactNode;
|
|
@@ -19,6 +20,7 @@ const Expandable = ({
|
|
|
19
20
|
className,
|
|
20
21
|
innerClassName,
|
|
21
22
|
btnClassName,
|
|
23
|
+
lineHeightMultiplier = 1.2,
|
|
22
24
|
defaultExpanded = false,
|
|
23
25
|
expandSymbol = () => '...',
|
|
24
26
|
collapseSymbol = (lang: string) =>
|
|
@@ -41,7 +43,7 @@ const Expandable = ({
|
|
|
41
43
|
let elLineHeight = computedStyle.lineHeight;
|
|
42
44
|
let lineHeight =
|
|
43
45
|
elLineHeight === 'normal' || !elLineHeight?.length
|
|
44
|
-
?
|
|
46
|
+
? lineHeightMultiplier * parseInt(computedStyle.fontSize, 10)
|
|
45
47
|
: parseInt(elLineHeight, 10);
|
|
46
48
|
|
|
47
49
|
console.table({
|