@rolster/react-components 18.15.23 → 18.15.31
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 +113 -100
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.js +113 -100
- package/dist/es/index.js.map +1 -1
- package/dist/esm/components/organisms/Datatable/Datatable.d.ts +2 -2
- package/dist/esm/components/organisms/Datatable/Datatable.js +1 -1
- package/dist/esm/components/organisms/Datatable/Datatable.js.map +1 -1
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.d.ts +35 -4
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js +20 -17
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js.map +1 -1
- package/dist/esm/components/organisms/FieldAutocomplete/{FieldAutocompleteHook.d.ts → FieldAutocompleteController.d.ts} +7 -6
- package/dist/esm/components/organisms/FieldAutocomplete/{FieldAutocompleteHook.js → FieldAutocompleteController.js} +28 -26
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteController.js.map +1 -0
- package/dist/esm/components/organisms/FieldDate/FieldDate.d.ts +3 -2
- package/dist/esm/components/organisms/FieldDate/FieldDate.js +3 -3
- package/dist/esm/components/organisms/FieldDate/FieldDate.js.map +1 -1
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.d.ts +36 -5
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.js +17 -14
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.js.map +1 -1
- package/dist/esm/components/organisms/FieldSelect/FieldSelectController.d.ts +25 -0
- package/dist/esm/components/organisms/FieldSelect/FieldSelectController.js +72 -0
- package/dist/esm/components/organisms/FieldSelect/FieldSelectController.js.map +1 -0
- package/dist/esm/components/organisms/PickerDate/PickerDate.d.ts +1 -1
- package/dist/esm/components/organisms/PickerDate/PickerDate.js.map +1 -1
- package/dist/esm/controllers/DatatableController.d.ts +6 -0
- package/dist/esm/controllers/DatatableController.js +24 -0
- package/dist/esm/controllers/DatatableController.js.map +1 -0
- package/dist/esm/{hooks/ListControlHook.d.ts → controllers/ListController.d.ts} +9 -8
- package/dist/esm/{hooks/ListControlHook.js → controllers/ListController.js} +12 -11
- package/dist/esm/controllers/ListController.js.map +1 -0
- package/dist/esm/controllers/index.d.ts +2 -0
- package/dist/esm/controllers/index.js +3 -0
- package/dist/esm/controllers/index.js.map +1 -0
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/package.json +7 -7
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteHook.js.map +0 -1
- package/dist/esm/components/organisms/FieldSelect/FieldSelectHook.d.ts +0 -24
- package/dist/esm/components/organisms/FieldSelect/FieldSelectHook.js +0 -70
- package/dist/esm/components/organisms/FieldSelect/FieldSelectHook.js.map +0 -1
- package/dist/esm/hooks/DatatableHook.d.ts +0 -6
- package/dist/esm/hooks/DatatableHook.js +0 -22
- package/dist/esm/hooks/DatatableHook.js.map +0 -1
- package/dist/esm/hooks/ListControlHook.js.map +0 -1
- package/dist/esm/hooks/index.d.ts +0 -2
- package/dist/esm/hooks/index.js +0 -3
- package/dist/esm/hooks/index.js.map +0 -1
package/dist/es/index.js
CHANGED
|
@@ -2037,40 +2037,43 @@ function RlsDatatableData({ children, className, control, overflow }) {
|
|
|
2037
2037
|
function RlsDatatable({ children, datatable, footer, header, rlsTheme, summary }) {
|
|
2038
2038
|
return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-datatable', {
|
|
2039
2039
|
scrolleable: datatable?.scrolleable
|
|
2040
|
-
}), "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("table", { children: [header && jsxRuntimeExports.jsx("thead", { className: "rls-datatable__thead", children: header }), jsxRuntimeExports.jsx("tbody", { ref: datatable?.
|
|
2040
|
+
}), "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("table", { children: [header && jsxRuntimeExports.jsx("thead", { className: "rls-datatable__thead", children: header }), jsxRuntimeExports.jsx("tbody", { ref: datatable?.tableRef, className: "rls-datatable__tbody", children: children })] }), summary && jsxRuntimeExports.jsx("div", { className: "rls-datatable__tsummary", children: summary }), footer && jsxRuntimeExports.jsx("div", { className: "rls-datatable__tfooter", children: footer })] }));
|
|
2041
2041
|
}
|
|
2042
2042
|
|
|
2043
|
+
function createObserver(options) {
|
|
2044
|
+
const { setScrolleable, table } = options;
|
|
2045
|
+
const observer = new ResizeObserver(() => {
|
|
2046
|
+
const scrollHeight = table.scrollHeight || 0;
|
|
2047
|
+
const clientHeight = table.clientHeight || 0;
|
|
2048
|
+
setScrolleable(scrollHeight > clientHeight);
|
|
2049
|
+
});
|
|
2050
|
+
observer.observe(table);
|
|
2051
|
+
return observer;
|
|
2052
|
+
}
|
|
2043
2053
|
function useDatatable() {
|
|
2044
2054
|
const [scrolleable, setScrolleable] = useState(false);
|
|
2045
|
-
const
|
|
2055
|
+
const tableRef = useRef(null);
|
|
2046
2056
|
useEffect(() => {
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
if (body) {
|
|
2050
|
-
observer = new ResizeObserver(() => {
|
|
2051
|
-
const scrollHeight = body.scrollHeight || 0;
|
|
2052
|
-
const clientHeight = body.clientHeight || 0;
|
|
2053
|
-
setScrolleable(scrollHeight > clientHeight);
|
|
2054
|
-
});
|
|
2055
|
-
observer.observe(bodyRef?.current);
|
|
2056
|
-
}
|
|
2057
|
+
const observer = tableRef?.current &&
|
|
2058
|
+
createObserver({ setScrolleable, table: tableRef?.current });
|
|
2057
2059
|
return () => {
|
|
2058
2060
|
observer?.disconnect();
|
|
2059
2061
|
};
|
|
2060
2062
|
}, []);
|
|
2061
|
-
return {
|
|
2063
|
+
return { scrolleable, tableRef };
|
|
2062
2064
|
}
|
|
2063
2065
|
|
|
2064
|
-
function
|
|
2066
|
+
function useListController(props) {
|
|
2067
|
+
const { suggestions, formControl, value } = props;
|
|
2068
|
+
const listIsOpen = useRef(false);
|
|
2065
2069
|
const contentRef = useRef(null);
|
|
2066
2070
|
const listRef = useRef(null);
|
|
2067
2071
|
const inputRef = useRef(null);
|
|
2068
|
-
const listIsOpen = useRef(false);
|
|
2069
2072
|
const [state, setState] = useState({
|
|
2070
2073
|
focused: false,
|
|
2071
2074
|
higher: false,
|
|
2072
2075
|
value: '',
|
|
2073
|
-
|
|
2076
|
+
modalIsVisible: false
|
|
2074
2077
|
});
|
|
2075
2078
|
const collection = useRef(new ListCollection([]));
|
|
2076
2079
|
const position = useRef(0);
|
|
@@ -2078,7 +2081,7 @@ function useListControl({ suggestions, formControl }) {
|
|
|
2078
2081
|
useEffect(() => {
|
|
2079
2082
|
function onCloseSuggestions({ target }) {
|
|
2080
2083
|
!contentRef?.current?.contains(target) &&
|
|
2081
|
-
setState((state) => ({ ...state,
|
|
2084
|
+
setState((state) => ({ ...state, modalIsVisible: false }));
|
|
2082
2085
|
}
|
|
2083
2086
|
document.addEventListener('click', onCloseSuggestions);
|
|
2084
2087
|
return () => {
|
|
@@ -2086,17 +2089,17 @@ function useListControl({ suggestions, formControl }) {
|
|
|
2086
2089
|
};
|
|
2087
2090
|
}, []);
|
|
2088
2091
|
useEffect(() => {
|
|
2089
|
-
if (!listIsOpen.current && state.
|
|
2092
|
+
if (!listIsOpen.current && state.modalIsVisible) {
|
|
2090
2093
|
listIsOpen.current = true;
|
|
2091
2094
|
}
|
|
2092
|
-
if (listIsOpen.current && !state.
|
|
2095
|
+
if (listIsOpen.current && !state.modalIsVisible) {
|
|
2093
2096
|
formControl?.touch();
|
|
2094
2097
|
}
|
|
2095
2098
|
setState((state) => ({
|
|
2096
2099
|
...state,
|
|
2097
2100
|
higher: locationListCanTop(contentRef.current, listRef.current)
|
|
2098
2101
|
}));
|
|
2099
|
-
}, [state.
|
|
2102
|
+
}, [state.modalIsVisible]);
|
|
2100
2103
|
useEffect(() => {
|
|
2101
2104
|
collection.current = new ListCollection(suggestions);
|
|
2102
2105
|
refresh(collection.current, formControl?.value);
|
|
@@ -2114,7 +2117,7 @@ function useListControl({ suggestions, formControl }) {
|
|
|
2114
2117
|
}
|
|
2115
2118
|
if (!refreshProtected(collection)) {
|
|
2116
2119
|
protectedValue.current = state;
|
|
2117
|
-
setFormValue(
|
|
2120
|
+
setFormValue(value);
|
|
2118
2121
|
refreshState({ value: '' });
|
|
2119
2122
|
}
|
|
2120
2123
|
}
|
|
@@ -2136,7 +2139,7 @@ function useListControl({ suggestions, formControl }) {
|
|
|
2136
2139
|
formControl?.setValue(value);
|
|
2137
2140
|
}
|
|
2138
2141
|
function navigationInput(event) {
|
|
2139
|
-
if (state.
|
|
2142
|
+
if (state.modalIsVisible) {
|
|
2140
2143
|
const newPosition = navigationListFromInput({
|
|
2141
2144
|
content: contentRef.current,
|
|
2142
2145
|
event: event,
|
|
@@ -2168,54 +2171,54 @@ function useListControl({ suggestions, formControl }) {
|
|
|
2168
2171
|
|
|
2169
2172
|
const DURATION_ANIMATION$1 = 240;
|
|
2170
2173
|
const MAX_ELEMENTS = 6;
|
|
2171
|
-
function useFieldAutocomplete(
|
|
2172
|
-
const
|
|
2174
|
+
function useFieldAutocomplete(props) {
|
|
2175
|
+
const controller = useListController(props);
|
|
2173
2176
|
const [coincidences, setCoincidences] = useState([]);
|
|
2177
|
+
const [pattern, setPattern] = useState('');
|
|
2174
2178
|
const currentStore = useRef({
|
|
2175
2179
|
coincidences: [],
|
|
2176
2180
|
pattern: '',
|
|
2177
2181
|
previous: null
|
|
2178
2182
|
});
|
|
2179
|
-
const
|
|
2180
|
-
const { inputRef, navigationElement, navigationInput, setFormValue, setState } = listControl;
|
|
2183
|
+
const disabled = props.formControl?.disabled || props.disabled;
|
|
2181
2184
|
useEffect(() => {
|
|
2182
2185
|
refreshCoincidences(pattern, true);
|
|
2183
|
-
}, [suggestions]);
|
|
2186
|
+
}, [props.suggestions]);
|
|
2184
2187
|
useEffect(() => {
|
|
2185
2188
|
refreshCoincidences(pattern);
|
|
2186
2189
|
}, [pattern]);
|
|
2187
2190
|
function onClickControl() {
|
|
2188
2191
|
if (!disabled) {
|
|
2189
|
-
setState({
|
|
2192
|
+
controller.setState({ modalIsVisible: true });
|
|
2190
2193
|
setTimeout(() => {
|
|
2191
|
-
inputRef?.current?.focus();
|
|
2194
|
+
controller.inputRef?.current?.focus();
|
|
2192
2195
|
}, DURATION_ANIMATION$1);
|
|
2193
2196
|
}
|
|
2194
2197
|
}
|
|
2195
2198
|
function onFocusInput() {
|
|
2196
|
-
setState({ focused: true });
|
|
2199
|
+
controller.setState({ focused: true });
|
|
2197
2200
|
}
|
|
2198
2201
|
function onBlurInput() {
|
|
2199
|
-
setState({ focused: false });
|
|
2202
|
+
controller.setState({ focused: false });
|
|
2200
2203
|
}
|
|
2201
2204
|
function onKeydownInput(event) {
|
|
2202
2205
|
switch (event.code) {
|
|
2203
2206
|
case 'Escape':
|
|
2204
2207
|
case 'Tab':
|
|
2205
|
-
setState({
|
|
2208
|
+
controller.setState({ modalIsVisible: false });
|
|
2206
2209
|
break;
|
|
2207
2210
|
default:
|
|
2208
|
-
navigationInput(event);
|
|
2211
|
+
controller.navigationInput(event);
|
|
2209
2212
|
break;
|
|
2210
2213
|
}
|
|
2211
2214
|
}
|
|
2212
2215
|
function onClickAction() {
|
|
2213
|
-
setState({
|
|
2214
|
-
setFormValue(
|
|
2215
|
-
onValue && onValue(
|
|
2216
|
+
controller.setState({ modalIsVisible: false, value: '' });
|
|
2217
|
+
controller.setFormValue(props.value);
|
|
2218
|
+
props.onValue && props.onValue(props.value);
|
|
2216
2219
|
}
|
|
2217
2220
|
function onClickBackdrop() {
|
|
2218
|
-
setState({
|
|
2221
|
+
controller.setState({ modalIsVisible: false });
|
|
2219
2222
|
}
|
|
2220
2223
|
function onClickElement(element) {
|
|
2221
2224
|
return () => {
|
|
@@ -2224,24 +2227,26 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
|
|
|
2224
2227
|
}
|
|
2225
2228
|
function onKeydownElement(element) {
|
|
2226
2229
|
return (event) => {
|
|
2227
|
-
event.code === 'Enter'
|
|
2230
|
+
event.code === 'Enter'
|
|
2231
|
+
? onChange(element)
|
|
2232
|
+
: controller.navigationElement(event);
|
|
2228
2233
|
};
|
|
2229
2234
|
}
|
|
2230
2235
|
function onChange({ description, value }) {
|
|
2231
|
-
if (onSelect) {
|
|
2232
|
-
setState({
|
|
2233
|
-
onSelect(value);
|
|
2236
|
+
if (props.onSelect) {
|
|
2237
|
+
controller.setState({ modalIsVisible: false });
|
|
2238
|
+
value && props.onSelect(value);
|
|
2234
2239
|
}
|
|
2235
2240
|
else {
|
|
2236
|
-
setState({
|
|
2237
|
-
setFormValue(value);
|
|
2241
|
+
controller.setState({ modalIsVisible: false, value: description });
|
|
2242
|
+
controller.setFormValue(value);
|
|
2238
2243
|
}
|
|
2239
|
-
onValue && onValue(value);
|
|
2244
|
+
props.onValue && props.onValue(value);
|
|
2240
2245
|
}
|
|
2241
2246
|
function refreshCoincidences(pattern, reboot = false) {
|
|
2242
2247
|
const { collection, store } = createAutocompleteStore({
|
|
2243
2248
|
pattern,
|
|
2244
|
-
suggestions,
|
|
2249
|
+
suggestions: props.suggestions,
|
|
2245
2250
|
reboot,
|
|
2246
2251
|
store: currentStore.current
|
|
2247
2252
|
});
|
|
@@ -2250,7 +2255,7 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
|
|
|
2250
2255
|
}
|
|
2251
2256
|
return {
|
|
2252
2257
|
coincidences,
|
|
2253
|
-
|
|
2258
|
+
controller,
|
|
2254
2259
|
onBlurInput,
|
|
2255
2260
|
onClickAction,
|
|
2256
2261
|
onClickBackdrop,
|
|
@@ -2265,22 +2270,25 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
|
|
|
2265
2270
|
}
|
|
2266
2271
|
|
|
2267
2272
|
function RlsFieldAutocompleteTemplate(props) {
|
|
2268
|
-
const
|
|
2269
|
-
const {
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2273
|
+
const autocomplete = useFieldAutocomplete(props);
|
|
2274
|
+
const { controller } = autocomplete;
|
|
2275
|
+
const { render, children, formControl, hiddenIcon, msgErrorDisabled, onSearch, placeholder, rlsTheme, searching } = props;
|
|
2276
|
+
const disabled = formControl?.disabled || props.disabled;
|
|
2277
|
+
const className = renderClassStatus('rls-field-box', {
|
|
2278
|
+
focused: controller.focused,
|
|
2279
|
+
disabled,
|
|
2280
|
+
error: formControl?.wrong,
|
|
2281
|
+
selected: !!controller.value
|
|
2282
|
+
}, 'rls-field-list rls-field-autocomplete');
|
|
2283
|
+
return (jsxRuntimeExports.jsxs("div", { ref: controller.contentRef, className: className, "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: controller.value, onClick: autocomplete.onClickControl }), !hiddenIcon && controller.value && (jsxRuntimeExports.jsx("button", { className: "rls-field-list__action", disabled: disabled, onClick: autocomplete.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', {
|
|
2284
|
+
visible: controller.modalIsVisible,
|
|
2285
|
+
higher: controller.higher,
|
|
2286
|
+
hide: !controller.modalIsVisible
|
|
2287
|
+
}), children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__suggestions__body", children: jsxRuntimeExports.jsxs("ul", { ref: controller.listRef, className: "rls-field-list__ul", children: [jsxRuntimeExports.jsxs("div", { className: "rls-field-list__ul__search", children: [jsxRuntimeExports.jsx("input", { ref: controller.inputRef, className: "rls-field-list__ul__control", type: "text", placeholder: reactI18n('listInputPlaceholder'), value: autocomplete.pattern, onChange: ({ target: { value } }) => {
|
|
2288
|
+
autocomplete.setPattern(value);
|
|
2289
|
+
}, disabled: disabled || searching, onFocus: autocomplete.onFocusInput, onBlur: autocomplete.onBlurInput, onKeyDown: autocomplete.onKeydownInput }), onSearch && (jsxRuntimeExports.jsx("button", { disabled: disabled || searching, onClick: () => {
|
|
2290
|
+
onSearch(autocomplete.pattern);
|
|
2291
|
+
}, children: jsxRuntimeExports.jsx(RlsIcon, { value: "search" }) }))] }), searching && jsxRuntimeExports.jsx(RlsProgressBar, { indeterminate: true }), autocomplete.coincidences.map((element, index) => (jsxRuntimeExports.jsx("li", { className: "rls-field-list__element", tabIndex: -1, onClick: autocomplete.onClickElement(element), onKeyDown: autocomplete.onKeydownElement(element), children: render(element) }, index))), !autocomplete.coincidences.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: autocomplete.onClickBackdrop })] })] }));
|
|
2284
2292
|
}
|
|
2285
2293
|
function RlsFieldAutocomplete(props) {
|
|
2286
2294
|
return (jsxRuntimeExports.jsx(RlsFieldAutocompleteTemplate, { ...props, render: (element) => (jsxRuntimeExports.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: jsxRuntimeExports.jsx("span", { children: element.title }) })) }));
|
|
@@ -2359,9 +2367,9 @@ function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDat
|
|
|
2359
2367
|
}
|
|
2360
2368
|
|
|
2361
2369
|
const FORMAT_DATE = '{dd}/{mx}/{aa}';
|
|
2362
|
-
function RlsFieldDate({ children, date, disabled, formControl, format, maxDate, minDate, msgErrorDisabled, onValue, placeholder, rlsTheme }) {
|
|
2370
|
+
function RlsFieldDate({ children, date, disabled, formControl, format, maxDate, minDate, msgErrorDisabled, onValue, placeholder, rlsTheme, value: defaultValue }) {
|
|
2363
2371
|
const today = new Date(); // Initial current date in component
|
|
2364
|
-
const [value, setValue] = useState();
|
|
2372
|
+
const [value, setValue] = useState(defaultValue);
|
|
2365
2373
|
const [modalIsVisible, setModalIsVisible] = useState(false);
|
|
2366
2374
|
useEffect(() => {
|
|
2367
2375
|
const dateCheck = checkDateRange({
|
|
@@ -2381,7 +2389,7 @@ function RlsFieldDate({ children, date, disabled, formControl, format, maxDate,
|
|
|
2381
2389
|
}
|
|
2382
2390
|
function onClickAction() {
|
|
2383
2391
|
if (value) {
|
|
2384
|
-
formControl?.setValue(
|
|
2392
|
+
formControl?.setValue(defaultValue);
|
|
2385
2393
|
formControl?.touch();
|
|
2386
2394
|
onChange(undefined);
|
|
2387
2395
|
}
|
|
@@ -2474,39 +2482,39 @@ function RlsFieldDateRange({ children, date: datePicker, disabled, formControl,
|
|
|
2474
2482
|
} }) })] }));
|
|
2475
2483
|
}
|
|
2476
2484
|
|
|
2477
|
-
function useFieldSelect(
|
|
2478
|
-
const
|
|
2479
|
-
const { inputRef, listIsVisible, navigationElement, navigationInput, setFormValue, setState } = listControl;
|
|
2485
|
+
function useFieldSelect(props) {
|
|
2486
|
+
const controller = useListController(props);
|
|
2480
2487
|
function onFocusInput() {
|
|
2481
|
-
setState({ focused: true });
|
|
2488
|
+
controller.setState({ focused: true });
|
|
2482
2489
|
}
|
|
2483
2490
|
function onBlurInput() {
|
|
2484
|
-
setState({ focused: false });
|
|
2491
|
+
controller.setState({ focused: false });
|
|
2485
2492
|
}
|
|
2486
2493
|
function onClickInput() {
|
|
2487
|
-
setState({
|
|
2494
|
+
controller.setState({ modalIsVisible: true });
|
|
2488
2495
|
}
|
|
2489
2496
|
function onKeydownInput(event) {
|
|
2490
2497
|
switch (event.code) {
|
|
2491
2498
|
case 'Space':
|
|
2492
2499
|
case 'Enter':
|
|
2493
|
-
setState({
|
|
2500
|
+
controller.setState({ modalIsVisible: true });
|
|
2494
2501
|
break;
|
|
2495
2502
|
case 'Escape':
|
|
2496
2503
|
case 'Tab':
|
|
2497
|
-
setState({
|
|
2504
|
+
controller.setState({ modalIsVisible: false });
|
|
2498
2505
|
break;
|
|
2499
2506
|
default:
|
|
2500
|
-
navigationInput(event);
|
|
2507
|
+
controller.navigationInput(event);
|
|
2501
2508
|
break;
|
|
2502
2509
|
}
|
|
2503
2510
|
}
|
|
2504
2511
|
function onClickAction() {
|
|
2505
|
-
|
|
2506
|
-
|
|
2512
|
+
const modalIsVisible = !controller.modalIsVisible;
|
|
2513
|
+
controller.setState({ modalIsVisible });
|
|
2514
|
+
modalIsVisible && controller.inputRef?.current?.focus();
|
|
2507
2515
|
}
|
|
2508
2516
|
function onClickBackdrop() {
|
|
2509
|
-
setState({
|
|
2517
|
+
controller.setState({ modalIsVisible: false });
|
|
2510
2518
|
}
|
|
2511
2519
|
function onClickElement(element) {
|
|
2512
2520
|
return () => {
|
|
@@ -2515,23 +2523,25 @@ function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
|
|
|
2515
2523
|
}
|
|
2516
2524
|
function onKeydownElement(element) {
|
|
2517
2525
|
return (event) => {
|
|
2518
|
-
event.code === 'Enter'
|
|
2526
|
+
event.code === 'Enter'
|
|
2527
|
+
? onChange(element)
|
|
2528
|
+
: controller.navigationElement(event);
|
|
2519
2529
|
};
|
|
2520
2530
|
}
|
|
2521
2531
|
function onChange({ description, value }) {
|
|
2522
|
-
inputRef?.current?.focus();
|
|
2523
|
-
if (onSelect) {
|
|
2524
|
-
setState({
|
|
2525
|
-
onSelect(value);
|
|
2532
|
+
controller.inputRef?.current?.focus();
|
|
2533
|
+
if (props.onSelect) {
|
|
2534
|
+
controller.setState({ modalIsVisible: false });
|
|
2535
|
+
value && props.onSelect(value);
|
|
2526
2536
|
}
|
|
2527
2537
|
else {
|
|
2528
|
-
setFormValue(value);
|
|
2529
|
-
setState({
|
|
2538
|
+
controller.setFormValue(value);
|
|
2539
|
+
controller.setState({ modalIsVisible: false, value: description });
|
|
2530
2540
|
}
|
|
2531
|
-
onValue && onValue(value);
|
|
2541
|
+
props.onValue && props.onValue(value);
|
|
2532
2542
|
}
|
|
2533
2543
|
return {
|
|
2534
|
-
|
|
2544
|
+
controller,
|
|
2535
2545
|
onBlurInput,
|
|
2536
2546
|
onClickAction,
|
|
2537
2547
|
onClickBackdrop,
|
|
@@ -2544,19 +2554,22 @@ function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
|
|
|
2544
2554
|
}
|
|
2545
2555
|
|
|
2546
2556
|
function RlsFieldSelectTemplate(props) {
|
|
2547
|
-
const
|
|
2548
|
-
const {
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2557
|
+
const select = useFieldSelect(props);
|
|
2558
|
+
const { controller } = select;
|
|
2559
|
+
const { render, suggestions, children, formControl, msgErrorDisabled, placeholder, rlsTheme } = props;
|
|
2560
|
+
const disabled = formControl?.disabled || props.disabled;
|
|
2561
|
+
const className = renderClassStatus('rls-field-box', {
|
|
2562
|
+
focused: controller.focused,
|
|
2563
|
+
disabled,
|
|
2564
|
+
error: formControl?.wrong
|
|
2565
|
+
}, 'rls-field-list rls-field-select');
|
|
2566
|
+
return (jsxRuntimeExports.jsxs("div", { ref: controller.contentRef, className: className, "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: controller.inputRef, className: "rls-field-list__control", readOnly: true, disabled: disabled, placeholder: placeholder, value: controller.value, onFocus: select.onFocusInput, onBlur: select.onBlurInput, onClick: select.onClickInput, onKeyDown: select.onKeydownInput }), jsxRuntimeExports.jsx("button", { className: renderClassStatus('rls-field-list__action', {
|
|
2567
|
+
visible: controller.modalIsVisible
|
|
2568
|
+
}), disabled: disabled, onClick: select.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', {
|
|
2569
|
+
visible: controller.modalIsVisible,
|
|
2570
|
+
higher: controller.higher,
|
|
2571
|
+
hide: !controller.modalIsVisible
|
|
2572
|
+
}), children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__suggestions__body", children: jsxRuntimeExports.jsxs("ul", { ref: controller.listRef, className: "rls-field-list__ul", children: [suggestions.map((element, index) => (jsxRuntimeExports.jsx("li", { className: "rls-field-list__element", tabIndex: -1, onClick: select.onClickElement(element), onKeyDown: select.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: select.onClickBackdrop })] })] }));
|
|
2560
2573
|
}
|
|
2561
2574
|
function RlsFieldSelect(props) {
|
|
2562
2575
|
return (jsxRuntimeExports.jsx(RlsFieldSelectTemplate, { ...props, render: (element) => (jsxRuntimeExports.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: jsxRuntimeExports.jsx("span", { children: element.title }) })) }));
|
|
@@ -2631,5 +2644,5 @@ function RlsApplication({ children }) {
|
|
|
2631
2644
|
}), children: [children, RlsSnackbar] }), RlsConfirmation] }));
|
|
2632
2645
|
}
|
|
2633
2646
|
|
|
2634
|
-
export { ConfirmationResult, RlsAmount, RlsApplication, RlsAvatar, RlsBadge, RlsBallot, RlsBreadcrumb, RlsButton, RlsButtonAction, RlsButtonProgress, RlsButtonToggle, RlsCard, RlsCheckBox, RlsCheckBoxControl, RlsConfirmation, RlsContext, RlsDatatable, RlsDatatableCell, RlsDatatableData, RlsDatatableHeader, RlsDatatableRecord, RlsDatatableTitle, RlsDatatableTotals, RlsFieldAutocomplete, RlsFieldAutocompleteTemplate, RlsFieldDate, RlsFieldDateRange, RlsFieldMoney, RlsFieldNumber, RlsFieldPassword, RlsFieldSelect, RlsFieldSelectTemplate, RlsFieldText, RlsFormNavigation, RlsIcon, RlsInput, RlsInputMoney, RlsInputNumber, RlsInputPassword, RlsInputSearch, RlsInputText, RlsLabel, RlsLabelCheckBox, RlsLabelRadioButton, RlsLabelSwitch, RlsMessageFormError, RlsMessageIcon, RlsModal, RlsPagination, RlsPickerDate, RlsPickerDateRange, RlsPickerDay, RlsPickerDayRange, RlsPickerMonth, RlsPickerMonthTitle, RlsPickerYear, RlsPoster, RlsProgressBar, RlsProgressCircular, RlsRadioButton, RlsSkeleton, RlsSkeletonText, RlsSnackbar, RlsSwitch, RlsSwitchControl, RlsTabularText, RlsToolbar, rangeFormatTemplate, renderClassStatus, useConfirmationService, useDatatable,
|
|
2647
|
+
export { ConfirmationResult, RlsAmount, RlsApplication, RlsAvatar, RlsBadge, RlsBallot, RlsBreadcrumb, RlsButton, RlsButtonAction, RlsButtonProgress, RlsButtonToggle, RlsCard, RlsCheckBox, RlsCheckBoxControl, RlsConfirmation, RlsContext, RlsDatatable, RlsDatatableCell, RlsDatatableData, RlsDatatableHeader, RlsDatatableRecord, RlsDatatableTitle, RlsDatatableTotals, RlsFieldAutocomplete, RlsFieldAutocompleteTemplate, RlsFieldDate, RlsFieldDateRange, RlsFieldMoney, RlsFieldNumber, RlsFieldPassword, RlsFieldSelect, RlsFieldSelectTemplate, RlsFieldText, RlsFormNavigation, RlsIcon, RlsInput, RlsInputMoney, RlsInputNumber, RlsInputPassword, RlsInputSearch, RlsInputText, RlsLabel, RlsLabelCheckBox, RlsLabelRadioButton, RlsLabelSwitch, RlsMessageFormError, RlsMessageIcon, RlsModal, RlsPagination, RlsPickerDate, RlsPickerDateRange, RlsPickerDay, RlsPickerDayRange, RlsPickerMonth, RlsPickerMonthTitle, RlsPickerYear, RlsPoster, RlsProgressBar, RlsProgressCircular, RlsRadioButton, RlsSkeleton, RlsSkeletonText, RlsSnackbar, RlsSwitch, RlsSwitchControl, RlsTabularText, RlsToolbar, rangeFormatTemplate, renderClassStatus, useConfirmationService, useDatatable, useListController, useSnackbarService };
|
|
2635
2648
|
//# sourceMappingURL=index.js.map
|