@admin-layout/client 7.0.2-alpha.0 → 7.0.2-alpha.5

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/lib/index.js CHANGED
@@ -1 +1 @@
1
- export{APPLICATION_ERROR_SLOT_FILL,CHANGE_LANGUAGE,CHANGE_SETTINGS_ACTION}from'./constants/constants.js';export{BACKEND_ERROR,CLEAR_APPLICATION_ERRORS,DISMISS_APPLICATION_ERROR,LOG_APPLICATION_ERROR,RESTORE_APPLICATION_ERRORS}from'./constants/error.js';export{dismissApplicationError,restoreApplicationError,setApplicationError}from'./redux/actions/error-actions.js';export{settingsReducer}from'./redux/settings.js';export{applicationErrors,initialErrorsState}from'./redux/reducers/error.js';export{getMenuSeparation}from'./utils/seperatedMenus.js';export{useComponentSize,useIsomorphicLayoutEffect}from'./utils/componentSize.js';export{matchParentRoute}from'./utils/parentRoute.js';export{ApplicationErrorHandlerCommon}from'./components/ApplicationErrorHandlerCommon.js';export{ErrorBoundaryCommon}from'./components/ErrorBoundaryCommon.js';export{ApplicationErrorFillWrapper}from'./components/ApplicationErrorFillWrapper.js';export{ErrorLink,errorReduxLink}from'./graphql/link/error-link.js';export{systemFont}from'./themes/systemFont/index.js';export{borderRadius,colors,lightLayoutTheme,lightNavigationBarTheme,lightTabBarTheme,shadows,sizes,spacings,textVariants}from'./themes/templates/lightLayoutTheme.js';export{createLayoutTheme}from'./themes/templates/createLayoutTheme.js';export{darkColors,darkLayoutTheme,darkNavigationBarTheme,darkTabBarTheme}from'./themes/templates/darkLayoutTheme.js';//# sourceMappingURL=index.js.map
1
+ export{APPLICATION_ERROR_SLOT_FILL,CHANGE_LANGUAGE,CHANGE_SETTINGS_ACTION}from'./constants/constants.js';export{BACKEND_ERROR,CLEAR_APPLICATION_ERRORS,DISMISS_APPLICATION_ERROR,LOG_APPLICATION_ERROR,RESTORE_APPLICATION_ERRORS}from'./constants/error.js';export{dismissApplicationError,restoreApplicationError,setApplicationError}from'./redux/actions/error-actions.js';export{settingsReducer}from'./redux/settings.js';export{applicationErrors,initialErrorsState}from'./redux/reducers/error.js';export{getMenuSeparation}from'./utils/seperatedMenus.js';export{useComponentSize,useIsomorphicLayoutEffect}from'./utils/componentSize.js';export{matchParentRoute}from'./utils/parentRoute.js';export{addProLayoutParentKeys,filterRoutesWithLocale,menuDataRender,removeUnnecessaryProperties,setLocale,transformData}from'./utils/menuUtils.js';export{ApplicationErrorHandlerCommon}from'./components/ApplicationErrorHandlerCommon.js';export{ErrorBoundaryCommon}from'./components/ErrorBoundaryCommon.js';export{ApplicationErrorFillWrapper}from'./components/ApplicationErrorFillWrapper.js';export{ErrorLink,errorReduxLink}from'./graphql/link/error-link.js';export{systemFont}from'./themes/systemFont/index.js';export{borderRadius,colors,lightLayoutTheme,lightNavigationBarTheme,lightTabBarTheme,shadows,sizes,spacings,textVariants}from'./themes/templates/lightLayoutTheme.js';export{createLayoutTheme}from'./themes/templates/createLayoutTheme.js';export{darkColors,darkLayoutTheme,darkNavigationBarTheme,darkTabBarTheme}from'./themes/templates/darkLayoutTheme.js';//# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- export{APPLICATION_ERROR_SLOT_FILL,CHANGE_LANGUAGE,CHANGE_SETTINGS_ACTION}from'./constants/constants.js';export{BACKEND_ERROR,CLEAR_APPLICATION_ERRORS,DISMISS_APPLICATION_ERROR,LOG_APPLICATION_ERROR,RESTORE_APPLICATION_ERRORS}from'./constants/error.js';export{dismissApplicationError,restoreApplicationError,setApplicationError}from'./redux/actions/error-actions.js';export{settingsReducer}from'./redux/settings.js';export{applicationErrors,initialErrorsState}from'./redux/reducers/error.js';export{getMenuSeparation}from'./utils/seperatedMenus.js';export{useComponentSize,useIsomorphicLayoutEffect}from'./utils/componentSize.js';export{matchParentRoute}from'./utils/parentRoute.js';export{ApplicationErrorHandlerCommon}from'./components/ApplicationErrorHandlerCommon.js';export{ErrorBoundaryCommon}from'./components/ErrorBoundaryCommon.js';export{ApplicationErrorFillWrapper}from'./components/ApplicationErrorFillWrapper.js';export{ErrorLink,errorReduxLink}from'./graphql/link/error-link.js';export{systemFont}from'./themes/systemFont/index.js';export{borderRadius,colors,lightLayoutTheme,lightNavigationBarTheme,lightTabBarTheme,shadows,sizes,spacings,textVariants}from'./themes/templates/lightLayoutTheme.js';export{createLayoutTheme}from'./themes/templates/createLayoutTheme.js';export{darkColors,darkLayoutTheme,darkNavigationBarTheme,darkTabBarTheme}from'./themes/templates/darkLayoutTheme.js';//# sourceMappingURL=index.native.js.map
1
+ export{APPLICATION_ERROR_SLOT_FILL,CHANGE_LANGUAGE,CHANGE_SETTINGS_ACTION}from'./constants/constants.js';export{BACKEND_ERROR,CLEAR_APPLICATION_ERRORS,DISMISS_APPLICATION_ERROR,LOG_APPLICATION_ERROR,RESTORE_APPLICATION_ERRORS}from'./constants/error.js';export{dismissApplicationError,restoreApplicationError,setApplicationError}from'./redux/actions/error-actions.js';export{settingsReducer}from'./redux/settings.js';export{applicationErrors,initialErrorsState}from'./redux/reducers/error.js';export{getMenuSeparation}from'./utils/seperatedMenus.js';export{useComponentSize,useIsomorphicLayoutEffect}from'./utils/componentSize.js';export{matchParentRoute}from'./utils/parentRoute.js';export{addProLayoutParentKeys,filterRoutesWithLocale,menuDataRender,removeUnnecessaryProperties,setLocale,transformData}from'./utils/menuUtils.js';export{ApplicationErrorHandlerCommon}from'./components/ApplicationErrorHandlerCommon.js';export{ErrorBoundaryCommon}from'./components/ErrorBoundaryCommon.js';export{ApplicationErrorFillWrapper}from'./components/ApplicationErrorFillWrapper.js';export{ErrorLink,errorReduxLink}from'./graphql/link/error-link.js';export{systemFont}from'./themes/systemFont/index.js';export{borderRadius,colors,lightLayoutTheme,lightNavigationBarTheme,lightTabBarTheme,shadows,sizes,spacings,textVariants}from'./themes/templates/lightLayoutTheme.js';export{createLayoutTheme}from'./themes/templates/createLayoutTheme.js';export{darkColors,darkLayoutTheme,darkNavigationBarTheme,darkTabBarTheme}from'./themes/templates/darkLayoutTheme.js';//# sourceMappingURL=index.native.js.map
@@ -1,4 +1,5 @@
1
1
  export * from './seperatedMenus';
2
2
  export * from './componentSize';
3
3
  export * from './parentRoute';
4
+ export * from './menuUtils';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { IMenuDataItem } from '@common-stack/client-react/lib/interfaces/menu';
2
+ /**
3
+ * Custom menuDataRender function which will be called on component render
4
+ * to filter out menus from props.menuData on the basis of authorities.
5
+ *
6
+ * Note: This will be removed when menuDataRender issue
7
+ * is resolved with the next release of Layout Components.
8
+ *
9
+ * @param menuList
10
+ * @param authorities
11
+ */
12
+ export declare const menuDataRender: (menuList: IMenuDataItem[], authorities: any) => IMenuDataItem[];
13
+ export declare function transformData(data: any): any;
14
+ export declare function setLocale(obj: any, parentName?: string): void;
15
+ export declare const addProLayoutParentKeys: (menuData?: any[], parentKeys?: string[]) => any[];
16
+ export declare const filterRoutesWithLocale: (routes: any) => any;
17
+ /**
18
+ *
19
+ * included [ 'dialogPath']
20
+ */
21
+ export declare function removeUnnecessaryProperties(obj: any): void;
22
+ //# sourceMappingURL=menuUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menuUtils.d.ts","sourceRoot":"","sources":["../../src/utils/menuUtils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AAC/E;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,aAAc,aAAa,EAAE,uBAAgB,aAAa,EAqBpF,CAAC;AAMF,wBAAgB,aAAa,CAAC,IAAI,KAAA,OAcjC;AACD,wBAAgB,SAAS,CAAC,GAAG,KAAA,EAAE,UAAU,SAAK,QAO7C;AAED,eAAO,MAAM,sBAAsB,cAAe,GAAG,EAAE,eAAc,MAAM,EAAE,UAS5E,CAAC;AAEF,eAAO,MAAM,sBAAsB,sBAalC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,KAAA,QAY9C"}
@@ -0,0 +1,91 @@
1
+ import {get,sortBy,cloneDeep}from'lodash-es';import {IPermissionType}from'@adminide-stack/core';import {logger}from'@cdm-logger/client';/**
2
+ * Custom menuDataRender function which will be called on component render
3
+ * to filter out menus from props.menuData on the basis of authorities.
4
+ *
5
+ * Note: This will be removed when menuDataRender issue
6
+ * is resolved with the next release of Layout Components.
7
+ *
8
+ * @param menuList
9
+ * @param authorities
10
+ */
11
+ const menuDataRender = (menuList, authorities) => {
12
+ logger.trace('menuDataRender execution started');
13
+ const sortedMenuList = sortMenusByPriority(menuList);
14
+ return (sortedMenuList
15
+ // filter routes with valid permission
16
+ .filter((item) => {
17
+ const { authority } = item;
18
+ if (Array.isArray(authority) && authority?.length) {
19
+ return authority.some((key) => IPermissionType.Allow === get(authorities, key));
20
+ }
21
+ return true;
22
+ })
23
+ .map((item) => {
24
+ // return Authorized.check(item.authority, localItem, null) as MenuDataItem;
25
+ return {
26
+ ...item,
27
+ children: item.children ? menuDataRender(item.children, authorities) : undefined,
28
+ };
29
+ }));
30
+ };
31
+ const sortMenusByPriority = (menus) => {
32
+ return sortBy(menus, (obj) => parseInt(obj.priority, 10));
33
+ };
34
+ function transformData(data) {
35
+ data.forEach((item) => {
36
+ if (item.routes && !item.children) {
37
+ item.children = cloneDeep(item.routes);
38
+ delete item.routes;
39
+ }
40
+ if (item.children && item.children.length > 0) {
41
+ transformData(item.children);
42
+ }
43
+ });
44
+ return data;
45
+ }
46
+ function setLocale(obj, parentName = '') {
47
+ const name = parentName ? `${parentName}.${obj.name}` : `menu.${obj.name}`;
48
+ obj.locale = name;
49
+ if (obj.routes && obj.routes.length > 0) {
50
+ obj.routes.forEach((child) => setLocale(child, obj.name));
51
+ }
52
+ }
53
+ const addProLayoutParentKeys = (menuData, parentKeys = []) => {
54
+ return (menuData || []).map((item) => {
55
+ const newItem = { ...item };
56
+ newItem.pro_layout_parentKeys = parentKeys; // Always set pro_layout_parentKeys for every item
57
+ if (item.children && item.children.length > 0) {
58
+ newItem.children = addProLayoutParentKeys(item.children, [...parentKeys, item.key]);
59
+ }
60
+ return newItem;
61
+ });
62
+ };
63
+ const filterRoutesWithLocale = (routes) => {
64
+ return routes
65
+ .filter((item) => {
66
+ if (item.routes && item.routes.length > 0) {
67
+ item.routes = filterRoutesWithLocale(item.routes);
68
+ }
69
+ return !item.hideInMenu;
70
+ })
71
+ .map((obj) => {
72
+ const newObj = { ...obj };
73
+ setLocale(newObj);
74
+ return newObj;
75
+ });
76
+ };
77
+ /**
78
+ *
79
+ * included [ 'dialogPath']
80
+ */
81
+ function removeUnnecessaryProperties(obj) {
82
+ const propertiesToRemove = ['componentPath', 'queries'];
83
+ for (const key in obj) {
84
+ if (propertiesToRemove.includes(key)) {
85
+ delete obj[key];
86
+ }
87
+ }
88
+ if (Array.isArray(obj.children)) {
89
+ obj.children.forEach((child) => removeUnnecessaryProperties(child));
90
+ }
91
+ }export{addProLayoutParentKeys,filterRoutesWithLocale,menuDataRender,removeUnnecessaryProperties,setLocale,transformData};//# sourceMappingURL=menuUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menuUtils.js","sources":["../../src/utils/menuUtils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAaG;AACH;AA2BA;AAeA,MAAA,uCAA+B;AAS/B,IAAO,MAAA,CAAA,KAAA,CAAA,kCAA2C,CAAA,CAAA;AAWlD,IAAO,MAAA,cAA4B,GAAA,mBAAA,CAAA,QAAA,CAAA,CAAA;AAenC,IAAA,QAAA,cAAA;;;AAGG,QAAA,MAAA,EAAA,SAAA,EAAA,GAAA,IAAA,CAAA;AACH,QAAA,IAAA,KAAA,CAAA,OAA2C,CAAA,SAAA,CAAA,IAAA,SAAA,EAAA,MAAI,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@admin-layout/client",
3
- "version": "7.0.2-alpha.0",
3
+ "version": "7.0.2-alpha.5",
4
4
  "description": "Sample client for higher packages to depend on",
5
5
  "license": "ISC",
6
6
  "author": "CDMBase LLC",
@@ -36,5 +36,5 @@
36
36
  "typescript": {
37
37
  "definition": "lib/index.d.ts"
38
38
  },
39
- "gitHead": "ee54ddb53f43010605863e32ab8644de4b597e4d"
39
+ "gitHead": "b5f8e42bd6b033914974cc9298b1eb98376eeefe"
40
40
  }