alaska-field-text
Advanced tools
Comparing version 0.12.11 to 0.12.12
@@ -55,3 +55,7 @@ 'use strict'; | ||
TextFeild.dbOptions = ['trim', 'match', 'lowercase', 'uppercase', 'maxlength', 'minlength']; | ||
TextFeild.viewOptions = ['trim', 'match', 'lowercase', 'uppercase', 'maxlength', 'minlength', 'addonBefore', 'addonAfter', 'placeholder', 'multiLine', 'translate']; | ||
TextFeild.viewOptions = ['trim', 'match', 'lowercase', 'uppercase', 'maxlength', 'minlength', 'addonBefore', 'addonAfter', 'placeholder', 'multiLine', 'translate', function (options, field) { | ||
if (field.match) { | ||
options.match = field.match.toString(); | ||
} | ||
}]; | ||
TextFeild.defaultOptions = { | ||
@@ -58,0 +62,0 @@ cell: 'TextFieldCell', |
{ | ||
"name": "alaska-field-text", | ||
"version": "0.12.11", | ||
"version": "0.12.12", | ||
"description": "Alaska text field", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -16,2 +16,19 @@ // @flow | ||
hasError() { | ||
let { | ||
field, | ||
value | ||
} = this.props; | ||
if (value && field.match && typeof field.match === 'string') { | ||
let matchs = field.match.match(/^\/(.+)\/([igm]*)$/); | ||
if (matchs) { | ||
let match = new RegExp(matchs[1], matchs[2]); | ||
if (!match.test(value)) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
handleChange = (event: SyntheticInputEvent<*>) => { | ||
@@ -35,2 +52,11 @@ if (this.props.onChange) { | ||
className += ' text-field'; | ||
if (!errorText && value && field.match && typeof field.match === 'string') { | ||
let matchs = field.match.match(/^\/(.+)\/([igm]*)$/); | ||
if (matchs) { | ||
let match = new RegExp(matchs[1], matchs[2]); | ||
if (!match.test(value)) { | ||
errorText = t('Invalid format'); | ||
} | ||
} | ||
} | ||
if (errorText) { | ||
@@ -79,20 +105,18 @@ className += ' has-error'; | ||
if (field.horizontal === false) { | ||
let labelElement = label ? <label className="control-label">{label}</label> : null; | ||
if (field.horizontal) { | ||
return ( | ||
<div className={className}> | ||
{labelElement} | ||
{inputElement} | ||
{helpElement} | ||
<label className="col-sm-2 control-label">{label}</label> | ||
<div className="col-sm-10"> | ||
{inputElement} | ||
{helpElement} | ||
</div> | ||
</div> | ||
); | ||
} | ||
return ( | ||
<div className={className}> | ||
<label className="col-sm-2 control-label">{label}</label> | ||
<div className="col-sm-10"> | ||
{inputElement} | ||
{helpElement} | ||
</div> | ||
{label ? <label className="control-label">{label}</label> : null} | ||
{inputElement} | ||
{helpElement} | ||
</div> | ||
@@ -99,0 +123,0 @@ ); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10166
303