@rolster/react-components 19.8.22 → 19.10.0

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.
@@ -486,6 +486,17 @@ const RlsAmount = require$$0.memo(RlsAmountComponent);
486
486
 
487
487
  const AREA_TEXT_MAX_ROWS = 8;
488
488
  const AREA_TEXT_MIN_ROWS = 3;
489
+ function writeAreaValue(element, valueArea) {
490
+ const rawArea = element.value;
491
+ if (rawArea === valueArea) {
492
+ return;
493
+ }
494
+ const selection = element.selectionStart;
495
+ const offset = valueArea.length - rawArea.length;
496
+ const caret = Math.max(0, Math.min(selection + offset, valueArea.length));
497
+ element.value = valueArea;
498
+ element.setSelectionRange(caret, caret);
499
+ }
489
500
  function RlsAreaTextComponent({ autoComplete, disabled, formControl, identifier, maxLength, maxRows, minRows, onBlur, onEnter, onFocus, onKeyDown, onKeyUp, onValue, placeholder, readOnly, resize = 'vertical', value }) {
490
501
  const valueInitial = String(formControl?.value ?? value ?? '');
491
502
  const rowsMin = minRows ?? AREA_TEXT_MIN_ROWS;
@@ -494,7 +505,9 @@ function RlsAreaTextComponent({ autoComplete, disabled, formControl, identifier,
494
505
  const [focused, setFocused] = require$$0.useState(false);
495
506
  const elementRef = require$$0.useRef(null);
496
507
  const areaRef = formControl?.elementRef ?? elementRef;
497
- const changeIsInternal = require$$0.useRef(false);
508
+ const composing = require$$0.useRef(false);
509
+ const valueSent = require$$0.useRef(formControl?.value);
510
+ const valueSource = require$$0.useRef(formControl ? formControl.value : value);
498
511
  const heightIsManual = require$$0.useRef(false);
499
512
  const heightApplied = require$$0.useRef(0);
500
513
  const refreshHeight = require$$0.useCallback(() => {
@@ -520,13 +533,16 @@ function RlsAreaTextComponent({ autoComplete, disabled, formControl, identifier,
520
533
  heightApplied.current = height;
521
534
  }, [areaRef, rowsMax, rowsMin]);
522
535
  require$$0.useEffect(() => {
523
- if (!changeIsInternal.current) {
524
- const nextValue = String(formControl?.value ?? value ?? '');
536
+ const source = formControl ? formControl.value : value;
537
+ const isEcho = Object.is(source, valueSent.current);
538
+ const isSame = Object.is(source, valueSource.current);
539
+ valueSource.current = source;
540
+ if (!isEcho && !isSame) {
541
+ const nextValue = String(source ?? '');
525
542
  if (valueArea !== nextValue) {
526
543
  setValueArea(nextValue);
527
544
  }
528
545
  }
529
- changeIsInternal.current = false;
530
546
  }, [formControl?.value, value, valueArea]);
531
547
  require$$0.useEffect(() => {
532
548
  refreshHeight();
@@ -550,13 +566,28 @@ function RlsAreaTextComponent({ autoComplete, disabled, formControl, identifier,
550
566
  observer.observe(element);
551
567
  return () => observer.disconnect();
552
568
  }, [areaRef, resize]);
553
- const onChangeArea = require$$0.useCallback((event) => {
554
- const nextValue = event.target.value;
555
- changeIsInternal.current = true;
569
+ const applyArea = require$$0.useCallback((element) => {
570
+ const rawArea = element.value;
571
+ const formatter = formControl?.formatter;
572
+ const nextValue = formatter && formControl?.formatOn !== 'blur' && !composing.current
573
+ ? (formatter(rawArea) ?? '')
574
+ : rawArea;
575
+ writeAreaValue(element, nextValue);
576
+ valueSent.current = nextValue;
556
577
  onValue?.(nextValue);
557
578
  setValueArea(nextValue);
558
579
  formControl?.setValue(nextValue);
559
580
  }, [formControl, onValue]);
581
+ const onChangeArea = require$$0.useCallback((event) => {
582
+ applyArea(event.target);
583
+ }, [applyArea]);
584
+ const onCompositionStart = require$$0.useCallback(() => {
585
+ composing.current = true;
586
+ }, []);
587
+ const onCompositionEnd = require$$0.useCallback((event) => {
588
+ composing.current = false;
589
+ applyArea(event.currentTarget);
590
+ }, [applyArea]);
560
591
  const onKeyDownArea = require$$0.useCallback((event) => {
561
592
  onKeyDown?.(event);
562
593
  if (event.key === 'Enter') {
@@ -583,7 +614,7 @@ function RlsAreaTextComponent({ autoComplete, disabled, formControl, identifier,
583
614
  readonly: readOnly,
584
615
  resizable: resize !== 'none' && !disabledArea && !readOnly
585
616
  });
586
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, children: [jsxRuntimeExports.jsx("textarea", { ref: areaRef, className: "rls-area-text__component", autoComplete: autoComplete ?? 'off', placeholder: placeholder, disabled: disabledArea, readOnly: readOnly, maxLength: maxLength, rows: rowsMin, style: { resize }, onFocus: onFocusArea, onBlur: onBlurArea, onChange: onChangeArea, onKeyDown: onKeyDownArea, onKeyUp: onKeyUpArea, value: valueArea }), jsxRuntimeExports.jsx("span", { className: "rls-area-text__value", "aria-hidden": "true", children: valueArea })] }));
617
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, children: [jsxRuntimeExports.jsx("textarea", { ref: areaRef, className: "rls-area-text__component", autoComplete: autoComplete ?? 'off', placeholder: placeholder, disabled: disabledArea, readOnly: readOnly, maxLength: maxLength, rows: rowsMin, style: { resize }, onFocus: onFocusArea, onBlur: onBlurArea, onChange: onChangeArea, onCompositionStart: onCompositionStart, onCompositionEnd: onCompositionEnd, onKeyDown: onKeyDownArea, onKeyUp: onKeyUpArea, value: valueArea }), jsxRuntimeExports.jsx("span", { className: "rls-area-text__value", "aria-hidden": "true", children: valueArea })] }));
587
618
  }
588
619
  const RlsAreaText = require$$0.memo(RlsAreaTextComponent);
589
620
 
@@ -712,30 +743,82 @@ function RlsImageComponent({ src, rlsTheme }) {
712
743
  }
713
744
  const RlsImage = require$$0.memo(RlsImageComponent);
714
745
 
746
+ function valueToInput(value) {
747
+ return value ? String(value) : '';
748
+ }
749
+ function selectionStartOf(element) {
750
+ try {
751
+ // Lanza o retorna null en inputs sin selección (number, email, etc.)
752
+ return element.selectionStart;
753
+ }
754
+ catch {
755
+ return null;
756
+ }
757
+ }
758
+ /**
759
+ * Escribe el valor formateado directamente en el DOM y conserva la posición
760
+ * del cursor, corrigiéndola por la diferencia de longitud. Es necesario
761
+ * porque, cuando el formateador rechaza un carácter, el estado del control
762
+ * no cambia y React no vuelve a escribir el input.
763
+ */
764
+ function writeInputValue(element, valueInput) {
765
+ const rawInput = element.value;
766
+ if (rawInput === valueInput) {
767
+ return;
768
+ }
769
+ const selection = selectionStartOf(element);
770
+ element.value = valueInput;
771
+ if (selection !== null) {
772
+ const offset = valueInput.length - rawInput.length;
773
+ const caret = Math.max(0, Math.min(selection + offset, valueInput.length));
774
+ element.setSelectionRange(caret, caret);
775
+ }
776
+ }
715
777
  function RlsInputComponent({ children, decimals, disabled, formControl, identifier, onBlur, onEnter, onFocus, onKeyDown, onKeyUp, onValue, placeholder, readOnly, type, value }) {
716
- const valueInitial = (formControl?.value ?? value) ? String(value) : '';
717
- const [valueInput, setValueInput] = require$$0.useState(valueInitial);
778
+ const [valueInput, setValueInput] = require$$0.useState(() => valueToInput(formControl?.value ?? value));
718
779
  const [focused, setFocused] = require$$0.useState(false);
719
- const changeIsInternal = require$$0.useRef(false);
780
+ const composing = require$$0.useRef(false);
781
+ const valueSent = require$$0.useRef(formControl?.value);
720
782
  require$$0.useEffect(() => {
721
- if (!changeIsInternal.current && formControl) {
722
- const valueControl = formControl.value ? String(formControl.value) : '';
783
+ if (formControl && !Object.is(formControl.value, valueSent.current)) {
784
+ const valueControl = valueToInput(formControl.value);
723
785
  if (valueInput !== valueControl) {
724
786
  setValueInput(valueControl);
725
787
  }
726
788
  }
727
- changeIsInternal.current = false;
728
789
  }, [formControl?.value]);
729
- const onChangeInput = require$$0.useCallback((event) => {
730
- const valueInput = event.target.value;
731
- const value = type === 'number'
732
- ? parseFloat((+valueInput).toFixed(decimals))
733
- : valueInput;
734
- changeIsInternal.current = true;
790
+ const applyInput = require$$0.useCallback((element) => {
791
+ const rawInput = element.value;
792
+ const parsed = type === 'number'
793
+ ? parseFloat((+rawInput).toFixed(decimals))
794
+ : rawInput;
795
+ const formatter = formControl?.formatter;
796
+ const value = formatter && formControl?.formatOn !== 'blur' && !composing.current
797
+ ? formatter(parsed)
798
+ : parsed;
799
+ const textInput = Object.is(value, parsed)
800
+ ? rawInput
801
+ : type === 'number'
802
+ ? Number.isNaN(value)
803
+ ? ''
804
+ : String(value)
805
+ : valueToInput(value);
806
+ writeInputValue(element, textInput);
807
+ valueSent.current = value;
735
808
  onValue?.(value);
736
- setValueInput(valueInput);
809
+ setValueInput(textInput);
737
810
  formControl?.setValue(value);
738
811
  }, [formControl, onValue, type, decimals]);
812
+ const onChangeInput = require$$0.useCallback((event) => {
813
+ applyInput(event.target);
814
+ }, [applyInput]);
815
+ const onCompositionStart = require$$0.useCallback(() => {
816
+ composing.current = true;
817
+ }, []);
818
+ const onCompositionEnd = require$$0.useCallback((event) => {
819
+ composing.current = false;
820
+ applyInput(event.currentTarget);
821
+ }, [applyInput]);
739
822
  const onKeyDownInput = require$$0.useCallback((event) => {
740
823
  onKeyDown?.(event);
741
824
  if (event.key === 'Enter') {
@@ -759,7 +842,7 @@ function RlsInputComponent({ children, decimals, disabled, formControl, identifi
759
842
  disabled: formControl?.disabled || disabled,
760
843
  focused: formControl?.focused ?? focused
761
844
  });
762
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, children: [jsxRuntimeExports.jsx("input", { ref: formControl?.elementRef, className: "rls-input__component", autoComplete: "off", type: type ?? 'text', placeholder: placeholder, disabled: formControl?.disabled || disabled, readOnly: readOnly, onFocus: onFocusInput, onBlur: onBlurInput, onChange: onChangeInput, onKeyDown: onKeyDownInput, onKeyUp: onKeyUpInput, value: valueInput }), jsxRuntimeExports.jsx("span", { className: "rls-input__value", children: children })] }));
845
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, children: [jsxRuntimeExports.jsx("input", { ref: formControl?.elementRef, className: "rls-input__component", autoComplete: "off", type: type ?? 'text', placeholder: placeholder, disabled: formControl?.disabled || disabled, readOnly: readOnly, onFocus: onFocusInput, onBlur: onBlurInput, onChange: onChangeInput, onCompositionStart: onCompositionStart, onCompositionEnd: onCompositionEnd, onKeyDown: onKeyDownInput, onKeyUp: onKeyUpInput, value: valueInput }), jsxRuntimeExports.jsx("span", { className: "rls-input__value", children: children })] }));
763
846
  }
764
847
  const RlsInput = require$$0.memo(RlsInputComponent);
765
848
 
@@ -1389,6 +1472,132 @@ function RlsAlertComponent({ bordered, children, icon, identifier, rlsTheme }) {
1389
1472
  }
1390
1473
  const RlsAlert = require$$0.memo(RlsAlertComponent);
1391
1474
 
1475
+ const APP_THEME_ATTRIBUTE = 'app-theme';
1476
+ function getAppTheme() {
1477
+ if (typeof document === 'undefined') {
1478
+ return 'light';
1479
+ }
1480
+ const theme = document.body.getAttribute(APP_THEME_ATTRIBUTE);
1481
+ return theme === 'dark' || theme === 'dim' ? theme : 'light';
1482
+ }
1483
+ function setAppTheme(theme) {
1484
+ if (typeof document === 'undefined') {
1485
+ return;
1486
+ }
1487
+ document.body.setAttribute(APP_THEME_ATTRIBUTE, theme);
1488
+ }
1489
+ function toggleAppTheme() {
1490
+ const theme = getAppTheme() === 'dark' ? 'light' : 'dark';
1491
+ setAppTheme(theme);
1492
+ return theme;
1493
+ }
1494
+
1495
+ const reactI18n = i18n.i18n({
1496
+ es: {
1497
+ appThemeDark: 'Oscuro',
1498
+ appThemeDim: 'Intermedio',
1499
+ appThemeLight: 'Claro',
1500
+ confirmationActionApproved: 'Aceptar',
1501
+ dateActionCancel: 'Cancelar',
1502
+ dateActionSelect: 'Establecer',
1503
+ dateActionToday: 'Hoy',
1504
+ chooserImageActionCancel: 'Cancelar',
1505
+ editorImageActionRestore: 'Restaurar',
1506
+ editorImageActionSelect: 'Seleccionar',
1507
+ listEmptyDescription: 'Lo sentimos, en el momento no hay elementos en el listado',
1508
+ listEmptyTitle: 'Selección no disponible',
1509
+ listInputPlaceholder: 'Escriba palabre clave para filtrar...'
1510
+ },
1511
+ en: {
1512
+ appThemeDark: 'Dark',
1513
+ appThemeDim: 'Dim',
1514
+ appThemeLight: 'Light',
1515
+ confirmationActionApproved: 'Approved',
1516
+ dateActionCancel: 'Cancel',
1517
+ dateActionSelect: 'Select',
1518
+ dateActionToday: 'Today',
1519
+ chooserImageActionCancel: 'Cancel',
1520
+ editorImageActionRestore: 'Restore',
1521
+ editorImageActionSelect: 'Select',
1522
+ listEmptyDescription: 'Sorry, there are currently no items in the list',
1523
+ listEmptyTitle: 'Selection not available',
1524
+ listInputPlaceholder: 'Enter keyword to filter...'
1525
+ }
1526
+ });
1527
+
1528
+ function RlsTab({ disabled, onSelect, tab, value }) {
1529
+ const className = renderClassStatus('rls-tabs__children', {
1530
+ active: tab.value === value,
1531
+ disabled: disabled || tab.disabled
1532
+ });
1533
+ const onClick = require$$0.useCallback(() => {
1534
+ if (!disabled && !tab.disabled) {
1535
+ onSelect(tab.value);
1536
+ }
1537
+ }, [disabled, tab.disabled, onSelect]);
1538
+ return (jsxRuntimeExports.jsx("div", { className: className, onClick: onClick, children: jsxRuntimeExports.jsx("span", { children: tab.label }) }));
1539
+ }
1540
+ function RlsTabsComponent({ tabs, formControl, onValue, value, rlsTheme }) {
1541
+ const [valueInternal, setValueInternal] = require$$0.useState();
1542
+ const valueSelected = require$$0.useMemo(() => {
1543
+ return formControl ? formControl.value : valueInternal;
1544
+ }, [formControl?.value, valueInternal]);
1545
+ const onSelect = require$$0.useCallback((value) => {
1546
+ if (formControl) {
1547
+ formControl?.setValue(value);
1548
+ }
1549
+ else {
1550
+ setValueInternal(value);
1551
+ }
1552
+ onValue?.(value);
1553
+ }, [formControl, onValue]);
1554
+ require$$0.useEffect(() => {
1555
+ if (formControl?.value !== undefined) {
1556
+ return setValueInternal(formControl.value);
1557
+ }
1558
+ if (value !== undefined) {
1559
+ return setValueInternal(value);
1560
+ }
1561
+ const initial = tabs.find((tab) => tab.defaultActive) ?? tabs[0];
1562
+ if (initial) {
1563
+ onSelect(initial.value);
1564
+ }
1565
+ }, [value, formControl?.value]);
1566
+ return (jsxRuntimeExports.jsx("div", { className: "rls-tabs", "rls-theme": rlsTheme, children: tabs.map((tab, index) => {
1567
+ return (jsxRuntimeExports.jsx(RlsTab, { tab: tab, disabled: formControl?.disabled, value: valueSelected, onSelect: onSelect }, index));
1568
+ }) }));
1569
+ }
1570
+ const RlsTabs = require$$0.memo(RlsTabsComponent);
1571
+
1572
+ const APP_THEMES = ['light', 'dim', 'dark'];
1573
+ const LABELS = {
1574
+ light: () => reactI18n('appThemeLight'),
1575
+ dim: () => reactI18n('appThemeDim'),
1576
+ dark: () => reactI18n('appThemeDark')
1577
+ };
1578
+ function RlsAppThemeTabsComponent({ labels, onValue, rlsTheme, themes = APP_THEMES, value }) {
1579
+ const [appTheme, setAppThemeValue] = require$$0.useState(() => value ?? getAppTheme());
1580
+ require$$0.useEffect(() => {
1581
+ if (value !== undefined) {
1582
+ setAppTheme(value);
1583
+ setAppThemeValue(value);
1584
+ }
1585
+ }, [value]);
1586
+ const tabs = require$$0.useMemo(() => {
1587
+ return themes.map((theme) => ({
1588
+ label: labels?.[theme] ?? LABELS[theme](),
1589
+ value: theme
1590
+ }));
1591
+ }, [labels, themes]);
1592
+ const onSelect = require$$0.useCallback((theme) => {
1593
+ setAppTheme(theme);
1594
+ setAppThemeValue(theme);
1595
+ onValue?.(theme);
1596
+ }, [onValue]);
1597
+ return (jsxRuntimeExports.jsx(RlsTabs, { tabs: tabs, value: appTheme, onValue: onSelect, rlsTheme: rlsTheme }));
1598
+ }
1599
+ const RlsAppThemeTabs = require$$0.memo(RlsAppThemeTabsComponent);
1600
+
1392
1601
  function RlsBallotComponent({ bordered, className, children, img, initials, skeleton, subtitle, rlsTheme }) {
1393
1602
  const classNameBallot = renderClassStatus('rls-ballot', { bordered, skeleton }, className);
1394
1603
  return (jsxRuntimeExports.jsxs("div", { className: classNameBallot, "rls-theme": rlsTheme, children: [(img || initials) && (jsxRuntimeExports.jsxs(RlsAvatar, { skeleton: skeleton, children: [img && jsxRuntimeExports.jsx("img", { src: img }), initials && jsxRuntimeExports.jsx("span", { children: initials })] })), jsxRuntimeExports.jsxs("div", { className: "rls-ballot__component", children: [jsxRuntimeExports.jsx("div", { className: "rls-ballot__title", children: jsxRuntimeExports.jsx(RlsSkeletonText, { active: skeleton, children: children }) }), subtitle && (jsxRuntimeExports.jsx("div", { className: "rls-ballot__subtitle", children: jsxRuntimeExports.jsx(RlsSkeletonText, { active: skeleton, children: subtitle }) }))] })] }));
@@ -1676,33 +1885,6 @@ function RlsFieldFileComponent({ accept, children, disabled: _disabled, formCont
1676
1885
  }
1677
1886
  const RlsFieldFile = require$$0.memo(RlsFieldFileComponent);
1678
1887
 
1679
- const reactI18n = i18n.i18n({
1680
- es: {
1681
- confirmationActionApproved: 'Aceptar',
1682
- dateActionCancel: 'Cancelar',
1683
- dateActionSelect: 'Establecer',
1684
- dateActionToday: 'Hoy',
1685
- chooserImageActionCancel: 'Cancelar',
1686
- editorImageActionRestore: 'Restaurar',
1687
- editorImageActionSelect: 'Seleccionar',
1688
- listEmptyDescription: 'Lo sentimos, en el momento no hay elementos en el listado',
1689
- listEmptyTitle: 'Selección no disponible',
1690
- listInputPlaceholder: 'Escriba palabre clave para filtrar...'
1691
- },
1692
- en: {
1693
- confirmationActionApproved: 'Approved',
1694
- dateActionCancel: 'Cancel',
1695
- dateActionSelect: 'Select',
1696
- dateActionToday: 'Today',
1697
- chooserImageActionCancel: 'Cancel',
1698
- editorImageActionRestore: 'Restore',
1699
- editorImageActionSelect: 'Select',
1700
- listEmptyDescription: 'Sorry, there are currently no items in the list',
1701
- listEmptyTitle: 'Selection not available',
1702
- listInputPlaceholder: 'Enter keyword to filter...'
1703
- }
1704
- });
1705
-
1706
1888
  function useEventCallback(callback) {
1707
1889
  const refCallback = require$$0.useRef(callback);
1708
1890
  require$$0.useInsertionEffect(() => {
@@ -2613,50 +2795,6 @@ function RlsSliderComponent({ children, className, disabled, formControl, identi
2613
2795
  }
2614
2796
  const RlsSlider = require$$0.memo(RlsSliderComponent);
2615
2797
 
2616
- function RlsTab({ disabled, onSelect, tab, value }) {
2617
- const className = renderClassStatus('rls-tabs__children', {
2618
- active: tab.value === value,
2619
- disabled: disabled || tab.disabled
2620
- });
2621
- const onClick = require$$0.useCallback(() => {
2622
- if (!disabled && !tab.disabled) {
2623
- onSelect(tab.value);
2624
- }
2625
- }, [disabled, tab.disabled, onSelect]);
2626
- return (jsxRuntimeExports.jsx("div", { className: className, onClick: onClick, children: jsxRuntimeExports.jsx("span", { children: tab.label }) }));
2627
- }
2628
- function RlsTabsComponent({ tabs, formControl, onValue, value, rlsTheme }) {
2629
- const [valueInternal, setValueInternal] = require$$0.useState();
2630
- const valueSelected = require$$0.useMemo(() => {
2631
- return formControl ? formControl.value : valueInternal;
2632
- }, [formControl?.value, valueInternal]);
2633
- const onSelect = require$$0.useCallback((value) => {
2634
- if (formControl) {
2635
- formControl?.setValue(value);
2636
- }
2637
- else {
2638
- setValueInternal(value);
2639
- }
2640
- onValue?.(value);
2641
- }, [formControl, onValue]);
2642
- require$$0.useEffect(() => {
2643
- if (formControl?.value !== undefined) {
2644
- return setValueInternal(formControl.value);
2645
- }
2646
- if (value !== undefined) {
2647
- return setValueInternal(value);
2648
- }
2649
- const initial = tabs.find((tab) => tab.defaultActive) ?? tabs[0];
2650
- if (initial) {
2651
- onSelect(initial.value);
2652
- }
2653
- }, [value, formControl?.value]);
2654
- return (jsxRuntimeExports.jsx("div", { className: "rls-tabs", "rls-theme": rlsTheme, children: tabs.map((tab, index) => {
2655
- return (jsxRuntimeExports.jsx(RlsTab, { tab: tab, disabled: formControl?.disabled, value: valueSelected, onSelect: onSelect }, index));
2656
- }) }));
2657
- }
2658
- const RlsTabs = require$$0.memo(RlsTabsComponent);
2659
-
2660
2798
  function RlsToolbarComponent({ actions, children, subtitle }) {
2661
2799
  return (jsxRuntimeExports.jsxs("div", { className: "rls-toolbar", children: [jsxRuntimeExports.jsxs("div", { className: "rls-toolbar__description", children: [children && jsxRuntimeExports.jsx("label", { className: "rls-toolbar__title", children: children }), subtitle && (jsxRuntimeExports.jsx("label", { className: "rls-toolbar__subtitle smalltext-semibold", children: subtitle }))] }), actions && (jsxRuntimeExports.jsx("div", { className: "rls-toolbar__actions", children: actions.map((action, index) => (jsxRuntimeExports.jsx("div", { children: action }, index))) }))] }));
2662
2800
  }
@@ -5141,6 +5279,24 @@ function RlsApplication({ children }) {
5141
5279
  return (jsxRuntimeExports.jsxs(RlsContext, { value: state, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children, jsxRuntimeExports.jsx(RlsSnackbar, {})] }), jsxRuntimeExports.jsx(RlsConfirmation, {}), jsxRuntimeExports.jsx(RlsNotifications, {})] }));
5142
5280
  }
5143
5281
 
5282
+ function useAppThemeController(initialTheme, primaryTheme = 'light', secondaryTheme = 'dark') {
5283
+ const [appTheme, setAppThemeValue] = require$$0.useState(() => {
5284
+ if (initialTheme) {
5285
+ setAppTheme(initialTheme);
5286
+ return initialTheme;
5287
+ }
5288
+ return getAppTheme();
5289
+ });
5290
+ const setValue = require$$0.useCallback((value) => {
5291
+ setAppTheme(value);
5292
+ setAppThemeValue(value);
5293
+ }, []);
5294
+ const toggle = require$$0.useCallback(() => {
5295
+ setValue(appTheme === primaryTheme ? secondaryTheme : primaryTheme);
5296
+ }, [appTheme, primaryTheme, secondaryTheme, setValue]);
5297
+ return { setValue, toggle, value: appTheme };
5298
+ }
5299
+
5144
5300
  const DEFAULT_DESIGN_SYSTEM = 'bordered';
5145
5301
 
5146
5302
  const DESIGN_SYSTEM_PREFIX = 'rls-design-system';
@@ -5274,32 +5430,13 @@ function useTabsController(options) {
5274
5430
  return require$$0.useMemo(() => ({ Tabs, formControl }), [Tabs, formControl]);
5275
5431
  }
5276
5432
 
5277
- const APP_THEME_ATTRIBUTE = 'app-theme';
5278
- function getAppTheme() {
5279
- if (typeof document === 'undefined') {
5280
- return 'light';
5281
- }
5282
- return document.body.getAttribute(APP_THEME_ATTRIBUTE) === 'dark'
5283
- ? 'dark'
5284
- : 'light';
5285
- }
5286
- function setAppTheme(theme) {
5287
- if (typeof document === 'undefined') {
5288
- return;
5289
- }
5290
- document.body.setAttribute(APP_THEME_ATTRIBUTE, theme);
5291
- }
5292
- function toggleAppTheme() {
5293
- const theme = getAppTheme() === 'dark' ? 'light' : 'dark';
5294
- setAppTheme(theme);
5295
- return theme;
5296
- }
5297
-
5433
+ exports.APP_THEMES = APP_THEMES;
5298
5434
  exports.ConfirmationResult = ConfirmationResult;
5299
5435
  exports.DEFAULT_COLOR = DEFAULT_COLOR;
5300
5436
  exports.RlsAccordion = RlsAccordion;
5301
5437
  exports.RlsAlert = RlsAlert;
5302
5438
  exports.RlsAmount = RlsAmount;
5439
+ exports.RlsAppThemeTabs = RlsAppThemeTabs;
5303
5440
  exports.RlsApplication = RlsApplication;
5304
5441
  exports.RlsAreaText = RlsAreaText;
5305
5442
  exports.RlsAvatar = RlsAvatar;
@@ -5433,6 +5570,7 @@ exports.setDesignSystem = setDesignSystem;
5433
5570
  exports.setErrorsI18n = setErrorsI18n;
5434
5571
  exports.setThemeColor = setThemeColor;
5435
5572
  exports.toggleAppTheme = toggleAppTheme;
5573
+ exports.useAppThemeController = useAppThemeController;
5436
5574
  exports.useConfirmation = useConfirmation;
5437
5575
  exports.useDatatable = useDatatable;
5438
5576
  exports.useDesingSystemController = useDesingSystemController;