@nocios/crudify-components 2.0.32 → 2.0.36

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 (61) hide show
  1. package/coverage/base.css +224 -0
  2. package/coverage/block-navigation.js +87 -0
  3. package/coverage/coverage-final.json +120 -0
  4. package/coverage/favicon.png +0 -0
  5. package/coverage/index.html +686 -0
  6. package/coverage/prettify.css +1 -0
  7. package/coverage/prettify.js +2 -0
  8. package/coverage/sort-arrow-sprite.png +0 -0
  9. package/coverage/sorter.js +210 -0
  10. package/dist/{CrudiaMarkdownField-C54-A_J3.d.mts → CrudiaMarkdownField-Bxl08sRG.d.mts} +12 -7
  11. package/dist/{CrudiaMarkdownField-C8HQh7s5.d.ts → CrudiaMarkdownField-DUJNOOzP.d.ts} +12 -7
  12. package/dist/chunk-44VU4TSP.mjs +1 -0
  13. package/dist/chunk-4LMFQECS.js +1 -0
  14. package/dist/chunk-77UKXG5L.mjs +1 -0
  15. package/dist/{chunk-4VN5YRYZ.js → chunk-BXFEQ6KP.js} +1 -1
  16. package/dist/{chunk-6ONAT4QU.js → chunk-H6XXWDUT.js} +1 -1
  17. package/dist/chunk-NIRLP2TC.js +1 -0
  18. package/dist/chunk-O4FUHIQG.mjs +1 -0
  19. package/dist/chunk-QFACMV2I.mjs +1 -0
  20. package/dist/chunk-QZH3KSJZ.js +1 -0
  21. package/dist/{chunk-RJBX4MWF.mjs → chunk-WMLIOPUC.mjs} +1 -1
  22. package/dist/components.d.mts +1 -1
  23. package/dist/components.d.ts +1 -1
  24. package/dist/components.js +1 -1
  25. package/dist/components.mjs +1 -1
  26. package/dist/errorTranslation-D-Y7uNN_.d.mts +141 -0
  27. package/dist/errorTranslation-DDlAXpMl.d.ts +141 -0
  28. package/dist/hooks.d.mts +2 -2
  29. package/dist/hooks.d.ts +2 -2
  30. package/dist/hooks.js +1 -1
  31. package/dist/hooks.mjs +1 -1
  32. package/dist/{index-DY90WVQQ.d.mts → index-U--xRr8A.d.mts} +225 -191
  33. package/dist/{index-d1vE803G.d.ts → index-dXVRVcEB.d.ts} +225 -191
  34. package/dist/index.d.mts +175 -6
  35. package/dist/index.d.ts +175 -6
  36. package/dist/index.js +2 -2
  37. package/dist/index.mjs +1 -1
  38. package/dist/{errorTranslation-By5Av0tL.d.ts → tenantConfig-DqJqQkoR.d.mts} +116 -139
  39. package/dist/{errorTranslation-DeeDj7Vt.d.mts → tenantConfig-DqJqQkoR.d.ts} +116 -139
  40. package/dist/utils.d.mts +2 -2
  41. package/dist/utils.d.ts +2 -2
  42. package/dist/utils.js +1 -1
  43. package/dist/utils.mjs +1 -1
  44. package/package.json +1 -1
  45. package/coverage/.tmp/coverage-102.json +0 -1
  46. package/coverage/.tmp/coverage-103.json +0 -1
  47. package/coverage/.tmp/coverage-104.json +0 -1
  48. package/coverage/.tmp/coverage-105.json +0 -1
  49. package/coverage/.tmp/coverage-106.json +0 -1
  50. package/coverage/.tmp/coverage-107.json +0 -1
  51. package/dist/api-B4uXiHF0.d.mts +0 -118
  52. package/dist/api-B4uXiHF0.d.ts +0 -118
  53. package/dist/chunk-4ILUXVPW.mjs +0 -1
  54. package/dist/chunk-5XBTRBE5.js +0 -1
  55. package/dist/chunk-CR5KJUST.js +0 -1
  56. package/dist/chunk-H5M2Q6PB.mjs +0 -1
  57. package/dist/chunk-JAPL7EZJ.mjs +0 -1
  58. package/dist/chunk-L7GKP6XY.mjs +0 -1
  59. package/dist/chunk-NSV6ECYO.js +0 -1
  60. package/dist/chunk-PTUSZGL4.mjs +0 -1
  61. package/dist/chunk-T6R65ROU.js +0 -1
@@ -1,8 +1,8 @@
1
- import { U as UserProfile, e as CrudifyRequestOptions, C as CrudifyApiResponse, g as TransactionInput, d as CrudifyOperationOptions } from './api-B4uXiHF0.mjs';
1
+ import { U as UserProfile, m as CrudifyRequestOptions, f as CrudifyApiResponse, o as TransactionInput, l as CrudifyOperationOptions } from './tenantConfig-DqJqQkoR.mjs';
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
  import { ReactNode } from 'react';
4
- import { b as NotificationSeverity } from './GlobalNotificationProvider-Zq18OkpI.mjs';
5
4
  import { CrudifyResponse } from '@nocios/crudify-sdk';
5
+ import { b as NotificationSeverity } from './GlobalNotificationProvider-Zq18OkpI.mjs';
6
6
 
7
7
  type TokenData = {
8
8
  accessToken: string;
@@ -462,6 +462,199 @@ declare function useSessionContext(): SessionContextType;
462
462
  */
463
463
  declare function SessionDebugInfo(): react_jsx_runtime.JSX.Element;
464
464
 
465
+ /**
466
+ * Individual file status
467
+ */
468
+ type FileStatus = "pending" | "uploading" | "completed" | "error" | "removing" | "pendingDeletion";
469
+ /**
470
+ * Represents a file in the system
471
+ */
472
+ interface FileItem {
473
+ /** Unique file ID (generated or from server) */
474
+ id: string;
475
+ /** Original file name */
476
+ name: string;
477
+ /** Size in bytes */
478
+ size: number;
479
+ /** MIME content type */
480
+ contentType: string;
481
+ /** Current file status */
482
+ status: FileStatus;
483
+ /** Upload progress (0-100) */
484
+ progress: number;
485
+ /**
486
+ * Relative file path (includes visibility)
487
+ * Format: "public/path/file.ext" or "private/path/file.ext"
488
+ */
489
+ filePath?: string;
490
+ /**
491
+ * File visibility
492
+ * Extracted from filePath for convenience
493
+ */
494
+ visibility?: "public" | "private";
495
+ /** Public URL for public files */
496
+ publicUrl?: string;
497
+ /** Preview URL (for images) */
498
+ previewUrl?: string;
499
+ /** Error message if failed */
500
+ errorMessage?: string;
501
+ /** Creation timestamp */
502
+ createdAt: number;
503
+ /** Original file (only during upload) */
504
+ file?: File;
505
+ /** Whether this file existed before (was loaded from server) */
506
+ isExisting?: boolean;
507
+ }
508
+ /**
509
+ * Hook configuration
510
+ */
511
+ interface UseFileUploadOptions {
512
+ /** Allowed MIME types (e.g., ["image/png", "image/jpeg", "application/pdf"]) */
513
+ acceptedTypes?: string[];
514
+ /** Maximum file size in bytes (default: 10MB) */
515
+ maxFileSize?: number;
516
+ /** Maximum number of files (undefined = no limit) */
517
+ maxFiles?: number;
518
+ /** Minimum number of required files (default: 0) */
519
+ minFiles?: number;
520
+ /**
521
+ * Visibility of uploaded files
522
+ * @default "private"
523
+ */
524
+ visibility?: "public" | "private";
525
+ /** Callback when an upload completes successfully */
526
+ onUploadComplete?: (file: FileItem) => void;
527
+ /** Callback when an upload fails */
528
+ onUploadError?: (file: FileItem, error: string) => void;
529
+ /** Callback when a file is removed */
530
+ onFileRemoved?: (file: FileItem) => void;
531
+ /** Callback when the file list changes */
532
+ onFilesChange?: (files: FileItem[]) => void;
533
+ /** Form mode: 'create' or 'edit' - affects delete behavior */
534
+ mode?: "create" | "edit";
535
+ }
536
+ /**
537
+ * Hook return type
538
+ */
539
+ interface UseFileUploadReturn {
540
+ /** Current file list */
541
+ files: FileItem[];
542
+ /** Active files (excluding pendingDeletion) */
543
+ activeFiles: FileItem[];
544
+ /** Count of active files */
545
+ activeFileCount: number;
546
+ /** Whether uploads are in progress */
547
+ isUploading: boolean;
548
+ /** Number of pending uploads */
549
+ pendingCount: number;
550
+ /** Add files (triggers automatic upload) */
551
+ addFiles: (files: FileList | File[]) => Promise<void>;
552
+ /** Remove a file - returns whether confirmation is needed */
553
+ removeFile: (fileId: string) => Promise<{
554
+ needsConfirmation: boolean;
555
+ isExisting: boolean;
556
+ }>;
557
+ /** Delete a file immediately from server (for new files or create mode) */
558
+ deleteFileImmediately: (fileId: string) => Promise<{
559
+ success: boolean;
560
+ error?: string;
561
+ }>;
562
+ /** Restore a file that was marked for deletion */
563
+ restoreFile: (fileId: string) => boolean;
564
+ /** Clear all files */
565
+ clearFiles: () => void;
566
+ /** Retry upload for a failed file */
567
+ retryUpload: (fileId: string) => Promise<void>;
568
+ /** Validate if minimum requirements are met */
569
+ isValid: boolean;
570
+ /** Validation error message (i18n key) */
571
+ validationError: string | null;
572
+ /** Validation error i18n key */
573
+ validationErrorKey: string | null;
574
+ /** Validation error params for i18n interpolation */
575
+ validationErrorParams: Record<string, string | number>;
576
+ /** Wait for all uploads to complete and return completed file paths */
577
+ waitForUploads: () => Promise<string[]>;
578
+ /**
579
+ * Completed file paths (for saving in form)
580
+ * Relative paths with visibility - subscriberKey is added in backend
581
+ */
582
+ completedFilePaths: string[];
583
+ /** Initialize with existing files (for editing) */
584
+ initializeFiles: (existingFiles: Array<{
585
+ filePath: string;
586
+ name: string;
587
+ size?: number;
588
+ contentType?: string;
589
+ }>, baseUrl?: string) => void;
590
+ /** Whether the user has interacted with the field */
591
+ isTouched: boolean;
592
+ /** Mark the field as touched (to show validation errors) */
593
+ markAsTouched: () => void;
594
+ /** Whether the form has been submitted */
595
+ isSubmitted: boolean;
596
+ /** Mark the form as submitted (to show all validation errors) */
597
+ markAsSubmitted: () => void;
598
+ /**
599
+ * Get URL for file preview
600
+ * - Public: returns publicUrl directly
601
+ * - Private: requests signed URL from backend
602
+ */
603
+ getPreviewUrl: (fileId: string) => Promise<string | null>;
604
+ /** List of file IDs pending deletion */
605
+ pendingDeletions: string[];
606
+ /** Whether there are files pending deletion */
607
+ hasPendingDeletions: boolean;
608
+ /** Execute all pending deletions (call this on form submit) */
609
+ commitDeletions: () => Promise<{
610
+ success: boolean;
611
+ errors: string[];
612
+ }>;
613
+ /** Cancel all pending deletions and restore files */
614
+ restorePendingDeletions: () => void;
615
+ }
616
+
617
+ /**
618
+ * Complete hook for file handling with:
619
+ * - Progressive upload to S3 with pre-signed URLs
620
+ * - Per-file progress tracking
621
+ * - Type and size validation
622
+ * - Soft delete (disableFile)
623
+ * - Multiple file support
624
+ */
625
+
626
+ /**
627
+ * Hook for complete file handling with S3 upload
628
+ *
629
+ * @example
630
+ * ```tsx
631
+ * const {
632
+ * files,
633
+ * addFiles,
634
+ * removeFile,
635
+ * isUploading,
636
+ * isValid,
637
+ * completedS3Keys
638
+ * } = useFileUpload({
639
+ * acceptedTypes: ["image/png", "image/jpeg", "application/pdf"],
640
+ * maxFileSize: 5 * 1024 * 1024, // 5MB
641
+ * maxFiles: 3,
642
+ * minFiles: 1
643
+ * });
644
+ *
645
+ * // In form submit
646
+ * const handleSubmit = async () => {
647
+ * await waitForUploads(); // Wait for pending uploads
648
+ * if (!isValid) return;
649
+ *
650
+ * await crudify.createItem("documents", {
651
+ * files: completedS3Keys
652
+ * });
653
+ * };
654
+ * ```
655
+ */
656
+ declare const useFileUpload: (options?: UseFileUploadOptions) => UseFileUploadReturn;
657
+
465
658
  /**
466
659
  * Complete user data structure (compatible con legacy)
467
660
  */
@@ -651,202 +844,20 @@ interface UseUserProfileReturn {
651
844
  declare const useUserProfile: (options?: UseUserProfileOptions) => UseUserProfileReturn;
652
845
 
653
846
  /**
654
- * Complete hook for file handling with:
655
- * - Progressive upload to S3 with pre-signed URLs
656
- * - Per-file progress tracking
657
- * - Type and size validation
658
- * - Soft delete (disableFile)
659
- * - Multiple file support
660
- */
661
- /**
662
- * Individual file status
663
- */
664
- type FileStatus = "pending" | "uploading" | "completed" | "error" | "removing" | "pendingDeletion";
665
- /**
666
- * Represents a file in the system
667
- */
668
- interface FileItem {
669
- /** Unique file ID (generated or from server) */
670
- id: string;
671
- /** Original file name */
672
- name: string;
673
- /** Size in bytes */
674
- size: number;
675
- /** MIME content type */
676
- contentType: string;
677
- /** Current file status */
678
- status: FileStatus;
679
- /** Upload progress (0-100) */
680
- progress: number;
681
- /**
682
- * Relative file path (includes visibility)
683
- * Format: "public/path/file.ext" or "private/path/file.ext"
684
- */
685
- filePath?: string;
686
- /**
687
- * File visibility
688
- * Extracted from filePath for convenience
689
- */
690
- visibility?: "public" | "private";
691
- /** Public URL for public files */
692
- publicUrl?: string;
693
- /** Preview URL (for images) */
694
- previewUrl?: string;
695
- /** Error message if failed */
696
- errorMessage?: string;
697
- /** Creation timestamp */
698
- createdAt: number;
699
- /** Original file (only during upload) */
700
- file?: File;
701
- /** Whether this file existed before (was loaded from server) */
702
- isExisting?: boolean;
703
- }
704
- /**
705
- * Hook configuration
847
+ * Types and interfaces for useCrudifyWithNotifications
706
848
  */
707
- interface UseFileUploadOptions {
708
- /** Allowed MIME types (e.g., ["image/png", "image/jpeg", "application/pdf"]) */
709
- acceptedTypes?: string[];
710
- /** Maximum file size in bytes (default: 10MB) */
711
- maxFileSize?: number;
712
- /** Maximum number of files (undefined = no limit) */
713
- maxFiles?: number;
714
- /** Minimum number of required files (default: 0) */
715
- minFiles?: number;
716
- /**
717
- * Visibility of uploaded files
718
- * @default "private"
719
- */
720
- visibility?: "public" | "private";
721
- /** Callback when an upload completes successfully */
722
- onUploadComplete?: (file: FileItem) => void;
723
- /** Callback when an upload fails */
724
- onUploadError?: (file: FileItem, error: string) => void;
725
- /** Callback when a file is removed */
726
- onFileRemoved?: (file: FileItem) => void;
727
- /** Callback when the file list changes */
728
- onFilesChange?: (files: FileItem[]) => void;
729
- /** Form mode: 'create' or 'edit' - affects delete behavior */
730
- mode?: "create" | "edit";
731
- }
732
- /**
733
- * Hook return type
734
- */
735
- interface UseFileUploadReturn {
736
- /** Current file list */
737
- files: FileItem[];
738
- /** Active files (excluding pendingDeletion) */
739
- activeFiles: FileItem[];
740
- /** Count of active files */
741
- activeFileCount: number;
742
- /** Whether uploads are in progress */
743
- isUploading: boolean;
744
- /** Number of pending uploads */
745
- pendingCount: number;
746
- /** Add files (triggers automatic upload) */
747
- addFiles: (files: FileList | File[]) => Promise<void>;
748
- /** Remove a file - returns whether confirmation is needed */
749
- removeFile: (fileId: string) => Promise<{
750
- needsConfirmation: boolean;
751
- isExisting: boolean;
752
- }>;
753
- /** Delete a file immediately from server (for new files or create mode) */
754
- deleteFileImmediately: (fileId: string) => Promise<{
755
- success: boolean;
756
- error?: string;
757
- }>;
758
- /** Restore a file that was marked for deletion */
759
- restoreFile: (fileId: string) => boolean;
760
- /** Clear all files */
761
- clearFiles: () => void;
762
- /** Retry upload for a failed file */
763
- retryUpload: (fileId: string) => Promise<void>;
764
- /** Validate if minimum requirements are met */
765
- isValid: boolean;
766
- /** Validation error message (i18n key) */
767
- validationError: string | null;
768
- /** Validation error i18n key */
769
- validationErrorKey: string | null;
770
- /** Validation error params for i18n interpolation */
771
- validationErrorParams: Record<string, string | number>;
772
- /** Wait for all uploads to complete and return completed file paths */
773
- waitForUploads: () => Promise<string[]>;
774
- /**
775
- * Completed file paths (for saving in form)
776
- * Relative paths with visibility - subscriberKey is added in backend
777
- */
778
- completedFilePaths: string[];
779
- /** Initialize with existing files (for editing) */
780
- initializeFiles: (existingFiles: Array<{
781
- filePath: string;
782
- name: string;
783
- size?: number;
784
- contentType?: string;
785
- }>, baseUrl?: string) => void;
786
- /** Whether the user has interacted with the field */
787
- isTouched: boolean;
788
- /** Mark the field as touched (to show validation errors) */
789
- markAsTouched: () => void;
790
- /** Whether the form has been submitted */
791
- isSubmitted: boolean;
792
- /** Mark the form as submitted (to show all validation errors) */
793
- markAsSubmitted: () => void;
794
- /**
795
- * Get URL for file preview
796
- * - Public: returns publicUrl directly
797
- * - Private: requests signed URL from backend
798
- */
799
- getPreviewUrl: (fileId: string) => Promise<string | null>;
800
- /** List of file IDs pending deletion */
801
- pendingDeletions: string[];
802
- /** Whether there are files pending deletion */
803
- hasPendingDeletions: boolean;
804
- /** Execute all pending deletions (call this on form submit) */
805
- commitDeletions: () => Promise<{
806
- success: boolean;
807
- errors: string[];
808
- }>;
809
- /** Cancel all pending deletions and restore files */
810
- restorePendingDeletions: () => void;
811
- }
849
+
812
850
  /**
813
- * Hook for complete file handling with S3 upload
814
- *
815
- * @example
816
- * ```tsx
817
- * const {
818
- * files,
819
- * addFiles,
820
- * removeFile,
821
- * isUploading,
822
- * isValid,
823
- * completedS3Keys
824
- * } = useFileUpload({
825
- * acceptedTypes: ["image/png", "image/jpeg", "application/pdf"],
826
- * maxFileSize: 5 * 1024 * 1024, // 5MB
827
- * maxFiles: 3,
828
- * minFiles: 1
829
- * });
830
- *
831
- * // In form submit
832
- * const handleSubmit = async () => {
833
- * await waitForUploads(); // Wait for pending uploads
834
- * if (!isValid) return;
835
- *
836
- * await crudify.createItem("documents", {
837
- * files: completedS3Keys
838
- * });
839
- * };
840
- * ```
851
+ * App structure action configuration
841
852
  */
842
- declare const useFileUpload: (options?: UseFileUploadOptions) => UseFileUploadReturn;
843
-
844
- /** App structure action configuration */
845
853
  interface AppStructureAction {
846
854
  key: string;
847
855
  moduleKey?: string;
848
856
  [key: string]: unknown;
849
857
  }
858
+ /**
859
+ * Options for the useCrudifyWithNotifications hook
860
+ */
850
861
  interface CrudifyWithNotificationsOptions {
851
862
  showSuccessNotifications?: boolean;
852
863
  showErrorNotifications?: boolean;
@@ -856,6 +867,29 @@ interface CrudifyWithNotificationsOptions {
856
867
  appStructure?: AppStructureAction[];
857
868
  translateFn?: (key: string, options?: Record<string, unknown>) => string;
858
869
  }
870
+
871
+ /**
872
+ * Notification filtering utilities
873
+ *
874
+ * Determines when and which notifications should be shown
875
+ */
876
+
877
+ /**
878
+ * Determines if a notification should be shown for a given response
879
+ *
880
+ * Returns false for:
881
+ * - Field validation errors (these go to form validation)
882
+ * - ONE_OR_MORE_OPERATIONS_FAILED (generic transaction error)
883
+ * - TOO_MANY_REQUESTS (handled by forms)
884
+ */
885
+ declare function shouldShowNotification(response: CrudifyResponse): boolean;
886
+
887
+ /**
888
+ * Hook that wraps crudify SDK operations with automatic notifications
889
+ *
890
+ * @param options - Configuration options
891
+ * @returns Object with wrapped CRUD operations and utility functions
892
+ */
859
893
  declare const useCrudifyWithNotifications: (options?: CrudifyWithNotificationsOptions) => {
860
894
  createItem: (moduleKey: string, data: object, options?: CrudifyOperationOptions) => Promise<CrudifyResponse>;
861
895
  updateItem: (moduleKey: string, data: object, options?: CrudifyOperationOptions) => Promise<CrudifyResponse>;
@@ -866,7 +900,7 @@ declare const useCrudifyWithNotifications: (options?: CrudifyWithNotificationsOp
866
900
  handleResponse: (response: CrudifyResponse, successMessage?: string) => CrudifyResponse;
867
901
  getErrorMessage: (response: CrudifyResponse) => string;
868
902
  getErrorSeverity: (response: CrudifyResponse) => NotificationSeverity;
869
- shouldShowNotification: (response: CrudifyResponse) => boolean;
903
+ shouldShowNotification: typeof shouldShowNotification;
870
904
  };
871
905
 
872
906
  export { type FileItem as F, type LoginResult as L, type NotificationOptions as N, SessionManager as S, TokenStorage as T, type UseSessionOptions as U, type SessionConfig as a, type TokenData as b, type StorageType as c, type SessionState as d, SessionProvider as e, useSessionContext as f, SessionDebugInfo as g, type SessionProviderProps as h, useUserData as i, type UseUserDataReturn as j, type UseUserDataOptions as k, type UserData as l, useAuth as m, type UseAuthReturn as n, useData as o, type UseDataReturn as p, useUserProfile as q, useFileUpload as r, type UseFileUploadOptions as s, type UseFileUploadReturn as t, useSession as u, type FileStatus as v, useCrudifyWithNotifications as w };