@rolster/react-components 19.6.0 → 19.6.3
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 +427 -339
- package/dist/cjs/index.cjs.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/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 +1 -1
- package/dist/esm/components/organisms/Confirmation/Confirmation.js.map +1 -1
- package/dist/esm/components/organisms/FieldClock/FieldClock.d.ts +2 -1
- package/dist/esm/components/organisms/FieldClock/FieldClock.js.map +1 -1
- package/dist/esm/components/organisms/FieldColor/FieldColor.d.ts +2 -1
- package/dist/esm/components/organisms/FieldColor/FieldColor.js.map +1 -1
- package/dist/esm/components/organisms/FieldDate/FieldDate.d.ts +2 -1
- package/dist/esm/components/organisms/FieldDate/FieldDate.js.map +1 -1
- package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.d.ts +2 -1
- package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.js.map +1 -1
- package/dist/esm/components/organisms/ModalSheet/ModalSheet.d.ts +4 -1
- package/dist/esm/components/organisms/ModalSheet/ModalSheet.js +5 -4
- package/dist/esm/components/organisms/ModalSheet/ModalSheet.js.map +1 -1
- package/dist/esm/components/types.d.ts +1 -0
- 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 +12 -21
- package/dist/esm/helpers/color.js +186 -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 +2 -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
|
@@ -582,8 +582,11 @@ function RlsButton({ type, children, disabled, identifier, onClick, prefixIcon,
|
|
|
582
582
|
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
583
|
}
|
|
584
584
|
|
|
585
|
-
function RlsButtonAction({ icon, disabled, identifier, onClick, tooltip }) {
|
|
586
|
-
|
|
585
|
+
function RlsButtonAction({ icon, disabled, identifier, onClick, rlsTheme, tooltip, type }) {
|
|
586
|
+
const className = require$$0.useMemo(() => {
|
|
587
|
+
return renderClassStatus('rls-button-action', { type });
|
|
588
|
+
}, [type]);
|
|
589
|
+
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
590
|
}
|
|
588
591
|
|
|
589
592
|
function RlsButtonIcon({ icon, className, disabled, onClick, skeleton }) {
|
|
@@ -857,8 +860,385 @@ function RlsLabel({ children, rlsTheme }) {
|
|
|
857
860
|
return (jsxRuntimeExports.jsx("span", { className: "rls-label", "rls-theme": rlsTheme, children: children }));
|
|
858
861
|
}
|
|
859
862
|
|
|
860
|
-
function
|
|
861
|
-
return
|
|
863
|
+
function msgInvalidColor(color) {
|
|
864
|
+
return `Invalid color: "${color}". Use format "#FF6600".`;
|
|
865
|
+
}
|
|
866
|
+
function clamp(value, min, max) {
|
|
867
|
+
return Math.min(max, Math.max(min, value));
|
|
868
|
+
}
|
|
869
|
+
function computeHue(max, r, g, b, d) {
|
|
870
|
+
if (d === 0) {
|
|
871
|
+
return 0;
|
|
872
|
+
}
|
|
873
|
+
switch (max) {
|
|
874
|
+
case r:
|
|
875
|
+
return ((g - b) / d + (g < b ? 6 : 0)) / 6;
|
|
876
|
+
case g:
|
|
877
|
+
return ((b - r) / d + 2) / 6;
|
|
878
|
+
case b:
|
|
879
|
+
return ((r - g) / d + 4) / 6;
|
|
880
|
+
default:
|
|
881
|
+
return 0;
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
function hsvToRgb({ h, s, v }) {
|
|
885
|
+
const _h = h / 360;
|
|
886
|
+
const _s = s / 100;
|
|
887
|
+
const _v = v / 100;
|
|
888
|
+
const i = Math.floor(_h * 6);
|
|
889
|
+
const f = _h * 6 - i;
|
|
890
|
+
const p = _v * (1 - _s);
|
|
891
|
+
const q = _v * (1 - f * _s);
|
|
892
|
+
const t = _v * (1 - (1 - f) * _s);
|
|
893
|
+
let r;
|
|
894
|
+
let g;
|
|
895
|
+
let b;
|
|
896
|
+
switch (i % 6) {
|
|
897
|
+
case 0:
|
|
898
|
+
r = _v;
|
|
899
|
+
g = t;
|
|
900
|
+
b = p;
|
|
901
|
+
break;
|
|
902
|
+
case 1:
|
|
903
|
+
r = q;
|
|
904
|
+
g = _v;
|
|
905
|
+
b = p;
|
|
906
|
+
break;
|
|
907
|
+
case 2:
|
|
908
|
+
r = p;
|
|
909
|
+
g = _v;
|
|
910
|
+
b = t;
|
|
911
|
+
break;
|
|
912
|
+
case 3:
|
|
913
|
+
r = p;
|
|
914
|
+
g = q;
|
|
915
|
+
b = _v;
|
|
916
|
+
break;
|
|
917
|
+
case 4:
|
|
918
|
+
r = t;
|
|
919
|
+
g = p;
|
|
920
|
+
b = _v;
|
|
921
|
+
break;
|
|
922
|
+
case 5:
|
|
923
|
+
r = _v;
|
|
924
|
+
g = p;
|
|
925
|
+
b = q;
|
|
926
|
+
break;
|
|
927
|
+
default:
|
|
928
|
+
r = 0;
|
|
929
|
+
g = 0;
|
|
930
|
+
b = 0;
|
|
931
|
+
}
|
|
932
|
+
return {
|
|
933
|
+
r: Math.round(r * 255),
|
|
934
|
+
g: Math.round(g * 255),
|
|
935
|
+
b: Math.round(b * 255)
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
function rgbToHsv({ r, g, b }) {
|
|
939
|
+
const _r = r / 255;
|
|
940
|
+
const _g = g / 255;
|
|
941
|
+
const _b = b / 255;
|
|
942
|
+
const max = Math.max(_r, _g, _b);
|
|
943
|
+
const min = Math.min(_r, _g, _b);
|
|
944
|
+
const d = max - min;
|
|
945
|
+
const s = max === 0 ? 0 : d / max;
|
|
946
|
+
const v = max;
|
|
947
|
+
const h = computeHue(max, _r, _g, _b, d);
|
|
948
|
+
return {
|
|
949
|
+
h: Math.round(h * 360),
|
|
950
|
+
s: Math.round(s * 100),
|
|
951
|
+
v: Math.round(v * 100)
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
function rgbToHex({ r, g, b }) {
|
|
955
|
+
const toHex = (channel) => clamp(Math.round(channel), 0, 255).toString(16).padStart(2, '0');
|
|
956
|
+
return `#${toHex(r)}${toHex(g)}${toHex(b)}`.toUpperCase();
|
|
957
|
+
}
|
|
958
|
+
function hexToRgb(hex) {
|
|
959
|
+
const normalized = normalizeHex(hex);
|
|
960
|
+
if (!normalized) {
|
|
961
|
+
return null;
|
|
962
|
+
}
|
|
963
|
+
return {
|
|
964
|
+
r: parseInt(normalized.slice(1, 3), 16),
|
|
965
|
+
g: parseInt(normalized.slice(3, 5), 16),
|
|
966
|
+
b: parseInt(normalized.slice(5, 7), 16)
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
function hexToHsv(hex) {
|
|
970
|
+
const rgb = hexToRgb(hex);
|
|
971
|
+
return rgb ? rgbToHsv(rgb) : null;
|
|
972
|
+
}
|
|
973
|
+
function hsvToHex(hsv) {
|
|
974
|
+
return rgbToHex(hsvToRgb(hsv));
|
|
975
|
+
}
|
|
976
|
+
function hexIsValid(hex) {
|
|
977
|
+
return /^#?([a-f\d]{3}){1,2}$/i.test(hex);
|
|
978
|
+
}
|
|
979
|
+
function normalizeHex(hex) {
|
|
980
|
+
let value = hex.replace(/[^a-fA-F\d]/g, '');
|
|
981
|
+
if (value.length === 3) {
|
|
982
|
+
value = value
|
|
983
|
+
.split('')
|
|
984
|
+
.map((c) => c + c)
|
|
985
|
+
.join('');
|
|
986
|
+
}
|
|
987
|
+
return value.length === 6 ? `#${value.toUpperCase()}` : '';
|
|
988
|
+
}
|
|
989
|
+
function hslToHex({ h, s, l }) {
|
|
990
|
+
const _s = s / 100;
|
|
991
|
+
const _l = l / 100;
|
|
992
|
+
const a = _s * Math.min(_l, 1 - _l);
|
|
993
|
+
const f = (n) => {
|
|
994
|
+
const k = (n + h / 30) % 12;
|
|
995
|
+
return clamp(Math.round(255 * (_l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1))), 0, 255)
|
|
996
|
+
.toString(16)
|
|
997
|
+
.padStart(2, '0');
|
|
998
|
+
};
|
|
999
|
+
return `#${f(0)}${f(8)}${f(4)}`.toUpperCase();
|
|
1000
|
+
}
|
|
1001
|
+
function rgbToHsl({ r, g, b }) {
|
|
1002
|
+
const _r = r / 255;
|
|
1003
|
+
const _g = g / 255;
|
|
1004
|
+
const _b = b / 255;
|
|
1005
|
+
const max = Math.max(_r, _g, _b);
|
|
1006
|
+
const min = Math.min(_r, _g, _b);
|
|
1007
|
+
const d = max - min;
|
|
1008
|
+
const l = (max + min) / 2;
|
|
1009
|
+
const s = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1));
|
|
1010
|
+
const h = computeHue(max, _r, _g, _b, d);
|
|
1011
|
+
return {
|
|
1012
|
+
h: Math.round(h * 360),
|
|
1013
|
+
s: Math.round(s * 100),
|
|
1014
|
+
l: Math.round(l * 100)
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
1017
|
+
function hexToHsl(hex) {
|
|
1018
|
+
const rgb = hexToRgb(hex);
|
|
1019
|
+
return rgb ? rgbToHsl(rgb) : null;
|
|
1020
|
+
}
|
|
1021
|
+
const SHADE_LABELS = [
|
|
1022
|
+
'950',
|
|
1023
|
+
'900',
|
|
1024
|
+
'800',
|
|
1025
|
+
'700',
|
|
1026
|
+
'600',
|
|
1027
|
+
'500',
|
|
1028
|
+
'400',
|
|
1029
|
+
'300',
|
|
1030
|
+
'200',
|
|
1031
|
+
'100',
|
|
1032
|
+
'050'
|
|
1033
|
+
];
|
|
1034
|
+
/**
|
|
1035
|
+
* Target perceptual lightness (OKLab L, expressed as a 0–100 percentage) for
|
|
1036
|
+
* each shade level. OKLab lightness is perceptually uniform, so equal numeric
|
|
1037
|
+
* steps look like equal visual steps regardless of hue.
|
|
1038
|
+
*/
|
|
1039
|
+
const STANDARD_LUMINANCE = {
|
|
1040
|
+
'950': 16,
|
|
1041
|
+
'900': 24,
|
|
1042
|
+
'800': 28,
|
|
1043
|
+
'700': 33,
|
|
1044
|
+
'600': 40,
|
|
1045
|
+
'500': 48,
|
|
1046
|
+
'400': 58,
|
|
1047
|
+
'300': 72,
|
|
1048
|
+
'200': 84,
|
|
1049
|
+
'100': 92,
|
|
1050
|
+
'050': 97
|
|
1051
|
+
};
|
|
1052
|
+
const SKELETON_OPACITY = {
|
|
1053
|
+
'500': 0.5,
|
|
1054
|
+
'400': 0.325,
|
|
1055
|
+
'300': 0.25,
|
|
1056
|
+
'200': 0.175,
|
|
1057
|
+
'100': 0.1
|
|
1058
|
+
};
|
|
1059
|
+
const GRADIENT_LABELS = ['700', '600', '500', '400', '300'];
|
|
1060
|
+
const BACKDROP_LABELS = [
|
|
1061
|
+
'900',
|
|
1062
|
+
'800',
|
|
1063
|
+
'700',
|
|
1064
|
+
'600',
|
|
1065
|
+
'500',
|
|
1066
|
+
'400',
|
|
1067
|
+
'300',
|
|
1068
|
+
'200',
|
|
1069
|
+
'100'
|
|
1070
|
+
];
|
|
1071
|
+
function parseHex(color) {
|
|
1072
|
+
const rgb = hexToRgb(color);
|
|
1073
|
+
if (!rgb) {
|
|
1074
|
+
throw new Error(msgInvalidColor(color));
|
|
1075
|
+
}
|
|
1076
|
+
return rgb;
|
|
1077
|
+
}
|
|
1078
|
+
function rgbChannels({ r, g, b }) {
|
|
1079
|
+
return `${r}, ${g}, ${b}`;
|
|
1080
|
+
}
|
|
1081
|
+
function generateThemeCSS(colors, theme) {
|
|
1082
|
+
const prop = (suffix, value) => ({
|
|
1083
|
+
name: `--rls-${theme}-${suffix}`,
|
|
1084
|
+
value
|
|
1085
|
+
});
|
|
1086
|
+
const rgb900 = rgbChannels(parseHex(colors['900']));
|
|
1087
|
+
const rgb700 = rgbChannels(parseHex(colors['700']));
|
|
1088
|
+
const rgb500 = rgbChannels(parseHex(colors['500']));
|
|
1089
|
+
const colorProps = SHADE_LABELS.map((label) => prop(`color-${label}`, colors[label]));
|
|
1090
|
+
const gradientProps = GRADIENT_LABELS.map((label) => {
|
|
1091
|
+
const darker = SHADE_LABELS[SHADE_LABELS.indexOf(label) - 1];
|
|
1092
|
+
return prop(`gradient-${label}`, `linear-gradient(180deg, ${colors[label]} 15%, ${colors[darker]} 85%)`);
|
|
1093
|
+
});
|
|
1094
|
+
const backdropProps = BACKDROP_LABELS.map((label) => prop(`backdrop-${label}`, `rgba(${rgb900}, ${Number(label) / 1000})`));
|
|
1095
|
+
const skeletonProps = Object.entries(SKELETON_OPACITY).map(([label, opacity]) => prop(`skeleton-${label}`, `rgba(${rgb700}, ${opacity})`));
|
|
1096
|
+
const shadowProps = [
|
|
1097
|
+
prop('shadow-color-500', `rgba(${rgb500}, 0.24)`),
|
|
1098
|
+
prop('shadow-500', `0px 0px 0px 3px rgba(${rgb500}, 0.24)`)
|
|
1099
|
+
];
|
|
1100
|
+
return [
|
|
1101
|
+
...colorProps,
|
|
1102
|
+
...gradientProps,
|
|
1103
|
+
...backdropProps,
|
|
1104
|
+
...skeletonProps,
|
|
1105
|
+
...shadowProps
|
|
1106
|
+
];
|
|
1107
|
+
}
|
|
1108
|
+
const srgbToLinear = (channel) => {
|
|
1109
|
+
const x = channel / 255;
|
|
1110
|
+
return x <= 0.04045 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;
|
|
1111
|
+
};
|
|
1112
|
+
const linearToSrgb = (channel) => {
|
|
1113
|
+
const v = channel <= 0.0031308
|
|
1114
|
+
? 12.92 * channel
|
|
1115
|
+
: 1.055 * channel ** (1 / 2.4) - 0.055;
|
|
1116
|
+
return clamp(Math.round(v * 255), 0, 255);
|
|
1117
|
+
};
|
|
1118
|
+
function rgbToOklch({ r, g, b }) {
|
|
1119
|
+
const lr = srgbToLinear(r);
|
|
1120
|
+
const lg = srgbToLinear(g);
|
|
1121
|
+
const lb = srgbToLinear(b);
|
|
1122
|
+
const l = Math.cbrt(0.4122214708 * lr + 0.5363325363 * lg + 0.0514459929 * lb);
|
|
1123
|
+
const m = Math.cbrt(0.2119034982 * lr + 0.6806995451 * lg + 0.1073969566 * lb);
|
|
1124
|
+
const s = Math.cbrt(0.0883024619 * lr + 0.2817188376 * lg + 0.6299787005 * lb);
|
|
1125
|
+
const okL = 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s;
|
|
1126
|
+
const okA = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s;
|
|
1127
|
+
const okB = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s;
|
|
1128
|
+
return { l: okL, c: Math.hypot(okA, okB), h: Math.atan2(okB, okA) };
|
|
1129
|
+
}
|
|
1130
|
+
function oklabToLinearRgb(l, a, b) {
|
|
1131
|
+
const l_ = (l + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
|
1132
|
+
const m_ = (l - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
|
1133
|
+
const s_ = (l - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
|
1134
|
+
return [
|
|
1135
|
+
4.0767416621 * l_ - 3.3077115913 * m_ + 0.2309699292 * s_,
|
|
1136
|
+
-1.2684380046 * l_ + 2.6097574011 * m_ - 0.3413193965 * s_,
|
|
1137
|
+
-0.0041960863 * l_ - 0.7034186147 * m_ + 1.707614701 * s_
|
|
1138
|
+
];
|
|
1139
|
+
}
|
|
1140
|
+
const inGamut = ([r, g, b]) => {
|
|
1141
|
+
const e = 1e-4;
|
|
1142
|
+
return r >= -e && r <= 1 + e && g >= -e && g <= 1 + e && b >= -e && b <= 1 + e;
|
|
1143
|
+
};
|
|
1144
|
+
/**
|
|
1145
|
+
* Converts an OKLCH color to sRGB. If the requested chroma falls outside the
|
|
1146
|
+
* sRGB gamut, chroma is reduced (binary search) while keeping lightness and
|
|
1147
|
+
* hue fixed — this preserves the intended tone instead of clipping channels.
|
|
1148
|
+
*/
|
|
1149
|
+
function oklchToRgb({ l, c, h }) {
|
|
1150
|
+
const a = Math.cos(h);
|
|
1151
|
+
const b = Math.sin(h);
|
|
1152
|
+
const linearAt = (chroma) => oklabToLinearRgb(l, a * chroma, b * chroma);
|
|
1153
|
+
if (!inGamut(linearAt(c))) {
|
|
1154
|
+
let lo = 0;
|
|
1155
|
+
let hi = c;
|
|
1156
|
+
for (let i = 0; i < 20; i++) {
|
|
1157
|
+
const mid = (lo + hi) / 2;
|
|
1158
|
+
if (inGamut(linearAt(mid))) {
|
|
1159
|
+
lo = mid;
|
|
1160
|
+
}
|
|
1161
|
+
else {
|
|
1162
|
+
hi = mid;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
c = lo;
|
|
1166
|
+
}
|
|
1167
|
+
const [lr, lg, lb] = linearAt(c);
|
|
1168
|
+
return { r: linearToSrgb(lr), g: linearToSrgb(lg), b: linearToSrgb(lb) };
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Scales chroma down toward the lightness extremes (very light / very dark) so
|
|
1172
|
+
* shades do not look oversaturated at the ends. Peaks at L=0.5 (factor 1).
|
|
1173
|
+
*/
|
|
1174
|
+
const chromaFactor = (lightness) => 0.4 + 0.6 * (1 - Math.abs(lightness - 0.5) * 2);
|
|
1175
|
+
function detectShadeLevel(lightness) {
|
|
1176
|
+
let bestLevel = '500';
|
|
1177
|
+
let minDiff = Infinity;
|
|
1178
|
+
SHADE_LABELS.forEach((level) => {
|
|
1179
|
+
const diff = Math.abs(lightness - STANDARD_LUMINANCE[level]);
|
|
1180
|
+
if (diff < minDiff) {
|
|
1181
|
+
minDiff = diff;
|
|
1182
|
+
bestLevel = level;
|
|
1183
|
+
}
|
|
1184
|
+
});
|
|
1185
|
+
return bestLevel;
|
|
1186
|
+
}
|
|
1187
|
+
function generateThemePalette(baseColor, theme = 'primary') {
|
|
1188
|
+
const rgb = hexToRgb(baseColor);
|
|
1189
|
+
if (!rgb) {
|
|
1190
|
+
throw new Error(msgInvalidColor(baseColor));
|
|
1191
|
+
}
|
|
1192
|
+
const base = rgbToOklch(rgb);
|
|
1193
|
+
const matchedLevel = detectShadeLevel(base.l * 100);
|
|
1194
|
+
const colors = {};
|
|
1195
|
+
SHADE_LABELS.forEach((label) => {
|
|
1196
|
+
if (label === matchedLevel) {
|
|
1197
|
+
colors[label] = rgbToHex(rgb); // preserve the base color exactly
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
const lightness = STANDARD_LUMINANCE[label] / 100;
|
|
1201
|
+
colors[label] = rgbToHex(oklchToRgb({
|
|
1202
|
+
l: lightness,
|
|
1203
|
+
c: base.c * chromaFactor(lightness),
|
|
1204
|
+
h: base.h
|
|
1205
|
+
}));
|
|
1206
|
+
});
|
|
1207
|
+
const properties = generateThemeCSS(colors, theme);
|
|
1208
|
+
return {
|
|
1209
|
+
theme,
|
|
1210
|
+
colors,
|
|
1211
|
+
css: properties.map((p) => `${p.name}: ${p.value};`).join('\n'),
|
|
1212
|
+
properties
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1215
|
+
function setThemeColor(baseColor, theme = 'primary') {
|
|
1216
|
+
if (typeof document === 'undefined') {
|
|
1217
|
+
return;
|
|
1218
|
+
}
|
|
1219
|
+
const { properties } = generateThemePalette(baseColor, theme);
|
|
1220
|
+
const target = document.body || document.documentElement;
|
|
1221
|
+
properties.forEach(({ name, value }) => {
|
|
1222
|
+
target.style.setProperty(name, value);
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
const DEFAULT_COLOR = '#1780e0';
|
|
1226
|
+
|
|
1227
|
+
const CONTENT_BACKGROUND = '--pvt-content-background';
|
|
1228
|
+
function RlsLed({ color, rlsTheme }) {
|
|
1229
|
+
const refLed = require$$0.useRef(null);
|
|
1230
|
+
const refColor = require$$0.useRef(undefined);
|
|
1231
|
+
require$$0.useEffect(() => {
|
|
1232
|
+
if (color && hexIsValid(color)) {
|
|
1233
|
+
refColor.current = normalizeHex(color);
|
|
1234
|
+
refLed.current?.style.setProperty(CONTENT_BACKGROUND, refColor.current);
|
|
1235
|
+
}
|
|
1236
|
+
else if (refColor.current) {
|
|
1237
|
+
refColor.current = undefined;
|
|
1238
|
+
refLed.current?.style.setProperty(CONTENT_BACKGROUND, 'var(--rls-app-color-500)');
|
|
1239
|
+
}
|
|
1240
|
+
}, [color]);
|
|
1241
|
+
return jsxRuntimeExports.jsx("div", { ref: refLed, className: "rls-led", "rls-theme": rlsTheme });
|
|
862
1242
|
}
|
|
863
1243
|
|
|
864
1244
|
function RlsMessageIcon({ icon, children, rlsTheme }) {
|
|
@@ -3060,337 +3440,6 @@ function RlsFieldSelect(props) {
|
|
|
3060
3440
|
return jsxRuntimeExports.jsx(RlsFieldSelectTemplate, { ...props, render: render });
|
|
3061
3441
|
}
|
|
3062
3442
|
|
|
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
3443
|
function RlsPickerColor({ color, formControl, onListener, rlsTheme }) {
|
|
3395
3444
|
const initialColor = require$$0.useMemo(() => formControl?.value ?? color ?? DEFAULT_COLOR, []);
|
|
3396
3445
|
const initialHsv = require$$0.useMemo(() => hexToHsv(initialColor) ?? { h: 258, s: 100, v: 100 }, []);
|
|
@@ -4235,13 +4284,14 @@ function RlsImageChooser(props) {
|
|
|
4235
4284
|
return (jsxRuntimeExports.jsxs("div", { className: "rls-image-chooser", children: [jsxRuntimeExports.jsx("div", { className: "rls-image-chooser__avatar", onClick: controller.onImageChooser, children: src && jsxRuntimeExports.jsx("img", { src: src }) }), controller.RlsImageEditorChooser] }));
|
|
4236
4285
|
}
|
|
4237
4286
|
|
|
4238
|
-
function RlsModalSheet({ children, className, onAutoClose, visible, rlsTheme }) {
|
|
4287
|
+
function RlsModalSheet({ autoclose, children, className, controller, onAutoClose, visible, rlsTheme }) {
|
|
4239
4288
|
const classNameModal = require$$0.useMemo(() => {
|
|
4240
|
-
return renderClassStatus('rls-modal-sheet', { visible }, className);
|
|
4241
|
-
}, [className, visible]);
|
|
4289
|
+
return renderClassStatus('rls-modal-sheet', { visible: controller?.visible ?? visible }, className);
|
|
4290
|
+
}, [className, visible, controller?.visible]);
|
|
4242
4291
|
const onClickBackdrop = require$$0.useCallback(() => {
|
|
4292
|
+
autoclose && controller?.close();
|
|
4243
4293
|
onAutoClose?.();
|
|
4244
|
-
}, [onAutoClose]);
|
|
4294
|
+
}, [autoclose, controller, onAutoClose]);
|
|
4245
4295
|
return ReactDOM.createPortal(jsxRuntimeExports.jsxs("div", { className: classNameModal, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-modal-sheet__component", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-modal-sheet__backdrop", onClick: onClickBackdrop })] }), document.body);
|
|
4246
4296
|
}
|
|
4247
4297
|
|
|
@@ -4339,6 +4389,42 @@ function RlsApplication({ children }) {
|
|
|
4339
4389
|
}, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children, RlsSnackbar] }), RlsConfirmation] }));
|
|
4340
4390
|
}
|
|
4341
4391
|
|
|
4392
|
+
const DEFAULT_DESIGN_SYSTEM = 'bordered';
|
|
4393
|
+
|
|
4394
|
+
const DESIGN_SYSTEM_PREFIX = 'rls-design-system';
|
|
4395
|
+
const DESIGN_SYSTEMS = ['bordered', 'filled'];
|
|
4396
|
+
function designSystemClass(designSystem) {
|
|
4397
|
+
return `${DESIGN_SYSTEM_PREFIX}-${designSystem}`;
|
|
4398
|
+
}
|
|
4399
|
+
function setDesignSystem(designSystem = DEFAULT_DESIGN_SYSTEM) {
|
|
4400
|
+
if (typeof document === 'undefined') {
|
|
4401
|
+
return;
|
|
4402
|
+
}
|
|
4403
|
+
const target = document.body || document.documentElement;
|
|
4404
|
+
DESIGN_SYSTEMS.forEach((value) => {
|
|
4405
|
+
target.classList.toggle(designSystemClass(value), value === designSystem);
|
|
4406
|
+
});
|
|
4407
|
+
}
|
|
4408
|
+
|
|
4409
|
+
function useDesingSystemController(primaryDesignSystem = 'bordered', secondaryDesignSystem = 'filled') {
|
|
4410
|
+
const [designSystem, setDesignSystemValue] = require$$0.useState(() => {
|
|
4411
|
+
setDesignSystem(primaryDesignSystem);
|
|
4412
|
+
return primaryDesignSystem;
|
|
4413
|
+
});
|
|
4414
|
+
const setValue = require$$0.useCallback((value) => {
|
|
4415
|
+
setDesignSystem(value);
|
|
4416
|
+
setDesignSystemValue(value);
|
|
4417
|
+
}, []);
|
|
4418
|
+
const toggle = require$$0.useCallback(() => {
|
|
4419
|
+
const nextDesignSystem = designSystem === primaryDesignSystem
|
|
4420
|
+
? secondaryDesignSystem
|
|
4421
|
+
: primaryDesignSystem;
|
|
4422
|
+
setDesignSystem(nextDesignSystem);
|
|
4423
|
+
setDesignSystemValue(nextDesignSystem);
|
|
4424
|
+
}, [designSystem, primaryDesignSystem, secondaryDesignSystem]);
|
|
4425
|
+
return { setValue, toggle, value: designSystem };
|
|
4426
|
+
}
|
|
4427
|
+
|
|
4342
4428
|
function useDropdownController(effect = '0% 0%') {
|
|
4343
4429
|
const [visible, setVisible] = require$$0.useState(false);
|
|
4344
4430
|
const component = require$$0.useRef(null);
|
|
@@ -4547,10 +4633,12 @@ exports.renderClassStatus = renderClassStatus;
|
|
|
4547
4633
|
exports.rgbToHex = rgbToHex;
|
|
4548
4634
|
exports.rgbToHsl = rgbToHsl;
|
|
4549
4635
|
exports.rgbToHsv = rgbToHsv;
|
|
4636
|
+
exports.setDesignSystem = setDesignSystem;
|
|
4550
4637
|
exports.setErrorsI18n = setErrorsI18n;
|
|
4551
4638
|
exports.setThemeColor = setThemeColor;
|
|
4552
4639
|
exports.useConfirmation = useConfirmation;
|
|
4553
4640
|
exports.useDatatable = useDatatable;
|
|
4641
|
+
exports.useDesingSystemController = useDesingSystemController;
|
|
4554
4642
|
exports.useDropdownController = useDropdownController;
|
|
4555
4643
|
exports.useFieldAutocomplete = useFieldAutocomplete;
|
|
4556
4644
|
exports.useFieldList = useFieldList;
|