@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
+ }
@@ -1,3 +1,4 @@
1
1
  export declare const POST_MESSAGE_TYPES: {
2
2
  REFETCH_DASHBOARD_LIST: string;
3
+ TOGGLE_DRAWER_DETAIL_FULLSCREEN: string;
3
4
  };
@@ -1,3 +1,4 @@
1
1
  export const POST_MESSAGE_TYPES = {
2
2
  REFETCH_DASHBOARD_LIST: 'REFETCH_DASHBOARD_LIST',
3
+ TOGGLE_DRAWER_DETAIL_FULLSCREEN: 'TOGGLE_DRAWER_DETAIL_FULLSCREEN',
3
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.486",
3
+ "version": "1.3.5-beta.487",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",