diff --git a/.changeset/empty-suits-flow.md b/.changeset/empty-suits-flow.md new file mode 100644 index 0000000000..35124fd3bf --- /dev/null +++ b/.changeset/empty-suits-flow.md @@ -0,0 +1,7 @@ +--- +'@react-select/docs': minor +'react-select': minor +'storybook': minor +--- + +Ability to customize the DummyInput component diff --git a/docs/examples/CustomDummyInput.tsx b/docs/examples/CustomDummyInput.tsx new file mode 100644 index 0000000000..27dc7b035c --- /dev/null +++ b/docs/examples/CustomDummyInput.tsx @@ -0,0 +1,32 @@ +import React from 'react'; +import Select, { components, DummyInputProps } from 'react-select'; +import { StateOption, stateOptions } from '../data'; + +const DummyInput = (props: DummyInputProps) => { + return ( +
+ + Custom Dummy Input + + +
+ ); +}; + +export default () => ( + + ); + + expect( + container.querySelector('input.react-select__dummy-input') + ).not.toBeInTheDocument(); + expect( + container.querySelector('.my-dummy-input-component') + ).toBeInTheDocument(); +}); + test('render custom Menu Component', () => { const MenuComponent = () =>
; let { container } = render( diff --git a/packages/react-select/src/components/DummyInput.tsx b/packages/react-select/src/components/DummyInput.tsx new file mode 100644 index 0000000000..8c030aa9a9 --- /dev/null +++ b/packages/react-select/src/components/DummyInput.tsx @@ -0,0 +1,91 @@ +/** @jsx jsx */ +import { InputHTMLAttributes, Ref } from 'react'; +import { jsx } from '@emotion/react'; + +import { + CommonPropsAndClassName, + CSSObjectWithLabel, + GroupBase, +} from '../types'; +import { cleanCommonProps, removeProps } from '../utils'; + +export interface DummyInputProps< + Option = unknown, + IsMulti extends boolean = boolean, + Group extends GroupBase