UNPKG

igniteui-webcomponents-charts

Version:

Ignite UI Web Components charting components for building rich data visualizations using TypeScript APIs.

416 lines (414 loc) 19 kB
import { __extends } from "tslib"; import { initializePropertiesFromCss, NamePatcher, toSpinal, fromSpinal, getAllPropertyNames } from "igniteui-webcomponents-core"; import { IgcLegendMouseButtonEventArgs } from "./igc-legend-mouse-button-event-args"; import { IgcLegendMouseEventArgs } from "./igc-legend-mouse-event-args"; import { IgcLegendSizeChangedEventArgs } from "./igc-legend-size-changed-event-args"; import { delegateCombine, delegateRemove } from "igniteui-webcomponents-core"; import { IgcHTMLElement } from "igniteui-webcomponents-core"; import { FontDefaults } from "igniteui-webcomponents-core"; export var LegendBaseStyles = [/*@__PURE__*/ /*@__PURE__*/ /*@__PURE__*/ /*@__PURE__*/ /*@__PURE__*/ /*@__PURE__*/ "\n:host {\n display: block;\n}\n.ig-legend {\n border: none;\n border: var(--legend-border, none);\n overflow: auto;\n overflow: var(--legend-item-overflow, auto);\n}\n.ig-chart-legend-item-text {\n vertical-align: middle;\n vertical-align: var(--legend-item-vertical-align, middle);\n}\n.ig-chart-legend-items-list\n{\n padding: 5px;\n padding: var(--legend-item-padding, 5px);\n margin: 0px;\n margin: var(--legend-item-margin, 0px);\n background-color: transparent;\n background-color: var(--legend-list-background-color, transparent);\n font: ".concat(FontDefaults.legendLabelsFontSize, "px ").concat(FontDefaults.legendLabelsFontFamily, ";\n font: var(--legend-item-font, ").concat(FontDefaults.legendLabelsFontSize, "px ").concat(FontDefaults.legendLabelsFontFamily, ");\n color: ").concat(FontDefaults.legendLabelsBrush.fill, ";\n color: var(--text-color, ").concat(FontDefaults.legendLabelsBrush.fill, ");\n}\n.ig-chart-legend-item-badge, .ui-chart-legend-item-badge, canvas\n{\n vertical-align: middle;\n vertical-align: var(--legend-item-badge-vertical-align, middle);\n}\n.ig-chart-legend-item\n{\n background-color: transparent;\n background-color: var(--legend-item-background-color, transparent);\n}\n")]; /** * Represents the base class for a legend in IgxDataChartComponent. */ var IgcLegendBaseComponent = /** @class */ /*@__PURE__*/ (function (_super) { __extends(IgcLegendBaseComponent, _super); function IgcLegendBaseComponent() { var _this = _super.call(this) || this; _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._legendItemMouseLeftButtonDown = null; _this._legendItemMouseLeftButtonDown_wrapped = null; _this._legendItemMouseLeftButtonUp = null; _this._legendItemMouseLeftButtonUp_wrapped = null; _this._legendItemMouseEnter = null; _this._legendItemMouseEnter_wrapped = null; _this._legendItemMouseLeave = null; _this._legendItemMouseLeave_wrapped = null; _this._legendItemMouseMove = null; _this._legendItemMouseMove_wrapped = null; _this._legendSizeChanged = null; _this._legendSizeChanged_wrapped = null; IgcLegendBaseComponent.ensureCss(); if (_this._styling) { NamePatcher.ensureStylablePatched(Object.getPrototypeOf(_this)); } _this._implementation = _this.createImplementation(); _this._implementation.externalObject = _this; _this.onImplementationCreated(); if (document) { //introduce styles globally for now. } return _this; } Object.defineProperty(IgcLegendBaseComponent.prototype, "i", { get: function () { return this._implementation; }, enumerable: false, configurable: true }); IgcLegendBaseComponent.prototype.onImplementationCreated = function () { }; IgcLegendBaseComponent.ensureCss = function () { if (!document) { return; } if (IgcLegendBaseComponent._checked.has(document)) { return; } for (var i = 0; i < document.head.children.length; i++) { var child = document.head.children[i]; if (child.tagName && child.tagName.toLowerCase() == "style" && child.hasAttribute("data-ig-legend-style")) { return; } } var style = document.createElement("style"); style.textContent = LegendBaseStyles[0]; style.setAttribute('data-ig-legend-style', 'true'); document.head.appendChild(style); IgcLegendBaseComponent._checked.set(document, true); }; IgcLegendBaseComponent.prototype._enqueueSetAttribute = function (attrName, attrValue) { this._queuedSetAttributes.push({ attrName: attrName, attrValue: attrValue }); }; IgcLegendBaseComponent.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; }; IgcLegendBaseComponent.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(IgcLegendBaseComponent, "observedAttributes", { get: function () { if (IgcLegendBaseComponent._observedAttributesIgcLegendBaseComponent == null) { var names = getAllPropertyNames(IgcLegendBaseComponent); for (var i = 0; i < names.length; i++) { names[i] = toSpinal(names[i]); } IgcLegendBaseComponent._observedAttributesIgcLegendBaseComponent = names; } return IgcLegendBaseComponent._observedAttributesIgcLegendBaseComponent; }, enumerable: false, configurable: true }); IgcLegendBaseComponent.prototype.attributeChangedCallback = function (name, oldValue, newValue) { if (this._settingAttributes) { return; } var setName = fromSpinal(name); this._updatingFromAttribute = true; this[setName] = newValue; this._updatingFromAttribute = false; }; Object.defineProperty(IgcLegendBaseComponent.prototype, "isItemwise", { /** * Gets if the legend is item-wise. */ get: function () { return this.i.isItemwise; }, enumerable: false, configurable: true }); Object.defineProperty(IgcLegendBaseComponent.prototype, "isFinancial", { /** * Gets if the legend is a financial legend. */ get: function () { return this.i.isFinancial; }, enumerable: false, configurable: true }); IgcLegendBaseComponent.prototype.findByName = function (name) { if (this.findEphemera) { if (name && name.indexOf("@@e:") == 0) { return this.findEphemera(name); } } return null; }; Object.defineProperty(IgcLegendBaseComponent.prototype, "hasUserValues", { get: function () { return this._hasUserValues; }, enumerable: false, configurable: true }); IgcLegendBaseComponent.prototype.__m = function (propertyName) { if (!this._inStyling) { this._hasUserValues.add(propertyName); } }; IgcLegendBaseComponent.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("LegendBaseComponent"); 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; }; /** * Returns the legend visuals expressed as a serialized string. */ IgcLegendBaseComponent.prototype.exportSerializedVisualData = function () { var iv = this.i.exportSerializedVisualData(); return (iv); }; Object.defineProperty(IgcLegendBaseComponent.prototype, "legendItemMouseLeftButtonDown", { /** * Event raised when the left mouse button is pressed while the mouse pointer is over a legend item * in this Legend. */ get: function () { return this._legendItemMouseLeftButtonDown; }, set: function (ev) { var _this = this; if (this._legendItemMouseLeftButtonDown_wrapped !== null) { this.i.legendItemMouseLeftButtonDown = delegateRemove(this.i.legendItemMouseLeftButtonDown, this._legendItemMouseLeftButtonDown_wrapped); this._legendItemMouseLeftButtonDown_wrapped = null; this._legendItemMouseLeftButtonDown = null; } this._legendItemMouseLeftButtonDown = ev; this._legendItemMouseLeftButtonDown_wrapped = function (o, e) { var outerArgs = new IgcLegendMouseButtonEventArgs(); outerArgs._provideImplementation(e); if (_this.beforeLegendItemMouseLeftButtonDown) { _this.beforeLegendItemMouseLeftButtonDown(_this, outerArgs); } if (_this._legendItemMouseLeftButtonDown) { _this._legendItemMouseLeftButtonDown(_this, outerArgs); } }; this.i.legendItemMouseLeftButtonDown = delegateCombine(this.i.legendItemMouseLeftButtonDown, this._legendItemMouseLeftButtonDown_wrapped); ; }, enumerable: false, configurable: true }); Object.defineProperty(IgcLegendBaseComponent.prototype, "legendItemMouseLeftButtonUp", { /** * Event raised when the left mouse button is released while the mouse pointer is over a legend item * in this Legend. */ get: function () { return this._legendItemMouseLeftButtonUp; }, set: function (ev) { var _this = this; if (this._legendItemMouseLeftButtonUp_wrapped !== null) { this.i.legendItemMouseLeftButtonUp = delegateRemove(this.i.legendItemMouseLeftButtonUp, this._legendItemMouseLeftButtonUp_wrapped); this._legendItemMouseLeftButtonUp_wrapped = null; this._legendItemMouseLeftButtonUp = null; } this._legendItemMouseLeftButtonUp = ev; this._legendItemMouseLeftButtonUp_wrapped = function (o, e) { var outerArgs = new IgcLegendMouseButtonEventArgs(); outerArgs._provideImplementation(e); if (_this.beforeLegendItemMouseLeftButtonUp) { _this.beforeLegendItemMouseLeftButtonUp(_this, outerArgs); } if (_this._legendItemMouseLeftButtonUp) { _this._legendItemMouseLeftButtonUp(_this, outerArgs); } }; this.i.legendItemMouseLeftButtonUp = delegateCombine(this.i.legendItemMouseLeftButtonUp, this._legendItemMouseLeftButtonUp_wrapped); ; }, enumerable: false, configurable: true }); Object.defineProperty(IgcLegendBaseComponent.prototype, "legendItemMouseEnter", { /** * Event raised when the mouse pointer enters a legend item of this legend. */ get: function () { return this._legendItemMouseEnter; }, set: function (ev) { var _this = this; if (this._legendItemMouseEnter_wrapped !== null) { this.i.legendItemMouseEnter = delegateRemove(this.i.legendItemMouseEnter, this._legendItemMouseEnter_wrapped); this._legendItemMouseEnter_wrapped = null; this._legendItemMouseEnter = null; } this._legendItemMouseEnter = ev; this._legendItemMouseEnter_wrapped = function (o, e) { var outerArgs = new IgcLegendMouseEventArgs(); outerArgs._provideImplementation(e); if (_this.beforeLegendItemMouseEnter) { _this.beforeLegendItemMouseEnter(_this, outerArgs); } if (_this._legendItemMouseEnter) { _this._legendItemMouseEnter(_this, outerArgs); } }; this.i.legendItemMouseEnter = delegateCombine(this.i.legendItemMouseEnter, this._legendItemMouseEnter_wrapped); ; }, enumerable: false, configurable: true }); Object.defineProperty(IgcLegendBaseComponent.prototype, "legendItemMouseLeave", { /** * Event raised when the mouse pointer leaves a legend item of this legend. */ get: function () { return this._legendItemMouseLeave; }, set: function (ev) { var _this = this; if (this._legendItemMouseLeave_wrapped !== null) { this.i.legendItemMouseLeave = delegateRemove(this.i.legendItemMouseLeave, this._legendItemMouseLeave_wrapped); this._legendItemMouseLeave_wrapped = null; this._legendItemMouseLeave = null; } this._legendItemMouseLeave = ev; this._legendItemMouseLeave_wrapped = function (o, e) { var outerArgs = new IgcLegendMouseEventArgs(); outerArgs._provideImplementation(e); if (_this.beforeLegendItemMouseLeave) { _this.beforeLegendItemMouseLeave(_this, outerArgs); } if (_this._legendItemMouseLeave) { _this._legendItemMouseLeave(_this, outerArgs); } }; this.i.legendItemMouseLeave = delegateCombine(this.i.legendItemMouseLeave, this._legendItemMouseLeave_wrapped); ; }, enumerable: false, configurable: true }); Object.defineProperty(IgcLegendBaseComponent.prototype, "legendItemMouseMove", { /** * Event raised when the mouse pointer moves over a legend item of this legend. */ get: function () { return this._legendItemMouseMove; }, set: function (ev) { var _this = this; if (this._legendItemMouseMove_wrapped !== null) { this.i.legendItemMouseMove = delegateRemove(this.i.legendItemMouseMove, this._legendItemMouseMove_wrapped); this._legendItemMouseMove_wrapped = null; this._legendItemMouseMove = null; } this._legendItemMouseMove = ev; this._legendItemMouseMove_wrapped = function (o, e) { var outerArgs = new IgcLegendMouseEventArgs(); outerArgs._provideImplementation(e); if (_this.beforeLegendItemMouseMove) { _this.beforeLegendItemMouseMove(_this, outerArgs); } if (_this._legendItemMouseMove) { _this._legendItemMouseMove(_this, outerArgs); } }; this.i.legendItemMouseMove = delegateCombine(this.i.legendItemMouseMove, this._legendItemMouseMove_wrapped); ; }, enumerable: false, configurable: true }); Object.defineProperty(IgcLegendBaseComponent.prototype, "legendSizeChanged", { /** * Event raised when this legend's required size changes. */ get: function () { return this._legendSizeChanged; }, set: function (ev) { var _this = this; if (this._legendSizeChanged_wrapped !== null) { this.i.legendSizeChanged = delegateRemove(this.i.legendSizeChanged, this._legendSizeChanged_wrapped); this._legendSizeChanged_wrapped = null; this._legendSizeChanged = null; } this._legendSizeChanged = ev; this._legendSizeChanged_wrapped = function (o, e) { var outerArgs = new IgcLegendSizeChangedEventArgs(); outerArgs._provideImplementation(e); if (_this.beforeLegendSizeChanged) { _this.beforeLegendSizeChanged(_this, outerArgs); } if (_this._legendSizeChanged) { _this._legendSizeChanged(_this, outerArgs); } }; this.i.legendSizeChanged = delegateCombine(this.i.legendSizeChanged, this._legendSizeChanged_wrapped); ; }, enumerable: false, configurable: true }); IgcLegendBaseComponent._checked = new WeakMap(); IgcLegendBaseComponent._observedAttributesIgcLegendBaseComponent = null; return IgcLegendBaseComponent; }(IgcHTMLElement)); export { IgcLegendBaseComponent };