index11.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. import { g as E, m as L, d as x, r as X, a3 as M, i as _, u as P, _ as I, a1 as G, P as T, bn as A } from "./index2.js";
  2. import { defineComponent as B, shallowRef as H, watch as j, onBeforeUnmount as R, createVNode as r, isVNode as N, cloneVNode as O } from "vue";
  3. function V(n, e, c) {
  4. var t = c || {}, i = t.noTrailing, m = i === void 0 ? !1 : i, b = t.noLeading, $ = b === void 0 ? !1 : b, y = t.debounceMode, a = y === void 0 ? void 0 : y, o, g = !1, f = 0;
  5. function D() {
  6. o && clearTimeout(o);
  7. }
  8. function z(d) {
  9. var v = d || {}, p = v.upcomingOnly, h = p === void 0 ? !1 : p;
  10. D(), g = !h;
  11. }
  12. function S() {
  13. for (var d = arguments.length, v = new Array(d), p = 0; p < d; p++)
  14. v[p] = arguments[p];
  15. var h = this, l = Date.now() - f;
  16. if (g)
  17. return;
  18. function u() {
  19. f = Date.now(), e.apply(h, v);
  20. }
  21. function s() {
  22. o = void 0;
  23. }
  24. !$ && a && !o && u(), D(), a === void 0 && l > n ? $ ? (f = Date.now(), m || (o = setTimeout(a ? s : u, n))) : u() : m !== !0 && (o = setTimeout(a ? s : u, a === void 0 ? n - l : n));
  25. }
  26. return S.cancel = z, S;
  27. }
  28. function F(n, e, c) {
  29. var t = {}, i = t.atBegin, m = i === void 0 ? !1 : i;
  30. return V(n, e, {
  31. debounceMode: m !== !1
  32. });
  33. }
  34. const K = new M("antSpinMove", {
  35. to: {
  36. opacity: 1
  37. }
  38. }), U = new M("antRotate", {
  39. to: {
  40. transform: "rotate(405deg)"
  41. }
  42. }), q = (n) => ({
  43. [`${n.componentCls}`]: x(x({}, X(n)), {
  44. position: "absolute",
  45. display: "none",
  46. color: n.colorPrimary,
  47. textAlign: "center",
  48. verticalAlign: "middle",
  49. opacity: 0,
  50. transition: `transform ${n.motionDurationSlow} ${n.motionEaseInOutCirc}`,
  51. "&-spinning": {
  52. position: "static",
  53. display: "inline-block",
  54. opacity: 1
  55. },
  56. "&-nested-loading": {
  57. position: "relative",
  58. [`> div > ${n.componentCls}`]: {
  59. position: "absolute",
  60. top: 0,
  61. insetInlineStart: 0,
  62. zIndex: 4,
  63. display: "block",
  64. width: "100%",
  65. height: "100%",
  66. maxHeight: n.contentHeight,
  67. [`${n.componentCls}-dot`]: {
  68. position: "absolute",
  69. top: "50%",
  70. insetInlineStart: "50%",
  71. margin: -n.spinDotSize / 2
  72. },
  73. [`${n.componentCls}-text`]: {
  74. position: "absolute",
  75. top: "50%",
  76. width: "100%",
  77. paddingTop: (n.spinDotSize - n.fontSize) / 2 + 2,
  78. textShadow: `0 1px 2px ${n.colorBgContainer}`
  79. // FIXME: shadow
  80. },
  81. [`&${n.componentCls}-show-text ${n.componentCls}-dot`]: {
  82. marginTop: -(n.spinDotSize / 2) - 10
  83. },
  84. "&-sm": {
  85. [`${n.componentCls}-dot`]: {
  86. margin: -n.spinDotSizeSM / 2
  87. },
  88. [`${n.componentCls}-text`]: {
  89. paddingTop: (n.spinDotSizeSM - n.fontSize) / 2 + 2
  90. },
  91. [`&${n.componentCls}-show-text ${n.componentCls}-dot`]: {
  92. marginTop: -(n.spinDotSizeSM / 2) - 10
  93. }
  94. },
  95. "&-lg": {
  96. [`${n.componentCls}-dot`]: {
  97. margin: -(n.spinDotSizeLG / 2)
  98. },
  99. [`${n.componentCls}-text`]: {
  100. paddingTop: (n.spinDotSizeLG - n.fontSize) / 2 + 2
  101. },
  102. [`&${n.componentCls}-show-text ${n.componentCls}-dot`]: {
  103. marginTop: -(n.spinDotSizeLG / 2) - 10
  104. }
  105. }
  106. },
  107. [`${n.componentCls}-container`]: {
  108. position: "relative",
  109. transition: `opacity ${n.motionDurationSlow}`,
  110. "&::after": {
  111. position: "absolute",
  112. top: 0,
  113. insetInlineEnd: 0,
  114. bottom: 0,
  115. insetInlineStart: 0,
  116. zIndex: 10,
  117. width: "100%",
  118. height: "100%",
  119. background: n.colorBgContainer,
  120. opacity: 0,
  121. transition: `all ${n.motionDurationSlow}`,
  122. content: '""',
  123. pointerEvents: "none"
  124. }
  125. },
  126. [`${n.componentCls}-blur`]: {
  127. clear: "both",
  128. opacity: 0.5,
  129. userSelect: "none",
  130. pointerEvents: "none",
  131. "&::after": {
  132. opacity: 0.4,
  133. pointerEvents: "auto"
  134. }
  135. }
  136. },
  137. // tip
  138. // ------------------------------
  139. "&-tip": {
  140. color: n.spinDotDefault
  141. },
  142. // dots
  143. // ------------------------------
  144. [`${n.componentCls}-dot`]: {
  145. position: "relative",
  146. display: "inline-block",
  147. fontSize: n.spinDotSize,
  148. width: "1em",
  149. height: "1em",
  150. "&-item": {
  151. position: "absolute",
  152. display: "block",
  153. width: (n.spinDotSize - n.marginXXS / 2) / 2,
  154. height: (n.spinDotSize - n.marginXXS / 2) / 2,
  155. backgroundColor: n.colorPrimary,
  156. borderRadius: "100%",
  157. transform: "scale(0.75)",
  158. transformOrigin: "50% 50%",
  159. opacity: 0.3,
  160. animationName: K,
  161. animationDuration: "1s",
  162. animationIterationCount: "infinite",
  163. animationTimingFunction: "linear",
  164. animationDirection: "alternate",
  165. "&:nth-child(1)": {
  166. top: 0,
  167. insetInlineStart: 0
  168. },
  169. "&:nth-child(2)": {
  170. top: 0,
  171. insetInlineEnd: 0,
  172. animationDelay: "0.4s"
  173. },
  174. "&:nth-child(3)": {
  175. insetInlineEnd: 0,
  176. bottom: 0,
  177. animationDelay: "0.8s"
  178. },
  179. "&:nth-child(4)": {
  180. bottom: 0,
  181. insetInlineStart: 0,
  182. animationDelay: "1.2s"
  183. }
  184. },
  185. "&-spin": {
  186. transform: "rotate(45deg)",
  187. animationName: U,
  188. animationDuration: "1.2s",
  189. animationIterationCount: "infinite",
  190. animationTimingFunction: "linear"
  191. }
  192. },
  193. // Sizes
  194. // ------------------------------
  195. // small
  196. [`&-sm ${n.componentCls}-dot`]: {
  197. fontSize: n.spinDotSizeSM,
  198. i: {
  199. width: (n.spinDotSizeSM - n.marginXXS / 2) / 2,
  200. height: (n.spinDotSizeSM - n.marginXXS / 2) / 2
  201. }
  202. },
  203. // large
  204. [`&-lg ${n.componentCls}-dot`]: {
  205. fontSize: n.spinDotSizeLG,
  206. i: {
  207. width: (n.spinDotSizeLG - n.marginXXS) / 2,
  208. height: (n.spinDotSizeLG - n.marginXXS) / 2
  209. }
  210. },
  211. [`&${n.componentCls}-show-text ${n.componentCls}-text`]: {
  212. display: "block"
  213. }
  214. })
  215. }), J = E("Spin", (n) => {
  216. const e = L(n, {
  217. spinDotDefault: n.colorTextDescription,
  218. spinDotSize: n.controlHeightLG / 2,
  219. spinDotSizeSM: n.controlHeightLG * 0.35,
  220. spinDotSizeLG: n.controlHeight
  221. });
  222. return [q(e)];
  223. }, {
  224. contentHeight: 400
  225. });
  226. var Q = function(n, e) {
  227. var c = {};
  228. for (var t in n) Object.prototype.hasOwnProperty.call(n, t) && e.indexOf(t) < 0 && (c[t] = n[t]);
  229. if (n != null && typeof Object.getOwnPropertySymbols == "function") for (var i = 0, t = Object.getOwnPropertySymbols(n); i < t.length; i++)
  230. e.indexOf(t[i]) < 0 && Object.prototype.propertyIsEnumerable.call(n, t[i]) && (c[t[i]] = n[t[i]]);
  231. return c;
  232. };
  233. const W = () => ({
  234. prefixCls: String,
  235. spinning: {
  236. type: Boolean,
  237. default: void 0
  238. },
  239. size: String,
  240. wrapperClassName: String,
  241. tip: T.any,
  242. delay: Number,
  243. indicator: T.any
  244. });
  245. let C = null;
  246. function Y(n, e) {
  247. return !!n && !!e && !isNaN(Number(e));
  248. }
  249. function Z(n) {
  250. const e = n.indicator;
  251. C = typeof e == "function" ? e : () => r(e, null, null);
  252. }
  253. const w = B({
  254. compatConfig: {
  255. MODE: 3
  256. },
  257. name: "ASpin",
  258. inheritAttrs: !1,
  259. props: _(W(), {
  260. size: "default",
  261. spinning: !0,
  262. wrapperClassName: ""
  263. }),
  264. setup(n, e) {
  265. let {
  266. attrs: c,
  267. slots: t
  268. } = e;
  269. const {
  270. prefixCls: i,
  271. size: m,
  272. direction: b
  273. } = P("spin", n), [$, y] = J(i), a = H(n.spinning && !Y(n.spinning, n.delay));
  274. let o;
  275. return j([() => n.spinning, () => n.delay], () => {
  276. o == null || o.cancel(), o = F(n.delay, () => {
  277. a.value = n.spinning;
  278. }), o == null || o();
  279. }, {
  280. immediate: !0,
  281. flush: "post"
  282. }), R(() => {
  283. o == null || o.cancel();
  284. }), () => {
  285. var g, f;
  286. const {
  287. class: D
  288. } = c, z = Q(c, ["class"]), {
  289. tip: S = (g = t.tip) === null || g === void 0 ? void 0 : g.call(t)
  290. } = n, d = (f = t.default) === null || f === void 0 ? void 0 : f.call(t), v = {
  291. [y.value]: !0,
  292. [i.value]: !0,
  293. [`${i.value}-sm`]: m.value === "small",
  294. [`${i.value}-lg`]: m.value === "large",
  295. [`${i.value}-spinning`]: a.value,
  296. [`${i.value}-show-text`]: !!S,
  297. [`${i.value}-rtl`]: b.value === "rtl",
  298. [D]: !!D
  299. };
  300. function p(l) {
  301. const u = `${l}-dot`;
  302. let s = A(t, n, "indicator");
  303. return s === null ? null : (Array.isArray(s) && (s = s.length === 1 ? s[0] : s), N(s) ? O(s, {
  304. class: u
  305. }) : C && N(C()) ? O(C(), {
  306. class: u
  307. }) : r("span", {
  308. class: `${u} ${l}-dot-spin`
  309. }, [r("i", {
  310. class: `${l}-dot-item`
  311. }, null), r("i", {
  312. class: `${l}-dot-item`
  313. }, null), r("i", {
  314. class: `${l}-dot-item`
  315. }, null), r("i", {
  316. class: `${l}-dot-item`
  317. }, null)]));
  318. }
  319. const h = r("div", I(I({}, z), {}, {
  320. class: v,
  321. "aria-live": "polite",
  322. "aria-busy": a.value
  323. }), [p(i.value), S ? r("div", {
  324. class: `${i.value}-text`
  325. }, [S]) : null]);
  326. if (d && G(d).length) {
  327. const l = {
  328. [`${i.value}-container`]: !0,
  329. [`${i.value}-blur`]: a.value
  330. };
  331. return $(r("div", {
  332. class: [`${i.value}-nested-loading`, n.wrapperClassName, y.value]
  333. }, [a.value && r("div", {
  334. key: "loading"
  335. }, [h]), r("div", {
  336. class: l,
  337. key: "container"
  338. }, [d])]));
  339. }
  340. return $(h);
  341. };
  342. }
  343. });
  344. w.setDefaultIndicator = Z;
  345. w.install = function(n) {
  346. return n.component(w.name, w), n;
  347. };
  348. export {
  349. w as S
  350. };