@jmruthers/pace-core 0.5.61 → 0.5.62
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.
- package/dist/{DataTable-5M6MV2VY.js → DataTable-7BER7PDS.js} +6 -6
- package/dist/{DataTable-DqDDvBfI.d.ts → DataTable-D15XipLZ.d.ts} +7 -0
- package/dist/{PublicLoadingSpinner-CrMOrhNz.d.ts → PublicLoadingSpinner-CXJ-W9wZ.d.ts} +2 -2
- package/dist/{chunk-44SAHU2N.js → chunk-2LPYEFXI.js} +5 -5
- package/dist/{chunk-XMTHMOOM.js → chunk-BTCA3ENN.js} +4 -4
- package/dist/{chunk-ESXTFEE6.js → chunk-C7GUF747.js} +3 -3
- package/dist/{chunk-W7PPXKTZ.js → chunk-CKNY7HYS.js} +2 -2
- package/dist/{chunk-5MLDIGHB.js → chunk-FVDOEGGG.js} +3 -3
- package/dist/{chunk-HFDYTSAP.js → chunk-QVEOQVD4.js} +3 -3
- package/dist/{chunk-XDXG6QVH.js → chunk-S66AJVI2.js} +13 -6
- package/dist/chunk-S66AJVI2.js.map +1 -0
- package/dist/{chunk-E4FPK232.js → chunk-T2MQY57J.js} +2 -2
- package/dist/{chunk-4ULBJNIT.js → chunk-T6HVDA24.js} +2 -2
- package/dist/{chunk-STT7INZR.js → chunk-ULBI5JGB.js} +2 -1
- package/dist/{chunk-CGSYCF2W.js → chunk-VTJ5HCZB.js} +2 -2
- package/dist/components.d.ts +82 -5
- package/dist/components.js +258 -9
- package/dist/components.js.map +1 -1
- package/dist/hooks.d.ts +3 -2
- package/dist/hooks.js +5 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +11 -11
- package/dist/{organisation-DD0yBbGU.d.ts → organisation-t-vvQC3g.d.ts} +1 -1
- package/dist/providers.d.ts +2 -2
- package/dist/providers.js +4 -4
- package/dist/rbac/index.js +6 -6
- package/dist/types.js +1 -1
- package/dist/{usePublicRouteParams-Cu6oKazv.d.ts → usePublicRouteParams-CdoFxnJK.d.ts} +2 -63
- package/dist/useToast-Bm6TnSK-.d.ts +63 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/docs/api/classes/ErrorBoundary.md +1 -1
- package/docs/api/classes/InvalidScopeError.md +1 -1
- package/docs/api/classes/MissingUserContextError.md +1 -1
- package/docs/api/classes/OrganisationContextRequiredError.md +1 -1
- package/docs/api/classes/PermissionDeniedError.md +1 -1
- package/docs/api/classes/PublicErrorBoundary.md +1 -1
- package/docs/api/classes/RBACAuditManager.md +1 -1
- package/docs/api/classes/RBACCache.md +1 -1
- package/docs/api/classes/RBACEngine.md +1 -1
- package/docs/api/classes/RBACError.md +1 -1
- package/docs/api/classes/RBACNotInitializedError.md +1 -1
- package/docs/api/classes/SecureSupabaseClient.md +1 -1
- package/docs/api/classes/StorageUtils.md +1 -1
- package/docs/api/interfaces/AggregateConfig.md +1 -1
- package/docs/api/interfaces/ButtonProps.md +1 -1
- package/docs/api/interfaces/CardProps.md +1 -1
- package/docs/api/interfaces/ColorPalette.md +1 -1
- package/docs/api/interfaces/ColorShade.md +1 -1
- package/docs/api/interfaces/DataAccessRecord.md +1 -1
- package/docs/api/interfaces/DataTableAction.md +1 -1
- package/docs/api/interfaces/DataTableColumn.md +1 -1
- package/docs/api/interfaces/DataTableProps.md +44 -18
- package/docs/api/interfaces/DataTableToolbarButton.md +1 -1
- package/docs/api/interfaces/EmptyStateConfig.md +1 -1
- package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
- package/docs/api/interfaces/EventContextType.md +1 -1
- package/docs/api/interfaces/EventLogoProps.md +1 -1
- package/docs/api/interfaces/EventProviderProps.md +1 -1
- package/docs/api/interfaces/FileSizeLimits.md +1 -1
- package/docs/api/interfaces/FileUploadProps.md +1 -1
- package/docs/api/interfaces/FooterProps.md +1 -1
- package/docs/api/interfaces/InactivityWarningModalProps.md +1 -1
- package/docs/api/interfaces/InputProps.md +1 -1
- package/docs/api/interfaces/LabelProps.md +1 -1
- package/docs/api/interfaces/LoginFormProps.md +1 -1
- package/docs/api/interfaces/NavigationAccessRecord.md +1 -1
- package/docs/api/interfaces/NavigationContextType.md +1 -1
- package/docs/api/interfaces/NavigationGuardProps.md +1 -1
- package/docs/api/interfaces/NavigationItem.md +1 -1
- package/docs/api/interfaces/NavigationMenuProps.md +1 -1
- package/docs/api/interfaces/NavigationProviderProps.md +1 -1
- package/docs/api/interfaces/Organisation.md +1 -1
- package/docs/api/interfaces/OrganisationContextType.md +1 -1
- package/docs/api/interfaces/OrganisationMembership.md +1 -1
- package/docs/api/interfaces/OrganisationProviderProps.md +1 -1
- package/docs/api/interfaces/OrganisationSecurityError.md +1 -1
- package/docs/api/interfaces/PaceAppLayoutProps.md +1 -1
- package/docs/api/interfaces/PaceLoginPageProps.md +1 -1
- package/docs/api/interfaces/PageAccessRecord.md +1 -1
- package/docs/api/interfaces/PagePermissionContextType.md +1 -1
- package/docs/api/interfaces/PagePermissionGuardProps.md +1 -1
- package/docs/api/interfaces/PagePermissionProviderProps.md +1 -1
- package/docs/api/interfaces/PaletteData.md +1 -1
- package/docs/api/interfaces/PermissionEnforcerProps.md +1 -1
- package/docs/api/interfaces/PublicErrorBoundaryProps.md +1 -1
- package/docs/api/interfaces/PublicErrorBoundaryState.md +1 -1
- package/docs/api/interfaces/PublicLoadingSpinnerProps.md +1 -1
- package/docs/api/interfaces/PublicPageFooterProps.md +1 -1
- package/docs/api/interfaces/PublicPageHeaderProps.md +1 -1
- package/docs/api/interfaces/PublicPageLayoutProps.md +1 -1
- package/docs/api/interfaces/RBACConfig.md +1 -1
- package/docs/api/interfaces/RBACContextType.md +1 -1
- package/docs/api/interfaces/RBACLogger.md +1 -1
- package/docs/api/interfaces/RBACProviderProps.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterContextType.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
- package/docs/api/interfaces/RouteAccessRecord.md +1 -1
- package/docs/api/interfaces/RouteConfig.md +1 -1
- package/docs/api/interfaces/SecureDataContextType.md +1 -1
- package/docs/api/interfaces/SecureDataProviderProps.md +1 -1
- package/docs/api/interfaces/StorageConfig.md +1 -1
- package/docs/api/interfaces/StorageFileInfo.md +1 -1
- package/docs/api/interfaces/StorageFileMetadata.md +1 -1
- package/docs/api/interfaces/StorageListOptions.md +1 -1
- package/docs/api/interfaces/StorageListResult.md +1 -1
- package/docs/api/interfaces/StorageUploadOptions.md +1 -1
- package/docs/api/interfaces/StorageUploadResult.md +1 -1
- package/docs/api/interfaces/StorageUrlOptions.md +1 -1
- package/docs/api/interfaces/StyleImport.md +1 -1
- package/docs/api/interfaces/ToastActionElement.md +1 -1
- package/docs/api/interfaces/ToastProps.md +1 -1
- package/docs/api/interfaces/UnifiedAuthContextType.md +1 -1
- package/docs/api/interfaces/UnifiedAuthProviderProps.md +1 -1
- package/docs/api/interfaces/UseInactivityTrackerOptions.md +1 -1
- package/docs/api/interfaces/UseInactivityTrackerReturn.md +1 -1
- package/docs/api/interfaces/UsePublicEventLogoOptions.md +1 -1
- package/docs/api/interfaces/UsePublicEventLogoReturn.md +1 -1
- package/docs/api/interfaces/UsePublicEventOptions.md +1 -1
- package/docs/api/interfaces/UsePublicEventReturn.md +1 -1
- package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
- package/docs/api/interfaces/UserEventAccess.md +1 -1
- package/docs/api/interfaces/UserMenuProps.md +1 -1
- package/docs/api/interfaces/UserProfile.md +1 -1
- package/docs/api/modules.md +3 -3
- package/docs/implementation-guides/data-tables.md +67 -0
- package/package.json +1 -1
- package/src/components/DataTable/DataTable.tsx +13 -0
- package/src/components/DataTable/__tests__/DataTable.default-state.test.tsx +414 -0
- package/src/components/DataTable/components/DataTableCore.tsx +19 -2
- package/src/components/DataTable/types.ts +9 -0
- package/src/components/Dialog/examples/__tests__/SmartDialogExample.unit.test.tsx +151 -0
- package/src/components/Dialog/utils/__tests__/safeHtml.unit.test.ts +611 -0
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.accessibility.test.tsx +287 -0
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.integration.test.tsx +861 -0
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.performance.test.tsx +628 -0
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.security.test.tsx +777 -0
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.unit.test.tsx +901 -0
- package/src/components/Toast/index.ts +2 -0
- package/src/components/index.ts +15 -0
- package/src/hooks/useFileReference.ts +37 -0
- package/src/styles/base.css +208 -0
- package/src/styles/semantic.css +24 -0
- package/dist/chunk-XDXG6QVH.js.map +0 -1
- /package/dist/{DataTable-5M6MV2VY.js.map → DataTable-7BER7PDS.js.map} +0 -0
- /package/dist/{chunk-44SAHU2N.js.map → chunk-2LPYEFXI.js.map} +0 -0
- /package/dist/{chunk-XMTHMOOM.js.map → chunk-BTCA3ENN.js.map} +0 -0
- /package/dist/{chunk-ESXTFEE6.js.map → chunk-C7GUF747.js.map} +0 -0
- /package/dist/{chunk-W7PPXKTZ.js.map → chunk-CKNY7HYS.js.map} +0 -0
- /package/dist/{chunk-5MLDIGHB.js.map → chunk-FVDOEGGG.js.map} +0 -0
- /package/dist/{chunk-HFDYTSAP.js.map → chunk-QVEOQVD4.js.map} +0 -0
- /package/dist/{chunk-E4FPK232.js.map → chunk-T2MQY57J.js.map} +0 -0
- /package/dist/{chunk-4ULBJNIT.js.map → chunk-T6HVDA24.js.map} +0 -0
- /package/dist/{chunk-STT7INZR.js.map → chunk-ULBI5JGB.js.map} +0 -0
- /package/dist/{chunk-CGSYCF2W.js.map → chunk-VTJ5HCZB.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AccessLevel,
|
|
3
3
|
init_unified
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ULBI5JGB.js";
|
|
5
5
|
import {
|
|
6
6
|
DebugLogger,
|
|
7
7
|
cn,
|
|
@@ -7891,4 +7891,4 @@ lodash/lodash.js:
|
|
|
7891
7891
|
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
7892
7892
|
*)
|
|
7893
7893
|
*/
|
|
7894
|
-
//# sourceMappingURL=chunk-
|
|
7894
|
+
//# sourceMappingURL=chunk-T2MQY57J.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
init_UnifiedAuthProvider,
|
|
3
3
|
useUnifiedAuth
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-T2MQY57J.js";
|
|
5
5
|
|
|
6
6
|
// src/hooks/useToast.ts
|
|
7
7
|
import * as React from "react";
|
|
@@ -503,4 +503,4 @@ export {
|
|
|
503
503
|
clearPublicLogoCache,
|
|
504
504
|
getPublicLogoCacheStats
|
|
505
505
|
};
|
|
506
|
-
//# sourceMappingURL=chunk-
|
|
506
|
+
//# sourceMappingURL=chunk-T6HVDA24.js.map
|
|
@@ -92,6 +92,7 @@ var init_unified = __esm({
|
|
|
92
92
|
|
|
93
93
|
export {
|
|
94
94
|
FileCategory,
|
|
95
|
+
init_file_reference,
|
|
95
96
|
AuthErrorCode,
|
|
96
97
|
PermissionErrorCode,
|
|
97
98
|
AccessLevel,
|
|
@@ -105,4 +106,4 @@ export {
|
|
|
105
106
|
isRequestId,
|
|
106
107
|
init_unified
|
|
107
108
|
};
|
|
108
|
-
//# sourceMappingURL=chunk-
|
|
109
|
+
//# sourceMappingURL=chunk-ULBI5JGB.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
init_UnifiedAuthProvider,
|
|
4
4
|
useOrganisations,
|
|
5
5
|
useUnifiedAuth
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-T2MQY57J.js";
|
|
7
7
|
import {
|
|
8
8
|
DebugLogger,
|
|
9
9
|
init_debugLogger,
|
|
@@ -312,4 +312,4 @@ export {
|
|
|
312
312
|
EventProvider_exports,
|
|
313
313
|
init_EventProvider
|
|
314
314
|
};
|
|
315
|
-
//# sourceMappingURL=chunk-
|
|
315
|
+
//# sourceMappingURL=chunk-VTJ5HCZB.js.map
|
package/dist/components.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export { b as UnifiedAuthContextType, U as UnifiedAuthProvider, a as UnifiedAuthProviderProps, u as useUnifiedAuth } from './UnifiedAuthProvider-CQNiemcB.js';
|
|
2
|
-
export { A as Alert,
|
|
3
|
-
export {
|
|
2
|
+
export { A as Alert, r as AlertDescription, q as AlertTitle, s as Avatar, u as AvatarFallback, t as AvatarImage, B as Button, g as ButtonProps, C as Card, m as CardActions, b3 as CardActionsProps, l as CardContent, k as CardDescription, i as CardFooter, h as CardHeader, n as CardProps, j as CardTitle, v as Checkbox, aU as DefaultPublicErrorFallback, D as Dialog, H as DialogBody, z as DialogClose, E as DialogContent, b6 as DialogContentProps, M as DialogDescription, bb as DialogDescriptionProps, J as DialogFooter, b9 as DialogFooterProps, G as DialogHeader, b8 as DialogHeaderProps, x as DialogOverlay, b7 as DialogOverlayProps, w as DialogPortal, b4 as DialogProps, bc as DialogSize, K as DialogTitle, ba as DialogTitleProps, y as DialogTrigger, b5 as DialogTriggerProps, ap as ErrorBoundary, bf as ErrorBoundaryProps, bg as ErrorBoundaryState, aP as EventLogo, aQ as EventLogoCompact, aR as EventLogoLarge, a$ as EventLogoProps, ar as EventSelector, ae as Footer, af as FooterProps, aa as Form, bd as FormProps, ad as Header, I as Input, o as InputProps, L as Label, p as LabelProps, aq as LoadingSpinner, ab as LoginForm, ac as LoginFormProps, ai as NavigationItem, ag as NavigationMenu, ah as NavigationMenuProps, as as OrganisationSelector, be as OrganisationSelectorProps, al as PaceAppLayout, am as PaceAppLayoutProps, an as PaceLoginPage, ao as PaceLoginPageProps, at as PasswordResetForm, P as Progress, aS as PublicErrorBoundary, b0 as PublicErrorBoundaryProps, b1 as PublicErrorBoundaryState, aX as PublicLoadingSkeleton, aV as PublicLoadingSpinner, aW as PublicLoadingSpinnerFullPage, b2 as PublicLoadingSpinnerProps, aO as PublicPageContextChecker, aM as PublicPageDebugger, aN as PublicPageDiagnostic, aL as PublicPageFooter, a_ as PublicPageFooterProps, aH as PublicPageHeader, aZ as PublicPageHeaderProps, aF as PublicPageLayout, aY as PublicPageLayoutProps, aI as PublicPageProvider, N as Select, T as SelectContent, O as SelectGroup, V as SelectItem, U as SelectLabel, W as SelectSeparator, R as SelectTrigger, Q as SelectValue, aw as Table, ay as TableBody, az as TableCaption, aA as TableCell, aB as TableFooter, aC as TableHead, ax as TableHeader, aD as TableRow, X as Toast, Z as ToastAction, a3 as ToastActionElement, a2 as ToastClose, a1 as ToastDescription, a4 as ToastProps, _ as ToastProvider, a0 as ToastTitle, $ as ToastViewport, Y as Toaster, a5 as Tooltip, a7 as TooltipContent, a8 as TooltipProvider, a9 as TooltipRoot, a6 as TooltipTrigger, bh as UseStorageOptions, bi as UseStorageReturn, aj as UserMenu, aT as useErrorBoundary, av as useFileUpload, aK as useIsPublicPage, aG as usePublicPageContext, aJ as usePublicPageProviderContext, au as useStorage } from './PublicLoadingSpinner-CXJ-W9wZ.js';
|
|
3
|
+
export { u as useToast } from './useToast-Bm6TnSK-.js';
|
|
4
|
+
export { D as DataTable, a as DataTableProps } from './DataTable-D15XipLZ.js';
|
|
4
5
|
export { A as AggregateConfig, D as DataRecord, f as DataTableAction, a as DataTableColumn, g as DataTableToolbarButton, E as EmptyStateConfig, G as GetRowId } from './types-E5WSpEtz.js';
|
|
5
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
7
|
import React__default from 'react';
|
|
7
8
|
import { FieldValues, FieldPath, UseFormReturn } from 'react-hook-form';
|
|
9
|
+
import { b as FileCategory, c as FileUploadOptions, e as FileUploadResult, F as FileReference } from './file-reference-9xUOnwyt.js';
|
|
10
|
+
export { a as FileMetadata } from './file-reference-9xUOnwyt.js';
|
|
8
11
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
9
|
-
import { b as FileCategory } from './file-reference-9xUOnwyt.js';
|
|
10
12
|
import './RBACProvider-BO4ilsQB.js';
|
|
11
13
|
import './unified-CMPjE_fv.js';
|
|
12
14
|
import '@radix-ui/react-label';
|
|
@@ -17,7 +19,7 @@ import '@radix-ui/react-dialog';
|
|
|
17
19
|
import '@radix-ui/react-toast';
|
|
18
20
|
import '@radix-ui/react-tooltip';
|
|
19
21
|
import 'zod';
|
|
20
|
-
import './organisation-
|
|
22
|
+
import './organisation-t-vvQC3g.js';
|
|
21
23
|
import '@tanstack/react-table';
|
|
22
24
|
|
|
23
25
|
interface FormFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> {
|
|
@@ -429,4 +431,79 @@ interface FileUploadProps {
|
|
|
429
431
|
declare function FileUpload({ supabase, table_name, record_id, organisation_id, app_id, category, accept, maxSize, // 10MB default
|
|
430
432
|
multiple, disabled, className, onUploadSuccess, onUploadError, children }: FileUploadProps): react_jsx_runtime.JSX.Element;
|
|
431
433
|
|
|
432
|
-
|
|
434
|
+
interface FileDisplayProps {
|
|
435
|
+
supabase: SupabaseClient;
|
|
436
|
+
table_name: string;
|
|
437
|
+
record_id: string;
|
|
438
|
+
organisation_id: string;
|
|
439
|
+
category?: FileCategory;
|
|
440
|
+
showUpload?: boolean;
|
|
441
|
+
showDelete?: boolean;
|
|
442
|
+
className?: string;
|
|
443
|
+
children?: React__default.ReactNode;
|
|
444
|
+
}
|
|
445
|
+
declare function FileDisplay({ supabase, table_name, record_id, organisation_id, category, showUpload, showDelete, className, children }: FileDisplayProps): react_jsx_runtime.JSX.Element;
|
|
446
|
+
|
|
447
|
+
declare function useFileReference(supabase: SupabaseClient): {
|
|
448
|
+
isLoading: boolean;
|
|
449
|
+
error: string | null;
|
|
450
|
+
uploadFile: (options: FileUploadOptions, file: File) => Promise<FileUploadResult | null>;
|
|
451
|
+
getFileReference: (table_name: string, record_id: string, organisation_id: string) => Promise<FileReference | null>;
|
|
452
|
+
getFileUrl: (table_name: string, record_id: string, organisation_id: string) => Promise<string | null>;
|
|
453
|
+
getSignedUrl: (table_name: string, record_id: string, organisation_id: string, expires_in?: number) => Promise<string | null>;
|
|
454
|
+
updateFileReference: (id: string, updates: Partial<FileReference>) => Promise<FileReference | null>;
|
|
455
|
+
deleteFileReference: (table_name: string, record_id: string, organisation_id: string, delete_file?: boolean) => Promise<boolean>;
|
|
456
|
+
listFileReferences: (table_name: string, record_id: string, organisation_id: string) => Promise<FileReference[]>;
|
|
457
|
+
getFileCount: (table_name: string, record_id: string, organisation_id: string) => Promise<number>;
|
|
458
|
+
clearError: () => void;
|
|
459
|
+
};
|
|
460
|
+
declare function useFileReferenceForRecord(supabase: SupabaseClient, table_name: string, record_id: string, organisation_id: string): {
|
|
461
|
+
isLoading: boolean;
|
|
462
|
+
error: string | null;
|
|
463
|
+
fileUrl: string | null;
|
|
464
|
+
fileReference: FileReference | null;
|
|
465
|
+
fileReferences: FileReference[];
|
|
466
|
+
fileCount: number;
|
|
467
|
+
loadFileReference: () => Promise<FileReference | null>;
|
|
468
|
+
loadFileUrl: () => Promise<string | null>;
|
|
469
|
+
loadFileReferences: () => Promise<FileReference[]>;
|
|
470
|
+
loadFileCount: () => Promise<number>;
|
|
471
|
+
deleteFile: (delete_file?: boolean) => Promise<boolean>;
|
|
472
|
+
updateFileReference: (id: string, updates: Partial<FileReference>) => Promise<FileReference | null>;
|
|
473
|
+
clearError: () => void;
|
|
474
|
+
};
|
|
475
|
+
type UseFileReferenceOptions = {
|
|
476
|
+
table_name: string;
|
|
477
|
+
record_id: string;
|
|
478
|
+
organisation_id: string;
|
|
479
|
+
};
|
|
480
|
+
type UseFileReferenceReturn = {
|
|
481
|
+
isLoading: boolean;
|
|
482
|
+
error: string | null;
|
|
483
|
+
uploadFile: (options: FileUploadOptions, file: File) => Promise<FileUploadResult | null>;
|
|
484
|
+
getFileReference: (table_name: string, record_id: string, organisation_id: string) => Promise<FileReference | null>;
|
|
485
|
+
getFileUrl: (table_name: string, record_id: string, organisation_id: string) => Promise<string | null>;
|
|
486
|
+
getSignedUrl: (table_name: string, record_id: string, organisation_id: string, expires_in?: number) => Promise<string | null>;
|
|
487
|
+
updateFileReference: (id: string, updates: Partial<FileReference>) => Promise<FileReference | null>;
|
|
488
|
+
deleteFileReference: (table_name: string, record_id: string, organisation_id: string, delete_file?: boolean) => Promise<boolean>;
|
|
489
|
+
listFileReferences: (table_name: string, record_id: string, organisation_id: string) => Promise<FileReference[]>;
|
|
490
|
+
getFileCount: (table_name: string, record_id: string, organisation_id: string) => Promise<number>;
|
|
491
|
+
clearError: () => void;
|
|
492
|
+
};
|
|
493
|
+
type UseFileReferenceForRecordReturn = {
|
|
494
|
+
isLoading: boolean;
|
|
495
|
+
error: string | null;
|
|
496
|
+
fileUrl: string | null;
|
|
497
|
+
fileReference: FileReference | null;
|
|
498
|
+
fileReferences: FileReference[];
|
|
499
|
+
fileCount: number;
|
|
500
|
+
loadFileReference: () => Promise<FileReference | null>;
|
|
501
|
+
loadFileUrl: () => Promise<string | null>;
|
|
502
|
+
loadFileReferences: () => Promise<FileReference[]>;
|
|
503
|
+
loadFileCount: () => Promise<number>;
|
|
504
|
+
deleteFile: (delete_file?: boolean) => Promise<boolean>;
|
|
505
|
+
updateFileReference: (id: string, updates: Partial<FileReference>) => Promise<FileReference | null>;
|
|
506
|
+
clearError: () => void;
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
export { FileCategory, FileDisplay, type FileDisplayProps, FileReference, FileUpload, FileUploadOptions, type FileUploadProps, FormErrorSummary, type FormErrorSummaryProps, FormField, type FormFieldProps, FormFieldset, type FormFieldsetProps, FormLiveRegion, type FormLiveRegionProps, SuperAdminBadge, SuperAdminDebugPanel, SuperAdminGuard, type SuperAdminGuardProps, type UseFileReferenceForRecordReturn, type UseFileReferenceOptions, type UseFileReferenceReturn, useFileReference, useFileReferenceForRecord };
|
package/dist/components.js
CHANGED
|
@@ -53,7 +53,7 @@ import {
|
|
|
53
53
|
useFileUpload,
|
|
54
54
|
usePublicPageContext as usePublicPageContext2,
|
|
55
55
|
useStorage
|
|
56
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-2LPYEFXI.js";
|
|
57
57
|
import {
|
|
58
58
|
Alert,
|
|
59
59
|
AlertDescription,
|
|
@@ -76,22 +76,23 @@ import {
|
|
|
76
76
|
SelectSeparator,
|
|
77
77
|
SelectTrigger,
|
|
78
78
|
SelectValue
|
|
79
|
-
} from "./chunk-
|
|
79
|
+
} from "./chunk-S66AJVI2.js";
|
|
80
80
|
import {
|
|
81
81
|
useRBAC
|
|
82
|
-
} from "./chunk-
|
|
82
|
+
} from "./chunk-C7GUF747.js";
|
|
83
83
|
import "./chunk-NHR52QAQ.js";
|
|
84
84
|
import "./chunk-B2WTCLCV.js";
|
|
85
|
-
import "./chunk-
|
|
86
|
-
import "./chunk-
|
|
85
|
+
import "./chunk-FVDOEGGG.js";
|
|
86
|
+
import "./chunk-VTJ5HCZB.js";
|
|
87
87
|
import {
|
|
88
88
|
DefaultPublicErrorFallback,
|
|
89
89
|
PublicErrorBoundary,
|
|
90
90
|
PublicPageProvider,
|
|
91
91
|
useErrorBoundary,
|
|
92
92
|
useIsPublicPage,
|
|
93
|
-
usePublicPageContext
|
|
94
|
-
|
|
93
|
+
usePublicPageContext,
|
|
94
|
+
useToast
|
|
95
|
+
} from "./chunk-T6HVDA24.js";
|
|
95
96
|
import "./chunk-YNUBMSMV.js";
|
|
96
97
|
import {
|
|
97
98
|
Button,
|
|
@@ -116,8 +117,11 @@ import {
|
|
|
116
117
|
init_Tooltip2 as init_Tooltip,
|
|
117
118
|
init_UnifiedAuthProvider,
|
|
118
119
|
useUnifiedAuth
|
|
119
|
-
} from "./chunk-
|
|
120
|
-
import
|
|
120
|
+
} from "./chunk-T2MQY57J.js";
|
|
121
|
+
import {
|
|
122
|
+
FileCategory,
|
|
123
|
+
init_file_reference
|
|
124
|
+
} from "./chunk-ULBI5JGB.js";
|
|
121
125
|
import {
|
|
122
126
|
LoadingSpinner
|
|
123
127
|
} from "./chunk-CDQ3PX7L.js";
|
|
@@ -698,6 +702,67 @@ function useFileReference(supabase) {
|
|
|
698
702
|
clearError
|
|
699
703
|
};
|
|
700
704
|
}
|
|
705
|
+
function useFileReferenceForRecord(supabase, table_name, record_id, organisation_id) {
|
|
706
|
+
const {
|
|
707
|
+
isLoading,
|
|
708
|
+
error,
|
|
709
|
+
getFileUrl,
|
|
710
|
+
getFileReference,
|
|
711
|
+
updateFileReference,
|
|
712
|
+
deleteFileReference,
|
|
713
|
+
listFileReferences,
|
|
714
|
+
getFileCount,
|
|
715
|
+
clearError
|
|
716
|
+
} = useFileReference(supabase);
|
|
717
|
+
const [fileUrl, setFileUrl] = useState2(null);
|
|
718
|
+
const [fileReference, setFileReference] = useState2(null);
|
|
719
|
+
const [fileReferences, setFileReferences] = useState2([]);
|
|
720
|
+
const [fileCount, setFileCount] = useState2(0);
|
|
721
|
+
const loadFileReference = useCallback(async () => {
|
|
722
|
+
const reference = await getFileReference(table_name, record_id, organisation_id);
|
|
723
|
+
setFileReference(reference);
|
|
724
|
+
return reference;
|
|
725
|
+
}, [getFileReference, table_name, record_id, organisation_id]);
|
|
726
|
+
const loadFileUrl = useCallback(async () => {
|
|
727
|
+
const url = await getFileUrl(table_name, record_id, organisation_id);
|
|
728
|
+
setFileUrl(url);
|
|
729
|
+
return url;
|
|
730
|
+
}, [getFileUrl, table_name, record_id, organisation_id]);
|
|
731
|
+
const loadFileReferences = useCallback(async () => {
|
|
732
|
+
const references = await listFileReferences(table_name, record_id, organisation_id);
|
|
733
|
+
setFileReferences(references);
|
|
734
|
+
return references;
|
|
735
|
+
}, [listFileReferences, table_name, record_id, organisation_id]);
|
|
736
|
+
const loadFileCount = useCallback(async () => {
|
|
737
|
+
const count = await getFileCount(table_name, record_id, organisation_id);
|
|
738
|
+
setFileCount(count);
|
|
739
|
+
return count;
|
|
740
|
+
}, [getFileCount, table_name, record_id, organisation_id]);
|
|
741
|
+
const deleteFile2 = useCallback(async (delete_file) => {
|
|
742
|
+
const success = await deleteFileReference(table_name, record_id, organisation_id, delete_file);
|
|
743
|
+
if (success) {
|
|
744
|
+
setFileReference(null);
|
|
745
|
+
setFileUrl(null);
|
|
746
|
+
await loadFileCount();
|
|
747
|
+
}
|
|
748
|
+
return success;
|
|
749
|
+
}, [deleteFileReference, table_name, record_id, organisation_id, loadFileCount]);
|
|
750
|
+
return {
|
|
751
|
+
isLoading,
|
|
752
|
+
error,
|
|
753
|
+
fileUrl,
|
|
754
|
+
fileReference,
|
|
755
|
+
fileReferences,
|
|
756
|
+
fileCount,
|
|
757
|
+
loadFileReference,
|
|
758
|
+
loadFileUrl,
|
|
759
|
+
loadFileReferences,
|
|
760
|
+
loadFileCount,
|
|
761
|
+
deleteFile: deleteFile2,
|
|
762
|
+
updateFileReference,
|
|
763
|
+
clearError
|
|
764
|
+
};
|
|
765
|
+
}
|
|
701
766
|
|
|
702
767
|
// src/components/FileUpload.tsx
|
|
703
768
|
import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
@@ -823,6 +888,185 @@ function FileUpload({
|
|
|
823
888
|
}
|
|
824
889
|
);
|
|
825
890
|
}
|
|
891
|
+
|
|
892
|
+
// src/components/FileDisplay.tsx
|
|
893
|
+
import { useState as useState4, useEffect as useEffect2 } from "react";
|
|
894
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
895
|
+
function FileDisplay({
|
|
896
|
+
supabase,
|
|
897
|
+
table_name,
|
|
898
|
+
record_id,
|
|
899
|
+
organisation_id,
|
|
900
|
+
category,
|
|
901
|
+
showUpload = false,
|
|
902
|
+
showDelete = false,
|
|
903
|
+
className = "",
|
|
904
|
+
children
|
|
905
|
+
}) {
|
|
906
|
+
const {
|
|
907
|
+
isLoading,
|
|
908
|
+
error,
|
|
909
|
+
fileUrl,
|
|
910
|
+
fileReference,
|
|
911
|
+
fileReferences,
|
|
912
|
+
fileCount,
|
|
913
|
+
loadFileReference,
|
|
914
|
+
loadFileUrl,
|
|
915
|
+
loadFileReferences,
|
|
916
|
+
loadFileCount,
|
|
917
|
+
deleteFile: deleteFile2,
|
|
918
|
+
clearError
|
|
919
|
+
} = useFileReferenceForRecord(supabase, table_name, record_id, organisation_id);
|
|
920
|
+
const [imageError, setImageError] = useState4(false);
|
|
921
|
+
useEffect2(() => {
|
|
922
|
+
loadFileCount();
|
|
923
|
+
if (category) {
|
|
924
|
+
loadFileReference();
|
|
925
|
+
} else {
|
|
926
|
+
loadFileReferences();
|
|
927
|
+
}
|
|
928
|
+
}, [loadFileCount, loadFileReference, loadFileReferences, category]);
|
|
929
|
+
useEffect2(() => {
|
|
930
|
+
if (fileReference) {
|
|
931
|
+
loadFileUrl();
|
|
932
|
+
}
|
|
933
|
+
}, [fileReference, loadFileUrl]);
|
|
934
|
+
const handleDelete = async () => {
|
|
935
|
+
if (window.confirm("Are you sure you want to delete this file?")) {
|
|
936
|
+
const success = await deleteFile2(true);
|
|
937
|
+
if (success) {
|
|
938
|
+
setImageError(false);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
};
|
|
942
|
+
const handleImageError = () => {
|
|
943
|
+
setImageError(true);
|
|
944
|
+
};
|
|
945
|
+
const getFileIcon = (fileType) => {
|
|
946
|
+
if (fileType.startsWith("image/")) return "\u{1F5BC}\uFE0F";
|
|
947
|
+
if (fileType.startsWith("video/")) return "\u{1F3A5}";
|
|
948
|
+
if (fileType.startsWith("audio/")) return "\u{1F3B5}";
|
|
949
|
+
if (fileType.includes("pdf")) return "\u{1F4C4}";
|
|
950
|
+
if (fileType.includes("word")) return "\u{1F4DD}";
|
|
951
|
+
if (fileType.includes("excel") || fileType.includes("spreadsheet")) return "\u{1F4CA}";
|
|
952
|
+
if (fileType.includes("powerpoint") || fileType.includes("presentation")) return "\u{1F4CA}";
|
|
953
|
+
return "\u{1F4C1}";
|
|
954
|
+
};
|
|
955
|
+
const formatFileSize = (bytes) => {
|
|
956
|
+
if (bytes === 0) return "0 Bytes";
|
|
957
|
+
const k = 1024;
|
|
958
|
+
const sizes = ["Bytes", "KB", "MB", "GB"];
|
|
959
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
960
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
|
|
961
|
+
};
|
|
962
|
+
if (isLoading) {
|
|
963
|
+
return /* @__PURE__ */ jsx7("div", { className: `flex items-center justify-center p-4 ${className}`, children: /* @__PURE__ */ jsx7("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-main-500" }) });
|
|
964
|
+
}
|
|
965
|
+
if (error) {
|
|
966
|
+
return /* @__PURE__ */ jsxs6("div", { className: `p-4 bg-acc-50 border border-acc-200 rounded-lg ${className}`, children: [
|
|
967
|
+
/* @__PURE__ */ jsxs6("div", { className: "text-acc-600", children: [
|
|
968
|
+
"Error loading file: ",
|
|
969
|
+
error
|
|
970
|
+
] }),
|
|
971
|
+
/* @__PURE__ */ jsx7(
|
|
972
|
+
"button",
|
|
973
|
+
{
|
|
974
|
+
onClick: clearError,
|
|
975
|
+
className: "mt-2 text-sm text-acc-700 hover:text-acc-800 underline",
|
|
976
|
+
children: "Try again"
|
|
977
|
+
}
|
|
978
|
+
)
|
|
979
|
+
] });
|
|
980
|
+
}
|
|
981
|
+
if (fileCount === 0) {
|
|
982
|
+
return /* @__PURE__ */ jsxs6("div", { className: `text-sec-500 text-center p-4 ${className}`, children: [
|
|
983
|
+
"No files found",
|
|
984
|
+
children
|
|
985
|
+
] });
|
|
986
|
+
}
|
|
987
|
+
if (category && fileReference) {
|
|
988
|
+
const isImage = fileReference.file_metadata.fileType?.startsWith("image/");
|
|
989
|
+
return /* @__PURE__ */ jsxs6("div", { className: `space-y-2 ${className}`, children: [
|
|
990
|
+
isImage && fileUrl && !imageError ? /* @__PURE__ */ jsxs6("div", { className: "relative", children: [
|
|
991
|
+
/* @__PURE__ */ jsx7(
|
|
992
|
+
"img",
|
|
993
|
+
{
|
|
994
|
+
src: fileUrl,
|
|
995
|
+
alt: fileReference.file_metadata.fileName || "File",
|
|
996
|
+
className: "max-w-full h-auto rounded-lg border border-sec-200",
|
|
997
|
+
onError: handleImageError
|
|
998
|
+
}
|
|
999
|
+
),
|
|
1000
|
+
showDelete && /* @__PURE__ */ jsx7(
|
|
1001
|
+
"button",
|
|
1002
|
+
{
|
|
1003
|
+
onClick: handleDelete,
|
|
1004
|
+
className: "absolute top-2 right-2 bg-acc-500 text-white rounded-full w-6 h-6 flex items-center justify-center text-sm hover:bg-acc-600",
|
|
1005
|
+
title: "Delete file",
|
|
1006
|
+
children: "\xD7"
|
|
1007
|
+
}
|
|
1008
|
+
)
|
|
1009
|
+
] }) : /* @__PURE__ */ jsxs6("div", { className: "flex items-center space-x-3 p-3 bg-sec-50 rounded-lg border border-sec-200", children: [
|
|
1010
|
+
/* @__PURE__ */ jsx7("span", { className: "text-2xl", children: getFileIcon(fileReference.file_metadata.fileType || "") }),
|
|
1011
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex-1 min-w-0", children: [
|
|
1012
|
+
/* @__PURE__ */ jsx7("div", { className: "font-medium text-sec-900 truncate", children: fileReference.file_metadata.fileName || "Unknown file" }),
|
|
1013
|
+
/* @__PURE__ */ jsxs6("div", { className: "text-sm text-sec-500", children: [
|
|
1014
|
+
fileReference.file_metadata.fileSize && formatFileSize(fileReference.file_metadata.fileSize),
|
|
1015
|
+
fileReference.file_metadata.fileType && ` \u2022 ${fileReference.file_metadata.fileType}`
|
|
1016
|
+
] })
|
|
1017
|
+
] }),
|
|
1018
|
+
showDelete && /* @__PURE__ */ jsx7(
|
|
1019
|
+
"button",
|
|
1020
|
+
{
|
|
1021
|
+
onClick: handleDelete,
|
|
1022
|
+
className: "text-acc-500 hover:text-acc-700 p-1",
|
|
1023
|
+
title: "Delete file",
|
|
1024
|
+
children: "\xD7"
|
|
1025
|
+
}
|
|
1026
|
+
)
|
|
1027
|
+
] }),
|
|
1028
|
+
children
|
|
1029
|
+
] });
|
|
1030
|
+
}
|
|
1031
|
+
return /* @__PURE__ */ jsxs6("div", { className: `space-y-2 ${className}`, children: [
|
|
1032
|
+
fileReferences.map((fileRef) => {
|
|
1033
|
+
const isImage = fileRef.file_metadata.fileType?.startsWith("image/");
|
|
1034
|
+
const fileUrl2 = fileRef.is_public ? `https://your-supabase-url.supabase.co/storage/v1/object/public/files/${fileRef.file_path}` : null;
|
|
1035
|
+
return /* @__PURE__ */ jsxs6("div", { className: "flex items-center space-x-3 p-3 bg-sec-50 rounded-lg border border-sec-200", children: [
|
|
1036
|
+
isImage && fileUrl2 ? /* @__PURE__ */ jsx7(
|
|
1037
|
+
"img",
|
|
1038
|
+
{
|
|
1039
|
+
src: fileUrl2,
|
|
1040
|
+
alt: fileRef.file_metadata.fileName || "File",
|
|
1041
|
+
className: "w-12 h-12 object-cover rounded",
|
|
1042
|
+
onError: handleImageError
|
|
1043
|
+
}
|
|
1044
|
+
) : /* @__PURE__ */ jsx7("span", { className: "text-2xl", children: getFileIcon(fileRef.file_metadata.fileType || "") }),
|
|
1045
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex-1 min-w-0", children: [
|
|
1046
|
+
/* @__PURE__ */ jsx7("div", { className: "font-medium text-sec-900 truncate", children: fileRef.file_metadata.fileName || "Unknown file" }),
|
|
1047
|
+
/* @__PURE__ */ jsxs6("div", { className: "text-sm text-sec-500", children: [
|
|
1048
|
+
fileRef.file_metadata.fileSize && formatFileSize(fileRef.file_metadata.fileSize),
|
|
1049
|
+
fileRef.file_metadata.fileType && ` \u2022 ${fileRef.file_metadata.fileType}`,
|
|
1050
|
+
fileRef.file_metadata.category && ` \u2022 ${fileRef.file_metadata.category}`
|
|
1051
|
+
] })
|
|
1052
|
+
] }),
|
|
1053
|
+
showDelete && /* @__PURE__ */ jsx7(
|
|
1054
|
+
"button",
|
|
1055
|
+
{
|
|
1056
|
+
onClick: () => deleteFile2(true),
|
|
1057
|
+
className: "text-acc-500 hover:text-acc-700 p-1",
|
|
1058
|
+
title: "Delete file",
|
|
1059
|
+
children: "\xD7"
|
|
1060
|
+
}
|
|
1061
|
+
)
|
|
1062
|
+
] }, fileRef.id);
|
|
1063
|
+
}),
|
|
1064
|
+
children
|
|
1065
|
+
] });
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
// src/components/index.ts
|
|
1069
|
+
init_file_reference();
|
|
826
1070
|
export {
|
|
827
1071
|
Alert,
|
|
828
1072
|
AlertDescription,
|
|
@@ -857,6 +1101,8 @@ export {
|
|
|
857
1101
|
EventLogoCompact,
|
|
858
1102
|
EventLogoLarge,
|
|
859
1103
|
EventSelector,
|
|
1104
|
+
FileCategory,
|
|
1105
|
+
FileDisplay,
|
|
860
1106
|
FileUpload,
|
|
861
1107
|
Footer,
|
|
862
1108
|
Form,
|
|
@@ -921,11 +1167,14 @@ export {
|
|
|
921
1167
|
UnifiedAuthProvider,
|
|
922
1168
|
UserMenu,
|
|
923
1169
|
useErrorBoundary,
|
|
1170
|
+
useFileReference,
|
|
1171
|
+
useFileReferenceForRecord,
|
|
924
1172
|
useFileUpload,
|
|
925
1173
|
useIsPublicPage,
|
|
926
1174
|
usePublicPageContext2 as usePublicPageContext,
|
|
927
1175
|
usePublicPageContext as usePublicPageProviderContext,
|
|
928
1176
|
useStorage,
|
|
1177
|
+
useToast,
|
|
929
1178
|
useUnifiedAuth
|
|
930
1179
|
};
|
|
931
1180
|
//# sourceMappingURL=components.js.map
|