Skip to content

Commit 038000c

Browse files
author
Edward Xiao
committed
- Remove default ID. It should be append when it is provided.
1 parent 5843447 commit 038000c

21 files changed

+181
-176
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Tested on IE9+ and Chrome and Safari(10.0.3)
6464
|Props | |Type |Description |Default |
6565
|--- |--- |--- |--- | --- |
6666
|tabIndex | Opt | Str | Num | | none |
67-
|id | Opt | Str | | "" |
67+
|id | Opt | Str | | none |
6868
|name | Opt | Str | | "" |
6969
|type | Opt | Str | | "text" |
7070
|value | Opt | Str | | "" |
@@ -179,7 +179,7 @@ import 'react-inputs-validation/lib/react-inputs-validation.min.css';
179179
|Props | |Type |Description |Default |
180180
|--- |--- |--- |--- | --- |
181181
|tabIndex | Opt | Str | Num | | none |
182-
|**id** |**Req**|**Str**|**IMPORTANT if you have multiple Radiobox on the page, id is used to distinguish them for the label 'for' use**|**""** |
182+
|**id** |**Req**|**Str**|**IMPORTANT if you have multiple Radiobox on the page, id is used to distinguish them for the label 'for' use**|**none**|
183183
|name | Opt | Str | | "" |
184184
|value | Opt | Str | | "" |
185185
|disabled | Opt | Bool | | false |
@@ -270,7 +270,7 @@ import 'react-inputs-validation/lib/react-inputs-validation.min.css';
270270
|Props | |Type |Description |Default |
271271
|--- |--- |--- |--- | --- |
272272
|tabIndex | Opt | Str | Num | | none |
273-
|id | Opt | Str | | "" |
273+
|id | Opt | Str | | none |
274274
|name | Opt | Str | | "" |
275275
|value | Opt | Str | | "" |
276276
|**checked** |**Req**|**Bool**|**Recommend using the value returned from ```onChange``` callback, which is ```isChecked```.** |**false** |
@@ -362,7 +362,7 @@ import 'react-inputs-validation/lib/react-inputs-validation.min.css';
362362
|Props | |Type |Description |Default |
363363
|--- |--- |--- |--- | --- |
364364
|tabIndex | Opt | Str | Num | | none |
365-
|id | Opt | Str | | "" |
365+
|id | Opt | Str | | none |
366366
|name | Opt | Str | | "" |
367367
|type | Opt | Str | | "text" |
368368
|value | Opt | Str | | "" |
@@ -471,7 +471,7 @@ import 'react-inputs-validation/lib/react-inputs-validation.min.css';
471471
|Props | |Type |Description |Default |
472472
|--- |--- |--- |--- | --- |
473473
|tabIndex | Opt | Str | Num | | none |
474-
|id | Opt | Str | | "" |
474+
|id | Opt | Str | | none |
475475
|name | Opt | Str | | "" |
476476
|type | Opt | Str | | "text" |
477477
|value | Opt | Str | | "" |

example/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ class Index extends Component {
574574
<h1>Validate Textbox Empty by onBlur Example:</h1>
575575
<Textbox
576576
// tabIndex="1" // Optional.[String or Number].Default: none.
577-
id={'Name'} // Optional.[String].Default: "". Input ID.
577+
// id={'Name'} // Optional.[String].Default: "". Input ID.
578578
name="Name" // Optional.[String].Default: "". Input name.
579579
type="text" // Optional.[String].Default: "text". Input type [text, password, number].
580580
value={name} // Optional.[String].Default: "".
@@ -607,7 +607,7 @@ class Index extends Component {
607607
<h1>Validate Textbox Regex by onBlur Example:</h1>
608608
<Textbox
609609
// tabIndex="1" // Optional.[String or Number].Default: none.
610-
id={'Name'} // Optional.[String].Default: "". Input ID.
610+
// id={'Name'} // Optional.[String].Default: "". Input ID.
611611
name="Name" // Optional.[String].Default: "". Input name.
612612
type="text" // Optional.[String].Default: "text". Input type [text, password, number].
613613
value={nameRg} // Optional.[String].Default: "".

lib/components/Checkbox.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ var _message = _interopRequireDefault(require("./message"));
1111

1212
var _const = require("./const");
1313

14-
var _utils = _interopRequireDefault(require("./utils"));
15-
1614
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
1715

1816
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
@@ -71,8 +69,6 @@ var reactInputsValidationCss = {
7169
};
7270
var TYPE = 'checkbox';
7371

74-
var DEFAULT_ID = _utils["default"].getRandomId();
75-
7672
var getDefaultValidationOption = function getDefaultValidationOption(obj) {
7773
var name = obj.name,
7874
check = obj.check,
@@ -120,7 +116,7 @@ var component = function component(_ref) {
120116
var _ref$tabIndex = _ref.tabIndex,
121117
tabIndex = _ref$tabIndex === void 0 ? null : _ref$tabIndex,
122118
_ref$id = _ref.id,
123-
id = _ref$id === void 0 ? DEFAULT_ID : _ref$id,
119+
id = _ref$id === void 0 ? null : _ref$id,
124120
_ref$name = _ref.name,
125121
name = _ref$name === void 0 ? '' : _ref$name,
126122
_ref$value = _ref.value,
@@ -271,6 +267,10 @@ var component = function component(_ref) {
271267
return;
272268
}
273269

270+
if (id) {
271+
$el.current.setAttribute('id', String(id));
272+
}
273+
274274
if (tabIndex) {
275275
$el.current.setAttribute('tabindex', String(tabIndex));
276276
}
@@ -338,7 +338,6 @@ var component = function component(_ref) {
338338
}, React.createElement("div", {
339339
className: reactInputsValidationCss['box']
340340
}), React.createElement("input", {
341-
id: id,
342341
name: name,
343342
type: TYPE,
344343
className: reactInputsValidationCss["".concat(TYPE, "__input")],

lib/components/Radiobox.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ var _message = _interopRequireDefault(require("./message"));
1111

1212
var _const = require("./const");
1313

14-
var _utils = _interopRequireDefault(require("./utils"));
15-
1614
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
1715

1816
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
@@ -71,8 +69,6 @@ var reactInputsValidationCss = {
7169
};
7270
var TYPE = 'radiobox';
7371

74-
var DEFAULT_ID = _utils["default"].getRandomId();
75-
7672
var getDefaultValidationOption = function getDefaultValidationOption(obj) {
7773
var name = obj.name,
7874
check = obj.check,
@@ -137,7 +133,7 @@ var component = function component(_ref) {
137133
var _ref$tabIndex = _ref.tabIndex,
138134
tabIndex = _ref$tabIndex === void 0 ? null : _ref$tabIndex,
139135
_ref$id = _ref.id,
140-
id = _ref$id === void 0 ? DEFAULT_ID : _ref$id,
136+
id = _ref$id === void 0 ? null : _ref$id,
141137
_ref$name = _ref.name,
142138
name = _ref$name === void 0 ? '' : _ref$name,
143139
_ref$value = _ref.value,
@@ -278,6 +274,10 @@ var component = function component(_ref) {
278274
return;
279275
}
280276

277+
if (id) {
278+
$el.current.setAttribute('id', String(id));
279+
}
280+
281281
if (tabIndex) {
282282
$el.current.setAttribute('tabindex', String(tabIndex));
283283
}
@@ -362,7 +362,6 @@ var component = function component(_ref) {
362362

363363
return React.createElement("div", {
364364
ref: $input,
365-
id: id,
366365
className: wrapperClass,
367366
style: customStyleWrapper,
368367
onClick: handleOnClick,

lib/components/Select.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ var _message = _interopRequireDefault(require("./message"));
1111

1212
var _const = require("./const");
1313

14-
var _utils = _interopRequireDefault(require("./utils"));
15-
1614
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
1715

1816
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
@@ -78,11 +76,8 @@ var reactInputsValidationCss = {
7876
"select__dropdown-icon-container": "react-inputs-validation__select__dropdown-icon-container___2ild-"
7977
};
8078
var TYPE = 'select';
81-
82-
var DEFAULT_ID = _utils["default"].getRandomId();
8379
/* istanbul ignore next */
8480

85-
8681
if (!String.prototype.startsWith) {
8782
String.prototype.startsWith = function (searchString, position) {
8883
var p = position || 0;
@@ -190,7 +185,7 @@ var component = function component(_ref) {
190185
var _ref$tabIndex = _ref.tabIndex,
191186
tabIndex = _ref$tabIndex === void 0 ? null : _ref$tabIndex,
192187
_ref$id = _ref.id,
193-
id = _ref$id === void 0 ? DEFAULT_ID : _ref$id,
188+
id = _ref$id === void 0 ? null : _ref$id,
194189
_ref$name = _ref.name,
195190
name = _ref$name === void 0 ? '' : _ref$name,
196191
_ref$value = _ref.value,
@@ -374,6 +369,10 @@ var component = function component(_ref) {
374369
window.addEventListener('mousedown', pageClick);
375370
window.addEventListener('touchstart', pageClick);
376371

372+
if (id) {
373+
$elWrapper.current.setAttribute('id', String(id));
374+
}
375+
377376
if (tabIndex) {
378377
$elWrapper.current.setAttribute('tabindex', String(tabIndex));
379378
}
@@ -692,7 +691,6 @@ var component = function component(_ref) {
692691
}));
693692
return React.createElement("div", {
694693
ref: $wrapper,
695-
id: reactInputsValidationCss["".concat(TYPE, "__wrapper")],
696694
className: wrapperClass,
697695
style: customStyleWrapper,
698696
onClick: function onClick(e) {
@@ -705,7 +703,6 @@ var component = function component(_ref) {
705703
className: containerClass,
706704
style: customStyleContainer
707705
}, React.createElement("input", {
708-
id: id,
709706
name: name,
710707
type: "hidden",
711708
value: value,

lib/components/Textarea.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@ var reactInputsValidationCss = {
7878
"select__dropdown-icon-container": "react-inputs-validation__select__dropdown-icon-container___2ild-"
7979
};
8080
var TYPE = 'textarea';
81-
82-
var DEFAULT_ID = _utils["default"].getRandomId();
83-
8481
var VALIDATE_OPTION_TYPE_LIST = ['string'];
8582
var DEFAULT_MAX_LENGTH = 524288; // Default value is 524288
8683

@@ -156,7 +153,7 @@ var component = function component(_ref) {
156153
var _ref$tabIndex = _ref.tabIndex,
157154
tabIndex = _ref$tabIndex === void 0 ? null : _ref$tabIndex,
158155
_ref$id = _ref.id,
159-
id = _ref$id === void 0 ? DEFAULT_ID : _ref$id,
156+
id = _ref$id === void 0 ? null : _ref$id,
160157
_ref$name = _ref.name,
161158
name = _ref$name === void 0 ? '' : _ref$name,
162159
_ref$value = _ref.value,
@@ -500,6 +497,10 @@ var component = function component(_ref) {
500497
return;
501498
}
502499

500+
if (id) {
501+
$el.current.setAttribute('id', String(id));
502+
}
503+
503504
if (tabIndex) {
504505
$el.current.setAttribute('tabindex', String(tabIndex));
505506
}
@@ -552,7 +553,6 @@ var component = function component(_ref) {
552553
className: containerClass,
553554
style: customStyleContainer
554555
}, React.createElement("textarea", {
555-
id: id,
556556
name: name,
557557
value: internalValue,
558558
disabled: disabled,

lib/components/Textbox.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@ var reactInputsValidationCss = {
7878
"select__dropdown-icon-container": "react-inputs-validation__select__dropdown-icon-container___2ild-"
7979
};
8080
var TYPE = 'textbox';
81-
82-
var DEFAULT_ID = _utils["default"].getRandomId();
83-
8481
var VALIDATE_OPTION_TYPE_LIST = ['string', 'number'];
8582
var VALIDATE_NUMBER_TYPE_LIST = ['decimal', 'int'];
8683
var DEFAULT_MAX_LENGTH = 524288; // Default value is 524288
@@ -190,7 +187,7 @@ var component = function component(_ref) {
190187
var _ref$tabIndex = _ref.tabIndex,
191188
tabIndex = _ref$tabIndex === void 0 ? null : _ref$tabIndex,
192189
_ref$id = _ref.id,
193-
id = _ref$id === void 0 ? DEFAULT_ID : _ref$id,
190+
id = _ref$id === void 0 ? null : _ref$id,
194191
_ref$name = _ref.name,
195192
name = _ref$name === void 0 ? '' : _ref$name,
196193
_ref$type = _ref.type,
@@ -639,6 +636,10 @@ var component = function component(_ref) {
639636
return;
640637
}
641638

639+
if (id) {
640+
$el.current.setAttribute('id', String(id));
641+
}
642+
642643
if (tabIndex) {
643644
$el.current.setAttribute('tabindex', String(tabIndex));
644645
}
@@ -699,7 +700,6 @@ var component = function component(_ref) {
699700
className: containerClass,
700701
style: customStyleContainer
701702
}, React.createElement("input", {
702-
id: id,
703703
name: name,
704704
type: type,
705705
value: internalValue,

lib/react-inputs-validation.js

Lines changed: 2 additions & 2 deletions
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: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)