@quillsql/admin 1.6.1 → 1.6.3

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 (678) hide show
  1. package/dist/cjs/Admin.d.ts +41 -87
  2. package/dist/cjs/Admin.d.ts.map +1 -1
  3. package/dist/cjs/Admin.js +358 -456
  4. package/dist/cjs/AdminProvider.d.ts +108 -50
  5. package/dist/cjs/AdminProvider.d.ts.map +1 -1
  6. package/dist/cjs/AdminProvider.js +390 -208
  7. package/dist/cjs/api/ConnectionClient.d.ts +20 -38
  8. package/dist/cjs/api/ConnectionClient.d.ts.map +1 -1
  9. package/dist/cjs/api/ConnectionClient.js +291 -321
  10. package/dist/cjs/assets/ArrowDownHeadIcon.d.ts.map +1 -1
  11. package/dist/cjs/components/Banner/index.d.ts +0 -1
  12. package/dist/cjs/components/Banner/index.d.ts.map +1 -1
  13. package/dist/cjs/components/Banner/index.js +1 -1
  14. package/dist/cjs/components/CardSection.js +1 -1
  15. package/dist/cjs/components/CardTitle.js +1 -1
  16. package/dist/cjs/components/ClipboardButton.d.ts +8 -0
  17. package/dist/cjs/components/ClipboardButton.d.ts.map +1 -0
  18. package/dist/cjs/components/ClipboardButton.js +74 -0
  19. package/dist/cjs/components/DashboardSelectPopover.d.ts +8 -5
  20. package/dist/cjs/components/DashboardSelectPopover.d.ts.map +1 -1
  21. package/dist/cjs/components/DashboardSelectPopover.js +74 -185
  22. package/dist/cjs/components/DatabaseMismatchCard.d.ts +3 -3
  23. package/dist/cjs/components/DatabaseMismatchCard.d.ts.map +1 -1
  24. package/dist/cjs/components/DatabaseMismatchCard.js +3 -3
  25. package/dist/cjs/components/DatabaseSelector.d.ts.map +1 -1
  26. package/dist/cjs/components/DatabaseSelector.js +10 -2
  27. package/dist/cjs/components/DateRangePicker/SingleDatePicker.d.ts +10 -0
  28. package/dist/cjs/components/DateRangePicker/SingleDatePicker.d.ts.map +1 -0
  29. package/dist/cjs/components/DateRangePicker/SingleDatePicker.js +263 -0
  30. package/dist/cjs/components/DateRangePicker/YearlessDateRangePicker.d.ts +18 -0
  31. package/dist/cjs/components/DateRangePicker/YearlessDateRangePicker.d.ts.map +1 -0
  32. package/dist/cjs/components/DateRangePicker/YearlessDateRangePicker.js +288 -0
  33. package/dist/cjs/components/DateRangePicker/dateRangePickerUtils.d.ts +91 -0
  34. package/dist/cjs/components/DateRangePicker/dateRangePickerUtils.d.ts.map +1 -0
  35. package/dist/cjs/components/DateRangePicker/dateRangePickerUtils.js +898 -0
  36. package/dist/cjs/components/DeleteButton.d.ts +0 -1
  37. package/dist/cjs/components/DeleteButton.d.ts.map +1 -1
  38. package/dist/cjs/components/DeleteButton.js +1 -1
  39. package/dist/cjs/components/DropDownMenu.js +1 -1
  40. package/dist/cjs/components/DropDownMenuWithLabel.d.ts +4 -3
  41. package/dist/cjs/components/DropDownMenuWithLabel.d.ts.map +1 -1
  42. package/dist/cjs/components/DropDownMenuWithLabel.js +56 -29
  43. package/dist/cjs/components/DynamicBanner.d.ts +2 -5
  44. package/dist/cjs/components/DynamicBanner.d.ts.map +1 -1
  45. package/dist/cjs/components/DynamicBanner.js +3 -3
  46. package/dist/cjs/components/EmptyDashboardComponent/index.d.ts +0 -1
  47. package/dist/cjs/components/EmptyDashboardComponent/index.d.ts.map +1 -1
  48. package/dist/cjs/components/EmptyDashboardComponent/index.js +6 -5
  49. package/dist/cjs/components/EmptyVirtualTablesComponent.d.ts +4 -0
  50. package/dist/cjs/components/EmptyVirtualTablesComponent.d.ts.map +1 -0
  51. package/dist/cjs/components/EmptyVirtualTablesComponent.js +41 -0
  52. package/dist/cjs/components/ExternalLink.d.ts +4 -0
  53. package/dist/cjs/components/ExternalLink.d.ts.map +1 -0
  54. package/dist/cjs/components/ExternalLink.js +15 -0
  55. package/dist/cjs/components/FormTooltip.d.ts +8 -0
  56. package/dist/cjs/components/FormTooltip.d.ts.map +1 -0
  57. package/dist/cjs/components/FormTooltip.js +89 -0
  58. package/dist/cjs/components/InputLabel.d.ts +4 -1
  59. package/dist/cjs/components/InputLabel.d.ts.map +1 -1
  60. package/dist/cjs/components/InputLabel.js +13 -8
  61. package/dist/cjs/components/InternalDashboard/ChartSkeleton.d.ts +11 -0
  62. package/dist/cjs/components/InternalDashboard/ChartSkeleton.d.ts.map +1 -0
  63. package/dist/cjs/components/InternalDashboard/ChartSkeleton.js +21 -0
  64. package/dist/cjs/components/InternalDashboard/DashboardFilter.d.ts +20 -0
  65. package/dist/cjs/components/InternalDashboard/DashboardFilter.d.ts.map +1 -0
  66. package/dist/cjs/components/InternalDashboard/DashboardFilter.js +104 -0
  67. package/dist/cjs/components/InternalDashboard/DashboardLoadingComponent.d.ts +7 -0
  68. package/dist/cjs/components/InternalDashboard/DashboardLoadingComponent.d.ts.map +1 -0
  69. package/dist/cjs/components/InternalDashboard/DashboardLoadingComponent.js +22 -0
  70. package/dist/cjs/components/InternalDashboard/DateRangePicker/QuillDateRangePicker.d.ts +37 -0
  71. package/dist/cjs/components/InternalDashboard/DateRangePicker/QuillDateRangePicker.d.ts.map +1 -0
  72. package/dist/cjs/components/InternalDashboard/DateRangePicker/QuillDateRangePicker.js +275 -0
  73. package/dist/cjs/components/InternalDashboard/DateRangePicker/dateRangePickerUtils.d.ts +85 -0
  74. package/dist/cjs/components/InternalDashboard/DateRangePicker/dateRangePickerUtils.d.ts.map +1 -0
  75. package/dist/cjs/components/InternalDashboard/DateRangePicker/dateRangePickerUtils.js +534 -0
  76. package/dist/cjs/components/InternalDashboard/InternalDashboard.d.ts +17 -0
  77. package/dist/cjs/components/InternalDashboard/InternalDashboard.d.ts.map +1 -0
  78. package/dist/cjs/components/InternalDashboard/InternalDashboard.js +1947 -0
  79. package/dist/cjs/components/OrgSelect.d.ts +9 -13
  80. package/dist/cjs/components/OrgSelect.d.ts.map +1 -1
  81. package/dist/cjs/components/OrgSelect.js +136 -119
  82. package/dist/cjs/components/QuillMultiSelectWithCombo.d.ts +30 -0
  83. package/dist/cjs/components/QuillMultiSelectWithCombo.d.ts.map +1 -0
  84. package/dist/cjs/components/QuillMultiSelectWithCombo.js +504 -0
  85. package/dist/cjs/components/QuillPopover.d.ts +11 -0
  86. package/dist/cjs/components/QuillPopover.d.ts.map +1 -0
  87. package/dist/cjs/components/QuillPopover.js +180 -0
  88. package/dist/cjs/components/QuillSelect.d.ts +1 -1
  89. package/dist/cjs/components/QuillSelect.d.ts.map +1 -1
  90. package/dist/cjs/components/QuillSelect.js +38 -16
  91. package/dist/cjs/components/QuillSelectWithCombo.d.ts +22 -0
  92. package/dist/cjs/components/QuillSelectWithCombo.d.ts.map +1 -0
  93. package/dist/cjs/components/QuillSelectWithCombo.js +327 -0
  94. package/dist/cjs/components/QuillTab.d.ts +12 -0
  95. package/dist/cjs/components/QuillTab.d.ts.map +1 -0
  96. package/dist/cjs/components/QuillTab.js +84 -0
  97. package/dist/cjs/components/QuillToolTipPortal.d.ts +11 -0
  98. package/dist/cjs/components/QuillToolTipPortal.d.ts.map +1 -0
  99. package/dist/cjs/components/QuillToolTipPortal.js +108 -0
  100. package/dist/cjs/components/SegmentedControl.d.ts +8 -2
  101. package/dist/cjs/components/SegmentedControl.d.ts.map +1 -1
  102. package/dist/cjs/components/SegmentedControl.js +11 -12
  103. package/dist/cjs/components/SqlTextEditor.d.ts +2 -5
  104. package/dist/cjs/components/SqlTextEditor.d.ts.map +1 -1
  105. package/dist/cjs/components/SqlTextEditor.js +20 -19
  106. package/dist/cjs/components/StepDisplay.d.ts.map +1 -1
  107. package/dist/cjs/components/StepDisplay.js +2 -2
  108. package/dist/cjs/components/Tenants/EditTenant.d.ts +41 -0
  109. package/dist/cjs/components/Tenants/EditTenant.d.ts.map +1 -0
  110. package/dist/cjs/components/Tenants/EditTenant.js +760 -0
  111. package/dist/cjs/components/UiComponents.d.ts +35 -6
  112. package/dist/cjs/components/UiComponents.d.ts.map +1 -1
  113. package/dist/cjs/components/UiComponents.js +226 -28
  114. package/dist/cjs/components/VirtualTableTile.d.ts +7 -0
  115. package/dist/cjs/components/VirtualTableTile.d.ts.map +1 -0
  116. package/dist/cjs/components/VirtualTableTile.js +51 -0
  117. package/dist/cjs/components/index.d.ts +5 -5
  118. package/dist/cjs/components/index.d.ts.map +1 -1
  119. package/dist/cjs/components/index.js +1 -1
  120. package/dist/cjs/constants/dataTypes.d.ts.map +1 -1
  121. package/dist/cjs/constants/dataTypes.js +2 -0
  122. package/dist/cjs/forms/client_onboard/ConnectDatabase.d.ts +15 -6
  123. package/dist/cjs/forms/client_onboard/ConnectDatabase.d.ts.map +1 -1
  124. package/dist/cjs/forms/client_onboard/ConnectDatabase.js +209 -96
  125. package/dist/cjs/forms/client_onboard/ConnectSchema.d.ts +13 -9
  126. package/dist/cjs/forms/client_onboard/ConnectSchema.d.ts.map +1 -1
  127. package/dist/cjs/forms/client_onboard/ConnectSchema.js +158 -236
  128. package/dist/cjs/forms/client_onboard/CreateVirtualTables.d.ts +47 -0
  129. package/dist/cjs/forms/client_onboard/CreateVirtualTables.d.ts.map +1 -0
  130. package/dist/cjs/forms/client_onboard/CreateVirtualTables.js +396 -0
  131. package/dist/cjs/forms/client_onboard/__tests__/ConnectDatabase.test.d.ts +2 -0
  132. package/dist/cjs/forms/client_onboard/__tests__/ConnectDatabase.test.d.ts.map +1 -0
  133. package/dist/cjs/forms/client_onboard/__tests__/ConnectDatabase.test.js +571 -0
  134. package/dist/cjs/forms/client_onboard/__tests__/ConnectSchema.test.d.ts +2 -0
  135. package/dist/cjs/forms/client_onboard/__tests__/ConnectSchema.test.d.ts.map +1 -0
  136. package/dist/cjs/forms/client_onboard/__tests__/ConnectSchema.test.js +459 -0
  137. package/dist/cjs/forms/client_onboard/__tests__/CreateVirtualTables.test.d.ts +2 -0
  138. package/dist/cjs/forms/client_onboard/__tests__/CreateVirtualTables.test.d.ts.map +1 -0
  139. package/dist/cjs/forms/client_onboard/__tests__/CreateVirtualTables.test.js +385 -0
  140. package/dist/cjs/forms/virtual_tables/CreateEditVirtualTable.d.ts +20 -0
  141. package/dist/cjs/forms/virtual_tables/CreateEditVirtualTable.d.ts.map +1 -0
  142. package/dist/cjs/forms/virtual_tables/CreateEditVirtualTable.js +294 -0
  143. package/dist/cjs/hooks/useDashboardManager.d.ts +16 -0
  144. package/dist/cjs/hooks/useDashboardManager.d.ts.map +1 -0
  145. package/dist/cjs/hooks/useDashboardManager.js +113 -0
  146. package/dist/cjs/hooks/useDatabaseSchema.d.ts +5 -0
  147. package/dist/cjs/hooks/useDatabaseSchema.d.ts.map +1 -0
  148. package/dist/cjs/hooks/useDatabaseSchema.js +54 -0
  149. package/dist/cjs/hooks/useItemBeingEdited.d.ts +1 -2
  150. package/dist/cjs/hooks/useItemBeingEdited.d.ts.map +1 -1
  151. package/dist/cjs/hooks/useItemBeingEdited.js +2 -14
  152. package/dist/cjs/hooks/useOnClickOutside.d.ts +4 -1
  153. package/dist/cjs/hooks/useOnClickOutside.d.ts.map +1 -1
  154. package/dist/cjs/hooks/useOnClickOutside.js +50 -7
  155. package/dist/cjs/hooks/useTenants.d.ts +13 -0
  156. package/dist/cjs/hooks/useTenants.d.ts.map +1 -0
  157. package/dist/cjs/hooks/useTenants.js +174 -0
  158. package/dist/cjs/hooks/useThrottle.d.ts +2 -0
  159. package/dist/cjs/hooks/useThrottle.d.ts.map +1 -0
  160. package/dist/cjs/hooks/useThrottle.js +14 -0
  161. package/dist/cjs/icons/CheckCircleIcon.d.ts +5 -0
  162. package/dist/cjs/icons/CheckCircleIcon.d.ts.map +1 -0
  163. package/dist/cjs/icons/CheckCircleIcon.js +5 -0
  164. package/dist/cjs/icons/DownChevronIcon.d.ts +2 -0
  165. package/dist/cjs/icons/DownChevronIcon.d.ts.map +1 -0
  166. package/dist/cjs/icons/DownChevronIcon.js +7 -0
  167. package/dist/cjs/icons/ExclamationFilledIcon.d.ts +5 -0
  168. package/dist/cjs/icons/ExclamationFilledIcon.d.ts.map +1 -0
  169. package/dist/cjs/icons/ExclamationFilledIcon.js +5 -0
  170. package/dist/cjs/icons/ExteriorLinkIcon.d.ts +5 -0
  171. package/dist/cjs/icons/ExteriorLinkIcon.d.ts.map +1 -0
  172. package/dist/cjs/icons/ExteriorLinkIcon.js +5 -0
  173. package/dist/cjs/icons/GlobeIcon.d.ts +5 -0
  174. package/dist/cjs/icons/GlobeIcon.d.ts.map +1 -0
  175. package/dist/cjs/icons/GlobeIcon.js +15 -0
  176. package/dist/cjs/icons/InformationCircleIcon.d.ts +4 -0
  177. package/dist/cjs/icons/InformationCircleIcon.d.ts.map +1 -0
  178. package/dist/cjs/icons/InformationCircleIcon.js +7 -0
  179. package/dist/cjs/icons/LeftChevronIcon.d.ts +2 -0
  180. package/dist/cjs/icons/LeftChevronIcon.d.ts.map +1 -0
  181. package/dist/cjs/icons/LeftChevronIcon.js +7 -0
  182. package/dist/cjs/icons/QuestionMarkCircleIcon.d.ts +5 -0
  183. package/dist/cjs/icons/QuestionMarkCircleIcon.d.ts.map +1 -0
  184. package/dist/cjs/icons/QuestionMarkCircleIcon.js +5 -0
  185. package/dist/cjs/icons/RightChevronIcon.d.ts +2 -0
  186. package/dist/cjs/icons/RightChevronIcon.d.ts.map +1 -0
  187. package/dist/cjs/icons/RightChevronIcon.js +7 -0
  188. package/dist/cjs/icons/XMarkIcon.d.ts +0 -1
  189. package/dist/cjs/icons/XMarkIcon.d.ts.map +1 -1
  190. package/dist/cjs/icons/XMarkIcon.js +1 -1
  191. package/dist/cjs/index.d.ts +2 -3
  192. package/dist/cjs/index.d.ts.map +1 -1
  193. package/dist/cjs/index.js +6 -7
  194. package/dist/cjs/modals/CodePreview.d.ts +6 -0
  195. package/dist/cjs/modals/CodePreview.d.ts.map +1 -0
  196. package/dist/cjs/modals/CodePreview.js +151 -0
  197. package/dist/cjs/modals/EditEnvironmentModal.d.ts +15 -0
  198. package/dist/cjs/modals/EditEnvironmentModal.d.ts.map +1 -0
  199. package/dist/cjs/modals/EditEnvironmentModal.js +551 -0
  200. package/dist/cjs/modals/EditFiltersModal.d.ts +14 -10
  201. package/dist/cjs/modals/EditFiltersModal.d.ts.map +1 -1
  202. package/dist/cjs/modals/EditFiltersModal.js +1219 -263
  203. package/dist/cjs/modals/NewDashboardModal.d.ts +6 -8
  204. package/dist/cjs/modals/NewDashboardModal.d.ts.map +1 -1
  205. package/dist/cjs/modals/NewDashboardModal.js +147 -146
  206. package/dist/cjs/modals/PromoteDashboardModal.d.ts +16 -0
  207. package/dist/cjs/modals/PromoteDashboardModal.d.ts.map +1 -0
  208. package/dist/cjs/modals/PromoteDashboardModal.js +56 -0
  209. package/dist/cjs/modals/PromoteReportModal.d.ts +15 -0
  210. package/dist/cjs/modals/PromoteReportModal.d.ts.map +1 -0
  211. package/dist/cjs/modals/PromoteReportModal.js +128 -0
  212. package/dist/cjs/modals/PromoteViewModal.d.ts +5 -5
  213. package/dist/cjs/modals/PromoteViewModal.d.ts.map +1 -1
  214. package/dist/cjs/modals/PromoteViewModal.js +58 -94
  215. package/dist/cjs/modals/ReorderDashboardModal.d.ts +1 -2
  216. package/dist/cjs/modals/ReorderDashboardModal.d.ts.map +1 -1
  217. package/dist/cjs/modals/ReorderDashboardModal.js +34 -20
  218. package/dist/cjs/modals/SavedQueriesModal.d.ts +7 -0
  219. package/dist/cjs/modals/SavedQueriesModal.d.ts.map +1 -0
  220. package/dist/cjs/modals/SavedQueriesModal.js +128 -0
  221. package/dist/cjs/modals/index.d.ts +0 -1
  222. package/dist/cjs/modals/index.d.ts.map +1 -1
  223. package/dist/cjs/modals/index.js +1 -3
  224. package/dist/cjs/primitives/ButtonPrimitive.d.ts +3 -1
  225. package/dist/cjs/primitives/ButtonPrimitive.d.ts.map +1 -1
  226. package/dist/cjs/primitives/ButtonPrimitive.js +24 -16
  227. package/dist/cjs/primitives/CheckboxPrimitive.d.ts +12 -0
  228. package/dist/cjs/primitives/CheckboxPrimitive.d.ts.map +1 -0
  229. package/dist/cjs/primitives/CheckboxPrimitive.js +29 -0
  230. package/dist/cjs/primitives/HeaderPrimitive.d.ts.map +1 -1
  231. package/dist/cjs/primitives/HeaderPrimitive.js +1 -1
  232. package/dist/cjs/primitives/MiniButtonPrimitive.d.ts +7 -0
  233. package/dist/cjs/primitives/MiniButtonPrimitive.d.ts.map +1 -0
  234. package/dist/cjs/primitives/MiniButtonPrimitive.js +56 -0
  235. package/dist/cjs/primitives/ModalPrimitive.d.ts +2 -10
  236. package/dist/cjs/primitives/ModalPrimitive.d.ts.map +1 -1
  237. package/dist/cjs/primitives/ModalPrimitive.js +6 -6
  238. package/dist/cjs/primitives/PlaceholderPrimitive.d.ts +5 -0
  239. package/dist/cjs/primitives/PlaceholderPrimitive.d.ts.map +1 -0
  240. package/dist/cjs/primitives/PlaceholderPrimitive.js +18 -0
  241. package/dist/cjs/primitives/PopoverPrimitive.d.ts +8 -0
  242. package/dist/cjs/primitives/PopoverPrimitive.d.ts.map +1 -0
  243. package/dist/cjs/primitives/PopoverPrimitive.js +53 -0
  244. package/dist/cjs/primitives/SecondaryButtonPrimitive.d.ts +3 -1
  245. package/dist/cjs/primitives/SecondaryButtonPrimitive.d.ts.map +1 -1
  246. package/dist/cjs/primitives/SecondaryButtonPrimitive.js +13 -10
  247. package/dist/cjs/primitives/TextInputPrimitive.d.ts +7 -2
  248. package/dist/cjs/primitives/TextInputPrimitive.d.ts.map +1 -1
  249. package/dist/cjs/primitives/TextInputPrimitive.js +109 -14
  250. package/dist/cjs/primitives/TogglePrimitive.d.ts +6 -3
  251. package/dist/cjs/primitives/TogglePrimitive.d.ts.map +1 -1
  252. package/dist/cjs/primitives/TogglePrimitive.js +10 -7
  253. package/dist/cjs/primitives/index.d.ts +1 -1
  254. package/dist/cjs/primitives/index.d.ts.map +1 -1
  255. package/dist/cjs/primitives/index.js +3 -3
  256. package/dist/cjs/public_components/ChartQueryBuilder.d.ts +9 -0
  257. package/dist/cjs/public_components/ChartQueryBuilder.d.ts.map +1 -0
  258. package/dist/cjs/public_components/ChartQueryBuilder.js +131 -0
  259. package/dist/cjs/public_components/CreateEnvironment.d.ts +1 -1
  260. package/dist/cjs/public_components/CreateEnvironment.d.ts.map +1 -1
  261. package/dist/cjs/public_components/CreateEnvironment.js +168 -81
  262. package/dist/cjs/public_components/DashboardManager.d.ts +2 -2
  263. package/dist/cjs/public_components/DashboardManager.d.ts.map +1 -1
  264. package/dist/cjs/public_components/DashboardManager.js +346 -187
  265. package/dist/cjs/public_components/EnvSelectPopover.d.ts +12 -0
  266. package/dist/cjs/public_components/EnvSelectPopover.d.ts.map +1 -0
  267. package/dist/cjs/public_components/EnvSelectPopover.js +144 -0
  268. package/dist/cjs/public_components/{SQLViewManager.d.ts → VirtualTableManager.d.ts} +3 -2
  269. package/dist/cjs/public_components/VirtualTableManager.d.ts.map +1 -0
  270. package/dist/cjs/public_components/VirtualTableManager.js +731 -0
  271. package/dist/cjs/public_components/__tests__/CreateEnvironment.test.d.ts +2 -0
  272. package/dist/cjs/public_components/__tests__/CreateEnvironment.test.d.ts.map +1 -0
  273. package/dist/cjs/public_components/__tests__/CreateEnvironment.test.js +685 -0
  274. package/dist/cjs/utils/astProcessing.d.ts +14 -1
  275. package/dist/cjs/utils/astProcessing.d.ts.map +1 -1
  276. package/dist/cjs/utils/astProcessing.js +72 -8
  277. package/dist/cjs/utils/astProcessing.uspec.js +7 -3
  278. package/dist/cjs/utils/columnProcessing.d.ts +12 -0
  279. package/dist/cjs/utils/columnProcessing.d.ts.map +1 -1
  280. package/dist/cjs/utils/columnProcessing.js +173 -7
  281. package/dist/cjs/utils/constants.d.ts +4 -21
  282. package/dist/cjs/utils/constants.d.ts.map +1 -1
  283. package/dist/cjs/utils/constants.js +20 -11
  284. package/dist/cjs/utils/dataEditor.d.ts +4 -3
  285. package/dist/cjs/utils/dataEditor.d.ts.map +1 -1
  286. package/dist/cjs/utils/dataEditor.js +69 -121
  287. package/dist/cjs/utils/dataFetcher.d.ts +20 -2
  288. package/dist/cjs/utils/dataFetcher.d.ts.map +1 -1
  289. package/dist/cjs/utils/dataFetcher.js +46 -56
  290. package/dist/cjs/utils/databases.d.ts +20 -8
  291. package/dist/cjs/utils/databases.d.ts.map +1 -1
  292. package/dist/cjs/utils/databases.js +63 -24
  293. package/dist/cjs/utils/filter.d.ts +222 -0
  294. package/dist/cjs/utils/filter.d.ts.map +1 -0
  295. package/dist/cjs/utils/filter.js +347 -0
  296. package/dist/cjs/utils/monacoAutocomplete.d.ts +2 -1
  297. package/dist/cjs/utils/monacoAutocomplete.d.ts.map +1 -1
  298. package/dist/cjs/utils/monacoAutocomplete.js +149 -44
  299. package/dist/cjs/utils/report.d.ts +120 -0
  300. package/dist/cjs/utils/report.d.ts.map +1 -0
  301. package/dist/cjs/utils/report.js +109 -0
  302. package/dist/cjs/utils/schema.d.ts +41 -29
  303. package/dist/cjs/utils/schema.d.ts.map +1 -1
  304. package/dist/cjs/utils/schema.js +137 -91
  305. package/dist/cjs/utils/table.d.ts +70 -4
  306. package/dist/cjs/utils/table.d.ts.map +1 -1
  307. package/dist/cjs/utils/tenants.d.ts +48 -0
  308. package/dist/cjs/utils/tenants.d.ts.map +1 -0
  309. package/dist/cjs/utils/tenants.js +37 -0
  310. package/dist/cjs/utils/textProcessing.js +1 -2
  311. package/dist/cjs/utils/ui.d.ts +2 -0
  312. package/dist/cjs/utils/ui.d.ts.map +1 -0
  313. package/dist/cjs/utils/ui.js +18 -0
  314. package/dist/cjs/utils/validation.d.ts +2 -0
  315. package/dist/cjs/utils/validation.d.ts.map +1 -0
  316. package/dist/cjs/utils/validation.js +77 -0
  317. package/dist/cjs/utils/validation.uspec.d.ts +2 -0
  318. package/dist/cjs/utils/validation.uspec.d.ts.map +1 -0
  319. package/dist/cjs/utils/validation.uspec.js +53 -0
  320. package/dist/esm/Admin.d.ts +41 -87
  321. package/dist/esm/Admin.d.ts.map +1 -1
  322. package/dist/esm/Admin.js +355 -422
  323. package/dist/esm/AdminProvider.d.ts +108 -50
  324. package/dist/esm/AdminProvider.d.ts.map +1 -1
  325. package/dist/esm/AdminProvider.js +390 -209
  326. package/dist/esm/api/ConnectionClient.d.ts +20 -38
  327. package/dist/esm/api/ConnectionClient.d.ts.map +1 -1
  328. package/dist/esm/api/ConnectionClient.js +280 -306
  329. package/dist/esm/assets/ArrowDownHeadIcon.d.ts.map +1 -1
  330. package/dist/esm/components/Banner/index.d.ts +0 -1
  331. package/dist/esm/components/Banner/index.d.ts.map +1 -1
  332. package/dist/esm/components/ClipboardButton.d.ts +8 -0
  333. package/dist/esm/components/ClipboardButton.d.ts.map +1 -0
  334. package/dist/esm/components/ClipboardButton.js +69 -0
  335. package/dist/esm/components/DashboardSelectPopover.d.ts +8 -5
  336. package/dist/esm/components/DashboardSelectPopover.d.ts.map +1 -1
  337. package/dist/esm/components/DashboardSelectPopover.js +72 -186
  338. package/dist/esm/components/DatabaseMismatchCard.d.ts +3 -3
  339. package/dist/esm/components/DatabaseMismatchCard.d.ts.map +1 -1
  340. package/dist/esm/components/DatabaseMismatchCard.js +2 -2
  341. package/dist/esm/components/DatabaseSelector.d.ts.map +1 -1
  342. package/dist/esm/components/DatabaseSelector.js +9 -1
  343. package/dist/esm/components/DateRangePicker/SingleDatePicker.d.ts +10 -0
  344. package/dist/esm/components/DateRangePicker/SingleDatePicker.d.ts.map +1 -0
  345. package/dist/esm/components/DateRangePicker/SingleDatePicker.js +227 -0
  346. package/dist/esm/components/DateRangePicker/YearlessDateRangePicker.d.ts +18 -0
  347. package/dist/esm/components/DateRangePicker/YearlessDateRangePicker.d.ts.map +1 -0
  348. package/dist/esm/components/DateRangePicker/YearlessDateRangePicker.js +282 -0
  349. package/dist/esm/components/DateRangePicker/dateRangePickerUtils.d.ts +91 -0
  350. package/dist/esm/components/DateRangePicker/dateRangePickerUtils.d.ts.map +1 -0
  351. package/dist/esm/components/DateRangePicker/dateRangePickerUtils.js +883 -0
  352. package/dist/esm/components/DeleteButton.d.ts +0 -1
  353. package/dist/esm/components/DeleteButton.d.ts.map +1 -1
  354. package/dist/esm/components/DropDownMenuWithLabel.d.ts +4 -3
  355. package/dist/esm/components/DropDownMenuWithLabel.d.ts.map +1 -1
  356. package/dist/esm/components/DropDownMenuWithLabel.js +37 -23
  357. package/dist/esm/components/DynamicBanner.d.ts +2 -5
  358. package/dist/esm/components/DynamicBanner.d.ts.map +1 -1
  359. package/dist/esm/components/DynamicBanner.js +2 -2
  360. package/dist/esm/components/EmptyDashboardComponent/index.d.ts +0 -1
  361. package/dist/esm/components/EmptyDashboardComponent/index.d.ts.map +1 -1
  362. package/dist/esm/components/EmptyDashboardComponent/index.js +5 -4
  363. package/dist/esm/components/EmptyVirtualTablesComponent.d.ts +4 -0
  364. package/dist/esm/components/EmptyVirtualTablesComponent.d.ts.map +1 -0
  365. package/dist/esm/components/EmptyVirtualTablesComponent.js +38 -0
  366. package/dist/esm/components/ExternalLink.d.ts +4 -0
  367. package/dist/esm/components/ExternalLink.d.ts.map +1 -0
  368. package/dist/esm/components/ExternalLink.js +9 -0
  369. package/dist/esm/components/FormTooltip.d.ts +8 -0
  370. package/dist/esm/components/FormTooltip.d.ts.map +1 -0
  371. package/dist/esm/components/FormTooltip.js +84 -0
  372. package/dist/esm/components/InputLabel.d.ts +4 -1
  373. package/dist/esm/components/InputLabel.d.ts.map +1 -1
  374. package/dist/esm/components/InputLabel.js +10 -8
  375. package/dist/esm/components/InternalDashboard/ChartSkeleton.d.ts +11 -0
  376. package/dist/esm/components/InternalDashboard/ChartSkeleton.d.ts.map +1 -0
  377. package/dist/esm/components/InternalDashboard/ChartSkeleton.js +16 -0
  378. package/dist/esm/components/InternalDashboard/DashboardFilter.d.ts +20 -0
  379. package/dist/esm/components/InternalDashboard/DashboardFilter.d.ts.map +1 -0
  380. package/dist/esm/components/InternalDashboard/DashboardFilter.js +101 -0
  381. package/dist/esm/components/InternalDashboard/DashboardLoadingComponent.d.ts +7 -0
  382. package/dist/esm/components/InternalDashboard/DashboardLoadingComponent.d.ts.map +1 -0
  383. package/dist/esm/components/InternalDashboard/DashboardLoadingComponent.js +15 -0
  384. package/dist/esm/components/InternalDashboard/DateRangePicker/QuillDateRangePicker.d.ts +37 -0
  385. package/dist/esm/components/InternalDashboard/DateRangePicker/QuillDateRangePicker.d.ts.map +1 -0
  386. package/dist/esm/components/InternalDashboard/DateRangePicker/QuillDateRangePicker.js +269 -0
  387. package/dist/esm/components/InternalDashboard/DateRangePicker/dateRangePickerUtils.d.ts +85 -0
  388. package/dist/esm/components/InternalDashboard/DateRangePicker/dateRangePickerUtils.d.ts.map +1 -0
  389. package/dist/esm/components/InternalDashboard/DateRangePicker/dateRangePickerUtils.js +520 -0
  390. package/dist/esm/components/InternalDashboard/InternalDashboard.d.ts +17 -0
  391. package/dist/esm/components/InternalDashboard/InternalDashboard.d.ts.map +1 -0
  392. package/dist/esm/components/InternalDashboard/InternalDashboard.js +1940 -0
  393. package/dist/esm/components/OrgSelect.d.ts +9 -13
  394. package/dist/esm/components/OrgSelect.d.ts.map +1 -1
  395. package/dist/esm/components/OrgSelect.js +134 -117
  396. package/dist/esm/components/QuillMultiSelectWithCombo.d.ts +30 -0
  397. package/dist/esm/components/QuillMultiSelectWithCombo.d.ts.map +1 -0
  398. package/dist/esm/components/QuillMultiSelectWithCombo.js +466 -0
  399. package/dist/esm/components/QuillPopover.d.ts +11 -0
  400. package/dist/esm/components/QuillPopover.d.ts.map +1 -0
  401. package/dist/esm/components/QuillPopover.js +144 -0
  402. package/dist/esm/components/QuillSelect.d.ts +1 -1
  403. package/dist/esm/components/QuillSelect.d.ts.map +1 -1
  404. package/dist/esm/components/QuillSelect.js +39 -16
  405. package/dist/esm/components/QuillSelectWithCombo.d.ts +22 -0
  406. package/dist/esm/components/QuillSelectWithCombo.d.ts.map +1 -0
  407. package/dist/esm/components/QuillSelectWithCombo.js +291 -0
  408. package/dist/esm/components/QuillTab.d.ts +12 -0
  409. package/dist/esm/components/QuillTab.d.ts.map +1 -0
  410. package/dist/esm/components/QuillTab.js +81 -0
  411. package/dist/esm/components/QuillToolTipPortal.d.ts +11 -0
  412. package/dist/esm/components/QuillToolTipPortal.d.ts.map +1 -0
  413. package/dist/esm/components/QuillToolTipPortal.js +104 -0
  414. package/dist/esm/components/SegmentedControl.d.ts +8 -2
  415. package/dist/esm/components/SegmentedControl.d.ts.map +1 -1
  416. package/dist/esm/components/SegmentedControl.js +10 -10
  417. package/dist/esm/components/SqlTextEditor.d.ts +2 -5
  418. package/dist/esm/components/SqlTextEditor.d.ts.map +1 -1
  419. package/dist/esm/components/SqlTextEditor.js +21 -20
  420. package/dist/esm/components/StepDisplay.d.ts.map +1 -1
  421. package/dist/esm/components/StepDisplay.js +1 -1
  422. package/dist/esm/components/Tenants/EditTenant.d.ts +41 -0
  423. package/dist/esm/components/Tenants/EditTenant.d.ts.map +1 -0
  424. package/dist/esm/components/Tenants/EditTenant.js +754 -0
  425. package/dist/esm/components/UiComponents.d.ts +35 -6
  426. package/dist/esm/components/UiComponents.d.ts.map +1 -1
  427. package/dist/esm/components/UiComponents.js +220 -26
  428. package/dist/esm/components/VirtualTableTile.d.ts +7 -0
  429. package/dist/esm/components/VirtualTableTile.d.ts.map +1 -0
  430. package/dist/esm/components/VirtualTableTile.js +48 -0
  431. package/dist/esm/components/index.d.ts +5 -5
  432. package/dist/esm/components/index.d.ts.map +1 -1
  433. package/dist/esm/components/index.js +5 -5
  434. package/dist/esm/constants/dataTypes.d.ts.map +1 -1
  435. package/dist/esm/constants/dataTypes.js +2 -0
  436. package/dist/esm/forms/client_onboard/ConnectDatabase.d.ts +15 -6
  437. package/dist/esm/forms/client_onboard/ConnectDatabase.d.ts.map +1 -1
  438. package/dist/esm/forms/client_onboard/ConnectDatabase.js +211 -98
  439. package/dist/esm/forms/client_onboard/ConnectSchema.d.ts +13 -9
  440. package/dist/esm/forms/client_onboard/ConnectSchema.d.ts.map +1 -1
  441. package/dist/esm/forms/client_onboard/ConnectSchema.js +160 -238
  442. package/dist/esm/forms/client_onboard/CreateVirtualTables.d.ts +47 -0
  443. package/dist/esm/forms/client_onboard/CreateVirtualTables.d.ts.map +1 -0
  444. package/dist/esm/forms/client_onboard/CreateVirtualTables.js +388 -0
  445. package/dist/esm/forms/client_onboard/__tests__/ConnectDatabase.test.d.ts +2 -0
  446. package/dist/esm/forms/client_onboard/__tests__/ConnectDatabase.test.d.ts.map +1 -0
  447. package/dist/esm/forms/client_onboard/__tests__/ConnectDatabase.test.js +566 -0
  448. package/dist/esm/forms/client_onboard/__tests__/ConnectSchema.test.d.ts +2 -0
  449. package/dist/esm/forms/client_onboard/__tests__/ConnectSchema.test.d.ts.map +1 -0
  450. package/dist/esm/forms/client_onboard/__tests__/ConnectSchema.test.js +454 -0
  451. package/dist/esm/forms/client_onboard/__tests__/CreateVirtualTables.test.d.ts +2 -0
  452. package/dist/esm/forms/client_onboard/__tests__/CreateVirtualTables.test.d.ts.map +1 -0
  453. package/dist/esm/forms/client_onboard/__tests__/CreateVirtualTables.test.js +380 -0
  454. package/dist/esm/forms/virtual_tables/CreateEditVirtualTable.d.ts +20 -0
  455. package/dist/esm/forms/virtual_tables/CreateEditVirtualTable.d.ts.map +1 -0
  456. package/dist/esm/forms/virtual_tables/CreateEditVirtualTable.js +288 -0
  457. package/dist/esm/hooks/useDashboardManager.d.ts +16 -0
  458. package/dist/esm/hooks/useDashboardManager.d.ts.map +1 -0
  459. package/dist/esm/hooks/useDashboardManager.js +109 -0
  460. package/dist/esm/hooks/useDatabaseSchema.d.ts +5 -0
  461. package/dist/esm/hooks/useDatabaseSchema.d.ts.map +1 -0
  462. package/dist/esm/hooks/useDatabaseSchema.js +50 -0
  463. package/dist/esm/hooks/useItemBeingEdited.d.ts +1 -2
  464. package/dist/esm/hooks/useItemBeingEdited.d.ts.map +1 -1
  465. package/dist/esm/hooks/useItemBeingEdited.js +3 -15
  466. package/dist/esm/hooks/useOnClickOutside.d.ts +4 -1
  467. package/dist/esm/hooks/useOnClickOutside.d.ts.map +1 -1
  468. package/dist/esm/hooks/useOnClickOutside.js +49 -8
  469. package/dist/esm/hooks/useTenants.d.ts +13 -0
  470. package/dist/esm/hooks/useTenants.d.ts.map +1 -0
  471. package/dist/esm/hooks/useTenants.js +170 -0
  472. package/dist/esm/hooks/useThrottle.d.ts +2 -0
  473. package/dist/esm/hooks/useThrottle.d.ts.map +1 -0
  474. package/dist/esm/hooks/useThrottle.js +11 -0
  475. package/dist/esm/icons/CheckCircleIcon.d.ts +5 -0
  476. package/dist/esm/icons/CheckCircleIcon.d.ts.map +1 -0
  477. package/dist/esm/icons/CheckCircleIcon.js +3 -0
  478. package/dist/esm/icons/DownChevronIcon.d.ts +2 -0
  479. package/dist/esm/icons/DownChevronIcon.d.ts.map +1 -0
  480. package/dist/esm/icons/DownChevronIcon.js +4 -0
  481. package/dist/esm/icons/ExclamationFilledIcon.d.ts +5 -0
  482. package/dist/esm/icons/ExclamationFilledIcon.d.ts.map +1 -0
  483. package/dist/esm/icons/ExclamationFilledIcon.js +3 -0
  484. package/dist/esm/icons/ExteriorLinkIcon.d.ts +5 -0
  485. package/dist/esm/icons/ExteriorLinkIcon.d.ts.map +1 -0
  486. package/dist/esm/icons/ExteriorLinkIcon.js +3 -0
  487. package/dist/esm/icons/GlobeIcon.d.ts +5 -0
  488. package/dist/esm/icons/GlobeIcon.d.ts.map +1 -0
  489. package/dist/esm/icons/GlobeIcon.js +12 -0
  490. package/dist/esm/icons/InformationCircleIcon.d.ts +4 -0
  491. package/dist/esm/icons/InformationCircleIcon.d.ts.map +1 -0
  492. package/dist/esm/icons/InformationCircleIcon.js +4 -0
  493. package/dist/esm/icons/LeftChevronIcon.d.ts +2 -0
  494. package/dist/esm/icons/LeftChevronIcon.d.ts.map +1 -0
  495. package/dist/esm/icons/LeftChevronIcon.js +4 -0
  496. package/dist/esm/icons/QuestionMarkCircleIcon.d.ts +5 -0
  497. package/dist/esm/icons/QuestionMarkCircleIcon.d.ts.map +1 -0
  498. package/dist/esm/icons/QuestionMarkCircleIcon.js +3 -0
  499. package/dist/esm/icons/RightChevronIcon.d.ts +2 -0
  500. package/dist/esm/icons/RightChevronIcon.d.ts.map +1 -0
  501. package/dist/esm/icons/RightChevronIcon.js +4 -0
  502. package/dist/esm/icons/XMarkIcon.d.ts +0 -1
  503. package/dist/esm/icons/XMarkIcon.d.ts.map +1 -1
  504. package/dist/esm/index.d.ts +2 -3
  505. package/dist/esm/index.d.ts.map +1 -1
  506. package/dist/esm/index.js +3 -3
  507. package/dist/esm/modals/CodePreview.d.ts +6 -0
  508. package/dist/esm/modals/CodePreview.d.ts.map +1 -0
  509. package/dist/esm/modals/CodePreview.js +145 -0
  510. package/dist/esm/modals/EditEnvironmentModal.d.ts +15 -0
  511. package/dist/esm/modals/EditEnvironmentModal.d.ts.map +1 -0
  512. package/dist/esm/modals/EditEnvironmentModal.js +545 -0
  513. package/dist/esm/modals/EditFiltersModal.d.ts +14 -10
  514. package/dist/esm/modals/EditFiltersModal.d.ts.map +1 -1
  515. package/dist/esm/modals/EditFiltersModal.js +1226 -264
  516. package/dist/esm/modals/NewDashboardModal.d.ts +6 -8
  517. package/dist/esm/modals/NewDashboardModal.d.ts.map +1 -1
  518. package/dist/esm/modals/NewDashboardModal.js +148 -146
  519. package/dist/esm/modals/PromoteDashboardModal.d.ts +16 -0
  520. package/dist/esm/modals/PromoteDashboardModal.d.ts.map +1 -0
  521. package/dist/esm/modals/PromoteDashboardModal.js +53 -0
  522. package/dist/esm/modals/PromoteReportModal.d.ts +15 -0
  523. package/dist/esm/modals/PromoteReportModal.d.ts.map +1 -0
  524. package/dist/esm/modals/PromoteReportModal.js +125 -0
  525. package/dist/esm/modals/PromoteViewModal.d.ts +5 -5
  526. package/dist/esm/modals/PromoteViewModal.d.ts.map +1 -1
  527. package/dist/esm/modals/PromoteViewModal.js +58 -94
  528. package/dist/esm/modals/ReorderDashboardModal.d.ts +1 -2
  529. package/dist/esm/modals/ReorderDashboardModal.d.ts.map +1 -1
  530. package/dist/esm/modals/ReorderDashboardModal.js +34 -20
  531. package/dist/esm/modals/SavedQueriesModal.d.ts +7 -0
  532. package/dist/esm/modals/SavedQueriesModal.d.ts.map +1 -0
  533. package/dist/esm/modals/SavedQueriesModal.js +125 -0
  534. package/dist/esm/modals/index.d.ts +0 -1
  535. package/dist/esm/modals/index.d.ts.map +1 -1
  536. package/dist/esm/modals/index.js +0 -1
  537. package/dist/esm/primitives/ButtonPrimitive.d.ts +3 -1
  538. package/dist/esm/primitives/ButtonPrimitive.d.ts.map +1 -1
  539. package/dist/esm/primitives/ButtonPrimitive.js +25 -17
  540. package/dist/esm/primitives/CheckboxPrimitive.d.ts +12 -0
  541. package/dist/esm/primitives/CheckboxPrimitive.d.ts.map +1 -0
  542. package/dist/esm/primitives/CheckboxPrimitive.js +27 -0
  543. package/dist/esm/primitives/HeaderPrimitive.d.ts.map +1 -1
  544. package/dist/esm/primitives/HeaderPrimitive.js +1 -1
  545. package/dist/esm/primitives/MiniButtonPrimitive.d.ts +7 -0
  546. package/dist/esm/primitives/MiniButtonPrimitive.d.ts.map +1 -0
  547. package/dist/esm/primitives/MiniButtonPrimitive.js +54 -0
  548. package/dist/esm/primitives/ModalPrimitive.d.ts +2 -10
  549. package/dist/esm/primitives/ModalPrimitive.d.ts.map +1 -1
  550. package/dist/esm/primitives/ModalPrimitive.js +7 -7
  551. package/dist/esm/primitives/PlaceholderPrimitive.d.ts +5 -0
  552. package/dist/esm/primitives/PlaceholderPrimitive.d.ts.map +1 -0
  553. package/dist/esm/primitives/PlaceholderPrimitive.js +15 -0
  554. package/dist/esm/primitives/PopoverPrimitive.d.ts +8 -0
  555. package/dist/esm/primitives/PopoverPrimitive.d.ts.map +1 -0
  556. package/dist/esm/primitives/PopoverPrimitive.js +49 -0
  557. package/dist/esm/primitives/SecondaryButtonPrimitive.d.ts +3 -1
  558. package/dist/esm/primitives/SecondaryButtonPrimitive.d.ts.map +1 -1
  559. package/dist/esm/primitives/SecondaryButtonPrimitive.js +14 -11
  560. package/dist/esm/primitives/TextInputPrimitive.d.ts +7 -2
  561. package/dist/esm/primitives/TextInputPrimitive.d.ts.map +1 -1
  562. package/dist/esm/primitives/TextInputPrimitive.js +77 -12
  563. package/dist/esm/primitives/TogglePrimitive.d.ts +6 -3
  564. package/dist/esm/primitives/TogglePrimitive.d.ts.map +1 -1
  565. package/dist/esm/primitives/TogglePrimitive.js +10 -7
  566. package/dist/esm/primitives/index.d.ts +1 -1
  567. package/dist/esm/primitives/index.d.ts.map +1 -1
  568. package/dist/esm/primitives/index.js +1 -1
  569. package/dist/esm/public_components/ChartQueryBuilder.d.ts +9 -0
  570. package/dist/esm/public_components/ChartQueryBuilder.d.ts.map +1 -0
  571. package/dist/esm/public_components/ChartQueryBuilder.js +125 -0
  572. package/dist/esm/public_components/CreateEnvironment.d.ts +1 -1
  573. package/dist/esm/public_components/CreateEnvironment.d.ts.map +1 -1
  574. package/dist/esm/public_components/CreateEnvironment.js +152 -75
  575. package/dist/esm/public_components/DashboardManager.d.ts +2 -2
  576. package/dist/esm/public_components/DashboardManager.d.ts.map +1 -1
  577. package/dist/esm/public_components/DashboardManager.js +350 -191
  578. package/dist/esm/public_components/EnvSelectPopover.d.ts +12 -0
  579. package/dist/esm/public_components/EnvSelectPopover.d.ts.map +1 -0
  580. package/dist/esm/public_components/EnvSelectPopover.js +138 -0
  581. package/dist/esm/public_components/{SQLViewManager.d.ts → VirtualTableManager.d.ts} +3 -2
  582. package/dist/esm/public_components/VirtualTableManager.d.ts.map +1 -0
  583. package/dist/esm/public_components/VirtualTableManager.js +723 -0
  584. package/dist/esm/public_components/__tests__/CreateEnvironment.test.d.ts +2 -0
  585. package/dist/esm/public_components/__tests__/CreateEnvironment.test.d.ts.map +1 -0
  586. package/dist/esm/public_components/__tests__/CreateEnvironment.test.js +680 -0
  587. package/dist/esm/utils/astProcessing.d.ts +14 -1
  588. package/dist/esm/utils/astProcessing.d.ts.map +1 -1
  589. package/dist/esm/utils/astProcessing.js +67 -6
  590. package/dist/esm/utils/astProcessing.uspec.js +8 -4
  591. package/dist/esm/utils/columnProcessing.d.ts +12 -0
  592. package/dist/esm/utils/columnProcessing.d.ts.map +1 -1
  593. package/dist/esm/utils/columnProcessing.js +167 -4
  594. package/dist/esm/utils/constants.d.ts +4 -21
  595. package/dist/esm/utils/constants.d.ts.map +1 -1
  596. package/dist/esm/utils/constants.js +18 -9
  597. package/dist/esm/utils/dataEditor.d.ts +4 -3
  598. package/dist/esm/utils/dataEditor.d.ts.map +1 -1
  599. package/dist/esm/utils/dataEditor.js +65 -117
  600. package/dist/esm/utils/dataFetcher.d.ts +20 -2
  601. package/dist/esm/utils/dataFetcher.d.ts.map +1 -1
  602. package/dist/esm/utils/dataFetcher.js +44 -53
  603. package/dist/esm/utils/databases.d.ts +20 -8
  604. package/dist/esm/utils/databases.d.ts.map +1 -1
  605. package/dist/esm/utils/databases.js +60 -21
  606. package/dist/esm/utils/filter.d.ts +222 -0
  607. package/dist/esm/utils/filter.d.ts.map +1 -0
  608. package/dist/esm/utils/filter.js +343 -0
  609. package/dist/esm/utils/monacoAutocomplete.d.ts +2 -1
  610. package/dist/esm/utils/monacoAutocomplete.d.ts.map +1 -1
  611. package/dist/esm/utils/monacoAutocomplete.js +146 -41
  612. package/dist/esm/utils/report.d.ts +120 -0
  613. package/dist/esm/utils/report.d.ts.map +1 -0
  614. package/dist/esm/utils/report.js +106 -0
  615. package/dist/esm/utils/schema.d.ts +41 -29
  616. package/dist/esm/utils/schema.d.ts.map +1 -1
  617. package/dist/esm/utils/schema.js +133 -88
  618. package/dist/esm/utils/table.d.ts +70 -4
  619. package/dist/esm/utils/table.d.ts.map +1 -1
  620. package/dist/esm/utils/tenants.d.ts +48 -0
  621. package/dist/esm/utils/tenants.d.ts.map +1 -0
  622. package/dist/esm/utils/tenants.js +31 -0
  623. package/dist/esm/utils/ui.d.ts +2 -0
  624. package/dist/esm/utils/ui.d.ts.map +1 -0
  625. package/dist/esm/utils/ui.js +14 -0
  626. package/dist/esm/utils/validation.d.ts +2 -0
  627. package/dist/esm/utils/validation.d.ts.map +1 -0
  628. package/dist/esm/utils/validation.js +74 -0
  629. package/dist/esm/utils/validation.uspec.d.ts +2 -0
  630. package/dist/esm/utils/validation.uspec.d.ts.map +1 -0
  631. package/dist/esm/utils/validation.uspec.js +51 -0
  632. package/package.json +22 -9
  633. package/dist/cjs/components/EnvSelectPopover.d.ts +0 -13
  634. package/dist/cjs/components/EnvSelectPopover.d.ts.map +0 -1
  635. package/dist/cjs/components/EnvSelectPopover.js +0 -224
  636. package/dist/cjs/components/SqlViewTile.d.ts +0 -8
  637. package/dist/cjs/components/SqlViewTile.d.ts.map +0 -1
  638. package/dist/cjs/components/SqlViewTile.js +0 -69
  639. package/dist/cjs/forms/client_onboard/CreateSqlViews.d.ts +0 -24
  640. package/dist/cjs/forms/client_onboard/CreateSqlViews.d.ts.map +0 -1
  641. package/dist/cjs/forms/client_onboard/CreateSqlViews.js +0 -250
  642. package/dist/cjs/forms/sql_views/CreateEditSqlView.d.ts +0 -29
  643. package/dist/cjs/forms/sql_views/CreateEditSqlView.d.ts.map +0 -1
  644. package/dist/cjs/forms/sql_views/CreateEditSqlView.js +0 -228
  645. package/dist/cjs/modals/PromoteDashModal.d.ts +0 -17
  646. package/dist/cjs/modals/PromoteDashModal.d.ts.map +0 -1
  647. package/dist/cjs/modals/PromoteDashModal.js +0 -133
  648. package/dist/cjs/primitives/SelectPrimitive.d.ts +0 -16
  649. package/dist/cjs/primitives/SelectPrimitive.d.ts.map +0 -1
  650. package/dist/cjs/primitives/SelectPrimitive.js +0 -43
  651. package/dist/cjs/public_components/DashboardBuilder.d.ts +0 -7
  652. package/dist/cjs/public_components/DashboardBuilder.d.ts.map +0 -1
  653. package/dist/cjs/public_components/DashboardBuilder.js +0 -220
  654. package/dist/cjs/public_components/SQLViewManager.d.ts.map +0 -1
  655. package/dist/cjs/public_components/SQLViewManager.js +0 -563
  656. package/dist/esm/components/EnvSelectPopover.d.ts +0 -13
  657. package/dist/esm/components/EnvSelectPopover.d.ts.map +0 -1
  658. package/dist/esm/components/EnvSelectPopover.js +0 -221
  659. package/dist/esm/components/SqlViewTile.d.ts +0 -8
  660. package/dist/esm/components/SqlViewTile.d.ts.map +0 -1
  661. package/dist/esm/components/SqlViewTile.js +0 -40
  662. package/dist/esm/forms/client_onboard/CreateSqlViews.d.ts +0 -24
  663. package/dist/esm/forms/client_onboard/CreateSqlViews.d.ts.map +0 -1
  664. package/dist/esm/forms/client_onboard/CreateSqlViews.js +0 -242
  665. package/dist/esm/forms/sql_views/CreateEditSqlView.d.ts +0 -29
  666. package/dist/esm/forms/sql_views/CreateEditSqlView.d.ts.map +0 -1
  667. package/dist/esm/forms/sql_views/CreateEditSqlView.js +0 -222
  668. package/dist/esm/modals/PromoteDashModal.d.ts +0 -17
  669. package/dist/esm/modals/PromoteDashModal.d.ts.map +0 -1
  670. package/dist/esm/modals/PromoteDashModal.js +0 -130
  671. package/dist/esm/primitives/SelectPrimitive.d.ts +0 -16
  672. package/dist/esm/primitives/SelectPrimitive.d.ts.map +0 -1
  673. package/dist/esm/primitives/SelectPrimitive.js +0 -41
  674. package/dist/esm/public_components/DashboardBuilder.d.ts +0 -7
  675. package/dist/esm/public_components/DashboardBuilder.d.ts.map +0 -1
  676. package/dist/esm/public_components/DashboardBuilder.js +0 -214
  677. package/dist/esm/public_components/SQLViewManager.d.ts.map +0 -1
  678. package/dist/esm/public_components/SQLViewManager.js +0 -555
@@ -0,0 +1,1940 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { arrayMove, rectSortingStrategy, SortableContext, sortableKeyboardCoordinates, useSortable, } from '@dnd-kit/sortable';
3
+ import { getEventCoordinates } from '@dnd-kit/utilities';
4
+ import { CSS } from '@dnd-kit/utilities';
5
+ import { DndContext, closestCorners, KeyboardSensor, PointerSensor, useSensor, useSensors, TouchSensor, MeasuringStrategy, pointerWithin, rectIntersection, DragOverlay, useDroppable, closestCenter, } from '@dnd-kit/core';
6
+ import { useCallback, useEffect, useMemo, useRef, useState, memo, } from 'react';
7
+ import { Chart, useDashboard, useAllReports, } from '@quillsql/react';
8
+ import equal from 'fast-deep-equal';
9
+ import { useAdmin } from '../../AdminProvider';
10
+ import { convertCustomFilter, DashboardFilterType, } from '../../utils/filter';
11
+ import EmptyDashboardComponent from '../EmptyDashboardComponent';
12
+ import { DashboardLoadingComponent } from './DashboardLoadingComponent';
13
+ import { QuillErrorMessageComponent } from '../UiComponents';
14
+ import { DashboardFilter } from './DashboardFilter';
15
+ import { COMPARISON_RANGE, defaultOptionsV2, getRangeFromPresetOptions, } from './DateRangePicker/dateRangePickerUtils';
16
+ import { SecondaryButtonPrimitive } from '../../primitives';
17
+ import { convertPresetOptionsToSelectableList } from '../DateRangePicker/dateRangePickerUtils';
18
+ const sortByOrdering = (a, b) => {
19
+ if (a.order === undefined && b.order === undefined)
20
+ return 0;
21
+ if (a.order === undefined)
22
+ return 1;
23
+ if (b.order === undefined)
24
+ return -1;
25
+ return a.order - b.order;
26
+ };
27
+ const snapRightToCursor = ({ activatorEvent, draggingNodeRect, transform, }) => {
28
+ if (draggingNodeRect && activatorEvent) {
29
+ const activatorCoordinates = getEventCoordinates(activatorEvent);
30
+ if (!activatorCoordinates) {
31
+ return transform;
32
+ }
33
+ const offsetX = activatorCoordinates.x - draggingNodeRect.right;
34
+ return {
35
+ ...transform,
36
+ x: transform.x + offsetX,
37
+ };
38
+ }
39
+ return transform;
40
+ };
41
+ const MemoizedChart = memo(({ reportId, chartType }) => {
42
+ const hasRendered = useRef(false);
43
+ useEffect(() => {
44
+ hasRendered.current = true;
45
+ }, []);
46
+ return (_jsx(Chart, { reportId: reportId, containerStyle: {
47
+ padding: 10,
48
+ height: chartType === 'metric' ? 80 : chartType === 'table' ? 420 : 250,
49
+ }, hideFilters: true, hideDateRangeFilter: true, propagateChanges: !!hasRendered.current }));
50
+ }, (prevProps, nextProps) => prevProps.reportId === nextProps.reportId &&
51
+ prevProps.chartType === nextProps.chartType);
52
+ export const InternalDashboard = ({ name, hidden = false, onClickReport,
53
+ // hoverActions,
54
+ onChangeLoading, filters,
55
+ // onUserFiltersUpdated,
56
+ // onClickChartElement,
57
+ // dateBucket,
58
+ containerStyle, parentLoading, onManageDashboard, }) => {
59
+ const { state, clientLoading: isClientLoading } = useAdmin();
60
+ const tenants = state.currentTenantIdentity;
61
+ // const client = state.client;
62
+ // const [userFilters, setUserFilters] = useState<{
63
+ // [label: string]: InternalFilter;
64
+ // }>({});
65
+ // const dataLoaderUserFilters = useMemo(() => {
66
+ // return (filters?.map((f) => convertCustomFilter(f)) ?? []).concat(
67
+ // Object.values(userFilters),
68
+ // );
69
+ // }, [filters, userFilters]);
70
+ // useEffect(() => {
71
+ // onUserFiltersUpdated?.(Object.values(userFilters));
72
+ // }, [userFilters]);
73
+ const { isLoading, data, isDashboardFilterLoading, dashboardFilters: populatedDashboardFilters, reload, setSectionOrder, } = useDashboard(name, filters?.map((f) => convertCustomFilter(f)) ?? []);
74
+ const { allReportsById } = useAllReports();
75
+ const [previewSectionOrder, setPreviewSectionOrder] = useState({});
76
+ const [isEditingNewSection, setIsEditingNewSection] = useState(false);
77
+ const metrics = useMemo(() => {
78
+ const map = {};
79
+ Object.keys(data?.sections ?? {}).forEach((section) => {
80
+ if (!data?.sections?.[section])
81
+ return;
82
+ const sectionMetrics = data.sections[section].filter(({ id, chartType }) => id && ['metric'].includes(chartType ?? ''));
83
+ const sectionOrder = data?.sectionOrder?.find((s) => s.section === section);
84
+ const reportOrder = previewSectionOrder[section] ?? sectionOrder?.reportOrder ?? [];
85
+ if (reportOrder.length > 0) {
86
+ map[section] = [...sectionMetrics].sort((a, b) => {
87
+ const aIndex = reportOrder.indexOf(a.id);
88
+ const bIndex = reportOrder.indexOf(b.id);
89
+ if (aIndex !== -1 && bIndex !== -1) {
90
+ return aIndex - bIndex;
91
+ }
92
+ if (aIndex !== -1)
93
+ return -1;
94
+ if (bIndex !== -1)
95
+ return 1;
96
+ return sortByOrdering(a, b);
97
+ });
98
+ }
99
+ else {
100
+ // Fallback to order property if no reportOrder
101
+ map[section] = sectionMetrics.sort(sortByOrdering);
102
+ }
103
+ });
104
+ return map;
105
+ }, [data?.sections, data?.sectionOrder]);
106
+ const charts = useMemo(() => {
107
+ const map = {};
108
+ Object.keys(data?.sections ?? {}).forEach((section) => {
109
+ if (!data?.sections?.[section])
110
+ return;
111
+ const sectionCharts = data.sections[section].filter(({ id, chartType }) => id && !['metric', 'table'].includes(chartType ?? ''));
112
+ const sectionOrder = data?.sectionOrder?.find((s) => s.section === section);
113
+ const reportOrder = previewSectionOrder[section] ?? sectionOrder?.reportOrder ?? [];
114
+ if (reportOrder.length > 0) {
115
+ map[section] = [...sectionCharts].sort((a, b) => {
116
+ const aIndex = reportOrder.indexOf(a.id);
117
+ const bIndex = reportOrder.indexOf(b.id);
118
+ if (aIndex !== -1 && bIndex !== -1)
119
+ return aIndex - bIndex;
120
+ if (aIndex !== -1)
121
+ return -1;
122
+ if (bIndex !== -1)
123
+ return 1;
124
+ return sortByOrdering(a, b);
125
+ });
126
+ }
127
+ else {
128
+ map[section] = sectionCharts.sort(sortByOrdering);
129
+ }
130
+ });
131
+ return map;
132
+ }, [data?.sections, data?.sectionOrder]);
133
+ const tables = useMemo(() => {
134
+ const map = {};
135
+ Object.keys(data?.sections ?? {}).forEach((section) => {
136
+ if (!data?.sections?.[section])
137
+ return;
138
+ const sectionTables = data.sections[section].filter(({ id, chartType }) => id && chartType === 'table');
139
+ const sectionOrder = data?.sectionOrder?.find((s) => s.section === section);
140
+ const reportOrder = previewSectionOrder[section] ?? sectionOrder?.reportOrder ?? [];
141
+ if (reportOrder.length > 0) {
142
+ map[section] = [...sectionTables].sort((a, b) => {
143
+ const aIndex = reportOrder.indexOf(a.id);
144
+ const bIndex = reportOrder.indexOf(b.id);
145
+ if (aIndex !== -1 && bIndex !== -1)
146
+ return aIndex - bIndex;
147
+ if (aIndex !== -1)
148
+ return -1;
149
+ if (bIndex !== -1)
150
+ return 1;
151
+ return sortByOrdering(a, b);
152
+ });
153
+ }
154
+ else {
155
+ map[section] = sectionTables.sort(sortByOrdering);
156
+ }
157
+ });
158
+ return map;
159
+ }, [data?.sections, data?.sectionOrder]);
160
+ const mounted = useRef(false);
161
+ useEffect(() => {
162
+ if (!mounted.current) {
163
+ mounted.current = true;
164
+ return;
165
+ }
166
+ if (isClientLoading || tenants === undefined) {
167
+ return;
168
+ }
169
+ reload(name, false, undefined, {
170
+ filters: populatedDashboardFilters ?? [],
171
+ });
172
+ }, [filters]);
173
+ const handleReorder = useCallback(async (items) => {
174
+ // find the section order
175
+ const sectionOrder = data?.sectionOrder;
176
+ if (!sectionOrder)
177
+ return;
178
+ const newSectionOrder = Object.entries(items)
179
+ .map(([section, reports]) => {
180
+ const sectionId = sectionOrder.find((s) => s.section === section)?._id;
181
+ if (!sectionId)
182
+ return;
183
+ return {
184
+ _id: sectionId,
185
+ section,
186
+ reportOrder: reports.map((r) => r.id),
187
+ };
188
+ })
189
+ .filter((s) => s);
190
+ await setSectionOrder(newSectionOrder);
191
+ }, [data?.sectionOrder]);
192
+ // New function to handle section reordering
193
+ const handleSectionReorder = useCallback(async (newSectionOrder) => {
194
+ if (!data?.sectionOrder)
195
+ return;
196
+ const reorderedSections = newSectionOrder
197
+ .map((sectionName) => {
198
+ const sectionData = data.sectionOrder?.find((s) => s.section === sectionName);
199
+ return sectionData;
200
+ })
201
+ .filter(Boolean);
202
+ await setSectionOrder(reorderedSections);
203
+ }, [data?.sectionOrder, setSectionOrder]);
204
+ const handleSectionNameUpdate = useCallback(async (oldSectionName, newSectionName) => {
205
+ if (!data?.sectionOrder)
206
+ return;
207
+ const updatedSections = data.sectionOrder.map((section) => {
208
+ if (section.section === oldSectionName) {
209
+ return {
210
+ ...section,
211
+ section: newSectionName,
212
+ };
213
+ }
214
+ return section;
215
+ });
216
+ await setSectionOrder(updatedSections);
217
+ }, [data?.sectionOrder, setSectionOrder]);
218
+ const handleSectionDelete = useCallback(async (sectionName) => {
219
+ if (!data?.sectionOrder || !data?.sections)
220
+ return;
221
+ const sectionToDelete = data.sectionOrder.find((s) => s.section === sectionName);
222
+ const reportsToMove = data.sections[sectionName] || [];
223
+ if (!sectionToDelete)
224
+ return;
225
+ const updatedSectionOrder = data.sectionOrder.filter((section) => section.section !== sectionName);
226
+ const defaultSection = updatedSectionOrder.find((s) => s.section === '');
227
+ if (defaultSection) {
228
+ defaultSection.reportOrder = [
229
+ ...defaultSection.reportOrder,
230
+ ...reportsToMove.map((r) => r.id),
231
+ ];
232
+ }
233
+ await setSectionOrder(updatedSectionOrder);
234
+ }, [data?.sectionOrder, data?.sections, setSectionOrder, reload, name]);
235
+ const handleClickReport = useCallback((report) => {
236
+ if (allReportsById[report.id]?.rows !== undefined) {
237
+ onClickReport?.(allReportsById[report.id] ?? report);
238
+ }
239
+ }, [allReportsById, onClickReport]);
240
+ // const [client, isClientLoading] = useContext(ClientContext);
241
+ // const { tenants, flags } = useTenants();
242
+ // const [theme] = useContext<any>(ThemeContext);
243
+ // const [schemaData] = useContext(SchemaDataContext);
244
+ // const { dispatch: dashboardFiltersDispatch } = useContext(
245
+ // DashboardFiltersContext,
246
+ // );
247
+ // const [fieldValuesMap, setFieldValuesMap] = useState<{
248
+ // [key: string]: { [key: string]: string[] };
249
+ // }>({}); // Mapping of unique values per field, used in string filter 'in' and 'not in'
250
+ // const [fieldValuesIsLoaded, setFieldValuesIsLoaded] = useState(false);
251
+ // const [addFilterPopoverIsOpen, setAddFilterPopoverIsOpen] = useState(false);
252
+ // const [filterListIsOpen, setFilterListIsOpen] = useState(false);
253
+ // const [
254
+ // filterListAddFilterPopoverIsOpen,
255
+ // setFilterListAddFilterPopoverIsOpen,
256
+ // ] = useState(false);
257
+ const presetOptions = useMemo(() => {
258
+ return populatedDashboardFilters?.[0]?.filterType === 'date_range'
259
+ ? convertPresetOptionsToSelectableList(populatedDashboardFilters[0].presetOptions ?? [], populatedDashboardFilters[0].defaultPresetRanges ?? [])
260
+ : defaultOptionsV2;
261
+ }, [populatedDashboardFilters]);
262
+ // A filter value can either be a string, an array of strings for a multiselect, or a date range (that could have a comparison range)
263
+ const [filterValues, setFilterValues] = useState({});
264
+ const prevNameRef = useRef(name);
265
+ const prevTenantsRef = useRef(tenants);
266
+ // const prevFlagsRef = useRef<string[] | undefined>(flags);
267
+ // const prevClientRef = useRef<string>(client?.publicKey ?? '');
268
+ // const addFilterPopoverButtonRef = useRef<HTMLDivElement>(null);
269
+ // const viewFiltersPopoverButtonRef = useRef<HTMLDivElement>(null);
270
+ const previousFilters = useRef(filters);
271
+ if (!equal(previousFilters.current, filters)) {
272
+ previousFilters.current = filters;
273
+ }
274
+ // const pendingReloadRef = useRef(false);
275
+ const isInitialLoadOfDashboardRef = useRef(false);
276
+ // const referencedTables = useMemo(() => {
277
+ // const sections = data?.sections || {};
278
+ // // find intersection of all referenced tables
279
+ // const tables: string[] = Object.values(sections)
280
+ // .flatMap((section: any) =>
281
+ // section.map((chart: QuillReportInternal) => chart.referencedTables),
282
+ // )
283
+ // .flat();
284
+ // return Array.from(new Set(tables));
285
+ // }, [data?.sections]);
286
+ useEffect(() => {
287
+ if (prevNameRef.current === name &&
288
+ Object.values(data?.sections ?? {}).flat().length) {
289
+ return;
290
+ }
291
+ prevNameRef.current = name;
292
+ if (isClientLoading || parentLoading || tenants === undefined) {
293
+ // Reload the dashboard when the client is loaded
294
+ // pendingReloadRef.current = true;
295
+ return;
296
+ }
297
+ if (isInitialLoadOfDashboardRef.current)
298
+ return;
299
+ isInitialLoadOfDashboardRef.current = true;
300
+ reload(name, true, undefined, populatedDashboardFilters?.length
301
+ ? { filters: populatedDashboardFilters, refetchReports: true }
302
+ : undefined).then(() => {
303
+ isInitialLoadOfDashboardRef.current = false;
304
+ prevTenantsRef.current = tenants;
305
+ // prevFlagsRef.current = flags;
306
+ });
307
+ }, [name, isClientLoading, parentLoading, tenants]);
308
+ const tenantMounted = useRef(false);
309
+ useEffect(() => {
310
+ if (!tenantMounted.current) {
311
+ tenantMounted.current = true;
312
+ return;
313
+ }
314
+ const tenantsChanged = !equal(prevTenantsRef.current, tenants);
315
+ // || equal(prevFlagsRef.current, flags);
316
+ if (isClientLoading || tenants === undefined || !tenantsChanged) {
317
+ // Reload the dashboard when the client is loaded
318
+ // pendingReloadRef.current = true;
319
+ return;
320
+ }
321
+ if (isInitialLoadOfDashboardRef.current)
322
+ return;
323
+ isInitialLoadOfDashboardRef.current = true;
324
+ reload(name, tenantsChanged).then(() => {
325
+ prevTenantsRef.current = tenants;
326
+ // prevFlagsRef.current = flags;
327
+ isInitialLoadOfDashboardRef.current = false;
328
+ });
329
+ }, [tenants]);
330
+ // TODO: this block does not appear necessary, uncomment if otherwise
331
+ // useEffect(() => {
332
+ // if (prevClientRef.current === client?.publicKey) {
333
+ // return;
334
+ // }
335
+ // prevClientRef.current = client?.publicKey ?? '';
336
+ // if (isClientLoading || tenants === undefined) {
337
+ // // Reload the dashboard when the client is loaded
338
+ // // pendingReloadRef.current = true;
339
+ // return;
340
+ // }
341
+ // if (isInitialLoadOfDashboardRef.current) return;
342
+ // isInitialLoadOfDashboardRef.current = true;
343
+ // reload(name, true).then(() => {
344
+ // prevTenantsRef.current = tenants;
345
+ // // prevFlagsRef.current = flags;
346
+ // isInitialLoadOfDashboardRef.current = false;
347
+ // });
348
+ // }, [client?.publicKey]);
349
+ useEffect(() => {
350
+ setFilterValues(Object.values(populatedDashboardFilters ?? {}).reduce((acc, f) => {
351
+ acc[f.label] =
352
+ f.filterType === 'string'
353
+ ? f.stringFilterType === 'multiselect'
354
+ ? { values: f.values, operator: 'IN' }
355
+ : { selectedValue: f.selectedValue }
356
+ : {
357
+ startDate: f.startDate,
358
+ endDate: f.endDate,
359
+ preset: f.preset,
360
+ comparisonRange: f.comparisonRange,
361
+ };
362
+ return acc;
363
+ }, {}));
364
+ }, [populatedDashboardFilters]);
365
+ // FIXME: enable user filters in internal dashboard
366
+ // useEffect(() => {
367
+ // const dashboardDateFilter = populatedDashboardFilters?.find(
368
+ // (f) => f.filterType === 'date_range',
369
+ // );
370
+ // if (dashboardDateFilter) {
371
+ // // Filter for custom date filter that applies to the report's dateField
372
+ // const customDateFilter = previousFilters.current?.find(
373
+ // (f) => f.filterType === FilterType.Date,
374
+ // // FIXME: this is the correct way to do it but the demo has a hardcoded filter field
375
+ // // && f.field === report?.dateField?.field && f.table === report?.dateField?.table,
376
+ // );
377
+ // if (!customDateFilter) {
378
+ // return;
379
+ // }
380
+ // const newFilter = applyCustomFilterToDashDateFilter(
381
+ // customDateFilter,
382
+ // dashboardDateFilter,
383
+ // );
384
+ // setFilterValues((filterValues) => ({
385
+ // ...filterValues,
386
+ // [dashboardDateFilter.label]: {
387
+ // startDate: newFilter.startDate,
388
+ // endDate: newFilter.endDate,
389
+ // preset: newFilter.preset,
390
+ // comparisonRange: newFilter.comparisonRange,
391
+ // },
392
+ // }));
393
+ // dashboardFiltersDispatch({
394
+ // type: 'UPDATE_DASHBOARD_FILTER',
395
+ // dashboardName: name,
396
+ // filterName: dashboardDateFilter.label,
397
+ // data: {
398
+ // filter: newFilter,
399
+ // loading: false,
400
+ // },
401
+ // });
402
+ // }
403
+ // }, [previousFilters.current]);
404
+ // Go through all columns in the referenced tables and get the unique values to use in fieldValuesMap
405
+ // useEffect(() => {
406
+ // const fetchData = async () => {
407
+ // setFieldValuesIsLoaded(false);
408
+ // const newFieldValues: { [key: string]: { [key: string]: string[] } } = {};
409
+ // await Promise.all(
410
+ // referencedTables.map(async (table: string) => {
411
+ // const tableInfo = schema.find(
412
+ // (tableInfo: Table) => tableInfo.name === table,
413
+ // );
414
+ // if (tableInfo) {
415
+ // const uniqueValues = await getUniqueStringValuesByColumn({
416
+ // columns: tableInfo.columns,
417
+ // tableName: table,
418
+ // client,
419
+ // tenants,
420
+ // dashboardName: name,
421
+ // });
422
+ // if (uniqueValues) {
423
+ // newFieldValues[table] = {};
424
+ // Object.keys(uniqueValues).forEach((field) => {
425
+ // newFieldValues[table]![field] = uniqueValues[field] || [];
426
+ // });
427
+ // }
428
+ // }
429
+ // }),
430
+ // );
431
+ // setFieldValuesMap(newFieldValues);
432
+ // setFieldValuesIsLoaded(true);
433
+ // };
434
+ // if (data?.customFiltersEnabled) {
435
+ // fetchData();
436
+ // }
437
+ // }, [referencedTables]);
438
+ const updateFilter = (filter, value, comparison) => {
439
+ if (!populatedDashboardFilters)
440
+ return;
441
+ let filterValue = {};
442
+ if (filter.filterType === 'string') {
443
+ if (filter.stringFilterType === 'multiselect') {
444
+ if ((value?.length ?? 0) === 0) {
445
+ filterValue = { values: undefined, operator: undefined };
446
+ }
447
+ else {
448
+ filterValue = { values: value, operator: 'IN' };
449
+ }
450
+ }
451
+ else {
452
+ filterValue = { selectedValue: value };
453
+ }
454
+ }
455
+ else if (filter.filterType === DashboardFilterType.Date) {
456
+ if (comparison ||
457
+ (filter.comparison &&
458
+ (filter.comparisonRange?.value ?? 'NO_COMPARISON') !==
459
+ 'NO_COMPARISON')) {
460
+ let preset = '';
461
+ if (comparison) {
462
+ preset = filter.preset.value;
463
+ }
464
+ const key = comparison?.value ||
465
+ (filter.comparisonRange?.value ?? 'NO_COMPARISON');
466
+ let primaryRange = {
467
+ startDate: value ? value.startDate : filter.startDate,
468
+ endDate: value ? value.endDate : filter.endDate,
469
+ };
470
+ if (value && value.preset) {
471
+ preset = value.preset;
472
+ primaryRange = getRangeFromPresetOptions(value.preset, presetOptions);
473
+ }
474
+ filterValue = {
475
+ startDate: primaryRange.startDate,
476
+ endDate: primaryRange.endDate,
477
+ preset: {
478
+ label: presetOptions.find((o) => o.value === preset)?.label ?? preset,
479
+ value: preset,
480
+ },
481
+ comparisonRange: {
482
+ startDate: COMPARISON_RANGE[key](primaryRange)
483
+ ?.startDate,
484
+ endDate: COMPARISON_RANGE[key](primaryRange)
485
+ ?.endDate,
486
+ value: key,
487
+ },
488
+ };
489
+ }
490
+ else {
491
+ const primaryRange = value && value.preset
492
+ ? getRangeFromPresetOptions(value.preset, presetOptions)
493
+ : {
494
+ startDate: value?.startDate || filter.startDate,
495
+ endDate: value?.endDate || filter.endDate,
496
+ };
497
+ const preset = value?.preset ? value.preset : '';
498
+ filterValue = {
499
+ startDate: primaryRange.startDate,
500
+ endDate: primaryRange.endDate,
501
+ preset: {
502
+ label: presetOptions.find((o) => o.value === preset)?.label ?? preset,
503
+ value: preset,
504
+ },
505
+ };
506
+ }
507
+ }
508
+ setFilterValues((filterValues) => ({
509
+ ...filterValues,
510
+ [filter.label]: filterValue,
511
+ }));
512
+ reload(name, false, undefined, {
513
+ filters: populatedDashboardFilters.map((f) => filter.label === f.label ? { ...f, ...filterValue } : f),
514
+ editedFilterLabel: filter.label,
515
+ });
516
+ };
517
+ // generate the correct filter structure
518
+ // const getUserFilter = (
519
+ // filter: InternalFilter,
520
+ // id: number,
521
+ // existingFilter?: any,
522
+ // ): any => {
523
+ // let userFilter = {};
524
+ // if (existingFilter) {
525
+ // userFilter = { ...existingFilter };
526
+ // } else {
527
+ // userFilter = { _id: `userFilter_${id}` };
528
+ // }
529
+ // userFilter = {
530
+ // ...userFilter,
531
+ // table: filter.table ?? '',
532
+ // field: filter.field,
533
+ // filterType: filter.filterType,
534
+ // fieldType: filter.fieldType,
535
+ // value: filter.value,
536
+ // operator: filter.operator,
537
+ // dashboardName: name,
538
+ // isUserFilter: true,
539
+ // };
540
+ // return userFilter;
541
+ // };
542
+ // // new update filter function for user added filters
543
+ // const updateUserFilter = (filter: InternalFilter) => {
544
+ // setUserFilters((userFilters) => ({
545
+ // ...userFilters,
546
+ // [filter.field]: filter,
547
+ // }));
548
+ // };
549
+ useEffect(() => {
550
+ if (onChangeLoading && isLoading) {
551
+ onChangeLoading(isLoading);
552
+ }
553
+ }, [isLoading, onChangeLoading]);
554
+ const sortedSections = useMemo(() => {
555
+ const sectionMap = (data?.sectionOrder || []).reduce((acc, section) => {
556
+ acc[section.section] = section._id;
557
+ return acc;
558
+ }, {});
559
+ return Object.keys(data?.sections ?? {})
560
+ .sort((a, b) => {
561
+ if (a === '')
562
+ return -1;
563
+ if (b === '')
564
+ return 1;
565
+ const sectionOrder = data?.sectionOrder;
566
+ if (!sectionOrder)
567
+ return 0;
568
+ const aIndex = sectionOrder.map((s) => s.section).indexOf(a);
569
+ const bIndex = sectionOrder.map((s) => s.section).indexOf(b);
570
+ if (aIndex === -1 && bIndex === -1)
571
+ return 0;
572
+ if (aIndex === -1)
573
+ return 1;
574
+ if (bIndex === -1)
575
+ return -1;
576
+ return aIndex - bIndex;
577
+ })
578
+ .map((sectionName) => ({
579
+ name: sectionName,
580
+ id: sectionMap[sectionName] || sectionName, // Fall back to name if ID is not found
581
+ }));
582
+ }, [data?.sections, data?.sectionOrder]);
583
+ const sortedSectionNames = useMemo(() => sortedSections.map((section) => section.name), [sortedSections]);
584
+ const dragSensors = useSensors(useSensor(PointerSensor, {
585
+ activationConstraint: {
586
+ distance: 5,
587
+ },
588
+ }), useSensor(KeyboardSensor, {
589
+ coordinateGetter: sortableKeyboardCoordinates,
590
+ }), useSensor(TouchSensor, {
591
+ activationConstraint: {
592
+ delay: 100,
593
+ tolerance: 8,
594
+ },
595
+ }));
596
+ const [activeId, setActiveId] = useState(null);
597
+ const [overId, setOverId] = useState(null);
598
+ const [activeItem, setActiveItem] = useState(null);
599
+ const [isDraggingSection, setIsDraggingSection] = useState(false);
600
+ const handleDragStart = useCallback((event) => {
601
+ const { active } = event;
602
+ setActiveId(active.id);
603
+ const activeDraggingSection = !String(active.id).includes('::');
604
+ setIsDraggingSection(activeDraggingSection);
605
+ if (activeDraggingSection) {
606
+ const sectionName = String(active.id);
607
+ setActiveItem({
608
+ type: 'section',
609
+ name: sectionName === '' ? 'Default Section' : sectionName,
610
+ id: sectionName,
611
+ });
612
+ }
613
+ else {
614
+ const [section, itemId] = String(active.id).split('::');
615
+ if (section === undefined || !itemId)
616
+ return;
617
+ let report;
618
+ report = data?.sections?.[section]?.find((r) => r._id === itemId || r.id === itemId);
619
+ if (!report && section === '') {
620
+ if (metrics?.[section]) {
621
+ report = metrics[section].find((r) => r._id === itemId || r.id === itemId);
622
+ }
623
+ if (!report && charts?.[section]) {
624
+ report = charts[section].find((r) => r._id === itemId || r.id === itemId);
625
+ }
626
+ if (!report && tables?.[section]) {
627
+ report = tables[section].find((r) => r._id === itemId || r.id === itemId);
628
+ }
629
+ }
630
+ if (report) {
631
+ const newActiveItem = {
632
+ type: 'report',
633
+ id: report.id,
634
+ section: section,
635
+ name: report.name || 'Untitled Report',
636
+ chartType: report.chartType || 'chart',
637
+ };
638
+ setActiveItem(newActiveItem);
639
+ }
640
+ else {
641
+ console.warn('Could not find report data for:', section, itemId);
642
+ }
643
+ }
644
+ }, [data?.sections, metrics, charts, tables]);
645
+ const handleDragEnd = useCallback((event) => {
646
+ const { active, over } = event;
647
+ setActiveId(null);
648
+ setOverId(null);
649
+ setActiveItem(null);
650
+ setIsDraggingSection(false);
651
+ setPreviewSectionOrder({});
652
+ if (!active || !over)
653
+ return;
654
+ const activeId = active.id.toString();
655
+ const overId = over.id.toString();
656
+ if (!activeId.includes('::')) {
657
+ let targetSection = overId;
658
+ if (overId.startsWith('section-')) {
659
+ targetSection = overId.replace('section-', '');
660
+ }
661
+ else if (overId.includes('::')) {
662
+ const [sectionName] = overId.split('::');
663
+ targetSection = sectionName;
664
+ }
665
+ if (targetSection &&
666
+ sortedSectionNames.includes(activeId) &&
667
+ sortedSectionNames.includes(targetSection)) {
668
+ const oldIndex = sortedSectionNames.indexOf(activeId);
669
+ const newIndex = sortedSectionNames.indexOf(targetSection);
670
+ if (oldIndex !== -1 && newIndex !== -1 && oldIndex !== newIndex) {
671
+ const newSectionOrder = arrayMove(sortedSectionNames, oldIndex, newIndex);
672
+ handleSectionReorder(newSectionOrder);
673
+ }
674
+ }
675
+ return;
676
+ }
677
+ const [sourceSection, reportId] = activeId.split('::');
678
+ let targetSection = '';
679
+ let targetReportId = '';
680
+ if (overId.startsWith('section-')) {
681
+ targetSection = overId.replace('section-', '');
682
+ }
683
+ else if (overId.includes('::')) {
684
+ [targetSection, targetReportId] = overId.split('::');
685
+ }
686
+ else {
687
+ targetSection = overId;
688
+ }
689
+ if (sourceSection === undefined ||
690
+ reportId === undefined ||
691
+ targetSection === undefined)
692
+ return;
693
+ const newItems = { ...data?.sections };
694
+ const report = newItems[sourceSection]?.find((item) => item._id === reportId || item.id === reportId);
695
+ if (!report || !newItems[sourceSection])
696
+ return;
697
+ if (sourceSection === '' && targetSection === '') {
698
+ const activeChartType = report.chartType || 'chart';
699
+ if (!targetReportId)
700
+ return;
701
+ const overItem = newItems[targetSection]?.find((item) => item._id === targetReportId || item.id === targetReportId);
702
+ if (!overItem)
703
+ return;
704
+ const overChartType = overItem.chartType || 'chart';
705
+ const isMetric = (type) => type === 'metric';
706
+ const isTable = (type) => type === 'table';
707
+ const isChart = (type) => !isMetric(type) && !isTable(type);
708
+ const isSameCategory = (isMetric(activeChartType) && isMetric(overChartType)) ||
709
+ (isTable(activeChartType) && isTable(overChartType)) ||
710
+ (isChart(activeChartType) && isChart(overChartType));
711
+ if (!isSameCategory) {
712
+ return;
713
+ }
714
+ const activeIndex = newItems[sourceSection].findIndex((item) => item._id === reportId || item.id === reportId);
715
+ const overIndex = newItems[sourceSection].findIndex((item) => item._id === targetReportId || item.id === targetReportId);
716
+ if (activeIndex !== -1 && overIndex !== -1) {
717
+ const sameTypeItems = newItems[sourceSection]
718
+ .map((item, index) => ({ item, index }))
719
+ .filter(({ item }) => {
720
+ const itemType = item.chartType || 'chart';
721
+ if (isMetric(activeChartType))
722
+ return isMetric(itemType);
723
+ if (isTable(activeChartType))
724
+ return isTable(itemType);
725
+ return isChart(itemType);
726
+ });
727
+ const typeActiveIndex = sameTypeItems.findIndex(({ item }) => item.id === reportId);
728
+ const typeOverIndex = sameTypeItems.findIndex(({ item }) => item.id === targetReportId);
729
+ if (typeActiveIndex !== -1 && typeOverIndex !== -1) {
730
+ const reordered = arrayMove(sameTypeItems.map(({ item }) => item), typeActiveIndex, typeOverIndex);
731
+ const result = [...newItems[sourceSection]];
732
+ let reorderedIndex = 0;
733
+ for (let i = 0; i < result.length; i++) {
734
+ const itemType = result[i]?.chartType || 'chart';
735
+ const isRightCategory = (isMetric(activeChartType) && isMetric(itemType)) ||
736
+ (isTable(activeChartType) && isTable(itemType)) ||
737
+ (isChart(activeChartType) && isChart(itemType));
738
+ if (isRightCategory && reorderedIndex < reordered.length) {
739
+ result[i] = reordered[reorderedIndex++];
740
+ }
741
+ }
742
+ newItems[sourceSection] = result;
743
+ handleReorder(newItems);
744
+ }
745
+ }
746
+ }
747
+ else if (sourceSection === targetSection) {
748
+ const overItem = newItems[sourceSection]?.find((item) => item._id === targetReportId);
749
+ if (!overItem)
750
+ return;
751
+ const activeIndex = newItems[sourceSection].indexOf(report);
752
+ const overIndex = newItems[sourceSection].indexOf(overItem);
753
+ if (activeIndex !== -1 && overIndex !== -1) {
754
+ newItems[sourceSection] = arrayMove(newItems[sourceSection], activeIndex, overIndex);
755
+ handleReorder(newItems);
756
+ }
757
+ }
758
+ else if (newItems[targetSection]) {
759
+ newItems[sourceSection] = newItems[sourceSection].filter((item) => item._id !== reportId && item.id !== reportId);
760
+ if (!newItems[targetSection]) {
761
+ newItems[targetSection] = [];
762
+ }
763
+ // Check if we're dropping on section header (starts with section-)
764
+ // or if the overId is exactly the section name (no specific report)
765
+ if (overId.startsWith('section-') ||
766
+ overId === targetSection ||
767
+ !targetReportId) {
768
+ // PREPEND to the section when dropped on section header IF the source section comes before the target section
769
+ // otherwise APPEND to the section
770
+ const targetIndex = sortedSectionNames.indexOf(targetSection);
771
+ const sourceIndex = sortedSectionNames.indexOf(sourceSection);
772
+ if (sourceIndex < targetIndex) {
773
+ newItems[targetSection]?.unshift(report);
774
+ }
775
+ else {
776
+ newItems[targetSection]?.push(report);
777
+ }
778
+ }
779
+ else {
780
+ // Regular drop on a specific report
781
+ const targetReport = newItems[targetSection]?.find((item) => item._id === targetReportId || item.id === targetReportId);
782
+ if (targetReport) {
783
+ const targetSectionIndex = sortedSectionNames.indexOf(targetSection);
784
+ const sourceSectionIndex = sortedSectionNames.indexOf(sourceSection);
785
+ const targetIndex = newItems[targetSection]?.indexOf(targetReport);
786
+ newItems[targetSection]?.splice((targetIndex ?? 0) +
787
+ (sourceSectionIndex > targetSectionIndex ? 1 : 0), 0, report);
788
+ }
789
+ else {
790
+ // No target found, append to end
791
+ newItems[targetSection]?.push(report);
792
+ }
793
+ }
794
+ handleReorder(newItems);
795
+ }
796
+ }, [data?.sections, sortedSectionNames, handleReorder, handleSectionReorder]);
797
+ const handleDragOver = useCallback((event) => {
798
+ const { active, over } = event;
799
+ if (!active || !over) {
800
+ setOverId(null);
801
+ return;
802
+ }
803
+ const activeId = active.id.toString();
804
+ const overId = over.id.toString();
805
+ // Check if we're dragging a section
806
+ const isDraggingSection = !activeId.includes('::');
807
+ if (isDraggingSection) {
808
+ let targetId = overId;
809
+ if (activeId === overId ||
810
+ (overId.startsWith('section-') && `section-${activeId}` === overId) ||
811
+ activeId === overId.replace('section-', '')) {
812
+ setOverId(null);
813
+ return;
814
+ }
815
+ if (overId.startsWith('section-')) {
816
+ targetId = overId.replace('section-', '');
817
+ // Don't allow unassigned section to be a target
818
+ if (targetId === '') {
819
+ setOverId(null);
820
+ return;
821
+ }
822
+ }
823
+ else if (overId.includes('::')) {
824
+ // If hovering over a report, extract its section
825
+ const [targetSection] = overId.split('::');
826
+ // Skip invalid section targets
827
+ if (!targetSection ||
828
+ targetSection === activeId ||
829
+ targetSection === '') {
830
+ setOverId(null);
831
+ return;
832
+ }
833
+ targetId = targetSection;
834
+ }
835
+ else if (overId === '') {
836
+ setOverId(null);
837
+ return;
838
+ }
839
+ setOverId(targetId);
840
+ return;
841
+ }
842
+ const [sourceSection] = activeId.split('::');
843
+ // Case 1: Hovering over a section container
844
+ if (overId.startsWith('section-')) {
845
+ const targetSection = overId.replace('section-', '');
846
+ if (sourceSection !== targetSection) {
847
+ setOverId(`section::${targetSection}`);
848
+ }
849
+ else {
850
+ setOverId(null);
851
+ }
852
+ return;
853
+ }
854
+ // Case 2: Hovering over a report
855
+ if (overId.includes('::')) {
856
+ const [targetSection] = overId.split('::');
857
+ if (sourceSection !== targetSection && targetSection) {
858
+ setOverId(`section::${targetSection}`);
859
+ }
860
+ else if (sourceSection === targetSection &&
861
+ overId !== activeId &&
862
+ sourceSection) {
863
+ const activeItemId = activeId.split('::')[1];
864
+ const overItemId = overId.split('::')[1];
865
+ // Always use the latest state with the functional form of setPreviewSectionOrder
866
+ setPreviewSectionOrder((prevOrder) => {
867
+ // Check if we already have a preview order for this section
868
+ const existingOrder = prevOrder[sourceSection];
869
+ if (!existingOrder) {
870
+ // No preview order yet, create one from the original data
871
+ const sectionItems = data?.sections?.[sourceSection]?.map((r) => r.id) ?? [];
872
+ const oldIndex = sectionItems.indexOf(activeItemId);
873
+ const newIndex = sectionItems.indexOf(overItemId);
874
+ if (oldIndex !== -1 && newIndex !== -1 && oldIndex !== newIndex) {
875
+ // Create new preview order but keep other sections
876
+ return {
877
+ ...prevOrder,
878
+ [sourceSection]: arrayMove(sectionItems, oldIndex, newIndex),
879
+ };
880
+ }
881
+ }
882
+ else {
883
+ // We already have a preview order, update it
884
+ const oldIndex = existingOrder.indexOf(activeItemId);
885
+ const newIndex = existingOrder.indexOf(overItemId);
886
+ if (oldIndex !== -1 && newIndex !== -1 && oldIndex !== newIndex) {
887
+ // Update existing preview order but keep other sections
888
+ return {
889
+ ...prevOrder,
890
+ [sourceSection]: arrayMove([...existingOrder], oldIndex, newIndex),
891
+ };
892
+ }
893
+ }
894
+ // Return unchanged state if conditions aren't met
895
+ return prevOrder;
896
+ });
897
+ setOverId(overId);
898
+ }
899
+ return;
900
+ }
901
+ setOverId(overId);
902
+ }, [data?.sections, setPreviewSectionOrder]);
903
+ const draggedIndex = useMemo(() => {
904
+ if (!activeId || !sortedSectionNames.includes(activeId))
905
+ return -1;
906
+ return sortedSectionNames.indexOf(activeId || '');
907
+ }, [activeId, sortedSectionNames]);
908
+ const collisionDetectionStrategy = useCallback((args) => {
909
+ if (!String(args.active.id).includes('::')) {
910
+ const collisions = pointerWithin(args).filter((collision) => {
911
+ return collision.id.toString().startsWith('section-');
912
+ });
913
+ if (collisions.length > 0)
914
+ return collisions;
915
+ // Fall back to closest corners
916
+ return closestCenter(args).filter((c) => c.id.toString().startsWith('section-'));
917
+ }
918
+ const [sourceSection] = String(args.active.id).split('::');
919
+ const sectionIntersections = args.droppableContainers
920
+ .filter((container) => {
921
+ const containerId = String(container.id);
922
+ return containerId.startsWith('section-');
923
+ })
924
+ .filter((container) => {
925
+ const sectionId = String(container.id).replace('section-', '');
926
+ return sectionId !== sourceSection;
927
+ })
928
+ .map((container) => {
929
+ const rect = container.rect.current;
930
+ const activeRect = args.active.rect.current;
931
+ if (!rect || !activeRect)
932
+ return null;
933
+ const isIntersecting = activeRect.left < rect.right &&
934
+ activeRect.right > rect.left &&
935
+ activeRect.top < rect.bottom &&
936
+ activeRect.bottom > rect.top;
937
+ if (isIntersecting) {
938
+ return {
939
+ id: container.id,
940
+ data: {
941
+ droppableContainer: true,
942
+ value: container.id,
943
+ },
944
+ };
945
+ }
946
+ return null;
947
+ })
948
+ .filter(Boolean);
949
+ if (sectionIntersections.length > 0) {
950
+ return sectionIntersections;
951
+ }
952
+ const pointerIntersections = pointerWithin(args);
953
+ if (pointerIntersections.length > 0)
954
+ return pointerIntersections;
955
+ const rectIntersections = rectIntersection(args);
956
+ if (rectIntersections.length > 0)
957
+ return rectIntersections;
958
+ return closestCorners(args);
959
+ }, []);
960
+ const handleAddSection = useCallback((sectionName) => {
961
+ if (!data?.sectionOrder)
962
+ return;
963
+ const updatedSectionOrder = [
964
+ ...data.sectionOrder,
965
+ {
966
+ section: sectionName,
967
+ reportOrder: [],
968
+ },
969
+ ];
970
+ setSectionOrder(updatedSectionOrder);
971
+ }, [data?.sectionOrder, data?.sections, setSectionOrder]);
972
+ const existingSectionNames = useMemo(() => Object.keys(data?.sections || {}), [data?.sections]);
973
+ if (!isLoading &&
974
+ (Object.keys(data?.sections ?? {}).length === 0 ||
975
+ Object.values(data?.sections ?? {}).flat().length === 0)) {
976
+ return _jsx(EmptyDashboardComponent, {});
977
+ }
978
+ if (hidden || isLoading || isClientLoading || parentLoading) {
979
+ return _jsx(DashboardLoadingComponent, { containerStyle: containerStyle });
980
+ }
981
+ if (!data?.sections) {
982
+ return (_jsx(QuillErrorMessageComponent, { containerStyle: { height: 100 }, errorMessage: "Error loading dashboard" }));
983
+ }
984
+ return (_jsxs("div", { style: containerStyle, children: [_jsx("style", { children: `
985
+ .section-header {
986
+ display: flex;
987
+ flex-direction: row;
988
+ align-items: center;
989
+ gap: 10px;
990
+ }
991
+ .section-drag-handle {
992
+ transform: translateY(2px);
993
+ }
994
+ .section-name-input {
995
+ font-size: 22px;
996
+ font-weight: bold;
997
+ border: none;
998
+ background: transparent;
999
+ // border-bottom: 2px solid #3b82f6;
1000
+ outline: none;
1001
+ width: auto;
1002
+ padding: 0;
1003
+ margin: 0;
1004
+ text-align: left;
1005
+ box-sizing: content-box;
1006
+ }
1007
+ .section-name-display {
1008
+ cursor: pointer;
1009
+ }
1010
+ .section-name-display:hover {
1011
+ text-decoration: underline;
1012
+ text-decoration-style: dotted;
1013
+ text-decoration-color: #9CA0A7;
1014
+ }
1015
+ .section-delete-button {
1016
+ cursor: pointer;
1017
+ color: #9CA0A7;
1018
+ transform: translateY(2px);
1019
+ }
1020
+ .section-delete-button:hover {
1021
+ color: #EF4444;
1022
+ }
1023
+ .dragging-item {
1024
+ opacity: 0.8;
1025
+ box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.2) !important;
1026
+ transform-origin: 0 0;
1027
+ transition: box-shadow 200ms ease, opacity 200ms ease !important;
1028
+ }
1029
+
1030
+ .section-drop-target {
1031
+ transition: all 150ms ease;
1032
+ }
1033
+
1034
+ .dragging-item {
1035
+ opacity: 0.7 !important;
1036
+ z-index: 9999 !important;
1037
+ cursor: grabbing !important;
1038
+ transform-origin: 0 0;
1039
+ box-shadow: 0px 10px 20px rgba(0,0,0,0.2) !important;
1040
+ transition: none !important;
1041
+ pointer-events: none;
1042
+ }
1043
+
1044
+ .section-drop-target {
1045
+ position: relative;
1046
+ border-radius: 8px;
1047
+ transition: all 0.2s ease;
1048
+ min-height: 100px;
1049
+ }
1050
+
1051
+ .section-grid-container {
1052
+ min-height: 100px;
1053
+ width: 100%;
1054
+ transition: background-color 0.2s ease;
1055
+ }
1056
+
1057
+ .section-container {
1058
+ position: relative;
1059
+ transition: all 150ms ease;
1060
+ }
1061
+
1062
+ .section-grid-container {
1063
+ min-height: 120px;
1064
+ width: 100%;
1065
+ border-radius: 8px;
1066
+ transition: all 0.15s ease-in-out;
1067
+ }
1068
+
1069
+ .dragging-section {
1070
+ z-index: 9999 !important;
1071
+ opacity: 0.8;
1072
+ background-color: white;
1073
+ box-shadow: 0px 10px 25px rgba(0,0,0,0.15) !important;
1074
+ outline: 1px solid #e5e7eb;
1075
+ transition: none !important;
1076
+ transform-origin: 0 0;
1077
+ }
1078
+
1079
+ .section-container {
1080
+ position: relative;
1081
+ transition: all 150ms ease;
1082
+ height: auto !important;
1083
+ min-height: fit-content;
1084
+ }
1085
+
1086
+ .section-grid-container.empty {
1087
+ border: 1px dashed #e5e7eb;
1088
+ min-height: 120px;
1089
+ padding: 16px !important;
1090
+ }
1091
+
1092
+ .sortable-section-wrapper {
1093
+ height: auto !important;
1094
+ min-height: fit-content !important;
1095
+ position: relative;
1096
+ margin-bottom: 20px;
1097
+ }
1098
+
1099
+ .dashboard-container.dragging-section .section-container {
1100
+ outline: none !important;
1101
+ box-shadow: none !important;
1102
+ background-color: transparent !important;
1103
+ }
1104
+
1105
+
1106
+ .section-container {
1107
+ position: relative;
1108
+ transition: all 150ms ease;
1109
+ height: auto !important;
1110
+ min-height: fit-content;
1111
+ padding: 0px;
1112
+ margin: 0px;
1113
+ }
1114
+
1115
+ .dashboard-container:not(.dragging-section) .section-highlighted {
1116
+ background-color: rgba(59, 130, 246, 0.05) !important;
1117
+ border-radius: 8px !important;
1118
+ outline: 2px solid #3b82f6 !important;
1119
+ box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1) !important;
1120
+ padding: 12px !important;
1121
+ margin: -12px !important;
1122
+ }
1123
+
1124
+ .dashboard-container.dragging-section .section-container {
1125
+ outline: none !important;
1126
+ box-shadow: none !important;
1127
+ background-color: transparent !important;
1128
+ /* Reset padding/margin when dragging sections */
1129
+ padding: 0px !important;
1130
+ margin: 0px !important;
1131
+ }
1132
+
1133
+ .section-drag-preview {
1134
+ background: white;
1135
+ border-radius: 8px;
1136
+ box-shadow: 0px 10px 25px rgba(0, 0, 0, 0.15);
1137
+ padding: 16px;
1138
+ border: 1px solid #e5e7eb;
1139
+ transform-origin: 0 0;
1140
+ cursor: grabbing;
1141
+ min-height: 300px;
1142
+ }
1143
+
1144
+ .section-drag-preview .section-header {
1145
+ display: flex;
1146
+ flex-direction: row;
1147
+ align-items: center;
1148
+ width: 100%;
1149
+ }
1150
+
1151
+ .section-drag-preview h2 {
1152
+ font-size: 22px;
1153
+ font-weight: bold;
1154
+ margin: 0;
1155
+ padding: 0;
1156
+ overflow: hidden;
1157
+ text-overflow: ellipsis;
1158
+ white-space: nowrap;
1159
+ }
1160
+
1161
+ .dashboard-container.dragging-section {
1162
+ box-shadow: none !important;
1163
+ outline: none !important;
1164
+ }
1165
+
1166
+ .dashboard-container.dragging-section > div {
1167
+ box-shadow: none;
1168
+ }
1169
+
1170
+ .quill-report-edit {
1171
+ box-shadow: 0px 2px 8px rgba(56, 65, 81, 0.08);
1172
+ }
1173
+
1174
+ .quill-report-edit.dragging-item {
1175
+ box-shadow: 0px 10px 20px rgba(0,0,0,0.2) !important;
1176
+ }
1177
+
1178
+ .section-grid-container.empty {
1179
+ background-color: rgba(249, 250, 251, 0.5);
1180
+ transition: all 0.2s ease;
1181
+ position: relative;
1182
+ }
1183
+
1184
+ .section-grid-container.empty::after {
1185
+ content: 'Drop reports here';
1186
+ color: #9CA3AF;
1187
+ font-size: 16px;
1188
+ opacity: 0.8;
1189
+ position: absolute;
1190
+ top: 50%;
1191
+ left: 50%;
1192
+ transform: translate(-50%, -50%);
1193
+ white-space: nowrap;
1194
+ }
1195
+
1196
+ .new-section-button.editing {
1197
+ opacity: 1;
1198
+ border-color: #3b82f6;
1199
+ background-color: white;
1200
+ cursor: default;
1201
+ min-height: 100px;
1202
+ height: auto;
1203
+ }
1204
+
1205
+ .new-section-button {
1206
+ border: 2px dashed #e5e7eb;
1207
+ border-radius: 8px;
1208
+ margin-top: 20px;
1209
+ padding: 16px;
1210
+ display: flex;
1211
+ flex-direction: column;
1212
+ align-items: center;
1213
+ justify-content: center;
1214
+ cursor: pointer;
1215
+ height: 100px;
1216
+ opacity: 0;
1217
+ pointer-events: auto; /* Enable pointer events by default */
1218
+ }
1219
+
1220
+ /* Only show hover effect when NOT dragging */
1221
+ .dashboard-container:not(.dragging-section):not(.dragging-report) .new-section-button:hover {
1222
+ opacity: 1;
1223
+ border-color: #3b82f6;
1224
+ }
1225
+
1226
+ .new-section-button.editing {
1227
+ opacity: 1;
1228
+ border-color: #3b82f6;
1229
+ background-color: white;
1230
+ cursor: default;
1231
+ min-height: 100px;
1232
+ height: auto;
1233
+ }
1234
+
1235
+ /* Disable button during drag operations */
1236
+ .dashboard-container.dragging-section .new-section-button,
1237
+ .dashboard-container.dragging-report .new-section-button {
1238
+ pointer-events: none;
1239
+ }
1240
+
1241
+ /* Disable pointer events on charts when dragging */
1242
+ .dashboard-container.dragging-section .quill-report-edit .MemoizedChart,
1243
+ .dashboard-container.dragging-report .quill-report-edit .MemoizedChart,
1244
+ .dashboard-container.dragging-section .quill-report-edit [data-testid="chart-container"],
1245
+ .dashboard-container.dragging-report .quill-report-edit [data-testid="chart-container"] {
1246
+ pointer-events: none !important;
1247
+ }
1248
+
1249
+ /* Also disable pointer events on all chart inner elements */
1250
+ .dashboard-container.dragging-section .quill-report-edit svg,
1251
+ .dashboard-container.dragging-report .quill-report-edit svg,
1252
+ .dashboard-container.dragging-section .quill-report-edit canvas,
1253
+ .dashboard-container.dragging-report .quill-report-edit canvas,
1254
+ .dashboard-container.dragging-section .quill-report-edit .recharts-wrapper,
1255
+ .dashboard-container.dragging-report .quill-report-edit .recharts-wrapper,
1256
+ .dashboard-container.dragging-section .quill-report-edit .recharts-surface,
1257
+ .dashboard-container.dragging-report .quill-report-edit .recharts-surface {
1258
+ pointer-events: none !important;
1259
+ }
1260
+
1261
+ .dragging-item * {
1262
+ pointer-events: none !important;
1263
+ }
1264
+
1265
+ /* Add transition for spacing changes */
1266
+ .sortable-section-wrapper {
1267
+ height: auto !important;
1268
+ min-height: fit-content !important;
1269
+ position: relative;
1270
+ margin-bottom: 20px;
1271
+ transition: margin 0.2s ease;
1272
+ }
1273
+
1274
+ /* Section drop indicator */
1275
+ .section-drop-indicator {
1276
+ position: absolute;
1277
+ left: 0;
1278
+ right: 0;
1279
+ height: 4px;
1280
+ background-color: #3b82f6;
1281
+ border-radius: 2px;
1282
+ opacity: 0;
1283
+ transition: opacity 0.15s ease;
1284
+ z-index: 999;
1285
+ }
1286
+
1287
+ .section-drop-indicator.top {
1288
+ top: -12px;
1289
+ }
1290
+
1291
+ .section-drop-indicator.bottom {
1292
+ bottom: -12px;
1293
+ }
1294
+
1295
+ .section-drop-indicator.active {
1296
+ opacity: 1;
1297
+ }
1298
+
1299
+ /* Add pointer events none to drop indicators so they don't interfere with dragging */
1300
+ .section-drop-indicator {
1301
+ pointer-events: none;
1302
+ }
1303
+
1304
+ /* Adjust spacing for the dragged item preview */
1305
+ .section-drag-preview {
1306
+ background: white;
1307
+ border-radius: 8px;
1308
+ box-shadow: 0px 10px 25px rgba(0, 0, 0, 0.15);
1309
+ padding: 16px;
1310
+ min-width: 300px;
1311
+ width: 70%;
1312
+ border: 1px solid #e5e7eb;
1313
+ transform-origin: 0 0;
1314
+ cursor: grabbing;
1315
+ }
1316
+
1317
+ /* Add additional styling to new section button to maintain spacing */
1318
+ .new-section-button {
1319
+ transition: opacity 0.2s ease, border-color 0.2s ease, margin 0.2s ease;
1320
+ margin-top: 20px;
1321
+ }
1322
+
1323
+ .dashboard-container.dragging-section .new-section-button {
1324
+ margin-top: 50px;
1325
+ }
1326
+ ` }), _jsxs("div", { className: `dashboard-container ${isDraggingSection ? 'dragging-section' : ''} ${activeId && !isDraggingSection ? 'dragging-report' : ''}`, children: [_jsxs("div", { style: {
1327
+ display: 'flex',
1328
+ flexDirection: 'row',
1329
+ gap: 12,
1330
+ marginBottom: 6,
1331
+ marginTop: -12,
1332
+ }, children: [_jsx(SecondaryButtonPrimitive, { onClick: onManageDashboard, label: "Manage Dashboard" }), _jsx(SecondaryButtonPrimitive, { onClick: () => {
1333
+ // Same as if the user clicked the Add section button at the bottom
1334
+ setIsEditingNewSection(true);
1335
+ // Scroll to the bottom of the page
1336
+ window.scrollTo({
1337
+ top: document.body.scrollHeight,
1338
+ behavior: 'smooth',
1339
+ });
1340
+ }, label: "Add Section +" })] }), _jsx("div", { style: {
1341
+ display: 'flex',
1342
+ flexDirection: 'row',
1343
+ alignItems: 'center',
1344
+ }, children: _jsx("div", { style: {
1345
+ width: '100%',
1346
+ marginBottom: 25,
1347
+ display: 'flex',
1348
+ flexDirection: 'row',
1349
+ alignItems: 'flex-end',
1350
+ flexWrap: 'wrap',
1351
+ gap: 12,
1352
+ }, children: (populatedDashboardFilters ?? []).map((filter) => (_jsx(DashboardFilter, { filter: {
1353
+ ...filter,
1354
+ ...(filter.filterType === 'date_range' && {
1355
+ options: presetOptions,
1356
+ }),
1357
+ ...filterValues[filter.label],
1358
+ }, onChangeFilter: updateFilter, isLoading: isDashboardFilterLoading(filter.label) }, filter.label + name))) }) }), _jsxs(DndContext, { sensors: dragSensors, collisionDetection: collisionDetectionStrategy, onDragStart: handleDragStart, onDragOver: handleDragOver, onDragEnd: handleDragEnd, measuring: {
1359
+ droppable: {
1360
+ strategy: MeasuringStrategy.Always,
1361
+ },
1362
+ }, autoScroll: {
1363
+ threshold: {
1364
+ x: 0.1,
1365
+ y: 0.2,
1366
+ },
1367
+ acceleration: 10,
1368
+ interval: 5,
1369
+ }, children: [_jsx(SortableContext, { items: sortedSectionNames, strategy: rectSortingStrategy, children: _jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 20 }, children: [sortedSections
1370
+ .filter((s) => s.name ||
1371
+ metrics[s.name]?.length ||
1372
+ charts[s.name]?.length ||
1373
+ tables[s.name]?.length)
1374
+ .map((section) => {
1375
+ return (_jsx(SortableSection, { id: section.name, sectionId: section.id, sectionName: section.name, sectionIndex: sortedSectionNames.indexOf(section.name), metrics: metrics, charts: charts, tables: tables, data: data, previewSectionOrder: previewSectionOrder, handleReorder: handleReorder, onClickReport: handleClickReport, onSectionNameUpdate: handleSectionNameUpdate, onSectionDelete: handleSectionDelete, isActive: activeId?.startsWith(`${section.name}::`) || false, activeId: activeId, overId: overId, draggedIndex: draggedIndex === -1 ? undefined : draggedIndex, isHighlighted: overId === section.name, isDraggingAnySection: isDraggingSection }, section.id));
1376
+ }), !isLoading && (_jsx(NewSectionButton, { onAddSection: handleAddSection, existingSections: existingSectionNames, isEditing: isEditingNewSection, setIsEditing: setIsEditingNewSection }))] }) }), _jsx(DragOverlay, { modifiers: activeItem?.type === 'section' ? undefined : [snapRightToCursor], children: activeItem &&
1377
+ (activeItem.type === 'section' ? (_jsxs("div", { className: "section-drag-preview", style: { width: '100%', maxWidth: '100%', minWidth: 'unset' }, children: [_jsxs("div", { className: "section-header", style: { marginBottom: '12px' }, children: [_jsx("h2", { style: {
1378
+ margin: 0,
1379
+ padding: 0,
1380
+ fontSize: '22px',
1381
+ fontWeight: 'bold',
1382
+ }, children: activeItem.name }), _jsxs("div", { style: { display: 'flex', gap: 8, alignItems: 'center' }, children: [activeItem.id !== '' && (_jsx("div", { style: {
1383
+ color: '#9CA0A7',
1384
+ marginLeft: -4,
1385
+ transform: 'translateY(2px)',
1386
+ }, children: _jsx("svg", { width: "12", height: "12", viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M1 1L13 13M1 13L13 1", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })), activeItem.id !== '' && (_jsx("div", { className: "section-drag-handle", children: _jsxs("div", { style: {
1387
+ display: 'flex',
1388
+ gap: 2,
1389
+ flexDirection: 'row',
1390
+ }, children: [_jsxs("div", { style: {
1391
+ display: 'flex',
1392
+ gap: 2,
1393
+ flexDirection: 'column',
1394
+ }, children: [_jsx("div", { style: {
1395
+ width: 3,
1396
+ height: 3,
1397
+ borderRadius: 3,
1398
+ background: '#9CA0A7',
1399
+ } }), _jsx("div", { style: {
1400
+ width: 3,
1401
+ height: 3,
1402
+ borderRadius: 3,
1403
+ background: '#9CA0A7',
1404
+ } }), _jsx("div", { style: {
1405
+ width: 3,
1406
+ height: 3,
1407
+ borderRadius: 3,
1408
+ background: '#9CA0A7',
1409
+ } })] }), _jsxs("div", { style: {
1410
+ display: 'flex',
1411
+ gap: 2,
1412
+ flexDirection: 'column',
1413
+ }, children: [_jsx("div", { style: {
1414
+ width: 3,
1415
+ height: 3,
1416
+ borderRadius: 3,
1417
+ background: '#9CA0A7',
1418
+ } }), _jsx("div", { style: {
1419
+ width: 3,
1420
+ height: 3,
1421
+ borderRadius: 3,
1422
+ background: '#9CA0A7',
1423
+ } }), _jsx("div", { style: {
1424
+ width: 3,
1425
+ height: 3,
1426
+ borderRadius: 3,
1427
+ background: '#9CA0A7',
1428
+ } })] })] }) }))] })] }), _jsx("div", { style: {
1429
+ backgroundColor: 'rgba(249, 250, 251, 0.5)',
1430
+ minHeight: '300px',
1431
+ borderRadius: '8px',
1432
+ border: '1px dashed #e5e7eb',
1433
+ width: '100%',
1434
+ } })] })) : (_jsx("div", { style: {
1435
+ display: 'flex',
1436
+ justifyContent: 'space-between',
1437
+ alignItems: 'top',
1438
+ borderRadius: '10px',
1439
+ border: '1px solid #E7E7E7',
1440
+ background: 'white',
1441
+ height: activeItem.chartType === 'metric'
1442
+ ? '150px'
1443
+ : activeItem.chartType === 'table'
1444
+ ? '500px'
1445
+ : '320px',
1446
+ opacity: 0.85,
1447
+ boxShadow: '0px 10px 25px rgba(0,0,0,0.2)',
1448
+ transform: 'rotate(1deg)',
1449
+ zIndex: 9999,
1450
+ pointerEvents: 'none',
1451
+ padding: '15px',
1452
+ transition: 'none',
1453
+ }, "data-chart-type": activeItem.chartType, children: _jsx("div", { style: {
1454
+ display: 'flex',
1455
+ alignItems: 'center',
1456
+ gap: '8px',
1457
+ width: '100%',
1458
+ marginBottom: 'auto',
1459
+ }, children: _jsx("h1", { style: {
1460
+ fontSize: 18,
1461
+ fontWeight: '500',
1462
+ margin: 0,
1463
+ textOverflow: 'ellipsis',
1464
+ overflow: 'hidden',
1465
+ whiteSpace: 'nowrap',
1466
+ maxWidth: '100%',
1467
+ }, children: activeItem.name || 'Report' }) }) }))) })] })] })] }));
1468
+ };
1469
+ const DeleteButton = ({ onClick }) => {
1470
+ return (_jsx("div", { className: "section-delete-button", onClick: onClick, title: "Delete section", style: {
1471
+ display: 'flex',
1472
+ alignItems: 'center',
1473
+ justifyContent: 'center',
1474
+ width: 12,
1475
+ height: 12,
1476
+ }, children: _jsx("svg", { width: "12", height: "12", viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M1 1L13 13M1 13L13 1", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) }));
1477
+ };
1478
+ const SortableSection = ({ id, sectionName, sectionIndex, metrics, charts, tables, data, previewSectionOrder, onClickReport, onSectionNameUpdate, onSectionDelete, activeId, overId, draggedIndex, isHighlighted, isDraggingAnySection, }) => {
1479
+ const { attributes, listeners, setNodeRef: setSortableNodeRef, isDragging, } = useSortable({ id, animateLayoutChanges: () => false });
1480
+ const [isEditing, setIsEditing] = useState(false);
1481
+ const [editedName, setEditedName] = useState(sectionName);
1482
+ const [inputWidth, setInputWidth] = useState('auto');
1483
+ const inputRef = useRef(null);
1484
+ const measurementRef = useRef(null);
1485
+ const h1Ref = useRef(null);
1486
+ const { setNodeRef: setDroppableNodeRef, isOver } = useDroppable({
1487
+ id: `section-${sectionName}`,
1488
+ data: {
1489
+ section: sectionName,
1490
+ type: 'section',
1491
+ },
1492
+ disabled: sectionName === '', // Disable dropping on unassigned section
1493
+ });
1494
+ const setNodeRef = useCallback((node) => {
1495
+ setSortableNodeRef(node);
1496
+ setDroppableNodeRef(node);
1497
+ }, [setSortableNodeRef, setDroppableNodeRef]);
1498
+ const calculateTextWidth = (text) => {
1499
+ if (!measurementRef.current)
1500
+ return 0;
1501
+ measurementRef.current.textContent = text;
1502
+ const width = measurementRef.current.getBoundingClientRect().width;
1503
+ return width;
1504
+ };
1505
+ useEffect(() => {
1506
+ if (isEditing && inputRef.current) {
1507
+ inputRef.current.focus();
1508
+ inputRef.current.selectionStart = inputRef.current.value.length;
1509
+ const width = calculateTextWidth(editedName);
1510
+ setInputWidth(`${width}px`);
1511
+ }
1512
+ }, [isEditing]);
1513
+ const handleTextChange = (e) => {
1514
+ const newText = e.target.value;
1515
+ setEditedName(newText);
1516
+ const width = calculateTextWidth(newText);
1517
+ setInputWidth(`${width}px`);
1518
+ };
1519
+ const handleStartEditing = () => {
1520
+ // Don't allow editing for empty section name (default section)
1521
+ if (sectionName === '')
1522
+ return;
1523
+ if (h1Ref.current) {
1524
+ setIsEditing(true);
1525
+ }
1526
+ else {
1527
+ setIsEditing(true);
1528
+ }
1529
+ };
1530
+ const handleSave = () => {
1531
+ if (isEditing && editedName.trim() !== '' && editedName !== sectionName) {
1532
+ // Make sure name doesn't already exist
1533
+ const sectionNames = Object.keys(data?.sections ?? {});
1534
+ if (sectionNames.includes(editedName)) {
1535
+ alert('Section name already exists');
1536
+ setEditedName(sectionName);
1537
+ }
1538
+ else {
1539
+ onSectionNameUpdate(sectionName, editedName);
1540
+ }
1541
+ }
1542
+ setIsEditing(false);
1543
+ };
1544
+ const handleKeyDown = (e) => {
1545
+ if (e.key === 'Enter') {
1546
+ handleSave();
1547
+ }
1548
+ else if (e.key === 'Escape') {
1549
+ setEditedName(sectionName);
1550
+ setIsEditing(false);
1551
+ }
1552
+ };
1553
+ // Handle clicking outside to save
1554
+ useEffect(() => {
1555
+ const handleClickOutside = (event) => {
1556
+ if (isEditing &&
1557
+ inputRef.current &&
1558
+ !inputRef.current.contains(event.target)) {
1559
+ handleSave();
1560
+ }
1561
+ };
1562
+ if (isEditing) {
1563
+ document.addEventListener('mousedown', handleClickOutside);
1564
+ }
1565
+ return () => {
1566
+ document.removeEventListener('mousedown', handleClickOutside);
1567
+ };
1568
+ }, [isEditing, handleSave]);
1569
+ const handleDeleteSection = () => {
1570
+ if (sectionName === '')
1571
+ return;
1572
+ if (window.confirm(`Are you sure you want to delete "${sectionName}"? All reports will be moved to the unassigned section.`)) {
1573
+ onSectionDelete(sectionName);
1574
+ }
1575
+ };
1576
+ const isDraggedOver = (overId?.split('::')[1] === sectionName ||
1577
+ overId === sectionName ||
1578
+ (overId?.startsWith('::') && sectionName == '')) &&
1579
+ activeId?.split('::')[0] !== sectionName;
1580
+ const isDraggingThisSection = activeId === sectionName;
1581
+ const shouldHighlight = (isDraggedOver || isOver) &&
1582
+ !isDraggingThisSection &&
1583
+ !activeId?.startsWith(sectionName + '::');
1584
+ const style = {
1585
+ zIndex: isDragging ? 100 : undefined,
1586
+ position: 'relative',
1587
+ boxShadow: shouldHighlight
1588
+ ? '0 0 0 2px #3b82f6, 0 0 20px rgba(59, 130, 246, 0.2)'
1589
+ : undefined,
1590
+ backgroundColor: shouldHighlight ? 'rgba(59, 130, 246, 0.05)' : undefined,
1591
+ borderRadius: shouldHighlight ? '8px' : undefined,
1592
+ padding: shouldHighlight ? '12px' : '0px',
1593
+ margin: shouldHighlight ? '-12px' : '0px',
1594
+ };
1595
+ const sectionClassName = `section-container ${shouldHighlight ? 'section-highlighted' : ''}`;
1596
+ const dataAttributes = {
1597
+ 'data-is-over': shouldHighlight ? 'true' : 'false',
1598
+ 'data-section': sectionName,
1599
+ 'data-unassigned': sectionName === '' ? 'true' : 'false',
1600
+ };
1601
+ const hasMultipleSections = useMemo(() => {
1602
+ return Object.keys(data?.sections || {}).length > 1;
1603
+ }, [data?.sections]);
1604
+ const isDefaultSection = sectionName === '';
1605
+ const reports = useMemo(() => {
1606
+ return previewSectionOrder[sectionName]
1607
+ ? // sort the reports based on the preview order
1608
+ data?.sections?.[sectionName]?.sort((a, b) => {
1609
+ const aIndex = previewSectionOrder[sectionName]?.indexOf(a.id) ?? 0;
1610
+ const bIndex = previewSectionOrder[sectionName]?.indexOf(b.id) ?? 0;
1611
+ return aIndex - bIndex;
1612
+ })
1613
+ : data?.sections?.[sectionName] || [];
1614
+ }, [data?.sections[sectionName], previewSectionOrder[sectionName]]);
1615
+ const isEmpty = reports.length === 0;
1616
+ const containerClass = `section-grid-container ${isEmpty ? 'empty' : ''} ${isHighlighted ? 'active-drop-target' : ''}`;
1617
+ const showTopDropIndicator = isDraggingAnySection &&
1618
+ draggedIndex !== undefined &&
1619
+ draggedIndex > sectionIndex &&
1620
+ isHighlighted;
1621
+ const showBottomDropIndicator = isDraggingAnySection &&
1622
+ draggedIndex !== undefined &&
1623
+ draggedIndex < sectionIndex &&
1624
+ isHighlighted;
1625
+ return (_jsxs("div", { className: "sortable-section-wrapper", style: {
1626
+ position: 'relative',
1627
+ marginBottom: 20,
1628
+ marginTop: 0,
1629
+ transition: 'margin 0.2s ease',
1630
+ }, children: [_jsx("div", { className: `section-drop-indicator top ${showTopDropIndicator ? 'active' : ''}`, style: {
1631
+ position: 'absolute',
1632
+ top: -30,
1633
+ left: 0,
1634
+ right: 0,
1635
+ height: 4,
1636
+ backgroundColor: '#3b82f6',
1637
+ borderRadius: 2,
1638
+ opacity: showTopDropIndicator ? 1 : 0,
1639
+ transition: 'opacity 0.15s ease',
1640
+ zIndex: 999,
1641
+ } }), _jsxs("div", { ref: setNodeRef, style: style, className: sectionClassName, ...dataAttributes, children: [_jsx("span", { ref: measurementRef, style: {
1642
+ position: 'absolute',
1643
+ visibility: 'hidden',
1644
+ whiteSpace: 'pre',
1645
+ fontSize: '22px',
1646
+ fontWeight: 'bold',
1647
+ fontFamily: 'inherit',
1648
+ } }), _jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 20 }, children: [_jsxs("div", { className: "section-header", style: { marginTop: sectionIndex > 0 ? 20 : 0 }, children: [sectionName ? (isEditing ? (_jsx("input", { ref: inputRef, className: "section-name-input", value: editedName, onChange: handleTextChange, onKeyDown: handleKeyDown, onBlur: handleSave, style: {
1649
+ fontSize: 22,
1650
+ fontWeight: 'bold',
1651
+ width: inputWidth,
1652
+ minWidth: '20px',
1653
+ textAlign: 'left',
1654
+ display: 'block',
1655
+ lineHeight: 'normal',
1656
+ margin: 0,
1657
+ padding: 0,
1658
+ } })) : (_jsx("h1", { className: isDefaultSection ? '' : 'section-name-display', onClick: isDefaultSection ? undefined : handleStartEditing, ref: h1Ref, style: {
1659
+ fontSize: 22,
1660
+ fontWeight: 'bold',
1661
+ textAlign: 'left',
1662
+ margin: 0,
1663
+ padding: 0,
1664
+ lineHeight: 'normal',
1665
+ display: 'block',
1666
+ cursor: isDefaultSection ? 'default' : 'pointer',
1667
+ }, children: isDefaultSection && hasMultipleSections
1668
+ ? 'Unassigned Items'
1669
+ : sectionName }))) : (
1670
+ // For the default empty section, show a non-editable header
1671
+ // (isDefaultSection && hasMultipleSections) && <h1
1672
+ // style={{
1673
+ // fontSize: 22,
1674
+ // fontWeight: 'bold',
1675
+ // textAlign: 'left',
1676
+ // margin: 0,
1677
+ // padding: 0,
1678
+ // lineHeight: 'normal',
1679
+ // display: 'block'
1680
+ // }}
1681
+ // >
1682
+ // Unassigned Items
1683
+ // </h1>
1684
+ _jsx(_Fragment, {})), _jsxs("div", { style: { display: 'flex', gap: 4, alignItems: 'center' }, children: [!isDefaultSection && (_jsx(DeleteButton, { onClick: handleDeleteSection })), !isDefaultSection && (_jsx("div", { className: `section-drag-handle`, children: _jsx(HandleButton, { ...listeners, ...attributes }) }))] })] }), _jsx("div", { className: containerClass, style: {
1685
+ boxSizing: 'border-box',
1686
+ width: '100%',
1687
+ minHeight: isEmpty ? '120px' : 'auto',
1688
+ padding: isEmpty ? '10px' : '0px',
1689
+ display: isEmpty && sectionName === '' ? 'none' : 'block',
1690
+ }, children: isDefaultSection && !isEmpty ? (_jsxs("div", { style: {
1691
+ display: 'flex',
1692
+ flexDirection: 'column',
1693
+ gap: 20,
1694
+ width: '100%',
1695
+ }, children: [(metrics?.[sectionName]?.length ?? 0) > 0 && (_jsx("div", { style: {
1696
+ display: 'grid',
1697
+ gap: 20,
1698
+ gridTemplateColumns: `repeat(auto-fill, minmax(400px, 1fr))`,
1699
+ width: '100%',
1700
+ }, "data-type": "metric", className: "unassigned-category-grid", children: _jsx(SortableContext, { items: metrics?.[sectionName]?.map((item) => `${sectionName}::${item._id || item.id}`) || [], strategy: rectSortingStrategy, children: metrics?.[sectionName]?.map((item) => (_jsx(SortableItem, { id: item.id, section: sectionName, chartType: item.chartType || 'metric', value: item.name || item._id || item.id, onClickReport: onClickReport }, item.id))) }) })), (charts?.[sectionName]?.length ?? 0) > 0 && (_jsx("div", { style: {
1701
+ display: 'grid',
1702
+ gap: 20,
1703
+ gridTemplateColumns: `repeat(auto-fill, minmax(400px, 1fr))`,
1704
+ width: '100%',
1705
+ }, "data-type": "chart", className: "unassigned-category-grid", children: _jsx(SortableContext, { items: charts?.[sectionName]?.map((item) => `${sectionName}::${item._id || item.id}`) || [], strategy: rectSortingStrategy, children: charts?.[sectionName]?.map((item) => (_jsx(SortableItem, { id: item.id, section: sectionName, chartType: item.chartType || 'chart', value: item.name || item._id || item.id, onClickReport: onClickReport }, item.id))) }) })), (tables?.[sectionName]?.length ?? 0) > 0 && (_jsx("div", { style: {
1706
+ display: 'grid',
1707
+ gap: 20,
1708
+ gridTemplateColumns: `repeat(auto-fill, minmax(400px, 1fr))`,
1709
+ width: '100%',
1710
+ }, "data-type": "table", className: "unassigned-category-grid", children: _jsx(SortableContext, { items: tables?.[sectionName]?.map((item) => `${sectionName}::${item._id || item.id}`) || [], strategy: rectSortingStrategy, children: tables?.[sectionName]?.map((item) => (_jsx(SortableItem, { id: item.id, section: sectionName, chartType: "table", value: item.name || item._id || item.id, onClickReport: onClickReport }, item.id))) }) }))] })) : (_jsx("div", { style: {
1711
+ display: 'grid',
1712
+ gap: 20,
1713
+ gridTemplateColumns: `repeat(auto-fill, minmax(400px, 1fr))`,
1714
+ width: '100%',
1715
+ minHeight: isEmpty ? '80px' : 'auto',
1716
+ }, children: _jsx(SortableContext, { items: reports.map((item) => `${sectionName}::${item._id || item.id}`) || [], strategy: () => null, children: reports.map((item) => (_jsx(SortableItem, { id: item.id, section: sectionName, chartType: item?.chartType ?? 'chart', value: item?.name ?? item.id, onClickReport: onClickReport }, item.id))) }) })) })] })] }), _jsx("div", { className: `section-drop-indicator bottom ${showBottomDropIndicator ? 'active' : ''}`, style: {
1717
+ position: 'absolute',
1718
+ bottom: -30,
1719
+ left: 0,
1720
+ right: 0,
1721
+ height: 4,
1722
+ backgroundColor: '#3b82f6',
1723
+ borderRadius: 2,
1724
+ opacity: showBottomDropIndicator ? 1 : 0,
1725
+ transition: 'opacity 0.15s ease',
1726
+ zIndex: 999,
1727
+ } })] }));
1728
+ };
1729
+ const SortableItem = ({ id, section, chartType, value, onClickReport, }) => {
1730
+ const compoundId = `${section}::${id}`;
1731
+ const { attributes, listeners, setNodeRef, transform, isDragging } = useSortable({
1732
+ id: compoundId,
1733
+ data: {
1734
+ chartType,
1735
+ section,
1736
+ id,
1737
+ },
1738
+ animateLayoutChanges: () => false,
1739
+ });
1740
+ const className = `quill-report-edit ${isDragging ? 'dragging-item' : ''}`;
1741
+ const style = {
1742
+ transform: CSS.Translate.toString(transform),
1743
+ display: 'flex',
1744
+ width: '100%',
1745
+ justifyContent: 'space-between',
1746
+ alignItems: 'center',
1747
+ borderRadius: '10px',
1748
+ border: '1px solid #E7E7E7',
1749
+ cursor: isDragging ? 'grabbing' : 'grab',
1750
+ userSelect: 'none',
1751
+ background: 'white',
1752
+ gridColumn: chartType === 'table' ? '1 / -1' : 'auto',
1753
+ height: 'fit-content',
1754
+ zIndex: isDragging ? 999 : undefined,
1755
+ boxShadow: isDragging
1756
+ ? '0px 10px 20px rgba(0,0,0,0.2)'
1757
+ : '0px 2px 8px rgba(56, 65, 81, 0.08)',
1758
+ opacity: isDragging ? 0.8 : 1,
1759
+ position: 'relative',
1760
+ };
1761
+ const handleReportClick = useCallback(() => {
1762
+ onClickReport?.({ id });
1763
+ }, [id, onClickReport]);
1764
+ return (_jsx("div", { ref: setNodeRef, style: {
1765
+ padding: '10px',
1766
+ margin: '-10px',
1767
+ gridColumn: chartType === 'table' ? '1 / -1' : 'auto',
1768
+ }, ...attributes, children: _jsx("div", { className: className, style: style, children: _jsxs("div", { style: {
1769
+ display: 'flex',
1770
+ flexDirection: 'column',
1771
+ width: '100%',
1772
+ padding: 20,
1773
+ cursor: 'pointer',
1774
+ }, onClick: handleReportClick, children: [_jsxs("div", { style: {
1775
+ display: 'flex',
1776
+ flexDirection: 'row',
1777
+ width: '100%',
1778
+ }, children: [_jsx("h1", { style: {
1779
+ fontSize: 18,
1780
+ fontWeight: '500',
1781
+ flexGrow: 1,
1782
+ }, children: value }), _jsx("div", { className: "quill-report-edit-buttons", style: {
1783
+ display: 'flex',
1784
+ flexDirection: 'column',
1785
+ }, children: _jsx(HandleButton, { ...listeners }) })] }), isDragging ? (_jsx("div", { style: {
1786
+ padding: 10,
1787
+ height: chartType === 'metric'
1788
+ ? 80
1789
+ : chartType === 'table'
1790
+ ? 420
1791
+ : 250,
1792
+ background: '#f9fafb',
1793
+ borderRadius: '6px',
1794
+ display: 'flex',
1795
+ alignItems: 'center',
1796
+ justifyContent: 'center',
1797
+ } })) : (_jsx(MemoizedChart, { reportId: id, chartType: chartType }))] }) }) }));
1798
+ };
1799
+ function HandleButton(props) {
1800
+ return (_jsxs("div", { style: {
1801
+ display: 'flex',
1802
+ gap: 2,
1803
+ flexDirection: 'row',
1804
+ paddingTop: 8,
1805
+ paddingBottom: 8,
1806
+ paddingLeft: 8,
1807
+ paddingRight: 8,
1808
+ borderRadius: 4,
1809
+ cursor: 'grab',
1810
+ }, className: "handle", ...props, children: [_jsx("style", { children: `.handle:hover{background:rgba(0,0,0,0.03);}` }), _jsxs("div", { style: { display: 'flex', gap: 2, flexDirection: 'column' }, children: [_jsx("div", { style: {
1811
+ width: 3,
1812
+ height: 3,
1813
+ borderRadius: 3,
1814
+ background: '#9CA0A7',
1815
+ } }), _jsx("div", { style: {
1816
+ width: 3,
1817
+ height: 3,
1818
+ borderRadius: 3,
1819
+ background: '#9CA0A7',
1820
+ } }), _jsx("div", { style: {
1821
+ width: 3,
1822
+ height: 3,
1823
+ borderRadius: 3,
1824
+ background: '#9CA0A7',
1825
+ } })] }), _jsxs("div", { style: { display: 'flex', gap: 2, flexDirection: 'column' }, children: [_jsx("div", { style: {
1826
+ width: 3,
1827
+ height: 3,
1828
+ borderRadius: 3,
1829
+ background: '#9CA0A7',
1830
+ } }), _jsx("div", { style: {
1831
+ width: 3,
1832
+ height: 3,
1833
+ borderRadius: 3,
1834
+ background: '#9CA0A7',
1835
+ } }), _jsx("div", { style: {
1836
+ width: 3,
1837
+ height: 3,
1838
+ borderRadius: 3,
1839
+ background: '#9CA0A7',
1840
+ } })] })] }));
1841
+ }
1842
+ const NewSectionButton = ({ onAddSection, existingSections, isEditing, setIsEditing, }) => {
1843
+ const [sectionName, setSectionName] = useState('');
1844
+ const [error, setError] = useState('');
1845
+ const inputRef = useRef(null);
1846
+ useEffect(() => {
1847
+ if (isEditing && inputRef.current) {
1848
+ inputRef.current.focus();
1849
+ }
1850
+ }, [isEditing]);
1851
+ const handleClick = () => {
1852
+ setIsEditing(true);
1853
+ };
1854
+ const handleSave = () => {
1855
+ if (sectionName.trim() !== '') {
1856
+ if (existingSections.includes(sectionName.trim())) {
1857
+ setError('Section name already exists');
1858
+ inputRef.current?.focus();
1859
+ return;
1860
+ }
1861
+ onAddSection(sectionName.trim());
1862
+ setSectionName('');
1863
+ setError('');
1864
+ setIsEditing(false);
1865
+ }
1866
+ else {
1867
+ setIsEditing(false);
1868
+ }
1869
+ };
1870
+ const handleKeyDown = (e) => {
1871
+ if (e.key === 'Enter') {
1872
+ if (sectionName.trim() === '') {
1873
+ setError('Section name cannot be empty');
1874
+ return;
1875
+ }
1876
+ if (existingSections.includes(sectionName.trim())) {
1877
+ setError('Section name already exists');
1878
+ return;
1879
+ }
1880
+ onAddSection(sectionName.trim());
1881
+ setSectionName('');
1882
+ setError('');
1883
+ setIsEditing(false);
1884
+ }
1885
+ else if (e.key === 'Escape') {
1886
+ setSectionName('');
1887
+ setError('');
1888
+ setIsEditing(false);
1889
+ }
1890
+ };
1891
+ if (!isEditing) {
1892
+ return (_jsxs("div", { className: "new-section-button", onClick: handleClick, style: {
1893
+ border: '2px dashed #e5e7eb',
1894
+ borderRadius: '8px',
1895
+ marginTop: '20px',
1896
+ padding: '16px',
1897
+ display: 'flex',
1898
+ flexDirection: 'column',
1899
+ alignItems: 'center',
1900
+ justifyContent: 'center',
1901
+ cursor: 'pointer',
1902
+ height: '100px',
1903
+ transition: 'border-color 0.2s ease, background-color 0.2s ease',
1904
+ }, children: [_jsx("div", { style: { fontSize: '24px', fontWeight: 'bold', color: '#9CA0A7' }, children: "+" }), _jsx("div", { style: {
1905
+ marginTop: '8px',
1906
+ fontSize: '16px',
1907
+ fontWeight: 300,
1908
+ color: '#9CA0A7',
1909
+ }, children: "New section" })] }));
1910
+ }
1911
+ return (_jsx("div", { className: "section-container", style: { marginTop: 20 }, children: _jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 20 }, children: [_jsx("div", { className: "section-header", children: _jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx("input", { ref: inputRef, className: "section-name-input", value: sectionName, onChange: (e) => {
1912
+ setSectionName(e.target.value);
1913
+ if (e.target.value.trim() !== '' && error) {
1914
+ setError('');
1915
+ }
1916
+ }, onBlur: handleSave, onKeyDown: handleKeyDown, placeholder: "New section name...", style: {
1917
+ fontSize: 22,
1918
+ fontWeight: 'bold',
1919
+ border: 'none',
1920
+ background: 'transparent',
1921
+ outline: 'none',
1922
+ width: '100%',
1923
+ minWidth: '200px',
1924
+ textAlign: 'left',
1925
+ padding: 0,
1926
+ margin: 0,
1927
+ lineHeight: 'normal',
1928
+ } }), error && (_jsx("div", { style: { color: '#EF4444', fontSize: '14px', marginTop: '4px' }, children: error }))] }) }), _jsx("div", { className: "section-grid-container empty", style: {
1929
+ boxSizing: 'border-box',
1930
+ width: '100%',
1931
+ minHeight: '120px',
1932
+ border: '1px dashed #e5e7eb',
1933
+ borderRadius: '8px',
1934
+ backgroundColor: 'rgba(249, 250, 251, 0.5)',
1935
+ position: 'relative',
1936
+ display: 'flex',
1937
+ alignItems: 'center',
1938
+ justifyContent: 'center',
1939
+ } })] }) }));
1940
+ };