@rolster/react-components 18.22.1 → 18.22.3

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.
@@ -514,6 +514,15 @@
514
514
  transition: all 160ms 0ms var(--rls-standard-curve);
515
515
  } /*# sourceMappingURL=CheckBox.css.map */
516
516
 
517
+ .rls-image {
518
+ content-visibility: auto;
519
+ background-color: var(--rls-theme-color-600);
520
+ opacity: 0;
521
+ }
522
+ .rls-image--complet {
523
+ opacity: 1;
524
+ } /*# sourceMappingURL=Image.css.map */
525
+
517
526
  .rls-input {
518
527
  --pvt-font-color: var(--rlc-input-font-color, var(--rls-app-color-900));
519
528
  --pvt-font-size: var(--rlc-input-font-size, var(--rls-input-font-size));
@@ -2609,10 +2618,10 @@
2609
2618
  .rls-image-chooser__modal {
2610
2619
  --rlc-image-editor-footer-padding: 0rem var(--rls-sizing-x12)
2611
2620
  var(--rls-sizing-x12) var(--rls-sizing-x12);
2612
- --rlc-modal-max-width: calc(100% - var(--rls-sizing-x16));
2621
+ --rlc-modal-max-width: calc(250rem - var(--rls-sizing-x16));
2613
2622
  width: 100%;
2614
2623
  }
2615
- @media only screen and (max-width: 420px) {
2624
+ @media only screen and (max-width: 480px) {
2616
2625
  .rls-image-chooser__modal {
2617
2626
  --rlc-image-editor-footer-padding: 0rem var(--rls-sizing-x8)
2618
2627
  var(--rls-sizing-x8) var(--rls-sizing-x8);
package/dist/cjs/index.js CHANGED
@@ -1554,6 +1554,24 @@ function RlsCheckBoxControl({ formControl, disabled, identifier, rlsTheme }) {
1554
1554
  return (jsxRuntimeExports.jsx(RlsCheckBox, { identifier: identifier, checked: !!formControl.value, disabled: disabled, onClick: onClick, rlsTheme: rlsTheme }));
1555
1555
  }
1556
1556
 
1557
+ function RlsImage({ src }) {
1558
+ const [isComplet, setIsComplet] = require$$0.useState(false);
1559
+ const refSrc = require$$0.useRef(src);
1560
+ const className = require$$0.useMemo(() => {
1561
+ return renderClassStatus('rls-image', { complet: isComplet });
1562
+ }, [isComplet]);
1563
+ require$$0.useEffect(() => {
1564
+ if (refSrc.current !== src) {
1565
+ setIsComplet(false);
1566
+ refSrc.current = src;
1567
+ }
1568
+ }, [src]);
1569
+ const onLoad = require$$0.useCallback(() => {
1570
+ setIsComplet(true);
1571
+ }, []);
1572
+ return jsxRuntimeExports.jsx("img", { className: className, src: src, onLoad: onLoad });
1573
+ }
1574
+
1557
1575
  function RlsInput({ children, decimals, disabled, formControl, identifier, onBlur, onEnter, onFocus, onKeyDown, onKeyUp, onValue, placeholder, readOnly, type, value }) {
1558
1576
  const valueInitial = formControl?.value ?? value ? String(value) : '';
1559
1577
  const [valueInput, setValueInput] = require$$0.useState(valueInitial);
@@ -3378,25 +3396,28 @@ function RlsImageEditor(props) {
3378
3396
  refOverlayLeft.current.style.width = `calc(${left}px)`;
3379
3397
  }, []);
3380
3398
  const refreshSelectionFromWidth = require$$0.useCallback((rateSelection) => {
3381
- const _ratio = rateSelection * getRatioFactor(props.ratio || '1:1');
3382
- let width = (refImage.current.offsetWidth * rateSelection) / 100;
3383
- let height = (refImage.current.offsetWidth * _ratio) / 100;
3384
- if (height > refImage.current.offsetHeight) {
3385
- height = refImage.current.offsetHeight;
3386
- width =
3387
- (height * refImage.current.offsetHeight) /
3388
- refImage.current.offsetHeight;
3399
+ const ratioFactor = getRatioFactor(props.ratio || '1:1');
3400
+ const _ratio = rateSelection * ratioFactor;
3401
+ const offsetWidth = refImage.current?.offsetWidth || 0;
3402
+ const offsetHeight = refImage.current?.offsetHeight || 0;
3403
+ let width = (offsetWidth * rateSelection) / 100;
3404
+ let height = (offsetWidth * _ratio) / 100;
3405
+ if (height > offsetHeight) {
3406
+ height = offsetHeight;
3407
+ width = height / ratioFactor;
3389
3408
  }
3390
3409
  return { height, width };
3391
3410
  }, [props.ratio]);
3392
3411
  const refreshSelectionFromHeight = require$$0.useCallback((rateSelection) => {
3393
- const _ratio = rateSelection * getRatioFactor(props.ratio || '1:1');
3394
- let height = (refImage.current.offsetHeight * rateSelection) / 100;
3395
- let width = (refImage.current.offsetHeight * _ratio) / 100;
3396
- if (width > refImage.current.offsetWidth) {
3397
- width = refImage.current.offsetWidth;
3398
- height =
3399
- (width * refImage.current.offsetWidth) / refImage.current.offsetWidth;
3412
+ const ratioFactor = getRatioFactor(props.ratio || '1:1');
3413
+ const _ratio = rateSelection * ratioFactor;
3414
+ const offsetWidth = refImage.current?.offsetWidth || 0;
3415
+ const offsetHeight = refImage.current?.offsetHeight || 0;
3416
+ let height = (offsetHeight * rateSelection) / 100;
3417
+ let width = (offsetHeight * _ratio) / 100;
3418
+ if (width > offsetWidth) {
3419
+ width = offsetWidth;
3420
+ height = width / ratioFactor;
3400
3421
  }
3401
3422
  return { height, width };
3402
3423
  }, [props.ratio]);
@@ -3499,13 +3520,14 @@ function RlsImageEditor(props) {
3499
3520
  props.formControl?.setValue(value);
3500
3521
  };
3501
3522
  }
3502
- }, props.mimeType || 'image/jpeg', 1);
3523
+ }, props.mimeType || 'image/jpeg', props.imgQuality || 1);
3503
3524
  }, [
3504
3525
  props.ratio,
3505
3526
  props.mimeType,
3506
3527
  props.onValue,
3507
3528
  props.formControl,
3508
- props.imgWidth
3529
+ props.imgWidth,
3530
+ props.imgQuality
3509
3531
  ]);
3510
3532
  const onRestore = require$$0.useCallback(() => {
3511
3533
  const context = refCanvas.current.getContext('2d');
@@ -3567,7 +3589,7 @@ function RlsImageChooser(props) {
3567
3589
  const onCancel = require$$0.useCallback(() => {
3568
3590
  setSrcEditor(undefined);
3569
3591
  }, []);
3570
- return (jsxRuntimeExports.jsxs("div", { className: "rls-image-chooser", children: [jsxRuntimeExports.jsx("div", { className: "rls-image-chooser__avatar", onClick: onSelect, children: src && jsxRuntimeExports.jsx("img", { src: src }) }), srcEditor && (jsxRuntimeExports.jsx(RlsModal, { className: "rls-image-chooser__modal", visible: true, children: jsxRuntimeExports.jsx(RlsImageEditor, { src: srcEditor, formControl: props.formControl, imgWidth: props.imgWidth, onValue: onEditorValue, children: jsxRuntimeExports.jsx(RlsButton, { type: "flat", rlsTheme: "danger", onClick: onCancel, disabled: props.disabled, children: labels.actionCancel }) }) })), jsxRuntimeExports.jsx("input", { ref: refInput, type: "file", disabled: props.disabled })] }));
3592
+ return (jsxRuntimeExports.jsxs("div", { className: "rls-image-chooser", children: [jsxRuntimeExports.jsx("div", { className: "rls-image-chooser__avatar", onClick: onSelect, children: src && jsxRuntimeExports.jsx("img", { src: src }) }), srcEditor && (jsxRuntimeExports.jsx(RlsModal, { className: "rls-image-chooser__modal", visible: true, children: jsxRuntimeExports.jsx(RlsImageEditor, { src: srcEditor, formControl: props.formControl, imgWidth: props.imgWidth, imgQuality: props.imgQuality, onValue: onEditorValue, children: jsxRuntimeExports.jsx(RlsButton, { type: "flat", rlsTheme: "danger", onClick: onCancel, disabled: props.disabled, children: labels.actionCancel }) }) })), jsxRuntimeExports.jsx("input", { ref: refInput, type: "file", disabled: props.disabled })] }));
3571
3593
  }
3572
3594
 
3573
3595
  const DURATION_ANIMATION = 240;
@@ -3695,6 +3717,7 @@ exports.RlsFieldSelectTemplate = RlsFieldSelectTemplate;
3695
3717
  exports.RlsFieldText = RlsFieldText;
3696
3718
  exports.RlsFormNavigation = RlsFormNavigation;
3697
3719
  exports.RlsIcon = RlsIcon;
3720
+ exports.RlsImage = RlsImage;
3698
3721
  exports.RlsImageChooser = RlsImageChooser;
3699
3722
  exports.RlsImageEditor = RlsImageEditor;
3700
3723
  exports.RlsInput = RlsInput;