@rolster/react-components 19.7.3 → 19.7.5

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.mjs CHANGED
@@ -4,7 +4,7 @@ import { i18n, i18nSubscribe } from '@rolster/i18n';
4
4
  import { PaginationController, verifyDayPicker, createDayPicker, createDayRangePicker, verifyMonthPicker, createMonthPicker, monthLimitTemplate, createYearPicker, verifyYearPicker, ListCollection, navigationListFromInput, navigationListFromElement, createAutocompleteStore, PickerListenerEvent, dateOutRange, verifyDateRange } from '@rolster/components';
5
5
  import { DAY_LABELS, DateRange, normalizeMinTime, assignDayInDate, dateIsBefore, MONTH_NAMES, Month, Time, dateFormatTemplate, assignYearInDate, assignMonthInDate } from '@rolster/dates';
6
6
  import ReactDOM from 'react-dom';
7
- import { useReactControl } from '@rolster/react-forms';
7
+ import { useReactControl, useFormControl } from '@rolster/react-forms';
8
8
 
9
9
  var jsxRuntime = {exports: {}};
10
10
 
@@ -2298,32 +2298,46 @@ function RlsSliderComponent({ children, className, disabled, formControl, identi
2298
2298
  }
2299
2299
  const RlsSlider = memo(RlsSliderComponent);
2300
2300
 
2301
- function RlsTab({ onSelect, tab, value }) {
2301
+ function RlsTab({ disabled, onSelect, tab, value }) {
2302
2302
  const className = renderClassStatus('rls-tabs__children', {
2303
2303
  active: tab.value === value,
2304
- disabled: tab.disabled
2304
+ disabled: disabled || tab.disabled
2305
2305
  });
2306
2306
  const onClick = useCallback(() => {
2307
- if (!tab.disabled) {
2307
+ if (!disabled && !tab.disabled) {
2308
2308
  onSelect(tab.value);
2309
2309
  }
2310
- }, [tab.disabled]);
2310
+ }, [disabled, tab.disabled, onSelect]);
2311
2311
  return (jsxRuntimeExports.jsx("div", { className: className, onClick: onClick, children: jsxRuntimeExports.jsx("span", { children: tab.label }) }));
2312
2312
  }
2313
- function RlsTabsComponent({ tabs, onValue, rlsTheme }) {
2314
- const [value, setValue] = useState();
2313
+ function RlsTabsComponent({ tabs, formControl, onValue, value, rlsTheme }) {
2314
+ const [valueInternal, setValueInternal] = useState();
2315
+ const valueSelected = useMemo(() => {
2316
+ return formControl ? formControl.value : valueInternal;
2317
+ }, [formControl?.value, valueInternal]);
2315
2318
  const onSelect = useCallback((value) => {
2316
- setValue(value);
2319
+ if (formControl) {
2320
+ formControl?.setValue(value);
2321
+ }
2322
+ else {
2323
+ setValueInternal(value);
2324
+ }
2317
2325
  onValue?.(value);
2318
- }, [onValue]);
2326
+ }, [formControl, onValue]);
2319
2327
  useEffect(() => {
2328
+ if (formControl?.value !== undefined) {
2329
+ return setValueInternal(formControl.value);
2330
+ }
2331
+ if (value !== undefined) {
2332
+ return setValueInternal(value);
2333
+ }
2320
2334
  const initial = tabs.find((tab) => tab.defaultActive) ?? tabs[0];
2321
2335
  if (initial) {
2322
2336
  onSelect(initial.value);
2323
2337
  }
2324
- }, []);
2338
+ }, [value, formControl?.value]);
2325
2339
  return (jsxRuntimeExports.jsx("div", { className: "rls-tabs", "rls-theme": rlsTheme, children: tabs.map((tab, index) => {
2326
- return (jsxRuntimeExports.jsx(RlsTab, { tab: tab, value: value, onSelect: onSelect }, index));
2340
+ return (jsxRuntimeExports.jsx(RlsTab, { tab: tab, disabled: formControl?.disabled, value: valueSelected, onSelect: onSelect }, index));
2327
2341
  }) }));
2328
2342
  }
2329
2343
  const RlsTabs = memo(RlsTabsComponent);
@@ -4720,6 +4734,14 @@ function usePortalController() {
4720
4734
  return { close, open, visible };
4721
4735
  }
4722
4736
 
4737
+ function useTabsController(options) {
4738
+ const formControl = useFormControl(options.value);
4739
+ const Tabs = useMemo(() => {
4740
+ return (jsxRuntimeExports.jsx(RlsTabs, { tabs: options.tabs, formControl: formControl, onValue: options.onValue }));
4741
+ }, [options.tabs, options.onValue, formControl]);
4742
+ return { Tabs, formControl };
4743
+ }
4744
+
4723
4745
  const APP_THEME_ATTRIBUTE = 'app-theme';
4724
4746
  function getAppTheme() {
4725
4747
  if (typeof document === 'undefined') {
@@ -4741,5 +4763,5 @@ function toggleAppTheme() {
4741
4763
  return theme;
4742
4764
  }
4743
4765
 
4744
- export { ConfirmationResult, DEFAULT_COLOR, RlsAccordion, RlsAlert, RlsAmount, RlsApplication, RlsAreaText, RlsAvatar, RlsBadge, RlsBallot, RlsBody, RlsBottomSheet, RlsBreadcrumb, RlsButton, RlsButtonAction, RlsButtonIcon, RlsButtonOption, RlsButtonProgress, RlsButtonStepper, RlsButtonToggle, RlsCard, RlsCheckBox, RlsCheckBoxControl, RlsConfirmation, RlsContent, RlsContext, RlsDatatable, RlsDatatableCell, RlsDatatableData, RlsDatatableFloating, RlsDatatableHeader, RlsDatatableRecord, RlsDatatableSubheader, RlsDatatableTitle, RlsDatatableTotals, RlsDropdown, RlsFieldArea, RlsFieldAutocomplete, RlsFieldAutocompleteTemplate, RlsFieldClock, RlsFieldColor, RlsFieldDate, RlsFieldDateRange, RlsFieldDecimal, RlsFieldFile, RlsFieldList, RlsFieldListSuggestions, RlsFieldListTemplate, RlsFieldMoney, RlsFieldNumber, RlsFieldPassword, RlsFieldPercentage, RlsFieldReadonly, RlsFieldSelect, RlsFieldSelectTemplate, RlsFieldText, RlsFormNavigation, RlsIcon, RlsImage, RlsImageChooser, RlsImageEditor, RlsInput, RlsInputCounter, RlsInputDecimal, RlsInputMoney, RlsInputNumber, RlsInputPassword, RlsInputPercentage, RlsInputSearch, RlsInputText, RlsLabel, RlsLabelCheckBox, RlsLabelRadioButton, RlsLabelSwitch, RlsLed, RlsMessageEmpty, RlsMessageFormError, RlsMessageIcon, RlsModal, RlsModalClock, RlsModalDate, RlsModalDateRange, RlsModalSheet, RlsNavbar, RlsNavbarMenu, RlsPagination, RlsPickerClock, RlsPickerColor, RlsPickerDate, RlsPickerDateRange, RlsPickerDay, RlsPickerDayRange, RlsPickerMonth, RlsPickerSelectorTitle, RlsPickerYear, RlsPoster, RlsProgressBar, RlsProgressCircular, RlsRadioButton, RlsSkeleton, RlsSkeletonText, RlsSlider, RlsSnackbar, RlsSpinner, RlsSwitch, RlsSwitchControl, RlsTabs, RlsTabularText, RlsToolbar, calculateImgDimension, generateThemePalette, getAppTheme, hexIsValid, hexToHsl, hexToHsv, hexToRgb, hslToHex, hsvToHex, hsvToRgb, normalizeHex, rangeFormatTemplate, renderClassStatus, rgbToHex, rgbToHsl, rgbToHsv, setAppTheme, setDesignSystem, setErrorsI18n, setThemeColor, toggleAppTheme, useConfirmation, useDatatable, useDesingSystemController, useDropdownController, useFieldAutocomplete, useFieldList, useFieldSelect, useFormSingleSelectionController, useFormToggleController, useImageEditorController, useListController, useNotifications, usePortalController, useRelocationOnComponent, useResize, useRlsContext, useSnackbar };
4766
+ export { ConfirmationResult, DEFAULT_COLOR, RlsAccordion, RlsAlert, RlsAmount, RlsApplication, RlsAreaText, RlsAvatar, RlsBadge, RlsBallot, RlsBody, RlsBottomSheet, RlsBreadcrumb, RlsButton, RlsButtonAction, RlsButtonIcon, RlsButtonOption, RlsButtonProgress, RlsButtonStepper, RlsButtonToggle, RlsCard, RlsCheckBox, RlsCheckBoxControl, RlsConfirmation, RlsContent, RlsContext, RlsDatatable, RlsDatatableCell, RlsDatatableData, RlsDatatableFloating, RlsDatatableHeader, RlsDatatableRecord, RlsDatatableSubheader, RlsDatatableTitle, RlsDatatableTotals, RlsDropdown, RlsFieldArea, RlsFieldAutocomplete, RlsFieldAutocompleteTemplate, RlsFieldClock, RlsFieldColor, RlsFieldDate, RlsFieldDateRange, RlsFieldDecimal, RlsFieldFile, RlsFieldList, RlsFieldListSuggestions, RlsFieldListTemplate, RlsFieldMoney, RlsFieldNumber, RlsFieldPassword, RlsFieldPercentage, RlsFieldReadonly, RlsFieldSelect, RlsFieldSelectTemplate, RlsFieldText, RlsFormNavigation, RlsIcon, RlsImage, RlsImageChooser, RlsImageEditor, RlsInput, RlsInputCounter, RlsInputDecimal, RlsInputMoney, RlsInputNumber, RlsInputPassword, RlsInputPercentage, RlsInputSearch, RlsInputText, RlsLabel, RlsLabelCheckBox, RlsLabelRadioButton, RlsLabelSwitch, RlsLed, RlsMessageEmpty, RlsMessageFormError, RlsMessageIcon, RlsModal, RlsModalClock, RlsModalDate, RlsModalDateRange, RlsModalSheet, RlsNavbar, RlsNavbarMenu, RlsPagination, RlsPickerClock, RlsPickerColor, RlsPickerDate, RlsPickerDateRange, RlsPickerDay, RlsPickerDayRange, RlsPickerMonth, RlsPickerSelectorTitle, RlsPickerYear, RlsPoster, RlsProgressBar, RlsProgressCircular, RlsRadioButton, RlsSkeleton, RlsSkeletonText, RlsSlider, RlsSnackbar, RlsSpinner, RlsSwitch, RlsSwitchControl, RlsTabs, RlsTabularText, RlsToolbar, calculateImgDimension, generateThemePalette, getAppTheme, hexIsValid, hexToHsl, hexToHsv, hexToRgb, hslToHex, hsvToHex, hsvToRgb, normalizeHex, rangeFormatTemplate, renderClassStatus, rgbToHex, rgbToHsl, rgbToHsv, setAppTheme, setDesignSystem, setErrorsI18n, setThemeColor, toggleAppTheme, useConfirmation, useDatatable, useDesingSystemController, useDropdownController, useFieldAutocomplete, useFieldList, useFieldSelect, useFormSingleSelectionController, useFormToggleController, useImageEditorController, useListController, useNotifications, usePortalController, useRelocationOnComponent, useResize, useRlsContext, useSnackbar, useTabsController };
4745
4767
  //# sourceMappingURL=index.mjs.map