UNPKG

gd-bs

Version:

Bootstrap JavaScript, TypeScript and Web Components library.

85 lines (84 loc) 3.29 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.IconLink = exports.IconLinkTypes = void 0; var base_1 = require("../base"); var common_1 = require("../common"); var templates_1 = require("./templates"); /** * Icon Link Types */ var IconLinkTypes; (function (IconLinkTypes) { IconLinkTypes[IconLinkTypes["AfterText"] = 1] = "AfterText"; IconLinkTypes[IconLinkTypes["BeforeText"] = 2] = "BeforeText"; })(IconLinkTypes = exports.IconLinkTypes || (exports.IconLinkTypes = {})); /** * Icon Link * @property props - The list box properties. */ var _IconLink = /** @class */ (function (_super) { __extends(_IconLink, _super); // Constructor function _IconLink(props, template) { if (template === void 0) { template = templates_1.HTML; } var _this = _super.call(this, template, props) || this; _this._elIcon = null; // Configure the list box _this.configure(); // Configure the events _this.configureEvents(); // Configure the parent _this.configureParent(); return _this; } // Configures the list box _IconLink.prototype.configure = function () { // Render the content (0, common_1.appendContent)(this.el, this.props.content); // Set the icon if it exists if (this.props.iconType) { if (typeof (this.props.iconType) === "function") { // Set the icon this._elIcon = this.props.iconType(this.props.iconSize, this.props.iconSize, this.props.iconClassName); } // Else, it's an element else if (typeof (this.props.iconType) === "object") { // Set the icon this._elIcon = this.props.iconType; } else { return; } // See if we are rendering the content first if (this.props.type == IconLinkTypes.AfterText) { // Append the icon this.el.appendChild(this._elIcon); } else { // Prepend the icon this.el.prepend(this._elIcon); } } }; // Configures the events _IconLink.prototype.configureEvents = function () { }; return _IconLink; }(base_1.Base)); var IconLink = function (props, template) { return new _IconLink(props, template); }; exports.IconLink = IconLink;