diff --git a/packages/patternfly-4/react-core/src/components/Select/Select.d.ts b/packages/patternfly-4/react-core/src/components/Select/Select.d.ts new file mode 100644 index 00000000000..e84de1aaa63 --- /dev/null +++ b/packages/patternfly-4/react-core/src/components/Select/Select.d.ts @@ -0,0 +1,18 @@ +import { HTMLProps, FormEvent } from 'react'; + +export const SelectVariant = { + single: 'single' +}; + +export interface SelectProps extends HTMLProps { + isExpanded?: boolean; + onToggle(value: boolean): void; + placeholderText?: string; + selections?: string; + variant?: string; + width?: string | number; +} + +declare const Select: React.FunctionComponent; + +export default Select; diff --git a/packages/patternfly-4/react-core/src/components/Select/Select.docs.js b/packages/patternfly-4/react-core/src/components/Select/Select.docs.js new file mode 100644 index 00000000000..49f15765ac9 --- /dev/null +++ b/packages/patternfly-4/react-core/src/components/Select/Select.docs.js @@ -0,0 +1,11 @@ +import { Select, SelectOption } from '@patternfly/react-core'; +import SingleSelectInput from './examples/SingleSelectInput'; + +export default { + title: 'Select', + components: { + Select, + SelectOption + }, + examples: [{ component: SingleSelectInput, title: 'Single Select Input' }] +}; diff --git a/packages/patternfly-4/react-core/src/components/Select/Select.js b/packages/patternfly-4/react-core/src/components/Select/Select.js new file mode 100644 index 00000000000..c71cdbf2e59 --- /dev/null +++ b/packages/patternfly-4/react-core/src/components/Select/Select.js @@ -0,0 +1,125 @@ +import React from 'react'; +import styles from '@patternfly/patternfly/components/Select/select.css'; +import { css } from '@patternfly/react-styles'; +import PropTypes from 'prop-types'; +import SingleSelect from './SingleSelect'; +import SelectToggle from './SelectToggle'; +import { SelectContext, SelectVariant } from './selectConstants'; + +// seed for the aria-labelledby ID +let currentId = 0; + +const propTypes = { + /** Content rendered inside the Select */ + children: PropTypes.node, + /** Classes applied to the root of the Select */ + className: PropTypes.string, + /** Flag to indicate if select is expanded */ + isExpanded: PropTypes.bool, + /** Placeholder text of Select */ + placeholderText: PropTypes.string, + /** Selected item */ + selections: PropTypes.string, + /** Id of label for the Select aria-labelledby */ + ariaLabelledBy: PropTypes.string, + /** Callback for selection behavior */ + onSelect: PropTypes.func.isRequired, + /** Callback for toggle button behavior */ + onToggle: PropTypes.func.isRequired, + /** Variant of rendered Select */ + variant: PropTypes.oneOf(['single']), + /** Width of the select container as a number of px or string percentage */ + width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + /** Additional props are spread to the container