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,196 @@
1
+ import { Menu, Transition } from "@headlessui/react";
2
+ import { storiesOf } from "@storybook/react";
3
+ import axios from "axios";
4
+ import Papa from "papaparse";
5
+ import React, { useEffect, useState } from "react";
6
+ import { Loading } from "../../display/loading";
7
+ import { Container } from "../../structure/container";
8
+ import { Query, Sort } from "../readQuery";
9
+ import { getSpaceData, getWorkspaceData } from "../stories";
10
+ import { blixifyDevCollection, blixifyDevWorkspace } from "../testData";
11
+ import { parseSpaceToDataStructure, parseWorkspaceSettings } from "../utils";
12
+ import { DataTemplateProps } from "./dataStateModel";
13
+ import { DataStructure } from "./model";
14
+ import README from "./README.md";
15
+ import SampleModule from "./SampleModule";
16
+ import { AdditionalQuery, ExtendedTabs, Space } from "./spaceModel";
17
+ import { Workspace } from "./workspaceModel";
18
+
19
+ const stories = storiesOf("Data", module);
20
+
21
+ stories.addParameters({
22
+ readme: {
23
+ content: README,
24
+ },
25
+ });
26
+
27
+ stories.add("Data Module", () => {
28
+ const [selectedSpace, setSelectedSpace] = useState<Space | null>(null);
29
+ const [selectedWorkspace, setSelectedWorkspace] =
30
+ useState<Workspace | null>(null);
31
+ const [mount, setMount] = useState<boolean>(false);
32
+ const [sort, setSort] = useState<Sort | undefined>({
33
+ sortId: "baseUpdatedAt",
34
+ type: "desc",
35
+ });
36
+ const [tabs, setTabs] = useState<ExtendedTabs[]>([]);
37
+ const [queries, setQueries] = useState<AdditionalQuery[]>([]);
38
+
39
+ //INFO : Change this to test for Blixify Space Sample
40
+ const [collectionParam] = useState(blixifyDevCollection);
41
+ const workspaceParam = blixifyDevWorkspace;
42
+
43
+ const [viewParam, setViewParam] = useState("general");
44
+ const [typeParam, setTypeParam] = useState("list");
45
+ const [dataParam, setDataParam] = useState(
46
+ "0f95e0b6-fcf7-4046-8395-06f2f271f56a"
47
+ );
48
+
49
+ const getLocalUrl = "/dashboard/spaceD";
50
+ const isProd = true;
51
+ const queryAPI = isProd
52
+ ? "https://space.blixify.co"
53
+ : "https://space-dev.blixify.co";
54
+ const storageUrl = "https://firebasestorage.googleapis.com/v0/b/";
55
+
56
+ const defaultAPIUrl = `${queryAPI}/api/spaceD`;
57
+ const defaultAssetAPI = `${storageUrl}${
58
+ isProd ? "blixify-space" : "blixify-space-dev"
59
+ }.appspot.com/o/`;
60
+ const defaultUploadAPI = `${queryAPI}/api/asset`;
61
+
62
+ useEffect(() => {
63
+ setMount(false);
64
+ handleRetrieveData();
65
+ }, [collectionParam]);
66
+
67
+ useEffect(() => {
68
+ try {
69
+ const mapAPIKey = "";
70
+ const mapScript = document.createElement("script");
71
+ mapScript.id = "googleMaps";
72
+ mapScript.type = "text/javascript";
73
+ mapScript.src = `https://maps.googleapis.com/maps/api/js?key=${mapAPIKey}&libraries=places,drawing,geometry`;
74
+ mapScript.async = true;
75
+ mapScript.defer = true;
76
+ const head = document.getElementsByTagName("head")[0];
77
+ if (head) {
78
+ head.appendChild(mapScript);
79
+ }
80
+ } catch (err) {}
81
+ }, []);
82
+
83
+ const handleNavigate = (
84
+ type: string,
85
+ selectedId?: string,
86
+ viewId?: string
87
+ ) => {
88
+ setTypeParam(type);
89
+ if (selectedId) setDataParam(selectedId);
90
+ if (viewId) setViewParam(viewId);
91
+ };
92
+
93
+ const handleRetrieveData = async () => {
94
+ if (collectionParam) {
95
+ const space: Space = await getSpaceData(collectionParam);
96
+ if (space) {
97
+ setSelectedSpace(space);
98
+ setTabs(space.extendedTabs ?? []);
99
+ setQueries(space.additionalQuery ?? []);
100
+ if (space?.sortBy?.sortId !== "") {
101
+ setSort(space.sortBy ?? undefined);
102
+ }
103
+ }
104
+ }
105
+ if (workspaceParam) {
106
+ const workspace: any = await getWorkspaceData(workspaceParam);
107
+ if (workspace) {
108
+ setSelectedWorkspace(workspace);
109
+ }
110
+ }
111
+ setMount(true);
112
+ };
113
+
114
+ if (!mount) {
115
+ return <Loading />;
116
+ }
117
+
118
+ const renderDataTemplateProps = (selectedSpace: Space) => {
119
+ const title = selectedSpace?.name;
120
+ const description = selectedSpace?.description ?? "";
121
+ const schema: DataStructure[] = parseSpaceToDataStructure(selectedSpace);
122
+
123
+ let spaceAdditionalQuery: Query[] = [];
124
+ let defaultPrefillSettings: { key: string; value: string }[] = [];
125
+
126
+ const workspaceDeveloperSettings = parseWorkspaceSettings({
127
+ dbEndpoint: defaultAPIUrl,
128
+ imageEndpoint: defaultAssetAPI,
129
+ uploadEndpoint: defaultUploadAPI,
130
+ });
131
+
132
+ const dataTemplateProps: DataTemplateProps = {
133
+ title: title,
134
+ description: description,
135
+ type: typeParam,
136
+ id: dataParam,
137
+ collectionId: collectionParam,
138
+ model: schema,
139
+ localURLEndpoint: getLocalUrl,
140
+ space: selectedSpace,
141
+ limit: 10,
142
+ edit: {
143
+ allEditable: true,
144
+ deleteBtn: false,
145
+ listEditable: true,
146
+ },
147
+ organise: {
148
+ sort: sort?.sortId ? sort : undefined,
149
+ additionalQuery: queries,
150
+ extendedTabs: tabs,
151
+ viewId: viewParam,
152
+ filterComponentNewRow: queries.length >= 4,
153
+ handleNavigate: handleNavigate,
154
+ },
155
+ lib: {
156
+ axios,
157
+ Transition,
158
+ Menu,
159
+ papaParser: Papa,
160
+ },
161
+ devSettings: {
162
+ ...workspaceDeveloperSettings,
163
+ schemaEndpoint: "/api/data",
164
+ schemaEndpointToken: "",
165
+ maxFileSize: 1024,
166
+ organisationMembers: [],
167
+ currentUser: {
168
+ userEmail: "",
169
+ userName: "",
170
+ },
171
+ functionEndpoint: `https://asia-southeast1-blixify-space${
172
+ !isProd ? "-dev" : ""
173
+ }.cloudfunctions.net`,
174
+ },
175
+ bareSettings: {
176
+ bareListFilterQuery: spaceAdditionalQuery,
177
+ bareUpdatePrefill: () => {
178
+ return defaultPrefillSettings;
179
+ },
180
+ bareCSVExportSettings: true,
181
+ bareCSVImportSettings: true,
182
+ },
183
+ linkType: "next",
184
+ };
185
+
186
+ return dataTemplateProps;
187
+ };
188
+
189
+ return (
190
+ <Container bgColor="bg-white">
191
+ {selectedSpace && selectedWorkspace && (
192
+ <SampleModule dataProps={renderDataTemplateProps(selectedSpace)} />
193
+ )}
194
+ </Container>
195
+ );
196
+ });
@@ -0,0 +1,337 @@
1
+ import { Menu, Transition } from "@headlessui/react";
2
+ import { TagIcon } from "@heroicons/react/24/outline";
3
+ import { storiesOf } from "@storybook/react";
4
+ import axios from "axios";
5
+ import Papa from "papaparse";
6
+ import React, { useEffect, useRef, useState } from "react";
7
+ import { DataTemplate } from ".";
8
+ import { Button } from "../../action/button";
9
+ import { Loading } from "../../display/loading";
10
+ import { StorySection } from "../../storyUtils";
11
+ import { Sort } from "../readQuery";
12
+ import {
13
+ dbAPIToken,
14
+ defaultDBEndpoint,
15
+ defaultImageEndpoint,
16
+ defaultUploadEndpoint,
17
+ getAllSpacesList,
18
+ getSpaceData,
19
+ getWorkspaceData,
20
+ schemaUrl,
21
+ storyRenderReferenceLabelOptions,
22
+ storyRenderReferenceSpaceOptions,
23
+ } from "../stories";
24
+ import { blixifyDevCollection, blixifyDevWorkspace } from "../testData";
25
+ import { parseSpaceToDataStructure, parseWorkspaceSettings } from "../utils";
26
+ import { DataStructure } from "./model";
27
+ import README from "./README.md";
28
+ import { AdditionalQuery, ExtendedTabs, Space } from "./spaceModel";
29
+ import { Workspace } from "./workspaceModel";
30
+
31
+ const stories = storiesOf("Data", module);
32
+
33
+ stories.addParameters({
34
+ readme: {
35
+ content: README,
36
+ },
37
+ });
38
+
39
+ stories.add("Data Template", () => {
40
+ const [selectedSpace, setSelectedSpace] = useState<Space | null>(null);
41
+ const [allWorkspaceSpace, setAllWorkspaceSpace] = useState<Space[]>([]);
42
+ const [selectedWorkspace, setSelectedWorkspace] =
43
+ useState<Workspace | null>(null);
44
+ const [mount, setMount] = useState<boolean>(false);
45
+ const [sort, setSort] = useState<Sort | undefined>({
46
+ sortId: "baseUpdatedAt",
47
+ type: "desc",
48
+ });
49
+ const [tabs, setTabs] = useState<ExtendedTabs[]>([]);
50
+ const [queries, setQueries] = useState<AdditionalQuery[]>([]);
51
+ const [collectionParam, setCollectionParams] = useState(blixifyDevCollection);
52
+ const workspaceParam = blixifyDevWorkspace;
53
+
54
+ const dataTemplateRef = useRef<any>(null);
55
+
56
+ const [viewParam, setViewParam] = useState("general");
57
+ const [typeParam, setTypeParam] = useState("list");
58
+ const [dataParam, setDataParam] = useState("");
59
+
60
+ const getLocalUrl = "/dashboard/spaceD";
61
+ const title = selectedSpace?.name ?? "";
62
+ const description = selectedSpace?.description ?? "List of sample data";
63
+
64
+ useEffect(() => {
65
+ setMount(false);
66
+ handleRetrieveData();
67
+ }, [collectionParam]);
68
+
69
+ const handleRetrieveData = async () => {
70
+ if (collectionParam) {
71
+ const space: Space = await getSpaceData(collectionParam);
72
+ if (space) {
73
+ if (space.structure) {
74
+ space.structure.forEach((field) => {
75
+ if (field.type === "markdown") {
76
+ field.enableImageUpload = true;
77
+ field.enableVideoUpload = true;
78
+ }
79
+ });
80
+ }
81
+ setSelectedSpace(space);
82
+ setTabs(space.extendedTabs ?? []);
83
+ setQueries(space?.additionalQuery ?? []);
84
+ if (space?.sortBy?.sortId !== "") {
85
+ setSort(space.sortBy ?? undefined);
86
+ }
87
+ }
88
+ }
89
+ if (workspaceParam) {
90
+ const workspace: any = await getWorkspaceData(workspaceParam);
91
+ if (workspace) {
92
+ setSelectedWorkspace(workspace);
93
+ const allSpaces = await getAllSpacesList(workspaceParam);
94
+ if (allSpaces) setAllWorkspaceSpace(allSpaces);
95
+ }
96
+ }
97
+ setMount(true);
98
+ };
99
+
100
+ const handleSortData = (sortValue: Sort) => {
101
+ setSort(sortValue.sortId !== "" ? sortValue : undefined);
102
+ };
103
+
104
+ const handleQueries = (queries: AdditionalQuery[]) => {
105
+ setQueries(queries);
106
+ };
107
+
108
+ const handleAddColumn = (structure: DataStructure[]) => {
109
+ const clonedSpace = JSON.parse(JSON.stringify(selectedSpace));
110
+ if (clonedSpace) {
111
+ clonedSpace["structure"] = JSON.parse(
112
+ JSON.stringify(
113
+ structure.filter((eachStructure) => eachStructure.id !== "id")
114
+ )
115
+ );
116
+ }
117
+ setSelectedSpace(clonedSpace);
118
+ dataTemplateRef.current?.handleRefresh?.();
119
+ };
120
+
121
+ const handleDrag = (dragId: string, dropId: string) => {
122
+ const selectedDS: DataStructure[] = JSON.parse(
123
+ JSON.stringify(selectedSpace?.structure ?? [])
124
+ );
125
+ const selectedIndex = selectedDS.findIndex((item) => item.id === dragId);
126
+ const [selectedItem] = selectedDS.splice(selectedIndex, 1);
127
+ const placingIndex = selectedDS.findIndex((item) => item.id === dropId);
128
+ selectedDS.splice(placingIndex, 0, selectedItem);
129
+ const clonedSpace = JSON.parse(JSON.stringify(selectedSpace));
130
+ if (clonedSpace) clonedSpace["structure"] = selectedDS;
131
+ setSelectedSpace(clonedSpace);
132
+ };
133
+
134
+ const handleHide = (valueList: DataStructure[]) => {
135
+ const clonedSpace: Space = JSON.parse(JSON.stringify(selectedSpace));
136
+ clonedSpace.structure?.map((eachStructure) => {
137
+ const selectedList = valueList.filter(
138
+ (eachValue) => eachValue.id === eachStructure.id
139
+ );
140
+ if (selectedList.length > 0) {
141
+ eachStructure.hide = selectedList[0].hide ? true : false;
142
+ }
143
+ return null;
144
+ });
145
+ setSelectedSpace(clonedSpace);
146
+ };
147
+
148
+ const handleTab = (tabValue: ExtendedTabs[]) => {
149
+ setTabs(tabValue);
150
+ };
151
+
152
+ if (!mount) {
153
+ return <Loading />;
154
+ }
155
+
156
+ const devSettings = parseWorkspaceSettings(
157
+ {
158
+ dbEndpoint: defaultDBEndpoint,
159
+ imageEndpoint: defaultImageEndpoint,
160
+ uploadEndpoint: defaultUploadEndpoint,
161
+ },
162
+ selectedWorkspace
163
+ );
164
+
165
+ return (
166
+ <>
167
+ {/*
168
+ * STORY CONTROLS
169
+ * These buttons demonstrate imperative ref methods and collection switching.
170
+ * In a real app these would be driven by routing / state management.
171
+ */}
172
+ <StorySection
173
+ title="Data Template"
174
+ description="Use DataTemplate when you have a Space object from the Blixify backend — it drives the schema, sort, tabs, and queries from the database. Pass the Space via the space prop and derive the model using parseSpaceToDataStructure. For custom integrations without a Space object, use DataTemplateWrapper instead."
175
+ >
176
+ <div className="flex flex-wrap gap-3 mb-4">
177
+ <Button
178
+ text={typeParam === "list" ? "Switch → Update" : "Switch → List"}
179
+ type="light"
180
+ onClick={() =>
181
+ setTypeParam((t) =>
182
+ t === "update" || t === "read" ? "list" : "update"
183
+ )
184
+ }
185
+ />
186
+ <Button
187
+ text="Prefill Form"
188
+ type="light"
189
+ onClick={() => {
190
+ dataTemplateRef.current?.handleUpdateSelectedData([
191
+ { key: "title", value: "Prefilled Value" },
192
+ ]);
193
+ }}
194
+ />
195
+ <Button
196
+ text="Swap Collection"
197
+ type="light"
198
+ onClick={() => {
199
+ setCollectionParams((c) =>
200
+ c === "e40bcbbf-191f-4bac-83d0-322cb4cbabde"
201
+ ? "602c90dd-ee39-4bf0-b44d-3d2c57f887cd"
202
+ : "e40bcbbf-191f-4bac-83d0-322cb4cbabde"
203
+ );
204
+ }}
205
+ />
206
+ </div>
207
+
208
+ {selectedSpace && selectedWorkspace && (
209
+ <div className="w-full">
210
+ <DataTemplate
211
+ ref={dataTemplateRef}
212
+ title={title}
213
+ description={description}
214
+ type={typeParam}
215
+ id={dataParam}
216
+ collectionId={collectionParam}
217
+ model={parseSpaceToDataStructure(selectedSpace)}
218
+ localURLEndpoint={getLocalUrl}
219
+ space={selectedSpace}
220
+ limit={30}
221
+ edit={{
222
+ allEditable: true,
223
+ listEditable: true,
224
+ listAddable: true,
225
+ deleteBtn: true,
226
+ disabledUpdate: false,
227
+ disableBatchUpdate: false,
228
+ activityLog: {
229
+ enableComments: true,
230
+ commentCollectionId: collectionParam + "-comments",
231
+ enableLogs: true,
232
+ logsCollectionId: collectionParam + "-logs",
233
+ userAPIEndpoint: "http://localhost:3000/api/data/users",
234
+ currentUserId: "3P3il3L8uScSkASU2MdAoqGs1M82",
235
+ },
236
+ }}
237
+ organise={{
238
+ sort: sort ?? undefined,
239
+ viewId: viewParam,
240
+ extendedTabs: tabs,
241
+ additionalQuery: queries,
242
+ splitView: false,
243
+ showGroupByFeature: true,
244
+ showReadFloatingNav: true,
245
+ disableMulti: false,
246
+ exportSettings: {
247
+ enableExportReadPDF: true,
248
+ exportReadPDFDimensions: {
249
+ forceDesktopView: true,
250
+ captureWidth: 1440,
251
+ captureHeight: 900,
252
+ pageSize: "a4",
253
+ scale: 2,
254
+ },
255
+ },
256
+ filterComponentNewRow: true,
257
+ addColumnEnabled: true,
258
+ advSortEnabled: true,
259
+ advFilterEnabled: true,
260
+ advDragEnabled: true,
261
+ onChangeSort: handleSortData,
262
+ onChangeFilter: handleQueries,
263
+ onChangeTabs: handleTab,
264
+ onChangeDrag: handleDrag,
265
+ onAddColumns: handleAddColumn,
266
+ onChangeHide: handleHide,
267
+ handleNavigate: (type, selectedId, viewId) => {
268
+ setTypeParam(type);
269
+ if (selectedId) setDataParam(selectedId);
270
+ if (viewId) setViewParam(viewId);
271
+ },
272
+ renderReferenceLabelOptions: storyRenderReferenceLabelOptions(
273
+ allWorkspaceSpace,
274
+ selectedSpace
275
+ ),
276
+ renderReferenceSpaceOptions: storyRenderReferenceSpaceOptions(
277
+ allWorkspaceSpace,
278
+ dataParam
279
+ ),
280
+ }}
281
+ lib={{
282
+ axios,
283
+ Menu,
284
+ Transition,
285
+ navigate: null,
286
+ papaParser: Papa,
287
+ }}
288
+ bareSettings={{
289
+ // Custom action buttons shown on each list row
290
+ bareListActionBtns: () => [
291
+ <div
292
+ key="tag"
293
+ onClick={(e) => {
294
+ e.stopPropagation();
295
+ e.preventDefault();
296
+ window.alert("Custom row action clicked!");
297
+ }}
298
+ >
299
+ <TagIcon className="w-5 h-5 text-primary-500" />
300
+ </div>,
301
+ ],
302
+ // Extra bulk-action buttons shown when rows are selected
303
+ bareListMultipleSelectAddtionalActions: [
304
+ {
305
+ text: "Custom Bulk Action",
306
+ onClick: (ids: string[]) =>
307
+ window.alert(
308
+ `Bulk action on ${ids.length} selected item(s)`
309
+ ),
310
+ },
311
+ ],
312
+ }}
313
+ devSettings={{
314
+ ...devSettings,
315
+ uploadEndpoint: defaultUploadEndpoint,
316
+ imageEndpoint: defaultImageEndpoint,
317
+ schemaEndpoint: schemaUrl,
318
+ dbAPIToken: dbAPIToken,
319
+ organisationMembers: [
320
+ { key: "3P3il3L8uScSkASU2MdAoqGs1M82", label: "Crystal" },
321
+ { key: "a2vG49kXjFg7hzzEYS5ZfJJJ43C3", label: "Chan Yi" },
322
+ { key: "qFZVckKT3tMIkxvohlVS27IWuhn1", label: "Chris" },
323
+ ],
324
+ currentUser: {
325
+ userEmail: "chanyi@blixify.co",
326
+ userName: "Chan Yi",
327
+ },
328
+ functionEndpoint:
329
+ "http://127.0.0.1:5001/blixify-space/asia-southeast1",
330
+ }}
331
+ />
332
+ </div>
333
+ )}
334
+ </StorySection>
335
+ </>
336
+ );
337
+ });