@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/cjs/index.cjs +151 -67
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/es/index.mjs +149 -68
- package/dist/es/index.mjs.map +1 -1
- package/dist/esm/components/atoms/Chip/Chip.d.ts +13 -0
- package/dist/esm/components/atoms/Chip/Chip.js +10 -0
- package/dist/esm/components/atoms/Chip/Chip.js.map +1 -0
- package/dist/esm/components/molecules/ChipGroup/ChipGroup.d.ts +31 -0
- package/dist/esm/components/molecules/ChipGroup/ChipGroup.js +34 -0
- package/dist/esm/components/molecules/ChipGroup/ChipGroup.js.map +1 -0
- package/dist/esm/components/organisms/FieldList/FieldList.js +4 -2
- package/dist/esm/components/organisms/FieldList/FieldList.js.map +1 -1
- package/dist/esm/components/organisms/ImageEditor/ImageEditor.js +2 -15
- package/dist/esm/components/organisms/ImageEditor/ImageEditor.js.map +1 -1
- package/dist/esm/components/organisms/LedColor/LedColor.d.ts +36 -0
- package/dist/esm/components/organisms/LedColor/LedColor.js +48 -0
- package/dist/esm/components/organisms/LedColor/LedColor.js.map +1 -0
- package/dist/esm/components/organisms/PickerClock/PickerClock.js +67 -53
- package/dist/esm/components/organisms/PickerClock/PickerClock.js.map +1 -1
- package/dist/esm/controllers/ImageEditorController.js +2 -2
- package/dist/esm/controllers/ImageEditorController.js.map +1 -1
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
- package/readme.md +3 -0
package/dist/cjs/index.cjs
CHANGED
|
@@ -721,6 +721,12 @@ function RlsCheckBoxControlComponent({ formControl, disabled, identifier, rlsThe
|
|
|
721
721
|
}
|
|
722
722
|
const RlsCheckBoxControl = require$$0.memo(RlsCheckBoxControlComponent);
|
|
723
723
|
|
|
724
|
+
function RlsChipComponent({ children, className, contrasted, disabled, icon, identifier, onClick, onRemove, rlsTheme, selected }) {
|
|
725
|
+
const classNameChip = renderClassStatus('rls-chip', { clickable: !!onClick && !disabled, contrasted, disabled, selected }, className);
|
|
726
|
+
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" }) }))] }));
|
|
727
|
+
}
|
|
728
|
+
const RlsChip = require$$0.memo(RlsChipComponent);
|
|
729
|
+
|
|
724
730
|
function RlsSkeletonComponent({ animation, rlsTheme }) {
|
|
725
731
|
const className = renderClassStatus('rls-skeleton', {
|
|
726
732
|
animation: animation !== 'shimmer' && animation
|
|
@@ -1671,6 +1677,36 @@ function RlsButtonToggleComponent({ onAction, options, type, automatic, disabled
|
|
|
1671
1677
|
}
|
|
1672
1678
|
const RlsButtonToggle = require$$0.memo(RlsButtonToggleComponent);
|
|
1673
1679
|
|
|
1680
|
+
function RlsChipGroupComponent({ className, disabled: disabledProps, formControl, identifier, onValue, options, reference, render, rlsTheme, value: valueInitial }) {
|
|
1681
|
+
const [value, setValue] = require$$0.useState(formControl?.value ?? valueInitial);
|
|
1682
|
+
const selected = require$$0.useMemo(() => {
|
|
1683
|
+
return formControl ? formControl.value : value;
|
|
1684
|
+
}, [formControl?.value, value]);
|
|
1685
|
+
const disabled = require$$0.useMemo(() => {
|
|
1686
|
+
return formControl?.disabled || disabledProps;
|
|
1687
|
+
}, [formControl?.disabled, disabledProps]);
|
|
1688
|
+
const classNameGroup = renderClassStatus('rls-chip-group', { disabled }, className);
|
|
1689
|
+
const isSelected = require$$0.useCallback((option) => {
|
|
1690
|
+
if (selected === undefined || selected === null) {
|
|
1691
|
+
return false;
|
|
1692
|
+
}
|
|
1693
|
+
return reference
|
|
1694
|
+
? reference(option) === reference(selected)
|
|
1695
|
+
: option === selected;
|
|
1696
|
+
}, [reference, selected]);
|
|
1697
|
+
const onSelect = require$$0.useCallback((option) => () => {
|
|
1698
|
+
if (disabled) {
|
|
1699
|
+
return;
|
|
1700
|
+
}
|
|
1701
|
+
setValue(option);
|
|
1702
|
+
formControl?.setValue(option);
|
|
1703
|
+
formControl?.touch();
|
|
1704
|
+
onValue?.(option);
|
|
1705
|
+
}, [disabled, formControl, onValue]);
|
|
1706
|
+
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))) }));
|
|
1707
|
+
}
|
|
1708
|
+
const RlsChipGroup = require$$0.memo(RlsChipGroupComponent);
|
|
1709
|
+
|
|
1674
1710
|
function RlsContentComponent({ children, identifier, rlsTheme }) {
|
|
1675
1711
|
return (jsxRuntimeExports.jsx("div", { id: identifier, className: "rls-app__page__content", "rls-theme": rlsTheme, children: children }));
|
|
1676
1712
|
}
|
|
@@ -3787,11 +3823,20 @@ const RlsModal = require$$0.memo(RlsModalComponent);
|
|
|
3787
3823
|
function formatTime(value) {
|
|
3788
3824
|
return String(value).padStart(2, '0');
|
|
3789
3825
|
}
|
|
3826
|
+
function pointerIsInsideTick({ clientX, clientY }, tick) {
|
|
3827
|
+
const { left, top, width, height } = tick.getBoundingClientRect();
|
|
3828
|
+
const distanceX = clientX - (left + width / 2);
|
|
3829
|
+
const distanceY = clientY - (top + height / 2);
|
|
3830
|
+
const radius = Math.min(width, height) / 2;
|
|
3831
|
+
return distanceX ** 2 + distanceY ** 2 <= radius ** 2;
|
|
3832
|
+
}
|
|
3790
3833
|
const CLOCK_VALUES = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
|
3834
|
+
const CLOCK_HOURS = 12;
|
|
3835
|
+
const CLOCK_MINUTES = 60;
|
|
3791
3836
|
const RADIUS = 48;
|
|
3792
3837
|
const DIAL_RADIUS = 60;
|
|
3793
3838
|
const TICK_RADIUS = 7;
|
|
3794
|
-
function RlsPickerClockTick({
|
|
3839
|
+
function RlsPickerClockTick({ selectionIsHours, value }) {
|
|
3795
3840
|
const styleTick = require$$0.useMemo(() => {
|
|
3796
3841
|
const radian = (value / 6) * Math.PI;
|
|
3797
3842
|
const x = Math.sin(radian) * RADIUS;
|
|
@@ -3801,20 +3846,13 @@ function RlsPickerClockTick({ onValue, selectionIsHours, value }) {
|
|
|
3801
3846
|
top: `${DIAL_RADIUS - y - TICK_RADIUS - 1}rem`
|
|
3802
3847
|
};
|
|
3803
3848
|
}, []);
|
|
3804
|
-
const
|
|
3849
|
+
const tickValue = require$$0.useMemo(() => {
|
|
3805
3850
|
if (selectionIsHours) {
|
|
3806
|
-
return
|
|
3851
|
+
return value;
|
|
3807
3852
|
}
|
|
3808
|
-
|
|
3809
|
-
return formatTime(0);
|
|
3810
|
-
}
|
|
3811
|
-
return formatTime(value * 5);
|
|
3853
|
+
return value === CLOCK_HOURS ? 0 : value * 5;
|
|
3812
3854
|
}, [selectionIsHours]);
|
|
3813
|
-
|
|
3814
|
-
event.preventDefault();
|
|
3815
|
-
onValue(value);
|
|
3816
|
-
}, [onValue]);
|
|
3817
|
-
return (jsxRuntimeExports.jsx("div", { className: "rls-picker-clock__tick", style: styleTick, onClick: onClick, children: label }));
|
|
3855
|
+
return (jsxRuntimeExports.jsx("div", { className: "rls-picker-clock__tick", style: styleTick, "data-value": tickValue, children: formatTime(tickValue) }));
|
|
3818
3856
|
}
|
|
3819
3857
|
function RlsPickerClockComponent({ formControl, onListener, rlsTheme, time }) {
|
|
3820
3858
|
const timeInitial = require$$0.useMemo(() => {
|
|
@@ -3887,22 +3925,6 @@ function RlsPickerClockComponent({ formControl, onListener, rlsTheme, time }) {
|
|
|
3887
3925
|
}
|
|
3888
3926
|
changeIsInternal.current = false;
|
|
3889
3927
|
}, [formControl?.value]);
|
|
3890
|
-
const refreshComponent = require$$0.useCallback((clientX, clientY) => {
|
|
3891
|
-
const rectangle = plateElement.current.getBoundingClientRect();
|
|
3892
|
-
const centerX = rectangle.left + rectangle.width / 2;
|
|
3893
|
-
const centerY = rectangle.top + rectangle.height / 2;
|
|
3894
|
-
const positionX = clientX - centerX;
|
|
3895
|
-
const positionY = clientY - centerY;
|
|
3896
|
-
const angle = Math.atan2(-positionX, positionY) + Math.PI;
|
|
3897
|
-
const value = Math.round(angle / radianUnit);
|
|
3898
|
-
refreshClock(value);
|
|
3899
|
-
if (selectionIsHours) {
|
|
3900
|
-
setHour(value === 0 ? 12 : value);
|
|
3901
|
-
}
|
|
3902
|
-
else {
|
|
3903
|
-
setMinute(value);
|
|
3904
|
-
}
|
|
3905
|
-
}, [selectionIsHours, radianUnit]);
|
|
3906
3928
|
const refreshClock = require$$0.useCallback((value) => {
|
|
3907
3929
|
const angle = value * radianUnit;
|
|
3908
3930
|
const x2 = Math.sin(angle) * (RADIUS - TICK_RADIUS);
|
|
@@ -3918,6 +3940,27 @@ function RlsPickerClockComponent({ formControl, onListener, rlsTheme, time }) {
|
|
|
3918
3940
|
pointElement.current.style.visibility =
|
|
3919
3941
|
selectionIsHours || value % 5 === 0 ? 'hidden' : 'visible';
|
|
3920
3942
|
}, [selectionIsHours, radianUnit]);
|
|
3943
|
+
const selectValue = require$$0.useCallback((value) => {
|
|
3944
|
+
refreshClock(value);
|
|
3945
|
+
if (selectionIsHours) {
|
|
3946
|
+
setHour(value === 0 ? CLOCK_HOURS : value);
|
|
3947
|
+
}
|
|
3948
|
+
else {
|
|
3949
|
+
setMinute(value);
|
|
3950
|
+
}
|
|
3951
|
+
}, [selectionIsHours, refreshClock]);
|
|
3952
|
+
const selectFromPosition = require$$0.useCallback((clientX, clientY) => {
|
|
3953
|
+
const rectangle = plateElement.current.getBoundingClientRect();
|
|
3954
|
+
const centerX = rectangle.left + rectangle.width / 2;
|
|
3955
|
+
const centerY = rectangle.top + rectangle.height / 2;
|
|
3956
|
+
const positionX = clientX - centerX;
|
|
3957
|
+
const positionY = clientY - centerY;
|
|
3958
|
+
// Angle in [0, 2π) measured clockwise from 12 o'clock
|
|
3959
|
+
const angle = Math.atan2(-positionX, positionY) + Math.PI;
|
|
3960
|
+
const steps = selectionIsHours ? CLOCK_HOURS : CLOCK_MINUTES;
|
|
3961
|
+
// Modulo keeps the last half step before 12 o'clock as 0, not as 60/12
|
|
3962
|
+
selectValue(Math.round(angle / radianUnit) % steps);
|
|
3963
|
+
}, [selectionIsHours, radianUnit, selectValue]);
|
|
3921
3964
|
const onClickHour = require$$0.useCallback(() => {
|
|
3922
3965
|
setSelectionIsHours(true);
|
|
3923
3966
|
}, []);
|
|
@@ -3930,49 +3973,56 @@ function RlsPickerClockComponent({ formControl, onListener, rlsTheme, time }) {
|
|
|
3930
3973
|
const onClickPM = require$$0.useCallback(() => {
|
|
3931
3974
|
setZoneIsPM(true);
|
|
3932
3975
|
}, []);
|
|
3933
|
-
const
|
|
3976
|
+
const onPointerDown = require$$0.useCallback((event) => {
|
|
3977
|
+
event.preventDefault();
|
|
3978
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
3934
3979
|
selectionIsActive.current = true;
|
|
3935
|
-
|
|
3936
|
-
|
|
3980
|
+
const tick = event.target.closest('.rls-picker-clock__tick');
|
|
3981
|
+
// Pressing inside a label circle snaps to its exact value,
|
|
3982
|
+
// anywhere else (and while dragging) the angle decides
|
|
3983
|
+
if (tick?.dataset.value && pointerIsInsideTick(event, tick)) {
|
|
3984
|
+
selectValue(Number(tick.dataset.value));
|
|
3985
|
+
}
|
|
3986
|
+
else {
|
|
3987
|
+
selectFromPosition(event.clientX, event.clientY);
|
|
3988
|
+
}
|
|
3989
|
+
}, [selectValue, selectFromPosition]);
|
|
3990
|
+
const onPointerMove = require$$0.useCallback((event) => {
|
|
3937
3991
|
if (selectionIsActive.current) {
|
|
3938
|
-
event.
|
|
3939
|
-
refreshComponent(event.clientX, event.clientY);
|
|
3992
|
+
selectFromPosition(event.clientX, event.clientY);
|
|
3940
3993
|
}
|
|
3941
|
-
}, [
|
|
3942
|
-
const
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
refreshComponent(touch.clientX, touch.clientY);
|
|
3994
|
+
}, [selectFromPosition]);
|
|
3995
|
+
const onPointerUp = require$$0.useCallback(() => {
|
|
3996
|
+
if (!selectionIsActive.current) {
|
|
3997
|
+
return;
|
|
3946
3998
|
}
|
|
3947
|
-
}, [refreshComponent]);
|
|
3948
|
-
const onInactiveSelection = require$$0.useCallback(() => {
|
|
3949
3999
|
selectionIsActive.current = false;
|
|
3950
|
-
|
|
3951
|
-
const onClickValue = require$$0.useCallback((value) => {
|
|
4000
|
+
// Once the hour is chosen, continue with the minutes
|
|
3952
4001
|
if (selectionIsHours) {
|
|
3953
|
-
|
|
3954
|
-
refreshClock(value);
|
|
3955
|
-
}
|
|
3956
|
-
else {
|
|
3957
|
-
const minute = value === 12 ? 0 : value * 5;
|
|
3958
|
-
setMinute(minute);
|
|
3959
|
-
refreshClock(minute);
|
|
4002
|
+
setSelectionIsHours(false);
|
|
3960
4003
|
}
|
|
3961
4004
|
}, [selectionIsHours]);
|
|
4005
|
+
const onPointerCancel = require$$0.useCallback(() => {
|
|
4006
|
+
selectionIsActive.current = false;
|
|
4007
|
+
}, []);
|
|
3962
4008
|
const onCancel = require$$0.useCallback(() => {
|
|
3963
4009
|
onListener?.({ event: components.PickerListenerEvent.Cancel });
|
|
3964
4010
|
}, [onListener]);
|
|
3965
4011
|
const onCurrentTime = require$$0.useCallback(() => {
|
|
3966
4012
|
const currentTime = dates.Time.now();
|
|
4013
|
+
const zoneIsPM = currentTime.hour >= 12;
|
|
4014
|
+
const hour = zoneIsPM ? currentTime.hour - 12 : currentTime.hour;
|
|
3967
4015
|
changeIsInternal.current = true;
|
|
3968
4016
|
formControl?.setValue(currentTime);
|
|
3969
|
-
|
|
4017
|
+
setZoneIsPM(zoneIsPM);
|
|
4018
|
+
setHour(hour);
|
|
3970
4019
|
setMinute(currentTime.minute);
|
|
4020
|
+
refreshClock(selectionIsHours ? hour : currentTime.minute);
|
|
3971
4021
|
onListener?.({
|
|
3972
4022
|
event: components.PickerListenerEvent.Select,
|
|
3973
4023
|
value: currentTime
|
|
3974
4024
|
});
|
|
3975
|
-
}, [formControl, onListener]);
|
|
4025
|
+
}, [formControl, onListener, selectionIsHours, refreshClock]);
|
|
3976
4026
|
const onSelect = require$$0.useCallback(() => {
|
|
3977
4027
|
const hourValue = zoneIsPM
|
|
3978
4028
|
? hour !== 12
|
|
@@ -3989,10 +4039,10 @@ function RlsPickerClockComponent({ formControl, onListener, rlsTheme, time }) {
|
|
|
3989
4039
|
value: timeValue
|
|
3990
4040
|
});
|
|
3991
4041
|
}, [formControl, hour, minute, zoneIsPM, onListener]);
|
|
3992
|
-
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,
|
|
4042
|
+
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: {
|
|
3993
4043
|
transform: `translate(${DIAL_RADIUS}rem, ${DIAL_RADIUS}rem)`
|
|
3994
4044
|
}, 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) => {
|
|
3995
|
-
return (jsxRuntimeExports.jsx(RlsPickerClockTick, { value: value, selectionIsHours: selectionIsHours
|
|
4045
|
+
return (jsxRuntimeExports.jsx(RlsPickerClockTick, { value: value, selectionIsHours: selectionIsHours }, value));
|
|
3996
4046
|
}) })] }) }), 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 }) })] })] }));
|
|
3997
4047
|
}
|
|
3998
4048
|
const RlsPickerClock = require$$0.memo(RlsPickerClockComponent);
|
|
@@ -4609,7 +4659,9 @@ function RlsFieldListInner({ render, suggestions, action, children, formControl,
|
|
|
4609
4659
|
readonly: props.readOnly
|
|
4610
4660
|
}, `rls-field-list rls-field-list__multi ${props.className ?? ''}`);
|
|
4611
4661
|
const renderWithCheckbox = require$$0.useCallback((element) => (jsxRuntimeExports.jsxs("div", { className: "rls-field-list__multi__element", children: [jsxRuntimeExports.jsx(RlsCheckBox, { checked: fieldList.isSelected(element) }), render(element)] })), [fieldList.isSelected, render]);
|
|
4612
|
-
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.
|
|
4662
|
+
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
|
|
4663
|
+
? fieldList.onRemoveElement(item)
|
|
4664
|
+
: 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 })] }));
|
|
4613
4665
|
}
|
|
4614
4666
|
function RlsFieldListTemplateComponent(props) {
|
|
4615
4667
|
const fieldList = useFieldList(props);
|
|
@@ -4804,10 +4856,6 @@ function calculateImgDimension(image, dimension) {
|
|
|
4804
4856
|
}
|
|
4805
4857
|
function RlsImageEditorComponent(props) {
|
|
4806
4858
|
const [selection, setSelection] = require$$0.useState(props.selection ?? 60);
|
|
4807
|
-
const [labels, setLabels] = require$$0.useState({
|
|
4808
|
-
actionRestore: reactI18n('editorImageActionRestore'),
|
|
4809
|
-
actionSelect: reactI18n('editorImageActionSelect')
|
|
4810
|
-
});
|
|
4811
4859
|
const refBody = require$$0.useRef(null);
|
|
4812
4860
|
const refImage = require$$0.useRef(null);
|
|
4813
4861
|
const refSelection = require$$0.useRef(null);
|
|
@@ -4932,16 +4980,9 @@ function RlsImageEditorComponent(props) {
|
|
|
4932
4980
|
refreshImageStyle();
|
|
4933
4981
|
refreshSelectionStyle(selection);
|
|
4934
4982
|
};
|
|
4935
|
-
const unsubscription = i18n.i18nSubscribe(() => {
|
|
4936
|
-
setLabels({
|
|
4937
|
-
actionRestore: reactI18n('editorImageActionRestore'),
|
|
4938
|
-
actionSelect: reactI18n('editorImageActionSelect')
|
|
4939
|
-
});
|
|
4940
|
-
});
|
|
4941
4983
|
window.addEventListener('resize', refreshImageStyle);
|
|
4942
4984
|
return () => {
|
|
4943
4985
|
window.removeEventListener('resize', refreshImageStyle);
|
|
4944
|
-
unsubscription();
|
|
4945
4986
|
};
|
|
4946
4987
|
}, []);
|
|
4947
4988
|
require$$0.useEffect(() => {
|
|
@@ -5004,7 +5045,7 @@ function RlsImageEditorComponent(props) {
|
|
|
5004
5045
|
context?.putImageData(originalImage.current, 0, 0);
|
|
5005
5046
|
}
|
|
5006
5047
|
}, []);
|
|
5007
|
-
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: "
|
|
5048
|
+
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 })] }));
|
|
5008
5049
|
}
|
|
5009
5050
|
const RlsImageEditor = require$$0.memo(RlsImageEditorComponent);
|
|
5010
5051
|
|
|
@@ -5062,7 +5103,7 @@ function useImageEditorController(options) {
|
|
|
5062
5103
|
setSrcEditor(undefined);
|
|
5063
5104
|
}, []);
|
|
5064
5105
|
const RlsImageEditorChooser = require$$0.useMemo(() => {
|
|
5065
|
-
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(
|
|
5106
|
+
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" }) }) })));
|
|
5066
5107
|
}, [
|
|
5067
5108
|
srcEditor,
|
|
5068
5109
|
labels,
|
|
@@ -5098,6 +5139,46 @@ function RlsImageChooserComponent(props) {
|
|
|
5098
5139
|
}
|
|
5099
5140
|
const RlsImageChooser = require$$0.memo(RlsImageChooserComponent);
|
|
5100
5141
|
|
|
5142
|
+
function RlsLedColorComponent({ className, color, disabled: disabledProps, formControl, identifier, onValue, readOnly, rlsTheme, value: valueInitial }) {
|
|
5143
|
+
const [value, setValue] = require$$0.useState(formControl?.value ?? valueInitial);
|
|
5144
|
+
const [modalIsVisible, setModalIsVisible] = require$$0.useState(false);
|
|
5145
|
+
const [pickerKey, setPickerKey] = require$$0.useState(0);
|
|
5146
|
+
const colorValue = require$$0.useMemo(() => {
|
|
5147
|
+
return formControl ? formControl.value : value;
|
|
5148
|
+
}, [formControl?.value, value]);
|
|
5149
|
+
const disabled = require$$0.useMemo(() => {
|
|
5150
|
+
return formControl?.disabled || disabledProps;
|
|
5151
|
+
}, [formControl?.disabled, disabledProps]);
|
|
5152
|
+
const ledColor = require$$0.useMemo(() => {
|
|
5153
|
+
return colorValue && hexIsValid(colorValue)
|
|
5154
|
+
? normalizeHex(colorValue)
|
|
5155
|
+
: undefined;
|
|
5156
|
+
}, [colorValue]);
|
|
5157
|
+
const classNameLed = renderClassStatus('rls-led-color', { disabled, error: formControl?.wrong, readonly: readOnly }, className);
|
|
5158
|
+
const onChange = require$$0.useCallback((value) => {
|
|
5159
|
+
setValue(value);
|
|
5160
|
+
onValue?.(value);
|
|
5161
|
+
}, [onValue]);
|
|
5162
|
+
const onClickLed = require$$0.useCallback(() => {
|
|
5163
|
+
if (!disabled && !readOnly) {
|
|
5164
|
+
setPickerKey((key) => key + 1);
|
|
5165
|
+
setModalIsVisible(true);
|
|
5166
|
+
}
|
|
5167
|
+
}, [disabled, readOnly]);
|
|
5168
|
+
const onListener = require$$0.useCallback(({ event, value }) => {
|
|
5169
|
+
if (event !== components.PickerListenerEvent.Cancel) {
|
|
5170
|
+
onChange(value);
|
|
5171
|
+
}
|
|
5172
|
+
formControl?.touch();
|
|
5173
|
+
setModalIsVisible(false);
|
|
5174
|
+
}, [formControl, onChange]);
|
|
5175
|
+
const onBackdrop = require$$0.useCallback(() => {
|
|
5176
|
+
setModalIsVisible(false);
|
|
5177
|
+
}, []);
|
|
5178
|
+
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) })] }));
|
|
5179
|
+
}
|
|
5180
|
+
const RlsLedColor = require$$0.memo(RlsLedColorComponent);
|
|
5181
|
+
|
|
5101
5182
|
function RlsModalSheetComponent({ autoclose, children, className, controller, onAutoClose, visible, rlsTheme }) {
|
|
5102
5183
|
const classNameModal = renderClassStatus('rls-modal-sheet', { visible: controller?.visible ?? visible }, className);
|
|
5103
5184
|
const onClickBackdrop = require$$0.useCallback(() => {
|
|
@@ -5455,6 +5536,8 @@ exports.RlsButtonToggle = RlsButtonToggle;
|
|
|
5455
5536
|
exports.RlsCard = RlsCard;
|
|
5456
5537
|
exports.RlsCheckBox = RlsCheckBox;
|
|
5457
5538
|
exports.RlsCheckBoxControl = RlsCheckBoxControl;
|
|
5539
|
+
exports.RlsChip = RlsChip;
|
|
5540
|
+
exports.RlsChipGroup = RlsChipGroup;
|
|
5458
5541
|
exports.RlsChooserAutocomplete = RlsChooserAutocomplete;
|
|
5459
5542
|
exports.RlsChooserAutocompleteTemplate = RlsChooserAutocompleteTemplate;
|
|
5460
5543
|
exports.RlsChooserList = RlsChooserList;
|
|
@@ -5514,6 +5597,7 @@ exports.RlsLabelCheckBox = RlsLabelCheckBox;
|
|
|
5514
5597
|
exports.RlsLabelRadioButton = RlsLabelRadioButton;
|
|
5515
5598
|
exports.RlsLabelSwitch = RlsLabelSwitch;
|
|
5516
5599
|
exports.RlsLed = RlsLed;
|
|
5600
|
+
exports.RlsLedColor = RlsLedColor;
|
|
5517
5601
|
exports.RlsMessageEmpty = RlsMessageEmpty;
|
|
5518
5602
|
exports.RlsMessageFormError = RlsMessageFormError;
|
|
5519
5603
|
exports.RlsMessageIcon = RlsMessageIcon;
|