diff --git a/playbook/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx b/playbook/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx
index 76d607a7b1..7585a12f60 100644
--- a/playbook/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx
+++ b/playbook/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx
@@ -4,7 +4,7 @@ import AsyncSelect from 'react-select/async'
import CreateableSelect from 'react-select/creatable'
import AsyncCreateableSelect from 'react-select/async-creatable'
import { get, isString, uniqueId } from 'lodash'
-import { globalProps, GlobalProps } from '../utilities/globalProps'
+import { globalProps } from '../utilities/globalProps'
import classnames from 'classnames'
import {
@@ -42,18 +42,15 @@ type TypeaheadProps = {
id?: string,
label?: string,
loadOptions?: string | Noop,
- getOptionLabel?: string | (() => any),
- getOptionValue?: string | (() => any),
+ getOptionLabel?: string | (() => string),
+ getOptionValue?: string | (() => string),
name?: string,
- marginBottom?: "none" | "xxs" | "xs" | "sm" | "md" | "lg" | "xl",
- pillColor?: "primary" | "neutral" | "success" | "warning" | "error" | "info" | "data_1" | "data_2" | "data_3" | "data_4" | "data_5" | "data_6" | "data_7" | "data_8" | "windows" | "siding" | "roofing" | "doors" | "gutters" | "solar" | "insulation" | "accessories",
-} & GlobalProps
+}
export type SelectValueType = {
label: string,
value: string,
imageUrl?: string,
- pillColor?: string,
}
type TagOnChangeValues = {
@@ -79,10 +76,8 @@ const Typeahead = ({
htmlOptions = {},
id,
loadOptions = noop,
- marginBottom = "sm",
- pillColor,
...props
-}: TypeaheadProps) => {
+}: TypeaheadProps): React.ReactElement => {
const selectProps = {
cacheOptions: true,
components: {
@@ -109,8 +104,8 @@ const Typeahead = ({
multiKit: '',
onCreateOption: null as null,
plusIcon: false,
- onMultiValueClick: (_option: SelectValueType): any => undefined,
- pillColor: pillColor,
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ onMultiValueClick: (_option: SelectValueType): void => undefined,
...props,
}
@@ -136,15 +131,11 @@ const Typeahead = ({
}
}
- const filteredProps: TypeaheadProps = {...props}
- delete filteredProps.truncate
-
const dataProps = buildDataProps(data)
const htmlProps = buildHtmlProps(htmlOptions)
const classes = classnames(
'pb_typeahead_kit react-select',
- `mb_${marginBottom}`,
- globalProps(filteredProps),
+ globalProps(props),
className
)
diff --git a/playbook/app/pb_kits/playbook/pb_typeahead/components/ClearIndicator.tsx b/playbook/app/pb_kits/playbook/pb_typeahead/components/ClearIndicator.tsx
index 9de04859a6..b9384c1ec5 100644
--- a/playbook/app/pb_kits/playbook/pb_typeahead/components/ClearIndicator.tsx
+++ b/playbook/app/pb_kits/playbook/pb_typeahead/components/ClearIndicator.tsx
@@ -1,16 +1,24 @@
import React, { useEffect } from 'react'
import { components } from 'react-select'
-const ClearContainer = (props: any) => {
+type ClearContainerProps = {
+ children: React.ReactNode,
+ selectProps?: {
+ id: string,
+ },
+ clearValue: () => void,
+}
+
+const ClearContainer = (props: ClearContainerProps): React.ReactElement => {
const { selectProps, clearValue } = props
useEffect(() => {
document.addEventListener(`pb-typeahead-kit-${selectProps.id}:clear`, clearValue)
- }, [true])
+ }, [clearValue, selectProps.id])
return (
)
}
diff --git a/playbook/app/pb_kits/playbook/pb_typeahead/components/Control.tsx b/playbook/app/pb_kits/playbook/pb_typeahead/components/Control.tsx
index 014a977902..fe02b40fe5 100644
--- a/playbook/app/pb_kits/playbook/pb_typeahead/components/Control.tsx
+++ b/playbook/app/pb_kits/playbook/pb_typeahead/components/Control.tsx
@@ -5,16 +5,19 @@ import Flex from '../../pb_flex/_flex'
import TextInput from '../../pb_text_input/_text_input'
type Props = {
- selectProps: any,
+ selectProps: {
+ dark?: boolean,
+ label: string,
+ error?: string,
+ },
}
-const TypeaheadControl = (props: Props) => (
+const TypeaheadControl = (props: Props): React.ReactElement => (
(
+type IndicatorsContainerProps = {
+ children: React.ReactNode,
+}
+
+
+const IndicatorsContainer = (props: IndicatorsContainerProps): React.ReactElement => (
)
diff --git a/playbook/app/pb_kits/playbook/pb_typeahead/components/MenuList.tsx b/playbook/app/pb_kits/playbook/pb_typeahead/components/MenuList.tsx
index a83e3e630e..b60408d77d 100644
--- a/playbook/app/pb_kits/playbook/pb_typeahead/components/MenuList.tsx
+++ b/playbook/app/pb_kits/playbook/pb_typeahead/components/MenuList.tsx
@@ -1,7 +1,12 @@
import React from 'react'
import { components } from 'react-select'
-const MenuList = (props: any) => {
+type MenuListProps = {
+ children: React.ReactNode,
+ footer: React.ReactNode,
+}
+
+const MenuList = (props: MenuListProps): React.ReactElement => {
return (
{props.children}
diff --git a/playbook/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx b/playbook/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx
index 7de89b233c..4da71cb648 100644
--- a/playbook/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx
+++ b/playbook/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx
@@ -7,22 +7,25 @@ import { SelectValueType } from '../_typeahead'
type Props = {
data: SelectValueType,
- multiValueTemplate: any,
- pillColor?: "primary" | "neutral" | "success" | "warning" | "error" | "info" | "data_1" | "data_2" | "data_3" | "data_4" | "data_5" | "data_6" | "data_7" | "data_8" | "windows" | "siding" | "roofing" | "doors" | "gutters" | "solar" | "insulation" | "accessories",
- removeProps: any,
- selectProps: any,
+ removeProps?: {
+ onClick?: React.MouseEventHandler,
+ onMouseDown?: React.MouseEventHandler,
+ onTouchEnd?: React.TouchEventHandler,
+ },
+ selectProps: {
+ multiKit?: string,
+ },
}
-const MultiValue = (props: Props) => {
+const MultiValue = (props: Props): React.ReactElement => {
const { removeProps } = props
const { imageUrl, label } = props.data
- const { dark, multiKit, pillColor, truncate } = props.selectProps
+ const { multiKit } = props.selectProps
const formPillProps = {
marginRight: 'xs',
name: label,
avatarUrl: '',
- dark,
}
if (typeof imageUrl === 'string') formPillProps.avatarUrl = imageUrl
@@ -45,28 +48,20 @@ const MultiValue = (props: Props) => {
}
{multiKit !== 'badge' && !imageUrl &&
}
diff --git a/playbook/app/pb_kits/playbook/pb_typeahead/components/Option.tsx b/playbook/app/pb_kits/playbook/pb_typeahead/components/Option.tsx
index f31b66561e..aefd3c1cca 100644
--- a/playbook/app/pb_kits/playbook/pb_typeahead/components/Option.tsx
+++ b/playbook/app/pb_kits/playbook/pb_typeahead/components/Option.tsx
@@ -3,7 +3,22 @@ import { components } from 'react-select'
import User from '../../pb_user/_user'
-const Option = (props: any) => {
+type OptionProps = {
+ children: React.ReactNode,
+ label?: string,
+ data: {
+ imageUrl?: string,
+ },
+ selectProps: {
+ dark?: boolean,
+ valueComponent?: (data: {
+ imageUrl?: string,
+ }) => React.ReactNode,
+ },
+}
+
+
+const Option = (props: OptionProps): React.ReactElement => {
const {
imageUrl,
} = props.data
@@ -14,11 +29,11 @@ const Option = (props: any) => {
<>
{!valueComponent && imageUrl &&
}
diff --git a/playbook/app/pb_kits/playbook/pb_typeahead/components/Placeholder.tsx b/playbook/app/pb_kits/playbook/pb_typeahead/components/Placeholder.tsx
index 9288eafc1e..f1fd65850c 100644
--- a/playbook/app/pb_kits/playbook/pb_typeahead/components/Placeholder.tsx
+++ b/playbook/app/pb_kits/playbook/pb_typeahead/components/Placeholder.tsx
@@ -4,19 +4,26 @@ import { components } from 'react-select'
import Flex from '../../pb_flex/_flex'
import Icon from '../../pb_icon/_icon'
-const Placeholder = (props: any) => (
+type PlaceholderProps = {
+ children: React.ReactNode,
+ selectProps: {
+ plusIcon?: boolean,
+ },
+}
+
+const Placeholder = (props: PlaceholderProps): React.ReactElement => (
<>
{props.selectProps.plusIcon &&
}
diff --git a/playbook/app/pb_kits/playbook/pb_typeahead/components/ValueContainer.tsx b/playbook/app/pb_kits/playbook/pb_typeahead/components/ValueContainer.tsx
index cc27bc0c2a..5c6b9ff90e 100644
--- a/playbook/app/pb_kits/playbook/pb_typeahead/components/ValueContainer.tsx
+++ b/playbook/app/pb_kits/playbook/pb_typeahead/components/ValueContainer.tsx
@@ -1,10 +1,14 @@
import React from 'react'
import { components } from 'react-select'
-const ValueContainer = (props: any) => (
+type ValueContainerProps = {
+ children: React.ReactNode,
+}
+
+const ValueContainer = (props: ValueContainerProps): React.ReactElement => (
)
diff --git a/playbook/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_menu_list.jsx b/playbook/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_menu_list.jsx
index e3b7edc33a..94fc8206f3 100644
--- a/playbook/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_menu_list.jsx
+++ b/playbook/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_menu_list.jsx
@@ -1,3 +1,5 @@
+/* eslint-disable react/no-multi-comp */
+
import React, { useState } from 'react'
import {
diff --git a/playbook/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.jsx b/playbook/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.jsx
index 2acf56d266..f66d0bda9a 100644
--- a/playbook/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.jsx
+++ b/playbook/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.jsx
@@ -45,8 +45,6 @@ const promiseOptions = (inputValue) =>
const TypeaheadWithPillsAsync = (props) => {
const [users, setUsers] = useState([])
- const handleOnChange = (value) => setUsers(formatUsers(value))
- const formatValue = (users) => formatUsers(users)
const formatUsers = (users) => {
const results = () => (users.map((user) => {
if (Object.keys(user)[0] === 'name' || Object.keys(user)[1] === 'id'){
@@ -57,6 +55,8 @@ const TypeaheadWithPillsAsync = (props) => {
}))
return results()
}
+ const handleOnChange = (value) => setUsers(formatUsers(value))
+ const formatValue = (users) => formatUsers(users)
return (
<>
diff --git a/playbook/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_custom_options.jsx b/playbook/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_custom_options.jsx
index 7517a7d8aa..640f62bf2a 100644
--- a/playbook/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_custom_options.jsx
+++ b/playbook/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_custom_options.jsx
@@ -83,13 +83,13 @@ const TypeaheadWithPillsAsyncCustomOptions = (props) => {
onChange={handleOnChange}
onMultiValueClick={handleOnMultiValueClick}
placeholder="type the name of a Github user"
- valueComponent={(props) => (
+ valueComponent={({ imageUrl, label, territory, type }) => (
)}
{...props}