@adaptabletools/adaptable
Version:
Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
31 lines (30 loc) • 1.44 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { useDispatch, useSelector } from 'react-redux';
import { SingleSelect } from '../../components/NewSelect';
import * as ThemeRedux from '../../Redux/ActionsReducers/ThemeRedux';
import { ACCESS_LEVEL_READ_ONLY } from '../../Utilities/Constants/GeneralConstants';
import { ThemeModuleId } from '../../Utilities/Constants/ModuleConstants';
import { useAdaptable } from '../AdaptableContext';
export const ThemeSelector = (props) => {
const adaptable = useAdaptable();
const dispatch = useDispatch();
const availableThemes = adaptable.api.themeApi.getThemes();
const currentTheme = useSelector((state) => state.Theme.CurrentTheme);
const disabled = adaptable.api.entitlementApi.getEntitlementAccessLevelForModule(ThemeModuleId) ===
ACCESS_LEVEL_READ_ONLY;
const optionThemes = availableThemes.map((theme) => {
if (typeof theme === 'string') {
theme = {
Name: theme,
Description: theme,
};
}
return {
value: theme.Name,
label: theme.Description,
};
});
return (_jsx(SingleSelect, { ariaLabel: "Select Theme", "data-name": "select-theme-dropdown", size: props.size, items: optionThemes, value: currentTheme, disabled: disabled, onValueChange: (themeName) => {
dispatch(ThemeRedux.ThemeSelect(themeName));
} }));
};