LoadingIcon.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.default = void 0;
  7. var _vue = require("vue");
  8. var _LoadingOutlined = _interopRequireDefault(require("@ant-design/icons-vue/lib/icons/LoadingOutlined"));
  9. var _transition = _interopRequireDefault(require("../_util/transition"));
  10. var getCollapsedWidth = function getCollapsedWidth(node) {
  11. if (node) {
  12. node.style.width = '0px';
  13. node.style.opacity = '0';
  14. node.style.transform = 'scale(0)';
  15. }
  16. };
  17. var getRealWidth = function getRealWidth(node) {
  18. (0, _vue.nextTick)(function () {
  19. if (node) {
  20. node.style.width = "".concat(node.scrollWidth, "px");
  21. node.style.opacity = '1';
  22. node.style.transform = 'scale(1)';
  23. }
  24. });
  25. };
  26. var resetStyle = function resetStyle(node) {
  27. if (node && node.style) {
  28. node.style.width = null;
  29. node.style.opacity = null;
  30. node.style.transform = null;
  31. }
  32. };
  33. var _default2 = (0, _vue.defineComponent)({
  34. compatConfig: {
  35. MODE: 3
  36. },
  37. name: 'LoadingIcon',
  38. props: {
  39. prefixCls: String,
  40. loading: [Boolean, Object],
  41. existIcon: Boolean
  42. },
  43. setup: function setup(props) {
  44. return function () {
  45. var existIcon = props.existIcon,
  46. prefixCls = props.prefixCls,
  47. loading = props.loading;
  48. if (existIcon) {
  49. return (0, _vue.createVNode)("span", {
  50. "class": "".concat(prefixCls, "-loading-icon")
  51. }, [(0, _vue.createVNode)(_LoadingOutlined.default, null, null)]);
  52. }
  53. var visible = !!loading;
  54. return (0, _vue.createVNode)(_transition.default, {
  55. "name": "".concat(prefixCls, "-loading-icon-motion"),
  56. "onBeforeEnter": getCollapsedWidth,
  57. "onEnter": getRealWidth,
  58. "onAfterEnter": resetStyle,
  59. "onBeforeLeave": getRealWidth,
  60. "onLeave": function onLeave(node) {
  61. setTimeout(function () {
  62. getCollapsedWidth(node);
  63. });
  64. },
  65. "onAfterLeave": resetStyle
  66. }, {
  67. default: function _default() {
  68. return [visible ? (0, _vue.createVNode)("span", {
  69. "class": "".concat(prefixCls, "-loading-icon")
  70. }, [(0, _vue.createVNode)(_LoadingOutlined.default, null, null)]) : null];
  71. }
  72. });
  73. };
  74. }
  75. });
  76. exports.default = _default2;