@rolster/react-components 18.15.13 → 18.15.20
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 +78 -84
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.js +78 -84
- 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 +2 -1
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js +7 -11
- 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 +3 -2
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.js +12 -13
- 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,29 +2086,36 @@ function useListControl({ suggestions, formControl }) {
|
|
|
2085
2086
|
};
|
|
2086
2087
|
}, []);
|
|
2087
2088
|
useEffect(() => {
|
|
2088
|
-
|
|
2089
|
+
if (!listIsOpen.current && state.listIsVisible) {
|
|
2090
|
+
listIsOpen.current = true;
|
|
2091
|
+
}
|
|
2092
|
+
if (listIsOpen.current && !state.listIsVisible) {
|
|
2093
|
+
formControl?.touch();
|
|
2094
|
+
}
|
|
2089
2095
|
setState((state) => ({
|
|
2090
2096
|
...state,
|
|
2091
2097
|
higher: locationListCanTop(contentRef.current, listRef.current)
|
|
2092
2098
|
}));
|
|
2093
|
-
}, [state.
|
|
2099
|
+
}, [state.listIsVisible]);
|
|
2094
2100
|
useEffect(() => {
|
|
2095
2101
|
collection.current = new ListCollection(suggestions);
|
|
2096
2102
|
refresh(collection.current, formControl?.value);
|
|
2097
2103
|
}, [suggestions, formControl?.value]);
|
|
2098
2104
|
function refresh(collection, state) {
|
|
2099
2105
|
if (!state) {
|
|
2100
|
-
return refreshProtected(collection)
|
|
2106
|
+
return refreshProtected(collection)
|
|
2107
|
+
? undefined
|
|
2108
|
+
: refreshState({ value: '' });
|
|
2101
2109
|
}
|
|
2102
2110
|
const element = collection.find(state);
|
|
2103
2111
|
if (element) {
|
|
2104
2112
|
protectedValue.current = undefined;
|
|
2105
|
-
return
|
|
2113
|
+
return refreshState({ value: element.description });
|
|
2106
2114
|
}
|
|
2107
2115
|
if (!refreshProtected(collection)) {
|
|
2108
2116
|
protectedValue.current = state;
|
|
2109
|
-
setValue('');
|
|
2110
2117
|
setFormValue(undefined);
|
|
2118
|
+
refreshState({ value: '' });
|
|
2111
2119
|
}
|
|
2112
2120
|
}
|
|
2113
2121
|
function refreshProtected(collection) {
|
|
@@ -2121,20 +2129,14 @@ function useListControl({ suggestions, formControl }) {
|
|
|
2121
2129
|
}
|
|
2122
2130
|
return false;
|
|
2123
2131
|
}
|
|
2124
|
-
function
|
|
2125
|
-
setState((
|
|
2126
|
-
}
|
|
2127
|
-
function setValue(value) {
|
|
2128
|
-
setState((state) => ({ ...state, value }));
|
|
2132
|
+
function refreshState(state) {
|
|
2133
|
+
setState((currentState) => ({ ...currentState, state }));
|
|
2129
2134
|
}
|
|
2130
2135
|
function setFormValue(value) {
|
|
2131
2136
|
formControl?.setValue(value);
|
|
2132
2137
|
}
|
|
2133
|
-
function setVisible(visible) {
|
|
2134
|
-
setState((state) => ({ ...state, visible }));
|
|
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
|
}
|
|
@@ -2265,21 +2264,17 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
|
|
|
2265
2264
|
};
|
|
2266
2265
|
}
|
|
2267
2266
|
|
|
2268
|
-
function RlsFieldAutocompleteTemplate(
|
|
2269
|
-
const fieldAutocomplete = useFieldAutocomplete(
|
|
2270
|
-
|
|
2271
|
-
disabled,
|
|
2272
|
-
formControl,
|
|
2273
|
-
onSelect,
|
|
2274
|
-
onValue
|
|
2275
|
-
});
|
|
2267
|
+
function RlsFieldAutocompleteTemplate(props) {
|
|
2268
|
+
const fieldAutocomplete = useFieldAutocomplete(props);
|
|
2269
|
+
const { render, children, disabled, formControl, hiddenIcon, msgErrorDisabled, onSearch, placeholder, rlsTheme, searching } = props;
|
|
2276
2270
|
return (jsxRuntimeExports.jsxs("div", { ref: fieldAutocomplete.listControl.contentRef, className: renderClassStatus('rls-field-box', {
|
|
2277
2271
|
disabled,
|
|
2278
2272
|
focused: fieldAutocomplete.listControl.focused,
|
|
2273
|
+
error: formControl?.wrong,
|
|
2279
2274
|
selected: !!fieldAutocomplete.listControl.value
|
|
2280
|
-
}, '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', {
|
|
2281
|
-
visible: fieldAutocomplete.listControl.
|
|
2282
|
-
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,
|
|
2283
2278
|
higher: fieldAutocomplete.listControl.higher
|
|
2284
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 } }) => {
|
|
2285
2280
|
fieldAutocomplete.setPattern(value);
|
|
@@ -2364,7 +2359,7 @@ function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDat
|
|
|
2364
2359
|
}
|
|
2365
2360
|
|
|
2366
2361
|
const FORMAT_DATE = '{dd}/{mx}/{aa}';
|
|
2367
|
-
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 }) {
|
|
2368
2363
|
const today = new Date(); // Initial current date in component
|
|
2369
2364
|
const [value, setValue] = useState();
|
|
2370
2365
|
const [modalIsVisible, setModalIsVisible] = useState(false);
|
|
@@ -2397,7 +2392,7 @@ function RlsFieldDate({ children, date, disabled, formControl, format, maxDate,
|
|
|
2397
2392
|
const valueInput = value
|
|
2398
2393
|
? dateFormatTemplate(value, format || FORMAT_DATE)
|
|
2399
2394
|
: '';
|
|
2400
|
-
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 }) => {
|
|
2401
2396
|
type !== PickerListenerType.Cancel && onChange(value);
|
|
2402
2397
|
formControl?.touch();
|
|
2403
2398
|
setModalIsVisible(false);
|
|
@@ -2456,7 +2451,7 @@ function RlsPickerDateRange({ automatic, date: datePicker, disabled, formControl
|
|
|
2456
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') }) })] }) })] }));
|
|
2457
2452
|
}
|
|
2458
2453
|
|
|
2459
|
-
function RlsFieldDateRange({ children, date: datePicker, disabled, formControl, maxDate, minDate, placeholder, rlsTheme }) {
|
|
2454
|
+
function RlsFieldDateRange({ children, date: datePicker, disabled, formControl, maxDate, minDate, msgErrorDisabled, placeholder, rlsTheme }) {
|
|
2460
2455
|
const currentRange = formControl?.value || DateRange.now();
|
|
2461
2456
|
const currentDate = datePicker || new Date();
|
|
2462
2457
|
const [value, setValue] = useState(currentRange);
|
|
@@ -2473,7 +2468,7 @@ function RlsFieldDateRange({ children, date: datePicker, disabled, formControl,
|
|
|
2473
2468
|
setModalIsVisible(true);
|
|
2474
2469
|
}
|
|
2475
2470
|
}
|
|
2476
|
-
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 }) => {
|
|
2477
2472
|
value && setValue(value);
|
|
2478
2473
|
setModalIsVisible(false);
|
|
2479
2474
|
} }) })] }));
|
|
@@ -2481,25 +2476,25 @@ function RlsFieldDateRange({ children, date: datePicker, disabled, formControl,
|
|
|
2481
2476
|
|
|
2482
2477
|
function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
|
|
2483
2478
|
const listControl = useListControl({ suggestions, formControl });
|
|
2484
|
-
const { inputRef,
|
|
2479
|
+
const { inputRef, listIsVisible, navigationElement, navigationInput, setFormValue, setState } = listControl;
|
|
2485
2480
|
function onFocusInput() {
|
|
2486
|
-
|
|
2481
|
+
setState({ focused: true });
|
|
2487
2482
|
}
|
|
2488
2483
|
function onBlurInput() {
|
|
2489
|
-
|
|
2484
|
+
setState({ focused: false });
|
|
2490
2485
|
}
|
|
2491
2486
|
function onClickInput() {
|
|
2492
|
-
|
|
2487
|
+
setState({ listIsVisible: true });
|
|
2493
2488
|
}
|
|
2494
2489
|
function onKeydownInput(event) {
|
|
2495
2490
|
switch (event.code) {
|
|
2496
2491
|
case 'Space':
|
|
2497
2492
|
case 'Enter':
|
|
2498
|
-
|
|
2493
|
+
setState({ listIsVisible: true });
|
|
2499
2494
|
break;
|
|
2500
2495
|
case 'Escape':
|
|
2501
2496
|
case 'Tab':
|
|
2502
|
-
|
|
2497
|
+
setState({ listIsVisible: false });
|
|
2503
2498
|
break;
|
|
2504
2499
|
default:
|
|
2505
2500
|
navigationInput(event);
|
|
@@ -2507,11 +2502,11 @@ function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
|
|
|
2507
2502
|
}
|
|
2508
2503
|
}
|
|
2509
2504
|
function onClickAction() {
|
|
2510
|
-
|
|
2511
|
-
!
|
|
2505
|
+
setState({ listIsVisible: !listIsVisible });
|
|
2506
|
+
!listIsVisible && inputRef?.current?.focus();
|
|
2512
2507
|
}
|
|
2513
2508
|
function onClickBackdrop() {
|
|
2514
|
-
|
|
2509
|
+
setState({ listIsVisible: false });
|
|
2515
2510
|
}
|
|
2516
2511
|
function onClickElement(element) {
|
|
2517
2512
|
return () => {
|
|
@@ -2525,13 +2520,13 @@ function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
|
|
|
2525
2520
|
}
|
|
2526
2521
|
function onChange({ description, value }) {
|
|
2527
2522
|
inputRef?.current?.focus();
|
|
2528
|
-
setVisible(false);
|
|
2529
2523
|
if (onSelect) {
|
|
2524
|
+
setState({ listIsVisible: false });
|
|
2530
2525
|
onSelect(value);
|
|
2531
2526
|
}
|
|
2532
2527
|
else {
|
|
2533
2528
|
setFormValue(value);
|
|
2534
|
-
|
|
2529
|
+
setState({ listIsVisible: false, value: description });
|
|
2535
2530
|
}
|
|
2536
2531
|
onValue && onValue(value);
|
|
2537
2532
|
}
|
|
@@ -2548,19 +2543,18 @@ function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
|
|
|
2548
2543
|
};
|
|
2549
2544
|
}
|
|
2550
2545
|
|
|
2551
|
-
function RlsFieldSelectTemplate(
|
|
2552
|
-
const fieldSelect = useFieldSelect(
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
hide: !fieldSelect.listControl.visible,
|
|
2546
|
+
function RlsFieldSelectTemplate(props) {
|
|
2547
|
+
const fieldSelect = useFieldSelect(props);
|
|
2548
|
+
const { render, suggestions, children, disabled, formControl, msgErrorDisabled, placeholder, rlsTheme } = props;
|
|
2549
|
+
return (jsxRuntimeExports.jsxs("div", { ref: fieldSelect.listControl.contentRef, className: renderClassStatus('rls-field-box', {
|
|
2550
|
+
focused: fieldSelect.listControl.focused,
|
|
2551
|
+
error: formControl?.wrong,
|
|
2552
|
+
disabled
|
|
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', {
|
|
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,
|
|
2564
2558
|
higher: fieldSelect.listControl.higher
|
|
2565
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 })] })] }));
|
|
2566
2560
|
}
|