@antscorp/antsomi-ui 1.3.5-beta.590 → 1.3.5-beta.592

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 (27) hide show
  1. package/es/components/atoms/PreviewTabs/styled.js +3 -1
  2. package/es/components/icons/DomainManagementIcon.js +3 -3
  3. package/es/components/molecules/ShareAccess/components/PeopleAccess/styled.js +2 -2
  4. package/es/components/organism/AccountSharing/styled.js +14 -14
  5. package/es/components/organism/Help/Help.js +1 -1
  6. package/es/components/organism/LeftMenu/LeftMenu.js +35 -24
  7. package/es/components/organism/LeftMenu/components/HomeMenu/index.js +2 -2
  8. package/es/components/organism/LeftMenu/components/HomeMenu/useHomeMenu.d.ts +1 -1
  9. package/es/components/organism/LeftMenu/components/HomeMenu/useHomeMenu.js +4 -4
  10. package/es/components/organism/LeftMenu/components/common/ChildMenu/components/MenuItemImage/styled.js +3 -3
  11. package/es/components/organism/LeftMenu/components/common/ChildMenu/index.js +9 -11
  12. package/es/components/organism/LeftMenu/components/common/ChildMenu/styled.js +4 -4
  13. package/es/components/organism/LeftMenu/hooks/useLeftMenu.js +47 -69
  14. package/es/components/organism/LeftMenu/hooks/usePermission.js +6 -7
  15. package/es/components/organism/LeftMenu/index.d.ts +5 -5
  16. package/es/components/organism/LeftMenu/index.js +2 -1
  17. package/es/components/organism/LeftMenu/stores/index.d.ts +2 -3
  18. package/es/components/organism/LeftMenu/stores/index.js +2 -2
  19. package/es/components/organism/LeftMenu/styled.js +7 -7
  20. package/es/components/organism/LeftMenu/types/index.d.ts +1 -0
  21. package/es/components/template/Layout/Layout.js +1 -1
  22. package/es/components/template/Layout/components/RecommendationWorkspace/components/MenuMapping/index.d.ts +6 -1
  23. package/es/components/template/Layout/components/RecommendationWorkspace/components/MenuMapping/index.js +17 -6
  24. package/es/components/template/Layout/components/RecommendationWorkspace/components/MenuMapping/styled.js +5 -5
  25. package/package.json +1 -1
  26. package/es/components/template/Layout/components/RecommendationWorkspace/components/MenuMapping/components/OldLeftMenu/constants/index.d.ts +0 -0
  27. package/es/components/template/Layout/components/RecommendationWorkspace/components/MenuMapping/components/OldLeftMenu/constants/index.js +0 -1
@@ -1,4 +1,6 @@
1
+ var _a;
1
2
  // Components
3
+ import { THEME } from '@antscorp/antsomi-ui/es/constants';
2
4
  import { Flex } from '../Flex';
3
5
  // Styled
4
6
  import styled from 'styled-components';
@@ -54,7 +56,7 @@ export const NavigationButton = styled(Flex) `
54
56
 
55
57
  i {
56
58
  font-size: 12px;
57
- color: #595959;
59
+ color: ${(_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.bw8};
58
60
  }
59
61
 
60
62
  &.navigation--previous {
@@ -6,7 +6,7 @@ export const DomainManagementIcon = forwardRef((props, ref) => {
6
6
  // width="29"
7
7
  // height="29"
8
8
  viewBox: "0 0 29 29", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg" }, props, { ref: ref, width: width, height: height }),
9
- React.createElement("path", { d: "M10 20C8.02219 20 6.08879 19.4135 4.4443 18.3147C2.79981 17.2159 1.51809 15.6541 0.761209 13.8268C0.00433286 11.9996 -0.1937 9.98891 0.192152 8.0491C0.578004 6.10929 1.53041 4.32746 2.92894 2.92894C4.32746 1.53041 6.10929 0.578004 8.0491 0.192152C9.98891 -0.1937 11.9996 0.00433286 13.8268 0.761209C15.6541 1.51809 17.2159 2.79981 18.3147 4.4443C19.4135 6.08879 20 8.02219 20 10C19.9974 12.6514 18.9429 15.1934 17.0681 17.0681C15.1934 18.9429 12.6514 19.9974 10 20ZM6.59667 8.39167H6.60667C7.42334 8.42334 8.87667 9.875 9.285 11.07C9.4297 11.5445 9.47273 12.0441 9.41127 12.5364C9.34982 13.0286 9.18526 13.5023 8.92834 13.9267C8.79 14.2283 8.61 14.6683 8.41834 15.135C8.09667 15.9233 7.73167 16.8167 7.41834 17.42C8.69991 17.8646 10.0747 17.9705 11.4092 17.7272C12.7437 17.484 13.9927 16.8999 15.035 16.0317C14.99 15.1317 15 12 15 11.9633C14.6817 11.8633 11.9267 10.9117 12.5 8.74834C12.7925 8.21523 13.2351 7.77975 13.7728 7.49591C14.3106 7.21207 14.9198 7.09237 15.525 7.15167C16.1834 7.14554 16.8371 7.26372 17.4517 7.5C17.1519 6.60523 16.6922 5.77228 16.095 5.04167C16.0615 5.00484 16.0201 4.97598 15.974 4.95724C15.9278 4.93849 15.8781 4.93032 15.8283 4.93334C15.606 4.95883 15.3951 5.04513 15.2187 5.18274C15.0422 5.32035 14.9072 5.50394 14.8283 5.71334C14.7967 5.80667 14.7733 5.895 14.7483 5.98167C14.6417 6.365 14.565 6.64834 14.0817 6.64834C13.9698 6.64709 13.8582 6.63593 13.7483 6.615C13.6293 6.60047 13.5146 6.56124 13.4115 6.49983C13.3085 6.43841 13.2194 6.35616 13.15 6.25834C13.0268 6.04163 12.986 5.78774 13.035 5.54334H13.7483V5H13.7383C13.5433 4.91667 13.0833 4.70334 13.0283 4.53834C13.023 4.52714 13.0202 4.5149 13.0202 4.5025C13.0202 4.49011 13.023 4.47786 13.0283 4.46667C13.4144 4.07223 13.849 3.72837 14.3217 3.44334C14.0489 3.26422 13.7656 3.10171 13.4733 2.95667C13.3667 3.14667 13.1217 3.22834 12.66 3.22834C12.5617 3.22834 12.4483 3.22834 12.315 3.21667C12.2256 3.22398 12.1359 3.20711 12.0552 3.16781C11.9746 3.12852 11.906 3.06825 11.8567 2.99334C11.8247 2.89165 11.8196 2.78343 11.8418 2.67918C11.864 2.57493 11.9127 2.47819 11.9833 2.39834C10.7781 2.08637 9.51627 2.06239 8.3 2.32834C8.26785 3.51083 7.93887 4.66625 7.34334 5.68834C7.275 5.815 7.205 5.94167 7.13834 6.07334C6.67167 6.98 4.48167 7.85 4.46 7.85834C4.85392 8.4311 5.21183 9.02781 5.53167 9.645C5.53874 9.3457 5.64838 9.0579 5.84224 8.82975C6.0361 8.60161 6.30243 8.44696 6.59667 8.39167ZM2.375 8.09334C1.99053 9.64021 2.08472 11.2674 2.6451 12.7595C3.20549 14.2517 4.20567 15.5386 5.51334 16.45C5.59575 15.6714 5.60356 14.8867 5.53667 14.1067L3.75 12.5L4.28667 10C4.27834 10 3.13167 8.73167 2.375 8.09334Z" }),
10
- React.createElement("path", { d: "M13.3674 12.0699L11.2275 11.2247L12.0693 13.3659L16.2184 23.9195L17.0515 26.0386L18.0482 23.9913L19.1392 21.7502L22.1044 24.708L22.8088 25.4106L23.515 24.7099L24.7044 23.5297L25.4298 22.8099L24.6944 22.1003L21.7366 19.2459L24.1054 18.1204L26.1842 17.1326L24.0436 16.2871L13.3674 12.0699Z", stroke: "white", strokeWidth: "2" }),
11
- React.createElement("path", { d: "M19.016 18.8012C19.0016 18.8894 18.9992 18.978 19.0081 19.0648C18.9031 19.0483 18.7949 19.0485 18.6873 19.0666C18.3687 19.1202 18.0957 19.3245 17.9543 19.615L17.2466 21.0686L14.7725 14.7753L21.1682 17.3017L19.5737 18.0593C19.2773 18.2001 19.0689 18.4774 19.016 18.8012Z", fill: "white", stroke: "#595959", strokeWidth: "2", strokeMiterlimit: "7.6613", strokeLinejoin: "round" })));
9
+ React.createElement("path", { d: "M15.7,15.7l1.9,0.8c1.6-1.8,2.4-4.1,2.4-6.5c0-2-0.6-3.9-1.7-5.6c-1.1-1.6-2.7-2.9-4.5-3.7C12,0,10-0.2,8,0.2\n\tC6.1,0.6,4.3,1.5,2.9,2.9C1.5,4.3,0.6,6.1,0.2,8c-0.4,2-0.2,4,0.6,5.8s2,3.4,3.7,4.5C6.1,19.4,8,20,10,20c2.3,0,4.7-0.9,6.4-2.4\n\tL15.7,15.7z M5.5,16.5c-1.3-0.9-2.3-2.2-2.9-3.7C2.1,11.3,2,9.6,2.4,8.1C3.1,8.7,4.3,10,4.3,10l-0.5,2.5l1.8,1.6\n\tC5.6,14.9,5.6,15.7,5.5,16.5z M13.8,7.5c-0.5,0.3-1,0.7-1.3,1.3C11.9,11,14.7,11.9,15,12c0,0,0,3.2,0,4.1c-1,0.9-2.3,1.5-3.6,1.7\n\tc-1.3,0.2-2.7,0.1-4-0.3c0.3-0.6,0.7-1.5,1-2.3c0.2-0.5,0.4-0.9,0.5-1.2c0.3-0.4,0.4-0.9,0.5-1.4c0.1-0.5,0-1-0.1-1.5\n\tC8.9,9.9,7.4,8.4,6.6,8.4C6.3,8.4,6,8.6,5.8,8.8S5.5,9.3,5.5,9.6C5.2,9,4.9,8.4,4.5,7.9c0,0,2.2-0.9,2.7-1.8C7.3,6,7.3,5.8,7.4,5.7\n\tc0.6-1,0.9-2.2,1-3.4c1.2-0.3,2.5-0.2,3.7,0.1C12,2.5,12,2.6,12,2.7c0,0.1,0,0.2,0,0.3s0.1,0.1,0.2,0.2c0.1,0,0.2,0.1,0.3,0\n\tc0.1,0,0.2,0,0.3,0c0.5,0,0.7-0.1,0.8-0.3c0.3,0.1,0.6,0.3,0.8,0.5c-0.5,0.3-0.9,0.6-1.3,1c0.1,0.2,0.5,0.4,0.7,0.5v0.5H13\n\tc0,0.2,0,0.5,0.1,0.7c0.1,0.1,0.2,0.2,0.3,0.2c0.1,0.1,0.2,0.1,0.3,0.1c0.1,0,0.2,0,0.3,0c0.5,0,0.6-0.3,0.7-0.7\n\tc0-0.1,0-0.2,0.1-0.3C14.9,5.2,15,5,15.2,4.9c0.2,0.1,0.4,0.1,0.6,0h0.1c0,0,0.1,0,0.1,0.1c0.6,0.7,1.1,1.6,1.4,2.5\n\tc-0.6-0.2-1.3-0.4-1.9-0.3C14.9,7.1,14.3,7.2,13.8,7.5z" }),
10
+ React.createElement("path", { fill: "white", d: "M28.7,17L9.5,9.4L17,28.5l2.5-5.1l3.4,3.4l4.1-4l-3.4-3.3L28.7,17z M19,18c-0.1,0-0.2,0.2-0.3,0.4l-0.1,0.2\n\tl-0.2,0.1c-0.2,0.1-0.4,0.2-0.6,0.4l-0.5,0.5l-1.5-3.9l4.5,1.8L19,18z" }),
11
+ React.createElement("path", { d: "M20,19l3.7-1.7L13,13l4.1,10.6l1.7-3.5l4,3.9l1.2-1.2L20,19z M18.2,18.2c-0.3,0.1-0.6,0.3-0.8,0.5l-0.8-2.1l2.2,0.9\n\tC18.5,17.6,18.3,17.9,18.2,18.2z" })));
12
12
  });
@@ -1,4 +1,4 @@
1
- var _a;
1
+ var _a, _b;
2
2
  import { THEME } from '@antscorp/antsomi-ui/es/constants';
3
3
  import styled from 'styled-components';
4
4
  export const StyledPeopleAccessRoot = styled.div `
@@ -36,7 +36,7 @@ export const StyledPeopleAccessRoot = styled.div `
36
36
  }
37
37
 
38
38
  .email {
39
- color: #595959;
39
+ color: ${(_b = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _b === void 0 ? void 0 : _b.bw8};
40
40
  }
41
41
  }
42
42
 
@@ -1,4 +1,4 @@
1
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
2
2
  import styled from 'styled-components';
3
3
  import { THEME } from '@antscorp/antsomi-ui/es/constants';
4
4
  export const InputSearchStyled = styled.div `
@@ -45,7 +45,7 @@ export const InputSearchStyled = styled.div `
45
45
 
46
46
  svg {
47
47
  position: absolute;
48
- fill: #595959;
48
+ fill: ${(_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.bw8};
49
49
  right: 5px;
50
50
  width: 20px;
51
51
  height: 20px;
@@ -70,7 +70,7 @@ export const TriggerPopoverStyled = styled.div `
70
70
  justify-content: space-between;
71
71
  gap: 15px;
72
72
  padding: 3px 3px 3px 10px;
73
- border: 1px solid ${(_a = THEME.token) === null || _a === void 0 ? void 0 : _a.bw3};
73
+ border: 1px solid ${(_b = THEME.token) === null || _b === void 0 ? void 0 : _b.bw3};
74
74
  background-color: white;
75
75
  border-radius: 999px;
76
76
 
@@ -105,7 +105,7 @@ export const PackageSharingStyled = styled.div `
105
105
  font-size: 13px;
106
106
  color: #666;
107
107
 
108
- background-color: ${(_b = THEME.token) === null || _b === void 0 ? void 0 : _b.blue1_2};
108
+ background-color: ${(_c = THEME.token) === null || _c === void 0 ? void 0 : _c.blue1_2};
109
109
 
110
110
  min-width: 400px;
111
111
  max-width: 400px;
@@ -203,14 +203,14 @@ export const PackageSharingStyled = styled.div `
203
203
  li {
204
204
  cursor: pointer;
205
205
  padding: 8px 5px;
206
- border-radius: ${(_c = THEME.token) === null || _c === void 0 ? void 0 : _c.borderRadius}px;
206
+ border-radius: ${(_d = THEME.token) === null || _d === void 0 ? void 0 : _d.borderRadius}px;
207
207
  display: flex;
208
208
  justify-content: space-between;
209
209
  align-items: center;
210
210
  gap: 10px;
211
211
 
212
212
  &:hover {
213
- background-color: ${(_d = THEME.token) === null || _d === void 0 ? void 0 : _d.blue};
213
+ background-color: ${(_e = THEME.token) === null || _e === void 0 ? void 0 : _e.blue};
214
214
  }
215
215
 
216
216
  .account-name {
@@ -257,7 +257,7 @@ export const PackageSharingStyled = styled.div `
257
257
  height: 42px;
258
258
  padding: 10px;
259
259
  border-radius: 10px;
260
- border: 1px solid ${(_e = THEME.token) === null || _e === void 0 ? void 0 : _e.bw4};
260
+ border: 1px solid ${(_f = THEME.token) === null || _f === void 0 ? void 0 : _f.bw4};
261
261
 
262
262
  & img {
263
263
  width: 100%;
@@ -281,15 +281,15 @@ export const PackageSharingStyled = styled.div `
281
281
  cursor: pointer;
282
282
  &:hover {
283
283
  .image-wrapper {
284
- background-color: ${(_f = THEME.token) === null || _f === void 0 ? void 0 : _f.blue};
285
- border-color: ${(_g = THEME.token) === null || _g === void 0 ? void 0 : _g.blue3};
284
+ background-color: ${(_g = THEME.token) === null || _g === void 0 ? void 0 : _g.blue};
285
+ border-color: ${(_h = THEME.token) === null || _h === void 0 ? void 0 : _h.blue3};
286
286
  }
287
287
  }
288
288
  &.disabled {
289
289
  cursor: default;
290
290
  .image-wrapper {
291
- background: ${(_h = THEME.token) === null || _h === void 0 ? void 0 : _h.blue1_1};
292
- border-color: ${(_j = THEME.token) === null || _j === void 0 ? void 0 : _j.blue7};
291
+ background: ${(_j = THEME.token) === null || _j === void 0 ? void 0 : _j.blue1_1};
292
+ border-color: ${(_k = THEME.token) === null || _k === void 0 ? void 0 : _k.blue7};
293
293
  img {
294
294
  cursor: default;
295
295
  }
@@ -298,7 +298,7 @@ export const PackageSharingStyled = styled.div `
298
298
  .image-wrapper {
299
299
  border: 1px solid #ddd;
300
300
  padding: 10px;
301
- border-radius: ${(_k = THEME.token) === null || _k === void 0 ? void 0 : _k.borderRadius}px;
301
+ border-radius: ${(_l = THEME.token) === null || _l === void 0 ? void 0 : _l.borderRadius}px;
302
302
  transition: all 0.2s ease-in-out;
303
303
  /* width: 108px;
304
304
  height: 45px; */
@@ -307,7 +307,7 @@ export const PackageSharingStyled = styled.div `
307
307
  }
308
308
  }
309
309
  .network-name {
310
- color: ${(_l = THEME.token) === null || _l === void 0 ? void 0 : _l.bw8};
310
+ color: ${(_m = THEME.token) === null || _m === void 0 ? void 0 : _m.bw8};
311
311
  font-size: 11px;
312
312
  margin-top: 5px;
313
313
  margin-bottom: 0;
@@ -337,7 +337,7 @@ export const PackageSharingStyled = styled.div `
337
337
  export const InnerCardStyled = styled.div `
338
338
  width: 370px;
339
339
  background-color: white;
340
- border-radius: ${(_m = THEME.token) === null || _m === void 0 ? void 0 : _m.borderRadius}px;
340
+ border-radius: ${(_o = THEME.token) === null || _o === void 0 ? void 0 : _o.borderRadius}px;
341
341
  padding: 10px;
342
342
  margin-bottom: 15px;
343
343
  `;
@@ -833,7 +833,7 @@ const Help = props => {
833
833
  "Message ",
834
834
  React.createElement("span", { style: { color: (_e = THEME.token) === null || _e === void 0 ? void 0 : _e.red8 } }, "*")),
835
835
  React.createElement(EditorWrapper, null,
836
- React.createElement(Editor, { apiKey: apiKey, value: valueInput.message, init: {
836
+ React.createElement(Editor, { apiKey: apiKey || TINYMCE_API_KEY, value: valueInput.message, init: {
837
837
  height: 200,
838
838
  width: '100%',
839
839
  max_height: 800,
@@ -13,35 +13,45 @@ import { APP_KEYS } from './constants';
13
13
  import { CustomMenu, CommonMenu, HomeMenu } from './components';
14
14
  // Hooks
15
15
  import { useLeftMenu } from './hooks';
16
+ // Contexts
16
17
  import { useLeftMenuContext } from './contexts';
17
18
  const SubLogoAntsomi = 'https://st-media-template.antsomi.com/icons/antsomi/antsomi.png';
19
+ const homePermissionCode = 'DASHBOARD';
18
20
  export const LeftMenuComponent = memo(props => {
19
21
  const { show = true, style, className, customization, showLogo = true } = props;
20
- const { isExpandable = true, isCustomized, isRecommendation, items = [], onMenuItemClick, } = customization || {};
22
+ const { showMenuPopover = true, showButtonExpand = true, type, items = [], onMenuItemClick, } = customization || {};
21
23
  const appHoverMenuChildren = useLeftMenuContext(store => store.appHoverMenuChildren);
24
+ const customHoverMenuChildren = useLeftMenuContext(store => store.customHoverMenuChildren);
25
+ const hoverMenuChildren = useMemo(() => {
26
+ if (type === 'customization')
27
+ return customHoverMenuChildren;
28
+ return appHoverMenuChildren;
29
+ }, [appHoverMenuChildren, customHoverMenuChildren, type]);
22
30
  const { state, activeAppCode, permissionMenu, customActiveAppKey, onToggleChildMenu, onMouseEnter, onMouseLeave, onHoverMenuBar, onShowPopover, onClickFeatureMenuItem, } = useLeftMenu(props);
23
31
  const childActiveMenu = useMemo(() => {
24
- const appActiveKey = isCustomized || isRecommendation ? customActiveAppKey : activeAppCode;
25
- if (isCustomized)
32
+ const appActiveKey = ['customization', 'recommendation'].includes(`${type}`)
33
+ ? customActiveAppKey
34
+ : activeAppCode;
35
+ if (type === 'customization')
26
36
  return React.createElement(CustomMenu, null);
27
37
  switch (appActiveKey) {
28
- case isRecommendation ? 'DASHBOARD' : APP_KEYS.HOME:
38
+ case type === 'recommendation' ? homePermissionCode : APP_KEYS.HOME:
29
39
  return React.createElement(HomeMenu, null);
30
40
  default:
31
41
  return React.createElement(CommonMenu, null);
32
42
  }
33
- }, [activeAppCode, customActiveAppKey, isCustomized, isRecommendation]);
43
+ }, [activeAppCode, customActiveAppKey, type]);
34
44
  const childHoverMenu = useMemo(() => {
35
45
  const appActiveKey = state.hoverItem;
36
- if (isCustomized)
46
+ if (type === 'customization')
37
47
  return React.createElement(CustomMenu, { isHover: true });
38
48
  switch (appActiveKey) {
39
- case isRecommendation ? 'DASHBOARD' : APP_KEYS.HOME:
40
- return React.createElement(HomeMenu, { isHover: !isRecommendation });
49
+ case type === 'recommendation' ? homePermissionCode : APP_KEYS.HOME:
50
+ return React.createElement(HomeMenu, { isHover: type !== 'recommendation' });
41
51
  default:
42
- return React.createElement(CommonMenu, { isHover: !isRecommendation });
52
+ return React.createElement(CommonMenu, { isHover: type !== 'recommendation' });
43
53
  }
44
- }, [isCustomized, isRecommendation, state.hoverItem]);
54
+ }, [state.hoverItem, type]);
45
55
  const renderFeatureMenuItem = useCallback((item) => {
46
56
  const { menu_item_name, menu_item, icon_name, menu_item_code } = item;
47
57
  const isActive = activeAppCode === menu_item_code;
@@ -49,9 +59,9 @@ export const LeftMenuComponent = memo(props => {
49
59
  const renderLabel = () => (React.createElement("li", { role: "menuitem", className: classNames({ isActive, isHover }) },
50
60
  React.createElement(IconWrapper, null, isNil(icon_name) ? null : React.createElement(Icon, { type: icon_name })),
51
61
  React.createElement(Typography.Text, null, menu_item_name),
52
- isExpandable && React.createElement("div", { className: "popup-triangle" })));
62
+ showMenuPopover && React.createElement("div", { className: "popup-triangle" })));
53
63
  return (React.createElement(FeatureMenuItem, { key: menu_item, onClick: () => onClickFeatureMenuItem(item), onMouseEnter: () => onMouseEnter(menu_item_code) }, renderLabel()));
54
- }, [activeAppCode, state.hoverItem, isExpandable, onMouseEnter, onClickFeatureMenuItem]);
64
+ }, [activeAppCode, state.hoverItem, showMenuPopover, onMouseEnter, onClickFeatureMenuItem]);
55
65
  const renderRecommendationMenuItem = useCallback((item) => {
56
66
  const { menu_item_name, menu_item, icon_name, permission_code } = item;
57
67
  const isActive = customActiveAppKey === permission_code;
@@ -69,33 +79,34 @@ export const LeftMenuComponent = memo(props => {
69
79
  React.createElement("li", { role: "menuitem", className: classNames({ isActive, isHover }) },
70
80
  React.createElement(IconWrapper, null, isNil(icon) ? null : React.createElement(Icon, { type: icon })),
71
81
  React.createElement(Typography.Text, null, label),
72
- isExpandable && React.createElement("div", { className: "popup-triangle" }))));
73
- }), [customActiveAppKey, state.hoverItem, isExpandable, onMenuItemClick, onMouseEnter]);
82
+ showMenuPopover && React.createElement("div", { className: "popup-triangle" }))));
83
+ }), [customActiveAppKey, state.hoverItem, showMenuPopover, onMenuItemClick, onMouseEnter]);
74
84
  const renderAppMenuItems = useCallback(() => {
75
85
  var _a;
76
- return isCustomized
86
+ return type === 'customization'
77
87
  ? renderCustomizedMenuItems(items)
78
- : (_a = permissionMenu === null || permissionMenu === void 0 ? void 0 : permissionMenu.filter(item => item.menu_item_code !== APP_KEYS.SETTINGS)) === null || _a === void 0 ? void 0 : _a.map(item => isRecommendation ? renderRecommendationMenuItem(item) : renderFeatureMenuItem(item));
88
+ : (_a = permissionMenu === null || permissionMenu === void 0 ? void 0 : permissionMenu.filter(item => item.menu_item_code !== APP_KEYS.SETTINGS)) === null || _a === void 0 ? void 0 : _a.map(item => type === 'recommendation'
89
+ ? renderRecommendationMenuItem(item)
90
+ : renderFeatureMenuItem(item));
79
91
  }, [
80
- isCustomized,
81
- isRecommendation,
82
92
  items,
83
93
  permissionMenu,
84
94
  renderCustomizedMenuItems,
85
95
  renderFeatureMenuItem,
86
96
  renderRecommendationMenuItem,
97
+ type,
87
98
  ]);
88
99
  const renderSettings = () => {
89
- if (!isCustomized) {
100
+ if (type !== 'customization') {
90
101
  const settingApp = permissionMenu === null || permissionMenu === void 0 ? void 0 : permissionMenu.find(item => item.menu_item_code === APP_KEYS.SETTINGS);
91
102
  if (settingApp)
92
- return isRecommendation
103
+ return type === 'recommendation'
93
104
  ? renderRecommendationMenuItem(settingApp)
94
105
  : renderFeatureMenuItem(settingApp);
95
106
  }
96
107
  return null;
97
108
  };
98
- return (React.createElement(LeftMenuNavWrapper, { "$show": show, style: style, "$isExpandMenu": state.isExpandMenu && isExpandable, className: className },
109
+ return (React.createElement(LeftMenuNavWrapper, { "$show": show, style: style, "$isExpandMenu": state.isExpandMenu, className: className },
99
110
  React.createElement(LeftMenuNav, { className: "left-menu-nav" },
100
111
  React.createElement(FeatureMenuWrapper, { vertical: true, onMouseEnter: () => onShowPopover(), onMouseLeave: onMouseLeave },
101
112
  showLogo && (React.createElement(NavLogoWrapper, { align: "center", justify: "center", onMouseEnter: onHoverMenuBar },
@@ -104,15 +115,15 @@ export const LeftMenuComponent = memo(props => {
104
115
  React.createElement(FeatureMenu, { role: "menu", className: "antsomi-scroll-box" },
105
116
  React.createElement("div", { className: "menu-content scroll-content" }, renderAppMenuItems()),
106
117
  React.createElement("div", { className: "nav-blank", onMouseEnter: onHoverMenuBar }),
107
- !isRecommendation && (React.createElement(PopoverWrapper, { show: state.isShowPopover && !isEmpty(appHoverMenuChildren) /* && isExpandable */, hasMarginTop: !isRecommendation, className: "antsomi-scroll-box antsomi-child-menu-popover" },
118
+ showMenuPopover && (React.createElement(PopoverWrapper, { show: state.isShowPopover && !isEmpty(hoverMenuChildren), hasMarginTop: type !== 'recommendation', className: "antsomi-scroll-box antsomi-child-menu-popover" },
108
119
  React.createElement("div", { className: "scroll-content", style: { width: '200px', maxHeight: '100%' } }, childHoverMenu)))),
109
120
  React.createElement("div", { style: { flexShrink: 0 } }, renderSettings())),
110
- isExpandable && !isRecommendation && (React.createElement(ExpandWrapper, { onMouseEnter: onMouseLeave },
121
+ showButtonExpand && (React.createElement(ExpandWrapper, { onMouseEnter: onMouseLeave },
111
122
  React.createElement(Icon, { type: "icon-ants-expand-more", style: {
112
123
  cursor: 'pointer',
113
124
  fontSize: '20px',
114
125
  transform: `rotate(${state.isExpandMenu ? '90deg' : '270deg'})`,
115
126
  }, onClick: onToggleChildMenu })))),
116
- React.createElement(ChildMenuWrapper, { isExpand: state.isExpandMenu && isExpandable, isMarginTop: showLogo, className: "antsomi-scroll-box" },
127
+ React.createElement(ChildMenuWrapper, { isExpand: state.isExpandMenu, isMarginTop: showLogo, className: "antsomi-scroll-box" },
117
128
  React.createElement("div", { className: "scroll-content", style: { width: '200px', maxHeight: '100%' } }, childActiveMenu))));
118
129
  }, (prevProps, nextProps) => isEqual(prevProps, nextProps));
@@ -10,10 +10,10 @@ import { CreateButton, HomeMenuWrapper, ModalWrapper } from './styled';
10
10
  // Hooks
11
11
  import { useHomeMenu } from './useHomeMenu';
12
12
  export const HomeMenu = memo(props => {
13
- const { children, removedDashboardId, isDashboardRemoving, isRecommendation, showCreateButton, setRemovedDashboardId, onCreateNewReport, onMenuClick, onRemoveDashboard, } = useHomeMenu(props);
13
+ const { children, removedDashboardId, isDashboardRemoving, type, showCreateButton, setRemovedDashboardId, onCreateNewReport, onMenuClick, onRemoveDashboard, } = useHomeMenu(props);
14
14
  return (React.createElement(React.Fragment, null,
15
15
  React.createElement(HomeMenuWrapper, { gap: 10, vertical: true },
16
- !isRecommendation && showCreateButton && (React.createElement(CreateButton, { type: "primary", onClick: onCreateNewReport },
16
+ type !== 'recommendation' && showCreateButton && (React.createElement(CreateButton, { type: "primary", onClick: onCreateNewReport },
17
17
  React.createElement(Flex, { gap: 10, align: "center" },
18
18
  React.createElement(Icon, { type: "icon-ants-plus-slim", style: { fontSize: 14 } }),
19
19
  React.createElement("span", null, "Create")))),
@@ -4,7 +4,7 @@ export declare const useHomeMenu: (props: HomeMenuProps) => {
4
4
  children: import("../../types").TMenuItem[];
5
5
  removedDashboardId: string;
6
6
  isDashboardRemoving: boolean;
7
- isRecommendation: boolean | undefined;
7
+ type: import("../../types").TLeftMenuType | undefined;
8
8
  showCreateButton: boolean;
9
9
  setRemovedDashboardId: import("react").Dispatch<import("react").SetStateAction<string>>;
10
10
  onCreateNewReport: import("react").MouseEventHandler<HTMLElement>;
@@ -28,7 +28,7 @@ export const useHomeMenu = (props) => {
28
28
  const { navigate, replace } = useCustomRouter();
29
29
  const appMenuChildren = useLeftMenuContext(store => store.appMenuChildren);
30
30
  const appHoverMenuChildren = useLeftMenuContext(store => store.appHoverMenuChildren);
31
- const isRecommendation = useLeftMenuContext(store => store.isRecommendation);
31
+ const type = useLeftMenuContext(store => store.type);
32
32
  const auth = useLeftMenuContext(store => { var _a; return (_a = store.appConfig) === null || _a === void 0 ? void 0 : _a.auth; });
33
33
  const env = useLeftMenuContext(store => { var _a; return (_a = store.appConfig) === null || _a === void 0 ? void 0 : _a.env; });
34
34
  const dashboardParams = useLeftMenuContext(store => store.dashboardParams);
@@ -81,13 +81,13 @@ export const useHomeMenu = (props) => {
81
81
  }
82
82
  }, [auth, env, navigate, onClickCreateDashboard, origin, replace, urlParams]);
83
83
  const onMenuClick = useCallback((key, _keyPath) => {
84
- if (!isRecommendation) {
84
+ if (type !== 'recommendation') {
85
85
  const newPathName = getGeneratePath(HOME_REPORT_ROUTES.DETAIL, Object.assign(Object.assign({}, auth), { dashboardId: key }));
86
86
  if (newPathName !== pathname) {
87
87
  navigate(newPathName);
88
88
  }
89
89
  }
90
- }, [isRecommendation, auth, pathname, navigate]);
90
+ }, [type, auth, pathname, navigate]);
91
91
  const onRemoveDashboard = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
92
92
  var _a, _b;
93
93
  if (removedDashboardId && auth && env) {
@@ -129,7 +129,7 @@ export const useHomeMenu = (props) => {
129
129
  children: isHover ? customHoverChildren : customChildren,
130
130
  removedDashboardId,
131
131
  isDashboardRemoving,
132
- isRecommendation,
132
+ type,
133
133
  showCreateButton,
134
134
  setRemovedDashboardId,
135
135
  onCreateNewReport,
@@ -1,4 +1,4 @@
1
- var _a;
1
+ var _a, _b;
2
2
  import styled from 'styled-components';
3
3
  // Constants
4
4
  import { ICON_SIZE } from '../../../../../constants';
@@ -8,7 +8,7 @@ import { Flex } from '../../../../../../../atoms';
8
8
  export const MaskImage = styled.div `
9
9
  width: ${ICON_SIZE}px;
10
10
  height: ${ICON_SIZE}px;
11
- background: #595959;
11
+ background: ${(_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.bw8};
12
12
  mask-size: contain;
13
13
  mask-position: center center;
14
14
  mask-repeat: no-repeat;
@@ -19,7 +19,7 @@ export const MenuItemImageWrapper = styled(Flex) `
19
19
 
20
20
  &.isActive {
21
21
  ${MaskImage} {
22
- background: ${(_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.colorPrimary} !important;
22
+ background: ${(_b = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _b === void 0 ? void 0 : _b.colorPrimary} !important;
23
23
  }
24
24
  }
25
25
  `;
@@ -46,8 +46,7 @@ export const ChildMenu = memo(props => {
46
46
  const activeAppCode = useLeftMenuContext(store => store.activeAppCode);
47
47
  const menuItems = useLeftMenuContext(store => store.menuItems);
48
48
  const customItems = useLeftMenuContext(store => store.customItems);
49
- const isCustomized = useLeftMenuContext(store => store.isCustomized);
50
- const isRecommendation = useLeftMenuContext(store => store.isRecommendation);
49
+ const type = useLeftMenuContext(store => store.type);
51
50
  const customActiveCurrentKey = useLeftMenuContext(store => store.customActiveCurrentKey);
52
51
  const setLeftMenuState = useLeftMenuContext(store => store.setState);
53
52
  const { navigate } = useCustomRouter();
@@ -59,8 +58,8 @@ export const ChildMenu = memo(props => {
59
58
  setOpenKeys((items === null || items === void 0 ? void 0 : items.map(item => item.key)) || []);
60
59
  }, [items]);
61
60
  useDeepCompareEffect(() => {
62
- switch (true) {
63
- case isCustomized: {
61
+ switch (type) {
62
+ case 'customization': {
64
63
  setCurrentActiveItem(customActiveCurrentKey);
65
64
  // Find parent key of active menu item to open it
66
65
  const parentKey = recursiveFindParentOfActiveItem({
@@ -72,7 +71,7 @@ export const ChildMenu = memo(props => {
72
71
  }
73
72
  break;
74
73
  }
75
- case isRecommendation: {
74
+ case 'recommendation': {
76
75
  const menuActiveKey = handleActiveRecommendationItem({
77
76
  customActiveCurrentKey,
78
77
  currentActiveItem,
@@ -128,15 +127,14 @@ export const ChildMenu = memo(props => {
128
127
  pathname,
129
128
  activeAppCode,
130
129
  menuItems,
131
- isCustomized,
130
+ type,
132
131
  customActiveCurrentKey,
133
132
  customItems,
134
- isRecommendation,
135
133
  env,
136
134
  setLeftMenuState,
137
135
  ]);
138
136
  const onClick = e => {
139
- if (isRecommendation) {
137
+ if (type === 'recommendation') {
140
138
  const [permissionCode, permissionCodePath] = (() => {
141
139
  var _a;
142
140
  if (e.key === 'WEB_PERSONALIZE') {
@@ -184,7 +182,7 @@ export const ChildMenu = memo(props => {
184
182
  const isOwnerDashboardKey = key === HOME_MENU_ITEMS.DASHBOARD;
185
183
  const renderLabel = () => (React.createElement(LabelWrapper, { gap: 10, align: "center", justify: "space-between", style: style },
186
184
  React.createElement(LabelCustom, { ellipsis: { tooltip: label } }, label),
187
- (options === null || options === void 0 ? void 0 : options.length) && !isRecommendation && (React.createElement(OptionDropdownWrapper, { align: "center" },
185
+ (options === null || options === void 0 ? void 0 : options.length) && type !== 'recommendation' && (React.createElement(OptionDropdownWrapper, { align: "center" },
188
186
  React.createElement(Dropdown, { menu: {
189
187
  items: options,
190
188
  onClick: e => {
@@ -195,14 +193,14 @@ export const ChildMenu = memo(props => {
195
193
  style: styles.dropdownMenu,
196
194
  }, trigger: ['click'] },
197
195
  React.createElement(Icon, { className: "child-menu-item-icon", type: "icon-ants-three-dot-vertical", style: styles.dotIcon })))),
198
- !(children === null || children === void 0 ? void 0 : children.length) && isRecommendation && !!menu_item_path && (React.createElement(Link, { to: getPath(menu_item_path), className: "icon-link", target: "_blank", onClick: e => e.stopPropagation() },
196
+ !(children === null || children === void 0 ? void 0 : children.length) && type === 'recommendation' && !!menu_item_path && (React.createElement(Link, { to: getPath(menu_item_path), className: "icon-link", target: "_blank", onClick: e => e.stopPropagation() },
199
197
  React.createElement(Icon, { type: "icon-ants-open-in-new-window" })))));
200
198
  const renderIcon = () => {
201
199
  var _a;
202
200
  return !!icon || !!logo_url ? (React.createElement(Flex, { style: { flexShrink: 0 }, align: "center" }, !isNil(icon) ? (React.createElement(IconWrapper, null,
203
201
  React.createElement(Icon, { type: icon }))) : !isNil(logo_url) ? (React.createElement(MenuItemImage, { imageUrl: logo_url, fallbackIcon: (_a = args === null || args === void 0 ? void 0 : args.parent) === null || _a === void 0 ? void 0 : _a.icon, className: classNames({ isActive: currentActiveItem === key }) })) : null)) : null;
204
202
  };
205
- const renderTitle = () => !menu_item_path || isRecommendation ? (renderLabel()) : (React.createElement("div", { className: "menu-link" }, renderLabel()));
203
+ const renderTitle = () => !menu_item_path || type === 'recommendation' ? (renderLabel()) : (React.createElement("div", { className: "menu-link" }, renderLabel()));
206
204
  return {
207
205
  key,
208
206
  label: (React.createElement(Flex, { gap: 10, align: "center", justify: "space-between", style: { height: '100%' }, onClick: () => onClickMenuItem(item) },
@@ -1,4 +1,4 @@
1
- var _a, _b;
1
+ var _a, _b, _c;
2
2
  // Libraries
3
3
  import styled from 'styled-components';
4
4
  // Components
@@ -14,7 +14,7 @@ export const LabelWrapper = styled(Flex) `
14
14
  width: fit-content;
15
15
  display: none;
16
16
  text-decoration-line: none !important;
17
- color: #595959 !important;
17
+ color: ${(_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.bw8} !important;
18
18
 
19
19
  i {
20
20
  font-size: 15px !important;
@@ -58,7 +58,7 @@ export const MenuWrapper = styled.div `
58
58
  margin: 0;
59
59
  padding-left: 0px !important;
60
60
  width: 100%;
61
- border-radius: ${(_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.borderRadiusXL}px;
61
+ border-radius: ${(_b = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _b === void 0 ? void 0 : _b.borderRadiusXL}px;
62
62
  padding-right: 4px !important;
63
63
  }
64
64
  }
@@ -72,7 +72,7 @@ export const MenuWrapper = styled.div `
72
72
  & .antsomi-menu-title-content {
73
73
  width: 100%;
74
74
  height: 100%;
75
- border-radius: ${(_b = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _b === void 0 ? void 0 : _b.borderRadiusXL}px;
75
+ border-radius: ${(_c = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _c === void 0 ? void 0 : _c.borderRadiusXL}px;
76
76
  padding: 0 8px;
77
77
 
78
78
  &:hover {
@@ -1,9 +1,10 @@
1
1
  // Libraries
2
2
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
- import { isArray, isNil } from 'lodash';
3
+ import { isArray, isBoolean, isNil } from 'lodash';
4
4
  import { Cookies as ReactCookies } from 'react-cookie';
5
5
  // Utils
6
6
  import { findActiveAppCodeByChild, findActiveAppCodeByUrl, recursiveGetMenuItemByPermission, } from '../utils';
7
+ import { flatTree } from '@antscorp/antsomi-ui/es/utils';
7
8
  // Store
8
9
  import { useLeftMenuContext } from '../contexts';
9
10
  // Constants
@@ -12,13 +13,12 @@ import { DASHBOARD_MODULE_CONFIG } from '../../../template/Layout/constants';
12
13
  import { usePermission } from './usePermission';
13
14
  import { useCustomRouter, useDeepCompareEffect } from '@antscorp/antsomi-ui/es/hooks';
14
15
  import { useNavigatePath } from './useNavigatePath';
15
- import { flatTree } from '@antscorp/antsomi-ui/es/utils';
16
16
  export const useLeftMenu = (props) => {
17
17
  // Props
18
18
  const { objectType = DASHBOARD_MODULE_CONFIG.objectType, objectId = DASHBOARD_MODULE_CONFIG.objectId, isGrouped = DASHBOARD_MODULE_CONFIG.isGrouped, appConfig, customization, onActiveMenuCodeChange, } = props;
19
- const { expandMenu = false, isCustomized = false, isRecommendation = false, items, activeKey, onMenuItemClick, } = customization || {};
19
+ const { defaultExpandMenu, type, items, activeKey, onMenuItemClick } = customization || {};
20
20
  const mappedActiveKey = useMemo(() => {
21
- if (!isRecommendation)
21
+ if (type !== 'recommendation')
22
22
  return activeKey;
23
23
  switch (activeKey) {
24
24
  case 'BUSINESS_OBJECT':
@@ -35,7 +35,7 @@ export const useLeftMenu = (props) => {
35
35
  default:
36
36
  return activeKey;
37
37
  }
38
- }, [activeKey, isRecommendation]);
38
+ }, [activeKey, type]);
39
39
  const cookies = new ReactCookies();
40
40
  const { pathname, hash, origin } = window.location;
41
41
  const { navigate } = useCustomRouter();
@@ -50,17 +50,25 @@ export const useLeftMenu = (props) => {
50
50
  const [state, setState] = useState({
51
51
  hoverItem: '',
52
52
  isShowPopover: false,
53
- isExpandMenu: expandMenu || isOpenMenu,
53
+ isExpandMenu: true,
54
54
  });
55
55
  const { mappingChildrenMenu, flattenMenuPermission, menuListPermission, permissionMenu, activeItemPath, } = usePermission();
56
+ useEffect(() => {
57
+ if (isBoolean(defaultExpandMenu)) {
58
+ setState(prev => (Object.assign(Object.assign({}, prev), { isExpandMenu: defaultExpandMenu })));
59
+ }
60
+ else {
61
+ setState(prev => (Object.assign(Object.assign({}, prev), { isExpandMenu: isOpenMenu })));
62
+ }
63
+ }, [defaultExpandMenu, isOpenMenu]);
56
64
  const onMenuClick = useCallback((key, keyPath) => {
57
- if (isRecommendation) {
65
+ if (type === 'recommendation') {
58
66
  setLeftMenuContextState({ customActiveCurrentKey: key });
59
67
  }
60
68
  onMenuItemClick === null || onMenuItemClick === void 0 ? void 0 : onMenuItemClick(key, [...keyPath, customActiveAppKey]);
61
- }, [customActiveAppKey, isRecommendation, onMenuItemClick, setLeftMenuContextState]);
69
+ }, [customActiveAppKey, onMenuItemClick, setLeftMenuContextState, type]);
62
70
  useDeepCompareEffect(() => {
63
- if (!expandMenu) {
71
+ if (!isBoolean(defaultExpandMenu)) {
64
72
  cookies.set('_leftmenu_state', state.isExpandMenu ? 1 : 0, {
65
73
  domain: `.${origin.split('.').splice(-2).join('.')}`,
66
74
  path: '/',
@@ -72,25 +80,15 @@ export const useLeftMenu = (props) => {
72
80
  useDeepCompareEffect(() => {
73
81
  setLeftMenuContextState({
74
82
  appConfig,
75
- isCustomized,
76
- isRecommendation,
83
+ type,
77
84
  dashboardParams: { objectId, isGrouped, objectType },
78
85
  onMenuClick,
79
86
  });
80
- }, [
81
- appConfig,
82
- isCustomized,
83
- isGrouped,
84
- isRecommendation,
85
- objectId,
86
- objectType,
87
- onMenuClick,
88
- setLeftMenuContextState,
89
- ]);
87
+ }, [appConfig, type, isGrouped, objectId, objectType, onMenuClick, setLeftMenuContextState]);
90
88
  // Active Custom App Key when active key is changed
91
89
  useDeepCompareEffect(() => {
92
- switch (true) {
93
- case isCustomized:
90
+ switch (type) {
91
+ case 'customization':
94
92
  setLeftMenuContextState({
95
93
  customActiveAppKey: findActiveAppCodeByChild({
96
94
  activeCurrentKey: activeKey || '',
@@ -99,7 +97,7 @@ export const useLeftMenu = (props) => {
99
97
  customActiveCurrentKey: activeKey,
100
98
  });
101
99
  break;
102
- case isRecommendation: {
100
+ case 'recommendation': {
103
101
  setLeftMenuContextState({
104
102
  customActiveAppKey: findActiveAppCodeByChild({
105
103
  activeCurrentKey: mappedActiveKey || '',
@@ -116,19 +114,20 @@ export const useLeftMenu = (props) => {
116
114
  }, [
117
115
  activeKey,
118
116
  appConfig,
119
- isCustomized,
120
- isRecommendation,
121
117
  items,
122
118
  mappedActiveKey,
123
119
  mappingChildrenMenu,
120
+ type,
124
121
  setLeftMenuContextState,
125
122
  ]);
126
123
  // Change list menu children when hovering or activating items, giving priority to hovering items
127
124
  useDeepCompareEffect(() => {
128
125
  var _a, _b, _c, _d, _e, _f;
129
- const appActiveKey = isCustomized || isRecommendation ? customActiveAppKey : activeAppCode;
130
- switch (true) {
131
- case isCustomized: {
126
+ const appActiveKey = ['customization', 'recommendation'].includes(`${type}`)
127
+ ? customActiveAppKey
128
+ : activeAppCode;
129
+ switch (type) {
130
+ case 'customization': {
132
131
  setLeftMenuContextState({
133
132
  customItems: items,
134
133
  customMenuChildren: ((_a = items === null || items === void 0 ? void 0 : items.find(item => item.key === appActiveKey)) === null || _a === void 0 ? void 0 : _a.children) || [],
@@ -138,7 +137,7 @@ export const useLeftMenu = (props) => {
138
137
  });
139
138
  break;
140
139
  }
141
- case isRecommendation: {
140
+ case 'recommendation': {
142
141
  setLeftMenuContextState({
143
142
  menuItems: mappingChildrenMenu,
144
143
  appMenuChildren: ((_c = mappingChildrenMenu === null || mappingChildrenMenu === void 0 ? void 0 : mappingChildrenMenu.find(item => item.permission_code === appActiveKey)) === null || _c === void 0 ? void 0 : _c.children) ||
@@ -166,56 +165,42 @@ export const useLeftMenu = (props) => {
166
165
  }, [
167
166
  activeAppCode,
168
167
  customActiveAppKey,
169
- isCustomized,
170
168
  items,
171
169
  mappingChildrenMenu,
172
170
  state.hoverItem,
173
- isRecommendation,
171
+ type,
174
172
  setLeftMenuContextState,
175
173
  ]);
176
174
  useDeepCompareEffect(() => {
177
- switch (true) {
178
- case isCustomized:
179
- break;
180
- default: {
181
- const url = `${pathname}${hash}`;
182
- // Active App Item having code matching url
183
- const matchAppCode = findActiveAppCodeByUrl({
184
- url,
185
- menuItems: mappingChildrenMenu,
186
- auth,
187
- env,
188
- });
189
- if (matchAppCode && matchAppCode !== activeAppCode) {
190
- setLeftMenuContextState({ activeAppCode: matchAppCode });
191
- }
192
- break;
175
+ if (type !== 'customization') {
176
+ const url = `${pathname}${hash}`;
177
+ // Active App Item having code matching url
178
+ const matchAppCode = findActiveAppCodeByUrl({
179
+ url,
180
+ menuItems: mappingChildrenMenu,
181
+ auth,
182
+ env,
183
+ });
184
+ if (matchAppCode && matchAppCode !== activeAppCode) {
185
+ setLeftMenuContextState({ activeAppCode: matchAppCode });
193
186
  }
194
187
  }
195
188
  }, [
196
189
  activeAppCode,
197
190
  auth,
198
191
  hash,
199
- isCustomized,
200
- isRecommendation,
201
192
  mappingChildrenMenu,
202
193
  pathname,
203
194
  env,
195
+ type,
204
196
  setLeftMenuContextState,
205
197
  ]);
206
198
  useEffect(() => {
207
- if (!isCustomized && !isRecommendation) {
199
+ if (!['customization', 'recommendation'].includes(`${type}`)) {
208
200
  // Callback function using at Layout when url change
209
201
  onActiveMenuCodeChange === null || onActiveMenuCodeChange === void 0 ? void 0 : onActiveMenuCodeChange(activeItemPath, flattenMenuPermission, menuListPermission);
210
202
  }
211
- }, [
212
- activeItemPath,
213
- flattenMenuPermission,
214
- isCustomized,
215
- isRecommendation,
216
- menuListPermission,
217
- onActiveMenuCodeChange,
218
- ]);
203
+ }, [activeItemPath, flattenMenuPermission, menuListPermission, onActiveMenuCodeChange, type]);
219
204
  useEffect(() => clearTimeout(timeoutPopover === null || timeoutPopover === void 0 ? void 0 : timeoutPopover.current), [timeoutPopover]);
220
205
  const onShowPopover = useCallback((hoverItem) => {
221
206
  if (timeoutPopover)
@@ -231,23 +216,16 @@ export const useLeftMenu = (props) => {
231
216
  const onMouseEnter = useCallback((key) => {
232
217
  if (state.hoverItem !== key) {
233
218
  onShowPopover(key);
234
- // if (!state.isExpandMenu || !isExpandable) {
235
- // setState(prev => ({ ...prev, hoverItem: key }));
236
- // }
237
219
  }
238
220
  }, [state.hoverItem, onShowPopover]);
239
221
  const onMouseLeave = useCallback(() => {
240
222
  timeoutPopover.current = setTimeout(() => {
241
- setState(prev => (Object.assign(Object.assign({}, prev), { hoverItem: '' })));
242
- setState(prev => (Object.assign(Object.assign({}, prev), { isShowPopover: false })));
223
+ setState(prev => (Object.assign(Object.assign({}, prev), { hoverItem: '', isShowPopover: false })));
243
224
  }, 200);
244
- // if (!state.isExpandMenu || !isExpandable) {
245
- // setState(prev => ({ ...prev, hoverItem: '' }));
246
- // }
247
225
  }, []);
248
226
  const onHoverMenuBar = useCallback(() => {
249
- onMouseEnter(isCustomized ? customActiveAppKey : activeAppCode);
250
- }, [activeAppCode, customActiveAppKey, isCustomized, onMouseEnter]);
227
+ onMouseEnter(type === 'customization' ? customActiveAppKey : activeAppCode);
228
+ }, [activeAppCode, customActiveAppKey, onMouseEnter, type]);
251
229
  const onClickFeatureMenuItem = useCallback((item) => {
252
230
  // Destructure permission_code from the item object
253
231
  const { permission_code } = item;
@@ -16,8 +16,7 @@ import { useDeepCompareEffect } from '@antscorp/antsomi-ui/es/hooks';
16
16
  const { DEV, SANDBOX, SANDBOX_CDP } = ENV;
17
17
  export const usePermission = () => {
18
18
  const appConfig = useLeftMenuContext(store => store.appConfig);
19
- const isCustomized = useLeftMenuContext(store => store.isCustomized);
20
- const isRecommendation = useLeftMenuContext(store => store.isRecommendation);
19
+ const type = useLeftMenuContext(store => store.type);
21
20
  const setLeftMenuState = useLeftMenuContext(store => store.setState);
22
21
  const { isGrouped, objectId, objectType } = useLeftMenuContext(store => store.dashboardParams);
23
22
  const { auth, languageCode = 'en', env = 'development', permissionDomain } = appConfig || {};
@@ -125,14 +124,14 @@ export const usePermission = () => {
125
124
  dashboardList,
126
125
  destinationChannelEntries: destinationChannel === null || destinationChannel === void 0 ? void 0 : destinationChannel.entries,
127
126
  destinationChannelGen2Entries: destinationChannelGen2 === null || destinationChannelGen2 === void 0 ? void 0 : destinationChannelGen2.entries,
128
- isRecommendation,
127
+ isRecommendation: type === 'recommendation',
129
128
  userPermission,
130
129
  }), [
131
130
  auth,
132
131
  dashboardList,
133
132
  destinationChannel === null || destinationChannel === void 0 ? void 0 : destinationChannel.entries,
134
133
  destinationChannelGen2 === null || destinationChannelGen2 === void 0 ? void 0 : destinationChannelGen2.entries,
135
- isRecommendation,
134
+ type,
136
135
  permissionMenu,
137
136
  userPermission,
138
137
  ]);
@@ -142,14 +141,14 @@ export const usePermission = () => {
142
141
  dashboardList,
143
142
  destinationChannelEntries: destinationChannel === null || destinationChannel === void 0 ? void 0 : destinationChannel.entries,
144
143
  destinationChannelGen2Entries: destinationChannelGen2 === null || destinationChannelGen2 === void 0 ? void 0 : destinationChannelGen2.entries,
145
- isRecommendation,
144
+ isRecommendation: type === 'recommendation',
146
145
  userPermission,
147
146
  }), [
148
147
  auth,
149
148
  dashboardList,
150
149
  destinationChannel === null || destinationChannel === void 0 ? void 0 : destinationChannel.entries,
151
150
  destinationChannelGen2 === null || destinationChannelGen2 === void 0 ? void 0 : destinationChannelGen2.entries,
152
- isRecommendation,
151
+ type,
153
152
  menuList === null || menuList === void 0 ? void 0 : menuList.rows,
154
153
  userPermission,
155
154
  ]);
@@ -170,7 +169,7 @@ export const usePermission = () => {
170
169
  }, [auth, env, hash, mappingChildrenMenuWithNoPermission, pathname]);
171
170
  useDeepCompareEffect(() => setLeftMenuState({ dashboardList }), [dashboardList, setLeftMenuState]);
172
171
  useEffect(() => {
173
- if (!isCustomized) {
172
+ if (type !== 'customization') {
174
173
  const receivePostMessage = (event) => {
175
174
  const { data } = event;
176
175
  const { type } = data || {};
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { AppConfigProviderProps } from '@antscorp/antsomi-ui/es/providers';
3
- import { TMenuItem } from './types';
4
3
  import { FeatureMenuPermission, TFeatureMenu } from '@antscorp/antsomi-ui/es/models/LeftMenu';
4
+ import { TLeftMenuType, TMenuItem } from './types';
5
5
  export interface LeftMenuProps {
6
6
  show?: boolean;
7
7
  appConfig?: AppConfigProviderProps;
@@ -12,12 +12,12 @@ export interface LeftMenuProps {
12
12
  className?: string;
13
13
  showLogo?: boolean;
14
14
  customization?: {
15
- isCustomized?: boolean;
16
- isRecommendation?: boolean;
17
- isExpandable?: boolean;
15
+ type?: TLeftMenuType;
16
+ showButtonExpand?: boolean;
17
+ showMenuPopover?: boolean;
18
18
  items?: TMenuItem[];
19
19
  activeKey?: string;
20
- expandMenu?: boolean;
20
+ defaultExpandMenu?: boolean;
21
21
  onMenuItemClick?: (key: string, keyPath: string[]) => void;
22
22
  };
23
23
  onActiveMenuCodeChange?: (activeItemPath: TFeatureMenu[], flattenPermissionList?: FeatureMenuPermission[], menuListPermission?: FeatureMenuPermission[]) => void;
@@ -2,12 +2,13 @@
2
2
  // Libraries
3
3
  import React, { memo, useRef } from 'react';
4
4
  import isEqual from 'react-fast-compare';
5
+ import { CookiesProvider } from 'react-cookie';
5
6
  // Providers
6
7
  import { LeftMenuProvider } from './providers';
7
8
  // Store
8
9
  import { createLeftMenuStore } from './stores';
10
+ // Types
9
11
  import { LeftMenuComponent } from './LeftMenu';
10
- import { CookiesProvider } from 'react-cookie';
11
12
  export const LeftMenu = memo((props) => {
12
13
  const storeRef = useRef();
13
14
  if (!storeRef.current) {
@@ -1,5 +1,5 @@
1
1
  import { TDashboard, TFeatureMenu } from '@antscorp/antsomi-ui/es/models/LeftMenu';
2
- import { TMenuItem } from '../types';
2
+ import { TLeftMenuType, TMenuItem } from '../types';
3
3
  import { AppConfigProviderProps } from '@antscorp/antsomi-ui/es/providers';
4
4
  export interface LeftMenuStoreProps {
5
5
  activeAppCode: string;
@@ -12,8 +12,7 @@ export interface LeftMenuStoreProps {
12
12
  appMenuChildren: TFeatureMenu[];
13
13
  appHoverMenuChildren: TFeatureMenu[];
14
14
  appConfig?: AppConfigProviderProps;
15
- isCustomized?: boolean;
16
- isRecommendation?: boolean;
15
+ type?: TLeftMenuType;
17
16
  dashboardParams: {
18
17
  objectId: number;
19
18
  objectType: string;
@@ -1,4 +1,5 @@
1
1
  import { createStore } from 'zustand';
2
+ // Constants
2
3
  import { DASHBOARD_MODULE_CONFIG } from '../../../template/Layout/constants';
3
4
  const DEFAULT_PROPS = {
4
5
  activeAppCode: '',
@@ -10,8 +11,7 @@ const DEFAULT_PROPS = {
10
11
  customItems: [],
11
12
  customMenuChildren: [],
12
13
  customHoverMenuChildren: [],
13
- isCustomized: false,
14
- isRecommendation: false,
14
+ type: 'default',
15
15
  dashboardParams: {
16
16
  objectId: DASHBOARD_MODULE_CONFIG.objectId,
17
17
  objectType: DASHBOARD_MODULE_CONFIG.objectType,
@@ -1,4 +1,4 @@
1
- var _a, _b, _c, _d, _e;
1
+ var _a, _b, _c, _d, _e, _f;
2
2
  // Libraries
3
3
  import styled from 'styled-components';
4
4
  // Constants
@@ -16,7 +16,7 @@ export const IconWrapper = styled.div `
16
16
 
17
17
  i {
18
18
  font-size: ${ICON_SIZE}px;
19
- color: #595959;
19
+ color: ${(_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.bw8};
20
20
  }
21
21
  `;
22
22
  export const PopoverWrapper = styled.div `
@@ -40,7 +40,7 @@ export const PopoverWrapper = styled.div `
40
40
  position: absolute;
41
41
  background-color: white;
42
42
  left: 65px;
43
- border-radius: ${(_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.borderRadiusXL}px;
43
+ border-radius: ${(_b = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _b === void 0 ? void 0 : _b.borderRadiusXL}px;
44
44
  bottom: 15px;
45
45
  box-shadow: 0px 3px 20px 0px #002e5933;
46
46
  height: ${({ hasMarginTop }) => hasMarginTop ? `calc(100% - ${HEADER_HEIGHT + 15}px)` : `calc(100% - 15px)`};
@@ -61,7 +61,7 @@ export const ExpandWrapper = styled.div `
61
61
  flex-direction: column;
62
62
  justify-content: center;
63
63
  align-items: center;
64
- border-top: 1px solid ${(_b = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _b === void 0 ? void 0 : _b.bw3};
64
+ border-top: 1px solid ${(_c = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _c === void 0 ? void 0 : _c.bw3};
65
65
  padding: 0 10px;
66
66
  `;
67
67
  export const LeftMenuNavWrapper = styled.div `
@@ -91,11 +91,11 @@ export const LeftMenuNav = styled.nav `
91
91
  position: relative;
92
92
  width: 70px;
93
93
  height: 100%;
94
- background-color: ${(_c = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _c === void 0 ? void 0 : _c.blue1_2};
94
+ background-color: ${(_d = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _d === void 0 ? void 0 : _d.blue1_2};
95
95
  display: flex;
96
96
  flex-direction: column;
97
97
  justify-content: space-between;
98
- border-right: 1px solid ${(_d = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _d === void 0 ? void 0 : _d.bw3};
98
+ border-right: 1px solid ${(_e = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _e === void 0 ? void 0 : _e.bw3};
99
99
 
100
100
  ${ExpandWrapper} {
101
101
  flex-shrink: 0;
@@ -151,7 +151,7 @@ export const FeatureMenuItem = styled.div `
151
151
  flex-direction: column;
152
152
  align-items: center;
153
153
  justify-content: center;
154
- border-radius: ${(_e = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _e === void 0 ? void 0 : _e.borderRadiusXL}px;
154
+ border-radius: ${(_f = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _f === void 0 ? void 0 : _f.borderRadiusXL}px;
155
155
  padding: 5px 0;
156
156
  position: relative;
157
157
 
@@ -27,4 +27,5 @@ type TOption = {
27
27
  optionKey: string;
28
28
  }) => void;
29
29
  };
30
+ export type TLeftMenuType = 'customization' | 'recommendation' | 'default';
30
31
  export {};
@@ -289,7 +289,7 @@ export const Layout = memo(props => {
289
289
  React.createElement(Flex, { className: "layout-body" },
290
290
  React.createElement(LeftMenu, Object.assign({ show: showLeftMenu && !showOnlyContent, className: `layout-body__menu ${leftMenuClassName}` }, mergeLeftMenuProps, { customization: Object.assign(Object.assign({}, mergeLeftMenuProps.customization), {
291
291
  // If user has access denied, disable expandable
292
- isExpandable: !isAccessDenied && ((_a = mergeLeftMenuProps.customization) === null || _a === void 0 ? void 0 : _a.isExpandable) }), appConfig: leftMenuAppConfig, onActiveMenuCodeChange: onActiveMenuCodeChange })),
292
+ showButtonExpand: !isAccessDenied && ((_a = mergeLeftMenuProps.customization) === null || _a === void 0 ? void 0 : _a.showButtonExpand) }), appConfig: leftMenuAppConfig, onActiveMenuCodeChange: onActiveMenuCodeChange })),
293
293
  React.createElement(ContentWrapper, Object.assign({ "$noPadding": noPadding, "$noSpaceTopContent": noSpaceTopContent, "$showOnlyContent": showOnlyContent }, mergeContentWrapperProps), (activeMenu === null || activeMenu === void 0 ? void 0 : activeMenu.menu_item_code) === HOME_MENU_ITEMS.RECOMMENDATION ? (React.createElement("div", { className: "layout-body__content" },
294
294
  React.createElement(RecommendationWorkspace, null))) : (React.createElement("div", Object.assign({ className: `layout-body__content ${(workspaceProps === null || workspaceProps === void 0 ? void 0 : workspaceProps.className) || ''}` }, mergeWorkSpaceProps), isLoadingLayout ? (React.createElement(LayoutLoading, { spinning: true })) : (React.createElement(React.Fragment, null,
295
295
  React.createElement(NotificationWrapper, { className: "process-notification", ref: notificationWrapperRef }, showNotification && (React.createElement(AntsProcessingNotification, Object.assign({}, antsProcessingNotificationConfig, { callback: handleCallbackNotify })))),
@@ -1,2 +1,7 @@
1
1
  import React from 'react';
2
- export declare const MenuMapping: React.FC;
2
+ import { AppConfigProps } from '@antscorp/antsomi-ui/es/providers';
3
+ interface MenuMappingProps {
4
+ appConfig?: AppConfigProps;
5
+ }
6
+ export declare const MenuMapping: React.FC<MenuMappingProps>;
7
+ export {};
@@ -1,7 +1,8 @@
1
1
  // Libraries
2
- import React, { useCallback, useState } from 'react';
2
+ import React, { memo, useCallback, useMemo, useState } from 'react';
3
3
  import { useContextSelector } from 'use-context-selector';
4
4
  import Icon from '@antscorp/icons';
5
+ import isEqual from 'react-fast-compare';
5
6
  // Styled
6
7
  import { MenuMappingWrapper, MenuMappingContainer } from './styled';
7
8
  // Components
@@ -9,24 +10,34 @@ import { LeftMenu } from '@antscorp/antsomi-ui/es/components/organism';
9
10
  import { OldLeftMenu } from './components';
10
11
  // Providers
11
12
  import { AppConfigContext } from '@antscorp/antsomi-ui/es/providers';
12
- export const MenuMapping = () => {
13
+ export const MenuMapping = memo(({ appConfig: appConfigProps }) => {
13
14
  const [activeKey, setActiveKey] = useState('DASHBOARD');
14
15
  const onMenuItemClick = useCallback((key, keyPath) => {
16
+ const appParentPermissionCode = keyPath === null || keyPath === void 0 ? void 0 : keyPath[1];
15
17
  switch (key) {
16
18
  case 'DATASOURCES':
17
19
  case 'BUSINESS_OBJECT':
18
- setActiveKey(`${key}-${keyPath === null || keyPath === void 0 ? void 0 : keyPath[1]}`);
20
+ setActiveKey(`${key}-${appParentPermissionCode}`);
19
21
  break;
20
22
  default:
21
23
  setActiveKey(key);
22
24
  }
23
25
  }, []);
24
- const appConfig = useContextSelector(AppConfigContext, state => state);
26
+ const appConfigSelector = useContextSelector(AppConfigContext, state => state);
27
+ const appConfig = useMemo(() => appConfigProps || appConfigSelector, [appConfigProps, appConfigSelector]);
25
28
  return (React.createElement(MenuMappingWrapper, null,
26
29
  React.createElement(MenuMappingContainer, null,
27
30
  React.createElement("div", { className: "old-menu-wrapper" },
28
31
  React.createElement(OldLeftMenu, { activeKey: activeKey, appConfig: appConfig, onMenuItemClick: onMenuItemClick })),
29
32
  React.createElement(Icon, { type: "icon-ants-arrow-forward" }),
30
33
  React.createElement("div", { className: "new-menu-wrapper" },
31
- React.createElement(LeftMenu, { appConfig: appConfig, showLogo: false, style: { maxHeight: '100%' }, customization: { isRecommendation: true, activeKey, expandMenu: true, onMenuItemClick } })))));
32
- };
34
+ React.createElement(LeftMenu, { appConfig: appConfig, showLogo: false, style: { maxHeight: '100%' }, customization: {
35
+ type: 'recommendation',
36
+ activeKey,
37
+ defaultExpandMenu: true,
38
+ showMenuPopover: false,
39
+ showButtonExpand: false,
40
+ onMenuItemClick,
41
+ } })))));
42
+ }, (prevProps, nextProps) => isEqual(prevProps, nextProps));
43
+ MenuMapping.displayName = 'MenuMapping';
@@ -1,4 +1,4 @@
1
- var _a, _b, _c;
1
+ var _a, _b, _c, _d;
2
2
  import { THEME } from '@antscorp/antsomi-ui/es/constants';
3
3
  import styled from 'styled-components';
4
4
  import { Flex } from '../../../../../../atoms';
@@ -8,7 +8,7 @@ export const MenuMappingContainer = styled(Flex) `
8
8
  & > i {
9
9
  font-size: 22px;
10
10
  font-weight: 400;
11
- color: #595959;
11
+ color: ${(_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.bw8};
12
12
  }
13
13
  `;
14
14
  MenuMappingContainer.defaultProps = {
@@ -23,7 +23,7 @@ export const MenuMappingWrapper = styled.div `
23
23
  overflow: hidden;
24
24
  height: 763px;
25
25
  flex-shrink: 0;
26
- border-radius: ${(_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.borderRadiusXL}px;
26
+ border-radius: ${(_b = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _b === void 0 ? void 0 : _b.borderRadiusXL}px;
27
27
 
28
28
  ${MenuMappingContainer} {
29
29
  max-height: 100%;
@@ -31,9 +31,9 @@ export const MenuMappingWrapper = styled.div `
31
31
  .old-menu-wrapper,
32
32
  .new-menu-wrapper {
33
33
  height: 100%;
34
- border-radius: ${(_b = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _b === void 0 ? void 0 : _b.borderRadiusXL}px;
34
+ border-radius: ${(_c = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _c === void 0 ? void 0 : _c.borderRadiusXL}px;
35
35
  box-shadow: 0px 3px 20px 0px #002e5933;
36
- background-color: ${(_c = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _c === void 0 ? void 0 : _c.blue1_3};
36
+ background-color: ${(_d = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _d === void 0 ? void 0 : _d.blue1_3};
37
37
  }
38
38
 
39
39
  .old-menu-wrapper {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.590",
3
+ "version": "1.3.5-beta.592",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",