Skip to content

Commit 057b681

Browse files
author
edwardxiao
committed
- label must provide attributesInput.id
1 parent 06ed3a6 commit 057b681

File tree

9 files changed

+12
-10
lines changed

9 files changed

+12
-10
lines changed

docs/v4-doc.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
|attributesWrapper | Opt | Obj | Modify wrapper general attributes.<br/> **{<br/>id: 'myTextInputWrapperId'<br/>...<br/>}** | {} |
3131
|attributesInput | Opt | Obj | Modify input general attributes. <br/> **{<br/>id: 'myTextInputId',<br/>maxLength: 524288,<br/>name: 'myTextInputName',<br/>type: 'password',<br/>autoComplete: 'On',<br/>placeholder: 'my placeholder text',<br/>...<br/>}** | {} |
3232
|value | Opt | Str | | "" |
33-
|label | Opt | Str | | "" | The content of label
33+
|label | Opt | Str | | "" | The content of label. NOTE: must provide attributesInput.id
3434
|disabled | Opt | Bool | | false |
3535
|**validate** |**Opt**|**Bool**|**If you have a submit button and trying to validate all the inputs of your form at once, toggle it to true, then it will validate the field and pass the result via the "validationCallback" you provide.**|**false** |
3636
|**validationCallback** |**Opt**|**Func**|**Return the validation result.**|**none** |
@@ -83,7 +83,7 @@ import 'react-inputs-validation/lib/react-inputs-validation.min.css';
8383
placeholder: 'Place your name here ^-^',
8484
}}
8585
value={name} //Optional.[String].Default: "".
86-
label="" // Optional.[String].Default: "". The content of label
86+
label="" // Optional.[String].Default: "". The content of label. NOTE: must provide attributesInput.id
8787
disabled={false} //Optional.[Bool].Default: false.
8888
validate={validate} //Optional.[Bool].Default: false. If you have a submit button and trying to validate all the inputs of your form at once, toggle it to true, then it will validate the field and pass the result via the "validationCallback" you provide.
8989
validationCallback={res => this.setState({ hasNameError: res, validate: false })} //Optional.[Func].Default: none. Return the validation result.

example/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ class Index extends Component {
848848
placeholder: 'Place your name here ^-^',
849849
}}
850850
value={name} // Optional.[String].Default: "".
851-
label="" // Optional.[String].Default: "". The content of label
851+
label="" // Optional.[String].Default: "". The content of label. NOTE: must provide attributesInput.id
852852
disabled={false} // Optional.[Bool].Default: false.
853853
validate={validate} // Optional.[Bool].Default: false. If you have a submit button and trying to validate all the inputs of your form at onece, toggle it to true, then it will validate the field and pass the result via the "validationCallback" you provide.
854854
validationCallback={res => this.setState({ hasNameError: res, validate: false })} // Optional.[Func].Default: none. Return the validation result.

lib/components/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/react-inputs-validation.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/react-inputs-validation.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/react-inputs-validation.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/react-inputs-validation.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-inputs-validation",
3-
"version": "4.4.6",
3+
"version": "4.5.0",
44
"description": "A react component for form inputs validation.",
55
"main": "index.js",
66
"repository": {

src/js/Inputs/Textbox.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ const getDefaultAsyncObj = (obj: DefaultAsyncMsgObj) => {
8686
};
8787
};
8888
interface AttributesInputObj {
89+
id?: string;
8990
maxLength?: number;
9091
}
9192
interface Props {
@@ -448,6 +449,7 @@ const component: React.FC<Props> = ({
448449
if (showMsg && !err && successMsg !== '') {
449450
msgHtml = <div className={successMsgClass}>{successMsg}</div>;
450451
}
452+
console.log(attributesInput.id)
451453
return (
452454
<div className={wrapperClass} style={customStyleWrapper} {...attributesWrapper}>
453455
<div className={containerClass} style={customStyleContainer}>
@@ -465,7 +467,7 @@ const component: React.FC<Props> = ({
465467
ref={$input}
466468
{...attributesInput}
467469
/>
468-
{label && <label>{label}</label>}
470+
{label && attributesInput.id && <label htmlFor={attributesInput.id}>{label}</label>}
469471
</div>
470472
{msgHtml}
471473
</div>

0 commit comments

Comments
 (0)