@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/es/index.js CHANGED
@@ -3476,7 +3476,7 @@ function RlsImageEditor(props) {
3476
3476
  useResize({ refElement: refImage, onResize: onResizeElement });
3477
3477
  const onCropImage = useCallback(() => {
3478
3478
  const cropProps = getCropProperties();
3479
- const width = props.imgWidth || cropProps.width;
3479
+ const width = props.maxWidth || cropProps.width;
3480
3480
  const height = width * getRatioFactor(props.ratio || '1:1');
3481
3481
  refPicture.current.width = width;
3482
3482
  refPicture.current.height = height;
@@ -3495,14 +3495,14 @@ function RlsImageEditor(props) {
3495
3495
  props.formControl?.setValue(value);
3496
3496
  };
3497
3497
  }
3498
- }, props.mimeType || 'image/jpeg', props.imgQuality || 1);
3498
+ }, props.mimeType || 'image/jpeg', props.quality || 1);
3499
3499
  }, [
3500
3500
  props.ratio,
3501
3501
  props.mimeType,
3502
3502
  props.onValue,
3503
3503
  props.formControl,
3504
- props.imgWidth,
3505
- props.imgQuality
3504
+ props.maxWidth,
3505
+ props.quality
3506
3506
  ]);
3507
3507
  const onRestore = useCallback(() => {
3508
3508
  const context = refCanvas.current.getContext('2d');
@@ -3544,7 +3544,6 @@ function useImageEditorController(options) {
3544
3544
  useEffect(() => {
3545
3545
  refInput.current = document.createElement('input');
3546
3546
  refInput.current.type = 'file';
3547
- refInput.current.disabled = true;
3548
3547
  refInput.current.onchange = () => {
3549
3548
  if (refInput.current.files &&
3550
3549
  MIME_TYPE_SUPPORTS.includes(refInput.current.files[0].type)) {
@@ -3564,22 +3563,23 @@ function useImageEditorController(options) {
3564
3563
  const onCancel = useCallback(() => {
3565
3564
  setSrcEditor(undefined);
3566
3565
  }, []);
3567
- const component = useMemo(() => {
3568
- 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 }) })));
3566
+ const RlsImageEditorChooser = useMemo(() => {
3567
+ 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 }) })));
3569
3568
  }, [
3570
3569
  srcEditor,
3571
3570
  labels,
3572
3571
  options.formControl,
3573
- options.imgWidth,
3574
- options.imgQuality,
3572
+ options.maxWidth,
3573
+ options.quality,
3574
+ options.ratio,
3575
3575
  options.disabled,
3576
3576
  onEditorValue,
3577
3577
  onCancel
3578
3578
  ]);
3579
3579
  const onImageChooser = useCallback(() => {
3580
- refInput.current.click();
3581
- }, []);
3582
- return { RlsImageEditorChooser: component, onImageChooser };
3580
+ !options.disabled && refInput.current.click();
3581
+ }, [options.disabled]);
3582
+ return { onImageChooser, RlsImageEditorChooser };
3583
3583
  }
3584
3584
 
3585
3585
  function RlsImageChooser(props) {
@@ -3588,17 +3588,11 @@ function RlsImageChooser(props) {
3588
3588
  setSrc(image.base64);
3589
3589
  props.onValue && props.onValue(image);
3590
3590
  }, [props.onValue]);
3591
- const { RlsImageEditorChooser, onImageChooser } = useImageEditorController({
3592
- disabled: props.disabled,
3593
- formControl: props.formControl,
3594
- imgQuality: props.imgQuality,
3595
- imgWidth: props.imgWidth,
3596
- onValue
3597
- });
3591
+ const controller = useImageEditorController({ ...props, onValue });
3598
3592
  useEffect(() => {
3599
3593
  props.src && setSrc(props.src);
3600
3594
  }, [props.src]);
3601
- 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] }));
3595
+ 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] }));
3602
3596
  }
3603
3597
 
3604
3598
  const DURATION_ANIMATION = 240;