UNPKG

igniteui-react-inputs

Version:

Ignite UI React input components.

532 lines (529 loc) 16.1 kB
import { __extends, __values } from "tslib"; import * as React from 'react'; import { XLabel } from "./XLabel"; import { ensureEnum, brushToString, stringToBrush, ensureBool, NamePatcher, isValidProp, getModifiedProps } from "igniteui-react-core"; import { FontInfo } from "igniteui-react-core"; import { ReactRenderer, PortalManager } from "igniteui-react-core"; import { IgrXInputGroupItem } from './igr-x-input-group-item'; import { ControlDisplayDensity_$type } from "igniteui-react-core"; import { BaseControlTheme_$type } from "igniteui-react-core"; var IgrXLabel = /** @class */ /*@__PURE__*/ (function (_super) { __extends(IgrXLabel, _super); function IgrXLabel(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("labelContent", _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 label = _this.i; _this._label = label; label.provideContainer(ren); if (props) { _this.initializeProperties(); } return _this; } IgrXLabel.prototype._getMainRef = function (ref) { this._elRef = ref; }; IgrXLabel.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-x-label igr-x-label", ref: this._getMainRef, children: children }); return div; }; IgrXLabel.prototype.requestRender = function () { if (this._initialized) { this.setState({}); } }; //private _getLabelPortal(element: DomWrapper, portalCallback: (portal: DomPortal) => void): void { // this._portalManager.getPortal(element, "TemplateContent", portalCallback); //} IgrXLabel.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; }; IgrXLabel.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 IgrXLabel.prototype.updateStyle = function () { this._styling(this._elRef, this); }; IgrXLabel.prototype.destroy = function () { this._label.destroy(); this._wrapper.destroy(); }; IgrXLabel.prototype.componentWillUnmount = function () { }; IgrXLabel.prototype.componentDidMount = function () { this._elRef.appendChild(this._container.getNativeElement()); this.initializeContent(); }; IgrXLabel.prototype.initializeContent = function () { this._styling(this._container.getNativeElement(), this); this.updateStyle(); this.i.onSizeReady(); }; IgrXLabel.prototype.createImplementation = function () { return new XLabel(); }; IgrXLabel.prototype._onDisplayChanged = function () { if (this._elRef) { this._elRef.style.display = this.display; } }; IgrXLabel.prototype._onFlexDirectionChanged = function () { if (this._elRef) { this._elRef.style.flexDirection = this.flexDirection; } }; IgrXLabel.prototype._onFlexGrowChanged = function () { if (this._elRef) { this._elRef.style.flexGrow = this.flexGrow; } }; IgrXLabel.prototype._onAlignItemsChanged = function () { if (this._elRef) { this._elRef.style.alignItems = this.alignItems; } }; IgrXLabel.prototype._onAlignSelfChanged = function () { if (this._elRef) { this._elRef.style.alignSelf = this.alignSelf; } }; Object.defineProperty(IgrXLabel.prototype, "i", { /** * @hidden */ get: function () { return this._implementation; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "baseTheme", { /** * Gets or sets the base built in theme to use for the label. */ get: function () { return this.i.p; }, set: function (v) { this.i.p = ensureEnum(BaseControlTheme_$type, v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "density", { /** * Gets or sets the display density to use for the label. */ get: function () { return this.i.t; }, set: function (v) { this.i.t = ensureEnum(ControlDisplayDensity_$type, v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "actualDensity", { /** * Gets the actual display density to use for the label. */ get: function () { return this.i.s; }, set: function (v) { this.i.s = ensureEnum(ControlDisplayDensity_$type, v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "actualTextColor", { /** * Gets the actual color to use for the text color. */ get: function () { return brushToString(this.i.c3); }, set: function (v) { this.i.c3 = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "actualHighlightTextColor", { /** * Gets the actual color to use for the text color. */ get: function () { return brushToString(this.i.c0); }, set: function (v) { this.i.c0 = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "actualHoverHighlightTextColor", { /** * Gets the actual color to use for the text color when highlighted and hovered. */ get: function () { return brushToString(this.i.c1); }, set: function (v) { this.i.c1 = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "actualHoverTextColor", { /** * Gets the actual hover color to use for the text. */ get: function () { return brushToString(this.i.c2); }, set: function (v) { this.i.c2 = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "textColor", { /** * Gets or sets the color to use for the text. */ get: function () { return brushToString(this.i.dj); }, set: function (v) { this.i.dj = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "highlightTextColor", { /** * Gets or sets the color to use for the text. */ get: function () { return brushToString(this.i.dg); }, set: function (v) { this.i.dg = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "hoverHighlightTextColor", { /** * Gets or sets the color to use for the text. */ get: function () { return brushToString(this.i.dh); }, set: function (v) { this.i.dh = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "textStyle", { /** * Gets or sets the use for the button. */ get: function () { if (this.i.y == null) { return null; } return this.i.y.fontString; }, set: function (v) { var fi = new FontInfo(); fi.fontString = v; this.i.y = fi; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "hoverTextColor", { /** * Gets or sets the color to use for the hovered text of the button regardless of type. */ get: function () { return brushToString(this.i.di); }, set: function (v) { this.i.di = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "id", { /** * Gets or sets the id to use for the checkbox. */ get: function () { return this.i.bw; }, set: function (v) { this.i.bw = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "display", { /** * Gets or sets the id to use for the checkbox. */ get: function () { return this.i.bk; }, set: function (v) { this.i.bk = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "flexDirection", { /** * Gets or sets the id to use for the checkbox. */ get: function () { return this.i.bn; }, set: function (v) { this.i.bn = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "flexGrow", { /** * Gets or sets the flex-grow setting for the button. */ get: function () { return this.i.bp; }, set: function (v) { this.i.bp = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "alignItems", { /** * Gets or sets the id to use for the checkbox. */ get: function () { return this.i.bc; }, set: function (v) { this.i.bc = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "alignSelf", { /** * Gets or sets the id to use for the checkbox. */ get: function () { return this.i.be; }, set: function (v) { this.i.be = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "tabIndex", { /** * Gets or sets TabIndex to use for the checkbox. */ get: function () { return this.i.au; }, set: function (v) { this.i.au = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "for", { /** * Gets or sets the for attribute to use for the label. */ get: function () { return this.i.br; }, set: function (v) { this.i.br = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "ariaLabel", { /** * Gets or sets the value of the aria-label attribute. */ get: function () { return this.i.bg; }, set: function (v) { this.i.bg = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "text", { /** * Gets or sets the text for the label. */ get: function () { return this.i.text; }, set: function (v) { this.i.text = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "isHover", { /** * Gets or sets whether the label is hovered. */ get: function () { return this.i.ao; }, set: function (v) { this.i.ao = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.prototype, "value", { /** * Gets or sets the value for the label. */ get: function () { return this.i.as; }, set: function (v) { this.i.as = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXLabel.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 }); IgrXLabel.prototype.onDetachedFromUI = function () { this.i.onDetachedFromUI(); }; IgrXLabel.prototype.onAttachedToUI = function () { this.i.onAttachedToUI(); }; /** * Exports visual information about the current state of the grid. */ IgrXLabel.prototype.exportVisualModel = function () { var iv = this.i.aw(); return (iv); }; /** * Returns a serialized copy of the exported visual model */ IgrXLabel.prototype.exportSerializedVisualModel = function () { var iv = this.i.bm(); return (iv); }; return IgrXLabel; }(IgrXInputGroupItem)); export { IgrXLabel };