Skip to content

Commit

Permalink
fix(Input): added prop type description for all Inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Utzel-Butzel committed Feb 16, 2021
1 parent c52d7a7 commit f86ad11
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 39 deletions.
17 changes: 7 additions & 10 deletions src/components/DatePicker/SingleDatePickerInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,19 @@ import settings from '../../globals/js/settings';
const { prefix } = settings;

export class SingleDatePickerInput extends PureComponent {

state = {
controlledValue: this.props.value ? this.props.value : null,
focusedInput: null,
};

handleFocusChange = focusedInput => {

handleFocusChange = (focusedInput) => {
if (!focusedInput && typeof this.props.onBlur === 'function') {
this.props.onBlur();
}
this.setState({ focusedInput });
};

render() {

const {
controlled,
datePicker,
Expand Down Expand Up @@ -75,12 +72,11 @@ export class SingleDatePickerInput extends PureComponent {
date={onChange && value ? value : controlledValue}
focused={focused}
hideKeyboardShortcutsPanel
onDateChange={value => {
onDateChange={(value) => {
if (onChange) {
onChange({ value });
}
this.setState({ controlledValue: value },() => {
});
this.setState({ controlledValue: value }, () => {});
}}
onFocusChange={({ focused }) => {
this.setState({ focused });
Expand Down Expand Up @@ -150,16 +146,17 @@ SingleDatePickerInput.propTypes = {
/**
* Specify whether to clear selected date or not
*/
showClearDate:PropTypes.bool,
showClearDate: PropTypes.bool,

/**
* Specify whether you want to show the calendar icon. It is true by default.
*/
showDefaultInputIcon: PropTypes.bool,
/**
* Specify whether the control is currently invalid
* Specify whether the control is currently invalid.
* Either a boolean in combination with `invalidText` or an `object`( eg. { message: "Message", …otherErrorProperties }) can be passed.
*/
invalid: PropTypes.bool,
invalid: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),

/**
* Provide the text that is displayed when the control is in an invalid state
Expand Down
9 changes: 5 additions & 4 deletions src/components/FileUploader/FileUploaderItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function FileUploaderItem({
iconDescription={iconDescription}
status={status}
invalid={invalid}
onKeyDown={evt => {
onKeyDown={(evt) => {
/*
if (matches(evt, [keys.Enter, keys.Space])) {
if (status === 'edit') {
Expand All @@ -46,7 +46,7 @@ export default function FileUploaderItem({
}
}*/
}}
onClick={evt => {
onClick={(evt) => {
if (status === 'edit') {
onDelete(evt, { uuid });
}
Expand Down Expand Up @@ -91,9 +91,10 @@ FileUploaderItem.propTypes = {
iconDescription: PropTypes.string,

/**
* Specify if the currently uploaded file is invalid
* Specify whether the control is currently invalid.
* Either a boolean in combination with `invalidText` or an `object`( eg. { message: "Message", …otherErrorProperties }) can be passed.
*/
invalid: PropTypes.bool,
invalid: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),

/**
* Event handler that is called after removing a file from the file uploader
Expand Down
5 changes: 3 additions & 2 deletions src/components/FormGroup/FormGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ FormGroup.propTypes = {
*/
className: PropTypes.string,
/**
* Specify an invalid attribute for the `fieldset`
* Specify whether the control is currently invalid.
* Either a boolean in combination with `invalidText` or an `object`( eg. { message: "Message", …otherErrorProperties }) can be passed.
*/
invalid: PropTypes.bool,
invalid: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),
/**
* Specify if a message is shown for the `fieldset`
*/
Expand Down
3 changes: 2 additions & 1 deletion src/components/Input/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ Input.propTypes = {
hideLabel: PropTypes.bool,

/**
* Specify whether the control is currently invalid. boolean or an object( eg. { message: "Input is too long", …otherErrorproperties }) can be passed
* Specify whether the control is currently invalid.
* Either a boolean in combination with `invalidText` or an `object`( eg. { message: "Message", …otherErrorProperties }) can be passed.
*/
invalid: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),

Expand Down
4 changes: 2 additions & 2 deletions src/components/NumberInput/NumberInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ NumberInput.propTypes = {
value: PropTypes.oneOfType([PropTypeEmptyString, PropTypes.number]),

/**
* Specify if the currently value is invalid.
* Specify whether the control is currently invalid.
* Either a boolean in combination with `invalidText` or an `object`( eg. { message: "Message", …otherErrorProperties }) can be passed.
*/
invalid: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),

Expand Down Expand Up @@ -252,5 +253,4 @@ NumberInput.propTypes = {
allowEmpty: PropTypes.bool,
};


export default NumberInput;
13 changes: 7 additions & 6 deletions src/components/NumberInput/NumberInput.legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ export default class NumberInput extends Component {
value: PropTypes.oneOfType([PropTypeEmptyString, PropTypes.number]),

/**
* Specify if the currently value is invalid.
* Specify whether the control is currently invalid.
* Either a boolean in combination with `invalidText` or an `object`( eg. { message: "Message", …otherErrorProperties }) can be passed.
*/
invalid: PropTypes.bool,
invalid: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),

/**
* Message which is displayed if the value is invalid.
Expand Down Expand Up @@ -169,7 +170,7 @@ export default class NumberInput extends Component {
};
}

handleChange = evt => {
handleChange = (evt) => {
if (!this.props.disabled) {
evt.persist();
evt.imaginaryTarget = this._inputRef;
Expand Down Expand Up @@ -215,7 +216,7 @@ export default class NumberInput extends Component {
* Preserves the DOM node ref of `<input>`.
* @param {HTMLInputElement} ref The DOM node ref of `<input>`.
*/
_handleInputRef = ref => {
_handleInputRef = (ref) => {
this._inputRef = ref;
};

Expand Down Expand Up @@ -292,7 +293,7 @@ export default class NumberInput extends Component {
<button
className={`${prefix}--number__control-btn up-icon`}
{...buttonProps}
onClick={evt => this.handleArrowClick(evt, 'up')}>
onClick={(evt) => this.handleArrowClick(evt, 'up')}>
<Icon
className="up-icon"
icon={iconCaretUp}
Expand All @@ -303,7 +304,7 @@ export default class NumberInput extends Component {
<button
className={`${prefix}--number__control-btn down-icon`}
{...buttonProps}
onClick={evt => this.handleArrowClick(evt, 'down')}>
onClick={(evt) => this.handleArrowClick(evt, 'down')}>
<Icon
className="down-icon"
icon={iconCaretDown}
Expand Down
5 changes: 3 additions & 2 deletions src/components/ReduxFormWrapper/ReduxFormWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ ReduxFormWrapper.propTypes = {
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),

/**
* Specify whether the control is currently invalid
* Specify whether the control is currently invalid.
* Either a boolean in combination with `invalidText` or an `object`( eg. { message: "Message", …otherErrorProperties }) can be passed.
*/
invalid: PropTypes.bool,
invalid: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),

/**
* Provide the text that is displayed when the control is in an invalid state
Expand Down
5 changes: 3 additions & 2 deletions src/components/Select/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ Select.propTypes = {
hideLabel: PropTypes.bool,

/**
* Specify if the currently value is invalid.
* Specify whether the control is currently invalid.
* Either a boolean in combination with `invalidText` or an `object`( eg. { message: "Message", …otherErrorProperties }) can be passed.
*/
invalid: PropTypes.bool,
invalid: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),

/**
* Message which is displayed if the value is invalid.
Expand Down
9 changes: 5 additions & 4 deletions src/components/Slider/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ function Slider(props) {
if (!disabled) {
evt.persist();
evt.imaginaryTarget = _inputRef;
if(evt.target.value > max){
if (evt.target.value > max) {
setValue(max);
onChange(parseFloat(max), evt);
}else{
} else {
setValue(evt.target.value);
onChange(parseFloat(evt.target.value), evt);
}
Expand Down Expand Up @@ -262,9 +262,10 @@ Slider.propTypes = {
value: PropTypes.oneOfType([PropTypeEmptyString, PropTypes.number]),

/**
* Specify if the currently value is invalid.
* Specify whether the control is currently invalid.
* Either a boolean in combination with `invalidText` or an `object`( eg. { message: "Message", …otherErrorProperties }) can be passed.
*/
invalid: PropTypes.bool,
invalid: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),

/**
* Message which is displayed if the value is invalid.
Expand Down
9 changes: 5 additions & 4 deletions src/components/TextArea/TextArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const TextArea = ({
},
};

const textareaClasses = classNames('wfp--text-area', className,{
const textareaClasses = classNames('wfp--text-area', className, {
[`${prefix}--textarea-fullwidth`]: fullWidth,
});
const labelClasses = classNames(`${prefix}--label`, {
Expand Down Expand Up @@ -150,9 +150,10 @@ TextArea.propTypes = {
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),

/**
* Specify whether the control is currently invalid
* Specify whether the control is currently invalid.
* Either a boolean in combination with `invalidText` or an `object`( eg. { message: "Message", …otherErrorProperties }) can be passed.
*/
invalid: PropTypes.bool,
invalid: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),

/**
* Provide the text that is displayed when the control is in an invalid state
Expand Down Expand Up @@ -184,7 +185,7 @@ TextArea.defaultProps = {
invalid: false,
invalidText: '',
helperText: '',
fullWidth:true
fullWidth: true,
};

export default TextArea;
5 changes: 3 additions & 2 deletions src/components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const TextInput = (props) => {
};

return (
<Input {...props} formItemClassName={formItemClassName} >
<Input {...props} formItemClassName={formItemClassName}>
{(e) => {
return (
<input
Expand Down Expand Up @@ -128,7 +128,8 @@ TextInput.propTypes = {
hideLabel: PropTypes.bool,

/**
* Specify whether the control is currently invalid
* Specify whether the control is currently invalid.
* Either a boolean in combination with `invalidText` or an `object`( eg. { message: "Message", …otherErrorProperties }) can be passed.
*/
invalid: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),

Expand Down

0 comments on commit f86ad11

Please sign in to comment.