@carlonicora/nextjs-jsonapi 1.0.3 → 1.0.5

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 (515) hide show
  1. package/dist/{AbstractService-BKlpJA61.d.mts → AbstractService-B2n_JdiC.d.mts} +1 -1
  2. package/dist/{AbstractService-D9eSVKNa.d.ts → AbstractService-DtQTYovo.d.ts} +1 -1
  3. package/dist/{content.interface-Dg2lt_An.d.mts → AuthComponent-CPLvEerw.d.mts} +11 -15
  4. package/dist/{content.interface-BhyAiOFq.d.ts → AuthComponent-m6Qp4Hz6.d.ts} +11 -15
  5. package/dist/{BlockNoteEditor-UVO3VZZE.mjs → BlockNoteEditor-BLVXQPXV.mjs} +14 -18
  6. package/dist/{BlockNoteEditor-UVO3VZZE.mjs.map → BlockNoteEditor-BLVXQPXV.mjs.map} +1 -1
  7. package/dist/{BlockNoteEditor-VFWG6LXI.js → BlockNoteEditor-ZTDHULFT.js} +15 -19
  8. package/dist/BlockNoteEditor-ZTDHULFT.js.map +1 -0
  9. package/dist/JsonApiRequest-O7BGUMFO.mjs +23 -0
  10. package/dist/JsonApiRequest-VARLNKAF.js +23 -0
  11. package/dist/JsonApiRequest-VARLNKAF.js.map +1 -0
  12. package/dist/chunk-2LM6LCJW.mjs +1 -0
  13. package/dist/chunk-3APORDYP.mjs +7783 -0
  14. package/dist/chunk-3APORDYP.mjs.map +1 -0
  15. package/dist/{chunk-TMVHSY3Y.js → chunk-5ZEADNNP.js} +36 -17
  16. package/dist/chunk-5ZEADNNP.js.map +1 -0
  17. package/dist/{chunk-ECDTZBYO.mjs → chunk-74F6BBHH.mjs} +21 -2
  18. package/dist/chunk-74F6BBHH.mjs.map +1 -0
  19. package/dist/{chunk-GYWPEPOH.mjs → chunk-7C5RAEBO.mjs} +72 -68
  20. package/dist/chunk-7C5RAEBO.mjs.map +1 -0
  21. package/dist/chunk-A5DDIABK.js +1 -0
  22. package/dist/{chunk-TEGF6ZWG.js → chunk-AGAJMJ4T.js} +47 -9
  23. package/dist/chunk-AGAJMJ4T.js.map +1 -0
  24. package/dist/{chunk-CXQOWQSY.js → chunk-AYHKQWHH.js} +15 -2
  25. package/dist/chunk-AYHKQWHH.js.map +1 -0
  26. package/dist/{chunk-I2REI7OA.js → chunk-HMHGLXWC.js} +33 -15
  27. package/dist/chunk-HMHGLXWC.js.map +1 -0
  28. package/dist/chunk-IWFGEPAA.mjs +1 -0
  29. package/dist/chunk-JC3WJK65.js +1 -0
  30. package/dist/{chunk-L6EQEAXU.mjs → chunk-PYF2U6WG.mjs} +25 -7
  31. package/dist/chunk-PYF2U6WG.mjs.map +1 -0
  32. package/dist/{chunk-YDVTFM7X.mjs → chunk-RBIVEH2K.mjs} +42 -4
  33. package/dist/chunk-RBIVEH2K.mjs.map +1 -0
  34. package/dist/{chunk-V2JJPI7N.js → chunk-RZO2LOW4.js} +237 -233
  35. package/dist/chunk-RZO2LOW4.js.map +1 -0
  36. package/dist/{chunk-X4BIHJ2B.mjs → chunk-SM63SZCP.mjs} +15 -2
  37. package/dist/chunk-SM63SZCP.mjs.map +1 -0
  38. package/dist/chunk-WEC4YMOS.js +7783 -0
  39. package/dist/chunk-WEC4YMOS.js.map +1 -0
  40. package/dist/client/index.d.mts +21 -2
  41. package/dist/client/index.d.ts +21 -2
  42. package/dist/client/index.js +18 -245
  43. package/dist/client/index.js.map +1 -1
  44. package/dist/client/index.mjs +28 -255
  45. package/dist/client/index.mjs.map +1 -1
  46. package/dist/components/index.d.mts +293 -8
  47. package/dist/components/index.d.ts +293 -8
  48. package/dist/components/index.js +78 -2323
  49. package/dist/components/index.js.map +1 -1
  50. package/dist/components/index.mjs +172 -2417
  51. package/dist/components/index.mjs.map +1 -1
  52. package/dist/{config-hXufftVS.d.ts → config-BmnK65TD.d.mts} +1 -0
  53. package/dist/{config-hXufftVS.d.mts → config-BmnK65TD.d.ts} +1 -0
  54. package/dist/config-DQeAo9Kf.d.mts +49 -0
  55. package/dist/config-DQeAo9Kf.d.ts +49 -0
  56. package/dist/contexts/index.d.mts +109 -21
  57. package/dist/contexts/index.d.ts +109 -21
  58. package/dist/contexts/index.js +39 -7
  59. package/dist/contexts/index.js.map +1 -1
  60. package/dist/contexts/index.mjs +40 -8
  61. package/dist/core/index.d.mts +3 -4
  62. package/dist/core/index.d.ts +3 -4
  63. package/dist/core/index.js +3 -7
  64. package/dist/core/index.js.map +1 -1
  65. package/dist/core/index.mjs +4 -8
  66. package/dist/{d3.link.interface-QMdB22bC.d.mts → d3.link.interface-ClC4Irqp.d.mts} +2 -1
  67. package/dist/{d3.link.interface-QMdB22bC.d.ts → d3.link.interface-ClC4Irqp.d.ts} +2 -1
  68. package/dist/features/index.d.mts +17 -86
  69. package/dist/features/index.d.ts +17 -86
  70. package/dist/features/index.js +7 -16
  71. package/dist/features/index.js.map +1 -1
  72. package/dist/features/index.mjs +10 -19
  73. package/dist/hooks/index.d.mts +18 -43
  74. package/dist/hooks/index.d.ts +18 -43
  75. package/dist/hooks/index.js +20 -7
  76. package/dist/hooks/index.js.map +1 -1
  77. package/dist/hooks/index.mjs +19 -6
  78. package/dist/index.d.mts +10 -6
  79. package/dist/index.d.ts +10 -6
  80. package/dist/index.js +13 -10
  81. package/dist/index.js.map +1 -1
  82. package/dist/index.mjs +22 -19
  83. package/dist/interfaces/index.d.mts +2 -1
  84. package/dist/interfaces/index.d.ts +2 -1
  85. package/dist/notification.interface-BBgMUdLR.d.mts +14 -0
  86. package/dist/notification.interface-gyvT-Z2F.d.ts +14 -0
  87. package/dist/permissions/index.d.mts +2 -3
  88. package/dist/permissions/index.d.ts +2 -3
  89. package/dist/server/index.d.mts +38 -18
  90. package/dist/server/index.d.ts +38 -18
  91. package/dist/server/index.js +70 -2
  92. package/dist/server/index.js.map +1 -1
  93. package/dist/server/index.mjs +68 -0
  94. package/dist/server/index.mjs.map +1 -1
  95. package/dist/types-BUAlgqqh.d.ts +39 -0
  96. package/dist/{types-DluCaP1I.d.ts → types-Bl61ob-7.d.mts} +19 -2
  97. package/dist/{types-lQVA8d_P.d.mts → types-Bl61ob-7.d.ts} +19 -2
  98. package/dist/types-iVdVY7ba.d.mts +39 -0
  99. package/dist/useSocket-Cn7fB_B1.d.mts +25 -0
  100. package/dist/useSocket-DzMKRKCA.d.ts +25 -0
  101. package/dist/user.fields-CbdObSmS.d.mts +18 -0
  102. package/dist/user.fields-CbdObSmS.d.ts +18 -0
  103. package/dist/utils/index.d.mts +1 -2
  104. package/dist/utils/index.d.ts +1 -2
  105. package/package.json +6 -3
  106. package/src/atoms/index.ts +1 -0
  107. package/src/atoms/recentPagesAtom.ts +10 -0
  108. package/src/client/context/JsonApiContext.ts +61 -0
  109. package/src/client/context/JsonApiProvider.tsx +27 -0
  110. package/src/client/context/index.ts +2 -0
  111. package/src/client/hooks/index.ts +3 -0
  112. package/src/client/hooks/useJsonApiGet.ts +188 -0
  113. package/src/client/hooks/useJsonApiMutation.ts +193 -0
  114. package/src/client/hooks/useRehydration.ts +47 -0
  115. package/src/client/index.ts +24 -0
  116. package/src/client/request.ts +97 -0
  117. package/src/client/token.ts +10 -0
  118. package/src/components/containers/PageContainer.tsx +15 -0
  119. package/src/components/containers/ReactMarkdownContainer.tsx +119 -0
  120. package/src/components/containers/TabsContainer.tsx +93 -0
  121. package/src/components/containers/index.ts +3 -0
  122. package/src/components/contents/AttributeElement.tsx +20 -0
  123. package/src/components/contents/index.ts +1 -0
  124. package/src/components/details/AllowedUsersDetails.tsx +23 -0
  125. package/src/components/details/index.ts +1 -0
  126. package/src/components/editors/BlockNoteDiffInlineContent.tsx +152 -0
  127. package/src/components/editors/BlockNoteEditor.tsx +404 -0
  128. package/src/components/editors/BlockNoteEditorContainer.tsx +13 -0
  129. package/src/components/editors/BlockNoteEditorFormattingToolbar.tsx +38 -0
  130. package/src/components/editors/index.ts +1 -0
  131. package/src/components/errors/ErrorDetails.tsx +41 -0
  132. package/src/components/errors/errorToast.ts +9 -0
  133. package/src/components/errors/index.ts +2 -0
  134. package/src/components/forms/CommonAssociationForm.tsx +162 -0
  135. package/src/components/forms/CommonDeleter.tsx +94 -0
  136. package/src/components/forms/CommonEditorButtons.tsx +30 -0
  137. package/src/components/forms/CommonEditorHeader.tsx +35 -0
  138. package/src/components/forms/CommonEditorTrigger.tsx +26 -0
  139. package/src/components/forms/DatePickerPopover.tsx +219 -0
  140. package/src/components/forms/DateRangeSelector.tsx +110 -0
  141. package/src/components/forms/FileUploader.tsx +324 -0
  142. package/src/components/forms/FormCheckbox.tsx +66 -0
  143. package/src/components/forms/FormContainerGeneric.tsx +39 -0
  144. package/src/components/forms/FormDate.tsx +247 -0
  145. package/src/components/forms/FormDateTime.tsx +231 -0
  146. package/src/components/forms/FormInput.tsx +110 -0
  147. package/src/components/forms/FormPassword.tsx +54 -0
  148. package/src/components/forms/FormPlaceAutocomplete.tsx +286 -0
  149. package/src/components/forms/FormSelect.tsx +72 -0
  150. package/src/components/forms/FormSlider.tsx +51 -0
  151. package/src/components/forms/FormSwitch.tsx +25 -0
  152. package/src/components/forms/FormTextarea.tsx +44 -0
  153. package/src/components/forms/MultiFileUploader.tsx +107 -0
  154. package/src/components/forms/PasswordInput.tsx +47 -0
  155. package/src/components/forms/index.ts +22 -0
  156. package/src/components/index.ts +16 -0
  157. package/src/components/navigations/Breadcrumb.tsx +83 -0
  158. package/src/components/navigations/ContentTitle.tsx +39 -0
  159. package/src/components/navigations/Header.tsx +27 -0
  160. package/src/components/navigations/ModeToggleSwitch.tsx +25 -0
  161. package/src/components/navigations/PageSection.tsx +64 -0
  162. package/src/components/navigations/RecentPagesNavigator.tsx +52 -0
  163. package/src/components/navigations/index.ts +6 -0
  164. package/src/components/pages/PageContainerContentDetails.tsx +76 -0
  165. package/src/components/pages/PageContentContainer.tsx +31 -0
  166. package/src/components/pages/index.ts +2 -0
  167. package/src/components/tables/ContentListTable.tsx +166 -0
  168. package/src/components/tables/ContentTableSearch.tsx +105 -0
  169. package/src/components/tables/cells/cell.component.tsx +18 -0
  170. package/src/components/tables/cells/cell.date.tsx +16 -0
  171. package/src/components/tables/cells/cell.id.tsx +27 -0
  172. package/src/components/tables/cells/cell.link.tsx +18 -0
  173. package/src/components/tables/cells/cell.text.tsx +12 -0
  174. package/src/components/tables/cells/cell.url.tsx +13 -0
  175. package/src/components/tables/cells/index.ts +5 -0
  176. package/src/components/tables/index.ts +3 -0
  177. package/src/contexts/CommonContext.tsx +52 -0
  178. package/src/contexts/SharedContext.tsx +37 -0
  179. package/src/contexts/SocketContext.tsx +65 -0
  180. package/src/contexts/index.ts +7 -0
  181. package/src/core/abstracts/AbstractApiData.ts +138 -0
  182. package/src/core/abstracts/AbstractService.ts +263 -0
  183. package/src/core/abstracts/index.ts +2 -0
  184. package/src/core/endpoint/EndpointCreator.ts +97 -0
  185. package/src/core/endpoint/index.ts +1 -0
  186. package/src/core/factories/JsonApiDataFactory.ts +12 -0
  187. package/src/core/factories/RehydrationFactory.ts +30 -0
  188. package/src/core/factories/index.ts +2 -0
  189. package/src/core/fields/FieldSelector.ts +15 -0
  190. package/src/core/fields/index.ts +1 -0
  191. package/src/core/index.ts +20 -0
  192. package/src/core/interfaces/ApiData.ts +8 -0
  193. package/src/core/interfaces/ApiDataInterface.ts +15 -0
  194. package/src/core/interfaces/ApiRequestDataTypeInterface.ts +14 -0
  195. package/src/core/interfaces/ApiResponseInterface.ts +17 -0
  196. package/src/core/interfaces/JsonApiHydratedDataInterface.ts +5 -0
  197. package/src/core/interfaces/index.ts +5 -0
  198. package/{dist/chunk-DO2HLAZO.js → src/core/registry/DataClassRegistry.ts} +20 -17
  199. package/src/core/registry/ModuleRegistrar.ts +43 -0
  200. package/src/core/registry/ModuleRegistry.ts +64 -0
  201. package/src/core/registry/index.ts +3 -0
  202. package/src/core/utils/index.ts +2 -0
  203. package/src/core/utils/rehydrate.ts +24 -0
  204. package/src/core/utils/translateResponse.ts +125 -0
  205. package/src/features/auth/auth.module.ts +9 -0
  206. package/src/features/auth/components/containers/AuthContainer.tsx +32 -0
  207. package/src/features/auth/components/containers/index.ts +1 -0
  208. package/src/features/auth/components/details/LandingComponent.tsx +39 -0
  209. package/src/features/auth/components/details/index.ts +1 -0
  210. package/src/features/auth/components/forms/AcceptInvitation.tsx +136 -0
  211. package/src/features/auth/components/forms/ActivateAccount.tsx +75 -0
  212. package/src/features/auth/components/forms/Cookies.tsx +32 -0
  213. package/src/features/auth/components/forms/ForgotPassword.tsx +108 -0
  214. package/src/features/auth/components/forms/Login.tsx +118 -0
  215. package/src/features/auth/components/forms/Logout.tsx +19 -0
  216. package/src/features/auth/components/forms/RefreshUser.tsx +39 -0
  217. package/src/features/auth/components/forms/Register.tsx +150 -0
  218. package/src/features/auth/components/forms/ResetPassword.tsx +126 -0
  219. package/src/features/auth/components/forms/index.ts +9 -0
  220. package/src/features/auth/components/index.ts +3 -0
  221. package/src/features/auth/config.ts +57 -0
  222. package/src/features/auth/contexts/AuthContext.tsx +77 -0
  223. package/src/features/auth/contexts/index.ts +1 -0
  224. package/src/features/auth/data/auth.interface.ts +31 -0
  225. package/src/features/auth/data/auth.service.ts +159 -0
  226. package/src/features/auth/data/auth.ts +54 -0
  227. package/src/features/auth/data/index.ts +3 -0
  228. package/src/features/auth/enums/AuthComponent.ts +9 -0
  229. package/src/features/auth/enums/index.ts +1 -0
  230. package/src/features/auth/index.ts +4 -0
  231. package/src/features/auth/utils/AuthCookies.ts +134 -0
  232. package/src/features/auth/utils/index.ts +1 -0
  233. package/src/features/company/company.module.ts +10 -0
  234. package/src/features/company/components/containers/AdminCompanyContainer.tsx +26 -0
  235. package/src/features/company/components/containers/CompanyContainer.tsx +17 -0
  236. package/src/features/company/components/containers/index.ts +2 -0
  237. package/src/features/company/components/details/CompanyDetails.tsx +26 -0
  238. package/src/features/company/components/details/index.ts +1 -0
  239. package/src/features/company/components/forms/CompanyConfigurationEditor.tsx +151 -0
  240. package/src/features/company/components/forms/CompanyConfigurationSecurityForm.tsx +97 -0
  241. package/src/features/company/components/forms/CompanyDeleter.tsx +121 -0
  242. package/src/features/company/components/forms/CompanyEditor.tsx +245 -0
  243. package/src/features/company/components/forms/CompanyLicense.tsx +213 -0
  244. package/src/features/company/components/forms/index.ts +5 -0
  245. package/src/features/company/components/index.ts +4 -0
  246. package/src/features/company/components/lists/CompaniesList.tsx +31 -0
  247. package/src/features/company/components/lists/index.ts +1 -0
  248. package/src/features/company/contexts/CompanyContext.tsx +99 -0
  249. package/src/features/company/contexts/index.ts +0 -0
  250. package/src/features/company/data/company.fields.ts +6 -0
  251. package/src/features/company/data/company.interface.ts +28 -0
  252. package/src/features/company/data/company.service.ts +73 -0
  253. package/src/features/company/data/company.ts +104 -0
  254. package/src/features/company/data/index.ts +4 -0
  255. package/src/features/company/hooks/index.ts +1 -0
  256. package/src/features/company/hooks/useCompanyTableStructure.tsx +82 -0
  257. package/src/features/company/index.ts +2 -0
  258. package/src/features/content/content.module.ts +20 -0
  259. package/src/features/content/data/content.fields.ts +13 -0
  260. package/src/features/content/data/content.interface.ts +23 -0
  261. package/src/features/content/data/content.service.ts +75 -0
  262. package/src/features/content/data/content.ts +85 -0
  263. package/src/features/content/data/index.ts +4 -0
  264. package/src/features/content/index.ts +2 -0
  265. package/src/features/feature/components/forms/FormFeatures.tsx +150 -0
  266. package/src/features/feature/components/forms/index.ts +1 -0
  267. package/src/features/feature/components/index.ts +1 -0
  268. package/src/features/feature/data/feature.interface.ts +9 -0
  269. package/src/features/feature/data/feature.service.ts +19 -0
  270. package/src/features/feature/data/feature.ts +33 -0
  271. package/src/features/feature/data/index.ts +3 -0
  272. package/src/features/feature/feature.module.ts +10 -0
  273. package/src/features/feature/index.ts +2 -0
  274. package/src/features/index.ts +12 -0
  275. package/src/features/module/data/index.ts +2 -0
  276. package/src/features/module/data/module.interface.ts +12 -0
  277. package/src/features/module/data/module.ts +42 -0
  278. package/src/features/module/index.ts +2 -0
  279. package/src/features/module/module.module.ts +10 -0
  280. package/src/features/notification/components/common/NotificationErrorBoundary.tsx +51 -0
  281. package/src/features/notification/components/common/index.ts +1 -0
  282. package/src/features/notification/components/containers/NotificationsListContainer.tsx +44 -0
  283. package/src/features/notification/components/containers/index.ts +1 -0
  284. package/src/features/notification/components/index.ts +5 -0
  285. package/src/features/notification/components/lists/NotificationsList.tsx +129 -0
  286. package/src/features/notification/components/lists/index.ts +1 -0
  287. package/src/features/notification/components/modals/NotificationModal.tsx +220 -0
  288. package/src/features/notification/components/modals/index.ts +1 -0
  289. package/src/features/notification/components/notifications/Notification.tsx +120 -0
  290. package/src/features/notification/components/notifications/PushNotificationProvider.tsx +9 -0
  291. package/src/features/notification/components/notifications/index.ts +2 -0
  292. package/src/features/notification/contexts/NotificationContext.tsx +187 -0
  293. package/src/features/notification/contexts/index.ts +1 -0
  294. package/src/features/notification/data/index.ts +4 -0
  295. package/src/features/notification/data/notification.fields.ts +8 -0
  296. package/src/features/notification/data/notification.interface.ts +14 -0
  297. package/src/features/notification/data/notification.service.ts +34 -0
  298. package/src/features/notification/data/notification.ts +51 -0
  299. package/src/features/notification/index.ts +2 -0
  300. package/src/features/notification/notification.module.ts +10 -0
  301. package/src/features/push/data/index.ts +3 -0
  302. package/src/features/push/data/push.interface.ts +8 -0
  303. package/src/features/push/data/push.service.ts +17 -0
  304. package/src/features/push/data/push.ts +18 -0
  305. package/src/features/push/index.ts +2 -0
  306. package/src/features/push/push.module.ts +10 -0
  307. package/src/features/role/components/containers/RoleContainer.tsx +18 -0
  308. package/src/features/role/components/containers/index.ts +1 -0
  309. package/src/features/role/components/details/RoleDetails.tsx +21 -0
  310. package/src/features/role/components/details/index.ts +1 -0
  311. package/src/features/role/components/forms/FormRoles.tsx +82 -0
  312. package/src/features/role/components/forms/RemoveUserFromRole.tsx +108 -0
  313. package/src/features/role/components/forms/UserRoleAdd.tsx +128 -0
  314. package/src/features/role/components/forms/index.ts +3 -0
  315. package/src/features/role/components/index.ts +4 -0
  316. package/src/features/role/components/lists/RolesList.tsx +27 -0
  317. package/src/features/role/components/lists/UserRolesList.tsx +31 -0
  318. package/src/features/role/components/lists/index.ts +2 -0
  319. package/src/features/role/contexts/RoleContext.tsx +84 -0
  320. package/src/features/role/contexts/index.ts +1 -0
  321. package/src/features/role/data/index.ts +4 -0
  322. package/src/features/role/data/role.fields.ts +8 -0
  323. package/src/features/role/data/role.interface.ts +16 -0
  324. package/src/features/role/data/role.service.ts +117 -0
  325. package/src/features/role/data/role.ts +62 -0
  326. package/src/features/role/hooks/index.ts +1 -0
  327. package/src/features/role/hooks/useRoleTableStructure.tsx +72 -0
  328. package/src/features/role/index.ts +2 -0
  329. package/src/features/role/role.module.ts +10 -0
  330. package/src/features/s3/data/index.ts +3 -0
  331. package/src/features/s3/data/s3.interface.ts +11 -0
  332. package/src/features/s3/data/s3.service.ts +30 -0
  333. package/src/features/s3/data/s3.ts +60 -0
  334. package/src/features/s3/index.ts +2 -0
  335. package/src/features/s3/s3.module.ts +10 -0
  336. package/src/features/search/index.ts +1 -0
  337. package/src/features/search/interfaces/index.ts +1 -0
  338. package/src/features/search/interfaces/search.result.interface.ts +3 -0
  339. package/src/features/user/author.module.ts +10 -0
  340. package/src/features/user/components/containers/UserContainer.tsx +23 -0
  341. package/src/features/user/components/containers/UserIndexContainer.tsx +12 -0
  342. package/src/features/user/components/containers/UsersListContainer.tsx +36 -0
  343. package/src/features/user/components/containers/index.ts +3 -0
  344. package/src/features/user/components/details/UserDetails.tsx +74 -0
  345. package/src/features/user/components/details/UserIndexDetails.tsx +28 -0
  346. package/src/features/user/components/details/index.ts +2 -0
  347. package/src/features/user/components/forms/RoleUserAdd.tsx +93 -0
  348. package/src/features/user/components/forms/UserAvatarEditor.tsx +78 -0
  349. package/src/features/user/components/forms/UserDeleter.tsx +49 -0
  350. package/src/features/user/components/forms/UserEditor.tsx +319 -0
  351. package/src/features/user/components/forms/UserMultiSelect.tsx +218 -0
  352. package/src/features/user/components/forms/UserReactivator.tsx +79 -0
  353. package/src/features/user/components/forms/UserResentInvitationEmail.tsx +88 -0
  354. package/src/features/user/components/forms/UserSelector.tsx +185 -0
  355. package/src/features/user/components/forms/index.ts +8 -0
  356. package/src/features/user/components/index.ts +5 -0
  357. package/src/features/user/components/lists/AdminUsersList.tsx +41 -0
  358. package/src/features/user/components/lists/CompanyUsersList.tsx +44 -0
  359. package/src/features/user/components/lists/ContributorsList.tsx +41 -0
  360. package/src/features/user/components/lists/RelevantUsersList.tsx +30 -0
  361. package/src/features/user/components/lists/RoleUsersList.tsx +31 -0
  362. package/src/features/user/components/lists/UserListInAdd.tsx +53 -0
  363. package/src/features/user/components/lists/UsersList.tsx +30 -0
  364. package/src/features/user/components/lists/UsersListByContentIds.tsx +30 -0
  365. package/src/features/user/components/lists/index.ts +8 -0
  366. package/src/features/user/components/widgets/UserAvatar.tsx +86 -0
  367. package/src/features/user/components/widgets/UserAvatarList.tsx +31 -0
  368. package/src/features/user/components/widgets/UserSearchPopover.tsx +89 -0
  369. package/src/features/user/components/widgets/index.ts +1 -0
  370. package/src/features/user/contexts/CurrentUserContext.tsx +156 -0
  371. package/src/features/user/contexts/UserContext.tsx +106 -0
  372. package/src/features/user/contexts/index.ts +2 -0
  373. package/src/features/user/data/index.ts +4 -0
  374. package/src/features/user/data/user.fields.ts +8 -0
  375. package/src/features/user/data/user.interface.ts +41 -0
  376. package/src/features/user/data/user.service.ts +246 -0
  377. package/src/features/user/data/user.ts +162 -0
  378. package/src/features/user/hooks/index.ts +2 -0
  379. package/src/features/user/hooks/useUserSearch.ts +53 -0
  380. package/src/features/user/hooks/useUserTableStructure.tsx +115 -0
  381. package/src/features/user/index.ts +3 -0
  382. package/src/features/user/user.module.ts +21 -0
  383. package/src/hooks/TableGeneratorRegistry.ts +53 -0
  384. package/src/hooks/index.ts +37 -0
  385. package/src/hooks/types.ts +35 -0
  386. package/src/hooks/url.rewriter.ts +22 -0
  387. package/src/hooks/useCustomD3Graph.tsx +707 -0
  388. package/src/hooks/useDataListRetriever.ts +349 -0
  389. package/src/hooks/useDebounce.ts +33 -0
  390. package/src/hooks/useNotificationSync.ts +20 -0
  391. package/src/hooks/usePageTracker.ts +69 -0
  392. package/src/hooks/usePageUrlGenerator.ts +50 -0
  393. package/src/hooks/usePushNotifications.ts +82 -0
  394. package/src/hooks/useSocket.ts +201 -0
  395. package/src/hooks/useTableGenerator.ts +20 -0
  396. package/src/i18n/config.ts +74 -0
  397. package/src/i18n/index.ts +18 -0
  398. package/src/index.ts +20 -0
  399. package/src/interfaces/breadcrumb.item.data.interface.ts +4 -0
  400. package/src/interfaces/d3.link.interface.ts +8 -0
  401. package/src/interfaces/d3.node.interface.ts +12 -0
  402. package/src/interfaces/index.ts +3 -0
  403. package/src/permissions/check.ts +127 -0
  404. package/src/permissions/index.ts +2 -0
  405. package/src/permissions/types.ts +109 -0
  406. package/src/roles/config.ts +46 -0
  407. package/src/roles/index.ts +1 -0
  408. package/src/server/ServerSession.ts +103 -0
  409. package/src/server/cache.ts +28 -0
  410. package/src/server/index.ts +4 -0
  411. package/src/server/request.ts +113 -0
  412. package/src/server/token.ts +10 -0
  413. package/src/shadcnui/custom/kanban.tsx +1001 -0
  414. package/src/shadcnui/custom/link.tsx +18 -0
  415. package/src/shadcnui/custom/multi-select.tsx +382 -0
  416. package/src/shadcnui/index.ts +49 -0
  417. package/src/shadcnui/ui/accordion.tsx +52 -0
  418. package/src/shadcnui/ui/alert-dialog.tsx +141 -0
  419. package/src/shadcnui/ui/alert.tsx +43 -0
  420. package/src/shadcnui/ui/avatar.tsx +50 -0
  421. package/src/shadcnui/ui/badge.tsx +40 -0
  422. package/src/shadcnui/ui/breadcrumb.tsx +115 -0
  423. package/src/shadcnui/ui/button.tsx +51 -0
  424. package/src/shadcnui/ui/calendar.tsx +73 -0
  425. package/src/shadcnui/ui/card.tsx +43 -0
  426. package/src/shadcnui/ui/carousel.tsx +225 -0
  427. package/src/shadcnui/ui/chart.tsx +320 -0
  428. package/src/shadcnui/ui/checkbox.tsx +29 -0
  429. package/src/shadcnui/ui/collapsible.tsx +11 -0
  430. package/src/shadcnui/ui/command.tsx +155 -0
  431. package/src/shadcnui/ui/context-menu.tsx +179 -0
  432. package/src/shadcnui/ui/dialog.tsx +96 -0
  433. package/src/shadcnui/ui/drawer.tsx +89 -0
  434. package/src/shadcnui/ui/dropdown-menu.tsx +205 -0
  435. package/src/shadcnui/ui/form.tsx +138 -0
  436. package/src/shadcnui/ui/hover-card.tsx +29 -0
  437. package/src/shadcnui/ui/input.tsx +21 -0
  438. package/src/shadcnui/ui/label.tsx +26 -0
  439. package/src/shadcnui/ui/navigation-menu.tsx +168 -0
  440. package/src/shadcnui/ui/popover.tsx +33 -0
  441. package/src/shadcnui/ui/progress.tsx +25 -0
  442. package/src/shadcnui/ui/radio-group.tsx +37 -0
  443. package/src/shadcnui/ui/resizable.tsx +47 -0
  444. package/src/shadcnui/ui/scroll-area.tsx +40 -0
  445. package/src/shadcnui/ui/select.tsx +164 -0
  446. package/src/shadcnui/ui/separator.tsx +28 -0
  447. package/src/shadcnui/ui/sheet.tsx +139 -0
  448. package/src/shadcnui/ui/sidebar.tsx +677 -0
  449. package/src/shadcnui/ui/skeleton.tsx +13 -0
  450. package/src/shadcnui/ui/slider.tsx +25 -0
  451. package/src/shadcnui/ui/sonner.tsx +25 -0
  452. package/src/shadcnui/ui/switch.tsx +31 -0
  453. package/src/shadcnui/ui/table.tsx +120 -0
  454. package/src/shadcnui/ui/tabs.tsx +55 -0
  455. package/src/shadcnui/ui/textarea.tsx +24 -0
  456. package/src/shadcnui/ui/toggle.tsx +39 -0
  457. package/src/shadcnui/ui/tooltip.tsx +61 -0
  458. package/src/unified/JsonApiRequest.ts +348 -0
  459. package/src/unified/index.ts +1 -0
  460. package/src/utils/blocknote-diff.util.ts +815 -0
  461. package/src/utils/blocknote-word-diff-renderer.util.ts +413 -0
  462. package/src/utils/cn.ts +6 -0
  463. package/src/utils/compose-refs.ts +61 -0
  464. package/src/utils/date-formatter.ts +53 -0
  465. package/src/utils/exists.ts +7 -0
  466. package/src/utils/index.ts +15 -0
  467. package/src/utils/schemas/entity.object.schema.ts +8 -0
  468. package/src/utils/schemas/index.ts +2 -0
  469. package/src/utils/schemas/user.object.schema.ts +9 -0
  470. package/src/utils/table-options.ts +67 -0
  471. package/src/utils/use-mobile.tsx +21 -0
  472. package/dist/ApiRequestDataTypeInterface-CUKFDBx2.d.mts +0 -20
  473. package/dist/ApiRequestDataTypeInterface-CUKFDBx2.d.ts +0 -20
  474. package/dist/BlockNoteEditor-VFWG6LXI.js.map +0 -1
  475. package/dist/JsonApiRequest-S3ICLM7B.mjs +0 -20
  476. package/dist/JsonApiRequest-ZZLSP26T.js +0 -20
  477. package/dist/JsonApiRequest-ZZLSP26T.js.map +0 -1
  478. package/dist/chunk-366S2JCC.mjs +0 -31
  479. package/dist/chunk-366S2JCC.mjs.map +0 -1
  480. package/dist/chunk-5W6AKZE6.mjs +0 -131
  481. package/dist/chunk-5W6AKZE6.mjs.map +0 -1
  482. package/dist/chunk-A3J3AAYM.mjs +0 -97
  483. package/dist/chunk-A3J3AAYM.mjs.map +0 -1
  484. package/dist/chunk-AWONBQQP.js +0 -97
  485. package/dist/chunk-AWONBQQP.js.map +0 -1
  486. package/dist/chunk-CXQOWQSY.js.map +0 -1
  487. package/dist/chunk-DKKMWBP4.mjs +0 -1
  488. package/dist/chunk-DKKMWBP4.mjs.map +0 -1
  489. package/dist/chunk-DO2HLAZO.js.map +0 -1
  490. package/dist/chunk-DZXDB3K2.mjs +0 -17
  491. package/dist/chunk-DZXDB3K2.mjs.map +0 -1
  492. package/dist/chunk-ECDTZBYO.mjs.map +0 -1
  493. package/dist/chunk-FY4SXJGU.js +0 -806
  494. package/dist/chunk-FY4SXJGU.js.map +0 -1
  495. package/dist/chunk-GYWPEPOH.mjs.map +0 -1
  496. package/dist/chunk-H6FMOA6B.js +0 -1
  497. package/dist/chunk-H6FMOA6B.js.map +0 -1
  498. package/dist/chunk-I2REI7OA.js.map +0 -1
  499. package/dist/chunk-J4Q36PMP.js +0 -31
  500. package/dist/chunk-J4Q36PMP.js.map +0 -1
  501. package/dist/chunk-L6EQEAXU.mjs.map +0 -1
  502. package/dist/chunk-MFO27OHB.mjs +0 -48
  503. package/dist/chunk-MFO27OHB.mjs.map +0 -1
  504. package/dist/chunk-RAF7PNLG.js +0 -131
  505. package/dist/chunk-RAF7PNLG.js.map +0 -1
  506. package/dist/chunk-RUR22SVM.js +0 -17
  507. package/dist/chunk-RUR22SVM.js.map +0 -1
  508. package/dist/chunk-TEGF6ZWG.js.map +0 -1
  509. package/dist/chunk-TMVHSY3Y.js.map +0 -1
  510. package/dist/chunk-V2JJPI7N.js.map +0 -1
  511. package/dist/chunk-WWWMJZEF.mjs +0 -806
  512. package/dist/chunk-WWWMJZEF.mjs.map +0 -1
  513. package/dist/chunk-X4BIHJ2B.mjs.map +0 -1
  514. package/dist/chunk-YDVTFM7X.mjs.map +0 -1
  515. /package/dist/{JsonApiRequest-S3ICLM7B.mjs.map → JsonApiRequest-O7BGUMFO.mjs.map} +0 -0
@@ -0,0 +1,707 @@
1
+ "use client";
2
+
3
+ import * as d3 from "d3";
4
+ import { Loader2 } from "lucide-react";
5
+ import { useCallback, useEffect, useMemo, useRef } from "react";
6
+ import { renderToStaticMarkup } from "react-dom/server";
7
+ import { D3Link, D3Node } from "../interfaces";
8
+
9
+ /**
10
+ * Custom hook for D3 graph visualization with larger circles and more interactive features
11
+ */
12
+ export function useCustomD3Graph(
13
+ nodes: D3Node[],
14
+ links: D3Link[],
15
+ onNodeClick: (nodeId: string) => void,
16
+ visibleNodeIds?: Set<string>,
17
+ loadingNodeIds?: Set<string>,
18
+ containerKey?: string | number,
19
+ ) {
20
+ const svgRef = useRef<SVGSVGElement | null>(null);
21
+ const zoomRef = useRef<d3.ZoomTransform | null>(null);
22
+ const zoomBehaviorRef = useRef<d3.ZoomBehavior<SVGSVGElement, unknown> | null>(null);
23
+ const nodePositionsRef = useRef<Map<string, { x: number; y: number }>>(new Map());
24
+ const prevContainerKeyRef = useRef<string | number | undefined>(containerKey);
25
+
26
+ const zoomToNode = useCallback(
27
+ (nodeId: string, childIds: string[] = []) => {
28
+ if (!svgRef.current || !zoomBehaviorRef.current) return;
29
+
30
+ const svg = d3.select(svgRef.current);
31
+ const zoom = zoomBehaviorRef.current;
32
+
33
+ const targetNode = nodes.find((n) => n.id === nodeId);
34
+ const childNodes = nodes.filter((n) => childIds.includes(n.id));
35
+
36
+ if (!targetNode) return;
37
+
38
+ const positions: { x: number; y: number }[] = [];
39
+
40
+ if (
41
+ targetNode.fx !== undefined &&
42
+ targetNode.fy !== undefined &&
43
+ targetNode.fx !== null &&
44
+ targetNode.fy !== null
45
+ ) {
46
+ positions.push({ x: targetNode.fx, y: targetNode.fy });
47
+ } else if (
48
+ targetNode.x !== undefined &&
49
+ targetNode.y !== undefined &&
50
+ targetNode.x !== null &&
51
+ targetNode.y !== null
52
+ ) {
53
+ positions.push({ x: targetNode.x, y: targetNode.y });
54
+ }
55
+
56
+ childNodes.forEach((child) => {
57
+ if (child.fx !== undefined && child.fy !== undefined && child.fx !== null && child.fy !== null) {
58
+ positions.push({ x: child.fx, y: child.fy });
59
+ } else if (child.x !== undefined && child.y !== undefined && child.x !== null && child.y !== null) {
60
+ positions.push({ x: child.x, y: child.y });
61
+ }
62
+ });
63
+
64
+ if (positions.length === 0) return;
65
+
66
+ const bounds = {
67
+ xMin: Math.min(...positions.map((p) => p.x)),
68
+ xMax: Math.max(...positions.map((p) => p.x)),
69
+ yMin: Math.min(...positions.map((p) => p.y)),
70
+ yMax: Math.max(...positions.map((p) => p.y)),
71
+ };
72
+
73
+ const padding = 150;
74
+ bounds.xMin -= padding;
75
+ bounds.xMax += padding;
76
+ bounds.yMin -= padding;
77
+ bounds.yMax += padding;
78
+
79
+ const width = svgRef.current.clientWidth;
80
+ const height = svgRef.current.clientHeight;
81
+
82
+ const contentWidth = bounds.xMax - bounds.xMin;
83
+ const contentHeight = bounds.yMax - bounds.yMin;
84
+
85
+ const scaleX = width / contentWidth;
86
+ const scaleY = height / contentHeight;
87
+
88
+ let scale = Math.min(scaleX, scaleY);
89
+
90
+ scale = Math.min(Math.max(scale, 0.2), 1.5);
91
+
92
+ const centerX = (bounds.xMin + bounds.xMax) / 2;
93
+ const centerY = (bounds.yMin + bounds.yMax) / 2;
94
+
95
+ const translateX = width / 2 - centerX * scale;
96
+ const translateY = height / 2 - centerY * scale;
97
+
98
+ svg
99
+ .transition()
100
+ .duration(750)
101
+ .call(zoom.transform, d3.zoomIdentity.translate(translateX, translateY).scale(scale));
102
+ },
103
+ [nodes],
104
+ );
105
+
106
+ const colorScale = useMemo(() => {
107
+ const accentColor = "var(--accent)";
108
+
109
+ // Define unified color for all content types
110
+ const contentColor = "hsl(30, 80%, 55%)"; // Orange for all content
111
+
112
+ const groupTypes = new Set<string>();
113
+ nodes.forEach((node) => {
114
+ groupTypes.add(node.instanceType);
115
+ });
116
+
117
+ const typeColorMap = new Map<string, string>();
118
+
119
+ Array.from(groupTypes).forEach((type, index) => {
120
+ if (type === nodes[0]?.instanceType) {
121
+ // Root node
122
+ typeColorMap.set(type, accentColor);
123
+ } else if (type === "documents" || type === "articles" || type === "hyperlinks") {
124
+ // All content types get the same orange color
125
+ typeColorMap.set(type, contentColor);
126
+ } else {
127
+ // Topics, Expertises, etc. - use golden angle
128
+ const hueShift = (index * 137.508) % 360;
129
+ typeColorMap.set(type, `hsl(${hueShift}, 32%, 52%)`);
130
+ }
131
+ });
132
+
133
+ return typeColorMap;
134
+ }, [nodes]);
135
+
136
+ const washOutColor = useCallback((color: string): string => {
137
+ // Parse HSL color and make it lighter and more desaturated
138
+ const hslMatch = color.match(/hsl\((\d+\.?\d*),\s*(\d+\.?\d*)%,\s*(\d+\.?\d*)%\)/);
139
+ if (hslMatch) {
140
+ const hue = parseFloat(hslMatch[1]);
141
+
142
+ // Reduce saturation to 15% and increase lightness to 80%
143
+ return `hsl(${hue}, 15%, 80%)`;
144
+ }
145
+
146
+ // For var(--accent), return a lighter version
147
+ if (color.includes("var(--accent)")) {
148
+ return "hsl(0, 0%, 80%)"; // Light gray for washed out accent
149
+ }
150
+
151
+ // Fallback
152
+ return "hsl(0, 0%, 80%)";
153
+ }, []);
154
+
155
+ const getNodeColor = useCallback(
156
+ (node: D3Node) => {
157
+ const baseColor = colorScale.get(node.instanceType) || "gray";
158
+ if (node.washedOut) {
159
+ return washOutColor(baseColor);
160
+ }
161
+ return baseColor;
162
+ },
163
+ [colorScale, washOutColor],
164
+ );
165
+
166
+ useEffect(() => {
167
+ if (!nodes.length || !svgRef.current) return;
168
+
169
+ const visibleNodes = visibleNodeIds
170
+ ? nodes.filter((node) => visibleNodeIds.has(node.id))
171
+ : nodes.filter((node) => node.visible !== false);
172
+
173
+ const visibleNodeIdSet = new Set(visibleNodes.map((node) => node.id));
174
+ const visibleLinks = links.filter((link) => {
175
+ const sourceId = typeof link.source === "string" ? link.source : link.source.id;
176
+ const targetId = typeof link.target === "string" ? link.target : link.target.id;
177
+ return visibleNodeIdSet.has(sourceId) && visibleNodeIdSet.has(targetId);
178
+ });
179
+
180
+ const svg = d3.select<SVGSVGElement, unknown>(svgRef.current);
181
+ svg.selectAll("*").remove();
182
+
183
+ const container = svgRef.current?.parentElement;
184
+ if (!container) return;
185
+
186
+ const width = container.clientWidth;
187
+ const height = container.clientHeight;
188
+
189
+ svg.attr("width", width).attr("height", height).attr("viewBox", `0 0 ${width} ${height}`);
190
+
191
+ const graphGroup = svg.append("g").attr("class", "graph-content");
192
+
193
+ const zoom = d3
194
+ .zoom<SVGSVGElement, unknown>()
195
+ .scaleExtent([0.1, 4])
196
+ .on("zoom", (event) => {
197
+ const transform = event.transform;
198
+ graphGroup.attr("transform", transform.toString());
199
+ zoomRef.current = transform;
200
+ });
201
+
202
+ zoomBehaviorRef.current = zoom;
203
+
204
+ svg
205
+ .call(zoom as any)
206
+ .on("wheel.zoom", null)
207
+ .on("dblclick.zoom", null);
208
+
209
+ const nodeRadius = 40;
210
+
211
+ const childDistanceFromRoot = Math.min(width, height) * 0.4;
212
+ const grandchildDistanceFromChild = nodeRadius * 10;
213
+
214
+ const centralNodeId = nodes[0].id;
215
+
216
+ const nodeHierarchy = new Map<
217
+ string,
218
+ {
219
+ depth: number;
220
+ parent: string | null;
221
+ children: string[];
222
+ angle?: number;
223
+ x?: number;
224
+ y?: number;
225
+ }
226
+ >();
227
+
228
+ nodeHierarchy.set(centralNodeId, {
229
+ depth: 0,
230
+ parent: null,
231
+ children: [],
232
+ });
233
+
234
+ visibleLinks.forEach((link) => {
235
+ const sourceId = typeof link.source === "string" ? link.source : link.source.id;
236
+ const targetId = typeof link.target === "string" ? link.target : link.target.id;
237
+
238
+ if (sourceId === centralNodeId) {
239
+ nodeHierarchy.set(targetId, { depth: 1, parent: centralNodeId, children: [] });
240
+ const rootNode = nodeHierarchy.get(centralNodeId);
241
+ if (rootNode) {
242
+ rootNode.children.push(targetId);
243
+ }
244
+ }
245
+ });
246
+
247
+ visibleLinks.forEach((link) => {
248
+ const sourceId = typeof link.source === "string" ? link.source : link.source.id;
249
+ const targetId = typeof link.target === "string" ? link.target : link.target.id;
250
+
251
+ const sourceNode = nodeHierarchy.get(sourceId);
252
+ if (sourceNode && sourceNode.depth === 1 && !nodeHierarchy.has(targetId)) {
253
+ nodeHierarchy.set(targetId, { depth: 2, parent: sourceId, children: [] });
254
+ sourceNode.children.push(targetId);
255
+ }
256
+ });
257
+
258
+ const rootChildren = nodeHierarchy.get(centralNodeId)?.children || [];
259
+
260
+ const childAngleStep = (2 * Math.PI) / Math.max(rootChildren.length, 1);
261
+
262
+ rootChildren.forEach((childId, index) => {
263
+ const childNode = nodeHierarchy.get(childId);
264
+ if (childNode) {
265
+ const angle = index * childAngleStep;
266
+ childNode.angle = angle;
267
+ childNode.x = width / 2 + childDistanceFromRoot * Math.cos(angle);
268
+ childNode.y = height / 2 + childDistanceFromRoot * Math.sin(angle);
269
+ }
270
+ });
271
+
272
+ for (const [nodeId, node] of nodeHierarchy.entries()) {
273
+ if (node.depth === 1 && node.angle !== undefined && node.x !== undefined && node.y !== undefined) {
274
+ const childAngle = node.angle;
275
+ const childX = node.x;
276
+ const childY = node.y;
277
+ const grandchildren = node.children;
278
+
279
+ if (grandchildren.length === 0) continue;
280
+
281
+ const dirX = childX - width / 2;
282
+ const dirY = childY - height / 2;
283
+ const dirLength = Math.sqrt(dirX * dirX + dirY * dirY);
284
+
285
+ const normDirX = dirX / dirLength;
286
+ const normDirY = dirY / dirLength;
287
+
288
+ if (grandchildren.length === 1) {
289
+ const grandchildId = grandchildren[0];
290
+ const grandchildNode = nodeHierarchy.get(grandchildId);
291
+ if (grandchildNode) {
292
+ grandchildNode.x = childX + normDirX * grandchildDistanceFromChild;
293
+ grandchildNode.y = childY + normDirY * grandchildDistanceFromChild;
294
+ grandchildNode.angle = childAngle;
295
+ }
296
+ } else {
297
+ // Multiple grandchildren - arrange in semicircular arc
298
+ const numChildren = grandchildren.length;
299
+
300
+ // Dynamic arc span: scale from 60° (2 children) to 180° (7+ children)
301
+ const minArc = Math.PI / 3; // 60 degrees
302
+ const maxArc = Math.PI; // 180 degrees
303
+ const arcProgress = Math.min(1, (numChildren - 2) / 5);
304
+ const arcSpan = minArc + arcProgress * (maxArc - minArc);
305
+
306
+ // Calculate starting angle (center the arc around the radial direction)
307
+ const startAngle = childAngle - arcSpan / 2;
308
+
309
+ grandchildren.forEach((grandchildId, index) => {
310
+ const grandchildNode = nodeHierarchy.get(grandchildId);
311
+ if (!grandchildNode) return;
312
+
313
+ // Calculate angle for this child
314
+ const angleOffset = numChildren > 1 ? (index / (numChildren - 1)) * arcSpan : 0;
315
+ const angle = startAngle + angleOffset;
316
+
317
+ // Position at constant radius from parent
318
+ grandchildNode.x = childX + grandchildDistanceFromChild * Math.cos(angle);
319
+ grandchildNode.y = childY + grandchildDistanceFromChild * Math.sin(angle);
320
+ grandchildNode.angle = angle;
321
+ });
322
+ }
323
+ }
324
+ }
325
+
326
+ visibleNodes.forEach((node) => {
327
+ const savedPosition = nodePositionsRef.current.get(node.id);
328
+
329
+ if (savedPosition) {
330
+ node.fx = savedPosition.x;
331
+ node.fy = savedPosition.y;
332
+ } else {
333
+ const hierarchyNode = nodeHierarchy.get(node.id);
334
+ if (hierarchyNode && hierarchyNode.x !== undefined && hierarchyNode.y !== undefined) {
335
+ node.fx = hierarchyNode.x;
336
+ node.fy = hierarchyNode.y;
337
+ // Save the calculated position so it persists across re-renders
338
+ nodePositionsRef.current.set(node.id, { x: hierarchyNode.x, y: hierarchyNode.y });
339
+ } else if (node.id === centralNodeId) {
340
+ node.fx = width / 2;
341
+ node.fy = height / 2;
342
+ // Save the center position
343
+ nodePositionsRef.current.set(node.id, { x: width / 2, y: height / 2 });
344
+ }
345
+ }
346
+ });
347
+
348
+ const simulation = d3
349
+ .forceSimulation<D3Node>(visibleNodes)
350
+ .force(
351
+ "link",
352
+ d3
353
+ .forceLink<D3Node, D3Link>(visibleLinks)
354
+ .id((d) => d.id)
355
+ .distance(nodeRadius * 3)
356
+ .strength(0.1),
357
+ )
358
+ .force("charge", d3.forceManyBody().strength(-500).distanceMax(300))
359
+ .force("collision", d3.forceCollide().radius(nodeRadius * 1.2))
360
+ .force("center", d3.forceCenter(width / 2, height / 2).strength(0.1));
361
+
362
+ simulation.stop();
363
+ for (let i = 0; i < 100; i++) {
364
+ simulation.tick();
365
+ }
366
+
367
+ visibleNodes.forEach((node) => {
368
+ if (node.fx === undefined) {
369
+ node.fx = node.x;
370
+ node.fy = node.y;
371
+ }
372
+ });
373
+
374
+ const link = graphGroup
375
+ .append("g")
376
+ .attr("stroke", "#999")
377
+ .attr("stroke-opacity", 0.6)
378
+ .selectAll("line")
379
+ .data(visibleLinks)
380
+ .join("line")
381
+ .attr("x1", (d) => (d.source as D3Node).x || 0)
382
+ .attr("y1", (d) => (d.source as D3Node).y || 0)
383
+ .attr("x2", (d) => (d.target as D3Node).x || 0)
384
+ .attr("y2", (d) => (d.target as D3Node).y || 0)
385
+ .attr("stroke-width", 1.5);
386
+
387
+ const node = graphGroup
388
+ .append("g")
389
+ .selectAll("g")
390
+ .data(visibleNodes)
391
+ .join("g")
392
+ .attr("class", "node-group")
393
+ .attr("cursor", "pointer")
394
+ .attr("transform", (d) => `translate(${d.x || 0}, ${d.y || 0})`)
395
+ .call(
396
+ d3
397
+ .drag<SVGGElement, D3Node>()
398
+ .subject(function (d) {
399
+ return d;
400
+ })
401
+ .on("start", function (event, d) {
402
+ d.fx = d.x;
403
+ d.fy = d.y;
404
+ })
405
+ .on("drag", function (event, d) {
406
+ d.fx = event.x;
407
+ d.fy = event.y;
408
+
409
+ d3.select(this).attr("transform", `translate(${event.x}, ${event.y})`);
410
+
411
+ d3.select(this).attr("transform", `translate(${event.x}, ${event.y})`);
412
+
413
+ nodePositionsRef.current.set(d.id, { x: event.x, y: event.y });
414
+
415
+ link
416
+ .attr("x1", (l) => {
417
+ const source = l.source as D3Node;
418
+ return source.fx || source.x || 0;
419
+ })
420
+ .attr("y1", (l) => {
421
+ const source = l.source as D3Node;
422
+ return source.fy || source.y || 0;
423
+ })
424
+ .attr("x2", (l) => {
425
+ const target = l.target as D3Node;
426
+ return target.fx || target.x || 0;
427
+ })
428
+ .attr("y2", (l) => {
429
+ const target = l.target as D3Node;
430
+ return target.fy || target.y || 0;
431
+ });
432
+ })
433
+ .on("end", function (event, d) {
434
+ d.fx = event.x;
435
+ d.fy = event.y;
436
+ }) as any,
437
+ )
438
+ .on("mouseenter", function (_event, d) {
439
+ // Skip hover effect for root node
440
+ if (d.instanceType === "root") return;
441
+
442
+ const currentNode = d3.select(this);
443
+
444
+ // Bring node to front
445
+ currentNode.raise();
446
+
447
+ // Get current zoom scale for counter-scaling text
448
+ const currentZoom = zoomRef.current?.k || 1;
449
+ const targetScreenFontSize = 20; // Target font size in screen pixels
450
+ const baseFontSize = 12; // Base font size in graph coordinates
451
+
452
+ // Calculate smooth scale factor for transform
453
+ const textScale = targetScreenFontSize / (baseFontSize * currentZoom);
454
+
455
+ // Calculate text position offset - circle stays in graph coords, only gap is counter-scaled
456
+ const hoverTextOffset = nodeRadius * 1.4 + 5 / currentZoom;
457
+
458
+ // Scale up the circle with smooth transition (unchanged)
459
+ currentNode
460
+ .select("circle")
461
+ .transition()
462
+ .duration(250)
463
+ .ease(d3.easeExpOut)
464
+ .attr("r", nodeRadius * 1.4)
465
+ .attr("filter", "drop-shadow(0px 4px 12px rgba(0, 0, 0, 0.3))");
466
+
467
+ // Scale up the text with smooth transform scaling around its anchor point
468
+ currentNode
469
+ .select("text")
470
+ .transition()
471
+ .duration(250)
472
+ .ease(d3.easeExpOut)
473
+ .attr("dy", -hoverTextOffset)
474
+ .attr("transform", `translate(0, ${-hoverTextOffset}) scale(${textScale}) translate(0, ${hoverTextOffset})`);
475
+ })
476
+ .on("mouseleave", function (_event, d) {
477
+ // Skip hover effect for root node
478
+ if (d.instanceType === "root") return;
479
+
480
+ const currentNode = d3.select(this);
481
+
482
+ // Return circle to normal size
483
+ currentNode
484
+ .select("circle")
485
+ .transition()
486
+ .duration(250)
487
+ .ease(d3.easeExpOut)
488
+ .attr("r", nodeRadius)
489
+ .attr("filter", null);
490
+
491
+ // Return text to normal size with smooth transform
492
+ const normalOffset = nodeRadius + 5;
493
+ currentNode
494
+ .select("text")
495
+ .transition()
496
+ .duration(250)
497
+ .ease(d3.easeExpOut)
498
+ .attr("dy", -normalOffset)
499
+ .attr("transform", `translate(0, ${-normalOffset}) scale(1) translate(0, ${normalOffset})`);
500
+ });
501
+
502
+ node
503
+ .append("circle")
504
+ .attr("r", nodeRadius)
505
+ .attr("fill", (d) => getNodeColor(d))
506
+ .attr("stroke", "#fff")
507
+ .attr("stroke-width", 1.5)
508
+ .on("click", (event, d) => {
509
+ event.preventDefault();
510
+ event.stopPropagation();
511
+ if (zoomBehaviorRef.current) {
512
+ svg.on(".zoom", null);
513
+ setTimeout(() => {
514
+ if (zoomBehaviorRef.current) {
515
+ svg
516
+ .call(zoomBehaviorRef.current as any)
517
+ .on("wheel.zoom", null)
518
+ .on("dblclick.zoom", null);
519
+ }
520
+ }, 100);
521
+ }
522
+ onNodeClick(d.id);
523
+ });
524
+
525
+ node.each(function (d: D3Node) {
526
+ if (d.icon) {
527
+ const Icon = d.icon as React.FC<{ size: number; color: string }>;
528
+ const iconSvg = renderToStaticMarkup(<Icon size={nodeRadius / 2} color="white" />);
529
+
530
+ const iconGroup = d3
531
+ .select(this)
532
+ .append("g")
533
+ .html(iconSvg)
534
+ .attr("transform", `translate(${-nodeRadius / 4}, ${-nodeRadius / 4})`)
535
+ .style("pointer-events", "all")
536
+ .on("click", (event) => {
537
+ event.stopPropagation();
538
+ onNodeClick(d.id);
539
+ });
540
+ }
541
+ });
542
+
543
+ // Add loading spinner for nodes that are fetching children
544
+ node.each(function (d: D3Node) {
545
+ if (loadingNodeIds && loadingNodeIds.has(d.id)) {
546
+ // Remove existing icon
547
+ d3.select(this).selectAll("g").remove();
548
+
549
+ // Add spinner
550
+ const spinnerSvg = renderToStaticMarkup(<Loader2 size={nodeRadius / 2} color="white" />);
551
+
552
+ d3.select(this)
553
+ .append("g")
554
+ .html(spinnerSvg)
555
+ .attr("class", "animate-spin")
556
+ .attr("transform", `translate(${-nodeRadius / 4}, ${-nodeRadius / 4})`)
557
+ .style("pointer-events", "none");
558
+ }
559
+ });
560
+
561
+ node.each(function (d: D3Node) {
562
+ const textElement = d3
563
+ .select(this)
564
+ .append("text")
565
+ .attr("text-anchor", "middle")
566
+ .attr("font-size", 12)
567
+ .attr("pointer-events", "none");
568
+
569
+ if (d.instanceType === "root") {
570
+ // Split text by spaces for multi-line display
571
+ const words = d.name.split(" ");
572
+ const lineHeight = 1.2; // em units
573
+ const numLines = words.length;
574
+ // Calculate starting position to center the text block vertically
575
+ // Account for the fact that we want the middle of the entire text block at y=0
576
+ const startY = -((numLines - 1) * lineHeight) / 2;
577
+
578
+ textElement.attr("fill", "var(--accent-foreground)").attr("dominant-baseline", "middle");
579
+
580
+ words.forEach((word, index) => {
581
+ textElement
582
+ .append("tspan")
583
+ .attr("x", 0)
584
+ .attr("dy", index === 0 ? `${startY}em` : `${lineHeight}em`)
585
+ .text(word);
586
+ });
587
+ } else {
588
+ // Non-root nodes: single line text above the circle
589
+ textElement
590
+ .attr("dy", -nodeRadius - 5)
591
+ .attr("fill", "currentColor")
592
+ .text(d.name);
593
+ }
594
+ });
595
+
596
+ return () => {
597
+ simulation.stop();
598
+ };
599
+ }, [nodes, links, colorScale, visibleNodeIds, loadingNodeIds, onNodeClick]);
600
+
601
+ const zoomIn = useCallback(() => {
602
+ if (!svgRef.current || !zoomBehaviorRef.current) return;
603
+
604
+ const svg = d3.select(svgRef.current);
605
+ const zoom = zoomBehaviorRef.current;
606
+
607
+ const currentTransform = zoomRef.current || d3.zoomIdentity;
608
+ const newScale = Math.min(currentTransform.k * 1.3, 4);
609
+
610
+ svg
611
+ .transition()
612
+ .duration(300)
613
+ .call(zoom.transform, d3.zoomIdentity.translate(currentTransform.x, currentTransform.y).scale(newScale));
614
+ }, []);
615
+
616
+ const zoomOut = useCallback(() => {
617
+ if (!svgRef.current || !zoomBehaviorRef.current) return;
618
+
619
+ const svg = d3.select(svgRef.current);
620
+ const zoom = zoomBehaviorRef.current;
621
+
622
+ const currentTransform = zoomRef.current || d3.zoomIdentity;
623
+ const newScale = Math.max(currentTransform.k * 0.7, 0.1);
624
+
625
+ svg
626
+ .transition()
627
+ .duration(300)
628
+ .call(zoom.transform, d3.zoomIdentity.translate(currentTransform.x, currentTransform.y).scale(newScale));
629
+ }, []);
630
+
631
+ const zoomToFitAll = useCallback(() => {
632
+ if (!svgRef.current || !zoomBehaviorRef.current) return;
633
+
634
+ const svg = d3.select(svgRef.current);
635
+ const zoom = zoomBehaviorRef.current;
636
+
637
+ // Get all visible nodes
638
+ const visibleNodes = visibleNodeIds
639
+ ? nodes.filter((node) => visibleNodeIds.has(node.id))
640
+ : nodes.filter((node) => node.visible !== false);
641
+
642
+ if (visibleNodes.length === 0) return;
643
+
644
+ // Calculate bounds of all visible nodes
645
+ const positions: { x: number; y: number }[] = [];
646
+ visibleNodes.forEach((node) => {
647
+ if (node.fx !== undefined && node.fy !== undefined && node.fx !== null && node.fy !== null) {
648
+ positions.push({ x: node.fx, y: node.fy });
649
+ } else if (node.x !== undefined && node.y !== undefined && node.x !== null && node.y !== null) {
650
+ positions.push({ x: node.x, y: node.y });
651
+ }
652
+ });
653
+
654
+ if (positions.length === 0) return;
655
+
656
+ const bounds = {
657
+ xMin: Math.min(...positions.map((p) => p.x)),
658
+ xMax: Math.max(...positions.map((p) => p.x)),
659
+ yMin: Math.min(...positions.map((p) => p.y)),
660
+ yMax: Math.max(...positions.map((p) => p.y)),
661
+ };
662
+
663
+ // Add padding
664
+ const padding = 150;
665
+ bounds.xMin -= padding;
666
+ bounds.xMax += padding;
667
+ bounds.yMin -= padding;
668
+ bounds.yMax += padding;
669
+
670
+ const width = svgRef.current.clientWidth;
671
+ const height = svgRef.current.clientHeight;
672
+
673
+ const contentWidth = bounds.xMax - bounds.xMin;
674
+ const contentHeight = bounds.yMax - bounds.yMin;
675
+
676
+ const scaleX = width / contentWidth;
677
+ const scaleY = height / contentHeight;
678
+
679
+ let scale = Math.min(scaleX, scaleY);
680
+ scale = Math.min(Math.max(scale, 0.1), 2); // Clamp between 0.1 and 2
681
+
682
+ const centerX = (bounds.xMin + bounds.xMax) / 2;
683
+ const centerY = (bounds.yMin + bounds.yMax) / 2;
684
+
685
+ const translateX = width / 2 - centerX * scale;
686
+ const translateY = height / 2 - centerY * scale;
687
+
688
+ svg.transition().duration(750).call(zoom.transform, d3.zoomIdentity.translate(translateX, translateY).scale(scale));
689
+ }, [nodes, visibleNodeIds]);
690
+
691
+ // When container size changes (full-screen toggle), zoom to fit all nodes
692
+ // This scales the view instead of recalculating positions, maintaining relative layout
693
+ useEffect(() => {
694
+ if (containerKey !== undefined && containerKey !== prevContainerKeyRef.current) {
695
+ // Small delay to allow the container to finish resizing
696
+ const timeoutId = setTimeout(() => {
697
+ zoomToFitAll();
698
+ }, 100);
699
+
700
+ prevContainerKeyRef.current = containerKey;
701
+
702
+ return () => clearTimeout(timeoutId);
703
+ }
704
+ }, [containerKey, zoomToFitAll]);
705
+
706
+ return { svgRef, zoomIn, zoomOut, zoomToNode, zoomToFitAll };
707
+ }