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