| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742 |
- 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";
- 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";
- import { s as Ne } from "./index3.js";
- function ee(e) {
- let n;
- const o = (r) => () => {
- n = null, e(...r);
- }, i = function() {
- if (n == null) {
- for (var r = arguments.length, p = new Array(r), u = 0; u < r; u++)
- p[u] = arguments[u];
- n = Q(o(p));
- }
- };
- return i.cancel = () => {
- Q.cancel(n), n = null;
- }, i;
- }
- function j(e) {
- return e !== window ? e.getBoundingClientRect() : {
- top: 0,
- bottom: window.innerHeight
- };
- }
- function te(e, n, o) {
- if (o !== void 0 && n.top > e.top - o)
- return `${o + n.top}px`;
- }
- function ne(e, n, o) {
- if (o !== void 0 && n.bottom < e.bottom + o) {
- const i = window.innerHeight - n.bottom;
- return `${o + i}px`;
- }
- }
- const de = ["resize", "scroll", "touchstart", "touchmove", "touchend", "pageshow", "load"];
- let H = [];
- function oe(e, n) {
- if (!e) return;
- let o = H.find((i) => i.target === e);
- o ? o.affixList.push(n) : (o = {
- target: e,
- affixList: [n],
- eventHandlers: {}
- }, H.push(o), de.forEach((i) => {
- o.eventHandlers[i] = q(e, i, () => {
- o.affixList.forEach((r) => {
- const {
- lazyUpdatePosition: p
- } = r.exposed;
- p();
- }, (i === "touchstart" || i === "touchmove") && Ce ? {
- passive: !0
- } : !1);
- });
- }));
- }
- function ie(e) {
- const n = H.find((o) => {
- const i = o.affixList.some((r) => r === e);
- return i && (o.affixList = o.affixList.filter((r) => r !== e)), i;
- });
- n && n.affixList.length === 0 && (H = H.filter((o) => o !== n), de.forEach((o) => {
- const i = n.eventHandlers[o];
- i && i.remove && i.remove();
- }));
- }
- const ze = (e) => {
- const {
- componentCls: n
- } = e;
- return {
- [n]: {
- position: "fixed",
- zIndex: e.zIndexPopup
- }
- };
- }, Oe = fe("Affix", (e) => {
- const n = ue(e, {
- zIndexPopup: e.zIndexBase + 10
- });
- return [ze(n)];
- });
- function Re() {
- return typeof window != "undefined" ? window : null;
- }
- var R;
- (function(e) {
- e[e.None = 0] = "None", e[e.Prepare = 1] = "Prepare";
- })(R || (R = {}));
- const De = () => ({
- /**
- * 距离窗口顶部达到指定偏移量后触发
- */
- offsetTop: Number,
- /** 距离窗口底部达到指定偏移量后触发 */
- offsetBottom: Number,
- /** 设置 Affix 需要监听其滚动事件的元素,值为一个返回对应 DOM 元素的函数 */
- target: {
- type: Function,
- default: Re
- },
- prefixCls: String,
- /** 固定状态改变时触发的回调函数 */
- onChange: Function,
- onTestUpdatePosition: Function
- }), Fe = G({
- compatConfig: {
- MODE: 3
- },
- name: "AAffix",
- inheritAttrs: !1,
- props: De(),
- setup(e, n) {
- let {
- slots: o,
- emit: i,
- expose: r,
- attrs: p
- } = n;
- const u = J(), g = J(), a = se({
- affixStyle: void 0,
- placeholderStyle: void 0,
- status: R.None,
- lastAffix: !1,
- prevTarget: null,
- timeout: null
- }), x = ge(), k = F(() => e.offsetBottom === void 0 && e.offsetTop === void 0 ? 0 : e.offsetTop), y = F(() => e.offsetBottom), w = () => {
- const {
- status: c,
- lastAffix: d
- } = a, {
- target: A
- } = e;
- if (c !== R.Prepare || !g.value || !u.value || !A)
- return;
- const P = A();
- if (!P)
- return;
- const v = {
- status: R.None
- }, t = j(u.value);
- if (t.top === 0 && t.left === 0 && t.width === 0 && t.height === 0)
- return;
- const l = j(P), m = te(t, l, k.value), T = ne(t, l, y.value);
- if (!(t.top === 0 && t.left === 0 && t.width === 0 && t.height === 0)) {
- if (m !== void 0) {
- const f = `${t.width}px`, h = `${t.height}px`;
- v.affixStyle = {
- position: "fixed",
- top: m,
- width: f,
- height: h
- }, v.placeholderStyle = {
- width: f,
- height: h
- };
- } else if (T !== void 0) {
- const f = `${t.width}px`, h = `${t.height}px`;
- v.affixStyle = {
- position: "fixed",
- bottom: T,
- width: f,
- height: h
- }, v.placeholderStyle = {
- width: f,
- height: h
- };
- }
- v.lastAffix = !!v.affixStyle, d !== v.lastAffix && i("change", v.lastAffix), N(a, v);
- }
- }, s = () => {
- N(a, {
- status: R.Prepare,
- affixStyle: void 0,
- placeholderStyle: void 0
- }), process.env.NODE_ENV === "test" && i("testUpdatePosition");
- }, C = ee(() => {
- s();
- }), S = ee(() => {
- const {
- target: c
- } = e, {
- affixStyle: d
- } = a;
- if (c && d) {
- const A = c();
- if (A && u.value) {
- const P = j(A), v = j(u.value), t = te(v, P, k.value), l = ne(v, P, y.value);
- if (t !== void 0 && d.top === t || l !== void 0 && d.bottom === l)
- return;
- }
- }
- s();
- });
- r({
- updatePosition: C,
- lazyUpdatePosition: S
- }), W(() => e.target, (c) => {
- const d = (c == null ? void 0 : c()) || null;
- a.prevTarget !== d && (ie(x), d && (oe(d, x), C()), a.prevTarget = d);
- }), W(() => [e.offsetTop, e.offsetBottom], C), V(() => {
- const {
- target: c
- } = e;
- c && (a.timeout = setTimeout(() => {
- oe(c(), x), C();
- }));
- }), ae(() => {
- w();
- }), me(() => {
- clearTimeout(a.timeout), ie(x), C.cancel(), S.cancel();
- });
- const {
- prefixCls: I
- } = K("affix", e), [B, L] = Oe(I);
- return () => {
- var c;
- const {
- affixStyle: d,
- placeholderStyle: A,
- status: P
- } = a, v = D({
- [I.value]: d,
- [L.value]: !0
- }), t = Te(e, ["prefixCls", "offsetTop", "offsetBottom", "target", "onChange", "onTestUpdatePosition"]);
- return B(b(we, {
- onResize: C
- }, {
- default: () => [b("div", z(z(z({}, t), p), {}, {
- ref: u,
- "data-measure-status": P
- }), [d && b("div", {
- style: A,
- "aria-hidden": "true"
- }, null), b("div", {
- class: v,
- ref: g,
- style: d
- }, [(c = o.default) === null || c === void 0 ? void 0 : c.call(o)])])]
- }));
- };
- }
- }), He = Se(Fe);
- function M() {
- }
- const he = Symbol("anchorContextKey"), je = (e) => {
- ve(he, e);
- }, Me = () => xe(he, {
- registerLink: M,
- unregisterLink: M,
- scrollTo: M,
- activeLink: F(() => ""),
- handleClick: M,
- direction: F(() => "vertical")
- }), Ue = (e) => {
- const {
- componentCls: n,
- holderOffsetBlock: o,
- motionDurationSlow: i,
- lineWidthBold: r,
- colorPrimary: p,
- lineType: u,
- colorSplit: g
- } = e;
- return {
- [`${n}-wrapper`]: {
- marginBlockStart: -o,
- paddingBlockStart: o,
- // delete overflow: auto
- // overflow: 'auto',
- backgroundColor: "transparent",
- [n]: N(N({}, $e(e)), {
- position: "relative",
- paddingInlineStart: r,
- [`${n}-link`]: {
- paddingBlock: e.anchorPaddingBlock,
- paddingInline: `${e.anchorPaddingInline}px 0`,
- "&-title": N(N({}, be), {
- position: "relative",
- display: "block",
- marginBlockEnd: e.anchorTitleBlock,
- color: e.colorText,
- transition: `all ${e.motionDurationSlow}`,
- "&:only-child": {
- marginBlockEnd: 0
- }
- }),
- [`&-active > ${n}-link-title`]: {
- color: e.colorPrimary
- },
- // link link
- [`${n}-link`]: {
- paddingBlock: e.anchorPaddingBlockSecondary
- }
- }
- }),
- [`&:not(${n}-wrapper-horizontal)`]: {
- [n]: {
- "&::before": {
- position: "absolute",
- left: {
- _skip_check_: !0,
- value: 0
- },
- top: 0,
- height: "100%",
- borderInlineStart: `${r}px ${u} ${g}`,
- content: '" "'
- },
- [`${n}-ink`]: {
- position: "absolute",
- left: {
- _skip_check_: !0,
- value: 0
- },
- display: "none",
- transform: "translateY(-50%)",
- transition: `top ${i} ease-in-out`,
- width: r,
- backgroundColor: p,
- [`&${n}-ink-visible`]: {
- display: "inline-block"
- }
- }
- }
- },
- [`${n}-fixed ${n}-ink ${n}-ink`]: {
- display: "none"
- }
- }
- };
- }, Ve = (e) => {
- const {
- componentCls: n,
- motionDurationSlow: o,
- lineWidthBold: i,
- colorPrimary: r
- } = e;
- return {
- [`${n}-wrapper-horizontal`]: {
- position: "relative",
- "&::before": {
- position: "absolute",
- left: {
- _skip_check_: !0,
- value: 0
- },
- right: {
- _skip_check_: !0,
- value: 0
- },
- bottom: 0,
- borderBottom: `1px ${e.lineType} ${e.colorSplit}`,
- content: '" "'
- },
- [n]: {
- overflowX: "scroll",
- position: "relative",
- display: "flex",
- scrollbarWidth: "none",
- "&::-webkit-scrollbar": {
- display: "none"
- /* Safari and Chrome */
- },
- [`${n}-link:first-of-type`]: {
- paddingInline: 0
- },
- [`${n}-ink`]: {
- position: "absolute",
- bottom: 0,
- transition: `left ${o} ease-in-out, width ${o} ease-in-out`,
- height: i,
- backgroundColor: r
- }
- }
- }
- };
- }, We = fe("Anchor", (e) => {
- const {
- fontSize: n,
- fontSizeLG: o,
- padding: i,
- paddingXXS: r
- } = e, p = ue(e, {
- holderOffsetBlock: r,
- anchorPaddingBlock: r,
- anchorPaddingBlockSecondary: r / 2,
- anchorPaddingInline: i,
- anchorTitleBlock: n / 14 * 3,
- anchorBallSize: o / 2
- });
- return [Ue(p), Ve(p)];
- }), qe = () => ({
- prefixCls: String,
- href: String,
- title: Pe(),
- target: String,
- /* private use */
- customTitleProps: Be()
- }), pe = G({
- compatConfig: {
- MODE: 3
- },
- name: "AAnchorLink",
- inheritAttrs: !1,
- props: Ae(qe(), {
- href: "#"
- }),
- slots: Object,
- setup(e, n) {
- let {
- slots: o,
- attrs: i
- } = n, r = null;
- const {
- handleClick: p,
- scrollTo: u,
- unregisterLink: g,
- registerLink: a,
- activeLink: x
- } = Me(), {
- prefixCls: k
- } = K("anchor", e), y = (w) => {
- const {
- href: s
- } = e;
- p(w, {
- title: r,
- href: s
- }), u(s);
- };
- return W(() => e.href, (w, s) => {
- X(() => {
- g(s), a(w);
- });
- }), V(() => {
- a(e.href);
- }), ce(() => {
- g(e.href);
- }), () => {
- var w;
- const {
- href: s,
- target: C,
- title: S = o.title,
- customTitleProps: I = {}
- } = e, B = k.value;
- r = typeof S == "function" ? S(I) : S;
- const L = x.value === s, c = D(`${B}-link`, {
- [`${B}-link-active`]: L
- }, i.class), d = D(`${B}-link-title`, {
- [`${B}-link-title-active`]: L
- });
- return b("div", z(z({}, i), {}, {
- class: c
- }), [b("a", {
- class: d,
- href: s,
- title: typeof r == "string" ? r : "",
- target: C,
- onClick: y
- }, [o.customTitle ? o.customTitle(I) : r]), (w = o.default) === null || w === void 0 ? void 0 : w.call(o)]);
- };
- }
- });
- function Ge() {
- return window;
- }
- function re(e, n) {
- if (!e.getClientRects().length)
- return 0;
- const o = e.getBoundingClientRect();
- return o.width || o.height ? n === window ? (n = e.ownerDocument.documentElement, o.top - n.clientTop) : o.top - n.getBoundingClientRect().top : o.top;
- }
- const le = /#([\S ]+)$/, Xe = () => ({
- prefixCls: String,
- offsetTop: Number,
- bounds: Number,
- affix: {
- type: Boolean,
- default: !0
- },
- showInkInFixed: {
- type: Boolean,
- default: !1
- },
- getContainer: Function,
- wrapperClass: String,
- wrapperStyle: {
- type: Object,
- default: void 0
- },
- getCurrentAnchor: Function,
- targetOffset: Number,
- items: _e(),
- direction: Le.oneOf(["vertical", "horizontal"]).def("vertical"),
- onChange: Function,
- onClick: Function
- }), _ = G({
- compatConfig: {
- MODE: 3
- },
- name: "AAnchor",
- inheritAttrs: !1,
- props: Xe(),
- setup(e, n) {
- let {
- emit: o,
- attrs: i,
- slots: r,
- expose: p
- } = n;
- var u;
- const {
- prefixCls: g,
- getTargetContainer: a,
- direction: x
- } = K("anchor", e), k = F(() => {
- var t;
- return (t = e.direction) !== null && t !== void 0 ? t : "vertical";
- });
- 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.");
- const y = U(null), w = U(), s = se({
- links: [],
- scrollContainer: null,
- scrollEvent: null,
- animating: !1
- }), C = U(null), S = F(() => {
- const {
- getContainer: t
- } = e;
- return t || (a == null ? void 0 : a.value) || Ge;
- }), I = function() {
- let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0, l = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 5;
- const m = [], T = S.value();
- return s.links.forEach((f) => {
- const h = le.exec(f.toString());
- if (!h)
- return;
- const $ = document.getElementById(h[1]);
- if ($) {
- const E = re($, T);
- E < t + l && m.push({
- link: f,
- top: E
- });
- }
- }), m.length ? m.reduce((h, $) => $.top > h.top ? $ : h).link : "";
- }, B = (t) => {
- const {
- getCurrentAnchor: l
- } = e;
- C.value !== t && (C.value = typeof l == "function" ? l(t) : t, o("change", t));
- }, L = (t) => {
- const {
- offsetTop: l,
- targetOffset: m
- } = e;
- B(t);
- const T = le.exec(t);
- if (!T)
- return;
- const f = document.getElementById(T[1]);
- if (!f)
- return;
- const h = S.value(), $ = Ee(h), E = re(f, h);
- let O = $ + E;
- O -= m !== void 0 ? m : l || 0, s.animating = !0, Ie(O, {
- callback: () => {
- s.animating = !1;
- },
- getContainer: S.value
- });
- };
- p({
- scrollTo: L
- });
- const c = () => {
- if (s.animating)
- return;
- const {
- offsetTop: t,
- bounds: l,
- targetOffset: m
- } = e, T = I(m !== void 0 ? m : t || 0, l);
- B(T);
- }, d = () => {
- const t = w.value.querySelector(`.${g.value}-link-title-active`);
- if (t && y.value) {
- const l = k.value === "horizontal";
- 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, {
- scrollMode: "if-needed",
- block: "nearest"
- });
- }
- };
- je({
- registerLink: (t) => {
- s.links.includes(t) || s.links.push(t);
- },
- unregisterLink: (t) => {
- const l = s.links.indexOf(t);
- l !== -1 && s.links.splice(l, 1);
- },
- activeLink: C,
- scrollTo: L,
- handleClick: (t, l) => {
- o("click", t, l);
- },
- direction: k
- }), V(() => {
- X(() => {
- const t = S.value();
- s.scrollContainer = t, s.scrollEvent = q(s.scrollContainer, "scroll", c), c();
- });
- }), ce(() => {
- s.scrollEvent && s.scrollEvent.remove();
- }), ae(() => {
- if (s.scrollEvent) {
- const t = S.value();
- s.scrollContainer !== t && (s.scrollContainer = t, s.scrollEvent.remove(), s.scrollEvent = q(s.scrollContainer, "scroll", c), c());
- }
- d();
- });
- const A = (t) => Array.isArray(t) ? t.map((l) => {
- const {
- children: m,
- key: T,
- href: f,
- target: h,
- class: $,
- style: E,
- title: O
- } = l;
- return b(pe, {
- key: T,
- href: f,
- target: h,
- class: $,
- style: E,
- title: O,
- customTitleProps: l
- }, {
- default: () => [k.value === "vertical" ? A(m) : null],
- customTitle: r.customTitle
- });
- }) : null, [P, v] = We(g);
- return () => {
- var t;
- const {
- offsetTop: l,
- affix: m,
- showInkInFixed: T
- } = e, f = g.value, h = D(`${f}-ink`, {
- [`${f}-ink-visible`]: C.value
- }), $ = D(v.value, e.wrapperClass, `${f}-wrapper`, {
- [`${f}-wrapper-horizontal`]: k.value === "horizontal",
- [`${f}-rtl`]: x.value === "rtl"
- }), E = D(f, {
- [`${f}-fixed`]: !m && !T
- }), O = N({
- maxHeight: l ? `calc(100vh - ${l}px)` : "100vh"
- }, e.wrapperStyle), Y = b("div", {
- class: $,
- style: O,
- ref: w
- }, [b("div", {
- class: E
- }, [b("span", {
- class: h,
- ref: y
- }, null), Array.isArray(e.items) ? A(e.items) : (t = r.default) === null || t === void 0 ? void 0 : t.call(r)])]);
- return P(m ? b(He, z(z({}, i), {}, {
- offsetTop: l,
- target: S.value
- }), {
- default: () => [Y]
- }) : Y);
- };
- }
- });
- _.Link = pe;
- _.install = function(e) {
- return e.component(_.name, _), e.component(_.Link.name, _.Link), e;
- };
- const Qe = /* @__PURE__ */ Object.assign({ name: "SAnchor" }, {
- __name: "SAnchor",
- props: {
- el: {
- type: String,
- default: "body"
- }
- },
- setup(e) {
- const n = e, o = U([]);
- function i() {
- const g = document.querySelectorAll(
- ".s-collapses .s-collapses-item .s-collapses-item-title"
- );
- g.length > 0 && g.forEach((a) => {
- o.value.push({
- el: a,
- key: a.id,
- href: `#${a.id}`,
- title: a.lastChild.innerText
- });
- });
- }
- function r() {
- i(), setTimeout(() => {
- o.value = [], i();
- }, 500);
- }
- function p(g, a) {
- var k;
- g.preventDefault();
- const x = o.value.find((y) => y.href === a.href);
- (k = x == null ? void 0 : x.el) == null || k.scrollIntoView({ block: "start", behavior: "smooth" });
- }
- function u() {
- return n.el === "el" ? document.getElementById("form-container") : document.querySelector(`.${n.el}`);
- }
- return V(() => {
- X(() => {
- r();
- });
- }), (g, a) => {
- const x = _;
- return ke(), ye(x, {
- affix: !1,
- showInkInFixed: "",
- targetOffset: 10,
- getContainer: u,
- onClick: p,
- items: o.value
- }, null, 8, ["items"]);
- };
- }
- });
- export {
- Qe as default
- };
|