@rolster/react-components 18.15.30 → 18.15.32

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/es/index.js CHANGED
@@ -2065,15 +2065,15 @@ function useDatatable() {
2065
2065
 
2066
2066
  function useListController(props) {
2067
2067
  const { suggestions, formControl, value } = props;
2068
+ const listIsOpen = useRef(false);
2068
2069
  const contentRef = useRef(null);
2069
2070
  const listRef = useRef(null);
2070
2071
  const inputRef = useRef(null);
2071
- const listIsOpen = useRef(false);
2072
2072
  const [state, setState] = useState({
2073
2073
  focused: false,
2074
2074
  higher: false,
2075
2075
  value: '',
2076
- listIsVisible: false
2076
+ modalIsVisible: false
2077
2077
  });
2078
2078
  const collection = useRef(new ListCollection([]));
2079
2079
  const position = useRef(0);
@@ -2081,7 +2081,7 @@ function useListController(props) {
2081
2081
  useEffect(() => {
2082
2082
  function onCloseSuggestions({ target }) {
2083
2083
  !contentRef?.current?.contains(target) &&
2084
- setState((state) => ({ ...state, listIsVisible: false }));
2084
+ setState((state) => ({ ...state, modalIsVisible: false }));
2085
2085
  }
2086
2086
  document.addEventListener('click', onCloseSuggestions);
2087
2087
  return () => {
@@ -2089,17 +2089,17 @@ function useListController(props) {
2089
2089
  };
2090
2090
  }, []);
2091
2091
  useEffect(() => {
2092
- if (!listIsOpen.current && state.listIsVisible) {
2092
+ if (!listIsOpen.current && state.modalIsVisible) {
2093
2093
  listIsOpen.current = true;
2094
2094
  }
2095
- if (listIsOpen.current && !state.listIsVisible) {
2095
+ if (listIsOpen.current && !state.modalIsVisible) {
2096
2096
  formControl?.touch();
2097
2097
  }
2098
2098
  setState((state) => ({
2099
2099
  ...state,
2100
2100
  higher: locationListCanTop(contentRef.current, listRef.current)
2101
2101
  }));
2102
- }, [state.listIsVisible]);
2102
+ }, [state.modalIsVisible]);
2103
2103
  useEffect(() => {
2104
2104
  collection.current = new ListCollection(suggestions);
2105
2105
  refresh(collection.current, formControl?.value);
@@ -2139,7 +2139,7 @@ function useListController(props) {
2139
2139
  formControl?.setValue(value);
2140
2140
  }
2141
2141
  function navigationInput(event) {
2142
- if (state.listIsVisible) {
2142
+ if (state.modalIsVisible) {
2143
2143
  const newPosition = navigationListFromInput({
2144
2144
  content: contentRef.current,
2145
2145
  event: event,
@@ -2173,8 +2173,8 @@ const DURATION_ANIMATION$1 = 240;
2173
2173
  const MAX_ELEMENTS = 6;
2174
2174
  function useFieldAutocomplete(props) {
2175
2175
  const controller = useListController(props);
2176
- const [pattern, setPattern] = useState('');
2177
2176
  const [coincidences, setCoincidences] = useState([]);
2177
+ const [pattern, setPattern] = useState('');
2178
2178
  const currentStore = useRef({
2179
2179
  coincidences: [],
2180
2180
  pattern: '',
@@ -2189,7 +2189,7 @@ function useFieldAutocomplete(props) {
2189
2189
  }, [pattern]);
2190
2190
  function onClickControl() {
2191
2191
  if (!disabled) {
2192
- controller.setState({ listIsVisible: true });
2192
+ controller.setState({ modalIsVisible: true });
2193
2193
  setTimeout(() => {
2194
2194
  controller.inputRef?.current?.focus();
2195
2195
  }, DURATION_ANIMATION$1);
@@ -2205,7 +2205,7 @@ function useFieldAutocomplete(props) {
2205
2205
  switch (event.code) {
2206
2206
  case 'Escape':
2207
2207
  case 'Tab':
2208
- controller.setState({ listIsVisible: false });
2208
+ controller.setState({ modalIsVisible: false });
2209
2209
  break;
2210
2210
  default:
2211
2211
  controller.navigationInput(event);
@@ -2213,12 +2213,12 @@ function useFieldAutocomplete(props) {
2213
2213
  }
2214
2214
  }
2215
2215
  function onClickAction() {
2216
- controller.setState({ listIsVisible: false, value: '' });
2216
+ controller.setState({ modalIsVisible: false, value: '' });
2217
2217
  controller.setFormValue(props.value);
2218
2218
  props.onValue && props.onValue(props.value);
2219
2219
  }
2220
2220
  function onClickBackdrop() {
2221
- controller.setState({ listIsVisible: false });
2221
+ controller.setState({ modalIsVisible: false });
2222
2222
  }
2223
2223
  function onClickElement(element) {
2224
2224
  return () => {
@@ -2234,11 +2234,11 @@ function useFieldAutocomplete(props) {
2234
2234
  }
2235
2235
  function onChange({ description, value }) {
2236
2236
  if (props.onSelect) {
2237
- controller.setState({ listIsVisible: false });
2237
+ controller.setState({ modalIsVisible: false });
2238
2238
  value && props.onSelect(value);
2239
2239
  }
2240
2240
  else {
2241
- controller.setState({ listIsVisible: false, value: description });
2241
+ controller.setState({ modalIsVisible: false, value: description });
2242
2242
  controller.setFormValue(value);
2243
2243
  }
2244
2244
  props.onValue && props.onValue(value);
@@ -2281,9 +2281,9 @@ function RlsFieldAutocompleteTemplate(props) {
2281
2281
  selected: !!controller.value
2282
2282
  }, 'rls-field-list rls-field-autocomplete');
2283
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.listIsVisible,
2284
+ visible: controller.modalIsVisible,
2285
2285
  higher: controller.higher,
2286
- hide: !controller.listIsVisible
2286
+ hide: !controller.modalIsVisible
2287
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
2288
  autocomplete.setPattern(value);
2289
2289
  }, disabled: disabled || searching, onFocus: autocomplete.onFocusInput, onBlur: autocomplete.onBlurInput, onKeyDown: autocomplete.onKeydownInput }), onSearch && (jsxRuntimeExports.jsx("button", { disabled: disabled || searching, onClick: () => {
@@ -2491,17 +2491,17 @@ function useFieldSelect(props) {
2491
2491
  controller.setState({ focused: false });
2492
2492
  }
2493
2493
  function onClickInput() {
2494
- controller.setState({ listIsVisible: true });
2494
+ controller.setState({ modalIsVisible: true });
2495
2495
  }
2496
2496
  function onKeydownInput(event) {
2497
2497
  switch (event.code) {
2498
2498
  case 'Space':
2499
2499
  case 'Enter':
2500
- controller.setState({ listIsVisible: true });
2500
+ controller.setState({ modalIsVisible: true });
2501
2501
  break;
2502
2502
  case 'Escape':
2503
2503
  case 'Tab':
2504
- controller.setState({ listIsVisible: false });
2504
+ controller.setState({ modalIsVisible: false });
2505
2505
  break;
2506
2506
  default:
2507
2507
  controller.navigationInput(event);
@@ -2509,11 +2509,12 @@ function useFieldSelect(props) {
2509
2509
  }
2510
2510
  }
2511
2511
  function onClickAction() {
2512
- controller.setState({ listIsVisible: !controller.listIsVisible });
2513
- !controller.listIsVisible && controller.inputRef?.current?.focus();
2512
+ const modalIsVisible = !controller.modalIsVisible;
2513
+ controller.setState({ modalIsVisible });
2514
+ modalIsVisible && controller.inputRef?.current?.focus();
2514
2515
  }
2515
2516
  function onClickBackdrop() {
2516
- controller.setState({ listIsVisible: false });
2517
+ controller.setState({ modalIsVisible: false });
2517
2518
  }
2518
2519
  function onClickElement(element) {
2519
2520
  return () => {
@@ -2530,12 +2531,12 @@ function useFieldSelect(props) {
2530
2531
  function onChange({ description, value }) {
2531
2532
  controller.inputRef?.current?.focus();
2532
2533
  if (props.onSelect) {
2533
- controller.setState({ listIsVisible: false });
2534
+ controller.setState({ modalIsVisible: false });
2534
2535
  value && props.onSelect(value);
2535
2536
  }
2536
2537
  else {
2537
2538
  controller.setFormValue(value);
2538
- controller.setState({ listIsVisible: false, value: description });
2539
+ controller.setState({ modalIsVisible: false, value: description });
2539
2540
  }
2540
2541
  props.onValue && props.onValue(value);
2541
2542
  }
@@ -2563,11 +2564,11 @@ function RlsFieldSelectTemplate(props) {
2563
2564
  error: formControl?.wrong
2564
2565
  }, 'rls-field-list rls-field-select');
2565
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', {
2566
- visible: controller.listIsVisible
2567
+ visible: controller.modalIsVisible
2567
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', {
2568
- visible: controller.listIsVisible,
2569
+ visible: controller.modalIsVisible,
2569
2570
  higher: controller.higher,
2570
- hide: !controller.listIsVisible
2571
+ hide: !controller.modalIsVisible
2571
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 })] })] }));
2572
2573
  }
2573
2574
  function RlsFieldSelect(props) {