UNPKG

igniteui-webcomponents-inputs

Version:

Ignite UI Web Components inputs components.

413 lines (410 loc) 13.5 kB
import { XLabel } from "./XLabel"; import { ensureEnum, brushToString, stringToBrush, ensureBool, NamePatcher, toSpinal, enumToString, getAllPropertyNames } from "igniteui-webcomponents-core"; import { FontInfo } from "igniteui-webcomponents-core"; import { WebComponentRenderer, PortalManager } from "igniteui-webcomponents-core"; import { RegisterElementHelper } from "igniteui-webcomponents-core"; import { IgcXInputGroupItemComponent } from './igc-x-input-group-item-component'; import { ControlDisplayDensity_$type } from "igniteui-webcomponents-core"; import { BaseControlTheme_$type } from "igniteui-webcomponents-core"; export let IgcXLabelComponent = /*@__PURE__*/ (() => { class IgcXLabelComponent extends IgcXInputGroupItemComponent { constructor() { super(); this._disconnected = false; if (this._styling) { NamePatcher.ensureStylablePatched(Object.getPrototypeOf(this)); } this._portalManager = new PortalManager("labelContent"); this._renderer = new WebComponentRenderer(this, document, true, {}, this._portalManager); this._container = this._renderer.createElement("div"); this._renderer.updateRoot(this._container); this._implementation = this.createImplementation(); this._implementation.externalObject = this; //this._container.setStyleProperty("width", "100%"); //this._container.setStyleProperty("height", "100%"); var root; root = this._container; if (this._container.getNativeElement() != null) { root = this._container.getNativeElement(); } this._wrapper = this._renderer; var label = this.i; this._label = label; label.provideContainer(this._renderer); this._onChildrenChanged(); //Checkbox.notifySizeChanged(); let mut = new MutationObserver((list) => { for (var mutation of list) { if (mutation.type == 'childList') { this._onChildrenChanged(); } } }); mut.observe(this, { childList: true }); //this._renderer.addSizeWatcher(() => { // this._checkbox.notifySizeChanged(); //}); } _onChildrenChanged() { var children = []; for (var i = 0; i < this.childNodes.length; i++) { var child = this.childNodes[i]; if (child !== this._container.getNativeElement()) { children.push(child); } } this._portalManager.onChildrenChanged(children); } // supports angular themes or custom properties set in CSS updateStyle() { this._styling(this, this); } destroy() { this._label.destroy(); this._wrapper.destroy(); } createImplementation() { return new XLabel(); } disconnectedCallback() { this._disconnected = true; if (this.i) { this.i.onDetachedFromUI(); } } connectedCallback() { if (this._disconnected) { this._disconnected = false; if (this.i) { this.i.onAttachedToUI(); } return; } this.classList.add("ig-label"); this.classList.add("igc-label"); this.appendChild(this._container.getNativeElement()); this._attached = true; this.style.display = "inline-block"; this.style.verticalAlign = "middle"; //this.style.height = this._height; //this.style.width = this._width; this._flushQueuedAttributes(); // supports themes or custom properties set in CSS this._styling(this, this); this.afterContentInit(); } afterContentInit() { this.i.onSizeReady(); //this.i.notifySizeChanged(); } _onDisplayChanged() { this.style.display = this.display; } _onFlexDirectionChanged() { this.style.flexDirection = this.flexDirection; } _onFlexGrowChanged() { this.style.flexGrow = this.flexGrow; } _onAlignItemsChanged() { this.style.alignItems = this.alignItems; } _onAlignSelfChanged() { this.style.alignSelf = this.alignSelf; } /** * @hidden */ get i() { return this._implementation; } static get observedAttributes() { if (IgcXLabelComponent._observedAttributesIgcXLabelComponent == null) { let names = getAllPropertyNames(IgcXLabelComponent); for (let i = 0; i < names.length; i++) { names[i] = toSpinal(names[i]); } IgcXLabelComponent._observedAttributesIgcXLabelComponent = names; } return IgcXLabelComponent._observedAttributesIgcXLabelComponent; } static register() { if (!IgcXLabelComponent._isElementRegistered) { IgcXLabelComponent._isElementRegistered = true; RegisterElementHelper.registerElement(IgcXLabelComponent.htmlTagName, IgcXLabelComponent); } } /** * Gets or sets the base built in theme to use for the label. */ get baseTheme() { return this.i.p; } set baseTheme(v) { this.i.p = ensureEnum(BaseControlTheme_$type, v); this._a("baseTheme", enumToString(BaseControlTheme_$type, this.i.p)); } /** * Gets or sets the display density to use for the label. */ get density() { return this.i.t; } set density(v) { this.i.t = ensureEnum(ControlDisplayDensity_$type, v); this._a("density", enumToString(ControlDisplayDensity_$type, this.i.t)); } /** * Gets the actual display density to use for the label. */ get actualDensity() { return this.i.s; } set actualDensity(v) { this.i.s = ensureEnum(ControlDisplayDensity_$type, v); this._a("actualDensity", enumToString(ControlDisplayDensity_$type, this.i.s)); } /** * Gets the actual color to use for the text color. */ get actualTextColor() { return brushToString(this.i.c3); } set actualTextColor(v) { this.i.c3 = stringToBrush(v); this._a("actualTextColor", brushToString(this.i.c3)); } /** * Gets the actual color to use for the text color. */ get actualHighlightTextColor() { return brushToString(this.i.c0); } set actualHighlightTextColor(v) { this.i.c0 = stringToBrush(v); this._a("actualHighlightTextColor", brushToString(this.i.c0)); } /** * Gets the actual color to use for the text color when highlighted and hovered. */ get actualHoverHighlightTextColor() { return brushToString(this.i.c1); } set actualHoverHighlightTextColor(v) { this.i.c1 = stringToBrush(v); this._a("actualHoverHighlightTextColor", brushToString(this.i.c1)); } /** * Gets the actual hover color to use for the text. */ get actualHoverTextColor() { return brushToString(this.i.c2); } set actualHoverTextColor(v) { this.i.c2 = stringToBrush(v); this._a("actualHoverTextColor", brushToString(this.i.c2)); } /** * Gets or sets the color to use for the text. */ get textColor() { return brushToString(this.i.dj); } set textColor(v) { this.i.dj = stringToBrush(v); this._a("textColor", brushToString(this.i.dj)); } /** * Gets or sets the color to use for the text. */ get highlightTextColor() { return brushToString(this.i.dg); } set highlightTextColor(v) { this.i.dg = stringToBrush(v); this._a("highlightTextColor", brushToString(this.i.dg)); } /** * Gets or sets the color to use for the text. */ get hoverHighlightTextColor() { return brushToString(this.i.dh); } set hoverHighlightTextColor(v) { this.i.dh = stringToBrush(v); this._a("hoverHighlightTextColor", brushToString(this.i.dh)); } /** * Gets or sets the use for the button. */ get textStyle() { if (this.i.y == null) { return null; } return this.i.y.fontString; } set textStyle(v) { let fi = new FontInfo(); fi.fontString = v; this.i.y = fi; this._a("textStyle", this.i.y != null ? this.i.y.fontString : ""); } /** * Gets or sets the color to use for the hovered text of the button regardless of type. */ get hoverTextColor() { return brushToString(this.i.di); } set hoverTextColor(v) { this.i.di = stringToBrush(v); this._a("hoverTextColor", brushToString(this.i.di)); } /** * Gets or sets the id to use for the checkbox. */ get id() { return this.i.bw; } set id(v) { this.i.bw = v; } /** * Gets or sets the id to use for the checkbox. */ get display() { return this.i.bk; } set display(v) { this.i.bk = v; } /** * Gets or sets the id to use for the checkbox. */ get flexDirection() { return this.i.bn; } set flexDirection(v) { this.i.bn = v; } /** * Gets or sets the flex-grow setting for the button. */ get flexGrow() { return this.i.bp; } set flexGrow(v) { this.i.bp = v; } /** * Gets or sets the id to use for the checkbox. */ get alignItems() { return this.i.bc; } set alignItems(v) { this.i.bc = v; } /** * Gets or sets the id to use for the checkbox. */ get alignSelf() { return this.i.be; } set alignSelf(v) { this.i.be = v; } /** * Gets or sets TabIndex to use for the checkbox. */ get tabIndex() { return this.i.au; } set tabIndex(v) { this.i.au = +v; this._a("tabIndex", this.i.au); } /** * Gets or sets the for attribute to use for the label. */ get for() { return this.i.br; } set for(v) { this.i.br = v; } /** * Gets or sets the value of the aria-label attribute. */ get ariaLabel() { return this.i.bg; } set ariaLabel(v) { this.i.bg = v; } /** * Gets or sets the text for the label. */ get text() { return this.i.text; } set text(v) { this.i.text = v; } /** * Gets or sets whether the label is hovered. */ get isHover() { return this.i.ao; } set isHover(v) { this.i.ao = ensureBool(v); this._a("isHover", this.i.ao); } /** * Gets or sets the value for the label. */ get value() { return this.i.as; } set value(v) { this.i.as = ensureBool(v); this._a("value", this.i.as); } /** * Gets or sets whether the checkbox is disabled. */ get disabled() { return this.i.disabled; } set disabled(v) { this.i.disabled = ensureBool(v); this._a("disabled", this.i.disabled); } onDetachedFromUI() { this.i.onDetachedFromUI(); } onAttachedToUI() { this.i.onAttachedToUI(); } /** * Exports visual information about the current state of the grid. */ exportVisualModel() { let iv = this.i.aw(); return (iv); } /** * Returns a serialized copy of the exported visual model */ exportSerializedVisualModel() { let iv = this.i.bm(); return (iv); } } IgcXLabelComponent._observedAttributesIgcXLabelComponent = null; IgcXLabelComponent.htmlTagName = "igc-x-label"; IgcXLabelComponent._isElementRegistered = false; return IgcXLabelComponent; })();