@antscorp/antsomi-ui 1.3.5-beta.576 → 1.3.5-beta.578
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/organism/LeftMenu/components/HomeMenu/index.js +2 -2
- package/es/components/organism/LeftMenu/components/HomeMenu/useHomeMenu.d.ts +1 -0
- package/es/components/organism/LeftMenu/components/HomeMenu/useHomeMenu.js +3 -1
- package/es/components/organism/PreviewTemplateModal/components/Banner/index.js +27 -5
- package/es/components/organism/PreviewTemplateModal/components/Banner/styled.d.ts +2 -1
- package/es/components/organism/PreviewTemplateModal/components/Banner/styled.js +14 -36
- package/es/components/organism/PreviewTemplateModal/types.d.ts +2 -1
- package/package.json +1 -1
|
@@ -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, setRemovedDashboardId, onCreateNewReport, onMenuClick, onRemoveDashboard, } = useHomeMenu(props);
|
|
13
|
+
const { children, removedDashboardId, isDashboardRemoving, isRecommendation, 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 && (React.createElement(CreateButton, { type: "primary", onClick: onCreateNewReport },
|
|
16
|
+
!isRecommendation && 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")))),
|
|
@@ -5,6 +5,7 @@ export declare const useHomeMenu: (props: HomeMenuProps) => {
|
|
|
5
5
|
removedDashboardId: string;
|
|
6
6
|
isDashboardRemoving: boolean;
|
|
7
7
|
isRecommendation: boolean | undefined;
|
|
8
|
+
showCreateButton: boolean;
|
|
8
9
|
setRemovedDashboardId: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
9
10
|
onCreateNewReport: import("react").MouseEventHandler<HTMLElement>;
|
|
10
11
|
onOptionCallback: (args: {
|
|
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
import { useCallback, useMemo, useState } from 'react';
|
|
12
12
|
// Constants
|
|
13
13
|
import { CONFIG_OPTIONS } from './constants';
|
|
14
|
-
import { HOME_REPORT_ROUTES, HOME_ROUTE } from '../../constants';
|
|
14
|
+
import { HOME_MENU_ITEMS, HOME_REPORT_ROUTES, HOME_ROUTE } from '../../constants';
|
|
15
15
|
import { API_RESPONSE_CODE, CDP_API, CDP_ROUTE } from '@antscorp/antsomi-ui/es/constants';
|
|
16
16
|
// Utils
|
|
17
17
|
import { getGeneratePath, getMenuItem } from '../../utils';
|
|
@@ -36,6 +36,7 @@ export const useHomeMenu = (props) => {
|
|
|
36
36
|
const onClickCreateDashboard = useLayoutStore(store => store.state.leftMenu.onClickCreateDashboard);
|
|
37
37
|
const [removedDashboardId, setRemovedDashboardId] = useState('');
|
|
38
38
|
const urlParams = useMemo(() => new URLSearchParams(search), [search]);
|
|
39
|
+
const showCreateButton = useMemo(() => !!(appMenuChildren === null || appMenuChildren === void 0 ? void 0 : appMenuChildren.find(item => item.menu_item_code === HOME_MENU_ITEMS.DASHBOARD)), [appMenuChildren]);
|
|
39
40
|
const { mutateAsync: removeDashboard, isLoading: isDashboardRemoving } = useRemoveDashboard();
|
|
40
41
|
const onOptionCallback = useCallback((args) => {
|
|
41
42
|
const { optionKey, menuItemKey } = args;
|
|
@@ -126,6 +127,7 @@ export const useHomeMenu = (props) => {
|
|
|
126
127
|
removedDashboardId,
|
|
127
128
|
isDashboardRemoving,
|
|
128
129
|
isRecommendation,
|
|
130
|
+
showCreateButton,
|
|
129
131
|
setRemovedDashboardId,
|
|
130
132
|
onCreateNewReport,
|
|
131
133
|
onOptionCallback,
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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,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: ${
|
|
19
|
+
height: ${({ $height }) => (isNumber($height) ? `${$height}px` : $height)};
|
|
18
20
|
|
|
19
21
|
// Calculate scale of mobile frame
|
|
20
22
|
#banner-mobile {
|
|
21
|
-
${
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
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
|
|
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'> & {
|