@memori.ai/memori-react 7.26.0 → 7.26.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/ChatBubble/ChatBubble.js +17 -9
- package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
- package/dist/components/ChatBubble/VirtualizedContent/VirtualizedContent.d.ts +7 -0
- package/dist/components/ChatBubble/VirtualizedContent/VirtualizedContent.js +69 -0
- package/dist/components/ChatBubble/VirtualizedContent/VirtualizedContent.js.map +1 -0
- package/dist/components/MediaWidget/LinkItemWidget.css +1 -0
- package/dist/components/MediaWidget/MediaItemWidget.css +10 -0
- package/dist/components/MediaWidget/MediaItemWidget.d.ts +6 -2
- package/dist/components/MediaWidget/MediaItemWidget.js +49 -11
- package/dist/components/MediaWidget/MediaItemWidget.js.map +1 -1
- package/dist/components/MediaWidget/MediaWidget.d.ts +3 -1
- package/dist/components/UploadButton/UploadButton.js +16 -5
- package/dist/components/UploadButton/UploadButton.js.map +1 -1
- package/dist/components/UploadButton/UploadImages/UploadImages.js +7 -16
- package/dist/components/UploadButton/UploadImages/UploadImages.js.map +1 -1
- package/dist/components/ui/Card.d.ts +1 -0
- package/dist/components/ui/Card.js +2 -2
- package/dist/components/ui/Card.js.map +1 -1
- package/esm/components/ChatBubble/ChatBubble.js +17 -9
- package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
- package/esm/components/ChatBubble/VirtualizedContent/VirtualizedContent.d.ts +7 -0
- package/esm/components/ChatBubble/VirtualizedContent/VirtualizedContent.js +67 -0
- package/esm/components/ChatBubble/VirtualizedContent/VirtualizedContent.js.map +1 -0
- package/esm/components/MediaWidget/LinkItemWidget.css +1 -0
- package/esm/components/MediaWidget/MediaItemWidget.css +10 -0
- package/esm/components/MediaWidget/MediaItemWidget.d.ts +6 -2
- package/esm/components/MediaWidget/MediaItemWidget.js +50 -12
- package/esm/components/MediaWidget/MediaItemWidget.js.map +1 -1
- package/esm/components/MediaWidget/MediaWidget.d.ts +3 -1
- package/esm/components/UploadButton/UploadButton.js +16 -5
- package/esm/components/UploadButton/UploadButton.js.map +1 -1
- package/esm/components/UploadButton/UploadImages/UploadImages.js +7 -16
- package/esm/components/UploadButton/UploadImages/UploadImages.js.map +1 -1
- package/esm/components/ui/Card.d.ts +1 -0
- package/esm/components/ui/Card.js +2 -2
- package/esm/components/ui/Card.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Chat/Chat.stories.tsx +12 -0
- package/src/components/ChatBubble/ChatBubble.stories.tsx +203 -26
- package/src/components/ChatBubble/ChatBubble.tsx +14 -11
- package/src/components/MediaWidget/LinkItemWidget.css +1 -0
- package/src/components/MediaWidget/MediaItemWidget.css +10 -0
- package/src/components/MediaWidget/MediaItemWidget.tsx +136 -118
- package/src/components/MediaWidget/MediaWidget.test.tsx +2 -1
- package/src/components/MediaWidget/MediaWidget.tsx +1 -1
- package/src/components/UploadButton/UploadButton.tsx +55 -34
- package/src/components/UploadButton/UploadImages/UploadImages.tsx +7 -24
- package/src/components/UploadButton/__snapshots__/UploadButton.test.tsx.snap +0 -1
- package/src/components/ui/Card.tsx +3 -0
|
@@ -91,7 +91,6 @@ FromUserWithLink.args = {
|
|
|
91
91
|
},
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
-
|
|
95
94
|
export const Initial = Template.bind({});
|
|
96
95
|
Initial.args = {
|
|
97
96
|
memori,
|
|
@@ -155,31 +154,6 @@ WithLongLink.args = {
|
|
|
155
154
|
},
|
|
156
155
|
};
|
|
157
156
|
|
|
158
|
-
export const WithFunctionCache = Template.bind({});
|
|
159
|
-
WithFunctionCache.args = {
|
|
160
|
-
memori,
|
|
161
|
-
tenant,
|
|
162
|
-
message: {
|
|
163
|
-
fromUser: false,
|
|
164
|
-
text: 'Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.',
|
|
165
|
-
initial: false,
|
|
166
|
-
translatedText:
|
|
167
|
-
'Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.',
|
|
168
|
-
generatedByAI: true,
|
|
169
|
-
media: [
|
|
170
|
-
{
|
|
171
|
-
functionCache: "true",
|
|
172
|
-
title: "Test",
|
|
173
|
-
content: "Test",
|
|
174
|
-
properties: {
|
|
175
|
-
functionCache: "true",
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
],
|
|
179
|
-
},
|
|
180
|
-
showFunctionCache: true,
|
|
181
|
-
};
|
|
182
|
-
|
|
183
157
|
export const WithFeedbackButtons = Template.bind({});
|
|
184
158
|
WithFeedbackButtons.args = {
|
|
185
159
|
memori,
|
|
@@ -642,3 +616,206 @@ WithHTML.args = {
|
|
|
642
616
|
`,
|
|
643
617
|
},
|
|
644
618
|
};
|
|
619
|
+
|
|
620
|
+
// 9. Complex HTML Table
|
|
621
|
+
export const ComplexHTMLTable = Template.bind({});
|
|
622
|
+
ComplexHTMLTable.args = {
|
|
623
|
+
memori,
|
|
624
|
+
tenant,
|
|
625
|
+
message: {
|
|
626
|
+
fromUser: false,
|
|
627
|
+
text: `<table border="1" style="border-collapse: collapse; width: 100%;">
|
|
628
|
+
<thead>
|
|
629
|
+
<tr style="background-color: #f2f2f2;">
|
|
630
|
+
<th colspan="3" style="text-align: center; padding: 8px;">Project Timeline</th>
|
|
631
|
+
</tr>
|
|
632
|
+
<tr style="background-color: #f2f2f2;">
|
|
633
|
+
<th style="text-align: left; padding: 8px;">Phase</th>
|
|
634
|
+
<th style="text-align: left; padding: 8px;">Start Date</th>
|
|
635
|
+
<th style="text-align: left; padding: 8px;">End Date</th>
|
|
636
|
+
</tr>
|
|
637
|
+
</thead>
|
|
638
|
+
<tbody>
|
|
639
|
+
<tr>
|
|
640
|
+
<td style="padding: 8px;">Planning</td>
|
|
641
|
+
<td style="padding: 8px;">Jan 15, 2025</td>
|
|
642
|
+
<td style="padding: 8px;">Feb 28, 2025</td>
|
|
643
|
+
</tr>
|
|
644
|
+
<tr style="background-color: #f9f9f9;">
|
|
645
|
+
<td style="padding: 8px;">Development</td>
|
|
646
|
+
<td style="padding: 8px;">Mar 1, 2025</td>
|
|
647
|
+
<td style="padding: 8px;">Jun 30, 2025</td>
|
|
648
|
+
</tr>
|
|
649
|
+
<tr>
|
|
650
|
+
<td style="padding: 8px;">Testing</td>
|
|
651
|
+
<td style="padding: 8px;">Jul 1, 2025</td>
|
|
652
|
+
<td style="padding: 8px;">Aug 15, 2025</td>
|
|
653
|
+
</tr>
|
|
654
|
+
<tr style="background-color: #f9f9f9;">
|
|
655
|
+
<td style="padding: 8px;">Deployment</td>
|
|
656
|
+
<td style="padding: 8px;">Aug 16, 2025</td>
|
|
657
|
+
<td style="padding: 8px;">Sep 30, 2025</td>
|
|
658
|
+
</tr>
|
|
659
|
+
</tbody>
|
|
660
|
+
<tfoot>
|
|
661
|
+
<tr style="background-color: #f2f2f2;">
|
|
662
|
+
<td colspan="3" style="text-align: center; padding: 8px;">Total Duration: 8.5 months</td>
|
|
663
|
+
</tr>
|
|
664
|
+
</tfoot>
|
|
665
|
+
</table>`,
|
|
666
|
+
initial: false,
|
|
667
|
+
},
|
|
668
|
+
};
|
|
669
|
+
ComplexHTMLTable.parameters = {
|
|
670
|
+
docs: {
|
|
671
|
+
description: {
|
|
672
|
+
story:
|
|
673
|
+
'A message containing a complex HTML table that should trigger the loading spinner before rendering.',
|
|
674
|
+
},
|
|
675
|
+
},
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
//10. Long text message
|
|
679
|
+
export const MediumLongTextMessage = Template.bind({});
|
|
680
|
+
MediumLongTextMessage.args = {
|
|
681
|
+
memori,
|
|
682
|
+
tenant,
|
|
683
|
+
message: {
|
|
684
|
+
fromUser: false,
|
|
685
|
+
text: Array(100)
|
|
686
|
+
.fill(
|
|
687
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor.'
|
|
688
|
+
)
|
|
689
|
+
.join('\n\n'),
|
|
690
|
+
initial: false,
|
|
691
|
+
},
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
export const LongTextMessage = Template.bind({});
|
|
695
|
+
LongTextMessage.args = {
|
|
696
|
+
memori,
|
|
697
|
+
tenant,
|
|
698
|
+
message: {
|
|
699
|
+
fromUser: false,
|
|
700
|
+
text: Array(200)
|
|
701
|
+
.fill(
|
|
702
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi.'
|
|
703
|
+
)
|
|
704
|
+
.join('\n\n'),
|
|
705
|
+
initial: false,
|
|
706
|
+
},
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
export const LongTextMessageWithHTML = Template.bind({});
|
|
710
|
+
LongTextMessageWithHTML.args = {
|
|
711
|
+
memori,
|
|
712
|
+
tenant,
|
|
713
|
+
message: {
|
|
714
|
+
fromUser: false,
|
|
715
|
+
text:
|
|
716
|
+
Array(200)
|
|
717
|
+
.fill(
|
|
718
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi. Proin porttitor, orci nec nonummy molestie, enim est eleifend mi, non fermentum diam nisl sit amet erat.'
|
|
719
|
+
)
|
|
720
|
+
.join('\n\n') +
|
|
721
|
+
`
|
|
722
|
+
<div>
|
|
723
|
+
<div style="width: 30%; margin-bottom: 20px;">
|
|
724
|
+
<img src="https://www.e-stayon.com/images/thumbs/0244280_lenovo-ideapad-3-chromebook-15-intel-celeron-4gb-64gb_360.jpeg" style="width:100%">
|
|
725
|
+
<h3>Lenovo IdeaPad 3 Chromebook</h3>
|
|
726
|
+
<p>Intel Celeron, 15", 4GB RAM, 64GB</p>
|
|
727
|
+
<p>Prezzo: €194,88 (sconto 12% da €221,59)</p>
|
|
728
|
+
</div>`,
|
|
729
|
+
},
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
// 10. Message with an embedded helper function to show requiresFormatting detection
|
|
733
|
+
export const FormattingDetectionDemo = Template.bind({});
|
|
734
|
+
FormattingDetectionDemo.args = {
|
|
735
|
+
memori,
|
|
736
|
+
tenant,
|
|
737
|
+
message: {
|
|
738
|
+
fromUser: false,
|
|
739
|
+
text: 'This message demonstrates how the formatting detection works.\n\nBelow are some examples of content that will be detected as requiring formatting:\n\n1. HTML tags: <div>Example</div>\n2. Markdown tables: | Header | Content |\n3. Code blocks: ```javascript\nconst x = 1;\n```\n4. Math formulas: $E = mc^2$\n5. Tabbed data: Name\tAge\tLocation\n\nThe requiresFormatting function will detect these patterns and show a loading spinner.',
|
|
740
|
+
initial: false,
|
|
741
|
+
},
|
|
742
|
+
};
|
|
743
|
+
FormattingDetectionDemo.parameters = {
|
|
744
|
+
docs: {
|
|
745
|
+
description: {
|
|
746
|
+
story:
|
|
747
|
+
'A demonstration of different content patterns that trigger the loading spinner.',
|
|
748
|
+
},
|
|
749
|
+
},
|
|
750
|
+
};
|
|
751
|
+
|
|
752
|
+
export const HTMLTable = Template.bind({});
|
|
753
|
+
HTMLTable.args = {
|
|
754
|
+
memori,
|
|
755
|
+
tenant,
|
|
756
|
+
message: {
|
|
757
|
+
fromUser: false,
|
|
758
|
+
text: `Ecco la lista formattata in HTML dei task e dei relativi assegnatari:
|
|
759
|
+
<table>
|
|
760
|
+
<tr>
|
|
761
|
+
<th>Task</th>
|
|
762
|
+
<th>Assegnato a</th>
|
|
763
|
+
</tr>
|
|
764
|
+
<tr><td>Market Research</td><td>Alice</td></tr>
|
|
765
|
+
<tr><td>Content Creation</td><td>Bob</td></tr>
|
|
766
|
+
<tr><td>Social Media Planning</td><td>Charlie</td></tr>
|
|
767
|
+
<tr><td>Campaign Analysis</td><td>Daisy</td></tr>
|
|
768
|
+
<tr><td>Prototype Development</td><td>Ethan</td></tr>
|
|
769
|
+
<tr><td>Quality Assurance</td><td>Fiona</td></tr>
|
|
770
|
+
<tr><td>User Interface Design</td><td>Gabriel</td></tr>
|
|
771
|
+
<tr><td>Service Improvement</td><td>Hannah</td></tr>
|
|
772
|
+
<tr><td>Ticket Resolution</td><td>Ian</td></tr>
|
|
773
|
+
<tr><td>Customer Feedback</td><td>Julia</td></tr>
|
|
774
|
+
<tr><td>Budget Analysis</td><td>Kevin</td></tr>
|
|
775
|
+
<tr><td>Financial Reporting</td><td>Mark</td></tr>
|
|
776
|
+
<tr><td>Investment Planning</td><td>Mark</td></tr>
|
|
777
|
+
<tr><td>Market Trends Analysis</td><td>Nathan</td></tr>
|
|
778
|
+
<tr><td>Data Collection</td><td>Olivia</td></tr>
|
|
779
|
+
<tr><td>Research Paper Writing</td><td>Peter</td></tr>
|
|
780
|
+
<tr><td>Software Development</td><td>Quinn</td></tr>
|
|
781
|
+
<tr><td>Feature Enhancement</td><td>Rachel</td></tr>
|
|
782
|
+
<tr><td>Code Review</td><td>Sam</td></tr>
|
|
783
|
+
<tr><td>Manufacturing</td><td>Tim</td></tr>
|
|
784
|
+
<tr><td>Product Design</td><td>Uma</td></tr>
|
|
785
|
+
<tr><td>UX Research</td><td>Victor</td></tr>
|
|
786
|
+
<tr><td>API Development</td><td>Wendy</td></tr>
|
|
787
|
+
<tr><td>Database Management</td><td>Xavier</td></tr>
|
|
788
|
+
<tr><td>Cloud Infrastructure</td><td>Yara</td></tr>
|
|
789
|
+
<tr><td>Security Testing</td><td>Zack</td></tr>
|
|
790
|
+
<tr><td>Documentation</td><td>Adam</td></tr>
|
|
791
|
+
<tr><td>Technical Support</td><td>Beth</td></tr>
|
|
792
|
+
<tr><td>Project Management</td><td>Carl</td></tr>
|
|
793
|
+
<tr><td>Business Analysis</td><td>Diana</td></tr>
|
|
794
|
+
<tr><td>DevOps Engineering</td><td>Erik</td></tr>
|
|
795
|
+
<tr><td>Mobile Development</td><td>Faith</td></tr>
|
|
796
|
+
<tr><td>Frontend Development</td><td>George</td></tr>
|
|
797
|
+
<tr><td>Backend Development</td><td>Helen</td></tr>
|
|
798
|
+
<tr><td>System Architecture</td><td>Isaac</td></tr>
|
|
799
|
+
<tr><td>Data Analysis</td><td>Jane</td></tr>
|
|
800
|
+
<tr><td>Machine Learning</td><td>Kyle</td></tr>
|
|
801
|
+
<tr><td>AI Development</td><td>Lisa</td></tr>
|
|
802
|
+
<tr><td>Network Security</td><td>Mike</td></tr>
|
|
803
|
+
<tr><td>Performance Testing</td><td>Nina</td></tr>
|
|
804
|
+
<tr><td>Load Testing</td><td>Oscar</td></tr>
|
|
805
|
+
<tr><td>Penetration Testing</td><td>Penny</td></tr>
|
|
806
|
+
<tr><td>Automation Testing</td><td>Quentin</td></tr>
|
|
807
|
+
<tr><td>Release Management</td><td>Rose</td></tr>
|
|
808
|
+
<tr><td>Configuration Management</td><td>Steve</td></tr>
|
|
809
|
+
<tr><td>Change Management</td><td>Tina</td></tr>
|
|
810
|
+
<tr><td>Risk Management</td><td>Ulysses</td></tr>
|
|
811
|
+
<tr><td>Resource Planning</td><td>Violet</td></tr>
|
|
812
|
+
<tr><td>Capacity Planning</td><td>Walter</td></tr>
|
|
813
|
+
<tr><td>Strategic Planning</td><td>Xena</td></tr>
|
|
814
|
+
<tr><td>Operations Management</td><td>Yuki</td></tr>
|
|
815
|
+
<tr><td>Quality Management</td><td>Zara</td></tr>
|
|
816
|
+
</table>
|
|
817
|
+
|
|
818
|
+
Ho mostrato i primi 20 task per brevità. La tabella include il nome del task e la persona assegnata.`,
|
|
819
|
+
initial: false,
|
|
820
|
+
},
|
|
821
|
+
};
|
|
@@ -102,11 +102,8 @@ const ChatBubble: React.FC<Props> = ({
|
|
|
102
102
|
const functionCacheData = message.media?.find(
|
|
103
103
|
m => m.properties?.functionCache === 'true'
|
|
104
104
|
);
|
|
105
|
-
|
|
106
|
-
// Render MathJax whenever message content changes
|
|
107
105
|
useLayoutEffect(() => {
|
|
108
106
|
if (typeof window !== 'undefined' && !message.fromUser) {
|
|
109
|
-
// Allow a short delay for the DOM to update
|
|
110
107
|
const timer = setTimeout(() => {
|
|
111
108
|
if (window.MathJax && window.MathJax.typesetPromise) {
|
|
112
109
|
try {
|
|
@@ -114,9 +111,21 @@ const ChatBubble: React.FC<Props> = ({
|
|
|
114
111
|
'.memori-chat--bubble-content'
|
|
115
112
|
);
|
|
116
113
|
if (elements.length > 0) {
|
|
114
|
+
// Salva la posizione di scroll corrente
|
|
115
|
+
const scrollContainer = document.querySelector('.memori-chat--history');
|
|
116
|
+
const currentScrollTop = scrollContainer?.scrollTop || 0;
|
|
117
|
+
const currentScrollHeight = scrollContainer?.scrollHeight || 0;
|
|
118
|
+
|
|
117
119
|
window.MathJax.typesetPromise([
|
|
118
120
|
'.memori-chat--bubble-content',
|
|
119
|
-
]).
|
|
121
|
+
]).then(() => {
|
|
122
|
+
// Ripristina la posizione di scroll dopo il rendering MathJax
|
|
123
|
+
if (scrollContainer) {
|
|
124
|
+
const newScrollHeight = scrollContainer.scrollHeight;
|
|
125
|
+
const heightDifference = newScrollHeight - currentScrollHeight;
|
|
126
|
+
scrollContainer.scrollTop = currentScrollTop + heightDifference;
|
|
127
|
+
}
|
|
128
|
+
}).catch(err =>
|
|
120
129
|
console.error('MathJax typesetting failed:', err)
|
|
121
130
|
);
|
|
122
131
|
}
|
|
@@ -125,16 +134,10 @@ const ChatBubble: React.FC<Props> = ({
|
|
|
125
134
|
}
|
|
126
135
|
}
|
|
127
136
|
}, 100);
|
|
128
|
-
|
|
137
|
+
|
|
129
138
|
return () => clearTimeout(timer);
|
|
130
139
|
}
|
|
131
140
|
}, [message.text, message.fromUser, renderedText]);
|
|
132
|
-
|
|
133
|
-
console.log(
|
|
134
|
-
'message',
|
|
135
|
-
message.media?.find(m => m.properties?.functionCache)
|
|
136
|
-
);
|
|
137
|
-
|
|
138
141
|
return (
|
|
139
142
|
<>
|
|
140
143
|
{(message.initial || isFirst) && (
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
.memori-media-items--grid {
|
|
2
2
|
display: grid;
|
|
3
3
|
padding: 1rem;
|
|
4
|
+
direction: rtl;
|
|
4
5
|
grid-auto-flow: dense;
|
|
5
6
|
grid-gap: 1rem;
|
|
6
7
|
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
|
|
@@ -143,3 +144,12 @@ a.memori-media-item--link {
|
|
|
143
144
|
border-color: #fff;
|
|
144
145
|
color: #fff;
|
|
145
146
|
}
|
|
147
|
+
|
|
148
|
+
.memori-media-item-preview--modal {
|
|
149
|
+
z-index: 10000;
|
|
150
|
+
width: 100%;
|
|
151
|
+
max-width: 80%;
|
|
152
|
+
height: 100%;
|
|
153
|
+
max-height: 80%;
|
|
154
|
+
background: #fff;
|
|
155
|
+
}
|