UNPKG

igniteui-webcomponents-inputs

Version:

Ignite UI Web Components inputs components.

385 lines (382 loc) 13.7 kB
import { XRipple } from "./XRipple"; import { brushToString, stringToBrush, ensureBool, initializePropertiesFromCss, NamePatcher, toSpinal, getAllPropertyNames, fromSpinal } from "igniteui-webcomponents-core"; import { WebComponentRenderer } from "igniteui-webcomponents-core"; import { TypeRegistrar } from "igniteui-webcomponents-core"; import { RegisterElementHelper } from "igniteui-webcomponents-core"; import { IgcHTMLElement } from "igniteui-webcomponents-core"; export let IgcXRippleComponent = /*@__PURE__*/ (() => { class IgcXRippleComponent extends IgcHTMLElement { set height(value) { this._height = value; this.style.height = value; } get height() { return this._height; } set width(value) { this._width = value; this.style.width = value; } get width() { return this._width; } set top(value) { this._top = value; this.style.top = value; } get top() { return this._top; } set left(value) { this._left = value; this.style.left = value; } get left() { return this._left; } set position(value) { this._position = value; this.style.position = value; } get position() { return this._position; } constructor() { super(); this._disconnected = false; this._settingAttributes = false; this._attached = false; this._queuedSetAttributes = []; this._updatingFromAttribute = false; this.__p = null; this._hasUserValues = new Set(); this._stylingContainer = null; this._stylingParent = null; this._inStyling = false; if (this._styling) { NamePatcher.ensureStylablePatched(Object.getPrototypeOf(this)); } this._renderer = new WebComponentRenderer(this, document, true, {}); this._implementation = this.createImplementation(); this._implementation.externalObject = this; this._container = this._renderer.createElement("div"); this._renderer.updateRoot(this._container); //this._renderer.rootWrapper.append(this._container); this._container.setStyleProperty("display", "inline-block"); //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 Ripple = this.i; this._ripple = Ripple; Ripple.provideContainer(this._renderer); //Ripple.notifySizeChanged(); //let mut = new MutationObserver((list) => { // for (var mutation of list) { // if (mutation.type == 'childList') { // this.updateContentStyleMappings(); // } // } //}); //mut.observe(this, { // childList: true //}); //this._renderer.addSizeWatcher(() => { // this._ripple.notifySizeChanged(); //}); } // supports angular themes or custom properties set in CSS updateStyle() { this._styling(this, this); } destroy() { this._ripple.destroy(); this._wrapper.destroy(); } createImplementation() { return new XRipple(); } 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-x-ripple"); this.classList.add("igc-x-ripple"); this.appendChild(this._renderer.rootWrapper.getNativeElement()); this._attached = true; this.style.display = "inline-block"; //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.notifySizeChanged(); } /** * @hidden */ get i() { return this._implementation; } /** * @hidden */ static _createFromInternal(internal) { if (!internal) { return null; } if (!internal.$type) { return null; } let name = internal.$type.name; let externalName = "Igc" + name + "Component"; if (!TypeRegistrar.isRegistered(externalName)) { return null; } return TypeRegistrar.create(externalName); } _enqueueSetAttribute(attrName, attrValue) { this._queuedSetAttributes.push({ attrName: attrName, attrValue: attrValue }); } _flushQueuedAttributes() { this._settingAttributes = true; for (let i = 0; i < this._queuedSetAttributes.length; i++) { this.setAttribute(this._queuedSetAttributes[i].attrName, this._queuedSetAttributes[i].attrValue); } this._settingAttributes = false; this._queuedSetAttributes.length = 0; } _a(attrName, attrValue) { if (this._updatingFromAttribute) { return; } if (attrValue) { attrValue = attrValue.toString(); } this._settingAttributes = true; attrName = toSpinal(attrName); if (this._attached) { this.setAttribute(attrName, attrValue); } else { this._enqueueSetAttribute(attrName, attrValue); } this._settingAttributes = false; } static get observedAttributes() { if (IgcXRippleComponent._observedAttributesIgcXRippleComponent == null) { let names = getAllPropertyNames(IgcXRippleComponent); for (let i = 0; i < names.length; i++) { names[i] = toSpinal(names[i]); } IgcXRippleComponent._observedAttributesIgcXRippleComponent = names; } return IgcXRippleComponent._observedAttributesIgcXRippleComponent; } attributeChangedCallback(name, oldValue, newValue) { if (this._settingAttributes) { return; } let setName = fromSpinal(name); this._updatingFromAttribute = true; this[setName] = newValue; this._updatingFromAttribute = false; } static register() { if (!IgcXRippleComponent._isElementRegistered) { IgcXRippleComponent._isElementRegistered = true; RegisterElementHelper.registerElement(IgcXRippleComponent.htmlTagName, IgcXRippleComponent); } } /** * Gets or sets the target element to inject ripples into. */ get eventSource() { return this.i.q; } set eventSource(v) { this.i.q = v; } /** * Gets or sets the color to use for the background when the checkbox is unchecked. */ get rippleColor() { return brushToString(this.i.ax); } set rippleColor(v) { this.i.ax = stringToBrush(v); this._a("rippleColor", brushToString(this.i.ax)); } /** * Gets or sets the color to use for the background when the ripple is hovered. */ get hoverColor() { return brushToString(this.i.aw); } set hoverColor(v) { this.i.aw = stringToBrush(v); this._a("hoverColor", brushToString(this.i.aw)); } /** * Gets or sets the actual color to use for the background when the ripple is hovered. */ get actualHoverColor() { return brushToString(this.i.as); } set actualHoverColor(v) { this.i.as = stringToBrush(v); this._a("actualHoverColor", brushToString(this.i.as)); } /** * Gets or sets the color to use for the actual background when the checkbox is unchecked. */ get actualRippleColor() { return brushToString(this.i.at); } set actualRippleColor(v) { this.i.at = stringToBrush(v); this._a("actualRippleColor", brushToString(this.i.at)); } /** * Gets or sets the duration to use for the ripple animation. */ get rippleDuration() { return this.i.o; } set rippleDuration(v) { this.i.o = +v; this._a("rippleDuration", this.i.o); } /** * Gets or sets if the ripple is disabled. */ get isDisabled() { return this.i.i; } set isDisabled(v) { this.i.i = ensureBool(v); this._a("isDisabled", this.i.i); } /** * Gets or sets if the ripple is centered. */ get isCentered() { return this.i.h; } set isCentered(v) { this.i.h = ensureBool(v); this._a("isCentered", this.i.h); } /** * Gets or sets if the ripple is centered. */ get isHoverEnabled() { return this.i.k; } set isHoverEnabled(v) { this.i.k = ensureBool(v); this._a("isHoverEnabled", this.i.k); } findByName(name) { if (this.findEphemera) { if (name && name.indexOf("@@e:") == 0) { return this.findEphemera(name); } } return null; } get hasUserValues() { return this._hasUserValues; } __m(propertyName) { if (!this._inStyling) { this._hasUserValues.add(propertyName); } } _styling(container, component, parent) { if (this._inStyling) { return; } this._inStyling = true; this._stylingContainer = container; this._stylingParent = component; let genericPrefix = ""; let typeName = this.i.$type.name; if (typeName.indexOf("Xam") === 0) { typeName = typeName.substring(3); } genericPrefix = toSpinal("XRippleComponent"); let additionalPrefixes = []; let prefix = toSpinal(typeName); additionalPrefixes.push(prefix + "-"); let b = this.i.$type.baseType; while (b && b.name != "Object" && b.name != "Base" && b.name != "Control" && b.Name != "DependencyObject" && b.Name != "FrameworkElement") { typeName = b.name; if (typeName.indexOf("Xam") === 0) { typeName = typeName.substring(3); } let basePrefix = toSpinal(typeName); additionalPrefixes.push(basePrefix + "-"); b = b.baseType; } if (parent) { let parentTypeName = parent.i.$type.name; if (parentTypeName.indexOf("Xam") === 0) { parentTypeName = parentTypeName.substring(3); } let parentPrefix = toSpinal(parentTypeName); additionalPrefixes.push(parentPrefix + "-" + genericPrefix + "-"); additionalPrefixes.push(parentPrefix + "-" + prefix + "-"); } initializePropertiesFromCss(container, this, genericPrefix + "-", this.hasUserValues, false, additionalPrefixes); if (this._otherStyling) { this._otherStyling(container, component, parent); } this._inStyling = false; } onDetachedFromUI() { this.i.onDetachedFromUI(); } onAttachedToUI() { this.i.onAttachedToUI(); } /** * Exports visual information about the current state of the grid. */ exportVisualModel() { let iv = this.i.r(); return (iv); } /** * Returns a serialized copy of the exported visual model */ exportSerializedVisualModel() { let iv = this.i.v(); return (iv); } } IgcXRippleComponent._observedAttributesIgcXRippleComponent = null; IgcXRippleComponent.htmlTagName = "igc-x-ripple"; IgcXRippleComponent._isElementRegistered = false; return IgcXRippleComponent; })();