UNPKG

igniteui-webcomponents-inputs

Version:

Ignite UI Web Components inputs components.

512 lines (509 loc) 18.9 kB
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"; let IgcXCalendarComponent = /*@__PURE__*/ (() => { class IgcXCalendarComponent extends IgcHTMLElement { set height(value) { this._height = value; this.style.height = value; this.i.notifySizeChanged(); } get height() { return this._height; } set width(value) { this._width = value; this.style.width = value; this.i.notifySizeChanged(); } get width() { return this._width; } 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; 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(() => { this._calendar.notifySizeChanged(); }); } // supports angular themes or custom properties set in CSS updateStyle() { this._styling(this, this); } destroy() { this._calendar.destroy(); } createImplementation() { return new XCalendar(); } disconnectedCallback() { this._disconnected = true; } connectedCallback() { 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(); } 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 (IgcXCalendarComponent._observedAttributesIgcXCalendarComponent == null) { let names = getAllPropertyNames(IgcXCalendarComponent); for (let i = 0; i < names.length; i++) { names[i] = toSpinal(names[i]); } IgcXCalendarComponent._observedAttributesIgcXCalendarComponent = names; } return IgcXCalendarComponent._observedAttributesIgcXCalendarComponent; } attributeChangedCallback(name, oldValue, newValue) { if (this._settingAttributes) { return; } let setName = fromSpinal(name); this._updatingFromAttribute = true; this[setName] = newValue; this._updatingFromAttribute = false; } static register() { if (!IgcXCalendarComponent._isElementRegistered) { IgcXCalendarComponent._isElementRegistered = true; RegisterElementHelper.registerElement(IgcXCalendarComponent.htmlTagName, IgcXCalendarComponent); } } /** * Gets or Sets the value for the calendar. */ get value() { return this.i.value; } set value(v) { this.i.value = v; } /** * Gets or Sets the property name that contains the values. */ get today() { return this.i.av; } set today(v) { this.i.av = v; } /** * Gets or Sets the property name that contains the MinDate. */ get minDate() { return this.i.au; } set minDate(v) { this.i.au = v; } /** * Gets or Sets the property name that contains the MaxDate. */ get maxDate() { return this.i.at; } set maxDate(v) { this.i.at = v; } /** * Gets or sets the display density to use for the calendar. */ 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 or sets the base built in theme to use for the calendar. */ get baseTheme() { return this.i.r; } set baseTheme(v) { this.i.r = ensureEnum(BaseControlTheme_$type, v); this._a("baseTheme", enumToString(BaseControlTheme_$type, this.i.r)); } /** * Gets or Sets the selected date background color */ get backgroundColor() { return brushToString(this.i.dg); } set backgroundColor(v) { this.i.dg = stringToBrush(v); this._a("backgroundColor", brushToString(this.i.dg)); } /** * Gets or Sets the selected date background color */ get selectedDateBackgroundColor() { return brushToString(this.i.dm); } set selectedDateBackgroundColor(v) { this.i.dm = stringToBrush(v); this._a("selectedDateBackgroundColor", brushToString(this.i.dm)); } /** * Gets or Sets the selected date background color */ get selectedFocusDateBackgroundColor() { return brushToString(this.i.dp); } set selectedFocusDateBackgroundColor(v) { this.i.dp = stringToBrush(v); this._a("selectedFocusDateBackgroundColor", brushToString(this.i.dp)); } /** * Gets or Sets the focus date background color */ get focusDateBackgroundColor() { return brushToString(this.i.dj); } set focusDateBackgroundColor(v) { this.i.dj = stringToBrush(v); this._a("focusDateBackgroundColor", brushToString(this.i.dj)); } /** * Gets or Sets the focus date background color */ get hoverBackgroundColor() { return brushToString(this.i.dl); } set hoverBackgroundColor(v) { this.i.dl = stringToBrush(v); this._a("hoverBackgroundColor", brushToString(this.i.dl)); } /** * Gets or Sets the selected date text color */ get textColor() { return brushToString(this.i.dq); } set textColor(v) { this.i.dq = stringToBrush(v); this._a("textColor", brushToString(this.i.dq)); } /** * Gets or Sets the selected date text color */ get selectedDateTextColor() { return brushToString(this.i.dn); } set selectedDateTextColor(v) { this.i.dn = stringToBrush(v); this._a("selectedDateTextColor", brushToString(this.i.dn)); } /** * Gets or Sets the focus date text color */ get focusDateTextColor() { return brushToString(this.i.dk); } set focusDateTextColor(v) { this.i.dk = stringToBrush(v); this._a("focusDateTextColor", brushToString(this.i.dk)); } /** * Gets or Sets the current date text color */ get currentDateTextColor() { return brushToString(this.i.di); } set currentDateTextColor(v) { this.i.di = stringToBrush(v); this._a("currentDateTextColor", brushToString(this.i.di)); } /** * Gets or Sets the current date text color */ get currentDateBorderColor() { return brushToString(this.i.dh); } set currentDateBorderColor(v) { this.i.dh = stringToBrush(v); this._a("currentDateBorderColor", brushToString(this.i.dh)); } /** * Gets or sets the ShowTodayButton property to detirmine if the today button is shown */ get showTodayButton() { return this.i.ae; } set showTodayButton(v) { this.i.ae = ensureBool(v); this._a("showTodayButton", this.i.ae); } /** * Gets or sets the font to use for the combobox. */ get textStyle() { if (this.i.v == null) { return null; } return this.i.v.fontString; } set textStyle(v) { let fi = new FontInfo(); fi.fontString = v; this.i.v = fi; this._a("textStyle", this.i.v != null ? this.i.v.fontString : ""); } /** * Gets or sets the FirstDayOfWeek property to detirmine first day of the week */ get firstDayOfWeek() { return this.i.l; } set firstDayOfWeek(v) { this.i.l = ensureEnum(DayOfWeek_$type, v); this._a("firstDayOfWeek", enumToString(DayOfWeek_$type, this.i.l)); } /** * Gets or sets the FirstWeekOfYear property to detirmine first week of the year */ get firstWeekOfYear() { return this.i.o; } set firstWeekOfYear(v) { this.i.o = ensureEnum(FirstWeek_$type, v); this._a("firstWeekOfYear", enumToString(FirstWeek_$type, this.i.o)); } /** * Gets or sets the ShowWeekNumbers property to detirmine if the week numbers are shown */ get showWeekNumbers() { return this.i.af; } set showWeekNumbers(v) { this.i.af = ensureBool(v); this._a("showWeekNumbers", this.i.af); } 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("XCalendarComponent"); 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; } /** * Exports visual information about the current state of the grid. */ exportVisualModel() { let iv = this.i.bj(); return (iv); } /** * Returns a serialized copy of the exported visual model */ exportSerializedVisualModel() { let iv = this.i.bs(); return (iv); } /** * Called when date is selected. */ get selectedValueChanged() { return this._selectedValueChanged; } set selectedValueChanged(ev) { 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 = (o, e) => { let 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); ; } get valueChange() { return this._valueChange; } set valueChange(ev) { 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 = (o, e) => { let 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); } } IgcXCalendarComponent._observedAttributesIgcXCalendarComponent = null; IgcXCalendarComponent.htmlTagName = "igc-x-calendar"; IgcXCalendarComponent._isElementRegistered = false; return IgcXCalendarComponent; })(); export { IgcXCalendarComponent };