Loading.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. });
  22. module.exports = __toCommonJS(stdin_exports);
  23. var import_vue = require("vue");
  24. var import_vue2 = require("vue");
  25. var import_utils = require("../utils");
  26. const [name, bem] = (0, import_utils.createNamespace)("loading");
  27. const SpinIcon = Array(12).fill(null).map((_, index) => (0, import_vue.createVNode)("i", {
  28. "class": bem("line", String(index + 1))
  29. }, null));
  30. const CircularIcon = (0, import_vue.createVNode)("svg", {
  31. "class": bem("circular"),
  32. "viewBox": "25 25 50 50"
  33. }, [(0, import_vue.createVNode)("circle", {
  34. "cx": "50",
  35. "cy": "50",
  36. "r": "20",
  37. "fill": "none"
  38. }, null)]);
  39. const loadingProps = {
  40. size: import_utils.numericProp,
  41. type: (0, import_utils.makeStringProp)("circular"),
  42. color: String,
  43. vertical: Boolean,
  44. textSize: import_utils.numericProp,
  45. textColor: String
  46. };
  47. var stdin_default = (0, import_vue2.defineComponent)({
  48. name,
  49. props: loadingProps,
  50. setup(props, {
  51. slots
  52. }) {
  53. const spinnerStyle = (0, import_vue2.computed)(() => (0, import_utils.extend)({
  54. color: props.color
  55. }, (0, import_utils.getSizeStyle)(props.size)));
  56. const renderText = () => {
  57. var _a;
  58. if (slots.default) {
  59. return (0, import_vue.createVNode)("span", {
  60. "class": bem("text"),
  61. "style": {
  62. fontSize: (0, import_utils.addUnit)(props.textSize),
  63. color: (_a = props.textColor) != null ? _a : props.color
  64. }
  65. }, [slots.default()]);
  66. }
  67. };
  68. return () => {
  69. const {
  70. type,
  71. vertical
  72. } = props;
  73. return (0, import_vue.createVNode)("div", {
  74. "class": bem([type, {
  75. vertical
  76. }]),
  77. "aria-live": "polite",
  78. "aria-busy": true
  79. }, [(0, import_vue.createVNode)("span", {
  80. "class": bem("spinner", type),
  81. "style": spinnerStyle.value
  82. }, [type === "spinner" ? SpinIcon : CircularIcon]), renderText()]);
  83. };
  84. }
  85. });