Skip to content

Commit

Permalink
fix(input): remove required from value prop, fixed type imports
Browse files Browse the repository at this point in the history
  • Loading branch information
richbachman committed Feb 2, 2021
1 parent b7c7257 commit 1c9683c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/silly-dodos-love.md
@@ -0,0 +1,5 @@
---
'@twilio-paste/input': patch
---

Removed required from the `value` prop, so Input can be used as an uncontrolled component. This allows Input to be used with libraries like `React-Hook-Form`. An example can be found by visiting this [link](https://cizwz.csb.app/).
Expand Up @@ -5,7 +5,8 @@ import {Label} from '@twilio-paste/label';
import {HelpText} from '@twilio-paste/help-text';
// @ts-ignore typescript doesn't like js imports
import axe from '../../../../../.jest/axe-helper';
import {InputTypes, Input} from '../src';
import {Input} from '../src';
import type {InputTypes} from '../src';

const NOOP = (): void => {};

Expand Down
4 changes: 2 additions & 2 deletions packages/paste-core/components/input/src/Input.tsx
Expand Up @@ -22,7 +22,7 @@ export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement>
size?: never;
style?: never;
type: InputTypes;
value: string;
value?: string;
variant?: InputVariants;
width?: never;
}
Expand Down Expand Up @@ -146,7 +146,7 @@ if (process.env.NODE_ENV === 'development') {
readOnly: PropTypes.bool,
required: PropTypes.bool,
type: PropTypes.oneOf(['text', 'email', 'hidden', 'number', 'password', 'search', 'tel']).isRequired as any,
value: PropTypes.string.isRequired,
value: PropTypes.string,
};
}

Expand Down
Expand Up @@ -7,8 +7,10 @@ import {Box} from '@twilio-paste/box';
import {Text} from '@twilio-paste/text';
import {InformationIcon} from '@twilio-paste/icons/esm/InformationIcon';
import {Label} from '@twilio-paste/label';
import {HelpText, HelpTextVariants} from '@twilio-paste/help-text';
import {Input, InputTypes} from '../src';
import {HelpText} from '@twilio-paste/help-text';
import type {HelpTextVariants} from '@twilio-paste/help-text';
import {Input} from '../src';
import type {InputTypes} from '../src';

const inputTypeOptions = ['text', 'email', 'hidden', 'number', 'password', 'search', 'tel'];
const helpVariantOptions = ['default', 'error'];
Expand Down

0 comments on commit 1c9683c

Please sign in to comment.