import { Localization } from "@Component/Localization/Localization"; import { Callout, DirectionalHint, Icon } from "@fluentui/react"; import { CtrlObject } from "@Model/CtrlObject"; import { Group } from "@Model/Group"; import { Label } from "@Model/Label"; import { Range } from "@Model/Range"; import { Component, ReactNode, RefObject } from "react"; import "./PickerList.scss"; type IPickerListItem = CtrlObject | Label; interface IPickerListProps { objectList?: IPickerListItem[]; target?: RefObject; dismiss?: () => any; click?: (item: IPickerListItem) => any; } class PickerList extends Component { private renderItem(item: IPickerListItem) { let color: number[] = []; let icon: string = "tag"; let name: string = ""; if (item instanceof Range) { icon = "CubeShape" } if (item instanceof Group) { icon = "WebAppBuilderFragment" } if (item instanceof CtrlObject) { color[0] = Math.round(item.color[0] * 255); color[1] = Math.round(item.color[1] * 255); color[2] = Math.round(item.color[2] * 255); name = item.displayName; } if (item instanceof Label) { icon = "tag"; color = item.color.concat([]); name = item.name; } return
{ if (this.props.click) { this.props.click(item) } }} >
{name}
; } public render(): ReactNode { return
{this.props.objectList ? this.props.objectList.map((item) => { return this.renderItem(item); }) : null} {!this.props.objectList || (this.props.objectList && this.props.objectList.length <= 0) ? : null }
} } export { PickerList }