UNPKG

igniteui-webcomponents-inputs

Version:

Ignite UI Web Components inputs components.

626 lines (623 loc) 22.8 kB
import { __extends } from "tslib"; import { ensureEnum, brushToString, stringToBrush, ensureBool, initializePropertiesFromCss, NamePatcher, toSpinal, enumToString, getAllPropertyNames, fromSpinal } from "igniteui-webcomponents-core"; import { FontInfo } from "igniteui-webcomponents-core"; import { WebComponentRenderer } from "igniteui-webcomponents-core"; import { delegateCombine, delegateRemove } from "igniteui-webcomponents-core"; import { TypeRegistrar } from "igniteui-webcomponents-core"; import { RegisterElementHelper } from "igniteui-webcomponents-core"; import { XCalendar } from './XCalendar'; import { IgcSelectedValueChangedEventArgs } from "./igc-selected-value-changed-event-args"; import { ControlDisplayDensity_$type } from "igniteui-webcomponents-core"; import { BaseControlTheme_$type } from "igniteui-webcomponents-core"; import { DayOfWeek_$type } from "./DayOfWeek"; import { FirstWeek_$type } from "./FirstWeek"; import { IgcHTMLElement } from "igniteui-webcomponents-core"; export var IgcXCalendarComponent = /** @class */ /*@__PURE__*/ (function (_super) { __extends(IgcXCalendarComponent, _super); function IgcXCalendarComponent() { 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; _this._selectedValueChanged = null; _this._selectedValueChanged_wrapped = null; _this._valueChange = null; _this._valueChange_wrapped = null; if (_this._styling) { NamePatcher.ensureStylablePatched(Object.getPrototypeOf(_this)); } _this._renderer = new WebComponentRenderer(_this, document, true, null); _this._implementation = _this.createImplementation(); _this._container = _this._renderer.createElement("div"); _this._renderer.updateRoot(_this._container); //this._renderer.rootWrapper.append(this._container); //this._container.setStyleProperty("width", "100%"); //this._container.setStyleProperty("height", "100%"); var calendar = _this.i; _this._calendar = calendar; _this._renderer.addSizeWatcher(function () { _this._calendar.notifySizeChanged(); }); return _this; } Object.defineProperty(IgcXCalendarComponent.prototype, "height", { get: function () { return this._height; }, set: function (value) { this._height = value; this.style.height = value; this.i.notifySizeChanged(); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "width", { get: function () { return this._width; }, set: function (value) { this._width = value; this.style.width = value; this.i.notifySizeChanged(); }, enumerable: false, configurable: true }); // supports angular themes or custom properties set in CSS IgcXCalendarComponent.prototype.updateStyle = function () { this._styling(this, this); }; IgcXCalendarComponent.prototype.destroy = function () { this._calendar.destroy(); }; IgcXCalendarComponent.prototype.createImplementation = function () { return new XCalendar(); }; IgcXCalendarComponent.prototype.disconnectedCallback = function () { this._disconnected = true; }; IgcXCalendarComponent.prototype.connectedCallback = function () { if (this._disconnected) { this._disconnected = false; return; } this.classList.add("ig-x-calendar"); this.classList.add("igc-x-calendar"); var rootWrapper = this._renderer.rootWrapper; var rootElement = rootWrapper.getNativeElement(); this.appendChild(rootElement); this._attached = true; this.style.display = "block"; this.style.height = this._height; this.style.width = this._width; this._calendar.provideContainer(this._renderer); this._calendar.notifySizeChanged(); this._flushQueuedAttributes(); // supports themes or custom properties set in CSS this._styling(this, this); this.afterContentInit(); }; IgcXCalendarComponent.prototype.afterContentInit = function () { this.i.notifySizeChanged(); }; Object.defineProperty(IgcXCalendarComponent.prototype, "i", { /** * @hidden */ get: function () { return this._implementation; } /** * @hidden */, enumerable: false, configurable: true }); IgcXCalendarComponent._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); }; IgcXCalendarComponent.prototype._enqueueSetAttribute = function (attrName, attrValue) { this._queuedSetAttributes.push({ attrName: attrName, attrValue: attrValue }); }; IgcXCalendarComponent.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; }; IgcXCalendarComponent.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(IgcXCalendarComponent, "observedAttributes", { get: function () { if (IgcXCalendarComponent._observedAttributesIgcXCalendarComponent == null) { var names = getAllPropertyNames(IgcXCalendarComponent); for (var i = 0; i < names.length; i++) { names[i] = toSpinal(names[i]); } IgcXCalendarComponent._observedAttributesIgcXCalendarComponent = names; } return IgcXCalendarComponent._observedAttributesIgcXCalendarComponent; }, enumerable: false, configurable: true }); IgcXCalendarComponent.prototype.attributeChangedCallback = function (name, oldValue, newValue) { if (this._settingAttributes) { return; } var setName = fromSpinal(name); this._updatingFromAttribute = true; this[setName] = newValue; this._updatingFromAttribute = false; }; IgcXCalendarComponent.register = function () { if (!IgcXCalendarComponent._isElementRegistered) { IgcXCalendarComponent._isElementRegistered = true; RegisterElementHelper.registerElement(IgcXCalendarComponent.htmlTagName, IgcXCalendarComponent); } }; Object.defineProperty(IgcXCalendarComponent.prototype, "value", { /** * Gets or Sets the value for the calendar. */ get: function () { return this.i.value; }, set: function (v) { this.i.value = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "today", { /** * Gets or Sets the property name that contains the values. */ get: function () { return this.i.av; }, set: function (v) { this.i.av = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "minDate", { /** * Gets or Sets the property name that contains the MinDate. */ get: function () { return this.i.au; }, set: function (v) { this.i.au = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "maxDate", { /** * Gets or Sets the property name that contains the MaxDate. */ get: function () { return this.i.at; }, set: function (v) { this.i.at = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "density", { /** * Gets or sets the display density to use for the calendar. */ get: function () { return this.i.t; }, set: function (v) { this.i.t = ensureEnum(ControlDisplayDensity_$type, v); this._a("density", enumToString(ControlDisplayDensity_$type, this.i.t)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "baseTheme", { /** * Gets or sets the base built in theme to use for the calendar. */ get: function () { return this.i.r; }, set: function (v) { this.i.r = ensureEnum(BaseControlTheme_$type, v); this._a("baseTheme", enumToString(BaseControlTheme_$type, this.i.r)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "backgroundColor", { /** * Gets or Sets the selected date background color */ get: function () { return brushToString(this.i.dg); }, set: function (v) { this.i.dg = stringToBrush(v); this._a("backgroundColor", brushToString(this.i.dg)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "selectedDateBackgroundColor", { /** * Gets or Sets the selected date background color */ get: function () { return brushToString(this.i.dm); }, set: function (v) { this.i.dm = stringToBrush(v); this._a("selectedDateBackgroundColor", brushToString(this.i.dm)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "selectedFocusDateBackgroundColor", { /** * Gets or Sets the selected date background color */ get: function () { return brushToString(this.i.dp); }, set: function (v) { this.i.dp = stringToBrush(v); this._a("selectedFocusDateBackgroundColor", brushToString(this.i.dp)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "focusDateBackgroundColor", { /** * Gets or Sets the focus date background color */ get: function () { return brushToString(this.i.dj); }, set: function (v) { this.i.dj = stringToBrush(v); this._a("focusDateBackgroundColor", brushToString(this.i.dj)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "hoverBackgroundColor", { /** * Gets or Sets the focus date background color */ get: function () { return brushToString(this.i.dl); }, set: function (v) { this.i.dl = stringToBrush(v); this._a("hoverBackgroundColor", brushToString(this.i.dl)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "textColor", { /** * Gets or Sets the selected date text color */ get: function () { return brushToString(this.i.dq); }, set: function (v) { this.i.dq = stringToBrush(v); this._a("textColor", brushToString(this.i.dq)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "selectedDateTextColor", { /** * Gets or Sets the selected date text color */ get: function () { return brushToString(this.i.dn); }, set: function (v) { this.i.dn = stringToBrush(v); this._a("selectedDateTextColor", brushToString(this.i.dn)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "focusDateTextColor", { /** * Gets or Sets the focus date text color */ get: function () { return brushToString(this.i.dk); }, set: function (v) { this.i.dk = stringToBrush(v); this._a("focusDateTextColor", brushToString(this.i.dk)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "currentDateTextColor", { /** * Gets or Sets the current date text color */ get: function () { return brushToString(this.i.di); }, set: function (v) { this.i.di = stringToBrush(v); this._a("currentDateTextColor", brushToString(this.i.di)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "currentDateBorderColor", { /** * Gets or Sets the current date text color */ get: function () { return brushToString(this.i.dh); }, set: function (v) { this.i.dh = stringToBrush(v); this._a("currentDateBorderColor", brushToString(this.i.dh)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "showTodayButton", { /** * Gets or sets the ShowTodayButton property to detirmine if the today button is shown */ get: function () { return this.i.ae; }, set: function (v) { this.i.ae = ensureBool(v); this._a("showTodayButton", this.i.ae); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "textStyle", { /** * Gets or sets the font to use for the combobox. */ get: function () { if (this.i.v == null) { return null; } return this.i.v.fontString; }, set: function (v) { var fi = new FontInfo(); fi.fontString = v; this.i.v = fi; this._a("textStyle", this.i.v != null ? this.i.v.fontString : ""); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "firstDayOfWeek", { /** * Gets or sets the FirstDayOfWeek property to detirmine first day of the week */ get: function () { return this.i.l; }, set: function (v) { this.i.l = ensureEnum(DayOfWeek_$type, v); this._a("firstDayOfWeek", enumToString(DayOfWeek_$type, this.i.l)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "firstWeekOfYear", { /** * Gets or sets the FirstWeekOfYear property to detirmine first week of the year */ get: function () { return this.i.o; }, set: function (v) { this.i.o = ensureEnum(FirstWeek_$type, v); this._a("firstWeekOfYear", enumToString(FirstWeek_$type, this.i.o)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "showWeekNumbers", { /** * Gets or sets the ShowWeekNumbers property to detirmine if the week numbers are shown */ get: function () { return this.i.af; }, set: function (v) { this.i.af = ensureBool(v); this._a("showWeekNumbers", this.i.af); }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "hasUserValues", { get: function () { return this._hasUserValues; }, enumerable: false, configurable: true }); IgcXCalendarComponent.prototype.__m = function (propertyName) { if (!this._inStyling) { this._hasUserValues.add(propertyName); } }; IgcXCalendarComponent.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("XCalendarComponent"); 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; }; /** * Exports visual information about the current state of the grid. */ IgcXCalendarComponent.prototype.exportVisualModel = function () { var iv = this.i.bj(); return (iv); }; /** * Returns a serialized copy of the exported visual model */ IgcXCalendarComponent.prototype.exportSerializedVisualModel = function () { var iv = this.i.bs(); return (iv); }; Object.defineProperty(IgcXCalendarComponent.prototype, "selectedValueChanged", { /** * Called when date is selected. */ get: function () { return this._selectedValueChanged; }, set: function (ev) { var _this = this; if (this._selectedValueChanged_wrapped !== null) { this.i.selectedValueChanged = delegateRemove(this.i.selectedValueChanged, this._selectedValueChanged_wrapped); this._selectedValueChanged_wrapped = null; this._selectedValueChanged = null; } this._selectedValueChanged = ev; this._selectedValueChanged_wrapped = function (o, e) { var outerArgs = new IgcSelectedValueChangedEventArgs(); outerArgs._provideImplementation(e); if (_this.beforeSelectedValueChanged) { _this.beforeSelectedValueChanged(_this, outerArgs); } if (_this._selectedValueChanged) { _this._selectedValueChanged(_this, outerArgs); } }; this.i.selectedValueChanged = delegateCombine(this.i.selectedValueChanged, this._selectedValueChanged_wrapped); ; }, enumerable: false, configurable: true }); Object.defineProperty(IgcXCalendarComponent.prototype, "valueChange", { get: function () { return this._valueChange; }, set: function (ev) { var _this = this; if (this._valueChange_wrapped !== null) { this.i.propertyChanged = delegateRemove(this.i.propertyChanged, this._valueChange_wrapped); this._valueChange_wrapped = null; this._valueChange = null; } this._valueChange = ev; this._valueChange_wrapped = function (o, e) { var ext = _this.value; if (e.propertyName == 'Value') { if (_this.beforeValueChange) { _this.beforeValueChange(_this, ext); } if (_this._valueChange) { _this._valueChange(_this, ext); } } }; this.i.propertyChanged = delegateCombine(this.i.propertyChanged, this._valueChange_wrapped); }, enumerable: false, configurable: true }); IgcXCalendarComponent._observedAttributesIgcXCalendarComponent = null; IgcXCalendarComponent.htmlTagName = "igc-x-calendar"; IgcXCalendarComponent._isElementRegistered = false; return IgcXCalendarComponent; }(IgcHTMLElement));