@nocios/crudify-ui 4.0.0 → 4.0.2
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 +76 -1
- package/dist/index.d.ts +76 -1
- package/dist/index.js +241 -3
- package/dist/index.mjs +239 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ export * from '@nocios/crudify-browser';
|
|
|
3
3
|
export { default as crudify } from '@nocios/crudify-browser';
|
|
4
4
|
import React, { ReactNode } from 'react';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
+
import { Theme } from '@mui/material/styles';
|
|
6
7
|
|
|
7
8
|
type BoxScreenType = "login" | "signUp" | "forgotPassword" | "resetPassword" | "checkCode";
|
|
8
9
|
interface CrudifyLoginConfig {
|
|
@@ -812,4 +813,78 @@ declare const useCrudifyWithNotifications: (options?: CrudifyWithNotificationsOp
|
|
|
812
813
|
shouldShowNotification: (response: CrudifyResponse) => boolean;
|
|
813
814
|
};
|
|
814
815
|
|
|
815
|
-
|
|
816
|
+
interface CrudifyThemeColors {
|
|
817
|
+
primary: {
|
|
818
|
+
main: string;
|
|
819
|
+
light: string;
|
|
820
|
+
dark: string;
|
|
821
|
+
contrastText: string;
|
|
822
|
+
};
|
|
823
|
+
secondary: {
|
|
824
|
+
main: string;
|
|
825
|
+
light: string;
|
|
826
|
+
dark: string;
|
|
827
|
+
contrastText: string;
|
|
828
|
+
};
|
|
829
|
+
background: {
|
|
830
|
+
default: string;
|
|
831
|
+
paper: string;
|
|
832
|
+
light: string;
|
|
833
|
+
};
|
|
834
|
+
button: {
|
|
835
|
+
primary: {
|
|
836
|
+
background: string;
|
|
837
|
+
backgroundHover: string;
|
|
838
|
+
border: string;
|
|
839
|
+
borderHover: string;
|
|
840
|
+
text: string;
|
|
841
|
+
textHover: string;
|
|
842
|
+
};
|
|
843
|
+
secondary: {
|
|
844
|
+
background: string;
|
|
845
|
+
backgroundHover: string;
|
|
846
|
+
border: string;
|
|
847
|
+
borderHover: string;
|
|
848
|
+
text: string;
|
|
849
|
+
textHover: string;
|
|
850
|
+
};
|
|
851
|
+
};
|
|
852
|
+
input: {
|
|
853
|
+
background: string;
|
|
854
|
+
border: string;
|
|
855
|
+
borderFocus: string;
|
|
856
|
+
text: string;
|
|
857
|
+
placeholder: string;
|
|
858
|
+
};
|
|
859
|
+
text: {
|
|
860
|
+
primary: string;
|
|
861
|
+
secondary: string;
|
|
862
|
+
disabled: string;
|
|
863
|
+
};
|
|
864
|
+
divider: string;
|
|
865
|
+
error: {
|
|
866
|
+
main: string;
|
|
867
|
+
light: string;
|
|
868
|
+
dark: string;
|
|
869
|
+
};
|
|
870
|
+
warning: {
|
|
871
|
+
main: string;
|
|
872
|
+
light: string;
|
|
873
|
+
dark: string;
|
|
874
|
+
};
|
|
875
|
+
success: {
|
|
876
|
+
main: string;
|
|
877
|
+
light: string;
|
|
878
|
+
dark: string;
|
|
879
|
+
};
|
|
880
|
+
info: {
|
|
881
|
+
main: string;
|
|
882
|
+
light: string;
|
|
883
|
+
dark: string;
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
declare const defaultCrudifyColors: CrudifyThemeColors;
|
|
887
|
+
declare const createCrudifyTheme: (colors?: Partial<CrudifyThemeColors>) => Theme;
|
|
888
|
+
declare const getCrudifyThemeFromCookies: () => Theme;
|
|
889
|
+
|
|
890
|
+
export { type ApiError, type BoxScreenType, type CrudifyApiResponse, CrudifyLogin, type CrudifyLoginConfig, type CrudifyLoginProps, type CrudifyLoginTranslations, type CrudifyThemeColors, type CrudifyTransactionResponse, ERROR_CODES, ERROR_SEVERITY_MAP, type ErrorCode, type ErrorSeverity, type ErrorTranslationConfig, type ForgotPasswordRequest, GlobalNotificationProvider, type GlobalNotificationProviderProps, type JwtPayload, LoginComponent, type LoginRequest, type LoginResponse, type LoginResult, type Notification, type NotificationOptions, type NotificationSeverity, POLICY_ACTIONS, PREFERRED_POLICY_ORDER, type ParsedError, Policies, type PolicyAction, ProtectedRoute, type ProtectedRouteProps, type ResetPasswordRequest, type SessionConfig, SessionDebugInfo, SessionManager, SessionProvider, type SessionProviderProps, type SessionState, SessionStatus, type StorageType, type TokenData, TokenStorage, type TransactionResponseData, type UseAuthReturn, type UseDataReturn, type UseSessionOptions, type UseUserDataOptions, type UseUserDataReturn, type UserData, type UserLoginData, type UserProfile, UserProfileDisplay, type ValidateCodeRequest, type ValidationError, createCrudifyTheme, createErrorTranslator, decodeJwtSafely, defaultCrudifyColors, getCookie, getCrudifyThemeFromCookies, getCurrentUserEmail, getErrorMessage, handleCrudifyError, isTokenExpired, parseApiError, parseJavaScriptError, parseTransactionError, secureLocalStorage, secureSessionStorage, translateError, translateErrorCode, translateErrorCodes, useAuth, useCrudifyWithNotifications, useData, useGlobalNotification, useSession, useSessionContext, useUserData, useUserProfile };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from '@nocios/crudify-browser';
|
|
|
3
3
|
export { default as crudify } from '@nocios/crudify-browser';
|
|
4
4
|
import React, { ReactNode } from 'react';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
+
import { Theme } from '@mui/material/styles';
|
|
6
7
|
|
|
7
8
|
type BoxScreenType = "login" | "signUp" | "forgotPassword" | "resetPassword" | "checkCode";
|
|
8
9
|
interface CrudifyLoginConfig {
|
|
@@ -812,4 +813,78 @@ declare const useCrudifyWithNotifications: (options?: CrudifyWithNotificationsOp
|
|
|
812
813
|
shouldShowNotification: (response: CrudifyResponse) => boolean;
|
|
813
814
|
};
|
|
814
815
|
|
|
815
|
-
|
|
816
|
+
interface CrudifyThemeColors {
|
|
817
|
+
primary: {
|
|
818
|
+
main: string;
|
|
819
|
+
light: string;
|
|
820
|
+
dark: string;
|
|
821
|
+
contrastText: string;
|
|
822
|
+
};
|
|
823
|
+
secondary: {
|
|
824
|
+
main: string;
|
|
825
|
+
light: string;
|
|
826
|
+
dark: string;
|
|
827
|
+
contrastText: string;
|
|
828
|
+
};
|
|
829
|
+
background: {
|
|
830
|
+
default: string;
|
|
831
|
+
paper: string;
|
|
832
|
+
light: string;
|
|
833
|
+
};
|
|
834
|
+
button: {
|
|
835
|
+
primary: {
|
|
836
|
+
background: string;
|
|
837
|
+
backgroundHover: string;
|
|
838
|
+
border: string;
|
|
839
|
+
borderHover: string;
|
|
840
|
+
text: string;
|
|
841
|
+
textHover: string;
|
|
842
|
+
};
|
|
843
|
+
secondary: {
|
|
844
|
+
background: string;
|
|
845
|
+
backgroundHover: string;
|
|
846
|
+
border: string;
|
|
847
|
+
borderHover: string;
|
|
848
|
+
text: string;
|
|
849
|
+
textHover: string;
|
|
850
|
+
};
|
|
851
|
+
};
|
|
852
|
+
input: {
|
|
853
|
+
background: string;
|
|
854
|
+
border: string;
|
|
855
|
+
borderFocus: string;
|
|
856
|
+
text: string;
|
|
857
|
+
placeholder: string;
|
|
858
|
+
};
|
|
859
|
+
text: {
|
|
860
|
+
primary: string;
|
|
861
|
+
secondary: string;
|
|
862
|
+
disabled: string;
|
|
863
|
+
};
|
|
864
|
+
divider: string;
|
|
865
|
+
error: {
|
|
866
|
+
main: string;
|
|
867
|
+
light: string;
|
|
868
|
+
dark: string;
|
|
869
|
+
};
|
|
870
|
+
warning: {
|
|
871
|
+
main: string;
|
|
872
|
+
light: string;
|
|
873
|
+
dark: string;
|
|
874
|
+
};
|
|
875
|
+
success: {
|
|
876
|
+
main: string;
|
|
877
|
+
light: string;
|
|
878
|
+
dark: string;
|
|
879
|
+
};
|
|
880
|
+
info: {
|
|
881
|
+
main: string;
|
|
882
|
+
light: string;
|
|
883
|
+
dark: string;
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
declare const defaultCrudifyColors: CrudifyThemeColors;
|
|
887
|
+
declare const createCrudifyTheme: (colors?: Partial<CrudifyThemeColors>) => Theme;
|
|
888
|
+
declare const getCrudifyThemeFromCookies: () => Theme;
|
|
889
|
+
|
|
890
|
+
export { type ApiError, type BoxScreenType, type CrudifyApiResponse, CrudifyLogin, type CrudifyLoginConfig, type CrudifyLoginProps, type CrudifyLoginTranslations, type CrudifyThemeColors, type CrudifyTransactionResponse, ERROR_CODES, ERROR_SEVERITY_MAP, type ErrorCode, type ErrorSeverity, type ErrorTranslationConfig, type ForgotPasswordRequest, GlobalNotificationProvider, type GlobalNotificationProviderProps, type JwtPayload, LoginComponent, type LoginRequest, type LoginResponse, type LoginResult, type Notification, type NotificationOptions, type NotificationSeverity, POLICY_ACTIONS, PREFERRED_POLICY_ORDER, type ParsedError, Policies, type PolicyAction, ProtectedRoute, type ProtectedRouteProps, type ResetPasswordRequest, type SessionConfig, SessionDebugInfo, SessionManager, SessionProvider, type SessionProviderProps, type SessionState, SessionStatus, type StorageType, type TokenData, TokenStorage, type TransactionResponseData, type UseAuthReturn, type UseDataReturn, type UseSessionOptions, type UseUserDataOptions, type UseUserDataReturn, type UserData, type UserLoginData, type UserProfile, UserProfileDisplay, type ValidateCodeRequest, type ValidationError, createCrudifyTheme, createErrorTranslator, decodeJwtSafely, defaultCrudifyColors, getCookie, getCrudifyThemeFromCookies, getCurrentUserEmail, getErrorMessage, handleCrudifyError, isTokenExpired, parseApiError, parseJavaScriptError, parseTransactionError, secureLocalStorage, secureSessionStorage, translateError, translateErrorCode, translateErrorCodes, useAuth, useCrudifyWithNotifications, useData, useGlobalNotification, useSession, useSessionContext, useUserData, useUserProfile };
|
package/dist/index.js
CHANGED
|
@@ -46,10 +46,13 @@ __export(index_exports, {
|
|
|
46
46
|
SessionStatus: () => SessionStatus,
|
|
47
47
|
TokenStorage: () => TokenStorage,
|
|
48
48
|
UserProfileDisplay: () => UserProfileDisplay_default,
|
|
49
|
+
createCrudifyTheme: () => createCrudifyTheme,
|
|
49
50
|
createErrorTranslator: () => createErrorTranslator,
|
|
50
51
|
crudify: () => import_crudify_browser7.default,
|
|
51
52
|
decodeJwtSafely: () => decodeJwtSafely,
|
|
53
|
+
defaultCrudifyColors: () => defaultCrudifyColors,
|
|
52
54
|
getCookie: () => getCookie,
|
|
55
|
+
getCrudifyThemeFromCookies: () => getCrudifyThemeFromCookies,
|
|
53
56
|
getCurrentUserEmail: () => getCurrentUserEmail,
|
|
54
57
|
getErrorMessage: () => getErrorMessage,
|
|
55
58
|
handleCrudifyError: () => handleCrudifyError,
|
|
@@ -1675,6 +1678,8 @@ function InnerSessionProvider({
|
|
|
1675
1678
|
const cookieEnv = getCookie("environment");
|
|
1676
1679
|
const cookieAppName = getCookie("appName");
|
|
1677
1680
|
const cookieLoginActions = getCookie("loginActions");
|
|
1681
|
+
const cookieLogo = getCookie("logo");
|
|
1682
|
+
const cookieColors = getCookie("colors");
|
|
1678
1683
|
if (cookieApiKey) {
|
|
1679
1684
|
publicApiKey = cookieApiKey;
|
|
1680
1685
|
configSource = "cookies";
|
|
@@ -1689,6 +1694,16 @@ function InnerSessionProvider({
|
|
|
1689
1694
|
const decodedActions = decodeURIComponent(cookieLoginActions);
|
|
1690
1695
|
loginActions = decodedActions.split(",").map((s) => s.trim()).filter(Boolean);
|
|
1691
1696
|
}
|
|
1697
|
+
if (cookieLogo) logo = decodeURIComponent(cookieLogo);
|
|
1698
|
+
if (cookieColors) {
|
|
1699
|
+
try {
|
|
1700
|
+
const decodedColors = decodeURIComponent(cookieColors);
|
|
1701
|
+
colors = JSON.parse(decodedColors);
|
|
1702
|
+
} catch (error) {
|
|
1703
|
+
console.error("Error parsing colors from cookie:", error);
|
|
1704
|
+
colors = {};
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1692
1707
|
}
|
|
1693
1708
|
return {
|
|
1694
1709
|
publicApiKey,
|
|
@@ -2920,6 +2935,226 @@ var CrudifyInitializer = ({ children, fallback }) => {
|
|
|
2920
2935
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children });
|
|
2921
2936
|
};
|
|
2922
2937
|
|
|
2938
|
+
// src/core/theme.ts
|
|
2939
|
+
var import_styles = require("@mui/material/styles");
|
|
2940
|
+
var defaultCrudifyColors = {
|
|
2941
|
+
primary: {
|
|
2942
|
+
main: "#c2d66c",
|
|
2943
|
+
light: "#d4e289",
|
|
2944
|
+
dark: "#a8c248",
|
|
2945
|
+
contrastText: "#1a1a1a"
|
|
2946
|
+
},
|
|
2947
|
+
secondary: {
|
|
2948
|
+
main: "#6cc2d6",
|
|
2949
|
+
light: "#89d4e2",
|
|
2950
|
+
dark: "#48a8c2",
|
|
2951
|
+
contrastText: "#ffffff"
|
|
2952
|
+
},
|
|
2953
|
+
background: {
|
|
2954
|
+
default: "#f8faf4",
|
|
2955
|
+
paper: "#ffffff",
|
|
2956
|
+
light: "#e8f0d8"
|
|
2957
|
+
},
|
|
2958
|
+
button: {
|
|
2959
|
+
primary: {
|
|
2960
|
+
background: "#c2d66c",
|
|
2961
|
+
backgroundHover: "#a8c248",
|
|
2962
|
+
border: "#a8c248",
|
|
2963
|
+
borderHover: "#8fb03d",
|
|
2964
|
+
text: "#1a1a1a",
|
|
2965
|
+
textHover: "#1a1a1a"
|
|
2966
|
+
},
|
|
2967
|
+
secondary: {
|
|
2968
|
+
background: "transparent",
|
|
2969
|
+
backgroundHover: "#f8faf4",
|
|
2970
|
+
border: "#c2d66c",
|
|
2971
|
+
borderHover: "#a8c248",
|
|
2972
|
+
text: "#c2d66c",
|
|
2973
|
+
textHover: "#a8c248"
|
|
2974
|
+
}
|
|
2975
|
+
},
|
|
2976
|
+
input: {
|
|
2977
|
+
background: "#ffffff",
|
|
2978
|
+
border: "#d1d5db",
|
|
2979
|
+
borderFocus: "#c2d66c",
|
|
2980
|
+
text: "#1a1a1a",
|
|
2981
|
+
placeholder: "#6b7280"
|
|
2982
|
+
},
|
|
2983
|
+
text: {
|
|
2984
|
+
primary: "#1a1a1a",
|
|
2985
|
+
secondary: "#4b5563",
|
|
2986
|
+
disabled: "#9ca3af"
|
|
2987
|
+
},
|
|
2988
|
+
divider: "#e5e7eb",
|
|
2989
|
+
error: {
|
|
2990
|
+
main: "#ef4444",
|
|
2991
|
+
light: "#f87171",
|
|
2992
|
+
dark: "#dc2626"
|
|
2993
|
+
},
|
|
2994
|
+
warning: {
|
|
2995
|
+
main: "#f59e0b",
|
|
2996
|
+
light: "#fbbf24",
|
|
2997
|
+
dark: "#d97706"
|
|
2998
|
+
},
|
|
2999
|
+
success: {
|
|
3000
|
+
main: "#10b981",
|
|
3001
|
+
light: "#34d399",
|
|
3002
|
+
dark: "#059669"
|
|
3003
|
+
},
|
|
3004
|
+
info: {
|
|
3005
|
+
main: "#3b82f6",
|
|
3006
|
+
light: "#60a5fa",
|
|
3007
|
+
dark: "#2563eb"
|
|
3008
|
+
}
|
|
3009
|
+
};
|
|
3010
|
+
var createCrudifyTheme = (colors = {}) => {
|
|
3011
|
+
const themeColors = { ...defaultCrudifyColors, ...colors };
|
|
3012
|
+
return (0, import_styles.createTheme)({
|
|
3013
|
+
palette: {
|
|
3014
|
+
primary: {
|
|
3015
|
+
main: themeColors.primary.main,
|
|
3016
|
+
light: themeColors.primary.light,
|
|
3017
|
+
dark: themeColors.primary.dark,
|
|
3018
|
+
contrastText: themeColors.primary.contrastText
|
|
3019
|
+
},
|
|
3020
|
+
secondary: {
|
|
3021
|
+
main: themeColors.secondary.main,
|
|
3022
|
+
light: themeColors.secondary.light,
|
|
3023
|
+
dark: themeColors.secondary.dark,
|
|
3024
|
+
contrastText: themeColors.secondary.contrastText
|
|
3025
|
+
},
|
|
3026
|
+
background: {
|
|
3027
|
+
default: themeColors.background.default,
|
|
3028
|
+
paper: themeColors.background.paper
|
|
3029
|
+
},
|
|
3030
|
+
text: {
|
|
3031
|
+
primary: themeColors.text.primary,
|
|
3032
|
+
secondary: themeColors.text.secondary,
|
|
3033
|
+
disabled: themeColors.text.disabled
|
|
3034
|
+
},
|
|
3035
|
+
divider: themeColors.divider,
|
|
3036
|
+
error: {
|
|
3037
|
+
main: themeColors.error.main,
|
|
3038
|
+
light: themeColors.error.light,
|
|
3039
|
+
dark: themeColors.error.dark
|
|
3040
|
+
},
|
|
3041
|
+
warning: {
|
|
3042
|
+
main: themeColors.warning.main,
|
|
3043
|
+
light: themeColors.warning.light,
|
|
3044
|
+
dark: themeColors.warning.dark
|
|
3045
|
+
},
|
|
3046
|
+
success: {
|
|
3047
|
+
main: themeColors.success.main,
|
|
3048
|
+
light: themeColors.success.light,
|
|
3049
|
+
dark: themeColors.success.dark
|
|
3050
|
+
},
|
|
3051
|
+
info: {
|
|
3052
|
+
main: themeColors.info.main,
|
|
3053
|
+
light: themeColors.info.light,
|
|
3054
|
+
dark: themeColors.info.dark
|
|
3055
|
+
}
|
|
3056
|
+
},
|
|
3057
|
+
components: {
|
|
3058
|
+
MuiButton: {
|
|
3059
|
+
styleOverrides: {
|
|
3060
|
+
contained: {
|
|
3061
|
+
backgroundColor: themeColors.button.primary.background,
|
|
3062
|
+
color: themeColors.button.primary.text,
|
|
3063
|
+
border: `1px solid ${themeColors.button.primary.border}`,
|
|
3064
|
+
"&:hover": {
|
|
3065
|
+
backgroundColor: themeColors.button.primary.backgroundHover,
|
|
3066
|
+
borderColor: themeColors.button.primary.borderHover,
|
|
3067
|
+
color: themeColors.button.primary.textHover
|
|
3068
|
+
}
|
|
3069
|
+
},
|
|
3070
|
+
outlined: {
|
|
3071
|
+
backgroundColor: themeColors.button.secondary.background,
|
|
3072
|
+
color: themeColors.button.secondary.text,
|
|
3073
|
+
border: `1px solid ${themeColors.button.secondary.border}`,
|
|
3074
|
+
"&:hover": {
|
|
3075
|
+
backgroundColor: themeColors.button.secondary.backgroundHover,
|
|
3076
|
+
borderColor: themeColors.button.secondary.borderHover,
|
|
3077
|
+
color: themeColors.button.secondary.textHover
|
|
3078
|
+
}
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
},
|
|
3082
|
+
MuiTextField: {
|
|
3083
|
+
styleOverrides: {
|
|
3084
|
+
root: {
|
|
3085
|
+
"& .MuiOutlinedInput-root": {
|
|
3086
|
+
backgroundColor: themeColors.input.background,
|
|
3087
|
+
"& fieldset": {
|
|
3088
|
+
borderColor: themeColors.input.border
|
|
3089
|
+
},
|
|
3090
|
+
"&:hover fieldset": {
|
|
3091
|
+
borderColor: themeColors.input.borderFocus
|
|
3092
|
+
},
|
|
3093
|
+
"&.Mui-focused fieldset": {
|
|
3094
|
+
borderColor: themeColors.input.borderFocus
|
|
3095
|
+
},
|
|
3096
|
+
"& input": {
|
|
3097
|
+
color: themeColors.input.text
|
|
3098
|
+
},
|
|
3099
|
+
"& input::placeholder": {
|
|
3100
|
+
color: themeColors.input.placeholder,
|
|
3101
|
+
opacity: 1
|
|
3102
|
+
}
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3105
|
+
}
|
|
3106
|
+
},
|
|
3107
|
+
MuiInputBase: {
|
|
3108
|
+
styleOverrides: {
|
|
3109
|
+
input: {
|
|
3110
|
+
"&::placeholder": {
|
|
3111
|
+
color: themeColors.input.placeholder,
|
|
3112
|
+
opacity: 1
|
|
3113
|
+
}
|
|
3114
|
+
}
|
|
3115
|
+
}
|
|
3116
|
+
},
|
|
3117
|
+
MuiTypography: {
|
|
3118
|
+
styleOverrides: {
|
|
3119
|
+
h6: {
|
|
3120
|
+
color: themeColors.text.primary
|
|
3121
|
+
}
|
|
3122
|
+
}
|
|
3123
|
+
}
|
|
3124
|
+
},
|
|
3125
|
+
typography: {
|
|
3126
|
+
fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif'
|
|
3127
|
+
}
|
|
3128
|
+
});
|
|
3129
|
+
};
|
|
3130
|
+
var getCrudifyThemeFromCookies = () => {
|
|
3131
|
+
let themeColors = {};
|
|
3132
|
+
if (typeof document !== "undefined") {
|
|
3133
|
+
try {
|
|
3134
|
+
const colorsCookie = document.cookie.split("; ").find((row) => row.startsWith("colors="));
|
|
3135
|
+
if (colorsCookie) {
|
|
3136
|
+
const decodedColors = decodeURIComponent(colorsCookie.split("=")[1]);
|
|
3137
|
+
const parsedColors = JSON.parse(decodedColors);
|
|
3138
|
+
if (parsedColors.primaryColor) {
|
|
3139
|
+
themeColors.primary = {
|
|
3140
|
+
...defaultCrudifyColors.primary,
|
|
3141
|
+
main: parsedColors.primaryColor
|
|
3142
|
+
};
|
|
3143
|
+
}
|
|
3144
|
+
if (parsedColors.bgColor) {
|
|
3145
|
+
themeColors.background = {
|
|
3146
|
+
...defaultCrudifyColors.background,
|
|
3147
|
+
default: parsedColors.bgColor
|
|
3148
|
+
};
|
|
3149
|
+
}
|
|
3150
|
+
}
|
|
3151
|
+
} catch (error) {
|
|
3152
|
+
console.error("Error parsing colors from cookie:", error);
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3155
|
+
return createCrudifyTheme(themeColors);
|
|
3156
|
+
};
|
|
3157
|
+
|
|
2923
3158
|
// src/components/CrudifyLogin/index.tsx
|
|
2924
3159
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2925
3160
|
var CrudifyLoginInternal = ({
|
|
@@ -2996,8 +3231,7 @@ var CrudifyLoginInternal = ({
|
|
|
2996
3231
|
component: "h1",
|
|
2997
3232
|
sx: {
|
|
2998
3233
|
textAlign: "center",
|
|
2999
|
-
mb: 2
|
|
3000
|
-
color: config.colors?.primaryColor || "#1066BA"
|
|
3234
|
+
mb: 2
|
|
3001
3235
|
},
|
|
3002
3236
|
children: config.appName
|
|
3003
3237
|
}
|
|
@@ -3014,7 +3248,8 @@ var CrudifyLogin = ({
|
|
|
3014
3248
|
...props
|
|
3015
3249
|
}) => {
|
|
3016
3250
|
const { config } = useSessionContext();
|
|
3017
|
-
|
|
3251
|
+
const theme = getCrudifyThemeFromCookies();
|
|
3252
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_material7.ThemeProvider, { theme, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(I18nProvider, { translations, translationsUrl, language, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CrudifyProvider, { config, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(LoginStateProvider, { config, initialScreen, autoReadFromCookies, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CrudifyLoginInternal, { ...props }) }) }) }) });
|
|
3018
3253
|
};
|
|
3019
3254
|
var CrudifyLogin_default = CrudifyLogin;
|
|
3020
3255
|
|
|
@@ -4907,10 +5142,13 @@ var useCrudifyWithNotifications = (options = {}) => {
|
|
|
4907
5142
|
SessionStatus,
|
|
4908
5143
|
TokenStorage,
|
|
4909
5144
|
UserProfileDisplay,
|
|
5145
|
+
createCrudifyTheme,
|
|
4910
5146
|
createErrorTranslator,
|
|
4911
5147
|
crudify,
|
|
4912
5148
|
decodeJwtSafely,
|
|
5149
|
+
defaultCrudifyColors,
|
|
4913
5150
|
getCookie,
|
|
5151
|
+
getCrudifyThemeFromCookies,
|
|
4914
5152
|
getCurrentUserEmail,
|
|
4915
5153
|
getErrorMessage,
|
|
4916
5154
|
handleCrudifyError,
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { default as default2 } from "@nocios/crudify-browser";
|
|
|
3
3
|
export * from "@nocios/crudify-browser";
|
|
4
4
|
|
|
5
5
|
// src/components/CrudifyLogin/index.tsx
|
|
6
|
-
import { Box as Box7, Typography as Typography6 } from "@mui/material";
|
|
6
|
+
import { Box as Box7, Typography as Typography6, ThemeProvider } from "@mui/material";
|
|
7
7
|
|
|
8
8
|
// src/components/CrudifyLogin/context/I18nProvider.tsx
|
|
9
9
|
import { createContext, useContext, useMemo } from "react";
|
|
@@ -1602,6 +1602,8 @@ function InnerSessionProvider({
|
|
|
1602
1602
|
const cookieEnv = getCookie("environment");
|
|
1603
1603
|
const cookieAppName = getCookie("appName");
|
|
1604
1604
|
const cookieLoginActions = getCookie("loginActions");
|
|
1605
|
+
const cookieLogo = getCookie("logo");
|
|
1606
|
+
const cookieColors = getCookie("colors");
|
|
1605
1607
|
if (cookieApiKey) {
|
|
1606
1608
|
publicApiKey = cookieApiKey;
|
|
1607
1609
|
configSource = "cookies";
|
|
@@ -1616,6 +1618,16 @@ function InnerSessionProvider({
|
|
|
1616
1618
|
const decodedActions = decodeURIComponent(cookieLoginActions);
|
|
1617
1619
|
loginActions = decodedActions.split(",").map((s) => s.trim()).filter(Boolean);
|
|
1618
1620
|
}
|
|
1621
|
+
if (cookieLogo) logo = decodeURIComponent(cookieLogo);
|
|
1622
|
+
if (cookieColors) {
|
|
1623
|
+
try {
|
|
1624
|
+
const decodedColors = decodeURIComponent(cookieColors);
|
|
1625
|
+
colors = JSON.parse(decodedColors);
|
|
1626
|
+
} catch (error) {
|
|
1627
|
+
console.error("Error parsing colors from cookie:", error);
|
|
1628
|
+
colors = {};
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1619
1631
|
}
|
|
1620
1632
|
return {
|
|
1621
1633
|
publicApiKey,
|
|
@@ -2847,6 +2859,226 @@ var CrudifyInitializer = ({ children, fallback }) => {
|
|
|
2847
2859
|
return /* @__PURE__ */ jsx10(Fragment6, { children });
|
|
2848
2860
|
};
|
|
2849
2861
|
|
|
2862
|
+
// src/core/theme.ts
|
|
2863
|
+
import { createTheme } from "@mui/material/styles";
|
|
2864
|
+
var defaultCrudifyColors = {
|
|
2865
|
+
primary: {
|
|
2866
|
+
main: "#c2d66c",
|
|
2867
|
+
light: "#d4e289",
|
|
2868
|
+
dark: "#a8c248",
|
|
2869
|
+
contrastText: "#1a1a1a"
|
|
2870
|
+
},
|
|
2871
|
+
secondary: {
|
|
2872
|
+
main: "#6cc2d6",
|
|
2873
|
+
light: "#89d4e2",
|
|
2874
|
+
dark: "#48a8c2",
|
|
2875
|
+
contrastText: "#ffffff"
|
|
2876
|
+
},
|
|
2877
|
+
background: {
|
|
2878
|
+
default: "#f8faf4",
|
|
2879
|
+
paper: "#ffffff",
|
|
2880
|
+
light: "#e8f0d8"
|
|
2881
|
+
},
|
|
2882
|
+
button: {
|
|
2883
|
+
primary: {
|
|
2884
|
+
background: "#c2d66c",
|
|
2885
|
+
backgroundHover: "#a8c248",
|
|
2886
|
+
border: "#a8c248",
|
|
2887
|
+
borderHover: "#8fb03d",
|
|
2888
|
+
text: "#1a1a1a",
|
|
2889
|
+
textHover: "#1a1a1a"
|
|
2890
|
+
},
|
|
2891
|
+
secondary: {
|
|
2892
|
+
background: "transparent",
|
|
2893
|
+
backgroundHover: "#f8faf4",
|
|
2894
|
+
border: "#c2d66c",
|
|
2895
|
+
borderHover: "#a8c248",
|
|
2896
|
+
text: "#c2d66c",
|
|
2897
|
+
textHover: "#a8c248"
|
|
2898
|
+
}
|
|
2899
|
+
},
|
|
2900
|
+
input: {
|
|
2901
|
+
background: "#ffffff",
|
|
2902
|
+
border: "#d1d5db",
|
|
2903
|
+
borderFocus: "#c2d66c",
|
|
2904
|
+
text: "#1a1a1a",
|
|
2905
|
+
placeholder: "#6b7280"
|
|
2906
|
+
},
|
|
2907
|
+
text: {
|
|
2908
|
+
primary: "#1a1a1a",
|
|
2909
|
+
secondary: "#4b5563",
|
|
2910
|
+
disabled: "#9ca3af"
|
|
2911
|
+
},
|
|
2912
|
+
divider: "#e5e7eb",
|
|
2913
|
+
error: {
|
|
2914
|
+
main: "#ef4444",
|
|
2915
|
+
light: "#f87171",
|
|
2916
|
+
dark: "#dc2626"
|
|
2917
|
+
},
|
|
2918
|
+
warning: {
|
|
2919
|
+
main: "#f59e0b",
|
|
2920
|
+
light: "#fbbf24",
|
|
2921
|
+
dark: "#d97706"
|
|
2922
|
+
},
|
|
2923
|
+
success: {
|
|
2924
|
+
main: "#10b981",
|
|
2925
|
+
light: "#34d399",
|
|
2926
|
+
dark: "#059669"
|
|
2927
|
+
},
|
|
2928
|
+
info: {
|
|
2929
|
+
main: "#3b82f6",
|
|
2930
|
+
light: "#60a5fa",
|
|
2931
|
+
dark: "#2563eb"
|
|
2932
|
+
}
|
|
2933
|
+
};
|
|
2934
|
+
var createCrudifyTheme = (colors = {}) => {
|
|
2935
|
+
const themeColors = { ...defaultCrudifyColors, ...colors };
|
|
2936
|
+
return createTheme({
|
|
2937
|
+
palette: {
|
|
2938
|
+
primary: {
|
|
2939
|
+
main: themeColors.primary.main,
|
|
2940
|
+
light: themeColors.primary.light,
|
|
2941
|
+
dark: themeColors.primary.dark,
|
|
2942
|
+
contrastText: themeColors.primary.contrastText
|
|
2943
|
+
},
|
|
2944
|
+
secondary: {
|
|
2945
|
+
main: themeColors.secondary.main,
|
|
2946
|
+
light: themeColors.secondary.light,
|
|
2947
|
+
dark: themeColors.secondary.dark,
|
|
2948
|
+
contrastText: themeColors.secondary.contrastText
|
|
2949
|
+
},
|
|
2950
|
+
background: {
|
|
2951
|
+
default: themeColors.background.default,
|
|
2952
|
+
paper: themeColors.background.paper
|
|
2953
|
+
},
|
|
2954
|
+
text: {
|
|
2955
|
+
primary: themeColors.text.primary,
|
|
2956
|
+
secondary: themeColors.text.secondary,
|
|
2957
|
+
disabled: themeColors.text.disabled
|
|
2958
|
+
},
|
|
2959
|
+
divider: themeColors.divider,
|
|
2960
|
+
error: {
|
|
2961
|
+
main: themeColors.error.main,
|
|
2962
|
+
light: themeColors.error.light,
|
|
2963
|
+
dark: themeColors.error.dark
|
|
2964
|
+
},
|
|
2965
|
+
warning: {
|
|
2966
|
+
main: themeColors.warning.main,
|
|
2967
|
+
light: themeColors.warning.light,
|
|
2968
|
+
dark: themeColors.warning.dark
|
|
2969
|
+
},
|
|
2970
|
+
success: {
|
|
2971
|
+
main: themeColors.success.main,
|
|
2972
|
+
light: themeColors.success.light,
|
|
2973
|
+
dark: themeColors.success.dark
|
|
2974
|
+
},
|
|
2975
|
+
info: {
|
|
2976
|
+
main: themeColors.info.main,
|
|
2977
|
+
light: themeColors.info.light,
|
|
2978
|
+
dark: themeColors.info.dark
|
|
2979
|
+
}
|
|
2980
|
+
},
|
|
2981
|
+
components: {
|
|
2982
|
+
MuiButton: {
|
|
2983
|
+
styleOverrides: {
|
|
2984
|
+
contained: {
|
|
2985
|
+
backgroundColor: themeColors.button.primary.background,
|
|
2986
|
+
color: themeColors.button.primary.text,
|
|
2987
|
+
border: `1px solid ${themeColors.button.primary.border}`,
|
|
2988
|
+
"&:hover": {
|
|
2989
|
+
backgroundColor: themeColors.button.primary.backgroundHover,
|
|
2990
|
+
borderColor: themeColors.button.primary.borderHover,
|
|
2991
|
+
color: themeColors.button.primary.textHover
|
|
2992
|
+
}
|
|
2993
|
+
},
|
|
2994
|
+
outlined: {
|
|
2995
|
+
backgroundColor: themeColors.button.secondary.background,
|
|
2996
|
+
color: themeColors.button.secondary.text,
|
|
2997
|
+
border: `1px solid ${themeColors.button.secondary.border}`,
|
|
2998
|
+
"&:hover": {
|
|
2999
|
+
backgroundColor: themeColors.button.secondary.backgroundHover,
|
|
3000
|
+
borderColor: themeColors.button.secondary.borderHover,
|
|
3001
|
+
color: themeColors.button.secondary.textHover
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
}
|
|
3005
|
+
},
|
|
3006
|
+
MuiTextField: {
|
|
3007
|
+
styleOverrides: {
|
|
3008
|
+
root: {
|
|
3009
|
+
"& .MuiOutlinedInput-root": {
|
|
3010
|
+
backgroundColor: themeColors.input.background,
|
|
3011
|
+
"& fieldset": {
|
|
3012
|
+
borderColor: themeColors.input.border
|
|
3013
|
+
},
|
|
3014
|
+
"&:hover fieldset": {
|
|
3015
|
+
borderColor: themeColors.input.borderFocus
|
|
3016
|
+
},
|
|
3017
|
+
"&.Mui-focused fieldset": {
|
|
3018
|
+
borderColor: themeColors.input.borderFocus
|
|
3019
|
+
},
|
|
3020
|
+
"& input": {
|
|
3021
|
+
color: themeColors.input.text
|
|
3022
|
+
},
|
|
3023
|
+
"& input::placeholder": {
|
|
3024
|
+
color: themeColors.input.placeholder,
|
|
3025
|
+
opacity: 1
|
|
3026
|
+
}
|
|
3027
|
+
}
|
|
3028
|
+
}
|
|
3029
|
+
}
|
|
3030
|
+
},
|
|
3031
|
+
MuiInputBase: {
|
|
3032
|
+
styleOverrides: {
|
|
3033
|
+
input: {
|
|
3034
|
+
"&::placeholder": {
|
|
3035
|
+
color: themeColors.input.placeholder,
|
|
3036
|
+
opacity: 1
|
|
3037
|
+
}
|
|
3038
|
+
}
|
|
3039
|
+
}
|
|
3040
|
+
},
|
|
3041
|
+
MuiTypography: {
|
|
3042
|
+
styleOverrides: {
|
|
3043
|
+
h6: {
|
|
3044
|
+
color: themeColors.text.primary
|
|
3045
|
+
}
|
|
3046
|
+
}
|
|
3047
|
+
}
|
|
3048
|
+
},
|
|
3049
|
+
typography: {
|
|
3050
|
+
fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif'
|
|
3051
|
+
}
|
|
3052
|
+
});
|
|
3053
|
+
};
|
|
3054
|
+
var getCrudifyThemeFromCookies = () => {
|
|
3055
|
+
let themeColors = {};
|
|
3056
|
+
if (typeof document !== "undefined") {
|
|
3057
|
+
try {
|
|
3058
|
+
const colorsCookie = document.cookie.split("; ").find((row) => row.startsWith("colors="));
|
|
3059
|
+
if (colorsCookie) {
|
|
3060
|
+
const decodedColors = decodeURIComponent(colorsCookie.split("=")[1]);
|
|
3061
|
+
const parsedColors = JSON.parse(decodedColors);
|
|
3062
|
+
if (parsedColors.primaryColor) {
|
|
3063
|
+
themeColors.primary = {
|
|
3064
|
+
...defaultCrudifyColors.primary,
|
|
3065
|
+
main: parsedColors.primaryColor
|
|
3066
|
+
};
|
|
3067
|
+
}
|
|
3068
|
+
if (parsedColors.bgColor) {
|
|
3069
|
+
themeColors.background = {
|
|
3070
|
+
...defaultCrudifyColors.background,
|
|
3071
|
+
default: parsedColors.bgColor
|
|
3072
|
+
};
|
|
3073
|
+
}
|
|
3074
|
+
}
|
|
3075
|
+
} catch (error) {
|
|
3076
|
+
console.error("Error parsing colors from cookie:", error);
|
|
3077
|
+
}
|
|
3078
|
+
}
|
|
3079
|
+
return createCrudifyTheme(themeColors);
|
|
3080
|
+
};
|
|
3081
|
+
|
|
2850
3082
|
// src/components/CrudifyLogin/index.tsx
|
|
2851
3083
|
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2852
3084
|
var CrudifyLoginInternal = ({
|
|
@@ -2923,8 +3155,7 @@ var CrudifyLoginInternal = ({
|
|
|
2923
3155
|
component: "h1",
|
|
2924
3156
|
sx: {
|
|
2925
3157
|
textAlign: "center",
|
|
2926
|
-
mb: 2
|
|
2927
|
-
color: config.colors?.primaryColor || "#1066BA"
|
|
3158
|
+
mb: 2
|
|
2928
3159
|
},
|
|
2929
3160
|
children: config.appName
|
|
2930
3161
|
}
|
|
@@ -2941,7 +3172,8 @@ var CrudifyLogin = ({
|
|
|
2941
3172
|
...props
|
|
2942
3173
|
}) => {
|
|
2943
3174
|
const { config } = useSessionContext();
|
|
2944
|
-
|
|
3175
|
+
const theme = getCrudifyThemeFromCookies();
|
|
3176
|
+
return /* @__PURE__ */ jsx11(ThemeProvider, { theme, children: /* @__PURE__ */ jsx11(I18nProvider, { translations, translationsUrl, language, children: /* @__PURE__ */ jsx11(CrudifyProvider, { config, children: /* @__PURE__ */ jsx11(LoginStateProvider, { config, initialScreen, autoReadFromCookies, children: /* @__PURE__ */ jsx11(CrudifyLoginInternal, { ...props }) }) }) }) });
|
|
2945
3177
|
};
|
|
2946
3178
|
var CrudifyLogin_default = CrudifyLogin;
|
|
2947
3179
|
|
|
@@ -4892,10 +5124,13 @@ export {
|
|
|
4892
5124
|
SessionStatus,
|
|
4893
5125
|
TokenStorage,
|
|
4894
5126
|
UserProfileDisplay_default as UserProfileDisplay,
|
|
5127
|
+
createCrudifyTheme,
|
|
4895
5128
|
createErrorTranslator,
|
|
4896
5129
|
default2 as crudify,
|
|
4897
5130
|
decodeJwtSafely,
|
|
5131
|
+
defaultCrudifyColors,
|
|
4898
5132
|
getCookie,
|
|
5133
|
+
getCrudifyThemeFromCookies,
|
|
4899
5134
|
getCurrentUserEmail,
|
|
4900
5135
|
getErrorMessage,
|
|
4901
5136
|
handleCrudifyError,
|