@rolster/react-components 18.23.6 → 18.23.7
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 +13 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.js +13 -10
- package/dist/es/index.js.map +1 -1
- package/dist/esm/components/organisms/ImageChooser/ImageChooser.d.ts +1 -0
- package/dist/esm/components/organisms/ImageChooser/ImageChooser.js.map +1 -1
- package/dist/esm/components/organisms/ImageEditor/ImageEditor.d.ts +1 -1
- package/dist/esm/components/organisms/ImageEditor/ImageEditor.js +13 -10
- package/dist/esm/components/organisms/ImageEditor/ImageEditor.js.map +1 -1
- package/dist/esm/components/organisms/ImageEditorModal/ImageEditorModal.d.ts +1 -1
- package/dist/esm/controllers/ImageEditorController.d.ts +1 -0
- package/dist/esm/controllers/ImageEditorController.js +1 -1
- package/dist/esm/controllers/ImageEditorController.js.map +1 -1
- package/package.json +1 -1
package/dist/es/index.js
CHANGED
|
@@ -3330,7 +3330,7 @@ function simpleThreeRule(value1, value2, proportion) {
|
|
|
3330
3330
|
return (value2 * proportion) / value1;
|
|
3331
3331
|
}
|
|
3332
3332
|
function RlsImageEditor(props) {
|
|
3333
|
-
const [selection, setSelection] = useState(props.
|
|
3333
|
+
const [selection, setSelection] = useState(props.selection ?? 60);
|
|
3334
3334
|
const [labels, setLabels] = useState({
|
|
3335
3335
|
actionRestore: reactI18n('editorImageActionRestore'),
|
|
3336
3336
|
actionSelect: reactI18n('editorImageActionSelect')
|
|
@@ -3346,6 +3346,9 @@ function RlsImageEditor(props) {
|
|
|
3346
3346
|
const refPicture = useRef(null);
|
|
3347
3347
|
const image = useRef(new Image());
|
|
3348
3348
|
const originalImage = useRef();
|
|
3349
|
+
const ratio = useMemo(() => {
|
|
3350
|
+
return props.ratio || '1:1';
|
|
3351
|
+
}, [props.ratio]);
|
|
3349
3352
|
const getCropProperties = useCallback(() => {
|
|
3350
3353
|
return {
|
|
3351
3354
|
height: simpleThreeRule(refImage.current.offsetHeight, image.current.height, refSelection.current.offsetHeight),
|
|
@@ -3371,7 +3374,7 @@ function RlsImageEditor(props) {
|
|
|
3371
3374
|
refOverlayLeft.current.style.width = `calc(${left}px)`;
|
|
3372
3375
|
}, []);
|
|
3373
3376
|
const refreshSelectionFromWidth = useCallback((rateSelection) => {
|
|
3374
|
-
const ratioFactor = getRatioFactor(
|
|
3377
|
+
const ratioFactor = getRatioFactor(ratio);
|
|
3375
3378
|
const _ratio = rateSelection * ratioFactor;
|
|
3376
3379
|
const offsetWidth = refImage.current?.offsetWidth || 0;
|
|
3377
3380
|
const offsetHeight = refImage.current?.offsetHeight || 0;
|
|
@@ -3382,10 +3385,10 @@ function RlsImageEditor(props) {
|
|
|
3382
3385
|
width = height / ratioFactor;
|
|
3383
3386
|
}
|
|
3384
3387
|
return { height, width };
|
|
3385
|
-
}, [
|
|
3388
|
+
}, [ratio]);
|
|
3386
3389
|
const refreshSelectionFromHeight = useCallback((rateSelection) => {
|
|
3387
|
-
const ratioFactor = getRatioFactor(
|
|
3388
|
-
const _ratio = rateSelection
|
|
3390
|
+
const ratioFactor = getRatioFactor(ratio);
|
|
3391
|
+
const _ratio = rateSelection / ratioFactor;
|
|
3389
3392
|
const offsetWidth = refImage.current?.offsetWidth || 0;
|
|
3390
3393
|
const offsetHeight = refImage.current?.offsetHeight || 0;
|
|
3391
3394
|
let height = (offsetHeight * rateSelection) / 100;
|
|
@@ -3395,7 +3398,7 @@ function RlsImageEditor(props) {
|
|
|
3395
3398
|
height = width / ratioFactor;
|
|
3396
3399
|
}
|
|
3397
3400
|
return { height, width };
|
|
3398
|
-
}, [
|
|
3401
|
+
}, [ratio]);
|
|
3399
3402
|
const refreshSelectionStyle = useCallback((rateSelection) => {
|
|
3400
3403
|
if (image.current.width > 0 && image.current.height > 0) {
|
|
3401
3404
|
const { height, width } = image.current.width >= image.current.height
|
|
@@ -3415,7 +3418,7 @@ function RlsImageEditor(props) {
|
|
|
3415
3418
|
}
|
|
3416
3419
|
refreshOverlaysStyle();
|
|
3417
3420
|
}
|
|
3418
|
-
}, [
|
|
3421
|
+
}, [ratio]);
|
|
3419
3422
|
const setImageStyle = useCallback((width, height) => {
|
|
3420
3423
|
refImage.current.style.width = width;
|
|
3421
3424
|
refImage.current.style.height = height;
|
|
@@ -3477,7 +3480,7 @@ function RlsImageEditor(props) {
|
|
|
3477
3480
|
const onCropImage = useCallback(() => {
|
|
3478
3481
|
const cropProps = getCropProperties();
|
|
3479
3482
|
const width = props.maxWidth || cropProps.width;
|
|
3480
|
-
const height = width * getRatioFactor(
|
|
3483
|
+
const height = width * getRatioFactor(ratio);
|
|
3481
3484
|
refPicture.current.width = width;
|
|
3482
3485
|
refPicture.current.height = height;
|
|
3483
3486
|
const context = refPicture.current.getContext('2d');
|
|
@@ -3497,7 +3500,7 @@ function RlsImageEditor(props) {
|
|
|
3497
3500
|
}
|
|
3498
3501
|
}, props.mimeType || 'image/jpeg', props.quality || 1);
|
|
3499
3502
|
}, [
|
|
3500
|
-
|
|
3503
|
+
ratio,
|
|
3501
3504
|
props.mimeType,
|
|
3502
3505
|
props.onValue,
|
|
3503
3506
|
props.formControl,
|
|
@@ -3564,7 +3567,7 @@ function useImageEditorController(options) {
|
|
|
3564
3567
|
setSrcEditor(undefined);
|
|
3565
3568
|
}, []);
|
|
3566
3569
|
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 }) })));
|
|
3570
|
+
return (srcEditor && (jsxRuntimeExports.jsx(RlsImageEditorModal, { visible: true, src: srcEditor, formControl: options.formControl, maxWidth: options.maxWidth, quality: options.quality, ratio: options.ratio, selection: options.selection, onValue: onEditorValue, children: jsxRuntimeExports.jsx(RlsButton, { type: "flat", rlsTheme: "danger", onClick: onCancel, disabled: options.disabled, children: labels.actionCancel }) })));
|
|
3568
3571
|
}, [
|
|
3569
3572
|
srcEditor,
|
|
3570
3573
|
labels,
|