UNPKG

xdesign-vue-next

Version:

XDesign Component for vue-next

252 lines (241 loc) 10.5 kB
/** * xdesign v1.0.6 * (c) 2023 xdesign * @license MIT */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var closeCircleFill = require('../_chunks/dep-3fb13dcd.js'); var errorWarningFill = require('../_chunks/dep-0a0a2988.js'); var checkboxCircleFill = require('../_chunks/dep-38e8405e.js'); var closeLine = require('../_chunks/dep-ac484abb.js'); var vue = require('vue'); var checkLine = require('../_chunks/dep-8de1bc11.js'); var _defineProperty = require('@babel/runtime/helpers/defineProperty'); var utils_helper = require('../utils/helper.js'); var progress_constants = require('./constants.js'); var progress_props = require('./props.js'); var hooks_useConfig = require('../hooks/useConfig.js'); var hooks_tnode = require('../hooks/tnode.js'); var isObject = require('lodash/isObject'); var isString = require('lodash/isString'); require('@babel/runtime/helpers/objectWithoutProperties'); require('@babel/runtime/helpers/slicedToArray'); require('lodash/camelCase'); require('lodash/isUndefined'); require('lodash/isNull'); require('lodash/isArray'); require('lodash/isNumber'); require('../config-provider/useConfig.js'); require('lodash/isFunction'); require('lodash/cloneDeep'); require('../config-provider/context.js'); require('lodash/mergeWith'); require('lodash/merge'); require('../_common/js/global-config/default-config.js'); require('../_common/js/global-config/locale/en_US.js'); require('../_chunks/dep-8d10b59f.js'); require('lodash/kebabCase'); require('../utils/render-tnode.js'); require('lodash/isEmpty'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty); var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject); var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString); const _hoisted_1 = { class: "x-icon", viewBox: "0 0 24 24", width: "1.1em", height: "1.1em" }; const _hoisted_2 = /*#__PURE__*/vue.createElementVNode("path", { fill: "currentColor", d: "m12.865 3l9.526 16.5a1 1 0 0 1-.866 1.5H2.473a1 1 0 0 1-.866-1.5L11.133 3a1 1 0 0 1 1.732 0Zm-8.66 16h15.588L12 5.5L4.205 19Zm6.794-3h2v2h-2v-2Zm0-7h2v5h-2V9Z" }, null, -1 /* HOISTED */); const _hoisted_3 = [ _hoisted_2 ]; function render(_ctx, _cache) { return (vue.openBlock(), vue.createElementBlock("svg", _hoisted_1, _hoisted_3)) } var __unplugin_components_1 = { name: 'ri-alert-line', render }; /* vite-plugin-components disabled */ var _Progress = vue.defineComponent({ name: "XProgress", props: progress_props["default"], setup: function setup(props2) { var renderTNodeJSX = hooks_tnode.useTNodeJSX(); var COMPONENT_NAME = hooks_useConfig.usePrefixClass("progress"); var statusStyle = vue.computed(function () { if (props2.percentage >= 100) { return "success"; } return props2.status || "default"; }); var trackBgStyle = vue.computed(function () { var style = {}; if (props2.strokeWidth) { var height = isString__default["default"](props2.strokeWidth) ? props2.strokeWidth : "".concat(props2.strokeWidth, "px"); style.height = height; style.borderRadius = height; } if (props2.trackColor) { style.backgroundColor = props2.trackColor; } return style; }); var barStyle = vue.computed(function () { return { width: "".concat(props2.percentage, "%"), background: props2.color && utils_helper.getBackgroundColor(props2.color) }; }); var circlePathStyle = vue.computed(function () { var strokeColor = isObject__default["default"](props2.color) ? "" : props2.color; return { stroke: strokeColor }; }); var circleOuterStyle = vue.computed(function () { var strokeColor = isObject__default["default"](props2.trackColor) ? "" : props2.trackColor; return { stroke: strokeColor }; }); var diameter = vue.computed(function () { var diameter2 = progress_constants.CIRCLE_SIZE_PX.MEDIUM; if (!props2.size) { return diameter2; } var SMALL = progress_constants.CIRCLE_SIZE.SMALL, LARGE = progress_constants.CIRCLE_SIZE.LARGE, MEDIUM = progress_constants.CIRCLE_SIZE.MEDIUM; switch (props2.size) { case SMALL: diameter2 = progress_constants.CIRCLE_SIZE_PX.SMALL; break; case MEDIUM: diameter2 = progress_constants.CIRCLE_SIZE_PX.MEDIUM; break; case LARGE: diameter2 = progress_constants.CIRCLE_SIZE_PX.LARGE; break; default: diameter2 = Number(props2.size); break; } return diameter2; }); var rPoints = vue.computed(function () { return diameter.value / 2; }); var radius = vue.computed(function () { return rPoints.value - circleStrokeWidth.value / 2; }); var circleStyle = vue.computed(function () { if (props2.theme !== progress_constants.PRO_THEME.CIRCLE) { return {}; } var fontSize = diameter.value * progress_constants.CIRCLE_FONT_SIZE_RATIO.MEDIUM; if (diameter.value <= progress_constants.CIRCLE_SIZE_PX.SMALL) { fontSize = diameter.value * progress_constants.CIRCLE_FONT_SIZE_RATIO.SMALL; } else if (diameter.value >= progress_constants.CIRCLE_SIZE_PX.LARGE) { fontSize = diameter.value * progress_constants.CIRCLE_FONT_SIZE_RATIO.LARGE; } return { width: "".concat(diameter.value, "px"), height: "".concat(diameter.value, "px"), fontSize: "".concat(fontSize, "px") }; }); var circleStrokeWidth = vue.computed(function () { var defaultWidth = props2.size === progress_constants.CIRCLE_SIZE.SMALL ? 4 : 6; return props2.strokeWidth ? Number(props2.strokeWidth) : defaultWidth; }); var strokeDashArr = vue.computed(function () { var radius2 = (diameter.value - circleStrokeWidth.value) / 2; var perimeter = Math.PI * 2 * radius2; var percent = props2.percentage / 100; return "".concat(perimeter * percent, " ").concat(perimeter * (1 - percent)); }); var getIconMap = function getIconMap() { var CIRCLE_ICONS = { success: vue.createVNode(checkLine.__unplugin_components_0, null, null), warning: vue.createVNode(__unplugin_components_1, null, null), error: vue.createVNode(closeLine.__unplugin_components_2, null, null) }; var NORMAL_ICONS = { success: vue.createVNode(checkboxCircleFill.__unplugin_components_0, null, null), warning: vue.createVNode(errorWarningFill.__unplugin_components_1, null, null), error: vue.createVNode(closeCircleFill.__unplugin_components_6, null, null) }; return props2.theme === progress_constants.PRO_THEME.CIRCLE ? CIRCLE_ICONS : NORMAL_ICONS; }; var getLabelContent = function getLabelContent() { var labelContent = "".concat(props2.percentage, "%"); var status = props2.status || ""; if (progress_constants.STATUS_ICON.includes(status) && props2.theme !== progress_constants.PRO_THEME.PLUMP) { var components = getIconMap(); var component = components[status]; if (component) { labelContent = vue.createVNode(component, { "class": ["".concat(COMPONENT_NAME.value, "__icon")] }, null); } } return labelContent; }; return function () { var labelContent = vue.createVNode("div", { "class": "".concat(COMPONENT_NAME.value, "__info") }, [renderTNodeJSX("label", getLabelContent())]); var PLUMP_SEPARATE = 10; var separateClasses = props2.percentage > PLUMP_SEPARATE ? "".concat(COMPONENT_NAME.value, "--over-ten") : "".concat(COMPONENT_NAME.value, "--under-ten"); return vue.createVNode("div", { "class": COMPONENT_NAME.value }, [props2.theme === progress_constants.PRO_THEME.LINE && vue.createVNode("div", { "class": "".concat(COMPONENT_NAME.value, "--thin ").concat(COMPONENT_NAME.value, "--status--").concat(statusStyle.value) }, [vue.createVNode("div", { "class": "".concat(COMPONENT_NAME.value, "__bar"), "style": trackBgStyle.value }, [vue.createVNode("div", { "class": "".concat(COMPONENT_NAME.value, "__inner"), "style": barStyle.value }, null)]), labelContent]), props2.theme === progress_constants.PRO_THEME.PLUMP && vue.createVNode("div", { "class": ["".concat(COMPONENT_NAME.value, "__bar ").concat(COMPONENT_NAME.value, "--plump ").concat(separateClasses), _defineProperty__default["default"]({}, "".concat(COMPONENT_NAME.value, "--status--").concat(statusStyle.value), statusStyle.value)], "style": trackBgStyle.value }, [vue.createVNode("div", { "class": "".concat(COMPONENT_NAME.value, "__inner"), "style": barStyle.value }, [props2.percentage > PLUMP_SEPARATE && labelContent]), props2.percentage <= PLUMP_SEPARATE && labelContent]), props2.theme === progress_constants.PRO_THEME.CIRCLE && vue.createVNode("div", { "class": "".concat(COMPONENT_NAME.value, "--circle ").concat(COMPONENT_NAME.value, "--status--").concat(statusStyle.value), "style": circleStyle.value }, [labelContent, vue.createVNode("svg", { "width": diameter.value, "height": diameter.value, "viewBox": "0 0 ".concat(diameter.value, " ").concat(diameter.value) }, [vue.createVNode("circle", { "cx": rPoints.value, "cy": rPoints.value, "r": radius.value, "stroke-width": circleStrokeWidth.value, "fill": "none", "class": ["".concat(COMPONENT_NAME.value, "__circle-outer")], "style": circleOuterStyle.value }, null), props2.percentage > 0 && vue.createVNode("circle", { "cx": rPoints.value, "cy": rPoints.value, "r": radius.value, "stroke-width": circleStrokeWidth.value, "fill": "none", "stroke-linecap": "round", "class": ["".concat(COMPONENT_NAME.value, "__circle-inner")], "transform": "matrix(0,-1,1,0,0,".concat(diameter.value, ")"), "stroke-dasharray": strokeDashArr.value, "style": circlePathStyle.value }, null)])])]); }; } }); exports["default"] = _Progress; //# sourceMappingURL=progress.js.map