Repository URL to install this package:
|
Version:
0.9.5 ▾
|
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importDefault(require("react"));
const TextBox_1 = __importDefault(require("src/inputs/TextBox"));
const isValid_1 = require("src/forms/deps/isValid");
const InputChain_1 = require("../../InputChain");
/**
* @todo 1. split to address plugin + autosuggest google plugin
* @todo @see https://www.the-art-of-web.com/html/html5-form-validation/ (price, long-lat)
* @see @wcag https://www.w3.org/WAI/tutorials/forms/validation/
*
* https://css-tricks.com/form-validation-ux-html-css/
* ## parse & validate
* https://github.com/mkoryak/address-validator
* https://github.com/DamonOehlman/addressit note - this one is similar to what we did in bootstrapper/google/ originally
* https://www.htmlgoodies.com/beyond/javascript/parsing-building-and-street-fields-from-an-address-using-regular-expressions.html
*/
class AutoSuggestInput extends InputChain_1.InputChain {
static isSatisfiedByProps(props) {
return props.type === 'googleAutoSugggest';
}
validate() {
console.dev('AutoSuggestInput_validate');
const state = this.get('state');
// @@todo when w hav
// this.isValid = validators.isValid(state.value, state.validationType)
this.isValid = isValid_1.isValid(state.value, state.validationType);
}
render() {
const state = this.get('state');
const props = this.get('props');
console.log('AutoSuggestInput_render', props);
// this should be moved as part of the component
const attributes = Object.assign({}, props, { state, onChange: value => {
state.value = value;
}, onBlur: value => {
this.validate();
} });
return react_1.default.createElement(TextBox_1.default, Object.assign({}, attributes));
// return AutoSuggest once it is fixed
// return <AutoSuggest {...attributes} />
}
}
exports.AutoSuggestInput = AutoSuggestInput;
exports.default = AutoSuggestInput;
//# sourceMappingURL=AutoSuggestInput.js.map