@rolster/react-components 18.15.14 → 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 +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/cjs/index.js
CHANGED
|
@@ -1418,7 +1418,7 @@ function RlsCheckBoxControl({ formControl, disabled, rlsTheme }) {
|
|
|
1418
1418
|
}, rlsTheme: rlsTheme }));
|
|
1419
1419
|
}
|
|
1420
1420
|
|
|
1421
|
-
function RlsInput({ children, disabled, formControl, placeholder, type, value
|
|
1421
|
+
function RlsInput({ children, disabled, formControl, onValue, placeholder, type, value }) {
|
|
1422
1422
|
const [focused, setFocused] = require$$0.useState(false);
|
|
1423
1423
|
function setValue(value) {
|
|
1424
1424
|
formControl?.setValue(value);
|
|
@@ -1441,7 +1441,7 @@ function RlsInput({ children, disabled, formControl, placeholder, type, value, o
|
|
|
1441
1441
|
}), 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 })] }));
|
|
1442
1442
|
}
|
|
1443
1443
|
|
|
1444
|
-
function RlsInputMoney({ decimals, disabled, formControl, placeholder, symbol, value
|
|
1444
|
+
function RlsInputMoney({ decimals, disabled, formControl, onValue, placeholder, symbol, value }) {
|
|
1445
1445
|
const [valueInput, setValueInput] = require$$0.useState(value || 0);
|
|
1446
1446
|
function onChange(value) {
|
|
1447
1447
|
!formControl && setValueInput(value);
|
|
@@ -1450,7 +1450,7 @@ function RlsInputMoney({ decimals, disabled, formControl, placeholder, symbol, v
|
|
|
1450
1450
|
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 }) }) }));
|
|
1451
1451
|
}
|
|
1452
1452
|
|
|
1453
|
-
function RlsInputNumber({ disabled, formControl, placeholder, value
|
|
1453
|
+
function RlsInputNumber({ disabled, formControl, onValue, placeholder, value }) {
|
|
1454
1454
|
const [valueInput, setValueInput] = require$$0.useState(value ?? 0);
|
|
1455
1455
|
function onChange(value) {
|
|
1456
1456
|
!formControl && setValueInput(value);
|
|
@@ -1459,7 +1459,7 @@ function RlsInputNumber({ disabled, formControl, placeholder, value, onValue })
|
|
|
1459
1459
|
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 }) }));
|
|
1460
1460
|
}
|
|
1461
1461
|
|
|
1462
|
-
function RlsInputPassword({ disabled, formControl, placeholder, type
|
|
1462
|
+
function RlsInputPassword({ disabled, formControl, onValue, placeholder, type }) {
|
|
1463
1463
|
const [focused, setFocused] = require$$0.useState(false);
|
|
1464
1464
|
function onChange(event) {
|
|
1465
1465
|
formControl?.setValue(event.target.value);
|
|
@@ -1479,12 +1479,12 @@ function RlsInputPassword({ disabled, formControl, placeholder, type, onValue })
|
|
|
1479
1479
|
}), children: jsxRuntimeExports.jsx("input", { className: "rls-input-password__component", autoComplete: "off", type: type ?? 'password', placeholder: placeholder, disabled: disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange }) }));
|
|
1480
1480
|
}
|
|
1481
1481
|
|
|
1482
|
-
function RlsInputSearch({ formControl,
|
|
1482
|
+
function RlsInputSearch({ formControl, onSearch, placeholder }) {
|
|
1483
1483
|
return (jsxRuntimeExports.jsxs("div", { className: "rls-input-search", children: [jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, placeholder: placeholder }), onSearch && jsxRuntimeExports.jsx(RlsButtonAction, { icon: "search", onClick: onSearch })] }));
|
|
1484
1484
|
}
|
|
1485
1485
|
|
|
1486
|
-
function RlsInputText({ disabled, formControl, placeholder, value
|
|
1487
|
-
const [valueInput, setValueInput] = require$$0.useState(value
|
|
1486
|
+
function RlsInputText({ disabled, formControl, onValue, placeholder, value }) {
|
|
1487
|
+
const [valueInput, setValueInput] = require$$0.useState(value ?? '');
|
|
1488
1488
|
function onChange(value) {
|
|
1489
1489
|
!formControl && setValueInput(value);
|
|
1490
1490
|
onValue && onValue(value);
|
|
@@ -1577,23 +1577,23 @@ function RlsMessageFormError({ className, formControl }) {
|
|
|
1577
1577
|
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 }) })) }));
|
|
1578
1578
|
}
|
|
1579
1579
|
|
|
1580
|
-
function RlsFieldMoney({ children, decimals, disabled, formControl, placeholder, symbol, rlsTheme, value
|
|
1580
|
+
function RlsFieldMoney({ children, decimals, disabled, formControl, msgErrorDisabled, onValue, placeholder, symbol, rlsTheme, value }) {
|
|
1581
1581
|
return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-box', {
|
|
1582
1582
|
focused: formControl?.focused,
|
|
1583
1583
|
error: formControl?.wrong,
|
|
1584
1584
|
disabled: formControl?.disabled || disabled
|
|
1585
|
-
}, '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 })] }));
|
|
1585
|
+
}, '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 }))] }));
|
|
1586
1586
|
}
|
|
1587
1587
|
|
|
1588
|
-
function RlsFieldNumber({ children, disabled, formControl, placeholder, rlsTheme, value
|
|
1588
|
+
function RlsFieldNumber({ children, disabled, formControl, msgErrorDisabled, onValue, placeholder, rlsTheme, value }) {
|
|
1589
1589
|
return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-box', {
|
|
1590
1590
|
focused: formControl?.focused,
|
|
1591
1591
|
error: formControl?.wrong,
|
|
1592
1592
|
disabled: formControl?.disabled || disabled
|
|
1593
|
-
}, '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 })] }));
|
|
1593
|
+
}, '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 }))] }));
|
|
1594
1594
|
}
|
|
1595
1595
|
|
|
1596
|
-
function RlsFieldPassword({ children, disabled, formControl, placeholder, rlsTheme }) {
|
|
1596
|
+
function RlsFieldPassword({ children, disabled, formControl, msgErrorDisabled, placeholder, rlsTheme }) {
|
|
1597
1597
|
const [password, setPassword] = require$$0.useState(true);
|
|
1598
1598
|
function onToggleInput() {
|
|
1599
1599
|
setPassword(!password);
|
|
@@ -1602,15 +1602,15 @@ function RlsFieldPassword({ children, disabled, formControl, placeholder, rlsThe
|
|
|
1602
1602
|
focused: formControl?.focused,
|
|
1603
1603
|
error: formControl?.wrong,
|
|
1604
1604
|
disabled: formControl?.disabled || disabled
|
|
1605
|
-
}, '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 })] }));
|
|
1605
|
+
}, '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 }))] }));
|
|
1606
1606
|
}
|
|
1607
1607
|
|
|
1608
|
-
function RlsFieldText({ children, disabled, formControl, placeholder, rlsTheme, value
|
|
1608
|
+
function RlsFieldText({ children, disabled, formControl, msgErrorDisabled, onValue, placeholder, rlsTheme, value }) {
|
|
1609
1609
|
return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-box', {
|
|
1610
1610
|
focused: formControl?.focused,
|
|
1611
1611
|
error: formControl?.wrong,
|
|
1612
1612
|
disabled: formControl?.disabled || disabled
|
|
1613
|
-
}, '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 })] }));
|
|
1613
|
+
}, '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 }))] }));
|
|
1614
1614
|
}
|
|
1615
1615
|
|
|
1616
1616
|
function RlsLabelCheckBox({ children, disabled, extended, formControl, rlsTheme }) {
|
|
@@ -2067,11 +2067,12 @@ function useListControl({ suggestions, formControl }) {
|
|
|
2067
2067
|
const contentRef = require$$0.useRef(null);
|
|
2068
2068
|
const listRef = require$$0.useRef(null);
|
|
2069
2069
|
const inputRef = require$$0.useRef(null);
|
|
2070
|
+
const listIsOpen = require$$0.useRef(false);
|
|
2070
2071
|
const [state, setState] = require$$0.useState({
|
|
2071
2072
|
focused: false,
|
|
2072
2073
|
higher: false,
|
|
2073
2074
|
value: '',
|
|
2074
|
-
|
|
2075
|
+
listIsVisible: false
|
|
2075
2076
|
});
|
|
2076
2077
|
const collection = require$$0.useRef(new components.ListCollection([]));
|
|
2077
2078
|
const position = require$$0.useRef(0);
|
|
@@ -2079,7 +2080,7 @@ function useListControl({ suggestions, formControl }) {
|
|
|
2079
2080
|
require$$0.useEffect(() => {
|
|
2080
2081
|
function onCloseSuggestions({ target }) {
|
|
2081
2082
|
!contentRef?.current?.contains(target) &&
|
|
2082
|
-
setState((state) => ({ ...state,
|
|
2083
|
+
setState((state) => ({ ...state, listIsVisible: false }));
|
|
2083
2084
|
}
|
|
2084
2085
|
document.addEventListener('click', onCloseSuggestions);
|
|
2085
2086
|
return () => {
|
|
@@ -2087,28 +2088,36 @@ function useListControl({ suggestions, formControl }) {
|
|
|
2087
2088
|
};
|
|
2088
2089
|
}, []);
|
|
2089
2090
|
require$$0.useEffect(() => {
|
|
2091
|
+
if (!listIsOpen.current && state.listIsVisible) {
|
|
2092
|
+
listIsOpen.current = true;
|
|
2093
|
+
}
|
|
2094
|
+
if (listIsOpen.current && !state.listIsVisible) {
|
|
2095
|
+
formControl?.touch();
|
|
2096
|
+
}
|
|
2090
2097
|
setState((state) => ({
|
|
2091
2098
|
...state,
|
|
2092
2099
|
higher: components.locationListCanTop(contentRef.current, listRef.current)
|
|
2093
2100
|
}));
|
|
2094
|
-
}, [state.
|
|
2101
|
+
}, [state.listIsVisible]);
|
|
2095
2102
|
require$$0.useEffect(() => {
|
|
2096
2103
|
collection.current = new components.ListCollection(suggestions);
|
|
2097
2104
|
refresh(collection.current, formControl?.value);
|
|
2098
2105
|
}, [suggestions, formControl?.value]);
|
|
2099
2106
|
function refresh(collection, state) {
|
|
2100
2107
|
if (!state) {
|
|
2101
|
-
return refreshProtected(collection)
|
|
2108
|
+
return refreshProtected(collection)
|
|
2109
|
+
? undefined
|
|
2110
|
+
: refreshState({ value: '' });
|
|
2102
2111
|
}
|
|
2103
2112
|
const element = collection.find(state);
|
|
2104
2113
|
if (element) {
|
|
2105
2114
|
protectedValue.current = undefined;
|
|
2106
|
-
return
|
|
2115
|
+
return refreshState({ value: element.description });
|
|
2107
2116
|
}
|
|
2108
2117
|
if (!refreshProtected(collection)) {
|
|
2109
2118
|
protectedValue.current = state;
|
|
2110
|
-
setValue('');
|
|
2111
2119
|
setFormValue(undefined);
|
|
2120
|
+
refreshState({ value: '' });
|
|
2112
2121
|
}
|
|
2113
2122
|
}
|
|
2114
2123
|
function refreshProtected(collection) {
|
|
@@ -2122,21 +2131,14 @@ function useListControl({ suggestions, formControl }) {
|
|
|
2122
2131
|
}
|
|
2123
2132
|
return false;
|
|
2124
2133
|
}
|
|
2125
|
-
function
|
|
2126
|
-
setState((
|
|
2127
|
-
}
|
|
2128
|
-
function setValue(value) {
|
|
2129
|
-
setState((state) => ({ ...state, value }));
|
|
2134
|
+
function refreshState(state) {
|
|
2135
|
+
setState((currentState) => ({ ...currentState, state }));
|
|
2130
2136
|
}
|
|
2131
2137
|
function setFormValue(value) {
|
|
2132
2138
|
formControl?.setValue(value);
|
|
2133
2139
|
}
|
|
2134
|
-
function setVisible(visible) {
|
|
2135
|
-
setState((state) => ({ ...state, visible }));
|
|
2136
|
-
!visible && formControl?.touch();
|
|
2137
|
-
}
|
|
2138
2140
|
function navigationInput(event) {
|
|
2139
|
-
if (state.
|
|
2141
|
+
if (state.listIsVisible) {
|
|
2140
2142
|
const newPosition = components.navigationListFromInput({
|
|
2141
2143
|
content: contentRef.current,
|
|
2142
2144
|
event: event,
|
|
@@ -2161,10 +2163,8 @@ function useListControl({ suggestions, formControl }) {
|
|
|
2161
2163
|
listRef,
|
|
2162
2164
|
navigationElement,
|
|
2163
2165
|
navigationInput,
|
|
2164
|
-
setFocused,
|
|
2165
2166
|
setFormValue,
|
|
2166
|
-
|
|
2167
|
-
setVisible
|
|
2167
|
+
setState: refreshState
|
|
2168
2168
|
};
|
|
2169
2169
|
}
|
|
2170
2170
|
|
|
@@ -2174,12 +2174,12 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
|
|
|
2174
2174
|
const [pattern, setPattern] = require$$0.useState('');
|
|
2175
2175
|
const [coincidences, setCoincidences] = require$$0.useState([]);
|
|
2176
2176
|
const currentStore = require$$0.useRef({
|
|
2177
|
-
pattern: '',
|
|
2178
2177
|
coincidences: [],
|
|
2178
|
+
pattern: '',
|
|
2179
2179
|
previous: null
|
|
2180
2180
|
});
|
|
2181
2181
|
const listControl = useListControl({ suggestions, formControl });
|
|
2182
|
-
const { inputRef, navigationElement, navigationInput,
|
|
2182
|
+
const { inputRef, navigationElement, navigationInput, setFormValue, setState } = listControl;
|
|
2183
2183
|
require$$0.useEffect(() => {
|
|
2184
2184
|
refreshCoincidences(pattern, true);
|
|
2185
2185
|
}, [suggestions]);
|
|
@@ -2188,23 +2188,23 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
|
|
|
2188
2188
|
}, [pattern]);
|
|
2189
2189
|
function onClickControl() {
|
|
2190
2190
|
if (!disabled) {
|
|
2191
|
-
|
|
2191
|
+
setState({ listIsVisible: true });
|
|
2192
2192
|
setTimeout(() => {
|
|
2193
2193
|
inputRef?.current?.focus();
|
|
2194
2194
|
}, DURATION_ANIMATION$1);
|
|
2195
2195
|
}
|
|
2196
2196
|
}
|
|
2197
2197
|
function onFocusInput() {
|
|
2198
|
-
|
|
2198
|
+
setState({ focused: true });
|
|
2199
2199
|
}
|
|
2200
2200
|
function onBlurInput() {
|
|
2201
|
-
|
|
2201
|
+
setState({ focused: false });
|
|
2202
2202
|
}
|
|
2203
2203
|
function onKeydownInput(event) {
|
|
2204
2204
|
switch (event.code) {
|
|
2205
2205
|
case 'Escape':
|
|
2206
2206
|
case 'Tab':
|
|
2207
|
-
|
|
2207
|
+
setState({ listIsVisible: false });
|
|
2208
2208
|
break;
|
|
2209
2209
|
default:
|
|
2210
2210
|
navigationInput(event);
|
|
@@ -2212,13 +2212,12 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
|
|
|
2212
2212
|
}
|
|
2213
2213
|
}
|
|
2214
2214
|
function onClickAction() {
|
|
2215
|
-
|
|
2216
|
-
setValue('');
|
|
2215
|
+
setState({ listIsVisible: false, value: '' });
|
|
2217
2216
|
setFormValue(undefined);
|
|
2218
2217
|
onValue && onValue(undefined);
|
|
2219
2218
|
}
|
|
2220
2219
|
function onClickBackdrop() {
|
|
2221
|
-
|
|
2220
|
+
setState({ listIsVisible: false });
|
|
2222
2221
|
}
|
|
2223
2222
|
function onClickElement(element) {
|
|
2224
2223
|
return () => {
|
|
@@ -2231,13 +2230,13 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
|
|
|
2231
2230
|
};
|
|
2232
2231
|
}
|
|
2233
2232
|
function onChange({ description, value }) {
|
|
2234
|
-
setVisible(false);
|
|
2235
2233
|
if (onSelect) {
|
|
2234
|
+
setState({ listIsVisible: false });
|
|
2236
2235
|
onSelect(value);
|
|
2237
2236
|
}
|
|
2238
2237
|
else {
|
|
2238
|
+
setState({ listIsVisible: false, value: description });
|
|
2239
2239
|
setFormValue(value);
|
|
2240
|
-
setValue(description);
|
|
2241
2240
|
}
|
|
2242
2241
|
onValue && onValue(value);
|
|
2243
2242
|
}
|
|
@@ -2269,15 +2268,15 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
|
|
|
2269
2268
|
|
|
2270
2269
|
function RlsFieldAutocompleteTemplate(props) {
|
|
2271
2270
|
const fieldAutocomplete = useFieldAutocomplete(props);
|
|
2272
|
-
const { render, children, disabled, formControl, hiddenIcon, onSearch, placeholder, rlsTheme, searching } = props;
|
|
2271
|
+
const { render, children, disabled, formControl, hiddenIcon, msgErrorDisabled, onSearch, placeholder, rlsTheme, searching } = props;
|
|
2273
2272
|
return (jsxRuntimeExports.jsxs("div", { ref: fieldAutocomplete.listControl.contentRef, className: renderClassStatus('rls-field-box', {
|
|
2274
2273
|
disabled,
|
|
2275
2274
|
focused: fieldAutocomplete.listControl.focused,
|
|
2276
2275
|
error: formControl?.wrong,
|
|
2277
2276
|
selected: !!fieldAutocomplete.listControl.value
|
|
2278
|
-
}, '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', {
|
|
2279
|
-
visible: fieldAutocomplete.listControl.
|
|
2280
|
-
hide: !fieldAutocomplete.listControl.
|
|
2277
|
+
}, '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', {
|
|
2278
|
+
visible: fieldAutocomplete.listControl.listIsVisible,
|
|
2279
|
+
hide: !fieldAutocomplete.listControl.listIsVisible,
|
|
2281
2280
|
higher: fieldAutocomplete.listControl.higher
|
|
2282
2281
|
}), 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 } }) => {
|
|
2283
2282
|
fieldAutocomplete.setPattern(value);
|
|
@@ -2362,7 +2361,7 @@ function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDat
|
|
|
2362
2361
|
}
|
|
2363
2362
|
|
|
2364
2363
|
const FORMAT_DATE = '{dd}/{mx}/{aa}';
|
|
2365
|
-
function RlsFieldDate({ children, date, disabled, formControl, format, maxDate, minDate, onValue, placeholder, rlsTheme }) {
|
|
2364
|
+
function RlsFieldDate({ children, date, disabled, formControl, format, maxDate, minDate, msgErrorDisabled, onValue, placeholder, rlsTheme }) {
|
|
2366
2365
|
const today = new Date(); // Initial current date in component
|
|
2367
2366
|
const [value, setValue] = require$$0.useState();
|
|
2368
2367
|
const [modalIsVisible, setModalIsVisible] = require$$0.useState(false);
|
|
@@ -2395,7 +2394,7 @@ function RlsFieldDate({ children, date, disabled, formControl, format, maxDate,
|
|
|
2395
2394
|
const valueInput = value
|
|
2396
2395
|
? dates.dateFormatTemplate(value, format || FORMAT_DATE)
|
|
2397
2396
|
: '';
|
|
2398
|
-
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 }) => {
|
|
2397
|
+
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 }) => {
|
|
2399
2398
|
type !== components.PickerListenerType.Cancel && onChange(value);
|
|
2400
2399
|
formControl?.touch();
|
|
2401
2400
|
setModalIsVisible(false);
|
|
@@ -2454,7 +2453,7 @@ function RlsPickerDateRange({ automatic, date: datePicker, disabled, formControl
|
|
|
2454
2453
|
}), 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') }) })] }) })] }));
|
|
2455
2454
|
}
|
|
2456
2455
|
|
|
2457
|
-
function RlsFieldDateRange({ children, date: datePicker, disabled, formControl, maxDate, minDate, placeholder, rlsTheme }) {
|
|
2456
|
+
function RlsFieldDateRange({ children, date: datePicker, disabled, formControl, maxDate, minDate, msgErrorDisabled, placeholder, rlsTheme }) {
|
|
2458
2457
|
const currentRange = formControl?.value || dates.DateRange.now();
|
|
2459
2458
|
const currentDate = datePicker || new Date();
|
|
2460
2459
|
const [value, setValue] = require$$0.useState(currentRange);
|
|
@@ -2471,7 +2470,7 @@ function RlsFieldDateRange({ children, date: datePicker, disabled, formControl,
|
|
|
2471
2470
|
setModalIsVisible(true);
|
|
2472
2471
|
}
|
|
2473
2472
|
}
|
|
2474
|
-
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 }) => {
|
|
2473
|
+
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 }) => {
|
|
2475
2474
|
value && setValue(value);
|
|
2476
2475
|
setModalIsVisible(false);
|
|
2477
2476
|
} }) })] }));
|
|
@@ -2479,25 +2478,25 @@ function RlsFieldDateRange({ children, date: datePicker, disabled, formControl,
|
|
|
2479
2478
|
|
|
2480
2479
|
function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
|
|
2481
2480
|
const listControl = useListControl({ suggestions, formControl });
|
|
2482
|
-
const { inputRef,
|
|
2481
|
+
const { inputRef, listIsVisible, navigationElement, navigationInput, setFormValue, setState } = listControl;
|
|
2483
2482
|
function onFocusInput() {
|
|
2484
|
-
|
|
2483
|
+
setState({ focused: true });
|
|
2485
2484
|
}
|
|
2486
2485
|
function onBlurInput() {
|
|
2487
|
-
|
|
2486
|
+
setState({ focused: false });
|
|
2488
2487
|
}
|
|
2489
2488
|
function onClickInput() {
|
|
2490
|
-
|
|
2489
|
+
setState({ listIsVisible: true });
|
|
2491
2490
|
}
|
|
2492
2491
|
function onKeydownInput(event) {
|
|
2493
2492
|
switch (event.code) {
|
|
2494
2493
|
case 'Space':
|
|
2495
2494
|
case 'Enter':
|
|
2496
|
-
|
|
2495
|
+
setState({ listIsVisible: true });
|
|
2497
2496
|
break;
|
|
2498
2497
|
case 'Escape':
|
|
2499
2498
|
case 'Tab':
|
|
2500
|
-
|
|
2499
|
+
setState({ listIsVisible: false });
|
|
2501
2500
|
break;
|
|
2502
2501
|
default:
|
|
2503
2502
|
navigationInput(event);
|
|
@@ -2505,11 +2504,11 @@ function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
|
|
|
2505
2504
|
}
|
|
2506
2505
|
}
|
|
2507
2506
|
function onClickAction() {
|
|
2508
|
-
|
|
2509
|
-
!
|
|
2507
|
+
setState({ listIsVisible: !listIsVisible });
|
|
2508
|
+
!listIsVisible && inputRef?.current?.focus();
|
|
2510
2509
|
}
|
|
2511
2510
|
function onClickBackdrop() {
|
|
2512
|
-
|
|
2511
|
+
setState({ listIsVisible: false });
|
|
2513
2512
|
}
|
|
2514
2513
|
function onClickElement(element) {
|
|
2515
2514
|
return () => {
|
|
@@ -2523,13 +2522,13 @@ function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
|
|
|
2523
2522
|
}
|
|
2524
2523
|
function onChange({ description, value }) {
|
|
2525
2524
|
inputRef?.current?.focus();
|
|
2526
|
-
setVisible(false);
|
|
2527
2525
|
if (onSelect) {
|
|
2526
|
+
setState({ listIsVisible: false });
|
|
2528
2527
|
onSelect(value);
|
|
2529
2528
|
}
|
|
2530
2529
|
else {
|
|
2531
2530
|
setFormValue(value);
|
|
2532
|
-
|
|
2531
|
+
setState({ listIsVisible: false, value: description });
|
|
2533
2532
|
}
|
|
2534
2533
|
onValue && onValue(value);
|
|
2535
2534
|
}
|
|
@@ -2548,16 +2547,16 @@ function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
|
|
|
2548
2547
|
|
|
2549
2548
|
function RlsFieldSelectTemplate(props) {
|
|
2550
2549
|
const fieldSelect = useFieldSelect(props);
|
|
2551
|
-
const { render, suggestions, children, disabled, formControl, placeholder, rlsTheme } = props;
|
|
2550
|
+
const { render, suggestions, children, disabled, formControl, msgErrorDisabled, placeholder, rlsTheme } = props;
|
|
2552
2551
|
return (jsxRuntimeExports.jsxs("div", { ref: fieldSelect.listControl.contentRef, className: renderClassStatus('rls-field-box', {
|
|
2553
2552
|
focused: fieldSelect.listControl.focused,
|
|
2554
2553
|
error: formControl?.wrong,
|
|
2555
2554
|
disabled
|
|
2556
2555
|
}, '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', {
|
|
2557
|
-
visible: fieldSelect.listControl.
|
|
2558
|
-
}), 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', {
|
|
2559
|
-
visible: fieldSelect.listControl.
|
|
2560
|
-
hide: !fieldSelect.listControl.
|
|
2556
|
+
visible: fieldSelect.listControl.listIsVisible
|
|
2557
|
+
}), 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', {
|
|
2558
|
+
visible: fieldSelect.listControl.listIsVisible,
|
|
2559
|
+
hide: !fieldSelect.listControl.listIsVisible,
|
|
2561
2560
|
higher: fieldSelect.listControl.higher
|
|
2562
2561
|
}), 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 })] })] }));
|
|
2563
2562
|
}
|