@antscorp/antsomi-ui 1.3.5-beta.486 → 1.3.5-beta.488

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,16 +12,17 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import { Scrollbars as CustomScrollbars, } from 'react-custom-scrollbars';
13
13
  import { cloneDeep } from 'lodash';
14
14
  // Libraries
15
- import React, { useRef } from 'react';
15
+ import React, { forwardRef, useImperativeHandle, useRef } from 'react';
16
16
  // Styled
17
17
  import { HorizontalTrack, ThumbBar, VerticalTrack } from './styled';
18
18
  const THUMB_SIZE = 4;
19
19
  const MARGIN = 3;
20
- export const Scrollbars = props => {
20
+ export const Scrollbars = forwardRef((props, refProp) => {
21
21
  // Props
22
22
  const { autoHide = true, autoHeightMax = 0, className } = props, restProps = __rest(props, ["autoHide", "autoHeightMax", "className"]);
23
23
  // Refs
24
24
  const ref = useRef(null);
25
+ useImperativeHandle(refProp, () => ref.current, []);
25
26
  /**
26
27
  * Updates the size and position of the custom scrollbar thumbs based on the provided dimensions and scroll positions.
27
28
  *
@@ -57,7 +58,7 @@ export const Scrollbars = props => {
57
58
  ref.current.trackHorizontal.style.visibility =
58
59
  scrollWidth <= clientWidth ? 'hidden' : 'visible';
59
60
  };
60
- return (React.createElement(CustomScrollbars, Object.assign({ className: `custom-scrollbars ${className || ''}`, ref: ref, autoHide: autoHide, autoHeightMax: autoHeightMax, renderThumbVertical: props => React.createElement(ThumbBar, Object.assign({ className: "thumb-vertical" }, props)), renderThumbHorizontal: props => React.createElement(ThumbBar, Object.assign({ className: "thumb-horizontal" }, props)), renderTrackVertical: (_a) => {
61
+ return (React.createElement(CustomScrollbars, Object.assign({ className: `custom-scrollbars ${className || ''}`, autoHide: autoHide, autoHeightMax: autoHeightMax, renderThumbVertical: props => React.createElement(ThumbBar, Object.assign({ className: "thumb-vertical" }, props)), renderThumbHorizontal: props => React.createElement(ThumbBar, Object.assign({ className: "thumb-horizontal" }, props)), renderTrackVertical: (_a) => {
61
62
  var { style } = _a, restOfProps = __rest(_a, ["style"]);
62
63
  return (React.createElement(VerticalTrack, Object.assign({ className: "scrollbar-track" }, restOfProps, { style: Object.assign(Object.assign({}, style), { display: 'block' }) })));
63
64
  }, renderTrackHorizontal: (_a) => {
@@ -77,5 +78,5 @@ export const Scrollbars = props => {
77
78
  // }
78
79
  // Return a div element with the adjusted styles and original props, applying a custom class for styling
79
80
  return React.createElement("div", Object.assign({ className: "scrollbar-view" }, props, { style: newStyle }));
80
- }, onUpdate: onUpdate, hideTracksWhenNotNeeded: true }, restProps)));
81
- };
81
+ }, onUpdate: onUpdate, hideTracksWhenNotNeeded: true }, restProps, { ref: ref })));
82
+ });
@@ -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.488",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",