labellife-design-tool 2.3.8 → 2.3.9

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.
@@ -3969,6 +3969,124 @@ var ImageMaskPanel = observer(function (_ref) {
3969
3969
  });
3970
3970
  ImageMaskPanel.displayName = 'ImageMaskPanel';
3971
3971
 
3972
+ // Cover-fit crop fractions (centered) for a box of given size over an image of natural size.
3973
+ // Mirrors the existing auto-crop calculation in canvas/image-element.js.
3974
+
3975
+ // Minimum scale at which the image (rendered at naturalWidth*scale x naturalHeight*scale)
3976
+ // still fully covers rect.
3977
+ function minScaleForRect(rect, naturalWidth, naturalHeight) {
3978
+ return Math.max(rect.width / naturalWidth, rect.height / naturalHeight);
3979
+ }
3980
+
3981
+ var ImageCropPanel = observer(function (_ref) {
3982
+ var store = _ref.store;
3983
+ var panel = store._toolbarPanel;
3984
+ if (!panel || panel.type !== 'crop') return null;
3985
+ var element = store.getElementById(panel.elementId);
3986
+ if (!element || !element._cropRect) return null;
3987
+ var handleCancel = function handleCancel() {
3988
+ element.cancelCropMode();
3989
+ store.closeToolbarPanel();
3990
+ };
3991
+ var handleDone = function handleDone() {
3992
+ element.commitCropMode();
3993
+ store.closeToolbarPanel();
3994
+ store.history.addUndoState();
3995
+ };
3996
+ var handleReset = function handleReset() {
3997
+ element.resetCropToDefault();
3998
+ };
3999
+ var minScale = minScaleForRect(element._cropRect, element._cropNaturalWidth, element._cropNaturalHeight);
4000
+ var maxScale = minScale * 4;
4001
+ return /*#__PURE__*/jsxs(Box, {
4002
+ sx: {
4003
+ width: 280,
4004
+ height: '100%',
4005
+ overflowY: 'auto',
4006
+ overflowX: 'hidden',
4007
+ backgroundColor: '#fff',
4008
+ borderRight: '1px solid #e0e0e0',
4009
+ flexShrink: 0,
4010
+ p: 2
4011
+ },
4012
+ children: [/*#__PURE__*/jsxs(Box, {
4013
+ sx: {
4014
+ display: 'flex',
4015
+ alignItems: 'center',
4016
+ justifyContent: 'space-between',
4017
+ mb: 2
4018
+ },
4019
+ children: [/*#__PURE__*/jsx(Typography, {
4020
+ variant: "subtitle1",
4021
+ sx: {
4022
+ fontWeight: 600
4023
+ },
4024
+ children: t('toolbar.crop', 'Crop')
4025
+ }), /*#__PURE__*/jsx(IconButton, {
4026
+ size: "small",
4027
+ onClick: handleCancel,
4028
+ children: /*#__PURE__*/jsx(CloseIcon, {
4029
+ fontSize: "small"
4030
+ })
4031
+ })]
4032
+ }), /*#__PURE__*/jsx(Typography, {
4033
+ variant: "body2",
4034
+ sx: {
4035
+ fontWeight: 500,
4036
+ mb: 0.5
4037
+ },
4038
+ children: t('toolbar.cropZoom', 'Zoom')
4039
+ }), /*#__PURE__*/jsx(Slider, {
4040
+ size: "small",
4041
+ value: element._cropImgScale,
4042
+ onChange: function onChange(_, v) {
4043
+ return element.setCropZoom(v);
4044
+ },
4045
+ min: minScale,
4046
+ max: maxScale,
4047
+ step: (maxScale - minScale) / 100 || 0.01,
4048
+ sx: {
4049
+ mb: 3
4050
+ }
4051
+ }), /*#__PURE__*/jsx(Button, {
4052
+ fullWidth: true,
4053
+ variant: "outlined",
4054
+ size: "small",
4055
+ onClick: handleReset,
4056
+ sx: {
4057
+ textTransform: 'none',
4058
+ mb: 3
4059
+ },
4060
+ children: t('toolbar.cropReset', 'Reset')
4061
+ }), /*#__PURE__*/jsxs(Box, {
4062
+ sx: {
4063
+ display: 'flex',
4064
+ gap: 1
4065
+ },
4066
+ children: [/*#__PURE__*/jsx(Button, {
4067
+ fullWidth: true,
4068
+ variant: "outlined",
4069
+ size: "small",
4070
+ onClick: handleCancel,
4071
+ sx: {
4072
+ textTransform: 'none'
4073
+ },
4074
+ children: t('toolbar.cropCancel', 'Cancel')
4075
+ }), /*#__PURE__*/jsx(Button, {
4076
+ fullWidth: true,
4077
+ variant: "contained",
4078
+ size: "small",
4079
+ onClick: handleDone,
4080
+ sx: {
4081
+ textTransform: 'none'
4082
+ },
4083
+ children: t('toolbar.cropDone', 'Done')
4084
+ })]
4085
+ })]
4086
+ });
4087
+ });
4088
+ ImageCropPanel.displayName = 'ImageCropPanel';
4089
+
3972
4090
  var SliderRow = function SliderRow(_ref) {
3973
4091
  var label = _ref.label,
3974
4092
  value = _ref.value,
@@ -4494,6 +4612,8 @@ var SidePanel = observer(function (_ref) {
4494
4612
  });
4495
4613
  }() : store._toolbarPanel.type === 'mask' ? /*#__PURE__*/jsx(ImageMaskPanel, {
4496
4614
  store: store
4615
+ }) : store._toolbarPanel.type === 'crop' ? /*#__PURE__*/jsx(ImageCropPanel, {
4616
+ store: store
4497
4617
  }) : null : (/* Normal panel content */
4498
4618
  activeSectionObj && /*#__PURE__*/jsx(Box, {
4499
4619
  sx: {