@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.
- package/dist/cjs/index.cjs +218 -68
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/es/index.mjs +213 -69
- 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/helpers/color.d.ts +12 -0
- package/dist/esm/helpers/color.js +64 -1
- package/dist/esm/helpers/color.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
|
|
@@ -1247,13 +1253,18 @@ function generateThemeCSS(colors, theme) {
|
|
|
1247
1253
|
const rgb900 = rgbChannels(parseHex(colors['900']));
|
|
1248
1254
|
const rgb700 = rgbChannels(parseHex(colors['700']));
|
|
1249
1255
|
const rgb500 = rgbChannels(parseHex(colors['500']));
|
|
1256
|
+
const rgb300 = rgbChannels(parseHex(colors['300']));
|
|
1250
1257
|
const colorProps = SHADE_LABELS.map((label) => prop(`color-${label}`, colors[label]));
|
|
1251
1258
|
const gradientProps = GRADIENT_LABELS.map((label) => {
|
|
1252
1259
|
const darker = SHADE_LABELS[SHADE_LABELS.indexOf(label) - 1];
|
|
1253
1260
|
return prop(`gradient-${label}`, `linear-gradient(180deg, ${colors[label]} 15%, ${colors[darker]} 85%)`);
|
|
1254
1261
|
});
|
|
1255
1262
|
const backdropProps = BACKDROP_LABELS.map((label) => prop(`backdrop-${label}`, `rgba(${rgb900}, ${Number(label) / 1000})`));
|
|
1256
|
-
const
|
|
1263
|
+
const skeletonOpacities = Object.entries(SKELETON_OPACITY);
|
|
1264
|
+
const skeletonProps = skeletonOpacities.map(([label, opacity]) => prop(`skeleton-${label}`, `rgba(${rgb700}, ${opacity})`));
|
|
1265
|
+
// Skeleton tokens for dark surfaces, taken from the light step that mirrors
|
|
1266
|
+
// color-700 around color-500, as the foundations mixin does.
|
|
1267
|
+
const skeletonDarkProps = skeletonOpacities.map(([label, opacity]) => prop(`skeleton-dark-${label}`, `rgba(${rgb300}, ${opacity})`));
|
|
1257
1268
|
const shadowProps = [
|
|
1258
1269
|
prop('shadow-color-500', `rgba(${rgb500}, 0.24)`),
|
|
1259
1270
|
prop('shadow-500', `0px 0px 0px 3px rgba(${rgb500}, 0.24)`)
|
|
@@ -1263,6 +1274,7 @@ function generateThemeCSS(colors, theme) {
|
|
|
1263
1274
|
...gradientProps,
|
|
1264
1275
|
...backdropProps,
|
|
1265
1276
|
...skeletonProps,
|
|
1277
|
+
...skeletonDarkProps,
|
|
1266
1278
|
...shadowProps
|
|
1267
1279
|
];
|
|
1268
1280
|
}
|
|
@@ -1332,12 +1344,69 @@ function setThemeColor(baseColor, theme = 'primary') {
|
|
|
1332
1344
|
if (typeof document === 'undefined') {
|
|
1333
1345
|
return;
|
|
1334
1346
|
}
|
|
1347
|
+
resetTheme(theme);
|
|
1335
1348
|
const { properties } = generateThemePalette(baseColor, theme);
|
|
1336
1349
|
const target = document.body || document.documentElement;
|
|
1337
1350
|
properties.forEach(({ name, value }) => {
|
|
1338
1351
|
target.style.setProperty(name, value);
|
|
1339
1352
|
});
|
|
1340
1353
|
}
|
|
1354
|
+
const ALIAS_LABELS = [
|
|
1355
|
+
'900',
|
|
1356
|
+
'800',
|
|
1357
|
+
'700',
|
|
1358
|
+
'600',
|
|
1359
|
+
'500',
|
|
1360
|
+
'400',
|
|
1361
|
+
'300',
|
|
1362
|
+
'200',
|
|
1363
|
+
'100'
|
|
1364
|
+
];
|
|
1365
|
+
const SKELETON_LABELS = Object.keys(SKELETON_OPACITY);
|
|
1366
|
+
const ALIAS_TOKENS = [
|
|
1367
|
+
...SHADE_LABELS.map((label) => `color-${label}`),
|
|
1368
|
+
...ALIAS_LABELS.map((label) => `gradient-${label}`),
|
|
1369
|
+
...ALIAS_LABELS.map((label) => `backdrop-${label}`),
|
|
1370
|
+
...SKELETON_LABELS.map((label) => `skeleton-${label}`),
|
|
1371
|
+
...SKELETON_LABELS.map((label) => `skeleton-dark-${label}`),
|
|
1372
|
+
'shadow-color-500',
|
|
1373
|
+
'shadow-500'
|
|
1374
|
+
];
|
|
1375
|
+
function resetTheme(theme = 'primary') {
|
|
1376
|
+
if (typeof document === 'undefined') {
|
|
1377
|
+
return;
|
|
1378
|
+
}
|
|
1379
|
+
const target = document.body || document.documentElement;
|
|
1380
|
+
ALIAS_TOKENS.forEach((token) => {
|
|
1381
|
+
target.style.removeProperty(`--rls-${theme}-${token}`);
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
function generateThemeAlias(source, theme = 'primary') {
|
|
1385
|
+
const properties = ALIAS_TOKENS.map((token) => ({
|
|
1386
|
+
name: `--rls-${theme}-${token}`,
|
|
1387
|
+
value: `var(--rls-${source}-${token})`
|
|
1388
|
+
}));
|
|
1389
|
+
return {
|
|
1390
|
+
source,
|
|
1391
|
+
theme,
|
|
1392
|
+
properties,
|
|
1393
|
+
css: properties.map((p) => `${p.name}: ${p.value};`).join('\n')
|
|
1394
|
+
};
|
|
1395
|
+
}
|
|
1396
|
+
function setThemeAlias(source, theme = 'primary') {
|
|
1397
|
+
if (typeof document === 'undefined') {
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1400
|
+
if (source === theme) {
|
|
1401
|
+
resetTheme(theme);
|
|
1402
|
+
return;
|
|
1403
|
+
}
|
|
1404
|
+
const { properties } = generateThemeAlias(source, theme);
|
|
1405
|
+
const target = document.body || document.documentElement;
|
|
1406
|
+
properties.forEach(({ name, value }) => {
|
|
1407
|
+
target.style.setProperty(name, value);
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1341
1410
|
const DEFAULT_COLOR = '#1780e0';
|
|
1342
1411
|
|
|
1343
1412
|
const CONTENT_BACKGROUND = '--pvt-content-background';
|
|
@@ -1671,6 +1740,36 @@ function RlsButtonToggleComponent({ onAction, options, type, automatic, disabled
|
|
|
1671
1740
|
}
|
|
1672
1741
|
const RlsButtonToggle = require$$0.memo(RlsButtonToggleComponent);
|
|
1673
1742
|
|
|
1743
|
+
function RlsChipGroupComponent({ className, disabled: disabledProps, formControl, identifier, onValue, options, reference, render, rlsTheme, value: valueInitial }) {
|
|
1744
|
+
const [value, setValue] = require$$0.useState(formControl?.value ?? valueInitial);
|
|
1745
|
+
const selected = require$$0.useMemo(() => {
|
|
1746
|
+
return formControl ? formControl.value : value;
|
|
1747
|
+
}, [formControl?.value, value]);
|
|
1748
|
+
const disabled = require$$0.useMemo(() => {
|
|
1749
|
+
return formControl?.disabled || disabledProps;
|
|
1750
|
+
}, [formControl?.disabled, disabledProps]);
|
|
1751
|
+
const classNameGroup = renderClassStatus('rls-chip-group', { disabled }, className);
|
|
1752
|
+
const isSelected = require$$0.useCallback((option) => {
|
|
1753
|
+
if (selected === undefined || selected === null) {
|
|
1754
|
+
return false;
|
|
1755
|
+
}
|
|
1756
|
+
return reference
|
|
1757
|
+
? reference(option) === reference(selected)
|
|
1758
|
+
: option === selected;
|
|
1759
|
+
}, [reference, selected]);
|
|
1760
|
+
const onSelect = require$$0.useCallback((option) => () => {
|
|
1761
|
+
if (disabled) {
|
|
1762
|
+
return;
|
|
1763
|
+
}
|
|
1764
|
+
setValue(option);
|
|
1765
|
+
formControl?.setValue(option);
|
|
1766
|
+
formControl?.touch();
|
|
1767
|
+
onValue?.(option);
|
|
1768
|
+
}, [disabled, formControl, onValue]);
|
|
1769
|
+
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))) }));
|
|
1770
|
+
}
|
|
1771
|
+
const RlsChipGroup = require$$0.memo(RlsChipGroupComponent);
|
|
1772
|
+
|
|
1674
1773
|
function RlsContentComponent({ children, identifier, rlsTheme }) {
|
|
1675
1774
|
return (jsxRuntimeExports.jsx("div", { id: identifier, className: "rls-app__page__content", "rls-theme": rlsTheme, children: children }));
|
|
1676
1775
|
}
|
|
@@ -3787,11 +3886,20 @@ const RlsModal = require$$0.memo(RlsModalComponent);
|
|
|
3787
3886
|
function formatTime(value) {
|
|
3788
3887
|
return String(value).padStart(2, '0');
|
|
3789
3888
|
}
|
|
3889
|
+
function pointerIsInsideTick({ clientX, clientY }, tick) {
|
|
3890
|
+
const { left, top, width, height } = tick.getBoundingClientRect();
|
|
3891
|
+
const distanceX = clientX - (left + width / 2);
|
|
3892
|
+
const distanceY = clientY - (top + height / 2);
|
|
3893
|
+
const radius = Math.min(width, height) / 2;
|
|
3894
|
+
return distanceX ** 2 + distanceY ** 2 <= radius ** 2;
|
|
3895
|
+
}
|
|
3790
3896
|
const CLOCK_VALUES = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
|
3897
|
+
const CLOCK_HOURS = 12;
|
|
3898
|
+
const CLOCK_MINUTES = 60;
|
|
3791
3899
|
const RADIUS = 48;
|
|
3792
3900
|
const DIAL_RADIUS = 60;
|
|
3793
3901
|
const TICK_RADIUS = 7;
|
|
3794
|
-
function RlsPickerClockTick({
|
|
3902
|
+
function RlsPickerClockTick({ selectionIsHours, value }) {
|
|
3795
3903
|
const styleTick = require$$0.useMemo(() => {
|
|
3796
3904
|
const radian = (value / 6) * Math.PI;
|
|
3797
3905
|
const x = Math.sin(radian) * RADIUS;
|
|
@@ -3801,20 +3909,13 @@ function RlsPickerClockTick({ onValue, selectionIsHours, value }) {
|
|
|
3801
3909
|
top: `${DIAL_RADIUS - y - TICK_RADIUS - 1}rem`
|
|
3802
3910
|
};
|
|
3803
3911
|
}, []);
|
|
3804
|
-
const
|
|
3912
|
+
const tickValue = require$$0.useMemo(() => {
|
|
3805
3913
|
if (selectionIsHours) {
|
|
3806
|
-
return
|
|
3914
|
+
return value;
|
|
3807
3915
|
}
|
|
3808
|
-
|
|
3809
|
-
return formatTime(0);
|
|
3810
|
-
}
|
|
3811
|
-
return formatTime(value * 5);
|
|
3916
|
+
return value === CLOCK_HOURS ? 0 : value * 5;
|
|
3812
3917
|
}, [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 }));
|
|
3918
|
+
return (jsxRuntimeExports.jsx("div", { className: "rls-picker-clock__tick", style: styleTick, "data-value": tickValue, children: formatTime(tickValue) }));
|
|
3818
3919
|
}
|
|
3819
3920
|
function RlsPickerClockComponent({ formControl, onListener, rlsTheme, time }) {
|
|
3820
3921
|
const timeInitial = require$$0.useMemo(() => {
|
|
@@ -3887,22 +3988,6 @@ function RlsPickerClockComponent({ formControl, onListener, rlsTheme, time }) {
|
|
|
3887
3988
|
}
|
|
3888
3989
|
changeIsInternal.current = false;
|
|
3889
3990
|
}, [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
3991
|
const refreshClock = require$$0.useCallback((value) => {
|
|
3907
3992
|
const angle = value * radianUnit;
|
|
3908
3993
|
const x2 = Math.sin(angle) * (RADIUS - TICK_RADIUS);
|
|
@@ -3918,6 +4003,27 @@ function RlsPickerClockComponent({ formControl, onListener, rlsTheme, time }) {
|
|
|
3918
4003
|
pointElement.current.style.visibility =
|
|
3919
4004
|
selectionIsHours || value % 5 === 0 ? 'hidden' : 'visible';
|
|
3920
4005
|
}, [selectionIsHours, radianUnit]);
|
|
4006
|
+
const selectValue = require$$0.useCallback((value) => {
|
|
4007
|
+
refreshClock(value);
|
|
4008
|
+
if (selectionIsHours) {
|
|
4009
|
+
setHour(value === 0 ? CLOCK_HOURS : value);
|
|
4010
|
+
}
|
|
4011
|
+
else {
|
|
4012
|
+
setMinute(value);
|
|
4013
|
+
}
|
|
4014
|
+
}, [selectionIsHours, refreshClock]);
|
|
4015
|
+
const selectFromPosition = require$$0.useCallback((clientX, clientY) => {
|
|
4016
|
+
const rectangle = plateElement.current.getBoundingClientRect();
|
|
4017
|
+
const centerX = rectangle.left + rectangle.width / 2;
|
|
4018
|
+
const centerY = rectangle.top + rectangle.height / 2;
|
|
4019
|
+
const positionX = clientX - centerX;
|
|
4020
|
+
const positionY = clientY - centerY;
|
|
4021
|
+
// Angle in [0, 2π) measured clockwise from 12 o'clock
|
|
4022
|
+
const angle = Math.atan2(-positionX, positionY) + Math.PI;
|
|
4023
|
+
const steps = selectionIsHours ? CLOCK_HOURS : CLOCK_MINUTES;
|
|
4024
|
+
// Modulo keeps the last half step before 12 o'clock as 0, not as 60/12
|
|
4025
|
+
selectValue(Math.round(angle / radianUnit) % steps);
|
|
4026
|
+
}, [selectionIsHours, radianUnit, selectValue]);
|
|
3921
4027
|
const onClickHour = require$$0.useCallback(() => {
|
|
3922
4028
|
setSelectionIsHours(true);
|
|
3923
4029
|
}, []);
|
|
@@ -3930,49 +4036,56 @@ function RlsPickerClockComponent({ formControl, onListener, rlsTheme, time }) {
|
|
|
3930
4036
|
const onClickPM = require$$0.useCallback(() => {
|
|
3931
4037
|
setZoneIsPM(true);
|
|
3932
4038
|
}, []);
|
|
3933
|
-
const
|
|
4039
|
+
const onPointerDown = require$$0.useCallback((event) => {
|
|
4040
|
+
event.preventDefault();
|
|
4041
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
3934
4042
|
selectionIsActive.current = true;
|
|
3935
|
-
|
|
3936
|
-
|
|
4043
|
+
const tick = event.target.closest('.rls-picker-clock__tick');
|
|
4044
|
+
// Pressing inside a label circle snaps to its exact value,
|
|
4045
|
+
// anywhere else (and while dragging) the angle decides
|
|
4046
|
+
if (tick?.dataset.value && pointerIsInsideTick(event, tick)) {
|
|
4047
|
+
selectValue(Number(tick.dataset.value));
|
|
4048
|
+
}
|
|
4049
|
+
else {
|
|
4050
|
+
selectFromPosition(event.clientX, event.clientY);
|
|
4051
|
+
}
|
|
4052
|
+
}, [selectValue, selectFromPosition]);
|
|
4053
|
+
const onPointerMove = require$$0.useCallback((event) => {
|
|
3937
4054
|
if (selectionIsActive.current) {
|
|
3938
|
-
event.
|
|
3939
|
-
refreshComponent(event.clientX, event.clientY);
|
|
4055
|
+
selectFromPosition(event.clientX, event.clientY);
|
|
3940
4056
|
}
|
|
3941
|
-
}, [
|
|
3942
|
-
const
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
refreshComponent(touch.clientX, touch.clientY);
|
|
4057
|
+
}, [selectFromPosition]);
|
|
4058
|
+
const onPointerUp = require$$0.useCallback(() => {
|
|
4059
|
+
if (!selectionIsActive.current) {
|
|
4060
|
+
return;
|
|
3946
4061
|
}
|
|
3947
|
-
}, [refreshComponent]);
|
|
3948
|
-
const onInactiveSelection = require$$0.useCallback(() => {
|
|
3949
4062
|
selectionIsActive.current = false;
|
|
3950
|
-
|
|
3951
|
-
const onClickValue = require$$0.useCallback((value) => {
|
|
4063
|
+
// Once the hour is chosen, continue with the minutes
|
|
3952
4064
|
if (selectionIsHours) {
|
|
3953
|
-
|
|
3954
|
-
refreshClock(value);
|
|
3955
|
-
}
|
|
3956
|
-
else {
|
|
3957
|
-
const minute = value === 12 ? 0 : value * 5;
|
|
3958
|
-
setMinute(minute);
|
|
3959
|
-
refreshClock(minute);
|
|
4065
|
+
setSelectionIsHours(false);
|
|
3960
4066
|
}
|
|
3961
4067
|
}, [selectionIsHours]);
|
|
4068
|
+
const onPointerCancel = require$$0.useCallback(() => {
|
|
4069
|
+
selectionIsActive.current = false;
|
|
4070
|
+
}, []);
|
|
3962
4071
|
const onCancel = require$$0.useCallback(() => {
|
|
3963
4072
|
onListener?.({ event: components.PickerListenerEvent.Cancel });
|
|
3964
4073
|
}, [onListener]);
|
|
3965
4074
|
const onCurrentTime = require$$0.useCallback(() => {
|
|
3966
4075
|
const currentTime = dates.Time.now();
|
|
4076
|
+
const zoneIsPM = currentTime.hour >= 12;
|
|
4077
|
+
const hour = zoneIsPM ? currentTime.hour - 12 : currentTime.hour;
|
|
3967
4078
|
changeIsInternal.current = true;
|
|
3968
4079
|
formControl?.setValue(currentTime);
|
|
3969
|
-
|
|
4080
|
+
setZoneIsPM(zoneIsPM);
|
|
4081
|
+
setHour(hour);
|
|
3970
4082
|
setMinute(currentTime.minute);
|
|
4083
|
+
refreshClock(selectionIsHours ? hour : currentTime.minute);
|
|
3971
4084
|
onListener?.({
|
|
3972
4085
|
event: components.PickerListenerEvent.Select,
|
|
3973
4086
|
value: currentTime
|
|
3974
4087
|
});
|
|
3975
|
-
}, [formControl, onListener]);
|
|
4088
|
+
}, [formControl, onListener, selectionIsHours, refreshClock]);
|
|
3976
4089
|
const onSelect = require$$0.useCallback(() => {
|
|
3977
4090
|
const hourValue = zoneIsPM
|
|
3978
4091
|
? hour !== 12
|
|
@@ -3989,10 +4102,10 @@ function RlsPickerClockComponent({ formControl, onListener, rlsTheme, time }) {
|
|
|
3989
4102
|
value: timeValue
|
|
3990
4103
|
});
|
|
3991
4104
|
}, [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,
|
|
4105
|
+
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
4106
|
transform: `translate(${DIAL_RADIUS}rem, ${DIAL_RADIUS}rem)`
|
|
3994
4107
|
}, 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
|
|
4108
|
+
return (jsxRuntimeExports.jsx(RlsPickerClockTick, { value: value, selectionIsHours: selectionIsHours }, value));
|
|
3996
4109
|
}) })] }) }), 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
4110
|
}
|
|
3998
4111
|
const RlsPickerClock = require$$0.memo(RlsPickerClockComponent);
|
|
@@ -4609,7 +4722,9 @@ function RlsFieldListInner({ render, suggestions, action, children, formControl,
|
|
|
4609
4722
|
readonly: props.readOnly
|
|
4610
4723
|
}, `rls-field-list rls-field-list__multi ${props.className ?? ''}`);
|
|
4611
4724
|
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.
|
|
4725
|
+
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
|
|
4726
|
+
? fieldList.onRemoveElement(item)
|
|
4727
|
+
: 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
4728
|
}
|
|
4614
4729
|
function RlsFieldListTemplateComponent(props) {
|
|
4615
4730
|
const fieldList = useFieldList(props);
|
|
@@ -4804,10 +4919,6 @@ function calculateImgDimension(image, dimension) {
|
|
|
4804
4919
|
}
|
|
4805
4920
|
function RlsImageEditorComponent(props) {
|
|
4806
4921
|
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
4922
|
const refBody = require$$0.useRef(null);
|
|
4812
4923
|
const refImage = require$$0.useRef(null);
|
|
4813
4924
|
const refSelection = require$$0.useRef(null);
|
|
@@ -4932,16 +5043,9 @@ function RlsImageEditorComponent(props) {
|
|
|
4932
5043
|
refreshImageStyle();
|
|
4933
5044
|
refreshSelectionStyle(selection);
|
|
4934
5045
|
};
|
|
4935
|
-
const unsubscription = i18n.i18nSubscribe(() => {
|
|
4936
|
-
setLabels({
|
|
4937
|
-
actionRestore: reactI18n('editorImageActionRestore'),
|
|
4938
|
-
actionSelect: reactI18n('editorImageActionSelect')
|
|
4939
|
-
});
|
|
4940
|
-
});
|
|
4941
5046
|
window.addEventListener('resize', refreshImageStyle);
|
|
4942
5047
|
return () => {
|
|
4943
5048
|
window.removeEventListener('resize', refreshImageStyle);
|
|
4944
|
-
unsubscription();
|
|
4945
5049
|
};
|
|
4946
5050
|
}, []);
|
|
4947
5051
|
require$$0.useEffect(() => {
|
|
@@ -5004,7 +5108,7 @@ function RlsImageEditorComponent(props) {
|
|
|
5004
5108
|
context?.putImageData(originalImage.current, 0, 0);
|
|
5005
5109
|
}
|
|
5006
5110
|
}, []);
|
|
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: "
|
|
5111
|
+
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
5112
|
}
|
|
5009
5113
|
const RlsImageEditor = require$$0.memo(RlsImageEditorComponent);
|
|
5010
5114
|
|
|
@@ -5062,7 +5166,7 @@ function useImageEditorController(options) {
|
|
|
5062
5166
|
setSrcEditor(undefined);
|
|
5063
5167
|
}, []);
|
|
5064
5168
|
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(
|
|
5169
|
+
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
5170
|
}, [
|
|
5067
5171
|
srcEditor,
|
|
5068
5172
|
labels,
|
|
@@ -5098,6 +5202,46 @@ function RlsImageChooserComponent(props) {
|
|
|
5098
5202
|
}
|
|
5099
5203
|
const RlsImageChooser = require$$0.memo(RlsImageChooserComponent);
|
|
5100
5204
|
|
|
5205
|
+
function RlsLedColorComponent({ className, color, disabled: disabledProps, formControl, identifier, onValue, readOnly, rlsTheme, value: valueInitial }) {
|
|
5206
|
+
const [value, setValue] = require$$0.useState(formControl?.value ?? valueInitial);
|
|
5207
|
+
const [modalIsVisible, setModalIsVisible] = require$$0.useState(false);
|
|
5208
|
+
const [pickerKey, setPickerKey] = require$$0.useState(0);
|
|
5209
|
+
const colorValue = require$$0.useMemo(() => {
|
|
5210
|
+
return formControl ? formControl.value : value;
|
|
5211
|
+
}, [formControl?.value, value]);
|
|
5212
|
+
const disabled = require$$0.useMemo(() => {
|
|
5213
|
+
return formControl?.disabled || disabledProps;
|
|
5214
|
+
}, [formControl?.disabled, disabledProps]);
|
|
5215
|
+
const ledColor = require$$0.useMemo(() => {
|
|
5216
|
+
return colorValue && hexIsValid(colorValue)
|
|
5217
|
+
? normalizeHex(colorValue)
|
|
5218
|
+
: undefined;
|
|
5219
|
+
}, [colorValue]);
|
|
5220
|
+
const classNameLed = renderClassStatus('rls-led-color', { disabled, error: formControl?.wrong, readonly: readOnly }, className);
|
|
5221
|
+
const onChange = require$$0.useCallback((value) => {
|
|
5222
|
+
setValue(value);
|
|
5223
|
+
onValue?.(value);
|
|
5224
|
+
}, [onValue]);
|
|
5225
|
+
const onClickLed = require$$0.useCallback(() => {
|
|
5226
|
+
if (!disabled && !readOnly) {
|
|
5227
|
+
setPickerKey((key) => key + 1);
|
|
5228
|
+
setModalIsVisible(true);
|
|
5229
|
+
}
|
|
5230
|
+
}, [disabled, readOnly]);
|
|
5231
|
+
const onListener = require$$0.useCallback(({ event, value }) => {
|
|
5232
|
+
if (event !== components.PickerListenerEvent.Cancel) {
|
|
5233
|
+
onChange(value);
|
|
5234
|
+
}
|
|
5235
|
+
formControl?.touch();
|
|
5236
|
+
setModalIsVisible(false);
|
|
5237
|
+
}, [formControl, onChange]);
|
|
5238
|
+
const onBackdrop = require$$0.useCallback(() => {
|
|
5239
|
+
setModalIsVisible(false);
|
|
5240
|
+
}, []);
|
|
5241
|
+
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) })] }));
|
|
5242
|
+
}
|
|
5243
|
+
const RlsLedColor = require$$0.memo(RlsLedColorComponent);
|
|
5244
|
+
|
|
5101
5245
|
function RlsModalSheetComponent({ autoclose, children, className, controller, onAutoClose, visible, rlsTheme }) {
|
|
5102
5246
|
const classNameModal = renderClassStatus('rls-modal-sheet', { visible: controller?.visible ?? visible }, className);
|
|
5103
5247
|
const onClickBackdrop = require$$0.useCallback(() => {
|
|
@@ -5455,6 +5599,8 @@ exports.RlsButtonToggle = RlsButtonToggle;
|
|
|
5455
5599
|
exports.RlsCard = RlsCard;
|
|
5456
5600
|
exports.RlsCheckBox = RlsCheckBox;
|
|
5457
5601
|
exports.RlsCheckBoxControl = RlsCheckBoxControl;
|
|
5602
|
+
exports.RlsChip = RlsChip;
|
|
5603
|
+
exports.RlsChipGroup = RlsChipGroup;
|
|
5458
5604
|
exports.RlsChooserAutocomplete = RlsChooserAutocomplete;
|
|
5459
5605
|
exports.RlsChooserAutocompleteTemplate = RlsChooserAutocompleteTemplate;
|
|
5460
5606
|
exports.RlsChooserList = RlsChooserList;
|
|
@@ -5514,6 +5660,7 @@ exports.RlsLabelCheckBox = RlsLabelCheckBox;
|
|
|
5514
5660
|
exports.RlsLabelRadioButton = RlsLabelRadioButton;
|
|
5515
5661
|
exports.RlsLabelSwitch = RlsLabelSwitch;
|
|
5516
5662
|
exports.RlsLed = RlsLed;
|
|
5663
|
+
exports.RlsLedColor = RlsLedColor;
|
|
5517
5664
|
exports.RlsMessageEmpty = RlsMessageEmpty;
|
|
5518
5665
|
exports.RlsMessageFormError = RlsMessageFormError;
|
|
5519
5666
|
exports.RlsMessageIcon = RlsMessageIcon;
|
|
@@ -5549,6 +5696,7 @@ exports.RlsTabs = RlsTabs;
|
|
|
5549
5696
|
exports.RlsTabularText = RlsTabularText;
|
|
5550
5697
|
exports.RlsToolbar = RlsToolbar;
|
|
5551
5698
|
exports.calculateImgDimension = calculateImgDimension;
|
|
5699
|
+
exports.generateThemeAlias = generateThemeAlias;
|
|
5552
5700
|
exports.generateThemePalette = generateThemePalette;
|
|
5553
5701
|
exports.getAppTheme = getAppTheme;
|
|
5554
5702
|
exports.getRemSize = getRemSize$1;
|
|
@@ -5562,12 +5710,14 @@ exports.hsvToRgb = hsvToRgb;
|
|
|
5562
5710
|
exports.normalizeHex = normalizeHex;
|
|
5563
5711
|
exports.rangeFormatTemplate = rangeFormatTemplate;
|
|
5564
5712
|
exports.renderClassStatus = renderClassStatus;
|
|
5713
|
+
exports.resetTheme = resetTheme;
|
|
5565
5714
|
exports.rgbToHex = rgbToHex;
|
|
5566
5715
|
exports.rgbToHsl = rgbToHsl;
|
|
5567
5716
|
exports.rgbToHsv = rgbToHsv;
|
|
5568
5717
|
exports.setAppTheme = setAppTheme;
|
|
5569
5718
|
exports.setDesignSystem = setDesignSystem;
|
|
5570
5719
|
exports.setErrorsI18n = setErrorsI18n;
|
|
5720
|
+
exports.setThemeAlias = setThemeAlias;
|
|
5571
5721
|
exports.setThemeColor = setThemeColor;
|
|
5572
5722
|
exports.toggleAppTheme = toggleAppTheme;
|
|
5573
5723
|
exports.useAppThemeController = useAppThemeController;
|