UNPKG

react-dadata

Version:

React-компонент для подсказок адресов, организаций и банков с помощью сервиса DaData.ru

50 lines (49 loc) 2.52 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.EmailSuggestions = void 0; var react_1 = __importDefault(require("react")); var base_suggestions_1 = require("../../base-suggestions"); var highlight_words_1 = require("../../highlight-words"); var EmailSuggestions = /** @class */ (function (_super) { __extends(EmailSuggestions, _super); function EmailSuggestions() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.loadSuggestionsUrl = 'https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/email'; _this.getLoadSuggestionsData = function () { var count = _this.props.count; var query = _this.state.query; return { query: query, count: count || 10, }; }; _this.getSuggestionKey = function (suggestion) { return suggestion.value; }; _this.renderOption = function (suggestion) { var _a = _this.props, renderOption = _a.renderOption, highlightClassName = _a.highlightClassName; var query = _this.state.query; return renderOption ? (renderOption(suggestion, query)) : (react_1.default.createElement("div", null, react_1.default.createElement(highlight_words_1.HighlightWords, { highlightClassName: highlightClassName || 'react-dadata--highlighted', words: _this.getHighlightWords(), text: suggestion.value }))); }; return _this; } return EmailSuggestions; }(base_suggestions_1.BaseSuggestions)); exports.EmailSuggestions = EmailSuggestions;