UNPKG

react-application-core

Version:

A react-based application core for the business applications.

108 lines 4.3 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 __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.KeyboardKey = void 0; var React = require("react"); var generic_component_1 = require("../../base/generic.component"); var button_1 = require("../../button"); var definition_1 = require("../../../definition"); var util_1 = require("../../../util"); var KeyboardKey = /** @class */ (function (_super) { __extends(KeyboardKey, _super); /** * @stable [26.01.2019] * @param {IKeyboardKeyProps} props */ function KeyboardKey(props) { var _this = _super.call(this, props) || this; _this.buttonRef = React.createRef(); _this.onClick = _this.onClick.bind(_this); return _this; } /** * @stable [27.01.2019] * @returns {JSX.Element} */ KeyboardKey.prototype.render = function () { var props = this.props; var keyAsObject = this.keyAsObject; var value = this.value; return (React.createElement(button_1.Button, { ref: this.buttonRef, disabled: props.disabled, touched: this.isKeyTouched, className: util_1.joinClassName('rac-keyboard-key', "rac-keyboard-key-" + value, keyAsObject && util_1.calc(keyAsObject.className), util_1.calc(props.className, value)), style: keyAsObject && keyAsObject.width ? { width: keyAsObject.width } : {}, onClick: this.onClick }, util_1.TypeUtils.isFn(props.renderer) ? props.renderer(value) : value)); }; /** * @stable [08.05.2018] */ KeyboardKey.prototype.onClick = function () { this.buttonRef.current.blur(); this.props.onSelect(this.props.value); }; Object.defineProperty(KeyboardKey.prototype, "value", { /** * @stable [02.02.2020] * @returns {string} */ get: function () { var props = this.props; var keyAsString = this.keyAsString; var keyAsObject = this.keyAsObject; return util_1.TypeUtils.isString(keyAsString) ? (props.useUppercase ? keyAsString.toUpperCase() : keyAsString) : (keyAsObject.type === definition_1.KeyboardKeysEnum.UPPERCASE ? (props.useUppercase ? definition_1.KeyboardKeyDescriptorsEnum.LOWERCASE : keyAsObject.value) : keyAsObject.value); }, enumerable: false, configurable: true }); Object.defineProperty(KeyboardKey.prototype, "isKeyTouched", { /** * @stable [02.02.2020] * @returns {boolean} */ get: function () { return util_1.TypeUtils.isString(this.keyAsString) || definition_1.KeyboardKeyDescriptorsEnum.CLOSE !== this.keyAsObject.value; // Touch issues fixes }, enumerable: false, configurable: true }); Object.defineProperty(KeyboardKey.prototype, "keyAsObject", { /** * @stable [02.02.2020] * @returns {IKeyboardKeyValueEntity} */ get: function () { return this.props.value; }, enumerable: false, configurable: true }); Object.defineProperty(KeyboardKey.prototype, "keyAsString", { /** * @stable [02.02.2020] * @returns {string} */ get: function () { return this.props.value; }, enumerable: false, configurable: true }); return KeyboardKey; }(generic_component_1.GenericComponent)); exports.KeyboardKey = KeyboardKey; //# sourceMappingURL=keyboard-key.component.js.map