Files
flipper/desktop/plugins/public/fresco/MultipleSelect.tsx
Andrey Goncharov d1158e2d02 Configure eslint to prevent imports from nested paths of externally provided modules
Summary: We have a list of modules that we do not bundle with the plugins, but provide externally to them from Flipper. For the mechanism to work correctly, we have to stop importing from nested paths of these modules.

Reviewed By: mweststrate

Differential Revision: D39776237

fbshipit-source-id: 06eae9bf9d5b11b48d2720bf592bfea749773847
2022-09-26 09:42:33 -07:00

56 lines
1.5 KiB
TypeScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import React, {Component} from 'react';
import {Layout} from 'flipper-plugin';
import {Button, Menu, Checkbox, Dropdown} from 'antd';
import {DownOutlined} from '@ant-design/icons';
// This import is OK since it is a type-only import
// eslint-disable-next-line no-restricted-imports
import type {CheckboxChangeEvent} from 'antd/lib/checkbox';
export default class MultipleSelect extends Component<{
selected: Set<string>;
options: Set<string>;
label: string;
onChange: (selectedItem: string, checked: boolean) => void;
}> {
handleOnChange = (option: string, event: CheckboxChangeEvent) => {
this.props.onChange(option, event.target.checked);
};
menu = () => {
return (
<Menu>
{Array.from(this.props.options).map((option, index) => (
<Menu.Item key={index} disabled>
<Checkbox
onChange={(e) => this.handleOnChange(option, e)}
checked={this.props.selected.has(option)}
/>{' '}
{option}
</Menu.Item>
))}
</Menu>
);
};
render() {
return (
<Layout.Container>
<Dropdown overlay={this.menu}>
<Button>
Surfaces <DownOutlined />
</Button>
</Dropdown>
</Layout.Container>
);
}
}