@antscorp/antsomi-ui 1.3.5-beta.280 → 1.3.5-beta.282
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/molecules/DrawerDetail/DrawerDetail.js +32 -19
- package/es/components/molecules/DrawerDetail/types.d.ts +2 -0
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/ImageSlider.js +10 -14
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/styled.js +4 -0
- package/package.json +1 -1
|
@@ -20,9 +20,10 @@ import { BREAK_POINT, DRAWER_LARGE_MAX_WIDTH, DRAWER_LARGE_MIN_WIDTH, DRAWER_SMA
|
|
|
20
20
|
import { ToggleDrawerSizeButton } from './components';
|
|
21
21
|
// Hooks
|
|
22
22
|
import { useMediaQuery, useToggle } from '@antscorp/antsomi-ui/es/hooks';
|
|
23
|
+
import { ConfigProvider } from 'antd';
|
|
23
24
|
export const DrawerDetail = props => {
|
|
24
25
|
// Props
|
|
25
|
-
const { width, fullScreen, children, menuProps, closeIconProps, maxWidth, minWidth } = props, restProps = __rest(props, ["width", "fullScreen", "children", "menuProps", "closeIconProps", "maxWidth", "minWidth"]);
|
|
26
|
+
const { width, fullScreen, children, menuProps, closeIconProps, maxWidth, minWidth, defaultSize = 'max' } = props, restProps = __rest(props, ["width", "fullScreen", "children", "menuProps", "closeIconProps", "maxWidth", "minWidth", "defaultSize"]);
|
|
26
27
|
const { show: showMenu = true, showExpandButton = true, showClose = true, items, selectedKeys, footer, onClick = () => { }, } = menuProps || {};
|
|
27
28
|
const { onClose = () => { } } = props;
|
|
28
29
|
const _a = closeIconProps || {}, { show: showCloseIcon, onClick: onCloseIconClick = () => { } } = _a, restOfCloseIcon = __rest(_a, ["show", "onClick"]);
|
|
@@ -32,8 +33,19 @@ export const DrawerDetail = props => {
|
|
|
32
33
|
const [collapseDrawer, toggleCollapseDrawer] = useToggle(false);
|
|
33
34
|
// Effects
|
|
34
35
|
useEffect(() => {
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
if (matchesSmallScreen) {
|
|
37
|
+
toggleCollapseDrawer(false);
|
|
38
|
+
}
|
|
39
|
+
switch (defaultSize) {
|
|
40
|
+
case 'max':
|
|
41
|
+
toggleCollapseDrawer(false);
|
|
42
|
+
break;
|
|
43
|
+
case 'min':
|
|
44
|
+
default:
|
|
45
|
+
toggleCollapseDrawer(true);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}, [matchesSmallScreen, defaultSize, toggleCollapseDrawer]);
|
|
37
49
|
// Memo
|
|
38
50
|
const drawerWidth = useMemo(() => {
|
|
39
51
|
if (fullScreen)
|
|
@@ -63,22 +75,23 @@ export const DrawerDetail = props => {
|
|
|
63
75
|
}
|
|
64
76
|
}
|
|
65
77
|
}, [collapseDrawer, fullScreen, matchesSmallScreen, maxWidth, minWidth, width]);
|
|
66
|
-
return (React.createElement(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
showCloseIcon && (React.createElement("div", Object.assign({ className: "close-btn" }, restOfCloseIcon, { onClick: e => {
|
|
70
|
-
onCloseIconClick(e);
|
|
71
|
-
onClose(e);
|
|
78
|
+
return (React.createElement(ConfigProvider, { theme: { components: { Drawer: { motionDurationSlow: '0ms' } } } },
|
|
79
|
+
React.createElement(StyledDrawer, Object.assign({}, restProps, { push: false, closable: false, width: drawerWidth, classNames: {
|
|
80
|
+
body: 'drawer-detail-body',
|
|
72
81
|
} }),
|
|
73
|
-
React.createElement(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
showCloseIcon && (React.createElement("div", Object.assign({ className: "close-btn" }, restOfCloseIcon, { onClick: e => {
|
|
83
|
+
onCloseIconClick(e);
|
|
84
|
+
onClose(e);
|
|
85
|
+
} }),
|
|
86
|
+
React.createElement(Icon, { type: "icon-ants-remove-slim", size: 14 }))),
|
|
87
|
+
showExpandButton && !fullScreen && (React.createElement(ToggleDrawerSizeButton, { style: Object.assign({}, (!showMenu && { background: '#ffffff' })), onClick: () => toggleCollapseDrawer(), collapse: collapseDrawer })),
|
|
88
|
+
showMenu && (React.createElement(LeftMenu, { className: "animate__animated animate__fadeIn" },
|
|
89
|
+
React.createElement("div", null,
|
|
90
|
+
showClose && (React.createElement(CloseBtn, { onClick: onClose },
|
|
91
|
+
React.createElement(Icon, { type: "icon-ants-remove-slim", size: 14 }))),
|
|
92
|
+
React.createElement(Flex, { vertical: true, gap: 10, align: "center", justify: "center" }, items === null || items === void 0 ? void 0 : items.map((item) => (React.createElement(Tooltip, { key: item === null || item === void 0 ? void 0 : item.key, title: item === null || item === void 0 ? void 0 : item.label, mouseEnterDelay: 0.3 },
|
|
93
|
+
React.createElement(MenuItem, { key: item === null || item === void 0 ? void 0 : item.key, className: (selectedKeys === null || selectedKeys === void 0 ? void 0 : selectedKeys.includes(item.key)) ? 'active' : '', onClick: () => onClick && onClick(item) }, item.icon)))))),
|
|
94
|
+
React.createElement(MenuFooter, null, footer))),
|
|
95
|
+
React.createElement(Content, null, children))));
|
|
83
96
|
};
|
|
84
97
|
DrawerDetail.defaultProps = {};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import type { DrawerProps, MenuProps as AntdProps } from 'antd';
|
|
3
3
|
import { ItemType } from 'antd/es/menu/hooks/useItems';
|
|
4
|
+
export type TDefaultSize = 'max' | 'min';
|
|
4
5
|
export interface DrawerDetailProps extends Omit<DrawerProps, 'closeIcon'> {
|
|
5
6
|
fullScreen?: boolean;
|
|
6
7
|
maxWidth?: string | number;
|
|
7
8
|
minWidth?: string | number;
|
|
9
|
+
defaultSize?: TDefaultSize;
|
|
8
10
|
menuProps?: DrawerDetailMenuProps;
|
|
9
11
|
closeIconProps?: DrawerDetailCloseIconProps;
|
|
10
12
|
}
|
|
@@ -93,23 +93,26 @@ export const ImageSlider = props => {
|
|
|
93
93
|
var _a;
|
|
94
94
|
(_a = fileRef === null || fileRef === void 0 ? void 0 : fileRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
95
95
|
}, []);
|
|
96
|
-
const onImportImageSelect = (e) => {
|
|
96
|
+
const onImportImageSelect = useCallback((e) => {
|
|
97
97
|
var _a, _b, _c;
|
|
98
98
|
if ((_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0]) {
|
|
99
99
|
if (((_b = e.target.files) === null || _b === void 0 ? void 0 : _b[0].size) > SIZE_LIMIT) {
|
|
100
|
-
|
|
100
|
+
/**
|
|
101
|
+
* NOTE: This reset e.target.files (fix: upload the same image later will trigger change input)
|
|
102
|
+
* use DataTransfer because e.target.files = null not work in this case
|
|
103
|
+
*/
|
|
104
|
+
e.target.files = new DataTransfer().files;
|
|
101
105
|
message.error({
|
|
102
106
|
content: 'File size too big',
|
|
103
107
|
style: { fontSize: '11px', fontFamily: 'Roboto' },
|
|
104
108
|
});
|
|
105
|
-
e.target.files = null;
|
|
106
109
|
return;
|
|
107
110
|
}
|
|
108
111
|
(_c = imageResizeRef.current) === null || _c === void 0 ? void 0 : _c.replaceImageWithUrl(URL.createObjectURL(e.target.files[0]));
|
|
109
112
|
setUploadThumbnail(undefined);
|
|
110
113
|
}
|
|
111
|
-
e.target.files =
|
|
112
|
-
};
|
|
114
|
+
e.target.files = new DataTransfer().files;
|
|
115
|
+
}, []);
|
|
113
116
|
useDropFile('.image-upload-zone', e => {
|
|
114
117
|
var _a, _b, _c, _d;
|
|
115
118
|
if (!((_a = e === null || e === void 0 ? void 0 : e.dataTransfer) === null || _a === void 0 ? void 0 : _a.files[0]))
|
|
@@ -143,16 +146,9 @@ export const ImageSlider = props => {
|
|
|
143
146
|
const ImageResizeComponent = useFabric ? ImageResizeTuiEditor : ImageResize;
|
|
144
147
|
return (React.createElement(ImageSliderStyled, { className: className || '', "$skeleton": showSkeletonMemo, "$imageWidth": imageWidth, "$smallImageWidth": smallImageWidth, "$imageHeight": imageHeight, vertical: true, gap: 10 },
|
|
145
148
|
React.createElement(Flex, { vertical: true, style: { zIndex: 25, display: !isNil(currentEditing) ? 'flex' : 'none' }, className: `edit-thumbnail-container ${!isNil(currentEditing) ? 'is-editing' : ''}` },
|
|
146
|
-
React.createElement(ImageResizeComponent, {
|
|
147
|
-
// latestCanvas && isEditPrevious
|
|
148
|
-
(latestCanvas === null || latestCanvas === void 0 ? void 0 : latestCanvas[currentEditing])
|
|
149
|
+
React.createElement(ImageResizeComponent, { className: `image-resize-wrapper ${typeof uploadThumbnail === 'number' ? 'visibility-hidden' : ''}`, width: imageWidth, height: imageHeight, ref: imageResizeRef, hideAction: true, imageUrl: (latestCanvas === null || latestCanvas === void 0 ? void 0 : latestCanvas[currentEditing])
|
|
149
150
|
? undefined
|
|
150
|
-
: getUrlNoCache(currentThumbnailUrl, timeGenerated),
|
|
151
|
-
// imageUrl={getUrlNoCache(
|
|
152
|
-
// thumbnails[editingThumbnail ?? (uploadThumbnail as number)],
|
|
153
|
-
// timeGenerated,
|
|
154
|
-
// )}
|
|
155
|
-
defaultValue: latestCanvas === null || latestCanvas === void 0 ? void 0 : latestCanvas[currentEditing] }),
|
|
151
|
+
: getUrlNoCache(currentThumbnailUrl, timeGenerated), defaultValue: latestCanvas === null || latestCanvas === void 0 ? void 0 : latestCanvas[currentEditing] }),
|
|
156
152
|
typeof uploadThumbnail !== 'number' ? null : (React.createElement(Flex, { className: `image-upload-zone ${!showSkeletonMemo ? 'hide-skeleton' : ''}` },
|
|
157
153
|
React.createElement(Icon, { type: "icon-ants-upload-fill", style: { fontSize: '40px' } }),
|
|
158
154
|
React.createElement(Flex, { vertical: true, align: "flex-start" },
|
|
@@ -47,6 +47,10 @@ export const ImageSliderStyled = styled(Flex) `
|
|
|
47
47
|
background-size: 90% 90%;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
.image-resize-wrapper.visibility-hidden {
|
|
51
|
+
visibility: hidden;
|
|
52
|
+
}
|
|
53
|
+
|
|
50
54
|
.image-resize-wrapper,
|
|
51
55
|
.image-upload-zone {
|
|
52
56
|
border: 1px solid ${(_a = THEME.token) === null || _a === void 0 ? void 0 : _a.blue1_1};
|