@antscorp/antsomi-ui 1.3.5-beta.575 → 1.3.5-beta.577

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.
@@ -9,6 +9,7 @@ interface Breadcrumb {
9
9
  useExternalLink?: boolean;
10
10
  }
11
11
  export interface HeaderV2Props {
12
+ show?: boolean;
12
13
  className?: string;
13
14
  style?: React.CSSProperties;
14
15
  pageTitle?: string | React.ReactNode;
@@ -32,7 +32,7 @@ export const HeaderV2 = memo(props => {
32
32
  const { search } = useLocation();
33
33
  const { replace } = useCustomRouter();
34
34
  // * Prefer to use Header in AppConfigContext
35
- const { className, style, breadcrumbs, showLogo = false, rightContent, pageTitle = '', accountSelection = {}, helpConfig, notificationConfig = {}, accountSharingConfig, useURLParam, config, } = props;
35
+ const { show = true, className, style, breadcrumbs, showLogo = false, rightContent, pageTitle = '', accountSelection = {}, helpConfig, notificationConfig = {}, accountSharingConfig, useURLParam, config, } = props;
36
36
  /** General config for children component */
37
37
  const { env = envContext, language = languageCode, userId = isNaN(Number(auth === null || auth === void 0 ? void 0 : auth.userId)) ? 0 : Number(auth === null || auth === void 0 ? void 0 : auth.userId), portalId = auth === null || auth === void 0 ? void 0 : auth.portalId, token = auth === null || auth === void 0 ? void 0 : auth.token, permissionDomain = PERMISSION_API, iamDomain = IAM_API, appCode = contextAppCode, menuCode = contextMenuCode, } = config || {};
38
38
  const { currentAccount, inputStyle = 'select', onSelectAccount } = accountSelection, accountSelectionProps = __rest(accountSelection, ["currentAccount", "inputStyle", "onSelectAccount"]);
@@ -108,7 +108,7 @@ export const HeaderV2 = memo(props => {
108
108
  onSelectAccount === null || onSelectAccount === void 0 ? void 0 : onSelectAccount(userId);
109
109
  };
110
110
  const QUOTE_ENTITY = React.createElement(React.Fragment, null, "\u00BB");
111
- return (React.createElement(HeaderV2Styled, { className: className || '', style: style },
111
+ return (React.createElement(HeaderV2Styled, { "$show": show, className: className || '', style: style },
112
112
  React.createElement("div", { className: "left-side" },
113
113
  showLogo && (React.createElement(LogoWrapper, { className: "logo-wrapper" },
114
114
  React.createElement("img", { src: SubLogoAntsomi, alt: "Antsomi sub logo" }))),
@@ -1,2 +1,4 @@
1
1
  export declare const LogoWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
2
- export declare const HeaderV2Styled: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export declare const HeaderV2Styled: import("styled-components").StyledComponent<"div", any, {
3
+ $show: boolean;
4
+ }, never>;
@@ -21,6 +21,8 @@ export const HeaderV2Styled = styled.div `
21
21
  padding: 10px 20px;
22
22
  box-sizing: border-box;
23
23
 
24
+ ${props => !props.$show && 'display: none;'}
25
+
24
26
  .left-side,
25
27
  .right-side {
26
28
  display: flex;
@@ -16,7 +16,7 @@ import { useLeftMenu } from './hooks';
16
16
  import { useLeftMenuContext } from './contexts';
17
17
  const SubLogoAntsomi = 'https://st-media-template.antsomi.com/icons/antsomi/antsomi.png';
18
18
  export const LeftMenuComponent = memo(props => {
19
- const { style, className, customization, showLogo = true } = props;
19
+ const { show = true, style, className, customization, showLogo = true } = props;
20
20
  const { isExpandable = true, isCustomized, isRecommendation, items = [], onMenuItemClick, } = customization || {};
21
21
  const appHoverMenuChildren = useLeftMenuContext(store => store.appHoverMenuChildren);
22
22
  const { state, activeAppCode, permissionMenu, customActiveAppKey, onToggleChildMenu, onMouseEnter, onMouseLeave, onHoverMenuBar, onShowPopover, onClickFeatureMenuItem, } = useLeftMenu(props);
@@ -95,7 +95,7 @@ export const LeftMenuComponent = memo(props => {
95
95
  }
96
96
  return null;
97
97
  };
98
- return (React.createElement(LeftMenuNavWrapper, { style: style, "$isExpandMenu": state.isExpandMenu && isExpandable, className: className },
98
+ return (React.createElement(LeftMenuNavWrapper, { "$show": show, style: style, "$isExpandMenu": state.isExpandMenu && isExpandable, className: className },
99
99
  React.createElement(LeftMenuNav, { className: "left-menu-nav" },
100
100
  React.createElement(FeatureMenuWrapper, { vertical: true, onMouseEnter: () => onShowPopover(), onMouseLeave: onMouseLeave },
101
101
  showLogo && (React.createElement(NavLogoWrapper, { align: "center", justify: "center", onMouseEnter: onHoverMenuBar },
@@ -8,6 +8,7 @@ export declare const FeatureMenuWrapper: import("styled-components").StyledCompo
8
8
  export declare const ExpandWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
9
9
  export declare const LeftMenuNavWrapper: import("styled-components").StyledComponent<"div", any, {
10
10
  $isExpandMenu?: boolean | undefined;
11
+ $show?: boolean | undefined;
11
12
  }, never>;
12
13
  export declare const NavLogoWrapper: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/flex/interface").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, {}, never>;
13
14
  export declare const LeftMenuNav: import("styled-components").StyledComponent<"nav", any, {}, never>;
@@ -44,7 +44,9 @@ export const PopoverWrapper = styled.div `
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)`};
47
- transition: visibility 0s, opacity 0.2s ease-out;
47
+ transition:
48
+ visibility 0s,
49
+ opacity 0.2s ease-out;
48
50
  z-index: 10;
49
51
  padding: 10px;
50
52
  box-sizing: border-box;
@@ -67,6 +69,8 @@ export const LeftMenuNavWrapper = styled.div `
67
69
  display: flex;
68
70
  transition: all 0.2s ease-out;
69
71
 
72
+ ${p => !p.$show && 'display: none;'}
73
+
70
74
  ${p => (p.$isExpandMenu ? `gap: 10px;` : `gap: 15px;`)}
71
75
  `;
72
76
  export const NavLogoWrapper = styled(Flex) `
@@ -206,7 +210,9 @@ export const ChildMenuWrapper = styled.div `
206
210
  margin-top: ${({ isMarginTop }) => (isMarginTop ? `${HEADER_HEIGHT}px` : '0px')};
207
211
  width: ${({ isExpand }) => (isExpand ? '210px' : '0px')};
208
212
  padding: ${({ isExpand }) => (isExpand ? '10px' : '10px 0')};
209
- transition: width 0.2s, padding 0.2s ease;
213
+ transition:
214
+ width 0.2s,
215
+ padding 0.2s ease;
210
216
  padding-left: 0px;
211
217
  box-sizing: border-box;
212
218
  z-index: 1;
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  // Libraries
13
- import React, { memo, useEffect, useMemo, useState } from 'react';
13
+ import React, { memo, useEffect, useMemo, useRef, useState } from 'react';
14
14
  import classNames from 'classnames';
15
15
  // Styled
16
16
  import { BannerWrapper } from './styled';
@@ -18,12 +18,15 @@ import { BannerWrapper } from './styled';
18
18
  import { MobileFrameV2 } from '@antscorp/antsomi-ui/es/components/atoms';
19
19
  // Constants
20
20
  import { DEVICE_TYPE } from '../../constants';
21
+ // Hooks
22
+ import { useForceUpdate } from '@antscorp/antsomi-ui/es/hooks';
21
23
  export const Banner = memo(props => {
22
- const { deviceType, showSkeleton = false, children, height } = props, restOfProps = __rest(props, ["deviceType", "showSkeleton", "children", "height"]);
24
+ var _a;
25
+ const { deviceType, showSkeleton = false, children, height = 700 } = props, restOfProps = __rest(props, ["deviceType", "showSkeleton", "children", "height"]);
26
+ const ref = useRef(null);
27
+ const forceUpdate = useForceUpdate();
23
28
  const isMobile = useMemo(() => deviceType === DEVICE_TYPE.MOBILE.value, [deviceType]);
24
- // States
25
29
  const [shouldAnimate, setShouldAnimate] = useState(false);
26
- // Side effects
27
30
  useEffect(() => {
28
31
  setShouldAnimate(true);
29
32
  const timerId = setTimeout(() => {
@@ -31,7 +34,26 @@ export const Banner = memo(props => {
31
34
  }, 1000);
32
35
  return () => clearTimeout(timerId);
33
36
  }, [children]);
34
- return (React.createElement(BannerWrapper, Object.assign({ "$height": height }, restOfProps),
37
+ useEffect(() => {
38
+ let timeoutAfterChange = null;
39
+ const handleResize = () => {
40
+ if (timeoutAfterChange) {
41
+ clearTimeout(timeoutAfterChange);
42
+ }
43
+ timeoutAfterChange = setTimeout(() => {
44
+ forceUpdate();
45
+ }, 0);
46
+ };
47
+ const resizeObserver = new ResizeObserver(handleResize);
48
+ if (ref === null || ref === void 0 ? void 0 : ref.current)
49
+ resizeObserver.observe(ref === null || ref === void 0 ? void 0 : ref.current);
50
+ return () => {
51
+ if (timeoutAfterChange) {
52
+ clearTimeout(timeoutAfterChange);
53
+ }
54
+ };
55
+ }, [forceUpdate]);
56
+ return (React.createElement(BannerWrapper, Object.assign({ ref: ref, "$height": height, clientHeight: (_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.offsetHeight }, restOfProps),
35
57
  React.createElement("div", { className: `${isMobile ? 'mobile-wrapper animate__animated animate__zoomIn' : 'desktop-wrapper'}` },
36
58
  React.createElement("div", { className: classNames({
37
59
  'content-wrapper': true,
@@ -1,3 +1,4 @@
1
1
  export declare const BannerWrapper: import("styled-components").StyledComponent<"div", any, {
2
- $height?: number | undefined;
2
+ $height: number | string;
3
+ clientHeight?: number | undefined;
3
4
  }, never>;
@@ -1,4 +1,6 @@
1
+ // Libraries
1
2
  import styled, { css } from 'styled-components';
3
+ import { isNumber } from 'lodash';
2
4
  // Images
3
5
  import skeletonBackground from '../../../../../assets/images/background/skeleton-background.png';
4
6
  // Constants
@@ -14,14 +16,21 @@ export const BannerWrapper = styled.div `
14
16
  background-color: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.colorBgSkeleton};
15
17
  border-radius: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.borderRadius}px;
16
18
  border: 1px solid ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.blue1_1};
17
- height: ${props => props.$height || 700}px;
19
+ height: ${({ $height }) => (isNumber($height) ? `${$height}px` : $height)};
18
20
 
19
21
  // Calculate scale of mobile frame
20
22
  #banner-mobile {
21
- ${props => {
22
- const height = props.$height || 700;
23
- const smallScale = (height - 10) / (MOBILE_VIEWPORT.MD.height + 36);
24
- const largeScale = (height - 10) / (MOBILE_VIEWPORT.LG.height + 36);
23
+ ${({ clientHeight }) => {
24
+ const [smallScale, largeScale] = (() => {
25
+ if (clientHeight) {
26
+ const bannerPadding = 5;
27
+ const margin = 18;
28
+ const smallScale = (clientHeight - bannerPadding * 2) / (MOBILE_VIEWPORT.MD.height + margin * 2);
29
+ const largeScale = (clientHeight - bannerPadding * 2) / (MOBILE_VIEWPORT.LG.height + margin * 2);
30
+ return [smallScale, largeScale];
31
+ }
32
+ return [1, 1];
33
+ })();
25
34
  return css `
26
35
  @media screen and (max-height: 1000px) {
27
36
  transform: scale(${smallScale});
@@ -34,37 +43,6 @@ export const BannerWrapper = styled.div `
34
43
  }}
35
44
  }
36
45
 
37
- /* ${props => props.$height
38
- ? css `
39
- height: ${props.$height}px;
40
-
41
- .mobile-wrapper {
42
- width: 359px;
43
- height: ${props.$height}px;
44
- }
45
- `
46
- : css `
47
- @media screen and (max-height: 1000px) {
48
- height: 760px;
49
- max-height: 760px;
50
-
51
- .mobile-wrapper {
52
- width: 359px;
53
- height: 722.41px;
54
- }
55
- }
56
-
57
- @media screen and (min-height: 1001px) {
58
- height: 830px;
59
- max-height: 830px;
60
-
61
- .mobile-wrapper {
62
- width: 380px;
63
- height: 800px;
64
- }
65
- }
66
- `} */
67
-
68
46
  .mobile-wrapper {
69
47
  position: relative;
70
48
  border-radius: 80px;
@@ -15,7 +15,8 @@ export interface PreviewTemplateModalProps extends ModalProps {
15
15
  export interface BannerProps extends React.HTMLAttributes<HTMLDivElement> {
16
16
  deviceType?: InformationProps['deviceType'];
17
17
  showSkeleton?: boolean;
18
- height?: number;
18
+ /** Type of height includes: number, px, %, vh */
19
+ height?: number | string;
19
20
  children?: React.ReactNode;
20
21
  }
21
22
  export type ThumbnailProps = Omit<ThumbnailCardProps, 'id' | 'name' | 'thumbnail' | 'onClickWrapper'> & {
@@ -5,6 +5,7 @@ import '@antscorp/processing-notification/dist/index.css';
5
5
  import { ProcessingNotificationProps } from '@antscorp/antsomi-ui/es/types';
6
6
  import { ContentWrapperProps, WorkspaceProps } from './types';
7
7
  export interface LayoutProps {
8
+ onlyContent?: boolean;
8
9
  headerProps?: Partial<Omit<HeaderV2Props, 'helpConfig'> & {
9
10
  helpConfig: Partial<HeaderV2Props['helpConfig']>;
10
11
  }>;
@@ -63,6 +63,7 @@ export const Layout = memo(props => {
63
63
  const header = useLayoutStore(store => store.state.header);
64
64
  const contentWrapper = useLayoutStore(store => store.state.contentWrapper);
65
65
  const workspace = useLayoutStore(store => store.state.workspace);
66
+ const onlyContent = useLayoutStore(store => store.state.onlyContent);
66
67
  const [, , removeCookie] = useCookies();
67
68
  const params = useParams();
68
69
  const location = useLocation();
@@ -88,6 +89,8 @@ export const Layout = memo(props => {
88
89
  attributeOldValue: true,
89
90
  characterDataOldValue: true,
90
91
  });
92
+ // Memo
93
+ const showOnlyContent = useDeepCompareMemo(() => { var _a; return (_a = props.onlyContent) !== null && _a !== void 0 ? _a : onlyContent; }, [onlyContent, props.onlyContent]);
91
94
  const permissionDomain = useDeepCompareMemo(() => {
92
95
  var _a;
93
96
  /**
@@ -193,6 +196,12 @@ export const Layout = memo(props => {
193
196
  setLoadingLayout(false);
194
197
  }
195
198
  }, [mergeLeftMenuProps.customization]);
199
+ /** Timeout for set layout loading off in case left menu no callback onActiveMenuCodeChange */
200
+ useDeepCompareEffect(() => {
201
+ setTimeout(() => {
202
+ setLoadingLayout(false);
203
+ }, 5000);
204
+ }, []);
196
205
  // Handle access denied
197
206
  const onClickSwitchAccount = useCallback(() => {
198
207
  // Remove cookie when switch account
@@ -276,12 +285,12 @@ export const Layout = memo(props => {
276
285
  ? header === null || header === void 0 ? void 0 : header.pageTitle
277
286
  : ''
278
287
  : activePageTitle))),
279
- React.createElement(HeaderV2, Object.assign({}, mergeHeaderProps, { showLogo: !showLeftMenu })),
288
+ React.createElement(HeaderV2, Object.assign({}, mergeHeaderProps, { show: !showOnlyContent, showLogo: !showLeftMenu })),
280
289
  React.createElement(Flex, { className: "layout-body" },
281
- showLeftMenu && (React.createElement(LeftMenu, Object.assign({ className: `layout-body__menu ${leftMenuClassName}` }, mergeLeftMenuProps, { customization: Object.assign(Object.assign({}, mergeLeftMenuProps.customization), {
290
+ React.createElement(LeftMenu, Object.assign({ show: showLeftMenu && !showOnlyContent, className: `layout-body__menu ${leftMenuClassName}` }, mergeLeftMenuProps, { customization: Object.assign(Object.assign({}, mergeLeftMenuProps.customization), {
282
291
  // If user has access denied, disable expandable
283
- isExpandable: !isAccessDenied && ((_a = mergeLeftMenuProps.customization) === null || _a === void 0 ? void 0 : _a.isExpandable) }), appConfig: leftMenuAppConfig, onActiveMenuCodeChange: onActiveMenuCodeChange }))),
284
- React.createElement(ContentWrapper, Object.assign({ "$noPadding": noPadding, "$noSpaceTopContent": noSpaceTopContent }, mergeContentWrapperProps), (activeMenu === null || activeMenu === void 0 ? void 0 : activeMenu.menu_item_code) === HOME_MENU_ITEMS.RECOMMENDATION ? (React.createElement("div", { className: "layout-body__content" },
292
+ isExpandable: !isAccessDenied && ((_a = mergeLeftMenuProps.customization) === null || _a === void 0 ? void 0 : _a.isExpandable) }), appConfig: leftMenuAppConfig, onActiveMenuCodeChange: onActiveMenuCodeChange })),
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" },
285
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,
286
295
  React.createElement(NotificationWrapper, { className: "process-notification", ref: notificationWrapperRef }, showNotification && (React.createElement(AntsProcessingNotification, Object.assign({}, antsProcessingNotificationConfig, { callback: handleCallbackNotify })))),
287
296
  React.createElement(ChildrenWrapper, Object.assign({}, workspaceContentProps), isAccessDenied ? (React.createElement(AccessDenied, { onClickRequestAccess: onClickRequestAccess, onClickSwitchAccount: onClickSwitchAccount })) : (React.createElement("div", null, children)))))))))));
@@ -15,6 +15,8 @@ export interface LayoutStoreState {
15
15
  leftMenu: LeftMenuStore;
16
16
  workspace: WorkspaceProps;
17
17
  contentWrapper: ContentWrapperProps;
18
+ /** Just show only content */
19
+ onlyContent?: boolean;
18
20
  }
19
21
  interface LayoutStore {
20
22
  state: LayoutStoreState;
@@ -6,6 +6,7 @@ const initialState = {
6
6
  leftMenu: {},
7
7
  workspace: {},
8
8
  contentWrapper: {},
9
+ onlyContent: false,
9
10
  };
10
11
  export const useLayoutStore = create(set => ({
11
12
  state: initialState,
@@ -5,6 +5,7 @@ export declare const LayoutWrapper: import("styled-components").StyledComponent<
5
5
  export declare const ContentWrapper: import("styled-components").StyledComponent<"div", any, {
6
6
  $noPadding?: boolean | undefined;
7
7
  $noSpaceTopContent?: boolean | undefined;
8
+ $showOnlyContent?: boolean | undefined;
8
9
  }, never>;
9
10
  export declare const NotificationWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
10
11
  export declare const ChildrenWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1,6 +1,6 @@
1
1
  var _a, _b;
2
2
  // Libraries
3
- import styled from 'styled-components';
3
+ import styled, { css } from 'styled-components';
4
4
  // Components
5
5
  import { Flex, Spin } from '../../atoms';
6
6
  // Constants
@@ -57,6 +57,16 @@ export const ContentWrapper = styled.div `
57
57
  .layout-body__content {
58
58
  ${({ $noSpaceTopContent }) => $noSpaceTopContent && 'padding-top: 0;'}
59
59
  }
60
+
61
+ ${({ $showOnlyContent }) => $showOnlyContent &&
62
+ css `
63
+ padding: 0px;
64
+
65
+ .layout-body__content {
66
+ padding: 0px;
67
+ border-radius: 0px;
68
+ }
69
+ `}
60
70
  `;
61
71
  export const NotificationWrapper = styled.div `
62
72
  flex-shrink: 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.575",
3
+ "version": "1.3.5-beta.577",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",
@@ -62,7 +62,7 @@
62
62
  "not op_mini all"
63
63
  ],
64
64
  "dependencies": {
65
- "@antscorp/icons": "0.27.51",
65
+ "@antscorp/icons": "0.27.52",
66
66
  "@antscorp/image-editor": "1.0.2",
67
67
  "@antscorp/processing-notification": "^1.0.3",
68
68
  "@dnd-kit/core": "^6.1.0",