UNPKG

react-application-core

Version:

A react-based application core for the business applications.

147 lines 5.27 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) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.SearchToolbar = void 0; var React = require("react"); var util_1 = require("../../../util"); var generic_component_1 = require("../../base/generic.component"); var definition_1 = require("../../../definition"); var button_1 = require("../../button"); var field_1 = require("../../field"); /** * @component-impl * @stable [06.05.2020] * * Please use the "Mappers.searchToolbarProps" */ var SearchToolbar = /** @class */ (function (_super) { __extends(SearchToolbar, _super); /** * @stable [06.05.2020] * @param {ISearchToolbarProps} props */ function SearchToolbar(props) { var _this = _super.call(this, props) || this; _this.onActivate = _this.onActivate.bind(_this); _this.onChange = _this.onChange.bind(_this); _this.onDeactivate = _this.onDeactivate.bind(_this); _this.onDelay = _this.onDelay.bind(_this); return _this; } /** * @stable [06.05.2020] * @returns {JSX.Element} */ SearchToolbar.prototype.render = function () { var props = this.props; return (React.createElement("div", { className: util_1.joinClassName(definition_1.ToolbarClassesEnum.SEARCH_TOOLBAR, util_1.isFull(props) && definition_1.ToolbarClassesEnum.FULL_TOOLBAR, util_1.calc(props.className)) }, !this.isActive && (React.createElement(button_1.Button, { icon: props.icon, onClick: this.onActivate, disabled: props.disabled })), this.isActive && (React.createElement(field_1.TextField, __assign({ value: this.query, actions: this.actions, autoFocus: true, errorMessageRendered: false, placeholder: this.settings.messages.SEARCH, plugins: field_1.DelayedChangesFieldPlugin, onChange: this.onChange, onDelay: this.onDelay }, this.props.fieldConfiguration))))); }; /** * @stable [06.05.2020] */ SearchToolbar.prototype.onActivate = function () { var props = this.props; if (util_1.isFn(props.onActivate)) { props.onActivate(); } }; /** * @stable [06.05.2020] */ SearchToolbar.prototype.onDeactivate = function () { var props = this.props; if (util_1.isFn(props.onDeactivate)) { props.onDeactivate(); } }; /** * @stable [06.05.2020] * @param {string} query */ SearchToolbar.prototype.onChange = function (query) { var props = this.props; if (util_1.isFn(props.onChange)) { props.onChange(query); } }; /** * @stable [06.05.2020] */ SearchToolbar.prototype.onDelay = function () { var props = this.props; if (props.onApply) { props.onApply(); } }; Object.defineProperty(SearchToolbar.prototype, "actions", { /** * @stable [06.05.2020] * @returns {IFieldActionEntity[]} */ get: function () { var props = this.props; return [ { disabled: props.disabled, type: definition_1.IconsEnum.TIMES, onClick: this.onDeactivate, } ]; }, enumerable: false, configurable: true }); Object.defineProperty(SearchToolbar.prototype, "isActive", { /** * @stable [06.05.2020] * @returns {string} */ get: function () { return this.props.active; }, enumerable: false, configurable: true }); Object.defineProperty(SearchToolbar.prototype, "query", { /** * @stable [06.05.2020] * @returns {string} */ get: function () { return this.props.query; }, enumerable: false, configurable: true }); SearchToolbar.defaultProps = { icon: definition_1.IconsEnum.SEARCH, }; return SearchToolbar; }(generic_component_1.GenericComponent)); exports.SearchToolbar = SearchToolbar; //# sourceMappingURL=search-toolbar.component.js.map