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,122 @@
1
+ import { PencilIcon } from "@heroicons/react/24/outline";
2
+ import { storiesOf } from "@storybook/react";
3
+ import moment from "moment";
4
+ import React, { useCallback, useEffect, useMemo, useState } from "react";
5
+ import { TreemapChart } from ".";
6
+ import { RangeInterface } from "../DateRange";
7
+ import README from "./README.md";
8
+
9
+ const stories = storiesOf("Chart", module);
10
+
11
+ stories.addParameters({
12
+ readme: {
13
+ content: README,
14
+ },
15
+ });
16
+
17
+ stories.add("Treemap Chart", () => {
18
+ const [seriesData, setSeriesData] = useState<any[]>([]);
19
+
20
+ const chartDummyData = useMemo(() => {
21
+ return [
22
+ {
23
+ label: "Analytics",
24
+ value: 20,
25
+ },
26
+ {
27
+ label: "Ecommerce",
28
+ value: 15,
29
+ },
30
+ {
31
+ label: "Desktop",
32
+ value: 13,
33
+ },
34
+ {
35
+ label: "Mobile",
36
+ value: 12,
37
+ },
38
+ {
39
+ label: "Social",
40
+ value: 10,
41
+ },
42
+ {
43
+ label: "Other",
44
+ value: 8,
45
+ },
46
+ {
47
+ label: "Marketing",
48
+ value: 7,
49
+ },
50
+ {
51
+ label: "Development",
52
+ value: 6,
53
+ },
54
+ {
55
+ label: "Design",
56
+ value: 5,
57
+ },
58
+ {
59
+ label: "Support",
60
+ value: 4,
61
+ },
62
+ ];
63
+ }, []);
64
+
65
+ const handleSetData = useCallback(
66
+ (customDate?: RangeInterface) => {
67
+ let dummySeriesData: any[] = [];
68
+ chartDummyData.map((eachData) => {
69
+ dummySeriesData.push({ x: eachData.label, y: eachData.value });
70
+ return null;
71
+ });
72
+ setSeriesData(dummySeriesData);
73
+ },
74
+ [chartDummyData]
75
+ );
76
+
77
+ useEffect(() => {
78
+ handleSetData();
79
+ }, [handleSetData]);
80
+
81
+ const sevenDaysAgo = new Date();
82
+ sevenDaysAgo.setDate(moment().toDate().getDate() - 7);
83
+
84
+ return (
85
+ <>
86
+ <div className="font-medium mb-5">Treemap Chart</div>
87
+ <TreemapChart
88
+ title="Page Views Distribution"
89
+ seriesName="Pages"
90
+ seriesData={seriesData}
91
+ tool={<PencilIcon className="h-4 w-4 text-primary-600" />}
92
+ dateRangeVisible={true}
93
+ customDate={{
94
+ startDate: sevenDaysAgo,
95
+ endDate: moment().toDate(),
96
+ isDuration: true,
97
+ }}
98
+ onChangeDate={handleSetData}
99
+ showDataLabel={true}
100
+ newTabUrl="https://www.google.com/"
101
+ />
102
+ <div className="font-medium my-5">Dark Mode Treemap Chart</div>
103
+ <TreemapChart
104
+ title="Data Categories"
105
+ seriesName="Categories"
106
+ seriesData={seriesData}
107
+ tool={<PencilIcon className="h-4 w-4 text-primary-600" />}
108
+ dateRangeVisible={true}
109
+ customDate={{
110
+ startDate: sevenDaysAgo,
111
+ endDate: moment().toDate(),
112
+ isDuration: true,
113
+ }}
114
+ onChangeDate={handleSetData}
115
+ showDataLabel={true}
116
+ darkMode={true}
117
+ darkModeBg="bg-gradient-to-r from-slate-700 to-gray-900"
118
+ borderColor=""
119
+ />
120
+ </>
121
+ );
122
+ });
@@ -0,0 +1,113 @@
1
+ # Chat Anchor
2
+
3
+ <!-- STORY -->
4
+
5
+ <hr>
6
+
7
+ Chat Anchor
8
+
9
+ ##### Import
10
+
11
+ ```js
12
+ import { ChatAnchor } from "blixify-ui-web/components/chat/chatAnchor";
13
+ import {
14
+ ChatBase,
15
+ Conversation,
16
+ } from "blixify-ui-web/components/chat/chatBase";
17
+ ```
18
+
19
+ ##### Usage
20
+
21
+ ```tsx
22
+ const [openChatBase, setOpenChatBase] = useState<boolean>(false);
23
+ const [message, setMessage] = useState("");
24
+ const [search, setSearch] = useState("");
25
+ const [filteredConversation, setFilteredConversation] =
26
+ useState<Conversation | null>();
27
+ const [conversation, setConversation] = useState<Conversation>({
28
+ id: "1",
29
+ members: [currentUser, botUser],
30
+ messageList: [
31
+ {
32
+ sender: botUser,
33
+ messageBody: "Hi! How can I help you? 🤖",
34
+ createdAt: moment(
35
+ "Fri Nov 03 2023 12:21:14 GMT+0800 (Malaysia Time)"
36
+ ).toDate(),
37
+ },
38
+ {
39
+ sender: currentUser,
40
+ messageBody: "Yo, my computer's acting up.",
41
+ createdAt: moment(
42
+ "Fri Nov 03 2023 13:21:14 GMT+0800 (Malaysia Time)"
43
+ ).toDate(),
44
+ },
45
+ ],
46
+ });
47
+
48
+ const handleOnClick = () => setOpenChatBase(!openChatBase);
49
+
50
+ const handleOnSendMessage = (conversation: Conversation) => {
51
+ setConversation(conversation);
52
+ setMessage("");
53
+ };
54
+
55
+ const handleOnSearch = (searchMessage: string) => {
56
+ if (searchMessage.length === 0) {
57
+ setSearch("");
58
+ setFilteredConversation(null);
59
+ } else {
60
+ const dupMessageList = conversation.messageList.filter((eachMessage) => {
61
+ return eachMessage.messageBody
62
+ .toLowerCase()
63
+ .includes(searchMessage.toLowerCase());
64
+ });
65
+ const dupConversation = {
66
+ id: conversation.id,
67
+ members: [...conversation.members],
68
+ messageList: [...dupMessageList],
69
+ };
70
+ setFilteredConversation(dupConversation);
71
+ }
72
+ };
73
+
74
+ const headerElement = (
75
+ <div className="p-2 bg-primary-500 rounded-t-md">
76
+ <img src={Logo} alt="" className="h-12" />
77
+ </div>
78
+ );
79
+
80
+ return (
81
+ <ChatAnchor
82
+ open={openChatBase}
83
+ value={message}
84
+ currentUser={currentUser}
85
+ conversation={filteredConversation ?? conversation}
86
+ headerElement={headerElement}
87
+ searchMessage={search}
88
+ onChangeSearch={(e) => setSearch(e.target.value)}
89
+ onSendMessage={handleOnSendMessage}
90
+ onChangeMessage={(e) => setMessage(e.target.value)}
91
+ onSearch={handleOnSearch}
92
+ onClose={handleOnClick}
93
+ className="shadow-lg border border-gray-200"
94
+ onClick={handleOnClick}
95
+ />
96
+ );
97
+ ```
98
+
99
+ ##### Required props
100
+
101
+ | Name | Type | Description |
102
+ | ------- | ------------ | ------------------------------------------------ |
103
+ | onClick | `() => void` | Function that triggers upon clicking Chat Anchor |
104
+
105
+ ##### Optional props
106
+
107
+ | Name | Type | Default | Description |
108
+ | ---------------- | ----------------------------- | ------- | -------------------------------- |
109
+ | `positionOffset` | `Tailwind class` | null | |
110
+ | `greetingText` | `string` | null | Text to display |
111
+ | `greetingCard` | `boolean` | null | Boolean to display greeting card |
112
+ | `openIcon` | `string` or `React.ReactNode` | null | Icon to expand chat |
113
+ | `closeIcon` | `string` or `React.ReactNode` | null | Icon to collapse chat |
@@ -0,0 +1,156 @@
1
+ import { storiesOf } from "@storybook/react";
2
+ import moment from "moment";
3
+ import React, { useState } from "react";
4
+ import { ChatAnchor } from ".";
5
+ import Logo from "../../../assets/logo.png";
6
+ import { Conversation } from "../chatBase";
7
+ import README from "./README.md";
8
+
9
+ const stories = storiesOf("Chat", module);
10
+
11
+ stories.addParameters({
12
+ readme: {
13
+ content: README,
14
+ },
15
+ });
16
+
17
+ stories.add("Chat Anchor", () => {
18
+ const botUser = {
19
+ id: "1",
20
+ name: "Bot",
21
+ imageUrl:
22
+ "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",
23
+ };
24
+ const currentUser = { id: "2", name: "Guest" };
25
+
26
+ const [openChatBase, setOpenChatBase] = useState<boolean>(false);
27
+ const [message, setMessage] = useState("");
28
+ const [search, setSearch] = useState("");
29
+ const [filteredConversation, setFilteredConversation] =
30
+ useState<Conversation | null>();
31
+
32
+ const [conversation, setConversation] = useState<Conversation>({
33
+ id: "1",
34
+ members: [currentUser, botUser],
35
+ messageList: [
36
+ {
37
+ sender: botUser,
38
+ messageBody: "Hi! How can I help you? 🤖",
39
+ createdAt: moment(
40
+ "Fri Nov 03 2023 12:21:14 GMT+0800 (Malaysia Time)"
41
+ ).toDate(),
42
+ },
43
+ {
44
+ sender: currentUser,
45
+ messageBody: "Yo, my computer's acting up.",
46
+ createdAt: moment(
47
+ "Fri Nov 03 2023 13:21:14 GMT+0800 (Malaysia Time)"
48
+ ).toDate(),
49
+ },
50
+ {
51
+ sender: currentUser,
52
+ messageBody:
53
+ "It keeps saying 'Error 404: Coffee not found' when I start it up.",
54
+ createdAt: moment(
55
+ "Fri Nov 03 2023 14:21:14 GMT+0800 (Malaysia Time)"
56
+ ).toDate(),
57
+ },
58
+ {
59
+ sender: botUser,
60
+ messageBody:
61
+ "Sounds like a caffeine emergency! Have you tried offering it coffee?",
62
+ createdAt: moment(
63
+ "Fri Nov 03 2023 15:21:14 GMT+0800 (Malaysia Time)"
64
+ ).toDate(),
65
+ },
66
+ {
67
+ sender: currentUser,
68
+ messageBody: "Seriously?",
69
+ createdAt: moment(
70
+ "Fri Nov 03 2023 16:21:14 GMT+0800 (Malaysia Time)"
71
+ ).toDate(),
72
+ },
73
+ {
74
+ sender: botUser,
75
+ messageBody:
76
+ "Well, computers do like a jolt of energy, but don't spill, that could be 'mocha-nical' trouble!",
77
+ createdAt: moment(
78
+ "Fri Nov 03 2023 17:21:14 GMT+0800 (Malaysia Time)"
79
+ ).toDate(),
80
+ },
81
+ {
82
+ sender: currentUser,
83
+ messageBody: "Cringe. I'll give it a shot. Thanks.",
84
+ createdAt: moment(
85
+ "Fri Nov 03 2023 18:21:14 GMT+0800 (Malaysia Time)"
86
+ ).toDate(),
87
+ },
88
+ {
89
+ sender: botUser,
90
+ messageBody:
91
+ "Anytime! If it demands a donut, that's on me. Have a brew-tiful day!",
92
+ createdAt: moment(
93
+ "Fri Nov 03 2023 19:21:14 GMT+0800 (Malaysia Time)"
94
+ ).toDate(),
95
+ },
96
+ ],
97
+ });
98
+
99
+ const handleOnClick = () => setOpenChatBase(!openChatBase);
100
+
101
+ const handleOnSendMessage = (conversation: Conversation) => {
102
+ setConversation(conversation);
103
+ setMessage("");
104
+ };
105
+
106
+ const handleOnSearch = (searchMessage: string) => {
107
+ if (searchMessage.length === 0) {
108
+ setSearch("");
109
+ setFilteredConversation(null);
110
+ } else {
111
+ const dupMessageList = conversation.messageList.filter((eachMessage) => {
112
+ if (typeof eachMessage.messageBody === "string") {
113
+ return eachMessage.messageBody
114
+ .toLowerCase()
115
+ .includes(searchMessage.toLowerCase());
116
+ }
117
+ return null;
118
+ });
119
+ const dupConversation = {
120
+ id: conversation.id,
121
+ members: [...conversation.members],
122
+ messageList: [...dupMessageList],
123
+ };
124
+ setFilteredConversation(dupConversation);
125
+ }
126
+ };
127
+
128
+ const headerElement = (
129
+ <div className="p-2 bg-primary-500 rounded-t-md">
130
+ <img src={Logo} alt="" className="h-12" />
131
+ </div>
132
+ );
133
+
134
+ return (
135
+ <div className="h-96 w-full relative">
136
+ <ChatAnchor
137
+ open={openChatBase}
138
+ value={message}
139
+ currentUser={currentUser}
140
+ conversation={filteredConversation ?? conversation}
141
+ headerElement={headerElement}
142
+ searchMessage={search}
143
+ onChangeSearch={(e) => setSearch(e.target.value)}
144
+ onSendMessage={handleOnSendMessage}
145
+ onChangeMessage={(e) => setMessage(e.target.value)}
146
+ onSearch={handleOnSearch}
147
+ onClose={handleOnClick}
148
+ className="shadow-lg border border-gray-200"
149
+ onClick={handleOnClick}
150
+ greetingCard={true}
151
+ greetingText="Ask me for more information"
152
+ openIcon="https://images.unsplash.com/photo-1719937206341-38a6392dfdef?q=80&w=2940&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
153
+ />
154
+ </div>
155
+ );
156
+ });
@@ -0,0 +1,223 @@
1
+ # Chat Base
2
+
3
+ <!-- STORY -->
4
+
5
+ <hr>
6
+
7
+ Chat Base
8
+
9
+ ##### Import
10
+
11
+ ```js
12
+ import { ChatBase } from "blixify-ui-web/components/chat/chatBase";
13
+ ```
14
+
15
+ ##### Usage
16
+
17
+ ```tsx
18
+ const [message, setMessage] = useState("");
19
+ const [search, setSearch] = useState("");
20
+ const [filteredConversation, setFilteredConversation] =
21
+ useState<Conversation | null>();
22
+ const [conversation, setConversation] = useState<Conversation>({
23
+ id: "1",
24
+ members: [currentUser, botUser],
25
+ messageList: [
26
+ {
27
+ sender: botUser,
28
+ messageBody: "Hi! How can I help you? 🤖",
29
+ createdAt: moment(
30
+ "Fri Nov 03 2023 12:21:14 GMT+0800 (Malaysia Time)"
31
+ ).toDate(),
32
+ },
33
+ {
34
+ sender: currentUser,
35
+ messageBody: "Yo, my computer's acting up.",
36
+ createdAt: moment(
37
+ "Fri Nov 03 2023 13:21:14 GMT+0800 (Malaysia Time)"
38
+ ).toDate(),
39
+ },
40
+ ],
41
+ });
42
+
43
+ const handleOnSendMessage = (conversation: Conversation) => {
44
+ setConversation(conversation);
45
+ setMessage("");
46
+ };
47
+
48
+ const handleOnSearch = (searchMessage: string) => {
49
+ if (searchMessage.length === 0) {
50
+ setSearch("");
51
+ setFilteredConversation(null);
52
+ } else {
53
+ const dupMessageList = conversation.messageList.filter((eachMessage) => {
54
+ return eachMessage.messageBody
55
+ .toLowerCase()
56
+ .includes(searchMessage.toLowerCase());
57
+ });
58
+ const dupConversation = {
59
+ id: conversation.id,
60
+ members: [...conversation.members],
61
+ messageList: [...dupMessageList],
62
+ };
63
+ setFilteredConversation(dupConversation);
64
+ }
65
+ };
66
+
67
+ const handleOnClearMessage = () => {
68
+ setFilteredConversation(null);
69
+ setConversation({
70
+ id: "1",
71
+ members: [currentUser, botUser],
72
+ messageList: [],
73
+ });
74
+ };
75
+
76
+ const headerElement = (
77
+ <div className="p-2 bg-primary-500 rounded-t-md">
78
+ <img src={Logo} alt="" className="h-12" />
79
+ </div>
80
+ );
81
+
82
+ const renderFooterElement = () => {
83
+ if (conversation.messageList.length >= messageLimit)
84
+ return (
85
+ <div className="p-2">
86
+ <div className="p-2 bg-primary-50 border border-primary-300 rounded-md shadow-md text-xs">
87
+ <p>
88
+ You have reached the message limit of: {messageLimit}
89
+ <br />
90
+ Clear previous messages to send a new one.
91
+ </p>
92
+ <TextButton
93
+ text="Clear now"
94
+ onClick={handleOnClearMessage}
95
+ className="mt-2"
96
+ />
97
+ </div>
98
+ </div>
99
+ );
100
+ else return <></>;
101
+ };
102
+ const footerElement = renderFooterElement();
103
+
104
+ const additionalAction: ChatBaseAction[] = [
105
+ {
106
+ text: "Clear",
107
+ onClick: handleOnClearMessage,
108
+ icon: <TrashIcon className="w-3 h-3" aria-hidden="true" />,
109
+ },
110
+ ];
111
+
112
+ return (
113
+ <ChatBase
114
+ open
115
+ value={message}
116
+ currentUser={currentUser}
117
+ conversation={filteredConversation ?? conversation}
118
+ headerElement={headerElement}
119
+ footerElement={footerElement}
120
+ additionalAction={additionalAction}
121
+ searchMessage={search}
122
+ onChangeSearch={(e) => setSearch(e.target.value)}
123
+ onSendMessage={handleOnSendMessage}
124
+ onChangeMessage={(e) => setMessage(e.target.value)}
125
+ onSearch={handleOnSearch}
126
+ className="border border-gray-200 shadow-lg w-96"
127
+ disableMobileResize
128
+ disableMessageInput={conversation.messageList.length >= messageLimit}
129
+ onHiddenChatText={true}
130
+ />
131
+ );
132
+ ```
133
+
134
+ ##### Required props
135
+
136
+ | Name | Type | Description |
137
+ | ------------ | -------------- | -------------------------------- |
138
+ | open | `boolean` | Visibility of ChatBase component |
139
+ | value | `string` | Message input text |
140
+ | currentUser | `User` | User Object |
141
+ | conversation | `Conversation` | Conversation Object |
142
+
143
+ ##### Optional props
144
+
145
+ | Name | Type | Default | Description |
146
+ | ------------------- | -------------------- | ---------- | -------------------------------------------------------------------------------------- |
147
+ | searchMessage | `string` | "" | Search input text |
148
+ | headerElement | `React Element` | null | Replaces default component Header |
149
+ | bodyElement | `React Element` | null | Replaces default component Body |
150
+ | footerElement | `React Element` | null | Footer element that floats above message input |
151
+ | additionalAction | `ChatBaseAction[]` | null | Additional buttons to be place within action dropdown in top right corner |
152
+ | disableMessageInput | `boolean` | null | When true, message input is disabled |
153
+ | isLoadingReply | `boolean` | null | When true, loading indicator appears above message input and message input is disabled |
154
+ | className | `tailwind classname` | "" | For component container |
155
+ | sizeClassName | `tailwind classname` | "" | For component size |
156
+ | paddingTop | `Padding top | "" | For mobile applications |
157
+ | disableMobileResize | `boolean` | null | When true, mobile resize is disabled |
158
+ | onSendMessage | `function` | `() => {}` | To send message |
159
+ | onChangeMessage | `function` | `() => {}` | To type in message input |
160
+ | onSearch | `function` | `() => {}` | To search in messages |
161
+ | onChangeSearch | `function` | `() => {}` | To type in search input |
162
+ | onClose | `function` | `() => {}` | To close ChatBase component - Only available on mobile |
163
+ | onHiddenChatText | `boolean` | `true` | To hide the chat text and Paper Clip Icon |
164
+
165
+ ##### Interface FileUpload
166
+
167
+ | Name | Type | Description |
168
+ | ----------------- | -------------------------------------- | ---------------------------------------------------------------------- |
169
+ | `allowFileUpload` | `boolean` | When true, users are able to upload image and video |
170
+ | `file` | `string \| File \| any` | Image / video file |
171
+ | `maxFileSize?` | `number` | Maximum file size |
172
+ | `acceptFileType?` | `string` | Accepted file types (eg. ".jpg,.jpeg,.png,.svg,.tiff,.mp4,.webm,.ogg") |
173
+ | `onChangeUpload` | `(event: any) => void` | Function to change file in file upload input |
174
+ | `onSendUpload` | `(conversation: Conversation) => void` | Function to upload file |
175
+
176
+ ##### Interface FileObj
177
+
178
+ | Name | Type | Description |
179
+ | ---------- | -------- | --------------------------- |
180
+ | `fileName` | `string` | File name |
181
+ | `token` | `string` | File token |
182
+ | `type` | `string` | File type (eg. "image/png") |
183
+
184
+ ##### Interface Conversation
185
+
186
+ | Name | Type | Description |
187
+ | ------------- | ----------- | ------------------------- |
188
+ | `id` | `string` | Required id |
189
+ | `members` | `User[]` | Required list of Users |
190
+ | `messageList` | `Message[]` | Required list of Messages |
191
+
192
+ ##### Interface User
193
+
194
+ | Name | Type | Description |
195
+ | ---------- | -------- | ----------------- |
196
+ | `id` | `string` | Required id |
197
+ | `name` | `string` | Required name |
198
+ | `imageUrl` | `string` | Optional imageURL |
199
+
200
+ ##### Interface Conversation
201
+
202
+ | Name | Type | Description |
203
+ | ------------- | ----------- | ------------------------- |
204
+ | `id` | `string` | Required id |
205
+ | `members` | `User[]` | Required list of Users |
206
+ | `messageList` | `Message[]` | Required list of Messages |
207
+
208
+ ##### Interface Message
209
+
210
+ | Name | Type | Description |
211
+ | ------------- | --------------- | ------------- |
212
+ | `sender` | `User` | Required User |
213
+ | `messageBody` | `string` | messageBody |
214
+ | `reactElemet` | `React Element` | React Element |
215
+ | `createdAt` | `Date` | Required date |
216
+
217
+ ##### Interface ChatBaseAction
218
+
219
+ | Name | Type | Description |
220
+ | --------- | ------------- | ------------------------- |
221
+ | `text` | `string` | Required text |
222
+ | `onClick` | `() => void` | Required onClick function |
223
+ | `icon` | `JSX.Element` | Required icon |