@bsol-oss/react-datatable5 12.0.0-beta.70 → 12.0.0-beta.72

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/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { Row, RowData, OnChangeFn, Updater, FilterFn, ColumnDef, RowSelectionState, ColumnOrderState, ColumnFiltersState, PaginationState, SortingState, VisibilityState, Table as Table$1, Column } from '@tanstack/react-table';
3
- import * as React$1 from 'react';
4
- import React__default, { ReactNode, Dispatch, SetStateAction } from 'react';
3
+ import * as react from 'react';
4
+ import react__default, { ReactNode, Dispatch, SetStateAction } from 'react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { ImageProps, GridProps, TableRootProps, TableHeaderProps as TableHeaderProps$1, TableRowProps, BoxProps, FlexProps, CardBodyProps, TextProps } from '@chakra-ui/react';
7
7
  import { IconType } from 'react-icons';
@@ -17,7 +17,7 @@ import { UseFormReturn, FieldValues, SubmitHandler } from 'react-hook-form';
17
17
  import { RenderProps, Props } from '@bsol-oss/dayzed-react19';
18
18
 
19
19
  interface DensityToggleButtonProps {
20
- icon?: React__default.ReactElement;
20
+ icon?: react__default.ReactElement;
21
21
  text?: string;
22
22
  }
23
23
  declare const DensityToggleButton: ({ text, icon, }: DensityToggleButtonProps) => react_jsx_runtime.JSX.Element;
@@ -50,7 +50,7 @@ declare const ResetSortingButton: () => react_jsx_runtime.JSX.Element;
50
50
  declare const RowCountText: () => react_jsx_runtime.JSX.Element;
51
51
 
52
52
  interface EditViewButtonProps {
53
- icon?: React__default.ReactElement;
53
+ icon?: react__default.ReactElement;
54
54
  }
55
55
  declare const ViewDialog: ({ icon }: EditViewButtonProps) => react_jsx_runtime.JSX.Element;
56
56
 
@@ -386,7 +386,7 @@ interface TableProps extends TableRootProps {
386
386
  canResize?: boolean;
387
387
  children: ReactNode;
388
388
  }
389
- declare const Table: ({ children, emptyComponent, canResize, ...props }: TableProps) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | React$1.ReactPortal | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null;
389
+ declare const Table: ({ children, emptyComponent, canResize, ...props }: TableProps) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null;
390
390
 
391
391
  interface TableBodyProps {
392
392
  pinnedBgColor?: {
@@ -500,9 +500,9 @@ declare const DefaultCardTitle: () => react_jsx_runtime.JSX.Element;
500
500
  declare const TableCards: <TData>({ isSelectable, showDisplayNameOnly, renderTitle, cardBodyProps, }: TableCardsProps<TData>) => react_jsx_runtime.JSX.Element;
501
501
 
502
502
  interface TableRendererProps<TData> {
503
- render: (render: Table$1<TData>) => React__default.ReactElement;
503
+ render: (render: Table$1<TData>) => react__default.ReactElement;
504
504
  }
505
- declare const TableComponent: <TData>({ render, }: TableRendererProps<TData>) => React__default.ReactElement<unknown, string | React__default.JSXElementConstructor<any>>;
505
+ declare const TableComponent: <TData>({ render, }: TableRendererProps<TData>) => react__default.ReactElement<unknown, string | react__default.JSXElementConstructor<any>>;
506
506
 
507
507
  declare const TableFilter: () => react_jsx_runtime.JSX.Element;
508
508
 
@@ -573,6 +573,22 @@ interface ForeignKeyProps {
573
573
  customQueryFn?: CustomQueryFn;
574
574
  }
575
575
 
576
+ interface DateTimePickerLabels {
577
+ monthNamesShort?: string[];
578
+ weekdayNamesShort?: string[];
579
+ backButtonLabel?: string;
580
+ forwardButtonLabel?: string;
581
+ }
582
+ interface IdPickerLabels {
583
+ undefined?: string;
584
+ addMore?: string;
585
+ typeToSearch?: string;
586
+ total?: string;
587
+ showing?: string;
588
+ perPage?: string;
589
+ emptySearchResult?: string;
590
+ initialResults?: string;
591
+ }
576
592
  interface CustomJSONSchema7 extends JSONSchema7 {
577
593
  gridColumn?: string;
578
594
  gridRow?: string;
@@ -597,6 +613,11 @@ interface CustomJSONSchema7 extends JSONSchema7 {
597
613
  displayTimeFormat?: string;
598
614
  showLabel?: boolean;
599
615
  }
616
+ interface TagPickerProps {
617
+ column: string;
618
+ schema: CustomJSONSchema7;
619
+ prefix: string;
620
+ }
600
621
 
601
622
  interface FormRootProps<TData extends FieldValues> {
602
623
  schema: CustomJSONSchema7;
@@ -615,11 +636,14 @@ interface FormRootProps<TData extends FieldValues> {
615
636
  requestOptions?: AxiosRequestConfig;
616
637
  getUpdatedData?: () => TData | Promise<TData> | void;
617
638
  customErrorRenderer?: (error: unknown) => ReactNode;
639
+ customSuccessRenderer?: (resetHandler: () => void | Promise<void>) => ReactNode;
618
640
  displayConfig?: {
619
641
  showSubmitButton?: boolean;
620
642
  showResetButton?: boolean;
621
643
  showTitle?: boolean;
622
644
  };
645
+ dateTimePickerLabels?: DateTimePickerLabels;
646
+ idPickerLabels?: IdPickerLabels;
623
647
  }
624
648
  interface CustomJSONSchema7Definition extends JSONSchema7 {
625
649
  variant: string;
@@ -636,7 +660,7 @@ declare const idPickerSanityCheck: (column: string, foreign_key?: {
636
660
  column?: string | undefined;
637
661
  display_column?: string | undefined;
638
662
  } | undefined) => void;
639
- declare const FormRoot: <TData extends FieldValues>({ schema, idMap, setIdMap, form, serverUrl, translate, children, order, ignore, include, onSubmit, rowNumber, requestOptions, getUpdatedData, customErrorRenderer, displayConfig, }: FormRootProps<TData>) => react_jsx_runtime.JSX.Element;
663
+ declare const FormRoot: <TData extends FieldValues>({ schema, idMap, setIdMap, form, serverUrl, translate, children, order, ignore, include, onSubmit, rowNumber, requestOptions, getUpdatedData, customErrorRenderer, customSuccessRenderer, displayConfig, dateTimePickerLabels, idPickerLabels, }: FormRootProps<TData>) => react_jsx_runtime.JSX.Element;
640
664
 
641
665
  interface DefaultFormProps<TData extends FieldValues> {
642
666
  formConfig: Omit<FormRootProps<TData>, "children">;
@@ -646,19 +670,240 @@ declare const DefaultForm: <TData extends FieldValues>({ formConfig, }: DefaultF
646
670
 
647
671
  declare const FormTitle: () => react_jsx_runtime.JSX.Element;
648
672
 
649
- declare const FormBody: <TData extends object>() => react_jsx_runtime.JSX.Element;
673
+ declare const FormBody: <TData extends object>() => string | number | bigint | boolean | Iterable<react.ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
650
674
 
651
675
  interface UseFormProps {
652
676
  preLoadedValues?: FieldValues | undefined;
653
677
  keyPrefix?: string;
678
+ namespace?: string;
654
679
  }
655
- declare const useForm: ({ preLoadedValues, keyPrefix }: UseFormProps) => {
680
+ declare const useForm: ({ preLoadedValues, keyPrefix, namespace }: UseFormProps) => {
656
681
  form: react_hook_form.UseFormReturn<FieldValues, any, undefined>;
657
682
  idMap: Record<string, object>;
658
- setIdMap: React$1.Dispatch<React$1.SetStateAction<Record<string, object>>>;
659
- translate: react_i18next.UseTranslationResponse<"", string>;
683
+ setIdMap: react.Dispatch<react.SetStateAction<Record<string, object>>>;
684
+ translate: react_i18next.UseTranslationResponse<string, string>;
660
685
  };
661
686
 
687
+ /**
688
+ * Type definitions for error message configuration
689
+ */
690
+ /**
691
+ * Common validation error types that can be customized
692
+ */
693
+ type ValidationErrorType = "minLength" | "maxLength" | "pattern" | "minimum" | "maximum" | "multipleOf" | "format" | "type" | "enum";
694
+ /**
695
+ * Configuration for field-specific validation errors
696
+ */
697
+ type FieldErrorConfig = Partial<Record<ValidationErrorType, string>>;
698
+ /**
699
+ * Configuration for building error messages
700
+ */
701
+ interface ErrorMessageConfig {
702
+ /**
703
+ * Required field error messages
704
+ * Maps field names to their required error messages
705
+ * Supports both plain strings and i18n translation keys
706
+ *
707
+ * @example
708
+ * ```typescript
709
+ * required: {
710
+ * username: "Username is required", // plain string
711
+ * email: "user.email.field_required" // i18n key
712
+ * }
713
+ * ```
714
+ */
715
+ required?: Record<string, string>;
716
+ /**
717
+ * Field-specific validation error messages
718
+ * Maps field names to their validation error configurations
719
+ *
720
+ * @example
721
+ * ```typescript
722
+ * properties: {
723
+ * username: {
724
+ * minLength: "Username must be at least 3 characters",
725
+ * pattern: "Username can only contain letters and numbers"
726
+ * },
727
+ * age: {
728
+ * minimum: "Age must be at least 18",
729
+ * maximum: "Age cannot exceed 120"
730
+ * }
731
+ * }
732
+ * ```
733
+ */
734
+ properties?: Record<string, FieldErrorConfig>;
735
+ /**
736
+ * Global fallback error messages for validation types
737
+ * These are used when no field-specific message is provided
738
+ *
739
+ * @example
740
+ * ```typescript
741
+ * {
742
+ * minLength: "This field is too short",
743
+ * minimum: "Value is too small"
744
+ * }
745
+ * ```
746
+ */
747
+ [key: string]: any;
748
+ }
749
+ /**
750
+ * Result of buildErrorMessages that follows ajv-errors format
751
+ */
752
+ interface ErrorMessageResult {
753
+ required?: Record<string, string>;
754
+ properties?: Record<string, FieldErrorConfig>;
755
+ [key: string]: any;
756
+ }
757
+ /**
758
+ * Schema-level error message builder
759
+ *
760
+ * Builds a complete errorMessage object compatible with ajv-errors plugin.
761
+ * Supports both i18n translation keys and plain string messages.
762
+ *
763
+ * @param config - Error message configuration
764
+ * @returns Complete errorMessage object for JSON Schema
765
+ *
766
+ * @example
767
+ * ```typescript
768
+ * // Simple required field errors
769
+ * const errorMessage = buildErrorMessages({
770
+ * required: {
771
+ * username: "Username is required",
772
+ * email: "user.email.field_required" // i18n key
773
+ * }
774
+ * });
775
+ *
776
+ * // With validation rules
777
+ * const errorMessage = buildErrorMessages({
778
+ * required: {
779
+ * password: "Password is required"
780
+ * },
781
+ * properties: {
782
+ * password: {
783
+ * minLength: "Password must be at least 8 characters",
784
+ * pattern: "Password must contain letters and numbers"
785
+ * },
786
+ * age: {
787
+ * minimum: "Must be 18 or older",
788
+ * maximum: "Must be under 120"
789
+ * }
790
+ * }
791
+ * });
792
+ *
793
+ * // With global fallbacks
794
+ * const errorMessage = buildErrorMessages({
795
+ * required: {
796
+ * email: "Email is required"
797
+ * },
798
+ * minLength: "This field is too short", // applies to all fields
799
+ * minimum: "Value is too small"
800
+ * });
801
+ * ```
802
+ */
803
+ declare const buildErrorMessages: (config: ErrorMessageConfig) => ErrorMessageResult;
804
+ /**
805
+ * Helper function to build required field errors
806
+ *
807
+ * Simplifies creating required field error messages, especially useful
808
+ * for generating i18n translation keys following a pattern.
809
+ *
810
+ * @param fields - Array of required field names
811
+ * @param messageOrGenerator - Either a string template or function to generate messages
812
+ * @returns Required field error configuration
813
+ *
814
+ * @example
815
+ * ```typescript
816
+ * // Plain string messages
817
+ * const required = buildRequiredErrors(
818
+ * ["username", "email", "password"],
819
+ * (field) => `${field} is required`
820
+ * );
821
+ * // Result: { username: "username is required", email: "email is required", ... }
822
+ *
823
+ * // i18n translation keys
824
+ * const required = buildRequiredErrors(
825
+ * ["username", "email"],
826
+ * (field) => `user.${field}.field_required`
827
+ * );
828
+ * // Result: { username: "user.username.field_required", email: "user.email.field_required" }
829
+ *
830
+ * // Same message for all fields
831
+ * const required = buildRequiredErrors(
832
+ * ["username", "email"],
833
+ * "This field is required"
834
+ * );
835
+ * // Result: { username: "This field is required", email: "This field is required" }
836
+ *
837
+ * // With keyPrefix for i18n
838
+ * const required = buildRequiredErrors(
839
+ * ["username", "email"],
840
+ * (field) => `${field}.field_required`,
841
+ * "user"
842
+ * );
843
+ * // Result: { username: "user.username.field_required", email: "user.email.field_required" }
844
+ * ```
845
+ */
846
+ declare const buildRequiredErrors: (fields: string[], messageOrGenerator: string | ((field: string) => string), keyPrefix?: string) => Record<string, string>;
847
+ /**
848
+ * Helper function to build field-specific validation errors
849
+ *
850
+ * Creates property-specific error messages for multiple fields at once.
851
+ *
852
+ * @param config - Maps field names to their validation error configurations
853
+ * @returns Properties error configuration
854
+ *
855
+ * @example
856
+ * ```typescript
857
+ * const properties = buildFieldErrors({
858
+ * username: {
859
+ * minLength: "Username must be at least 3 characters",
860
+ * pattern: "Username can only contain letters and numbers"
861
+ * },
862
+ * age: {
863
+ * minimum: "Must be 18 or older",
864
+ * maximum: "Must be under 120"
865
+ * },
866
+ * email: {
867
+ * format: "Please enter a valid email address"
868
+ * }
869
+ * });
870
+ * ```
871
+ */
872
+ declare const buildFieldErrors: (config: Record<string, FieldErrorConfig>) => Record<string, FieldErrorConfig>;
873
+ /**
874
+ * Helper function to create a complete error message configuration in one call
875
+ *
876
+ * Convenient wrapper that combines required and validation errors.
877
+ *
878
+ * @param required - Required field error messages
879
+ * @param properties - Field-specific validation error messages
880
+ * @param globalFallbacks - Global fallback error messages
881
+ * @returns Complete error message configuration
882
+ *
883
+ * @example
884
+ * ```typescript
885
+ * const errorMessage = createErrorMessage(
886
+ * {
887
+ * username: "Username is required",
888
+ * email: "Email is required"
889
+ * },
890
+ * {
891
+ * username: {
892
+ * minLength: "Username must be at least 3 characters"
893
+ * },
894
+ * email: {
895
+ * format: "Please enter a valid email"
896
+ * }
897
+ * },
898
+ * {
899
+ * minLength: "This field is too short",
900
+ * format: "Invalid format"
901
+ * }
902
+ * );
903
+ * ```
904
+ */
905
+ declare const createErrorMessage: (required?: Record<string, string>, properties?: Record<string, FieldErrorConfig>, globalFallbacks?: Partial<Record<ValidationErrorType, string>>) => ErrorMessageResult;
906
+
662
907
  interface CalendarProps extends RenderProps {
663
908
  firstDayOfWeek?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
664
909
  }
@@ -689,7 +934,7 @@ interface DatePickerProps extends Props {
689
934
  backButtonLabel?: string;
690
935
  forwardButtonLabel?: string;
691
936
  };
692
- render?: (dayzedData: any) => React__default.ReactNode;
937
+ render?: (dayzedData: any) => react__default.ReactNode;
693
938
  }
694
939
  interface DatePickerLabels {
695
940
  monthNamesShort: string[];
@@ -806,4 +1051,4 @@ declare module "@tanstack/react-table" {
806
1051
  }
807
1052
  }
808
1053
 
809
- export { type CalendarProps, CardHeader, type CardHeaderProps, type CustomJSONSchema7Definition, DataDisplay, type DataDisplayProps, type DataResponse, DataTable, type DataTableDefaultState, type DataTableProps, DataTableServer, type DataTableServerProps, type DatePickerLabels, type DatePickerProps, DefaultCardTitle, DefaultForm, type DefaultFormProps, DefaultTable, type DefaultTableProps, DensityToggleButton, type DensityToggleButtonProps, type EditFilterButtonProps, EditSortingButton, type EditSortingButtonProps, type EditViewButtonProps, EmptyState, type EmptyStateProps, ErrorAlert, type ErrorAlertProps, FilterDialog, FormBody, FormRoot, type FormRootProps, FormTitle, type GetColumnsConfigs, type GetDateColorProps, type GetMultiDatesProps, type GetRangeDatesProps, type GetStyleProps, type GetVariantProps, GlobalFilter, PageSizeControl, type PageSizeControlProps, Pagination, type QueryParams, type RangeCalendarProps, type RangeDatePickerProps, RecordDisplay, type RecordDisplayProps, ReloadButton, type ReloadButtonProps, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, type Result, RowCountText, Table, TableBody, type TableBodyProps, TableCardContainer, type TableCardContainerProps, TableCards, type TableCardsProps, TableComponent, TableControls, type TableControlsProps, TableDataDisplay, type TableDataDisplayProps, TableFilter, TableFilterTags, TableFooter, type TableFooterProps, TableHeader, type TableHeaderProps, type TableHeaderTexts, TableLoadingComponent, type TableLoadingComponentProps, type TableProps, type TableRendererProps, type TableRowSelectorProps, TableSelector, TableSorter, TableViewer, TextCell, type TextCellProps, type UseDataTableProps, type UseDataTableReturn, type UseDataTableServerProps, type UseDataTableServerReturn, type UseFormProps, ViewDialog, getColumns, getMultiDates, getRangeDates, idPickerSanityCheck, useDataTable, useDataTableContext, useDataTableServer, useForm, widthSanityCheck };
1054
+ export { type CalendarProps, CardHeader, type CardHeaderProps, type CustomJSONSchema7, type CustomJSONSchema7Definition, DataDisplay, type DataDisplayProps, type DataResponse, DataTable, type DataTableDefaultState, type DataTableProps, DataTableServer, type DataTableServerProps, type DatePickerLabels, type DatePickerProps, type DateTimePickerLabels, DefaultCardTitle, DefaultForm, type DefaultFormProps, DefaultTable, type DefaultTableProps, DensityToggleButton, type DensityToggleButtonProps, type EditFilterButtonProps, EditSortingButton, type EditSortingButtonProps, type EditViewButtonProps, EmptyState, type EmptyStateProps, ErrorAlert, type ErrorAlertProps, type ErrorMessageConfig, type ErrorMessageResult, type FieldErrorConfig, FilterDialog, FormBody, FormRoot, type FormRootProps, FormTitle, type GetColumnsConfigs, type GetDateColorProps, type GetMultiDatesProps, type GetRangeDatesProps, type GetStyleProps, type GetVariantProps, GlobalFilter, type IdPickerLabels, PageSizeControl, type PageSizeControlProps, Pagination, type QueryParams, type RangeCalendarProps, type RangeDatePickerProps, RecordDisplay, type RecordDisplayProps, ReloadButton, type ReloadButtonProps, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, type Result, RowCountText, Table, TableBody, type TableBodyProps, TableCardContainer, type TableCardContainerProps, TableCards, type TableCardsProps, TableComponent, TableControls, type TableControlsProps, TableDataDisplay, type TableDataDisplayProps, TableFilter, TableFilterTags, TableFooter, type TableFooterProps, TableHeader, type TableHeaderProps, type TableHeaderTexts, TableLoadingComponent, type TableLoadingComponentProps, type TableProps, type TableRendererProps, type TableRowSelectorProps, TableSelector, TableSorter, TableViewer, type TagPickerProps, TextCell, type TextCellProps, type UseDataTableProps, type UseDataTableReturn, type UseDataTableServerProps, type UseDataTableServerReturn, type UseFormProps, type ValidationErrorType, ViewDialog, buildErrorMessages, buildFieldErrors, buildRequiredErrors, createErrorMessage, getColumns, getMultiDates, getRangeDates, idPickerSanityCheck, useDataTable, useDataTableContext, useDataTableServer, useForm, widthSanityCheck };