warqadui 0.0.51 → 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 +171 -1
- package/dist/index.d.ts +171 -1
- package/dist/index.js +609 -243
- package/dist/index.mjs +599 -240
- package/dist/styles.js +61 -0
- package/dist/styles.mjs +61 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -7,6 +7,7 @@ import { ColumnDef, SortingState, ColumnFiltersState, RowData } from '@tanstack/
|
|
|
7
7
|
import * as z from 'zod';
|
|
8
8
|
import * as react_to_print from 'react-to-print';
|
|
9
9
|
import { UploadFile } from 'antd';
|
|
10
|
+
import * as zustand from 'zustand';
|
|
10
11
|
|
|
11
12
|
interface ButtonProps extends React__default.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
12
13
|
variant?: "primary" | "secondary" | "outline" | "ghost" | "danger" | "warning";
|
|
@@ -540,6 +541,7 @@ interface BaseLoginProps {
|
|
|
540
541
|
footer?: React__default.ReactNode;
|
|
541
542
|
brandName?: string;
|
|
542
543
|
backUrl?: string;
|
|
544
|
+
isLoading?: boolean;
|
|
543
545
|
}
|
|
544
546
|
declare const ThemedLogin: React__default.FC<BaseLoginProps>;
|
|
545
547
|
|
|
@@ -564,6 +566,7 @@ interface UseLoginProps {
|
|
|
564
566
|
title?: string;
|
|
565
567
|
subtitle?: string;
|
|
566
568
|
backUrl?: string;
|
|
569
|
+
isLoading?: boolean;
|
|
567
570
|
}
|
|
568
571
|
declare const useLogin: (props: UseLoginProps) => {
|
|
569
572
|
form: UseFormReturn<{
|
|
@@ -576,6 +579,23 @@ declare const useLogin: (props: UseLoginProps) => {
|
|
|
576
579
|
Login: React__default.FC<{}>;
|
|
577
580
|
};
|
|
578
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
|
+
|
|
579
599
|
interface FetchProps {
|
|
580
600
|
url: string;
|
|
581
601
|
body?: Record<string, any>;
|
|
@@ -823,4 +843,154 @@ declare const Views: {
|
|
|
823
843
|
}>;
|
|
824
844
|
};
|
|
825
845
|
|
|
826
|
-
|
|
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
|
@@ -7,6 +7,7 @@ import { ColumnDef, SortingState, ColumnFiltersState, RowData } from '@tanstack/
|
|
|
7
7
|
import * as z from 'zod';
|
|
8
8
|
import * as react_to_print from 'react-to-print';
|
|
9
9
|
import { UploadFile } from 'antd';
|
|
10
|
+
import * as zustand from 'zustand';
|
|
10
11
|
|
|
11
12
|
interface ButtonProps extends React__default.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
12
13
|
variant?: "primary" | "secondary" | "outline" | "ghost" | "danger" | "warning";
|
|
@@ -540,6 +541,7 @@ interface BaseLoginProps {
|
|
|
540
541
|
footer?: React__default.ReactNode;
|
|
541
542
|
brandName?: string;
|
|
542
543
|
backUrl?: string;
|
|
544
|
+
isLoading?: boolean;
|
|
543
545
|
}
|
|
544
546
|
declare const ThemedLogin: React__default.FC<BaseLoginProps>;
|
|
545
547
|
|
|
@@ -564,6 +566,7 @@ interface UseLoginProps {
|
|
|
564
566
|
title?: string;
|
|
565
567
|
subtitle?: string;
|
|
566
568
|
backUrl?: string;
|
|
569
|
+
isLoading?: boolean;
|
|
567
570
|
}
|
|
568
571
|
declare const useLogin: (props: UseLoginProps) => {
|
|
569
572
|
form: UseFormReturn<{
|
|
@@ -576,6 +579,23 @@ declare const useLogin: (props: UseLoginProps) => {
|
|
|
576
579
|
Login: React__default.FC<{}>;
|
|
577
580
|
};
|
|
578
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
|
+
|
|
579
599
|
interface FetchProps {
|
|
580
600
|
url: string;
|
|
581
601
|
body?: Record<string, any>;
|
|
@@ -823,4 +843,154 @@ declare const Views: {
|
|
|
823
843
|
}>;
|
|
824
844
|
};
|
|
825
845
|
|
|
826
|
-
|
|
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 };
|