@memori.ai/ui 1.0.0-alpha

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 (274) hide show
  1. package/README.md +105 -0
  2. package/dist/components/Alert/Alert.d.ts +18 -0
  3. package/dist/components/Alert/index.d.ts +2 -0
  4. package/dist/components/Button/Button.d.ts +27 -0
  5. package/dist/components/Button/index.d.ts +2 -0
  6. package/dist/components/ButtonBase/ButtonBase.d.ts +28 -0
  7. package/dist/components/ButtonBase/index.d.ts +3 -0
  8. package/dist/components/Card/Card.d.ts +13 -0
  9. package/dist/components/Card/index.d.ts +2 -0
  10. package/dist/components/Checkbox/Checkbox.d.ts +11 -0
  11. package/dist/components/Checkbox/index.d.ts +2 -0
  12. package/dist/components/ConfirmDialog/ConfirmDialog.d.ts +12 -0
  13. package/dist/components/ConfirmDialog/index.d.ts +2 -0
  14. package/dist/components/Drawer/Drawer.d.ts +32 -0
  15. package/dist/components/Drawer/index.d.ts +2 -0
  16. package/dist/components/Dropdown/Dropdown.d.ts +11 -0
  17. package/dist/components/Dropdown/index.d.ts +2 -0
  18. package/dist/components/Expandable/Expandable.d.ts +15 -0
  19. package/dist/components/Expandable/helpers.d.ts +3 -0
  20. package/dist/components/Expandable/index.d.ts +2 -0
  21. package/dist/components/InputBase/InputBase.d.ts +49 -0
  22. package/dist/components/InputBase/index.d.ts +3 -0
  23. package/dist/components/Modal/Modal.d.ts +16 -0
  24. package/dist/components/Modal/index.d.ts +2 -0
  25. package/dist/components/Select/Select.d.ts +16 -0
  26. package/dist/components/Select/index.d.ts +2 -0
  27. package/dist/components/Slider/Slider.d.ts +12 -0
  28. package/dist/components/Slider/index.d.ts +2 -0
  29. package/dist/components/Spin/Spin.d.ts +9 -0
  30. package/dist/components/Spin/index.d.ts +2 -0
  31. package/dist/components/Tooltip/Tooltip.d.ts +11 -0
  32. package/dist/components/Tooltip/index.d.ts +2 -0
  33. package/dist/i18n/I18nWrapper.d.ts +6 -0
  34. package/dist/icons/AI.d.ts +5 -0
  35. package/dist/icons/Alert.d.ts +5 -0
  36. package/dist/icons/ArrowUp.d.ts +5 -0
  37. package/dist/icons/Bug.d.ts +5 -0
  38. package/dist/icons/Chat.d.ts +5 -0
  39. package/dist/icons/ChevronDown.d.ts +5 -0
  40. package/dist/icons/ChevronLeft.d.ts +5 -0
  41. package/dist/icons/ChevronRight.d.ts +5 -0
  42. package/dist/icons/ChevronUp.d.ts +5 -0
  43. package/dist/icons/Clear.d.ts +5 -0
  44. package/dist/icons/Close.d.ts +6 -0
  45. package/dist/icons/Code.d.ts +5 -0
  46. package/dist/icons/Copy.d.ts +5 -0
  47. package/dist/icons/DeepThought.d.ts +5 -0
  48. package/dist/icons/Delete.d.ts +5 -0
  49. package/dist/icons/Document.d.ts +5 -0
  50. package/dist/icons/Download.d.ts +5 -0
  51. package/dist/icons/Edit.d.ts +5 -0
  52. package/dist/icons/Expand.d.ts +5 -0
  53. package/dist/icons/Eye.d.ts +5 -0
  54. package/dist/icons/EyeInvisible.d.ts +5 -0
  55. package/dist/icons/Facebook.d.ts +5 -0
  56. package/dist/icons/Feedback.d.ts +5 -0
  57. package/dist/icons/File.d.ts +5 -0
  58. package/dist/icons/FileExcel.d.ts +5 -0
  59. package/dist/icons/FilePdf.d.ts +5 -0
  60. package/dist/icons/FileWord.d.ts +5 -0
  61. package/dist/icons/Fullscreen.d.ts +5 -0
  62. package/dist/icons/FullscreenExit.d.ts +5 -0
  63. package/dist/icons/Group.d.ts +5 -0
  64. package/dist/icons/History.d.ts +6 -0
  65. package/dist/icons/Image.d.ts +4 -0
  66. package/dist/icons/Info.d.ts +5 -0
  67. package/dist/icons/Link.d.ts +5 -0
  68. package/dist/icons/Linkedin.d.ts +5 -0
  69. package/dist/icons/Loading.d.ts +6 -0
  70. package/dist/icons/Logout.d.ts +5 -0
  71. package/dist/icons/Mail.d.ts +5 -0
  72. package/dist/icons/MapMarker.d.ts +5 -0
  73. package/dist/icons/MenuHorizontal.d.ts +6 -0
  74. package/dist/icons/MenuVertical.d.ts +6 -0
  75. package/dist/icons/Message.d.ts +5 -0
  76. package/dist/icons/Microphone.d.ts +5 -0
  77. package/dist/icons/Minus.d.ts +5 -0
  78. package/dist/icons/MinusCircle.d.ts +5 -0
  79. package/dist/icons/PaperClip.d.ts +5 -0
  80. package/dist/icons/Picture.d.ts +5 -0
  81. package/dist/icons/Plus.d.ts +5 -0
  82. package/dist/icons/Preview.d.ts +4 -0
  83. package/dist/icons/Print.d.ts +6 -0
  84. package/dist/icons/QuestionHelp.d.ts +5 -0
  85. package/dist/icons/Refresh.d.ts +5 -0
  86. package/dist/icons/SelectIcon.d.ts +5 -0
  87. package/dist/icons/Send.d.ts +5 -0
  88. package/dist/icons/Setting.d.ts +5 -0
  89. package/dist/icons/Share.d.ts +5 -0
  90. package/dist/icons/Sound.d.ts +5 -0
  91. package/dist/icons/SoundDeactivated.d.ts +5 -0
  92. package/dist/icons/Telegram.d.ts +5 -0
  93. package/dist/icons/ThumbDown.d.ts +5 -0
  94. package/dist/icons/ThumbUp.d.ts +5 -0
  95. package/dist/icons/Translation.d.ts +5 -0
  96. package/dist/icons/Twitter.d.ts +5 -0
  97. package/dist/icons/Upload.d.ts +4 -0
  98. package/dist/icons/User.d.ts +5 -0
  99. package/dist/icons/Warning.d.ts +5 -0
  100. package/dist/icons/WhatsApp.d.ts +5 -0
  101. package/dist/index.d.ts +13 -0
  102. package/dist/memori-ai-ui.css +2 -0
  103. package/dist/memori-ai-ui.es.js +6400 -0
  104. package/dist/memori-ai-ui.umd.js +23 -0
  105. package/package.json +97 -0
  106. package/src/components/Alert/Alert.css +95 -0
  107. package/src/components/Alert/Alert.stories.tsx +156 -0
  108. package/src/components/Alert/Alert.test.tsx +122 -0
  109. package/src/components/Alert/Alert.tsx +124 -0
  110. package/src/components/Alert/__snapshots__/Alert.test.tsx.snap +67 -0
  111. package/src/components/Alert/index.tsx +2 -0
  112. package/src/components/Button/Button.css +173 -0
  113. package/src/components/Button/Button.stories.tsx +173 -0
  114. package/src/components/Button/Button.test.tsx +80 -0
  115. package/src/components/Button/Button.tsx +104 -0
  116. package/src/components/Button/__snapshots__/Button.test.tsx.snap +204 -0
  117. package/src/components/Button/index.tsx +2 -0
  118. package/src/components/ButtonBase/ButtonBase.stories.tsx +194 -0
  119. package/src/components/ButtonBase/ButtonBase.tsx +84 -0
  120. package/src/components/ButtonBase/index.tsx +3 -0
  121. package/src/components/ButtonBase/styles.module.css +135 -0
  122. package/src/components/Card/Card.css +67 -0
  123. package/src/components/Card/Card.stories.tsx +104 -0
  124. package/src/components/Card/Card.test.tsx +67 -0
  125. package/src/components/Card/Card.tsx +58 -0
  126. package/src/components/Card/__snapshots__/Card.test.tsx.snap +321 -0
  127. package/src/components/Card/index.tsx +2 -0
  128. package/src/components/Checkbox/Checkbox.css +114 -0
  129. package/src/components/Checkbox/Checkbox.stories.tsx +77 -0
  130. package/src/components/Checkbox/Checkbox.test.tsx +50 -0
  131. package/src/components/Checkbox/Checkbox.tsx +61 -0
  132. package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +131 -0
  133. package/src/components/Checkbox/index.tsx +2 -0
  134. package/src/components/ConfirmDialog/ConfirmDialog.css +44 -0
  135. package/src/components/ConfirmDialog/ConfirmDialog.stories.tsx +235 -0
  136. package/src/components/ConfirmDialog/ConfirmDialog.test.tsx +129 -0
  137. package/src/components/ConfirmDialog/ConfirmDialog.tsx +73 -0
  138. package/src/components/ConfirmDialog/__snapshots__/ConfirmDialog.test.tsx.snap +11 -0
  139. package/src/components/ConfirmDialog/index.tsx +2 -0
  140. package/src/components/Details/Details.css +66 -0
  141. package/src/components/Details/Details.stories.tsx +67 -0
  142. package/src/components/Drawer/Drawer.css +210 -0
  143. package/src/components/Drawer/Drawer.stories.tsx +275 -0
  144. package/src/components/Drawer/Drawer.test.tsx +158 -0
  145. package/src/components/Drawer/Drawer.tsx +242 -0
  146. package/src/components/Drawer/__snapshots__/Drawer.test.tsx.snap +21 -0
  147. package/src/components/Drawer/index.tsx +2 -0
  148. package/src/components/Dropdown/Dropdown.css +177 -0
  149. package/src/components/Dropdown/Dropdown.stories.tsx +73 -0
  150. package/src/components/Dropdown/Dropdown.test.tsx +88 -0
  151. package/src/components/Dropdown/Dropdown.tsx +88 -0
  152. package/src/components/Dropdown/__snapshots__/Dropdown.test.tsx.snap +141 -0
  153. package/src/components/Dropdown/index.tsx +2 -0
  154. package/src/components/Expandable/Expandable.css +15 -0
  155. package/src/components/Expandable/Expandable.stories.tsx +196 -0
  156. package/src/components/Expandable/Expandable.test.tsx +143 -0
  157. package/src/components/Expandable/Expandable.tsx +122 -0
  158. package/src/components/Expandable/__snapshots__/Expandable.test.tsx.snap +199 -0
  159. package/src/components/Expandable/helpers.ts +16 -0
  160. package/src/components/Expandable/index.tsx +2 -0
  161. package/src/components/InputBase/InputBase.stories.tsx +237 -0
  162. package/src/components/InputBase/InputBase.tsx +105 -0
  163. package/src/components/InputBase/index.tsx +3 -0
  164. package/src/components/InputBase/styles.module.css +96 -0
  165. package/src/components/Modal/Modal.css +95 -0
  166. package/src/components/Modal/Modal.stories.tsx +184 -0
  167. package/src/components/Modal/Modal.test.tsx +129 -0
  168. package/src/components/Modal/Modal.tsx +124 -0
  169. package/src/components/Modal/__snapshots__/Modal.test.tsx.snap +17 -0
  170. package/src/components/Modal/index.tsx +2 -0
  171. package/src/components/Select/Select.css +134 -0
  172. package/src/components/Select/Select.stories.tsx +85 -0
  173. package/src/components/Select/Select.test.tsx +85 -0
  174. package/src/components/Select/Select.tsx +84 -0
  175. package/src/components/Select/__snapshots__/Select.test.tsx.snap +261 -0
  176. package/src/components/Select/index.tsx +2 -0
  177. package/src/components/Slider/Slider.css +194 -0
  178. package/src/components/Slider/Slider.stories.tsx +85 -0
  179. package/src/components/Slider/Slider.test.tsx +55 -0
  180. package/src/components/Slider/Slider.tsx +157 -0
  181. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +419 -0
  182. package/src/components/Slider/index.tsx +2 -0
  183. package/src/components/Spin/Spin.css +31 -0
  184. package/src/components/Spin/Spin.stories.tsx +65 -0
  185. package/src/components/Spin/Spin.test.tsx +47 -0
  186. package/src/components/Spin/Spin.tsx +34 -0
  187. package/src/components/Spin/__snapshots__/Spin.test.tsx.snap +193 -0
  188. package/src/components/Spin/index.tsx +2 -0
  189. package/src/components/Table/Table.css +130 -0
  190. package/src/components/Table/Table.stories.tsx +274 -0
  191. package/src/components/Tooltip/Tooltip.css +160 -0
  192. package/src/components/Tooltip/Tooltip.stories.tsx +136 -0
  193. package/src/components/Tooltip/Tooltip.test.tsx +110 -0
  194. package/src/components/Tooltip/Tooltip.tsx +46 -0
  195. package/src/components/Tooltip/__snapshots__/Tooltip.test.tsx.snap +163 -0
  196. package/src/components/Tooltip/index.tsx +2 -0
  197. package/src/components/definitions.stories.tsx +150 -0
  198. package/src/i18n/I18nWrapper.tsx +13 -0
  199. package/src/i18n/i18n.ts +34 -0
  200. package/src/icons/AI.tsx +38 -0
  201. package/src/icons/Alert.tsx +31 -0
  202. package/src/icons/ArrowUp.tsx +28 -0
  203. package/src/icons/Bug.tsx +81 -0
  204. package/src/icons/Chat.tsx +30 -0
  205. package/src/icons/ChevronDown.tsx +26 -0
  206. package/src/icons/ChevronLeft.tsx +28 -0
  207. package/src/icons/ChevronRight.tsx +28 -0
  208. package/src/icons/ChevronUp.tsx +24 -0
  209. package/src/icons/Clear.tsx +23 -0
  210. package/src/icons/Close.tsx +30 -0
  211. package/src/icons/Code.tsx +30 -0
  212. package/src/icons/Copy.tsx +30 -0
  213. package/src/icons/DeepThought.tsx +38 -0
  214. package/src/icons/Delete.tsx +23 -0
  215. package/src/icons/Document.tsx +52 -0
  216. package/src/icons/Download.tsx +23 -0
  217. package/src/icons/Edit.tsx +17 -0
  218. package/src/icons/Expand.tsx +23 -0
  219. package/src/icons/Eye.tsx +17 -0
  220. package/src/icons/EyeInvisible.tsx +24 -0
  221. package/src/icons/Facebook.tsx +23 -0
  222. package/src/icons/Feedback.tsx +27 -0
  223. package/src/icons/File.tsx +17 -0
  224. package/src/icons/FileExcel.tsx +23 -0
  225. package/src/icons/FilePdf.tsx +23 -0
  226. package/src/icons/FileWord.tsx +23 -0
  227. package/src/icons/Fullscreen.tsx +23 -0
  228. package/src/icons/FullscreenExit.tsx +23 -0
  229. package/src/icons/Group.tsx +30 -0
  230. package/src/icons/History.tsx +33 -0
  231. package/src/icons/Image.tsx +37 -0
  232. package/src/icons/Info.tsx +37 -0
  233. package/src/icons/Link.tsx +17 -0
  234. package/src/icons/Linkedin.tsx +23 -0
  235. package/src/icons/Loading.tsx +28 -0
  236. package/src/icons/Logout.tsx +33 -0
  237. package/src/icons/Mail.tsx +17 -0
  238. package/src/icons/MapMarker.tsx +26 -0
  239. package/src/icons/MenuHorizontal.tsx +29 -0
  240. package/src/icons/MenuVertical.tsx +29 -0
  241. package/src/icons/Message.tsx +23 -0
  242. package/src/icons/Microphone.tsx +23 -0
  243. package/src/icons/Minus.tsx +23 -0
  244. package/src/icons/MinusCircle.tsx +24 -0
  245. package/src/icons/PaperClip.tsx +23 -0
  246. package/src/icons/Picture.tsx +23 -0
  247. package/src/icons/Plus.tsx +18 -0
  248. package/src/icons/Preview.tsx +31 -0
  249. package/src/icons/Print.tsx +37 -0
  250. package/src/icons/QuestionHelp.tsx +34 -0
  251. package/src/icons/Refresh.tsx +30 -0
  252. package/src/icons/SelectIcon.tsx +28 -0
  253. package/src/icons/Send.tsx +17 -0
  254. package/src/icons/Setting.tsx +23 -0
  255. package/src/icons/Share.tsx +23 -0
  256. package/src/icons/Sound.tsx +23 -0
  257. package/src/icons/SoundDeactivated.tsx +27 -0
  258. package/src/icons/Telegram.tsx +26 -0
  259. package/src/icons/ThumbDown.tsx +29 -0
  260. package/src/icons/ThumbUp.tsx +29 -0
  261. package/src/icons/Translation.tsx +24 -0
  262. package/src/icons/Twitter.tsx +23 -0
  263. package/src/icons/Upload.tsx +34 -0
  264. package/src/icons/User.tsx +17 -0
  265. package/src/icons/Warning.tsx +27 -0
  266. package/src/icons/WhatsApp.tsx +24 -0
  267. package/src/icons/icons.stories.css +5 -0
  268. package/src/icons/icons.stories.tsx +110 -0
  269. package/src/icons/loading.css +14 -0
  270. package/src/index.ts +15 -0
  271. package/src/styles/utils.css +17 -0
  272. package/src/styles.css +4 -0
  273. package/src/theme/variables.css +110 -0
  274. package/src/vite-env.d.ts +6 -0
@@ -0,0 +1,141 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`renders Dropdown open unchanged 1`] = `
4
+ <div>
5
+ <div
6
+ class="memori-dropdown"
7
+ >
8
+ <div
9
+ class="memori-dropdown--trigger"
10
+ tabindex="0"
11
+ >
12
+ <button
13
+ class="memori-button memori-button--rounded memori-button--padded"
14
+ >
15
+ Open
16
+ </button>
17
+ </div>
18
+ <div
19
+ class="memori-dropdown--content memori-dropdown--content--bottom-right"
20
+ >
21
+ <div>
22
+ Content
23
+ </div>
24
+ </div>
25
+ </div>
26
+ </div>
27
+ `;
28
+
29
+ exports[`renders Dropdown unchanged 1`] = `
30
+ <div>
31
+ <div
32
+ class="memori-dropdown"
33
+ >
34
+ <div
35
+ class="memori-dropdown--trigger"
36
+ tabindex="0"
37
+ >
38
+ <button
39
+ class="memori-button memori-button--rounded memori-button--padded"
40
+ >
41
+ Open
42
+ </button>
43
+ </div>
44
+ </div>
45
+ </div>
46
+ `;
47
+
48
+ exports[`renders Dropdown with className unchanged 1`] = `
49
+ <div>
50
+ <div
51
+ class="memori-dropdown custom-dropdown"
52
+ >
53
+ <div
54
+ class="memori-dropdown--trigger"
55
+ tabindex="0"
56
+ >
57
+ <button
58
+ class="memori-button memori-button--rounded memori-button--padded"
59
+ >
60
+ Open
61
+ </button>
62
+ </div>
63
+ </div>
64
+ </div>
65
+ `;
66
+
67
+ exports[`renders Dropdown with placement bottom-left unchanged 1`] = `
68
+ <div>
69
+ <div
70
+ class="memori-dropdown"
71
+ >
72
+ <div
73
+ class="memori-dropdown--trigger"
74
+ tabindex="0"
75
+ >
76
+ <button
77
+ class="memori-button memori-button--rounded memori-button--padded"
78
+ >
79
+ Open
80
+ </button>
81
+ </div>
82
+ </div>
83
+ </div>
84
+ `;
85
+
86
+ exports[`renders Dropdown with placement bottom-right unchanged 1`] = `
87
+ <div>
88
+ <div
89
+ class="memori-dropdown"
90
+ >
91
+ <div
92
+ class="memori-dropdown--trigger"
93
+ tabindex="0"
94
+ >
95
+ <button
96
+ class="memori-button memori-button--rounded memori-button--padded"
97
+ >
98
+ Open
99
+ </button>
100
+ </div>
101
+ </div>
102
+ </div>
103
+ `;
104
+
105
+ exports[`renders Dropdown with placement top-left unchanged 1`] = `
106
+ <div>
107
+ <div
108
+ class="memori-dropdown"
109
+ >
110
+ <div
111
+ class="memori-dropdown--trigger"
112
+ tabindex="0"
113
+ >
114
+ <button
115
+ class="memori-button memori-button--rounded memori-button--padded"
116
+ >
117
+ Open
118
+ </button>
119
+ </div>
120
+ </div>
121
+ </div>
122
+ `;
123
+
124
+ exports[`renders Dropdown with placement top-right unchanged 1`] = `
125
+ <div>
126
+ <div
127
+ class="memori-dropdown"
128
+ >
129
+ <div
130
+ class="memori-dropdown--trigger"
131
+ tabindex="0"
132
+ >
133
+ <button
134
+ class="memori-button memori-button--rounded memori-button--padded"
135
+ >
136
+ Open
137
+ </button>
138
+ </div>
139
+ </div>
140
+ </div>
141
+ `;
@@ -0,0 +1,2 @@
1
+ import Dropdown from './Dropdown'
2
+ export { Dropdown }
@@ -0,0 +1,15 @@
1
+ .memori-expandable {
2
+ line-height: 1;
3
+ }
4
+
5
+ .memori-expandable--inner {
6
+ overflow: hidden;
7
+ max-height: 9999px;
8
+ transition: max-height 0.2s ease-in-out;
9
+ }
10
+
11
+ .memori-expandable > button {
12
+ color: var(--memori-primary, #333);
13
+ font-size: 0.9em;
14
+ text-decoration: underline;
15
+ }
@@ -0,0 +1,196 @@
1
+ import React from 'react'
2
+ import type { Meta, StoryObj } from '@storybook/react'
3
+ import Expandable, { type Props } from './Expandable'
4
+
5
+ const Template = (args: Props) => (
6
+ <Expandable {...args}>
7
+ Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales nulla,
8
+ sed semper nisi. Suspendisse a sodales nulla, sed semper nisi. Suspendisse a
9
+ sodales nulla, sed semper nisi. Suspendisse a sodales nulla, sed semper
10
+ nisi. Lorem Ipsum is simply dummy text of the printing and typesetting
11
+ industry. Lorem Ipsum has been the industry&apos;s standard dummy text ever
12
+ since the 1500s, when an unknown printer took a galley of type and scrambled
13
+ it to make a type specimen book. It has survived not only five centuries,
14
+ but also the leap into electronic typesetting, remaining essentially
15
+ unchanged. It was popularised in the 1960s with the release of Letraset
16
+ sheets containing Lorem Ipsum passages, and more recently with desktop
17
+ publishing software like Aldus PageMaker including versions of Lorem Ipsum.
18
+ Lorem Ipsum is simply dummy text of the printing and typesetting industry.
19
+ Lorem Ipsum has been the industry&apos;s standard dummy text ever since the
20
+ 1500s, when an unknown printer took a galley of type and scrambled it to
21
+ make a type specimen book. It has survived not only five centuries, but also
22
+ the leap into electronic typesetting, remaining essentially unchanged. It
23
+ was popularised in the 1960s with the release of Letraset sheets containing
24
+ Lorem Ipsum passages, and more recently with desktop publishing software
25
+ like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is
26
+ simply dummy text of the printing and typesetting industry. Lorem Ipsum has
27
+ been the industry&apos;s standard dummy text ever since the 1500s, when an
28
+ unknown printer took a galley of type and scrambled it to make a type
29
+ specimen book. It has survived not only five centuries, but also the leap
30
+ into electronic typesetting, remaining essentially unchanged. It was
31
+ popularised in the 1960s with the release of Letraset sheets containing
32
+ Lorem Ipsum passages, and more recently with desktop publishing software
33
+ like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is
34
+ simply dummy text of the printing and typesetting industry. Lorem Ipsum has
35
+ been the industry&apos;s standard dummy text ever since the 1500s, when an
36
+ unknown printer took a galley of type and scrambled it to make a type
37
+ specimen book. It has survived not only five centuries, but also the leap
38
+ into electronic typesetting, remaining essentially unchanged. It was
39
+ popularised in the 1960s with the release of Letraset sheets containing
40
+ Lorem Ipsum passages, and more recently with desktop publishing software
41
+ like Aldus PageMaker including versions of Lorem Ipsum.
42
+ </Expandable>
43
+ )
44
+
45
+ const TemplateWithHTML = (args: Props) => (
46
+ <Expandable {...args}>
47
+ <p>
48
+ Ah, ottima domanda! Stavo giusto riflettendo su come spiegare al meglio le
49
+ funzionalità di questo sistema.{' '}
50
+ </p>
51
+ <p>Da qui puoi fare diverse cose interessanti:</p>
52
+ <ol>
53
+ <li>
54
+ <p>
55
+ Puoi conversare con me, Nunzio Fiore, e io risponderò basandomi sulle
56
+ mie conoscenze ed esperienze.
57
+ </p>
58
+ </li>
59
+ <li>
60
+ <p>
61
+ Puoi aggiungere nuove memorie o informazioni al mio database. Questo
62
+ significa che puoi insegnarmi cose nuove o aggiornare le mie
63
+ conoscenze esistenti.
64
+ </p>
65
+ </li>
66
+ <li>
67
+ <p>
68
+ Puoi creare, modificare o eliminare ricevitori. Questi sono come
69
+ utenti specifici che possono interagire con me in modo personalizzato.
70
+ </p>
71
+ </li>
72
+ <li>
73
+ <p>
74
+ Puoi associare determinate memorie a ricevitori specifici, creando
75
+ così contenuti personalizzati per diverse persone.
76
+ </p>
77
+ </li>
78
+ <li>
79
+ <p>
80
+ Puoi cercare tra le memorie esistenti, visualizzare le ultime
81
+ aggiunte, o modificare quelle già presenti.
82
+ </p>
83
+ </li>
84
+ </ol>
85
+ <p>
86
+ In pratica, stai interagendo con un sistema che permette di creare e
87
+ gestire un &quot;gemello digitale&quot; - in questo caso, me stesso. È un
88
+ po&apos; come scrivere un libro interattivo sulla mia vita e le mie
89
+ conoscenze.
90
+ </p>
91
+ <p>
92
+ C&apos;è qualcosa in particolare che ti interessa esplorare o su cui
93
+ vorresti saperne di più?
94
+ </p>
95
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
96
+ <div className="memori--responsive-table-wrapper">
97
+ <table className="memori--table memori--table--compact">
98
+ <thead>
99
+ <tr>
100
+ <th>Header 1</th>
101
+ <th>Header 2</th>
102
+ <th>Header 3</th>
103
+ </tr>
104
+ </thead>
105
+ <tbody>
106
+ <tr>
107
+ <td>Cell 1</td>
108
+ <td>Cell 2</td>
109
+ <td>Cell 3</td>
110
+ </tr>
111
+ <tr>
112
+ <td>Cell 4</td>
113
+ <td>Cell 5</td>
114
+ <td>Cell 6</td>
115
+ </tr>
116
+ </tbody>
117
+ </table>
118
+ </div>
119
+ <p>Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
120
+ </Expandable>
121
+ )
122
+
123
+ const meta = {
124
+ title: 'UI/Expandable',
125
+ component: Expandable,
126
+ tags: ['autodocs'],
127
+ argTypes: {
128
+ className: {
129
+ control: {
130
+ type: 'text',
131
+ },
132
+ },
133
+ },
134
+ args: {
135
+ children: 'Test',
136
+ },
137
+ parameters: {
138
+ controls: { expanded: true },
139
+ },
140
+ render: args => <Template {...args}>{args.children}</Template>,
141
+ } satisfies Meta<typeof Expandable>
142
+
143
+ export default meta
144
+
145
+ type Story = StoryObj<typeof meta>
146
+
147
+ export const Default: Story = {
148
+ args: {
149
+ rows: 2,
150
+ mode: 'rows',
151
+ },
152
+ }
153
+
154
+ export const DefaultExpanded: Story = {
155
+ args: {
156
+ rows: 3,
157
+ mode: 'rows',
158
+ children: 'Test',
159
+ defaultExpanded: true,
160
+ },
161
+ }
162
+
163
+ export const WithCustomProps: Story = {
164
+ args: {
165
+ rows: 3,
166
+ innerClassName: 'custom-inner-class',
167
+ btnClassName: 'custom-btn-class',
168
+ expandSymbol: () => '🔽',
169
+ collapseSymbol: () => '🔼',
170
+ },
171
+ }
172
+
173
+ export const WithHTML: Story = {
174
+ args: {
175
+ rows: 3,
176
+ mode: 'rows',
177
+ },
178
+ render: args => (
179
+ <TemplateWithHTML {...args}>{args.children}</TemplateWithHTML>
180
+ ),
181
+ }
182
+
183
+ export const ModeChar: Story = {
184
+ args: {
185
+ mode: 'characters',
186
+ },
187
+ }
188
+
189
+ export const ModeCharWithHTML: Story = {
190
+ args: {
191
+ mode: 'characters',
192
+ },
193
+ render: args => (
194
+ <TemplateWithHTML {...args}>{args.children}</TemplateWithHTML>
195
+ ),
196
+ }
@@ -0,0 +1,143 @@
1
+ import { render } from '@testing-library/react'
2
+ import { expect, it } from 'vitest'
3
+ import Expandable from './Expandable'
4
+
5
+ // Check if we're in CI mode (jsdom environment) vs browser mode
6
+ // In browser mode, we want to run all tests; in CI (jsdom), skip snapshot tests
7
+ const isCI = typeof process !== 'undefined' && process.env.CI === 'true'
8
+
9
+ it('renders Expandable unchanged', () => {
10
+ const { container } = render(<Expandable rows={1}>Test</Expandable>)
11
+ expect(container).toMatchSnapshot()
12
+ })
13
+
14
+ it.skipIf(isCI)('renders Expandable with long text unchanged', () => {
15
+ const { container } = render(
16
+ <Expandable rows={1}>
17
+ Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales nulla,
18
+ sed semper nisi. Suspendisse a sodales nulla, sed semper nisi. Suspendisse
19
+ a sodales nulla, sed semper nisi. Suspendisse a sodales nulla, sed semper
20
+ nisi.
21
+ </Expandable>,
22
+ )
23
+ expect(container).toMatchSnapshot()
24
+ })
25
+
26
+ it.skipIf(isCI)('renders Expandable with multiple rows unchanged', () => {
27
+ const { container } = render(
28
+ <Expandable rows={3}>
29
+ Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales nulla,
30
+ sed semper nisi. Suspendisse a sodales nulla, sed semper nisi. Suspendisse
31
+ a sodales nulla, sed semper nisi. Suspendisse a sodales nulla, sed semper
32
+ nisi.
33
+ </Expandable>,
34
+ )
35
+ expect(container).toMatchSnapshot()
36
+ })
37
+
38
+ it.skipIf(isCI)(
39
+ 'renders Expandable with custom wrapper CSS class unchanged',
40
+ () => {
41
+ const { container } = render(
42
+ <Expandable
43
+ rows={1}
44
+ className="test"
45
+ >
46
+ Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales
47
+ nulla, sed semper nisi. Suspendisse a sodales nulla, sed semper nisi.
48
+ Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales
49
+ nulla, sed semper nisi.
50
+ </Expandable>,
51
+ )
52
+ expect(container).toMatchSnapshot()
53
+ },
54
+ )
55
+
56
+ it.skipIf(isCI)(
57
+ 'renders Expandable with custom inner CSS class unchanged',
58
+ () => {
59
+ const { container } = render(
60
+ <Expandable
61
+ rows={1}
62
+ innerClassName="test"
63
+ >
64
+ Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales
65
+ nulla, sed semper nisi. Suspendisse a sodales nulla, sed semper nisi.
66
+ Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales
67
+ nulla, sed semper nisi.
68
+ </Expandable>,
69
+ )
70
+ expect(container).toMatchSnapshot()
71
+ },
72
+ )
73
+
74
+ it.skipIf(isCI)(
75
+ 'renders Expandable with custom button CSS class unchanged',
76
+ () => {
77
+ const { container } = render(
78
+ <Expandable
79
+ rows={1}
80
+ btnClassName="test"
81
+ >
82
+ Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales
83
+ nulla, sed semper nisi. Suspendisse a sodales nulla, sed semper nisi.
84
+ Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales
85
+ nulla, sed semper nisi.
86
+ </Expandable>,
87
+ )
88
+ expect(container).toMatchSnapshot()
89
+ },
90
+ )
91
+
92
+ it.skipIf(isCI)(
93
+ 'renders Expandable with custom expand symbol unchanged',
94
+ () => {
95
+ const { container } = render(
96
+ <Expandable
97
+ rows={1}
98
+ expandSymbol={() => 'test'}
99
+ >
100
+ Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales
101
+ nulla, sed semper nisi. Suspendisse a sodales nulla, sed semper nisi.
102
+ Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales
103
+ nulla, sed semper nisi.
104
+ </Expandable>,
105
+ )
106
+ expect(container).toMatchSnapshot()
107
+ },
108
+ )
109
+
110
+ it.skipIf(isCI)(
111
+ 'renders Expandable with custom collapse symbol unchanged',
112
+ () => {
113
+ const { container } = render(
114
+ <Expandable
115
+ rows={1}
116
+ collapseSymbol={() => 'test collapse'}
117
+ defaultExpanded
118
+ >
119
+ Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales
120
+ nulla, sed semper nisi. Suspendisse a sodales nulla, sed semper nisi.
121
+ Suspendisse a sodales nulla, sed semper nisi. Suspendisse a sodales
122
+ nulla, sed semper nisi.
123
+ </Expandable>,
124
+ )
125
+ expect(container).toMatchSnapshot()
126
+ },
127
+ )
128
+
129
+ it.skipIf(isCI)('renders Expandable with JSX markup unchanged', () => {
130
+ const { container } = render(
131
+ <Expandable rows={1}>
132
+ <h1>Lorem ipsum</h1>
133
+ <p>Suspendisse a sodales nulla, sed semper nisi.</p>
134
+ <h2>Suspendisse a sodales nulla, sed semper nisi.</h2>
135
+ <p>Suspendisse a sodales nulla, sed semper nisi.</p>
136
+ <p>Suspendisse a sodales nulla, sed semper nisi.</p>
137
+ <button>Dolor sit amet</button>
138
+ <p>Suspendisse a sodales nulla, sed semper nisi.</p>
139
+ <p>Suspendisse a sodales nulla, sed semper nisi.</p>
140
+ </Expandable>,
141
+ )
142
+ expect(container).toMatchSnapshot()
143
+ })
@@ -0,0 +1,122 @@
1
+ import React, { useEffect, useRef, useState } from 'react'
2
+ import Button from '../Button/Button'
3
+ import cx from 'classnames'
4
+ import { useTranslation } from 'react-i18next'
5
+ import { truncateMessage, MAX_MSG_CHARS, MAX_MSG_WORDS } from './helpers'
6
+
7
+ import './Expandable.css'
8
+
9
+ export interface Props {
10
+ rows?: number
11
+ className?: string
12
+ innerClassName?: string
13
+ btnClassName?: string
14
+ lineHeightMultiplier?: number
15
+ defaultExpanded?: boolean
16
+ expandSymbol?: (lang: string) => React.ReactNode
17
+ collapseSymbol?: (lang: string) => React.ReactNode
18
+ children: React.ReactNode
19
+ mode?: 'rows' | 'characters'
20
+ }
21
+
22
+ const Expandable = ({
23
+ rows,
24
+ className,
25
+ innerClassName,
26
+ btnClassName,
27
+ lineHeightMultiplier = 1.2,
28
+ defaultExpanded = false,
29
+ expandSymbol = () => '...',
30
+ collapseSymbol = (lang: string) =>
31
+ lang === 'it' ? 'Mostra meno' : 'Show less',
32
+ children,
33
+ mode = 'rows',
34
+ }: Props) => {
35
+ const { i18n } = useTranslation()
36
+ const lang = i18n.language
37
+ const collapseSymbolText = collapseSymbol(lang)
38
+ const expandSymbolText = expandSymbol(lang)
39
+ const [expanded, setExpanded] = useState(defaultExpanded)
40
+ const [needsExpanding, setNeedsExpanding] = useState(false)
41
+ const [rowHeight, setRowHeight] = useState(16)
42
+ const ref = useRef<HTMLDivElement>(null)
43
+
44
+ useEffect(() => {
45
+ if (ref.current) {
46
+ if (mode === 'rows') {
47
+ let height = ref.current.getBoundingClientRect().height
48
+ let computedStyle = getComputedStyle(ref.current)
49
+ let elLineHeight = computedStyle.lineHeight
50
+ let lineHeight =
51
+ elLineHeight === 'normal' || !elLineHeight?.length
52
+ ? lineHeightMultiplier * parseInt(computedStyle.fontSize, 10)
53
+ : parseInt(elLineHeight, 10)
54
+
55
+ setRowHeight(lineHeight)
56
+ if (height && rows && height > rows * lineHeight) {
57
+ setNeedsExpanding(true)
58
+ }
59
+ } else if (mode === 'characters') {
60
+ // Get text content length
61
+ const textContent = ref.current.textContent || ''
62
+
63
+ if (
64
+ textContent.length > MAX_MSG_CHARS ||
65
+ textContent.split(' ').length > MAX_MSG_WORDS
66
+ ) {
67
+ setNeedsExpanding(true)
68
+ }
69
+ }
70
+ }
71
+ }, [rows, mode, ref.current])
72
+
73
+ const renderContent = () => {
74
+ if (mode === 'characters' && !expanded && needsExpanding) {
75
+ const content = ref.current?.textContent || ''
76
+ let truncatedContent = truncateMessage(content)
77
+
78
+ return truncatedContent
79
+ }
80
+
81
+ return children
82
+ }
83
+
84
+ return (
85
+ <div className={cx('memori-expandable', className)}>
86
+ <div
87
+ ref={ref}
88
+ className={cx('memori-expandable--inner', innerClassName)}
89
+ style={{
90
+ maxHeight:
91
+ expanded || !needsExpanding || mode === 'characters'
92
+ ? '9999px'
93
+ : `${rowHeight * (rows || 1)}px`,
94
+ }}
95
+ >
96
+ {renderContent()}
97
+ </div>
98
+ {needsExpanding && !expanded && (
99
+ <Button
100
+ ghost
101
+ padded={false}
102
+ className={btnClassName}
103
+ onClick={() => setExpanded(true)}
104
+ >
105
+ {expandSymbolText}
106
+ </Button>
107
+ )}
108
+ {needsExpanding && expanded && (
109
+ <Button
110
+ ghost
111
+ padded={false}
112
+ className={btnClassName}
113
+ onClick={() => setExpanded(false)}
114
+ >
115
+ {collapseSymbolText}
116
+ </Button>
117
+ )}
118
+ </div>
119
+ )
120
+ }
121
+
122
+ export default Expandable