@jmruthers/pace-core 0.5.95 → 0.5.97

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-FB22ES46.js} +2 -2
  2. package/dist/{chunk-EPKHU5SS.js → chunk-QX5I62KP.js} +77 -11
  3. package/dist/chunk-QX5I62KP.js.map +1 -0
  4. package/dist/{chunk-V5CTX4FR.js → chunk-UBPRDNPY.js} +2 -2
  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 +51 -18
  117. package/src/components/DataTable/components/DataTableModals.tsx +76 -5
  118. package/src/components/DataTable/utils/exportUtils.ts +18 -2
  119. package/dist/chunk-EPKHU5SS.js.map +0 -1
  120. /package/dist/{DataTable-XENXNMCP.js.map → DataTable-FB22ES46.js.map} +0 -0
  121. /package/dist/{chunk-V5CTX4FR.js.map → chunk-UBPRDNPY.js.map} +0 -0
@@ -53,7 +53,7 @@ import {
53
53
  sortHierarchicalDataWithSorting,
54
54
  validateHierarchicalData,
55
55
  validatePaginationConfig
56
- } from "./chunk-EPKHU5SS.js";
56
+ } from "./chunk-QX5I62KP.js";
57
57
  import "./chunk-2KLAOD4M.js";
58
58
  import "./chunk-S63MFSY6.js";
59
59
  import "./chunk-Q7APDV6H.js";
@@ -155,4 +155,4 @@ export {
155
155
  validateHierarchicalData,
156
156
  validatePaginationConfig
157
157
  };
158
- //# sourceMappingURL=DataTable-XENXNMCP.js.map
158
+ //# sourceMappingURL=DataTable-FB22ES46.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
  }
@@ -11677,17 +11722,32 @@ function DataTableInternal({
11677
11722
  const isSystemColumn = col.id === "select" || col.id === "actions";
11678
11723
  return !isSystemColumn && col.getIsVisible();
11679
11724
  });
11680
- const visibleColumns2 = visibleTableColumns.map((tableCol) => {
11725
+ const visibleColumns2 = [];
11726
+ visibleTableColumns.forEach((tableCol) => {
11681
11727
  const originalCol = columns.find((col) => {
11682
11728
  const colId = col.id || col.accessorKey;
11683
11729
  return colId && String(colId) === tableCol.id;
11684
11730
  });
11685
- if (!originalCol) return null;
11686
- return {
11731
+ if (!originalCol) return;
11732
+ const hasAccessorFn = "accessorFn" in originalCol && originalCol.accessorFn;
11733
+ const editAccessorKey = originalCol.editAccessorKey;
11734
+ visibleColumns2.push({
11687
11735
  ...originalCol,
11688
- header: typeof originalCol.header === "string" ? originalCol.header : originalCol.accessorKey || tableCol.id || "Column"
11689
- };
11690
- }).filter((col) => col !== null);
11736
+ header: typeof originalCol.header === "string" ? originalCol.header : originalCol.accessorKey || tableCol.id || "Column",
11737
+ // Preserve accessorFn if present (for computed/reference fields)
11738
+ // accessorFn is part of ColumnDef from TanStack Table
11739
+ accessorFn: hasAccessorFn ? originalCol.accessorFn : void 0
11740
+ });
11741
+ if (hasAccessorFn && editAccessorKey) {
11742
+ visibleColumns2.push({
11743
+ id: editAccessorKey,
11744
+ accessorKey: editAccessorKey,
11745
+ header: `${originalCol.header || "ID"} (ID)`,
11746
+ isIdColumn: true,
11747
+ editAccessorKey
11748
+ });
11749
+ }
11750
+ });
11691
11751
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
11692
11752
  const filename = title ? `${title.replace(/[^a-z0-9]/gi, "_").toLowerCase()}_${timestamp}.csv` : `data_export_${timestamp}.csv`;
11693
11753
  await exportToCSV(currentData, visibleColumns2, filename);
@@ -11881,7 +11941,13 @@ function DataTableInternal({
11881
11941
  }
11882
11942
  stateActions.setImportModal(false);
11883
11943
  },
11884
- importModalConfig
11944
+ importModalConfig,
11945
+ columns: columns.map((col) => ({
11946
+ id: col.id,
11947
+ accessorKey: col.accessorKey,
11948
+ header: typeof col.header === "string" ? col.header : void 0,
11949
+ editAccessorKey: col.editAccessorKey
11950
+ }))
11885
11951
  }
11886
11952
  )
11887
11953
  ] });
@@ -12128,4 +12194,4 @@ lodash/lodash.js:
12128
12194
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
12129
12195
  *)
12130
12196
  */
12131
- //# sourceMappingURL=chunk-EPKHU5SS.js.map
12197
+ //# sourceMappingURL=chunk-QX5I62KP.js.map