UNPKG

igniteui-react-inputs

Version:

Ignite UI React input components.

780 lines (777 loc) 26.3 kB
import { __extends, __values } from "tslib"; import * as React from 'react'; import { ensureEnum, brushToString, stringToBrush, ensureBool, initializePropertiesFromCss, NamePatcher, isValidProp, toSpinal, getModifiedProps } from "igniteui-react-core"; import { FontInfo } from "igniteui-react-core"; import { ReactRenderer } from "igniteui-react-core"; import { delegateCombine, delegateRemove } from "igniteui-react-core"; import { XDatePicker } from './XDatePicker'; import { IgrSelectedValueChangedEventArgs } from "./igr-selected-value-changed-event-args"; import { IgrGotFocusEventArgs } from "./igr-got-focus-event-args"; import { IgrLostFocusEventArgs } from "./igr-lost-focus-event-args"; import { IgrInputChangeEventArgs } from "./igr-input-change-event-args"; import { IgrKeyEventArgs } from "igniteui-react-core"; import { ControlDisplayDensity_$type } from "igniteui-react-core"; import { BaseControlTheme_$type } from "igniteui-react-core"; import { DateFormats_$type } from "./DateFormats"; import { DayOfWeek_$type } from "./DayOfWeek"; import { FirstWeek_$type } from "./FirstWeek"; var IgrXDatePicker = /** @class */ /*@__PURE__*/ (function (_super) { __extends(IgrXDatePicker, _super); function IgrXDatePicker(props) { var _this = _super.call(this, props) || this; _this._implementation = null; _this.__p = null; _this._hasUserValues = new Set(); _this._stylingContainer = null; _this._stylingParent = null; _this._inStyling = false; _this._selectedValueChanged = null; _this._selectedValueChanged_wrapped = null; _this._gotFocus = null; _this._gotFocus_wrapped = null; _this._lostFocus = null; _this._lostFocus_wrapped = null; _this._keyDown = null; _this._keyDown_wrapped = null; _this._changing = null; _this._changing_wrapped = null; _this._valueChange = null; _this._valueChange_wrapped = null; if (_this._styling) { NamePatcher.ensureStylablePatched(Object.getPrototypeOf(_this)); } _this._getMainRef = _this._getMainRef.bind(_this); _this._implementation = _this.createImplementation(); var datePicker = _this.i; _this._datePicker = datePicker; datePicker.notifySizeChanged(); if (props) { _this.initializeProperties(); } return _this; } Object.defineProperty(IgrXDatePicker.prototype, "height", { get: function () { return this._height; }, set: function (value) { this._height = value; if (this._elRef) { this._elRef.style.height = value; this._datePicker.notifySizeChanged(); } }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "width", { get: function () { return this._width; }, set: function (value) { this._width = value; if (this._elRef) { this._elRef.style.height = value; this._datePicker.notifySizeChanged(); } }, enumerable: false, configurable: true }); IgrXDatePicker.prototype._getMainRef = function (ref) { this._elRef = ref; if (this._elRef != null) { this._renderer = new ReactRenderer(this._elRef, document, false, null); this._datePicker.provideContainer(this._renderer); } }; IgrXDatePicker.prototype.render = function () { var children = []; var inputContainer = React.createElement("div", { key: "inputContainer" }); children.push(inputContainer); var popupContainer = React.createElement("div", { key: "popupContainer" }); children.push(popupContainer); var div = React.createElement("div", { className: "ig-x-date-picker igr-x-date-picker", ref: this._getMainRef, children: children }); return div; }; IgrXDatePicker.prototype.shouldComponentUpdate = function (nextProps, nextState) { var e_1, _a; var mod = getModifiedProps(this.props, nextProps); try { for (var _b = __values(Object.keys(mod)), _c = _b.next(); !_c.done; _c = _b.next()) { var p = _c.value; if (isValidProp(this, p)) { this[p] = mod[p]; } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } } return true; }; IgrXDatePicker.prototype.initializeProperties = function () { var e_2, _a; try { for (var _b = __values(Object.keys(this.props)), _c = _b.next(); !_c.done; _c = _b.next()) { var p = _c.value; if (isValidProp(this, p)) { this[p] = this.props[p]; } } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_2) throw e_2.error; } } }; // supports angular themes or custom properties set in CSS IgrXDatePicker.prototype.updateStyle = function () { this._styling(this._elRef, this); }; IgrXDatePicker.prototype.destroy = function () { this._datePicker.destroy(); if (this._renderer) { this._renderer.destroy(); } }; IgrXDatePicker.prototype.componentWillUnmount = function () { }; IgrXDatePicker.prototype.componentDidMount = function () { this._elRef.style.width = this._width ? this._width : ""; this._elRef.style.height = this._height ? this._height : ""; this._datePicker.notifySizeChanged(); this.initializeContent(); }; IgrXDatePicker.prototype.initializeContent = function () { this.updateStyle(); this.i.notifySizeChanged(); }; IgrXDatePicker.prototype.createImplementation = function () { return new XDatePicker(); }; Object.defineProperty(IgrXDatePicker.prototype, "i", { get: function () { return this._implementation; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "value", { /** * Gets or Sets the property name that contains the values. */ get: function () { return this.i.value; }, set: function (v) { this.i.value = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "today", { /** * Gets or Sets the property name that contains the values. */ get: function () { return this.i.bb; }, set: function (v) { this.i.bb = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "label", { /** * Gets or Sets the property name that contains the label. */ get: function () { return this.i.b4; }, set: function (v) { this.i.b4 = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "labelTextColor", { /** * Gets or sets the color to use for the text. */ get: function () { return brushToString(this.i.dx); }, set: function (v) { this.i.dx = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "labelTextStyle", { /** * Gets or sets the font to use for the combobox. */ get: function () { if (this.i.ac == null) { return null; } return this.i.ac.fontString; }, set: function (v) { var fi = new FontInfo(); fi.fontString = v; this.i.ac = fi; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "placeholder", { /** * Gets or Sets the property name that contains the placeholder. */ get: function () { return this.i.cc; }, set: function (v) { this.i.cc = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "minDate", { /** * Gets or Sets the property name that contains the MinDate. */ get: function () { return this.i.ba; }, set: function (v) { this.i.ba = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "maxDate", { /** * Gets or Sets the property name that contains the MaxDate. */ get: function () { return this.i.a9; }, set: function (v) { this.i.a9 = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "density", { /** * Gets or sets the display density to use for the date pcicker. */ get: function () { return this.i.y; }, set: function (v) { this.i.y = ensureEnum(ControlDisplayDensity_$type, v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "baseTheme", { /** * Gets or sets the base built in theme to use for the date picker. */ get: function () { return this.i.w; }, set: function (v) { this.i.w = ensureEnum(BaseControlTheme_$type, v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "textStyle", { /** * Gets or sets the font to use for the combobox. */ get: function () { if (this.i.ad == null) { return null; } return this.i.ad.fontString; }, set: function (v) { var fi = new FontInfo(); fi.fontString = v; this.i.ad = fi; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "textColor", { /** * Gets or Sets the text color */ get: function () { return brushToString(this.i.dy); }, set: function (v) { this.i.dy = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "iconColor", { /** * Gets or Sets the text color */ get: function () { return brushToString(this.i.dw); }, set: function (v) { this.i.dw = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "showClearButton", { /** * Gets or sets the ShowClearButton property to detirmine if the clear button is shown */ get: function () { return this.i.a0; }, set: function (v) { this.i.a0 = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "showTodayButton", { /** * Gets or sets the ShowTodayButton property to detirmine if the today button is shown */ get: function () { return this.i.a1; }, set: function (v) { this.i.a1 = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "allowTextInput", { /** * Gets or sets the AllowTextInput property to detirmine if entering text into the input is allowed */ get: function () { return this.i.au; }, set: function (v) { this.i.au = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "openOnFocus", { /** * Gets or sets the AllowTextInput property to detirmine if entering text into the input is allowed */ get: function () { return this.i.ay; }, set: function (v) { this.i.ay = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "firstDayOfWeek", { /** * Gets or sets the FirstDayOfWeek property to detirmine first day of the week */ get: function () { return this.i.j; }, set: function (v) { this.i.j = ensureEnum(DayOfWeek_$type, v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "firstWeekOfYear", { /** * Gets or sets the FirstWeekOfYear property to detirmine first week of the year */ get: function () { return this.i.l; }, set: function (v) { this.i.l = ensureEnum(FirstWeek_$type, v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "showWeekNumbers", { /** * Gets or sets the ShowWeekNumbers property to detirmine if the week numbers are shown */ get: function () { return this.i.a2; }, set: function (v) { this.i.a2 = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "dateFormat", { /** * Gets or sets the date time format to use for this column. If FormatString is specificied this value is ignored. */ get: function () { return this.i.e; }, set: function (v) { this.i.e = ensureEnum(DateFormats_$type, v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "formatString", { /** * Gets or sets the Format property to detirmine the format of the date in the input */ get: function () { return this.i.bz; }, set: function (v) { this.i.bz = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "isDisabled", { get: function () { return this.i.av; }, set: function (v) { this.i.av = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "isFixed", { /** * Indicates that the calendar dropdown will position itself relative to the window instead of the document. */ get: function () { return this.i.aw; }, set: function (v) { this.i.aw = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "openAsChild", { /** * Indicates that the dropdown should open as a child of the date picker. */ get: function () { return this.i.ax; }, set: function (v) { this.i.ax = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "useTopLayer", { /** * Indicates that the dropdown will place itself into the browser top layer. */ get: function () { return this.i.a3; }, set: function (v) { this.i.a3 = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "hasUserValues", { get: function () { return this._hasUserValues; }, enumerable: false, configurable: true }); IgrXDatePicker.prototype.__m = function (propertyName) { if (!this._inStyling) { this._hasUserValues.add(propertyName); } }; IgrXDatePicker.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("XDatePicker"); 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; }; IgrXDatePicker.prototype.select = function () { this.i.dg(); }; /** * Exports visual information about the current state of the grid. */ IgrXDatePicker.prototype.exportVisualModel = function () { var iv = this.i.bg(); return (iv); }; /** * Returns a serialized copy of the exported visual model */ IgrXDatePicker.prototype.exportSerializedVisualModel = function () { var iv = this.i.bw(); return (iv); }; Object.defineProperty(IgrXDatePicker.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 IgrSelectedValueChangedEventArgs(); 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(IgrXDatePicker.prototype, "gotFocus", { get: function () { return this._gotFocus; }, set: function (ev) { var _this = this; if (this._gotFocus_wrapped !== null) { this.i.gotFocus = delegateRemove(this.i.gotFocus, this._gotFocus_wrapped); this._gotFocus_wrapped = null; this._gotFocus = null; } this._gotFocus = ev; this._gotFocus_wrapped = function (o, e) { var outerArgs = new IgrGotFocusEventArgs(); outerArgs._provideImplementation(e); if (_this.beforeGotFocus) { _this.beforeGotFocus(_this, outerArgs); } if (_this._gotFocus) { _this._gotFocus(_this, outerArgs); } }; this.i.gotFocus = delegateCombine(this.i.gotFocus, this._gotFocus_wrapped); ; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "lostFocus", { get: function () { return this._lostFocus; }, set: function (ev) { var _this = this; if (this._lostFocus_wrapped !== null) { this.i.lostFocus = delegateRemove(this.i.lostFocus, this._lostFocus_wrapped); this._lostFocus_wrapped = null; this._lostFocus = null; } this._lostFocus = ev; this._lostFocus_wrapped = function (o, e) { var outerArgs = new IgrLostFocusEventArgs(); outerArgs._provideImplementation(e); if (_this.beforeLostFocus) { _this.beforeLostFocus(_this, outerArgs); } if (_this._lostFocus) { _this._lostFocus(_this, outerArgs); } }; this.i.lostFocus = delegateCombine(this.i.lostFocus, this._lostFocus_wrapped); ; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "keyDown", { get: function () { return this._keyDown; }, set: function (ev) { var _this = this; if (this._keyDown_wrapped !== null) { this.i.keyDown = delegateRemove(this.i.keyDown, this._keyDown_wrapped); this._keyDown_wrapped = null; this._keyDown = null; } this._keyDown = ev; this._keyDown_wrapped = function (o, e) { var outerArgs = new IgrKeyEventArgs(); outerArgs._provideImplementation(e); if (_this.beforeKeyDown) { _this.beforeKeyDown(_this, outerArgs); } if (_this._keyDown) { _this._keyDown(_this, outerArgs); } }; this.i.keyDown = delegateCombine(this.i.keyDown, this._keyDown_wrapped); ; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.prototype, "changing", { get: function () { return this._changing; }, set: function (ev) { var _this = this; if (this._changing_wrapped !== null) { this.i.changing = delegateRemove(this.i.changing, this._changing_wrapped); this._changing_wrapped = null; this._changing = null; } this._changing = ev; this._changing_wrapped = function (o, e) { var outerArgs = new IgrInputChangeEventArgs(); outerArgs._provideImplementation(e); if (_this.beforeChanging) { _this.beforeChanging(_this, outerArgs); } if (_this._changing) { _this._changing(_this, outerArgs); } }; this.i.changing = delegateCombine(this.i.changing, this._changing_wrapped); ; }, enumerable: false, configurable: true }); Object.defineProperty(IgrXDatePicker.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 (_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 }); return IgrXDatePicker; }(React.Component)); export { IgrXDatePicker };