UNPKG

igniteui-react-inputs

Version:

Ignite UI React input components.

487 lines (486 loc) 17.2 kB
import { __extends, __values } from "tslib"; import * as React from 'react'; import { ColorEditorPanel } from "./ColorEditorPanel"; import { ensureEnum, brushToString, stringToBrush, initializePropertiesFromCss, NamePatcher, isValidProp, toSpinal, getModifiedProps } from "igniteui-react-core"; import { FontInfo } from "igniteui-react-core"; import { ReactRenderer, PortalManager } from "igniteui-react-core"; import { delegateCombine, delegateRemove } from "igniteui-react-core"; import { TypeRegistrar } from "igniteui-react-core"; import { ControlDisplayDensity_$type } from "igniteui-react-core"; import { BaseControlTheme_$type } from "igniteui-react-core"; import { IgrColorEditorPanelSelectedValueChangedEventArgs } from "./igr-color-editor-panel-selected-value-changed-event-args"; var IgrColorEditorPanel = /** @class */ /*@__PURE__*/ (function (_super) { __extends(IgrColorEditorPanel, _super); function IgrColorEditorPanel(props) { var _this = _super.call(this, props) || this; _this._wrapper = null; _this.mounted = false; _this.__p = null; _this._hasUserValues = new Set(); _this._stylingContainer = null; _this._stylingParent = null; _this._inStyling = false; _this._valueChanged = null; _this._valueChanged_wrapped = null; _this._valueChanging = null; _this._valueChanging_wrapped = null; if (_this._styling) { NamePatcher.ensureStylablePatched(Object.getPrototypeOf(_this)); } _this._implementation = _this.createImplementation(); _this._implementation.externalObject = _this; _this._getMainRef = _this._getMainRef.bind(_this); var container; if (document) { container = document.createElement("div"); } var root; root = container; if (container != null) { root = container; } _this.requestRender = _this.requestRender.bind(_this); _this._portalManager = new PortalManager("colorEditorPanelContent", _this.requestRender); var ren = new ReactRenderer(root, document, true, {}, _this._portalManager); _this._wrapper = ren; _this._container = _this._wrapper.rootWrapper; _this._container.setStyleProperty("display", "block"); var colorEditorPanel = _this.i; _this._colorEditorPanel = colorEditorPanel; colorEditorPanel.provideContainer(ren); if (props) { _this.initializeProperties(); } return _this; } IgrColorEditorPanel.prototype._getMainRef = function (ref) { this._elRef = ref; }; IgrColorEditorPanel.prototype.render = function () { var propChildren = this.props.children; var children = []; React.Children.forEach(propChildren, function (ch) { children.push(React.cloneElement(ch)); }); this._portalManager.onRender(children); var div = React.createElement("div", { className: "ig-color-editor-panel igr-color-editor-panel", ref: this._getMainRef, children: children }); return div; }; IgrColorEditorPanel.prototype.requestRender = function () { if (this._initialized) { this.setState({}); } }; //private _onDisplayChanged() { // this._container.setStyleProperty("display", this.display); //} //private _onFlexDirectionChanged() { // this._container.setStyleProperty("flex-direction", this.flexDirection); //} //private _onFlexGrowChanged() { // this._container.setStyleProperty("flex-grow", this.flexGrow); //} //private _onAlignItemsChanged() { // this._container.setStyleProperty("align-items", this.alignItems); //} //private _getLabelPortal(element: DomWrapper, portalCallback: (portal: DomPortal) => void): void { // this._portalManager.getPortal(element, "TemplateContent", portalCallback); //} IgrColorEditorPanel.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; }; IgrColorEditorPanel.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 IgrColorEditorPanel.prototype.updateStyle = function () { this._styling(this._elRef, this); }; IgrColorEditorPanel.prototype.destroy = function () { this._colorEditorPanel.destroy(); this._wrapper.destroy(); }; IgrColorEditorPanel.prototype.componentWillUnmount = function () { }; IgrColorEditorPanel.prototype.componentDidMount = function () { this._elRef.appendChild(this._container.getNativeElement()); this.initializeContent(); }; IgrColorEditorPanel.prototype.initializeContent = function () { this._styling(this._container.getNativeElement(), this); this.updateStyle(); }; IgrColorEditorPanel.prototype.createImplementation = function () { return new ColorEditorPanel(); }; Object.defineProperty(IgrColorEditorPanel.prototype, "nativeElement", { get: function () { return this._implementation.nativeElement; }, enumerable: false, configurable: true }); Object.defineProperty(IgrColorEditorPanel.prototype, "i", { /** * @hidden */ get: function () { return this._implementation; } /** * @hidden */, enumerable: false, configurable: true }); IgrColorEditorPanel._createFromInternal = function (internal) { if (!internal) { return null; } if (!internal.$type) { return null; } var name = internal.$type.name; var externalName = "Igr" + name; if (!TypeRegistrar.isRegistered(externalName)) { return null; } return TypeRegistrar.create(externalName); }; Object.defineProperty(IgrColorEditorPanel.prototype, "value", { /** * Gets or Sets the value for the color editor panel. */ get: function () { return brushToString(this.i.value); }, set: function (v) { this.i.value = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrColorEditorPanel.prototype, "density", { /** * Gets or sets the display density to use for the ColorEditorPanel. */ get: function () { return this.i.h; }, set: function (v) { this.i.h = ensureEnum(ControlDisplayDensity_$type, v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrColorEditorPanel.prototype, "baseTheme", { /** * Gets or sets the base built in theme to use for the ColorEditorPanel. */ get: function () { return this.i.f; }, set: function (v) { this.i.f = ensureEnum(BaseControlTheme_$type, v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrColorEditorPanel.prototype, "backgroundColor", { /** * Gets or Sets the selected color background color */ get: function () { return brushToString(this.i.by); }, set: function (v) { this.i.by = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrColorEditorPanel.prototype, "selectedColorBorderColor", { /** * Gets or Sets the selected color boreder color */ get: function () { return brushToString(this.i.b1); }, set: function (v) { this.i.b1 = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrColorEditorPanel.prototype, "selectedFocusDateBackgroundColor", { /** * Gets or Sets the selected color border color */ get: function () { return brushToString(this.i.b2); }, set: function (v) { this.i.b2 = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrColorEditorPanel.prototype, "focusColorBorderColor", { /** * Gets or Sets the focus color border color */ get: function () { return brushToString(this.i.bz); }, set: function (v) { this.i.bz = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrColorEditorPanel.prototype, "hoverBackgroundColor", { /** * Gets or Sets the focus date background color */ get: function () { return brushToString(this.i.b0); }, set: function (v) { this.i.b0 = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrColorEditorPanel.prototype, "textColor", { /** * Gets or Sets the selected date text color */ get: function () { return brushToString(this.i.b3); }, set: function (v) { this.i.b3 = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrColorEditorPanel.prototype, "textStyle", { /** * Gets or sets the font to use for the combobox. */ get: function () { if (this.i.j == null) { return null; } return this.i.j.fontString; }, set: function (v) { var fi = new FontInfo(); fi.fontString = v; this.i.j = fi; }, enumerable: false, configurable: true }); Object.defineProperty(IgrColorEditorPanel.prototype, "pixelScalingRatio", { /** * Gets or sets the scaling value used to affect the pixel density of the control. * A higher scaling ratio will produce crisper visuals at the expense of memory. Lower values will cause the control * to appear blurry. */ get: function () { return this.i.ae; }, set: function (v) { this.i.ae = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrColorEditorPanel.prototype, "actualPixelScalingRatio", { get: function () { return this.i.ab; }, set: function (v) { this.i.ab = +v; }, enumerable: false, configurable: true }); IgrColorEditorPanel.prototype.findByName = function (name) { if (this.findEphemera) { if (name && name.indexOf("@@e:") == 0) { return this.findEphemera(name); } } return null; }; Object.defineProperty(IgrColorEditorPanel.prototype, "hasUserValues", { get: function () { return this._hasUserValues; }, enumerable: false, configurable: true }); IgrColorEditorPanel.prototype.__m = function (propertyName) { if (!this._inStyling) { this._hasUserValues.add(propertyName); } }; IgrColorEditorPanel.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("ColorEditorPanel"); 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; }; Object.defineProperty(IgrColorEditorPanel.prototype, "valueChanged", { /** * Called when date is selected. */ get: function () { return this._valueChanged; }, set: function (ev) { var _this = this; if (this._valueChanged_wrapped !== null) { this.i.valueChanged = delegateRemove(this.i.valueChanged, this._valueChanged_wrapped); this._valueChanged_wrapped = null; this._valueChanged = null; } this._valueChanged = ev; this._valueChanged_wrapped = function (o, e) { var outerArgs = new IgrColorEditorPanelSelectedValueChangedEventArgs(); outerArgs._provideImplementation(e); if (_this.beforeValueChanged) { _this.beforeValueChanged(_this, outerArgs); } if (_this._valueChanged) { _this._valueChanged(_this, outerArgs); } }; this.i.valueChanged = delegateCombine(this.i.valueChanged, this._valueChanged_wrapped); ; }, enumerable: false, configurable: true }); Object.defineProperty(IgrColorEditorPanel.prototype, "valueChanging", { /** * Called when date is selected. */ get: function () { return this._valueChanging; }, set: function (ev) { var _this = this; if (this._valueChanging_wrapped !== null) { this.i.valueChanging = delegateRemove(this.i.valueChanging, this._valueChanging_wrapped); this._valueChanging_wrapped = null; this._valueChanging = null; } this._valueChanging = ev; this._valueChanging_wrapped = function (o, e) { var outerArgs = new IgrColorEditorPanelSelectedValueChangedEventArgs(); outerArgs._provideImplementation(e); if (_this.beforeValueChanging) { _this.beforeValueChanging(_this, outerArgs); } if (_this._valueChanging) { _this._valueChanging(_this, outerArgs); } }; this.i.valueChanging = delegateCombine(this.i.valueChanging, this._valueChanging_wrapped); ; }, enumerable: false, configurable: true }); return IgrColorEditorPanel; }(React.Component)); export { IgrColorEditorPanel };