@jmruthers/pace-core 0.5.95 → 0.5.98

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 (121) hide show
  1. package/dist/{DataTable-XENXNMCP.js → DataTable-YK5UZGRI.js} +4 -2
  2. package/dist/{chunk-V5CTX4FR.js → chunk-DIKQ7AB6.js} +2 -2
  3. package/dist/{chunk-EPKHU5SS.js → chunk-UWBDIT5N.js} +155 -13
  4. package/dist/chunk-UWBDIT5N.js.map +1 -0
  5. package/dist/components.js +2 -2
  6. package/dist/index.js +2 -2
  7. package/dist/utils.js +1 -1
  8. package/docs/api/classes/ColumnFactory.md +1 -1
  9. package/docs/api/classes/ErrorBoundary.md +1 -1
  10. package/docs/api/classes/InvalidScopeError.md +1 -1
  11. package/docs/api/classes/MissingUserContextError.md +1 -1
  12. package/docs/api/classes/OrganisationContextRequiredError.md +1 -1
  13. package/docs/api/classes/PermissionDeniedError.md +1 -1
  14. package/docs/api/classes/PublicErrorBoundary.md +1 -1
  15. package/docs/api/classes/RBACAuditManager.md +1 -1
  16. package/docs/api/classes/RBACCache.md +1 -1
  17. package/docs/api/classes/RBACEngine.md +1 -1
  18. package/docs/api/classes/RBACError.md +1 -1
  19. package/docs/api/classes/RBACNotInitializedError.md +1 -1
  20. package/docs/api/classes/SecureSupabaseClient.md +1 -1
  21. package/docs/api/classes/StorageUtils.md +1 -1
  22. package/docs/api/enums/FileCategory.md +1 -1
  23. package/docs/api/interfaces/AggregateConfig.md +1 -1
  24. package/docs/api/interfaces/ButtonProps.md +1 -1
  25. package/docs/api/interfaces/CardProps.md +1 -1
  26. package/docs/api/interfaces/ColorPalette.md +1 -1
  27. package/docs/api/interfaces/ColorShade.md +1 -1
  28. package/docs/api/interfaces/DataAccessRecord.md +1 -1
  29. package/docs/api/interfaces/DataRecord.md +1 -1
  30. package/docs/api/interfaces/DataTableAction.md +1 -1
  31. package/docs/api/interfaces/DataTableColumn.md +1 -1
  32. package/docs/api/interfaces/DataTableProps.md +1 -1
  33. package/docs/api/interfaces/DataTableToolbarButton.md +1 -1
  34. package/docs/api/interfaces/EmptyStateConfig.md +1 -1
  35. package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
  36. package/docs/api/interfaces/EventLogoProps.md +1 -1
  37. package/docs/api/interfaces/FileDisplayProps.md +1 -1
  38. package/docs/api/interfaces/FileMetadata.md +1 -1
  39. package/docs/api/interfaces/FileReference.md +1 -1
  40. package/docs/api/interfaces/FileSizeLimits.md +1 -1
  41. package/docs/api/interfaces/FileUploadOptions.md +1 -1
  42. package/docs/api/interfaces/FileUploadProps.md +1 -1
  43. package/docs/api/interfaces/FooterProps.md +1 -1
  44. package/docs/api/interfaces/InactivityWarningModalProps.md +1 -1
  45. package/docs/api/interfaces/InputProps.md +1 -1
  46. package/docs/api/interfaces/LabelProps.md +1 -1
  47. package/docs/api/interfaces/LoginFormProps.md +1 -1
  48. package/docs/api/interfaces/NavigationAccessRecord.md +1 -1
  49. package/docs/api/interfaces/NavigationContextType.md +1 -1
  50. package/docs/api/interfaces/NavigationGuardProps.md +1 -1
  51. package/docs/api/interfaces/NavigationItem.md +1 -1
  52. package/docs/api/interfaces/NavigationMenuProps.md +1 -1
  53. package/docs/api/interfaces/NavigationProviderProps.md +1 -1
  54. package/docs/api/interfaces/Organisation.md +1 -1
  55. package/docs/api/interfaces/OrganisationContextType.md +1 -1
  56. package/docs/api/interfaces/OrganisationMembership.md +1 -1
  57. package/docs/api/interfaces/OrganisationProviderProps.md +1 -1
  58. package/docs/api/interfaces/OrganisationSecurityError.md +1 -1
  59. package/docs/api/interfaces/PaceAppLayoutProps.md +1 -1
  60. package/docs/api/interfaces/PaceLoginPageProps.md +1 -1
  61. package/docs/api/interfaces/PageAccessRecord.md +1 -1
  62. package/docs/api/interfaces/PagePermissionContextType.md +1 -1
  63. package/docs/api/interfaces/PagePermissionGuardProps.md +1 -1
  64. package/docs/api/interfaces/PagePermissionProviderProps.md +1 -1
  65. package/docs/api/interfaces/PaletteData.md +1 -1
  66. package/docs/api/interfaces/PermissionEnforcerProps.md +1 -1
  67. package/docs/api/interfaces/ProtectedRouteProps.md +1 -1
  68. package/docs/api/interfaces/PublicErrorBoundaryProps.md +1 -1
  69. package/docs/api/interfaces/PublicErrorBoundaryState.md +1 -1
  70. package/docs/api/interfaces/PublicLoadingSpinnerProps.md +1 -1
  71. package/docs/api/interfaces/PublicPageFooterProps.md +1 -1
  72. package/docs/api/interfaces/PublicPageHeaderProps.md +1 -1
  73. package/docs/api/interfaces/PublicPageLayoutProps.md +1 -1
  74. package/docs/api/interfaces/RBACConfig.md +1 -1
  75. package/docs/api/interfaces/RBACLogger.md +1 -1
  76. package/docs/api/interfaces/RoleBasedRouterContextType.md +1 -1
  77. package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
  78. package/docs/api/interfaces/RouteAccessRecord.md +1 -1
  79. package/docs/api/interfaces/RouteConfig.md +1 -1
  80. package/docs/api/interfaces/SecureDataContextType.md +1 -1
  81. package/docs/api/interfaces/SecureDataProviderProps.md +1 -1
  82. package/docs/api/interfaces/StorageConfig.md +1 -1
  83. package/docs/api/interfaces/StorageFileInfo.md +1 -1
  84. package/docs/api/interfaces/StorageFileMetadata.md +1 -1
  85. package/docs/api/interfaces/StorageListOptions.md +1 -1
  86. package/docs/api/interfaces/StorageListResult.md +1 -1
  87. package/docs/api/interfaces/StorageUploadOptions.md +1 -1
  88. package/docs/api/interfaces/StorageUploadResult.md +1 -1
  89. package/docs/api/interfaces/StorageUrlOptions.md +1 -1
  90. package/docs/api/interfaces/StyleImport.md +1 -1
  91. package/docs/api/interfaces/SwitchProps.md +1 -1
  92. package/docs/api/interfaces/ToastActionElement.md +1 -1
  93. package/docs/api/interfaces/ToastProps.md +1 -1
  94. package/docs/api/interfaces/UnifiedAuthContextType.md +1 -1
  95. package/docs/api/interfaces/UnifiedAuthProviderProps.md +1 -1
  96. package/docs/api/interfaces/UseEventLogoOptions.md +1 -1
  97. package/docs/api/interfaces/UseEventLogoReturn.md +1 -1
  98. package/docs/api/interfaces/UseInactivityTrackerOptions.md +1 -1
  99. package/docs/api/interfaces/UseInactivityTrackerReturn.md +1 -1
  100. package/docs/api/interfaces/UsePublicEventLogoOptions.md +1 -1
  101. package/docs/api/interfaces/UsePublicEventLogoReturn.md +1 -1
  102. package/docs/api/interfaces/UsePublicEventOptions.md +1 -1
  103. package/docs/api/interfaces/UsePublicEventReturn.md +1 -1
  104. package/docs/api/interfaces/UsePublicFileDisplayOptions.md +1 -1
  105. package/docs/api/interfaces/UsePublicFileDisplayReturn.md +1 -1
  106. package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
  107. package/docs/api/interfaces/UseResolvedScopeOptions.md +1 -1
  108. package/docs/api/interfaces/UseResolvedScopeReturn.md +1 -1
  109. package/docs/api/interfaces/UserEventAccess.md +1 -1
  110. package/docs/api/interfaces/UserMenuProps.md +1 -1
  111. package/docs/api/interfaces/UserProfile.md +1 -1
  112. package/docs/api/modules.md +2 -2
  113. package/docs/implementation-guides/data-tables.md +156 -1
  114. package/package.json +1 -1
  115. package/src/components/DataTable/DataTable.tsx +1 -1
  116. package/src/components/DataTable/components/DataTableCore.tsx +72 -24
  117. package/src/components/DataTable/components/DataTableModals.tsx +76 -5
  118. package/src/components/DataTable/utils/exportUtils.ts +133 -2
  119. package/dist/chunk-EPKHU5SS.js.map +0 -1
  120. /package/dist/{DataTable-XENXNMCP.js.map → DataTable-YK5UZGRI.js.map} +0 -0
  121. /package/dist/{chunk-V5CTX4FR.js.map → chunk-DIKQ7AB6.js.map} +0 -0
@@ -33,6 +33,7 @@ import {
33
33
  createHierarchicalStructure,
34
34
  defaultDataTableFeatures,
35
35
  exportToCSV,
36
+ exportToCSVWithTableRows,
36
37
  generateCSVContent,
37
38
  getAriaSortValue,
38
39
  getCellRenderer,
@@ -53,7 +54,7 @@ import {
53
54
  sortHierarchicalDataWithSorting,
54
55
  validateHierarchicalData,
55
56
  validatePaginationConfig
56
- } from "./chunk-EPKHU5SS.js";
57
+ } from "./chunk-UWBDIT5N.js";
57
58
  import "./chunk-2KLAOD4M.js";
58
59
  import "./chunk-S63MFSY6.js";
59
60
  import "./chunk-Q7APDV6H.js";
@@ -130,6 +131,7 @@ export {
130
131
  defaultDataTableFeatures,
131
132
  determinePaginationMode,
132
133
  exportToCSV,
134
+ exportToCSVWithTableRows,
133
135
  generateCSVContent,
134
136
  getAriaSortValue,
135
137
  getCellRenderer,
@@ -155,4 +157,4 @@ export {
155
157
  validateHierarchicalData,
156
158
  validatePaginationConfig
157
159
  };
158
- //# sourceMappingURL=DataTable-XENXNMCP.js.map
160
+ //# sourceMappingURL=DataTable-YK5UZGRI.js.map
@@ -25,7 +25,7 @@ import {
25
25
  SelectSeparator,
26
26
  SelectTrigger,
27
27
  SelectValue
28
- } from "./chunk-EPKHU5SS.js";
28
+ } from "./chunk-UWBDIT5N.js";
29
29
  import {
30
30
  isPermitted,
31
31
  isSuperAdmin
@@ -4799,4 +4799,4 @@ export {
4799
4799
  EventLogoCompact,
4800
4800
  EventLogoLarge
4801
4801
  };
4802
- //# sourceMappingURL=chunk-V5CTX4FR.js.map
4802
+ //# sourceMappingURL=chunk-DIKQ7AB6.js.map
@@ -8914,11 +8914,40 @@ function ImportModal({ isOpen, onClose, onImport, config = {} }) {
8914
8914
 
8915
8915
  // src/components/DataTable/components/DataTableModals.tsx
8916
8916
  import { Fragment as Fragment3, jsx as jsx19 } from "react/jsx-runtime";
8917
+ function mapCSVToTableColumns(csvData, columns) {
8918
+ const columnMap = /* @__PURE__ */ new Map();
8919
+ columns.forEach((col) => {
8920
+ const fieldName = col.editAccessorKey || col.accessorKey || col.id;
8921
+ const header = typeof col.header === "string" ? col.header : "";
8922
+ if (fieldName && header) {
8923
+ columnMap.set(header.toLowerCase(), fieldName);
8924
+ const colId = col.id || col.accessorKey;
8925
+ if (colId && colId !== header && colId !== fieldName) {
8926
+ columnMap.set(colId.toLowerCase(), fieldName);
8927
+ }
8928
+ if (col.editAccessorKey && header) {
8929
+ const idColumnHeader = `${header} (ID)`;
8930
+ columnMap.set(idColumnHeader.toLowerCase(), col.editAccessorKey);
8931
+ columnMap.set(col.editAccessorKey.toLowerCase(), col.editAccessorKey);
8932
+ }
8933
+ }
8934
+ });
8935
+ return csvData.map((row) => {
8936
+ const mappedRow = {};
8937
+ Object.keys(row).forEach((csvHeader) => {
8938
+ const csvHeaderLower = csvHeader.toLowerCase();
8939
+ const fieldName = columnMap.get(csvHeaderLower) || csvHeaderLower;
8940
+ mappedRow[fieldName] = row[csvHeader];
8941
+ });
8942
+ return mappedRow;
8943
+ });
8944
+ }
8917
8945
  function DataTableModals({
8918
8946
  showImportModal,
8919
8947
  onCloseImportModal,
8920
8948
  onImport,
8921
8949
  importModalConfig,
8950
+ columns,
8922
8951
  onStoreFocus,
8923
8952
  onRestoreFocus
8924
8953
  }) {
@@ -8937,7 +8966,13 @@ function DataTableModals({
8937
8966
  {
8938
8967
  isOpen: showImportModal,
8939
8968
  onClose: onCloseImportModal,
8940
- onImport,
8969
+ onImport: async (rawData) => {
8970
+ const mappedData = columns ? mapCSVToTableColumns(rawData, columns) : rawData;
8971
+ const result = onImport(mappedData);
8972
+ if (result && typeof result.then === "function") {
8973
+ await result;
8974
+ }
8975
+ },
8941
8976
  config: importModalConfig
8942
8977
  }
8943
8978
  ) });
@@ -10218,8 +10253,18 @@ function generateCSVContent(data, columns, options = {}) {
10218
10253
  });
10219
10254
  const csvData = data.map((row) => {
10220
10255
  return columns.map((col) => {
10221
- const key = col.accessorKey || col.id;
10222
- let value = key ? row[key] : void 0;
10256
+ let value;
10257
+ if (col.accessorFn) {
10258
+ try {
10259
+ value = col.accessorFn(row);
10260
+ } catch (error) {
10261
+ console.warn("Error evaluating accessorFn for column:", col.id || col.header, error);
10262
+ value = void 0;
10263
+ }
10264
+ } else {
10265
+ const key = col.accessorKey || col.id;
10266
+ value = key ? row[key] : void 0;
10267
+ }
10223
10268
  if (locale && (typeof value === "number" || value instanceof Date || typeof value === "boolean")) {
10224
10269
  value = formatLocaleValue(value, locale);
10225
10270
  }
@@ -10229,6 +10274,76 @@ function generateCSVContent(data, columns, options = {}) {
10229
10274
  const csvContent = includeHeaders ? [headers.join(","), ...csvData].join("\n") : csvData.join("\n");
10230
10275
  return csvContent;
10231
10276
  }
10277
+ async function exportToCSVWithTableRows(tableRows, columns, columnIdToTableColumn, filename = "download.csv", options = {}) {
10278
+ const logger = createLogger("ExportUtils");
10279
+ return new Promise((resolve, reject) => {
10280
+ try {
10281
+ if (typeof window === "undefined") {
10282
+ throw new Error("CSV export is only available in browser environments");
10283
+ }
10284
+ if (!tableRows || tableRows.length === 0) {
10285
+ throw new Error("No data to export");
10286
+ }
10287
+ if (!columns || columns.length === 0) {
10288
+ throw new Error("No columns defined for export");
10289
+ }
10290
+ const headers = columns.map((col) => {
10291
+ const headerValue = col.header || col.id || "Column";
10292
+ return escapeCSVValue(headerValue, options.sanitizeForSecurity !== false);
10293
+ });
10294
+ const csvData = tableRows.map((tableRow) => {
10295
+ return columns.map((col) => {
10296
+ let value;
10297
+ if (col.isIdColumn && col.accessorKey) {
10298
+ value = tableRow.original[col.accessorKey];
10299
+ } else if (col.id && columnIdToTableColumn.has(col.id)) {
10300
+ try {
10301
+ value = tableRow.getValue(col.id);
10302
+ } catch (error) {
10303
+ if (col.accessorFn) {
10304
+ try {
10305
+ value = col.accessorFn(tableRow.original);
10306
+ } catch (accessorError) {
10307
+ console.warn("Error evaluating accessorFn for column:", col.id || col.header, accessorError);
10308
+ value = void 0;
10309
+ }
10310
+ } else {
10311
+ const key = col.accessorKey || col.id;
10312
+ value = key ? tableRow.original[key] : void 0;
10313
+ }
10314
+ }
10315
+ } else {
10316
+ const key = col.accessorKey || col.id;
10317
+ value = key ? tableRow.original[key] : void 0;
10318
+ }
10319
+ if (options.locale && (typeof value === "number" || value instanceof Date || typeof value === "boolean")) {
10320
+ value = formatLocaleValue(value, options.locale);
10321
+ }
10322
+ return escapeCSVValue(value, options.sanitizeForSecurity !== false);
10323
+ }).join(",");
10324
+ });
10325
+ const csvContent = [headers.join(","), ...csvData].join("\n");
10326
+ const blob = new Blob([csvContent], { type: "text/csv;charset=utf-8;" });
10327
+ const link = document.createElement("a");
10328
+ const url = URL.createObjectURL(blob);
10329
+ link.setAttribute("href", url);
10330
+ link.setAttribute("download", filename);
10331
+ link.style.display = "none";
10332
+ link.onclick = () => {
10333
+ setTimeout(() => {
10334
+ URL.revokeObjectURL(url);
10335
+ resolve();
10336
+ }, 100);
10337
+ };
10338
+ document.body.appendChild(link);
10339
+ link.click();
10340
+ document.body.removeChild(link);
10341
+ } catch (error) {
10342
+ logger.error("Failed to export data to CSV:", error);
10343
+ reject(error);
10344
+ }
10345
+ });
10346
+ }
10232
10347
  function exportToCSV(data, columns, filename = "download.csv", options = {}) {
10233
10348
  const logger = createLogger("ExportUtils");
10234
10349
  return new Promise((resolve, reject) => {
@@ -11671,26 +11786,46 @@ function DataTableInternal({
11671
11786
  onImportClick: () => stateActions.setImportModal(true),
11672
11787
  onExport: secureHandlers.onExport || (async () => {
11673
11788
  try {
11674
- const currentData = table.getFilteredRowModel().rows.map((row) => row.original);
11789
+ const tableRows = table.getFilteredRowModel().rows;
11675
11790
  const tableColumns = table.getAllColumns();
11676
11791
  const visibleTableColumns = tableColumns.filter((col) => {
11677
11792
  const isSystemColumn = col.id === "select" || col.id === "actions";
11678
11793
  return !isSystemColumn && col.getIsVisible();
11679
11794
  });
11680
- const visibleColumns2 = visibleTableColumns.map((tableCol) => {
11795
+ const visibleColumns2 = [];
11796
+ const columnIdToTableColumn = /* @__PURE__ */ new Map();
11797
+ visibleTableColumns.forEach((tableCol) => {
11681
11798
  const originalCol = columns.find((col) => {
11682
11799
  const colId = col.id || col.accessorKey;
11683
11800
  return colId && String(colId) === tableCol.id;
11684
11801
  });
11685
- if (!originalCol) return null;
11686
- return {
11802
+ if (!originalCol) return;
11803
+ columnIdToTableColumn.set(tableCol.id, tableCol);
11804
+ const hasAccessorFn = "accessorFn" in originalCol && originalCol.accessorFn;
11805
+ const editAccessorKey = originalCol.editAccessorKey;
11806
+ const displayHeader = typeof originalCol.header === "string" ? originalCol.header : originalCol.accessorKey || tableCol.id || "Column";
11807
+ visibleColumns2.push({
11687
11808
  ...originalCol,
11688
- header: typeof originalCol.header === "string" ? originalCol.header : originalCol.accessorKey || tableCol.id || "Column"
11689
- };
11690
- }).filter((col) => col !== null);
11809
+ header: displayHeader,
11810
+ // Store table column ID for getValue() lookup
11811
+ id: tableCol.id,
11812
+ // Preserve accessorFn if present (will use getValue() if available)
11813
+ accessorFn: hasAccessorFn ? originalCol.accessorFn : void 0
11814
+ });
11815
+ if (hasAccessorFn && editAccessorKey) {
11816
+ const idHeader = `${displayHeader} (ID)`;
11817
+ visibleColumns2.push({
11818
+ id: editAccessorKey,
11819
+ accessorKey: editAccessorKey,
11820
+ header: idHeader,
11821
+ isIdColumn: true,
11822
+ editAccessorKey
11823
+ });
11824
+ }
11825
+ });
11691
11826
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
11692
11827
  const filename = title ? `${title.replace(/[^a-z0-9]/gi, "_").toLowerCase()}_${timestamp}.csv` : `data_export_${timestamp}.csv`;
11693
- await exportToCSV(currentData, visibleColumns2, filename);
11828
+ await exportToCSVWithTableRows(tableRows, visibleColumns2, columnIdToTableColumn, filename);
11694
11829
  toast({
11695
11830
  title: "Export Successful",
11696
11831
  description: `Data exported to ${filename}`,
@@ -11881,7 +12016,13 @@ function DataTableInternal({
11881
12016
  }
11882
12017
  stateActions.setImportModal(false);
11883
12018
  },
11884
- importModalConfig
12019
+ importModalConfig,
12020
+ columns: columns.map((col) => ({
12021
+ id: col.id,
12022
+ accessorKey: col.accessorKey,
12023
+ header: typeof col.header === "string" ? col.header : void 0,
12024
+ editAccessorKey: col.editAccessorKey
12025
+ }))
11885
12026
  }
11886
12027
  )
11887
12028
  ] });
@@ -12094,6 +12235,7 @@ export {
12094
12235
  isHierarchicalSortableColumn,
12095
12236
  getHierarchicalSortConfig,
12096
12237
  generateCSVContent,
12238
+ exportToCSVWithTableRows,
12097
12239
  exportToCSV,
12098
12240
  defaultDataTableFeatures,
12099
12241
  normalizeDataTableFeatures,
@@ -12128,4 +12270,4 @@ lodash/lodash.js:
12128
12270
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
12129
12271
  *)
12130
12272
  */
12131
- //# sourceMappingURL=chunk-EPKHU5SS.js.map
12273
+ //# sourceMappingURL=chunk-UWBDIT5N.js.map