Loading.mjs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { computed, defineComponent, createVNode as _createVNode } from "vue";
  2. import { extend, addUnit, numericProp, getSizeStyle, makeStringProp, createNamespace } from "../utils/index.mjs";
  3. const [name, bem] = createNamespace("loading");
  4. const SpinIcon = Array(12).fill(null).map((_, index) => _createVNode("i", {
  5. "class": bem("line", String(index + 1))
  6. }, null));
  7. const CircularIcon = _createVNode("svg", {
  8. "class": bem("circular"),
  9. "viewBox": "25 25 50 50"
  10. }, [_createVNode("circle", {
  11. "cx": "50",
  12. "cy": "50",
  13. "r": "20",
  14. "fill": "none"
  15. }, null)]);
  16. const loadingProps = {
  17. size: numericProp,
  18. type: makeStringProp("circular"),
  19. color: String,
  20. vertical: Boolean,
  21. textSize: numericProp,
  22. textColor: String
  23. };
  24. var stdin_default = defineComponent({
  25. name,
  26. props: loadingProps,
  27. setup(props, {
  28. slots
  29. }) {
  30. const spinnerStyle = computed(() => extend({
  31. color: props.color
  32. }, getSizeStyle(props.size)));
  33. const renderIcon = () => {
  34. const DefaultIcon = props.type === "spinner" ? SpinIcon : CircularIcon;
  35. return _createVNode("span", {
  36. "class": bem("spinner", props.type),
  37. "style": spinnerStyle.value
  38. }, [slots.icon ? slots.icon() : DefaultIcon]);
  39. };
  40. const renderText = () => {
  41. var _a;
  42. if (slots.default) {
  43. return _createVNode("span", {
  44. "class": bem("text"),
  45. "style": {
  46. fontSize: addUnit(props.textSize),
  47. color: (_a = props.textColor) != null ? _a : props.color
  48. }
  49. }, [slots.default()]);
  50. }
  51. };
  52. return () => {
  53. const {
  54. type,
  55. vertical
  56. } = props;
  57. return _createVNode("div", {
  58. "class": bem([type, {
  59. vertical
  60. }]),
  61. "aria-live": "polite",
  62. "aria-busy": true
  63. }, [renderIcon(), renderText()]);
  64. };
  65. }
  66. });
  67. export {
  68. stdin_default as default,
  69. loadingProps
  70. };