blixify-ui-web-mcp 0.1.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.
Files changed (245) hide show
  1. package/README.md +5 -0
  2. package/lib/components/action/button/README.md +75 -0
  3. package/lib/components/action/button/button.stories.tsx +138 -0
  4. package/lib/components/action/buttonGroup/README.md +79 -0
  5. package/lib/components/action/buttonGroup/buttonGroup.stories.tsx +104 -0
  6. package/lib/components/action/iconButton/README.md +39 -0
  7. package/lib/components/action/iconButton/iconButton.stories.tsx +22 -0
  8. package/lib/components/action/radioList/README.md +98 -0
  9. package/lib/components/action/radioList/radioList.stories.tsx +181 -0
  10. package/lib/components/action/slider/README.md +86 -0
  11. package/lib/components/action/slider/slider.stories.tsx +133 -0
  12. package/lib/components/action/textButton/README.md +34 -0
  13. package/lib/components/action/textButton/textButton.stories.tsx +16 -0
  14. package/lib/components/action/toggle/README.md +39 -0
  15. package/lib/components/action/toggle/toggle.stories.tsx +23 -0
  16. package/lib/components/advanced/collapse/README.md +106 -0
  17. package/lib/components/advanced/collapse/collapse.stories.tsx +165 -0
  18. package/lib/components/advanced/infoWindow/README.md +69 -0
  19. package/lib/components/advanced/infoWindow/infoWindow.stories.tsx +112 -0
  20. package/lib/components/advanced/popUp/README.md +95 -0
  21. package/lib/components/advanced/popUp/popUp.stories.tsx +189 -0
  22. package/lib/components/auth/bareSignIn/README.md +78 -0
  23. package/lib/components/auth/bareSignIn/bareSignIn.stories.tsx +141 -0
  24. package/lib/components/auth/bareSignUp/README.md +130 -0
  25. package/lib/components/auth/bareSignUp/bareSignUp.stories.tsx +159 -0
  26. package/lib/components/auth/signIn/README.md +53 -0
  27. package/lib/components/auth/signIn/signIn.stories.tsx +120 -0
  28. package/lib/components/auth/signUp/README.md +136 -0
  29. package/lib/components/auth/signUp/signUp.stories.tsx +193 -0
  30. package/lib/components/chart/README.md +13 -0
  31. package/lib/components/chart/areaChart/README.md +133 -0
  32. package/lib/components/chart/areaChart/areaChart.stories.tsx +199 -0
  33. package/lib/components/chart/barChart/README.md +193 -0
  34. package/lib/components/chart/barChart/barChart.stories.tsx +318 -0
  35. package/lib/components/chart/boxPlotChart/README.md +124 -0
  36. package/lib/components/chart/boxPlotChart/boxPlotChart.stories.tsx +104 -0
  37. package/lib/components/chart/bubbleChart/README.md +166 -0
  38. package/lib/components/chart/bubbleChart/bubbleChart.stories.tsx +144 -0
  39. package/lib/components/chart/card/README.md +107 -0
  40. package/lib/components/chart/card/card.stories.tsx +89 -0
  41. package/lib/components/chart/ganttChart/README.md +142 -0
  42. package/lib/components/chart/ganttChart/ganttChart.stories.tsx +138 -0
  43. package/lib/components/chart/heatmapChart/README.md +125 -0
  44. package/lib/components/chart/heatmapChart/heatmapChart.stories.tsx +106 -0
  45. package/lib/components/chart/lineChart/README.md +140 -0
  46. package/lib/components/chart/lineChart/lineChart.stories.tsx +152 -0
  47. package/lib/components/chart/pieChart/README.md +117 -0
  48. package/lib/components/chart/pieChart/pieChart.stories.tsx +180 -0
  49. package/lib/components/chart/polarAreaChart/README.md +126 -0
  50. package/lib/components/chart/polarAreaChart/polarAreaChart.stories.tsx +106 -0
  51. package/lib/components/chart/radarChart/README.md +57 -0
  52. package/lib/components/chart/radarChart/radarChart.stories.tsx +36 -0
  53. package/lib/components/chart/radialBar/README.md +152 -0
  54. package/lib/components/chart/radialBar/radialChart.stories.tsx +136 -0
  55. package/lib/components/chart/rangeBarChart/README.md +323 -0
  56. package/lib/components/chart/rangeBarChart/rangeBarChart.stories.tsx +208 -0
  57. package/lib/components/chart/statsCard/README.md +97 -0
  58. package/lib/components/chart/statsCard/statsCard.stories.tsx +183 -0
  59. package/lib/components/chart/treemapChart/README.md +142 -0
  60. package/lib/components/chart/treemapChart/treemapChart.stories.tsx +122 -0
  61. package/lib/components/chat/chatAnchor/README.md +113 -0
  62. package/lib/components/chat/chatAnchor/chatAnchor.stories.tsx +156 -0
  63. package/lib/components/chat/chatBase/README.md +223 -0
  64. package/lib/components/chat/chatBase/chatBase.stories.tsx +306 -0
  65. package/lib/components/chat/chatDashboard/README.md +161 -0
  66. package/lib/components/chat/chatDashboard/chatDashboard.stories.tsx +154 -0
  67. package/lib/components/data/dataGraph/README.md +13 -0
  68. package/lib/components/data/dataGraph/dataGraph.stories.tsx +84 -0
  69. package/lib/components/data/dataReference/README.md +62 -0
  70. package/lib/components/data/dataReference/dataReference.stories.tsx +53 -0
  71. package/lib/components/data/dataTemplate/README.md +903 -0
  72. package/lib/components/data/dataTemplate/dataModule.stories.tsx +196 -0
  73. package/lib/components/data/dataTemplate/dataTemplate.stories.tsx +337 -0
  74. package/lib/components/data/dataWrapper/README.md +1077 -0
  75. package/lib/components/data/dataWrapper/dataWrapper.stories.tsx +831 -0
  76. package/lib/components/data/queryForm/README.md +56 -0
  77. package/lib/components/data/queryForm/queryForm.stories.tsx +85 -0
  78. package/lib/components/data/readQuery/README.md +282 -0
  79. package/lib/components/data/readQuery/readQuery.stories.tsx +256 -0
  80. package/lib/components/data/readQueryHoc/README.md +89 -0
  81. package/lib/components/data/readQueryHoc/readQueryHoc.stories.tsx +33 -0
  82. package/lib/components/data/writeQuery/README.md +178 -0
  83. package/lib/components/data/writeQuery/writeQuery.stories.tsx +209 -0
  84. package/lib/components/design/actionSection/README.md +47 -0
  85. package/lib/components/design/actionSection/actionSection.stories.tsx +74 -0
  86. package/lib/components/design/banner/README.md +43 -0
  87. package/lib/components/design/banner/banner.stories.tsx +34 -0
  88. package/lib/components/design/bannerAction/README.md +44 -0
  89. package/lib/components/design/bannerAction/bannerAction.stories.tsx +25 -0
  90. package/lib/components/design/blogSection/README.md +111 -0
  91. package/lib/components/design/blogSection/blogSection.stories.tsx +72 -0
  92. package/lib/components/design/carouselSection/README.md +82 -0
  93. package/lib/components/design/carouselSection/carouselSection.stories.tsx +52 -0
  94. package/lib/components/design/designList/README.md +60 -0
  95. package/lib/components/design/designList/designList.stories.tsx +44 -0
  96. package/lib/components/design/faq/README.md +121 -0
  97. package/lib/components/design/faq/faq.stories.tsx +103 -0
  98. package/lib/components/design/fileGrid/README.md +87 -0
  99. package/lib/components/design/fileGrid/fileGrid.stories.tsx +110 -0
  100. package/lib/components/design/fileViewer/README.md +40 -0
  101. package/lib/components/design/fileViewer/fileViewer.stories.tsx +28 -0
  102. package/lib/components/design/footerSection/README.md +62 -0
  103. package/lib/components/design/footerSection/footerSection.stories.tsx +84 -0
  104. package/lib/components/design/googleReview/README.md +45 -0
  105. package/lib/components/design/googleReview/googleReview.stories.tsx +33 -0
  106. package/lib/components/design/heroSection/README.md +48 -0
  107. package/lib/components/design/heroSection/heroSection.stories.tsx +85 -0
  108. package/lib/components/design/iconList/README.md +60 -0
  109. package/lib/components/design/iconList/iconList.stories.tsx +41 -0
  110. package/lib/components/design/imageGallery/README.md +56 -0
  111. package/lib/components/design/imageGallery/imageGallery.stories.tsx +45 -0
  112. package/lib/components/design/imageZoom/README.md +47 -0
  113. package/lib/components/design/imageZoom/imageZoom.stories.tsx +30 -0
  114. package/lib/components/design/leftContent/README.md +47 -0
  115. package/lib/components/design/leftContent/leftContent.stories.tsx +32 -0
  116. package/lib/components/design/logoCloud/README.md +42 -0
  117. package/lib/components/design/logoCloud/logoCloud.stories.tsx +44 -0
  118. package/lib/components/design/onboarding/README.md +100 -0
  119. package/lib/components/design/onboarding/onboarding.stories.tsx +113 -0
  120. package/lib/components/design/pricing/README.md +112 -0
  121. package/lib/components/design/pricing/pricing.stories.tsx +86 -0
  122. package/lib/components/design/rightContent/README.md +47 -0
  123. package/lib/components/design/rightContent/rightContent.stories.tsx +32 -0
  124. package/lib/components/design/sectionList/README.md +51 -0
  125. package/lib/components/design/sectionList/sectionList.stories.tsx +35 -0
  126. package/lib/components/design/teams/README.md +62 -0
  127. package/lib/components/design/teams/teams.stories.tsx +61 -0
  128. package/lib/components/display/alert/README.md +82 -0
  129. package/lib/components/display/alert/alert.stories.tsx +71 -0
  130. package/lib/components/display/calendar/README.md +113 -0
  131. package/lib/components/display/calendar/calendar.stories.tsx +159 -0
  132. package/lib/components/display/clipboard/README.md +36 -0
  133. package/lib/components/display/clipboard/clipboard.stories.tsx +32 -0
  134. package/lib/components/display/detailList/README.md +61 -0
  135. package/lib/components/display/detailList/detailList.stories.tsx +131 -0
  136. package/lib/components/display/drawer/README.md +74 -0
  137. package/lib/components/display/drawer/drawer.stories.tsx +66 -0
  138. package/lib/components/display/emptyState/README.md +38 -0
  139. package/lib/components/display/emptyState/emptyState.stories.tsx +22 -0
  140. package/lib/components/display/feeds/README.md +80 -0
  141. package/lib/components/display/feeds/feeds.stories.tsx +75 -0
  142. package/lib/components/display/flexTable/README.md +160 -0
  143. package/lib/components/display/flexTable/flexTable.stories.tsx +313 -0
  144. package/lib/components/display/grid/README.md +121 -0
  145. package/lib/components/display/grid/grid.stories.tsx +234 -0
  146. package/lib/components/display/kanban/README.md +78 -0
  147. package/lib/components/display/kanban/kanban.stories.tsx +133 -0
  148. package/lib/components/display/list/README.md +109 -0
  149. package/lib/components/display/list/list.stories.tsx +188 -0
  150. package/lib/components/display/loading/README.md +25 -0
  151. package/lib/components/display/loading/loading.stories.tsx +15 -0
  152. package/lib/components/display/mapView/README.md +99 -0
  153. package/lib/components/display/mapView/mapView.stories.tsx +225 -0
  154. package/lib/components/display/modal/README.md +43 -0
  155. package/lib/components/display/modal/modal.stories.tsx +81 -0
  156. package/lib/components/display/notification/README.md +43 -0
  157. package/lib/components/display/notification/notification.stories.tsx +30 -0
  158. package/lib/components/display/progress/README.md +25 -0
  159. package/lib/components/display/progress/progress.stories.tsx +15 -0
  160. package/lib/components/display/stepper/README.md +96 -0
  161. package/lib/components/display/stepper/stepper.stories.tsx +175 -0
  162. package/lib/components/display/table/README.md +176 -0
  163. package/lib/components/display/table/table.stories.tsx +330 -0
  164. package/lib/components/display/tag/README.md +74 -0
  165. package/lib/components/display/tag/tag.stories.tsx +79 -0
  166. package/lib/components/input/address/README.md +132 -0
  167. package/lib/components/input/address/address.stories.tsx +147 -0
  168. package/lib/components/input/canvas/README.md +131 -0
  169. package/lib/components/input/canvas/canvas.stories.tsx +165 -0
  170. package/lib/components/input/checkbox/README.md +61 -0
  171. package/lib/components/input/checkbox/checkbox.stories.tsx +30 -0
  172. package/lib/components/input/datePicker/README.md +124 -0
  173. package/lib/components/input/datePicker/datePicker.stories.tsx +197 -0
  174. package/lib/components/input/form/README.md +55 -0
  175. package/lib/components/input/form/form.stories.tsx +143 -0
  176. package/lib/components/input/markdown/README.md +146 -0
  177. package/lib/components/input/markdown/markdown.stories.tsx +40 -0
  178. package/lib/components/input/monthYearPicker/README.md +69 -0
  179. package/lib/components/input/monthYearPicker/monthYearPicker.stories.tsx +47 -0
  180. package/lib/components/input/netPromoterScore/README.md +52 -0
  181. package/lib/components/input/netPromoterScore/netPromoterScore.stories.tsx +30 -0
  182. package/lib/components/input/rating/README.md +51 -0
  183. package/lib/components/input/rating/rating.stories.tsx +30 -0
  184. package/lib/components/input/select/README.md +108 -0
  185. package/lib/components/input/select/select.stories.tsx +286 -0
  186. package/lib/components/input/signature/README.md +106 -0
  187. package/lib/components/input/signature/signature.stories.tsx +188 -0
  188. package/lib/components/input/textArea/README.md +55 -0
  189. package/lib/components/input/textArea/textArea.stories.tsx +30 -0
  190. package/lib/components/input/textInput/README.md +81 -0
  191. package/lib/components/input/textInput/textinput.stories.tsx +231 -0
  192. package/lib/components/input/uploadInput/README.md +134 -0
  193. package/lib/components/input/uploadInput/uploadInput.stories.tsx +193 -0
  194. package/lib/components/navigation/bars/README.md +40 -0
  195. package/lib/components/navigation/bars/bars.stories.tsx +85 -0
  196. package/lib/components/navigation/bottomTab/README.md +53 -0
  197. package/lib/components/navigation/bottomTab/bottomTab.stories.tsx +32 -0
  198. package/lib/components/navigation/breadcrumb/README.md +48 -0
  199. package/lib/components/navigation/breadcrumb/breadcrumb.stories.tsx +27 -0
  200. package/lib/components/navigation/header/README.md +149 -0
  201. package/lib/components/navigation/header/header.stories.tsx +107 -0
  202. package/lib/components/navigation/leftNav/README.md +91 -0
  203. package/lib/components/navigation/leftNav/leftNav.stories.tsx +106 -0
  204. package/lib/components/navigation/tabs/README.md +75 -0
  205. package/lib/components/navigation/tabs/tabs.stories.tsx +60 -0
  206. package/lib/components/structure/column/README.md +40 -0
  207. package/lib/components/structure/column/column.stories.tsx +26 -0
  208. package/lib/components/structure/container/README.md +34 -0
  209. package/lib/components/structure/container/container.stories.tsx +19 -0
  210. package/lib/components/structure/link/README.md +55 -0
  211. package/lib/components/structure/link/link.stories.tsx +30 -0
  212. package/lib/components/structure/text/README.md +42 -0
  213. package/lib/components/structure/text/text.stories.tsx +39 -0
  214. package/lib/components/template/authPage/authPage.stories.tsx +68 -0
  215. package/lib/components/template/landingPage/landingPage.stories.tsx +288 -0
  216. package/lib/components/template/productListing/productListing.stories.tsx +297 -0
  217. package/lib/components/template/productOverview/productOverview.stories.tsx +194 -0
  218. package/lib/components/template/shoppingCart/shoppingCart.stories.tsx +252 -0
  219. package/lib/components/template/userHomePage/userHomePage.stories.tsx +605 -0
  220. package/lib/components/template/userRankingDashboard/userRankingDashboard.stories.tsx +481 -0
  221. package/lib/mcp/server.d.ts +2 -0
  222. package/lib/mcp/server.d.ts.map +1 -0
  223. package/lib/mcp/server.js +33 -0
  224. package/lib/mcp/server.js.map +1 -0
  225. package/lib/mcp/tools/getBackendComponent.d.ts +13 -0
  226. package/lib/mcp/tools/getBackendComponent.d.ts.map +1 -0
  227. package/lib/mcp/tools/getBackendComponent.js +119 -0
  228. package/lib/mcp/tools/getBackendComponent.js.map +1 -0
  229. package/lib/mcp/tools/getComponent.d.ts +17 -0
  230. package/lib/mcp/tools/getComponent.d.ts.map +1 -0
  231. package/lib/mcp/tools/getComponent.js +118 -0
  232. package/lib/mcp/tools/getComponent.js.map +1 -0
  233. package/lib/mcp/tools/listComponents.d.ts +13 -0
  234. package/lib/mcp/tools/listComponents.d.ts.map +1 -0
  235. package/lib/mcp/tools/listComponents.js +113 -0
  236. package/lib/mcp/tools/listComponents.js.map +1 -0
  237. package/lib/mcp/tools/listTemplates.d.ts +13 -0
  238. package/lib/mcp/tools/listTemplates.d.ts.map +1 -0
  239. package/lib/mcp/tools/listTemplates.js +68 -0
  240. package/lib/mcp/tools/listTemplates.js.map +1 -0
  241. package/lib/mcp/tools/suggestTemplate.d.ts +17 -0
  242. package/lib/mcp/tools/suggestTemplate.d.ts.map +1 -0
  243. package/lib/mcp/tools/suggestTemplate.js +212 -0
  244. package/lib/mcp/tools/suggestTemplate.js.map +1 -0
  245. package/package.json +23 -0
@@ -0,0 +1,306 @@
1
+ import { TrashIcon } from "@heroicons/react/24/outline";
2
+ import { storiesOf } from "@storybook/react";
3
+ import moment from "moment";
4
+ import React, { useEffect, useState } from "react";
5
+ import { v4 as uuidv4 } from "uuid";
6
+ import { ChatBase, ChatBaseAction, Conversation } from ".";
7
+ import Logo from "../../../assets/logo.png";
8
+ import { TextButton } from "../../action/textButton";
9
+ import { Loading } from "../../display/loading";
10
+ import README from "./README.md";
11
+
12
+ const stories = storiesOf("Chat", module);
13
+
14
+ stories.addParameters({
15
+ readme: {
16
+ content: README,
17
+ },
18
+ });
19
+
20
+ stories.add("Chat Base", () => {
21
+ const botUser = {
22
+ id: "1",
23
+ name: "Bot",
24
+ imageUrl:
25
+ "https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80",
26
+ };
27
+ const currentUser = { id: "2", name: "Guest" };
28
+
29
+ const [message, setMessage] = useState("");
30
+ const [messageLimit] = useState(20);
31
+ const [search, setSearch] = useState("");
32
+ const [filteredConversation, setFilteredConversation] =
33
+ useState<Conversation | null>();
34
+ const [file, setFile] = useState<File | any>(undefined);
35
+ const [loading, setLoading] = useState(false);
36
+
37
+ const [conversation, setConversation] = useState<Conversation>({
38
+ id: "1",
39
+ members: [currentUser, botUser],
40
+ messageList: [
41
+ {
42
+ sender: botUser,
43
+ messageBody: "Hi! How can I help you? 🤖",
44
+ createdAt: moment(
45
+ "Fri Nov 03 2023 12:21:14 GMT+0800 (Malaysia Time)"
46
+ ).toDate(),
47
+ },
48
+ {
49
+ sender: currentUser,
50
+ messageBody: "Yo, my computer's acting up.",
51
+ createdAt: moment(
52
+ "Fri Nov 03 2023 13:21:14 GMT+0800 (Malaysia Time)"
53
+ ).toDate(),
54
+ },
55
+ {
56
+ sender: currentUser,
57
+ messageBody:
58
+ "It keeps saying 'Error 404: Coffee not found' when I start it up.",
59
+ createdAt: moment(
60
+ "Fri Nov 03 2023 14:21:14 GMT+0800 (Malaysia Time)"
61
+ ).toDate(),
62
+ },
63
+ {
64
+ sender: botUser,
65
+ messageBody:
66
+ "Sounds like a caffeine emergency!\nHave you tried offering it coffee?",
67
+ createdAt: moment(
68
+ "Fri Nov 03 2023 15:21:14 GMT+0800 (Malaysia Time)"
69
+ ).toDate(),
70
+ },
71
+ {
72
+ sender: currentUser,
73
+ messageBody: "Seriously?",
74
+ createdAt: moment(
75
+ "Fri Nov 03 2023 16:21:14 GMT+0800 (Malaysia Time)"
76
+ ).toDate(),
77
+ },
78
+ {
79
+ sender: botUser,
80
+ messageBody:
81
+ "Well, computers do like a jolt of energy, but don't spill, that could be 'mocha-nical' trouble!",
82
+ createdAt: moment(
83
+ "Fri Nov 03 2023 17:21:14 GMT+0800 (Malaysia Time)"
84
+ ).toDate(),
85
+ },
86
+ {
87
+ sender: currentUser,
88
+ messageBody: "Cringe. I'll give it a shot.Thanks.",
89
+ createdAt: moment(
90
+ "Fri Nov 03 2023 18:21:14 GMT+0800 (Malaysia Time)"
91
+ ).toDate(),
92
+ },
93
+ {
94
+ sender: botUser,
95
+ messageBody:
96
+ "**Quick Tips for Productivity**\n1. Set timers.\n2. Prioritize tasks.\n3. Take breaks.\n\n**Healthy Habits**\n 1. Stay hydrated.\n2. Eat well.\n3. Exercise daily.",
97
+ createdAt: moment(
98
+ "Fri Nov 03 2023 19:21:14 GMT+0800 (Malaysia Time)"
99
+ ).toDate(),
100
+ },
101
+ {
102
+ sender: botUser,
103
+ messageBody: "Hey check out my dog!",
104
+ createdAt: moment(
105
+ "Fri Nov 03 2023 19:21:10 GMT+0800 (Malaysia Time)"
106
+ ).toDate(),
107
+ },
108
+ {
109
+ sender: botUser,
110
+ messageBody: {
111
+ fileName:
112
+ "https://player.vimeo.com/external/364708250.sd.mp4?s=7382fdedda817a193bcffb6ff74624fa245ee666&profile_id=164&oauth2_token_id=57447761",
113
+ token: "A",
114
+ type: "video/mp4",
115
+ },
116
+ createdAt: moment(
117
+ "Fri Nov 03 2023 19:21:14 GMT+0800 (Malaysia Time)"
118
+ ).toDate(),
119
+ },
120
+ {
121
+ sender: currentUser,
122
+ messageBody: {
123
+ fileName:
124
+ "https://images.pexels.com/photos/3726314/pexels-photo-3726314.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1",
125
+ token: "B",
126
+ type: "image/png",
127
+ },
128
+ createdAt: moment(
129
+ "Fri Nov 03 2023 19:21:18 GMT+0800 (Malaysia Time)"
130
+ ).toDate(),
131
+ },
132
+ {
133
+ sender: currentUser,
134
+ messageBody: "Here's mine! He says hello!",
135
+ createdAt: moment(
136
+ "Fri Nov 03 2023 19:22:14 GMT+0800 (Malaysia Time)"
137
+ ).toDate(),
138
+ },
139
+ ],
140
+ });
141
+
142
+ const handleOnSendMessage = (conversation: Conversation) => {
143
+ setConversation(conversation);
144
+ setMessage("");
145
+ setFile(undefined);
146
+ };
147
+
148
+ const handleOnSearch = (searchMessage: string) => {
149
+ if (searchMessage.length === 0) {
150
+ setSearch("");
151
+ setFilteredConversation(null);
152
+ } else {
153
+ const dupMessageList = conversation.messageList.filter((eachMessage) => {
154
+ if (typeof eachMessage.messageBody === "string") {
155
+ return eachMessage.messageBody
156
+ .toLowerCase()
157
+ .includes(searchMessage.toLowerCase());
158
+ }
159
+ return null;
160
+ });
161
+ const dupConversation = {
162
+ id: conversation.id,
163
+ members: [...conversation.members],
164
+ messageList: [...dupMessageList],
165
+ };
166
+ setFilteredConversation(dupConversation);
167
+ }
168
+ };
169
+
170
+ const handleOnClearMessage = () => {
171
+ setFilteredConversation(null);
172
+ setConversation({
173
+ id: "1",
174
+ members: [currentUser, botUser],
175
+ messageList: [],
176
+ });
177
+ };
178
+
179
+ const handleOnChangeUpload = (e: any) => {
180
+ if (e && e.target.files.length > 0) {
181
+ setFile(e.target.files[0]);
182
+ } else {
183
+ setFile(undefined);
184
+ }
185
+ };
186
+
187
+ const handleOnSendUpload = (conversation: Conversation) => {
188
+ if (file && conversation) {
189
+ setLoading(true);
190
+ const dupConversation = {
191
+ id: conversation.id,
192
+ members: [...conversation.members],
193
+ messageList: [...conversation.messageList],
194
+ };
195
+ const fileUrl = URL.createObjectURL(file);
196
+ const fileObj = {
197
+ fileName: fileUrl,
198
+ token: uuidv4(),
199
+ type: file.type,
200
+ };
201
+ dupConversation.messageList.push({
202
+ sender: currentUser,
203
+ messageBody: fileObj,
204
+ createdAt: moment().toDate(),
205
+ });
206
+ setTimeout(() => {
207
+ setConversation(dupConversation);
208
+ setMessage("");
209
+ setFile(undefined);
210
+ setLoading(false);
211
+ }, 5000);
212
+ }
213
+ };
214
+
215
+ const headerElement = (
216
+ <div className="p-2 bg-primary-500 rounded-t-md">
217
+ <img src={Logo} alt="" className="h-12" />
218
+ </div>
219
+ );
220
+
221
+ const renderFooterElement = () => {
222
+ if (conversation.messageList.length >= messageLimit)
223
+ return (
224
+ <div className="p-2">
225
+ <div className="p-2 text-xs border rounded-md shadow-md bg-primary-50 border-primary-300">
226
+ <p>
227
+ You have reached the message limit of: {messageLimit}
228
+ <br />
229
+ Clear previous messages to send a new one.
230
+ </p>
231
+ <TextButton
232
+ text="Clear now"
233
+ onClick={handleOnClearMessage}
234
+ className="mt-2"
235
+ />
236
+ </div>
237
+ </div>
238
+ );
239
+ else return undefined;
240
+ };
241
+ const footerElement = renderFooterElement();
242
+
243
+ const additionalAction: ChatBaseAction[] = [
244
+ {
245
+ text: "Clear",
246
+ onClick: handleOnClearMessage,
247
+ icon: <TrashIcon className="w-3 h-3" aria-hidden="true" />,
248
+ },
249
+ ];
250
+
251
+ const loadingElement = (
252
+ <div className="w-full h-full flex flex-col justify-center items-center">
253
+ <Loading />
254
+ <p className="mt-2">Uploading File</p>
255
+ </div>
256
+ );
257
+
258
+ useEffect(() => {
259
+ setTimeout(() => {
260
+ const dupConversation: Conversation = {
261
+ id: conversation.id,
262
+ members: [...conversation.members],
263
+ messageList: [...conversation.messageList],
264
+ };
265
+ dupConversation.messageList.push({
266
+ sender: botUser,
267
+ messageBody: "Hello to you too",
268
+ createdAt: moment().toDate(),
269
+ });
270
+ setConversation(dupConversation);
271
+ }, 2000);
272
+ }, []);
273
+
274
+ return (
275
+ <ChatBase
276
+ open
277
+ value={message}
278
+ currentUser={currentUser}
279
+ conversation={filteredConversation ?? conversation}
280
+ fileUpload={{
281
+ allowFileUpload: true,
282
+ file: file,
283
+ acceptFileType: ".jpg,.jpeg,.png,.svg,.tiff,.mp4,.webm,.ogg",
284
+ onChangeUpload: (e) => handleOnChangeUpload(e),
285
+ onSendUpload: (conversation) => {
286
+ handleOnSendUpload(conversation);
287
+ },
288
+ }}
289
+ headerElement={headerElement}
290
+ footerElement={footerElement}
291
+ bodyElement={loading ? loadingElement : undefined}
292
+ additionalAction={additionalAction}
293
+ searchMessage={search}
294
+ onChangeSearch={(e) => setSearch(e.target.value)}
295
+ onSendMessage={handleOnSendMessage}
296
+ onChangeMessage={(e) => setMessage(e.target.value)}
297
+ onSearch={handleOnSearch}
298
+ className="w-full border border-gray-200 shadow-lg sm:w-96"
299
+ disableMobileResize
300
+ disableMessageInput={
301
+ conversation.messageList.length >= messageLimit || (file ? true : false)
302
+ }
303
+ onHiddenChatText={true}
304
+ />
305
+ );
306
+ });
@@ -0,0 +1,161 @@
1
+ # Chat Dashboard
2
+
3
+ <!-- STORY -->
4
+
5
+ <hr>
6
+
7
+ Chat Dashboard
8
+
9
+ ##### Import
10
+
11
+ ```js
12
+ import { ChatDashboard } from "blixify-ui-web/components/chat/chatDashboard";
13
+ ```
14
+
15
+ ##### Usage
16
+
17
+ ```jsx
18
+ const [message, setMessage] = useState("");
19
+ const [search, setSearch] = useState("");
20
+ const [isLoading, setIsLoading] = useState(false);
21
+ const [mobileSelectedChat, setMobileSelectedChat] = useState(false);
22
+ const [filteredConversation, setFilteredConversation] =
23
+ useState<Conversation | null>();
24
+ const [conversation, setConversation] = useState<Conversation>({
25
+ id: "",
26
+ members: [],
27
+ messageList: [],
28
+ });
29
+ const [conversationList, setConversationList] = useState<Conversation[]>([]);
30
+
31
+ const handleOnSendMessage = (conversation: Conversation) => {
32
+ setConversation({
33
+ id: conversation.id,
34
+ members: [...conversation.members],
35
+ messageList: [...conversation.messageList],
36
+ });
37
+ setMessage("");
38
+ const dupConvoList = conversationList.map((eachConvo, i) => {
39
+ if (eachConvo.id === conversation.id) {
40
+ return conversation;
41
+ }
42
+ return eachConvo;
43
+ });
44
+
45
+ handleSortConvoList(dupConvoList);
46
+ };
47
+
48
+ const handleSortConvoList = (convoList: Conversation[]) => {
49
+ const sortedConvoList = convoList.sort((a, b) => {
50
+ return moment(b.messageList[b.messageList.length - 1].createdAt).diff(
51
+ moment(a.messageList[a.messageList.length - 1].createdAt)
52
+ );
53
+ });
54
+ setConversationList(sortedConvoList);
55
+ setConversation(sortedConvoList[0]);
56
+ };
57
+
58
+ const handleMessageList = (id: string) => {
59
+ setIsLoading(true);
60
+ setMobileSelectedChat(true);
61
+ setTimeout(() => {
62
+ setIsLoading(false);
63
+ conversationList.map((eachConversation) => {
64
+ if (eachConversation.id === id) {
65
+ setConversation(eachConversation);
66
+ }
67
+ return null;
68
+ });
69
+ }, 1000);
70
+ };
71
+
72
+ const handleOnSearch = (searchMessage: string) => {
73
+ if (searchMessage.length === 0) {
74
+ setSearch("");
75
+ setFilteredConversation(null);
76
+ } else {
77
+ const dupMessageList = conversation.messageList.filter((eachMessage) => {
78
+ return eachMessage.messageBody
79
+ .toLowerCase()
80
+ .includes(searchMessage.toLowerCase());
81
+ });
82
+ const dupConversation = {
83
+ id: conversation.id,
84
+ members: [...conversation.members],
85
+ messageList: [...dupMessageList],
86
+ };
87
+ setFilteredConversation(dupConversation);
88
+ }
89
+ };
90
+
91
+ return (
92
+ <ChatDashboard
93
+ value={message}
94
+ searchMessage={search}
95
+ currentUser={currentUser}
96
+ selectedConversation={filteredConversation ?? conversation}
97
+ conversationList={conversationList}
98
+ mobileSelectedChat={mobileSelectedChat}
99
+ sizeClassName="w-full h-[50vh] sm:h-[50vh]"
100
+ chatBaseSizeClassName="w-full h-[50vh] sm:h-[50vh]"
101
+ headerElement={renderHeaderElement()}
102
+ bodyElement={renderBodyElement()}
103
+ onChangeMessage={(e) => setMessage(e.target.value)}
104
+ handleSelectedConversation={handleMessageList}
105
+ onSendMessage={handleOnSendMessage}
106
+ onChangeSearch={(e) => setSearch(e.target.value)}
107
+ onSearch={handleOnSearch}
108
+ />
109
+ );
110
+ ```
111
+
112
+ ##### Required props
113
+
114
+ | Name | Type | Description |
115
+ | -------------------- | ---------------- | --------------------------------------- |
116
+ | value | `string` | Message input text |
117
+ | currentUser | `User` | User Object |
118
+ | selectedConversation | `Conversation` | Selected Conversation Object to display |
119
+ | conversationList | `Conversation[]` | List of Conversation Objects |
120
+
121
+ ##### Optional props
122
+
123
+ | Name | Type | Default | Description |
124
+ | -------------------------- | -------------------- | ------------------------------- | --------------------------------- |
125
+ | mobileSelectedChat | `boolean` | false | Mobile state for selected chat |
126
+ | searchMessage | `string` | "" | Search input text |
127
+ | headerElement | `React Element` | null | Replaces default component Header |
128
+ | bodyElement | `React Element` | null | Replaces default component Body |
129
+ | className | `tailwind classname` | "" | For component container |
130
+ | sizeClassName | `tailwind classname` | "" | For component size |
131
+ | chatBaseClassName | `tailwind classname` | "" | For Chat Base component container |
132
+ | chatBaseSizeClassName | `tailwind classname` | "" | For Chat Base component size |
133
+ | onSendMessage | `function` | `(event: any) => {}` | To send message |
134
+ | onChangeMessage | `function` | `(event: any) => {}` | To type in message input |
135
+ | onChangeSearch | `function` | `(event: any) => {}` | To type in search input |
136
+ | onSearch | `function` | `(searchMessage: string) => {}` | To search in messages |
137
+ | handleSelectedConversation | `function` | `(id: string) => {}` | Display selected conversation |
138
+
139
+ ##### Interface User
140
+
141
+ | Name | Type | Description |
142
+ | ---------- | -------- | ----------------- |
143
+ | `id` | `string` | Required id |
144
+ | `name` | `string` | Required name |
145
+ | `imageUrl` | `string` | Optional imageURL |
146
+
147
+ ##### Interface Conversation
148
+
149
+ | Name | Type | Description |
150
+ | ------------- | ----------- | ------------------------- |
151
+ | `id` | `string` | Required id |
152
+ | `members` | `User[]` | Required list of Users |
153
+ | `messageList` | `Message[]` | Required list of Messages |
154
+
155
+ ##### Interface Message
156
+
157
+ | Name | Type | Description |
158
+ | ------------- | -------- | -------------------- |
159
+ | `sender` | `User` | Required User |
160
+ | `messageBody` | `string` | Required messageBody |
161
+ | `createdAt` | `Date` | Required date |
@@ -0,0 +1,154 @@
1
+ import { ChevronLeftIcon } from "@heroicons/react/24/outline";
2
+ import { storiesOf } from "@storybook/react";
3
+ import moment from "moment";
4
+ import React, { useEffect, useState } from "react";
5
+ import { ChatDashboard } from ".";
6
+ import Logo from "../../../assets/logo.png";
7
+ import { IconButton } from "../../action/iconButton";
8
+ import { Loading } from "../../display/loading";
9
+ import { Conversation } from "../chatBase";
10
+ import { conversationList as convoList, currentUser } from "../chatUtils";
11
+ import README from "./README.md";
12
+
13
+ const stories = storiesOf("Chat", module);
14
+
15
+ stories.addParameters({
16
+ readme: {
17
+ content: README,
18
+ },
19
+ });
20
+
21
+ stories.add("Chat Dashboard", () => {
22
+ const [message, setMessage] = useState("");
23
+ const [search, setSearch] = useState("");
24
+ const [isLoading, setIsLoading] = useState(false);
25
+ const [mobileSelectedChat, setMobileSelectedChat] = useState(false);
26
+ const [filteredConversation, setFilteredConversation] =
27
+ useState<Conversation | null>();
28
+ const [conversation, setConversation] = useState<Conversation>({
29
+ id: "",
30
+ members: [],
31
+ messageList: [],
32
+ });
33
+ const [conversationList, setConversationList] = useState<Conversation[]>([]);
34
+
35
+ useEffect(() => {
36
+ handleSortConvoList(convoList);
37
+ }, []);
38
+
39
+ const handleOnSearch = (searchMessage: string) => {
40
+ if (searchMessage.length === 0) {
41
+ setSearch("");
42
+ setFilteredConversation(null);
43
+ } else {
44
+ const dupMessageList = conversation.messageList.filter((eachMessage) => {
45
+ if (typeof eachMessage.messageBody === "string") {
46
+ return eachMessage.messageBody
47
+ .toLowerCase()
48
+ .includes(searchMessage.toLowerCase());
49
+ }
50
+ return null;
51
+ });
52
+ const dupConversation = {
53
+ id: conversation.id,
54
+ members: [...conversation.members],
55
+ messageList: [...dupMessageList],
56
+ };
57
+ setFilteredConversation(dupConversation);
58
+ }
59
+ };
60
+
61
+ const handleOnSendMessage = (conversation: Conversation) => {
62
+ setConversation({
63
+ id: conversation.id,
64
+ members: [...conversation.members],
65
+ messageList: [...conversation.messageList],
66
+ });
67
+ setMessage("");
68
+ const dupConvoList = conversationList.map((eachConvo, i) => {
69
+ if (eachConvo.id === conversation.id) {
70
+ return conversation;
71
+ }
72
+ return eachConvo;
73
+ });
74
+
75
+ handleSortConvoList(dupConvoList);
76
+ };
77
+
78
+ const handleSortConvoList = (convoList: Conversation[]) => {
79
+ const sortedConvoList = convoList.sort((a, b) => {
80
+ return moment(b.messageList[b.messageList.length - 1].createdAt).diff(
81
+ moment(a.messageList[a.messageList.length - 1].createdAt)
82
+ );
83
+ });
84
+ setConversationList(sortedConvoList);
85
+ setConversation(sortedConvoList[0]);
86
+ };
87
+
88
+ const handleMessageList = (id: string) => {
89
+ setIsLoading(true);
90
+ setMobileSelectedChat(true);
91
+ setTimeout(() => {
92
+ setIsLoading(false);
93
+ conversationList.map((eachConversation) => {
94
+ if (eachConversation.id === id) {
95
+ setConversation(eachConversation);
96
+ }
97
+ return null;
98
+ });
99
+ }, 1000);
100
+ };
101
+
102
+ const renderBodyElement = () => {
103
+ return isLoading ? (
104
+ <div className="w-full">
105
+ <Loading />
106
+ </div>
107
+ ) : undefined;
108
+ };
109
+
110
+ const renderHeaderElement = () => {
111
+ const otherUser = conversation.members.find((eachMember) => {
112
+ return eachMember.id !== currentUser.id;
113
+ });
114
+ const userName = otherUser ? otherUser.name : "";
115
+
116
+ return (
117
+ <div className="w-full flex items-center h-12 text-white bg-primary-500 text-center">
118
+ <IconButton
119
+ icon={<ChevronLeftIcon className="w-6 h-6" />}
120
+ background="bg-transparent"
121
+ onClick={() => setMobileSelectedChat(false)}
122
+ className={`${!mobileSelectedChat ? "hidden sm:flex" : ""} sm:hidden`}
123
+ />
124
+ <p className="ml-2 sm:ml-12">{userName}</p>
125
+ </div>
126
+ );
127
+ };
128
+
129
+ return (
130
+ <div>
131
+ <div className="flex justify-center items-center py-2 space-x-4">
132
+ <img src={Logo} alt="" className="h-14" />
133
+ <h1 className="text-2xl text-primary-400">Chat App</h1>
134
+ </div>
135
+ <ChatDashboard
136
+ value={message}
137
+ searchMessage={search}
138
+ currentUser={currentUser}
139
+ selectedConversation={filteredConversation ?? conversation}
140
+ conversationList={conversationList}
141
+ mobileSelectedChat={mobileSelectedChat}
142
+ sizeClassName="w-full h-[50vh] sm:h-[50vh]"
143
+ chatBaseSizeClassName="w-full h-[50vh] sm:h-[50vh]"
144
+ headerElement={renderHeaderElement()}
145
+ bodyElement={renderBodyElement()}
146
+ onChangeMessage={(e) => setMessage(e.target.value)}
147
+ handleSelectedConversation={handleMessageList}
148
+ onSendMessage={handleOnSendMessage}
149
+ onChangeSearch={(e) => setSearch(e.target.value)}
150
+ onSearch={handleOnSearch}
151
+ />
152
+ </div>
153
+ );
154
+ });
@@ -0,0 +1,13 @@
1
+ # Data Graph
2
+
3
+ <!-- STORY -->
4
+
5
+ <hr>
6
+
7
+ Data Graph for Dashboard
8
+
9
+ ##### Import
10
+
11
+ ```js
12
+ import { DataGraph } from "blixify-ui-web/components/data/dataGraph";
13
+ ```