igniteui-webcomponents-inputs
Version:
Ignite UI Web Components inputs components.
455 lines (452 loc) • 16.1 kB
JavaScript
import { __extends } from "tslib";
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";
var IgcXRippleComponent = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(IgcXRippleComponent, _super);
function IgcXRippleComponent() {
var _this = _super.call(this) || this;
_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);
return _this;
//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();
//});
}
Object.defineProperty(IgcXRippleComponent.prototype, "height", {
get: function () {
return this._height;
},
set: function (value) {
this._height = value;
this.style.height = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcXRippleComponent.prototype, "width", {
get: function () {
return this._width;
},
set: function (value) {
this._width = value;
this.style.width = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcXRippleComponent.prototype, "top", {
get: function () {
return this._top;
},
set: function (value) {
this._top = value;
this.style.top = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcXRippleComponent.prototype, "left", {
get: function () {
return this._left;
},
set: function (value) {
this._left = value;
this.style.left = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcXRippleComponent.prototype, "position", {
get: function () {
return this._position;
},
set: function (value) {
this._position = value;
this.style.position = value;
},
enumerable: false,
configurable: true
});
// supports angular themes or custom properties set in CSS
IgcXRippleComponent.prototype.updateStyle = function () {
this._styling(this, this);
};
IgcXRippleComponent.prototype.destroy = function () {
this._ripple.destroy();
this._wrapper.destroy();
};
IgcXRippleComponent.prototype.createImplementation = function () {
return new XRipple();
};
IgcXRippleComponent.prototype.disconnectedCallback = function () {
this._disconnected = true;
if (this.i) {
this.i.onDetachedFromUI();
}
};
IgcXRippleComponent.prototype.connectedCallback = function () {
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();
};
IgcXRippleComponent.prototype.afterContentInit = function () {
//this.i.notifySizeChanged();
};
Object.defineProperty(IgcXRippleComponent.prototype, "i", {
/**
* @hidden
*/
get: function () {
return this._implementation;
} /**
* @hidden
*/,
enumerable: false,
configurable: true
});
IgcXRippleComponent._createFromInternal = function (internal) {
if (!internal) {
return null;
}
if (!internal.$type) {
return null;
}
var name = internal.$type.name;
var externalName = "Igc" + name + "Component";
if (!TypeRegistrar.isRegistered(externalName)) {
return null;
}
return TypeRegistrar.create(externalName);
};
IgcXRippleComponent.prototype._enqueueSetAttribute = function (attrName, attrValue) {
this._queuedSetAttributes.push({ attrName: attrName, attrValue: attrValue });
};
IgcXRippleComponent.prototype._flushQueuedAttributes = function () {
this._settingAttributes = true;
for (var i = 0; i < this._queuedSetAttributes.length; i++) {
this.setAttribute(this._queuedSetAttributes[i].attrName, this._queuedSetAttributes[i].attrValue);
}
this._settingAttributes = false;
this._queuedSetAttributes.length = 0;
};
IgcXRippleComponent.prototype._a = function (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;
};
Object.defineProperty(IgcXRippleComponent, "observedAttributes", {
get: function () {
if (IgcXRippleComponent._observedAttributesIgcXRippleComponent == null) {
var names = getAllPropertyNames(IgcXRippleComponent);
for (var i = 0; i < names.length; i++) {
names[i] = toSpinal(names[i]);
}
IgcXRippleComponent._observedAttributesIgcXRippleComponent = names;
}
return IgcXRippleComponent._observedAttributesIgcXRippleComponent;
},
enumerable: false,
configurable: true
});
IgcXRippleComponent.prototype.attributeChangedCallback = function (name, oldValue, newValue) {
if (this._settingAttributes) {
return;
}
var setName = fromSpinal(name);
this._updatingFromAttribute = true;
this[setName] = newValue;
this._updatingFromAttribute = false;
};
IgcXRippleComponent.register = function () {
if (!IgcXRippleComponent._isElementRegistered) {
IgcXRippleComponent._isElementRegistered = true;
RegisterElementHelper.registerElement(IgcXRippleComponent.htmlTagName, IgcXRippleComponent);
}
};
Object.defineProperty(IgcXRippleComponent.prototype, "eventSource", {
/**
* Gets or sets the target element to inject ripples into.
*/
get: function () {
return this.i.q;
},
set: function (v) {
this.i.q = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcXRippleComponent.prototype, "rippleColor", {
/**
* Gets or sets the color to use for the background when the checkbox is unchecked.
*/
get: function () {
return brushToString(this.i.ax);
},
set: function (v) {
this.i.ax = stringToBrush(v);
this._a("rippleColor", brushToString(this.i.ax));
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcXRippleComponent.prototype, "hoverColor", {
/**
* Gets or sets the color to use for the background when the ripple is hovered.
*/
get: function () {
return brushToString(this.i.aw);
},
set: function (v) {
this.i.aw = stringToBrush(v);
this._a("hoverColor", brushToString(this.i.aw));
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcXRippleComponent.prototype, "actualHoverColor", {
/**
* Gets or sets the actual color to use for the background when the ripple is hovered.
*/
get: function () {
return brushToString(this.i.as);
},
set: function (v) {
this.i.as = stringToBrush(v);
this._a("actualHoverColor", brushToString(this.i.as));
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcXRippleComponent.prototype, "actualRippleColor", {
/**
* Gets or sets the color to use for the actual background when the checkbox is unchecked.
*/
get: function () {
return brushToString(this.i.at);
},
set: function (v) {
this.i.at = stringToBrush(v);
this._a("actualRippleColor", brushToString(this.i.at));
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcXRippleComponent.prototype, "rippleDuration", {
/**
* Gets or sets the duration to use for the ripple animation.
*/
get: function () {
return this.i.o;
},
set: function (v) {
this.i.o = +v;
this._a("rippleDuration", this.i.o);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcXRippleComponent.prototype, "isDisabled", {
/**
* Gets or sets if the ripple is disabled.
*/
get: function () {
return this.i.i;
},
set: function (v) {
this.i.i = ensureBool(v);
this._a("isDisabled", this.i.i);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcXRippleComponent.prototype, "isCentered", {
/**
* Gets or sets if the ripple is centered.
*/
get: function () {
return this.i.h;
},
set: function (v) {
this.i.h = ensureBool(v);
this._a("isCentered", this.i.h);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcXRippleComponent.prototype, "isHoverEnabled", {
/**
* Gets or sets if the ripple is centered.
*/
get: function () {
return this.i.k;
},
set: function (v) {
this.i.k = ensureBool(v);
this._a("isHoverEnabled", this.i.k);
},
enumerable: false,
configurable: true
});
IgcXRippleComponent.prototype.findByName = function (name) {
if (this.findEphemera) {
if (name && name.indexOf("@@e:") == 0) {
return this.findEphemera(name);
}
}
return null;
};
Object.defineProperty(IgcXRippleComponent.prototype, "hasUserValues", {
get: function () {
return this._hasUserValues;
},
enumerable: false,
configurable: true
});
IgcXRippleComponent.prototype.__m = function (propertyName) {
if (!this._inStyling) {
this._hasUserValues.add(propertyName);
}
};
IgcXRippleComponent.prototype._styling = function (container, component, parent) {
if (this._inStyling) {
return;
}
this._inStyling = true;
this._stylingContainer = container;
this._stylingParent = component;
var genericPrefix = "";
var typeName = this.i.$type.name;
if (typeName.indexOf("Xam") === 0) {
typeName = typeName.substring(3);
}
genericPrefix = toSpinal("XRippleComponent");
var additionalPrefixes = [];
var prefix = toSpinal(typeName);
additionalPrefixes.push(prefix + "-");
var 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);
}
var basePrefix = toSpinal(typeName);
additionalPrefixes.push(basePrefix + "-");
b = b.baseType;
}
if (parent) {
var parentTypeName = parent.i.$type.name;
if (parentTypeName.indexOf("Xam") === 0) {
parentTypeName = parentTypeName.substring(3);
}
var 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;
};
IgcXRippleComponent.prototype.onDetachedFromUI = function () {
this.i.onDetachedFromUI();
};
IgcXRippleComponent.prototype.onAttachedToUI = function () {
this.i.onAttachedToUI();
};
/**
* Exports visual information about the current state of the grid.
*/
IgcXRippleComponent.prototype.exportVisualModel = function () {
var iv = this.i.r();
return (iv);
};
/**
* Returns a serialized copy of the exported visual model
*/
IgcXRippleComponent.prototype.exportSerializedVisualModel = function () {
var iv = this.i.v();
return (iv);
};
IgcXRippleComponent._observedAttributesIgcXRippleComponent = null;
IgcXRippleComponent.htmlTagName = "igc-x-ripple";
IgcXRippleComponent._isElementRegistered = false;
return IgcXRippleComponent;
}(IgcHTMLElement));
export { IgcXRippleComponent };