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