@jmruthers/pace-core 0.5.191 → 0.5.193

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 (293) hide show
  1. package/dist/{AuthService-CbP_utw2.d.ts → AuthService-DjnJHDtC.d.ts} +1 -0
  2. package/dist/{DataTable-WKRZD47S.js → DataTable-5FU7IESH.js} +7 -6
  3. package/dist/{PublicPageProvider-ULXC_u6U.d.ts → PublicPageProvider-C0Sm_e5k.d.ts} +3 -1
  4. package/dist/{UnifiedAuthProvider-BYA9qB-o.d.ts → UnifiedAuthProvider-185Ih4dj.d.ts} +2 -0
  5. package/dist/{UnifiedAuthProvider-FTSG5XH7.js → UnifiedAuthProvider-RGJTDE2C.js} +3 -3
  6. package/dist/{api-IHKALJZD.js → api-N774RPUA.js} +2 -2
  7. package/dist/chunk-6C4YBBJM 5.js +628 -0
  8. package/dist/chunk-7D4SUZUM.js 2.map +1 -0
  9. package/dist/{chunk-LOMZXPSN.js → chunk-7EQTDTTJ.js} +47 -74
  10. package/dist/chunk-7EQTDTTJ.js 2.map +1 -0
  11. package/dist/chunk-7EQTDTTJ.js.map +1 -0
  12. package/dist/{chunk-6LTQQAT6.js → chunk-7FLMSG37.js} +336 -137
  13. package/dist/chunk-7FLMSG37.js 2.map +1 -0
  14. package/dist/chunk-7FLMSG37.js.map +1 -0
  15. package/dist/{chunk-XNYQOL3Z.js → chunk-BC4IJKSL.js} +9 -18
  16. package/dist/chunk-BC4IJKSL.js.map +1 -0
  17. package/dist/{chunk-ULHIJK66.js → chunk-E3SPN4VZ 5.js } +146 -36
  18. package/dist/chunk-E3SPN4VZ.js +12917 -0
  19. package/dist/{chunk-ULHIJK66.js.map → chunk-E3SPN4VZ.js.map} +1 -1
  20. package/dist/chunk-E66EQZE6 5.js +37 -0
  21. package/dist/chunk-E66EQZE6.js 2.map +1 -0
  22. package/dist/{chunk-6TQDD426.js → chunk-HWIIPPNI.js} +40 -221
  23. package/dist/chunk-HWIIPPNI.js.map +1 -0
  24. package/dist/chunk-I7PSE6JW 5.js +191 -0
  25. package/dist/chunk-I7PSE6JW.js 2.map +1 -0
  26. package/dist/{chunk-OETXORNB.js → chunk-IIELH4DL.js} +211 -136
  27. package/dist/chunk-IIELH4DL.js.map +1 -0
  28. package/dist/{chunk-ROXMHMY2.js → chunk-KNC55RTG.js} +13 -3
  29. package/dist/{chunk-ROXMHMY2.js.map → chunk-KNC55RTG.js 5.map } +1 -1
  30. package/dist/chunk-KNC55RTG.js.map +1 -0
  31. package/dist/chunk-KQCRWDSA.js 5.map +1 -0
  32. package/dist/{chunk-XYXSXPUK.js → chunk-LFNCN2SP.js} +7 -6
  33. package/dist/chunk-LFNCN2SP.js 2.map +1 -0
  34. package/dist/chunk-LFNCN2SP.js.map +1 -0
  35. package/dist/chunk-LMC26NLJ 2.js +84 -0
  36. package/dist/{chunk-VKB2CO4Z.js → chunk-NOAYCWCX 5.js } +84 -87
  37. package/dist/chunk-NOAYCWCX.js +4993 -0
  38. package/dist/chunk-NOAYCWCX.js.map +1 -0
  39. package/dist/chunk-QWWZ5CAQ.js 3.map +1 -0
  40. package/dist/chunk-QXHPKYJV 3.js +113 -0
  41. package/dist/chunk-R77UEZ4E 3.js +68 -0
  42. package/dist/chunk-VBXEHIUJ.js 6.map +1 -0
  43. package/dist/{chunk-VRGWKHDB.js → chunk-XNXXZ43G.js} +77 -33
  44. package/dist/chunk-XNXXZ43G.js.map +1 -0
  45. package/dist/chunk-ZSAAAMVR 6.js +25 -0
  46. package/dist/components.d.ts +2 -2
  47. package/dist/components.js +7 -7
  48. package/dist/components.js 5.map +1 -0
  49. package/dist/hooks.js +8 -8
  50. package/dist/index.d.ts +5 -5
  51. package/dist/index.js +12 -14
  52. package/dist/index.js.map +1 -1
  53. package/dist/providers.d.ts +3 -3
  54. package/dist/providers.js +2 -2
  55. package/dist/rbac/index.d.ts +1 -19
  56. package/dist/rbac/index.js +7 -9
  57. package/dist/styles/index 2.js +12 -0
  58. package/dist/styles/index.js 5.map +1 -0
  59. package/dist/theming/runtime 5.js +19 -0
  60. package/dist/theming/runtime.js 5.map +1 -0
  61. package/dist/utils.js +1 -1
  62. package/docs/api/classes/ColumnFactory.md +1 -1
  63. package/docs/api/classes/ErrorBoundary.md +1 -1
  64. package/docs/api/classes/InvalidScopeError.md +1 -1
  65. package/docs/api/classes/Logger.md +1 -1
  66. package/docs/api/classes/MissingUserContextError.md +1 -1
  67. package/docs/api/classes/OrganisationContextRequiredError.md +1 -1
  68. package/docs/api/classes/PermissionDeniedError.md +2 -2
  69. package/docs/api/classes/RBACAuditManager.md +2 -2
  70. package/docs/api/classes/RBACCache.md +1 -1
  71. package/docs/api/classes/RBACEngine.md +2 -2
  72. package/docs/api/classes/RBACError.md +1 -1
  73. package/docs/api/classes/RBACNotInitializedError.md +1 -1
  74. package/docs/api/classes/SecureSupabaseClient.md +10 -10
  75. package/docs/api/classes/StorageUtils.md +1 -1
  76. package/docs/api/enums/FileCategory.md +1 -1
  77. package/docs/api/enums/LogLevel.md +1 -1
  78. package/docs/api/enums/RBACErrorCode.md +1 -1
  79. package/docs/api/enums/RPCFunction.md +1 -1
  80. package/docs/api/interfaces/AddressFieldProps.md +1 -1
  81. package/docs/api/interfaces/AddressFieldRef.md +1 -1
  82. package/docs/api/interfaces/AggregateConfig.md +1 -1
  83. package/docs/api/interfaces/AutocompleteOptions.md +1 -1
  84. package/docs/api/interfaces/AvatarProps.md +1 -1
  85. package/docs/api/interfaces/BadgeProps.md +1 -1
  86. package/docs/api/interfaces/ButtonProps.md +1 -1
  87. package/docs/api/interfaces/CalendarProps.md +1 -1
  88. package/docs/api/interfaces/CardProps.md +1 -1
  89. package/docs/api/interfaces/ColorPalette.md +1 -1
  90. package/docs/api/interfaces/ColorShade.md +1 -1
  91. package/docs/api/interfaces/ComplianceResult.md +1 -1
  92. package/docs/api/interfaces/DataAccessRecord.md +1 -1
  93. package/docs/api/interfaces/DataRecord.md +1 -1
  94. package/docs/api/interfaces/DataTableAction.md +1 -1
  95. package/docs/api/interfaces/DataTableColumn.md +1 -1
  96. package/docs/api/interfaces/DataTableProps.md +1 -1
  97. package/docs/api/interfaces/DataTableToolbarButton.md +1 -1
  98. package/docs/api/interfaces/DatabaseComplianceResult.md +1 -1
  99. package/docs/api/interfaces/DatabaseIssue.md +1 -1
  100. package/docs/api/interfaces/EmptyStateConfig.md +1 -1
  101. package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
  102. package/docs/api/interfaces/EventAppRoleData.md +1 -1
  103. package/docs/api/interfaces/ExportColumn.md +1 -1
  104. package/docs/api/interfaces/ExportOptions.md +1 -1
  105. package/docs/api/interfaces/FileDisplayProps.md +24 -11
  106. package/docs/api/interfaces/FileMetadata.md +1 -1
  107. package/docs/api/interfaces/FileReference.md +1 -1
  108. package/docs/api/interfaces/FileSizeLimits.md +1 -1
  109. package/docs/api/interfaces/FileUploadOptions.md +1 -1
  110. package/docs/api/interfaces/FileUploadProps.md +1 -1
  111. package/docs/api/interfaces/FooterProps.md +1 -1
  112. package/docs/api/interfaces/FormFieldProps.md +1 -1
  113. package/docs/api/interfaces/FormProps.md +1 -1
  114. package/docs/api/interfaces/GrantEventAppRoleParams.md +1 -1
  115. package/docs/api/interfaces/InactivityWarningModalProps.md +1 -1
  116. package/docs/api/interfaces/InputProps.md +1 -1
  117. package/docs/api/interfaces/LabelProps.md +1 -1
  118. package/docs/api/interfaces/LoggerConfig.md +1 -1
  119. package/docs/api/interfaces/LoginFormProps.md +1 -1
  120. package/docs/api/interfaces/NavigationAccessRecord.md +2 -2
  121. package/docs/api/interfaces/NavigationContextType.md +1 -1
  122. package/docs/api/interfaces/NavigationGuardProps.md +1 -1
  123. package/docs/api/interfaces/NavigationItem.md +1 -1
  124. package/docs/api/interfaces/NavigationMenuProps.md +1 -1
  125. package/docs/api/interfaces/NavigationProviderProps.md +1 -1
  126. package/docs/api/interfaces/Organisation.md +1 -1
  127. package/docs/api/interfaces/OrganisationContextType.md +1 -1
  128. package/docs/api/interfaces/OrganisationMembership.md +1 -1
  129. package/docs/api/interfaces/OrganisationProviderProps.md +1 -1
  130. package/docs/api/interfaces/OrganisationSecurityError.md +1 -1
  131. package/docs/api/interfaces/PaceAppLayoutProps.md +1 -1
  132. package/docs/api/interfaces/PaceLoginPageProps.md +1 -1
  133. package/docs/api/interfaces/PageAccessRecord.md +1 -1
  134. package/docs/api/interfaces/PagePermissionContextType.md +1 -1
  135. package/docs/api/interfaces/PagePermissionGuardProps.md +2 -2
  136. package/docs/api/interfaces/PagePermissionProviderProps.md +1 -1
  137. package/docs/api/interfaces/PaletteData.md +1 -1
  138. package/docs/api/interfaces/ParsedAddress.md +1 -1
  139. package/docs/api/interfaces/PermissionEnforcerProps.md +4 -4
  140. package/docs/api/interfaces/ProgressProps.md +1 -1
  141. package/docs/api/interfaces/ProtectedRouteProps.md +1 -1
  142. package/docs/api/interfaces/PublicPageFooterProps.md +1 -1
  143. package/docs/api/interfaces/PublicPageHeaderProps.md +1 -1
  144. package/docs/api/interfaces/PublicPageLayoutProps.md +1 -1
  145. package/docs/api/interfaces/QuickFix.md +1 -1
  146. package/docs/api/interfaces/RBACAccessValidateParams.md +1 -1
  147. package/docs/api/interfaces/RBACAccessValidateResult.md +1 -1
  148. package/docs/api/interfaces/RBACAuditLogParams.md +1 -1
  149. package/docs/api/interfaces/RBACAuditLogResult.md +1 -1
  150. package/docs/api/interfaces/RBACConfig.md +2 -2
  151. package/docs/api/interfaces/RBACContext.md +1 -1
  152. package/docs/api/interfaces/RBACLogger.md +1 -1
  153. package/docs/api/interfaces/RBACPageAccessCheckParams.md +1 -1
  154. package/docs/api/interfaces/RBACPerformanceMetrics.md +1 -1
  155. package/docs/api/interfaces/RBACPermissionCheckParams.md +1 -1
  156. package/docs/api/interfaces/RBACPermissionCheckResult.md +2 -2
  157. package/docs/api/interfaces/RBACPermissionsGetParams.md +1 -1
  158. package/docs/api/interfaces/RBACPermissionsGetResult.md +1 -1
  159. package/docs/api/interfaces/RBACResult.md +1 -1
  160. package/docs/api/interfaces/RBACRoleGrantParams.md +2 -2
  161. package/docs/api/interfaces/RBACRoleGrantResult.md +1 -1
  162. package/docs/api/interfaces/RBACRoleRevokeParams.md +2 -2
  163. package/docs/api/interfaces/RBACRoleRevokeResult.md +1 -1
  164. package/docs/api/interfaces/RBACRoleValidateParams.md +2 -2
  165. package/docs/api/interfaces/RBACRoleValidateResult.md +1 -1
  166. package/docs/api/interfaces/RBACRolesListParams.md +1 -1
  167. package/docs/api/interfaces/RBACRolesListResult.md +2 -2
  168. package/docs/api/interfaces/RBACSessionTrackParams.md +1 -1
  169. package/docs/api/interfaces/RBACSessionTrackResult.md +1 -1
  170. package/docs/api/interfaces/ResourcePermissions.md +1 -1
  171. package/docs/api/interfaces/RevokeEventAppRoleParams.md +1 -1
  172. package/docs/api/interfaces/RoleBasedRouterContextType.md +1 -1
  173. package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
  174. package/docs/api/interfaces/RoleManagementResult.md +1 -1
  175. package/docs/api/interfaces/RouteAccessRecord.md +2 -2
  176. package/docs/api/interfaces/RouteConfig.md +2 -2
  177. package/docs/api/interfaces/RuntimeComplianceResult.md +1 -1
  178. package/docs/api/interfaces/SecureDataContextType.md +1 -1
  179. package/docs/api/interfaces/SecureDataProviderProps.md +1 -1
  180. package/docs/api/interfaces/SessionRestorationLoaderProps.md +1 -1
  181. package/docs/api/interfaces/SetupIssue.md +1 -1
  182. package/docs/api/interfaces/StorageConfig.md +1 -1
  183. package/docs/api/interfaces/StorageFileInfo.md +1 -1
  184. package/docs/api/interfaces/StorageFileMetadata.md +1 -1
  185. package/docs/api/interfaces/StorageListOptions.md +1 -1
  186. package/docs/api/interfaces/StorageListResult.md +1 -1
  187. package/docs/api/interfaces/StorageUploadOptions.md +1 -1
  188. package/docs/api/interfaces/StorageUploadResult.md +1 -1
  189. package/docs/api/interfaces/StorageUrlOptions.md +1 -1
  190. package/docs/api/interfaces/StyleImport.md +1 -1
  191. package/docs/api/interfaces/SwitchProps.md +1 -1
  192. package/docs/api/interfaces/TabsContentProps.md +1 -1
  193. package/docs/api/interfaces/TabsListProps.md +1 -1
  194. package/docs/api/interfaces/TabsProps.md +1 -1
  195. package/docs/api/interfaces/TabsTriggerProps.md +1 -1
  196. package/docs/api/interfaces/TextareaProps.md +1 -1
  197. package/docs/api/interfaces/ToastActionElement.md +1 -1
  198. package/docs/api/interfaces/ToastProps.md +1 -1
  199. package/docs/api/interfaces/UnifiedAuthContextType.md +60 -38
  200. package/docs/api/interfaces/UnifiedAuthProviderProps.md +13 -13
  201. package/docs/api/interfaces/UseFormDialogOptions.md +1 -1
  202. package/docs/api/interfaces/UseFormDialogReturn.md +1 -1
  203. package/docs/api/interfaces/UseInactivityTrackerOptions.md +1 -1
  204. package/docs/api/interfaces/UseInactivityTrackerReturn.md +1 -1
  205. package/docs/api/interfaces/UsePublicEventLogoOptions.md +2 -2
  206. package/docs/api/interfaces/UsePublicEventLogoReturn.md +1 -1
  207. package/docs/api/interfaces/UsePublicEventOptions.md +1 -1
  208. package/docs/api/interfaces/UsePublicEventReturn.md +1 -1
  209. package/docs/api/interfaces/UsePublicFileDisplayOptions.md +2 -2
  210. package/docs/api/interfaces/UsePublicFileDisplayReturn.md +1 -1
  211. package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
  212. package/docs/api/interfaces/UseResolvedScopeOptions.md +2 -2
  213. package/docs/api/interfaces/UseResolvedScopeReturn.md +1 -1
  214. package/docs/api/interfaces/UseResourcePermissionsOptions.md +1 -1
  215. package/docs/api/interfaces/UserEventAccess.md +1 -1
  216. package/docs/api/interfaces/UserMenuProps.md +1 -1
  217. package/docs/api/interfaces/UserProfile.md +1 -1
  218. package/docs/api/modules.md +194 -209
  219. package/docs/migration/database-changes-december-2025.md +2 -1
  220. package/docs/rbac/event-based-apps.md +124 -6
  221. package/package.json +1 -1
  222. package/scripts/check-pace-core-compliance.cjs +292 -57
  223. package/src/__tests__/rls-policies.test.ts +3 -1
  224. package/src/components/DataTable/__tests__/DataTable.default-state.test.tsx +172 -45
  225. package/src/components/DataTable/__tests__/DataTable.grouping-aggregation.test.tsx +121 -28
  226. package/src/components/DataTable/__tests__/DataTableCore.test-setup.ts +9 -8
  227. package/src/components/DataTable/__tests__/DataTableCore.test.tsx +20 -52
  228. package/src/components/DataTable/__tests__/a11y.basic.test.tsx +170 -34
  229. package/src/components/DataTable/__tests__/keyboard.test.tsx +75 -12
  230. package/src/components/DataTable/__tests__/pagination.modes.test.tsx +75 -11
  231. package/src/components/DataTable/components/UnifiedTableBody.tsx +85 -14
  232. package/src/components/DataTable/hooks/useDataTablePermissions.ts +75 -10
  233. package/src/components/FileDisplay/FileDisplay.test.tsx +2 -1
  234. package/src/components/FileDisplay/FileDisplay.tsx +16 -4
  235. package/src/components/NavigationMenu/NavigationMenu.test.tsx +6 -4
  236. package/src/components/NavigationMenu/NavigationMenu.tsx +1 -10
  237. package/src/components/OrganisationSelector/OrganisationSelector.tsx +0 -1
  238. package/src/components/PaceAppLayout/PaceAppLayout.test.tsx +25 -2
  239. package/src/components/PaceAppLayout/PaceAppLayout.tsx +97 -68
  240. package/src/components/PaceLoginPage/PaceLoginPage.tsx +0 -7
  241. package/src/components/ProtectedRoute/ProtectedRoute.test.tsx +5 -9
  242. package/src/components/ProtectedRoute/ProtectedRoute.tsx +0 -1
  243. package/src/components/PublicLayout/PublicPageProvider.tsx +0 -1
  244. package/src/hooks/__tests__/useSecureDataAccess.unit.test.tsx +14 -7
  245. package/src/hooks/services/useAuthService.ts +21 -3
  246. package/src/hooks/services/useEventService.ts +21 -3
  247. package/src/hooks/services/useInactivityService.ts +21 -3
  248. package/src/hooks/services/useOrganisationService.ts +21 -3
  249. package/src/hooks/useFileDisplay.ts +10 -17
  250. package/src/hooks/useSecureDataAccess.test.ts +16 -9
  251. package/src/hooks/useSecureDataAccess.ts +3 -2
  252. package/src/providers/services/EventServiceProvider.tsx +0 -8
  253. package/src/providers/services/UnifiedAuthProvider.tsx +174 -24
  254. package/src/rbac/__tests__/adapters.comprehensive.test.tsx +10 -16
  255. package/src/rbac/__tests__/isSuperAdmin.real.test.ts +82 -0
  256. package/src/rbac/adapters.tsx +3 -22
  257. package/src/rbac/api.test.ts +2 -2
  258. package/src/rbac/api.ts +7 -1
  259. package/src/rbac/components/EnhancedNavigationMenu.tsx +2 -15
  260. package/src/rbac/components/NavigationGuard.tsx +1 -10
  261. package/src/rbac/components/NavigationProvider.tsx +0 -1
  262. package/src/rbac/components/PermissionEnforcer.tsx +45 -12
  263. package/src/rbac/components/SecureDataProvider.tsx +0 -1
  264. package/src/rbac/components/__tests__/EnhancedNavigationMenu.test.tsx +7 -43
  265. package/src/rbac/components/__tests__/NavigationGuard.test.tsx +4 -11
  266. package/src/rbac/components/__tests__/NavigationProvider.test.tsx +3 -3
  267. package/src/rbac/components/__tests__/SecureDataProvider.fixed.test.tsx +1 -1
  268. package/src/rbac/components/__tests__/SecureDataProvider.test.tsx +1 -1
  269. package/src/rbac/engine.ts +14 -2
  270. package/src/rbac/hooks/index.ts +0 -3
  271. package/src/rbac/hooks/usePermissions.ts +51 -11
  272. package/src/rbac/hooks/useRBAC.ts +3 -13
  273. package/src/rbac/hooks/useResolvedScope.test.ts +75 -54
  274. package/src/rbac/hooks/useResolvedScope.ts +58 -33
  275. package/src/rbac/hooks/useSecureSupabase.ts +4 -9
  276. package/src/rbac/secureClient.ts +31 -0
  277. package/src/services/EventService.ts +4 -57
  278. package/src/services/InactivityService.ts +127 -34
  279. package/src/services/OrganisationService.ts +68 -10
  280. package/dist/chunk-6LTQQAT6.js.map +0 -1
  281. package/dist/chunk-6TQDD426.js.map +0 -1
  282. package/dist/chunk-LOMZXPSN.js.map +0 -1
  283. package/dist/chunk-OETXORNB.js.map +0 -1
  284. package/dist/chunk-VKB2CO4Z.js.map +0 -1
  285. package/dist/chunk-VRGWKHDB.js.map +0 -1
  286. package/dist/chunk-XNYQOL3Z.js.map +0 -1
  287. package/dist/chunk-XYXSXPUK.js.map +0 -1
  288. package/scripts/check-pace-core-compliance.js +0 -512
  289. package/src/rbac/hooks/useSuperAdminBypass.ts +0 -126
  290. package/src/utils/context/superAdminOverride.ts +0 -58
  291. /package/dist/{DataTable-WKRZD47S.js.map → DataTable-5FU7IESH.js.map} +0 -0
  292. /package/dist/{UnifiedAuthProvider-FTSG5XH7.js.map → UnifiedAuthProvider-RGJTDE2C.js.map} +0 -0
  293. /package/dist/{api-IHKALJZD.js.map → api-N774RPUA.js.map} +0 -0
@@ -0,0 +1,628 @@
1
+ import {
2
+ logger
3
+ } from "./chunk-PWLANIRT.js";
4
+
5
+ // src/hooks/useToast.ts
6
+ import * as React from "react";
7
+ var TOAST_LIMIT = 5;
8
+ var TOAST_REMOVE_DELAY = 1e3;
9
+ var DEFAULT_TOAST_DURATION = 5e3;
10
+ var toastTimeouts = /* @__PURE__ */ new Map();
11
+ var memoryState = {
12
+ toasts: []
13
+ };
14
+ var listeners = [];
15
+ function dispatch(action) {
16
+ memoryState = reducer(memoryState, action);
17
+ listeners.forEach((listener) => {
18
+ listener(memoryState);
19
+ });
20
+ }
21
+ function genId() {
22
+ return Math.random().toString(36).substring(2, 9);
23
+ }
24
+ var addToRemoveQueue = (toastId) => {
25
+ if (toastTimeouts.has(toastId)) {
26
+ return;
27
+ }
28
+ const timeout = setTimeout(() => {
29
+ toastTimeouts.delete(toastId);
30
+ dispatch({
31
+ type: "REMOVE_TOAST",
32
+ toastId
33
+ });
34
+ }, TOAST_REMOVE_DELAY);
35
+ toastTimeouts.set(toastId, timeout);
36
+ };
37
+ function reducer(state, action) {
38
+ switch (action.type) {
39
+ case "ADD_TOAST":
40
+ return {
41
+ ...state,
42
+ toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT)
43
+ };
44
+ case "UPDATE_TOAST":
45
+ return {
46
+ ...state,
47
+ toasts: state.toasts.map(
48
+ (t) => t.id === action.toast?.id ? { ...t, ...action.toast } : t
49
+ )
50
+ };
51
+ case "DISMISS_TOAST": {
52
+ const { toastId } = action;
53
+ if (toastId) {
54
+ addToRemoveQueue(toastId);
55
+ }
56
+ return {
57
+ ...state,
58
+ toasts: state.toasts.map(
59
+ (t) => t.id === toastId || toastId === void 0 ? {
60
+ ...t,
61
+ open: false
62
+ } : t
63
+ )
64
+ };
65
+ }
66
+ case "REMOVE_TOAST":
67
+ if (action.toastId === void 0) {
68
+ return {
69
+ ...state,
70
+ toasts: []
71
+ };
72
+ }
73
+ return {
74
+ ...state,
75
+ toasts: state.toasts.filter((t) => t.id !== action.toastId)
76
+ };
77
+ }
78
+ }
79
+ function toast(props) {
80
+ const id = genId();
81
+ const update = (props2) => dispatch({
82
+ type: "UPDATE_TOAST",
83
+ toast: { ...props2, duration: DEFAULT_TOAST_DURATION, id }
84
+ });
85
+ const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id });
86
+ dispatch({
87
+ type: "ADD_TOAST",
88
+ toast: {
89
+ ...props,
90
+ duration: DEFAULT_TOAST_DURATION,
91
+ id,
92
+ open: true,
93
+ dismiss,
94
+ onOpenChange: (open) => {
95
+ if (!open) dismiss();
96
+ }
97
+ }
98
+ });
99
+ return {
100
+ id,
101
+ dismiss,
102
+ update
103
+ };
104
+ }
105
+ function useToast() {
106
+ const [state, setState] = React.useState(memoryState);
107
+ React.useEffect(() => {
108
+ listeners.push(setState);
109
+ return () => {
110
+ const index = listeners.indexOf(setState);
111
+ if (index > -1) {
112
+ listeners.splice(index, 1);
113
+ }
114
+ };
115
+ }, [state]);
116
+ return {
117
+ ...state,
118
+ toast,
119
+ dismiss: (toastId) => dispatch({ type: "DISMISS_TOAST", toastId })
120
+ };
121
+ }
122
+
123
+ // src/components/DataTable/utils/performanceUtils.ts
124
+ function determinePaginationMode(dataLength, serverSideThreshold = 1e4) {
125
+ if (dataLength <= 1e3) return "client";
126
+ return "hybrid";
127
+ }
128
+ function getOptimalPageSizeOptions(mode, dataLength) {
129
+ switch (mode) {
130
+ case "client":
131
+ return dataLength <= 100 ? [10, 25, 50] : [10, 25, 50, 100];
132
+ case "hybrid":
133
+ return [50, 100, 250, 500];
134
+ case "server":
135
+ return [25, 50, 100, 250];
136
+ default:
137
+ return [10, 25, 50, 100];
138
+ }
139
+ }
140
+ function chunkData(data, chunkSize) {
141
+ const chunks = [];
142
+ for (let i = 0; i < data.length; i += chunkSize) {
143
+ chunks.push(data.slice(i, i + chunkSize));
144
+ }
145
+ return chunks;
146
+ }
147
+ var DataChunkManager = class {
148
+ constructor(config) {
149
+ this.chunks = /* @__PURE__ */ new Map();
150
+ this.accessOrder = [];
151
+ this.maxChunks = config.maxChunksInMemory;
152
+ this.chunkSize = config.chunkSize;
153
+ }
154
+ getChunk(chunkIndex, allData) {
155
+ if (this.chunks.has(chunkIndex)) {
156
+ this.updateAccessOrder(chunkIndex);
157
+ return this.chunks.get(chunkIndex);
158
+ }
159
+ const startIndex = chunkIndex * this.chunkSize;
160
+ const endIndex = Math.min(startIndex + this.chunkSize, allData.length);
161
+ const chunk = allData.slice(startIndex, endIndex);
162
+ this.addChunk(chunkIndex, chunk);
163
+ return chunk;
164
+ }
165
+ addChunk(chunkIndex, chunk) {
166
+ if (this.chunks.size >= this.maxChunks && !this.chunks.has(chunkIndex)) {
167
+ const oldestChunk = this.accessOrder.shift();
168
+ if (oldestChunk !== void 0) {
169
+ this.chunks.delete(oldestChunk);
170
+ }
171
+ }
172
+ this.chunks.set(chunkIndex, chunk);
173
+ this.updateAccessOrder(chunkIndex);
174
+ }
175
+ updateAccessOrder(chunkIndex) {
176
+ const existingIndex = this.accessOrder.indexOf(chunkIndex);
177
+ if (existingIndex > -1) {
178
+ this.accessOrder.splice(existingIndex, 1);
179
+ }
180
+ this.accessOrder.push(chunkIndex);
181
+ }
182
+ clear() {
183
+ this.chunks.clear();
184
+ this.accessOrder = [];
185
+ }
186
+ getMemoryUsage() {
187
+ let totalSize = 0;
188
+ for (const chunk of this.chunks.values()) {
189
+ totalSize += JSON.stringify(chunk).length;
190
+ }
191
+ return totalSize / (1024 * 1024);
192
+ }
193
+ };
194
+ var SearchIndex = class {
195
+ constructor(config) {
196
+ this.index = /* @__PURE__ */ new Map();
197
+ this.data = [];
198
+ this.indexedFields = config.indexedFields;
199
+ this.fuzzySearch = config.fuzzySearch ?? false;
200
+ this.fuzzyThreshold = config.fuzzyThreshold ?? 0.6;
201
+ }
202
+ buildIndex(data) {
203
+ this.data = data;
204
+ this.index.clear();
205
+ data.forEach((row, rowIndex) => {
206
+ this.indexedFields.forEach((field) => {
207
+ const value = this.getNestedValue(row, field);
208
+ if (value != null) {
209
+ const searchableText = String(value).toLowerCase();
210
+ const words = this.tokenize(searchableText);
211
+ words.forEach((word) => {
212
+ if (!this.index.has(word)) {
213
+ this.index.set(word, /* @__PURE__ */ new Set());
214
+ }
215
+ this.index.get(word).add(rowIndex);
216
+ });
217
+ }
218
+ });
219
+ });
220
+ }
221
+ search(query) {
222
+ if (!query.trim()) return [];
223
+ const searchTerms = this.tokenize(query.toLowerCase());
224
+ const matchingSets = [];
225
+ searchTerms.forEach((term) => {
226
+ const matches = /* @__PURE__ */ new Set();
227
+ if (this.index.has(term)) {
228
+ this.index.get(term).forEach((index) => matches.add(index));
229
+ }
230
+ if (this.fuzzySearch) {
231
+ for (const [indexedTerm, indices] of this.index.entries()) {
232
+ if (this.calculateSimilarity(term, indexedTerm) >= this.fuzzyThreshold) {
233
+ indices.forEach((index) => matches.add(index));
234
+ }
235
+ }
236
+ }
237
+ matchingSets.push(matches);
238
+ });
239
+ if (matchingSets.length === 0) return [];
240
+ let result = matchingSets[0];
241
+ for (let i = 1; i < matchingSets.length; i++) {
242
+ result = new Set([...result].filter((x) => matchingSets[i].has(x)));
243
+ }
244
+ return Array.from(result);
245
+ }
246
+ getNestedValue(obj, path) {
247
+ return path.split(".").reduce((current, key) => {
248
+ if (current && typeof current === "object" && key in current) {
249
+ return current[key];
250
+ }
251
+ return void 0;
252
+ }, obj);
253
+ }
254
+ tokenize(text) {
255
+ return text.replace(/[^\w\s]/g, " ").split(/\s+/).filter((word) => word.length > 0);
256
+ }
257
+ calculateSimilarity(str1, str2) {
258
+ const longer = str1.length > str2.length ? str1 : str2;
259
+ const shorter = str1.length > str2.length ? str2 : str1;
260
+ if (longer.length === 0) return 1;
261
+ const editDistance = this.levenshteinDistance(longer, shorter);
262
+ return (longer.length - editDistance) / longer.length;
263
+ }
264
+ levenshteinDistance(str1, str2) {
265
+ const matrix = Array(str2.length + 1).fill(null).map(
266
+ () => Array(str1.length + 1).fill(null)
267
+ );
268
+ for (let i = 0; i <= str1.length; i++) matrix[0][i] = i;
269
+ for (let j = 0; j <= str2.length; j++) matrix[j][0] = j;
270
+ for (let j = 1; j <= str2.length; j++) {
271
+ for (let i = 1; i <= str1.length; i++) {
272
+ const substitutionCost = str1[i - 1] === str2[j - 1] ? 0 : 1;
273
+ matrix[j][i] = Math.min(
274
+ matrix[j][i - 1] + 1,
275
+ // insertion
276
+ matrix[j - 1][i] + 1,
277
+ // deletion
278
+ matrix[j - 1][i - 1] + substitutionCost
279
+ // substitution
280
+ );
281
+ }
282
+ }
283
+ return matrix[str2.length][str1.length];
284
+ }
285
+ };
286
+ function debounce(func, delay) {
287
+ let timeoutId;
288
+ return (...args) => {
289
+ clearTimeout(timeoutId);
290
+ timeoutId = setTimeout(() => func(...args), delay);
291
+ };
292
+ }
293
+ function throttle(func, delay) {
294
+ let lastCall = 0;
295
+ return (...args) => {
296
+ const now = Date.now();
297
+ if (now - lastCall >= delay) {
298
+ lastCall = now;
299
+ func(...args);
300
+ }
301
+ };
302
+ }
303
+ var VisibilityTracker = class {
304
+ constructor() {
305
+ this.observer = null;
306
+ this.visibleElements = /* @__PURE__ */ new Set();
307
+ this.callbacks = /* @__PURE__ */ new Set();
308
+ if (typeof IntersectionObserver !== "undefined") {
309
+ this.observer = new IntersectionObserver(
310
+ (entries) => {
311
+ entries.forEach((entry) => {
312
+ if (entry.isIntersecting) {
313
+ this.visibleElements.add(entry.target);
314
+ } else {
315
+ this.visibleElements.delete(entry.target);
316
+ }
317
+ });
318
+ this.callbacks.forEach((callback) => {
319
+ callback(this.visibleElements.size);
320
+ });
321
+ },
322
+ { threshold: 0.1 }
323
+ );
324
+ }
325
+ }
326
+ observe(element) {
327
+ this.observer?.observe(element);
328
+ }
329
+ unobserve(element) {
330
+ this.observer?.unobserve(element);
331
+ this.visibleElements.delete(element);
332
+ }
333
+ onVisibilityChange(callback) {
334
+ this.callbacks.add(callback);
335
+ return () => this.callbacks.delete(callback);
336
+ }
337
+ getVisibleCount() {
338
+ return this.visibleElements.size;
339
+ }
340
+ destroy() {
341
+ this.observer?.disconnect();
342
+ this.visibleElements.clear();
343
+ this.callbacks.clear();
344
+ }
345
+ };
346
+
347
+ // src/components/DataTable/utils/errorHandling.ts
348
+ var DEFAULT_FALLBACK_CONFIG = {
349
+ enabled: false
350
+ };
351
+ var DataTableErrorType = /* @__PURE__ */ ((DataTableErrorType3) => {
352
+ DataTableErrorType3["VIRTUALIZATION"] = "virtualization";
353
+ DataTableErrorType3["SEARCH_INDEX"] = "search_index";
354
+ DataTableErrorType3["DATA_CHUNK"] = "data_chunk";
355
+ DataTableErrorType3["SERVER_FETCH"] = "server_fetch";
356
+ DataTableErrorType3["MEMORY"] = "memory";
357
+ return DataTableErrorType3;
358
+ })(DataTableErrorType || {});
359
+ var DataTableError = class extends Error {
360
+ constructor(message, type, recoverable = true) {
361
+ super(message);
362
+ this.type = type;
363
+ this.recoverable = recoverable;
364
+ this.name = "DataTableError";
365
+ }
366
+ };
367
+ var ErrorRecoveryManager = class {
368
+ constructor(config) {
369
+ this.config = config;
370
+ }
371
+ async handleError(error) {
372
+ return { recovered: false, strategy: null };
373
+ }
374
+ clearErrorLog() {
375
+ }
376
+ };
377
+ var MemoryMonitor = class {
378
+ constructor(threshold = 100) {
379
+ this.threshold = threshold;
380
+ }
381
+ getCurrentUsage() {
382
+ return 0;
383
+ }
384
+ checkThreshold() {
385
+ return true;
386
+ }
387
+ stopMonitoring() {
388
+ }
389
+ };
390
+ var CircuitBreaker = class {
391
+ constructor() {
392
+ }
393
+ isOpen() {
394
+ return false;
395
+ }
396
+ recordSuccess() {
397
+ }
398
+ recordFailure() {
399
+ }
400
+ reset() {
401
+ }
402
+ };
403
+ function safeExecute(fn, fallback) {
404
+ try {
405
+ return fn();
406
+ } catch {
407
+ return fallback;
408
+ }
409
+ }
410
+
411
+ // src/hooks/useDataTablePerformance.ts
412
+ import { useState as useState2, useEffect as useEffect2, useCallback, useMemo, useRef } from "react";
413
+ function useDataTablePerformance({
414
+ data,
415
+ performance = {},
416
+ serverSide,
417
+ chunking,
418
+ searchIndex,
419
+ fallbackConfig = DEFAULT_FALLBACK_CONFIG,
420
+ onError,
421
+ enableErrorRecovery = true
422
+ }) {
423
+ const [isLoading, setIsLoading] = useState2(false);
424
+ const [searchQuery, setSearchQuery] = useState2("");
425
+ const [searchResults, setSearchResults] = useState2([]);
426
+ const [serverData, setServerData] = useState2(null);
427
+ const [memoryUsage, setMemoryUsage] = useState2(0);
428
+ const [errorState, setErrorState] = useState2({
429
+ hasErrors: false,
430
+ errorCount: 0,
431
+ lastError: null,
432
+ fallbacksActive: []
433
+ });
434
+ const [lastFailedOperation, setLastFailedOperation] = useState2(null);
435
+ const chunkManagerRef = useRef(null);
436
+ const searchIndexRef = useRef(null);
437
+ const visibilityTrackerRef = useRef(null);
438
+ const errorRecoveryManagerRef = useRef(new ErrorRecoveryManager(fallbackConfig));
439
+ const memoryMonitorRef = useRef(null);
440
+ const circuitBreakerRef = useRef(new CircuitBreaker());
441
+ const paginationMode = useMemo(() => {
442
+ if (serverSide) return "server";
443
+ return determinePaginationMode(data?.length || 0, performance.serverSideThreshold);
444
+ }, [data?.length, performance.serverSideThreshold, serverSide]);
445
+ const isVirtualized = false;
446
+ const pageSizeOptions = useMemo(() => {
447
+ return getOptimalPageSizeOptions(paginationMode, data?.length || 0);
448
+ }, [paginationMode, data?.length]);
449
+ const processedData = useMemo(() => {
450
+ if (serverSide && serverData) {
451
+ return serverData.data;
452
+ }
453
+ let filteredData = data;
454
+ if (searchQuery && searchResults.length > 0) {
455
+ filteredData = searchResults.map((index) => data[index]);
456
+ }
457
+ return filteredData;
458
+ }, [data, serverData, searchQuery, searchResults, serverSide]);
459
+ const totalCount = useMemo(() => {
460
+ if (serverSide && serverData) {
461
+ return serverData.totalCount;
462
+ }
463
+ return processedData?.length || 0;
464
+ }, [serverData, processedData?.length, serverSide]);
465
+ useEffect2(() => {
466
+ if (chunking && !chunkManagerRef.current) {
467
+ chunkManagerRef.current = new DataChunkManager(chunking);
468
+ }
469
+ }, [chunking]);
470
+ useEffect2(() => {
471
+ if (searchIndex && !searchIndexRef.current) {
472
+ searchIndexRef.current = new SearchIndex(searchIndex);
473
+ }
474
+ if (searchIndexRef.current && data.length > 0) {
475
+ searchIndexRef.current.buildIndex(data);
476
+ }
477
+ }, [searchIndex, data]);
478
+ const debouncedSearch = useCallback(
479
+ debounce(((query) => {
480
+ if (!searchIndexRef.current) return;
481
+ if (!query.trim()) {
482
+ setSearchResults([]);
483
+ return;
484
+ }
485
+ const results = searchIndexRef.current.search(query);
486
+ setSearchResults(results);
487
+ }), performance.debounceSearch ?? 300),
488
+ [performance.debounceSearch]
489
+ );
490
+ useEffect2(() => {
491
+ debouncedSearch(searchQuery);
492
+ }, [searchQuery, debouncedSearch]);
493
+ const fetchServerData = useCallback(async (params) => {
494
+ if (!serverSide) return;
495
+ setIsLoading(true);
496
+ try {
497
+ const response = await serverSide.fetchData(params);
498
+ setServerData(response);
499
+ } catch (error) {
500
+ logger.error("useDataTablePerformance", "Failed to fetch server data:", error);
501
+ } finally {
502
+ setIsLoading(false);
503
+ }
504
+ }, [serverSide]);
505
+ useEffect2(() => {
506
+ if (!visibilityTrackerRef.current) {
507
+ visibilityTrackerRef.current = new VisibilityTracker();
508
+ }
509
+ const tracker = visibilityTrackerRef.current;
510
+ const unsubscribe = tracker.onVisibilityChange((visibleCount) => {
511
+ });
512
+ return unsubscribe;
513
+ }, [totalCount, isVirtualized, paginationMode]);
514
+ useEffect2(() => {
515
+ const updateMemoryUsage = () => {
516
+ let usage = 0;
517
+ if (chunkManagerRef.current) {
518
+ usage += chunkManagerRef.current.getMemoryUsage();
519
+ }
520
+ usage += JSON.stringify(processedData || []).length / (1024 * 1024);
521
+ setMemoryUsage(usage);
522
+ };
523
+ updateMemoryUsage();
524
+ const interval = import.meta.env.MODE !== "test" ? setInterval(updateMemoryUsage, 5e3) : null;
525
+ return () => {
526
+ if (interval) {
527
+ clearInterval(interval);
528
+ }
529
+ };
530
+ }, [processedData]);
531
+ const handleError = useCallback(async (error, operation) => {
532
+ if (enableErrorRecovery) {
533
+ try {
534
+ const recovery = await errorRecoveryManagerRef.current.handleError(error);
535
+ setErrorState((prev) => ({
536
+ hasErrors: true,
537
+ errorCount: prev.errorCount + 1,
538
+ lastError: error,
539
+ fallbacksActive: [...prev.fallbacksActive, error.type]
540
+ }));
541
+ if (operation) {
542
+ setLastFailedOperation(() => operation);
543
+ }
544
+ onError?.(error);
545
+ return recovery;
546
+ } catch (recoveryError) {
547
+ logger.error("useDataTablePerformance", "Error recovery failed:", recoveryError);
548
+ }
549
+ }
550
+ throw error;
551
+ }, [enableErrorRecovery, onError]);
552
+ const retryLastOperation = useCallback(async () => {
553
+ if (lastFailedOperation) {
554
+ try {
555
+ await lastFailedOperation();
556
+ setLastFailedOperation(null);
557
+ setErrorState((prev) => ({ ...prev, hasErrors: false }));
558
+ } catch (error) {
559
+ logger.error("useDataTablePerformance", "Retry failed:", error);
560
+ }
561
+ }
562
+ }, [lastFailedOperation]);
563
+ const clearErrors = useCallback(() => {
564
+ setErrorState({
565
+ hasErrors: false,
566
+ errorCount: 0,
567
+ lastError: null,
568
+ fallbacksActive: []
569
+ });
570
+ setLastFailedOperation(null);
571
+ errorRecoveryManagerRef.current.clearErrorLog();
572
+ }, []);
573
+ const cleanup = useCallback(() => {
574
+ chunkManagerRef.current?.clear();
575
+ visibilityTrackerRef.current?.destroy();
576
+ memoryMonitorRef.current?.stopMonitoring();
577
+ }, []);
578
+ useEffect2(() => {
579
+ return cleanup;
580
+ }, [cleanup]);
581
+ return {
582
+ // Performance state
583
+ paginationMode,
584
+ isVirtualized,
585
+ pageSizeOptions,
586
+ // Data management
587
+ processedData,
588
+ totalCount,
589
+ isLoading,
590
+ // Search functionality
591
+ searchQuery,
592
+ setSearchQuery,
593
+ searchResults,
594
+ // Server-side functionality
595
+ fetchServerData,
596
+ serverData,
597
+ // Performance monitoring
598
+ memoryUsage,
599
+ // Error handling and recovery
600
+ errorState,
601
+ retryLastOperation,
602
+ clearErrors,
603
+ // Cleanup
604
+ cleanup
605
+ };
606
+ }
607
+
608
+ export {
609
+ toast,
610
+ useToast,
611
+ determinePaginationMode,
612
+ getOptimalPageSizeOptions,
613
+ chunkData,
614
+ DataChunkManager,
615
+ SearchIndex,
616
+ debounce,
617
+ throttle,
618
+ VisibilityTracker,
619
+ DEFAULT_FALLBACK_CONFIG,
620
+ DataTableErrorType,
621
+ DataTableError,
622
+ ErrorRecoveryManager,
623
+ MemoryMonitor,
624
+ CircuitBreaker,
625
+ safeExecute,
626
+ useDataTablePerformance
627
+ };
628
+ //# sourceMappingURL=chunk-6C4YBBJM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}