@rolster/react-components 18.23.4 → 18.23.6

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/dist/cjs/index.js CHANGED
@@ -3478,7 +3478,7 @@ function RlsImageEditor(props) {
3478
3478
  useResize({ refElement: refImage, onResize: onResizeElement });
3479
3479
  const onCropImage = require$$0.useCallback(() => {
3480
3480
  const cropProps = getCropProperties();
3481
- const width = props.imgWidth || cropProps.width;
3481
+ const width = props.maxWidth || cropProps.width;
3482
3482
  const height = width * getRatioFactor(props.ratio || '1:1');
3483
3483
  refPicture.current.width = width;
3484
3484
  refPicture.current.height = height;
@@ -3497,14 +3497,14 @@ function RlsImageEditor(props) {
3497
3497
  props.formControl?.setValue(value);
3498
3498
  };
3499
3499
  }
3500
- }, props.mimeType || 'image/jpeg', props.imgQuality || 1);
3500
+ }, props.mimeType || 'image/jpeg', props.quality || 1);
3501
3501
  }, [
3502
3502
  props.ratio,
3503
3503
  props.mimeType,
3504
3504
  props.onValue,
3505
3505
  props.formControl,
3506
- props.imgWidth,
3507
- props.imgQuality
3506
+ props.maxWidth,
3507
+ props.quality
3508
3508
  ]);
3509
3509
  const onRestore = require$$0.useCallback(() => {
3510
3510
  const context = refCanvas.current.getContext('2d');
@@ -3546,7 +3546,6 @@ function useImageEditorController(options) {
3546
3546
  require$$0.useEffect(() => {
3547
3547
  refInput.current = document.createElement('input');
3548
3548
  refInput.current.type = 'file';
3549
- refInput.current.disabled = true;
3550
3549
  refInput.current.onchange = () => {
3551
3550
  if (refInput.current.files &&
3552
3551
  MIME_TYPE_SUPPORTS.includes(refInput.current.files[0].type)) {
@@ -3566,22 +3565,23 @@ function useImageEditorController(options) {
3566
3565
  const onCancel = require$$0.useCallback(() => {
3567
3566
  setSrcEditor(undefined);
3568
3567
  }, []);
3569
- const component = require$$0.useMemo(() => {
3570
- return (srcEditor && (jsxRuntimeExports.jsx(RlsImageEditorModal, { src: srcEditor, formControl: options.formControl, imgWidth: options.imgWidth, imgQuality: options.imgQuality, onValue: onEditorValue, visible: true, children: jsxRuntimeExports.jsx(RlsButton, { type: "flat", rlsTheme: "danger", onClick: onCancel, disabled: options.disabled, children: labels.actionCancel }) })));
3568
+ const RlsImageEditorChooser = require$$0.useMemo(() => {
3569
+ return (srcEditor && (jsxRuntimeExports.jsx(RlsImageEditorModal, { visible: true, src: srcEditor, formControl: options.formControl, maxWidth: options.maxWidth, quality: options.quality, ratio: options.ratio, onValue: onEditorValue, children: jsxRuntimeExports.jsx(RlsButton, { type: "flat", rlsTheme: "danger", onClick: onCancel, disabled: options.disabled, children: labels.actionCancel }) })));
3571
3570
  }, [
3572
3571
  srcEditor,
3573
3572
  labels,
3574
3573
  options.formControl,
3575
- options.imgWidth,
3576
- options.imgQuality,
3574
+ options.maxWidth,
3575
+ options.quality,
3576
+ options.ratio,
3577
3577
  options.disabled,
3578
3578
  onEditorValue,
3579
3579
  onCancel
3580
3580
  ]);
3581
3581
  const onImageChooser = require$$0.useCallback(() => {
3582
- refInput.current.click();
3583
- }, []);
3584
- return { RlsImageEditorChooser: component, onImageChooser };
3582
+ !options.disabled && refInput.current.click();
3583
+ }, [options.disabled]);
3584
+ return { onImageChooser, RlsImageEditorChooser };
3585
3585
  }
3586
3586
 
3587
3587
  function RlsImageChooser(props) {
@@ -3590,17 +3590,11 @@ function RlsImageChooser(props) {
3590
3590
  setSrc(image.base64);
3591
3591
  props.onValue && props.onValue(image);
3592
3592
  }, [props.onValue]);
3593
- const { RlsImageEditorChooser, onImageChooser } = useImageEditorController({
3594
- disabled: props.disabled,
3595
- formControl: props.formControl,
3596
- imgQuality: props.imgQuality,
3597
- imgWidth: props.imgWidth,
3598
- onValue
3599
- });
3593
+ const controller = useImageEditorController({ ...props, onValue });
3600
3594
  require$$0.useEffect(() => {
3601
3595
  props.src && setSrc(props.src);
3602
3596
  }, [props.src]);
3603
- return (jsxRuntimeExports.jsxs("div", { className: "rls-image-chooser", children: [jsxRuntimeExports.jsx("div", { className: "rls-image-chooser__avatar", onClick: onImageChooser, children: src && jsxRuntimeExports.jsx("img", { src: src }) }), RlsImageEditorChooser] }));
3597
+ return (jsxRuntimeExports.jsxs("div", { className: "rls-image-chooser", children: [jsxRuntimeExports.jsx("div", { className: "rls-image-chooser__avatar", onClick: controller.onImageChooser, children: src && jsxRuntimeExports.jsx("img", { src: src }) }), controller.RlsImageEditorChooser] }));
3604
3598
  }
3605
3599
 
3606
3600
  const DURATION_ANIMATION = 240;