warqadui 0.0.50 → 0.0.52

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.mts CHANGED
@@ -4,8 +4,10 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react_hook_form from 'react-hook-form';
5
5
  import { FieldValues, Path, UseFormReturn } from 'react-hook-form';
6
6
  import { ColumnDef, SortingState, ColumnFiltersState, RowData } from '@tanstack/react-table';
7
+ import * as z from 'zod';
7
8
  import * as react_to_print from 'react-to-print';
8
9
  import { UploadFile } from 'antd';
10
+ import * as zustand from 'zustand';
9
11
 
10
12
  interface ButtonProps extends React__default.ButtonHTMLAttributes<HTMLButtonElement> {
11
13
  variant?: "primary" | "secondary" | "outline" | "ghost" | "danger" | "warning";
@@ -527,6 +529,73 @@ interface BrandingProps {
527
529
  }
528
530
  declare const Branding: React__default.FC<BrandingProps>;
529
531
 
532
+ type LoginTheme = "tech" | "travel" | "healthcare";
533
+ interface BaseLoginProps {
534
+ form: UseFormReturn<LoginSchema>;
535
+ onSubmit: (data: LoginSchema, form: UseFormReturn<LoginSchema>) => void;
536
+ image?: string;
537
+ theme?: LoginTheme;
538
+ title?: string;
539
+ subtitle?: string;
540
+ logo?: React__default.ReactNode;
541
+ footer?: React__default.ReactNode;
542
+ brandName?: string;
543
+ backUrl?: string;
544
+ isLoading?: boolean;
545
+ }
546
+ declare const ThemedLogin: React__default.FC<BaseLoginProps>;
547
+
548
+ declare const defaultLoginSchema: z.ZodObject<{
549
+ email: z.ZodString;
550
+ password: z.ZodString;
551
+ }, "strip", z.ZodTypeAny, {
552
+ email: string;
553
+ password: string;
554
+ }, {
555
+ email: string;
556
+ password: string;
557
+ }>;
558
+ type LoginSchema = z.infer<typeof defaultLoginSchema>;
559
+ interface UseLoginProps {
560
+ theme?: LoginTheme;
561
+ image?: string;
562
+ schema?: z.ZodType<any, any, any>;
563
+ defaultValues?: any;
564
+ onSubmit: (data: any, form: UseFormReturn<LoginSchema>) => void;
565
+ brandName?: string;
566
+ title?: string;
567
+ subtitle?: string;
568
+ backUrl?: string;
569
+ isLoading?: boolean;
570
+ }
571
+ declare const useLogin: (props: UseLoginProps) => {
572
+ form: UseFormReturn<{
573
+ email: string;
574
+ password: string;
575
+ }, any, {
576
+ email: string;
577
+ password: string;
578
+ }>;
579
+ Login: React__default.FC<{}>;
580
+ };
581
+
582
+ interface ProfileDropdownItem {
583
+ label: string;
584
+ icon?: React__default.ReactNode;
585
+ onClick?: () => void | Promise<void>;
586
+ disabled?: boolean;
587
+ className?: string;
588
+ }
589
+ interface ProfileDropdownProps {
590
+ name: string;
591
+ image?: string;
592
+ items: ProfileDropdownItem[];
593
+ className?: string;
594
+ triggerMode?: "click" | "hover";
595
+ size?: "sm" | "md" | "lg";
596
+ }
597
+ declare const ProfileDropdown: React__default.FC<ProfileDropdownProps>;
598
+
530
599
  interface FetchProps {
531
600
  url: string;
532
601
  body?: Record<string, any>;
@@ -774,4 +843,154 @@ declare const Views: {
774
843
  }>;
775
844
  };
776
845
 
777
- export { Badge, type BadgeProps, Branding, type BrandingProps, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CategoryCard, type CategoryItem, ClassicSpin, CodeBlock, DashboardLayout, DataTable, type DataTableColumn, DateInput, type DateInputProps, type DeleteFunction, type FetchFunction, type FetchProps, Fields, InfoGrid, Input, type InputProps, LoadingBox, LoadingSpin, Modal, type ModalProps, type NavItem, type NavItems, type Option, OverlaySpin, PageA4, PageHeader, type PdfOptions, PhoneInput, type PhoneInputProps, type PostFunction, PostTable, type PostTableActions, type PostTableChangeParams, type PutFunction, SearchApi, SearchApiContent, SearchApiInput, SearchApiItem, type SearchApiProps, SearchApiTrigger, Select, SelectContent, SelectItem, type SelectProps, SelectTrigger, SimpleTable, type SimpleTableColumn, type StorageManager, type StoreConfig, Textarea, type TextareaProps, type ThemeConfig, ThemeProvider, ThemeToggle, type UseModalReturn, Views, type WarqadConfig, type WarqadConfigContextType, WarqadProvider, generatePdf, storage, useA4CategoryView, useA4StatementView, useAntdImageUpload, useApi, useModal, useSearchApiContext, useSelectContext, useTheme, useTransaction, useWarqadConfig };
846
+ /**
847
+ * Guard component that fetches the current user profile on every route change.
848
+ * It ensures the auth state is synchronized with the server.
849
+ */
850
+ declare const Guard: () => react_jsx_runtime.JSX.Element;
851
+ /**
852
+ * Ensures the user is logged in to access child routes.
853
+ */
854
+ declare const ProtectedRoute: () => react_jsx_runtime.JSX.Element;
855
+ /**
856
+ * Ensures the user is NOT logged in to access child routes (e.g. Login/Signup pages).
857
+ */
858
+ declare const UnProtectedRoute: () => react_jsx_runtime.JSX.Element;
859
+ /**
860
+ * Ensures only users with 'admin' role can access child routes.
861
+ */
862
+ declare const AdminProtectedRoute: () => react_jsx_runtime.JSX.Element;
863
+
864
+ type Role = string;
865
+ type AccountType = string;
866
+ type AuthData = {
867
+ _id: string;
868
+ role: Role;
869
+ email: string;
870
+ phoneNumber: string;
871
+ isActive: boolean;
872
+ isEmailVerified: boolean;
873
+ isPhoneVerified: boolean;
874
+ permissions?: Record<string, boolean>;
875
+ homePath?: string;
876
+ };
877
+ type AccountData = {
878
+ _id: string;
879
+ name: string;
880
+ email: string;
881
+ phoneNumber: string;
882
+ type: AccountType;
883
+ };
884
+ type AuthState = {
885
+ auth: AuthData | null;
886
+ account: AccountData | null;
887
+ isLoggedIn: boolean;
888
+ isFetched: boolean;
889
+ setAuth: (auth: AuthData, account: AccountData) => void;
890
+ setIsLoggedIn: (isLoggedIn: boolean) => void;
891
+ setIsFetched: (isFetched: boolean) => void;
892
+ logout: () => void;
893
+ updateAuth: (data: Partial<AuthData>) => void;
894
+ updateAccount: (data: Partial<AccountData>) => void;
895
+ hasPermission: (key: string) => boolean;
896
+ };
897
+ declare const useAuthStore: zustand.UseBoundStore<zustand.StoreApi<AuthState>>;
898
+
899
+ declare const useAuth: () => {
900
+ auth: {
901
+ _id: string;
902
+ role: Role;
903
+ email: string;
904
+ phoneNumber: string;
905
+ isActive: boolean;
906
+ isEmailVerified: boolean;
907
+ isPhoneVerified: boolean;
908
+ permissions?: Record<string, boolean>;
909
+ homePath?: string;
910
+ } | null;
911
+ user: {
912
+ _id: string;
913
+ role: Role;
914
+ email: string;
915
+ phoneNumber: string;
916
+ isActive: boolean;
917
+ isEmailVerified: boolean;
918
+ isPhoneVerified: boolean;
919
+ permissions?: Record<string, boolean>;
920
+ homePath?: string;
921
+ } | null;
922
+ account: {
923
+ _id: string;
924
+ name: string;
925
+ email: string;
926
+ phoneNumber: string;
927
+ type: AccountType;
928
+ } | null;
929
+ isLoggedIn: boolean;
930
+ isFetched: boolean;
931
+ role: string | undefined;
932
+ userId: string | undefined;
933
+ accountId: string | undefined;
934
+ userName: string | undefined;
935
+ userEmail: string | undefined;
936
+ permissions: Record<string, boolean>;
937
+ isAdmin: boolean;
938
+ isActive: boolean;
939
+ isVerified: boolean;
940
+ isEmailVerified: boolean;
941
+ isPhoneVerified: boolean;
942
+ logout: () => void;
943
+ setIsLoggedIn: (isLoggedIn: boolean) => void;
944
+ setIsFetched: (isFetched: boolean) => void;
945
+ setAuth: (auth: {
946
+ _id: string;
947
+ role: Role;
948
+ email: string;
949
+ phoneNumber: string;
950
+ isActive: boolean;
951
+ isEmailVerified: boolean;
952
+ isPhoneVerified: boolean;
953
+ permissions?: Record<string, boolean>;
954
+ homePath?: string;
955
+ }, account: {
956
+ _id: string;
957
+ name: string;
958
+ email: string;
959
+ phoneNumber: string;
960
+ type: AccountType;
961
+ }) => void;
962
+ login: (data: any) => void;
963
+ updateAuth: (data: Partial<{
964
+ _id: string;
965
+ role: Role;
966
+ email: string;
967
+ phoneNumber: string;
968
+ isActive: boolean;
969
+ isEmailVerified: boolean;
970
+ isPhoneVerified: boolean;
971
+ permissions?: Record<string, boolean>;
972
+ homePath?: string;
973
+ }>) => void;
974
+ updateUser: (data: Partial<{
975
+ _id: string;
976
+ role: Role;
977
+ email: string;
978
+ phoneNumber: string;
979
+ isActive: boolean;
980
+ isEmailVerified: boolean;
981
+ isPhoneVerified: boolean;
982
+ permissions?: Record<string, boolean>;
983
+ homePath?: string;
984
+ }>) => void;
985
+ updateAccount: (data: Partial<{
986
+ _id: string;
987
+ name: string;
988
+ email: string;
989
+ phoneNumber: string;
990
+ type: AccountType;
991
+ }>) => void;
992
+ hasPermission: (key: string) => boolean;
993
+ can: (key: string) => boolean;
994
+ };
995
+
996
+ export { type AccountType, AdminProtectedRoute, Badge, type BadgeProps, Branding, type BrandingProps, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CategoryCard, type CategoryItem, ClassicSpin, CodeBlock, DashboardLayout, DataTable, type DataTableColumn, DateInput, type DateInputProps, type DeleteFunction, type FetchFunction, type FetchProps, Fields, Guard, InfoGrid, Input, type InputProps, LoadingBox, LoadingSpin, type LoginSchema, type LoginTheme, Modal, type ModalProps, type NavItem, type NavItems, type Option, OverlaySpin, PageA4, PageHeader, type PdfOptions, PhoneInput, type PhoneInputProps, type PostFunction, PostTable, type PostTableActions, type PostTableChangeParams, ProfileDropdown, type ProfileDropdownItem, type ProfileDropdownProps, ProtectedRoute, type PutFunction, type Role, SearchApi, SearchApiContent, SearchApiInput, SearchApiItem, type SearchApiProps, SearchApiTrigger, Select, SelectContent, SelectItem, type SelectProps, SelectTrigger, SimpleTable, type SimpleTableColumn, type StorageManager, type StoreConfig, Textarea, type TextareaProps, type ThemeConfig, ThemeProvider, ThemeToggle, ThemedLogin, UnProtectedRoute, type UseModalReturn, Views, type WarqadConfig, type WarqadConfigContextType, WarqadProvider, generatePdf, storage, useA4CategoryView, useA4StatementView, useAntdImageUpload, useApi, useAuth, useAuthStore, useLogin, useModal, useSearchApiContext, useSelectContext, useTheme, useTransaction, useWarqadConfig };
package/dist/index.d.ts CHANGED
@@ -4,8 +4,10 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react_hook_form from 'react-hook-form';
5
5
  import { FieldValues, Path, UseFormReturn } from 'react-hook-form';
6
6
  import { ColumnDef, SortingState, ColumnFiltersState, RowData } from '@tanstack/react-table';
7
+ import * as z from 'zod';
7
8
  import * as react_to_print from 'react-to-print';
8
9
  import { UploadFile } from 'antd';
10
+ import * as zustand from 'zustand';
9
11
 
10
12
  interface ButtonProps extends React__default.ButtonHTMLAttributes<HTMLButtonElement> {
11
13
  variant?: "primary" | "secondary" | "outline" | "ghost" | "danger" | "warning";
@@ -527,6 +529,73 @@ interface BrandingProps {
527
529
  }
528
530
  declare const Branding: React__default.FC<BrandingProps>;
529
531
 
532
+ type LoginTheme = "tech" | "travel" | "healthcare";
533
+ interface BaseLoginProps {
534
+ form: UseFormReturn<LoginSchema>;
535
+ onSubmit: (data: LoginSchema, form: UseFormReturn<LoginSchema>) => void;
536
+ image?: string;
537
+ theme?: LoginTheme;
538
+ title?: string;
539
+ subtitle?: string;
540
+ logo?: React__default.ReactNode;
541
+ footer?: React__default.ReactNode;
542
+ brandName?: string;
543
+ backUrl?: string;
544
+ isLoading?: boolean;
545
+ }
546
+ declare const ThemedLogin: React__default.FC<BaseLoginProps>;
547
+
548
+ declare const defaultLoginSchema: z.ZodObject<{
549
+ email: z.ZodString;
550
+ password: z.ZodString;
551
+ }, "strip", z.ZodTypeAny, {
552
+ email: string;
553
+ password: string;
554
+ }, {
555
+ email: string;
556
+ password: string;
557
+ }>;
558
+ type LoginSchema = z.infer<typeof defaultLoginSchema>;
559
+ interface UseLoginProps {
560
+ theme?: LoginTheme;
561
+ image?: string;
562
+ schema?: z.ZodType<any, any, any>;
563
+ defaultValues?: any;
564
+ onSubmit: (data: any, form: UseFormReturn<LoginSchema>) => void;
565
+ brandName?: string;
566
+ title?: string;
567
+ subtitle?: string;
568
+ backUrl?: string;
569
+ isLoading?: boolean;
570
+ }
571
+ declare const useLogin: (props: UseLoginProps) => {
572
+ form: UseFormReturn<{
573
+ email: string;
574
+ password: string;
575
+ }, any, {
576
+ email: string;
577
+ password: string;
578
+ }>;
579
+ Login: React__default.FC<{}>;
580
+ };
581
+
582
+ interface ProfileDropdownItem {
583
+ label: string;
584
+ icon?: React__default.ReactNode;
585
+ onClick?: () => void | Promise<void>;
586
+ disabled?: boolean;
587
+ className?: string;
588
+ }
589
+ interface ProfileDropdownProps {
590
+ name: string;
591
+ image?: string;
592
+ items: ProfileDropdownItem[];
593
+ className?: string;
594
+ triggerMode?: "click" | "hover";
595
+ size?: "sm" | "md" | "lg";
596
+ }
597
+ declare const ProfileDropdown: React__default.FC<ProfileDropdownProps>;
598
+
530
599
  interface FetchProps {
531
600
  url: string;
532
601
  body?: Record<string, any>;
@@ -774,4 +843,154 @@ declare const Views: {
774
843
  }>;
775
844
  };
776
845
 
777
- export { Badge, type BadgeProps, Branding, type BrandingProps, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CategoryCard, type CategoryItem, ClassicSpin, CodeBlock, DashboardLayout, DataTable, type DataTableColumn, DateInput, type DateInputProps, type DeleteFunction, type FetchFunction, type FetchProps, Fields, InfoGrid, Input, type InputProps, LoadingBox, LoadingSpin, Modal, type ModalProps, type NavItem, type NavItems, type Option, OverlaySpin, PageA4, PageHeader, type PdfOptions, PhoneInput, type PhoneInputProps, type PostFunction, PostTable, type PostTableActions, type PostTableChangeParams, type PutFunction, SearchApi, SearchApiContent, SearchApiInput, SearchApiItem, type SearchApiProps, SearchApiTrigger, Select, SelectContent, SelectItem, type SelectProps, SelectTrigger, SimpleTable, type SimpleTableColumn, type StorageManager, type StoreConfig, Textarea, type TextareaProps, type ThemeConfig, ThemeProvider, ThemeToggle, type UseModalReturn, Views, type WarqadConfig, type WarqadConfigContextType, WarqadProvider, generatePdf, storage, useA4CategoryView, useA4StatementView, useAntdImageUpload, useApi, useModal, useSearchApiContext, useSelectContext, useTheme, useTransaction, useWarqadConfig };
846
+ /**
847
+ * Guard component that fetches the current user profile on every route change.
848
+ * It ensures the auth state is synchronized with the server.
849
+ */
850
+ declare const Guard: () => react_jsx_runtime.JSX.Element;
851
+ /**
852
+ * Ensures the user is logged in to access child routes.
853
+ */
854
+ declare const ProtectedRoute: () => react_jsx_runtime.JSX.Element;
855
+ /**
856
+ * Ensures the user is NOT logged in to access child routes (e.g. Login/Signup pages).
857
+ */
858
+ declare const UnProtectedRoute: () => react_jsx_runtime.JSX.Element;
859
+ /**
860
+ * Ensures only users with 'admin' role can access child routes.
861
+ */
862
+ declare const AdminProtectedRoute: () => react_jsx_runtime.JSX.Element;
863
+
864
+ type Role = string;
865
+ type AccountType = string;
866
+ type AuthData = {
867
+ _id: string;
868
+ role: Role;
869
+ email: string;
870
+ phoneNumber: string;
871
+ isActive: boolean;
872
+ isEmailVerified: boolean;
873
+ isPhoneVerified: boolean;
874
+ permissions?: Record<string, boolean>;
875
+ homePath?: string;
876
+ };
877
+ type AccountData = {
878
+ _id: string;
879
+ name: string;
880
+ email: string;
881
+ phoneNumber: string;
882
+ type: AccountType;
883
+ };
884
+ type AuthState = {
885
+ auth: AuthData | null;
886
+ account: AccountData | null;
887
+ isLoggedIn: boolean;
888
+ isFetched: boolean;
889
+ setAuth: (auth: AuthData, account: AccountData) => void;
890
+ setIsLoggedIn: (isLoggedIn: boolean) => void;
891
+ setIsFetched: (isFetched: boolean) => void;
892
+ logout: () => void;
893
+ updateAuth: (data: Partial<AuthData>) => void;
894
+ updateAccount: (data: Partial<AccountData>) => void;
895
+ hasPermission: (key: string) => boolean;
896
+ };
897
+ declare const useAuthStore: zustand.UseBoundStore<zustand.StoreApi<AuthState>>;
898
+
899
+ declare const useAuth: () => {
900
+ auth: {
901
+ _id: string;
902
+ role: Role;
903
+ email: string;
904
+ phoneNumber: string;
905
+ isActive: boolean;
906
+ isEmailVerified: boolean;
907
+ isPhoneVerified: boolean;
908
+ permissions?: Record<string, boolean>;
909
+ homePath?: string;
910
+ } | null;
911
+ user: {
912
+ _id: string;
913
+ role: Role;
914
+ email: string;
915
+ phoneNumber: string;
916
+ isActive: boolean;
917
+ isEmailVerified: boolean;
918
+ isPhoneVerified: boolean;
919
+ permissions?: Record<string, boolean>;
920
+ homePath?: string;
921
+ } | null;
922
+ account: {
923
+ _id: string;
924
+ name: string;
925
+ email: string;
926
+ phoneNumber: string;
927
+ type: AccountType;
928
+ } | null;
929
+ isLoggedIn: boolean;
930
+ isFetched: boolean;
931
+ role: string | undefined;
932
+ userId: string | undefined;
933
+ accountId: string | undefined;
934
+ userName: string | undefined;
935
+ userEmail: string | undefined;
936
+ permissions: Record<string, boolean>;
937
+ isAdmin: boolean;
938
+ isActive: boolean;
939
+ isVerified: boolean;
940
+ isEmailVerified: boolean;
941
+ isPhoneVerified: boolean;
942
+ logout: () => void;
943
+ setIsLoggedIn: (isLoggedIn: boolean) => void;
944
+ setIsFetched: (isFetched: boolean) => void;
945
+ setAuth: (auth: {
946
+ _id: string;
947
+ role: Role;
948
+ email: string;
949
+ phoneNumber: string;
950
+ isActive: boolean;
951
+ isEmailVerified: boolean;
952
+ isPhoneVerified: boolean;
953
+ permissions?: Record<string, boolean>;
954
+ homePath?: string;
955
+ }, account: {
956
+ _id: string;
957
+ name: string;
958
+ email: string;
959
+ phoneNumber: string;
960
+ type: AccountType;
961
+ }) => void;
962
+ login: (data: any) => void;
963
+ updateAuth: (data: Partial<{
964
+ _id: string;
965
+ role: Role;
966
+ email: string;
967
+ phoneNumber: string;
968
+ isActive: boolean;
969
+ isEmailVerified: boolean;
970
+ isPhoneVerified: boolean;
971
+ permissions?: Record<string, boolean>;
972
+ homePath?: string;
973
+ }>) => void;
974
+ updateUser: (data: Partial<{
975
+ _id: string;
976
+ role: Role;
977
+ email: string;
978
+ phoneNumber: string;
979
+ isActive: boolean;
980
+ isEmailVerified: boolean;
981
+ isPhoneVerified: boolean;
982
+ permissions?: Record<string, boolean>;
983
+ homePath?: string;
984
+ }>) => void;
985
+ updateAccount: (data: Partial<{
986
+ _id: string;
987
+ name: string;
988
+ email: string;
989
+ phoneNumber: string;
990
+ type: AccountType;
991
+ }>) => void;
992
+ hasPermission: (key: string) => boolean;
993
+ can: (key: string) => boolean;
994
+ };
995
+
996
+ export { type AccountType, AdminProtectedRoute, Badge, type BadgeProps, Branding, type BrandingProps, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CategoryCard, type CategoryItem, ClassicSpin, CodeBlock, DashboardLayout, DataTable, type DataTableColumn, DateInput, type DateInputProps, type DeleteFunction, type FetchFunction, type FetchProps, Fields, Guard, InfoGrid, Input, type InputProps, LoadingBox, LoadingSpin, type LoginSchema, type LoginTheme, Modal, type ModalProps, type NavItem, type NavItems, type Option, OverlaySpin, PageA4, PageHeader, type PdfOptions, PhoneInput, type PhoneInputProps, type PostFunction, PostTable, type PostTableActions, type PostTableChangeParams, ProfileDropdown, type ProfileDropdownItem, type ProfileDropdownProps, ProtectedRoute, type PutFunction, type Role, SearchApi, SearchApiContent, SearchApiInput, SearchApiItem, type SearchApiProps, SearchApiTrigger, Select, SelectContent, SelectItem, type SelectProps, SelectTrigger, SimpleTable, type SimpleTableColumn, type StorageManager, type StoreConfig, Textarea, type TextareaProps, type ThemeConfig, ThemeProvider, ThemeToggle, ThemedLogin, UnProtectedRoute, type UseModalReturn, Views, type WarqadConfig, type WarqadConfigContextType, WarqadProvider, generatePdf, storage, useA4CategoryView, useA4StatementView, useAntdImageUpload, useApi, useAuth, useAuthStore, useLogin, useModal, useSearchApiContext, useSelectContext, useTheme, useTransaction, useWarqadConfig };