@antscorp/antsomi-ui 1.3.5-beta.263 → 1.3.5-beta.265
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/ImageEditor/ImageEditor.d.ts +1 -0
- package/es/components/molecules/ImageEditor/ImageEditor.js +2 -2
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/ImageSlider.js +20 -19
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/styled.js +6 -1
- package/es/components/molecules/TemplateSaveAs/styled.js +3 -2
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ interface ImageEditorProps {
|
|
|
13
13
|
imageUrl?: string;
|
|
14
14
|
defaultValue?: CanvasState;
|
|
15
15
|
showSelection?: boolean;
|
|
16
|
+
style?: Omit<React.CSSProperties, 'width'>;
|
|
16
17
|
}
|
|
17
18
|
export declare const ImageEditor: React.ForwardRefExoticComponent<ImageEditorProps & React.RefAttributes<ImageResizeHandle>>;
|
|
18
19
|
export {};
|
|
@@ -25,7 +25,7 @@ import { downloadURI, getTransformData } from './utils';
|
|
|
25
25
|
import { StageWrapperStyled } from './styled';
|
|
26
26
|
const SNAP_THRESHOLD = 5;
|
|
27
27
|
export const ImageEditor = React.forwardRef((props, ref) => {
|
|
28
|
-
const { defaultValue, className, width, height, hideAction, imageUrl = '', showSelection, } = props;
|
|
28
|
+
const { defaultValue, className, width, height, hideAction, imageUrl = '', showSelection, style, } = props;
|
|
29
29
|
const [color, setColor] = useState('#000');
|
|
30
30
|
const [drawAction, setDrawAction] = useState(DrawAction.Select);
|
|
31
31
|
const [cropZone, setCropZone] = useState();
|
|
@@ -618,7 +618,7 @@ export const ImageEditor = React.forwardRef((props, ref) => {
|
|
|
618
618
|
target.setAbsolutePosition(newPos);
|
|
619
619
|
// selectedNode.setAbsolutePosition(newPos);
|
|
620
620
|
}, []);
|
|
621
|
-
return (React.createElement("div", { style: { width: `${width}px` } },
|
|
621
|
+
return (React.createElement("div", { style: Object.assign({ width: `${width}px` }, (style || {})) },
|
|
622
622
|
React.createElement(Flex, { justify: "space-between", align: "center", style: { marginBottom: '6px', display: hideAction ? 'none' : 'flex' } },
|
|
623
623
|
React.createElement(Flex, { gap: 4 },
|
|
624
624
|
PAINT_OPTIONS.map(({ id, label, icon }) => (React.createElement(Button, { key: id, "aria-label": label, icon: React.createElement(Icon, { type: icon, style: { fontSize: '16px' } }), onClick: () => {
|
|
@@ -9,6 +9,7 @@ import { SmallImage } from './SmallImage';
|
|
|
9
9
|
import { BigImage } from './BigImage';
|
|
10
10
|
import { useDropFile } from '@antscorp/antsomi-ui/es/hooks';
|
|
11
11
|
import { checkShowSkeletonBaseUrl, getUrlNoCache } from '@antscorp/antsomi-ui/es/utils';
|
|
12
|
+
import { isNil } from 'lodash';
|
|
12
13
|
// Image size limit to 10MB
|
|
13
14
|
const SIZE_LIMIT = 10 * 1024 * 1024;
|
|
14
15
|
const ButtonSlider = React.memo(({ direction, type, onClick }) => (React.createElement("div", { className: type === 'slider'
|
|
@@ -78,6 +79,7 @@ export const ImageSlider = props => {
|
|
|
78
79
|
return (Object.assign(Object.assign({}, prev), { [selectedThumbnail]: (_a = imageResizeRef.current) === null || _a === void 0 ? void 0 : _a.getCurrentState() }));
|
|
79
80
|
});
|
|
80
81
|
setEditingThumbnail(undefined);
|
|
82
|
+
handleSelectThumbnail(selectedThumbnail);
|
|
81
83
|
};
|
|
82
84
|
const fileRef = useRef(null);
|
|
83
85
|
const onImportImageClick = useCallback(() => {
|
|
@@ -108,26 +110,22 @@ export const ImageSlider = props => {
|
|
|
108
110
|
const currentTime = useMemo(() => new Date(), []);
|
|
109
111
|
const timeGenerated = Math.floor(currentTime.getTime() / 1000 - (currentTime.getTime() % 3)) * 1000;
|
|
110
112
|
const currentEditing = useMemo(() => editingThumbnail !== null && editingThumbnail !== void 0 ? editingThumbnail : uploadThumbnail, [editingThumbnail, uploadThumbnail]);
|
|
111
|
-
const imageResizeProps = {
|
|
112
|
-
className: 'image-resize-wrapper',
|
|
113
|
-
width: imageWidth,
|
|
114
|
-
height: imageHeight,
|
|
115
|
-
ref: imageResizeRef,
|
|
116
|
-
hideAction: true,
|
|
117
|
-
imageUrl:
|
|
118
|
-
// latestCanvas && isEditPrevious
|
|
119
|
-
(latestCanvas === null || latestCanvas === void 0 ? void 0 : latestCanvas[currentEditing])
|
|
120
|
-
? undefined
|
|
121
|
-
: getUrlNoCache(thumbnails[currentEditing], timeGenerated),
|
|
122
|
-
defaultValue: latestCanvas === null || latestCanvas === void 0 ? void 0 : latestCanvas[currentEditing],
|
|
123
|
-
};
|
|
124
113
|
const ImageResizeComponent = useFabric ? ImageResizeTuiEditor : ImageResize;
|
|
125
114
|
const showSkeletonMemo = skeleton !== undefined
|
|
126
115
|
? skeleton
|
|
127
116
|
: checkShowSkeletonBaseUrl(getUrlNoCache(thumbnails[currentEditing], timeGenerated));
|
|
128
117
|
return (React.createElement(ImageSliderStyled, { className: className || '', "$skeleton": skeleton, "$imageWidth": imageWidth, "$smallImageWidth": smallImageWidth, "$imageHeight": imageHeight, vertical: true, gap: 10 },
|
|
129
|
-
|
|
130
|
-
React.createElement(ImageResizeComponent,
|
|
118
|
+
React.createElement(Flex, { vertical: true, style: { zIndex: 25, display: !isNil(currentEditing) ? 'flex' : 'none' }, className: `edit-thumbnail-container ${!isNil(currentEditing) ? 'is-editing' : ''}` },
|
|
119
|
+
React.createElement(ImageResizeComponent, { style: { visibility: typeof uploadThumbnail === 'number' ? 'hidden' : 'visible' }, className: "image-resize-wrapper", width: imageWidth, height: imageHeight, ref: imageResizeRef, hideAction: true, imageUrl:
|
|
120
|
+
// latestCanvas && isEditPrevious
|
|
121
|
+
(latestCanvas === null || latestCanvas === void 0 ? void 0 : latestCanvas[currentEditing])
|
|
122
|
+
? undefined
|
|
123
|
+
: getUrlNoCache(thumbnails[currentEditing], timeGenerated),
|
|
124
|
+
// imageUrl={getUrlNoCache(
|
|
125
|
+
// thumbnails[editingThumbnail ?? (uploadThumbnail as number)],
|
|
126
|
+
// timeGenerated,
|
|
127
|
+
// )}
|
|
128
|
+
defaultValue: latestCanvas === null || latestCanvas === void 0 ? void 0 : latestCanvas[currentEditing] }),
|
|
131
129
|
typeof uploadThumbnail !== 'number' ? null : (React.createElement(Flex, { className: `image-upload-zone ${!showSkeletonMemo ? 'hide-skeleton' : ''}` },
|
|
132
130
|
React.createElement(Icon, { type: "icon-ants-upload-fill", style: { fontSize: '40px' } }),
|
|
133
131
|
React.createElement(Flex, { vertical: true, align: "flex-start" },
|
|
@@ -140,10 +138,13 @@ export const ImageSlider = props => {
|
|
|
140
138
|
React.createElement(Button, { onClick: () => {
|
|
141
139
|
setEditingThumbnail(undefined);
|
|
142
140
|
setUploadThumbnail(undefined);
|
|
143
|
-
} }, "Cancel")))
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
141
|
+
} }, "Cancel"))),
|
|
142
|
+
React.createElement(Flex, { className: "thumbnail-preview-container", ref: thumbnailSelectedRef, style: { display: !isNil(currentEditing) ? 'none' : 'flex' } }, isLoading ? (React.createElement(Spin, { spinning: true })) : (thumbnails.map((url, index) => (React.createElement(BigImage, { key: `image-big_${url}_${index * 2}`, url: url, index: index, showSkeleton: skeleton, isDefaultThumbnail: defaultThumbnailInternal === index, isHideDefaultButton: hideDefaultButton || hideThumbnailsList || thumbnailsQuantity <= 1, imageFit: thumbnailFit, onClickDefaultButton: handleClickDefault, onClickEdit: () => setEditingThumbnail(selectedThumbnail),
|
|
143
|
+
// onClickEdit={index => setEditingThumbnail(index)}
|
|
144
|
+
onClickUpload: () => {
|
|
145
|
+
setEditingThumbnail(selectedThumbnail);
|
|
146
|
+
setUploadThumbnail(selectedThumbnail);
|
|
147
|
+
} }))))),
|
|
147
148
|
hideThumbnailsList || thumbnailsQuantity <= 1 ? null : (React.createElement(Flex, { gap: 10, className: "thumbnail-slider-container", ref: sliderContainerRef, style: { justifyContent: thumbnailsQuantity < slidesPerView ? 'center' : 'flex-start' } }, isLoading ? (React.createElement(Spin, { spinning: true })) : (thumbnails.map((url, index) => (React.createElement(SmallImage, { imageFit: thumbnailFit, key: `${url}_${index * 2}`, showSkeleton: skeleton, isSelected: index === selectedThumbnail, url: url, index: index, onClick: handleSelectThumbnail })))))),
|
|
148
149
|
previewNavigation && !isLoading ? (React.createElement(React.Fragment, null,
|
|
149
150
|
React.createElement(ButtonSlider, { direction: "left", type: "preview", onClick: handlePrevThumbnail }),
|
|
@@ -80,7 +80,12 @@ export const ImageSliderStyled = styled(Flex) `
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
&:not(.hide-skeleton) {
|
|
83
|
-
background: ${props =>
|
|
83
|
+
background: ${props => {
|
|
84
|
+
var _a;
|
|
85
|
+
return props.$skeleton
|
|
86
|
+
? `url(${SkeletonBg}) no-repeat center center`
|
|
87
|
+
: (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorBgSkeleton;
|
|
88
|
+
}};
|
|
84
89
|
|
|
85
90
|
background-size: 90% 90%;
|
|
86
91
|
}
|
|
@@ -10,8 +10,9 @@ export const TemplateSaveAsStyled = styled(Flex) `
|
|
|
10
10
|
|
|
11
11
|
position: relative;
|
|
12
12
|
|
|
13
|
-
&:has(canvas),
|
|
14
|
-
&:has(.image-upload-zone) {
|
|
13
|
+
/* &:has(canvas),
|
|
14
|
+
&:has(.image-upload-zone) { */
|
|
15
|
+
&:has(.is-editing) {
|
|
15
16
|
&:after {
|
|
16
17
|
content: '';
|
|
17
18
|
position: absolute;
|