@rolster/react-components 18.21.20 → 18.21.21

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
@@ -2399,7 +2399,7 @@ function useDatatable() {
2399
2399
  }
2400
2400
 
2401
2401
  function useListController(props) {
2402
- const { suggestions, automatic, formControl, reference } = props;
2402
+ const { limit, suggestions, automatic, formControl, reference } = props;
2403
2403
  const listIsOpen = useRef(false);
2404
2404
  const contentRef = useRef(null);
2405
2405
  const listRef = useRef(null);
@@ -2462,15 +2462,15 @@ function useListController(props) {
2462
2462
  changeValueInternal.current = false;
2463
2463
  }, [collection, formControl?.value]);
2464
2464
  const setState = useCallback((state) => {
2465
- const length = suggestions.length > 6 ? 6 : suggestions.length;
2465
+ const minHeightList = limit > 0 ? (limit < 6 ? limit * 48 : 300) : 160;
2466
2466
  const _state = state.modalIsVisible
2467
2467
  ? {
2468
2468
  ...state,
2469
- higher: locationListCanTop(contentRef.current, listRef.current, length * 48)
2469
+ higher: locationListCanTop(contentRef.current, listRef.current, minHeightList)
2470
2470
  }
2471
2471
  : state;
2472
2472
  refreshState((state) => ({ ...state, ..._state }));
2473
- }, []);
2473
+ }, [limit]);
2474
2474
  const setFormValue = useCallback((element, initialValue = false) => {
2475
2475
  refreshState((state) => ({
2476
2476
  ...state,
@@ -2515,10 +2515,14 @@ function useListController(props) {
2515
2515
  const DURATION_ANIMATION$1 = 240;
2516
2516
  const MAX_ELEMENTS = 6;
2517
2517
  function useFieldAutocomplete(props) {
2518
- const controller = useListController(props);
2518
+ const limit = useRef(props.suggestions.length);
2519
+ const controller = useListController({
2520
+ ...props,
2521
+ limit: limit.current
2522
+ });
2519
2523
  const [coincidences, setCoincidences] = useState([]);
2520
2524
  const [pattern, setPattern] = useState('');
2521
- const currentStore = useRef({
2525
+ const _store = useRef({
2522
2526
  coincidences: [],
2523
2527
  pattern: '',
2524
2528
  previous: null
@@ -2528,10 +2532,12 @@ function useFieldAutocomplete(props) {
2528
2532
  pattern,
2529
2533
  suggestions,
2530
2534
  reboot,
2531
- store: currentStore.current
2535
+ store: _store.current
2532
2536
  });
2533
- currentStore.current = store;
2534
- setCoincidences(collection.slice(0, MAX_ELEMENTS));
2537
+ _store.current = store;
2538
+ const coincidences = collection.slice(0, MAX_ELEMENTS);
2539
+ setCoincidences(coincidences);
2540
+ limit.current = coincidences.length;
2535
2541
  }, []);
2536
2542
  useEffect(() => {
2537
2543
  refreshCoincidences(props.suggestions, pattern, true);
@@ -2919,7 +2925,14 @@ function RlsFieldDateRange({ children, date: _date, disabled, formControl, ident
2919
2925
  }
2920
2926
 
2921
2927
  function useFieldSelect(props) {
2922
- const controller = useListController(props);
2928
+ const limit = useRef(props.suggestions.length);
2929
+ const controller = useListController({
2930
+ ...props,
2931
+ limit: limit.current
2932
+ });
2933
+ useEffect(() => {
2934
+ limit.current = props.suggestions.length;
2935
+ }, [props.suggestions]);
2923
2936
  const onFocusInput = useCallback(() => {
2924
2937
  controller.setState({ focused: true });
2925
2938
  }, [controller.setState]);
@@ -3117,16 +3130,26 @@ const RlsContext = createContext({
3117
3130
  return Promise.resolve(ConfirmationResult.approved());
3118
3131
  },
3119
3132
  snackbar: () => { },
3120
- withNavbar: () => { }
3133
+ setNavbarInApp: () => { },
3134
+ setNavbarIsCondense: () => { }
3121
3135
  });
3122
3136
  function RlsApplication({ children }) {
3123
3137
  const { RlsConfirmation, confirmation } = useConfirmation();
3124
3138
  const { RlsSnackbar, snackbar } = useSnackbar();
3125
- const [_withNavbar, withNavbar] = useState(false);
3139
+ const [hasNavbar, setNavbarInApp] = useState(false);
3140
+ const [isNavbarCondense, setNavbarIsCondense] = useState(false);
3126
3141
  const className = useMemo(() => {
3127
- return renderClassStatus('rls-app__body', { snackbar: _withNavbar });
3128
- }, [_withNavbar]);
3129
- return (jsxRuntimeExports.jsxs(RlsContext.Provider, { value: { confirmation, snackbar, withNavbar }, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children, RlsSnackbar] }), RlsConfirmation] }));
3142
+ return renderClassStatus('rls-app__body', {
3143
+ snackbar: hasNavbar,
3144
+ 'navbar-condense': isNavbarCondense
3145
+ });
3146
+ }, [hasNavbar]);
3147
+ return (jsxRuntimeExports.jsxs(RlsContext.Provider, { value: {
3148
+ confirmation,
3149
+ snackbar,
3150
+ setNavbarInApp,
3151
+ setNavbarIsCondense
3152
+ }, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children, RlsSnackbar] }), RlsConfirmation] }));
3130
3153
  }
3131
3154
 
3132
3155
  export { ConfirmationResult, RlsAlert, RlsAmount, RlsApplication, RlsAvatar, RlsBadge, RlsBallot, RlsBreadcrumb, RlsButton, RlsButtonAction, RlsButtonProgress, RlsButtonToggle, RlsCard, RlsCheckBox, RlsCheckBoxControl, RlsConfirmation, RlsContext, RlsDatatable, RlsDatatableCell, RlsDatatableData, RlsDatatableFloating, RlsDatatableHeader, RlsDatatableRecord, RlsDatatableSubheader, RlsDatatableTitle, RlsDatatableTotals, RlsFieldAutocomplete, RlsFieldAutocompleteTemplate, RlsFieldDate, RlsFieldDateRange, RlsFieldMoney, RlsFieldNumber, RlsFieldPassword, RlsFieldReadonly, RlsFieldSelect, RlsFieldSelectTemplate, RlsFieldText, RlsFormNavigation, RlsIcon, RlsInput, RlsInputMoney, RlsInputNumber, RlsInputPassword, RlsInputSearch, RlsInputText, RlsLabel, RlsLabelCheckBox, RlsLabelRadioButton, RlsLabelSwitch, RlsMessageFormError, RlsMessageIcon, RlsModal, RlsPagination, RlsPickerDate, RlsPickerDateRange, RlsPickerDay, RlsPickerDayRange, RlsPickerMonth, RlsPickerSelectorTitle, RlsPickerYear, RlsPoster, RlsProgressBar, RlsProgressCircular, RlsRadioButton, RlsSkeleton, RlsSkeletonText, RlsSnackbar, RlsSwitch, RlsSwitchControl, RlsTabularText, RlsToolbar, rangeFormatTemplate, renderClassStatus, setErrorsI18n, useConfirmation, useDatatable, useListController, useSnackbar };