@rolster/react-components 19.9.0 → 19.11.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/cjs/index.cjs +229 -93
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/es/index.mjs +224 -94
- package/dist/es/index.mjs.map +1 -1
- package/dist/esm/components/atoms/Chip/Chip.d.ts +13 -0
- package/dist/esm/components/atoms/Chip/Chip.js +10 -0
- package/dist/esm/components/atoms/Chip/Chip.js.map +1 -0
- package/dist/esm/components/molecules/AppThemeTabs/AppThemeTabs.d.ts +13 -0
- package/dist/esm/components/molecules/AppThemeTabs/AppThemeTabs.js +34 -0
- package/dist/esm/components/molecules/AppThemeTabs/AppThemeTabs.js.map +1 -0
- package/dist/esm/components/molecules/ChipGroup/ChipGroup.d.ts +31 -0
- package/dist/esm/components/molecules/ChipGroup/ChipGroup.js +34 -0
- package/dist/esm/components/molecules/ChipGroup/ChipGroup.js.map +1 -0
- package/dist/esm/components/organisms/FieldList/FieldList.js +4 -2
- package/dist/esm/components/organisms/FieldList/FieldList.js.map +1 -1
- package/dist/esm/components/organisms/LedColor/LedColor.d.ts +36 -0
- package/dist/esm/components/organisms/LedColor/LedColor.js +48 -0
- package/dist/esm/components/organisms/LedColor/LedColor.js.map +1 -0
- package/dist/esm/controllers/AppThemeController.d.ts +7 -0
- package/dist/esm/controllers/AppThemeController.js +20 -0
- package/dist/esm/controllers/AppThemeController.js.map +1 -0
- package/dist/esm/helpers/app-theme.js +2 -3
- package/dist/esm/helpers/app-theme.js.map +1 -1
- package/dist/esm/i18n.d.ts +3 -0
- package/dist/esm/i18n.js +6 -0
- package/dist/esm/i18n.js.map +1 -1
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types.d.ts +2 -2
- package/package.json +2 -2
- package/readme.md +30 -24
package/dist/es/index.mjs
CHANGED
|
@@ -719,6 +719,12 @@ function RlsCheckBoxControlComponent({ formControl, disabled, identifier, rlsThe
|
|
|
719
719
|
}
|
|
720
720
|
const RlsCheckBoxControl = memo(RlsCheckBoxControlComponent);
|
|
721
721
|
|
|
722
|
+
function RlsChipComponent({ children, className, contrasted, disabled, icon, identifier, onClick, onRemove, rlsTheme, selected }) {
|
|
723
|
+
const classNameChip = renderClassStatus('rls-chip', { clickable: !!onClick && !disabled, contrasted, disabled, selected }, className);
|
|
724
|
+
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: classNameChip, "rls-theme": rlsTheme, onClick: disabled ? undefined : onClick, children: [icon && jsxRuntimeExports.jsx(RlsIcon, { className: "rls-chip__icon", value: icon }), jsxRuntimeExports.jsx("span", { className: "rls-chip__description", children: children }), onRemove && !disabled && (jsxRuntimeExports.jsx("button", { className: "rls-chip__remove", type: "button", onClick: onRemove, children: jsxRuntimeExports.jsx(RlsIcon, { value: "close" }) }))] }));
|
|
725
|
+
}
|
|
726
|
+
const RlsChip = memo(RlsChipComponent);
|
|
727
|
+
|
|
722
728
|
function RlsSkeletonComponent({ animation, rlsTheme }) {
|
|
723
729
|
const className = renderClassStatus('rls-skeleton', {
|
|
724
730
|
animation: animation !== 'shimmer' && animation
|
|
@@ -1470,6 +1476,132 @@ function RlsAlertComponent({ bordered, children, icon, identifier, rlsTheme }) {
|
|
|
1470
1476
|
}
|
|
1471
1477
|
const RlsAlert = memo(RlsAlertComponent);
|
|
1472
1478
|
|
|
1479
|
+
const APP_THEME_ATTRIBUTE = 'app-theme';
|
|
1480
|
+
function getAppTheme() {
|
|
1481
|
+
if (typeof document === 'undefined') {
|
|
1482
|
+
return 'light';
|
|
1483
|
+
}
|
|
1484
|
+
const theme = document.body.getAttribute(APP_THEME_ATTRIBUTE);
|
|
1485
|
+
return theme === 'dark' || theme === 'dim' ? theme : 'light';
|
|
1486
|
+
}
|
|
1487
|
+
function setAppTheme(theme) {
|
|
1488
|
+
if (typeof document === 'undefined') {
|
|
1489
|
+
return;
|
|
1490
|
+
}
|
|
1491
|
+
document.body.setAttribute(APP_THEME_ATTRIBUTE, theme);
|
|
1492
|
+
}
|
|
1493
|
+
function toggleAppTheme() {
|
|
1494
|
+
const theme = getAppTheme() === 'dark' ? 'light' : 'dark';
|
|
1495
|
+
setAppTheme(theme);
|
|
1496
|
+
return theme;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
const reactI18n = i18n({
|
|
1500
|
+
es: {
|
|
1501
|
+
appThemeDark: 'Oscuro',
|
|
1502
|
+
appThemeDim: 'Intermedio',
|
|
1503
|
+
appThemeLight: 'Claro',
|
|
1504
|
+
confirmationActionApproved: 'Aceptar',
|
|
1505
|
+
dateActionCancel: 'Cancelar',
|
|
1506
|
+
dateActionSelect: 'Establecer',
|
|
1507
|
+
dateActionToday: 'Hoy',
|
|
1508
|
+
chooserImageActionCancel: 'Cancelar',
|
|
1509
|
+
editorImageActionRestore: 'Restaurar',
|
|
1510
|
+
editorImageActionSelect: 'Seleccionar',
|
|
1511
|
+
listEmptyDescription: 'Lo sentimos, en el momento no hay elementos en el listado',
|
|
1512
|
+
listEmptyTitle: 'Selección no disponible',
|
|
1513
|
+
listInputPlaceholder: 'Escriba palabre clave para filtrar...'
|
|
1514
|
+
},
|
|
1515
|
+
en: {
|
|
1516
|
+
appThemeDark: 'Dark',
|
|
1517
|
+
appThemeDim: 'Dim',
|
|
1518
|
+
appThemeLight: 'Light',
|
|
1519
|
+
confirmationActionApproved: 'Approved',
|
|
1520
|
+
dateActionCancel: 'Cancel',
|
|
1521
|
+
dateActionSelect: 'Select',
|
|
1522
|
+
dateActionToday: 'Today',
|
|
1523
|
+
chooserImageActionCancel: 'Cancel',
|
|
1524
|
+
editorImageActionRestore: 'Restore',
|
|
1525
|
+
editorImageActionSelect: 'Select',
|
|
1526
|
+
listEmptyDescription: 'Sorry, there are currently no items in the list',
|
|
1527
|
+
listEmptyTitle: 'Selection not available',
|
|
1528
|
+
listInputPlaceholder: 'Enter keyword to filter...'
|
|
1529
|
+
}
|
|
1530
|
+
});
|
|
1531
|
+
|
|
1532
|
+
function RlsTab({ disabled, onSelect, tab, value }) {
|
|
1533
|
+
const className = renderClassStatus('rls-tabs__children', {
|
|
1534
|
+
active: tab.value === value,
|
|
1535
|
+
disabled: disabled || tab.disabled
|
|
1536
|
+
});
|
|
1537
|
+
const onClick = useCallback(() => {
|
|
1538
|
+
if (!disabled && !tab.disabled) {
|
|
1539
|
+
onSelect(tab.value);
|
|
1540
|
+
}
|
|
1541
|
+
}, [disabled, tab.disabled, onSelect]);
|
|
1542
|
+
return (jsxRuntimeExports.jsx("div", { className: className, onClick: onClick, children: jsxRuntimeExports.jsx("span", { children: tab.label }) }));
|
|
1543
|
+
}
|
|
1544
|
+
function RlsTabsComponent({ tabs, formControl, onValue, value, rlsTheme }) {
|
|
1545
|
+
const [valueInternal, setValueInternal] = useState();
|
|
1546
|
+
const valueSelected = useMemo(() => {
|
|
1547
|
+
return formControl ? formControl.value : valueInternal;
|
|
1548
|
+
}, [formControl?.value, valueInternal]);
|
|
1549
|
+
const onSelect = useCallback((value) => {
|
|
1550
|
+
if (formControl) {
|
|
1551
|
+
formControl?.setValue(value);
|
|
1552
|
+
}
|
|
1553
|
+
else {
|
|
1554
|
+
setValueInternal(value);
|
|
1555
|
+
}
|
|
1556
|
+
onValue?.(value);
|
|
1557
|
+
}, [formControl, onValue]);
|
|
1558
|
+
useEffect(() => {
|
|
1559
|
+
if (formControl?.value !== undefined) {
|
|
1560
|
+
return setValueInternal(formControl.value);
|
|
1561
|
+
}
|
|
1562
|
+
if (value !== undefined) {
|
|
1563
|
+
return setValueInternal(value);
|
|
1564
|
+
}
|
|
1565
|
+
const initial = tabs.find((tab) => tab.defaultActive) ?? tabs[0];
|
|
1566
|
+
if (initial) {
|
|
1567
|
+
onSelect(initial.value);
|
|
1568
|
+
}
|
|
1569
|
+
}, [value, formControl?.value]);
|
|
1570
|
+
return (jsxRuntimeExports.jsx("div", { className: "rls-tabs", "rls-theme": rlsTheme, children: tabs.map((tab, index) => {
|
|
1571
|
+
return (jsxRuntimeExports.jsx(RlsTab, { tab: tab, disabled: formControl?.disabled, value: valueSelected, onSelect: onSelect }, index));
|
|
1572
|
+
}) }));
|
|
1573
|
+
}
|
|
1574
|
+
const RlsTabs = memo(RlsTabsComponent);
|
|
1575
|
+
|
|
1576
|
+
const APP_THEMES = ['light', 'dim', 'dark'];
|
|
1577
|
+
const LABELS = {
|
|
1578
|
+
light: () => reactI18n('appThemeLight'),
|
|
1579
|
+
dim: () => reactI18n('appThemeDim'),
|
|
1580
|
+
dark: () => reactI18n('appThemeDark')
|
|
1581
|
+
};
|
|
1582
|
+
function RlsAppThemeTabsComponent({ labels, onValue, rlsTheme, themes = APP_THEMES, value }) {
|
|
1583
|
+
const [appTheme, setAppThemeValue] = useState(() => value ?? getAppTheme());
|
|
1584
|
+
useEffect(() => {
|
|
1585
|
+
if (value !== undefined) {
|
|
1586
|
+
setAppTheme(value);
|
|
1587
|
+
setAppThemeValue(value);
|
|
1588
|
+
}
|
|
1589
|
+
}, [value]);
|
|
1590
|
+
const tabs = useMemo(() => {
|
|
1591
|
+
return themes.map((theme) => ({
|
|
1592
|
+
label: labels?.[theme] ?? LABELS[theme](),
|
|
1593
|
+
value: theme
|
|
1594
|
+
}));
|
|
1595
|
+
}, [labels, themes]);
|
|
1596
|
+
const onSelect = useCallback((theme) => {
|
|
1597
|
+
setAppTheme(theme);
|
|
1598
|
+
setAppThemeValue(theme);
|
|
1599
|
+
onValue?.(theme);
|
|
1600
|
+
}, [onValue]);
|
|
1601
|
+
return (jsxRuntimeExports.jsx(RlsTabs, { tabs: tabs, value: appTheme, onValue: onSelect, rlsTheme: rlsTheme }));
|
|
1602
|
+
}
|
|
1603
|
+
const RlsAppThemeTabs = memo(RlsAppThemeTabsComponent);
|
|
1604
|
+
|
|
1473
1605
|
function RlsBallotComponent({ bordered, className, children, img, initials, skeleton, subtitle, rlsTheme }) {
|
|
1474
1606
|
const classNameBallot = renderClassStatus('rls-ballot', { bordered, skeleton }, className);
|
|
1475
1607
|
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 }) }))] })] }));
|
|
@@ -1543,6 +1675,36 @@ function RlsButtonToggleComponent({ onAction, options, type, automatic, disabled
|
|
|
1543
1675
|
}
|
|
1544
1676
|
const RlsButtonToggle = memo(RlsButtonToggleComponent);
|
|
1545
1677
|
|
|
1678
|
+
function RlsChipGroupComponent({ className, disabled: disabledProps, formControl, identifier, onValue, options, reference, render, rlsTheme, value: valueInitial }) {
|
|
1679
|
+
const [value, setValue] = useState(formControl?.value ?? valueInitial);
|
|
1680
|
+
const selected = useMemo(() => {
|
|
1681
|
+
return formControl ? formControl.value : value;
|
|
1682
|
+
}, [formControl?.value, value]);
|
|
1683
|
+
const disabled = useMemo(() => {
|
|
1684
|
+
return formControl?.disabled || disabledProps;
|
|
1685
|
+
}, [formControl?.disabled, disabledProps]);
|
|
1686
|
+
const classNameGroup = renderClassStatus('rls-chip-group', { disabled }, className);
|
|
1687
|
+
const isSelected = useCallback((option) => {
|
|
1688
|
+
if (selected === undefined || selected === null) {
|
|
1689
|
+
return false;
|
|
1690
|
+
}
|
|
1691
|
+
return reference
|
|
1692
|
+
? reference(option) === reference(selected)
|
|
1693
|
+
: option === selected;
|
|
1694
|
+
}, [reference, selected]);
|
|
1695
|
+
const onSelect = useCallback((option) => () => {
|
|
1696
|
+
if (disabled) {
|
|
1697
|
+
return;
|
|
1698
|
+
}
|
|
1699
|
+
setValue(option);
|
|
1700
|
+
formControl?.setValue(option);
|
|
1701
|
+
formControl?.touch();
|
|
1702
|
+
onValue?.(option);
|
|
1703
|
+
}, [disabled, formControl, onValue]);
|
|
1704
|
+
return (jsxRuntimeExports.jsx("div", { id: identifier, className: classNameGroup, "rls-theme": rlsTheme, children: options.map((option, index) => (jsxRuntimeExports.jsx(RlsChip, { disabled: disabled, selected: isSelected(option), onClick: onSelect(option), children: render ? render(option) : String(option) }, index))) }));
|
|
1705
|
+
}
|
|
1706
|
+
const RlsChipGroup = memo(RlsChipGroupComponent);
|
|
1707
|
+
|
|
1546
1708
|
function RlsContentComponent({ children, identifier, rlsTheme }) {
|
|
1547
1709
|
return (jsxRuntimeExports.jsx("div", { id: identifier, className: "rls-app__page__content", "rls-theme": rlsTheme, children: children }));
|
|
1548
1710
|
}
|
|
@@ -1757,33 +1919,6 @@ function RlsFieldFileComponent({ accept, children, disabled: _disabled, formCont
|
|
|
1757
1919
|
}
|
|
1758
1920
|
const RlsFieldFile = memo(RlsFieldFileComponent);
|
|
1759
1921
|
|
|
1760
|
-
const reactI18n = i18n({
|
|
1761
|
-
es: {
|
|
1762
|
-
confirmationActionApproved: 'Aceptar',
|
|
1763
|
-
dateActionCancel: 'Cancelar',
|
|
1764
|
-
dateActionSelect: 'Establecer',
|
|
1765
|
-
dateActionToday: 'Hoy',
|
|
1766
|
-
chooserImageActionCancel: 'Cancelar',
|
|
1767
|
-
editorImageActionRestore: 'Restaurar',
|
|
1768
|
-
editorImageActionSelect: 'Seleccionar',
|
|
1769
|
-
listEmptyDescription: 'Lo sentimos, en el momento no hay elementos en el listado',
|
|
1770
|
-
listEmptyTitle: 'Selección no disponible',
|
|
1771
|
-
listInputPlaceholder: 'Escriba palabre clave para filtrar...'
|
|
1772
|
-
},
|
|
1773
|
-
en: {
|
|
1774
|
-
confirmationActionApproved: 'Approved',
|
|
1775
|
-
dateActionCancel: 'Cancel',
|
|
1776
|
-
dateActionSelect: 'Select',
|
|
1777
|
-
dateActionToday: 'Today',
|
|
1778
|
-
chooserImageActionCancel: 'Cancel',
|
|
1779
|
-
editorImageActionRestore: 'Restore',
|
|
1780
|
-
editorImageActionSelect: 'Select',
|
|
1781
|
-
listEmptyDescription: 'Sorry, there are currently no items in the list',
|
|
1782
|
-
listEmptyTitle: 'Selection not available',
|
|
1783
|
-
listInputPlaceholder: 'Enter keyword to filter...'
|
|
1784
|
-
}
|
|
1785
|
-
});
|
|
1786
|
-
|
|
1787
1922
|
function useEventCallback(callback) {
|
|
1788
1923
|
const refCallback = useRef(callback);
|
|
1789
1924
|
useInsertionEffect(() => {
|
|
@@ -2694,50 +2829,6 @@ function RlsSliderComponent({ children, className, disabled, formControl, identi
|
|
|
2694
2829
|
}
|
|
2695
2830
|
const RlsSlider = memo(RlsSliderComponent);
|
|
2696
2831
|
|
|
2697
|
-
function RlsTab({ disabled, onSelect, tab, value }) {
|
|
2698
|
-
const className = renderClassStatus('rls-tabs__children', {
|
|
2699
|
-
active: tab.value === value,
|
|
2700
|
-
disabled: disabled || tab.disabled
|
|
2701
|
-
});
|
|
2702
|
-
const onClick = useCallback(() => {
|
|
2703
|
-
if (!disabled && !tab.disabled) {
|
|
2704
|
-
onSelect(tab.value);
|
|
2705
|
-
}
|
|
2706
|
-
}, [disabled, tab.disabled, onSelect]);
|
|
2707
|
-
return (jsxRuntimeExports.jsx("div", { className: className, onClick: onClick, children: jsxRuntimeExports.jsx("span", { children: tab.label }) }));
|
|
2708
|
-
}
|
|
2709
|
-
function RlsTabsComponent({ tabs, formControl, onValue, value, rlsTheme }) {
|
|
2710
|
-
const [valueInternal, setValueInternal] = useState();
|
|
2711
|
-
const valueSelected = useMemo(() => {
|
|
2712
|
-
return formControl ? formControl.value : valueInternal;
|
|
2713
|
-
}, [formControl?.value, valueInternal]);
|
|
2714
|
-
const onSelect = useCallback((value) => {
|
|
2715
|
-
if (formControl) {
|
|
2716
|
-
formControl?.setValue(value);
|
|
2717
|
-
}
|
|
2718
|
-
else {
|
|
2719
|
-
setValueInternal(value);
|
|
2720
|
-
}
|
|
2721
|
-
onValue?.(value);
|
|
2722
|
-
}, [formControl, onValue]);
|
|
2723
|
-
useEffect(() => {
|
|
2724
|
-
if (formControl?.value !== undefined) {
|
|
2725
|
-
return setValueInternal(formControl.value);
|
|
2726
|
-
}
|
|
2727
|
-
if (value !== undefined) {
|
|
2728
|
-
return setValueInternal(value);
|
|
2729
|
-
}
|
|
2730
|
-
const initial = tabs.find((tab) => tab.defaultActive) ?? tabs[0];
|
|
2731
|
-
if (initial) {
|
|
2732
|
-
onSelect(initial.value);
|
|
2733
|
-
}
|
|
2734
|
-
}, [value, formControl?.value]);
|
|
2735
|
-
return (jsxRuntimeExports.jsx("div", { className: "rls-tabs", "rls-theme": rlsTheme, children: tabs.map((tab, index) => {
|
|
2736
|
-
return (jsxRuntimeExports.jsx(RlsTab, { tab: tab, disabled: formControl?.disabled, value: valueSelected, onSelect: onSelect }, index));
|
|
2737
|
-
}) }));
|
|
2738
|
-
}
|
|
2739
|
-
const RlsTabs = memo(RlsTabsComponent);
|
|
2740
|
-
|
|
2741
2832
|
function RlsToolbarComponent({ actions, children, subtitle }) {
|
|
2742
2833
|
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))) }))] }));
|
|
2743
2834
|
}
|
|
@@ -4552,7 +4643,9 @@ function RlsFieldListInner({ render, suggestions, action, children, formControl,
|
|
|
4552
4643
|
readonly: props.readOnly
|
|
4553
4644
|
}, `rls-field-list rls-field-list__multi ${props.className ?? ''}`);
|
|
4554
4645
|
const renderWithCheckbox = useCallback((element) => (jsxRuntimeExports.jsxs("div", { className: "rls-field-list__multi__element", children: [jsxRuntimeExports.jsx(RlsCheckBox, { checked: fieldList.isSelected(element) }), render(element)] })), [fieldList.isSelected, render]);
|
|
4555
|
-
return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: fieldList.refContent, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__multi__chips", onClick: disabled ? undefined : fieldList.onClickInput, children: !fieldList.selected.length && placeholder ? (jsxRuntimeExports.jsx("span", { className: "rls-field-list__multi__placeholder", children: placeholder })) : (fieldList.selected.map((item, index) => (jsxRuntimeExports.
|
|
4646
|
+
return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: fieldList.refContent, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__multi__chips", onClick: disabled ? undefined : fieldList.onClickInput, children: !fieldList.selected.length && placeholder ? (jsxRuntimeExports.jsx("span", { className: "rls-field-list__multi__placeholder", children: placeholder })) : (fieldList.selected.map((item, index) => (jsxRuntimeExports.jsx(RlsChip, { onRemove: !props.readOnly && !disabled
|
|
4647
|
+
? fieldList.onRemoveElement(item)
|
|
4648
|
+
: undefined, children: item.description }, index)))) }), !props.readOnly && !disabled && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: "arrow-ios-down", onClick: fieldList.onClickAction }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsx(RlsFieldListSuggestions, { elements: suggestions, visible: fieldList.listIsVisible, action: action, disabled: disabled, higher: fieldList.higher, render: renderWithCheckbox, refAnchor: fieldList.refContent, refList: fieldList.refList, refSuggestions: fieldList.refSuggestions, onClickElement: fieldList.onClickElement, onKeydownElement: fieldList.onKeydownElement, onClickBackdrop: fieldList.onClickBackdrop, onHiddenAnchor: fieldList.onClickBackdrop })] }));
|
|
4556
4649
|
}
|
|
4557
4650
|
function RlsFieldListTemplateComponent(props) {
|
|
4558
4651
|
const fieldList = useFieldList(props);
|
|
@@ -5041,6 +5134,46 @@ function RlsImageChooserComponent(props) {
|
|
|
5041
5134
|
}
|
|
5042
5135
|
const RlsImageChooser = memo(RlsImageChooserComponent);
|
|
5043
5136
|
|
|
5137
|
+
function RlsLedColorComponent({ className, color, disabled: disabledProps, formControl, identifier, onValue, readOnly, rlsTheme, value: valueInitial }) {
|
|
5138
|
+
const [value, setValue] = useState(formControl?.value ?? valueInitial);
|
|
5139
|
+
const [modalIsVisible, setModalIsVisible] = useState(false);
|
|
5140
|
+
const [pickerKey, setPickerKey] = useState(0);
|
|
5141
|
+
const colorValue = useMemo(() => {
|
|
5142
|
+
return formControl ? formControl.value : value;
|
|
5143
|
+
}, [formControl?.value, value]);
|
|
5144
|
+
const disabled = useMemo(() => {
|
|
5145
|
+
return formControl?.disabled || disabledProps;
|
|
5146
|
+
}, [formControl?.disabled, disabledProps]);
|
|
5147
|
+
const ledColor = useMemo(() => {
|
|
5148
|
+
return colorValue && hexIsValid(colorValue)
|
|
5149
|
+
? normalizeHex(colorValue)
|
|
5150
|
+
: undefined;
|
|
5151
|
+
}, [colorValue]);
|
|
5152
|
+
const classNameLed = renderClassStatus('rls-led-color', { disabled, error: formControl?.wrong, readonly: readOnly }, className);
|
|
5153
|
+
const onChange = useCallback((value) => {
|
|
5154
|
+
setValue(value);
|
|
5155
|
+
onValue?.(value);
|
|
5156
|
+
}, [onValue]);
|
|
5157
|
+
const onClickLed = useCallback(() => {
|
|
5158
|
+
if (!disabled && !readOnly) {
|
|
5159
|
+
setPickerKey((key) => key + 1);
|
|
5160
|
+
setModalIsVisible(true);
|
|
5161
|
+
}
|
|
5162
|
+
}, [disabled, readOnly]);
|
|
5163
|
+
const onListener = useCallback(({ event, value }) => {
|
|
5164
|
+
if (event !== PickerListenerEvent.Cancel) {
|
|
5165
|
+
onChange(value);
|
|
5166
|
+
}
|
|
5167
|
+
formControl?.touch();
|
|
5168
|
+
setModalIsVisible(false);
|
|
5169
|
+
}, [formControl, onChange]);
|
|
5170
|
+
const onBackdrop = useCallback(() => {
|
|
5171
|
+
setModalIsVisible(false);
|
|
5172
|
+
}, []);
|
|
5173
|
+
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: classNameLed, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("button", { className: "rls-led-color__trigger", type: "button", disabled: disabled, onClick: onClickLed, children: jsxRuntimeExports.jsx(RlsLed, { color: ledColor, rlsTheme: rlsTheme }) }), jsxRuntimeExports.jsx(RlsModal, { className: "rls-modal-color", visible: modalIsVisible, rlsTheme: rlsTheme, onBackdrop: onBackdrop, children: jsxRuntimeExports.jsx(RlsPickerColor, { formControl: formControl, color: ledColor ?? color, disabled: disabled, onListener: onListener }, pickerKey) })] }));
|
|
5174
|
+
}
|
|
5175
|
+
const RlsLedColor = memo(RlsLedColorComponent);
|
|
5176
|
+
|
|
5044
5177
|
function RlsModalSheetComponent({ autoclose, children, className, controller, onAutoClose, visible, rlsTheme }) {
|
|
5045
5178
|
const classNameModal = renderClassStatus('rls-modal-sheet', { visible: controller?.visible ?? visible }, className);
|
|
5046
5179
|
const onClickBackdrop = useCallback(() => {
|
|
@@ -5222,6 +5355,24 @@ function RlsApplication({ children }) {
|
|
|
5222
5355
|
return (jsxRuntimeExports.jsxs(RlsContext, { value: state, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children, jsxRuntimeExports.jsx(RlsSnackbar, {})] }), jsxRuntimeExports.jsx(RlsConfirmation, {}), jsxRuntimeExports.jsx(RlsNotifications, {})] }));
|
|
5223
5356
|
}
|
|
5224
5357
|
|
|
5358
|
+
function useAppThemeController(initialTheme, primaryTheme = 'light', secondaryTheme = 'dark') {
|
|
5359
|
+
const [appTheme, setAppThemeValue] = useState(() => {
|
|
5360
|
+
if (initialTheme) {
|
|
5361
|
+
setAppTheme(initialTheme);
|
|
5362
|
+
return initialTheme;
|
|
5363
|
+
}
|
|
5364
|
+
return getAppTheme();
|
|
5365
|
+
});
|
|
5366
|
+
const setValue = useCallback((value) => {
|
|
5367
|
+
setAppTheme(value);
|
|
5368
|
+
setAppThemeValue(value);
|
|
5369
|
+
}, []);
|
|
5370
|
+
const toggle = useCallback(() => {
|
|
5371
|
+
setValue(appTheme === primaryTheme ? secondaryTheme : primaryTheme);
|
|
5372
|
+
}, [appTheme, primaryTheme, secondaryTheme, setValue]);
|
|
5373
|
+
return { setValue, toggle, value: appTheme };
|
|
5374
|
+
}
|
|
5375
|
+
|
|
5225
5376
|
const DEFAULT_DESIGN_SYSTEM = 'bordered';
|
|
5226
5377
|
|
|
5227
5378
|
const DESIGN_SYSTEM_PREFIX = 'rls-design-system';
|
|
@@ -5355,26 +5506,5 @@ function useTabsController(options) {
|
|
|
5355
5506
|
return useMemo(() => ({ Tabs, formControl }), [Tabs, formControl]);
|
|
5356
5507
|
}
|
|
5357
5508
|
|
|
5358
|
-
|
|
5359
|
-
function getAppTheme() {
|
|
5360
|
-
if (typeof document === 'undefined') {
|
|
5361
|
-
return 'light';
|
|
5362
|
-
}
|
|
5363
|
-
return document.body.getAttribute(APP_THEME_ATTRIBUTE) === 'dark'
|
|
5364
|
-
? 'dark'
|
|
5365
|
-
: 'light';
|
|
5366
|
-
}
|
|
5367
|
-
function setAppTheme(theme) {
|
|
5368
|
-
if (typeof document === 'undefined') {
|
|
5369
|
-
return;
|
|
5370
|
-
}
|
|
5371
|
-
document.body.setAttribute(APP_THEME_ATTRIBUTE, theme);
|
|
5372
|
-
}
|
|
5373
|
-
function toggleAppTheme() {
|
|
5374
|
-
const theme = getAppTheme() === 'dark' ? 'light' : 'dark';
|
|
5375
|
-
setAppTheme(theme);
|
|
5376
|
-
return theme;
|
|
5377
|
-
}
|
|
5378
|
-
|
|
5379
|
-
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 };
|
|
5509
|
+
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, RlsChip, RlsChipGroup, 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, RlsLedColor, 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 };
|
|
5380
5510
|
//# sourceMappingURL=index.mjs.map
|