@rolster/react-components 18.15.14 → 18.15.21
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.js +68 -69
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.js +68 -69
- package/dist/es/index.js.map +1 -1
- package/dist/esm/components/atoms/Input/Input.d.ts +2 -2
- package/dist/esm/components/atoms/Input/Input.js +1 -1
- package/dist/esm/components/atoms/Input/Input.js.map +1 -1
- package/dist/esm/components/atoms/InputMoney/InputMoney.d.ts +3 -8
- package/dist/esm/components/atoms/InputMoney/InputMoney.js +1 -1
- package/dist/esm/components/atoms/InputMoney/InputMoney.js.map +1 -1
- package/dist/esm/components/atoms/InputNumber/InputNumber.d.ts +2 -10
- package/dist/esm/components/atoms/InputNumber/InputNumber.js +1 -1
- package/dist/esm/components/atoms/InputNumber/InputNumber.js.map +1 -1
- package/dist/esm/components/atoms/InputPassword/InputPassword.d.ts +4 -4
- package/dist/esm/components/atoms/InputPassword/InputPassword.js +1 -1
- package/dist/esm/components/atoms/InputPassword/InputPassword.js.map +1 -1
- package/dist/esm/components/atoms/InputSearch/InputSearch.d.ts +3 -3
- package/dist/esm/components/atoms/InputSearch/InputSearch.js +1 -1
- package/dist/esm/components/atoms/InputSearch/InputSearch.js.map +1 -1
- package/dist/esm/components/atoms/InputText/InputText.d.ts +2 -10
- package/dist/esm/components/atoms/InputText/InputText.js +2 -2
- package/dist/esm/components/atoms/InputText/InputText.js.map +1 -1
- package/dist/esm/components/molecules/FieldMoney/FieldMoney.d.ts +3 -9
- package/dist/esm/components/molecules/FieldMoney/FieldMoney.js +2 -2
- package/dist/esm/components/molecules/FieldMoney/FieldMoney.js.map +1 -1
- package/dist/esm/components/molecules/FieldNumber/FieldNumber.d.ts +2 -11
- package/dist/esm/components/molecules/FieldNumber/FieldNumber.js +2 -2
- package/dist/esm/components/molecules/FieldNumber/FieldNumber.js.map +1 -1
- package/dist/esm/components/molecules/FieldPassword/FieldPassword.d.ts +4 -3
- package/dist/esm/components/molecules/FieldPassword/FieldPassword.js +2 -2
- package/dist/esm/components/molecules/FieldPassword/FieldPassword.js.map +1 -1
- package/dist/esm/components/molecules/FieldText/FieldText.d.ts +2 -11
- package/dist/esm/components/molecules/FieldText/FieldText.js +2 -2
- package/dist/esm/components/molecules/FieldText/FieldText.js.map +1 -1
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.d.ts +1 -0
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js +4 -4
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js.map +1 -1
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteHook.js +10 -11
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteHook.js.map +1 -1
- 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/FieldSelect/FieldSelect.d.ts +2 -1
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.js +5 -5
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.js.map +1 -1
- package/dist/esm/components/organisms/FieldSelect/FieldSelectHook.js +11 -11
- package/dist/esm/components/organisms/FieldSelect/FieldSelectHook.js.map +1 -1
- package/dist/esm/components/types.d.ts +13 -0
- package/dist/esm/components/types.js +2 -0
- package/dist/esm/components/types.js.map +1 -0
- package/dist/esm/hooks/ListControlHook.d.ts +2 -4
- package/dist/esm/hooks/ListControlHook.js +19 -19
- package/dist/esm/hooks/ListControlHook.js.map +1 -1
- package/package.json +2 -2
package/dist/es/index.js
CHANGED
|
@@ -1416,7 +1416,7 @@ function RlsCheckBoxControl({ formControl, disabled, rlsTheme }) {
|
|
|
1416
1416
|
}, rlsTheme: rlsTheme }));
|
|
1417
1417
|
}
|
|
1418
1418
|
|
|
1419
|
-
function RlsInput({ children, disabled, formControl, placeholder, type, value
|
|
1419
|
+
function RlsInput({ children, disabled, formControl, onValue, placeholder, type, value }) {
|
|
1420
1420
|
const [focused, setFocused] = useState(false);
|
|
1421
1421
|
function setValue(value) {
|
|
1422
1422
|
formControl?.setValue(value);
|
|
@@ -1439,7 +1439,7 @@ function RlsInput({ children, disabled, formControl, placeholder, type, value, o
|
|
|
1439
1439
|
}), children: [jsxRuntimeExports.jsx("input", { ref: formControl?.elementRef, className: "rls-input__component", autoComplete: "off", type: type ?? 'text', placeholder: placeholder, disabled: formControl?.disabled ?? disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange, value: formControl?.value ?? value ?? '' }), jsxRuntimeExports.jsx("span", { className: "rls-input__value", children: children })] }));
|
|
1440
1440
|
}
|
|
1441
1441
|
|
|
1442
|
-
function RlsInputMoney({ decimals, disabled, formControl, placeholder, symbol, value
|
|
1442
|
+
function RlsInputMoney({ decimals, disabled, formControl, onValue, placeholder, symbol, value }) {
|
|
1443
1443
|
const [valueInput, setValueInput] = useState(value || 0);
|
|
1444
1444
|
function onChange(value) {
|
|
1445
1445
|
!formControl && setValueInput(value);
|
|
@@ -1448,7 +1448,7 @@ function RlsInputMoney({ decimals, disabled, formControl, placeholder, symbol, v
|
|
|
1448
1448
|
return (jsxRuntimeExports.jsx("div", { className: "rls-input-money", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue: onChange, children: jsxRuntimeExports.jsx(RlsAmount, { value: formControl?.value ?? value ?? valueInput, symbol: symbol, decimals: decimals }) }) }));
|
|
1449
1449
|
}
|
|
1450
1450
|
|
|
1451
|
-
function RlsInputNumber({ disabled, formControl, placeholder, value
|
|
1451
|
+
function RlsInputNumber({ disabled, formControl, onValue, placeholder, value }) {
|
|
1452
1452
|
const [valueInput, setValueInput] = useState(value ?? 0);
|
|
1453
1453
|
function onChange(value) {
|
|
1454
1454
|
!formControl && setValueInput(value);
|
|
@@ -1457,7 +1457,7 @@ function RlsInputNumber({ disabled, formControl, placeholder, value, onValue })
|
|
|
1457
1457
|
return (jsxRuntimeExports.jsx("div", { className: "rls-input-number", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue: onChange, children: formControl?.value ?? value ?? valueInput }) }));
|
|
1458
1458
|
}
|
|
1459
1459
|
|
|
1460
|
-
function RlsInputPassword({ disabled, formControl, placeholder, type
|
|
1460
|
+
function RlsInputPassword({ disabled, formControl, onValue, placeholder, type }) {
|
|
1461
1461
|
const [focused, setFocused] = useState(false);
|
|
1462
1462
|
function onChange(event) {
|
|
1463
1463
|
formControl?.setValue(event.target.value);
|
|
@@ -1477,12 +1477,12 @@ function RlsInputPassword({ disabled, formControl, placeholder, type, onValue })
|
|
|
1477
1477
|
}), children: jsxRuntimeExports.jsx("input", { className: "rls-input-password__component", autoComplete: "off", type: type ?? 'password', placeholder: placeholder, disabled: disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange }) }));
|
|
1478
1478
|
}
|
|
1479
1479
|
|
|
1480
|
-
function RlsInputSearch({ formControl,
|
|
1480
|
+
function RlsInputSearch({ formControl, onSearch, placeholder }) {
|
|
1481
1481
|
return (jsxRuntimeExports.jsxs("div", { className: "rls-input-search", children: [jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, placeholder: placeholder }), onSearch && jsxRuntimeExports.jsx(RlsButtonAction, { icon: "search", onClick: onSearch })] }));
|
|
1482
1482
|
}
|
|
1483
1483
|
|
|
1484
|
-
function RlsInputText({ disabled, formControl, placeholder, value
|
|
1485
|
-
const [valueInput, setValueInput] = useState(value
|
|
1484
|
+
function RlsInputText({ disabled, formControl, onValue, placeholder, value }) {
|
|
1485
|
+
const [valueInput, setValueInput] = useState(value ?? '');
|
|
1486
1486
|
function onChange(value) {
|
|
1487
1487
|
!formControl && setValueInput(value);
|
|
1488
1488
|
onValue && onValue(value);
|
|
@@ -1575,23 +1575,23 @@ function RlsMessageFormError({ className, formControl }) {
|
|
|
1575
1575
|
return (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: formControl?.wrong && (jsxRuntimeExports.jsx("div", { className: className, children: jsxRuntimeExports.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl?.error?.message }) })) }));
|
|
1576
1576
|
}
|
|
1577
1577
|
|
|
1578
|
-
function RlsFieldMoney({ children, decimals, disabled, formControl, placeholder, symbol, rlsTheme, value
|
|
1578
|
+
function RlsFieldMoney({ children, decimals, disabled, formControl, msgErrorDisabled, onValue, placeholder, symbol, rlsTheme, value }) {
|
|
1579
1579
|
return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-box', {
|
|
1580
1580
|
focused: formControl?.focused,
|
|
1581
1581
|
error: formControl?.wrong,
|
|
1582
1582
|
disabled: formControl?.disabled || disabled
|
|
1583
|
-
}, 'rls-field-money'), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsInputMoney, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, symbol: symbol, decimals: decimals, onValue: onValue }) }) }), jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }));
|
|
1583
|
+
}, 'rls-field-money'), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsInputMoney, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, symbol: symbol, decimals: decimals, onValue: onValue }) }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
|
|
1584
1584
|
}
|
|
1585
1585
|
|
|
1586
|
-
function RlsFieldNumber({ children, disabled, formControl, placeholder, rlsTheme, value
|
|
1586
|
+
function RlsFieldNumber({ children, disabled, formControl, msgErrorDisabled, onValue, placeholder, rlsTheme, value }) {
|
|
1587
1587
|
return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-box', {
|
|
1588
1588
|
focused: formControl?.focused,
|
|
1589
1589
|
error: formControl?.wrong,
|
|
1590
1590
|
disabled: formControl?.disabled || disabled
|
|
1591
|
-
}, 'rls-field-number'), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsInputNumber, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, onValue: onValue }) }) }), jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }));
|
|
1591
|
+
}, 'rls-field-number'), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsInputNumber, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, onValue: onValue }) }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
|
|
1592
1592
|
}
|
|
1593
1593
|
|
|
1594
|
-
function RlsFieldPassword({ children, disabled, formControl, placeholder, rlsTheme }) {
|
|
1594
|
+
function RlsFieldPassword({ children, disabled, formControl, msgErrorDisabled, placeholder, rlsTheme }) {
|
|
1595
1595
|
const [password, setPassword] = useState(true);
|
|
1596
1596
|
function onToggleInput() {
|
|
1597
1597
|
setPassword(!password);
|
|
@@ -1600,15 +1600,15 @@ function RlsFieldPassword({ children, disabled, formControl, placeholder, rlsThe
|
|
|
1600
1600
|
focused: formControl?.focused,
|
|
1601
1601
|
error: formControl?.wrong,
|
|
1602
1602
|
disabled: formControl?.disabled || disabled
|
|
1603
|
-
}, 'rls-field-password'), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { 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(RlsInputPassword, { formControl: formControl, disabled: disabled, placeholder: placeholder, type: password ? 'password' : 'text' }), jsxRuntimeExports.jsx(RlsButtonAction, { icon: password ? 'eye' : 'eye-off', onClick: onToggleInput })] }) }), jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }));
|
|
1603
|
+
}, 'rls-field-password'), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { 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(RlsInputPassword, { formControl: formControl, disabled: disabled, placeholder: placeholder, type: password ? 'password' : 'text' }), jsxRuntimeExports.jsx(RlsButtonAction, { icon: password ? 'eye' : 'eye-off', onClick: onToggleInput })] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
|
|
1604
1604
|
}
|
|
1605
1605
|
|
|
1606
|
-
function RlsFieldText({ children, disabled, formControl, placeholder, rlsTheme, value
|
|
1606
|
+
function RlsFieldText({ children, disabled, formControl, msgErrorDisabled, onValue, placeholder, rlsTheme, value }) {
|
|
1607
1607
|
return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-box', {
|
|
1608
1608
|
focused: formControl?.focused,
|
|
1609
1609
|
error: formControl?.wrong,
|
|
1610
1610
|
disabled: formControl?.disabled || disabled
|
|
1611
|
-
}, 'rls-field-text'), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsInputText, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, onValue: onValue }) }) }), jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }));
|
|
1611
|
+
}, 'rls-field-text'), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsInputText, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, onValue: onValue }) }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
|
|
1612
1612
|
}
|
|
1613
1613
|
|
|
1614
1614
|
function RlsLabelCheckBox({ children, disabled, extended, formControl, rlsTheme }) {
|
|
@@ -2065,11 +2065,12 @@ function useListControl({ suggestions, formControl }) {
|
|
|
2065
2065
|
const contentRef = useRef(null);
|
|
2066
2066
|
const listRef = useRef(null);
|
|
2067
2067
|
const inputRef = useRef(null);
|
|
2068
|
+
const listIsOpen = useRef(false);
|
|
2068
2069
|
const [state, setState] = useState({
|
|
2069
2070
|
focused: false,
|
|
2070
2071
|
higher: false,
|
|
2071
2072
|
value: '',
|
|
2072
|
-
|
|
2073
|
+
listIsVisible: false
|
|
2073
2074
|
});
|
|
2074
2075
|
const collection = useRef(new ListCollection([]));
|
|
2075
2076
|
const position = useRef(0);
|
|
@@ -2077,7 +2078,7 @@ function useListControl({ suggestions, formControl }) {
|
|
|
2077
2078
|
useEffect(() => {
|
|
2078
2079
|
function onCloseSuggestions({ target }) {
|
|
2079
2080
|
!contentRef?.current?.contains(target) &&
|
|
2080
|
-
setState((state) => ({ ...state,
|
|
2081
|
+
setState((state) => ({ ...state, listIsVisible: false }));
|
|
2081
2082
|
}
|
|
2082
2083
|
document.addEventListener('click', onCloseSuggestions);
|
|
2083
2084
|
return () => {
|
|
@@ -2085,28 +2086,36 @@ function useListControl({ suggestions, formControl }) {
|
|
|
2085
2086
|
};
|
|
2086
2087
|
}, []);
|
|
2087
2088
|
useEffect(() => {
|
|
2089
|
+
if (!listIsOpen.current && state.listIsVisible) {
|
|
2090
|
+
listIsOpen.current = true;
|
|
2091
|
+
}
|
|
2092
|
+
if (listIsOpen.current && !state.listIsVisible) {
|
|
2093
|
+
formControl?.touch();
|
|
2094
|
+
}
|
|
2088
2095
|
setState((state) => ({
|
|
2089
2096
|
...state,
|
|
2090
2097
|
higher: locationListCanTop(contentRef.current, listRef.current)
|
|
2091
2098
|
}));
|
|
2092
|
-
}, [state.
|
|
2099
|
+
}, [state.listIsVisible]);
|
|
2093
2100
|
useEffect(() => {
|
|
2094
2101
|
collection.current = new ListCollection(suggestions);
|
|
2095
2102
|
refresh(collection.current, formControl?.value);
|
|
2096
2103
|
}, [suggestions, formControl?.value]);
|
|
2097
2104
|
function refresh(collection, state) {
|
|
2098
2105
|
if (!state) {
|
|
2099
|
-
return refreshProtected(collection)
|
|
2106
|
+
return refreshProtected(collection)
|
|
2107
|
+
? undefined
|
|
2108
|
+
: refreshState({ value: '' });
|
|
2100
2109
|
}
|
|
2101
2110
|
const element = collection.find(state);
|
|
2102
2111
|
if (element) {
|
|
2103
2112
|
protectedValue.current = undefined;
|
|
2104
|
-
return
|
|
2113
|
+
return refreshState({ value: element.description });
|
|
2105
2114
|
}
|
|
2106
2115
|
if (!refreshProtected(collection)) {
|
|
2107
2116
|
protectedValue.current = state;
|
|
2108
|
-
setValue('');
|
|
2109
2117
|
setFormValue(undefined);
|
|
2118
|
+
refreshState({ value: '' });
|
|
2110
2119
|
}
|
|
2111
2120
|
}
|
|
2112
2121
|
function refreshProtected(collection) {
|
|
@@ -2120,21 +2129,14 @@ function useListControl({ suggestions, formControl }) {
|
|
|
2120
2129
|
}
|
|
2121
2130
|
return false;
|
|
2122
2131
|
}
|
|
2123
|
-
function
|
|
2124
|
-
setState((
|
|
2125
|
-
}
|
|
2126
|
-
function setValue(value) {
|
|
2127
|
-
setState((state) => ({ ...state, value }));
|
|
2132
|
+
function refreshState(state) {
|
|
2133
|
+
setState((currentState) => ({ ...currentState, ...state }));
|
|
2128
2134
|
}
|
|
2129
2135
|
function setFormValue(value) {
|
|
2130
2136
|
formControl?.setValue(value);
|
|
2131
2137
|
}
|
|
2132
|
-
function setVisible(visible) {
|
|
2133
|
-
setState((state) => ({ ...state, visible }));
|
|
2134
|
-
!visible && formControl?.touch();
|
|
2135
|
-
}
|
|
2136
2138
|
function navigationInput(event) {
|
|
2137
|
-
if (state.
|
|
2139
|
+
if (state.listIsVisible) {
|
|
2138
2140
|
const newPosition = navigationListFromInput({
|
|
2139
2141
|
content: contentRef.current,
|
|
2140
2142
|
event: event,
|
|
@@ -2159,10 +2161,8 @@ function useListControl({ suggestions, formControl }) {
|
|
|
2159
2161
|
listRef,
|
|
2160
2162
|
navigationElement,
|
|
2161
2163
|
navigationInput,
|
|
2162
|
-
setFocused,
|
|
2163
2164
|
setFormValue,
|
|
2164
|
-
|
|
2165
|
-
setVisible
|
|
2165
|
+
setState: refreshState
|
|
2166
2166
|
};
|
|
2167
2167
|
}
|
|
2168
2168
|
|
|
@@ -2172,12 +2172,12 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
|
|
|
2172
2172
|
const [pattern, setPattern] = useState('');
|
|
2173
2173
|
const [coincidences, setCoincidences] = useState([]);
|
|
2174
2174
|
const currentStore = useRef({
|
|
2175
|
-
pattern: '',
|
|
2176
2175
|
coincidences: [],
|
|
2176
|
+
pattern: '',
|
|
2177
2177
|
previous: null
|
|
2178
2178
|
});
|
|
2179
2179
|
const listControl = useListControl({ suggestions, formControl });
|
|
2180
|
-
const { inputRef, navigationElement, navigationInput,
|
|
2180
|
+
const { inputRef, navigationElement, navigationInput, setFormValue, setState } = listControl;
|
|
2181
2181
|
useEffect(() => {
|
|
2182
2182
|
refreshCoincidences(pattern, true);
|
|
2183
2183
|
}, [suggestions]);
|
|
@@ -2186,23 +2186,23 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
|
|
|
2186
2186
|
}, [pattern]);
|
|
2187
2187
|
function onClickControl() {
|
|
2188
2188
|
if (!disabled) {
|
|
2189
|
-
|
|
2189
|
+
setState({ listIsVisible: true });
|
|
2190
2190
|
setTimeout(() => {
|
|
2191
2191
|
inputRef?.current?.focus();
|
|
2192
2192
|
}, DURATION_ANIMATION$1);
|
|
2193
2193
|
}
|
|
2194
2194
|
}
|
|
2195
2195
|
function onFocusInput() {
|
|
2196
|
-
|
|
2196
|
+
setState({ focused: true });
|
|
2197
2197
|
}
|
|
2198
2198
|
function onBlurInput() {
|
|
2199
|
-
|
|
2199
|
+
setState({ focused: false });
|
|
2200
2200
|
}
|
|
2201
2201
|
function onKeydownInput(event) {
|
|
2202
2202
|
switch (event.code) {
|
|
2203
2203
|
case 'Escape':
|
|
2204
2204
|
case 'Tab':
|
|
2205
|
-
|
|
2205
|
+
setState({ listIsVisible: false });
|
|
2206
2206
|
break;
|
|
2207
2207
|
default:
|
|
2208
2208
|
navigationInput(event);
|
|
@@ -2210,13 +2210,12 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
|
|
|
2210
2210
|
}
|
|
2211
2211
|
}
|
|
2212
2212
|
function onClickAction() {
|
|
2213
|
-
|
|
2214
|
-
setValue('');
|
|
2213
|
+
setState({ listIsVisible: false, value: '' });
|
|
2215
2214
|
setFormValue(undefined);
|
|
2216
2215
|
onValue && onValue(undefined);
|
|
2217
2216
|
}
|
|
2218
2217
|
function onClickBackdrop() {
|
|
2219
|
-
|
|
2218
|
+
setState({ listIsVisible: false });
|
|
2220
2219
|
}
|
|
2221
2220
|
function onClickElement(element) {
|
|
2222
2221
|
return () => {
|
|
@@ -2229,13 +2228,13 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
|
|
|
2229
2228
|
};
|
|
2230
2229
|
}
|
|
2231
2230
|
function onChange({ description, value }) {
|
|
2232
|
-
setVisible(false);
|
|
2233
2231
|
if (onSelect) {
|
|
2232
|
+
setState({ listIsVisible: false });
|
|
2234
2233
|
onSelect(value);
|
|
2235
2234
|
}
|
|
2236
2235
|
else {
|
|
2236
|
+
setState({ listIsVisible: false, value: description });
|
|
2237
2237
|
setFormValue(value);
|
|
2238
|
-
setValue(description);
|
|
2239
2238
|
}
|
|
2240
2239
|
onValue && onValue(value);
|
|
2241
2240
|
}
|
|
@@ -2267,15 +2266,15 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
|
|
|
2267
2266
|
|
|
2268
2267
|
function RlsFieldAutocompleteTemplate(props) {
|
|
2269
2268
|
const fieldAutocomplete = useFieldAutocomplete(props);
|
|
2270
|
-
const { render, children, disabled, formControl, hiddenIcon, onSearch, placeholder, rlsTheme, searching } = props;
|
|
2269
|
+
const { render, children, disabled, formControl, hiddenIcon, msgErrorDisabled, onSearch, placeholder, rlsTheme, searching } = props;
|
|
2271
2270
|
return (jsxRuntimeExports.jsxs("div", { ref: fieldAutocomplete.listControl.contentRef, className: renderClassStatus('rls-field-box', {
|
|
2272
2271
|
disabled,
|
|
2273
2272
|
focused: fieldAutocomplete.listControl.focused,
|
|
2274
2273
|
error: formControl?.wrong,
|
|
2275
2274
|
selected: !!fieldAutocomplete.listControl.value
|
|
2276
|
-
}, 'rls-field-list rls-field-autocomplete'), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { 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: fieldAutocomplete.listControl.value, onClick: fieldAutocomplete.onClickControl }), !hiddenIcon && fieldAutocomplete.listControl.value && (jsxRuntimeExports.jsx("button", { className: "rls-field-list__action", disabled: disabled, onClick: fieldAutocomplete.onClickAction, children: jsxRuntimeExports.jsx(RlsIcon, { value: "trash-2" }) }))] }) }), jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }), jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-list__suggestions', {
|
|
2277
|
-
visible: fieldAutocomplete.listControl.
|
|
2278
|
-
hide: !fieldAutocomplete.listControl.
|
|
2275
|
+
}, 'rls-field-list rls-field-autocomplete'), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { 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: fieldAutocomplete.listControl.value, onClick: fieldAutocomplete.onClickControl }), !hiddenIcon && fieldAutocomplete.listControl.value && (jsxRuntimeExports.jsx("button", { className: "rls-field-list__action", disabled: disabled, onClick: fieldAutocomplete.onClickAction, children: jsxRuntimeExports.jsx(RlsIcon, { value: "trash-2" }) }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-list__suggestions', {
|
|
2276
|
+
visible: fieldAutocomplete.listControl.listIsVisible,
|
|
2277
|
+
hide: !fieldAutocomplete.listControl.listIsVisible,
|
|
2279
2278
|
higher: fieldAutocomplete.listControl.higher
|
|
2280
2279
|
}), children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__suggestions__body", children: jsxRuntimeExports.jsxs("ul", { ref: fieldAutocomplete.listControl.listRef, className: "rls-field-list__ul", children: [jsxRuntimeExports.jsxs("div", { className: "rls-field-list__ul__search", children: [jsxRuntimeExports.jsx("input", { ref: fieldAutocomplete.listControl.inputRef, className: "rls-field-list__ul__control", type: "text", placeholder: reactI18n('listInputPlaceholder'), value: fieldAutocomplete.pattern, onChange: ({ target: { value } }) => {
|
|
2281
2280
|
fieldAutocomplete.setPattern(value);
|
|
@@ -2360,7 +2359,7 @@ function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDat
|
|
|
2360
2359
|
}
|
|
2361
2360
|
|
|
2362
2361
|
const FORMAT_DATE = '{dd}/{mx}/{aa}';
|
|
2363
|
-
function RlsFieldDate({ children, date, disabled, formControl, format, maxDate, minDate, onValue, placeholder, rlsTheme }) {
|
|
2362
|
+
function RlsFieldDate({ children, date, disabled, formControl, format, maxDate, minDate, msgErrorDisabled, onValue, placeholder, rlsTheme }) {
|
|
2364
2363
|
const today = new Date(); // Initial current date in component
|
|
2365
2364
|
const [value, setValue] = useState();
|
|
2366
2365
|
const [modalIsVisible, setModalIsVisible] = useState(false);
|
|
@@ -2393,7 +2392,7 @@ function RlsFieldDate({ children, date, disabled, formControl, format, maxDate,
|
|
|
2393
2392
|
const valueInput = value
|
|
2394
2393
|
? dateFormatTemplate(value, format || FORMAT_DATE)
|
|
2395
2394
|
: '';
|
|
2396
|
-
return (jsxRuntimeExports.jsxs("div", { className: "rls-field-date", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-box', { disabled }), children: [children && jsxRuntimeExports.jsx("label", { 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: valueInput, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), jsxRuntimeExports.jsx("button", { className: "rls-field-date__action", onClick: onClickAction, disabled: disabled, children: jsxRuntimeExports.jsx(RlsIcon, { value: value ? 'trash-2' : 'calendar' }) })] }) }), jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }), jsxRuntimeExports.jsx(RlsModal, { visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerDate, { formControl: formControl, date: date, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value, type }) => {
|
|
2395
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-field-date", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-box', { disabled }), children: [children && jsxRuntimeExports.jsx("label", { 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: valueInput, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), jsxRuntimeExports.jsx("button", { className: "rls-field-date__action", onClick: onClickAction, disabled: disabled, children: jsxRuntimeExports.jsx(RlsIcon, { value: value ? 'trash-2' : 'calendar' }) })] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }), jsxRuntimeExports.jsx(RlsModal, { visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerDate, { formControl: formControl, date: date, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value, type }) => {
|
|
2397
2396
|
type !== PickerListenerType.Cancel && onChange(value);
|
|
2398
2397
|
formControl?.touch();
|
|
2399
2398
|
setModalIsVisible(false);
|
|
@@ -2452,7 +2451,7 @@ function RlsPickerDateRange({ automatic, date: datePicker, disabled, formControl
|
|
|
2452
2451
|
}), children: jsxRuntimeExports.jsxs("div", { className: "rls-picker-date-range__actions", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__actions--cancel", children: jsxRuntimeExports.jsx(RlsButton, { type: "ghost", onClick: onCancel, children: reactI18n('dateActionCancel') }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__actions--ok", children: jsxRuntimeExports.jsx(RlsButton, { type: "raised", onClick: onSelect, children: reactI18n('dateActionSelect') }) })] }) })] }));
|
|
2453
2452
|
}
|
|
2454
2453
|
|
|
2455
|
-
function RlsFieldDateRange({ children, date: datePicker, disabled, formControl, maxDate, minDate, placeholder, rlsTheme }) {
|
|
2454
|
+
function RlsFieldDateRange({ children, date: datePicker, disabled, formControl, maxDate, minDate, msgErrorDisabled, placeholder, rlsTheme }) {
|
|
2456
2455
|
const currentRange = formControl?.value || DateRange.now();
|
|
2457
2456
|
const currentDate = datePicker || new Date();
|
|
2458
2457
|
const [value, setValue] = useState(currentRange);
|
|
@@ -2469,7 +2468,7 @@ function RlsFieldDateRange({ children, date: datePicker, disabled, formControl,
|
|
|
2469
2468
|
setModalIsVisible(true);
|
|
2470
2469
|
}
|
|
2471
2470
|
}
|
|
2472
|
-
return (jsxRuntimeExports.jsxs("div", { className: "rls-field-date-range", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-box', { disabled }), children: [children && jsxRuntimeExports.jsx("label", { 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: value ? rangeFormatTemplate(value) : '', readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), jsxRuntimeExports.jsx("button", { className: "rls-field-date-range__action", onClick: onClickAction, disabled: disabled, children: jsxRuntimeExports.jsx(RlsIcon, { value: value ? 'trash-2' : 'calendar' }) })] }) }), jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }), jsxRuntimeExports.jsx(RlsModal, { visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerDateRange, { formControl: formControl, date: currentDate, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value }) => {
|
|
2471
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-field-date-range", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-box', { disabled }), children: [children && jsxRuntimeExports.jsx("label", { 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: value ? rangeFormatTemplate(value) : '', readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), jsxRuntimeExports.jsx("button", { className: "rls-field-date-range__action", onClick: onClickAction, disabled: disabled, children: jsxRuntimeExports.jsx(RlsIcon, { value: value ? 'trash-2' : 'calendar' }) })] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }), jsxRuntimeExports.jsx(RlsModal, { visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerDateRange, { formControl: formControl, date: currentDate, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value }) => {
|
|
2473
2472
|
value && setValue(value);
|
|
2474
2473
|
setModalIsVisible(false);
|
|
2475
2474
|
} }) })] }));
|
|
@@ -2477,25 +2476,25 @@ function RlsFieldDateRange({ children, date: datePicker, disabled, formControl,
|
|
|
2477
2476
|
|
|
2478
2477
|
function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
|
|
2479
2478
|
const listControl = useListControl({ suggestions, formControl });
|
|
2480
|
-
const { inputRef,
|
|
2479
|
+
const { inputRef, listIsVisible, navigationElement, navigationInput, setFormValue, setState } = listControl;
|
|
2481
2480
|
function onFocusInput() {
|
|
2482
|
-
|
|
2481
|
+
setState({ focused: true });
|
|
2483
2482
|
}
|
|
2484
2483
|
function onBlurInput() {
|
|
2485
|
-
|
|
2484
|
+
setState({ focused: false });
|
|
2486
2485
|
}
|
|
2487
2486
|
function onClickInput() {
|
|
2488
|
-
|
|
2487
|
+
setState({ listIsVisible: true });
|
|
2489
2488
|
}
|
|
2490
2489
|
function onKeydownInput(event) {
|
|
2491
2490
|
switch (event.code) {
|
|
2492
2491
|
case 'Space':
|
|
2493
2492
|
case 'Enter':
|
|
2494
|
-
|
|
2493
|
+
setState({ listIsVisible: true });
|
|
2495
2494
|
break;
|
|
2496
2495
|
case 'Escape':
|
|
2497
2496
|
case 'Tab':
|
|
2498
|
-
|
|
2497
|
+
setState({ listIsVisible: false });
|
|
2499
2498
|
break;
|
|
2500
2499
|
default:
|
|
2501
2500
|
navigationInput(event);
|
|
@@ -2503,11 +2502,11 @@ function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
|
|
|
2503
2502
|
}
|
|
2504
2503
|
}
|
|
2505
2504
|
function onClickAction() {
|
|
2506
|
-
|
|
2507
|
-
!
|
|
2505
|
+
setState({ listIsVisible: !listIsVisible });
|
|
2506
|
+
!listIsVisible && inputRef?.current?.focus();
|
|
2508
2507
|
}
|
|
2509
2508
|
function onClickBackdrop() {
|
|
2510
|
-
|
|
2509
|
+
setState({ listIsVisible: false });
|
|
2511
2510
|
}
|
|
2512
2511
|
function onClickElement(element) {
|
|
2513
2512
|
return () => {
|
|
@@ -2521,13 +2520,13 @@ function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
|
|
|
2521
2520
|
}
|
|
2522
2521
|
function onChange({ description, value }) {
|
|
2523
2522
|
inputRef?.current?.focus();
|
|
2524
|
-
setVisible(false);
|
|
2525
2523
|
if (onSelect) {
|
|
2524
|
+
setState({ listIsVisible: false });
|
|
2526
2525
|
onSelect(value);
|
|
2527
2526
|
}
|
|
2528
2527
|
else {
|
|
2529
2528
|
setFormValue(value);
|
|
2530
|
-
|
|
2529
|
+
setState({ listIsVisible: false, value: description });
|
|
2531
2530
|
}
|
|
2532
2531
|
onValue && onValue(value);
|
|
2533
2532
|
}
|
|
@@ -2546,16 +2545,16 @@ function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
|
|
|
2546
2545
|
|
|
2547
2546
|
function RlsFieldSelectTemplate(props) {
|
|
2548
2547
|
const fieldSelect = useFieldSelect(props);
|
|
2549
|
-
const { render, suggestions, children, disabled, formControl, placeholder, rlsTheme } = props;
|
|
2548
|
+
const { render, suggestions, children, disabled, formControl, msgErrorDisabled, placeholder, rlsTheme } = props;
|
|
2550
2549
|
return (jsxRuntimeExports.jsxs("div", { ref: fieldSelect.listControl.contentRef, className: renderClassStatus('rls-field-box', {
|
|
2551
2550
|
focused: fieldSelect.listControl.focused,
|
|
2552
2551
|
error: formControl?.wrong,
|
|
2553
2552
|
disabled
|
|
2554
2553
|
}, 'rls-field-list rls-field-select'), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { 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: fieldSelect.listControl.inputRef, className: "rls-field-list__control", readOnly: true, disabled: disabled, placeholder: placeholder, value: fieldSelect.listControl.value, onFocus: fieldSelect.onFocusInput, onBlur: fieldSelect.onBlurInput, onClick: fieldSelect.onClickInput, onKeyDown: fieldSelect.onKeydownInput }), jsxRuntimeExports.jsx("button", { className: renderClassStatus('rls-field-list__action', {
|
|
2555
|
-
visible: fieldSelect.listControl.
|
|
2556
|
-
}), disabled: disabled, onClick: fieldSelect.onClickAction, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrow-ios-down" }) })] }) }), jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }), jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-list__suggestions', {
|
|
2557
|
-
visible: fieldSelect.listControl.
|
|
2558
|
-
hide: !fieldSelect.listControl.
|
|
2554
|
+
visible: fieldSelect.listControl.listIsVisible
|
|
2555
|
+
}), disabled: disabled, onClick: fieldSelect.onClickAction, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrow-ios-down" }) })] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-list__suggestions', {
|
|
2556
|
+
visible: fieldSelect.listControl.listIsVisible,
|
|
2557
|
+
hide: !fieldSelect.listControl.listIsVisible,
|
|
2559
2558
|
higher: fieldSelect.listControl.higher
|
|
2560
2559
|
}), children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__suggestions__body", children: jsxRuntimeExports.jsxs("ul", { ref: fieldSelect.listControl.listRef, className: "rls-field-list__ul", children: [suggestions.map((element, index) => (jsxRuntimeExports.jsx("li", { className: "rls-field-list__element", tabIndex: -1, onClick: fieldSelect.onClickElement(element), onKeyDown: fieldSelect.onKeydownElement(element), children: render(element) }, index))), !suggestions.length && (jsxRuntimeExports.jsx("li", { className: "rls-field-list__empty", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-list__empty__description", children: [jsxRuntimeExports.jsx("label", { className: "rls-label-bold truncate", children: reactI18n('listEmptyTitle') }), jsxRuntimeExports.jsx("p", { className: "rls-caption-regular", children: reactI18n('listEmptyDescription') })] }) }))] }) }), jsxRuntimeExports.jsx("div", { className: "rls-field-list__backdrop", onClick: fieldSelect.onClickBackdrop })] })] }));
|
|
2561
2560
|
}
|