@antscorp/antsomi-ui 1.3.5-beta.486 → 1.3.5-beta.487
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.
|
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
// Libraries
|
|
13
13
|
import { ConfigProvider } from 'antd';
|
|
14
14
|
import { isNil } from 'lodash';
|
|
15
|
-
import React, { useEffect, useMemo } from 'react';
|
|
15
|
+
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
16
16
|
// Components
|
|
17
17
|
import { Flex, Icon, Tooltip } from '../../atoms';
|
|
18
18
|
// Styled
|
|
@@ -24,9 +24,10 @@ import { ToggleDrawerSizeButton } from './components';
|
|
|
24
24
|
import { useMediaQuery, useToggle } from '@antscorp/antsomi-ui/es/hooks';
|
|
25
25
|
// Utils
|
|
26
26
|
import { safeParseJson } from '@antscorp/antsomi-ui/es/utils';
|
|
27
|
+
import { POST_MESSAGE_TYPES } from '@antscorp/antsomi-ui/es/constants';
|
|
27
28
|
export const DrawerDetail = props => {
|
|
28
29
|
// Props
|
|
29
|
-
const { width, fullScreen, children, menuProps, closeIconProps, maxWidth, minWidth, defaultSize = 'max', headerProps, name, destroyOnClose = true } = props, restProps = __rest(props, ["width", "fullScreen", "children", "menuProps", "closeIconProps", "maxWidth", "minWidth", "defaultSize", "headerProps", "name", "destroyOnClose"]);
|
|
30
|
+
const { width, fullScreen: fullScreenProp = false, children, menuProps, closeIconProps, maxWidth, minWidth, defaultSize = 'max', headerProps, name, destroyOnClose = true } = props, restProps = __rest(props, ["width", "fullScreen", "children", "menuProps", "closeIconProps", "maxWidth", "minWidth", "defaultSize", "headerProps", "name", "destroyOnClose"]);
|
|
30
31
|
const { show: showMenu = true, showExpandButton = true, showClose = true, items, selectedKeys, footer, onClick = () => { }, } = menuProps || {};
|
|
31
32
|
const _a = headerProps || {}, { children: headerChildren } = _a, restOfHeaderProps = __rest(_a, ["children"]);
|
|
32
33
|
const { onClose = () => { } } = props;
|
|
@@ -35,7 +36,25 @@ export const DrawerDetail = props => {
|
|
|
35
36
|
const matchesSmallScreen = useMediaQuery(`(max-width: ${BREAK_POINT})`);
|
|
36
37
|
// State
|
|
37
38
|
const [collapseDrawer, toggleCollapseDrawer] = useToggle(false);
|
|
39
|
+
const [fullScreen, toggleFullScreen] = useToggle(fullScreenProp);
|
|
40
|
+
// Handlers
|
|
41
|
+
const handleToggleDrawerDetailFullscreen = useCallback((event) => {
|
|
42
|
+
const { type, data } = event.data || {};
|
|
43
|
+
const { name: payloadName, value } = data || {};
|
|
44
|
+
if (type === POST_MESSAGE_TYPES.TOGGLE_DRAWER_DETAIL_FULLSCREEN && payloadName === name) {
|
|
45
|
+
toggleFullScreen(isNil(value) ? undefined : value);
|
|
46
|
+
}
|
|
47
|
+
}, [name, toggleFullScreen]);
|
|
38
48
|
// Effects
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
window.addEventListener('message', handleToggleDrawerDetailFullscreen);
|
|
51
|
+
return () => {
|
|
52
|
+
window.removeEventListener('message', handleToggleDrawerDetailFullscreen);
|
|
53
|
+
};
|
|
54
|
+
}, [handleToggleDrawerDetailFullscreen]);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
toggleFullScreen(fullScreenProp);
|
|
57
|
+
}, [fullScreenProp, toggleFullScreen]);
|
|
39
58
|
useEffect(() => {
|
|
40
59
|
if (matchesSmallScreen) {
|
|
41
60
|
toggleCollapseDrawer(false);
|
|
@@ -87,7 +106,6 @@ export const DrawerDetail = props => {
|
|
|
87
106
|
}
|
|
88
107
|
}
|
|
89
108
|
}, [collapseDrawer, fullScreen, matchesSmallScreen, maxWidth, minWidth, width]);
|
|
90
|
-
// Handlers
|
|
91
109
|
const handleToggleDrawerSize = () => {
|
|
92
110
|
const localStorageValues = safeParseJson(localStorage.getItem(DRAWER_DETAIL_LOCAL_STORAGE_KEY), {});
|
|
93
111
|
toggleCollapseDrawer(!collapseDrawer);
|
|
@@ -19,9 +19,6 @@
|
|
|
19
19
|
padding: 0 !important;
|
|
20
20
|
|
|
21
21
|
.antsomi-picker-cell-inner {
|
|
22
|
-
// display: flex !important;
|
|
23
|
-
// align-items: center;
|
|
24
|
-
// justify-content: center;
|
|
25
22
|
width: 36px;
|
|
26
23
|
height: 36px !important;
|
|
27
24
|
line-height: 36px !important;
|
|
@@ -34,4 +31,4 @@
|
|
|
34
31
|
}
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
|
-
}
|
|
34
|
+
}
|