Loading.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. loadingProps: () => loadingProps
  22. });
  23. module.exports = __toCommonJS(stdin_exports);
  24. var import_vue = 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_vue.defineComponent)({
  48. name,
  49. props: loadingProps,
  50. setup(props, {
  51. slots
  52. }) {
  53. const spinnerStyle = (0, import_vue.computed)(() => (0, import_utils.extend)({
  54. color: props.color
  55. }, (0, import_utils.getSizeStyle)(props.size)));
  56. const renderIcon = () => {
  57. const DefaultIcon = props.type === "spinner" ? SpinIcon : CircularIcon;
  58. return (0, import_vue.createVNode)("span", {
  59. "class": bem("spinner", props.type),
  60. "style": spinnerStyle.value
  61. }, [slots.icon ? slots.icon() : DefaultIcon]);
  62. };
  63. const renderText = () => {
  64. var _a;
  65. if (slots.default) {
  66. return (0, import_vue.createVNode)("span", {
  67. "class": bem("text"),
  68. "style": {
  69. fontSize: (0, import_utils.addUnit)(props.textSize),
  70. color: (_a = props.textColor) != null ? _a : props.color
  71. }
  72. }, [slots.default()]);
  73. }
  74. };
  75. return () => {
  76. const {
  77. type,
  78. vertical
  79. } = props;
  80. return (0, import_vue.createVNode)("div", {
  81. "class": bem([type, {
  82. vertical
  83. }]),
  84. "aria-live": "polite",
  85. "aria-busy": true
  86. }, [renderIcon(), renderText()]);
  87. };
  88. }
  89. });