@dashadmin/dash-admin-state 1.3.25 → 1.3.26
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/DefaultThemeSettings.js +34 -1
- package/dist/defaults/defaultAuth.js +9 -1
- package/dist/defaults/defaultCommon.js +44 -1
- package/dist/defaults/defaultFormState.js +5 -1
- package/dist/defaults/defaultPage.js +9 -1
- package/dist/defaults/defaultSettings.js +51 -1
- package/dist/hooks/DashAdminStateSelectors.js +149 -1
- package/dist/hooks/useLocalStorage.js +69 -1
- package/dist/index.js +41 -691
- package/dist/redux/ReduxStoreAccesor.js +19 -1
- package/dist/redux/actions/ActionTypes.js +84 -1
- package/dist/redux/actions/Auth.js +6 -1
- package/dist/redux/actions/Common.js +51 -1
- package/dist/redux/actions/ComponentData.js +33 -1
- package/dist/redux/actions/Menu.js +5 -1
- package/dist/redux/actions/Page.js +7 -1
- package/dist/redux/actions/Resources.js +21 -1
- package/dist/redux/actions/Setting.js +90 -1
- package/dist/redux/actions/index.js +6 -1
- package/dist/redux/reducers/Auth.js +55 -1
- package/dist/redux/reducers/Common.js +134 -1
- package/dist/redux/reducers/ComponentData.js +59 -1
- package/dist/redux/reducers/FormData.js +32 -1
- package/dist/redux/reducers/Menu.js +22 -1
- package/dist/redux/reducers/Page.js +30 -1
- package/dist/redux/reducers/Resources.js +19 -1
- package/dist/redux/reducers/Settings.js +79 -1
- package/dist/redux/reducers/index.js +25 -1
- package/dist/redux/sagas/index.js +9 -1
- package/dist/redux/store/index.js +35 -1
- package/package.json +75 -57
- package/src/DefaultThemeSettings.tsx +33 -0
- package/src/defaults/defaultAuth.tsx +8 -0
- package/src/defaults/defaultCommon.tsx +55 -0
- package/src/defaults/defaultFormState.tsx +4 -0
- package/src/defaults/defaultPage.tsx +9 -0
- package/src/defaults/defaultSettings.tsx +61 -0
- package/src/hooks/DashAdminStateSelectors.tsx +142 -0
- package/src/hooks/useLocalStorage.tsx +79 -0
- package/src/index.tsx +34 -0
- package/src/redux/ReduxStoreAccesor.tsx +18 -0
- package/src/redux/actions/ActionTypes.tsx +47 -0
- package/src/redux/actions/Auth.tsx +5 -0
- package/src/redux/actions/Common.tsx +51 -0
- package/src/redux/actions/ComponentData.tsx +78 -0
- package/src/redux/actions/Menu.tsx +4 -0
- package/src/redux/actions/Page.tsx +6 -0
- package/src/redux/actions/Resources.tsx +19 -0
- package/src/redux/actions/Setting.tsx +91 -0
- package/src/redux/actions/index.tsx +7 -0
- package/src/redux/interfaces/IAuthState.tsx +7 -0
- package/src/redux/interfaces/ICommonState.tsx +25 -0
- package/src/redux/interfaces/IComponentData.tsx +32 -0
- package/src/redux/interfaces/IDASHAppState.tsx +53 -0
- package/src/redux/interfaces/IDashResourceGroupsIcons.tsx +5 -0
- package/src/redux/interfaces/IFormDataState.tsx +6 -0
- package/src/redux/interfaces/IPage.tsx +27 -0
- package/src/redux/interfaces/IResources.tsx +0 -0
- package/src/redux/interfaces/ISettings.tsx +27 -0
- package/src/redux/reducers/Auth.tsx +38 -0
- package/src/redux/reducers/Common.tsx +144 -0
- package/src/redux/reducers/ComponentData.tsx +52 -0
- package/src/redux/reducers/FormData.tsx +21 -0
- package/src/redux/reducers/Menu.tsx +27 -0
- package/src/redux/reducers/Page.tsx +17 -0
- package/src/redux/reducers/Resources.tsx +19 -0
- package/src/redux/reducers/Settings.tsx +78 -0
- package/src/redux/reducers/index.tsx +25 -0
- package/src/redux/sagas/index.tsx +8 -0
- package/src/redux/store/index.tsx +33 -0
|
@@ -1 +1,30 @@
|
|
|
1
|
-
|
|
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
|
+
const ACTION_UPDATE_PAGE = "UPDATE_PAGE";
|
|
18
|
+
const PageReducer = (state = {}, action) => {
|
|
19
|
+
switch (action.type) {
|
|
20
|
+
case ACTION_UPDATE_PAGE:
|
|
21
|
+
return __spreadValues(__spreadValues({}, state), action.payload);
|
|
22
|
+
default:
|
|
23
|
+
return state;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var Page_default = PageReducer;
|
|
27
|
+
export {
|
|
28
|
+
ACTION_UPDATE_PAGE,
|
|
29
|
+
Page_default as default
|
|
30
|
+
};
|
|
@@ -1 +1,19 @@
|
|
|
1
|
-
import{APPEND_RESOURCES
|
|
1
|
+
import { APPEND_RESOURCES, SET_RESOURCES } from "../actions/ActionTypes";
|
|
2
|
+
const ResourcesReducer = (state = { items: [] }, action) => {
|
|
3
|
+
switch (action.type) {
|
|
4
|
+
case SET_RESOURCES:
|
|
5
|
+
return {
|
|
6
|
+
items: [...action.payload]
|
|
7
|
+
};
|
|
8
|
+
case APPEND_RESOURCES:
|
|
9
|
+
return {
|
|
10
|
+
items: [...state.items, ...action.payload]
|
|
11
|
+
};
|
|
12
|
+
default:
|
|
13
|
+
return state;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var Resources_default = ResourcesReducer;
|
|
17
|
+
export {
|
|
18
|
+
Resources_default as default
|
|
19
|
+
};
|
|
@@ -1 +1,79 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import DefaultThemeSettings from "../../DefaultThemeSettings";
|
|
21
|
+
import {
|
|
22
|
+
UPDATE_THEME_SETTINGS,
|
|
23
|
+
SWITCH_LANGUAGE,
|
|
24
|
+
SET_RESOURCES
|
|
25
|
+
} from "../actions/ActionTypes";
|
|
26
|
+
const SettingsReducer = (state = {
|
|
27
|
+
loading: false,
|
|
28
|
+
navStyle: void 0,
|
|
29
|
+
layoutType: "",
|
|
30
|
+
themeType: void 0,
|
|
31
|
+
themeColor: "",
|
|
32
|
+
isDirectionRTL: false,
|
|
33
|
+
/* @ts-ignore */
|
|
34
|
+
locale: {
|
|
35
|
+
languageId: "",
|
|
36
|
+
locale: "",
|
|
37
|
+
name: "",
|
|
38
|
+
icon: ""
|
|
39
|
+
}
|
|
40
|
+
}, action) => {
|
|
41
|
+
switch (action.type) {
|
|
42
|
+
case SET_RESOURCES:
|
|
43
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
44
|
+
resources: action.payload
|
|
45
|
+
});
|
|
46
|
+
case DefaultThemeSettings.THEME_TYPE:
|
|
47
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
48
|
+
themeType: action.themeType
|
|
49
|
+
});
|
|
50
|
+
case DefaultThemeSettings.THEME_COLOR:
|
|
51
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
52
|
+
themeColor: action.themeColor
|
|
53
|
+
});
|
|
54
|
+
case DefaultThemeSettings.UPDATE_RTL_STATUS:
|
|
55
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
56
|
+
isDirectionRTL: action.rtlStatus
|
|
57
|
+
});
|
|
58
|
+
case UPDATE_THEME_SETTINGS:
|
|
59
|
+
return __spreadValues(__spreadValues({}, state), action.payload);
|
|
60
|
+
case DefaultThemeSettings.NAV_STYLE:
|
|
61
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
62
|
+
navStyle: action.navStyle
|
|
63
|
+
});
|
|
64
|
+
case DefaultThemeSettings.LAYOUT_TYPE:
|
|
65
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
66
|
+
layoutType: action.layoutType
|
|
67
|
+
});
|
|
68
|
+
case SWITCH_LANGUAGE:
|
|
69
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
70
|
+
locale: action.payload
|
|
71
|
+
});
|
|
72
|
+
default:
|
|
73
|
+
return state;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
var Settings_default = SettingsReducer;
|
|
77
|
+
export {
|
|
78
|
+
Settings_default as default
|
|
79
|
+
};
|
|
@@ -1 +1,25 @@
|
|
|
1
|
-
import{combineReducers
|
|
1
|
+
import { combineReducers } from "redux";
|
|
2
|
+
import SettingsReducer from "./Settings";
|
|
3
|
+
import AuthReducer from "./Auth";
|
|
4
|
+
import CommonReducer from "./Common";
|
|
5
|
+
import PageReducer from "./Page";
|
|
6
|
+
import ResourcesReducer from "./Resources";
|
|
7
|
+
import FormDataReducer from "./FormData";
|
|
8
|
+
import MenuReducer from "./Menu";
|
|
9
|
+
import ComponentDataReducer from "./ComponentData";
|
|
10
|
+
const createRootReducer = () => combineReducers({
|
|
11
|
+
//router: connectRouter(history),
|
|
12
|
+
page: PageReducer,
|
|
13
|
+
settings: SettingsReducer,
|
|
14
|
+
auth: AuthReducer,
|
|
15
|
+
common: CommonReducer,
|
|
16
|
+
resources: ResourcesReducer,
|
|
17
|
+
formData: FormDataReducer,
|
|
18
|
+
menu: MenuReducer,
|
|
19
|
+
componentData: ComponentDataReducer
|
|
20
|
+
});
|
|
21
|
+
var reducers_default = createRootReducer;
|
|
22
|
+
export {
|
|
23
|
+
createRootReducer,
|
|
24
|
+
reducers_default as default
|
|
25
|
+
};
|
|
@@ -1 +1,35 @@
|
|
|
1
|
-
import
|
|
1
|
+
import createSagaMiddleware from "redux-saga";
|
|
2
|
+
import { applyMiddleware, compose } from "redux";
|
|
3
|
+
import { routerMiddleware } from "connected-react-router";
|
|
4
|
+
import rootSaga from "../sagas/index";
|
|
5
|
+
import createRootReducer from "../reducers";
|
|
6
|
+
import { createBrowserHistory } from "history";
|
|
7
|
+
import { legacy_createStore as createStore } from "redux";
|
|
8
|
+
import { thunk } from "redux-thunk";
|
|
9
|
+
const history = createBrowserHistory();
|
|
10
|
+
const routeMiddleware = routerMiddleware(history);
|
|
11
|
+
const sagaMiddleware = createSagaMiddleware();
|
|
12
|
+
const middlewares = [thunk, sagaMiddleware, routeMiddleware];
|
|
13
|
+
const configureStore = (preloadedState) => {
|
|
14
|
+
const store = createStore(
|
|
15
|
+
createRootReducer(
|
|
16
|
+
/*history*/
|
|
17
|
+
),
|
|
18
|
+
// root reducer with router state
|
|
19
|
+
preloadedState,
|
|
20
|
+
compose(
|
|
21
|
+
applyMiddleware(
|
|
22
|
+
routerMiddleware(history),
|
|
23
|
+
...middlewares
|
|
24
|
+
)
|
|
25
|
+
)
|
|
26
|
+
);
|
|
27
|
+
sagaMiddleware.run(rootSaga, {});
|
|
28
|
+
return store;
|
|
29
|
+
};
|
|
30
|
+
var store_default = configureStore;
|
|
31
|
+
export {
|
|
32
|
+
configureStore,
|
|
33
|
+
store_default as default,
|
|
34
|
+
history
|
|
35
|
+
};
|
package/package.json
CHANGED
|
@@ -1,58 +1,76 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
2
|
+
"name": "@dashadmin/dash-admin-state",
|
|
3
|
+
"version": "1.3.26",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"devDependencies": {
|
|
7
|
+
"@commitlint/cli": "latest",
|
|
8
|
+
"@commitlint/config-conventional": "latest",
|
|
9
|
+
"@types/jest": "latest",
|
|
10
|
+
"@types/node": "latest",
|
|
11
|
+
"@types/react": "latest",
|
|
12
|
+
"@types/react-dom": "latest",
|
|
13
|
+
"@typescript-eslint/eslint-plugin": "latest",
|
|
14
|
+
"@typescript-eslint/parser": "latest",
|
|
15
|
+
"eslint-config-airbnb-typescript": "latest",
|
|
16
|
+
"eslint-config-prettier": "latest",
|
|
17
|
+
"eslint-plugin-html": "latest",
|
|
18
|
+
"eslint-plugin-import": "latest",
|
|
19
|
+
"eslint-plugin-jsdoc": "latest",
|
|
20
|
+
"eslint-plugin-json": "latest",
|
|
21
|
+
"eslint-plugin-prettier": "latest",
|
|
22
|
+
"ts-jest": "latest",
|
|
23
|
+
"ts-loader": "latest",
|
|
24
|
+
"tsconfig-paths": "latest",
|
|
25
|
+
"typescript": "latest"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"connected-react-router": "latest",
|
|
29
|
+
"history": "latest",
|
|
30
|
+
"react-redux": "latest",
|
|
31
|
+
"redux-saga": "latest",
|
|
32
|
+
"redux-thunk": "^3.1.0",
|
|
33
|
+
"@dashadmin/dash-auto-admin": "workspace:*",
|
|
34
|
+
"@dashadmin/dash-constants": "workspace:*",
|
|
35
|
+
"@dashadmin/dash-utils": "workspace:*"
|
|
36
|
+
},
|
|
37
|
+
"module": "dist/index.js",
|
|
38
|
+
"types": "./src/index.tsx",
|
|
39
|
+
"exports": {
|
|
40
|
+
".": "./dist/index.js",
|
|
41
|
+
"./redux/actions": "./dist/redux/actions/index.js",
|
|
42
|
+
"./src/redux/actions": "./dist/redux/actions/index.js",
|
|
43
|
+
"./redux/reducers": "./dist/redux/reducers/index.js",
|
|
44
|
+
"./src/redux/reducers": "./dist/redux/reducers/index.js",
|
|
45
|
+
"./redux/sagas": "./dist/redux/sagas/index.js",
|
|
46
|
+
"./src/redux/sagas": "./dist/redux/sagas/index.js",
|
|
47
|
+
"./redux/store": "./dist/redux/store/index.js",
|
|
48
|
+
"./src/redux/store": "./dist/redux/store/index.js",
|
|
49
|
+
"./*": "./dist/*.js",
|
|
50
|
+
"./src/*": "./dist/*.js"
|
|
51
|
+
},
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public",
|
|
54
|
+
"registry": "https://registry.npmjs.org"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsup"
|
|
58
|
+
},
|
|
59
|
+
"type": "module",
|
|
60
|
+
"files": [
|
|
61
|
+
"dist",
|
|
62
|
+
"src"
|
|
63
|
+
],
|
|
64
|
+
"typesVersions": {
|
|
65
|
+
"*": {
|
|
66
|
+
"src/*": [
|
|
67
|
+
"src/*",
|
|
68
|
+
"src/*/index"
|
|
69
|
+
],
|
|
70
|
+
"*": [
|
|
71
|
+
"src/*",
|
|
72
|
+
"src/*/index"
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
class DefaultThemeSettings {
|
|
2
|
+
|
|
3
|
+
static TAB_SIZE = 992;
|
|
4
|
+
static MOBILE_SIZE = 575;
|
|
5
|
+
static THEME_TYPE = 'THEME_TYPE';
|
|
6
|
+
static THEME_TYPE_LIGHT = 'light';
|
|
7
|
+
static THEME_TYPE_DARK = 'dark';
|
|
8
|
+
static THEME_TYPE_DASH_DEFAULT = 'light';
|
|
9
|
+
static THEME_TYPE_SEMI_DARK = 'THEME_TYPE_SEMI_DARK';
|
|
10
|
+
static THEME_COLOR = 'THEME_COLOR';
|
|
11
|
+
static LAYOUT_TYPE = 'LAYOUT_TYPE';
|
|
12
|
+
static LAYOUT_TYPE_FRAMED = 'framed-layout';
|
|
13
|
+
static LAYOUT_TYPE_BOXED = 'boxed-layout';
|
|
14
|
+
static LAYOUT_TYPE_FULL = 'full-layout';
|
|
15
|
+
static NAV_STYLE = 'NAV_STYLE';
|
|
16
|
+
static NAV_STYLE_FIXED = 'NAV_STYLE_FIXED';
|
|
17
|
+
static NAV_STYLE_MINI_SIDEBAR = 'NAV_STYLE_MINI_SIDEBAR';
|
|
18
|
+
static NAV_STYLE_DRAWER = 'NAV_STYLE_DRAWER';
|
|
19
|
+
static NAV_STYLE_NO_HEADER_MINI_SIDEBAR = 'NAV_STYLE_NO_HEADER_MINI_SIDEBAR';
|
|
20
|
+
static NAV_STYLE_NO_HEADER_EXPANDED_SIDEBAR =
|
|
21
|
+
'NAV_STYLE_NO_HEADER_EXPANDED_SIDEBAR';
|
|
22
|
+
static NAV_STYLE_DEFAULT_HORIZONTAL = 'NAV_STYLE_DEFAULT_HORIZONTAL';
|
|
23
|
+
static NAV_STYLE_DARK_HORIZONTAL = 'NAV_STYLE_DARK_HORIZONTAL';
|
|
24
|
+
static NAV_STYLE_INSIDE_HEADER_HORIZONTAL =
|
|
25
|
+
'NAV_STYLE_INSIDE_HEADER_HORIZONTAL';
|
|
26
|
+
static NAV_STYLE_BELOW_HEADER = 'NAV_STYLE_BELOW_HEADER';
|
|
27
|
+
static NAV_STYLE_ABOVE_HEADER = 'NAV_STYLE_ABOVE_HEADER';
|
|
28
|
+
static NAV_STYLE_COLLAPSABLE = 'NAV_STYLE_COLLAPSABLE';
|
|
29
|
+
static UPDATE_RTL_STATUS = 'UPDATE_RTL_STATUS';
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default DefaultThemeSettings;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import ICommonState from "../redux/interfaces/ICommonState";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Default Common State
|
|
5
|
+
*
|
|
6
|
+
* Provides default values for common application state including
|
|
7
|
+
* layout, navigation, and panel settings. These can be overridden
|
|
8
|
+
* by the consuming application during store initialization.
|
|
9
|
+
*/
|
|
10
|
+
const defaultCommon: ICommonState = {
|
|
11
|
+
appPath: '/',
|
|
12
|
+
error: '',
|
|
13
|
+
loading: false,
|
|
14
|
+
message: '',
|
|
15
|
+
navExpanded: true,
|
|
16
|
+
width: typeof window !== 'undefined' ? window.innerWidth : 1920,
|
|
17
|
+
height: typeof window !== 'undefined' ? window.innerHeight : 1080,
|
|
18
|
+
content_width: null,
|
|
19
|
+
content_height: null,
|
|
20
|
+
pathname: '/',
|
|
21
|
+
componentsState: {},
|
|
22
|
+
headerToolBar: null,
|
|
23
|
+
headerToolBarReplace: false,
|
|
24
|
+
navSize: "small",
|
|
25
|
+
|
|
26
|
+
// Panel settings with sidebar dimensions
|
|
27
|
+
// These values can be overridden by CSS variables at runtime
|
|
28
|
+
panelSettings: {
|
|
29
|
+
// Branding
|
|
30
|
+
appName: 'Dash App',
|
|
31
|
+
horizontalLogo: <>🖥</>,
|
|
32
|
+
squaredLogo: <>🖥</>,
|
|
33
|
+
loginBackground: undefined,
|
|
34
|
+
|
|
35
|
+
// Sidebar dimensions (can be overridden via CSS variables)
|
|
36
|
+
sidebarLargeWidth: 255,
|
|
37
|
+
sidebarSmallWidth: 64,
|
|
38
|
+
sidebarHorizontalHeight: 120,
|
|
39
|
+
|
|
40
|
+
// Logo dimensions
|
|
41
|
+
logoVerticalMaxWidth: 130,
|
|
42
|
+
logoVerticalMaxHeight: 130,
|
|
43
|
+
logoHorizontalMaxWidth: 200,
|
|
44
|
+
logoHorizontalMaxHeight: 60,
|
|
45
|
+
|
|
46
|
+
// Content padding (derived from sidebar)
|
|
47
|
+
paddingHorizontal: 255,
|
|
48
|
+
paddingVertical: 120,
|
|
49
|
+
|
|
50
|
+
// Position
|
|
51
|
+
sidebarPosition: 'left',
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default defaultCommon;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import ISettingsState from "../redux/interfaces/ISettings";
|
|
2
|
+
import {DASHAdminSystemConstants} from 'dash-constants';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Default Settings State
|
|
6
|
+
*
|
|
7
|
+
* Provides default values for all settings. These can be overridden
|
|
8
|
+
* by the consuming application during store initialization.
|
|
9
|
+
*/
|
|
10
|
+
const defaultSettings: ISettingsState = {
|
|
11
|
+
// Loading state
|
|
12
|
+
loading: false,
|
|
13
|
+
|
|
14
|
+
// Navigation and layout
|
|
15
|
+
navStyle: DASHAdminSystemConstants.panel.NAV_STYLE_FIXED,
|
|
16
|
+
layoutType: DASHAdminSystemConstants.panel.LAYOUT_TYPE_FULL,
|
|
17
|
+
themeType: DASHAdminSystemConstants.panel.THEME_TYPE_DARK,
|
|
18
|
+
themeColor: '',
|
|
19
|
+
isDirectionRTL: false,
|
|
20
|
+
|
|
21
|
+
// Layout settings (dimensions, breakpoints, etc.)
|
|
22
|
+
layoutSettings: {
|
|
23
|
+
// Sidebar dimensions
|
|
24
|
+
sidebarLargeWidth: 255,
|
|
25
|
+
sidebarSmallWidth: 64,
|
|
26
|
+
sidebarHorizontalHeight: 120,
|
|
27
|
+
// Logo dimensions
|
|
28
|
+
logoVerticalMaxWidth: 130,
|
|
29
|
+
logoVerticalMaxHeight: 130,
|
|
30
|
+
logoHorizontalMaxWidth: 200,
|
|
31
|
+
logoHorizontalMaxHeight: 60,
|
|
32
|
+
// Content padding (based on sidebar)
|
|
33
|
+
paddingHorizontal: 255,
|
|
34
|
+
paddingVertical: 120,
|
|
35
|
+
// Breakpoints
|
|
36
|
+
mobileBreakpoint: 768,
|
|
37
|
+
tabletBreakpoint: 1024,
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
// Localization
|
|
41
|
+
locale: 'es',
|
|
42
|
+
availableLocales: [
|
|
43
|
+
{
|
|
44
|
+
locale: 'es',
|
|
45
|
+
languageId: 'spanish',
|
|
46
|
+
name: 'Español',
|
|
47
|
+
icon: 'es',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
locale: 'en',
|
|
51
|
+
languageId: 'english',
|
|
52
|
+
name: 'English',
|
|
53
|
+
icon: 'en',
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
|
|
57
|
+
// Translations (populated by i18n provider)
|
|
58
|
+
translations: {},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default defaultSettings;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { useSelector } from 'react-redux';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { isEqual } from 'lodash';
|
|
4
|
+
import { IDASHAppState } from '../';
|
|
5
|
+
import { IDashAutoAdminResourceConfig } from 'dash-auto-admin';
|
|
6
|
+
|
|
7
|
+
// Custom hook for layout-related state
|
|
8
|
+
export const useLayoutState = <U, A>() => {
|
|
9
|
+
return useSelector(
|
|
10
|
+
(state: IDASHAppState<U, A, IDashAutoAdminResourceConfig>) => ({
|
|
11
|
+
navStyle: state.settings.navStyle,
|
|
12
|
+
layoutType: state.settings.layoutType,
|
|
13
|
+
themeType: state.settings.themeType,
|
|
14
|
+
layoutSettings: state.settings.layoutSettings,
|
|
15
|
+
navExpanded: state.common?.navExpanded ?? state.common?.navExpanded ?? true,
|
|
16
|
+
navSize: state.common.navSize,
|
|
17
|
+
panelSettings: state.common.panelSettings,
|
|
18
|
+
}),
|
|
19
|
+
isEqual
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// Custom hook for authentication state
|
|
24
|
+
export const useAuthState = <U, A>() => {
|
|
25
|
+
return useSelector(
|
|
26
|
+
(state: IDASHAppState<U, A, IDashAutoAdminResourceConfig>) => ({
|
|
27
|
+
authenticated: state.auth.authenticated,
|
|
28
|
+
user: state.auth.user,
|
|
29
|
+
}),
|
|
30
|
+
isEqual
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Custom hook for app settings
|
|
35
|
+
export const useSettingsState = <U, A>() => {
|
|
36
|
+
return useSelector(
|
|
37
|
+
(state: IDASHAppState<U, A, IDashAutoAdminResourceConfig>) => ({
|
|
38
|
+
groupIcons: state.settings.groupIcons,
|
|
39
|
+
locale: state.settings.locale,
|
|
40
|
+
themeColor: state.settings.themeColor,
|
|
41
|
+
availableLocales: state.settings.availableLocales,
|
|
42
|
+
isDirectionRTL: state.settings.isDirectionRTL,
|
|
43
|
+
}),
|
|
44
|
+
isEqual
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// Custom hook for common state
|
|
49
|
+
export const useCommonState = <U, A>() => {
|
|
50
|
+
return useSelector(
|
|
51
|
+
(state: IDASHAppState<U, A, IDashAutoAdminResourceConfig>) => ({
|
|
52
|
+
appPath: state.common.appPath,
|
|
53
|
+
width: state.common.width,
|
|
54
|
+
height: state.common.height,
|
|
55
|
+
headerToolBar: state.common.headerToolBar,
|
|
56
|
+
panelSettings: state.common.panelSettings,
|
|
57
|
+
}),
|
|
58
|
+
isEqual
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// Custom hook for page state
|
|
63
|
+
export const usePageState = <U, A>() => {
|
|
64
|
+
return useSelector(
|
|
65
|
+
(state: IDASHAppState<U, A, IDashAutoAdminResourceConfig>) => ({
|
|
66
|
+
title: state.page.title,
|
|
67
|
+
icon: state.page.icon,
|
|
68
|
+
subTitle: state.page.subTitle,
|
|
69
|
+
}),
|
|
70
|
+
isEqual
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// Custom hook for resources state
|
|
75
|
+
export const useResourcesState = <U, A>() => {
|
|
76
|
+
return useSelector(
|
|
77
|
+
(state: IDASHAppState<U, A, IDashAutoAdminResourceConfig>) => ({
|
|
78
|
+
items: state.resources.items,
|
|
79
|
+
}),
|
|
80
|
+
isEqual
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// Memoized hook for logo settings specifically
|
|
85
|
+
export const useLogoSettings = <U, A>() => {
|
|
86
|
+
const { panelSettings } = useCommonState<U, A>();
|
|
87
|
+
|
|
88
|
+
return useMemo(() => ({
|
|
89
|
+
horizontalLogo: panelSettings?.horizontalLogo || <></>,
|
|
90
|
+
squaredLogo: panelSettings?.squaredLogo || <></>,
|
|
91
|
+
loginBackground: panelSettings?.loginBackground,
|
|
92
|
+
}), [panelSettings]);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// Memoized hook for sidebar/panel settings (dimensions, position, padding)
|
|
96
|
+
export const usePanelSettings = <U, A>() => {
|
|
97
|
+
const { panelSettings } = useCommonState<U, A>();
|
|
98
|
+
|
|
99
|
+
return useMemo(() => ({
|
|
100
|
+
// Sidebar position: 'left' | 'right' | 'top' | 'bottom'
|
|
101
|
+
sidebarPosition: panelSettings?.sidebarPosition || 'left',
|
|
102
|
+
// Sidebar dimensions
|
|
103
|
+
sidebarLargeWidth: panelSettings?.sidebarLargeWidth || 255,
|
|
104
|
+
sidebarSmallWidth: panelSettings?.sidebarSmallWidth || 60,
|
|
105
|
+
sidebarHorizontalHeight: panelSettings?.sidebarHorizontalHeight || 120,
|
|
106
|
+
// Logo dimensions for vertical sidebar (left/right)
|
|
107
|
+
logoVerticalMaxWidth: panelSettings?.logoVerticalMaxWidth || 130,
|
|
108
|
+
logoVerticalMaxHeight: panelSettings?.logoVerticalMaxHeight || 130,
|
|
109
|
+
// Logo dimensions for horizontal sidebar (top/bottom)
|
|
110
|
+
logoHorizontalMaxWidth: panelSettings?.logoHorizontalMaxWidth || 200,
|
|
111
|
+
logoHorizontalMaxHeight: panelSettings?.logoHorizontalMaxHeight || 60,
|
|
112
|
+
// Padding configuration
|
|
113
|
+
paddingHorizontal: panelSettings?.paddingHorizontal || 255,
|
|
114
|
+
paddingVertical: panelSettings?.paddingVertical || 120,
|
|
115
|
+
// App name
|
|
116
|
+
appName: panelSettings?.appName || 'DASH',
|
|
117
|
+
}), [panelSettings]);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// Combined hook for theme-related state (optimized for DomainTheme)
|
|
121
|
+
export const useThemeState = <U, A>() => {
|
|
122
|
+
const layoutState = useLayoutState<U, A>();
|
|
123
|
+
const logoSettings = useLogoSettings<U, A>();
|
|
124
|
+
|
|
125
|
+
return useMemo(() => ({
|
|
126
|
+
...layoutState,
|
|
127
|
+
...logoSettings,
|
|
128
|
+
}), [layoutState, logoSettings]);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// Hook for navigation state specifically
|
|
132
|
+
export const useNavigationState = <U, A>() => {
|
|
133
|
+
return useSelector(
|
|
134
|
+
(state: IDASHAppState<U, A, IDashAutoAdminResourceConfig>) => ({
|
|
135
|
+
navExpanded: state.common?.navExpanded ?? state.common?.navExpanded ?? true,
|
|
136
|
+
navSize: state.common.navSize,
|
|
137
|
+
navStyle: state.settings.navStyle,
|
|
138
|
+
layoutSettings: state.settings.layoutSettings,
|
|
139
|
+
}),
|
|
140
|
+
isEqual
|
|
141
|
+
);
|
|
142
|
+
};
|