@dashadmin/dash-admin-state 1.3.25 → 1.3.28

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 (70) hide show
  1. package/dist/DefaultThemeSettings.js +34 -1
  2. package/dist/defaults/defaultAuth.js +9 -1
  3. package/dist/defaults/defaultCommon.js +44 -1
  4. package/dist/defaults/defaultFormState.js +5 -1
  5. package/dist/defaults/defaultPage.js +9 -1
  6. package/dist/defaults/defaultSettings.js +51 -1
  7. package/dist/hooks/DashAdminStateSelectors.js +149 -1
  8. package/dist/hooks/useLocalStorage.js +69 -1
  9. package/dist/index.js +41 -691
  10. package/dist/redux/ReduxStoreAccesor.js +19 -1
  11. package/dist/redux/actions/ActionTypes.js +84 -1
  12. package/dist/redux/actions/Auth.js +6 -1
  13. package/dist/redux/actions/Common.js +51 -1
  14. package/dist/redux/actions/ComponentData.js +33 -1
  15. package/dist/redux/actions/Menu.js +5 -1
  16. package/dist/redux/actions/Page.js +7 -1
  17. package/dist/redux/actions/Resources.js +21 -1
  18. package/dist/redux/actions/Setting.js +90 -1
  19. package/dist/redux/actions/index.js +6 -1
  20. package/dist/redux/reducers/Auth.js +55 -1
  21. package/dist/redux/reducers/Common.js +134 -1
  22. package/dist/redux/reducers/ComponentData.js +59 -1
  23. package/dist/redux/reducers/FormData.js +32 -1
  24. package/dist/redux/reducers/Menu.js +22 -1
  25. package/dist/redux/reducers/Page.js +30 -1
  26. package/dist/redux/reducers/Resources.js +19 -1
  27. package/dist/redux/reducers/Settings.js +79 -1
  28. package/dist/redux/reducers/index.js +25 -1
  29. package/dist/redux/sagas/index.js +9 -1
  30. package/dist/redux/store/index.js +35 -1
  31. package/package.json +75 -57
  32. package/src/DefaultThemeSettings.tsx +33 -0
  33. package/src/defaults/defaultAuth.tsx +8 -0
  34. package/src/defaults/defaultCommon.tsx +55 -0
  35. package/src/defaults/defaultFormState.tsx +4 -0
  36. package/src/defaults/defaultPage.tsx +9 -0
  37. package/src/defaults/defaultSettings.tsx +61 -0
  38. package/src/hooks/DashAdminStateSelectors.tsx +142 -0
  39. package/src/hooks/useLocalStorage.tsx +79 -0
  40. package/src/index.tsx +34 -0
  41. package/src/redux/ReduxStoreAccesor.tsx +18 -0
  42. package/src/redux/actions/ActionTypes.tsx +47 -0
  43. package/src/redux/actions/Auth.tsx +5 -0
  44. package/src/redux/actions/Common.tsx +51 -0
  45. package/src/redux/actions/ComponentData.tsx +78 -0
  46. package/src/redux/actions/Menu.tsx +4 -0
  47. package/src/redux/actions/Page.tsx +6 -0
  48. package/src/redux/actions/Resources.tsx +19 -0
  49. package/src/redux/actions/Setting.tsx +91 -0
  50. package/src/redux/actions/index.tsx +7 -0
  51. package/src/redux/interfaces/IAuthState.tsx +7 -0
  52. package/src/redux/interfaces/ICommonState.tsx +25 -0
  53. package/src/redux/interfaces/IComponentData.tsx +32 -0
  54. package/src/redux/interfaces/IDASHAppState.tsx +53 -0
  55. package/src/redux/interfaces/IDashResourceGroupsIcons.tsx +5 -0
  56. package/src/redux/interfaces/IFormDataState.tsx +6 -0
  57. package/src/redux/interfaces/IPage.tsx +27 -0
  58. package/src/redux/interfaces/IResources.tsx +0 -0
  59. package/src/redux/interfaces/ISettings.tsx +27 -0
  60. package/src/redux/reducers/Auth.tsx +38 -0
  61. package/src/redux/reducers/Common.tsx +144 -0
  62. package/src/redux/reducers/ComponentData.tsx +52 -0
  63. package/src/redux/reducers/FormData.tsx +21 -0
  64. package/src/redux/reducers/Menu.tsx +27 -0
  65. package/src/redux/reducers/Page.tsx +17 -0
  66. package/src/redux/reducers/Resources.tsx +19 -0
  67. package/src/redux/reducers/Settings.tsx +78 -0
  68. package/src/redux/reducers/index.tsx +25 -0
  69. package/src/redux/sagas/index.tsx +8 -0
  70. package/src/redux/store/index.tsx +33 -0
@@ -1 +1,34 @@
1
- var N=Object.defineProperty;var Y=(L,A,T)=>A in L?N(L,A,{enumerable:!0,configurable:!0,writable:!0,value:T}):L[A]=T;var E=(L,A,T)=>Y(L,typeof A!="symbol"?A+"":A,T);class _{}E(_,"TAB_SIZE",992),E(_,"MOBILE_SIZE",575),E(_,"THEME_TYPE","THEME_TYPE"),E(_,"THEME_TYPE_LIGHT","light"),E(_,"THEME_TYPE_DARK","dark"),E(_,"THEME_TYPE_DASH_DEFAULT","light"),E(_,"THEME_TYPE_SEMI_DARK","THEME_TYPE_SEMI_DARK"),E(_,"THEME_COLOR","THEME_COLOR"),E(_,"LAYOUT_TYPE","LAYOUT_TYPE"),E(_,"LAYOUT_TYPE_FRAMED","framed-layout"),E(_,"LAYOUT_TYPE_BOXED","boxed-layout"),E(_,"LAYOUT_TYPE_FULL","full-layout"),E(_,"NAV_STYLE","NAV_STYLE"),E(_,"NAV_STYLE_FIXED","NAV_STYLE_FIXED"),E(_,"NAV_STYLE_MINI_SIDEBAR","NAV_STYLE_MINI_SIDEBAR"),E(_,"NAV_STYLE_DRAWER","NAV_STYLE_DRAWER"),E(_,"NAV_STYLE_NO_HEADER_MINI_SIDEBAR","NAV_STYLE_NO_HEADER_MINI_SIDEBAR"),E(_,"NAV_STYLE_NO_HEADER_EXPANDED_SIDEBAR","NAV_STYLE_NO_HEADER_EXPANDED_SIDEBAR"),E(_,"NAV_STYLE_DEFAULT_HORIZONTAL","NAV_STYLE_DEFAULT_HORIZONTAL"),E(_,"NAV_STYLE_DARK_HORIZONTAL","NAV_STYLE_DARK_HORIZONTAL"),E(_,"NAV_STYLE_INSIDE_HEADER_HORIZONTAL","NAV_STYLE_INSIDE_HEADER_HORIZONTAL"),E(_,"NAV_STYLE_BELOW_HEADER","NAV_STYLE_BELOW_HEADER"),E(_,"NAV_STYLE_ABOVE_HEADER","NAV_STYLE_ABOVE_HEADER"),E(_,"NAV_STYLE_COLLAPSABLE","NAV_STYLE_COLLAPSABLE"),E(_,"UPDATE_RTL_STATUS","UPDATE_RTL_STATUS");var O=_;export{O as default};
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ class DefaultThemeSettings {
5
+ }
6
+ __publicField(DefaultThemeSettings, "TAB_SIZE", 992);
7
+ __publicField(DefaultThemeSettings, "MOBILE_SIZE", 575);
8
+ __publicField(DefaultThemeSettings, "THEME_TYPE", "THEME_TYPE");
9
+ __publicField(DefaultThemeSettings, "THEME_TYPE_LIGHT", "light");
10
+ __publicField(DefaultThemeSettings, "THEME_TYPE_DARK", "dark");
11
+ __publicField(DefaultThemeSettings, "THEME_TYPE_DASH_DEFAULT", "light");
12
+ __publicField(DefaultThemeSettings, "THEME_TYPE_SEMI_DARK", "THEME_TYPE_SEMI_DARK");
13
+ __publicField(DefaultThemeSettings, "THEME_COLOR", "THEME_COLOR");
14
+ __publicField(DefaultThemeSettings, "LAYOUT_TYPE", "LAYOUT_TYPE");
15
+ __publicField(DefaultThemeSettings, "LAYOUT_TYPE_FRAMED", "framed-layout");
16
+ __publicField(DefaultThemeSettings, "LAYOUT_TYPE_BOXED", "boxed-layout");
17
+ __publicField(DefaultThemeSettings, "LAYOUT_TYPE_FULL", "full-layout");
18
+ __publicField(DefaultThemeSettings, "NAV_STYLE", "NAV_STYLE");
19
+ __publicField(DefaultThemeSettings, "NAV_STYLE_FIXED", "NAV_STYLE_FIXED");
20
+ __publicField(DefaultThemeSettings, "NAV_STYLE_MINI_SIDEBAR", "NAV_STYLE_MINI_SIDEBAR");
21
+ __publicField(DefaultThemeSettings, "NAV_STYLE_DRAWER", "NAV_STYLE_DRAWER");
22
+ __publicField(DefaultThemeSettings, "NAV_STYLE_NO_HEADER_MINI_SIDEBAR", "NAV_STYLE_NO_HEADER_MINI_SIDEBAR");
23
+ __publicField(DefaultThemeSettings, "NAV_STYLE_NO_HEADER_EXPANDED_SIDEBAR", "NAV_STYLE_NO_HEADER_EXPANDED_SIDEBAR");
24
+ __publicField(DefaultThemeSettings, "NAV_STYLE_DEFAULT_HORIZONTAL", "NAV_STYLE_DEFAULT_HORIZONTAL");
25
+ __publicField(DefaultThemeSettings, "NAV_STYLE_DARK_HORIZONTAL", "NAV_STYLE_DARK_HORIZONTAL");
26
+ __publicField(DefaultThemeSettings, "NAV_STYLE_INSIDE_HEADER_HORIZONTAL", "NAV_STYLE_INSIDE_HEADER_HORIZONTAL");
27
+ __publicField(DefaultThemeSettings, "NAV_STYLE_BELOW_HEADER", "NAV_STYLE_BELOW_HEADER");
28
+ __publicField(DefaultThemeSettings, "NAV_STYLE_ABOVE_HEADER", "NAV_STYLE_ABOVE_HEADER");
29
+ __publicField(DefaultThemeSettings, "NAV_STYLE_COLLAPSABLE", "NAV_STYLE_COLLAPSABLE");
30
+ __publicField(DefaultThemeSettings, "UPDATE_RTL_STATUS", "UPDATE_RTL_STATUS");
31
+ var DefaultThemeSettings_default = DefaultThemeSettings;
32
+ export {
33
+ DefaultThemeSettings_default as default
34
+ };
@@ -1 +1,9 @@
1
- const t={authenticated:!1,user:null,auth:null};var a=t;export{a as default};
1
+ const defaultAuth = {
2
+ authenticated: false,
3
+ user: null,
4
+ auth: null
5
+ };
6
+ var defaultAuth_default = defaultAuth;
7
+ export {
8
+ defaultAuth_default as default
9
+ };
@@ -1 +1,44 @@
1
- import{Fragment as o,jsx as e}from"react/jsx-runtime";const a={appPath:"/",error:"",loading:!1,message:"",navExpanded:!0,width:typeof window<"u"?window.innerWidth:1920,height:typeof window<"u"?window.innerHeight:1080,content_width:null,content_height:null,pathname:"/",componentsState:{},headerToolBar:null,headerToolBarReplace:!1,navSize:"small",panelSettings:{appName:"Dash App",horizontalLogo:e(o,{children:"\u{1F5A5}"}),squaredLogo:e(o,{children:"\u{1F5A5}"}),loginBackground:void 0,sidebarLargeWidth:255,sidebarSmallWidth:64,sidebarHorizontalHeight:120,logoVerticalMaxWidth:130,logoVerticalMaxHeight:130,logoHorizontalMaxWidth:200,logoHorizontalMaxHeight:60,paddingHorizontal:255,paddingVertical:120,sidebarPosition:"left"}};var i=a;export{i as default};
1
+ import { Fragment, jsx } from "react/jsx-runtime";
2
+ const defaultCommon = {
3
+ appPath: "/",
4
+ error: "",
5
+ loading: false,
6
+ message: "",
7
+ navExpanded: true,
8
+ width: typeof window !== "undefined" ? window.innerWidth : 1920,
9
+ height: typeof window !== "undefined" ? window.innerHeight : 1080,
10
+ content_width: null,
11
+ content_height: null,
12
+ pathname: "/",
13
+ componentsState: {},
14
+ headerToolBar: null,
15
+ headerToolBarReplace: false,
16
+ navSize: "small",
17
+ // Panel settings with sidebar dimensions
18
+ // These values can be overridden by CSS variables at runtime
19
+ panelSettings: {
20
+ // Branding
21
+ appName: "Dash App",
22
+ horizontalLogo: /* @__PURE__ */ jsx(Fragment, { children: "\u{1F5A5}" }),
23
+ squaredLogo: /* @__PURE__ */ jsx(Fragment, { children: "\u{1F5A5}" }),
24
+ loginBackground: void 0,
25
+ // Sidebar dimensions (can be overridden via CSS variables)
26
+ sidebarLargeWidth: 255,
27
+ sidebarSmallWidth: 64,
28
+ sidebarHorizontalHeight: 120,
29
+ // Logo dimensions
30
+ logoVerticalMaxWidth: 130,
31
+ logoVerticalMaxHeight: 130,
32
+ logoHorizontalMaxWidth: 200,
33
+ logoHorizontalMaxHeight: 60,
34
+ // Content padding (derived from sidebar)
35
+ paddingHorizontal: 255,
36
+ paddingVertical: 120,
37
+ // Position
38
+ sidebarPosition: "left"
39
+ }
40
+ };
41
+ var defaultCommon_default = defaultCommon;
42
+ export {
43
+ defaultCommon_default as default
44
+ };
@@ -1 +1,5 @@
1
- const t={};var e=t;export{e as default};
1
+ const defaultFormState = {};
2
+ var defaultFormState_default = defaultFormState;
3
+ export {
4
+ defaultFormState_default as default
5
+ };
@@ -1 +1,9 @@
1
- const t={title:"",icon:null,subTitle:""};var l=t;export{l as default};
1
+ const defaultPageSettings = {
2
+ title: "",
3
+ icon: null,
4
+ subTitle: ""
5
+ };
6
+ var defaultPage_default = defaultPageSettings;
7
+ export {
8
+ defaultPage_default as default
9
+ };
@@ -1 +1,51 @@
1
- import{DASHAdminSystemConstants as a}from"@dashadmin/dash-constants";const e={loading:!1,navStyle:a.panel.NAV_STYLE_FIXED,layoutType:a.panel.LAYOUT_TYPE_FULL,themeType:a.panel.THEME_TYPE_DARK,themeColor:"",isDirectionRTL:!1,layoutSettings:{sidebarLargeWidth:255,sidebarSmallWidth:64,sidebarHorizontalHeight:120,logoVerticalMaxWidth:130,logoVerticalMaxHeight:130,logoHorizontalMaxWidth:200,logoHorizontalMaxHeight:60,paddingHorizontal:255,paddingVertical:120,mobileBreakpoint:768,tabletBreakpoint:1024},locale:"es",availableLocales:[{locale:"es",languageId:"spanish",name:"Espa\xF1ol",icon:"es"},{locale:"en",languageId:"english",name:"English",icon:"en"}],translations:{}};var o=e;export{o as default};
1
+ import { DASHAdminSystemConstants } from "dash-constants";
2
+ const defaultSettings = {
3
+ // Loading state
4
+ loading: false,
5
+ // Navigation and layout
6
+ navStyle: DASHAdminSystemConstants.panel.NAV_STYLE_FIXED,
7
+ layoutType: DASHAdminSystemConstants.panel.LAYOUT_TYPE_FULL,
8
+ themeType: DASHAdminSystemConstants.panel.THEME_TYPE_DARK,
9
+ themeColor: "",
10
+ isDirectionRTL: false,
11
+ // Layout settings (dimensions, breakpoints, etc.)
12
+ layoutSettings: {
13
+ // Sidebar dimensions
14
+ sidebarLargeWidth: 255,
15
+ sidebarSmallWidth: 64,
16
+ sidebarHorizontalHeight: 120,
17
+ // Logo dimensions
18
+ logoVerticalMaxWidth: 130,
19
+ logoVerticalMaxHeight: 130,
20
+ logoHorizontalMaxWidth: 200,
21
+ logoHorizontalMaxHeight: 60,
22
+ // Content padding (based on sidebar)
23
+ paddingHorizontal: 255,
24
+ paddingVertical: 120,
25
+ // Breakpoints
26
+ mobileBreakpoint: 768,
27
+ tabletBreakpoint: 1024
28
+ },
29
+ // Localization
30
+ locale: "es",
31
+ availableLocales: [
32
+ {
33
+ locale: "es",
34
+ languageId: "spanish",
35
+ name: "Espa\xF1ol",
36
+ icon: "es"
37
+ },
38
+ {
39
+ locale: "en",
40
+ languageId: "english",
41
+ name: "English",
42
+ icon: "en"
43
+ }
44
+ ],
45
+ // Translations (populated by i18n provider)
46
+ translations: {}
47
+ };
48
+ var defaultSettings_default = defaultSettings;
49
+ export {
50
+ defaultSettings_default as default
51
+ };
@@ -1 +1,149 @@
1
- import{Fragment as r,jsx as s}from"react/jsx-runtime";import{useSelector as e}from"react-redux";import{useMemo as n}from"react";import{isEqual as t}from"lodash";const g=()=>e(o=>({navStyle:o.settings.navStyle,layoutType:o.settings.layoutType,themeType:o.settings.themeType,layoutSettings:o.settings.layoutSettings,navExpanded:o.common?.navExpanded??o.common?.navExpanded??!0,navSize:o.common.navSize,panelSettings:o.common.panelSettings}),t),h=()=>e(o=>({authenticated:o.auth.authenticated,user:o.auth.user}),t),x=()=>e(o=>({groupIcons:o.settings.groupIcons,locale:o.settings.locale,themeColor:o.settings.themeColor,availableLocales:o.settings.availableLocales,isDirectionRTL:o.settings.isDirectionRTL}),t),a=()=>e(o=>({appPath:o.common.appPath,width:o.common.width,height:o.common.height,headerToolBar:o.common.headerToolBar,panelSettings:o.common.panelSettings}),t),H=()=>e(o=>({title:o.page.title,icon:o.page.icon,subTitle:o.page.subTitle}),t),U=()=>e(o=>({items:o.resources.items}),t),l=()=>{const{panelSettings:o}=a();return n(()=>({horizontalLogo:o?.horizontalLogo||s(r,{}),squaredLogo:o?.squaredLogo||s(r,{}),loginBackground:o?.loginBackground}),[o])},D=()=>{const{panelSettings:o}=a();return n(()=>({sidebarPosition:o?.sidebarPosition||"left",sidebarLargeWidth:o?.sidebarLargeWidth||255,sidebarSmallWidth:o?.sidebarSmallWidth||60,sidebarHorizontalHeight:o?.sidebarHorizontalHeight||120,logoVerticalMaxWidth:o?.logoVerticalMaxWidth||130,logoVerticalMaxHeight:o?.logoVerticalMaxHeight||130,logoHorizontalMaxWidth:o?.logoHorizontalMaxWidth||200,logoHorizontalMaxHeight:o?.logoHorizontalMaxHeight||60,paddingHorizontal:o?.paddingHorizontal||255,paddingVertical:o?.paddingVertical||120,appName:o?.appName||"DASH"}),[o])},I=()=>{const o=g(),i=l();return n(()=>({...o,...i}),[o,i])},v=()=>e(o=>({navExpanded:o.common?.navExpanded??o.common?.navExpanded??!0,navSize:o.common.navSize,navStyle:o.settings.navStyle,layoutSettings:o.settings.layoutSettings}),t);export{h as useAuthState,a as useCommonState,g as useLayoutState,l as useLogoSettings,v as useNavigationState,H as usePageState,D as usePanelSettings,U as useResourcesState,x as useSettingsState,I as useThemeState};
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ import { Fragment, jsx } from "react/jsx-runtime";
18
+ import { useSelector } from "react-redux";
19
+ import { useMemo } from "react";
20
+ import { isEqual } from "lodash";
21
+ const useLayoutState = () => {
22
+ return useSelector(
23
+ (state) => {
24
+ var _a, _b, _c, _d;
25
+ return {
26
+ navStyle: state.settings.navStyle,
27
+ layoutType: state.settings.layoutType,
28
+ themeType: state.settings.themeType,
29
+ layoutSettings: state.settings.layoutSettings,
30
+ navExpanded: (_d = (_c = (_a = state.common) == null ? void 0 : _a.navExpanded) != null ? _c : (_b = state.common) == null ? void 0 : _b.navExpanded) != null ? _d : true,
31
+ navSize: state.common.navSize,
32
+ panelSettings: state.common.panelSettings
33
+ };
34
+ },
35
+ isEqual
36
+ );
37
+ };
38
+ const useAuthState = () => {
39
+ return useSelector(
40
+ (state) => ({
41
+ authenticated: state.auth.authenticated,
42
+ user: state.auth.user
43
+ }),
44
+ isEqual
45
+ );
46
+ };
47
+ const useSettingsState = () => {
48
+ return useSelector(
49
+ (state) => ({
50
+ groupIcons: state.settings.groupIcons,
51
+ locale: state.settings.locale,
52
+ themeColor: state.settings.themeColor,
53
+ availableLocales: state.settings.availableLocales,
54
+ isDirectionRTL: state.settings.isDirectionRTL
55
+ }),
56
+ isEqual
57
+ );
58
+ };
59
+ const useCommonState = () => {
60
+ return useSelector(
61
+ (state) => ({
62
+ appPath: state.common.appPath,
63
+ width: state.common.width,
64
+ height: state.common.height,
65
+ headerToolBar: state.common.headerToolBar,
66
+ panelSettings: state.common.panelSettings
67
+ }),
68
+ isEqual
69
+ );
70
+ };
71
+ const usePageState = () => {
72
+ return useSelector(
73
+ (state) => ({
74
+ title: state.page.title,
75
+ icon: state.page.icon,
76
+ subTitle: state.page.subTitle
77
+ }),
78
+ isEqual
79
+ );
80
+ };
81
+ const useResourcesState = () => {
82
+ return useSelector(
83
+ (state) => ({
84
+ items: state.resources.items
85
+ }),
86
+ isEqual
87
+ );
88
+ };
89
+ const useLogoSettings = () => {
90
+ const { panelSettings } = useCommonState();
91
+ return useMemo(() => ({
92
+ horizontalLogo: (panelSettings == null ? void 0 : panelSettings.horizontalLogo) || /* @__PURE__ */ jsx(Fragment, {}),
93
+ squaredLogo: (panelSettings == null ? void 0 : panelSettings.squaredLogo) || /* @__PURE__ */ jsx(Fragment, {}),
94
+ loginBackground: panelSettings == null ? void 0 : panelSettings.loginBackground
95
+ }), [panelSettings]);
96
+ };
97
+ const usePanelSettings = () => {
98
+ const { panelSettings } = useCommonState();
99
+ return useMemo(() => ({
100
+ // Sidebar position: 'left' | 'right' | 'top' | 'bottom'
101
+ sidebarPosition: (panelSettings == null ? void 0 : panelSettings.sidebarPosition) || "left",
102
+ // Sidebar dimensions
103
+ sidebarLargeWidth: (panelSettings == null ? void 0 : panelSettings.sidebarLargeWidth) || 255,
104
+ sidebarSmallWidth: (panelSettings == null ? void 0 : panelSettings.sidebarSmallWidth) || 60,
105
+ sidebarHorizontalHeight: (panelSettings == null ? void 0 : panelSettings.sidebarHorizontalHeight) || 120,
106
+ // Logo dimensions for vertical sidebar (left/right)
107
+ logoVerticalMaxWidth: (panelSettings == null ? void 0 : panelSettings.logoVerticalMaxWidth) || 130,
108
+ logoVerticalMaxHeight: (panelSettings == null ? void 0 : panelSettings.logoVerticalMaxHeight) || 130,
109
+ // Logo dimensions for horizontal sidebar (top/bottom)
110
+ logoHorizontalMaxWidth: (panelSettings == null ? void 0 : panelSettings.logoHorizontalMaxWidth) || 200,
111
+ logoHorizontalMaxHeight: (panelSettings == null ? void 0 : panelSettings.logoHorizontalMaxHeight) || 60,
112
+ // Padding configuration
113
+ paddingHorizontal: (panelSettings == null ? void 0 : panelSettings.paddingHorizontal) || 255,
114
+ paddingVertical: (panelSettings == null ? void 0 : panelSettings.paddingVertical) || 120,
115
+ // App name
116
+ appName: (panelSettings == null ? void 0 : panelSettings.appName) || "DASH"
117
+ }), [panelSettings]);
118
+ };
119
+ const useThemeState = () => {
120
+ const layoutState = useLayoutState();
121
+ const logoSettings = useLogoSettings();
122
+ return useMemo(() => __spreadValues(__spreadValues({}, layoutState), logoSettings), [layoutState, logoSettings]);
123
+ };
124
+ const useNavigationState = () => {
125
+ return useSelector(
126
+ (state) => {
127
+ var _a, _b, _c, _d;
128
+ return {
129
+ navExpanded: (_d = (_c = (_a = state.common) == null ? void 0 : _a.navExpanded) != null ? _c : (_b = state.common) == null ? void 0 : _b.navExpanded) != null ? _d : true,
130
+ navSize: state.common.navSize,
131
+ navStyle: state.settings.navStyle,
132
+ layoutSettings: state.settings.layoutSettings
133
+ };
134
+ },
135
+ isEqual
136
+ );
137
+ };
138
+ export {
139
+ useAuthState,
140
+ useCommonState,
141
+ useLayoutState,
142
+ useLogoSettings,
143
+ useNavigationState,
144
+ usePageState,
145
+ usePanelSettings,
146
+ useResourcesState,
147
+ useSettingsState,
148
+ useThemeState
149
+ };
@@ -1 +1,69 @@
1
- import{useCallback as d,useEffect as l,useState as m,useMemo as g}from"react";import{dashStorage as f}from"@dashadmin/dash-utils";const w=typeof window<"u",S=()=>{if(!w)return!1;const e=`test-${Date.now()}`;try{return f.setItem(e,e),f.removeItem(e),!0}catch{return!1}},h=(e,o="")=>{const r=S(),c=d(()=>{try{if(!r)return o;const t=f.getItem(e);return t?JSON.parse(t):o}catch{return o}},[r,o,e]),[a,u]=m(c());l(()=>{const t=c();u(t)},[r,c]);const i=d(t=>{const{key:s,newValue:n}=t;e===s&&u(JSON.parse(n))},[e]);return l(()=>{if(r)return window.addEventListener("storage",i),()=>{window.removeEventListener("storage",i)}},[r]),g(()=>[a,s=>{if(!r)return!1;const n=s instanceof Function?s(a):s;n!==a&&(u(n),window.dashStorage.setItem(e,JSON.stringify(n)))}],[a,r,e])};var L=h;export{L as default};
1
+ import { useCallback, useEffect, useState, useMemo } from "react";
2
+ import { dashStorage } from "dash-utils";
3
+ const isBrowser = typeof window !== "undefined";
4
+ const isLocalstorageAvailable = () => {
5
+ if (!isBrowser) {
6
+ return false;
7
+ }
8
+ const test = `test-${Date.now()}`;
9
+ try {
10
+ dashStorage.setItem(test, test);
11
+ dashStorage.removeItem(test);
12
+ return true;
13
+ } catch (e) {
14
+ return false;
15
+ }
16
+ };
17
+ const useLocalStorage = (key, initialValue = "") => {
18
+ const available = isLocalstorageAvailable();
19
+ const getValueFromLocalstorage = useCallback(() => {
20
+ try {
21
+ if (!available) {
22
+ return initialValue;
23
+ }
24
+ const item = dashStorage.getItem(key);
25
+ return item ? JSON.parse(item) : initialValue;
26
+ } catch (error) {
27
+ return initialValue;
28
+ }
29
+ }, [available, initialValue, key]);
30
+ const [storedValue, setStoredValue] = useState(getValueFromLocalstorage());
31
+ useEffect(() => {
32
+ const value = getValueFromLocalstorage();
33
+ setStoredValue(value);
34
+ }, [available, getValueFromLocalstorage]);
35
+ const changeHandler = useCallback(
36
+ (e) => {
37
+ const { key: changeKey, newValue } = e;
38
+ if (key === changeKey) {
39
+ setStoredValue(JSON.parse(newValue));
40
+ }
41
+ },
42
+ [key]
43
+ );
44
+ useEffect(() => {
45
+ if (available) {
46
+ window.addEventListener("storage", changeHandler);
47
+ return () => {
48
+ window.removeEventListener("storage", changeHandler);
49
+ };
50
+ }
51
+ }, [available]);
52
+ return useMemo(() => {
53
+ const setValue = (value) => {
54
+ if (!available) {
55
+ return false;
56
+ }
57
+ const valueToStore = value instanceof Function ? value(storedValue) : value;
58
+ if (valueToStore !== storedValue) {
59
+ setStoredValue(valueToStore);
60
+ window.dashStorage.setItem(key, JSON.stringify(valueToStore));
61
+ }
62
+ };
63
+ return [storedValue, setValue];
64
+ }, [storedValue, available, key]);
65
+ };
66
+ var useLocalStorage_default = useLocalStorage;
67
+ export {
68
+ useLocalStorage_default as default
69
+ };