@antscorp/antsomi-ui 1.3.5-beta.344 → 1.3.5-beta.346

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.
@@ -3,15 +3,15 @@ import { LeftMenuProps } from '../../organism';
3
3
  import { HeaderV2Props } from '../../molecules';
4
4
  import '@antscorp/processing-notification/dist/index.css';
5
5
  import { ProcessingNotificationProps } from '@antscorp/antsomi-ui/es/types';
6
+ import { ContentWrapperProps, WorkspaceProps } from './types';
6
7
  interface LayoutProps {
7
8
  headerProps?: Partial<Omit<HeaderV2Props, 'helpConfig'> & {
8
9
  helpConfig: Partial<HeaderV2Props['helpConfig']>;
9
10
  }>;
10
11
  leftMenuProps?: LeftMenuProps;
11
12
  processingNotificationProps?: Partial<ProcessingNotificationProps>;
12
- workspaceProps?: React.HTMLAttributes<HTMLDivElement> & {
13
- workspaceContentProps?: React.HTMLAttributes<HTMLDivElement>;
14
- };
13
+ contentWrapperProps?: ContentWrapperProps;
14
+ workspaceProps?: WorkspaceProps;
15
15
  onActiveMenuChange?: (menuActive?: string) => void;
16
16
  }
17
17
  export declare const Layout: React.FC<PropsWithChildren<LayoutProps>>;
@@ -10,10 +10,10 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  // Libraries
13
- import React, { memo, useCallback, useMemo, useState } from 'react';
13
+ import React, { memo, useCallback, useMemo, useRef, useState } from 'react';
14
14
  import { useContextSelector } from 'use-context-selector';
15
15
  import AntsProcessingNotification from '@antscorp/processing-notification';
16
- import { merge } from 'lodash';
16
+ import { cloneDeep, merge, omit } from 'lodash';
17
17
  // Styled
18
18
  import { ChildrenWrapper, ContentWrapper, LayoutWrapper, NotificationWrapper } from './styled';
19
19
  // Components
@@ -29,9 +29,10 @@ import '@antscorp/processing-notification/dist/index.css';
29
29
  import { useLayoutStore } from './stores';
30
30
  // Utils
31
31
  import { hasSelectAccountPermission } from './utils';
32
+ import { useDeepCompareMemo, useMutationObserver } from '@antscorp/antsomi-ui/es/hooks';
32
33
  const { DATAFLOWS, APP_ANTALYSER } = APP_CODES;
33
34
  export const Layout = memo(props => {
34
- const { leftMenuProps, headerProps = {}, workspaceProps, processingNotificationProps, children, onActiveMenuChange, } = props;
35
+ const { leftMenuProps, headerProps = {}, workspaceProps, contentWrapperProps, processingNotificationProps, children, onActiveMenuChange, } = props;
35
36
  const _a = leftMenuProps || {}, { className = '' } = _a, restOfLeftMenuProps = __rest(_a, ["className"]);
36
37
  const _b = workspaceProps || {}, { workspaceContentProps } = _b, restOfWorkspaceProps = __rest(_b, ["workspaceContentProps"]);
37
38
  const appConfig = useContextSelector(AppConfigContext, state => state);
@@ -39,7 +40,28 @@ export const Layout = memo(props => {
39
40
  const { token, userId, portalId } = auth || {};
40
41
  const headerStore = useLayoutStore(store => store.state.header);
41
42
  const showLeftMenu = useLayoutStore(store => store.state.leftMenu.show);
43
+ const contentWrapper = useLayoutStore(store => store.state.contentWrapper);
44
+ const workspace = useLayoutStore(store => store.state.workspace);
45
+ const layoutState = useLayoutStore(store => store.state);
46
+ console.log('🚀 ~ layoutState: joifdsjfiodsjfoids', layoutState, contentWrapper);
42
47
  const [showAccountSelection, setShowAccountSelection] = useState(false);
48
+ const [noSpaceTopContent, setNoSpaceTopContent] = useState(false);
49
+ // Refs
50
+ const notificationWrapperRef = useRef(null);
51
+ // Hooks
52
+ useMutationObserver(() => {
53
+ if (notificationWrapperRef.current) {
54
+ const child = notificationWrapperRef.current.querySelector('div');
55
+ setNoSpaceTopContent(!!child);
56
+ }
57
+ }, notificationWrapperRef, {
58
+ attributes: true,
59
+ childList: true,
60
+ subtree: true,
61
+ characterData: true,
62
+ attributeOldValue: true,
63
+ characterDataOldValue: true,
64
+ });
43
65
  // Memo
44
66
  const permissionDomain = useMemo(() => {
45
67
  var _a;
@@ -84,7 +106,15 @@ export const Layout = memo(props => {
84
106
  INSIGHT_U_OGS: 'uogs',
85
107
  } }) }), accountSharingConfig: Object.assign(Object.assign({}, headerProps === null || headerProps === void 0 ? void 0 : headerProps.accountSharingConfig), { u_ogs: 'uogs', appCode: 'APP_CUSTOMER_360' }), accountSelection: Object.assign(Object.assign({}, headerProps === null || headerProps === void 0 ? void 0 : headerProps.accountSelection), { show: !!((_b = headerProps === null || headerProps === void 0 ? void 0 : headerProps.accountSelection) === null || _b === void 0 ? void 0 : _b.show) && showAccountSelection }) }));
86
108
  }, [headerProps, iamDomain, permissionDomain, showAccountSelection]);
87
- const mergeHeaderProps = useMemo(() => merge(initialHeaderProps, headerStore), [initialHeaderProps, headerStore]);
109
+ const mergeHeaderProps = useDeepCompareMemo(() => merge(cloneDeep(initialHeaderProps), cloneDeep(headerStore)),
110
+ // eslint-disable-next-line react-hooks/exhaustive-deps
111
+ [cloneDeep(initialHeaderProps), cloneDeep(headerStore)]);
112
+ const mergeContentWrapperProps = useDeepCompareMemo(() => merge(contentWrapperProps, contentWrapper),
113
+ // eslint-disable-next-line react-hooks/exhaustive-deps
114
+ [cloneDeep(contentWrapperProps), cloneDeep(contentWrapper)]);
115
+ const mergeWorkSpaceProps = useDeepCompareMemo(() => merge(restOfWorkspaceProps, omit(workspace, 'workspaceContentProps')),
116
+ // eslint-disable-next-line react-hooks/exhaustive-deps
117
+ [cloneDeep(restOfWorkspaceProps), cloneDeep(workspace)]);
88
118
  const antsProcessingNotificationConfig = useMemo(() => (Object.assign({ permissionDomain, socketDomain: SOCKET_API, token, accountId: userId, userId, lang: languageCode, networkId: portalId }, processingNotificationProps)), [permissionDomain, token, userId, languageCode, portalId, processingNotificationProps]);
89
119
  const onActiveMenuCodeChange = useCallback((activeItemPath, flattenPermissionList) => {
90
120
  var _a;
@@ -96,9 +126,9 @@ export const Layout = memo(props => {
96
126
  React.createElement(HeaderV2, Object.assign({}, mergeHeaderProps, { showLogo: !showLeftMenu })),
97
127
  React.createElement(Flex, { className: "layout-body" },
98
128
  showLeftMenu && (React.createElement(LeftMenu, Object.assign({ className: `layout-body__menu ${className}`, appConfig: appConfig }, restOfLeftMenuProps, { onActiveMenuCodeChange: onActiveMenuCodeChange }))),
99
- React.createElement(ContentWrapper, null,
100
- React.createElement("div", Object.assign({}, restOfWorkspaceProps, { className: `layout-body__content ${(workspaceProps === null || workspaceProps === void 0 ? void 0 : workspaceProps.className) || ''}` }),
101
- React.createElement(NotificationWrapper, null,
129
+ React.createElement(ContentWrapper, Object.assign({ "$noPadding": mergeContentWrapperProps.noPadding, "$noSpaceTopContent": noSpaceTopContent }, mergeContentWrapperProps),
130
+ React.createElement("div", Object.assign({}, mergeWorkSpaceProps, { className: `layout-body__content ${(workspaceProps === null || workspaceProps === void 0 ? void 0 : workspaceProps.className) || ''}` }),
131
+ React.createElement(NotificationWrapper, { ref: notificationWrapperRef },
102
132
  React.createElement(AntsProcessingNotification, Object.assign({}, antsProcessingNotificationConfig))),
103
133
  React.createElement(ChildrenWrapper, Object.assign({}, workspaceContentProps),
104
134
  React.createElement("div", null, children)))))));
@@ -1,25 +1,26 @@
1
1
  /// <reference types="react" />
2
2
  import { HeaderV2Props } from '../../../molecules';
3
3
  import { DeepPartial } from '@antscorp/antsomi-ui/es/types';
4
+ import { ContentWrapperProps, WorkspaceProps } from '../types';
4
5
  export interface HeaderStore extends Partial<HeaderV2Props> {
5
6
  }
6
7
  export interface LeftMenuStore {
7
8
  show: boolean;
8
9
  onClickCreateDashboard?: React.MouseEventHandler<HTMLElement>;
9
10
  }
10
- export interface WorkspaceStore {
11
- }
12
11
  export interface LayoutStoreState {
13
12
  header: HeaderStore;
14
13
  leftMenu: LeftMenuStore;
15
- workspace: WorkspaceStore;
14
+ workspace: WorkspaceProps;
15
+ contentWrapper: ContentWrapperProps;
16
16
  }
17
17
  interface LayoutStore {
18
18
  state: LayoutStoreState;
19
19
  setHeaderState: (state: DeepPartial<HeaderStore>) => void;
20
20
  setLeftMenuState: (state: DeepPartial<LeftMenuStore>) => void;
21
- setWorkspaceState: (state: Partial<WorkspaceStore>) => void;
21
+ setWorkspaceState: (state: Partial<WorkspaceProps>) => void;
22
22
  setLayoutState: (state: DeepPartial<LayoutStoreState>) => void;
23
+ setContentWrapperState: (state: DeepPartial<ContentWrapperProps>) => void;
23
24
  resetHeaderState: () => void;
24
25
  resetLeftMenuState: () => void;
25
26
  resetWorkspaceState: () => void;
@@ -5,6 +5,7 @@ const initialState = {
5
5
  header: {},
6
6
  leftMenu: { show: true },
7
7
  workspace: {},
8
+ contentWrapper: {},
8
9
  };
9
10
  export const useLayoutStore = create(set => ({
10
11
  state: initialState,
@@ -18,6 +19,9 @@ export const useLayoutStore = create(set => ({
18
19
  setWorkspaceState: newState => set(store => ({
19
20
  state: Object.assign(Object.assign({}, store.state), { workspace: Object.assign(Object.assign({}, store.state.workspace), newState) }),
20
21
  })),
22
+ setContentWrapperState: newState => set(store => ({
23
+ state: Object.assign(Object.assign({}, store.state), { contentWrapper: Object.assign(Object.assign({}, store.state.contentWrapper), newState) }),
24
+ })),
21
25
  resetHeaderState: () => set(store => ({
22
26
  state: Object.assign(Object.assign({}, store.state), { header: {} }),
23
27
  })),
@@ -27,11 +31,10 @@ export const useLayoutStore = create(set => ({
27
31
  resetWorkspaceState: () => set(store => ({
28
32
  state: Object.assign(Object.assign({}, store.state), { workspace: {} }),
29
33
  })),
30
- resetLayoutState: () => set(store => ({
31
- state: Object.assign(Object.assign({}, store.state), {
32
- header: {},
33
- leftMenu: { show: true },
34
- workspace: {},
35
- }),
34
+ resetContentWrapperState: () => set(store => ({
35
+ state: Object.assign(Object.assign({}, store.state), { contentWrapper: initialState.contentWrapper }),
36
+ })),
37
+ resetLayoutState: () => set(() => ({
38
+ state: initialState,
36
39
  })),
37
40
  }));
@@ -2,6 +2,9 @@
2
2
  export declare const LayoutWrapper: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/flex/interface").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, {
3
3
  showLeftMenu: boolean;
4
4
  }, never>;
5
- export declare const ContentWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
5
+ export declare const ContentWrapper: import("styled-components").StyledComponent<"div", any, {
6
+ $noPadding?: boolean | undefined;
7
+ $noSpaceTopContent?: boolean | undefined;
8
+ }, never>;
6
9
  export declare const NotificationWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
7
10
  export declare const ChildrenWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -38,7 +38,6 @@ export const LayoutWrapper = styled(Flex) `
38
38
  background-color: white;
39
39
  height: 100%;
40
40
  padding: 15px;
41
- padding-top: 0px;
42
41
  display: flex;
43
42
  flex-direction: column;
44
43
  box-sizing: border-box;
@@ -51,8 +50,13 @@ export const ContentWrapper = styled.div `
51
50
  position: relative;
52
51
  width: 100%;
53
52
  height: 100vh;
54
- padding: ${HEADER_HEIGHT}px 15px 15px 0;
55
53
  box-sizing: border-box;
54
+
55
+ ${({ $noPadding }) => $noPadding ? `padding: ${HEADER_HEIGHT}px 0 0 0;` : `padding: ${HEADER_HEIGHT}px 15px 15px 0;`}
56
+
57
+ .layout-body__content {
58
+ ${({ $noSpaceTopContent }) => $noSpaceTopContent && 'padding-top: 0;'}
59
+ }
56
60
  `;
57
61
  export const NotificationWrapper = styled.div `
58
62
  flex-shrink: 0;
@@ -61,11 +65,11 @@ export const NotificationWrapper = styled.div `
61
65
  /* height: 50px; */
62
66
  width: 100%;
63
67
  /* margin-bottom: 6px; */
64
- padding-top: 15px;
65
68
  background-color: white;
66
69
  z-index: 999;
67
70
 
68
71
  > div {
72
+ margin-top: 15px;
69
73
  margin-bottom: 6px;
70
74
  }
71
75
  `;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export interface ContentWrapperProps extends React.HtmlHTMLAttributes<HTMLDivElement> {
3
+ noPadding?: boolean;
4
+ }
5
+ export interface WorkspaceProps extends React.HTMLAttributes<HTMLDivElement> {
6
+ workspaceContentProps?: React.HTMLAttributes<HTMLDivElement>;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -221,6 +221,8 @@ THEME.components = {
221
221
  itemDisabledColor: (_2 = THEME.token) === null || _2 === void 0 ? void 0 : _2.colorTextDisabled,
222
222
  itemActiveBg: (_3 = THEME.token) === null || _3 === void 0 ? void 0 : _3.blue1_1,
223
223
  },
224
- Form: {},
224
+ Form: {
225
+ itemMarginBottom: 15,
226
+ },
225
227
  };
226
228
  export const globalToken = theme.getDesignToken(THEME);
@@ -767,7 +767,7 @@ export const GlobalStyle = () => {
767
767
 
768
768
  /* Modal Close */
769
769
  .antsomi-modal-root .antsomi-modal-wrap {
770
- z-index: 3001 !important;
770
+ z-index: 3001;
771
771
  }
772
772
 
773
773
  .antsomi-modal .antsomi-modal-close {
@@ -780,6 +780,7 @@ export const GlobalStyle = () => {
780
780
  padding: 20px;
781
781
  }
782
782
  }
783
+
783
784
  .antsomi-modal-content {
784
785
  .antsomi-modal-header {
785
786
  .antsomi-modal-title {
@@ -789,8 +790,8 @@ export const GlobalStyle = () => {
789
790
  word-wrap: break-word;
790
791
  }
791
792
  }
793
+
792
794
  .antsomi-modal-body {
793
- font-size: 14px !important;
794
795
  p {
795
796
  margin: 0;
796
797
  }
@@ -817,10 +818,9 @@ export const GlobalStyle = () => {
817
818
  }
818
819
  }
819
820
  .antsomi-modal-footer {
820
- padding: 15px !important;
821
821
  text-align: right;
822
822
  background: transparent;
823
- border-top: 1px solid #f0f0f0 !important;
823
+ border-top: 1px solid #f0f0f0;
824
824
  border-radius: 0 0 2px 2px;
825
825
  }
826
826
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.344",
3
+ "version": "1.3.5-beta.346",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",