Loading.js 2.9 KB

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