@rolster/react-components 19.10.0 → 19.12.0

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.mjs CHANGED
@@ -719,6 +719,12 @@ function RlsCheckBoxControlComponent({ formControl, disabled, identifier, rlsThe
719
719
  }
720
720
  const RlsCheckBoxControl = memo(RlsCheckBoxControlComponent);
721
721
 
722
+ function RlsChipComponent({ children, className, contrasted, disabled, icon, identifier, onClick, onRemove, rlsTheme, selected }) {
723
+ const classNameChip = renderClassStatus('rls-chip', { clickable: !!onClick && !disabled, contrasted, disabled, selected }, className);
724
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: classNameChip, "rls-theme": rlsTheme, onClick: disabled ? undefined : onClick, children: [icon && jsxRuntimeExports.jsx(RlsIcon, { className: "rls-chip__icon", value: icon }), jsxRuntimeExports.jsx("span", { className: "rls-chip__description", children: children }), onRemove && !disabled && (jsxRuntimeExports.jsx("button", { className: "rls-chip__remove", type: "button", onClick: onRemove, children: jsxRuntimeExports.jsx(RlsIcon, { value: "close" }) }))] }));
725
+ }
726
+ const RlsChip = memo(RlsChipComponent);
727
+
722
728
  function RlsSkeletonComponent({ animation, rlsTheme }) {
723
729
  const className = renderClassStatus('rls-skeleton', {
724
730
  animation: animation !== 'shimmer' && animation
@@ -1669,6 +1675,36 @@ function RlsButtonToggleComponent({ onAction, options, type, automatic, disabled
1669
1675
  }
1670
1676
  const RlsButtonToggle = memo(RlsButtonToggleComponent);
1671
1677
 
1678
+ function RlsChipGroupComponent({ className, disabled: disabledProps, formControl, identifier, onValue, options, reference, render, rlsTheme, value: valueInitial }) {
1679
+ const [value, setValue] = useState(formControl?.value ?? valueInitial);
1680
+ const selected = useMemo(() => {
1681
+ return formControl ? formControl.value : value;
1682
+ }, [formControl?.value, value]);
1683
+ const disabled = useMemo(() => {
1684
+ return formControl?.disabled || disabledProps;
1685
+ }, [formControl?.disabled, disabledProps]);
1686
+ const classNameGroup = renderClassStatus('rls-chip-group', { disabled }, className);
1687
+ const isSelected = useCallback((option) => {
1688
+ if (selected === undefined || selected === null) {
1689
+ return false;
1690
+ }
1691
+ return reference
1692
+ ? reference(option) === reference(selected)
1693
+ : option === selected;
1694
+ }, [reference, selected]);
1695
+ const onSelect = useCallback((option) => () => {
1696
+ if (disabled) {
1697
+ return;
1698
+ }
1699
+ setValue(option);
1700
+ formControl?.setValue(option);
1701
+ formControl?.touch();
1702
+ onValue?.(option);
1703
+ }, [disabled, formControl, onValue]);
1704
+ return (jsxRuntimeExports.jsx("div", { id: identifier, className: classNameGroup, "rls-theme": rlsTheme, children: options.map((option, index) => (jsxRuntimeExports.jsx(RlsChip, { disabled: disabled, selected: isSelected(option), onClick: onSelect(option), children: render ? render(option) : String(option) }, index))) }));
1705
+ }
1706
+ const RlsChipGroup = memo(RlsChipGroupComponent);
1707
+
1672
1708
  function RlsContentComponent({ children, identifier, rlsTheme }) {
1673
1709
  return (jsxRuntimeExports.jsx("div", { id: identifier, className: "rls-app__page__content", "rls-theme": rlsTheme, children: children }));
1674
1710
  }
@@ -3785,11 +3821,20 @@ const RlsModal = memo(RlsModalComponent);
3785
3821
  function formatTime(value) {
3786
3822
  return String(value).padStart(2, '0');
3787
3823
  }
3824
+ function pointerIsInsideTick({ clientX, clientY }, tick) {
3825
+ const { left, top, width, height } = tick.getBoundingClientRect();
3826
+ const distanceX = clientX - (left + width / 2);
3827
+ const distanceY = clientY - (top + height / 2);
3828
+ const radius = Math.min(width, height) / 2;
3829
+ return distanceX ** 2 + distanceY ** 2 <= radius ** 2;
3830
+ }
3788
3831
  const CLOCK_VALUES = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
3832
+ const CLOCK_HOURS = 12;
3833
+ const CLOCK_MINUTES = 60;
3789
3834
  const RADIUS = 48;
3790
3835
  const DIAL_RADIUS = 60;
3791
3836
  const TICK_RADIUS = 7;
3792
- function RlsPickerClockTick({ onValue, selectionIsHours, value }) {
3837
+ function RlsPickerClockTick({ selectionIsHours, value }) {
3793
3838
  const styleTick = useMemo(() => {
3794
3839
  const radian = (value / 6) * Math.PI;
3795
3840
  const x = Math.sin(radian) * RADIUS;
@@ -3799,20 +3844,13 @@ function RlsPickerClockTick({ onValue, selectionIsHours, value }) {
3799
3844
  top: `${DIAL_RADIUS - y - TICK_RADIUS - 1}rem`
3800
3845
  };
3801
3846
  }, []);
3802
- const label = useMemo(() => {
3847
+ const tickValue = useMemo(() => {
3803
3848
  if (selectionIsHours) {
3804
- return formatTime(value);
3849
+ return value;
3805
3850
  }
3806
- if (value === 12) {
3807
- return formatTime(0);
3808
- }
3809
- return formatTime(value * 5);
3851
+ return value === CLOCK_HOURS ? 0 : value * 5;
3810
3852
  }, [selectionIsHours]);
3811
- const onClick = useCallback((event) => {
3812
- event.preventDefault();
3813
- onValue(value);
3814
- }, [onValue]);
3815
- return (jsxRuntimeExports.jsx("div", { className: "rls-picker-clock__tick", style: styleTick, onClick: onClick, children: label }));
3853
+ return (jsxRuntimeExports.jsx("div", { className: "rls-picker-clock__tick", style: styleTick, "data-value": tickValue, children: formatTime(tickValue) }));
3816
3854
  }
3817
3855
  function RlsPickerClockComponent({ formControl, onListener, rlsTheme, time }) {
3818
3856
  const timeInitial = useMemo(() => {
@@ -3885,22 +3923,6 @@ function RlsPickerClockComponent({ formControl, onListener, rlsTheme, time }) {
3885
3923
  }
3886
3924
  changeIsInternal.current = false;
3887
3925
  }, [formControl?.value]);
3888
- const refreshComponent = useCallback((clientX, clientY) => {
3889
- const rectangle = plateElement.current.getBoundingClientRect();
3890
- const centerX = rectangle.left + rectangle.width / 2;
3891
- const centerY = rectangle.top + rectangle.height / 2;
3892
- const positionX = clientX - centerX;
3893
- const positionY = clientY - centerY;
3894
- const angle = Math.atan2(-positionX, positionY) + Math.PI;
3895
- const value = Math.round(angle / radianUnit);
3896
- refreshClock(value);
3897
- if (selectionIsHours) {
3898
- setHour(value === 0 ? 12 : value);
3899
- }
3900
- else {
3901
- setMinute(value);
3902
- }
3903
- }, [selectionIsHours, radianUnit]);
3904
3926
  const refreshClock = useCallback((value) => {
3905
3927
  const angle = value * radianUnit;
3906
3928
  const x2 = Math.sin(angle) * (RADIUS - TICK_RADIUS);
@@ -3916,6 +3938,27 @@ function RlsPickerClockComponent({ formControl, onListener, rlsTheme, time }) {
3916
3938
  pointElement.current.style.visibility =
3917
3939
  selectionIsHours || value % 5 === 0 ? 'hidden' : 'visible';
3918
3940
  }, [selectionIsHours, radianUnit]);
3941
+ const selectValue = useCallback((value) => {
3942
+ refreshClock(value);
3943
+ if (selectionIsHours) {
3944
+ setHour(value === 0 ? CLOCK_HOURS : value);
3945
+ }
3946
+ else {
3947
+ setMinute(value);
3948
+ }
3949
+ }, [selectionIsHours, refreshClock]);
3950
+ const selectFromPosition = useCallback((clientX, clientY) => {
3951
+ const rectangle = plateElement.current.getBoundingClientRect();
3952
+ const centerX = rectangle.left + rectangle.width / 2;
3953
+ const centerY = rectangle.top + rectangle.height / 2;
3954
+ const positionX = clientX - centerX;
3955
+ const positionY = clientY - centerY;
3956
+ // Angle in [0, 2π) measured clockwise from 12 o'clock
3957
+ const angle = Math.atan2(-positionX, positionY) + Math.PI;
3958
+ const steps = selectionIsHours ? CLOCK_HOURS : CLOCK_MINUTES;
3959
+ // Modulo keeps the last half step before 12 o'clock as 0, not as 60/12
3960
+ selectValue(Math.round(angle / radianUnit) % steps);
3961
+ }, [selectionIsHours, radianUnit, selectValue]);
3919
3962
  const onClickHour = useCallback(() => {
3920
3963
  setSelectionIsHours(true);
3921
3964
  }, []);
@@ -3928,49 +3971,56 @@ function RlsPickerClockComponent({ formControl, onListener, rlsTheme, time }) {
3928
3971
  const onClickPM = useCallback(() => {
3929
3972
  setZoneIsPM(true);
3930
3973
  }, []);
3931
- const onActiveSelection = useCallback(() => {
3974
+ const onPointerDown = useCallback((event) => {
3975
+ event.preventDefault();
3976
+ event.currentTarget.setPointerCapture(event.pointerId);
3932
3977
  selectionIsActive.current = true;
3933
- }, []);
3934
- const onMouseSelection = useCallback((event) => {
3978
+ const tick = event.target.closest('.rls-picker-clock__tick');
3979
+ // Pressing inside a label circle snaps to its exact value,
3980
+ // anywhere else (and while dragging) the angle decides
3981
+ if (tick?.dataset.value && pointerIsInsideTick(event, tick)) {
3982
+ selectValue(Number(tick.dataset.value));
3983
+ }
3984
+ else {
3985
+ selectFromPosition(event.clientX, event.clientY);
3986
+ }
3987
+ }, [selectValue, selectFromPosition]);
3988
+ const onPointerMove = useCallback((event) => {
3935
3989
  if (selectionIsActive.current) {
3936
- event.preventDefault();
3937
- refreshComponent(event.clientX, event.clientY);
3990
+ selectFromPosition(event.clientX, event.clientY);
3938
3991
  }
3939
- }, [refreshComponent]);
3940
- const onTouchSelection = useCallback((event) => {
3941
- const touch = event.touches.item(0);
3942
- if (selectionIsActive.current && touch) {
3943
- refreshComponent(touch.clientX, touch.clientY);
3992
+ }, [selectFromPosition]);
3993
+ const onPointerUp = useCallback(() => {
3994
+ if (!selectionIsActive.current) {
3995
+ return;
3944
3996
  }
3945
- }, [refreshComponent]);
3946
- const onInactiveSelection = useCallback(() => {
3947
3997
  selectionIsActive.current = false;
3948
- }, []);
3949
- const onClickValue = useCallback((value) => {
3998
+ // Once the hour is chosen, continue with the minutes
3950
3999
  if (selectionIsHours) {
3951
- setHour(value);
3952
- refreshClock(value);
3953
- }
3954
- else {
3955
- const minute = value === 12 ? 0 : value * 5;
3956
- setMinute(minute);
3957
- refreshClock(minute);
4000
+ setSelectionIsHours(false);
3958
4001
  }
3959
4002
  }, [selectionIsHours]);
4003
+ const onPointerCancel = useCallback(() => {
4004
+ selectionIsActive.current = false;
4005
+ }, []);
3960
4006
  const onCancel = useCallback(() => {
3961
4007
  onListener?.({ event: PickerListenerEvent.Cancel });
3962
4008
  }, [onListener]);
3963
4009
  const onCurrentTime = useCallback(() => {
3964
4010
  const currentTime = Time.now();
4011
+ const zoneIsPM = currentTime.hour >= 12;
4012
+ const hour = zoneIsPM ? currentTime.hour - 12 : currentTime.hour;
3965
4013
  changeIsInternal.current = true;
3966
4014
  formControl?.setValue(currentTime);
3967
- setHour(currentTime.hour);
4015
+ setZoneIsPM(zoneIsPM);
4016
+ setHour(hour);
3968
4017
  setMinute(currentTime.minute);
4018
+ refreshClock(selectionIsHours ? hour : currentTime.minute);
3969
4019
  onListener?.({
3970
4020
  event: PickerListenerEvent.Select,
3971
4021
  value: currentTime
3972
4022
  });
3973
- }, [formControl, onListener]);
4023
+ }, [formControl, onListener, selectionIsHours, refreshClock]);
3974
4024
  const onSelect = useCallback(() => {
3975
4025
  const hourValue = zoneIsPM
3976
4026
  ? hour !== 12
@@ -3987,10 +4037,10 @@ function RlsPickerClockComponent({ formControl, onListener, rlsTheme, time }) {
3987
4037
  value: timeValue
3988
4038
  });
3989
4039
  }, [formControl, hour, minute, zoneIsPM, onListener]);
3990
- return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-clock", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-clock__header", children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-clock__title", children: [jsxRuntimeExports.jsx("span", { className: classNameHour, onClick: onClickHour, children: hourFormat }), jsxRuntimeExports.jsx("span", { className: "rls-picker-clock__title__separator", children: ":" }), jsxRuntimeExports.jsx("span", { className: classNameMinute, onClick: onClickMinute, children: minuteFormat })] }), jsxRuntimeExports.jsxs("div", { className: "rls-picker-clock__zone", children: [jsxRuntimeExports.jsx("span", { className: classNameAM, onClick: onClickAM, children: "AM" }), jsxRuntimeExports.jsx("span", { className: classNamePM, onClick: onClickPM, children: "PM" })] })] }), jsxRuntimeExports.jsx("div", { className: "rls-picker-clock__body", children: jsxRuntimeExports.jsxs("div", { className: "rls-picker-clock__plate", ref: plateElement, onMouseDown: onActiveSelection, onMouseMove: onMouseSelection, onMouseUp: onInactiveSelection, onMouseLeave: onInactiveSelection, onTouchStart: onActiveSelection, onTouchMove: onTouchSelection, onTouchEnd: onInactiveSelection, children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-clock__canvas", children: jsxRuntimeExports.jsx("svg", { width: "120rem", height: "120rem", children: jsxRuntimeExports.jsxs("g", { style: {
4040
+ return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-clock", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-clock__header", children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-clock__title", children: [jsxRuntimeExports.jsx("span", { className: classNameHour, onClick: onClickHour, children: hourFormat }), jsxRuntimeExports.jsx("span", { className: "rls-picker-clock__title__separator", children: ":" }), jsxRuntimeExports.jsx("span", { className: classNameMinute, onClick: onClickMinute, children: minuteFormat })] }), jsxRuntimeExports.jsxs("div", { className: "rls-picker-clock__zone", children: [jsxRuntimeExports.jsx("span", { className: classNameAM, onClick: onClickAM, children: "AM" }), jsxRuntimeExports.jsx("span", { className: classNamePM, onClick: onClickPM, children: "PM" })] })] }), jsxRuntimeExports.jsx("div", { className: "rls-picker-clock__body", children: jsxRuntimeExports.jsxs("div", { className: "rls-picker-clock__plate", ref: plateElement, onPointerDown: onPointerDown, onPointerMove: onPointerMove, onPointerUp: onPointerUp, onPointerCancel: onPointerCancel, children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-clock__canvas", children: jsxRuntimeExports.jsx("svg", { width: "120rem", height: "120rem", children: jsxRuntimeExports.jsxs("g", { style: {
3991
4041
  transform: `translate(${DIAL_RADIUS}rem, ${DIAL_RADIUS}rem)`
3992
4042
  }, children: [jsxRuntimeExports.jsx("line", { ref: lineElement, className: "rls-picker-clock__canvas__line", x1: "-1", y1: "-1" }), jsxRuntimeExports.jsx("circle", { ref: centerElement, className: "rls-picker-clock__canvas__center", r: "4", cx: "-1", cy: "-1" }), jsxRuntimeExports.jsx("circle", { ref: indicatorElement, className: "rls-picker-clock__canvas__indicator", r: `${TICK_RADIUS}rem` }), jsxRuntimeExports.jsx("circle", { ref: pointElement, className: "rls-picker-clock__canvas__point", r: "3.5" })] }) }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-clock__hours", children: CLOCK_VALUES.map((value) => {
3993
- return (jsxRuntimeExports.jsx(RlsPickerClockTick, { value: value, selectionIsHours: selectionIsHours, onValue: onClickValue }, value));
4043
+ return (jsxRuntimeExports.jsx(RlsPickerClockTick, { value: value, selectionIsHours: selectionIsHours }, value));
3994
4044
  }) })] }) }), jsxRuntimeExports.jsxs("div", { className: "rls-picker-clock__footer", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-clock__footer--cancel", children: jsxRuntimeExports.jsx(RlsButton, { type: "flat", onClick: onCancel, children: labels.timeActionCancel }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-clock__footer--today", children: jsxRuntimeExports.jsx(RlsButtonAction, { icon: "timer", onClick: onCurrentTime }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-clock__footer--ok", children: jsxRuntimeExports.jsx(RlsButton, { type: "raised", onClick: onSelect, children: labels.timeActionSelect }) })] })] }));
3995
4045
  }
3996
4046
  const RlsPickerClock = memo(RlsPickerClockComponent);
@@ -4607,7 +4657,9 @@ function RlsFieldListInner({ render, suggestions, action, children, formControl,
4607
4657
  readonly: props.readOnly
4608
4658
  }, `rls-field-list rls-field-list__multi ${props.className ?? ''}`);
4609
4659
  const renderWithCheckbox = useCallback((element) => (jsxRuntimeExports.jsxs("div", { className: "rls-field-list__multi__element", children: [jsxRuntimeExports.jsx(RlsCheckBox, { checked: fieldList.isSelected(element) }), render(element)] })), [fieldList.isSelected, render]);
4610
- return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: fieldList.refContent, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__multi__chips", onClick: disabled ? undefined : fieldList.onClickInput, children: !fieldList.selected.length && placeholder ? (jsxRuntimeExports.jsx("span", { className: "rls-field-list__multi__placeholder", children: placeholder })) : (fieldList.selected.map((item, index) => (jsxRuntimeExports.jsxs("div", { className: "rls-field-list__multi__chip", children: [jsxRuntimeExports.jsx("span", { className: "rls-field-list__multi__chip__description", children: item.description }), !props.readOnly && !disabled && (jsxRuntimeExports.jsx("button", { className: "rls-field-list__multi__chip__remove", onClick: fieldList.onRemoveElement(item), children: jsxRuntimeExports.jsx(RlsIcon, { value: "close" }) }))] }, index)))) }), !props.readOnly && !disabled && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: "arrow-ios-down", onClick: fieldList.onClickAction }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsx(RlsFieldListSuggestions, { elements: suggestions, visible: fieldList.listIsVisible, action: action, disabled: disabled, higher: fieldList.higher, render: renderWithCheckbox, refAnchor: fieldList.refContent, refList: fieldList.refList, refSuggestions: fieldList.refSuggestions, onClickElement: fieldList.onClickElement, onKeydownElement: fieldList.onKeydownElement, onClickBackdrop: fieldList.onClickBackdrop, onHiddenAnchor: fieldList.onClickBackdrop })] }));
4660
+ return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: fieldList.refContent, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__multi__chips", onClick: disabled ? undefined : fieldList.onClickInput, children: !fieldList.selected.length && placeholder ? (jsxRuntimeExports.jsx("span", { className: "rls-field-list__multi__placeholder", children: placeholder })) : (fieldList.selected.map((item, index) => (jsxRuntimeExports.jsx(RlsChip, { onRemove: !props.readOnly && !disabled
4661
+ ? fieldList.onRemoveElement(item)
4662
+ : undefined, children: item.description }, index)))) }), !props.readOnly && !disabled && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: "arrow-ios-down", onClick: fieldList.onClickAction }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsx(RlsFieldListSuggestions, { elements: suggestions, visible: fieldList.listIsVisible, action: action, disabled: disabled, higher: fieldList.higher, render: renderWithCheckbox, refAnchor: fieldList.refContent, refList: fieldList.refList, refSuggestions: fieldList.refSuggestions, onClickElement: fieldList.onClickElement, onKeydownElement: fieldList.onKeydownElement, onClickBackdrop: fieldList.onClickBackdrop, onHiddenAnchor: fieldList.onClickBackdrop })] }));
4611
4663
  }
4612
4664
  function RlsFieldListTemplateComponent(props) {
4613
4665
  const fieldList = useFieldList(props);
@@ -4802,10 +4854,6 @@ function calculateImgDimension(image, dimension) {
4802
4854
  }
4803
4855
  function RlsImageEditorComponent(props) {
4804
4856
  const [selection, setSelection] = useState(props.selection ?? 60);
4805
- const [labels, setLabels] = useState({
4806
- actionRestore: reactI18n('editorImageActionRestore'),
4807
- actionSelect: reactI18n('editorImageActionSelect')
4808
- });
4809
4857
  const refBody = useRef(null);
4810
4858
  const refImage = useRef(null);
4811
4859
  const refSelection = useRef(null);
@@ -4930,16 +4978,9 @@ function RlsImageEditorComponent(props) {
4930
4978
  refreshImageStyle();
4931
4979
  refreshSelectionStyle(selection);
4932
4980
  };
4933
- const unsubscription = i18nSubscribe(() => {
4934
- setLabels({
4935
- actionRestore: reactI18n('editorImageActionRestore'),
4936
- actionSelect: reactI18n('editorImageActionSelect')
4937
- });
4938
- });
4939
4981
  window.addEventListener('resize', refreshImageStyle);
4940
4982
  return () => {
4941
4983
  window.removeEventListener('resize', refreshImageStyle);
4942
- unsubscription();
4943
4984
  };
4944
4985
  }, []);
4945
4986
  useEffect(() => {
@@ -5002,7 +5043,7 @@ function RlsImageEditorComponent(props) {
5002
5043
  context?.putImageData(originalImage.current, 0, 0);
5003
5044
  }
5004
5045
  }, []);
5005
- return (jsxRuntimeExports.jsxs("div", { className: "rls-image-editor", children: [jsxRuntimeExports.jsx("div", { ref: refBody, className: "rls-image-editor__body", children: jsxRuntimeExports.jsxs("div", { ref: refImage, className: "rls-image-editor__body__image", children: [jsxRuntimeExports.jsx("div", { ref: refSelection, className: "rls-image-editor__body__selection" }), jsxRuntimeExports.jsx("div", { ref: refOverlayTop, className: "rls-image-editor__body__overlay--top" }), jsxRuntimeExports.jsx("div", { ref: refOverlayRight, className: "rls-image-editor__body__overlay--right" }), jsxRuntimeExports.jsx("div", { ref: refOverlayBottom, className: "rls-image-editor__body__overlay--bottom" }), jsxRuntimeExports.jsx("div", { ref: refOverlayLeft, className: "rls-image-editor__body__overlay--left" }), jsxRuntimeExports.jsx("canvas", { ref: refCanvas })] }) }), jsxRuntimeExports.jsxs("div", { className: "rls-image-editor__footer", children: [jsxRuntimeExports.jsx("div", { className: "rls-image-editor__sliders", children: jsxRuntimeExports.jsx(RlsSlider, { prefixIcon: "external-link", value: selection, minValue: MIN_SLIDER_VALUE, maxValue: MAX_SLIDER_VALUE, onValue: setSelection, disabled: props.disabled }) }), jsxRuntimeExports.jsxs("div", { className: "rls-image-editor__actions", children: [props.children, jsxRuntimeExports.jsx(RlsButton, { type: "flat", rlsTheme: "standard", prefixIcon: "refresh", onClick: onRestore, disabled: props.disabled, children: labels.actionRestore }), jsxRuntimeExports.jsx(RlsButton, { type: "raised", rlsTheme: "primary", prefixIcon: "crop", onClick: onCropImage, disabled: props.disabled, children: labels.actionSelect })] })] }), jsxRuntimeExports.jsx("canvas", { ref: refPicture })] }));
5046
+ return (jsxRuntimeExports.jsxs("div", { className: "rls-image-editor", children: [jsxRuntimeExports.jsx("div", { ref: refBody, className: "rls-image-editor__body", children: jsxRuntimeExports.jsxs("div", { ref: refImage, className: "rls-image-editor__body__image", children: [jsxRuntimeExports.jsx("div", { ref: refSelection, className: "rls-image-editor__body__selection" }), jsxRuntimeExports.jsx("div", { ref: refOverlayTop, className: "rls-image-editor__body__overlay--top" }), jsxRuntimeExports.jsx("div", { ref: refOverlayRight, className: "rls-image-editor__body__overlay--right" }), jsxRuntimeExports.jsx("div", { ref: refOverlayBottom, className: "rls-image-editor__body__overlay--bottom" }), jsxRuntimeExports.jsx("div", { ref: refOverlayLeft, className: "rls-image-editor__body__overlay--left" }), jsxRuntimeExports.jsx("canvas", { ref: refCanvas })] }) }), jsxRuntimeExports.jsxs("div", { className: "rls-image-editor__footer", children: [jsxRuntimeExports.jsx("div", { className: "rls-image-editor__sliders", children: jsxRuntimeExports.jsx(RlsSlider, { prefixIcon: "crop", value: selection, minValue: MIN_SLIDER_VALUE, maxValue: MAX_SLIDER_VALUE, onValue: setSelection, disabled: props.disabled }) }), jsxRuntimeExports.jsxs("div", { className: "rls-image-editor__actions", children: [props.children, jsxRuntimeExports.jsx("button", { className: "rls-image-editor__action", "rls-theme": "standard", onClick: onRestore, disabled: props.disabled, children: jsxRuntimeExports.jsx(RlsIcon, { value: "refresh" }) }), jsxRuntimeExports.jsx("button", { className: "rls-image-editor__action", "rls-theme": "success", onClick: onCropImage, disabled: props.disabled, children: jsxRuntimeExports.jsx(RlsIcon, { value: "checkmark-circle-out" }) })] })] }), jsxRuntimeExports.jsx("canvas", { ref: refPicture })] }));
5006
5047
  }
5007
5048
  const RlsImageEditor = memo(RlsImageEditorComponent);
5008
5049
 
@@ -5060,7 +5101,7 @@ function useImageEditorController(options) {
5060
5101
  setSrcEditor(undefined);
5061
5102
  }, []);
5062
5103
  const RlsImageEditorChooser = useMemo(() => {
5063
- 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 }) })));
5104
+ 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("button", { className: "rls-image-editor__action", "rls-theme": "danger", onClick: onCancel, disabled: options.disabled, children: jsxRuntimeExports.jsx(RlsIcon, { value: "close" }) }) })));
5064
5105
  }, [
5065
5106
  srcEditor,
5066
5107
  labels,
@@ -5096,6 +5137,46 @@ function RlsImageChooserComponent(props) {
5096
5137
  }
5097
5138
  const RlsImageChooser = memo(RlsImageChooserComponent);
5098
5139
 
5140
+ function RlsLedColorComponent({ className, color, disabled: disabledProps, formControl, identifier, onValue, readOnly, rlsTheme, value: valueInitial }) {
5141
+ const [value, setValue] = useState(formControl?.value ?? valueInitial);
5142
+ const [modalIsVisible, setModalIsVisible] = useState(false);
5143
+ const [pickerKey, setPickerKey] = useState(0);
5144
+ const colorValue = useMemo(() => {
5145
+ return formControl ? formControl.value : value;
5146
+ }, [formControl?.value, value]);
5147
+ const disabled = useMemo(() => {
5148
+ return formControl?.disabled || disabledProps;
5149
+ }, [formControl?.disabled, disabledProps]);
5150
+ const ledColor = useMemo(() => {
5151
+ return colorValue && hexIsValid(colorValue)
5152
+ ? normalizeHex(colorValue)
5153
+ : undefined;
5154
+ }, [colorValue]);
5155
+ const classNameLed = renderClassStatus('rls-led-color', { disabled, error: formControl?.wrong, readonly: readOnly }, className);
5156
+ const onChange = useCallback((value) => {
5157
+ setValue(value);
5158
+ onValue?.(value);
5159
+ }, [onValue]);
5160
+ const onClickLed = useCallback(() => {
5161
+ if (!disabled && !readOnly) {
5162
+ setPickerKey((key) => key + 1);
5163
+ setModalIsVisible(true);
5164
+ }
5165
+ }, [disabled, readOnly]);
5166
+ const onListener = useCallback(({ event, value }) => {
5167
+ if (event !== PickerListenerEvent.Cancel) {
5168
+ onChange(value);
5169
+ }
5170
+ formControl?.touch();
5171
+ setModalIsVisible(false);
5172
+ }, [formControl, onChange]);
5173
+ const onBackdrop = useCallback(() => {
5174
+ setModalIsVisible(false);
5175
+ }, []);
5176
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: classNameLed, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("button", { className: "rls-led-color__trigger", type: "button", disabled: disabled, onClick: onClickLed, children: jsxRuntimeExports.jsx(RlsLed, { color: ledColor, rlsTheme: rlsTheme }) }), jsxRuntimeExports.jsx(RlsModal, { className: "rls-modal-color", visible: modalIsVisible, rlsTheme: rlsTheme, onBackdrop: onBackdrop, children: jsxRuntimeExports.jsx(RlsPickerColor, { formControl: formControl, color: ledColor ?? color, disabled: disabled, onListener: onListener }, pickerKey) })] }));
5177
+ }
5178
+ const RlsLedColor = memo(RlsLedColorComponent);
5179
+
5099
5180
  function RlsModalSheetComponent({ autoclose, children, className, controller, onAutoClose, visible, rlsTheme }) {
5100
5181
  const classNameModal = renderClassStatus('rls-modal-sheet', { visible: controller?.visible ?? visible }, className);
5101
5182
  const onClickBackdrop = useCallback(() => {
@@ -5428,5 +5509,5 @@ function useTabsController(options) {
5428
5509
  return useMemo(() => ({ Tabs, formControl }), [Tabs, formControl]);
5429
5510
  }
5430
5511
 
5431
- export { APP_THEMES, ConfirmationResult, DEFAULT_COLOR, RlsAccordion, RlsAlert, RlsAmount, RlsAppThemeTabs, RlsApplication, RlsAreaText, RlsAvatar, RlsBadge, RlsBallot, RlsBody, RlsBottomSheet, RlsBreadcrumb, RlsButton, RlsButtonAction, RlsButtonIcon, RlsButtonOption, RlsButtonProgress, RlsButtonStepper, RlsButtonToggle, RlsCard, RlsCheckBox, RlsCheckBoxControl, RlsChooserAutocomplete, RlsChooserAutocompleteTemplate, RlsChooserList, RlsChooserListTemplate, RlsChooserSelect, RlsChooserSelectTemplate, RlsConfirmation, RlsContent, RlsContext, RlsDatatable, RlsDatatableCell, RlsDatatableData, RlsDatatableFloating, RlsDatatableHeader, RlsDatatableRecord, RlsDatatableSubheader, RlsDatatableTitle, RlsDatatableTotals, RlsDropdown, RlsFieldArea, RlsFieldAutocomplete, RlsFieldAutocompleteTemplate, RlsFieldClock, RlsFieldColor, RlsFieldDate, RlsFieldDateRange, RlsFieldDecimal, RlsFieldFile, RlsFieldList, RlsFieldListSuggestions, RlsFieldListTemplate, RlsFieldMoney, RlsFieldNumber, RlsFieldPassword, RlsFieldPercentage, RlsFieldReadonly, RlsFieldSelect, RlsFieldSelectTemplate, RlsFieldText, RlsFormNavigation, RlsHoverSwap, RlsIcon, RlsImage, RlsImageChooser, RlsImageEditor, RlsInput, RlsInputCounter, RlsInputDecimal, RlsInputMoney, RlsInputNumber, RlsInputPassword, RlsInputPercentage, RlsInputSearch, RlsInputText, RlsLabel, RlsLabelCheckBox, RlsLabelRadioButton, RlsLabelSwitch, RlsLed, RlsMessageEmpty, RlsMessageFormError, RlsMessageIcon, RlsModal, RlsModalClock, RlsModalDate, RlsModalDateRange, RlsModalSheet, RlsNavbar, RlsNavbarMenu, RlsPagination, RlsPickerClock, RlsPickerColor, RlsPickerDate, RlsPickerDateRange, RlsPickerDay, RlsPickerDayRange, RlsPickerMonth, RlsPickerSelectorTitle, RlsPickerYear, RlsPoster, RlsProgressBar, RlsProgressCircular, RlsRadioButton, RlsSkeleton, RlsSkeletonText, RlsSlider, RlsSnackbar, RlsSpinner, RlsSwitch, RlsSwitchControl, RlsTabs, RlsTabularText, RlsToolbar, calculateImgDimension, generateThemePalette, getAppTheme, getRemSize$1 as getRemSize, hexIsValid, hexToHsl, hexToHsv, hexToRgb, hslToHex, hsvToHex, hsvToRgb, normalizeHex, rangeFormatTemplate, renderClassStatus, rgbToHex, rgbToHsl, rgbToHsv, setAppTheme, setDesignSystem, setErrorsI18n, setThemeColor, toggleAppTheme, useAppThemeController, useConfirmation, useDatatable, useDesingSystemController, useDropdownController, useEventCallback, useFieldAutocomplete, useFieldList, useFieldSelect, useFormSingleSelectionController, useFormToggleController, useImageEditorController, useListController, useNotifications, usePortalController, useRelocationOnComponent, useResize, useRlsContext, useSnackbar, useTabsController };
5512
+ export { APP_THEMES, ConfirmationResult, DEFAULT_COLOR, RlsAccordion, RlsAlert, RlsAmount, RlsAppThemeTabs, RlsApplication, RlsAreaText, RlsAvatar, RlsBadge, RlsBallot, RlsBody, RlsBottomSheet, RlsBreadcrumb, RlsButton, RlsButtonAction, RlsButtonIcon, RlsButtonOption, RlsButtonProgress, RlsButtonStepper, RlsButtonToggle, RlsCard, RlsCheckBox, RlsCheckBoxControl, RlsChip, RlsChipGroup, RlsChooserAutocomplete, RlsChooserAutocompleteTemplate, RlsChooserList, RlsChooserListTemplate, RlsChooserSelect, RlsChooserSelectTemplate, RlsConfirmation, RlsContent, RlsContext, RlsDatatable, RlsDatatableCell, RlsDatatableData, RlsDatatableFloating, RlsDatatableHeader, RlsDatatableRecord, RlsDatatableSubheader, RlsDatatableTitle, RlsDatatableTotals, RlsDropdown, RlsFieldArea, RlsFieldAutocomplete, RlsFieldAutocompleteTemplate, RlsFieldClock, RlsFieldColor, RlsFieldDate, RlsFieldDateRange, RlsFieldDecimal, RlsFieldFile, RlsFieldList, RlsFieldListSuggestions, RlsFieldListTemplate, RlsFieldMoney, RlsFieldNumber, RlsFieldPassword, RlsFieldPercentage, RlsFieldReadonly, RlsFieldSelect, RlsFieldSelectTemplate, RlsFieldText, RlsFormNavigation, RlsHoverSwap, RlsIcon, RlsImage, RlsImageChooser, RlsImageEditor, RlsInput, RlsInputCounter, RlsInputDecimal, RlsInputMoney, RlsInputNumber, RlsInputPassword, RlsInputPercentage, RlsInputSearch, RlsInputText, RlsLabel, RlsLabelCheckBox, RlsLabelRadioButton, RlsLabelSwitch, RlsLed, RlsLedColor, RlsMessageEmpty, RlsMessageFormError, RlsMessageIcon, RlsModal, RlsModalClock, RlsModalDate, RlsModalDateRange, RlsModalSheet, RlsNavbar, RlsNavbarMenu, RlsPagination, RlsPickerClock, RlsPickerColor, RlsPickerDate, RlsPickerDateRange, RlsPickerDay, RlsPickerDayRange, RlsPickerMonth, RlsPickerSelectorTitle, RlsPickerYear, RlsPoster, RlsProgressBar, RlsProgressCircular, RlsRadioButton, RlsSkeleton, RlsSkeletonText, RlsSlider, RlsSnackbar, RlsSpinner, RlsSwitch, RlsSwitchControl, RlsTabs, RlsTabularText, RlsToolbar, calculateImgDimension, generateThemePalette, getAppTheme, getRemSize$1 as getRemSize, hexIsValid, hexToHsl, hexToHsv, hexToRgb, hslToHex, hsvToHex, hsvToRgb, normalizeHex, rangeFormatTemplate, renderClassStatus, rgbToHex, rgbToHsl, rgbToHsv, setAppTheme, setDesignSystem, setErrorsI18n, setThemeColor, toggleAppTheme, useAppThemeController, useConfirmation, useDatatable, useDesingSystemController, useDropdownController, useEventCallback, useFieldAutocomplete, useFieldList, useFieldSelect, useFormSingleSelectionController, useFormToggleController, useImageEditorController, useListController, useNotifications, usePortalController, useRelocationOnComponent, useResize, useRlsContext, useSnackbar, useTabsController };
5432
5513
  //# sourceMappingURL=index.mjs.map