From 15e163aef6e358fcf8d522cc5419ab686e6db8ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?v=C3=A9gtelens=C3=A9g?= Date: Tue, 5 Mar 2019 13:17:02 +0200 Subject: [PATCH] Added missing prop for the multi select component --- types/react-widgets/lib/Multiselect.d.ts | 61 ++++-- types/react-widgets/react-widgets-tests.tsx | 196 ++++++++++---------- 2 files changed, 139 insertions(+), 118 deletions(-) diff --git a/types/react-widgets/lib/Multiselect.d.ts b/types/react-widgets/lib/Multiselect.d.ts index 56a2753d3e..afafdfcb12 100644 --- a/types/react-widgets/lib/Multiselect.d.ts +++ b/types/react-widgets/lib/Multiselect.d.ts @@ -1,12 +1,14 @@ -import * as React from 'react'; -import { ReactWidgetsCommonDropdownProps, AutoFocus } from './CommonProps'; +import * as React from "react"; +import { ReactWidgetsCommonDropdownProps, AutoFocus } from "./CommonProps"; -interface MultiselectProps extends ReactWidgetsCommonDropdownProps, AutoFocus { +interface MultiselectProps + extends ReactWidgetsCommonDropdownProps, + AutoFocus { /** * Enables the list option creation UI. onFilter will only the UI when actively filtering for a list item. * @default 'onFilter' */ - allowCreate?: boolean | 'onFilter'; + allowCreate?: boolean | "onFilter"; /** * The current values of the Multiselect. The value should can null, or an array of * valueField values, or an array of objects (such as a few items in the data array) @@ -20,20 +22,26 @@ interface MultiselectProps extends ReactWidgetsCommonDropdownProps void; + onChange?: ( + dataItems: any[], + metadata: { + dataItem: any; + action: "insert" | "remove"; + originalEvent?: any; + lastValue?: any[]; + searchTerm?: string; + } + ) => void; /** * This handler fires when an item has been selected from the list. It fires before the * onChange handler, and fires regardless of whether the value has actually changed */ - onSelect?: (value: any, metadata: { - originalEvent: any; - }) => void; + onSelect?: ( + value: any, + metadata: { + originalEvent: any; + } + ) => void; /** * This handler fires when the user chooses to create a new tag, not in the data list. It is * up to the widget parent to implement creation logic, a common implementation is shown @@ -100,11 +108,14 @@ interface MultiselectProps extends ReactWidgetsCommonDropdownProps void; + onSearch?: ( + searchTerm: string, + metadata: { + action: "clear" | "input"; + lastSearchTerm?: string; + originalEvent?: any; + } + ) => void; /** * Whether or not the Multiselect is open. When unset (undefined) the Multiselect will * handle the opening and closing internally. The defaultOpen prop can be used to set an @@ -124,7 +135,12 @@ interface MultiselectProps extends ReactWidgetsCommonDropdownProps boolean); + filter?: + | false + | "startsWith" + | "endsWith" + | "contains" + | ((dataItem: any, searchTerm: string) => boolean); /** * Use in conjunction with the filter prop. Filter the list without regard for case. This * only applies to non function values for filter. @@ -167,6 +183,11 @@ interface MultiselectProps extends ReactWidgetsCommonDropdownProps{props.value}; @@ -18,105 +26,97 @@ function listComponent(props: { value: string }) { class Test extends React.Component> { render() { return ( -
- - - - - - - +
+ + + + + + + +
+
+ + + + + + + +
+
+ + + + + +
+
+ + + + + + + +
+
+ + + } + /> + + + + + + + +
+
+ } + /> +
-
- - - - - - - -
-
- - - - - -
-
- - - - - - - -
-
- - - - } - /> - - - - - - -
-
- } /> -
-
); } }