@solostylist/image-editor 1.0.9 → 1.0.10
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/lib/actions/add-filter.js +11 -1
- package/lib/actions/change-pointer-icon.js +10 -1
- package/lib/actions/change-rotation.js +13 -1
- package/lib/actions/clear-annotations-selections.js +10 -1
- package/lib/actions/duplicate-annotations.js +26 -1
- package/lib/actions/enable-text-content-edit.js +10 -1
- package/lib/actions/hide-loader.js +10 -1
- package/lib/actions/index.js +36 -1
- package/lib/actions/redo.js +27 -1
- package/lib/actions/remove-annotations.js +27 -1
- package/lib/actions/reset.js +26 -1
- package/lib/actions/select-annotation.js +27 -1
- package/lib/actions/select-tab.js +16 -1
- package/lib/actions/select-tool.js +11 -1
- package/lib/actions/set-annotation.js +28 -1
- package/lib/actions/set-canvas-size.js +31 -1
- package/lib/actions/set-crop.js +25 -1
- package/lib/actions/set-feedback.js +11 -1
- package/lib/actions/set-finetune.js +13 -1
- package/lib/actions/set-latest-color.js +10 -1
- package/lib/actions/set-original-image.js +13 -1
- package/lib/actions/set-resize.js +14 -1
- package/lib/actions/set-saved.js +10 -1
- package/lib/actions/set-saving.js +11 -1
- package/lib/actions/set-show-tabs-menu.js +10 -1
- package/lib/actions/set-shown-image-dimensions.js +12 -1
- package/lib/actions/show-loader.js +10 -1
- package/lib/actions/toggle-flip.js +13 -1
- package/lib/actions/toggle-original-image-display.js +10 -1
- package/lib/actions/undo.js +27 -1
- package/lib/actions/update-state.js +7 -1
- package/lib/actions/zoom-canvas.js +37 -1
- package/lib/components/app/index.js +283 -1
- package/lib/components/assembly-point/index.js +23 -1
- package/lib/components/common/annotation-options/annotation-options.constants.js +10 -1
- package/lib/components/common/annotation-options/index.js +140 -1
- package/lib/components/common/annotation-options/opacity-field.js +23 -1
- package/lib/components/common/annotation-options/position-fields.js +39 -1
- package/lib/components/common/annotation-options/shadow-fields.js +62 -1
- package/lib/components/common/annotation-options/stroke-fields.js +33 -1
- package/lib/components/common/button-with-menu/index.js +86 -1
- package/lib/components/common/color-input/index.js +101 -1
- package/lib/components/common/color-picker-modal/index.js +70 -1
- package/lib/components/common/hidden-upload-input/index.js +17 -1
- package/lib/components/common/icon-wrapper/index.js +40 -1
- package/lib/components/common/image-preview-tile/index.js +57 -1
- package/lib/components/common/slider/index.js +38 -1
- package/lib/components/feedback-popup/index.js +41 -1
- package/lib/components/layers/design-layer/annotation-nodes/annotation-nodes.constants.js +10 -1
- package/lib/components/layers/design-layer/annotation-nodes/arrow-node.js +62 -1
- package/lib/components/layers/design-layer/annotation-nodes/ellipse-node.js +64 -1
- package/lib/components/layers/design-layer/annotation-nodes/image-node.js +78 -1
- package/lib/components/layers/design-layer/annotation-nodes/index.js +22 -1
- package/lib/components/layers/design-layer/annotation-nodes/line-node.js +60 -1
- package/lib/components/layers/design-layer/annotation-nodes/memoized-annotation.js +16 -1
- package/lib/components/layers/design-layer/annotation-nodes/polygon-node.js +63 -1
- package/lib/components/layers/design-layer/annotation-nodes/rect-node.js +65 -1
- package/lib/components/layers/design-layer/annotation-nodes/text-node.js +80 -1
- package/lib/components/layers/design-layer/index.js +202 -1
- package/lib/components/layers/design-layer/nodes-common-prop-types.js +16 -1
- package/lib/components/layers/design-layer/preview-group.js +9 -1
- package/lib/components/layers/index.js +2 -1
- package/lib/components/layers/transformers-layer/crop-transformer.js +248 -1
- package/lib/components/layers/transformers-layer/index.js +16 -1
- package/lib/components/layers/transformers-layer/nodes-transformer.js +73 -1
- package/lib/components/layers/transformers-layer/transformers-layer.utils.js +93 -1
- package/lib/components/main-canvas/canvas-node.js +177 -1
- package/lib/components/main-canvas/index.js +51 -1
- package/lib/components/main-canvas/touch-zooming-events.js +69 -1
- package/lib/components/node-controls/index.js +79 -1
- package/lib/components/tabs/index.js +66 -1
- package/lib/components/tabs/tabs.constants.js +27 -1
- package/lib/components/tabs-drawer/index.js +109 -1
- package/lib/components/tools/arrow/arrow-button.js +17 -1
- package/lib/components/tools/arrow/arrow-options.js +19 -1
- package/lib/components/tools/arrow/index.js +2 -1
- package/lib/components/tools/blur/blur-options.js +35 -1
- package/lib/components/tools/blur/blur.js +17 -1
- package/lib/components/tools/blur/index.js +2 -1
- package/lib/components/tools/brightness/brightness-options.js +36 -1
- package/lib/components/tools/brightness/brightness.js +17 -1
- package/lib/components/tools/brightness/index.js +2 -1
- package/lib/components/tools/contrast/contrast-options.js +35 -1
- package/lib/components/tools/contrast/contrast.js +17 -1
- package/lib/components/tools/contrast/index.js +2 -1
- package/lib/components/tools/crop/crop.constants.js +31 -1
- package/lib/components/tools/crop/crop.js +122 -1
- package/lib/components/tools/crop/index.js +1 -1
- package/lib/components/tools/ellipse/ellipse-button.js +17 -1
- package/lib/components/tools/ellipse/ellipse-options.js +17 -1
- package/lib/components/tools/ellipse/index.js +2 -1
- package/lib/components/tools/filters/filter-item.js +77 -1
- package/lib/components/tools/filters/filters.constants.js +139 -1
- package/lib/components/tools/filters/filters.js +74 -1
- package/lib/components/tools/filters/index.js +1 -1
- package/lib/components/tools/flip/flip-x.js +48 -1
- package/lib/components/tools/flip/flip-y.js +50 -1
- package/lib/components/tools/flip/index.js +2 -1
- package/lib/components/tools/hsv/hsv.js +17 -1
- package/lib/components/tools/hsv/hsvoptions.js +60 -1
- package/lib/components/tools/hsv/index.js +2 -1
- package/lib/components/tools/image/image-button.js +17 -1
- package/lib/components/tools/image/image-controls.js +12 -1
- package/lib/components/tools/image/image-options.js +162 -1
- package/lib/components/tools/image/images-gallery.js +55 -1
- package/lib/components/tools/image/index.js +2 -1
- package/lib/components/tools/line/index.js +2 -1
- package/lib/components/tools/line/line-button.js +17 -1
- package/lib/components/tools/line/line-options.js +19 -1
- package/lib/components/tools/pen/index.js +2 -1
- package/lib/components/tools/pen/pen-button.js +17 -1
- package/lib/components/tools/pen/pen-options.js +120 -1
- package/lib/components/tools/polygon/index.js +2 -1
- package/lib/components/tools/polygon/polygon-button.js +17 -1
- package/lib/components/tools/polygon/polygon-options.js +22 -1
- package/lib/components/tools/polygon/polygon-sides-field.js +23 -1
- package/lib/components/tools/polygon/polygon.constants.js +10 -1
- package/lib/components/tools/rect/index.js +2 -1
- package/lib/components/tools/rect/rect-button.js +17 -1
- package/lib/components/tools/rect/rect-corner-field.js +24 -1
- package/lib/components/tools/rect/rect-options.js +21 -1
- package/lib/components/tools/rect/rect.constants.js +10 -1
- package/lib/components/tools/resize/index.js +1 -1
- package/lib/components/tools/resize/resize.js +141 -1
- package/lib/components/tools/rotate/index.js +2 -1
- package/lib/components/tools/rotate/rotate-button.js +17 -1
- package/lib/components/tools/rotate/rotate-options.js +97 -1
- package/lib/components/tools/text/index.js +2 -1
- package/lib/components/tools/text/text-button.js +17 -1
- package/lib/components/tools/text/text-options/handle-text-change-area.js +122 -1
- package/lib/components/tools/text/text-options/index.js +17 -1
- package/lib/components/tools/text/text-options/text-alignment-fields.js +38 -1
- package/lib/components/tools/text/text-options/text-controls.js +147 -1
- package/lib/components/tools/text/text-options/text-options.constants.js +16 -1
- package/lib/components/tools/text/text-options/text-spacings-fields.js +34 -1
- package/lib/components/tools/tools.constants.js +98 -1
- package/lib/components/tools/warmth/index.js +2 -1
- package/lib/components/tools/warmth/warmth-options.js +35 -1
- package/lib/components/tools/warmth/warmth.js +17 -1
- package/lib/components/tools/watermark/index.js +1 -1
- package/lib/components/tools/watermark/watermark-padding.js +59 -1
- package/lib/components/tools/watermark/watermark.js +221 -1
- package/lib/components/tools/watermark/watermarks-gallery.js +77 -1
- package/lib/components/tools-bar/index.js +113 -1
- package/lib/components/tools-bar/tools-bar-item-button.js +39 -1
- package/lib/components/topbar/canvas-zooming.js +119 -1
- package/lib/components/topbar/confirmation-modal.js +53 -1
- package/lib/components/topbar/image-dimensions-and-display-toggle.js +68 -1
- package/lib/components/topbar/index.js +47 -1
- package/lib/components/topbar/redo-button.js +25 -1
- package/lib/components/topbar/reset-button.js +21 -1
- package/lib/components/topbar/save-button.js +251 -1
- package/lib/components/topbar/topbar.constants.js +31 -1
- package/lib/components/topbar/undo-button.js +27 -1
- package/lib/context/app-context.js +3 -1
- package/lib/context/app-provider-overriden-value.js +9 -1
- package/lib/context/app-provider.js +48 -1
- package/lib/context/app-reducer.js +5 -1
- package/lib/context/default-config.js +75 -1
- package/lib/context/default-translations.js +115 -1
- package/lib/context/get-initial-app-state.js +61 -1
- package/lib/context/index.js +4 -1
- package/lib/custom/filters/aden.js +8 -1
- package/lib/custom/filters/amaro.js +8 -1
- package/lib/custom/filters/ashby.js +8 -1
- package/lib/custom/filters/base-filters.js +82 -1
- package/lib/custom/filters/black-and-white.js +11 -1
- package/lib/custom/filters/brannan.js +8 -1
- package/lib/custom/filters/brooklyn.js +8 -1
- package/lib/custom/filters/charmes.js +8 -1
- package/lib/custom/filters/clarendon.js +9 -1
- package/lib/custom/filters/crema.js +8 -1
- package/lib/custom/filters/dogpatch.js +8 -1
- package/lib/custom/filters/earlybird.js +7 -1
- package/lib/custom/filters/gingham.js +8 -1
- package/lib/custom/filters/ginza.js +8 -1
- package/lib/custom/filters/hefe.js +8 -1
- package/lib/custom/filters/helena.js +8 -1
- package/lib/custom/filters/hudson.js +9 -1
- package/lib/custom/filters/index.js +40 -1
- package/lib/custom/filters/juno.js +8 -1
- package/lib/custom/filters/kelvin.js +9 -1
- package/lib/custom/filters/lark.js +9 -1
- package/lib/custom/filters/lo-fi.js +8 -1
- package/lib/custom/filters/ludwig.js +8 -1
- package/lib/custom/filters/maven.js +9 -1
- package/lib/custom/filters/mayfair.js +8 -1
- package/lib/custom/filters/moon.js +7 -1
- package/lib/custom/filters/nashville.js +8 -1
- package/lib/custom/filters/ninteen-seventy-seven.js +8 -1
- package/lib/custom/filters/perpetua.js +7 -1
- package/lib/custom/filters/reyes.js +9 -1
- package/lib/custom/filters/rise.js +9 -1
- package/lib/custom/filters/sierra.js +8 -1
- package/lib/custom/filters/skyline.js +8 -1
- package/lib/custom/filters/slumber.js +8 -1
- package/lib/custom/filters/stinson.js +8 -1
- package/lib/custom/filters/sutro.js +8 -1
- package/lib/custom/filters/toaster.js +8 -1
- package/lib/custom/filters/valencia.js +9 -1
- package/lib/custom/filters/vesper.js +9 -1
- package/lib/custom/filters/walden.js +8 -1
- package/lib/custom/filters/willow.js +8 -1
- package/lib/custom/filters/xpro2.js +9 -1
- package/lib/custom/finetunes/custom-threshold.js +19 -1
- package/lib/custom/finetunes/index.js +2 -1
- package/lib/custom/finetunes/warmth.js +15 -1
- package/lib/demo/app.js +175 -1
- package/lib/demo/index.js +1 -1
- package/lib/hooks/index.js +12 -1
- package/lib/hooks/use-annotation/get-bounding-rect-un-scaled.js +14 -1
- package/lib/hooks/use-annotation/get-new-annotation-preview.js +83 -1
- package/lib/hooks/use-annotation/index.js +138 -1
- package/lib/hooks/use-annotation/preview-then-call-annotation-adding.js +159 -1
- package/lib/hooks/use-annotation-events.js +83 -1
- package/lib/hooks/use-app-reducer.js +53 -1
- package/lib/hooks/use-debounced-callback.js +7 -1
- package/lib/hooks/use-drag.js +37 -1
- package/lib/hooks/use-filter.js +20 -1
- package/lib/hooks/use-finetune.js +31 -1
- package/lib/hooks/use-phone-screen.js +5 -1
- package/lib/hooks/use-popover.js +27 -1
- package/lib/hooks/use-resize-observer.js +60 -1
- package/lib/hooks/use-store.js +6 -1
- package/lib/hooks/use-transformed-img-data.js +156 -1
- package/lib/hooks/use-update-effect.js +18 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -1
- package/lib/types/actions.js +31 -1
- package/lib/types/annotations.js +42 -1
- package/lib/types/common.js +1 -1
- package/lib/types/config.js +34 -1
- package/lib/types/index.js +5 -1
- package/lib/types/state.js +1 -1
- package/lib/utils/assign-finetune-names-to-konva.js +7 -1
- package/lib/utils/calculate-zoom-data.js +36 -1
- package/lib/utils/compare-ratios.js +5 -1
- package/lib/utils/constants.js +84 -1
- package/lib/utils/crop-image.js +10 -1
- package/lib/utils/debounce.js +19 -1
- package/lib/utils/deep-merge.js +26 -1
- package/lib/utils/extract-current-design-state.js +15 -1
- package/lib/utils/extract-name-from-url.js +5 -1
- package/lib/utils/filter-str-to-class.js +9 -1
- package/lib/utils/finetunes-strs-to-classes.js +13 -1
- package/lib/utils/get-center-rotated-point.js +34 -1
- package/lib/utils/get-default-save-quality.js +5 -1
- package/lib/utils/get-dimensions-minimal-ratio.js +6 -1
- package/lib/utils/get-elem-document-coords.js +24 -1
- package/lib/utils/get-file-full-name.js +21 -1
- package/lib/utils/get-pointer-offset-position-bounded-to-object.js +26 -1
- package/lib/utils/get-proper-dimensions.js +21 -1
- package/lib/utils/get-proper-image-to-canvas-spacing.js +6 -1
- package/lib/utils/get-scroll-offset.js +13 -1
- package/lib/utils/get-size-after-rotation.js +31 -1
- package/lib/utils/get-zoom-fit-factor.js +5 -1
- package/lib/utils/image-to-base64.js +12 -1
- package/lib/utils/is-default-zero-values-only.js +6 -1
- package/lib/utils/is-same-image.js +4 -1
- package/lib/utils/load-image.js +19 -1
- package/lib/utils/map-crop-box.js +16 -1
- package/lib/utils/map-number.js +4 -1
- package/lib/utils/map-position-string-to-point.js +92 -1
- package/lib/utils/random-id.js +5 -1
- package/lib/utils/restrict-number.js +7 -1
- package/lib/utils/serialize-design-state.js +62 -1
- package/lib/utils/to-precised-float.js +5 -1
- package/lib/utils/translator.js +14 -1
- package/package.json +1 -1
|
@@ -1 +1,55 @@
|
|
|
1
|
-
import{Popover}from
|
|
1
|
+
import { Popover } from '@mui/material';
|
|
2
|
+
import { SFlexBox } from '@solostylist/ui-kit/core';
|
|
3
|
+
import ImagePreviewTile from 'components/common/image-preview-tile';
|
|
4
|
+
var ImagesGallery = function ImagesGallery(_ref) {
|
|
5
|
+
var _ref$gallery = _ref.gallery,
|
|
6
|
+
gallery = _ref$gallery === void 0 ? [] : _ref$gallery,
|
|
7
|
+
_ref$anchorEl = _ref.anchorEl,
|
|
8
|
+
anchorEl = _ref$anchorEl === void 0 ? null : _ref$anchorEl,
|
|
9
|
+
onClose = _ref.onClose,
|
|
10
|
+
onSelect = _ref.onSelect;
|
|
11
|
+
return React.createElement(Popover, {
|
|
12
|
+
anchorEl: anchorEl,
|
|
13
|
+
open: Boolean(anchorEl),
|
|
14
|
+
onClose: onClose,
|
|
15
|
+
anchorOrigin: {
|
|
16
|
+
vertical: 'top',
|
|
17
|
+
horizontal: 'center'
|
|
18
|
+
},
|
|
19
|
+
transformOrigin: {
|
|
20
|
+
vertical: 'bottom',
|
|
21
|
+
horizontal: 'center'
|
|
22
|
+
},
|
|
23
|
+
slotProps: {
|
|
24
|
+
paper: {
|
|
25
|
+
sx: {
|
|
26
|
+
px: 2,
|
|
27
|
+
py: 1
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}, React.createElement(SFlexBox, {
|
|
32
|
+
sx: {
|
|
33
|
+
borderRadius: 1,
|
|
34
|
+
paddingX: 1,
|
|
35
|
+
paddingY: 2,
|
|
36
|
+
overflowY: 'auto',
|
|
37
|
+
maxHeight: '450px',
|
|
38
|
+
display: 'grid',
|
|
39
|
+
gridTemplateColumns: 'repeat(4, 1fr)',
|
|
40
|
+
gap: 1
|
|
41
|
+
}
|
|
42
|
+
}, gallery.map(function (_ref2) {
|
|
43
|
+
var originalUrl = _ref2.originalUrl,
|
|
44
|
+
previewUrl = _ref2.previewUrl;
|
|
45
|
+
return React.createElement(ImagePreviewTile, {
|
|
46
|
+
key: originalUrl,
|
|
47
|
+
src: previewUrl,
|
|
48
|
+
alt: previewUrl,
|
|
49
|
+
onClick: function onClick() {
|
|
50
|
+
return onSelect(originalUrl);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
})));
|
|
54
|
+
};
|
|
55
|
+
export default ImagesGallery;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export{default as ImageButton}from"./image-button";
|
|
1
|
+
export { default as ImageButton } from "./image-button";
|
|
2
|
+
export { default as ImageOptions } from "./image-options";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export{default as LineButton}from"./line-button";
|
|
1
|
+
export { default as LineButton } from "./line-button";
|
|
2
|
+
export { default as LineOptions } from "./line-options";
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
import{HorizontalRuleOutlined as Line}from
|
|
1
|
+
import { HorizontalRuleOutlined as Line } from '@mui/icons-material';
|
|
2
|
+
import ToolsBarItemButton from 'components/tools-bar/tools-bar-item-button';
|
|
3
|
+
import { TOOLS_IDS } from 'utils/constants';
|
|
4
|
+
var LineButton = function LineButton(_ref) {
|
|
5
|
+
var selectTool = _ref.selectTool,
|
|
6
|
+
_ref$isSelected = _ref.isSelected,
|
|
7
|
+
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
|
|
8
|
+
t = _ref.t;
|
|
9
|
+
return React.createElement(ToolsBarItemButton, {
|
|
10
|
+
id: TOOLS_IDS.LINE,
|
|
11
|
+
label: t('lineTool'),
|
|
12
|
+
Icon: Line,
|
|
13
|
+
onClick: selectTool,
|
|
14
|
+
isSelected: isSelected
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
export default LineButton;
|
|
@@ -1 +1,19 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import { useAnnotation } from 'hooks';
|
|
3
|
+
import { TOOLS_IDS } from 'utils/constants';
|
|
4
|
+
import AnnotationOptions from 'components/common/annotation-options';
|
|
5
|
+
var LineOptions = function LineOptions() {
|
|
6
|
+
var _useAnnotation = useAnnotation({
|
|
7
|
+
name: TOOLS_IDS.LINE
|
|
8
|
+
}),
|
|
9
|
+
_useAnnotation2 = _slicedToArray(_useAnnotation, 2),
|
|
10
|
+
line = _useAnnotation2[0],
|
|
11
|
+
saveLine = _useAnnotation2[1];
|
|
12
|
+
return React.createElement(AnnotationOptions, {
|
|
13
|
+
annotation: line,
|
|
14
|
+
updateAnnotation: saveLine,
|
|
15
|
+
hidePositionField: true,
|
|
16
|
+
hideFillOption: true
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
export default LineOptions;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export{default as PenButton}from"./pen-button";
|
|
1
|
+
export { default as PenButton } from "./pen-button";
|
|
2
|
+
export { default as PenOptions } from "./pen-options";
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
import{GestureOutlined as PenIcon}from
|
|
1
|
+
import { GestureOutlined as PenIcon } from '@mui/icons-material';
|
|
2
|
+
import ToolsBarItemButton from 'components/tools-bar/tools-bar-item-button';
|
|
3
|
+
import { TOOLS_IDS } from 'utils/constants';
|
|
4
|
+
var PenButton = function PenButton(_ref) {
|
|
5
|
+
var selectTool = _ref.selectTool,
|
|
6
|
+
_ref$isSelected = _ref.isSelected,
|
|
7
|
+
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
|
|
8
|
+
t = _ref.t;
|
|
9
|
+
return React.createElement(ToolsBarItemButton, {
|
|
10
|
+
id: TOOLS_IDS.PEN,
|
|
11
|
+
label: t('penTool'),
|
|
12
|
+
Icon: PenIcon,
|
|
13
|
+
onClick: selectTool,
|
|
14
|
+
isSelected: isSelected
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
export default PenButton;
|
|
@@ -1 +1,120 @@
|
|
|
1
|
-
import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
7
|
+
import { useAnnotation, useStore } from 'hooks';
|
|
8
|
+
import { TOOLS_IDS } from 'utils/constants';
|
|
9
|
+
import AnnotationOptions from 'components/common/annotation-options';
|
|
10
|
+
import getPointerOffsetPositionBoundedToObject from 'utils/get-pointer-offset-position-bounded-to-object';
|
|
11
|
+
import randomId from 'utils/random-id';
|
|
12
|
+
import { SELECT_ANNOTATION, SET_ANNOTATION } from 'actions';
|
|
13
|
+
import getElemDocumentCoords from 'utils/get-elem-document-coords';
|
|
14
|
+
var eventsOptions = {
|
|
15
|
+
passive: true
|
|
16
|
+
};
|
|
17
|
+
var PenOptions = function PenOptions() {
|
|
18
|
+
var _useStore = useStore(),
|
|
19
|
+
dispatch = _useStore.dispatch,
|
|
20
|
+
designLayer = _useStore.designLayer,
|
|
21
|
+
previewGroup = _useStore.previewGroup,
|
|
22
|
+
config = _useStore.config,
|
|
23
|
+
t = _useStore.t;
|
|
24
|
+
var _useAnnotation = useAnnotation(_objectSpread(_objectSpread(_objectSpread({}, config.annotationsCommon), config[TOOLS_IDS.PEN]), {}, {
|
|
25
|
+
name: TOOLS_IDS.PEN
|
|
26
|
+
}), false),
|
|
27
|
+
_useAnnotation2 = _slicedToArray(_useAnnotation, 3),
|
|
28
|
+
pen = _useAnnotation2[0],
|
|
29
|
+
savePenDebounced = _useAnnotation2[1],
|
|
30
|
+
savePenNoDebounce = _useAnnotation2[2];
|
|
31
|
+
var canvasRef = useRef(null);
|
|
32
|
+
var updatedPen = useRef({
|
|
33
|
+
points: [],
|
|
34
|
+
moved: false,
|
|
35
|
+
id: ''
|
|
36
|
+
});
|
|
37
|
+
var getPointerPosition = useCallback(function () {
|
|
38
|
+
var canvasBoundingRect = getElemDocumentCoords(canvasRef.current.content);
|
|
39
|
+
var pos = getPointerOffsetPositionBoundedToObject(previewGroup, canvasBoundingRect);
|
|
40
|
+
return [pos.offsetX - (designLayer.attrs.xPadding || 0), pos.offsetY - (designLayer.attrs.yPadding || 0)];
|
|
41
|
+
}, [designLayer]);
|
|
42
|
+
var handlePointerMove = useCallback(function () {
|
|
43
|
+
var _updatedPen$current;
|
|
44
|
+
if (!((_updatedPen$current = updatedPen.current) !== null && _updatedPen$current !== void 0 && _updatedPen$current.moved)) {
|
|
45
|
+
var _updatedPen$current2;
|
|
46
|
+
updatedPen.current = {
|
|
47
|
+
moved: true,
|
|
48
|
+
id: randomId(TOOLS_IDS.PEN),
|
|
49
|
+
points: [].concat(_toConsumableArray(((_updatedPen$current2 = updatedPen.current) === null || _updatedPen$current2 === void 0 ? void 0 : _updatedPen$current2.points) || []), _toConsumableArray(getPointerPosition()))
|
|
50
|
+
};
|
|
51
|
+
savePenNoDebounce({
|
|
52
|
+
id: updatedPen.current.id,
|
|
53
|
+
name: TOOLS_IDS.PEN,
|
|
54
|
+
points: updatedPen.current.points
|
|
55
|
+
});
|
|
56
|
+
} else if (updatedPen.current) {
|
|
57
|
+
updatedPen.current.points = updatedPen.current.points.concat(getPointerPosition());
|
|
58
|
+
dispatch({
|
|
59
|
+
type: SET_ANNOTATION,
|
|
60
|
+
payload: {
|
|
61
|
+
id: updatedPen.current.id,
|
|
62
|
+
points: updatedPen.current.points,
|
|
63
|
+
dismissHistory: true
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}, [getPointerPosition]);
|
|
68
|
+
var handlePointerUp = useCallback(function () {
|
|
69
|
+
var _updatedPen$current3, _config$TOOLS_IDS$PEN;
|
|
70
|
+
if ((_updatedPen$current3 = updatedPen.current) !== null && _updatedPen$current3 !== void 0 && _updatedPen$current3.id && (_config$TOOLS_IDS$PEN = config[TOOLS_IDS.PEN]) !== null && _config$TOOLS_IDS$PEN !== void 0 && _config$TOOLS_IDS$PEN.selectAnnotationAfterDrawing) {
|
|
71
|
+
dispatch({
|
|
72
|
+
type: SELECT_ANNOTATION,
|
|
73
|
+
payload: {
|
|
74
|
+
annotationId: updatedPen.current.id
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
updatedPen.current = null;
|
|
79
|
+
canvasRef.current.off('mousemove touchmove', handlePointerMove);
|
|
80
|
+
canvasRef.current.off('mouseleave touchcancel', handlePointerUp);
|
|
81
|
+
document.removeEventListener('mouseup', handlePointerUp, eventsOptions);
|
|
82
|
+
document.removeEventListener('touchend', handlePointerUp, eventsOptions);
|
|
83
|
+
document.removeEventListener('mouseleave', handlePointerUp, eventsOptions);
|
|
84
|
+
document.removeEventListener('touchcancel', handlePointerUp, eventsOptions);
|
|
85
|
+
}, [handlePointerMove]);
|
|
86
|
+
var handlePointerDown = useCallback(function (e) {
|
|
87
|
+
if (e.target.attrs.draggable) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
e.evt.preventDefault();
|
|
91
|
+
updatedPen.current = {
|
|
92
|
+
points: getPointerPosition()
|
|
93
|
+
};
|
|
94
|
+
canvasRef.current.on('mousemove touchmove', handlePointerMove);
|
|
95
|
+
canvasRef.current.on('mouseleave touchcancel', handlePointerUp);
|
|
96
|
+
document.addEventListener('mouseup', handlePointerUp, eventsOptions);
|
|
97
|
+
document.addEventListener('touchend', handlePointerUp, eventsOptions);
|
|
98
|
+
document.addEventListener('mouseleave', handlePointerUp, eventsOptions);
|
|
99
|
+
document.addEventListener('touchcancel', handlePointerUp, eventsOptions);
|
|
100
|
+
}, [getPointerPosition, handlePointerMove, handlePointerUp]);
|
|
101
|
+
useEffect(function () {
|
|
102
|
+
canvasRef.current = designLayer === null || designLayer === void 0 ? void 0 : designLayer.getStage();
|
|
103
|
+
if (canvasRef.current) {
|
|
104
|
+
canvasRef.current.on('mousedown touchstart', handlePointerDown);
|
|
105
|
+
}
|
|
106
|
+
return function () {
|
|
107
|
+
if (canvasRef.current) {
|
|
108
|
+
canvasRef.current.off('mousedown touchstart', handlePointerDown);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}, [designLayer]);
|
|
112
|
+
return React.createElement(AnnotationOptions, {
|
|
113
|
+
annotation: pen,
|
|
114
|
+
updateAnnotation: savePenDebounced,
|
|
115
|
+
t: t,
|
|
116
|
+
hidePositionField: true,
|
|
117
|
+
hideFillOption: true
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
export default PenOptions;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export{default as PolygonButton}from"./polygon-button";
|
|
1
|
+
export { default as PolygonButton } from "./polygon-button";
|
|
2
|
+
export { default as PolygonOptions } from "./polygon-options";
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
import{HexagonOutlined as PolygonIcon}from
|
|
1
|
+
import { HexagonOutlined as PolygonIcon } from '@mui/icons-material';
|
|
2
|
+
import ToolsBarItemButton from 'components/tools-bar/tools-bar-item-button';
|
|
3
|
+
import { TOOLS_IDS } from 'utils/constants';
|
|
4
|
+
var PolygonButton = function PolygonButton(_ref) {
|
|
5
|
+
var selectTool = _ref.selectTool,
|
|
6
|
+
_ref$isSelected = _ref.isSelected,
|
|
7
|
+
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
|
|
8
|
+
t = _ref.t;
|
|
9
|
+
return React.createElement(ToolsBarItemButton, {
|
|
10
|
+
id: TOOLS_IDS.POLYGON,
|
|
11
|
+
label: t('polygonTool'),
|
|
12
|
+
Icon: PolygonIcon,
|
|
13
|
+
onClick: selectTool,
|
|
14
|
+
isSelected: isSelected
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
export default PolygonButton;
|
|
@@ -1 +1,22 @@
|
|
|
1
|
-
import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import { useAnnotation } from 'hooks';
|
|
4
|
+
import { TOOLS_IDS } from 'utils/constants';
|
|
5
|
+
import AnnotationOptions from 'components/common/annotation-options';
|
|
6
|
+
import { polygonOptionsPopupComponents, POLYGON_POPPABLE_OPTIONS } from "./polygon.constants";
|
|
7
|
+
var PolygonOptions = function PolygonOptions() {
|
|
8
|
+
var _useAnnotation = useAnnotation({
|
|
9
|
+
name: TOOLS_IDS.POLYGON
|
|
10
|
+
}),
|
|
11
|
+
_useAnnotation2 = _slicedToArray(_useAnnotation, 2),
|
|
12
|
+
polygon = _useAnnotation2[0],
|
|
13
|
+
savePolygon = _useAnnotation2[1];
|
|
14
|
+
return React.createElement(AnnotationOptions, {
|
|
15
|
+
morePoppableOptionsPrepended: _toConsumableArray(POLYGON_POPPABLE_OPTIONS),
|
|
16
|
+
moreOptionsPopupComponentsObj: polygonOptionsPopupComponents,
|
|
17
|
+
annotation: polygon,
|
|
18
|
+
updateAnnotation: savePolygon,
|
|
19
|
+
hidePositionField: true
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
export default PolygonOptions;
|
|
@@ -1 +1,23 @@
|
|
|
1
|
-
import Slider from
|
|
1
|
+
import Slider from 'components/common/slider';
|
|
2
|
+
import restrictNumber from 'utils/restrict-number';
|
|
3
|
+
var MIN_VALUE = 3;
|
|
4
|
+
var MAX_VALUE = 25;
|
|
5
|
+
var PolygonSidesField = function PolygonSidesField(_ref) {
|
|
6
|
+
var polygon = _ref.annotation,
|
|
7
|
+
updatePolygon = _ref.updateAnnotation,
|
|
8
|
+
t = _ref.t;
|
|
9
|
+
var sides = polygon.sides;
|
|
10
|
+
var updateSidesNumber = function updateSidesNumber(newSidesNumber) {
|
|
11
|
+
updatePolygon({
|
|
12
|
+
sides: restrictNumber(newSidesNumber, MIN_VALUE, MAX_VALUE)
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
return React.createElement(Slider, {
|
|
16
|
+
label: t('sides'),
|
|
17
|
+
onChange: updateSidesNumber,
|
|
18
|
+
value: sides,
|
|
19
|
+
min: MIN_VALUE,
|
|
20
|
+
max: MAX_VALUE
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
export default PolygonSidesField;
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
import _defineProperty from"@babel/runtime/helpers/defineProperty";
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { CategoryOutlined as PolygonSides } from '@mui/icons-material';
|
|
3
|
+
import PolygonSidesField from "./polygon-sides-field";
|
|
4
|
+
export var SIDES_NUMBER = 'sides-number';
|
|
5
|
+
export var POLYGON_POPPABLE_OPTIONS = [{
|
|
6
|
+
titleKey: 'sides',
|
|
7
|
+
name: SIDES_NUMBER,
|
|
8
|
+
Icon: PolygonSides
|
|
9
|
+
}];
|
|
10
|
+
export var polygonOptionsPopupComponents = _defineProperty({}, SIDES_NUMBER, PolygonSidesField);
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export{default as RectButton}from"./rect-button";
|
|
1
|
+
export { default as RectButton } from "./rect-button";
|
|
2
|
+
export { default as RectOptions } from "./rect-options";
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
import{CropLandscapeOutlined as RectIcon}from
|
|
1
|
+
import { CropLandscapeOutlined as RectIcon } from '@mui/icons-material';
|
|
2
|
+
import ToolsBarItemButton from 'components/tools-bar/tools-bar-item-button';
|
|
3
|
+
import { TOOLS_IDS } from 'utils/constants';
|
|
4
|
+
var RectButton = function RectButton(_ref) {
|
|
5
|
+
var selectTool = _ref.selectTool,
|
|
6
|
+
_ref$isSelected = _ref.isSelected,
|
|
7
|
+
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
|
|
8
|
+
t = _ref.t;
|
|
9
|
+
return React.createElement(ToolsBarItemButton, {
|
|
10
|
+
id: TOOLS_IDS.RECT,
|
|
11
|
+
label: t('rectangleTool'),
|
|
12
|
+
Icon: RectIcon,
|
|
13
|
+
onClick: selectTool,
|
|
14
|
+
isSelected: isSelected
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
export default RectButton;
|
|
@@ -1 +1,24 @@
|
|
|
1
|
-
import Slider from
|
|
1
|
+
import Slider from 'components/common/slider';
|
|
2
|
+
import restrictNumber from 'utils/restrict-number';
|
|
3
|
+
var MIN_VALUE = 0;
|
|
4
|
+
var MAX_VALUE = 150;
|
|
5
|
+
var RectCornerField = function RectCornerField(_ref) {
|
|
6
|
+
var rect = _ref.annotation,
|
|
7
|
+
updateRect = _ref.updateAnnotation,
|
|
8
|
+
t = _ref.t;
|
|
9
|
+
var cornerRadius = rect.cornerRadius;
|
|
10
|
+
var updateCornerRadius = function updateCornerRadius(newCornerRadius) {
|
|
11
|
+
updateRect({
|
|
12
|
+
cornerRadius: restrictNumber(newCornerRadius, MIN_VALUE, MAX_VALUE)
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
return React.createElement(Slider, {
|
|
16
|
+
annotation: "px",
|
|
17
|
+
label: t('cornerRadius'),
|
|
18
|
+
onChange: updateCornerRadius,
|
|
19
|
+
value: cornerRadius,
|
|
20
|
+
min: MIN_VALUE,
|
|
21
|
+
max: MAX_VALUE
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
export default RectCornerField;
|
|
@@ -1 +1,21 @@
|
|
|
1
|
-
import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import { useAnnotation } from 'hooks';
|
|
4
|
+
import { TOOLS_IDS } from 'utils/constants';
|
|
5
|
+
import AnnotationOptions from 'components/common/annotation-options';
|
|
6
|
+
import { rectOptionsPopupComponents, RECT_POPPABLE_OPTIONS } from "./rect.constants";
|
|
7
|
+
var RectOptions = function RectOptions() {
|
|
8
|
+
var _useAnnotation = useAnnotation({
|
|
9
|
+
name: TOOLS_IDS.RECT
|
|
10
|
+
}),
|
|
11
|
+
_useAnnotation2 = _slicedToArray(_useAnnotation, 2),
|
|
12
|
+
rect = _useAnnotation2[0],
|
|
13
|
+
saveRect = _useAnnotation2[1];
|
|
14
|
+
return React.createElement(AnnotationOptions, {
|
|
15
|
+
moreOptionsPopupComponentsObj: rectOptionsPopupComponents,
|
|
16
|
+
morePoppableOptionsPrepended: _toConsumableArray(RECT_POPPABLE_OPTIONS),
|
|
17
|
+
annotation: rect,
|
|
18
|
+
updateAnnotation: saveRect
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
export default RectOptions;
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
import _defineProperty from"@babel/runtime/helpers/defineProperty";
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { RoundedCornerOutlined as RadiusCorner } from '@mui/icons-material';
|
|
3
|
+
import RectCornerField from "./rect-corner-field";
|
|
4
|
+
export var CORNER_RADIUS = 'corner-radius';
|
|
5
|
+
export var RECT_POPPABLE_OPTIONS = [{
|
|
6
|
+
titleKey: 'cornerRadius',
|
|
7
|
+
name: CORNER_RADIUS,
|
|
8
|
+
Icon: RadiusCorner
|
|
9
|
+
}];
|
|
10
|
+
export var rectOptionsPopupComponents = _defineProperty({}, CORNER_RADIUS, RectCornerField);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{default as Resize}from"./resize";
|
|
1
|
+
export { default as Resize } from "./resize";
|
|
@@ -1 +1,141 @@
|
|
|
1
|
-
import _defineProperty from"@babel/runtime/helpers/defineProperty";
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
import { Refresh, LockOutlined, LockOpenOutlined } from '@mui/icons-material';
|
|
5
|
+
import { SFlexBox, SIconButton, STextField } from '@solostylist/ui-kit/core';
|
|
6
|
+
import { SET_RESIZE, ZOOM_CANVAS } from 'actions';
|
|
7
|
+
import { useStore } from 'hooks';
|
|
8
|
+
import { DEFAULT_ZOOM_FACTOR } from 'utils/constants';
|
|
9
|
+
import getProperDimensions from 'utils/get-proper-dimensions';
|
|
10
|
+
import getSizeAfterRotation from 'utils/get-size-after-rotation';
|
|
11
|
+
import getZoomFitFactor from 'utils/get-zoom-fit-factor';
|
|
12
|
+
import restrictNumber from 'utils/restrict-number';
|
|
13
|
+
var Resize = function Resize(_ref) {
|
|
14
|
+
var onChange = _ref.onChange,
|
|
15
|
+
_ref$currentSize = _ref.currentSize,
|
|
16
|
+
currentSize = _ref$currentSize === void 0 ? {} : _ref$currentSize,
|
|
17
|
+
_ref$hideResetButton = _ref.hideResetButton,
|
|
18
|
+
hideResetButton = _ref$hideResetButton === void 0 ? false : _ref$hideResetButton;
|
|
19
|
+
var _useStore = useStore(),
|
|
20
|
+
dispatch = _useStore.dispatch,
|
|
21
|
+
originalImage = _useStore.originalImage,
|
|
22
|
+
resize = _useStore.resize,
|
|
23
|
+
shownImageDimensions = _useStore.shownImageDimensions,
|
|
24
|
+
_useStore$adjustments = _useStore.adjustments,
|
|
25
|
+
crop = _useStore$adjustments.crop,
|
|
26
|
+
_useStore$adjustments2 = _useStore$adjustments.rotation,
|
|
27
|
+
rotation = _useStore$adjustments2 === void 0 ? 0 : _useStore$adjustments2,
|
|
28
|
+
t = _useStore.t;
|
|
29
|
+
var dimensions = getProperDimensions(((currentSize === null || currentSize === void 0 ? void 0 : currentSize.width) || (currentSize === null || currentSize === void 0 ? void 0 : currentSize.height)) && currentSize || resize, crop, shownImageDimensions, originalImage, rotation);
|
|
30
|
+
var changeResize = function changeResize(e) {
|
|
31
|
+
var _currentSize$ratioUnl;
|
|
32
|
+
var _e$target = e.target,
|
|
33
|
+
name = _e$target.name,
|
|
34
|
+
value = _e$target.value;
|
|
35
|
+
if (parseFloat(value) < 1) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
var maxResizeNumber = Math.min(originalImage.width * 10, originalImage.height * 10);
|
|
39
|
+
var originalImgSizeAfterRotation = getSizeAfterRotation(originalImage.width, originalImage.height, rotation);
|
|
40
|
+
var isHeight = name === 'height';
|
|
41
|
+
var secondDimensionName = isHeight ? 'width' : 'height';
|
|
42
|
+
var newResize = _defineProperty(_defineProperty({}, name, value ? restrictNumber(value, 0, maxResizeNumber) : value), secondDimensionName, dimensions[secondDimensionName]);
|
|
43
|
+
var isRatioUnlocked = (_currentSize$ratioUnl = currentSize.ratioUnlocked) !== null && _currentSize$ratioUnl !== void 0 ? _currentSize$ratioUnl : resize.ratioUnlocked;
|
|
44
|
+
if (!isRatioUnlocked) {
|
|
45
|
+
var originalImgRatio = originalImgSizeAfterRotation.width / originalImgSizeAfterRotation.height;
|
|
46
|
+
newResize[secondDimensionName] = isHeight ? Math.round(newResize[name] * originalImgRatio) : Math.round(newResize[name] / originalImgRatio);
|
|
47
|
+
}
|
|
48
|
+
if (newResize[name] === resize[name] && newResize[secondDimensionName] === resize[secondDimensionName]) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (typeof onChange === 'function') {
|
|
52
|
+
onChange(newResize);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
dispatch({
|
|
56
|
+
type: SET_RESIZE,
|
|
57
|
+
payload: newResize
|
|
58
|
+
});
|
|
59
|
+
var dimensUsedInFit = crop.width && crop.height && crop || shownImageDimensions;
|
|
60
|
+
var updatedResize = _objectSpread(_objectSpread({}, resize), newResize);
|
|
61
|
+
dispatch({
|
|
62
|
+
type: ZOOM_CANVAS,
|
|
63
|
+
payload: {
|
|
64
|
+
factor: updatedResize.width && updatedResize.height ? getZoomFitFactor(dimensUsedInFit, updatedResize) : DEFAULT_ZOOM_FACTOR,
|
|
65
|
+
isAbsoluteZoom: true
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
var toggleRatioLock = function toggleRatioLock() {
|
|
70
|
+
if (typeof onChange === 'function') {
|
|
71
|
+
onChange({
|
|
72
|
+
ratioUnlocked: !currentSize.ratioUnlocked
|
|
73
|
+
});
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
dispatch({
|
|
77
|
+
type: SET_RESIZE,
|
|
78
|
+
payload: {
|
|
79
|
+
ratioUnlocked: !resize.ratioUnlocked
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
var resetResize = function resetResize() {
|
|
84
|
+
dispatch({
|
|
85
|
+
type: SET_RESIZE,
|
|
86
|
+
payload: {
|
|
87
|
+
width: undefined,
|
|
88
|
+
height: undefined,
|
|
89
|
+
ratioUnlocked: false
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
var dimensUsedInFit = crop.width && crop.height && crop || shownImageDimensions;
|
|
93
|
+
dispatch({
|
|
94
|
+
type: ZOOM_CANVAS,
|
|
95
|
+
payload: {
|
|
96
|
+
factor: getZoomFitFactor(dimensUsedInFit, dimensUsedInFit)
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
var isOriginalSize = typeof resize.width === 'undefined' && typeof resize.height === 'undefined' || originalImage.width === resize.width && originalImage.height === resize.height;
|
|
101
|
+
var isManualChangeDisabled = resize.manualChangeDisabled;
|
|
102
|
+
var isEmptyEditedWidth = typeof resize.width !== 'undefined' && !resize.width;
|
|
103
|
+
var isEmptyEditedHeight = typeof resize.height !== 'undefined' && !resize.height;
|
|
104
|
+
return React.createElement(SFlexBox, {
|
|
105
|
+
sx: {
|
|
106
|
+
gap: 1,
|
|
107
|
+
alignItems: 'flex-end'
|
|
108
|
+
}
|
|
109
|
+
}, React.createElement(STextField, {
|
|
110
|
+
name: "width",
|
|
111
|
+
value: isEmptyEditedWidth ? '' : dimensions.width,
|
|
112
|
+
onChange: isManualChangeDisabled ? undefined : changeResize,
|
|
113
|
+
inputMode: "numeric",
|
|
114
|
+
label: "".concat(t('width'), " (px)"),
|
|
115
|
+
disabled: isManualChangeDisabled
|
|
116
|
+
}), React.createElement(SIconButton, {
|
|
117
|
+
tooltipOptions: {
|
|
118
|
+
title: t('toggleRatioLockTitle')
|
|
119
|
+
},
|
|
120
|
+
onClick: isManualChangeDisabled ? undefined : toggleRatioLock,
|
|
121
|
+
disabled: isManualChangeDisabled
|
|
122
|
+
}, currentSize.ratioUnlocked || resize.ratioUnlocked ? React.createElement(LockOpenOutlined, {
|
|
123
|
+
color: "success"
|
|
124
|
+
}) : React.createElement(LockOutlined, {
|
|
125
|
+
color: "error"
|
|
126
|
+
})), React.createElement(STextField, {
|
|
127
|
+
name: "height",
|
|
128
|
+
value: isEmptyEditedHeight ? '' : dimensions.height,
|
|
129
|
+
onChange: isManualChangeDisabled ? undefined : changeResize,
|
|
130
|
+
inputMode: "numeric",
|
|
131
|
+
label: "".concat(t('height'), " (px)"),
|
|
132
|
+
disabled: isManualChangeDisabled
|
|
133
|
+
}), !hideResetButton && React.createElement(SIconButton, {
|
|
134
|
+
tooltipOptions: {
|
|
135
|
+
title: t('resetSize')
|
|
136
|
+
},
|
|
137
|
+
onClick: isOriginalSize || isManualChangeDisabled ? undefined : resetResize,
|
|
138
|
+
disabled: isOriginalSize || isManualChangeDisabled
|
|
139
|
+
}, React.createElement(Refresh, null)));
|
|
140
|
+
};
|
|
141
|
+
export default Resize;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export{default as RotateButton}from"./rotate-button";
|
|
1
|
+
export { default as RotateButton } from "./rotate-button";
|
|
2
|
+
export { default as RotateOptions } from "./rotate-options";
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
import{RotateLeftOutlined as RotateIcon}from
|
|
1
|
+
import { RotateLeftOutlined as RotateIcon } from '@mui/icons-material';
|
|
2
|
+
import ToolsBarItemButton from 'components/tools-bar/tools-bar-item-button';
|
|
3
|
+
import { TOOLS_IDS } from 'utils/constants';
|
|
4
|
+
var RotateButton = function RotateButton(_ref) {
|
|
5
|
+
var selectTool = _ref.selectTool,
|
|
6
|
+
_ref$isSelected = _ref.isSelected,
|
|
7
|
+
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
|
|
8
|
+
t = _ref.t;
|
|
9
|
+
return React.createElement(ToolsBarItemButton, {
|
|
10
|
+
id: TOOLS_IDS.ROTATE,
|
|
11
|
+
label: t('rotateTool'),
|
|
12
|
+
Icon: RotateIcon,
|
|
13
|
+
onClick: selectTool,
|
|
14
|
+
isSelected: isSelected
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
export default RotateButton;
|