@rolster/react-components 19.7.2 → 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
 
@@ -537,11 +537,12 @@ function RlsAreaTextComponent({ autoComplete, disabled, formControl, identifier,
537
537
  }
538
538
  const RlsAreaText = memo(RlsAreaTextComponent);
539
539
 
540
- function RlsAvatarComponent({ children, contrasted, rounded, skeleton, rlsTheme }) {
540
+ function RlsAvatarComponent({ children, contrasted, rounded, skeleton, transparent, rlsTheme }) {
541
541
  const className = renderClassStatus('rls-avatar', {
542
542
  contrasted,
543
543
  rounded,
544
- skeleton
544
+ skeleton,
545
+ transparent
545
546
  });
546
547
  return (jsxRuntimeExports.jsx("div", { className: className, "rls-theme": rlsTheme, children: children }));
547
548
  }
@@ -584,9 +585,9 @@ function RlsButtonComponent({ type, children, disabled, identifier, onClick, pre
584
585
  }
585
586
  const RlsButton = memo(RlsButtonComponent);
586
587
 
587
- function RlsButtonActionComponent({ icon, disabled, identifier, onClick, rlsTheme, tooltip, type }) {
588
+ function RlsButtonActionComponent({ icon, badge, disabled, identifier, onClick, rlsTheme, tooltip, type }) {
588
589
  const className = renderClassStatus('rls-button-action', { type });
589
- return (jsxRuntimeExports.jsxs("button", { id: identifier, className: className, onClick: onClick, disabled: disabled, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-button-action__content", children: jsxRuntimeExports.jsx(RlsIcon, { value: icon }) }), tooltip && (jsxRuntimeExports.jsx("div", { className: "rls-button-action__tooltip rls-overline-font-medium", children: jsxRuntimeExports.jsx("span", { children: tooltip }) }))] }));
590
+ return (jsxRuntimeExports.jsxs("button", { id: identifier, className: className, onClick: onClick, disabled: disabled, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-button-action__content", children: [jsxRuntimeExports.jsx(RlsIcon, { value: icon }), badge && jsxRuntimeExports.jsx("span", { className: "rls-button-action__badge", children: badge })] }), tooltip && (jsxRuntimeExports.jsx("div", { className: "rls-button-action__tooltip rls-overline-font-medium", children: jsxRuntimeExports.jsx("span", { children: tooltip }) }))] }));
590
591
  }
591
592
  const RlsButtonAction = memo(RlsButtonActionComponent);
592
593
 
@@ -2297,32 +2298,46 @@ function RlsSliderComponent({ children, className, disabled, formControl, identi
2297
2298
  }
2298
2299
  const RlsSlider = memo(RlsSliderComponent);
2299
2300
 
2300
- function RlsTab({ onSelect, tab, value }) {
2301
+ function RlsTab({ disabled, onSelect, tab, value }) {
2301
2302
  const className = renderClassStatus('rls-tabs__children', {
2302
2303
  active: tab.value === value,
2303
- disabled: tab.disabled
2304
+ disabled: disabled || tab.disabled
2304
2305
  });
2305
2306
  const onClick = useCallback(() => {
2306
- if (!tab.disabled) {
2307
+ if (!disabled && !tab.disabled) {
2307
2308
  onSelect(tab.value);
2308
2309
  }
2309
- }, [tab.disabled]);
2310
+ }, [disabled, tab.disabled, onSelect]);
2310
2311
  return (jsxRuntimeExports.jsx("div", { className: className, onClick: onClick, children: jsxRuntimeExports.jsx("span", { children: tab.label }) }));
2311
2312
  }
2312
- function RlsTabsComponent({ tabs, onValue, rlsTheme }) {
2313
- 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]);
2314
2318
  const onSelect = useCallback((value) => {
2315
- setValue(value);
2319
+ if (formControl) {
2320
+ formControl?.setValue(value);
2321
+ }
2322
+ else {
2323
+ setValueInternal(value);
2324
+ }
2316
2325
  onValue?.(value);
2317
- }, [onValue]);
2326
+ }, [formControl, onValue]);
2318
2327
  useEffect(() => {
2328
+ if (formControl?.value !== undefined) {
2329
+ return setValueInternal(formControl.value);
2330
+ }
2331
+ if (value !== undefined) {
2332
+ return setValueInternal(value);
2333
+ }
2319
2334
  const initial = tabs.find((tab) => tab.defaultActive) ?? tabs[0];
2320
2335
  if (initial) {
2321
2336
  onSelect(initial.value);
2322
2337
  }
2323
- }, []);
2338
+ }, [value, formControl?.value]);
2324
2339
  return (jsxRuntimeExports.jsx("div", { className: "rls-tabs", "rls-theme": rlsTheme, children: tabs.map((tab, index) => {
2325
- 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));
2326
2341
  }) }));
2327
2342
  }
2328
2343
  const RlsTabs = memo(RlsTabsComponent);
@@ -4719,6 +4734,14 @@ function usePortalController() {
4719
4734
  return { close, open, visible };
4720
4735
  }
4721
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
+
4722
4745
  const APP_THEME_ATTRIBUTE = 'app-theme';
4723
4746
  function getAppTheme() {
4724
4747
  if (typeof document === 'undefined') {
@@ -4740,5 +4763,5 @@ function toggleAppTheme() {
4740
4763
  return theme;
4741
4764
  }
4742
4765
 
4743
- 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 };
4744
4767
  //# sourceMappingURL=index.mjs.map