@memori.ai/memori-react 8.30.1 → 8.32.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 (123) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/components/DrawerFooter/DrawerFooter.css +62 -0
  3. package/dist/components/DrawerFooter/DrawerFooter.d.ts +12 -0
  4. package/dist/components/DrawerFooter/DrawerFooter.js +10 -0
  5. package/dist/components/DrawerFooter/DrawerFooter.js.map +1 -0
  6. package/dist/components/Header/Header.css +53 -0
  7. package/dist/components/Header/Header.d.ts +1 -0
  8. package/dist/components/Header/Header.js +74 -3
  9. package/dist/components/Header/Header.js.map +1 -1
  10. package/dist/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.js +5 -17
  11. package/dist/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.js.map +1 -1
  12. package/dist/components/MemoriWidget/MemoriWidget.js +1 -0
  13. package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
  14. package/dist/components/PositionPopover/PositionPopover.css +194 -0
  15. package/dist/components/PositionPopover/PositionPopover.d.ts +15 -0
  16. package/dist/components/PositionPopover/PositionPopover.js +181 -0
  17. package/dist/components/PositionPopover/PositionPopover.js.map +1 -0
  18. package/dist/components/icons/GasStation.d.ts +6 -0
  19. package/dist/components/icons/GasStation.js +6 -0
  20. package/dist/components/icons/GasStation.js.map +1 -0
  21. package/dist/components/layouts/WebsiteAssistant/WebsiteAssistant.d.ts +4 -0
  22. package/dist/components/layouts/WebsiteAssistant/WebsiteAssistant.js +37 -0
  23. package/dist/components/layouts/WebsiteAssistant/WebsiteAssistant.js.map +1 -0
  24. package/dist/components/layouts/WebsiteAssistant/website-assistant.css +671 -0
  25. package/dist/components/layouts/chat.css +14 -0
  26. package/dist/components/layouts/fullpage.css +119 -0
  27. package/dist/helpers/userMessage.d.ts +2 -0
  28. package/dist/helpers/userMessage.js +23 -0
  29. package/dist/helpers/userMessage.js.map +1 -0
  30. package/dist/icons/FacebookIcon.d.ts +3 -0
  31. package/dist/icons/FacebookIcon.js +6 -0
  32. package/dist/icons/FacebookIcon.js.map +1 -0
  33. package/dist/icons/LinkedinIcon.d.ts +3 -0
  34. package/dist/icons/LinkedinIcon.js +6 -0
  35. package/dist/icons/LinkedinIcon.js.map +1 -0
  36. package/dist/icons/TelegramIcon.d.ts +3 -0
  37. package/dist/icons/TelegramIcon.js +6 -0
  38. package/dist/icons/TelegramIcon.js.map +1 -0
  39. package/dist/icons/TwitterIcon.d.ts +3 -0
  40. package/dist/icons/TwitterIcon.js +6 -0
  41. package/dist/icons/TwitterIcon.js.map +1 -0
  42. package/dist/icons/WhatsappIcon.d.ts +3 -0
  43. package/dist/icons/WhatsappIcon.js +6 -0
  44. package/dist/icons/WhatsappIcon.js.map +1 -0
  45. package/dist/locales/de.json +1 -0
  46. package/dist/locales/en.json +1 -0
  47. package/dist/locales/es.json +1 -0
  48. package/dist/locales/fr.json +1 -0
  49. package/dist/locales/it.json +1 -0
  50. package/dist/testUtils.d.ts +5 -0
  51. package/dist/testUtils.js +18 -0
  52. package/dist/testUtils.js.map +1 -0
  53. package/dist/version.d.ts +1 -1
  54. package/dist/version.js +1 -1
  55. package/esm/components/DrawerFooter/DrawerFooter.css +62 -0
  56. package/esm/components/DrawerFooter/DrawerFooter.d.ts +12 -0
  57. package/esm/components/DrawerFooter/DrawerFooter.js +8 -0
  58. package/esm/components/DrawerFooter/DrawerFooter.js.map +1 -0
  59. package/esm/components/Header/Header.css +53 -0
  60. package/esm/components/Header/Header.d.ts +1 -0
  61. package/esm/components/Header/Header.js +75 -4
  62. package/esm/components/Header/Header.js.map +1 -1
  63. package/esm/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.js +5 -17
  64. package/esm/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.js.map +1 -1
  65. package/esm/components/MemoriWidget/MemoriWidget.js +1 -0
  66. package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
  67. package/esm/components/PositionPopover/PositionPopover.css +194 -0
  68. package/esm/components/PositionPopover/PositionPopover.d.ts +15 -0
  69. package/esm/components/PositionPopover/PositionPopover.js +178 -0
  70. package/esm/components/PositionPopover/PositionPopover.js.map +1 -0
  71. package/esm/components/icons/GasStation.d.ts +6 -0
  72. package/esm/components/icons/GasStation.js +4 -0
  73. package/esm/components/icons/GasStation.js.map +1 -0
  74. package/esm/components/layouts/WebsiteAssistant/WebsiteAssistant.d.ts +4 -0
  75. package/esm/components/layouts/WebsiteAssistant/WebsiteAssistant.js +34 -0
  76. package/esm/components/layouts/WebsiteAssistant/WebsiteAssistant.js.map +1 -0
  77. package/esm/components/layouts/WebsiteAssistant/website-assistant.css +671 -0
  78. package/esm/components/layouts/chat.css +14 -0
  79. package/esm/components/layouts/fullpage.css +119 -0
  80. package/esm/helpers/userMessage.d.ts +2 -0
  81. package/esm/helpers/userMessage.js +18 -0
  82. package/esm/helpers/userMessage.js.map +1 -0
  83. package/esm/icons/FacebookIcon.d.ts +3 -0
  84. package/esm/icons/FacebookIcon.js +4 -0
  85. package/esm/icons/FacebookIcon.js.map +1 -0
  86. package/esm/icons/LinkedinIcon.d.ts +3 -0
  87. package/esm/icons/LinkedinIcon.js +4 -0
  88. package/esm/icons/LinkedinIcon.js.map +1 -0
  89. package/esm/icons/TelegramIcon.d.ts +3 -0
  90. package/esm/icons/TelegramIcon.js +4 -0
  91. package/esm/icons/TelegramIcon.js.map +1 -0
  92. package/esm/icons/TwitterIcon.d.ts +3 -0
  93. package/esm/icons/TwitterIcon.js +4 -0
  94. package/esm/icons/TwitterIcon.js.map +1 -0
  95. package/esm/icons/WhatsappIcon.d.ts +3 -0
  96. package/esm/icons/WhatsappIcon.js +4 -0
  97. package/esm/icons/WhatsappIcon.js.map +1 -0
  98. package/esm/locales/de.json +1 -0
  99. package/esm/locales/en.json +1 -0
  100. package/esm/locales/es.json +1 -0
  101. package/esm/locales/fr.json +1 -0
  102. package/esm/locales/it.json +1 -0
  103. package/esm/testUtils.d.ts +5 -0
  104. package/esm/testUtils.js +15 -0
  105. package/esm/testUtils.js.map +1 -0
  106. package/esm/version.d.ts +1 -1
  107. package/esm/version.js +1 -1
  108. package/package.json +1 -1
  109. package/src/components/Header/Header.css +53 -0
  110. package/src/components/Header/Header.stories.tsx +46 -0
  111. package/src/components/Header/Header.tsx +151 -2
  112. package/src/components/MemoriArtifactSystem/ArtifactDrawer.stories.tsx +71 -0
  113. package/src/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.tsx +10 -24
  114. package/src/components/MemoriWidget/MemoriWidget.tsx +1 -0
  115. package/src/components/icons/GasStation.tsx +36 -0
  116. package/src/components/layouts/chat.css +14 -0
  117. package/src/components/layouts/layouts.stories.tsx +14 -14
  118. package/src/locales/de.json +1 -0
  119. package/src/locales/en.json +1 -0
  120. package/src/locales/es.json +1 -0
  121. package/src/locales/fr.json +1 -0
  122. package/src/locales/it.json +1 -0
  123. package/src/version.ts +1 -1
@@ -0,0 +1,119 @@
1
+ /* FullPage layout – spacing, typography and structure using global design tokens */
2
+
3
+ .memori-widget.memori-layout-fullpage {
4
+ max-width: var(--memori-layout-max-width);
5
+ padding: var(--memori-spacing-md);
6
+ margin-right: auto;
7
+ margin-left: auto;
8
+ }
9
+
10
+ .memori-widget.memori-layout-fullpage > .memori-spin {
11
+ display: flex;
12
+ height: 100%;
13
+ flex-direction: column;
14
+ gap: var(--memori-spacing-lg);
15
+ }
16
+
17
+ /* Header spacing */
18
+ .memori-widget.memori-layout-fullpage .memori-chat-layout--header {
19
+ min-width: 100%;
20
+ flex-shrink: 0;
21
+ border-radius: var(--memori-radius-box);
22
+ margin-bottom: var(--memori-spacing-md);
23
+ }
24
+
25
+ /* Grid: main + left column (avatar) */
26
+ .memori-widget.memori-layout-fullpage .memori--grid {
27
+ display: flex;
28
+ height: auto;
29
+ height: 95vh;
30
+ min-height: 0;
31
+ flex: 1 1 auto;
32
+ align-items: stretch;
33
+ justify-content: center;
34
+ gap: var(--memori-spacing-xl);
35
+ }
36
+
37
+ .memori-widget.memori-layout-fullpage .memori--grid-column-left {
38
+ width: 50%;
39
+ max-width: 420px;
40
+ flex-shrink: 0;
41
+ margin-right: 0;
42
+ }
43
+
44
+ .memori-widget.memori-layout-fullpage .memori-chat-layout--main {
45
+ display: flex;
46
+ min-width: 0;
47
+ flex: 1;
48
+ flex-direction: column;
49
+ align-items: center;
50
+ justify-content: center;
51
+ }
52
+
53
+ .memori-widget.memori-layout-fullpage .memori-chat-layout--controls {
54
+ display: flex;
55
+ width: 100%;
56
+ max-width: 720px;
57
+ flex-direction: column;
58
+ align-items: center;
59
+ padding: var(--memori-spacing-md);
60
+ }
61
+
62
+ .memori-widget.memori-layout-fullpage .memori-chat-layout--controls .memori--start-panel,
63
+ .memori-widget.memori-layout-fullpage .memori-chat-layout--controls .memori-chat--wrapper {
64
+ width: 100%;
65
+ max-width: 100%;
66
+ padding: 0 !important;
67
+ margin-right: 0;
68
+ margin-left: 0;
69
+ }
70
+
71
+ /* Typography: title and description in fullpage left column */
72
+ .memori-widget.memori-layout-fullpage .memori--title {
73
+ margin-bottom: var(--memori-spacing-xs);
74
+ color: var(--memori-text-color);
75
+ font-size: var(--memori-text-size-heading-large);
76
+ font-weight: var(--memori-text-weight-semibold);
77
+ line-height: var(--memori-text-line-tight);
78
+ }
79
+
80
+ .memori-widget.memori-layout-fullpage .memori--description,
81
+ .memori-widget.memori-layout-fullpage .memori--needsPosition {
82
+ padding: var(--memori-spacing-lg);
83
+ padding-top: var(--memori-spacing-xs);
84
+ color: var(--memori-text-color);
85
+ font-size: var(--memori-text-size-base);
86
+ line-height: var(--memori-text-line-relaxed);
87
+ }
88
+
89
+ /* Powered-by position in fullpage */
90
+ .memori-widget.memori-layout-fullpage .memori--powered-by {
91
+ flex-shrink: 0;
92
+ padding: var(--memori-spacing-sm) var(--memori-spacing-md);
93
+ border-radius: var(--memori-radius-box);
94
+ font-size: var(--memori-text-size-small);
95
+ }
96
+
97
+ @media (max-width: 870px) {
98
+ .memori-widget.memori-layout-fullpage {
99
+ padding: var(--memori-spacing-sm);
100
+ }
101
+
102
+ .memori-widget.memori-layout-fullpage > .memori-spin {
103
+ gap: var(--memori-spacing-md);
104
+ }
105
+
106
+ .memori-widget.memori-layout-fullpage .memori--grid-column-left {
107
+ display: none;
108
+ }
109
+
110
+ .memori-widget.memori-layout-fullpage .memori-chat-layout--controls {
111
+ padding: var(--memori-spacing-sm);
112
+ }
113
+ }
114
+
115
+ @media (max-width: 480px) {
116
+ .memori-widget.memori-layout-fullpage .memori-chat-layout--controls {
117
+ padding: var(--memori-spacing-xs);
118
+ }
119
+ }
@@ -0,0 +1,2 @@
1
+ export declare function sanitizeUserMessageInput(raw: string): string;
2
+ export declare function formatUserBubbleHtml(cleanText: string): string;
@@ -0,0 +1,18 @@
1
+ import DOMPurify from 'dompurify';
2
+ import { escapeHTML } from './utils';
3
+ import { truncateMessagePlain } from './message';
4
+ export function sanitizeUserMessageInput(raw) {
5
+ if (raw == null || typeof raw !== 'string') {
6
+ return '';
7
+ }
8
+ const stripped = DOMPurify.sanitize(raw, {
9
+ ALLOWED_TAGS: [],
10
+ ALLOWED_ATTR: [],
11
+ });
12
+ return stripped.trim();
13
+ }
14
+ export function formatUserBubbleHtml(cleanText) {
15
+ const truncated = truncateMessagePlain(cleanText);
16
+ return escapeHTML(truncated).replace(/\n/g, '<br />');
17
+ }
18
+ //# sourceMappingURL=userMessage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userMessage.js","sourceRoot":"","sources":["../../src/helpers/userMessage.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAMjD,MAAM,UAAU,wBAAwB,CAAC,GAAW;IAClD,IAAI,GAAG,IAAI,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC3C,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE;QACvC,YAAY,EAAE,EAAE;QAChB,YAAY,EAAE,EAAE;KACjB,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC;AAGD,MAAM,UAAU,oBAAoB,CAAC,SAAiB;IACpD,MAAM,SAAS,GAAG,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAClD,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AACxD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ declare const FacebookIcon: (props: React.SVGProps<SVGSVGElement>) => JSX.Element;
3
+ export default FacebookIcon;
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ const FacebookIcon = (props) => (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: 800, height: 800, fill: "currentColor", viewBox: "0 0 24 24", ...props, children: [_jsx("path", { fill: "currentColor", d: "M17.3 9.6a1 1 0 1 0-1.6-1.2l-2.308 3.078-2.185-2.185A1 1 0 0 0 9.7 9.4l-3 4a1 1 0 0 0 1.6 1.2l2.308-3.078 2.185 2.185A1 1 0 0 0 14.3 13.6l3-4Z" }), _jsx("path", { fill: "currentColor", fillRule: "evenodd", d: "M12 23c-1.224 0-1.9-.131-3-.5l-2.106 1.053A2 2 0 0 1 4 21.763V19.5c-2.153-2.008-3-4.323-3-7.5C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11Zm-6-4.37-.636-.593C3.691 16.477 3 14.733 3 12a9 9 0 1 1 9 9c-.986 0-1.448-.089-2.364-.396l-.788-.264L6 21.764V18.63Z", clipRule: "evenodd" })] }));
3
+ export default FacebookIcon;
4
+ //# sourceMappingURL=FacebookIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FacebookIcon.js","sourceRoot":"","sources":["../../src/icons/FacebookIcon.tsx"],"names":[],"mappings":";AACA,MAAM,YAAY,GAAG,CAAC,KAAoC,EAAE,EAAE,CAAC,CAC7D,eACE,KAAK,EAAC,4BAA4B,EAClC,KAAK,EAAE,GAAG,EACV,MAAM,EAAE,GAAG,EACX,IAAI,EAAC,cAAc,EACnB,OAAO,EAAC,WAAW,KACf,KAAK,aAET,eACE,IAAI,EAAC,cAAc,EACnB,CAAC,EAAC,gJAAgJ,GAClJ,EACF,eACE,IAAI,EAAC,cAAc,EACnB,QAAQ,EAAC,SAAS,EAClB,CAAC,EAAC,uQAAuQ,EACzQ,QAAQ,EAAC,SAAS,GAClB,IACE,CACP,CAAA;AACD,eAAe,YAAY,CAAA"}
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ declare const LinkedinIcon: (props: React.SVGProps<SVGSVGElement>) => JSX.Element;
3
+ export default LinkedinIcon;
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ const LinkedinIcon = (props) => (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: 800, height: 800, fill: "currentColor", viewBox: "0 0 24 24", ...props, children: [_jsx("path", { fill: "currentColor", d: "M6.5 8a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3ZM5 10a1 1 0 0 1 1-1h1a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-8ZM11 19h1a1 1 0 0 0 1-1v-4.5c0-1.5 3-2.5 3-.5v5a1 1 0 0 0 1 1h1a1 1 0 0 0 1-1v-6c0-2-1.5-3-3.5-3S13 10.5 13 10.5V10a1 1 0 0 0-1-1h-1a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1Z" }), _jsx("path", { fill: "currentColor", fillRule: "evenodd", d: "M20 1a3 3 0 0 1 3 3v16a3 3 0 0 1-3 3H4a3 3 0 0 1-3-3V4a3 3 0 0 1 3-3h16Zm0 2a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h16Z", clipRule: "evenodd" })] }));
3
+ export default LinkedinIcon;
4
+ //# sourceMappingURL=LinkedinIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinkedinIcon.js","sourceRoot":"","sources":["../../src/icons/LinkedinIcon.tsx"],"names":[],"mappings":";AACA,MAAM,YAAY,GAAG,CAAC,KAAoC,EAAE,EAAE,CAAC,CAC7D,eACE,KAAK,EAAC,4BAA4B,EAClC,KAAK,EAAE,GAAG,EACV,MAAM,EAAE,GAAG,EACX,IAAI,EAAC,cAAc,EACnB,OAAO,EAAC,WAAW,KACf,KAAK,aAET,eACE,IAAI,EAAC,cAAc,EACnB,CAAC,EAAC,sRAAsR,GACxR,EACF,eACE,IAAI,EAAC,cAAc,EACnB,QAAQ,EAAC,SAAS,EAClB,CAAC,EAAC,iJAAiJ,EACnJ,QAAQ,EAAC,SAAS,GAClB,IACE,CACP,CAAA;AACD,eAAe,YAAY,CAAA"}
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ declare const TelegramIcon: (props: React.SVGProps<SVGSVGElement>) => JSX.Element;
3
+ export default TelegramIcon;
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ const TelegramIcon = (props) => (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: 800, height: 800, fill: "currentColor", viewBox: "0 0 24 24", ...props, children: _jsx("path", { fill: "currentColor", fillRule: "evenodd", d: "M23.112 4.494c.318-1.55-1.205-2.837-2.68-2.267L2.342 9.216c-1.647.637-1.72 2.941-.117 3.682l3.94 1.818 1.873 6.559a1 1 0 0 0 1.67.432l2.886-2.887 4.043 3.033a2 2 0 0 0 3.16-1.198l3.315-16.16ZM3.063 11.082l18.09-6.99-3.316 16.161L13.1 16.7a1 1 0 0 0-1.307.093l-1.236 1.236.371-2.043 7.28-7.279a1 1 0 0 0-1.204-1.575L6.95 12.876l-3.888-1.794Zm5.114 3.397.606 2.123.233-1.281a1 1 0 0 1 .277-.528l2.22-2.22-3.336 1.906Z", clipRule: "evenodd" }) }));
3
+ export default TelegramIcon;
4
+ //# sourceMappingURL=TelegramIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TelegramIcon.js","sourceRoot":"","sources":["../../src/icons/TelegramIcon.tsx"],"names":[],"mappings":";AACA,MAAM,YAAY,GAAG,CAAC,KAAoC,EAAE,EAAE,CAAC,CAC7D,cACE,KAAK,EAAC,4BAA4B,EAClC,KAAK,EAAE,GAAG,EACV,MAAM,EAAE,GAAG,EACX,IAAI,EAAC,cAAc,EACnB,OAAO,EAAC,WAAW,KACf,KAAK,YAET,eACE,IAAI,EAAC,cAAc,EACnB,QAAQ,EAAC,SAAS,EAClB,CAAC,EAAC,iaAAia,EACna,QAAQ,EAAC,SAAS,GAClB,GACE,CACP,CAAA;AACD,eAAe,YAAY,CAAA"}
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ declare const TwitterIcon: (props: React.SVGProps<SVGSVGElement>) => JSX.Element;
3
+ export default TwitterIcon;
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ const TwitterIcon = (props) => (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: 800, height: 800, fill: "currentColor", viewBox: "0 0 100 100", ...props, children: [_jsx("path", { fill: "currentColor", d: "M69.7 8.7H30.4C18.7 8.7 9.1 18.2 9.1 30v41.2c0 11.7 9.5 21.3 21.3 21.3h39.4c11.7 0 21.3-9.5 21.3-21.3V29.9C91 18.2 81.5 8.7 69.7 8.7zm7.1 69.6H61.4c-.1 0-.2 0-.2-.1L46.8 57.3h-.1C40.9 64 35.2 70.6 29.6 77.1c-.3.4-.7.7-1 1-.1.1-.2.1-.3.1h-4.2c-.1 0-.2 0-.1-.1l20.5-23.8c.1-.1.1-.2 0-.3L24.1 24.3v-.1h15.5c.1 0 .1 0 .2.1L53.4 44h.1l16.9-19.7c.1-.1.2-.1.3-.1h4.2c.2 0 .2.1.1.2L55.6 46.9c-.1.1-.1.2 0 .3l21.3 31s0 .1-.1.1z" }), _jsx("path", { d: "M37.8 27.8h-6.7c-.1 0-.1.1-.1.2l32.2 46.7H69.9c.1 0 .1-.1.1-.2L37.8 27.8z" })] }));
3
+ export default TwitterIcon;
4
+ //# sourceMappingURL=TwitterIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TwitterIcon.js","sourceRoot":"","sources":["../../src/icons/TwitterIcon.tsx"],"names":[],"mappings":";AACA,MAAM,WAAW,GAAG,CAAC,KAAoC,EAAE,EAAE,CAAC,CAC5D,eAAK,KAAK,EAAC,4BAA4B,EAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAC,cAAc,EAAC,OAAO,EAAC,aAAa,KAAK,KAAK,aAClH,eAAM,IAAI,EAAC,cAAc,EAAC,CAAC,EAAC,oaAAoa,GAAG,EACnc,eAAM,CAAC,EAAC,2EAA2E,GAAG,IAClF,CACP,CAAA;AACD,eAAe,WAAW,CAAA"}
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ declare const WhatsappIcon: (props: React.SVGProps<SVGSVGElement>) => JSX.Element;
3
+ export default WhatsappIcon;
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ const WhatsappIcon = (props) => (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: 800, height: 800, fill: "currentColor", viewBox: "0 0 24 24", ...props, children: [_jsx("path", { fill: "currentColor", d: "M6.014 8.006c.114-.904 1.289-2.132 2.22-1.996V6.01c.907.172 1.625 1.734 2.03 2.436.286.509.1 1.025-.167 1.243-.361.29-.926.692-.808 1.095C9.5 11.5 12 14 13.23 14.711c.466.269.804-.44 1.092-.804.21-.28.726-.447 1.234-.171.759.442 1.474.956 2.135 1.534.33.276.408.684.179 1.115-.403.76-1.569 1.76-2.415 1.557C13.976 17.587 8 15.27 6.08 8.558c-.108-.318-.08-.438-.066-.552Z" }), _jsx("path", { fill: "currentColor", fillRule: "evenodd", d: "M12 23c-1.224 0-1.9-.131-3-.5l-2.106 1.053A2 2 0 0 1 4 21.763V19.5c-2.153-2.008-3-4.323-3-7.5C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11Zm-6-4.37-.636-.593C3.691 16.477 3 14.733 3 12a9 9 0 1 1 9 9c-.986 0-1.448-.089-2.364-.396l-.788-.264L6 21.764V18.63Z", clipRule: "evenodd" })] }));
3
+ export default WhatsappIcon;
4
+ //# sourceMappingURL=WhatsappIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WhatsappIcon.js","sourceRoot":"","sources":["../../src/icons/WhatsappIcon.tsx"],"names":[],"mappings":";AACA,MAAM,YAAY,GAAG,CAAC,KAAoC,EAAE,EAAE,CAAC,CAC7D,eACE,KAAK,EAAC,4BAA4B,EAClC,KAAK,EAAE,GAAG,EACV,MAAM,EAAE,GAAG,EACX,IAAI,EAAC,cAAc,EACnB,OAAO,EAAC,WAAW,KACf,KAAK,aAET,eACE,IAAI,EAAC,cAAc,EACnB,CAAC,EAAC,oXAAoX,GACtX,EACF,eACE,IAAI,EAAC,cAAc,EACnB,QAAQ,EAAC,SAAS,EAClB,CAAC,EAAC,uQAAuQ,EACzQ,QAAQ,EAAC,SAAS,GAClB,IACE,CACP,CAAA;AACD,eAAe,YAAY,CAAA"}
@@ -383,6 +383,7 @@
383
383
  "co2": "CO2",
384
384
  "water": "Wasser",
385
385
  "usageBadgesHint": "Klicke auf einen dieser Buttons, um mehr Informationen zu sehen",
386
+ "totalChatConsumptionTitle": "Gesamter Chat-Verbrauch",
386
387
  "impactComparisonUnavailable": "Indikativer Vergleich nicht verfuegbar.",
387
388
  "impactComparisonEnergy": "Indikativer Vergleich: in etwa wie eine 10-W-LED-Lampe fuer {{duration}} eingeschaltet lassen.",
388
389
  "impactComparisonCo2": "Indikativer Vergleich: etwa {{distance}} mit einem durchschnittlichen Benzinauto gefahren.",
@@ -454,6 +454,7 @@
454
454
  "co2": "CO2",
455
455
  "water": "Water",
456
456
  "usageBadgesHint": "Click one of these buttons to show more information",
457
+ "totalChatConsumptionTitle": "Total Chat Consumption",
457
458
  "impactComparisonUnavailable": "Indicative comparison unavailable.",
458
459
  "impactComparisonEnergy": "Indicative comparison: roughly like keeping a 10 W LED bulb on for {{duration}}.",
459
460
  "impactComparisonCo2": "Indicative comparison: about {{distance}} traveled by an average gasoline car.",
@@ -410,6 +410,7 @@
410
410
  "co2": "CO2",
411
411
  "water": "Agua",
412
412
  "usageBadgesHint": "Haz clic en uno de estos botones para ver más información",
413
+ "totalChatConsumptionTitle": "Consumo Total del Chat",
413
414
  "impactComparisonUnavailable": "Comparacion indicativa no disponible.",
414
415
  "impactComparisonEnergy": "Comparacion indicativa: aproximadamente como mantener encendida una bombilla LED de 10 W durante {{duration}}.",
415
416
  "impactComparisonCo2": "Comparacion indicativa: aproximadamente {{distance}} recorridos en un coche de gasolina promedio.",
@@ -418,6 +418,7 @@
418
418
  "co2": "CO2",
419
419
  "water": "Eau",
420
420
  "usageBadgesHint": "Cliquez sur un de ces boutons pour afficher plus d'informations",
421
+ "totalChatConsumptionTitle": "Consommation Totale du Chat",
421
422
  "impactComparisonUnavailable": "Comparaison indicative non disponible.",
422
423
  "impactComparisonEnergy": "Comparaison indicative : environ comme laisser allumee une ampoule LED de 10 W pendant {{duration}}.",
423
424
  "impactComparisonCo2": "Comparaison indicative : environ {{distance}} parcourus en voiture essence moyenne.",
@@ -450,6 +450,7 @@
450
450
  "co2": "CO2",
451
451
  "water": "Acqua",
452
452
  "usageBadgesHint": "Clicca uno di questi pulsanti per mostrare maggiori informazioni",
453
+ "totalChatConsumptionTitle": "Consumo Totale Chat",
453
454
  "impactComparisonUnavailable": "Confronto indicativo non disponibile.",
454
455
  "impactComparisonEnergy": "Confronto indicativo: circa quanto tenere accesa una lampadina LED da 10 W per {{duration}}.",
455
456
  "impactComparisonCo2": "Confronto indicativo: circa {{distance}} percorsi in auto a benzina media.",
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { RenderOptions, RenderResult } from '@testing-library/react';
3
+ declare function render(ui: React.ReactElement, options?: Omit<RenderOptions, 'wrapper'>): RenderResult;
4
+ export * from '@testing-library/react';
5
+ export { render };
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { render as rtlRender, } from '@testing-library/react';
3
+ import { AlertProvider, AlertViewport } from '@memori.ai/ui';
4
+ function AlertProviderWrapper({ children }) {
5
+ return (_jsxs(AlertProvider, { children: [children, _jsx(AlertViewport, {})] }));
6
+ }
7
+ function render(ui, options) {
8
+ return rtlRender(ui, {
9
+ wrapper: AlertProviderWrapper,
10
+ ...options,
11
+ });
12
+ }
13
+ export * from '@testing-library/react';
14
+ export { render };
15
+ //# sourceMappingURL=testUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testUtils.js","sourceRoot":"","sources":["../src/testUtils.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,MAAM,IAAI,SAAS,GAGpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAM7D,SAAS,oBAAoB,CAAC,EAAE,QAAQ,EAAiC;IACvE,OAAO,CACL,MAAC,aAAa,eACX,QAAQ,EACT,KAAC,aAAa,KAAG,IACH,CACjB,CAAC;AACJ,CAAC;AAUD,SAAS,MAAM,CACb,EAAsB,EACtB,OAAwC;IAExC,OAAO,SAAS,CAAC,EAAE,EAAE;QACnB,OAAO,EAAE,oBAAoB;QAC7B,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC;AAGD,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,CAAC"}
package/esm/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "8.30.1";
1
+ export declare const version = "8.32.0";
package/esm/version.js CHANGED
@@ -1,2 +1,2 @@
1
- export const version = '8.30.1';
1
+ export const version = '8.32.0';
2
2
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "8.30.1",
2
+ "version": "8.32.0",
3
3
  "name": "@memori.ai/memori-react",
4
4
  "author": "Memori Srl",
5
5
  "main": "dist/index.js",
@@ -97,10 +97,18 @@
97
97
  }
98
98
  }
99
99
 
100
+ .memori-header--button--sustainability-icon {
101
+ width: 1em;
102
+ color: currentColor;
103
+ }
100
104
  .memori-header .memori-header--button--position {
101
105
  margin-right: 0;
102
106
  }
103
107
 
108
+ .memori-header--button--sustainability{
109
+ max-height: 37px;
110
+ }
111
+
104
112
 
105
113
  .memori-dropdown--avatar-input{
106
114
  position: absolute;
@@ -124,3 +132,48 @@
124
132
  .memori-dropdown--avatar-initial:hover + .memori-dropdown--avatar-input,.memori-dropdown--avatar:hover + .memori-dropdown--avatar-input{
125
133
  display: block;
126
134
  }
135
+
136
+ .memori-dropdown--sustainability {
137
+ min-width: 260px;
138
+ padding: 0.625rem 0.75rem;
139
+ border-radius: 8px;
140
+ background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(247, 249, 252, 0.96) 100%);
141
+ }
142
+
143
+ .memori-dropdown--sustainability-title {
144
+ margin: 0 0 0.5rem 0;
145
+ font-size: 0.95rem;
146
+ font-weight: 700;
147
+ line-height: 1.2;
148
+ text-align: center;
149
+ }
150
+
151
+ .memori-dropdown--sustainability-metrics {
152
+ display: flex;
153
+ flex-direction: column;
154
+ gap: 0.35rem;
155
+ }
156
+
157
+ .memori-dropdown--sustainability-row {
158
+ display: flex;
159
+ align-items: center;
160
+ justify-content: space-between;
161
+ padding: 0.4rem 0.5rem;
162
+ border-radius: 6px;
163
+ background: rgba(255, 255, 255, 0.8);
164
+ gap: 1rem;
165
+ }
166
+
167
+ .memori-dropdown--sustainability-label {
168
+ display: inline-flex;
169
+ align-items: center;
170
+ font-size: 0.82rem;
171
+ font-weight: 500;
172
+ gap: 0.35rem;
173
+ opacity: 0.9;
174
+ }
175
+
176
+ .memori-dropdown--sustainability-value {
177
+ font-size: 0.85rem;
178
+ white-space: nowrap;
179
+ }
@@ -26,6 +26,31 @@ const meta: Meta = {
26
26
 
27
27
  export default meta;
28
28
 
29
+ const historyWithConsumption = [
30
+ ...history,
31
+ {
32
+ ...history[history.length - 1],
33
+ llmUsage: {
34
+ energyImpact: {
35
+ energy: { parsedValue: 0.0012 },
36
+ gwp: { parsedValue: 0.00045 },
37
+ wcf: { parsedValue: 0.0021 },
38
+ },
39
+ },
40
+ },
41
+ {
42
+ ...history[history.length - 1],
43
+ text: 'Second sustainability sample',
44
+ llmUsage: {
45
+ energyImpact: {
46
+ energy: 0.0008,
47
+ gwp: { source: '0.00035' },
48
+ wcf: { source: '0.0014' },
49
+ },
50
+ },
51
+ },
52
+ ] as any;
53
+
29
54
  const Template: Story<Props> = args => {
30
55
  const [speakerMuted, setSpeakerMuted] = React.useState(args.speakerMuted);
31
56
  const [showSettingsDrawer, setShowSettingsDrawer] = React.useState(false);
@@ -283,3 +308,24 @@ WithLogin.args = {
283
308
  hasUserActivatedSpeak: false,
284
309
  showLogin: true,
285
310
  };
311
+
312
+ export const WithSustainabilityPopover = Template.bind({});
313
+ WithSustainabilityPopover.args = {
314
+ memori,
315
+ history: historyWithConsumption,
316
+ setShowPositionDrawer: () => {},
317
+ setShowSettingsDrawer: () => {},
318
+ setShowChatHistoryDrawer: () => {},
319
+ setShowKnownFactsDrawer: () => {},
320
+ setShowExpertsDrawer: () => {},
321
+ setShowLoginDrawer: () => {},
322
+ clearHistory: () => {},
323
+ speakerMuted: false,
324
+ hasUserActivatedSpeak: true,
325
+ showShare: false,
326
+ showSettings: false,
327
+ showMessageConsumption: true,
328
+ apiClient: {
329
+ backend: {},
330
+ } as any,
331
+ };
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useEffect, useState } from 'react';
1
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
2
2
  import cx from 'classnames';
3
3
  import {
4
4
  Memori,
@@ -23,11 +23,13 @@ import DeepThought from '../icons/DeepThought';
23
23
  import Group from '../icons/Group';
24
24
  import UserIcon from '../icons/User';
25
25
  import MessageIcon from '../icons/Message';
26
+ import GasStation from '../icons/GasStation';
26
27
  import Logout from '../icons/Logout';
27
28
  import { getErrori18nKey } from '../../helpers/error';
28
29
  import toast from 'react-hot-toast';
29
30
  import memoriApiClient from '@memori.ai/memori-api-client';
30
31
  import { Props as WidgetProps } from '../MemoriWidget/MemoriWidget';
32
+ import { BADGE_EMOJI } from '../../helpers/llmUsage';
31
33
 
32
34
  const imgMimeTypes = ['image/jpeg', 'image/png', 'image/jpg', 'image/gif'];
33
35
 
@@ -63,6 +65,7 @@ export interface Props {
63
65
  apiClient: ReturnType<typeof memoriApiClient>;
64
66
  layout?: WidgetProps['layout'];
65
67
  additionalSettings?: WidgetProps['additionalSettings'];
68
+ showMessageConsumption?: boolean;
66
69
  }
67
70
 
68
71
  const Header: React.FC<Props> = ({
@@ -97,11 +100,96 @@ const Header: React.FC<Props> = ({
97
100
  apiClient,
98
101
  layout,
99
102
  additionalSettings,
103
+ showMessageConsumption = false,
100
104
  }) => {
101
- const { t } = useTranslation();
105
+ const { t, i18n } = useTranslation();
102
106
  const { uploadAsset, pwlUpdateUser } = apiClient.backend;
103
107
  const [fullScreenAvailable, setFullScreenAvailable] = useState(false);
104
108
  const [fullScreen, setFullScreen] = useState(false);
109
+
110
+ type ImpactMetricType = 'energy' | 'co2' | 'water';
111
+
112
+ type LlmUsageEnergyImpact = {
113
+ energy?: number | { source?: string; parsedValue?: number };
114
+ gwp?: number | { source?: string; parsedValue?: number };
115
+ wcf?: number | { source?: string; parsedValue?: number };
116
+ };
117
+
118
+ const getMetricValue = (
119
+ metric?: number | { source?: string; parsedValue?: number },
120
+ ): number | undefined => {
121
+ if (typeof metric === 'number' && Number.isFinite(metric)) return metric;
122
+ if (!metric || typeof metric !== 'object') return undefined;
123
+ if (
124
+ typeof metric.parsedValue === 'number' &&
125
+ Number.isFinite(metric.parsedValue)
126
+ ) {
127
+ return metric.parsedValue;
128
+ }
129
+ if (typeof metric.source === 'string') {
130
+ const parsed = Number(metric.source);
131
+ if (Number.isFinite(parsed)) return parsed;
132
+ }
133
+ return undefined;
134
+ };
135
+
136
+ const formatMetricValue = (value: number, locale: string): string =>
137
+ new Intl.NumberFormat(locale, {
138
+ minimumFractionDigits: 0,
139
+ maximumFractionDigits: Math.abs(value) >= 1 ? 3 : 4,
140
+ }).format(value);
141
+
142
+ const formatImpactInReadableUnit = (
143
+ value: number,
144
+ metricType: ImpactMetricType,
145
+ locale: string,
146
+ ): string => {
147
+ const absValue = Math.abs(value);
148
+
149
+ if (metricType === 'energy') {
150
+ if (absValue >= 1) return `${formatMetricValue(value, locale)} kWh`;
151
+ const wh = value * 1000;
152
+ if (Math.abs(wh) >= 1) return `${formatMetricValue(wh, locale)} Wh`;
153
+ return `${formatMetricValue(wh * 1000, locale)} mWh`;
154
+ }
155
+
156
+ if (metricType === 'co2') {
157
+ if (absValue >= 1) return `${formatMetricValue(value, locale)} kg`;
158
+ const g = value * 1000;
159
+ if (Math.abs(g) >= 1) return `${formatMetricValue(g, locale)} g`;
160
+ return `${formatMetricValue(g * 1000, locale)} mg`;
161
+ }
162
+
163
+ if (absValue >= 1) return `${formatMetricValue(value, locale)} L`;
164
+ const ml = value * 1000;
165
+ if (Math.abs(ml) >= 1) return `${formatMetricValue(ml, locale)} mL`;
166
+ return `${formatMetricValue(ml * 1000, locale)} μL`;
167
+ };
168
+
169
+ const currentLocale = i18n.language || navigator.language || 'en';
170
+ const chatLog = useMemo(() => ({ lines: history }), [history]);
171
+ const sustainabilityTotals = useMemo(() => {
172
+ const totals = { energy: 0, gwp: 0, wcf: 0 };
173
+ (chatLog?.lines ?? []).forEach(line => {
174
+ const energyImpact = (line as Message & {
175
+ llmUsage?: { energyImpact?: LlmUsageEnergyImpact };
176
+ }).llmUsage?.energyImpact;
177
+ if (!energyImpact) return;
178
+ totals.energy += getMetricValue(energyImpact.energy) ?? 0;
179
+ totals.gwp += getMetricValue(energyImpact.gwp) ?? 0;
180
+ totals.wcf += getMetricValue(energyImpact.wcf) ?? 0;
181
+ });
182
+ return totals;
183
+ }, [chatLog]);
184
+ const hasSustainabilityData = useMemo(
185
+ () =>
186
+ (chatLog?.lines ?? []).some(
187
+ line =>
188
+ !!(line as Message & { llmUsage?: { energyImpact?: LlmUsageEnergyImpact } })
189
+ .llmUsage?.energyImpact
190
+ ),
191
+ [chatLog]
192
+ );
105
193
  useEffect(() => {
106
194
  if (document.fullscreenEnabled) {
107
195
  setFullScreenAvailable(true);
@@ -219,6 +307,67 @@ const Header: React.FC<Props> = ({
219
307
  onClick={() => setShowChatHistoryDrawer(true)}
220
308
  />
221
309
  )}
310
+ {showMessageConsumption && hasSustainabilityData && (
311
+ <Dropdown
312
+ placement="bottom-right"
313
+ trigger={
314
+ <Button
315
+ primary
316
+ shape="circle"
317
+ className={cx('memori-header--button', 'memori-header--button--sustainability', hasSpacedButtons && 'memori-header--button-spaced')}
318
+ title={t('write_and_speak.showMessageConsumptionLabel') || 'LLM consumption'}
319
+ icon={<GasStation className="memori-header--button--sustainability-icon" />}
320
+ />
321
+ }
322
+ >
323
+ <div className="memori-dropdown--sustainability">
324
+ <h4 className="memori-dropdown--sustainability-title">
325
+ {t('chatLogs.totalChatConsumptionTitle') || 'Consumo Totale Chat'}
326
+ </h4>
327
+ <div className="memori-dropdown--sustainability-metrics">
328
+ <div className="memori-dropdown--sustainability-row">
329
+ <span className="memori-dropdown--sustainability-label">
330
+ <span aria-hidden="true">{BADGE_EMOJI.energy}</span>{' '}
331
+ {t('chatLogs.energy') || 'Energy'}
332
+ </span>
333
+ <strong className="memori-dropdown--sustainability-value">
334
+ {formatImpactInReadableUnit(
335
+ sustainabilityTotals.energy,
336
+ 'energy',
337
+ currentLocale
338
+ )}
339
+ </strong>
340
+ </div>
341
+ <div className="memori-dropdown--sustainability-row">
342
+ <span className="memori-dropdown--sustainability-label">
343
+ <span aria-hidden="true">{BADGE_EMOJI.co2}</span>{' '}
344
+ {t('chatLogs.co2') || 'CO2'}
345
+ </span>
346
+ <strong className="memori-dropdown--sustainability-value">
347
+ {formatImpactInReadableUnit(
348
+ sustainabilityTotals.gwp,
349
+ 'co2',
350
+ currentLocale
351
+ )}
352
+ </strong>
353
+ </div>
354
+ <div className="memori-dropdown--sustainability-row">
355
+ <span className="memori-dropdown--sustainability-label">
356
+ <span aria-hidden="true">{BADGE_EMOJI.water}</span>{' '}
357
+ {t('chatLogs.water') || 'Water'}
358
+ </span>
359
+ <strong className="memori-dropdown--sustainability-value">
360
+ {formatImpactInReadableUnit(
361
+ sustainabilityTotals.wcf,
362
+ 'water',
363
+ currentLocale
364
+ )}
365
+ </strong>
366
+ </div>
367
+ </div>
368
+ </div>
369
+ </Dropdown>
370
+ )}
222
371
  {fullScreenAvailable && (
223
372
  <Button
224
373
  primary