igniteui-react-inputs
Version:
Ignite UI React input components.
577 lines (574 loc) • 18.9 kB
JavaScript
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 { XCalendar } from './XCalendar';
import { IgrSelectedValueChangedEventArgs } from "./igr-selected-value-changed-event-args";
import { ControlDisplayDensity_$type } from "igniteui-react-core";
import { BaseControlTheme_$type } from "igniteui-react-core";
import { DayOfWeek_$type } from "./DayOfWeek";
import { FirstWeek_$type } from "./FirstWeek";
var IgrXCalendar = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(IgrXCalendar, _super);
function IgrXCalendar(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._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 calendar = _this.i;
_this._calendar = calendar;
calendar.notifySizeChanged();
if (props) {
_this.initializeProperties();
}
return _this;
}
Object.defineProperty(IgrXCalendar.prototype, "height", {
get: function () {
return this._height;
},
set: function (value) {
this._height = value;
if (this._elRef) {
this._elRef.style.height = value;
this._calendar.notifySizeChanged();
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrXCalendar.prototype, "width", {
get: function () {
return this._width;
},
set: function (value) {
this._width = value;
if (this._elRef) {
this._elRef.style.height = value;
this._calendar.notifySizeChanged();
}
},
enumerable: false,
configurable: true
});
IgrXCalendar.prototype._getMainRef = function (ref) {
this._elRef = ref;
if (this._elRef != null) {
this._renderer = new ReactRenderer(this._elRef, document, false, null);
this._calendar.provideContainer(this._renderer);
}
};
IgrXCalendar.prototype.render = function () {
var children = [];
var div = React.createElement("div", {
className: "ig-x-calendar igr-x-calendar",
ref: this._getMainRef,
children: children
});
return div;
};
IgrXCalendar.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;
};
IgrXCalendar.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
IgrXCalendar.prototype.updateStyle = function () {
this._styling(this._elRef, this);
};
IgrXCalendar.prototype.destroy = function () {
this._calendar.destroy();
if (this._renderer) {
this._renderer.destroy();
}
};
IgrXCalendar.prototype.componentWillUnmount = function () {
};
IgrXCalendar.prototype.componentDidMount = function () {
this._elRef.style.width = this._width ? this._width : "";
this._elRef.style.height = this._height ? this._height : "";
this._calendar.notifySizeChanged();
this.initializeContent();
};
IgrXCalendar.prototype.initializeContent = function () {
this.updateStyle();
this.i.notifySizeChanged();
};
IgrXCalendar.prototype.createImplementation = function () {
return new XCalendar();
};
Object.defineProperty(IgrXCalendar.prototype, "i", {
get: function () {
return this._implementation;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrXCalendar.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(IgrXCalendar.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(IgrXCalendar.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(IgrXCalendar.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(IgrXCalendar.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);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrXCalendar.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);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrXCalendar.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);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrXCalendar.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);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrXCalendar.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);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrXCalendar.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);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrXCalendar.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);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrXCalendar.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);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrXCalendar.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);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrXCalendar.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);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrXCalendar.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);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrXCalendar.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);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrXCalendar.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);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrXCalendar.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;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrXCalendar.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);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrXCalendar.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);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrXCalendar.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);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrXCalendar.prototype, "hasUserValues", {
get: function () {
return this._hasUserValues;
},
enumerable: false,
configurable: true
});
IgrXCalendar.prototype.__m = function (propertyName) {
if (!this._inStyling) {
this._hasUserValues.add(propertyName);
}
};
IgrXCalendar.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("XCalendar");
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.
*/
IgrXCalendar.prototype.exportVisualModel = function () {
var iv = this.i.bj();
return (iv);
};
/**
* Returns a serialized copy of the exported visual model
*/
IgrXCalendar.prototype.exportSerializedVisualModel = function () {
var iv = this.i.bs();
return (iv);
};
Object.defineProperty(IgrXCalendar.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(IgrXCalendar.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 IgrXCalendar;
}(React.Component));
export { IgrXCalendar };