winbox-ui-next
Version:
We Design Vue 2.0: A Vue.js 3 UI Library
142 lines (141 loc) • 4.38 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var vue = require("vue");
var NP = require("number-precision");
var globalConfig = require("../_utils/global-config.js");
var is = require("../_utils/is.js");
var index = require("../icon/icon-exclamation-circle-fill/index.js");
var pluginVue_exportHelper = require("../_virtual/plugin-vue_export-helper");
function _interopDefaultLegacy(e) {
return e && typeof e === "object" && "default" in e ? e : { "default": e };
}
var NP__default = /* @__PURE__ */ _interopDefaultLegacy(NP);
const DEFAULT_STROKE_WIDTH = {
small: 3,
medium: 4,
default: 6
};
const getBackground = (color) => {
if (!color) {
return void 0;
}
if (is.isObject(color)) {
const val = Object.keys(color).map((key) => `${color[key]} ${key}`).join(",");
return {
backgroundImage: `linear-gradient(to right, ${val})`
};
}
return {
backgroundColor: color
};
};
const _sfc_main = vue.defineComponent({
name: "ProgressLine",
components: {
IconExclamationCircleFill: index
},
props: {
percent: {
type: Number,
default: 0
},
animation: {
type: Boolean,
default: false
},
size: {
type: String,
default: "medium"
},
strokeWidth: {
type: Number,
default: 4
},
width: {
type: [Number, String],
default: "100%"
},
color: {
type: [String, Object],
default: void 0
},
trackColor: String,
formatText: {
type: Function,
default: void 0
},
status: {
type: String
},
showText: Boolean
},
setup(props) {
const prefixCls = globalConfig.getPrefixCls("progress-line");
const strokeWidth = vue.computed(() => {
if (props.strokeWidth !== 4) {
return props.strokeWidth;
}
return DEFAULT_STROKE_WIDTH[props.size];
});
const text = vue.computed(() => `${NP__default["default"].times(props.percent, 100)}%`);
const style = vue.computed(() => ({
width: props.width,
height: `${strokeWidth.value}px`,
backgroundColor: props.trackColor
}));
const barStyle = vue.computed(() => __spreadValues({
width: `${props.percent * 100}%`
}, getBackground(props.color)));
return {
prefixCls,
style,
barStyle,
text
};
}
});
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_icon_exclamation_circle_fill = vue.resolveComponent("icon-exclamation-circle-fill");
return vue.openBlock(), vue.createElementBlock("div", {
class: vue.normalizeClass(`${_ctx.prefixCls}-wrapper`)
}, [
vue.createElementVNode("div", {
class: vue.normalizeClass(_ctx.prefixCls),
style: vue.normalizeStyle(_ctx.style)
}, [
vue.createElementVNode("div", {
class: vue.normalizeClass(`${_ctx.prefixCls}-bar-buffer`)
}, null, 2),
vue.createElementVNode("div", {
class: vue.normalizeClass([`${_ctx.prefixCls}-bar`]),
style: vue.normalizeStyle(_ctx.barStyle)
}, null, 6)
], 6),
_ctx.showText ? (vue.openBlock(), vue.createElementBlock("div", {
key: 0,
class: vue.normalizeClass(`${_ctx.prefixCls}-text`)
}, [
vue.renderSlot(_ctx.$slots, "text", { percent: _ctx.percent }, () => [
vue.createTextVNode(vue.toDisplayString(_ctx.text) + " ", 1),
_ctx.status === "danger" ? (vue.openBlock(), vue.createBlock(_component_icon_exclamation_circle_fill, { key: 0 })) : vue.createCommentVNode("v-if", true)
])
], 2)) : vue.createCommentVNode("v-if", true)
], 2);
}
var ProgressLine = /* @__PURE__ */ pluginVue_exportHelper(_sfc_main, [["render", _sfc_render]]);
module.exports = ProgressLine;