UNPKG

igniteui-react-inputs

Version:

Ignite UI React input components.

225 lines (222 loc) 7.25 kB
import { __extends, __values } from "tslib"; import * as React from 'react'; import { XSuffix } from "./XSuffix"; import { ensureBool, NamePatcher, isValidProp, getModifiedProps } from "igniteui-react-core"; import { ReactRenderer, PortalManager } from "igniteui-react-core"; import { IgrXInputGroupItem } from './igr-x-input-group-item'; var IgrXSuffix = /** @class */ /*@__PURE__*/ (function (_super) { __extends(IgrXSuffix, _super); function IgrXSuffix(props) { var _this = _super.call(this, props) || this; _this._wrapper = null; if (_this._styling) { NamePatcher.ensureStylablePatched(Object.getPrototypeOf(_this)); } _this._implementation = _this.createImplementation(); _this._implementation.externalObject = _this; _this._getMainRef = _this._getMainRef.bind(_this); var container; if (document) { container = document.createElement("div"); } var root; root = container; if (container != null) { root = container; } _this.requestRender = _this.requestRender.bind(_this); _this._portalManager = new PortalManager("suffixContent", _this.requestRender); var ren = new ReactRenderer(root, document, true, {}, _this._portalManager); _this._wrapper = ren; _this._container = _this._wrapper.rootWrapper; _this._container.setStyleProperty("display", "inline-block"); _this._container.setStyleProperty("vertical-align", "middle"); var suffix = _this.i; _this._suffix = suffix; suffix.provideContainer(ren); if (props) { _this.initializeProperties(); } return _this; } IgrXSuffix.prototype._getMainRef = function (ref) { this._elRef = ref; }; IgrXSuffix.prototype.render = function () { var propChildren = this.props.children; var children = []; React.Children.forEach(propChildren, function (ch) { children.push(React.cloneElement(ch)); }); this._portalManager.onRender(children); var div = React.createElement("div", { className: "ig-suffix igr-suffix", ref: this._getMainRef, children: children }); return div; }; IgrXSuffix.prototype.requestRender = function () { if (this._initialized) { this.setState({}); } }; //private _getLabelPortal(element: DomWrapper, portalCallback: (portal: DomPortal) => void): void { // this._portalManager.getPortal(element, "TemplateContent", portalCallback); //} IgrXSuffix.prototype.shouldComponentUpdate = function (nextProps, nextState) { var e_1, _a; var mod = getModifiedProps(this.props, nextProps); try { for (var _b = __values(Object.keys(mod)), _c = _b.next(); !_c.done; _c = _b.next()) { var p = _c.value; if (isValidProp(this, p)) { this[p] = mod[p]; } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } } return true; }; IgrXSuffix.prototype.initializeProperties = function () { var e_2, _a; try { for (var _b = __values(Object.keys(this.props)), _c = _b.next(); !_c.done; _c = _b.next()) { var p = _c.value; if (isValidProp(this, p)) { this[p] = this.props[p]; } } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_2) throw e_2.error; } } }; // supports angular themes or custom properties set in CSS IgrXSuffix.prototype.updateStyle = function () { this._styling(this._elRef, this); }; IgrXSuffix.prototype.destroy = function () { this._suffix.destroy(); this._wrapper.destroy(); }; IgrXSuffix.prototype.componentWillUnmount = function () { }; IgrXSuffix.prototype.componentDidMount = function () { this._elRef.appendChild(this._container.getNativeElement()); this.initializeContent(); }; IgrXSuffix.prototype.initializeContent = function () { this._styling(this._container.getNativeElement(), this); this.updateStyle(); }; IgrXSuffix.prototype.createImplementation = function () { return new XSuffix(); }; Object.defineProperty(IgrXSuffix.prototype, "i", { /** * @hidden */ get: function () { return this._implementation; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXSuffix.prototype, "id", { /** * Gets or sets the id to use for the checkbox. */ get: function () { return this.i.z; }, set: function (v) { this.i.z = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXSuffix.prototype, "ariaLabel", { /** * Gets or sets the value of the aria-label attribute. */ get: function () { return this.i.w; }, set: function (v) { this.i.w = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXSuffix.prototype, "isHover", { /** * Gets or sets whether the suffix is hovered. */ get: function () { return this.i.q; }, set: function (v) { this.i.q = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXSuffix.prototype, "disabled", { /** * Gets or sets whether the checkbox is disabled. */ get: function () { return this.i.disabled; }, set: function (v) { this.i.disabled = ensureBool(v); }, enumerable: false, configurable: true }); IgrXSuffix.prototype.onDetachedFromUI = function () { this.i.onDetachedFromUI(); }; IgrXSuffix.prototype.onAttachedToUI = function () { this.i.onAttachedToUI(); }; /** * Exports visual information about the current state of the grid. */ IgrXSuffix.prototype.exportVisualModel = function () { var iv = this.i.t(); return (iv); }; /** * Returns a serialized copy of the exported visual model */ IgrXSuffix.prototype.exportSerializedVisualModel = function () { var iv = this.i.y(); return (iv); }; return IgrXSuffix; }(IgrXInputGroupItem)); export { IgrXSuffix };