UNPKG

gd-bs

Version:

Bootstrap JavaScript, TypeScript and Web Components library.

105 lines (104 loc) 4.46 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.Progress = exports.ProgressBarClassNames = exports.ProgressBarTypes = void 0; var classNames_1 = require("../classNames"); var base_1 = require("../base"); var templates_1 = require("./templates"); /** * Progress Bar Types */ var ProgressBarTypes; (function (ProgressBarTypes) { ProgressBarTypes[ProgressBarTypes["Danger"] = 1] = "Danger"; ProgressBarTypes[ProgressBarTypes["Dark"] = 2] = "Dark"; ProgressBarTypes[ProgressBarTypes["Info"] = 3] = "Info"; ProgressBarTypes[ProgressBarTypes["Light"] = 4] = "Light"; ProgressBarTypes[ProgressBarTypes["Primary"] = 5] = "Primary"; ProgressBarTypes[ProgressBarTypes["Secondary"] = 6] = "Secondary"; ProgressBarTypes[ProgressBarTypes["Success"] = 7] = "Success"; ProgressBarTypes[ProgressBarTypes["Transparent"] = 8] = "Transparent"; ProgressBarTypes[ProgressBarTypes["Warning"] = 9] = "Warning"; ProgressBarTypes[ProgressBarTypes["White"] = 10] = "White"; })(ProgressBarTypes = exports.ProgressBarTypes || (exports.ProgressBarTypes = {})); /** * Progress Bar Class Names */ exports.ProgressBarClassNames = new classNames_1.ClassNames([ "bg-danger", "bg-dark", "bg-info", "bg-light", "bg-primary", "bg-secondary", "bg-success", "bg-transparent", "bg-warning", "bg-white" ]); /** * Progress */ var _Progress = /** @class */ (function (_super) { __extends(_Progress, _super); // Constructor function _Progress(props, template) { if (template === void 0) { template = templates_1.HTML; } var _this = _super.call(this, template, props) || this; // Configure the collapse _this.configure(); // Configure the parent _this.configureParent(); return _this; } // Configure the card group _Progress.prototype.configure = function () { // Set the default values var maxValue = typeof (this.props.max) === "number" ? this.props.max : 100; var minValue = typeof (this.props.min) === "number" ? this.props.min : 0; var size = typeof (this.props.size) === "number" ? this.props.size : 0; // Update the progress bar var progressBar = this.el.querySelector(".progress-bar"); if (progressBar) { progressBar.style.width = size + "%"; progressBar.setAttribute("aria-valuenow", size.toString()); progressBar.setAttribute("aria-valuemin", minValue.toString()); progressBar.setAttribute("aria-valuemax", maxValue.toString()); this.props.isAnimated ? progressBar.classList.add("progress-bar-animated") : null; this.props.isStriped ? progressBar.classList.add("progress-bar-striped") : null; this.props.label ? progressBar.innerHTML = this.props.label : null; // See if a type exists var className = exports.ProgressBarClassNames.getByType(this.props.type); if (className) { // Add the class name progressBar.classList.add(className); } } }; Object.defineProperty(_Progress.prototype, "progressBar", { /** * Public Interface */ // Return the progress bar element get: function () { return this.el.querySelector(".progress-bar"); }, enumerable: false, configurable: true }); return _Progress; }(base_1.Base)); var Progress = function (props, template) { return new _Progress(props, template); }; exports.Progress = Progress;