import { ToggleButton, ToggleButtonGroup } from '@mui/material'; import OptionIcon from './OptionIcon'; import { DeviceEntityMask } from './types'; import type { DeviceEntity } from './types'; type EntityMaskToggleProps = { onUpdate: (de: DeviceEntity) => void; de: DeviceEntity; }; const EntityMaskToggle = ({ onUpdate, de }: EntityMaskToggleProps) => { const getMaskNumber = (newMask: string[]) => { let new_mask = 0; for (const entry of newMask) { new_mask |= Number(entry); } return new_mask; }; const getMaskString = (m: number) => { const new_masks: string[] = []; if ((m & 1) === 1) { new_masks.push('1'); } if ((m & 2) === 2) { new_masks.push('2'); } if ((m & 4) === 4) { new_masks.push('4'); } if ((m & 8) === 8) { new_masks.push('8'); } if ((m & 128) === 128) { new_masks.push('128'); } return new_masks; }; return ( { de.m = getMaskNumber(mask); if (de.n === '' && de.m & DeviceEntityMask.DV_READONLY) { de.m = de.m | DeviceEntityMask.DV_WEB_EXCLUDE; } if (de.m & DeviceEntityMask.DV_WEB_EXCLUDE) { de.m = de.m & ~DeviceEntityMask.DV_FAVORITE; } onUpdate(de); }} > = 3}> ); }; export default EntityMaskToggle;