@rolster/react-components 18.21.20 → 18.21.22

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 CHANGED
@@ -2401,7 +2401,7 @@ function useDatatable() {
2401
2401
  }
2402
2402
 
2403
2403
  function useListController(props) {
2404
- const { suggestions, automatic, formControl, reference } = props;
2404
+ const { limit, suggestions, automatic, formControl, reference } = props;
2405
2405
  const listIsOpen = require$$0.useRef(false);
2406
2406
  const contentRef = require$$0.useRef(null);
2407
2407
  const listRef = require$$0.useRef(null);
@@ -2464,15 +2464,15 @@ function useListController(props) {
2464
2464
  changeValueInternal.current = false;
2465
2465
  }, [collection, formControl?.value]);
2466
2466
  const setState = require$$0.useCallback((state) => {
2467
- const length = suggestions.length > 6 ? 6 : suggestions.length;
2467
+ const minHeightList = limit > 0 ? (limit < 6 ? limit * 48 : 300) : 160;
2468
2468
  const _state = state.modalIsVisible
2469
2469
  ? {
2470
2470
  ...state,
2471
- higher: components.locationListCanTop(contentRef.current, listRef.current, length * 48)
2471
+ higher: components.locationListCanTop(contentRef.current, listRef.current, minHeightList)
2472
2472
  }
2473
2473
  : state;
2474
2474
  refreshState((state) => ({ ...state, ..._state }));
2475
- }, []);
2475
+ }, [limit]);
2476
2476
  const setFormValue = require$$0.useCallback((element, initialValue = false) => {
2477
2477
  refreshState((state) => ({
2478
2478
  ...state,
@@ -2517,10 +2517,14 @@ function useListController(props) {
2517
2517
  const DURATION_ANIMATION$1 = 240;
2518
2518
  const MAX_ELEMENTS = 6;
2519
2519
  function useFieldAutocomplete(props) {
2520
- const controller = useListController(props);
2520
+ const limit = require$$0.useRef(props.suggestions.length);
2521
+ const controller = useListController({
2522
+ ...props,
2523
+ limit: limit.current
2524
+ });
2521
2525
  const [coincidences, setCoincidences] = require$$0.useState([]);
2522
2526
  const [pattern, setPattern] = require$$0.useState('');
2523
- const currentStore = require$$0.useRef({
2527
+ const _store = require$$0.useRef({
2524
2528
  coincidences: [],
2525
2529
  pattern: '',
2526
2530
  previous: null
@@ -2530,10 +2534,12 @@ function useFieldAutocomplete(props) {
2530
2534
  pattern,
2531
2535
  suggestions,
2532
2536
  reboot,
2533
- store: currentStore.current
2537
+ store: _store.current
2534
2538
  });
2535
- currentStore.current = store;
2536
- setCoincidences(collection.slice(0, MAX_ELEMENTS));
2539
+ _store.current = store;
2540
+ const coincidences = collection.slice(0, MAX_ELEMENTS);
2541
+ setCoincidences(coincidences);
2542
+ limit.current = coincidences.length;
2537
2543
  }, []);
2538
2544
  require$$0.useEffect(() => {
2539
2545
  refreshCoincidences(props.suggestions, pattern, true);
@@ -2921,7 +2927,14 @@ function RlsFieldDateRange({ children, date: _date, disabled, formControl, ident
2921
2927
  }
2922
2928
 
2923
2929
  function useFieldSelect(props) {
2924
- const controller = useListController(props);
2930
+ const limit = require$$0.useRef(props.suggestions.length);
2931
+ const controller = useListController({
2932
+ ...props,
2933
+ limit: limit.current
2934
+ });
2935
+ require$$0.useEffect(() => {
2936
+ limit.current = props.suggestions.length;
2937
+ }, [props.suggestions]);
2925
2938
  const onFocusInput = require$$0.useCallback(() => {
2926
2939
  controller.setState({ focused: true });
2927
2940
  }, [controller.setState]);
@@ -3119,16 +3132,26 @@ const RlsContext = require$$0.createContext({
3119
3132
  return Promise.resolve(ConfirmationResult.approved());
3120
3133
  },
3121
3134
  snackbar: () => { },
3122
- withNavbar: () => { }
3135
+ setNavbarInApp: () => { },
3136
+ setNavbarIsCondense: () => { }
3123
3137
  });
3124
3138
  function RlsApplication({ children }) {
3125
3139
  const { RlsConfirmation, confirmation } = useConfirmation();
3126
3140
  const { RlsSnackbar, snackbar } = useSnackbar();
3127
- const [_withNavbar, withNavbar] = require$$0.useState(false);
3141
+ const [hasNavbar, setNavbarInApp] = require$$0.useState(false);
3142
+ const [isNavbarCondense, setNavbarIsCondense] = require$$0.useState(false);
3128
3143
  const className = require$$0.useMemo(() => {
3129
- return renderClassStatus('rls-app__body', { snackbar: _withNavbar });
3130
- }, [_withNavbar]);
3131
- return (jsxRuntimeExports.jsxs(RlsContext.Provider, { value: { confirmation, snackbar, withNavbar }, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children, RlsSnackbar] }), RlsConfirmation] }));
3144
+ return renderClassStatus('rls-app__body', {
3145
+ snackbar: hasNavbar,
3146
+ 'navbar-condense': isNavbarCondense
3147
+ });
3148
+ }, [hasNavbar, isNavbarCondense]);
3149
+ return (jsxRuntimeExports.jsxs(RlsContext.Provider, { value: {
3150
+ confirmation,
3151
+ snackbar,
3152
+ setNavbarInApp,
3153
+ setNavbarIsCondense
3154
+ }, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children, RlsSnackbar] }), RlsConfirmation] }));
3132
3155
  }
3133
3156
 
3134
3157
  exports.ConfirmationResult = ConfirmationResult;