SAnchor.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. import { defineComponent as G, shallowRef as J, reactive as se, getCurrentInstance as ge, computed as F, watch as W, onMounted as V, onUpdated as ae, onUnmounted as me, createVNode as b, provide as ve, inject as xe, nextTick as X, onBeforeUnmount as ce, ref as U, openBlock as ke, createBlock as ye } from "vue";
  2. import { w as Q, a as q, s as Ce, g as fe, m as ue, b as Se, u as K, c as D, o as Te, R as we, _ as z, d as N, r as $e, t as be, i as Ae, e as Be, f as Pe, h as Z, j as Ee, k as Ie, P as Le, l as _e } from "./index2.js";
  3. import { s as Ne } from "./index3.js";
  4. function ee(e) {
  5. let n;
  6. const o = (r) => () => {
  7. n = null, e(...r);
  8. }, i = function() {
  9. if (n == null) {
  10. for (var r = arguments.length, p = new Array(r), u = 0; u < r; u++)
  11. p[u] = arguments[u];
  12. n = Q(o(p));
  13. }
  14. };
  15. return i.cancel = () => {
  16. Q.cancel(n), n = null;
  17. }, i;
  18. }
  19. function j(e) {
  20. return e !== window ? e.getBoundingClientRect() : {
  21. top: 0,
  22. bottom: window.innerHeight
  23. };
  24. }
  25. function te(e, n, o) {
  26. if (o !== void 0 && n.top > e.top - o)
  27. return `${o + n.top}px`;
  28. }
  29. function ne(e, n, o) {
  30. if (o !== void 0 && n.bottom < e.bottom + o) {
  31. const i = window.innerHeight - n.bottom;
  32. return `${o + i}px`;
  33. }
  34. }
  35. const de = ["resize", "scroll", "touchstart", "touchmove", "touchend", "pageshow", "load"];
  36. let H = [];
  37. function oe(e, n) {
  38. if (!e) return;
  39. let o = H.find((i) => i.target === e);
  40. o ? o.affixList.push(n) : (o = {
  41. target: e,
  42. affixList: [n],
  43. eventHandlers: {}
  44. }, H.push(o), de.forEach((i) => {
  45. o.eventHandlers[i] = q(e, i, () => {
  46. o.affixList.forEach((r) => {
  47. const {
  48. lazyUpdatePosition: p
  49. } = r.exposed;
  50. p();
  51. }, (i === "touchstart" || i === "touchmove") && Ce ? {
  52. passive: !0
  53. } : !1);
  54. });
  55. }));
  56. }
  57. function ie(e) {
  58. const n = H.find((o) => {
  59. const i = o.affixList.some((r) => r === e);
  60. return i && (o.affixList = o.affixList.filter((r) => r !== e)), i;
  61. });
  62. n && n.affixList.length === 0 && (H = H.filter((o) => o !== n), de.forEach((o) => {
  63. const i = n.eventHandlers[o];
  64. i && i.remove && i.remove();
  65. }));
  66. }
  67. const ze = (e) => {
  68. const {
  69. componentCls: n
  70. } = e;
  71. return {
  72. [n]: {
  73. position: "fixed",
  74. zIndex: e.zIndexPopup
  75. }
  76. };
  77. }, Oe = fe("Affix", (e) => {
  78. const n = ue(e, {
  79. zIndexPopup: e.zIndexBase + 10
  80. });
  81. return [ze(n)];
  82. });
  83. function Re() {
  84. return typeof window != "undefined" ? window : null;
  85. }
  86. var R;
  87. (function(e) {
  88. e[e.None = 0] = "None", e[e.Prepare = 1] = "Prepare";
  89. })(R || (R = {}));
  90. const De = () => ({
  91. /**
  92. * 距离窗口顶部达到指定偏移量后触发
  93. */
  94. offsetTop: Number,
  95. /** 距离窗口底部达到指定偏移量后触发 */
  96. offsetBottom: Number,
  97. /** 设置 Affix 需要监听其滚动事件的元素,值为一个返回对应 DOM 元素的函数 */
  98. target: {
  99. type: Function,
  100. default: Re
  101. },
  102. prefixCls: String,
  103. /** 固定状态改变时触发的回调函数 */
  104. onChange: Function,
  105. onTestUpdatePosition: Function
  106. }), Fe = G({
  107. compatConfig: {
  108. MODE: 3
  109. },
  110. name: "AAffix",
  111. inheritAttrs: !1,
  112. props: De(),
  113. setup(e, n) {
  114. let {
  115. slots: o,
  116. emit: i,
  117. expose: r,
  118. attrs: p
  119. } = n;
  120. const u = J(), g = J(), a = se({
  121. affixStyle: void 0,
  122. placeholderStyle: void 0,
  123. status: R.None,
  124. lastAffix: !1,
  125. prevTarget: null,
  126. timeout: null
  127. }), x = ge(), k = F(() => e.offsetBottom === void 0 && e.offsetTop === void 0 ? 0 : e.offsetTop), y = F(() => e.offsetBottom), w = () => {
  128. const {
  129. status: c,
  130. lastAffix: d
  131. } = a, {
  132. target: A
  133. } = e;
  134. if (c !== R.Prepare || !g.value || !u.value || !A)
  135. return;
  136. const P = A();
  137. if (!P)
  138. return;
  139. const v = {
  140. status: R.None
  141. }, t = j(u.value);
  142. if (t.top === 0 && t.left === 0 && t.width === 0 && t.height === 0)
  143. return;
  144. const l = j(P), m = te(t, l, k.value), T = ne(t, l, y.value);
  145. if (!(t.top === 0 && t.left === 0 && t.width === 0 && t.height === 0)) {
  146. if (m !== void 0) {
  147. const f = `${t.width}px`, h = `${t.height}px`;
  148. v.affixStyle = {
  149. position: "fixed",
  150. top: m,
  151. width: f,
  152. height: h
  153. }, v.placeholderStyle = {
  154. width: f,
  155. height: h
  156. };
  157. } else if (T !== void 0) {
  158. const f = `${t.width}px`, h = `${t.height}px`;
  159. v.affixStyle = {
  160. position: "fixed",
  161. bottom: T,
  162. width: f,
  163. height: h
  164. }, v.placeholderStyle = {
  165. width: f,
  166. height: h
  167. };
  168. }
  169. v.lastAffix = !!v.affixStyle, d !== v.lastAffix && i("change", v.lastAffix), N(a, v);
  170. }
  171. }, s = () => {
  172. N(a, {
  173. status: R.Prepare,
  174. affixStyle: void 0,
  175. placeholderStyle: void 0
  176. }), process.env.NODE_ENV === "test" && i("testUpdatePosition");
  177. }, C = ee(() => {
  178. s();
  179. }), S = ee(() => {
  180. const {
  181. target: c
  182. } = e, {
  183. affixStyle: d
  184. } = a;
  185. if (c && d) {
  186. const A = c();
  187. if (A && u.value) {
  188. const P = j(A), v = j(u.value), t = te(v, P, k.value), l = ne(v, P, y.value);
  189. if (t !== void 0 && d.top === t || l !== void 0 && d.bottom === l)
  190. return;
  191. }
  192. }
  193. s();
  194. });
  195. r({
  196. updatePosition: C,
  197. lazyUpdatePosition: S
  198. }), W(() => e.target, (c) => {
  199. const d = (c == null ? void 0 : c()) || null;
  200. a.prevTarget !== d && (ie(x), d && (oe(d, x), C()), a.prevTarget = d);
  201. }), W(() => [e.offsetTop, e.offsetBottom], C), V(() => {
  202. const {
  203. target: c
  204. } = e;
  205. c && (a.timeout = setTimeout(() => {
  206. oe(c(), x), C();
  207. }));
  208. }), ae(() => {
  209. w();
  210. }), me(() => {
  211. clearTimeout(a.timeout), ie(x), C.cancel(), S.cancel();
  212. });
  213. const {
  214. prefixCls: I
  215. } = K("affix", e), [B, L] = Oe(I);
  216. return () => {
  217. var c;
  218. const {
  219. affixStyle: d,
  220. placeholderStyle: A,
  221. status: P
  222. } = a, v = D({
  223. [I.value]: d,
  224. [L.value]: !0
  225. }), t = Te(e, ["prefixCls", "offsetTop", "offsetBottom", "target", "onChange", "onTestUpdatePosition"]);
  226. return B(b(we, {
  227. onResize: C
  228. }, {
  229. default: () => [b("div", z(z(z({}, t), p), {}, {
  230. ref: u,
  231. "data-measure-status": P
  232. }), [d && b("div", {
  233. style: A,
  234. "aria-hidden": "true"
  235. }, null), b("div", {
  236. class: v,
  237. ref: g,
  238. style: d
  239. }, [(c = o.default) === null || c === void 0 ? void 0 : c.call(o)])])]
  240. }));
  241. };
  242. }
  243. }), He = Se(Fe);
  244. function M() {
  245. }
  246. const he = Symbol("anchorContextKey"), je = (e) => {
  247. ve(he, e);
  248. }, Me = () => xe(he, {
  249. registerLink: M,
  250. unregisterLink: M,
  251. scrollTo: M,
  252. activeLink: F(() => ""),
  253. handleClick: M,
  254. direction: F(() => "vertical")
  255. }), Ue = (e) => {
  256. const {
  257. componentCls: n,
  258. holderOffsetBlock: o,
  259. motionDurationSlow: i,
  260. lineWidthBold: r,
  261. colorPrimary: p,
  262. lineType: u,
  263. colorSplit: g
  264. } = e;
  265. return {
  266. [`${n}-wrapper`]: {
  267. marginBlockStart: -o,
  268. paddingBlockStart: o,
  269. // delete overflow: auto
  270. // overflow: 'auto',
  271. backgroundColor: "transparent",
  272. [n]: N(N({}, $e(e)), {
  273. position: "relative",
  274. paddingInlineStart: r,
  275. [`${n}-link`]: {
  276. paddingBlock: e.anchorPaddingBlock,
  277. paddingInline: `${e.anchorPaddingInline}px 0`,
  278. "&-title": N(N({}, be), {
  279. position: "relative",
  280. display: "block",
  281. marginBlockEnd: e.anchorTitleBlock,
  282. color: e.colorText,
  283. transition: `all ${e.motionDurationSlow}`,
  284. "&:only-child": {
  285. marginBlockEnd: 0
  286. }
  287. }),
  288. [`&-active > ${n}-link-title`]: {
  289. color: e.colorPrimary
  290. },
  291. // link link
  292. [`${n}-link`]: {
  293. paddingBlock: e.anchorPaddingBlockSecondary
  294. }
  295. }
  296. }),
  297. [`&:not(${n}-wrapper-horizontal)`]: {
  298. [n]: {
  299. "&::before": {
  300. position: "absolute",
  301. left: {
  302. _skip_check_: !0,
  303. value: 0
  304. },
  305. top: 0,
  306. height: "100%",
  307. borderInlineStart: `${r}px ${u} ${g}`,
  308. content: '" "'
  309. },
  310. [`${n}-ink`]: {
  311. position: "absolute",
  312. left: {
  313. _skip_check_: !0,
  314. value: 0
  315. },
  316. display: "none",
  317. transform: "translateY(-50%)",
  318. transition: `top ${i} ease-in-out`,
  319. width: r,
  320. backgroundColor: p,
  321. [`&${n}-ink-visible`]: {
  322. display: "inline-block"
  323. }
  324. }
  325. }
  326. },
  327. [`${n}-fixed ${n}-ink ${n}-ink`]: {
  328. display: "none"
  329. }
  330. }
  331. };
  332. }, Ve = (e) => {
  333. const {
  334. componentCls: n,
  335. motionDurationSlow: o,
  336. lineWidthBold: i,
  337. colorPrimary: r
  338. } = e;
  339. return {
  340. [`${n}-wrapper-horizontal`]: {
  341. position: "relative",
  342. "&::before": {
  343. position: "absolute",
  344. left: {
  345. _skip_check_: !0,
  346. value: 0
  347. },
  348. right: {
  349. _skip_check_: !0,
  350. value: 0
  351. },
  352. bottom: 0,
  353. borderBottom: `1px ${e.lineType} ${e.colorSplit}`,
  354. content: '" "'
  355. },
  356. [n]: {
  357. overflowX: "scroll",
  358. position: "relative",
  359. display: "flex",
  360. scrollbarWidth: "none",
  361. "&::-webkit-scrollbar": {
  362. display: "none"
  363. /* Safari and Chrome */
  364. },
  365. [`${n}-link:first-of-type`]: {
  366. paddingInline: 0
  367. },
  368. [`${n}-ink`]: {
  369. position: "absolute",
  370. bottom: 0,
  371. transition: `left ${o} ease-in-out, width ${o} ease-in-out`,
  372. height: i,
  373. backgroundColor: r
  374. }
  375. }
  376. }
  377. };
  378. }, We = fe("Anchor", (e) => {
  379. const {
  380. fontSize: n,
  381. fontSizeLG: o,
  382. padding: i,
  383. paddingXXS: r
  384. } = e, p = ue(e, {
  385. holderOffsetBlock: r,
  386. anchorPaddingBlock: r,
  387. anchorPaddingBlockSecondary: r / 2,
  388. anchorPaddingInline: i,
  389. anchorTitleBlock: n / 14 * 3,
  390. anchorBallSize: o / 2
  391. });
  392. return [Ue(p), Ve(p)];
  393. }), qe = () => ({
  394. prefixCls: String,
  395. href: String,
  396. title: Pe(),
  397. target: String,
  398. /* private use */
  399. customTitleProps: Be()
  400. }), pe = G({
  401. compatConfig: {
  402. MODE: 3
  403. },
  404. name: "AAnchorLink",
  405. inheritAttrs: !1,
  406. props: Ae(qe(), {
  407. href: "#"
  408. }),
  409. slots: Object,
  410. setup(e, n) {
  411. let {
  412. slots: o,
  413. attrs: i
  414. } = n, r = null;
  415. const {
  416. handleClick: p,
  417. scrollTo: u,
  418. unregisterLink: g,
  419. registerLink: a,
  420. activeLink: x
  421. } = Me(), {
  422. prefixCls: k
  423. } = K("anchor", e), y = (w) => {
  424. const {
  425. href: s
  426. } = e;
  427. p(w, {
  428. title: r,
  429. href: s
  430. }), u(s);
  431. };
  432. return W(() => e.href, (w, s) => {
  433. X(() => {
  434. g(s), a(w);
  435. });
  436. }), V(() => {
  437. a(e.href);
  438. }), ce(() => {
  439. g(e.href);
  440. }), () => {
  441. var w;
  442. const {
  443. href: s,
  444. target: C,
  445. title: S = o.title,
  446. customTitleProps: I = {}
  447. } = e, B = k.value;
  448. r = typeof S == "function" ? S(I) : S;
  449. const L = x.value === s, c = D(`${B}-link`, {
  450. [`${B}-link-active`]: L
  451. }, i.class), d = D(`${B}-link-title`, {
  452. [`${B}-link-title-active`]: L
  453. });
  454. return b("div", z(z({}, i), {}, {
  455. class: c
  456. }), [b("a", {
  457. class: d,
  458. href: s,
  459. title: typeof r == "string" ? r : "",
  460. target: C,
  461. onClick: y
  462. }, [o.customTitle ? o.customTitle(I) : r]), (w = o.default) === null || w === void 0 ? void 0 : w.call(o)]);
  463. };
  464. }
  465. });
  466. function Ge() {
  467. return window;
  468. }
  469. function re(e, n) {
  470. if (!e.getClientRects().length)
  471. return 0;
  472. const o = e.getBoundingClientRect();
  473. return o.width || o.height ? n === window ? (n = e.ownerDocument.documentElement, o.top - n.clientTop) : o.top - n.getBoundingClientRect().top : o.top;
  474. }
  475. const le = /#([\S ]+)$/, Xe = () => ({
  476. prefixCls: String,
  477. offsetTop: Number,
  478. bounds: Number,
  479. affix: {
  480. type: Boolean,
  481. default: !0
  482. },
  483. showInkInFixed: {
  484. type: Boolean,
  485. default: !1
  486. },
  487. getContainer: Function,
  488. wrapperClass: String,
  489. wrapperStyle: {
  490. type: Object,
  491. default: void 0
  492. },
  493. getCurrentAnchor: Function,
  494. targetOffset: Number,
  495. items: _e(),
  496. direction: Le.oneOf(["vertical", "horizontal"]).def("vertical"),
  497. onChange: Function,
  498. onClick: Function
  499. }), _ = G({
  500. compatConfig: {
  501. MODE: 3
  502. },
  503. name: "AAnchor",
  504. inheritAttrs: !1,
  505. props: Xe(),
  506. setup(e, n) {
  507. let {
  508. emit: o,
  509. attrs: i,
  510. slots: r,
  511. expose: p
  512. } = n;
  513. var u;
  514. const {
  515. prefixCls: g,
  516. getTargetContainer: a,
  517. direction: x
  518. } = K("anchor", e), k = F(() => {
  519. var t;
  520. return (t = e.direction) !== null && t !== void 0 ? t : "vertical";
  521. });
  522. process.env.NODE_ENV !== "production" && Z(e.items && typeof r.default != "function", "Anchor", "`Anchor children` is deprecated. Please use `items` instead."), process.env.NODE_ENV !== "production" && Z(!(k.value === "horizontal" && (!((u = e.items) === null || u === void 0) && u.some((t) => "children" in t))), "Anchor", "`Anchor items#children` is not supported when `Anchor` direction is horizontal.");
  523. const y = U(null), w = U(), s = se({
  524. links: [],
  525. scrollContainer: null,
  526. scrollEvent: null,
  527. animating: !1
  528. }), C = U(null), S = F(() => {
  529. const {
  530. getContainer: t
  531. } = e;
  532. return t || (a == null ? void 0 : a.value) || Ge;
  533. }), I = function() {
  534. let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0, l = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 5;
  535. const m = [], T = S.value();
  536. return s.links.forEach((f) => {
  537. const h = le.exec(f.toString());
  538. if (!h)
  539. return;
  540. const $ = document.getElementById(h[1]);
  541. if ($) {
  542. const E = re($, T);
  543. E < t + l && m.push({
  544. link: f,
  545. top: E
  546. });
  547. }
  548. }), m.length ? m.reduce((h, $) => $.top > h.top ? $ : h).link : "";
  549. }, B = (t) => {
  550. const {
  551. getCurrentAnchor: l
  552. } = e;
  553. C.value !== t && (C.value = typeof l == "function" ? l(t) : t, o("change", t));
  554. }, L = (t) => {
  555. const {
  556. offsetTop: l,
  557. targetOffset: m
  558. } = e;
  559. B(t);
  560. const T = le.exec(t);
  561. if (!T)
  562. return;
  563. const f = document.getElementById(T[1]);
  564. if (!f)
  565. return;
  566. const h = S.value(), $ = Ee(h), E = re(f, h);
  567. let O = $ + E;
  568. O -= m !== void 0 ? m : l || 0, s.animating = !0, Ie(O, {
  569. callback: () => {
  570. s.animating = !1;
  571. },
  572. getContainer: S.value
  573. });
  574. };
  575. p({
  576. scrollTo: L
  577. });
  578. const c = () => {
  579. if (s.animating)
  580. return;
  581. const {
  582. offsetTop: t,
  583. bounds: l,
  584. targetOffset: m
  585. } = e, T = I(m !== void 0 ? m : t || 0, l);
  586. B(T);
  587. }, d = () => {
  588. const t = w.value.querySelector(`.${g.value}-link-title-active`);
  589. if (t && y.value) {
  590. const l = k.value === "horizontal";
  591. y.value.style.top = l ? "" : `${t.offsetTop + t.clientHeight / 2}px`, y.value.style.height = l ? "" : `${t.clientHeight}px`, y.value.style.left = l ? `${t.offsetLeft}px` : "", y.value.style.width = l ? `${t.clientWidth}px` : "", l && Ne(t, {
  592. scrollMode: "if-needed",
  593. block: "nearest"
  594. });
  595. }
  596. };
  597. je({
  598. registerLink: (t) => {
  599. s.links.includes(t) || s.links.push(t);
  600. },
  601. unregisterLink: (t) => {
  602. const l = s.links.indexOf(t);
  603. l !== -1 && s.links.splice(l, 1);
  604. },
  605. activeLink: C,
  606. scrollTo: L,
  607. handleClick: (t, l) => {
  608. o("click", t, l);
  609. },
  610. direction: k
  611. }), V(() => {
  612. X(() => {
  613. const t = S.value();
  614. s.scrollContainer = t, s.scrollEvent = q(s.scrollContainer, "scroll", c), c();
  615. });
  616. }), ce(() => {
  617. s.scrollEvent && s.scrollEvent.remove();
  618. }), ae(() => {
  619. if (s.scrollEvent) {
  620. const t = S.value();
  621. s.scrollContainer !== t && (s.scrollContainer = t, s.scrollEvent.remove(), s.scrollEvent = q(s.scrollContainer, "scroll", c), c());
  622. }
  623. d();
  624. });
  625. const A = (t) => Array.isArray(t) ? t.map((l) => {
  626. const {
  627. children: m,
  628. key: T,
  629. href: f,
  630. target: h,
  631. class: $,
  632. style: E,
  633. title: O
  634. } = l;
  635. return b(pe, {
  636. key: T,
  637. href: f,
  638. target: h,
  639. class: $,
  640. style: E,
  641. title: O,
  642. customTitleProps: l
  643. }, {
  644. default: () => [k.value === "vertical" ? A(m) : null],
  645. customTitle: r.customTitle
  646. });
  647. }) : null, [P, v] = We(g);
  648. return () => {
  649. var t;
  650. const {
  651. offsetTop: l,
  652. affix: m,
  653. showInkInFixed: T
  654. } = e, f = g.value, h = D(`${f}-ink`, {
  655. [`${f}-ink-visible`]: C.value
  656. }), $ = D(v.value, e.wrapperClass, `${f}-wrapper`, {
  657. [`${f}-wrapper-horizontal`]: k.value === "horizontal",
  658. [`${f}-rtl`]: x.value === "rtl"
  659. }), E = D(f, {
  660. [`${f}-fixed`]: !m && !T
  661. }), O = N({
  662. maxHeight: l ? `calc(100vh - ${l}px)` : "100vh"
  663. }, e.wrapperStyle), Y = b("div", {
  664. class: $,
  665. style: O,
  666. ref: w
  667. }, [b("div", {
  668. class: E
  669. }, [b("span", {
  670. class: h,
  671. ref: y
  672. }, null), Array.isArray(e.items) ? A(e.items) : (t = r.default) === null || t === void 0 ? void 0 : t.call(r)])]);
  673. return P(m ? b(He, z(z({}, i), {}, {
  674. offsetTop: l,
  675. target: S.value
  676. }), {
  677. default: () => [Y]
  678. }) : Y);
  679. };
  680. }
  681. });
  682. _.Link = pe;
  683. _.install = function(e) {
  684. return e.component(_.name, _), e.component(_.Link.name, _.Link), e;
  685. };
  686. const Qe = /* @__PURE__ */ Object.assign({ name: "SAnchor" }, {
  687. __name: "SAnchor",
  688. props: {
  689. el: {
  690. type: String,
  691. default: "body"
  692. }
  693. },
  694. setup(e) {
  695. const n = e, o = U([]);
  696. function i() {
  697. const g = document.querySelectorAll(
  698. ".s-collapses .s-collapses-item .s-collapses-item-title"
  699. );
  700. g.length > 0 && g.forEach((a) => {
  701. o.value.push({
  702. el: a,
  703. key: a.id,
  704. href: `#${a.id}`,
  705. title: a.lastChild.innerText
  706. });
  707. });
  708. }
  709. function r() {
  710. i(), setTimeout(() => {
  711. o.value = [], i();
  712. }, 500);
  713. }
  714. function p(g, a) {
  715. var k;
  716. g.preventDefault();
  717. const x = o.value.find((y) => y.href === a.href);
  718. (k = x == null ? void 0 : x.el) == null || k.scrollIntoView({ block: "start", behavior: "smooth" });
  719. }
  720. function u() {
  721. return n.el === "el" ? document.getElementById("form-container") : document.querySelector(`.${n.el}`);
  722. }
  723. return V(() => {
  724. X(() => {
  725. r();
  726. });
  727. }), (g, a) => {
  728. const x = _;
  729. return ke(), ye(x, {
  730. affix: !1,
  731. showInkInFixed: "",
  732. targetOffset: 10,
  733. getContainer: u,
  734. onClick: p,
  735. items: o.value
  736. }, null, 8, ["items"]);
  737. };
  738. }
  739. });
  740. export {
  741. Qe as default
  742. };