@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/cjs/index.js
CHANGED
|
@@ -3332,7 +3332,7 @@ function simpleThreeRule(value1, value2, proportion) {
|
|
|
3332
3332
|
return (value2 * proportion) / value1;
|
|
3333
3333
|
}
|
|
3334
3334
|
function RlsImageEditor(props) {
|
|
3335
|
-
const [selection, setSelection] = require$$0.useState(props.
|
|
3335
|
+
const [selection, setSelection] = require$$0.useState(props.selection ?? 60);
|
|
3336
3336
|
const [labels, setLabels] = require$$0.useState({
|
|
3337
3337
|
actionRestore: reactI18n('editorImageActionRestore'),
|
|
3338
3338
|
actionSelect: reactI18n('editorImageActionSelect')
|
|
@@ -3348,6 +3348,9 @@ function RlsImageEditor(props) {
|
|
|
3348
3348
|
const refPicture = require$$0.useRef(null);
|
|
3349
3349
|
const image = require$$0.useRef(new Image());
|
|
3350
3350
|
const originalImage = require$$0.useRef();
|
|
3351
|
+
const ratio = require$$0.useMemo(() => {
|
|
3352
|
+
return props.ratio || '1:1';
|
|
3353
|
+
}, [props.ratio]);
|
|
3351
3354
|
const getCropProperties = require$$0.useCallback(() => {
|
|
3352
3355
|
return {
|
|
3353
3356
|
height: simpleThreeRule(refImage.current.offsetHeight, image.current.height, refSelection.current.offsetHeight),
|
|
@@ -3373,7 +3376,7 @@ function RlsImageEditor(props) {
|
|
|
3373
3376
|
refOverlayLeft.current.style.width = `calc(${left}px)`;
|
|
3374
3377
|
}, []);
|
|
3375
3378
|
const refreshSelectionFromWidth = require$$0.useCallback((rateSelection) => {
|
|
3376
|
-
const ratioFactor = getRatioFactor(
|
|
3379
|
+
const ratioFactor = getRatioFactor(ratio);
|
|
3377
3380
|
const _ratio = rateSelection * ratioFactor;
|
|
3378
3381
|
const offsetWidth = refImage.current?.offsetWidth || 0;
|
|
3379
3382
|
const offsetHeight = refImage.current?.offsetHeight || 0;
|
|
@@ -3384,10 +3387,10 @@ function RlsImageEditor(props) {
|
|
|
3384
3387
|
width = height / ratioFactor;
|
|
3385
3388
|
}
|
|
3386
3389
|
return { height, width };
|
|
3387
|
-
}, [
|
|
3390
|
+
}, [ratio]);
|
|
3388
3391
|
const refreshSelectionFromHeight = require$$0.useCallback((rateSelection) => {
|
|
3389
|
-
const ratioFactor = getRatioFactor(
|
|
3390
|
-
const _ratio = rateSelection
|
|
3392
|
+
const ratioFactor = getRatioFactor(ratio);
|
|
3393
|
+
const _ratio = rateSelection / ratioFactor;
|
|
3391
3394
|
const offsetWidth = refImage.current?.offsetWidth || 0;
|
|
3392
3395
|
const offsetHeight = refImage.current?.offsetHeight || 0;
|
|
3393
3396
|
let height = (offsetHeight * rateSelection) / 100;
|
|
@@ -3397,7 +3400,7 @@ function RlsImageEditor(props) {
|
|
|
3397
3400
|
height = width / ratioFactor;
|
|
3398
3401
|
}
|
|
3399
3402
|
return { height, width };
|
|
3400
|
-
}, [
|
|
3403
|
+
}, [ratio]);
|
|
3401
3404
|
const refreshSelectionStyle = require$$0.useCallback((rateSelection) => {
|
|
3402
3405
|
if (image.current.width > 0 && image.current.height > 0) {
|
|
3403
3406
|
const { height, width } = image.current.width >= image.current.height
|
|
@@ -3417,7 +3420,7 @@ function RlsImageEditor(props) {
|
|
|
3417
3420
|
}
|
|
3418
3421
|
refreshOverlaysStyle();
|
|
3419
3422
|
}
|
|
3420
|
-
}, [
|
|
3423
|
+
}, [ratio]);
|
|
3421
3424
|
const setImageStyle = require$$0.useCallback((width, height) => {
|
|
3422
3425
|
refImage.current.style.width = width;
|
|
3423
3426
|
refImage.current.style.height = height;
|
|
@@ -3479,7 +3482,7 @@ function RlsImageEditor(props) {
|
|
|
3479
3482
|
const onCropImage = require$$0.useCallback(() => {
|
|
3480
3483
|
const cropProps = getCropProperties();
|
|
3481
3484
|
const width = props.maxWidth || cropProps.width;
|
|
3482
|
-
const height = width * getRatioFactor(
|
|
3485
|
+
const height = width * getRatioFactor(ratio);
|
|
3483
3486
|
refPicture.current.width = width;
|
|
3484
3487
|
refPicture.current.height = height;
|
|
3485
3488
|
const context = refPicture.current.getContext('2d');
|
|
@@ -3499,7 +3502,7 @@ function RlsImageEditor(props) {
|
|
|
3499
3502
|
}
|
|
3500
3503
|
}, props.mimeType || 'image/jpeg', props.quality || 1);
|
|
3501
3504
|
}, [
|
|
3502
|
-
|
|
3505
|
+
ratio,
|
|
3503
3506
|
props.mimeType,
|
|
3504
3507
|
props.onValue,
|
|
3505
3508
|
props.formControl,
|
|
@@ -3566,7 +3569,7 @@ function useImageEditorController(options) {
|
|
|
3566
3569
|
setSrcEditor(undefined);
|
|
3567
3570
|
}, []);
|
|
3568
3571
|
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 }) })));
|
|
3572
|
+
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 }) })));
|
|
3570
3573
|
}, [
|
|
3571
3574
|
srcEditor,
|
|
3572
3575
|
labels,
|