@memori.ai/memori-react 8.2.0 → 8.4.0-rc.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 (146) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/components/Chat/Chat.js +8 -1
  3. package/dist/components/Chat/Chat.js.map +1 -1
  4. package/dist/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.css +160 -0
  5. package/dist/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.d.ts +4 -0
  6. package/dist/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.js +166 -0
  7. package/dist/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.js.map +1 -0
  8. package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.css +877 -0
  9. package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.d.ts +3 -0
  10. package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js +115 -0
  11. package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js.map +1 -0
  12. package/dist/components/MemoriArtifactSystem/components/ArtifactHandler/ArtifactHandler.css +238 -0
  13. package/dist/components/MemoriArtifactSystem/components/ArtifactHandler/ArtifactHandler.d.ts +4 -0
  14. package/dist/components/MemoriArtifactSystem/components/ArtifactHandler/ArtifactHandler.js +104 -0
  15. package/dist/components/MemoriArtifactSystem/components/ArtifactHandler/ArtifactHandler.js.map +1 -0
  16. package/dist/components/MemoriArtifactSystem/components/ArtifactHistory/ArtifactHistory.css +319 -0
  17. package/dist/components/MemoriArtifactSystem/components/ArtifactHistory/ArtifactHistory.d.ts +4 -0
  18. package/dist/components/MemoriArtifactSystem/components/ArtifactHistory/ArtifactHistory.js +50 -0
  19. package/dist/components/MemoriArtifactSystem/components/ArtifactHistory/ArtifactHistory.js.map +1 -0
  20. package/dist/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.css +343 -0
  21. package/dist/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.d.ts +4 -0
  22. package/dist/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.js +78 -0
  23. package/dist/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.js.map +1 -0
  24. package/dist/components/MemoriArtifactSystem/context/ArtifactSystemContext.d.ts +12 -0
  25. package/dist/components/MemoriArtifactSystem/context/ArtifactSystemContext.js +22 -0
  26. package/dist/components/MemoriArtifactSystem/context/ArtifactSystemContext.js.map +1 -0
  27. package/dist/components/MemoriArtifactSystem/hooks/useArtifactSystem.d.ts +12 -0
  28. package/dist/components/MemoriArtifactSystem/hooks/useArtifactSystem.js +288 -0
  29. package/dist/components/MemoriArtifactSystem/hooks/useArtifactSystem.js.map +1 -0
  30. package/dist/components/MemoriArtifactSystem/index.d.ts +9 -0
  31. package/dist/components/MemoriArtifactSystem/index.js +28 -0
  32. package/dist/components/MemoriArtifactSystem/index.js.map +1 -0
  33. package/dist/components/MemoriArtifactSystem/types/artifact.types.d.ts +108 -0
  34. package/dist/components/MemoriArtifactSystem/types/artifact.types.js +31 -0
  35. package/dist/components/MemoriArtifactSystem/types/artifact.types.js.map +1 -0
  36. package/dist/components/icons/Print.d.ts +6 -0
  37. package/dist/components/icons/Print.js +6 -0
  38. package/dist/components/icons/Print.js.map +1 -0
  39. package/dist/components/layouts/Chat.js +29 -1
  40. package/dist/components/layouts/Chat.js.map +1 -1
  41. package/dist/components/layouts/FullPage.js +33 -1
  42. package/dist/components/layouts/FullPage.js.map +1 -1
  43. package/dist/components/layouts/ZoomedFullBody.js +29 -2
  44. package/dist/components/layouts/ZoomedFullBody.js.map +1 -1
  45. package/dist/components/layouts/chat.css +335 -13
  46. package/dist/components/layouts/zoomed-full-body.css +1 -3
  47. package/dist/helpers/message.js +1 -0
  48. package/dist/helpers/message.js.map +1 -1
  49. package/dist/helpers/stt/useSTT.js +76 -9
  50. package/dist/helpers/stt/useSTT.js.map +1 -1
  51. package/dist/index.js +58 -15
  52. package/dist/index.js.map +1 -1
  53. package/dist/styles.css +5 -0
  54. package/esm/components/Chat/Chat.js +8 -1
  55. package/esm/components/Chat/Chat.js.map +1 -1
  56. package/esm/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.css +160 -0
  57. package/esm/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.d.ts +4 -0
  58. package/esm/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.js +163 -0
  59. package/esm/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.js.map +1 -0
  60. package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.css +877 -0
  61. package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.d.ts +3 -0
  62. package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js +112 -0
  63. package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js.map +1 -0
  64. package/esm/components/MemoriArtifactSystem/components/ArtifactHandler/ArtifactHandler.css +238 -0
  65. package/esm/components/MemoriArtifactSystem/components/ArtifactHandler/ArtifactHandler.d.ts +4 -0
  66. package/esm/components/MemoriArtifactSystem/components/ArtifactHandler/ArtifactHandler.js +101 -0
  67. package/esm/components/MemoriArtifactSystem/components/ArtifactHandler/ArtifactHandler.js.map +1 -0
  68. package/esm/components/MemoriArtifactSystem/components/ArtifactHistory/ArtifactHistory.css +319 -0
  69. package/esm/components/MemoriArtifactSystem/components/ArtifactHistory/ArtifactHistory.d.ts +4 -0
  70. package/esm/components/MemoriArtifactSystem/components/ArtifactHistory/ArtifactHistory.js +47 -0
  71. package/esm/components/MemoriArtifactSystem/components/ArtifactHistory/ArtifactHistory.js.map +1 -0
  72. package/esm/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.css +343 -0
  73. package/esm/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.d.ts +4 -0
  74. package/esm/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.js +75 -0
  75. package/esm/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.js.map +1 -0
  76. package/esm/components/MemoriArtifactSystem/context/ArtifactSystemContext.d.ts +12 -0
  77. package/esm/components/MemoriArtifactSystem/context/ArtifactSystemContext.js +17 -0
  78. package/esm/components/MemoriArtifactSystem/context/ArtifactSystemContext.js.map +1 -0
  79. package/esm/components/MemoriArtifactSystem/hooks/useArtifactSystem.d.ts +12 -0
  80. package/esm/components/MemoriArtifactSystem/hooks/useArtifactSystem.js +281 -0
  81. package/esm/components/MemoriArtifactSystem/hooks/useArtifactSystem.js.map +1 -0
  82. package/esm/components/MemoriArtifactSystem/index.d.ts +9 -0
  83. package/esm/components/MemoriArtifactSystem/index.js +9 -0
  84. package/esm/components/MemoriArtifactSystem/index.js.map +1 -0
  85. package/esm/components/MemoriArtifactSystem/types/artifact.types.d.ts +108 -0
  86. package/esm/components/MemoriArtifactSystem/types/artifact.types.js +28 -0
  87. package/esm/components/MemoriArtifactSystem/types/artifact.types.js.map +1 -0
  88. package/esm/components/icons/Print.d.ts +6 -0
  89. package/esm/components/icons/Print.js +4 -0
  90. package/esm/components/icons/Print.js.map +1 -0
  91. package/esm/components/layouts/Chat.js +29 -1
  92. package/esm/components/layouts/Chat.js.map +1 -1
  93. package/esm/components/layouts/FullPage.js +33 -1
  94. package/esm/components/layouts/FullPage.js.map +1 -1
  95. package/esm/components/layouts/ZoomedFullBody.js +30 -3
  96. package/esm/components/layouts/ZoomedFullBody.js.map +1 -1
  97. package/esm/components/layouts/chat.css +335 -13
  98. package/esm/components/layouts/zoomed-full-body.css +1 -3
  99. package/esm/helpers/message.js +1 -0
  100. package/esm/helpers/message.js.map +1 -1
  101. package/esm/helpers/stt/useSTT.js +76 -9
  102. package/esm/helpers/stt/useSTT.js.map +1 -1
  103. package/esm/index.js +58 -15
  104. package/esm/index.js.map +1 -1
  105. package/esm/styles.css +5 -0
  106. package/package.json +1 -1
  107. package/src/components/Avatar/Avatar.test.tsx +13 -0
  108. package/src/components/Chat/Chat.stories.tsx +33 -2
  109. package/src/components/Chat/Chat.test.tsx +340 -213
  110. package/src/components/Chat/Chat.tsx +27 -4
  111. package/src/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.css +160 -0
  112. package/src/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.tsx +278 -0
  113. package/src/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.css +877 -0
  114. package/src/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.tsx +308 -0
  115. package/src/components/MemoriArtifactSystem/components/ArtifactHandler/ArtifactHandler.css +238 -0
  116. package/src/components/MemoriArtifactSystem/components/ArtifactHandler/ArtifactHandler.tsx +282 -0
  117. package/src/components/MemoriArtifactSystem/components/ArtifactHistory/ArtifactHistory.css +319 -0
  118. package/src/components/MemoriArtifactSystem/components/ArtifactHistory/ArtifactHistory.tsx +178 -0
  119. package/src/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.css +343 -0
  120. package/src/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.tsx +190 -0
  121. package/src/components/MemoriArtifactSystem/context/ArtifactSystemContext.tsx +57 -0
  122. package/src/components/MemoriArtifactSystem/hooks/useArtifactSystem.ts +419 -0
  123. package/src/components/MemoriArtifactSystem/index.ts +45 -0
  124. package/src/components/MemoriArtifactSystem/types/artifact.types.ts +180 -0
  125. package/src/components/icons/Print.tsx +34 -0
  126. package/src/components/layouts/Chat.test.tsx +13 -0
  127. package/src/components/layouts/Chat.tsx +80 -25
  128. package/src/components/layouts/FullPage.test.tsx +40 -11
  129. package/src/components/layouts/FullPage.tsx +92 -24
  130. package/src/components/layouts/HiddenChat.test.tsx +13 -0
  131. package/src/components/layouts/Totem.test.tsx +13 -0
  132. package/src/components/layouts/WebsiteAssistant.test.tsx +13 -0
  133. package/src/components/layouts/ZoomedFullBody.test.tsx +13 -0
  134. package/src/components/layouts/ZoomedFullBody.tsx +78 -14
  135. package/src/components/layouts/__snapshots__/Chat.test.tsx.snap +252 -248
  136. package/src/components/layouts/__snapshots__/FullPage.test.tsx.snap +504 -496
  137. package/src/components/layouts/__snapshots__/ZoomedFullBody.test.tsx.snap +252 -248
  138. package/src/components/layouts/chat.css +335 -13
  139. package/src/components/layouts/layouts.stories.tsx +13 -2
  140. package/src/components/layouts/zoomed-full-body.css +1 -3
  141. package/src/helpers/message.ts +1 -0
  142. package/src/helpers/stt/useSTT.ts +101 -16
  143. package/src/index.stories.tsx +26 -22
  144. package/src/index.tsx +46 -0
  145. package/src/mocks/data.ts +258 -0
  146. package/src/styles.css +5 -0
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const ArtifactDrawer: React.FC;
3
+ export default ArtifactDrawer;
@@ -0,0 +1,112 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState, useCallback, useEffect } from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { Dialog, Transition } from '@headlessui/react';
5
+ import Button from '../../../ui/Button';
6
+ import Close from '../../../icons/Close';
7
+ import ArtifactActions from '../ArtifactActions/ArtifactActions';
8
+ import ArtifactPreview from '../ArtifactPreview/ArtifactPreview';
9
+ import { useArtifactSystemContext } from '../../context/ArtifactSystemContext';
10
+ const ArtifactDrawer = () => {
11
+ const { actions, state } = useArtifactSystemContext();
12
+ const { t } = useTranslation();
13
+ const [activeTab, setActiveTab] = useState('preview');
14
+ const [showHistory, setShowHistory] = useState(false);
15
+ const [isMobile, setIsMobile] = useState(false);
16
+ const [isAnimating, setIsAnimating] = useState(false);
17
+ useEffect(() => {
18
+ const handleResize = () => {
19
+ const newIsMobile = window.innerWidth < 769;
20
+ if (newIsMobile !== isMobile) {
21
+ setIsAnimating(true);
22
+ setTimeout(() => {
23
+ setIsMobile(newIsMobile);
24
+ setIsAnimating(false);
25
+ }, 150);
26
+ }
27
+ else {
28
+ setIsMobile(newIsMobile);
29
+ }
30
+ };
31
+ handleResize();
32
+ window.addEventListener('resize', handleResize);
33
+ return () => window.removeEventListener('resize', handleResize);
34
+ }, [isMobile]);
35
+ const handleTabChange = useCallback((tab) => {
36
+ setActiveTab(tab);
37
+ }, []);
38
+ const handleCopy = useCallback(async () => {
39
+ if (!state.currentArtifact)
40
+ return;
41
+ try {
42
+ if (navigator.clipboard && navigator.clipboard.writeText) {
43
+ await navigator.clipboard.writeText(state.currentArtifact.content);
44
+ }
45
+ else {
46
+ const textArea = document.createElement('textarea');
47
+ textArea.value = state.currentArtifact.content;
48
+ textArea.style.position = 'fixed';
49
+ textArea.style.left = '-999999px';
50
+ textArea.style.top = '-999999px';
51
+ document.body.appendChild(textArea);
52
+ textArea.focus();
53
+ textArea.select();
54
+ document.execCommand('copy');
55
+ document.body.removeChild(textArea);
56
+ }
57
+ }
58
+ catch (error) {
59
+ console.error('Copy failed:', error);
60
+ throw error;
61
+ }
62
+ }, [state.currentArtifact]);
63
+ const handleDownload = useCallback(() => {
64
+ console.log('Download triggered');
65
+ }, []);
66
+ const handlePrint = useCallback(() => {
67
+ console.log('Print triggered');
68
+ }, []);
69
+ const handleOpenExternal = useCallback(() => {
70
+ console.log('External open triggered');
71
+ }, []);
72
+ const handleToggleFullscreen = useCallback(() => {
73
+ if (actions.toggleFullscreen) {
74
+ actions.toggleFullscreen();
75
+ }
76
+ }, [actions.toggleFullscreen]);
77
+ const handleClose = useCallback(() => {
78
+ setIsAnimating(true);
79
+ setTimeout(() => {
80
+ actions.closeDrawer();
81
+ setIsAnimating(false);
82
+ }, 200);
83
+ }, [actions.closeDrawer]);
84
+ const toggleHistory = useCallback(() => {
85
+ setShowHistory(prev => !prev);
86
+ }, []);
87
+ if (!state.currentArtifact) {
88
+ return null;
89
+ }
90
+ if (isMobile) {
91
+ return (_jsx(Transition, { show: state.isDrawerOpen, children: state.isDrawerOpen && (_jsxs(Dialog, { open: state.isDrawerOpen, onClose: handleClose, className: "memori-artifact-drawer memori-artifact-drawer--mobile", as: "div", children: [_jsx("div", { className: "memori-artifact-drawer--backdrop", onClick: handleClose }), _jsxs("div", { className: "memori-artifact-drawer--panel memori-artifact-drawer--panel-mobile", children: [_jsxs("div", { className: "memori-artifact-drawer--header", children: [_jsxs("div", { className: "memori-artifact-drawer--header-content", children: [_jsx("h2", { className: "memori-artifact-drawer--title", children: state.currentArtifact.title }), _jsx("p", { className: "memori-artifact-drawer--subtitle", children: state.currentArtifact.customTitle ||
92
+ `${state.currentArtifact.typeInfo.name} Content` }), _jsxs("div", { className: "memori-artifact-drawer--meta", children: [_jsxs("span", { className: "memori-artifact-drawer--meta-item", children: [t('artifact.type', 'Type'), ": ", state.currentArtifact.typeInfo.name] }), _jsxs("span", { className: "memori-artifact-drawer--meta-item", children: [t('artifact.size', 'Size'), ": ", formatBytes(state.currentArtifact.size)] }), _jsxs("span", { className: "memori-artifact-drawer--meta-item", children: [t('artifact.generated', 'Generated'), ":", ' ', formatTimestamp(state.currentArtifact.timestamp)] })] })] }), _jsx("div", { className: "memori-artifact-drawer--header-actions", children: _jsx(ArtifactActions, { artifact: state.currentArtifact, onCopy: handleCopy, onDownload: handleDownload, onPrint: handlePrint, onOpenExternal: handleOpenExternal, onToggleFullscreen: handleToggleFullscreen, isFullscreen: state.isFullscreen }) }), _jsx(Button, { onClick: handleClose, className: "memori-artifact-drawer--close", ghost: true, title: t('artifact.close', 'Close') || 'Close', children: _jsx(Close, { className: "memori-artifact-drawer--close-icon" }) })] }), _jsx("div", { className: "memori-artifact-drawer--content", children: _jsx("div", { className: "memori-artifact-drawer--main", children: _jsx(ArtifactPreview, { artifact: state.currentArtifact, activeTab: activeTab, onTabChange: handleTabChange }) }) })] })] })) }));
93
+ }
94
+ return (_jsxs("div", { className: "memori-artifact-panel", children: [_jsxs("div", { className: "memori-artifact-panel--header", children: [_jsxs("div", { className: "memori-artifact-panel--header-content", children: [_jsx("h2", { className: "memori-artifact-panel--title", children: state.currentArtifact.title }), _jsx("p", { className: "memori-artifact-panel--subtitle", children: state.currentArtifact.customTitle ||
95
+ `${state.currentArtifact.typeInfo.name} Content` }), _jsxs("div", { className: "memori-artifact-panel--meta", children: [_jsxs("span", { className: "memori-artifact-panel--meta-item", children: [t('artifact.type', 'Type'), ": ", state.currentArtifact.typeInfo.name] }), _jsxs("span", { className: "memori-artifact-panel--meta-item", children: [t('artifact.size', 'Size'), ": ", formatBytes(state.currentArtifact.size)] }), _jsxs("span", { className: "memori-artifact-panel--meta-item", children: [t('artifact.generated', 'Generated'), ":", ' ', formatTimestamp(state.currentArtifact.timestamp)] })] })] }), _jsx("div", { className: "memori-artifact-panel--header-actions", children: _jsx(ArtifactActions, { artifact: state.currentArtifact, onCopy: handleCopy, onDownload: handleDownload, onPrint: handlePrint, onOpenExternal: handleOpenExternal, onToggleFullscreen: handleToggleFullscreen, isFullscreen: state.isFullscreen }) }), _jsx(Button, { onClick: handleClose, className: "memori-artifact-panel--close", ghost: true, title: t('artifact.close', 'Close') || 'Close', children: _jsx(Close, { className: "memori-artifact-panel--close-icon" }) })] }), _jsx("div", { className: "memori-artifact-panel--content", children: _jsx("div", { className: "memori-artifact-panel--main", children: _jsx(ArtifactPreview, { artifact: state.currentArtifact, activeTab: activeTab, onTabChange: handleTabChange }) }) })] }));
96
+ };
97
+ function formatBytes(bytes) {
98
+ if (bytes === 0)
99
+ return '0 Bytes';
100
+ const k = 1024;
101
+ const sizes = ['Bytes', 'KB', 'MB'];
102
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
103
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
104
+ }
105
+ function formatTimestamp(timestamp) {
106
+ return timestamp.toLocaleTimeString('en-US', {
107
+ hour: '2-digit',
108
+ minute: '2-digit',
109
+ });
110
+ }
111
+ export default ArtifactDrawer;
112
+ //# sourceMappingURL=ArtifactDrawer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArtifactDrawer.js","sourceRoot":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,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,OAAO,UAAU,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC;AAKD,SAAS,eAAe,CAAC,SAAe;IACtC,OAAO,SAAS,CAAC,kBAAkB,CAAC,OAAO,EAAE;QAC3C,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,SAAS;KAClB,CAAC,CAAC;AACL,CAAC;AAED,eAAe,cAAc,CAAC"}
@@ -0,0 +1,238 @@
1
+ /**
2
+ * ArtifactHandler CSS Styles
3
+ * Following the project's design system and CSS patterns
4
+ */
5
+
6
+ .memori-artifact-handler {
7
+ border: 1px solid var(--memori-button-border-color, #e9ecef);
8
+ border-radius: var(--memori-border-radius, 12px);
9
+ margin: 0.75rem 0;
10
+ animation: fadeInUp 0.5s ease forwards;
11
+ backdrop-filter: blur(4px);
12
+ background: rgba(255, 255, 255, 0.95);
13
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
14
+ cursor: pointer;
15
+ opacity: 0;
16
+ transform: translateY(10px);
17
+ transition: all 0.3s ease;
18
+ }
19
+
20
+ .memori-artifact-handler:hover {
21
+ border-color: var(--memori-primary);
22
+ background: rgba(130, 70, 175, 0.05);
23
+ box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
24
+ transform: translateY(-2px);
25
+ }
26
+
27
+ .memori-artifact-handler--active {
28
+ border-color: var(--memori-primary);
29
+ background: linear-gradient(135deg, var(--memori-primary) 0%, #764ba2 100%);
30
+ box-shadow: 0 4px 16px rgba(130, 70, 175, 0.3);
31
+ color: var(--memori-primary-text, #fff);
32
+ }
33
+
34
+ .memori-artifact-handler--active:hover {
35
+ box-shadow: 0 6px 20px rgba(130, 70, 175, 0.4);
36
+ transform: translateY(-2px);
37
+ }
38
+
39
+ .memori-artifact-handler-content {
40
+ display: flex;
41
+ align-items: center;
42
+ padding: 1rem;
43
+ gap: 0.75rem;
44
+ }
45
+
46
+ .memori-artifact-handler-icon {
47
+ flex-shrink: 0;
48
+ font-size: 1.5rem;
49
+ line-height: 1;
50
+ }
51
+
52
+ .memori-artifact-handler-info {
53
+ min-width: 0;
54
+ flex: 1;
55
+ }
56
+
57
+ .memori-artifact-handler-title {
58
+ overflow: hidden;
59
+ margin-bottom: 0.25rem;
60
+ color: inherit;
61
+ font-size: 0.875rem;
62
+ font-weight: 600;
63
+ line-height: 1.3;
64
+ text-overflow: ellipsis;
65
+ white-space: nowrap;
66
+ }
67
+
68
+ .memori-artifact-handler-subtitle {
69
+ overflow: hidden;
70
+ margin-bottom: 0.25rem;
71
+ color: inherit;
72
+ font-size: 0.75rem;
73
+ opacity: 0.7;
74
+ text-overflow: ellipsis;
75
+ white-space: nowrap;
76
+ }
77
+
78
+ .memori-artifact-handler-meta {
79
+ display: flex;
80
+ flex-wrap: wrap;
81
+ font-size: 0.625rem;
82
+ gap: 0.5rem;
83
+ opacity: 0.6;
84
+ }
85
+
86
+ .memori-artifact-handler-type {
87
+ padding: 0.125rem 0.375rem;
88
+ border-radius: 10px;
89
+ background: rgba(0, 0, 0, 0.1);
90
+ color: inherit;
91
+ font-weight: 500;
92
+ letter-spacing: 0.025em;
93
+ text-transform: uppercase;
94
+ }
95
+
96
+ .memori-artifact-handler-custom-title {
97
+ overflow: hidden;
98
+ max-width: 120px;
99
+ padding: 0.125rem 0.375rem;
100
+ border-radius: 10px;
101
+ background: rgba(0, 0, 0, 0.1);
102
+ color: inherit;
103
+ font-style: italic;
104
+ text-overflow: ellipsis;
105
+ white-space: nowrap;
106
+ }
107
+
108
+ .memori-artifact-handler--active .memori-artifact-handler-type,
109
+ .memori-artifact-handler--active .memori-artifact-handler-custom-title {
110
+ background: rgba(255, 255, 255, 0.2);
111
+ }
112
+
113
+ .memori-artifact-handler-actions {
114
+ flex-shrink: 0;
115
+ }
116
+
117
+ .memori-artifact-handler-toggle {
118
+ display: flex;
119
+ align-items: center;
120
+ justify-content: center;
121
+ padding: 0.375rem;
122
+ border: 1px solid rgba(0, 0, 0, 0.1);
123
+ border-radius: var(--memori-border-radius, 6px);
124
+ background: rgba(0, 0, 0, 0.05);
125
+ color: inherit;
126
+ cursor: pointer;
127
+ transition: all 0.2s ease;
128
+ }
129
+
130
+ .memori-artifact-handler-toggle:hover {
131
+ background: rgba(0, 0, 0, 0.1);
132
+ transform: scale(1.05);
133
+ }
134
+
135
+ .memori-artifact-handler--active .memori-artifact-handler-toggle {
136
+ border-color: rgba(255, 255, 255, 0.3);
137
+ background: rgba(255, 255, 255, 0.2);
138
+ }
139
+
140
+ .memori-artifact-handler-toggle:focus {
141
+ outline: 2px solid var(--memori-primary);
142
+ outline-offset: 2px;
143
+ }
144
+
145
+ .memori-artifact-handler-toggle:focus:not(:focus-visible) {
146
+ outline: none;
147
+ }
148
+
149
+ .memori-artifact-handler--active .memori-artifact-handler-toggle:hover {
150
+ background: rgba(255, 255, 255, 0.3);
151
+ }
152
+
153
+ .memori-artifact-handler-toggle svg {
154
+ width: 16px;
155
+ height: 16px;
156
+ stroke-width: 2;
157
+ }
158
+
159
+ /* Animation */
160
+ @keyframes fadeInUp {
161
+ from {
162
+ opacity: 0;
163
+ transform: translateY(10px);
164
+ }
165
+ to {
166
+ opacity: 1;
167
+ transform: translateY(0);
168
+ }
169
+ }
170
+
171
+ /* Responsive Design */
172
+ @media (max-width: 768px) {
173
+ .memori-artifact-handler {
174
+ margin: 0.5rem 0;
175
+ }
176
+
177
+ .memori-artifact-handler-content {
178
+ padding: 0.75rem;
179
+ gap: 0.5rem;
180
+ }
181
+
182
+ .memori-artifact-handler-icon {
183
+ font-size: 1.25rem;
184
+ }
185
+
186
+ .memori-artifact-handler-title {
187
+ font-size: 0.8125rem;
188
+ }
189
+
190
+ .memori-artifact-handler-subtitle {
191
+ font-size: 0.6875rem;
192
+ }
193
+
194
+ .memori-artifact-handler-meta {
195
+ font-size: 0.5625rem;
196
+ }
197
+
198
+ .memori-artifact-handler-custom-title {
199
+ max-width: 80px;
200
+ }
201
+ }
202
+
203
+ /* Dark Mode Support */
204
+ @media (prefers-color-scheme: dark) {
205
+ .memori-artifact-handler {
206
+ /* background: rgba(26, 26, 26, 0.95); */
207
+ border-color: var(--memori-button-border-color, #404040);
208
+ }
209
+
210
+ .memori-artifact-handler:hover {
211
+ background: rgba(130, 70, 175, 0.1);
212
+ box-shadow: 0 4px 16px rgba(255, 255, 255, 0.1);
213
+ }
214
+
215
+ .memori-artifact-handler-type,
216
+ .memori-artifact-handler-custom-title {
217
+ background: rgba(255, 255, 255, 0.1);
218
+ }
219
+
220
+ .memori-artifact-handler-toggle {
221
+ border-color: rgba(255, 255, 255, 0.1);
222
+ background: rgba(255, 255, 255, 0.05);
223
+ }
224
+
225
+ .memori-artifact-handler-toggle:hover {
226
+ background: rgba(255, 255, 255, 0.1);
227
+ }
228
+ }
229
+
230
+ /* Focus States for Accessibility */
231
+ .memori-artifact-handler:focus {
232
+ outline: 2px solid var(--memori-primary);
233
+ outline-offset: 2px;
234
+ }
235
+
236
+ .memori-artifact-handler:focus:not(:focus-visible) {
237
+ outline: none;
238
+ }
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { ArtifactHandlerProps } from '../../types/artifact.types';
3
+ declare const ArtifactHandler: React.FC<ArtifactHandlerProps>;
4
+ export default ArtifactHandler;
@@ -0,0 +1,101 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useMemo } from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import cx from 'classnames';
5
+ import { useArtifactCreator, useArtifactProcessor, useArtifactDetector } from '../../hooks/useArtifactSystem';
6
+ const ArtifactHandler = ({ artifact, artifacts, customTitle, config, actions, message, onArtifactCreated, }) => {
7
+ var _a, _b;
8
+ const { t } = useTranslation();
9
+ const { createArtifact } = useArtifactCreator();
10
+ const { processArtifactContent } = useArtifactProcessor();
11
+ const { hasArtifacts } = useArtifactDetector();
12
+ const formatBytes = useCallback((bytes) => {
13
+ if (bytes === 0)
14
+ return '0 Bytes';
15
+ const k = 1024;
16
+ const sizes = ['Bytes', 'KB', 'MB'];
17
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
18
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
19
+ }, []);
20
+ const formatTimestamp = useCallback((timestamp) => {
21
+ return timestamp === null || timestamp === void 0 ? void 0 : timestamp.toLocaleTimeString('en-US', {
22
+ hour: '2-digit',
23
+ minute: '2-digit',
24
+ });
25
+ }, []);
26
+ const handleArtifactClick = useCallback(() => {
27
+ const artifactData = artifact;
28
+ if (onArtifactCreated) {
29
+ onArtifactCreated(artifactData);
30
+ }
31
+ }, [artifact, onArtifactCreated]);
32
+ useEffect(() => {
33
+ const handleMemoriNewDialogState = (message) => {
34
+ if (!message || typeof message !== 'string')
35
+ return;
36
+ console.log('🎨 Processing message for artifacts...');
37
+ const processed = processArtifactContent(message, (content, mimeType, title) => {
38
+ var _a, _b, _c, _d, _e;
39
+ const artifact = {
40
+ id: `artifact-${mimeType}-${Date.now()}-${Math.random()
41
+ .toString(36)
42
+ .substr(2, 9)}`,
43
+ content,
44
+ mimeType: mimeType,
45
+ typeInfo: ((_a = config.supportedMimeTypes) === null || _a === void 0 ? void 0 : _a[mimeType]) || {
46
+ name: mimeType.toUpperCase(),
47
+ icon: '📄',
48
+ hasPreview: false,
49
+ language: 'text',
50
+ mimeType: 'text/plain',
51
+ },
52
+ title: title ||
53
+ `${((_c = (_b = config.supportedMimeTypes) === null || _b === void 0 ? void 0 : _b[mimeType]) === null || _c === void 0 ? void 0 : _c.icon) || '📄'} ${((_e = (_d = config.supportedMimeTypes) === null || _d === void 0 ? void 0 : _d[mimeType]) === null || _e === void 0 ? void 0 : _e.name) || mimeType.toUpperCase()} Artifact`,
54
+ customTitle: title,
55
+ messageID: message.timestamp || `msg-${Date.now()}`,
56
+ timestamp: new Date(),
57
+ size: content.length,
58
+ };
59
+ actions.addArtifact(artifact);
60
+ if (config.autoOpenArtifacts) {
61
+ setTimeout(() => {
62
+ actions.selectArtifact(artifact);
63
+ }, 500);
64
+ }
65
+ if (onArtifactCreated) {
66
+ onArtifactCreated(artifact);
67
+ }
68
+ });
69
+ if (processed) {
70
+ console.log('✅ Artifacts processed successfully');
71
+ }
72
+ };
73
+ if (!message.fromUser) {
74
+ handleMemoriNewDialogState(message.translatedText || message.text);
75
+ }
76
+ }, [message]);
77
+ const messageText = message.translatedText || message.text || '';
78
+ const messageHasArtifacts = useMemo(() => hasArtifacts(messageText), [messageText]);
79
+ if (!messageHasArtifacts) {
80
+ return null;
81
+ }
82
+ if (artifacts && artifacts.length > 0) {
83
+ return (_jsx("div", { className: "memori-artifact-handler-container", children: artifacts.map((messageArtifact) => {
84
+ var _a, _b;
85
+ return (_jsx("div", { className: cx('memori-artifact-handler', 'memori-card', {
86
+ 'memori-artifact-handler-active': messageArtifact.isActive,
87
+ }), onClick: () => {
88
+ actions.selectArtifact(messageArtifact);
89
+ if (onArtifactCreated) {
90
+ onArtifactCreated(messageArtifact);
91
+ }
92
+ }, children: _jsxs("div", { className: "memori-artifact-handler-content", children: [_jsx("div", { className: "memori-artifact-handler-icon", children: ((_a = messageArtifact.typeInfo) === null || _a === void 0 ? void 0 : _a.icon) || '📄' }), _jsxs("div", { className: "memori-artifact-handler-info", children: [_jsx("div", { className: "memori-artifact-handler-title", children: messageArtifact.title }), _jsxs("div", { className: "memori-artifact-handler-subtitle", children: [t('artifact.generatedAt', 'Generated at'), ' ', formatTimestamp(messageArtifact.timestamp), " \u2022", ' ', formatBytes(messageArtifact.size)] }), _jsxs("div", { className: "memori-artifact-handler-meta", children: [_jsx("span", { className: "memori-artifact-handler-type", children: ((_b = messageArtifact.typeInfo) === null || _b === void 0 ? void 0 : _b.name) || 'Text' }), messageArtifact.customTitle && (_jsx("span", { className: "memori-artifact-handler-custom-title", children: messageArtifact.customTitle }))] })] }), _jsx("div", { className: "memori-artifact-handler-actions", children: _jsx("button", { className: "memori-artifact-handler-toggle", title: t('artifact.open', 'Open artifact') || 'Open artifact', children: _jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [_jsx("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }), _jsx("path", { d: "M9 9l6 6m0-6l-6 6" })] }) }) })] }) }, messageArtifact.id));
93
+ }) }));
94
+ }
95
+ if (artifact) {
96
+ return (_jsx("div", { className: cx('memori-artifact-handler', 'memori-card'), onClick: handleArtifactClick, children: _jsxs("div", { className: "memori-artifact-handler-content", children: [_jsx("div", { className: "memori-artifact-handler-icon", children: ((_a = artifact.typeInfo) === null || _a === void 0 ? void 0 : _a.icon) || '📄' }), _jsxs("div", { className: "memori-artifact-handler-info", children: [_jsx("div", { className: "memori-artifact-handler-title", children: artifact.title }), _jsxs("div", { className: "memori-artifact-handler-subtitle", children: [t('artifact.generatedAt', 'Generated at'), ' ', formatTimestamp(artifact.timestamp), " \u2022", ' ', formatBytes(artifact.size)] }), _jsxs("div", { className: "memori-artifact-handler-meta", children: [_jsx("span", { className: "memori-artifact-handler-type", children: ((_b = artifact.typeInfo) === null || _b === void 0 ? void 0 : _b.name) || 'Text' }), customTitle && (_jsx("span", { className: "memori-artifact-handler-custom-title", children: customTitle }))] })] }), _jsx("div", { className: "memori-artifact-handler-actions", children: _jsx("button", { className: "memori-artifact-handler-toggle", title: t('artifact.open', 'Open artifact') || 'Open artifact', children: _jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [_jsx("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }), _jsx("path", { d: "M9 9l6 6m0-6l-6 6" })] }) }) })] }) }));
97
+ }
98
+ return null;
99
+ };
100
+ export default ArtifactHandler;
101
+ //# sourceMappingURL=ArtifactHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArtifactHandler.js","sourceRoot":"","sources":["../../../../../src/components/MemoriArtifactSystem/components/ArtifactHandler/ArtifactHandler.tsx"],"names":[],"mappings":";AAMA,OAAc,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAE9G,MAAM,eAAe,GAAmC,CAAC,EACvD,QAAQ,EACR,SAAS,EACT,WAAW,EACX,MAAM,EACN,OAAO,EACP,OAAO,EACP,iBAAiB,GAClB,EAAE,EAAE;;IACH,MAAM,EAAE,CAAC,EAAE,GAAG,cAAc,EAAE,CAAC;IAC/B,MAAM,EAAE,cAAc,EAAE,GAAG,kBAAkB,EAAE,CAAC;IAChD,MAAM,EAAE,sBAAsB,EAAE,GAAG,oBAAoB,EAAE,CAAC;IAC1D,MAAM,EAAE,YAAY,EAAE,GAAG,mBAAmB,EAAE,CAAC;IAK/C,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,KAAa,EAAU,EAAE;QACxD,IAAI,KAAK,KAAK,CAAC;YAAE,OAAO,SAAS,CAAC;QAClC,MAAM,CAAC,GAAG,IAAI,CAAC;QACf,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACpC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACpD,OAAO,UAAU,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EA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