Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
PropTypes.number
])),
/**
* when used with the `value` prop, the component will not control its own state
*/
onChange: PropTypes.func,
disabled: PropTypes.bool,
/** works just like disabled but keeps the same styles as if it were active */
readOnly: PropTypes.bool,
/**
* object with shape: `{
* text: PropTypes.string,
* type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
* }`
*/
messages: PropTypes.arrayOf(CustomPropTypes.message),
/**
* children of type `RadioInput`
*/
children: CustomPropTypes.Children.oneOf([RadioInput]),
variant: PropTypes.oneOf(['simple', 'toggle']), // TODO: split toggle out to its own component
size: PropTypes.oneOf(['small', 'medium', 'large']),
/**
* Note: `columns` will render as `stacked` when variant is `toggle`
*/
layout: PropTypes.oneOf([
'stacked',
'columns',
'inline'
])
}
**/
class FormField extends Component {
/* eslint-disable react/require-default-props */
static propTypes = {
label: PropTypes.node.isRequired,
/**
* the id of the input (to link it to its label for a11y)
*/
id: PropTypes.string.isRequired,
/**
* object with shape: `{
* text: PropTypes.string,
* type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
* }`
*/
messages: PropTypes.arrayOf(CustomPropTypes.message),
messagesId: PropTypes.string,
children: PropTypes.node,
inline: PropTypes.bool,
layout: PropTypes.oneOf(['stacked', 'inline']),
labelAlign: PropTypes.oneOf(['start', 'end']),
vAlign: PropTypes.oneOf(['top', 'middle', 'bottom']),
width: PropTypes.string
};
/* eslint-enable react/require-default-props */
static defaultProps = {
inline: false,
layout: 'stacked',
messagesId: undefined,
labelAlign: 'end',
vAlign: 'middle'
@themeable(theme, styles)
class Checkbox extends Component {
static propTypes = {
label: PropTypes.node.isRequired,
id: PropTypes.string,
value: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
]),
/**
* object with shape: `{
* text: PropTypes.string,
* type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
* }`
*/
messages: PropTypes.arrayOf(CustomPropTypes.message),
/* whether to set the input to checked or not on initial render */
defaultChecked: PropTypes.bool,
/**
* whether the input is checked or not (must be accompanied by an `onChange` prop)
*/
checked: CustomPropTypes.controllable(PropTypes.bool, 'onChange', 'defaultChecked'),
/**
* when used with the `checked` prop, the component will not control its own state
*/
onChange: PropTypes.func,
onKeyDown: PropTypes.func,
onFocus: PropTypes.func,
onBlur: PropTypes.func,
onMouseOver: PropTypes.func,
onMouseOut: PropTypes.func,
disabled: PropTypes.bool,
*/
placement: CustomPropTypes.placement,
/**
This display to show in the input when a date is selected.
Valid formats are compatible with
[moment.js formats](https://momentjs.com/docs/#/displaying/format/),
including localized formats.
**/
format: PropTypes.string, // display format
/**
* object with shape: `{
* text: PropTypes.string,
* type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
* }`
*/
messages: PropTypes.arrayOf(CustomPropTypes.message),
/**
A standard language id
**/
locale: PropTypes.string,
/**
A timezone identifier in the format: Area/Location
**/
timezone: PropTypes.string,
/**
An ISO 8601 formatted string. The initial date value to display on render.
It should only be used when using this component as an uncontrolled input.
**/
defaultDateValue: CustomPropTypes.iso8601,
/**
label: PropTypes.node.isRequired,
/**
* the id of the input (to link it to its label for a11y)
*/
id: PropTypes.string,
/**
* the element type to render as
*/
as: CustomPropTypes.elementType,
/**
* object with shape: `{
* text: PropTypes.string,
* type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
* }`
*/
messages: PropTypes.arrayOf(CustomPropTypes.message),
/**
* id for the form field messages
*/
messagesId: PropTypes.string,
children: PropTypes.node,
inline: PropTypes.bool,
layout: PropTypes.oneOf(['stacked', 'inline']),
labelAlign: PropTypes.oneOf(['start', 'end']),
width: PropTypes.string
};
/* eslint-enable react/require-default-props */
static defaultProps = {
inline: false,
layout: 'stacked',
as: 'label',
{ text: 'Invalid name', type: 'error' },
{ text: 'Good job!', type: 'success' },
{ text: 'Full name, first and last', type: 'hint' },
]} />
/
@themeable(theme, styles)
export default class FormFieldMessages extends Component {
static propTypes = {
/
* object with shape: { * text: PropTypes.string, * type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only']) * }
*/
messages: PropTypes.arrayOf(CustomPropTypes.message)
}
render () { const {messages} = this.props return messages && messages.length > 0 ? ( <span> { messages.map((msg, i) => { return ( <span>
{msg.text}
</span>
)
})</span>
* the selected values (must be accompanied by an `onChange` prop)
*/
value: CustomPropTypes.controllable(PropTypes.array),
/**
* when used with the `value` prop, the component will not control its own state
*/
onChange: PropTypes.func,
disabled: PropTypes.bool,
readOnly: PropTypes.bool,
/**
* object with shape: `{
text: PropTypes.string,
type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
}`
*/
messages: PropTypes.arrayOf(CustomPropTypes.message),
/**
* children of type `Checkbox`
*/
children: CustomPropTypes.Children.oneOf([Checkbox]),
size: PropTypes.oneOf(['small', 'medium', 'large']),
layout: PropTypes.oneOf([
'stacked',
'columns',
'inline'
])
}
static defaultProps = {
disabled: false,
readOnly: false,
size: 'medium',
**/
@themeable(theme, styles)
export default class FormFieldGroup extends Component {
static propTypes = {
description: PropTypes.node.isRequired,
/**
* the element type to render as
*/
as: CustomPropTypes.elementType,
/**
* object with shape: `{
* text: PropTypes.string,
* type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
* }`
*/
messages: PropTypes.arrayOf(CustomPropTypes.message),
/**
* id for the form field messages
*/
messagesId: PropTypes.string,
disabled: PropTypes.bool,
children: PropTypes.node,
layout: PropTypes.oneOf(['stacked', 'columns', 'inline']),
rowSpacing: PropTypes.oneOf(['none', 'small', 'medium', 'large']),
colSpacing: PropTypes.oneOf(['none', 'small', 'medium', 'large']),
vAlign: PropTypes.oneOf(['top', 'middle', 'bottom']),
startAt: PropTypes.oneOf(['small', 'medium', 'large', 'x-large', null])
}
static defaultProps = {
as: 'fieldset',
disabled: false,
width: PropTypes.string,
/**
* a initial height for the textarea (if autoGrow is true it will grow vertically)
*/
height: PropTypes.string,
/**
* when autoGrow is true, the textarea will never grow beyond this value (in pixels)
*/
maxHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
/**
* object with shape: `{
* text: PropTypes.string,
* type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
* }`
*/
messages: PropTypes.arrayOf(CustomPropTypes.message),
inline: PropTypes.bool,
/**
* Html placeholder text to display when the input has no value. This should be hint text, not a label
* replacement.
*/
placeholder: PropTypes.string,
disabled: PropTypes.bool,
required: PropTypes.bool,
/**
* a function that provides a reference to the actual textarea element
*/
textareaRef: PropTypes.func,
/**
* value to set on initial render
*/
defaultValue: PropTypes.string,
static propTypes = {
min: PropTypes.number.isRequired,
max: PropTypes.number.isRequired,
/**
* value to set on initial render
*/
defaultValue: PropTypes.number,
/**
* the selected value (must be accompanied by an `onChange` prop)
*/
value: CustomPropTypes.controllable(PropTypes.number),
/**
* when used with the `value` prop, the component will not control its own state
*/
onChange: PropTypes.func,
messages: PropTypes.arrayOf(CustomPropTypes.message),
size: PropTypes.oneOf(['small', 'medium', 'large']),
layout: PropTypes.oneOf(['stacked', 'inline']),
id: PropTypes.string,
label: PropTypes.node.isRequired,
/**
* whether to display the current value
*/
displayValue: PropTypes.bool,
step: PropTypes.number,
/**
* A function to format the displayed value
*/
formatValue: PropTypes.func,
inline: PropTypes.bool
}