@rolster/react-components 19.10.0 → 19.11.2

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.
Files changed (29) hide show
  1. package/dist/cjs/index.cjs +218 -68
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/es/index.mjs +213 -69
  4. package/dist/es/index.mjs.map +1 -1
  5. package/dist/esm/components/atoms/Chip/Chip.d.ts +13 -0
  6. package/dist/esm/components/atoms/Chip/Chip.js +10 -0
  7. package/dist/esm/components/atoms/Chip/Chip.js.map +1 -0
  8. package/dist/esm/components/molecules/ChipGroup/ChipGroup.d.ts +31 -0
  9. package/dist/esm/components/molecules/ChipGroup/ChipGroup.js +34 -0
  10. package/dist/esm/components/molecules/ChipGroup/ChipGroup.js.map +1 -0
  11. package/dist/esm/components/organisms/FieldList/FieldList.js +4 -2
  12. package/dist/esm/components/organisms/FieldList/FieldList.js.map +1 -1
  13. package/dist/esm/components/organisms/ImageEditor/ImageEditor.js +2 -15
  14. package/dist/esm/components/organisms/ImageEditor/ImageEditor.js.map +1 -1
  15. package/dist/esm/components/organisms/LedColor/LedColor.d.ts +36 -0
  16. package/dist/esm/components/organisms/LedColor/LedColor.js +48 -0
  17. package/dist/esm/components/organisms/LedColor/LedColor.js.map +1 -0
  18. package/dist/esm/components/organisms/PickerClock/PickerClock.js +67 -53
  19. package/dist/esm/components/organisms/PickerClock/PickerClock.js.map +1 -1
  20. package/dist/esm/controllers/ImageEditorController.js +2 -2
  21. package/dist/esm/controllers/ImageEditorController.js.map +1 -1
  22. package/dist/esm/helpers/color.d.ts +12 -0
  23. package/dist/esm/helpers/color.js +64 -1
  24. package/dist/esm/helpers/color.js.map +1 -1
  25. package/dist/esm/index.d.ts +3 -0
  26. package/dist/esm/index.js +3 -0
  27. package/dist/esm/index.js.map +1 -1
  28. package/package.json +2 -2
  29. package/readme.md +3 -0
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
@@ -1245,13 +1251,18 @@ function generateThemeCSS(colors, theme) {
1245
1251
  const rgb900 = rgbChannels(parseHex(colors['900']));
1246
1252
  const rgb700 = rgbChannels(parseHex(colors['700']));
1247
1253
  const rgb500 = rgbChannels(parseHex(colors['500']));
1254
+ const rgb300 = rgbChannels(parseHex(colors['300']));
1248
1255
  const colorProps = SHADE_LABELS.map((label) => prop(`color-${label}`, colors[label]));
1249
1256
  const gradientProps = GRADIENT_LABELS.map((label) => {
1250
1257
  const darker = SHADE_LABELS[SHADE_LABELS.indexOf(label) - 1];
1251
1258
  return prop(`gradient-${label}`, `linear-gradient(180deg, ${colors[label]} 15%, ${colors[darker]} 85%)`);
1252
1259
  });
1253
1260
  const backdropProps = BACKDROP_LABELS.map((label) => prop(`backdrop-${label}`, `rgba(${rgb900}, ${Number(label) / 1000})`));
1254
- const skeletonProps = Object.entries(SKELETON_OPACITY).map(([label, opacity]) => prop(`skeleton-${label}`, `rgba(${rgb700}, ${opacity})`));
1261
+ const skeletonOpacities = Object.entries(SKELETON_OPACITY);
1262
+ const skeletonProps = skeletonOpacities.map(([label, opacity]) => prop(`skeleton-${label}`, `rgba(${rgb700}, ${opacity})`));
1263
+ // Skeleton tokens for dark surfaces, taken from the light step that mirrors
1264
+ // color-700 around color-500, as the foundations mixin does.
1265
+ const skeletonDarkProps = skeletonOpacities.map(([label, opacity]) => prop(`skeleton-dark-${label}`, `rgba(${rgb300}, ${opacity})`));
1255
1266
  const shadowProps = [
1256
1267
  prop('shadow-color-500', `rgba(${rgb500}, 0.24)`),
1257
1268
  prop('shadow-500', `0px 0px 0px 3px rgba(${rgb500}, 0.24)`)
@@ -1261,6 +1272,7 @@ function generateThemeCSS(colors, theme) {
1261
1272
  ...gradientProps,
1262
1273
  ...backdropProps,
1263
1274
  ...skeletonProps,
1275
+ ...skeletonDarkProps,
1264
1276
  ...shadowProps
1265
1277
  ];
1266
1278
  }
@@ -1330,12 +1342,69 @@ function setThemeColor(baseColor, theme = 'primary') {
1330
1342
  if (typeof document === 'undefined') {
1331
1343
  return;
1332
1344
  }
1345
+ resetTheme(theme);
1333
1346
  const { properties } = generateThemePalette(baseColor, theme);
1334
1347
  const target = document.body || document.documentElement;
1335
1348
  properties.forEach(({ name, value }) => {
1336
1349
  target.style.setProperty(name, value);
1337
1350
  });
1338
1351
  }
1352
+ const ALIAS_LABELS = [
1353
+ '900',
1354
+ '800',
1355
+ '700',
1356
+ '600',
1357
+ '500',
1358
+ '400',
1359
+ '300',
1360
+ '200',
1361
+ '100'
1362
+ ];
1363
+ const SKELETON_LABELS = Object.keys(SKELETON_OPACITY);
1364
+ const ALIAS_TOKENS = [
1365
+ ...SHADE_LABELS.map((label) => `color-${label}`),
1366
+ ...ALIAS_LABELS.map((label) => `gradient-${label}`),
1367
+ ...ALIAS_LABELS.map((label) => `backdrop-${label}`),
1368
+ ...SKELETON_LABELS.map((label) => `skeleton-${label}`),
1369
+ ...SKELETON_LABELS.map((label) => `skeleton-dark-${label}`),
1370
+ 'shadow-color-500',
1371
+ 'shadow-500'
1372
+ ];
1373
+ function resetTheme(theme = 'primary') {
1374
+ if (typeof document === 'undefined') {
1375
+ return;
1376
+ }
1377
+ const target = document.body || document.documentElement;
1378
+ ALIAS_TOKENS.forEach((token) => {
1379
+ target.style.removeProperty(`--rls-${theme}-${token}`);
1380
+ });
1381
+ }
1382
+ function generateThemeAlias(source, theme = 'primary') {
1383
+ const properties = ALIAS_TOKENS.map((token) => ({
1384
+ name: `--rls-${theme}-${token}`,
1385
+ value: `var(--rls-${source}-${token})`
1386
+ }));
1387
+ return {
1388
+ source,
1389
+ theme,
1390
+ properties,
1391
+ css: properties.map((p) => `${p.name}: ${p.value};`).join('\n')
1392
+ };
1393
+ }
1394
+ function setThemeAlias(source, theme = 'primary') {
1395
+ if (typeof document === 'undefined') {
1396
+ return;
1397
+ }
1398
+ if (source === theme) {
1399
+ resetTheme(theme);
1400
+ return;
1401
+ }
1402
+ const { properties } = generateThemeAlias(source, theme);
1403
+ const target = document.body || document.documentElement;
1404
+ properties.forEach(({ name, value }) => {
1405
+ target.style.setProperty(name, value);
1406
+ });
1407
+ }
1339
1408
  const DEFAULT_COLOR = '#1780e0';
1340
1409
 
1341
1410
  const CONTENT_BACKGROUND = '--pvt-content-background';
@@ -1669,6 +1738,36 @@ function RlsButtonToggleComponent({ onAction, options, type, automatic, disabled
1669
1738
  }
1670
1739
  const RlsButtonToggle = memo(RlsButtonToggleComponent);
1671
1740
 
1741
+ function RlsChipGroupComponent({ className, disabled: disabledProps, formControl, identifier, onValue, options, reference, render, rlsTheme, value: valueInitial }) {
1742
+ const [value, setValue] = useState(formControl?.value ?? valueInitial);
1743
+ const selected = useMemo(() => {
1744
+ return formControl ? formControl.value : value;
1745
+ }, [formControl?.value, value]);
1746
+ const disabled = useMemo(() => {
1747
+ return formControl?.disabled || disabledProps;
1748
+ }, [formControl?.disabled, disabledProps]);
1749
+ const classNameGroup = renderClassStatus('rls-chip-group', { disabled }, className);
1750
+ const isSelected = useCallback((option) => {
1751
+ if (selected === undefined || selected === null) {
1752
+ return false;
1753
+ }
1754
+ return reference
1755
+ ? reference(option) === reference(selected)
1756
+ : option === selected;
1757
+ }, [reference, selected]);
1758
+ const onSelect = useCallback((option) => () => {
1759
+ if (disabled) {
1760
+ return;
1761
+ }
1762
+ setValue(option);
1763
+ formControl?.setValue(option);
1764
+ formControl?.touch();
1765
+ onValue?.(option);
1766
+ }, [disabled, formControl, onValue]);
1767
+ 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))) }));
1768
+ }
1769
+ const RlsChipGroup = memo(RlsChipGroupComponent);
1770
+
1672
1771
  function RlsContentComponent({ children, identifier, rlsTheme }) {
1673
1772
  return (jsxRuntimeExports.jsx("div", { id: identifier, className: "rls-app__page__content", "rls-theme": rlsTheme, children: children }));
1674
1773
  }
@@ -3785,11 +3884,20 @@ const RlsModal = memo(RlsModalComponent);
3785
3884
  function formatTime(value) {
3786
3885
  return String(value).padStart(2, '0');
3787
3886
  }
3887
+ function pointerIsInsideTick({ clientX, clientY }, tick) {
3888
+ const { left, top, width, height } = tick.getBoundingClientRect();
3889
+ const distanceX = clientX - (left + width / 2);
3890
+ const distanceY = clientY - (top + height / 2);
3891
+ const radius = Math.min(width, height) / 2;
3892
+ return distanceX ** 2 + distanceY ** 2 <= radius ** 2;
3893
+ }
3788
3894
  const CLOCK_VALUES = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
3895
+ const CLOCK_HOURS = 12;
3896
+ const CLOCK_MINUTES = 60;
3789
3897
  const RADIUS = 48;
3790
3898
  const DIAL_RADIUS = 60;
3791
3899
  const TICK_RADIUS = 7;
3792
- function RlsPickerClockTick({ onValue, selectionIsHours, value }) {
3900
+ function RlsPickerClockTick({ selectionIsHours, value }) {
3793
3901
  const styleTick = useMemo(() => {
3794
3902
  const radian = (value / 6) * Math.PI;
3795
3903
  const x = Math.sin(radian) * RADIUS;
@@ -3799,20 +3907,13 @@ function RlsPickerClockTick({ onValue, selectionIsHours, value }) {
3799
3907
  top: `${DIAL_RADIUS - y - TICK_RADIUS - 1}rem`
3800
3908
  };
3801
3909
  }, []);
3802
- const label = useMemo(() => {
3910
+ const tickValue = useMemo(() => {
3803
3911
  if (selectionIsHours) {
3804
- return formatTime(value);
3912
+ return value;
3805
3913
  }
3806
- if (value === 12) {
3807
- return formatTime(0);
3808
- }
3809
- return formatTime(value * 5);
3914
+ return value === CLOCK_HOURS ? 0 : value * 5;
3810
3915
  }, [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 }));
3916
+ return (jsxRuntimeExports.jsx("div", { className: "rls-picker-clock__tick", style: styleTick, "data-value": tickValue, children: formatTime(tickValue) }));
3816
3917
  }
3817
3918
  function RlsPickerClockComponent({ formControl, onListener, rlsTheme, time }) {
3818
3919
  const timeInitial = useMemo(() => {
@@ -3885,22 +3986,6 @@ function RlsPickerClockComponent({ formControl, onListener, rlsTheme, time }) {
3885
3986
  }
3886
3987
  changeIsInternal.current = false;
3887
3988
  }, [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
3989
  const refreshClock = useCallback((value) => {
3905
3990
  const angle = value * radianUnit;
3906
3991
  const x2 = Math.sin(angle) * (RADIUS - TICK_RADIUS);
@@ -3916,6 +4001,27 @@ function RlsPickerClockComponent({ formControl, onListener, rlsTheme, time }) {
3916
4001
  pointElement.current.style.visibility =
3917
4002
  selectionIsHours || value % 5 === 0 ? 'hidden' : 'visible';
3918
4003
  }, [selectionIsHours, radianUnit]);
4004
+ const selectValue = useCallback((value) => {
4005
+ refreshClock(value);
4006
+ if (selectionIsHours) {
4007
+ setHour(value === 0 ? CLOCK_HOURS : value);
4008
+ }
4009
+ else {
4010
+ setMinute(value);
4011
+ }
4012
+ }, [selectionIsHours, refreshClock]);
4013
+ const selectFromPosition = useCallback((clientX, clientY) => {
4014
+ const rectangle = plateElement.current.getBoundingClientRect();
4015
+ const centerX = rectangle.left + rectangle.width / 2;
4016
+ const centerY = rectangle.top + rectangle.height / 2;
4017
+ const positionX = clientX - centerX;
4018
+ const positionY = clientY - centerY;
4019
+ // Angle in [0, 2π) measured clockwise from 12 o'clock
4020
+ const angle = Math.atan2(-positionX, positionY) + Math.PI;
4021
+ const steps = selectionIsHours ? CLOCK_HOURS : CLOCK_MINUTES;
4022
+ // Modulo keeps the last half step before 12 o'clock as 0, not as 60/12
4023
+ selectValue(Math.round(angle / radianUnit) % steps);
4024
+ }, [selectionIsHours, radianUnit, selectValue]);
3919
4025
  const onClickHour = useCallback(() => {
3920
4026
  setSelectionIsHours(true);
3921
4027
  }, []);
@@ -3928,49 +4034,56 @@ function RlsPickerClockComponent({ formControl, onListener, rlsTheme, time }) {
3928
4034
  const onClickPM = useCallback(() => {
3929
4035
  setZoneIsPM(true);
3930
4036
  }, []);
3931
- const onActiveSelection = useCallback(() => {
4037
+ const onPointerDown = useCallback((event) => {
4038
+ event.preventDefault();
4039
+ event.currentTarget.setPointerCapture(event.pointerId);
3932
4040
  selectionIsActive.current = true;
3933
- }, []);
3934
- const onMouseSelection = useCallback((event) => {
4041
+ const tick = event.target.closest('.rls-picker-clock__tick');
4042
+ // Pressing inside a label circle snaps to its exact value,
4043
+ // anywhere else (and while dragging) the angle decides
4044
+ if (tick?.dataset.value && pointerIsInsideTick(event, tick)) {
4045
+ selectValue(Number(tick.dataset.value));
4046
+ }
4047
+ else {
4048
+ selectFromPosition(event.clientX, event.clientY);
4049
+ }
4050
+ }, [selectValue, selectFromPosition]);
4051
+ const onPointerMove = useCallback((event) => {
3935
4052
  if (selectionIsActive.current) {
3936
- event.preventDefault();
3937
- refreshComponent(event.clientX, event.clientY);
4053
+ selectFromPosition(event.clientX, event.clientY);
3938
4054
  }
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);
4055
+ }, [selectFromPosition]);
4056
+ const onPointerUp = useCallback(() => {
4057
+ if (!selectionIsActive.current) {
4058
+ return;
3944
4059
  }
3945
- }, [refreshComponent]);
3946
- const onInactiveSelection = useCallback(() => {
3947
4060
  selectionIsActive.current = false;
3948
- }, []);
3949
- const onClickValue = useCallback((value) => {
4061
+ // Once the hour is chosen, continue with the minutes
3950
4062
  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);
4063
+ setSelectionIsHours(false);
3958
4064
  }
3959
4065
  }, [selectionIsHours]);
4066
+ const onPointerCancel = useCallback(() => {
4067
+ selectionIsActive.current = false;
4068
+ }, []);
3960
4069
  const onCancel = useCallback(() => {
3961
4070
  onListener?.({ event: PickerListenerEvent.Cancel });
3962
4071
  }, [onListener]);
3963
4072
  const onCurrentTime = useCallback(() => {
3964
4073
  const currentTime = Time.now();
4074
+ const zoneIsPM = currentTime.hour >= 12;
4075
+ const hour = zoneIsPM ? currentTime.hour - 12 : currentTime.hour;
3965
4076
  changeIsInternal.current = true;
3966
4077
  formControl?.setValue(currentTime);
3967
- setHour(currentTime.hour);
4078
+ setZoneIsPM(zoneIsPM);
4079
+ setHour(hour);
3968
4080
  setMinute(currentTime.minute);
4081
+ refreshClock(selectionIsHours ? hour : currentTime.minute);
3969
4082
  onListener?.({
3970
4083
  event: PickerListenerEvent.Select,
3971
4084
  value: currentTime
3972
4085
  });
3973
- }, [formControl, onListener]);
4086
+ }, [formControl, onListener, selectionIsHours, refreshClock]);
3974
4087
  const onSelect = useCallback(() => {
3975
4088
  const hourValue = zoneIsPM
3976
4089
  ? hour !== 12
@@ -3987,10 +4100,10 @@ function RlsPickerClockComponent({ formControl, onListener, rlsTheme, time }) {
3987
4100
  value: timeValue
3988
4101
  });
3989
4102
  }, [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: {
4103
+ 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
4104
  transform: `translate(${DIAL_RADIUS}rem, ${DIAL_RADIUS}rem)`
3992
4105
  }, 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));
4106
+ return (jsxRuntimeExports.jsx(RlsPickerClockTick, { value: value, selectionIsHours: selectionIsHours }, value));
3994
4107
  }) })] }) }), 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
4108
  }
3996
4109
  const RlsPickerClock = memo(RlsPickerClockComponent);
@@ -4607,7 +4720,9 @@ function RlsFieldListInner({ render, suggestions, action, children, formControl,
4607
4720
  readonly: props.readOnly
4608
4721
  }, `rls-field-list rls-field-list__multi ${props.className ?? ''}`);
4609
4722
  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 })] }));
4723
+ 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
4724
+ ? fieldList.onRemoveElement(item)
4725
+ : 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
4726
  }
4612
4727
  function RlsFieldListTemplateComponent(props) {
4613
4728
  const fieldList = useFieldList(props);
@@ -4802,10 +4917,6 @@ function calculateImgDimension(image, dimension) {
4802
4917
  }
4803
4918
  function RlsImageEditorComponent(props) {
4804
4919
  const [selection, setSelection] = useState(props.selection ?? 60);
4805
- const [labels, setLabels] = useState({
4806
- actionRestore: reactI18n('editorImageActionRestore'),
4807
- actionSelect: reactI18n('editorImageActionSelect')
4808
- });
4809
4920
  const refBody = useRef(null);
4810
4921
  const refImage = useRef(null);
4811
4922
  const refSelection = useRef(null);
@@ -4930,16 +5041,9 @@ function RlsImageEditorComponent(props) {
4930
5041
  refreshImageStyle();
4931
5042
  refreshSelectionStyle(selection);
4932
5043
  };
4933
- const unsubscription = i18nSubscribe(() => {
4934
- setLabels({
4935
- actionRestore: reactI18n('editorImageActionRestore'),
4936
- actionSelect: reactI18n('editorImageActionSelect')
4937
- });
4938
- });
4939
5044
  window.addEventListener('resize', refreshImageStyle);
4940
5045
  return () => {
4941
5046
  window.removeEventListener('resize', refreshImageStyle);
4942
- unsubscription();
4943
5047
  };
4944
5048
  }, []);
4945
5049
  useEffect(() => {
@@ -5002,7 +5106,7 @@ function RlsImageEditorComponent(props) {
5002
5106
  context?.putImageData(originalImage.current, 0, 0);
5003
5107
  }
5004
5108
  }, []);
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 })] }));
5109
+ 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
5110
  }
5007
5111
  const RlsImageEditor = memo(RlsImageEditorComponent);
5008
5112
 
@@ -5060,7 +5164,7 @@ function useImageEditorController(options) {
5060
5164
  setSrcEditor(undefined);
5061
5165
  }, []);
5062
5166
  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 }) })));
5167
+ 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
5168
  }, [
5065
5169
  srcEditor,
5066
5170
  labels,
@@ -5096,6 +5200,46 @@ function RlsImageChooserComponent(props) {
5096
5200
  }
5097
5201
  const RlsImageChooser = memo(RlsImageChooserComponent);
5098
5202
 
5203
+ function RlsLedColorComponent({ className, color, disabled: disabledProps, formControl, identifier, onValue, readOnly, rlsTheme, value: valueInitial }) {
5204
+ const [value, setValue] = useState(formControl?.value ?? valueInitial);
5205
+ const [modalIsVisible, setModalIsVisible] = useState(false);
5206
+ const [pickerKey, setPickerKey] = useState(0);
5207
+ const colorValue = useMemo(() => {
5208
+ return formControl ? formControl.value : value;
5209
+ }, [formControl?.value, value]);
5210
+ const disabled = useMemo(() => {
5211
+ return formControl?.disabled || disabledProps;
5212
+ }, [formControl?.disabled, disabledProps]);
5213
+ const ledColor = useMemo(() => {
5214
+ return colorValue && hexIsValid(colorValue)
5215
+ ? normalizeHex(colorValue)
5216
+ : undefined;
5217
+ }, [colorValue]);
5218
+ const classNameLed = renderClassStatus('rls-led-color', { disabled, error: formControl?.wrong, readonly: readOnly }, className);
5219
+ const onChange = useCallback((value) => {
5220
+ setValue(value);
5221
+ onValue?.(value);
5222
+ }, [onValue]);
5223
+ const onClickLed = useCallback(() => {
5224
+ if (!disabled && !readOnly) {
5225
+ setPickerKey((key) => key + 1);
5226
+ setModalIsVisible(true);
5227
+ }
5228
+ }, [disabled, readOnly]);
5229
+ const onListener = useCallback(({ event, value }) => {
5230
+ if (event !== PickerListenerEvent.Cancel) {
5231
+ onChange(value);
5232
+ }
5233
+ formControl?.touch();
5234
+ setModalIsVisible(false);
5235
+ }, [formControl, onChange]);
5236
+ const onBackdrop = useCallback(() => {
5237
+ setModalIsVisible(false);
5238
+ }, []);
5239
+ 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) })] }));
5240
+ }
5241
+ const RlsLedColor = memo(RlsLedColorComponent);
5242
+
5099
5243
  function RlsModalSheetComponent({ autoclose, children, className, controller, onAutoClose, visible, rlsTheme }) {
5100
5244
  const classNameModal = renderClassStatus('rls-modal-sheet', { visible: controller?.visible ?? visible }, className);
5101
5245
  const onClickBackdrop = useCallback(() => {
@@ -5428,5 +5572,5 @@ function useTabsController(options) {
5428
5572
  return useMemo(() => ({ Tabs, formControl }), [Tabs, formControl]);
5429
5573
  }
5430
5574
 
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 };
5575
+ 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, generateThemeAlias, generateThemePalette, getAppTheme, getRemSize$1 as getRemSize, hexIsValid, hexToHsl, hexToHsv, hexToRgb, hslToHex, hsvToHex, hsvToRgb, normalizeHex, rangeFormatTemplate, renderClassStatus, resetTheme, rgbToHex, rgbToHsl, rgbToHsv, setAppTheme, setDesignSystem, setErrorsI18n, setThemeAlias, setThemeColor, toggleAppTheme, useAppThemeController, useConfirmation, useDatatable, useDesingSystemController, useDropdownController, useEventCallback, useFieldAutocomplete, useFieldList, useFieldSelect, useFormSingleSelectionController, useFormToggleController, useImageEditorController, useListController, useNotifications, usePortalController, useRelocationOnComponent, useResize, useRlsContext, useSnackbar, useTabsController };
5432
5576
  //# sourceMappingURL=index.mjs.map