igniteui-webcomponents-inputs
Version:
Ignite UI Web Components inputs components.
186 lines (183 loc) • 6.63 kB
JavaScript
import { XPrefix } from "./XPrefix";
import { ensureBool, NamePatcher, toSpinal, getAllPropertyNames } 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';
export let IgcXPrefixComponent = /*@__PURE__*/ (() => {
class IgcXPrefixComponent extends IgcXInputGroupItemComponent {
constructor() {
super();
this._disconnected = false;
if (this._styling) {
NamePatcher.ensureStylablePatched(Object.getPrototypeOf(this));
}
this._portalManager = new PortalManager("prefixContent");
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 prefix = this.i;
this._prefix = prefix;
prefix.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._prefix.destroy();
this._wrapper.destroy();
}
createImplementation() {
return new XPrefix();
}
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-prefix");
this.classList.add("igc-x-prefix");
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.notifySizeChanged();
}
/**
* @hidden
*/
get i() {
return this._implementation;
}
static get observedAttributes() {
if (IgcXPrefixComponent._observedAttributesIgcXPrefixComponent == null) {
let names = getAllPropertyNames(IgcXPrefixComponent);
for (let i = 0; i < names.length; i++) {
names[i] = toSpinal(names[i]);
}
IgcXPrefixComponent._observedAttributesIgcXPrefixComponent = names;
}
return IgcXPrefixComponent._observedAttributesIgcXPrefixComponent;
}
static register() {
if (!IgcXPrefixComponent._isElementRegistered) {
IgcXPrefixComponent._isElementRegistered = true;
RegisterElementHelper.registerElement(IgcXPrefixComponent.htmlTagName, IgcXPrefixComponent);
}
}
/**
* Gets or sets the id to use for the checkbox.
*/
get id() {
return this.i.z;
}
set id(v) {
this.i.z = v;
}
/**
* Gets or sets the value of the aria-label attribute.
*/
get ariaLabel() {
return this.i.w;
}
set ariaLabel(v) {
this.i.w = v;
}
/**
* Gets or sets whether the prefix is hovered.
*/
get isHover() {
return this.i.q;
}
set isHover(v) {
this.i.q = ensureBool(v);
this._a("isHover", this.i.q);
}
/**
* 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.t();
return (iv);
}
/**
* Returns a serialized copy of the exported visual model
*/
exportSerializedVisualModel() {
let iv = this.i.y();
return (iv);
}
}
IgcXPrefixComponent._observedAttributesIgcXPrefixComponent = null;
IgcXPrefixComponent.htmlTagName = "igc-x-prefix";
IgcXPrefixComponent._isElementRegistered = false;
return IgcXPrefixComponent;
})();