@rolster/react-components 19.6.1 → 19.6.4
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/LICENSE +21 -21
- package/dist/cjs/index.cjs +443 -349
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/es/index.mjs +4521 -0
- package/dist/es/index.mjs.map +1 -0
- package/dist/esm/components/atoms/Breadcrumb/Breadcrumb.d.ts +2 -3
- package/dist/esm/components/atoms/Breadcrumb/Breadcrumb.js.map +1 -1
- package/dist/esm/components/atoms/Button/Button.d.ts +1 -1
- package/dist/esm/components/atoms/Button/Button.js.map +1 -1
- package/dist/esm/components/atoms/ButtonAction/ButtonAction.d.ts +3 -1
- package/dist/esm/components/atoms/ButtonAction/ButtonAction.js +7 -2
- package/dist/esm/components/atoms/ButtonAction/ButtonAction.js.map +1 -1
- package/dist/esm/components/atoms/Led/Led.d.ts +5 -1
- package/dist/esm/components/atoms/Led/Led.js +17 -2
- package/dist/esm/components/atoms/Led/Led.js.map +1 -1
- package/dist/esm/components/atoms/ProgressCircular/ProgressCircular.d.ts +2 -6
- package/dist/esm/components/atoms/ProgressCircular/ProgressCircular.js.map +1 -1
- package/dist/esm/components/definitions.d.ts +1 -1
- package/dist/esm/components/molecules/ButtonProgress/ButtonProgress.d.ts +2 -3
- package/dist/esm/components/molecules/ButtonProgress/ButtonProgress.js.map +1 -1
- package/dist/esm/components/molecules/ButtonToggle/ButtonToggle.d.ts +1 -1
- package/dist/esm/components/molecules/ButtonToggle/ButtonToggle.js.map +1 -1
- package/dist/esm/components/organisms/Confirmation/Confirmation.d.ts +5 -8
- package/dist/esm/components/organisms/Confirmation/Confirmation.js.map +1 -1
- package/dist/esm/components/organisms/ImageEditor/ImageEditor.js +17 -9
- package/dist/esm/components/organisms/ImageEditor/ImageEditor.js.map +1 -1
- package/dist/esm/components/organisms/Snackbar/Snackbar.d.ts +2 -3
- package/dist/esm/components/organisms/Snackbar/Snackbar.js.map +1 -1
- package/dist/esm/controllers/DesingSystemController.d.ts +7 -0
- package/dist/esm/controllers/DesingSystemController.js +21 -0
- package/dist/esm/controllers/DesingSystemController.js.map +1 -0
- package/dist/esm/definitions.d.ts +2 -0
- package/dist/esm/definitions.js +1 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/helpers/color.d.ts +13 -22
- package/dist/esm/helpers/color.js +177 -153
- package/dist/esm/helpers/color.js.map +1 -1
- package/dist/esm/helpers/design-system.d.ts +2 -0
- package/dist/esm/helpers/design-system.js +16 -0
- package/dist/esm/helpers/design-system.js.map +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types.d.ts +9 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/package.json +91 -91
package/dist/cjs/index.cjs
CHANGED
|
@@ -414,13 +414,21 @@ function requireReactJsxRuntime_development () {
|
|
|
414
414
|
return reactJsxRuntime_development;
|
|
415
415
|
}
|
|
416
416
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
417
|
+
var hasRequiredJsxRuntime;
|
|
418
|
+
|
|
419
|
+
function requireJsxRuntime () {
|
|
420
|
+
if (hasRequiredJsxRuntime) return jsxRuntime.exports;
|
|
421
|
+
hasRequiredJsxRuntime = 1;
|
|
422
|
+
|
|
423
|
+
if (process.env.NODE_ENV === 'production') {
|
|
424
|
+
jsxRuntime.exports = requireReactJsxRuntime_production();
|
|
425
|
+
} else {
|
|
426
|
+
jsxRuntime.exports = requireReactJsxRuntime_development();
|
|
427
|
+
}
|
|
428
|
+
return jsxRuntime.exports;
|
|
421
429
|
}
|
|
422
430
|
|
|
423
|
-
var jsxRuntimeExports =
|
|
431
|
+
var jsxRuntimeExports = requireJsxRuntime();
|
|
424
432
|
|
|
425
433
|
function renderClassStatus(base, status = {}, additionals) {
|
|
426
434
|
const _classElement = [base];
|
|
@@ -582,8 +590,11 @@ function RlsButton({ type, children, disabled, identifier, onClick, prefixIcon,
|
|
|
582
590
|
return (jsxRuntimeExports.jsx("button", { id: identifier, className: "rls-button", onClick: onClick, "rls-theme": rlsTheme, disabled: disabled, children: jsxRuntimeExports.jsxs("div", { className: className, children: [requesting && jsxRuntimeExports.jsx(RlsSpinner, {}), prefixIcon && jsxRuntimeExports.jsx(RlsIcon, { value: prefixIcon }), children && jsxRuntimeExports.jsx("div", { className: "rls-button__description", children: children }), suffixIcon && jsxRuntimeExports.jsx(RlsIcon, { value: suffixIcon })] }) }));
|
|
583
591
|
}
|
|
584
592
|
|
|
585
|
-
function RlsButtonAction({ icon, disabled, identifier, onClick, tooltip }) {
|
|
586
|
-
|
|
593
|
+
function RlsButtonAction({ icon, disabled, identifier, onClick, rlsTheme, tooltip, type }) {
|
|
594
|
+
const className = require$$0.useMemo(() => {
|
|
595
|
+
return renderClassStatus('rls-button-action', { type });
|
|
596
|
+
}, [type]);
|
|
597
|
+
return (jsxRuntimeExports.jsxs("button", { id: identifier, className: className, onClick: onClick, disabled: disabled, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-button-action__content", children: jsxRuntimeExports.jsx(RlsIcon, { value: icon }) }), tooltip && (jsxRuntimeExports.jsx("div", { className: "rls-button-action__tooltip rls-overline-font-medium", children: jsxRuntimeExports.jsx("span", { children: tooltip }) }))] }));
|
|
587
598
|
}
|
|
588
599
|
|
|
589
600
|
function RlsButtonIcon({ icon, className, disabled, onClick, skeleton }) {
|
|
@@ -857,8 +868,376 @@ function RlsLabel({ children, rlsTheme }) {
|
|
|
857
868
|
return (jsxRuntimeExports.jsx("span", { className: "rls-label", "rls-theme": rlsTheme, children: children }));
|
|
858
869
|
}
|
|
859
870
|
|
|
860
|
-
function
|
|
861
|
-
return
|
|
871
|
+
function msgInvalidColor(color) {
|
|
872
|
+
return `Invalid color: "${color}". Use format "#FF6600".`;
|
|
873
|
+
}
|
|
874
|
+
function clamp(value, min, max) {
|
|
875
|
+
return Math.min(max, Math.max(min, value));
|
|
876
|
+
}
|
|
877
|
+
function computeHue(max, r, g, b, d) {
|
|
878
|
+
if (d === 0) {
|
|
879
|
+
return 0;
|
|
880
|
+
}
|
|
881
|
+
switch (max) {
|
|
882
|
+
case r:
|
|
883
|
+
return ((g - b) / d + (g < b ? 6 : 0)) / 6;
|
|
884
|
+
case g:
|
|
885
|
+
return ((b - r) / d + 2) / 6;
|
|
886
|
+
case b:
|
|
887
|
+
return ((r - g) / d + 4) / 6;
|
|
888
|
+
default:
|
|
889
|
+
return 0;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
function hsvToRgb({ h, s, v }) {
|
|
893
|
+
const _h = h / 360;
|
|
894
|
+
const _s = s / 100;
|
|
895
|
+
const _v = v / 100;
|
|
896
|
+
const i = Math.floor(_h * 6);
|
|
897
|
+
const f = _h * 6 - i;
|
|
898
|
+
const p = _v * (1 - _s);
|
|
899
|
+
const q = _v * (1 - f * _s);
|
|
900
|
+
const t = _v * (1 - (1 - f) * _s);
|
|
901
|
+
let r;
|
|
902
|
+
let g;
|
|
903
|
+
let b;
|
|
904
|
+
switch (i % 6) {
|
|
905
|
+
case 0:
|
|
906
|
+
r = _v;
|
|
907
|
+
g = t;
|
|
908
|
+
b = p;
|
|
909
|
+
break;
|
|
910
|
+
case 1:
|
|
911
|
+
r = q;
|
|
912
|
+
g = _v;
|
|
913
|
+
b = p;
|
|
914
|
+
break;
|
|
915
|
+
case 2:
|
|
916
|
+
r = p;
|
|
917
|
+
g = _v;
|
|
918
|
+
b = t;
|
|
919
|
+
break;
|
|
920
|
+
case 3:
|
|
921
|
+
r = p;
|
|
922
|
+
g = q;
|
|
923
|
+
b = _v;
|
|
924
|
+
break;
|
|
925
|
+
case 4:
|
|
926
|
+
r = t;
|
|
927
|
+
g = p;
|
|
928
|
+
b = _v;
|
|
929
|
+
break;
|
|
930
|
+
case 5:
|
|
931
|
+
r = _v;
|
|
932
|
+
g = p;
|
|
933
|
+
b = q;
|
|
934
|
+
break;
|
|
935
|
+
default:
|
|
936
|
+
r = 0;
|
|
937
|
+
g = 0;
|
|
938
|
+
b = 0;
|
|
939
|
+
}
|
|
940
|
+
return {
|
|
941
|
+
r: Math.round(r * 255),
|
|
942
|
+
g: Math.round(g * 255),
|
|
943
|
+
b: Math.round(b * 255)
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
function rgbToHsv({ r, g, b }) {
|
|
947
|
+
const _r = r / 255;
|
|
948
|
+
const _g = g / 255;
|
|
949
|
+
const _b = b / 255;
|
|
950
|
+
const max = Math.max(_r, _g, _b);
|
|
951
|
+
const min = Math.min(_r, _g, _b);
|
|
952
|
+
const d = max - min;
|
|
953
|
+
const s = max === 0 ? 0 : d / max;
|
|
954
|
+
const v = max;
|
|
955
|
+
const h = computeHue(max, _r, _g, _b, d);
|
|
956
|
+
return {
|
|
957
|
+
h: Math.round(h * 360),
|
|
958
|
+
s: Math.round(s * 100),
|
|
959
|
+
v: Math.round(v * 100)
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
function rgbToHex({ r, g, b }) {
|
|
963
|
+
const toHex = (channel) => clamp(Math.round(channel), 0, 255).toString(16).padStart(2, '0');
|
|
964
|
+
return `#${toHex(r)}${toHex(g)}${toHex(b)}`.toUpperCase();
|
|
965
|
+
}
|
|
966
|
+
function hexToRgb(hex) {
|
|
967
|
+
const normalized = normalizeHex(hex);
|
|
968
|
+
if (!normalized) {
|
|
969
|
+
return null;
|
|
970
|
+
}
|
|
971
|
+
return {
|
|
972
|
+
r: parseInt(normalized.slice(1, 3), 16),
|
|
973
|
+
g: parseInt(normalized.slice(3, 5), 16),
|
|
974
|
+
b: parseInt(normalized.slice(5, 7), 16)
|
|
975
|
+
};
|
|
976
|
+
}
|
|
977
|
+
function hexToHsv(hex) {
|
|
978
|
+
const rgb = hexToRgb(hex);
|
|
979
|
+
return rgb ? rgbToHsv(rgb) : null;
|
|
980
|
+
}
|
|
981
|
+
function hsvToHex(hsv) {
|
|
982
|
+
return rgbToHex(hsvToRgb(hsv));
|
|
983
|
+
}
|
|
984
|
+
function hexIsValid(hex) {
|
|
985
|
+
return /^#?([a-f\d]{3}){1,2}$/i.test(hex);
|
|
986
|
+
}
|
|
987
|
+
function normalizeHex(hex) {
|
|
988
|
+
let value = hex.replace(/[^a-fA-F\d]/g, '');
|
|
989
|
+
if (value.length === 3) {
|
|
990
|
+
value = value
|
|
991
|
+
.split('')
|
|
992
|
+
.map((c) => c + c)
|
|
993
|
+
.join('');
|
|
994
|
+
}
|
|
995
|
+
return value.length === 6 ? `#${value.toUpperCase()}` : '';
|
|
996
|
+
}
|
|
997
|
+
function hslToHex({ h, s, l }) {
|
|
998
|
+
const _s = s / 100;
|
|
999
|
+
const _l = l / 100;
|
|
1000
|
+
const a = _s * Math.min(_l, 1 - _l);
|
|
1001
|
+
const f = (n) => {
|
|
1002
|
+
const k = (n + h / 30) % 12;
|
|
1003
|
+
return clamp(Math.round(255 * (_l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1))), 0, 255)
|
|
1004
|
+
.toString(16)
|
|
1005
|
+
.padStart(2, '0');
|
|
1006
|
+
};
|
|
1007
|
+
return `#${f(0)}${f(8)}${f(4)}`.toUpperCase();
|
|
1008
|
+
}
|
|
1009
|
+
function rgbToHsl({ r, g, b }) {
|
|
1010
|
+
const _r = r / 255;
|
|
1011
|
+
const _g = g / 255;
|
|
1012
|
+
const _b = b / 255;
|
|
1013
|
+
const max = Math.max(_r, _g, _b);
|
|
1014
|
+
const min = Math.min(_r, _g, _b);
|
|
1015
|
+
const d = max - min;
|
|
1016
|
+
const l = (max + min) / 2;
|
|
1017
|
+
const s = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1));
|
|
1018
|
+
const h = computeHue(max, _r, _g, _b, d);
|
|
1019
|
+
return {
|
|
1020
|
+
h: Math.round(h * 360),
|
|
1021
|
+
s: Math.round(s * 100),
|
|
1022
|
+
l: Math.round(l * 100)
|
|
1023
|
+
};
|
|
1024
|
+
}
|
|
1025
|
+
function hexToHsl(hex) {
|
|
1026
|
+
const rgb = hexToRgb(hex);
|
|
1027
|
+
return rgb ? rgbToHsl(rgb) : null;
|
|
1028
|
+
}
|
|
1029
|
+
const SHADE_LABELS = [
|
|
1030
|
+
'950',
|
|
1031
|
+
'900',
|
|
1032
|
+
'800',
|
|
1033
|
+
'700',
|
|
1034
|
+
'600',
|
|
1035
|
+
'500',
|
|
1036
|
+
'400',
|
|
1037
|
+
'300',
|
|
1038
|
+
'200',
|
|
1039
|
+
'100',
|
|
1040
|
+
'050'
|
|
1041
|
+
];
|
|
1042
|
+
/**
|
|
1043
|
+
* Target perceptual lightness (OKLab L, expressed as a 0–100 percentage) for
|
|
1044
|
+
* each shade level. OKLab lightness is perceptually uniform, so equal numeric
|
|
1045
|
+
* steps look like equal visual steps regardless of hue.
|
|
1046
|
+
*/
|
|
1047
|
+
const STANDARD_LUMINANCE = {
|
|
1048
|
+
'950': 16,
|
|
1049
|
+
'900': 24,
|
|
1050
|
+
'800': 28,
|
|
1051
|
+
'700': 33,
|
|
1052
|
+
'600': 40,
|
|
1053
|
+
'500': 48,
|
|
1054
|
+
'400': 58,
|
|
1055
|
+
'300': 72,
|
|
1056
|
+
'200': 84,
|
|
1057
|
+
'100': 92,
|
|
1058
|
+
'050': 97
|
|
1059
|
+
};
|
|
1060
|
+
const SKELETON_OPACITY = {
|
|
1061
|
+
'500': 0.5,
|
|
1062
|
+
'400': 0.325,
|
|
1063
|
+
'300': 0.25,
|
|
1064
|
+
'200': 0.175,
|
|
1065
|
+
'100': 0.1
|
|
1066
|
+
};
|
|
1067
|
+
const GRADIENT_LABELS = ['700', '600', '500', '400', '300'];
|
|
1068
|
+
const BACKDROP_LABELS = [
|
|
1069
|
+
'900',
|
|
1070
|
+
'800',
|
|
1071
|
+
'700',
|
|
1072
|
+
'600',
|
|
1073
|
+
'500',
|
|
1074
|
+
'400',
|
|
1075
|
+
'300',
|
|
1076
|
+
'200',
|
|
1077
|
+
'100'
|
|
1078
|
+
];
|
|
1079
|
+
function parseHex(color) {
|
|
1080
|
+
const rgb = hexToRgb(color);
|
|
1081
|
+
if (!rgb) {
|
|
1082
|
+
throw new Error(msgInvalidColor(color));
|
|
1083
|
+
}
|
|
1084
|
+
return rgb;
|
|
1085
|
+
}
|
|
1086
|
+
function rgbChannels({ r, g, b }) {
|
|
1087
|
+
return `${r}, ${g}, ${b}`;
|
|
1088
|
+
}
|
|
1089
|
+
function generateThemeCSS(colors, theme) {
|
|
1090
|
+
const prop = (suffix, value) => ({
|
|
1091
|
+
name: `--rls-${theme}-${suffix}`,
|
|
1092
|
+
value
|
|
1093
|
+
});
|
|
1094
|
+
const rgb900 = rgbChannels(parseHex(colors['900']));
|
|
1095
|
+
const rgb700 = rgbChannels(parseHex(colors['700']));
|
|
1096
|
+
const rgb500 = rgbChannels(parseHex(colors['500']));
|
|
1097
|
+
const colorProps = SHADE_LABELS.map((label) => prop(`color-${label}`, colors[label]));
|
|
1098
|
+
const gradientProps = GRADIENT_LABELS.map((label) => {
|
|
1099
|
+
const darker = SHADE_LABELS[SHADE_LABELS.indexOf(label) - 1];
|
|
1100
|
+
return prop(`gradient-${label}`, `linear-gradient(180deg, ${colors[label]} 15%, ${colors[darker]} 85%)`);
|
|
1101
|
+
});
|
|
1102
|
+
const backdropProps = BACKDROP_LABELS.map((label) => prop(`backdrop-${label}`, `rgba(${rgb900}, ${Number(label) / 1000})`));
|
|
1103
|
+
const skeletonProps = Object.entries(SKELETON_OPACITY).map(([label, opacity]) => prop(`skeleton-${label}`, `rgba(${rgb700}, ${opacity})`));
|
|
1104
|
+
const shadowProps = [
|
|
1105
|
+
prop('shadow-color-500', `rgba(${rgb500}, 0.24)`),
|
|
1106
|
+
prop('shadow-500', `0px 0px 0px 3px rgba(${rgb500}, 0.24)`)
|
|
1107
|
+
];
|
|
1108
|
+
return [
|
|
1109
|
+
...colorProps,
|
|
1110
|
+
...gradientProps,
|
|
1111
|
+
...backdropProps,
|
|
1112
|
+
...skeletonProps,
|
|
1113
|
+
...shadowProps
|
|
1114
|
+
];
|
|
1115
|
+
}
|
|
1116
|
+
const srgbToLinear = (channel) => {
|
|
1117
|
+
const x = channel / 255;
|
|
1118
|
+
return x <= 0.04045 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;
|
|
1119
|
+
};
|
|
1120
|
+
const linearToSrgb = (channel) => {
|
|
1121
|
+
const v = channel <= 0.0031308
|
|
1122
|
+
? 12.92 * channel
|
|
1123
|
+
: 1.055 * channel ** (1 / 2.4) - 0.055;
|
|
1124
|
+
return clamp(Math.round(v * 255), 0, 255);
|
|
1125
|
+
};
|
|
1126
|
+
function rgbToOklch({ r, g, b }) {
|
|
1127
|
+
const lr = srgbToLinear(r);
|
|
1128
|
+
const lg = srgbToLinear(g);
|
|
1129
|
+
const lb = srgbToLinear(b);
|
|
1130
|
+
const l = Math.cbrt(0.4122214708 * lr + 0.5363325363 * lg + 0.0514459929 * lb);
|
|
1131
|
+
const m = Math.cbrt(0.2119034982 * lr + 0.6806995451 * lg + 0.1073969566 * lb);
|
|
1132
|
+
const s = Math.cbrt(0.0883024619 * lr + 0.2817188376 * lg + 0.6299787005 * lb);
|
|
1133
|
+
const okL = 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s;
|
|
1134
|
+
const okA = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s;
|
|
1135
|
+
const okB = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s;
|
|
1136
|
+
return { l: okL, c: Math.hypot(okA, okB), h: Math.atan2(okB, okA) };
|
|
1137
|
+
}
|
|
1138
|
+
function oklabToLinearRgb(l, a, b) {
|
|
1139
|
+
const l_ = (l + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
|
1140
|
+
const m_ = (l - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
|
1141
|
+
const s_ = (l - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
|
1142
|
+
return [
|
|
1143
|
+
4.0767416621 * l_ - 3.3077115913 * m_ + 0.2309699292 * s_,
|
|
1144
|
+
-1.2684380046 * l_ + 2.6097574011 * m_ - 0.3413193965 * s_,
|
|
1145
|
+
-0.0041960863 * l_ - 0.7034186147 * m_ + 1.707614701 * s_
|
|
1146
|
+
];
|
|
1147
|
+
}
|
|
1148
|
+
const inGamut = ([r, g, b]) => {
|
|
1149
|
+
const e = 1e-4;
|
|
1150
|
+
return (r >= -e && r <= 1 + e && g >= -e && g <= 1 + e && b >= -e && b <= 1 + e);
|
|
1151
|
+
};
|
|
1152
|
+
function oklchToRgb({ l, c, h }) {
|
|
1153
|
+
const a = Math.cos(h);
|
|
1154
|
+
const b = Math.sin(h);
|
|
1155
|
+
const linearAt = (chroma) => oklabToLinearRgb(l, a * chroma, b * chroma);
|
|
1156
|
+
if (!inGamut(linearAt(c))) {
|
|
1157
|
+
let lo = 0;
|
|
1158
|
+
let hi = c;
|
|
1159
|
+
for (let i = 0; i < 20; i++) {
|
|
1160
|
+
const mid = (lo + hi) / 2;
|
|
1161
|
+
if (inGamut(linearAt(mid))) {
|
|
1162
|
+
lo = mid;
|
|
1163
|
+
}
|
|
1164
|
+
else {
|
|
1165
|
+
hi = mid;
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
c = lo;
|
|
1169
|
+
}
|
|
1170
|
+
const [lr, lg, lb] = linearAt(c);
|
|
1171
|
+
return { r: linearToSrgb(lr), g: linearToSrgb(lg), b: linearToSrgb(lb) };
|
|
1172
|
+
}
|
|
1173
|
+
const chromaFactor = (lightness) => 0.4 + 0.6 * (1 - Math.abs(lightness - 0.5) * 2);
|
|
1174
|
+
function detectShadeLevel(lightness) {
|
|
1175
|
+
let bestLevel = '500';
|
|
1176
|
+
let minDiff = Infinity;
|
|
1177
|
+
SHADE_LABELS.forEach((level) => {
|
|
1178
|
+
const diff = Math.abs(lightness - STANDARD_LUMINANCE[level]);
|
|
1179
|
+
if (diff < minDiff) {
|
|
1180
|
+
minDiff = diff;
|
|
1181
|
+
bestLevel = level;
|
|
1182
|
+
}
|
|
1183
|
+
});
|
|
1184
|
+
return bestLevel;
|
|
1185
|
+
}
|
|
1186
|
+
function generateThemePalette(baseColor, theme = 'primary') {
|
|
1187
|
+
const rgb = hexToRgb(baseColor);
|
|
1188
|
+
if (!rgb) {
|
|
1189
|
+
throw new Error(msgInvalidColor(baseColor));
|
|
1190
|
+
}
|
|
1191
|
+
const base = rgbToOklch(rgb);
|
|
1192
|
+
const matchedLevel = detectShadeLevel(base.l * 100);
|
|
1193
|
+
const colors = {};
|
|
1194
|
+
SHADE_LABELS.forEach((label) => {
|
|
1195
|
+
if (label === matchedLevel) {
|
|
1196
|
+
colors[label] = rgbToHex(rgb); // preserve the base color exactly
|
|
1197
|
+
return;
|
|
1198
|
+
}
|
|
1199
|
+
const lightness = STANDARD_LUMINANCE[label] / 100;
|
|
1200
|
+
colors[label] = rgbToHex(oklchToRgb({
|
|
1201
|
+
l: lightness,
|
|
1202
|
+
c: base.c * chromaFactor(lightness),
|
|
1203
|
+
h: base.h
|
|
1204
|
+
}));
|
|
1205
|
+
});
|
|
1206
|
+
const properties = generateThemeCSS(colors, theme);
|
|
1207
|
+
return {
|
|
1208
|
+
theme,
|
|
1209
|
+
colors,
|
|
1210
|
+
css: properties.map((p) => `${p.name}: ${p.value};`).join('\n'),
|
|
1211
|
+
properties
|
|
1212
|
+
};
|
|
1213
|
+
}
|
|
1214
|
+
function setThemeColor(baseColor, theme = 'primary') {
|
|
1215
|
+
if (typeof document === 'undefined') {
|
|
1216
|
+
return;
|
|
1217
|
+
}
|
|
1218
|
+
const { properties } = generateThemePalette(baseColor, theme);
|
|
1219
|
+
const target = document.body || document.documentElement;
|
|
1220
|
+
properties.forEach(({ name, value }) => {
|
|
1221
|
+
target.style.setProperty(name, value);
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1224
|
+
const DEFAULT_COLOR = '#1780e0';
|
|
1225
|
+
|
|
1226
|
+
const CONTENT_BACKGROUND = '--pvt-content-background';
|
|
1227
|
+
function RlsLed({ color, rlsTheme }) {
|
|
1228
|
+
const refLed = require$$0.useRef(null);
|
|
1229
|
+
const refColor = require$$0.useRef(undefined);
|
|
1230
|
+
require$$0.useEffect(() => {
|
|
1231
|
+
if (color && hexIsValid(color)) {
|
|
1232
|
+
refColor.current = normalizeHex(color);
|
|
1233
|
+
refLed.current?.style.setProperty(CONTENT_BACKGROUND, refColor.current);
|
|
1234
|
+
}
|
|
1235
|
+
else if (refColor.current) {
|
|
1236
|
+
refColor.current = undefined;
|
|
1237
|
+
refLed.current?.style.setProperty(CONTENT_BACKGROUND, 'var(--rls-app-color-500)');
|
|
1238
|
+
}
|
|
1239
|
+
}, [color]);
|
|
1240
|
+
return jsxRuntimeExports.jsx("div", { ref: refLed, className: "rls-led", "rls-theme": rlsTheme });
|
|
862
1241
|
}
|
|
863
1242
|
|
|
864
1243
|
function RlsMessageIcon({ icon, children, rlsTheme }) {
|
|
@@ -3060,337 +3439,6 @@ function RlsFieldSelect(props) {
|
|
|
3060
3439
|
return jsxRuntimeExports.jsx(RlsFieldSelectTemplate, { ...props, render: render });
|
|
3061
3440
|
}
|
|
3062
3441
|
|
|
3063
|
-
function hsvToRgb({ h, s, v }) {
|
|
3064
|
-
const _h = h / 360;
|
|
3065
|
-
const _s = s / 100;
|
|
3066
|
-
const _v = v / 100;
|
|
3067
|
-
const i = Math.floor(_h * 6);
|
|
3068
|
-
const f = _h * 6 - i;
|
|
3069
|
-
const p = _v * (1 - _s);
|
|
3070
|
-
const q = _v * (1 - f * _s);
|
|
3071
|
-
const t = _v * (1 - (1 - f) * _s);
|
|
3072
|
-
let r;
|
|
3073
|
-
let g;
|
|
3074
|
-
let b;
|
|
3075
|
-
switch (i % 6) {
|
|
3076
|
-
case 0:
|
|
3077
|
-
r = _v;
|
|
3078
|
-
g = t;
|
|
3079
|
-
b = p;
|
|
3080
|
-
break;
|
|
3081
|
-
case 1:
|
|
3082
|
-
r = q;
|
|
3083
|
-
g = _v;
|
|
3084
|
-
b = p;
|
|
3085
|
-
break;
|
|
3086
|
-
case 2:
|
|
3087
|
-
r = p;
|
|
3088
|
-
g = _v;
|
|
3089
|
-
b = t;
|
|
3090
|
-
break;
|
|
3091
|
-
case 3:
|
|
3092
|
-
r = p;
|
|
3093
|
-
g = q;
|
|
3094
|
-
b = _v;
|
|
3095
|
-
break;
|
|
3096
|
-
case 4:
|
|
3097
|
-
r = t;
|
|
3098
|
-
g = p;
|
|
3099
|
-
b = _v;
|
|
3100
|
-
break;
|
|
3101
|
-
case 5:
|
|
3102
|
-
r = _v;
|
|
3103
|
-
g = p;
|
|
3104
|
-
b = q;
|
|
3105
|
-
break;
|
|
3106
|
-
default:
|
|
3107
|
-
r = 0;
|
|
3108
|
-
g = 0;
|
|
3109
|
-
b = 0;
|
|
3110
|
-
}
|
|
3111
|
-
return {
|
|
3112
|
-
r: Math.round(r * 255),
|
|
3113
|
-
g: Math.round(g * 255),
|
|
3114
|
-
b: Math.round(b * 255)
|
|
3115
|
-
};
|
|
3116
|
-
}
|
|
3117
|
-
function rgbToHsv(r, g, b) {
|
|
3118
|
-
const _r = r / 255;
|
|
3119
|
-
const _g = g / 255;
|
|
3120
|
-
const _b = b / 255;
|
|
3121
|
-
const max = Math.max(_r, _g, _b);
|
|
3122
|
-
const min = Math.min(_r, _g, _b);
|
|
3123
|
-
const d = max - min;
|
|
3124
|
-
let h = 0;
|
|
3125
|
-
const s = max === 0 ? 0 : d / max;
|
|
3126
|
-
const v = max;
|
|
3127
|
-
if (max !== min) {
|
|
3128
|
-
switch (max) {
|
|
3129
|
-
case _r:
|
|
3130
|
-
h = ((_g - _b) / d + (_g < _b ? 6 : 0)) / 6;
|
|
3131
|
-
break;
|
|
3132
|
-
case _g:
|
|
3133
|
-
h = ((_b - _r) / d + 2) / 6;
|
|
3134
|
-
break;
|
|
3135
|
-
case _b:
|
|
3136
|
-
h = ((_r - _g) / d + 4) / 6;
|
|
3137
|
-
break;
|
|
3138
|
-
}
|
|
3139
|
-
}
|
|
3140
|
-
return {
|
|
3141
|
-
h: Math.round(h * 360),
|
|
3142
|
-
s: Math.round(s * 100),
|
|
3143
|
-
v: Math.round(v * 100)
|
|
3144
|
-
};
|
|
3145
|
-
}
|
|
3146
|
-
function rgbToHex(r, g, b) {
|
|
3147
|
-
return ('#' +
|
|
3148
|
-
[r, g, b]
|
|
3149
|
-
.map((x) => x.toString(16).padStart(2, '0'))
|
|
3150
|
-
.join('')
|
|
3151
|
-
.toUpperCase());
|
|
3152
|
-
}
|
|
3153
|
-
function hexToRgb(hex) {
|
|
3154
|
-
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
3155
|
-
return result
|
|
3156
|
-
? {
|
|
3157
|
-
r: parseInt(result[1], 16),
|
|
3158
|
-
g: parseInt(result[2], 16),
|
|
3159
|
-
b: parseInt(result[3], 16)
|
|
3160
|
-
}
|
|
3161
|
-
: null;
|
|
3162
|
-
}
|
|
3163
|
-
function hexToHsv(hex) {
|
|
3164
|
-
const rgb = hexToRgb(hex);
|
|
3165
|
-
return rgb ? rgbToHsv(rgb.r, rgb.g, rgb.b) : null;
|
|
3166
|
-
}
|
|
3167
|
-
function hsvToHex(hsv) {
|
|
3168
|
-
const rgb = hsvToRgb(hsv);
|
|
3169
|
-
return rgbToHex(rgb.r, rgb.g, rgb.b);
|
|
3170
|
-
}
|
|
3171
|
-
function hexIsValid(hex) {
|
|
3172
|
-
return /^#?([a-f\d]{3}){1,2}$/i.test(hex);
|
|
3173
|
-
}
|
|
3174
|
-
function normalizeHex(hex) {
|
|
3175
|
-
let value = hex.replace(/[^a-fA-F\d]/g, '');
|
|
3176
|
-
if (value.length === 3) {
|
|
3177
|
-
value = value
|
|
3178
|
-
.split('')
|
|
3179
|
-
.map((c) => c + c)
|
|
3180
|
-
.join('');
|
|
3181
|
-
}
|
|
3182
|
-
return value.length === 6 ? `#${value.toUpperCase()}` : '';
|
|
3183
|
-
}
|
|
3184
|
-
function hslToHex({ h, s, l }) {
|
|
3185
|
-
const _s = s / 100;
|
|
3186
|
-
const _l = l / 100;
|
|
3187
|
-
const a = _s * Math.min(_l, 1 - _l);
|
|
3188
|
-
const f = (n) => {
|
|
3189
|
-
const k = (n + h / 30) % 12;
|
|
3190
|
-
return Math.round(255 * (_l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1)))
|
|
3191
|
-
.toString(16)
|
|
3192
|
-
.padStart(2, '0');
|
|
3193
|
-
};
|
|
3194
|
-
return `#${f(0)}${f(8)}${f(4)}`.toUpperCase();
|
|
3195
|
-
}
|
|
3196
|
-
function rgbToHsl(r, g, b) {
|
|
3197
|
-
const _r = r / 255;
|
|
3198
|
-
const _g = g / 255;
|
|
3199
|
-
const _b = b / 255;
|
|
3200
|
-
const max = Math.max(_r, _g, _b);
|
|
3201
|
-
const min = Math.min(_r, _g, _b);
|
|
3202
|
-
const d = max - min;
|
|
3203
|
-
let h = 0;
|
|
3204
|
-
const l = (max + min) / 2;
|
|
3205
|
-
const s = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1));
|
|
3206
|
-
if (d !== 0) {
|
|
3207
|
-
switch (max) {
|
|
3208
|
-
case _r:
|
|
3209
|
-
h = ((_g - _b) / d + (_g < _b ? 6 : 0)) / 6;
|
|
3210
|
-
break;
|
|
3211
|
-
case _g:
|
|
3212
|
-
h = ((_b - _r) / d + 2) / 6;
|
|
3213
|
-
break;
|
|
3214
|
-
case _b:
|
|
3215
|
-
h = ((_r - _g) / d + 4) / 6;
|
|
3216
|
-
break;
|
|
3217
|
-
}
|
|
3218
|
-
}
|
|
3219
|
-
return {
|
|
3220
|
-
h: Math.round(h * 360),
|
|
3221
|
-
s: Math.round(s * 100),
|
|
3222
|
-
l: Math.round(l * 100)
|
|
3223
|
-
};
|
|
3224
|
-
}
|
|
3225
|
-
function hexToHsl(hex) {
|
|
3226
|
-
const rgb = hexToRgb(hex);
|
|
3227
|
-
return rgb ? rgbToHsl(rgb.r, rgb.g, rgb.b) : null;
|
|
3228
|
-
}
|
|
3229
|
-
const STANDARD_LUMINANCE = {
|
|
3230
|
-
'950': 16,
|
|
3231
|
-
'900': 24,
|
|
3232
|
-
'800': 28,
|
|
3233
|
-
'700': 33,
|
|
3234
|
-
'600': 40,
|
|
3235
|
-
'500': 48,
|
|
3236
|
-
'400': 58,
|
|
3237
|
-
'300': 72,
|
|
3238
|
-
'200': 84,
|
|
3239
|
-
'100': 92,
|
|
3240
|
-
'050': 97
|
|
3241
|
-
};
|
|
3242
|
-
const SHADE_LABELS = [
|
|
3243
|
-
'950',
|
|
3244
|
-
'900',
|
|
3245
|
-
'800',
|
|
3246
|
-
'700',
|
|
3247
|
-
'600',
|
|
3248
|
-
'500',
|
|
3249
|
-
'400',
|
|
3250
|
-
'300',
|
|
3251
|
-
'200',
|
|
3252
|
-
'100',
|
|
3253
|
-
'050'
|
|
3254
|
-
];
|
|
3255
|
-
function parseHex(color) {
|
|
3256
|
-
const rgb = hexToRgb(color);
|
|
3257
|
-
if (!rgb)
|
|
3258
|
-
throw new Error(`Invalid color: "${color}". Use format "#FF6600".`);
|
|
3259
|
-
return rgb;
|
|
3260
|
-
}
|
|
3261
|
-
function generateThemeCSS(colors, theme) {
|
|
3262
|
-
const c900 = colors['900'];
|
|
3263
|
-
const c700 = colors['700'];
|
|
3264
|
-
const c500 = colors['500'];
|
|
3265
|
-
const r900 = parseHex(c900);
|
|
3266
|
-
const r700 = parseHex(c700);
|
|
3267
|
-
const r500 = parseHex(c500);
|
|
3268
|
-
const rgb900 = `${r900.r}, ${r900.g}, ${r900.b}`;
|
|
3269
|
-
const rgb700 = `${r700.r}, ${r700.g}, ${r700.b}`;
|
|
3270
|
-
const rgb500 = `${r500.r}, ${r500.g}, ${r500.b}`;
|
|
3271
|
-
return [
|
|
3272
|
-
{ name: `--rls-${theme}-color-950`, value: colors['950'] },
|
|
3273
|
-
{ name: `--rls-${theme}-color-900`, value: c900 },
|
|
3274
|
-
{ name: `--rls-${theme}-color-800`, value: colors['800'] },
|
|
3275
|
-
{ name: `--rls-${theme}-color-700`, value: c700 },
|
|
3276
|
-
{ name: `--rls-${theme}-color-600`, value: colors['600'] },
|
|
3277
|
-
{ name: `--rls-${theme}-color-500`, value: c500 },
|
|
3278
|
-
{ name: `--rls-${theme}-color-400`, value: colors['400'] },
|
|
3279
|
-
{ name: `--rls-${theme}-color-300`, value: colors['300'] },
|
|
3280
|
-
{ name: `--rls-${theme}-color-200`, value: colors['200'] },
|
|
3281
|
-
{ name: `--rls-${theme}-color-100`, value: colors['100'] },
|
|
3282
|
-
{ name: `--rls-${theme}-color-050`, value: colors['050'] },
|
|
3283
|
-
{
|
|
3284
|
-
name: `--rls-${theme}-gradient-700`,
|
|
3285
|
-
value: `linear-gradient(180deg, ${c700} 15%, ${colors['800']} 85%)`
|
|
3286
|
-
},
|
|
3287
|
-
{
|
|
3288
|
-
name: `--rls-${theme}-gradient-600`,
|
|
3289
|
-
value: `linear-gradient(180deg, ${colors['600']} 15%, ${c700} 85%)`
|
|
3290
|
-
},
|
|
3291
|
-
{
|
|
3292
|
-
name: `--rls-${theme}-gradient-500`,
|
|
3293
|
-
value: `linear-gradient(180deg, ${c500} 15%, ${colors['600']} 85%)`
|
|
3294
|
-
},
|
|
3295
|
-
{
|
|
3296
|
-
name: `--rls-${theme}-gradient-400`,
|
|
3297
|
-
value: `linear-gradient(180deg, ${colors['400']} 15%, ${c500} 85%)`
|
|
3298
|
-
},
|
|
3299
|
-
{
|
|
3300
|
-
name: `--rls-${theme}-gradient-300`,
|
|
3301
|
-
value: `linear-gradient(180deg, ${colors['300']} 15%, ${colors['400']} 85%)`
|
|
3302
|
-
},
|
|
3303
|
-
{ name: `--rls-${theme}-backdrop-900`, value: `rgba(${rgb900}, 0.9)` },
|
|
3304
|
-
{ name: `--rls-${theme}-backdrop-800`, value: `rgba(${rgb900}, 0.8)` },
|
|
3305
|
-
{ name: `--rls-${theme}-backdrop-700`, value: `rgba(${rgb900}, 0.7)` },
|
|
3306
|
-
{ name: `--rls-${theme}-backdrop-600`, value: `rgba(${rgb900}, 0.6)` },
|
|
3307
|
-
{ name: `--rls-${theme}-backdrop-500`, value: `rgba(${rgb900}, 0.5)` },
|
|
3308
|
-
{ name: `--rls-${theme}-backdrop-400`, value: `rgba(${rgb900}, 0.4)` },
|
|
3309
|
-
{ name: `--rls-${theme}-backdrop-300`, value: `rgba(${rgb900}, 0.3)` },
|
|
3310
|
-
{ name: `--rls-${theme}-backdrop-200`, value: `rgba(${rgb900}, 0.2)` },
|
|
3311
|
-
{ name: `--rls-${theme}-backdrop-100`, value: `rgba(${rgb900}, 0.1)` },
|
|
3312
|
-
{ name: `--rls-${theme}-skeleton-500`, value: `rgba(${rgb700}, 0.5)` },
|
|
3313
|
-
{ name: `--rls-${theme}-skeleton-400`, value: `rgba(${rgb700}, 0.325)` },
|
|
3314
|
-
{ name: `--rls-${theme}-skeleton-300`, value: `rgba(${rgb700}, 0.25)` },
|
|
3315
|
-
{ name: `--rls-${theme}-skeleton-200`, value: `rgba(${rgb700}, 0.175)` },
|
|
3316
|
-
{ name: `--rls-${theme}-skeleton-100`, value: `rgba(${rgb700}, 0.1)` },
|
|
3317
|
-
{ name: `--rls-${theme}-shadow-color-500`, value: `rgba(${rgb500}, 0.24)` },
|
|
3318
|
-
{
|
|
3319
|
-
name: `--rls-${theme}-shadow-500`,
|
|
3320
|
-
value: `0px 0px 0px 3px rgba(${rgb500}, 0.24)`
|
|
3321
|
-
}
|
|
3322
|
-
];
|
|
3323
|
-
}
|
|
3324
|
-
function detectShadeLevel(hsl) {
|
|
3325
|
-
let bestLevel = '500';
|
|
3326
|
-
let minDiff = Infinity;
|
|
3327
|
-
Object.keys(STANDARD_LUMINANCE).forEach((level) => {
|
|
3328
|
-
const targetL = STANDARD_LUMINANCE[level];
|
|
3329
|
-
const diff = Math.abs(hsl.l - targetL);
|
|
3330
|
-
if (diff < minDiff) {
|
|
3331
|
-
minDiff = diff;
|
|
3332
|
-
bestLevel = level;
|
|
3333
|
-
}
|
|
3334
|
-
});
|
|
3335
|
-
return bestLevel;
|
|
3336
|
-
}
|
|
3337
|
-
function generateThemePalette(baseColor, theme = 'primary') {
|
|
3338
|
-
const hsl = hexToHsl(baseColor);
|
|
3339
|
-
if (!hsl)
|
|
3340
|
-
throw new Error(`Invalid color: "${baseColor}". Use format "#FF6600".`);
|
|
3341
|
-
const matchedLevel = detectShadeLevel(hsl);
|
|
3342
|
-
const targetL = STANDARD_LUMINANCE[matchedLevel];
|
|
3343
|
-
const inputL = hsl.l;
|
|
3344
|
-
const colors = {};
|
|
3345
|
-
const matchedIndex = SHADE_LABELS.indexOf(matchedLevel);
|
|
3346
|
-
SHADE_LABELS.forEach((label) => {
|
|
3347
|
-
if (label === matchedLevel) {
|
|
3348
|
-
colors[label] = baseColor.toUpperCase();
|
|
3349
|
-
return;
|
|
3350
|
-
}
|
|
3351
|
-
const shadeTargetL = STANDARD_LUMINANCE[label];
|
|
3352
|
-
const labelIndex = SHADE_LABELS.indexOf(label);
|
|
3353
|
-
let lightL;
|
|
3354
|
-
if (labelIndex < matchedIndex) {
|
|
3355
|
-
const ratio = inputL / targetL;
|
|
3356
|
-
lightL = shadeTargetL * ratio;
|
|
3357
|
-
}
|
|
3358
|
-
else {
|
|
3359
|
-
const remainingInput = 100 - inputL;
|
|
3360
|
-
const remainingTarget = 100 - targetL;
|
|
3361
|
-
const progress = (shadeTargetL - targetL) / remainingTarget;
|
|
3362
|
-
lightL = inputL + progress * remainingInput;
|
|
3363
|
-
}
|
|
3364
|
-
lightL = Math.min(100, Math.max(0, lightL));
|
|
3365
|
-
const satFactor = lightL > 60
|
|
3366
|
-
? Math.max(0.2, (100 - lightL) / 40)
|
|
3367
|
-
: lightL < 30
|
|
3368
|
-
? Math.max(0.2, lightL / 30)
|
|
3369
|
-
: 1;
|
|
3370
|
-
colors[label] = hslToHex({
|
|
3371
|
-
h: hsl.h,
|
|
3372
|
-
s: Math.round(Math.min(100, hsl.s * satFactor)),
|
|
3373
|
-
l: Math.round(lightL)
|
|
3374
|
-
});
|
|
3375
|
-
});
|
|
3376
|
-
const shades = colors;
|
|
3377
|
-
const properties = generateThemeCSS(shades, theme);
|
|
3378
|
-
return {
|
|
3379
|
-
theme,
|
|
3380
|
-
colors: shades,
|
|
3381
|
-
css: properties.map((p) => `${p.name}: ${p.value};`).join('\n'),
|
|
3382
|
-
properties
|
|
3383
|
-
};
|
|
3384
|
-
}
|
|
3385
|
-
function setThemeColor(baseColor, theme = 'primary') {
|
|
3386
|
-
const { properties } = generateThemePalette(baseColor, theme);
|
|
3387
|
-
const target = document.body || document.documentElement;
|
|
3388
|
-
properties.forEach(({ name, value }) => {
|
|
3389
|
-
target.style.setProperty(name, value);
|
|
3390
|
-
});
|
|
3391
|
-
}
|
|
3392
|
-
const DEFAULT_COLOR = '#1780e0';
|
|
3393
|
-
|
|
3394
3442
|
function RlsPickerColor({ color, formControl, onListener, rlsTheme }) {
|
|
3395
3443
|
const initialColor = require$$0.useMemo(() => formControl?.value ?? color ?? DEFAULT_COLOR, []);
|
|
3396
3444
|
const initialHsv = require$$0.useMemo(() => hexToHsv(initialColor) ?? { h: 258, s: 100, v: 100 }, []);
|
|
@@ -3930,8 +3978,8 @@ function useResize(props) {
|
|
|
3930
3978
|
}, []);
|
|
3931
3979
|
}
|
|
3932
3980
|
|
|
3933
|
-
const
|
|
3934
|
-
const
|
|
3981
|
+
const MIN_SLIDER_VALUE = 50;
|
|
3982
|
+
const MAX_SLIDER_VALUE = 100;
|
|
3935
3983
|
function getRatioFactor(ratio) {
|
|
3936
3984
|
switch (ratio) {
|
|
3937
3985
|
case '16:9':
|
|
@@ -3979,6 +4027,7 @@ function RlsImageEditor(props) {
|
|
|
3979
4027
|
const refPicture = require$$0.useRef(null);
|
|
3980
4028
|
const image = require$$0.useRef(new Image());
|
|
3981
4029
|
const originalImage = require$$0.useRef(undefined);
|
|
4030
|
+
const hasInteracted = require$$0.useRef(false);
|
|
3982
4031
|
const ratio = require$$0.useMemo(() => {
|
|
3983
4032
|
return props.ratio || '1:1';
|
|
3984
4033
|
}, [props.ratio]);
|
|
@@ -4037,18 +4086,22 @@ function RlsImageEditor(props) {
|
|
|
4037
4086
|
image.current.width > 0 &&
|
|
4038
4087
|
image.current.height > 0) {
|
|
4039
4088
|
const { height, width } = image.current.width >= image.current.height
|
|
4040
|
-
?
|
|
4041
|
-
:
|
|
4089
|
+
? refreshSelectionFromWidth(rateSelection)
|
|
4090
|
+
: refreshSelectionFromHeight(rateSelection);
|
|
4042
4091
|
refSelection.current.style.width = `${width}px`;
|
|
4043
4092
|
refSelection.current.style.height = `${height}px`;
|
|
4093
|
+
const left = refImage.current.offsetWidth - width;
|
|
4094
|
+
const top = refImage.current.offsetHeight - height;
|
|
4095
|
+
if (!hasInteracted.current) {
|
|
4096
|
+
refSelection.current.style.left = `${left / 2}px`;
|
|
4097
|
+
refSelection.current.style.top = `${top / 2}px`;
|
|
4098
|
+
}
|
|
4044
4099
|
if (refSelection.current.offsetLeft + width >
|
|
4045
4100
|
refImage.current.offsetWidth) {
|
|
4046
|
-
const left = refImage.current.offsetWidth - width;
|
|
4047
4101
|
refSelection.current.style.left = `${left < 0 ? 0 : left}px`;
|
|
4048
4102
|
}
|
|
4049
4103
|
if (refSelection.current.offsetTop + height >
|
|
4050
4104
|
refImage.current.offsetHeight) {
|
|
4051
|
-
const top = refImage.current.offsetHeight - height;
|
|
4052
4105
|
refSelection.current.style.top = `${top < 0 ? 0 : top}px`;
|
|
4053
4106
|
}
|
|
4054
4107
|
refreshOverlaysStyle();
|
|
@@ -4072,7 +4125,7 @@ function RlsImageEditor(props) {
|
|
|
4072
4125
|
const width = (refBody.current.offsetHeight * image.current.width) /
|
|
4073
4126
|
image.current.height;
|
|
4074
4127
|
return setImageStyle(`${width}px`, '100%');
|
|
4075
|
-
}, [
|
|
4128
|
+
}, []);
|
|
4076
4129
|
require$$0.useEffect(() => {
|
|
4077
4130
|
image.current.onload = () => {
|
|
4078
4131
|
const context = refCanvas.current.getContext('2d', {
|
|
@@ -4111,7 +4164,10 @@ function RlsImageEditor(props) {
|
|
|
4111
4164
|
useRelocationOnComponent({
|
|
4112
4165
|
container: refImage,
|
|
4113
4166
|
element: refSelection,
|
|
4114
|
-
onDrag:
|
|
4167
|
+
onDrag: () => {
|
|
4168
|
+
hasInteracted.current = true;
|
|
4169
|
+
refreshOverlaysStyle();
|
|
4170
|
+
}
|
|
4115
4171
|
});
|
|
4116
4172
|
useResize({ refElement: refImage, onResize: onResizeElement });
|
|
4117
4173
|
const onCropImage = require$$0.useCallback(() => {
|
|
@@ -4150,7 +4206,7 @@ function RlsImageEditor(props) {
|
|
|
4150
4206
|
context?.putImageData(originalImage.current, 0, 0);
|
|
4151
4207
|
}
|
|
4152
4208
|
}, []);
|
|
4153
|
-
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:
|
|
4209
|
+
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 })] }));
|
|
4154
4210
|
}
|
|
4155
4211
|
|
|
4156
4212
|
function RlsImageEditorModal(props) {
|
|
@@ -4340,6 +4396,42 @@ function RlsApplication({ children }) {
|
|
|
4340
4396
|
}, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children, RlsSnackbar] }), RlsConfirmation] }));
|
|
4341
4397
|
}
|
|
4342
4398
|
|
|
4399
|
+
const DEFAULT_DESIGN_SYSTEM = 'bordered';
|
|
4400
|
+
|
|
4401
|
+
const DESIGN_SYSTEM_PREFIX = 'rls-design-system';
|
|
4402
|
+
const DESIGN_SYSTEMS = ['bordered', 'filled'];
|
|
4403
|
+
function designSystemClass(designSystem) {
|
|
4404
|
+
return `${DESIGN_SYSTEM_PREFIX}-${designSystem}`;
|
|
4405
|
+
}
|
|
4406
|
+
function setDesignSystem(designSystem = DEFAULT_DESIGN_SYSTEM) {
|
|
4407
|
+
if (typeof document === 'undefined') {
|
|
4408
|
+
return;
|
|
4409
|
+
}
|
|
4410
|
+
const target = document.body || document.documentElement;
|
|
4411
|
+
DESIGN_SYSTEMS.forEach((value) => {
|
|
4412
|
+
target.classList.toggle(designSystemClass(value), value === designSystem);
|
|
4413
|
+
});
|
|
4414
|
+
}
|
|
4415
|
+
|
|
4416
|
+
function useDesingSystemController(primaryDesignSystem = 'bordered', secondaryDesignSystem = 'filled') {
|
|
4417
|
+
const [designSystem, setDesignSystemValue] = require$$0.useState(() => {
|
|
4418
|
+
setDesignSystem(primaryDesignSystem);
|
|
4419
|
+
return primaryDesignSystem;
|
|
4420
|
+
});
|
|
4421
|
+
const setValue = require$$0.useCallback((value) => {
|
|
4422
|
+
setDesignSystem(value);
|
|
4423
|
+
setDesignSystemValue(value);
|
|
4424
|
+
}, []);
|
|
4425
|
+
const toggle = require$$0.useCallback(() => {
|
|
4426
|
+
const nextDesignSystem = designSystem === primaryDesignSystem
|
|
4427
|
+
? secondaryDesignSystem
|
|
4428
|
+
: primaryDesignSystem;
|
|
4429
|
+
setDesignSystem(nextDesignSystem);
|
|
4430
|
+
setDesignSystemValue(nextDesignSystem);
|
|
4431
|
+
}, [designSystem, primaryDesignSystem, secondaryDesignSystem]);
|
|
4432
|
+
return { setValue, toggle, value: designSystem };
|
|
4433
|
+
}
|
|
4434
|
+
|
|
4343
4435
|
function useDropdownController(effect = '0% 0%') {
|
|
4344
4436
|
const [visible, setVisible] = require$$0.useState(false);
|
|
4345
4437
|
const component = require$$0.useRef(null);
|
|
@@ -4548,10 +4640,12 @@ exports.renderClassStatus = renderClassStatus;
|
|
|
4548
4640
|
exports.rgbToHex = rgbToHex;
|
|
4549
4641
|
exports.rgbToHsl = rgbToHsl;
|
|
4550
4642
|
exports.rgbToHsv = rgbToHsv;
|
|
4643
|
+
exports.setDesignSystem = setDesignSystem;
|
|
4551
4644
|
exports.setErrorsI18n = setErrorsI18n;
|
|
4552
4645
|
exports.setThemeColor = setThemeColor;
|
|
4553
4646
|
exports.useConfirmation = useConfirmation;
|
|
4554
4647
|
exports.useDatatable = useDatatable;
|
|
4648
|
+
exports.useDesingSystemController = useDesingSystemController;
|
|
4555
4649
|
exports.useDropdownController = useDropdownController;
|
|
4556
4650
|
exports.useFieldAutocomplete = useFieldAutocomplete;
|
|
4557
4651
|
exports.useFieldList = useFieldList;
|