index.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. exports.__esModule = true;
  4. exports.default = void 0;
  5. var _babelHelperVueJsxMergeProps = _interopRequireDefault(require("@vue/babel-helper-vue-jsx-merge-props"));
  6. var _utils = require("../utils");
  7. var _functional = require("../utils/functional");
  8. // Utils
  9. var _createNamespace = (0, _utils.createNamespace)('loading'),
  10. createComponent = _createNamespace[0],
  11. bem = _createNamespace[1];
  12. function LoadingIcon(h, props) {
  13. if (props.type === 'spinner') {
  14. var Spin = [];
  15. for (var i = 0; i < 12; i++) {
  16. Spin.push(h("i"));
  17. }
  18. return Spin;
  19. }
  20. return h("svg", {
  21. "class": bem('circular'),
  22. "attrs": {
  23. "viewBox": "25 25 50 50"
  24. }
  25. }, [h("circle", {
  26. "attrs": {
  27. "cx": "50",
  28. "cy": "50",
  29. "r": "20",
  30. "fill": "none"
  31. }
  32. })]);
  33. }
  34. function LoadingText(h, props, slots) {
  35. if (slots.default) {
  36. var _props$textColor;
  37. var style = {
  38. fontSize: (0, _utils.addUnit)(props.textSize),
  39. color: (_props$textColor = props.textColor) != null ? _props$textColor : props.color
  40. };
  41. return h("span", {
  42. "class": bem('text'),
  43. "style": style
  44. }, [slots.default()]);
  45. }
  46. }
  47. function Loading(h, props, slots, ctx) {
  48. var color = props.color,
  49. size = props.size,
  50. type = props.type;
  51. var style = {
  52. color: color
  53. };
  54. if (size) {
  55. var iconSize = (0, _utils.addUnit)(size);
  56. style.width = iconSize;
  57. style.height = iconSize;
  58. }
  59. return h("div", (0, _babelHelperVueJsxMergeProps.default)([{
  60. "class": bem([type, {
  61. vertical: props.vertical
  62. }])
  63. }, (0, _functional.inherit)(ctx, true)]), [h("span", {
  64. "class": bem('spinner', type),
  65. "style": style
  66. }, [LoadingIcon(h, props)]), LoadingText(h, props, slots)]);
  67. }
  68. Loading.props = {
  69. color: String,
  70. size: [Number, String],
  71. vertical: Boolean,
  72. textSize: [Number, String],
  73. textColor: String,
  74. type: {
  75. type: String,
  76. default: 'circular'
  77. }
  78. };
  79. var _default = createComponent(Loading);
  80. exports.default = _default;