LoadingIcon.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. const getCollapsedWidth = node => {
  10. if (node) {
  11. node.style.width = '0px';
  12. node.style.opacity = '0';
  13. node.style.transform = 'scale(0)';
  14. }
  15. };
  16. const getRealWidth = node => {
  17. (0, _vue.nextTick)(() => {
  18. if (node) {
  19. node.style.width = `${node.scrollWidth}px`;
  20. node.style.opacity = '1';
  21. node.style.transform = 'scale(1)';
  22. }
  23. });
  24. };
  25. const resetStyle = node => {
  26. if (node && node.style) {
  27. node.style.width = null;
  28. node.style.opacity = null;
  29. node.style.transform = null;
  30. }
  31. };
  32. var _default = exports.default = (0, _vue.defineComponent)({
  33. compatConfig: {
  34. MODE: 3
  35. },
  36. name: 'LoadingIcon',
  37. props: {
  38. prefixCls: String,
  39. loading: [Boolean, Object],
  40. existIcon: Boolean
  41. },
  42. setup(props) {
  43. return () => {
  44. const {
  45. existIcon,
  46. prefixCls,
  47. loading
  48. } = props;
  49. if (existIcon) {
  50. return (0, _vue.createVNode)("span", {
  51. "class": `${prefixCls}-loading-icon`
  52. }, [(0, _vue.createVNode)(_LoadingOutlined.default, null, null)]);
  53. }
  54. const visible = !!loading;
  55. return (0, _vue.createVNode)(_vue.Transition, {
  56. "name": `${prefixCls}-loading-icon-motion`,
  57. "onBeforeEnter": getCollapsedWidth,
  58. "onEnter": getRealWidth,
  59. "onAfterEnter": resetStyle,
  60. "onBeforeLeave": getRealWidth,
  61. "onLeave": node => {
  62. setTimeout(() => {
  63. getCollapsedWidth(node);
  64. });
  65. },
  66. "onAfterLeave": resetStyle
  67. }, {
  68. default: () => [visible ? (0, _vue.createVNode)("span", {
  69. "class": `${prefixCls}-loading-icon`
  70. }, [(0, _vue.createVNode)(_LoadingOutlined.default, null, null)]) : null]
  71. });
  72. };
  73. }
  74. });