selected items instead of selection

Signed-off-by: lukzerom <lukzerom@gmail.com>
This commit is contained in:
lukzerom
2021-12-14 23:40:30 +01:00
parent 8ecfac35fd
commit aec8c678c8
3 changed files with 10 additions and 10 deletions
@@ -107,15 +107,15 @@ export type SelectItem = {
value: string | number;
};
export type Selection = string | string[] | number | number[];
export type SelectedItems = string | string[] | number | number[];
export type SelectProps = {
multiple?: boolean;
items: SelectItem[];
label: string;
placeholder?: string;
selected?: Selection;
onChange: (arg: Selection) => void;
selected?: SelectedItems;
onChange: (arg: SelectedItems) => void;
triggerReset?: boolean;
native?: boolean;
disabled?: boolean;
@@ -134,7 +134,7 @@ export function SelectComponent(props: SelectProps) {
disabled = false,
} = props;
const classes = useStyles();
const [value, setValue] = useState<Selection>(
const [value, setValue] = useState<SelectedItems>(
selected || (multiple ? [] : ''),
);
const [isOpen, setOpen] = useState(false);
@@ -150,8 +150,8 @@ export function SelectComponent(props: SelectProps) {
}, [selected]);
const handleChange = (event: React.ChangeEvent<{ value: unknown }>) => {
setValue(event.target.value as Selection);
onChange(event.target.value as Selection);
setValue(event.target.value as SelectedItems);
onChange(event.target.value as SelectedItems);
};
const handleClick = (event: React.ChangeEvent<any>) => {
@@ -17,8 +17,8 @@
export { SelectComponent as Select } from './Select';
export type {
SelectClassKey,
SelectedItems,
SelectInputBaseClassKey,
Selection,
SelectItem,
} from './Select';
export type { ClosedDropdownClassKey } from './static/ClosedDropdown';
@@ -16,7 +16,7 @@
import {
Progress,
Select,
Selection,
SelectedItems,
SelectItem,
} from '@backstage/core-components';
import { useApi } from '@backstage/core-plugin-api';
@@ -109,7 +109,7 @@ export const RepoUrlPicker = ({
allowedOwners,
);
const updateHost = useCallback(
(value: Selection) => {
(value: SelectedItems) => {
onChange(
serializeFormData({
host: value as string,
@@ -125,7 +125,7 @@ export const RepoUrlPicker = ({
);
const updateOwnerSelect = useCallback(
(value: Selection) =>
(value: SelectedItems) =>
onChange(
serializeFormData({
host,