@rolster/react-components 19.5.4 → 19.6.1
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 +865 -36
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/components/atoms/ButtonIcon/ButtonIcon.d.ts +9 -0
- package/dist/esm/components/atoms/ButtonIcon/ButtonIcon.js +11 -0
- package/dist/esm/components/atoms/ButtonIcon/ButtonIcon.js.map +1 -0
- package/dist/esm/components/atoms/InputCounter/InputCounter.d.ts +9 -0
- package/dist/esm/components/atoms/InputCounter/InputCounter.js +57 -0
- package/dist/esm/components/atoms/InputCounter/InputCounter.js.map +1 -0
- package/dist/esm/components/molecules/ButtonStepper/ButtonStepper.d.ts +8 -0
- package/dist/esm/components/molecules/ButtonStepper/ButtonStepper.js +13 -0
- package/dist/esm/components/molecules/ButtonStepper/ButtonStepper.js.map +1 -0
- package/dist/esm/components/molecules/PickerSelectorTitle/PickerSelectorTitle.js +2 -2
- package/dist/esm/components/molecules/PickerSelectorTitle/PickerSelectorTitle.js.map +1 -1
- package/dist/esm/components/molecules/PickerYear/PickerYear.js +12 -19
- package/dist/esm/components/molecules/PickerYear/PickerYear.js.map +1 -1
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js +2 -2
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js.map +1 -1
- package/dist/esm/components/organisms/FieldClock/FieldClock.d.ts +2 -1
- package/dist/esm/components/organisms/FieldClock/FieldClock.js +2 -2
- package/dist/esm/components/organisms/FieldClock/FieldClock.js.map +1 -1
- package/dist/esm/components/organisms/FieldColor/FieldColor.d.ts +36 -0
- package/dist/esm/components/organisms/FieldColor/FieldColor.js +53 -0
- package/dist/esm/components/organisms/FieldColor/FieldColor.js.map +1 -0
- package/dist/esm/components/organisms/FieldDate/FieldDate.d.ts +2 -1
- package/dist/esm/components/organisms/FieldDate/FieldDate.js +2 -2
- 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 +2 -2
- package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.js.map +1 -1
- package/dist/esm/components/organisms/FieldList/FieldList.d.ts +43 -0
- package/dist/esm/components/organisms/FieldList/FieldList.js +41 -0
- package/dist/esm/components/organisms/FieldList/FieldList.js.map +1 -0
- package/dist/esm/components/organisms/FieldList/FieldListController.d.ts +27 -0
- package/dist/esm/components/organisms/FieldList/FieldListController.js +133 -0
- package/dist/esm/components/organisms/FieldList/FieldListController.js.map +1 -0
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.js +2 -2
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.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/organisms/PickerColor/PickerColor.d.ts +15 -0
- package/dist/esm/components/organisms/PickerColor/PickerColor.js +212 -0
- package/dist/esm/components/organisms/PickerColor/PickerColor.js.map +1 -0
- package/dist/esm/components/types.d.ts +1 -0
- package/dist/esm/helpers/color.d.ts +52 -0
- package/dist/esm/helpers/color.js +331 -0
- package/dist/esm/helpers/color.js.map +1 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -586,6 +586,13 @@ function RlsButtonAction({ icon, disabled, identifier, onClick, tooltip }) {
|
|
|
586
586
|
return (jsxRuntimeExports.jsxs("button", { id: identifier, className: "rls-button-action", onClick: onClick, disabled: disabled, 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
587
|
}
|
|
588
588
|
|
|
589
|
+
function RlsButtonIcon({ icon, className, disabled, onClick, skeleton }) {
|
|
590
|
+
const classNameButton = require$$0.useMemo(() => {
|
|
591
|
+
return renderClassStatus('rls-button-icon', { skeleton }, className);
|
|
592
|
+
}, [className, skeleton]);
|
|
593
|
+
return (jsxRuntimeExports.jsx("button", { className: classNameButton, onClick: onClick, disabled: disabled, children: !skeleton && jsxRuntimeExports.jsx(RlsIcon, { value: icon }) }));
|
|
594
|
+
}
|
|
595
|
+
|
|
589
596
|
function useFormSingleSelectionController({ disabled, formControl, onValue, value }) {
|
|
590
597
|
const [checked, setChecked] = require$$0.useState(formControl?.value === value);
|
|
591
598
|
require$$0.useEffect(() => {
|
|
@@ -697,6 +704,59 @@ function RlsInput({ children, decimals, disabled, formControl, identifier, onBlu
|
|
|
697
704
|
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, children: [jsxRuntimeExports.jsx("input", { ref: formControl?.elementRef, className: "rls-input__component", autoComplete: "off", type: type ?? 'text', placeholder: placeholder, disabled: formControl?.disabled || disabled, readOnly: readOnly, onFocus: onFocusInput, onBlur: onBlurInput, onChange: onChangeInput, onKeyDown: onKeyDownInput, onKeyUp: onKeyUpInput, value: valueInput }), jsxRuntimeExports.jsx("span", { className: "rls-input__value", children: children })] }));
|
|
698
705
|
}
|
|
699
706
|
|
|
707
|
+
function RlsInputCounter({ className, disabled, formControl, identifier, max, min, onBlur, onFocus, onValue, readOnly, rlsTheme, step = 1, value: valueProp }) {
|
|
708
|
+
const changeIsInternal = require$$0.useRef(false);
|
|
709
|
+
const [value, setValue] = require$$0.useState(formControl?.value ?? valueProp ?? 0);
|
|
710
|
+
const [focused, setFocused] = require$$0.useState(false);
|
|
711
|
+
const _disabled = require$$0.useMemo(() => formControl?.disabled || disabled, [formControl?.disabled, disabled]);
|
|
712
|
+
const classNameCounter = require$$0.useMemo(() => {
|
|
713
|
+
return renderClassStatus('rls-input-counter', {
|
|
714
|
+
disabled: _disabled,
|
|
715
|
+
focused: formControl?.focused ?? focused,
|
|
716
|
+
readonly: readOnly
|
|
717
|
+
}, className);
|
|
718
|
+
}, [_disabled, formControl?.focused, focused, readOnly, className]);
|
|
719
|
+
require$$0.useEffect(() => {
|
|
720
|
+
if (!changeIsInternal.current && formControl) {
|
|
721
|
+
const counterValue = formControl.value;
|
|
722
|
+
counterValue !== undefined &&
|
|
723
|
+
counterValue !== value &&
|
|
724
|
+
setValue(counterValue);
|
|
725
|
+
}
|
|
726
|
+
changeIsInternal.current = false;
|
|
727
|
+
}, [formControl?.value]);
|
|
728
|
+
const onUpdate = require$$0.useCallback((nextValue) => {
|
|
729
|
+
const clamped = Math.min(max ?? Infinity, Math.max(min ?? -Infinity, nextValue));
|
|
730
|
+
changeIsInternal.current = true;
|
|
731
|
+
setValue(clamped);
|
|
732
|
+
formControl?.setValue(clamped);
|
|
733
|
+
onValue?.(clamped);
|
|
734
|
+
}, [formControl, max, min, onValue]);
|
|
735
|
+
const onDecrement = require$$0.useCallback(() => {
|
|
736
|
+
onUpdate(value - step);
|
|
737
|
+
}, [onUpdate, value, step]);
|
|
738
|
+
const onIncrement = require$$0.useCallback(() => {
|
|
739
|
+
onUpdate(value + step);
|
|
740
|
+
}, [onUpdate, value, step]);
|
|
741
|
+
const decrementIsAllowed = require$$0.useMemo(() => min !== undefined && value <= min, [min, value]);
|
|
742
|
+
const incrementIsAllowed = require$$0.useMemo(() => max !== undefined && value >= max, [max, value]);
|
|
743
|
+
const onChangeInput = require$$0.useCallback((event) => {
|
|
744
|
+
const parsed = parseFloat(event.target.value);
|
|
745
|
+
!isNaN(parsed) && onUpdate(parsed);
|
|
746
|
+
}, [onUpdate]);
|
|
747
|
+
const onFocusInput = require$$0.useCallback(() => {
|
|
748
|
+
setFocused(true);
|
|
749
|
+
formControl?.focus();
|
|
750
|
+
onFocus?.();
|
|
751
|
+
}, [formControl, onFocus]);
|
|
752
|
+
const onBlurInput = require$$0.useCallback(() => {
|
|
753
|
+
setFocused(false);
|
|
754
|
+
formControl?.blur();
|
|
755
|
+
onBlur?.();
|
|
756
|
+
}, [formControl, onBlur]);
|
|
757
|
+
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: classNameCounter, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx(RlsButtonIcon, { className: "rls-input-counter__down", icon: "minus", onClick: onDecrement, disabled: _disabled || decrementIsAllowed }), jsxRuntimeExports.jsx("div", { className: "rls-input-counter__body", children: jsxRuntimeExports.jsx("input", { ref: formControl?.elementRef, className: "rls-input-counter__control", type: "text", inputMode: "numeric", value: value, disabled: _disabled, readOnly: readOnly, onChange: onChangeInput, onFocus: onFocusInput, onBlur: onBlurInput }) }), jsxRuntimeExports.jsx(RlsButtonIcon, { className: "rls-input-counter__up", icon: "plus", onClick: onIncrement, disabled: _disabled || incrementIsAllowed })] }));
|
|
758
|
+
}
|
|
759
|
+
|
|
700
760
|
function RlsInputDecimal(props) {
|
|
701
761
|
const { decimals, formControl, identifier, onValue, symbol, value } = props;
|
|
702
762
|
const [valueInput, setValueInput] = require$$0.useState((formControl?.value ?? value ?? commons.BigDecimal.zero()).rounded);
|
|
@@ -926,6 +986,16 @@ function RlsButtonProgress({ icon, disabled, onClick, progressing, rlsTheme }) {
|
|
|
926
986
|
return (jsxRuntimeExports.jsxs("div", { className: className, "rls-theme": rlsTheme, children: [!progressing && (jsxRuntimeExports.jsx(RlsButtonAction, { icon: icon, onClick: onClick, disabled: disabled })), progressing && jsxRuntimeExports.jsx(RlsProgressCircular, {})] }));
|
|
927
987
|
}
|
|
928
988
|
|
|
989
|
+
function RlsButtonStepper({ disabled, onAction, rlsTheme }) {
|
|
990
|
+
const onDown = require$$0.useCallback(() => {
|
|
991
|
+
onAction?.('down');
|
|
992
|
+
}, [onAction]);
|
|
993
|
+
const onUp = require$$0.useCallback(() => {
|
|
994
|
+
onAction?.('up');
|
|
995
|
+
}, [onAction]);
|
|
996
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-button-stepper", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx(RlsButtonIcon, { icon: "arrow-ios-down", disabled: disabled, onClick: onDown }), jsxRuntimeExports.jsx(RlsButtonIcon, { icon: "arrow-ios-up", disabled: disabled, onClick: onUp })] }));
|
|
997
|
+
}
|
|
998
|
+
|
|
929
999
|
function RlsButtonToggle({ onAction, options, type, automatic, disabled, rlsTheme }) {
|
|
930
1000
|
const componentRef = require$$0.useRef(null);
|
|
931
1001
|
const [action, setAction] = require$$0.useState(options[0]);
|
|
@@ -1699,7 +1769,7 @@ function RlsPickerSelectorTitle({ monthControl, type, yearControl, date, disable
|
|
|
1699
1769
|
const onNext = require$$0.useCallback(() => {
|
|
1700
1770
|
type === 'month' ? onNextMonth() : onNextYear();
|
|
1701
1771
|
}, [type, onNextMonth, onNextYear]);
|
|
1702
|
-
return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-selector-title", children: [jsxRuntimeExports.jsx("
|
|
1772
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-selector-title", children: [jsxRuntimeExports.jsx(RlsButtonIcon, { icon: "arrow-ios-left", onClick: onPrevious, disabled: limitPrevious || disabled }), jsxRuntimeExports.jsxs("div", { className: "rls-picker-selector-title__label", children: [jsxRuntimeExports.jsxs("span", { onClick: onMonth, children: [label, ","] }), jsxRuntimeExports.jsx("span", { onClick: onYear, children: yearControl.value })] }), jsxRuntimeExports.jsx(RlsButtonIcon, { icon: "arrow-ios-right", onClick: onNext, disabled: limitNext || disabled })] }));
|
|
1703
1773
|
}
|
|
1704
1774
|
|
|
1705
1775
|
function RlsPickerYearElement({ onSelect, year, disabled }) {
|
|
@@ -1717,7 +1787,6 @@ function RlsPickerYearElement({ onSelect, year, disabled }) {
|
|
|
1717
1787
|
}
|
|
1718
1788
|
function RlsPickerYear({ date, disabled, formControl, maxDate, minDate, onValue, rlsTheme }) {
|
|
1719
1789
|
const dateYear = require$$0.useMemo(() => date ?? new Date(), [date]);
|
|
1720
|
-
const [value, setValue] = require$$0.useState(formControl?.value ?? dateYear.getFullYear());
|
|
1721
1790
|
const [year, setYear] = require$$0.useState(formControl?.value ?? dateYear.getFullYear());
|
|
1722
1791
|
const createPickerOptions = require$$0.useCallback(() => {
|
|
1723
1792
|
return {
|
|
@@ -1728,32 +1797,26 @@ function RlsPickerYear({ date, disabled, formControl, maxDate, minDate, onValue,
|
|
|
1728
1797
|
};
|
|
1729
1798
|
}, [dateYear, year, minDate, maxDate]);
|
|
1730
1799
|
const [template, setTemplate] = require$$0.useState(components.createYearPicker(createPickerOptions()));
|
|
1731
|
-
const setYearValue = require$$0.useCallback((value) => {
|
|
1732
|
-
formControl ? formControl.setValue(value) : setValue(value);
|
|
1733
|
-
setYear(value);
|
|
1734
|
-
}, [formControl]);
|
|
1735
|
-
const onSelect = require$$0.useCallback((value) => {
|
|
1736
|
-
setYearValue(value);
|
|
1737
|
-
onValue?.(value);
|
|
1738
|
-
}, [setYearValue, onValue]);
|
|
1739
1800
|
require$$0.useEffect(() => {
|
|
1740
|
-
const options = createPickerOptions();
|
|
1741
|
-
const
|
|
1742
|
-
|
|
1743
|
-
}, [dateYear, year,
|
|
1801
|
+
const options = createPickerOptions();
|
|
1802
|
+
const validYear = components.verifyYearPicker(options);
|
|
1803
|
+
validYear ? setYear(validYear) : setTemplate(components.createYearPicker(options));
|
|
1804
|
+
}, [dateYear, year, minDate, maxDate]);
|
|
1744
1805
|
require$$0.useEffect(() => {
|
|
1745
|
-
const
|
|
1746
|
-
commons.valueIsDefined(year)
|
|
1747
|
-
? formControl?.setValue(year)
|
|
1748
|
-
: setValue(formControl?.value ?? dateYear.getFullYear());
|
|
1806
|
+
const yearValue = formControl?.value;
|
|
1807
|
+
commons.valueIsDefined(yearValue) && yearValue !== year && setYear(yearValue);
|
|
1749
1808
|
}, [formControl?.value]);
|
|
1809
|
+
const onSelect = require$$0.useCallback((value) => {
|
|
1810
|
+
formControl ? formControl.setValue(value) : setYear(value);
|
|
1811
|
+
onValue?.(value);
|
|
1812
|
+
}, [formControl, onValue]);
|
|
1750
1813
|
const onClickPrev = require$$0.useCallback(() => {
|
|
1751
1814
|
setYear((year) => year - 8);
|
|
1752
1815
|
}, []);
|
|
1753
1816
|
const onClickNext = require$$0.useCallback(() => {
|
|
1754
1817
|
setYear((year) => year + 8);
|
|
1755
1818
|
}, []);
|
|
1756
|
-
return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-year", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-year__header", children: [jsxRuntimeExports.jsx(
|
|
1819
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-year", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-year__header", children: [jsxRuntimeExports.jsx(RlsButtonIcon, { icon: "arrow-ios-left", onClick: onClickPrev, disabled: !template.canPrevious || disabled }), jsxRuntimeExports.jsxs("span", { children: [template.minRange, " - ", template.maxRange] }), jsxRuntimeExports.jsx(RlsButtonIcon, { icon: "arrow-ios-right", onClick: onClickNext, disabled: !template.canNext || disabled })] }), jsxRuntimeExports.jsx("div", { className: "rls-picker-year__component", children: template.years.map((year, index) => (jsxRuntimeExports.jsx(RlsPickerYearElement, { year: year, onSelect: onSelect, disabled: disabled }, index))) })] }));
|
|
1757
1820
|
}
|
|
1758
1821
|
|
|
1759
1822
|
function calculateInitialValue(value, minValue, maxValue) {
|
|
@@ -2014,23 +2077,23 @@ function RlsDropdown({ children, controller, rlsTheme }) {
|
|
|
2014
2077
|
return (jsxRuntimeExports.jsx("div", { ref: controller.component, className: className, "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-dropdown__content", children: children }) }));
|
|
2015
2078
|
}
|
|
2016
2079
|
|
|
2017
|
-
const MAX_LIST_HEIGHT_REM = 90;
|
|
2018
|
-
const FALLBACK_REM_SIZE = 16;
|
|
2019
|
-
function getRemSize() {
|
|
2080
|
+
const MAX_LIST_HEIGHT_REM$1 = 90;
|
|
2081
|
+
const FALLBACK_REM_SIZE$1 = 16;
|
|
2082
|
+
function getRemSize$1() {
|
|
2020
2083
|
if (typeof window === 'undefined') {
|
|
2021
|
-
return FALLBACK_REM_SIZE;
|
|
2084
|
+
return FALLBACK_REM_SIZE$1;
|
|
2022
2085
|
}
|
|
2023
2086
|
const fontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
2024
|
-
return fontSize > 0 ? fontSize : FALLBACK_REM_SIZE;
|
|
2087
|
+
return fontSize > 0 ? fontSize : FALLBACK_REM_SIZE$1;
|
|
2025
2088
|
}
|
|
2026
|
-
function shouldDisplayHigher(content, list) {
|
|
2089
|
+
function shouldDisplayHigher$1(content, list) {
|
|
2027
2090
|
if (!content) {
|
|
2028
2091
|
return false;
|
|
2029
2092
|
}
|
|
2030
2093
|
const { top, bottom } = content.getBoundingClientRect();
|
|
2031
2094
|
const spaceAbove = top;
|
|
2032
2095
|
const spaceBelow = window.innerHeight - bottom;
|
|
2033
|
-
const maxHeight = MAX_LIST_HEIGHT_REM * getRemSize();
|
|
2096
|
+
const maxHeight = MAX_LIST_HEIGHT_REM$1 * getRemSize$1();
|
|
2034
2097
|
const desiredHeight = Math.min(list?.scrollHeight || maxHeight, maxHeight);
|
|
2035
2098
|
if (spaceBelow >= desiredHeight) {
|
|
2036
2099
|
return false;
|
|
@@ -2107,7 +2170,7 @@ function useListController(props) {
|
|
|
2107
2170
|
const _state = state.listIsVisible
|
|
2108
2171
|
? {
|
|
2109
2172
|
...state,
|
|
2110
|
-
higher: shouldDisplayHigher(refContent.current, refList.current)
|
|
2173
|
+
higher: shouldDisplayHigher$1(refContent.current, refList.current)
|
|
2111
2174
|
}
|
|
2112
2175
|
: state;
|
|
2113
2176
|
refreshState((state) => ({ ...state, ..._state }));
|
|
@@ -2349,7 +2412,7 @@ function RlsFieldAutocompleteTemplate(props) {
|
|
|
2349
2412
|
onClickPattern,
|
|
2350
2413
|
onSearch
|
|
2351
2414
|
]);
|
|
2352
|
-
return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: autocomplete.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("input", { className: "rls-field-list__control", readOnly: true, disabled: disabled, placeholder: placeholder, value: autocomplete.value, onClick: autocomplete.onClickControl }), !props.readOnly && (jsxRuntimeExports.jsx(
|
|
2415
|
+
return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: autocomplete.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("input", { className: "rls-field-list__control", readOnly: true, disabled: disabled, placeholder: placeholder, value: autocomplete.value, onClick: autocomplete.onClickControl }), !props.readOnly && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: autocomplete.value ? 'trash-2' : 'arrow-ios-down', onClick: autocomplete.onClickAction, disabled: disabled }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsx(RlsFieldListSuggestions, { elements: autocomplete.coincidences, visible: autocomplete.listIsVisible, action: action, disabled: disabled, higher: autocomplete.higher, render: render, refList: autocomplete.refList, searchControl: searchControl, onClickElement: autocomplete.onClickElement, onKeydownElement: autocomplete.onKeydownElement, onClickBackdrop: autocomplete.onClickBackdrop })] }));
|
|
2353
2416
|
}
|
|
2354
2417
|
function RlsFieldAutocomplete(props) {
|
|
2355
2418
|
const render = require$$0.useCallback((element) => (jsxRuntimeExports.jsx(RlsBallot, { className: "rls-field-list__ballot", subtitle: element.subtitle, img: element.img, initials: element.initials, children: jsxRuntimeExports.jsx("span", { children: element.title }) })), []);
|
|
@@ -2620,7 +2683,7 @@ function RlsFieldClock({ children, disabled: disabledProps, formControl, identif
|
|
|
2620
2683
|
formControl?.touch();
|
|
2621
2684
|
setModalIsVisible(false);
|
|
2622
2685
|
}, [formControl, onChange]);
|
|
2623
|
-
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-clock", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, 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("input", { className: "rls-field-clock__control", type: "text", value: status.valueInput, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), !readOnly && (jsxRuntimeExports.jsx(
|
|
2686
|
+
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-clock", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, 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("input", { className: "rls-field-clock__control", type: "text", value: status.valueInput, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), !readOnly && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: status.icon, onClick: onClickAction, disabled: disabled }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }), jsxRuntimeExports.jsx(RlsModal, { className: "rls-field-clock-modal", visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerClock, { formControl: formControl, time: time, disabled: disabled, onListener: onListener }) })] }));
|
|
2624
2687
|
}
|
|
2625
2688
|
|
|
2626
2689
|
const DATE_FORMAT = '{dd}/{mx}/{yy}';
|
|
@@ -2757,7 +2820,7 @@ function RlsFieldDate({ children, date, disabled: disabledProps, formControl, fo
|
|
|
2757
2820
|
formControl?.touch();
|
|
2758
2821
|
setModalIsVisible(false);
|
|
2759
2822
|
}, [formControl, onChange]);
|
|
2760
|
-
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-date", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, 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("input", { className: "rls-field-date__control", type: "text", value: status.label, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), !readOnly && (jsxRuntimeExports.jsx(
|
|
2823
|
+
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-date", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, 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("input", { className: "rls-field-date__control", type: "text", value: status.label, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), !readOnly && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: status.icon, onClick: onClickAction, disabled: disabled }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }), jsxRuntimeExports.jsx(RlsModal, { className: "rls-field-date-modal", visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerDate, { formControl: formControl, date: date, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: onListener }) })] }));
|
|
2761
2824
|
}
|
|
2762
2825
|
|
|
2763
2826
|
function rangeFormatTemplate({ maxDate, minDate }) {
|
|
@@ -2872,7 +2935,7 @@ function RlsFieldDateRange({ children, date, disabled: disabledProps, formContro
|
|
|
2872
2935
|
formControl?.touch();
|
|
2873
2936
|
setModalIsVisible(false);
|
|
2874
2937
|
}, [formControl, onChange]);
|
|
2875
|
-
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-date-range", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, 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("input", { className: "rls-field-date-range__control", type: "text", value: status.valueInput, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), !readOnly && (jsxRuntimeExports.jsx(
|
|
2938
|
+
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-date-range", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, 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("input", { className: "rls-field-date-range__control", type: "text", value: status.valueInput, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), !readOnly && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: status.icon, onClick: onClickAction, disabled: disabled }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }), jsxRuntimeExports.jsx(RlsModal, { className: "rls-field-date-range-modal", visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerDateRange, { formControl: formControl, date: currentDate, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: onListener }) })] }));
|
|
2876
2939
|
}
|
|
2877
2940
|
|
|
2878
2941
|
function useFieldSelect(props) {
|
|
@@ -2990,13 +3053,756 @@ function RlsFieldSelectTemplate(props) {
|
|
|
2990
3053
|
props.readOnly,
|
|
2991
3054
|
disabled
|
|
2992
3055
|
]);
|
|
2993
|
-
return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: select.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("input", { ref: select.refInput, className: "rls-field-list__control", readOnly: true, placeholder: placeholder, value: select.value, onFocus: select.onFocusInput, onBlur: select.onBlurInput, onClick: select.onClickInput, onKeyDown: select.onKeydownInput, disabled: disabled }), !props.readOnly && (jsxRuntimeExports.jsx(
|
|
3056
|
+
return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: select.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("input", { ref: select.refInput, className: "rls-field-list__control", readOnly: true, placeholder: placeholder, value: select.value, onFocus: select.onFocusInput, onBlur: select.onBlurInput, onClick: select.onClickInput, onKeyDown: select.onKeydownInput, disabled: disabled }), !props.readOnly && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: !unremovable && !!select.value ? 'close' : 'arrow-ios-down', onClick: select.onClickAction, disabled: disabled }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsx(RlsFieldListSuggestions, { elements: suggestions, visible: select.listIsVisible, action: action, disabled: disabled, higher: select.higher, render: render, refList: select.refList, onClickElement: select.onClickElement, onKeydownElement: select.onKeydownElement, onClickBackdrop: select.onClickBackdrop })] }));
|
|
2994
3057
|
}
|
|
2995
3058
|
function RlsFieldSelect(props) {
|
|
2996
3059
|
const render = require$$0.useCallback((element) => (jsxRuntimeExports.jsx(RlsBallot, { className: "rls-field-list__ballot", subtitle: element.subtitle, img: element.img, initials: element.initials, children: jsxRuntimeExports.jsx("span", { children: element.title }) })), []);
|
|
2997
3060
|
return jsxRuntimeExports.jsx(RlsFieldSelectTemplate, { ...props, render: render });
|
|
2998
3061
|
}
|
|
2999
3062
|
|
|
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
|
+
function RlsPickerColor({ color, formControl, onListener, rlsTheme }) {
|
|
3395
|
+
const initialColor = require$$0.useMemo(() => formControl?.value ?? color ?? DEFAULT_COLOR, []);
|
|
3396
|
+
const initialHsv = require$$0.useMemo(() => hexToHsv(initialColor) ?? { h: 258, s: 100, v: 100 }, []);
|
|
3397
|
+
const canvasRef = require$$0.useRef(null);
|
|
3398
|
+
const hueRef = require$$0.useRef(null);
|
|
3399
|
+
const alphaRef = require$$0.useRef(null);
|
|
3400
|
+
const selectionIsActive = require$$0.useRef(false);
|
|
3401
|
+
const activeSlider = require$$0.useRef(null);
|
|
3402
|
+
const hexEditing = require$$0.useRef(false);
|
|
3403
|
+
const [hsv, setHsv] = require$$0.useState(initialHsv);
|
|
3404
|
+
const [alpha, setAlpha] = require$$0.useState(1);
|
|
3405
|
+
const [hexInput, setHexInput] = require$$0.useState(initialColor);
|
|
3406
|
+
const [labels, setLabels] = require$$0.useState({
|
|
3407
|
+
colorActionCancel: reactI18n('dateActionCancel'),
|
|
3408
|
+
colorActionSelect: reactI18n('dateActionSelect')
|
|
3409
|
+
});
|
|
3410
|
+
const hexColor = require$$0.useMemo(() => hsvToHex(hsv), [hsv]);
|
|
3411
|
+
const hexValue = require$$0.useMemo(() => {
|
|
3412
|
+
return hexInput.replace('#', '');
|
|
3413
|
+
}, [hexInput]);
|
|
3414
|
+
const canvasStyle = require$$0.useMemo(() => {
|
|
3415
|
+
const { r, g, b } = hsvToRgb({ h: hsv.h, s: 100, v: 100 });
|
|
3416
|
+
return {
|
|
3417
|
+
background: `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent), rgb(${r}, ${g}, ${b})`
|
|
3418
|
+
};
|
|
3419
|
+
}, [hsv.h]);
|
|
3420
|
+
const indicatorPosition = require$$0.useMemo(() => {
|
|
3421
|
+
return {
|
|
3422
|
+
left: `${(hsv.s / 100) * 100}%`,
|
|
3423
|
+
top: `${100 - (hsv.v / 100) * 100}%`
|
|
3424
|
+
};
|
|
3425
|
+
}, [hsv.s, hsv.v]);
|
|
3426
|
+
const hueSliderStyle = require$$0.useMemo(() => {
|
|
3427
|
+
return {
|
|
3428
|
+
background: 'linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%)'
|
|
3429
|
+
};
|
|
3430
|
+
}, []);
|
|
3431
|
+
const hueIndicatorStyle = require$$0.useMemo(() => {
|
|
3432
|
+
return { left: `${(hsv.h / 360) * 100}%`, backgroundColor: hexColor };
|
|
3433
|
+
}, [hsv.h, hexColor]);
|
|
3434
|
+
const alphaSliderStyle = require$$0.useMemo(() => {
|
|
3435
|
+
return {
|
|
3436
|
+
background: `linear-gradient(to right, transparent, ${hexColor})`
|
|
3437
|
+
};
|
|
3438
|
+
}, [hexColor]);
|
|
3439
|
+
const alphaIndicatorStyle = require$$0.useMemo(() => {
|
|
3440
|
+
return { left: `${alpha * 100}%`, backgroundColor: hexColor };
|
|
3441
|
+
}, [alpha, hexColor]);
|
|
3442
|
+
require$$0.useEffect(() => {
|
|
3443
|
+
!hexEditing.current && setHexInput(hexColor);
|
|
3444
|
+
}, [hexColor]);
|
|
3445
|
+
require$$0.useEffect(() => {
|
|
3446
|
+
return i18n.i18nSubscribe(() => {
|
|
3447
|
+
setLabels({
|
|
3448
|
+
colorActionCancel: reactI18n('dateActionCancel'),
|
|
3449
|
+
colorActionSelect: reactI18n('dateActionSelect')
|
|
3450
|
+
});
|
|
3451
|
+
});
|
|
3452
|
+
}, []);
|
|
3453
|
+
const getPositionInElement = require$$0.useCallback((element, clientX, clientY) => {
|
|
3454
|
+
const rect = element.getBoundingClientRect();
|
|
3455
|
+
return {
|
|
3456
|
+
x: (clientX - rect.left) / rect.width,
|
|
3457
|
+
y: (clientY - rect.top) / rect.height
|
|
3458
|
+
};
|
|
3459
|
+
}, []);
|
|
3460
|
+
const updateColorOnCanvas = require$$0.useEffectEvent((clientX, clientY) => {
|
|
3461
|
+
if (!canvasRef.current)
|
|
3462
|
+
return;
|
|
3463
|
+
const pos = getPositionInElement(canvasRef.current, clientX, clientY);
|
|
3464
|
+
setHsv((prev) => ({
|
|
3465
|
+
...prev,
|
|
3466
|
+
s: Math.round(Math.min(1, Math.max(0, pos.x)) * 100),
|
|
3467
|
+
v: Math.round(Math.min(1, Math.max(0, 1 - pos.y)) * 100)
|
|
3468
|
+
}));
|
|
3469
|
+
});
|
|
3470
|
+
const updateHueOnSlider = require$$0.useEffectEvent((clientX, clientY) => {
|
|
3471
|
+
if (!hueRef.current)
|
|
3472
|
+
return;
|
|
3473
|
+
const pos = getPositionInElement(hueRef.current, clientX, clientY);
|
|
3474
|
+
setHsv((prev) => ({
|
|
3475
|
+
...prev,
|
|
3476
|
+
h: Math.round(Math.min(1, Math.max(0, pos.x)) * 360)
|
|
3477
|
+
}));
|
|
3478
|
+
});
|
|
3479
|
+
const updateAlphaOnSlider = require$$0.useEffectEvent((clientX, clientY) => {
|
|
3480
|
+
if (!alphaRef.current)
|
|
3481
|
+
return;
|
|
3482
|
+
const pos = getPositionInElement(alphaRef.current, clientX, clientY);
|
|
3483
|
+
setAlpha(Math.min(1, Math.max(0, pos.x)));
|
|
3484
|
+
});
|
|
3485
|
+
const onMouseDown = require$$0.useCallback((event) => {
|
|
3486
|
+
const slider = event.currentTarget.dataset.slider;
|
|
3487
|
+
if (!slider)
|
|
3488
|
+
return;
|
|
3489
|
+
event.preventDefault();
|
|
3490
|
+
selectionIsActive.current = true;
|
|
3491
|
+
activeSlider.current = slider;
|
|
3492
|
+
switch (slider) {
|
|
3493
|
+
case 'canvas':
|
|
3494
|
+
updateColorOnCanvas(event.clientX, event.clientY);
|
|
3495
|
+
break;
|
|
3496
|
+
case 'hue':
|
|
3497
|
+
updateHueOnSlider(event.clientX, event.clientY);
|
|
3498
|
+
break;
|
|
3499
|
+
case 'alpha':
|
|
3500
|
+
updateAlphaOnSlider(event.clientX, event.clientY);
|
|
3501
|
+
break;
|
|
3502
|
+
}
|
|
3503
|
+
}, [updateColorOnCanvas, updateHueOnSlider, updateAlphaOnSlider]);
|
|
3504
|
+
const onMouseMove = require$$0.useCallback((event) => {
|
|
3505
|
+
if (!selectionIsActive.current || !activeSlider.current)
|
|
3506
|
+
return;
|
|
3507
|
+
event.preventDefault();
|
|
3508
|
+
switch (activeSlider.current) {
|
|
3509
|
+
case 'canvas':
|
|
3510
|
+
updateColorOnCanvas(event.clientX, event.clientY);
|
|
3511
|
+
break;
|
|
3512
|
+
case 'hue':
|
|
3513
|
+
updateHueOnSlider(event.clientX, event.clientY);
|
|
3514
|
+
break;
|
|
3515
|
+
case 'alpha':
|
|
3516
|
+
updateAlphaOnSlider(event.clientX, event.clientY);
|
|
3517
|
+
break;
|
|
3518
|
+
}
|
|
3519
|
+
}, [updateColorOnCanvas, updateHueOnSlider, updateAlphaOnSlider]);
|
|
3520
|
+
const onTouchStart = require$$0.useCallback((event) => {
|
|
3521
|
+
const slider = event.currentTarget.dataset.slider;
|
|
3522
|
+
if (!slider)
|
|
3523
|
+
return;
|
|
3524
|
+
const touch = event.touches.item(0);
|
|
3525
|
+
if (!touch)
|
|
3526
|
+
return;
|
|
3527
|
+
selectionIsActive.current = true;
|
|
3528
|
+
activeSlider.current = slider;
|
|
3529
|
+
switch (slider) {
|
|
3530
|
+
case 'canvas':
|
|
3531
|
+
updateColorOnCanvas(touch.clientX, touch.clientY);
|
|
3532
|
+
break;
|
|
3533
|
+
case 'hue':
|
|
3534
|
+
updateHueOnSlider(touch.clientX, touch.clientY);
|
|
3535
|
+
break;
|
|
3536
|
+
case 'alpha':
|
|
3537
|
+
updateAlphaOnSlider(touch.clientX, touch.clientY);
|
|
3538
|
+
break;
|
|
3539
|
+
}
|
|
3540
|
+
}, [updateColorOnCanvas, updateHueOnSlider, updateAlphaOnSlider]);
|
|
3541
|
+
const onTouchMove = require$$0.useCallback((event) => {
|
|
3542
|
+
const touch = event.touches.item(0);
|
|
3543
|
+
if (!selectionIsActive.current || !activeSlider.current || !touch)
|
|
3544
|
+
return;
|
|
3545
|
+
switch (activeSlider.current) {
|
|
3546
|
+
case 'canvas':
|
|
3547
|
+
updateColorOnCanvas(touch.clientX, touch.clientY);
|
|
3548
|
+
break;
|
|
3549
|
+
case 'hue':
|
|
3550
|
+
updateHueOnSlider(touch.clientX, touch.clientY);
|
|
3551
|
+
break;
|
|
3552
|
+
case 'alpha':
|
|
3553
|
+
updateAlphaOnSlider(touch.clientX, touch.clientY);
|
|
3554
|
+
break;
|
|
3555
|
+
}
|
|
3556
|
+
}, [updateColorOnCanvas, updateHueOnSlider, updateAlphaOnSlider]);
|
|
3557
|
+
const onInactiveSelection = require$$0.useCallback(() => {
|
|
3558
|
+
selectionIsActive.current = false;
|
|
3559
|
+
activeSlider.current = null;
|
|
3560
|
+
}, []);
|
|
3561
|
+
const onHexChange = require$$0.useCallback((value) => {
|
|
3562
|
+
setHexInput(value);
|
|
3563
|
+
const normalized = normalizeHex(value);
|
|
3564
|
+
if (normalized) {
|
|
3565
|
+
const hsv = hexToHsv(normalized);
|
|
3566
|
+
hsv && setHsv(hsv);
|
|
3567
|
+
}
|
|
3568
|
+
}, []);
|
|
3569
|
+
const onHexFocus = require$$0.useCallback(() => {
|
|
3570
|
+
hexEditing.current = true;
|
|
3571
|
+
}, []);
|
|
3572
|
+
const onHexBlur = require$$0.useEffectEvent(() => {
|
|
3573
|
+
hexEditing.current = false;
|
|
3574
|
+
const normalized = normalizeHex(hexInput);
|
|
3575
|
+
if (normalized) {
|
|
3576
|
+
setHexInput(normalized);
|
|
3577
|
+
}
|
|
3578
|
+
else {
|
|
3579
|
+
setHexInput(hexColor);
|
|
3580
|
+
}
|
|
3581
|
+
});
|
|
3582
|
+
const onHexKeyDown = require$$0.useCallback((event) => {
|
|
3583
|
+
event.key === 'Enter' && onHexBlur();
|
|
3584
|
+
}, [onHexBlur]);
|
|
3585
|
+
const onHexInputChange = require$$0.useCallback((event) => onHexChange(event.target.value ? `#${event.target.value}` : ''), [onHexChange]);
|
|
3586
|
+
const onCancel = require$$0.useCallback(() => {
|
|
3587
|
+
onListener?.({ event: components.PickerListenerEvent.Cancel });
|
|
3588
|
+
}, [onListener]);
|
|
3589
|
+
const onSelect = require$$0.useCallback(() => {
|
|
3590
|
+
formControl?.setValue(hexColor);
|
|
3591
|
+
onListener?.({ event: components.PickerListenerEvent.Select, value: hexColor });
|
|
3592
|
+
}, [formControl, hexColor, onListener]);
|
|
3593
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-color", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-color__preview", children: jsxRuntimeExports.jsx("div", { ref: canvasRef, className: "rls-picker-color__canvas", style: canvasStyle, "data-slider": "canvas", onMouseDown: onMouseDown, onMouseMove: onMouseMove, onMouseUp: onInactiveSelection, onMouseLeave: onInactiveSelection, onTouchStart: onTouchStart, onTouchMove: onTouchMove, onTouchEnd: onInactiveSelection, children: jsxRuntimeExports.jsx("div", { className: "rls-picker-color__indicator", style: {
|
|
3594
|
+
left: indicatorPosition.left,
|
|
3595
|
+
top: indicatorPosition.top
|
|
3596
|
+
}, children: jsxRuntimeExports.jsx("div", { className: "rls-picker-color__indicator__circle", style: { backgroundColor: hexColor } }) }) }) }), jsxRuntimeExports.jsxs("div", { className: "rls-picker-color__controls", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-color__slider", children: jsxRuntimeExports.jsx("div", { ref: hueRef, className: "rls-picker-color__slider__track", style: hueSliderStyle, "data-slider": "hue", onMouseDown: onMouseDown, onMouseMove: onMouseMove, onMouseUp: onInactiveSelection, onMouseLeave: onInactiveSelection, onTouchStart: onTouchStart, onTouchMove: onTouchMove, onTouchEnd: onInactiveSelection, children: jsxRuntimeExports.jsx("div", { className: "rls-picker-color__slider__thumb", style: hueIndicatorStyle }) }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-color__slider", children: jsxRuntimeExports.jsx("div", { ref: alphaRef, className: "rls-picker-color__slider__track rls-picker-color__slider__track--alpha", style: alphaSliderStyle, "data-slider": "alpha", onMouseDown: onMouseDown, onMouseMove: onMouseMove, onMouseUp: onInactiveSelection, onMouseLeave: onInactiveSelection, onTouchStart: onTouchStart, onTouchMove: onTouchMove, onTouchEnd: onInactiveSelection, children: jsxRuntimeExports.jsx("div", { className: "rls-picker-color__slider__thumb", style: alphaIndicatorStyle }) }) })] }), jsxRuntimeExports.jsx("div", { className: "rls-picker-color__footer", children: jsxRuntimeExports.jsxs("div", { className: "rls-picker-color__hex", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-color__hex__swatch", style: { backgroundColor: hexColor } }), jsxRuntimeExports.jsx("span", { className: "rls-picker-color__hex__prefix", children: "#" }), jsxRuntimeExports.jsx("input", { className: "rls-picker-color__hex__input", type: "text", maxLength: 6, value: hexValue, onChange: onHexInputChange, onFocus: onHexFocus, onBlur: onHexBlur, onKeyDown: onHexKeyDown })] }) }), jsxRuntimeExports.jsxs("div", { className: "rls-picker-color__actions", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-color__actions--cancel", children: jsxRuntimeExports.jsx(RlsButton, { type: "flat", onClick: onCancel, children: labels.colorActionCancel }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-color__actions--ok", children: jsxRuntimeExports.jsx(RlsButton, { type: "gradient", onClick: onSelect, children: labels.colorActionSelect }) })] })] }));
|
|
3597
|
+
}
|
|
3598
|
+
|
|
3599
|
+
function RlsFieldColor({ children, color, disabled: disabledProps, formControl, identifier, msgErrorDisabled, onValue, placeholder, readOnly, rlsTheme, value: valueInitial }) {
|
|
3600
|
+
const [value, setValue] = require$$0.useState(formControl?.value ?? valueInitial);
|
|
3601
|
+
const [modalIsVisible, setModalIsVisible] = require$$0.useState(false);
|
|
3602
|
+
const colorValue = require$$0.useMemo(() => {
|
|
3603
|
+
return formControl ? formControl.value : value;
|
|
3604
|
+
}, [formControl?.value, value]);
|
|
3605
|
+
const disabled = require$$0.useMemo(() => {
|
|
3606
|
+
return formControl?.disabled || disabledProps;
|
|
3607
|
+
}, [formControl?.disabled, disabledProps]);
|
|
3608
|
+
const className = require$$0.useMemo(() => {
|
|
3609
|
+
return renderClassStatus('rls-field-box', {
|
|
3610
|
+
disabled,
|
|
3611
|
+
readonly: readOnly
|
|
3612
|
+
});
|
|
3613
|
+
}, [disabled, readOnly]);
|
|
3614
|
+
const displayHex = require$$0.useMemo(() => {
|
|
3615
|
+
const hex = colorValue && hexIsValid(colorValue) ? colorValue : '';
|
|
3616
|
+
return normalizeHex(hex);
|
|
3617
|
+
}, [colorValue]);
|
|
3618
|
+
const onClickInput = require$$0.useCallback(() => {
|
|
3619
|
+
!readOnly && setModalIsVisible(true);
|
|
3620
|
+
}, [readOnly]);
|
|
3621
|
+
const onChange = require$$0.useCallback((value) => {
|
|
3622
|
+
setValue(value);
|
|
3623
|
+
onValue?.(value);
|
|
3624
|
+
}, [onValue]);
|
|
3625
|
+
const onClickAction = require$$0.useCallback(() => {
|
|
3626
|
+
if (colorValue) {
|
|
3627
|
+
formControl?.setValue(valueInitial);
|
|
3628
|
+
formControl?.touch();
|
|
3629
|
+
onChange(valueInitial);
|
|
3630
|
+
}
|
|
3631
|
+
else {
|
|
3632
|
+
setModalIsVisible(true);
|
|
3633
|
+
}
|
|
3634
|
+
}, [colorValue, formControl, valueInitial, onChange]);
|
|
3635
|
+
const onListener = require$$0.useCallback(({ event, value }) => {
|
|
3636
|
+
event !== components.PickerListenerEvent.Cancel && onChange(value);
|
|
3637
|
+
formControl?.touch();
|
|
3638
|
+
setModalIsVisible(false);
|
|
3639
|
+
}, [formControl, onChange]);
|
|
3640
|
+
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-color", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, 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: [displayHex && (jsxRuntimeExports.jsx("div", { className: "rls-field-color__swatch", style: { backgroundColor: displayHex } })), jsxRuntimeExports.jsx("input", { className: "rls-field-color__control", type: "text", value: displayHex, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), !readOnly && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: colorValue ? 'trash-2' : 'color-palette', onClick: onClickAction, disabled: disabled }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }), jsxRuntimeExports.jsx(RlsModal, { className: "rls-field-color-modal", visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerColor, { formControl: formControl, color: color, disabled: disabled, onListener: onListener }) })] }));
|
|
3641
|
+
}
|
|
3642
|
+
|
|
3643
|
+
const MAX_LIST_HEIGHT_REM = 90;
|
|
3644
|
+
const FALLBACK_REM_SIZE = 16;
|
|
3645
|
+
function getRemSize() {
|
|
3646
|
+
if (typeof window === 'undefined') {
|
|
3647
|
+
return FALLBACK_REM_SIZE;
|
|
3648
|
+
}
|
|
3649
|
+
const fontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
3650
|
+
return fontSize > 0 ? fontSize : FALLBACK_REM_SIZE;
|
|
3651
|
+
}
|
|
3652
|
+
function shouldDisplayHigher(content, list) {
|
|
3653
|
+
if (!content) {
|
|
3654
|
+
return false;
|
|
3655
|
+
}
|
|
3656
|
+
const { top, bottom } = content.getBoundingClientRect();
|
|
3657
|
+
const spaceAbove = top;
|
|
3658
|
+
const spaceBelow = window.innerHeight - bottom;
|
|
3659
|
+
const maxHeight = MAX_LIST_HEIGHT_REM * getRemSize();
|
|
3660
|
+
const desiredHeight = Math.min(list?.scrollHeight || maxHeight, maxHeight);
|
|
3661
|
+
if (spaceBelow >= desiredHeight) {
|
|
3662
|
+
return false;
|
|
3663
|
+
}
|
|
3664
|
+
if (spaceAbove >= desiredHeight) {
|
|
3665
|
+
return true;
|
|
3666
|
+
}
|
|
3667
|
+
return spaceAbove > spaceBelow;
|
|
3668
|
+
}
|
|
3669
|
+
function useFieldList(props) {
|
|
3670
|
+
const { suggestions, disabled } = props;
|
|
3671
|
+
const refContent = require$$0.useRef(null);
|
|
3672
|
+
const refList = require$$0.useRef(null);
|
|
3673
|
+
const formControl = props.formControl;
|
|
3674
|
+
const [state, setState] = require$$0.useState({
|
|
3675
|
+
higher: false,
|
|
3676
|
+
listIsVisible: false
|
|
3677
|
+
});
|
|
3678
|
+
const [selected, setSelected] = require$$0.useState([]);
|
|
3679
|
+
require$$0.useEffect(() => {
|
|
3680
|
+
function onCloseSuggestions({ target }) {
|
|
3681
|
+
!refContent?.current?.contains(target) &&
|
|
3682
|
+
setState((state) => ({ ...state, listIsVisible: false }));
|
|
3683
|
+
}
|
|
3684
|
+
document.addEventListener('click', onCloseSuggestions);
|
|
3685
|
+
return () => {
|
|
3686
|
+
document.removeEventListener('click', onCloseSuggestions);
|
|
3687
|
+
};
|
|
3688
|
+
}, []);
|
|
3689
|
+
require$$0.useEffect(() => {
|
|
3690
|
+
const formValue = formControl?.value;
|
|
3691
|
+
if (formValue !== undefined && formValue !== null && formValue.length) {
|
|
3692
|
+
const selectedElements = suggestions.filter((state) => formValue.some((value) => state.compareTo(value)));
|
|
3693
|
+
setSelected(selectedElements);
|
|
3694
|
+
}
|
|
3695
|
+
else {
|
|
3696
|
+
setSelected([]);
|
|
3697
|
+
}
|
|
3698
|
+
}, [formControl?.value, suggestions]);
|
|
3699
|
+
const setListState = require$$0.useCallback((updates) => {
|
|
3700
|
+
setState((state) => {
|
|
3701
|
+
const _updates = updates.listIsVisible !== undefined
|
|
3702
|
+
? {
|
|
3703
|
+
...updates,
|
|
3704
|
+
...(updates.listIsVisible
|
|
3705
|
+
? {
|
|
3706
|
+
higher: shouldDisplayHigher(refContent.current, refList.current)
|
|
3707
|
+
}
|
|
3708
|
+
: {})
|
|
3709
|
+
}
|
|
3710
|
+
: updates;
|
|
3711
|
+
return { ...state, ..._updates };
|
|
3712
|
+
});
|
|
3713
|
+
}, []);
|
|
3714
|
+
const toggleElement = require$$0.useCallback((element) => {
|
|
3715
|
+
const alreadySelected = selected.some((state) => state.compareTo(element.value));
|
|
3716
|
+
const newSelected = alreadySelected
|
|
3717
|
+
? selected.filter((state) => !state.compareTo(element.value))
|
|
3718
|
+
: [...selected, element];
|
|
3719
|
+
const newValues = newSelected.map((state) => state.value);
|
|
3720
|
+
setSelected(newSelected);
|
|
3721
|
+
formControl?.setValue(newValues);
|
|
3722
|
+
props.onValue?.(newValues);
|
|
3723
|
+
}, [selected, formControl, props.onValue]);
|
|
3724
|
+
const isSelected = require$$0.useCallback((element) => {
|
|
3725
|
+
return selected.some((state) => state.compareTo(element.value));
|
|
3726
|
+
}, [selected]);
|
|
3727
|
+
const onClickInput = require$$0.useCallback(() => {
|
|
3728
|
+
if (!props.readOnly) {
|
|
3729
|
+
setListState({ listIsVisible: true });
|
|
3730
|
+
}
|
|
3731
|
+
}, [setListState, props.readOnly]);
|
|
3732
|
+
const onClickBackdrop = require$$0.useCallback(() => {
|
|
3733
|
+
setListState({ listIsVisible: false });
|
|
3734
|
+
}, [setListState]);
|
|
3735
|
+
const onClickAction = require$$0.useCallback(() => {
|
|
3736
|
+
if (!disabled && !props.readOnly) {
|
|
3737
|
+
setListState({ listIsVisible: !state.listIsVisible });
|
|
3738
|
+
}
|
|
3739
|
+
}, [disabled, props.readOnly, setListState, state.listIsVisible]);
|
|
3740
|
+
const onClickElement = require$$0.useCallback((element) => {
|
|
3741
|
+
return () => {
|
|
3742
|
+
toggleElement(element);
|
|
3743
|
+
};
|
|
3744
|
+
}, [toggleElement]);
|
|
3745
|
+
const onRemoveElement = require$$0.useCallback((element) => {
|
|
3746
|
+
return (event) => {
|
|
3747
|
+
event.stopPropagation();
|
|
3748
|
+
const newSelected = selected.filter((state) => !state.compareTo(element.value));
|
|
3749
|
+
const newValues = newSelected.map((state) => state.value);
|
|
3750
|
+
setSelected(newSelected);
|
|
3751
|
+
formControl?.setValue(newValues);
|
|
3752
|
+
props.onValue?.(newValues);
|
|
3753
|
+
};
|
|
3754
|
+
}, [selected, formControl, props.onValue]);
|
|
3755
|
+
const onKeydownElement = require$$0.useCallback((element) => {
|
|
3756
|
+
return (event) => {
|
|
3757
|
+
event.code === 'Enter' && toggleElement(element);
|
|
3758
|
+
};
|
|
3759
|
+
}, [toggleElement]);
|
|
3760
|
+
return {
|
|
3761
|
+
...state,
|
|
3762
|
+
selected,
|
|
3763
|
+
refContent,
|
|
3764
|
+
refList,
|
|
3765
|
+
isSelected,
|
|
3766
|
+
onClickAction,
|
|
3767
|
+
onClickBackdrop,
|
|
3768
|
+
onClickElement,
|
|
3769
|
+
onClickInput,
|
|
3770
|
+
onKeydownElement,
|
|
3771
|
+
onRemoveElement
|
|
3772
|
+
};
|
|
3773
|
+
}
|
|
3774
|
+
|
|
3775
|
+
function RlsFieldListInner({ render, suggestions, action, children, formControl, fieldList, msgErrorDisabled, placeholder, rlsTheme, ...props }) {
|
|
3776
|
+
const disabled = require$$0.useMemo(() => {
|
|
3777
|
+
return formControl?.disabled || props.disabled;
|
|
3778
|
+
}, [formControl?.disabled, props.disabled]);
|
|
3779
|
+
const className = require$$0.useMemo(() => {
|
|
3780
|
+
return renderClassStatus('rls-field-box', {
|
|
3781
|
+
focused: fieldList.listIsVisible && !disabled,
|
|
3782
|
+
error: formControl?.wrong,
|
|
3783
|
+
disabled,
|
|
3784
|
+
readonly: props.readOnly
|
|
3785
|
+
}, `rls-field-list rls-field-list__multi ${props.className ?? ''}`);
|
|
3786
|
+
}, [
|
|
3787
|
+
formControl?.wrong,
|
|
3788
|
+
fieldList.listIsVisible,
|
|
3789
|
+
props.className,
|
|
3790
|
+
props.readOnly,
|
|
3791
|
+
disabled
|
|
3792
|
+
]);
|
|
3793
|
+
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]);
|
|
3794
|
+
return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: fieldList.refContent, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__multi__chips", onClick: disabled ? undefined : fieldList.onClickInput, children: !fieldList.selected.length && placeholder ? (jsxRuntimeExports.jsx("span", { className: "rls-field-list__multi__placeholder", children: placeholder })) : (fieldList.selected.map((item, index) => (jsxRuntimeExports.jsxs("div", { className: "rls-field-list__multi__chip", children: [jsxRuntimeExports.jsx("span", { className: "rls-field-list__multi__chip__description", children: item.description }), !props.readOnly && (jsxRuntimeExports.jsx("button", { className: "rls-field-list__multi__chip__remove", onClick: fieldList.onRemoveElement(item), disabled: disabled, children: jsxRuntimeExports.jsx(RlsIcon, { value: "close" }) }))] }, index)))) }), !props.readOnly && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: "arrow-ios-down", onClick: fieldList.onClickAction, disabled: disabled }))] }) }), !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, refList: fieldList.refList, onClickElement: fieldList.onClickElement, onKeydownElement: fieldList.onKeydownElement, onClickBackdrop: fieldList.onClickBackdrop })] }));
|
|
3795
|
+
}
|
|
3796
|
+
function RlsFieldListTemplate(props) {
|
|
3797
|
+
const fieldList = useFieldList(props);
|
|
3798
|
+
return jsxRuntimeExports.jsx(RlsFieldListInner, { ...props, fieldList: fieldList });
|
|
3799
|
+
}
|
|
3800
|
+
function RlsFieldList(props) {
|
|
3801
|
+
const fieldList = useFieldList(props);
|
|
3802
|
+
const render = require$$0.useCallback((element) => (jsxRuntimeExports.jsx(RlsBallot, { className: "rls-field-list__ballot", subtitle: element.subtitle, img: element.img, initials: element.initials, children: jsxRuntimeExports.jsx("span", { children: element.title }) })), []);
|
|
3803
|
+
return jsxRuntimeExports.jsx(RlsFieldListInner, { ...props, render: render, fieldList: fieldList });
|
|
3804
|
+
}
|
|
3805
|
+
|
|
3000
3806
|
function RlsFormNavigation({ children, className, controller, visible, rlsTheme }) {
|
|
3001
3807
|
const classNameForm = require$$0.useMemo(() => {
|
|
3002
3808
|
return renderClassStatus('rls-form-navigation', { visible: controller?.visible ?? visible }, className);
|
|
@@ -3429,13 +4235,14 @@ function RlsImageChooser(props) {
|
|
|
3429
4235
|
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] }));
|
|
3430
4236
|
}
|
|
3431
4237
|
|
|
3432
|
-
function RlsModalSheet({ children, className, onAutoClose, visible, rlsTheme }) {
|
|
4238
|
+
function RlsModalSheet({ autoclose, children, className, controller, onAutoClose, visible, rlsTheme }) {
|
|
3433
4239
|
const classNameModal = require$$0.useMemo(() => {
|
|
3434
|
-
return renderClassStatus('rls-modal-sheet', { visible }, className);
|
|
3435
|
-
}, [className, visible]);
|
|
4240
|
+
return renderClassStatus('rls-modal-sheet', { visible: controller?.visible ?? visible }, className);
|
|
4241
|
+
}, [className, visible, controller?.visible]);
|
|
3436
4242
|
const onClickBackdrop = require$$0.useCallback(() => {
|
|
4243
|
+
autoclose && controller?.close();
|
|
3437
4244
|
onAutoClose?.();
|
|
3438
|
-
}, [onAutoClose]);
|
|
4245
|
+
}, [autoclose, controller, onAutoClose]);
|
|
3439
4246
|
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);
|
|
3440
4247
|
}
|
|
3441
4248
|
|
|
@@ -3621,6 +4428,7 @@ function usePortalController() {
|
|
|
3621
4428
|
}
|
|
3622
4429
|
|
|
3623
4430
|
exports.ConfirmationResult = ConfirmationResult;
|
|
4431
|
+
exports.DEFAULT_COLOR = DEFAULT_COLOR;
|
|
3624
4432
|
exports.RlsAccordion = RlsAccordion;
|
|
3625
4433
|
exports.RlsAlert = RlsAlert;
|
|
3626
4434
|
exports.RlsAmount = RlsAmount;
|
|
@@ -3634,8 +4442,10 @@ exports.RlsBottomSheet = RlsBottomSheet;
|
|
|
3634
4442
|
exports.RlsBreadcrumb = RlsBreadcrumb;
|
|
3635
4443
|
exports.RlsButton = RlsButton;
|
|
3636
4444
|
exports.RlsButtonAction = RlsButtonAction;
|
|
4445
|
+
exports.RlsButtonIcon = RlsButtonIcon;
|
|
3637
4446
|
exports.RlsButtonOption = RlsButtonOption;
|
|
3638
4447
|
exports.RlsButtonProgress = RlsButtonProgress;
|
|
4448
|
+
exports.RlsButtonStepper = RlsButtonStepper;
|
|
3639
4449
|
exports.RlsButtonToggle = RlsButtonToggle;
|
|
3640
4450
|
exports.RlsCard = RlsCard;
|
|
3641
4451
|
exports.RlsCheckBox = RlsCheckBox;
|
|
@@ -3657,11 +4467,14 @@ exports.RlsFieldArea = RlsFieldArea;
|
|
|
3657
4467
|
exports.RlsFieldAutocomplete = RlsFieldAutocomplete;
|
|
3658
4468
|
exports.RlsFieldAutocompleteTemplate = RlsFieldAutocompleteTemplate;
|
|
3659
4469
|
exports.RlsFieldClock = RlsFieldClock;
|
|
4470
|
+
exports.RlsFieldColor = RlsFieldColor;
|
|
3660
4471
|
exports.RlsFieldDate = RlsFieldDate;
|
|
3661
4472
|
exports.RlsFieldDateRange = RlsFieldDateRange;
|
|
3662
4473
|
exports.RlsFieldDecimal = RlsFieldDecimal;
|
|
3663
4474
|
exports.RlsFieldFile = RlsFieldFile;
|
|
4475
|
+
exports.RlsFieldList = RlsFieldList;
|
|
3664
4476
|
exports.RlsFieldListSuggestions = RlsFieldListSuggestions;
|
|
4477
|
+
exports.RlsFieldListTemplate = RlsFieldListTemplate;
|
|
3665
4478
|
exports.RlsFieldMoney = RlsFieldMoney;
|
|
3666
4479
|
exports.RlsFieldNumber = RlsFieldNumber;
|
|
3667
4480
|
exports.RlsFieldPassword = RlsFieldPassword;
|
|
@@ -3676,6 +4489,7 @@ exports.RlsImage = RlsImage;
|
|
|
3676
4489
|
exports.RlsImageChooser = RlsImageChooser;
|
|
3677
4490
|
exports.RlsImageEditor = RlsImageEditor;
|
|
3678
4491
|
exports.RlsInput = RlsInput;
|
|
4492
|
+
exports.RlsInputCounter = RlsInputCounter;
|
|
3679
4493
|
exports.RlsInputDecimal = RlsInputDecimal;
|
|
3680
4494
|
exports.RlsInputMoney = RlsInputMoney;
|
|
3681
4495
|
exports.RlsInputNumber = RlsInputNumber;
|
|
@@ -3697,6 +4511,7 @@ exports.RlsNavbar = RlsNavbar;
|
|
|
3697
4511
|
exports.RlsNavbarMenu = RlsNavbarMenu;
|
|
3698
4512
|
exports.RlsPagination = RlsPagination;
|
|
3699
4513
|
exports.RlsPickerClock = RlsPickerClock;
|
|
4514
|
+
exports.RlsPickerColor = RlsPickerColor;
|
|
3700
4515
|
exports.RlsPickerDate = RlsPickerDate;
|
|
3701
4516
|
exports.RlsPickerDateRange = RlsPickerDateRange;
|
|
3702
4517
|
exports.RlsPickerDay = RlsPickerDay;
|
|
@@ -3719,13 +4534,27 @@ exports.RlsTabs = RlsTabs;
|
|
|
3719
4534
|
exports.RlsTabularText = RlsTabularText;
|
|
3720
4535
|
exports.RlsToolbar = RlsToolbar;
|
|
3721
4536
|
exports.calculateImgDimension = calculateImgDimension;
|
|
4537
|
+
exports.generateThemePalette = generateThemePalette;
|
|
4538
|
+
exports.hexIsValid = hexIsValid;
|
|
4539
|
+
exports.hexToHsl = hexToHsl;
|
|
4540
|
+
exports.hexToHsv = hexToHsv;
|
|
4541
|
+
exports.hexToRgb = hexToRgb;
|
|
4542
|
+
exports.hslToHex = hslToHex;
|
|
4543
|
+
exports.hsvToHex = hsvToHex;
|
|
4544
|
+
exports.hsvToRgb = hsvToRgb;
|
|
4545
|
+
exports.normalizeHex = normalizeHex;
|
|
3722
4546
|
exports.rangeFormatTemplate = rangeFormatTemplate;
|
|
3723
4547
|
exports.renderClassStatus = renderClassStatus;
|
|
4548
|
+
exports.rgbToHex = rgbToHex;
|
|
4549
|
+
exports.rgbToHsl = rgbToHsl;
|
|
4550
|
+
exports.rgbToHsv = rgbToHsv;
|
|
3724
4551
|
exports.setErrorsI18n = setErrorsI18n;
|
|
4552
|
+
exports.setThemeColor = setThemeColor;
|
|
3725
4553
|
exports.useConfirmation = useConfirmation;
|
|
3726
4554
|
exports.useDatatable = useDatatable;
|
|
3727
4555
|
exports.useDropdownController = useDropdownController;
|
|
3728
4556
|
exports.useFieldAutocomplete = useFieldAutocomplete;
|
|
4557
|
+
exports.useFieldList = useFieldList;
|
|
3729
4558
|
exports.useFieldSelect = useFieldSelect;
|
|
3730
4559
|
exports.useFormSingleSelectionController = useFormSingleSelectionController;
|
|
3731
4560
|
exports.useFormToggleController = useFormToggleController;
|