@jmruthers/pace-core 0.6.4 → 0.6.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 (101) hide show
  1. package/dist/{DataTable-E7YQZD7D.js → DataTable-AOVNCPTX.js} +8 -8
  2. package/dist/{PublicPageProvider-DEMpysFR.d.ts → PublicPageProvider-QTFVrL-Z.d.ts} +65 -83
  3. package/dist/{UnifiedAuthProvider-QPXO24B4.js → UnifiedAuthProvider-4SBX4LU5.js} +4 -4
  4. package/dist/{api-6LVZTHDS.js → api-O6HTBX5Y.js} +3 -3
  5. package/dist/{chunk-I6DAQMWX.js → chunk-6COVEUS7.js} +130 -106
  6. package/dist/chunk-6COVEUS7.js.map +1 -0
  7. package/dist/{chunk-36LVWXB2.js → chunk-AFVQODI2.js} +37 -1
  8. package/dist/{chunk-36LVWXB2.js.map → chunk-AFVQODI2.js.map} +1 -1
  9. package/dist/{chunk-3LPHPB62.js → chunk-EFN2EIMK.js} +2 -2
  10. package/dist/{chunk-ATKZM7RX.js → chunk-G7QEZTYQ.js} +31 -31
  11. package/dist/{chunk-ATKZM7RX.js.map → chunk-G7QEZTYQ.js.map} +1 -1
  12. package/dist/{chunk-NN6WWZ5U.js → chunk-HU2C6SSC.js} +29 -18
  13. package/dist/chunk-HU2C6SSC.js.map +1 -0
  14. package/dist/{chunk-AVMLPIM7.js → chunk-IHB5DR3H.js} +102 -51
  15. package/dist/chunk-IHB5DR3H.js.map +1 -0
  16. package/dist/{chunk-7JPAB3T5.js → chunk-IVOFDYWT.js} +364 -208
  17. package/dist/chunk-IVOFDYWT.js.map +1 -0
  18. package/dist/{chunk-6SOIHG6Z.js → chunk-JGRYX5UX.js} +120 -20
  19. package/dist/chunk-JGRYX5UX.js.map +1 -0
  20. package/dist/{chunk-OEWDTMG7.js → chunk-NTM7ZSB6.js} +4 -4
  21. package/dist/chunk-NTM7ZSB6.js.map +1 -0
  22. package/dist/{chunk-5EC5MEWX.js → chunk-RGAWHO7N.js} +4 -4
  23. package/dist/chunk-RGAWHO7N.js.map +1 -0
  24. package/dist/{chunk-YKRAFF5K.js → chunk-UPPMRMYG.js} +3 -3
  25. package/dist/{chunk-YKRAFF5K.js.map → chunk-UPPMRMYG.js.map} +1 -1
  26. package/dist/components.d.ts +2 -3
  27. package/dist/components.js +24 -28
  28. package/dist/components.js.map +1 -1
  29. package/dist/{contextValidator-OOPCLPZW.js → contextValidator-5OGXSPKS.js} +2 -2
  30. package/dist/hooks.d.ts +3 -3
  31. package/dist/hooks.js +41 -139
  32. package/dist/hooks.js.map +1 -1
  33. package/dist/index.d.ts +27 -18
  34. package/dist/index.js +41 -50
  35. package/dist/index.js.map +1 -1
  36. package/dist/providers.js +3 -3
  37. package/dist/rbac/index.d.ts +16 -9
  38. package/dist/rbac/index.js +6 -6
  39. package/dist/{usePublicRouteParams-i3qtoBgg.d.ts → usePublicRouteParams-ClnV4tnv.d.ts} +8 -8
  40. package/dist/utils.js +1 -1
  41. package/docs/api/modules.md +210 -100
  42. package/package.json +1 -2
  43. package/scripts/validate-master.js +1 -1
  44. package/src/components/DataTable/__tests__/keyboard.test.tsx +15 -2
  45. package/src/components/DataTable/components/ImportModal.tsx +4 -6
  46. package/src/components/DataTable/components/ViewRowModal.tsx +4 -4
  47. package/src/components/DataTable/components/__tests__/ImportModal.test.tsx +455 -96
  48. package/src/components/DataTable/components/__tests__/ViewRowModal.test.tsx +122 -58
  49. package/src/components/DataTable/core/DataTableContext.tsx +1 -1
  50. package/src/components/DateTimeField/DateTimeField.tsx +17 -19
  51. package/src/components/DateTimeField/README.md +5 -2
  52. package/src/components/Dialog/Dialog.test.tsx +248 -228
  53. package/src/components/Dialog/Dialog.tsx +455 -325
  54. package/src/components/Dialog/index.ts +3 -3
  55. package/src/components/FileDisplay/FileDisplay.test.tsx +41 -0
  56. package/src/components/FileDisplay/FileDisplay.tsx +5 -5
  57. package/src/components/Form/Form.test.tsx +3 -2
  58. package/src/components/Form/Form.tsx +4 -5
  59. package/src/components/InactivityWarningModal/InactivityWarningModal.test.tsx +28 -28
  60. package/src/components/InactivityWarningModal/InactivityWarningModal.tsx +40 -54
  61. package/src/components/LoginForm/LoginForm.tsx +2 -2
  62. package/src/components/NavigationMenu/NavigationMenu.tsx +2 -2
  63. package/src/components/PaceAppLayout/PaceAppLayout.tsx +32 -39
  64. package/src/components/PaceAppLayout/README.md +10 -9
  65. package/src/components/PaceAppLayout/test-setup.tsx +40 -31
  66. package/src/components/PasswordChange/PasswordChangeForm.test.tsx +61 -0
  67. package/src/components/PasswordChange/PasswordChangeForm.tsx +20 -13
  68. package/src/components/PublicLayout/PublicLayout.test.tsx +7 -3
  69. package/src/components/PublicLayout/PublicPageLayout.tsx +5 -8
  70. package/src/components/UserMenu/UserMenu.test.tsx +38 -6
  71. package/src/components/UserMenu/UserMenu.tsx +36 -34
  72. package/src/components/index.ts +3 -4
  73. package/src/hooks/useEventTheme.ts +4 -4
  74. package/src/hooks/useEvents.ts +11 -7
  75. package/src/hooks/useKeyboardShortcuts.ts +1 -1
  76. package/src/hooks/useOrganisationPermissions.ts +4 -4
  77. package/src/hooks/useOrganisations.ts +13 -7
  78. package/src/index.ts +11 -1
  79. package/src/rbac/README.md +20 -20
  80. package/src/rbac/hooks/useRBAC.test.ts +21 -3
  81. package/src/rbac/hooks/useRBAC.ts +4 -3
  82. package/src/rbac/hooks/useResourcePermissions.test.ts +125 -30
  83. package/src/rbac/hooks/useResourcePermissions.ts +57 -29
  84. package/src/rbac/permissions.ts +17 -17
  85. package/src/rbac/utils/contextValidator.ts +36 -0
  86. package/src/services/AuthService.ts +2 -5
  87. package/src/services/InactivityService.ts +139 -58
  88. package/src/styles/core.css +4 -0
  89. package/src/utils/formatting/formatTime.test.ts +3 -2
  90. package/dist/chunk-5EC5MEWX.js.map +0 -1
  91. package/dist/chunk-6SOIHG6Z.js.map +0 -1
  92. package/dist/chunk-7JPAB3T5.js.map +0 -1
  93. package/dist/chunk-AVMLPIM7.js.map +0 -1
  94. package/dist/chunk-I6DAQMWX.js.map +0 -1
  95. package/dist/chunk-NN6WWZ5U.js.map +0 -1
  96. package/dist/chunk-OEWDTMG7.js.map +0 -1
  97. /package/dist/{DataTable-E7YQZD7D.js.map → DataTable-AOVNCPTX.js.map} +0 -0
  98. /package/dist/{UnifiedAuthProvider-QPXO24B4.js.map → UnifiedAuthProvider-4SBX4LU5.js.map} +0 -0
  99. /package/dist/{api-6LVZTHDS.js.map → api-O6HTBX5Y.js.map} +0 -0
  100. /package/dist/{chunk-3LPHPB62.js.map → chunk-EFN2EIMK.js.map} +0 -0
  101. /package/dist/{contextValidator-OOPCLPZW.js.map → contextValidator-5OGXSPKS.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  isRBACInitialized,
3
3
  setupRBAC
4
- } from "./chunk-3LPHPB62.js";
4
+ } from "./chunk-EFN2EIMK.js";
5
5
  import {
6
6
  assertOrganisationId,
7
7
  assertUserId
@@ -126,11 +126,6 @@ var _AuthService = class _AuthService extends BaseService {
126
126
  }
127
127
  // Auth state getters
128
128
  getUser() {
129
- if (this.user) {
130
- logger.debug("AuthService", `getUser() [ID:${this.instanceId}] returning user: ${this.user.id}`);
131
- } else {
132
- logger.debug("AuthService", `getUser() [ID:${this.instanceId}] returning null`);
133
- }
134
129
  return this.user;
135
130
  }
136
131
  getSession() {
@@ -1016,7 +1011,7 @@ var _OrganisationService = class _OrganisationService extends BaseService {
1016
1011
  let userIsSuperAdmin = false;
1017
1012
  if (this.user?.id) {
1018
1013
  try {
1019
- const { isSuperAdmin: checkSuperAdmin, isRBACInitialized: isRBACInitialized2, setupRBAC: setupRBAC2 } = await import("./api-6LVZTHDS.js");
1014
+ const { isSuperAdmin: checkSuperAdmin, isRBACInitialized: isRBACInitialized2, setupRBAC: setupRBAC2 } = await import("./api-O6HTBX5Y.js");
1020
1015
  if (!isRBACInitialized2() && this.supabaseClient) {
1021
1016
  setupRBAC2(this.supabaseClient);
1022
1017
  }
@@ -1291,7 +1286,7 @@ var _EventService = class _EventService extends BaseService {
1291
1286
  this.setSelectedEventId = setSelectedEventId;
1292
1287
  if (user?.id) {
1293
1288
  try {
1294
- const { isRBACInitialized: isRBACInitialized2, isSuperAdmin: checkSuperAdmin, setupRBAC: setupRBAC2 } = await import("./api-6LVZTHDS.js");
1289
+ const { isRBACInitialized: isRBACInitialized2, isSuperAdmin: checkSuperAdmin, setupRBAC: setupRBAC2 } = await import("./api-O6HTBX5Y.js");
1295
1290
  if (!isRBACInitialized2() && this.supabaseClient) {
1296
1291
  setupRBAC2(this.supabaseClient);
1297
1292
  }
@@ -1533,7 +1528,7 @@ var _EventService = class _EventService extends BaseService {
1533
1528
  let organisationIdForRpc = null;
1534
1529
  let userIsSuperAdmin = this.isSuperAdmin;
1535
1530
  try {
1536
- const { isRBACInitialized: isRBACInitialized2, isSuperAdmin: checkSuperAdmin, setupRBAC: setupRBAC2 } = await import("./api-6LVZTHDS.js");
1531
+ const { isRBACInitialized: isRBACInitialized2, isSuperAdmin: checkSuperAdmin, setupRBAC: setupRBAC2 } = await import("./api-O6HTBX5Y.js");
1537
1532
  if (!isRBACInitialized2() && this.supabaseClient) {
1538
1533
  setupRBAC2(this.supabaseClient);
1539
1534
  }
@@ -2070,27 +2065,34 @@ var InactivityService = class extends BaseService {
2070
2065
  }
2071
2066
  setupEventHandlers() {
2072
2067
  if (typeof window === "undefined") return;
2073
- let idleTimer = null;
2074
2068
  let warningTimer = null;
2069
+ let logoutTimer = null;
2070
+ let countdownInterval = null;
2075
2071
  let lastActivity = Date.now();
2076
- let pollInterval = null;
2077
2072
  let prevIsIdle = false;
2078
2073
  let prevShowWarning = false;
2079
2074
  let prevShowInactivityWarning = false;
2080
2075
  let prevInactivityTimeRemaining = 0;
2081
2076
  let prevTimeRemaining = this.idleTimeoutMs;
2082
- const pollInactivityState = () => {
2077
+ const getTimeUntilWarning = () => {
2078
+ const timeSinceActivity = Date.now() - lastActivity;
2079
+ return Math.max(0, this.idleTimeoutMs - this.warnBeforeMs - timeSinceActivity);
2080
+ };
2081
+ const getTimeUntilLogout = () => {
2082
+ const timeSinceActivity = Date.now() - lastActivity;
2083
+ return Math.max(0, this.idleTimeoutMs - timeSinceActivity);
2084
+ };
2085
+ const updateState = (forceNotify = false) => {
2083
2086
  const now = Date.now();
2084
2087
  const timeSinceActivity = now - lastActivity;
2085
2088
  const timeUntilIdle = this.idleTimeoutMs - timeSinceActivity;
2086
- const timeUntilWarning = this.idleTimeoutMs - this.warnBeforeMs - timeSinceActivity;
2087
- const newIsIdle = timeSinceActivity >= this.idleTimeoutMs - this.warnBeforeMs;
2088
- const newShowWarning = newIsIdle && timeSinceActivity < this.idleTimeoutMs;
2089
+ const newIsIdle = timeSinceActivity >= this.idleTimeoutMs;
2090
+ const newShowWarning = timeSinceActivity >= this.idleTimeoutMs - this.warnBeforeMs && !newIsIdle;
2089
2091
  const newShowInactivityWarning = newShowWarning;
2090
- const newInactivityTimeRemaining = newShowWarning ? Math.ceil((this.idleTimeoutMs - timeSinceActivity) / 1e3) : 0;
2092
+ const newInactivityTimeRemaining = newShowWarning ? Math.ceil(timeUntilIdle / 1e3) : 0;
2091
2093
  const newTimeRemaining = Math.max(0, timeUntilIdle);
2092
- const stateChanged = prevIsIdle !== newIsIdle || prevShowWarning !== newShowWarning || prevShowInactivityWarning !== newShowInactivityWarning || prevInactivityTimeRemaining !== newInactivityTimeRemaining || prevTimeRemaining !== newTimeRemaining;
2093
- if (stateChanged) {
2094
+ const stateChanged = prevIsIdle !== newIsIdle || prevShowWarning !== newShowWarning || prevShowInactivityWarning !== newShowInactivityWarning || newShowWarning && prevInactivityTimeRemaining !== newInactivityTimeRemaining || prevTimeRemaining !== newTimeRemaining;
2095
+ if (stateChanged || forceNotify) {
2094
2096
  this._isIdle = newIsIdle;
2095
2097
  this._showWarning = newShowWarning;
2096
2098
  this._showInactivityWarning = newShowInactivityWarning;
@@ -2101,73 +2103,123 @@ var InactivityService = class extends BaseService {
2101
2103
  prevShowInactivityWarning = newShowInactivityWarning;
2102
2104
  prevInactivityTimeRemaining = newInactivityTimeRemaining;
2103
2105
  prevTimeRemaining = newTimeRemaining;
2104
- this.notify();
2105
- if (newIsIdle && timeSinceActivity >= this.idleTimeoutMs) {
2106
+ if (stateChanged) {
2107
+ this.notify();
2108
+ }
2109
+ if (newIsIdle) {
2106
2110
  this.handleIdleLogout();
2107
2111
  }
2108
2112
  }
2109
- if (idleTimer) {
2110
- clearTimeout(idleTimer);
2111
- idleTimer = null;
2112
- }
2113
+ };
2114
+ const scheduleNextCheck = () => {
2113
2115
  if (warningTimer) {
2114
2116
  clearTimeout(warningTimer);
2115
2117
  warningTimer = null;
2116
2118
  }
2117
- if (!newIsIdle && timeUntilIdle > 0) {
2118
- idleTimer = setTimeout(() => {
2119
- pollInactivityState();
2120
- }, Math.min(1e4, timeUntilIdle));
2121
- }
2122
- if (newShowWarning && timeUntilIdle > 0) {
2123
- warningTimer = setTimeout(() => {
2119
+ if (logoutTimer) {
2120
+ clearTimeout(logoutTimer);
2121
+ logoutTimer = null;
2122
+ }
2123
+ if (countdownInterval) {
2124
+ clearInterval(countdownInterval);
2125
+ countdownInterval = null;
2126
+ }
2127
+ const timeUntilWarning = getTimeUntilWarning();
2128
+ const timeUntilLogout = getTimeUntilLogout();
2129
+ const timeSinceActivity = Date.now() - lastActivity;
2130
+ if (timeSinceActivity >= this.idleTimeoutMs) {
2131
+ return;
2132
+ }
2133
+ if (timeSinceActivity >= this.idleTimeoutMs - this.warnBeforeMs) {
2134
+ updateState();
2135
+ countdownInterval = setInterval(() => {
2136
+ updateState();
2137
+ if (Date.now() - lastActivity >= this.idleTimeoutMs) {
2138
+ if (countdownInterval) {
2139
+ clearInterval(countdownInterval);
2140
+ countdownInterval = null;
2141
+ }
2142
+ this.handleIdleLogout();
2143
+ }
2144
+ }, 1e3);
2145
+ logoutTimer = setTimeout(() => {
2146
+ if (countdownInterval) {
2147
+ clearInterval(countdownInterval);
2148
+ countdownInterval = null;
2149
+ }
2124
2150
  this.handleIdleLogout();
2125
- }, timeUntilIdle);
2151
+ }, timeUntilLogout);
2152
+ } else {
2153
+ const timeUntilWarningMs = timeUntilWarning;
2154
+ const adaptiveInterval = timeUntilWarningMs > 5 * 60 * 1e3 ? 60 * 1e3 : timeUntilWarningMs > 60 * 1e3 ? 10 * 1e3 : 1e3;
2155
+ warningTimer = setTimeout(() => {
2156
+ updateState();
2157
+ scheduleNextCheck();
2158
+ }, Math.min(adaptiveInterval, timeUntilWarningMs));
2126
2159
  }
2127
2160
  };
2128
2161
  const resetTimers = () => {
2129
2162
  lastActivity = Date.now();
2130
- if (idleTimer) {
2131
- clearTimeout(idleTimer);
2132
- idleTimer = null;
2133
- }
2134
2163
  if (warningTimer) {
2135
2164
  clearTimeout(warningTimer);
2136
2165
  warningTimer = null;
2137
2166
  }
2167
+ if (logoutTimer) {
2168
+ clearTimeout(logoutTimer);
2169
+ logoutTimer = null;
2170
+ }
2171
+ if (countdownInterval) {
2172
+ clearInterval(countdownInterval);
2173
+ countdownInterval = null;
2174
+ }
2175
+ const hadWarning = this._showWarning || this._showInactivityWarning;
2138
2176
  this._showInactivityWarning = false;
2139
2177
  this._inactivityTimeRemaining = 0;
2140
2178
  this._isIdle = false;
2141
2179
  this._showWarning = false;
2180
+ this._timeRemaining = this.idleTimeoutMs;
2142
2181
  prevIsIdle = false;
2143
2182
  prevShowWarning = false;
2144
2183
  prevShowInactivityWarning = false;
2145
2184
  prevInactivityTimeRemaining = 0;
2146
2185
  prevTimeRemaining = this.idleTimeoutMs;
2186
+ if (hadWarning) {
2187
+ this.notify();
2188
+ }
2189
+ scheduleNextCheck();
2147
2190
  };
2148
2191
  const activityEvents = ["mousedown", "mousemove", "keypress", "scroll", "touchstart", "click"];
2192
+ let activityThrottleTimer = null;
2149
2193
  const handleActivity = () => {
2150
- resetTimers();
2194
+ if (activityThrottleTimer) {
2195
+ return;
2196
+ }
2197
+ activityThrottleTimer = setTimeout(() => {
2198
+ activityThrottleTimer = null;
2199
+ resetTimers();
2200
+ }, 1e3);
2151
2201
  };
2152
2202
  activityEvents.forEach((event) => {
2153
2203
  document.addEventListener(event, handleActivity, true);
2154
2204
  });
2155
- pollInterval = setInterval(() => {
2156
- pollInactivityState();
2157
- }, 1e4);
2158
- pollInactivityState();
2205
+ updateState(true);
2206
+ scheduleNextCheck();
2159
2207
  this.cleanupHandlers = () => {
2160
- if (idleTimer) {
2161
- clearTimeout(idleTimer);
2162
- idleTimer = null;
2163
- }
2164
2208
  if (warningTimer) {
2165
2209
  clearTimeout(warningTimer);
2166
2210
  warningTimer = null;
2167
2211
  }
2168
- if (pollInterval) {
2169
- clearInterval(pollInterval);
2170
- pollInterval = null;
2212
+ if (logoutTimer) {
2213
+ clearTimeout(logoutTimer);
2214
+ logoutTimer = null;
2215
+ }
2216
+ if (countdownInterval) {
2217
+ clearInterval(countdownInterval);
2218
+ countdownInterval = null;
2219
+ }
2220
+ if (activityThrottleTimer) {
2221
+ clearTimeout(activityThrottleTimer);
2222
+ activityThrottleTimer = null;
2171
2223
  }
2172
2224
  activityEvents.forEach((event) => {
2173
2225
  document.removeEventListener(event, handleActivity, true);
@@ -2180,7 +2232,6 @@ var InactivityService = class extends BaseService {
2180
2232
  this._inactivityTimeRemaining = 0;
2181
2233
  };
2182
2234
  this._isTracking = true;
2183
- this.notify();
2184
2235
  }
2185
2236
  };
2186
2237
 
@@ -2494,7 +2545,7 @@ function UnifiedAuthContextProvider({
2494
2545
  resolvedUserIdRef.current = currentUserId;
2495
2546
  const userId = currentUserId;
2496
2547
  const appNameValue = appName;
2497
- import("./api-6LVZTHDS.js").then(async ({ resolveAppContext, setupRBAC: setupRBAC2 }) => {
2548
+ import("./api-O6HTBX5Y.js").then(async ({ resolveAppContext, setupRBAC: setupRBAC2 }) => {
2498
2549
  try {
2499
2550
  setupRBAC2(supabase);
2500
2551
  const result = await resolveAppContext({
@@ -2961,4 +3012,4 @@ export {
2961
3012
  useUnifiedAuth,
2962
3013
  UnifiedAuthProvider
2963
3014
  };
2964
- //# sourceMappingURL=chunk-AVMLPIM7.js.map
3015
+ //# sourceMappingURL=chunk-IHB5DR3H.js.map