Progress.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. var __defProp = Object.defineProperty;
  2. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  3. var __getOwnPropNames = Object.getOwnPropertyNames;
  4. var __hasOwnProp = Object.prototype.hasOwnProperty;
  5. var __export = (target, all) => {
  6. for (var name2 in all)
  7. __defProp(target, name2, { get: all[name2], enumerable: true });
  8. };
  9. var __copyProps = (to, from, except, desc) => {
  10. if (from && typeof from === "object" || typeof from === "function") {
  11. for (let key of __getOwnPropNames(from))
  12. if (!__hasOwnProp.call(to, key) && key !== except)
  13. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  14. }
  15. return to;
  16. };
  17. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  18. var stdin_exports = {};
  19. __export(stdin_exports, {
  20. default: () => stdin_default,
  21. progressProps: () => progressProps
  22. });
  23. module.exports = __toCommonJS(stdin_exports);
  24. var import_vue = require("vue");
  25. var import_vue2 = require("vue");
  26. var import_utils = require("../utils");
  27. const [name, bem] = (0, import_utils.createNamespace)("progress");
  28. const progressProps = {
  29. color: String,
  30. inactive: Boolean,
  31. pivotText: String,
  32. textColor: String,
  33. showPivot: import_utils.truthProp,
  34. pivotColor: String,
  35. trackColor: String,
  36. strokeWidth: import_utils.numericProp,
  37. percentage: {
  38. type: import_utils.numericProp,
  39. default: 0,
  40. validator: (value) => value >= 0 && value <= 100
  41. }
  42. };
  43. var stdin_default = (0, import_vue2.defineComponent)({
  44. name,
  45. props: progressProps,
  46. setup(props) {
  47. const background = (0, import_vue2.computed)(() => props.inactive ? void 0 : props.color);
  48. const renderPivot = () => {
  49. const {
  50. textColor,
  51. pivotText,
  52. pivotColor,
  53. percentage
  54. } = props;
  55. const text = pivotText != null ? pivotText : `${percentage}%`;
  56. if (props.showPivot && text) {
  57. const style = {
  58. color: textColor,
  59. left: `${+percentage}%`,
  60. transform: `translate(-${+percentage}%,-50%)`,
  61. background: pivotColor || background.value
  62. };
  63. return (0, import_vue.createVNode)("span", {
  64. "style": style,
  65. "class": bem("pivot", {
  66. inactive: props.inactive
  67. })
  68. }, [text]);
  69. }
  70. };
  71. return () => {
  72. const {
  73. trackColor,
  74. percentage,
  75. strokeWidth
  76. } = props;
  77. const rootStyle = {
  78. background: trackColor,
  79. height: (0, import_utils.addUnit)(strokeWidth)
  80. };
  81. const portionStyle = {
  82. width: `${percentage}%`,
  83. background: background.value
  84. };
  85. return (0, import_vue.createVNode)("div", {
  86. "class": bem(),
  87. "style": rootStyle
  88. }, [(0, import_vue.createVNode)("span", {
  89. "class": bem("portion", {
  90. inactive: props.inactive
  91. }),
  92. "style": portionStyle
  93. }, null), renderPivot()]);
  94. };
  95. }
  96. });