donar 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cspell/custom-dictionary.txt +5 -0
- package/.github/actions/base-check/action.yaml +27 -0
- package/.github/actions/env-setup/action.yaml +74 -0
- package/.github/workflows/pr-check.yaml +33 -0
- package/.github/workflows/release.yaml +112 -0
- package/.gitignore +41 -0
- package/.node-version +1 -0
- package/.npmignore +7 -0
- package/.vscode/extensions.json +10 -0
- package/.vscode/settings.json +44 -0
- package/LICENSE +21 -0
- package/README.md +160 -0
- package/commitlint.config.ts +3 -0
- package/cspell.json +27 -0
- package/dist/components.esm.js +2 -0
- package/dist/css/components.C24nnsjt.css +1 -0
- package/dist/hooks.esm.js +185 -0
- package/dist/index.esm.js +4 -0
- package/dist/js/components.nFDoAkCq.js +198 -0
- package/dist/js/utils.CVb1iSAU.js +330 -0
- package/dist/types/components.d.ts +1 -0
- package/dist/types/hooks.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/src/components/async-custom-show/index.d.ts +22 -0
- package/dist/types/src/components/carousel/hooks.d.ts +74 -0
- package/dist/types/src/components/carousel/index.d.ts +88 -0
- package/dist/types/src/components/custom-show/index.d.ts +21 -0
- package/dist/types/src/components/error-boundary/index.d.ts +31 -0
- package/dist/types/src/components/index.d.ts +8 -0
- package/dist/types/src/hooks/async-guard.d.ts +9 -0
- package/dist/types/src/hooks/index.d.ts +5 -0
- package/dist/types/src/hooks/observer.d.ts +70 -0
- package/dist/types/src/hooks/state.d.ts +44 -0
- package/dist/types/src/hooks/storage.d.ts +25 -0
- package/dist/types/src/hooks/timer.d.ts +16 -0
- package/dist/types/src/index.d.ts +3 -0
- package/dist/types/src/test/emiter-test.d.ts +1 -0
- package/dist/types/src/test/index.d.ts +1 -0
- package/dist/types/src/test/retry-async-test.d.ts +1 -0
- package/dist/types/src/utils/class-singleton.d.ts +6 -0
- package/dist/types/src/utils/concurrency.d.ts +17 -0
- package/dist/types/src/utils/debounce.d.ts +8 -0
- package/dist/types/src/utils/deep-copy.d.ts +11 -0
- package/dist/types/src/utils/dev.d.ts +8 -0
- package/dist/types/src/utils/download.d.ts +15 -0
- package/dist/types/src/utils/event-emitter/helpers.d.ts +36 -0
- package/dist/types/src/utils/event-emitter/index.d.ts +65 -0
- package/dist/types/src/utils/fetch-xhr/helpers.d.ts +28 -0
- package/dist/types/src/utils/fetch-xhr/index.d.ts +25 -0
- package/dist/types/src/utils/hash.d.ts +8 -0
- package/dist/types/src/utils/index.d.ts +15 -0
- package/dist/types/src/utils/is-deep-plain-equal.d.ts +15 -0
- package/dist/types/src/utils/json-convert.d.ts +66 -0
- package/dist/types/src/utils/micro-queue-scheduler.d.ts +14 -0
- package/dist/types/src/utils/raf-interval.d.ts +16 -0
- package/dist/types/src/utils/record-typed-map.d.ts +27 -0
- package/dist/types/src/utils/retry-async.d.ts +9 -0
- package/dist/types/src/utils/thenable.d.ts +15 -0
- package/dist/types/utils.d.ts +1 -0
- package/dist/utils.esm.js +2 -0
- package/eslint.config.ts +48 -0
- package/lint-staged.config.ts +13 -0
- package/oxfmt.config.ts +14 -0
- package/package.json +90 -0
- package/pnpm-workspace.yaml +3 -0
- package/scripts/sync-node-version/index.js +31 -0
- package/simple-git-hooks.js +4 -0
- package/src/components/async-custom-show/index.tsx +37 -0
- package/src/components/carousel/hooks.ts +312 -0
- package/src/components/carousel/index.module.scss +163 -0
- package/src/components/carousel/index.tsx +215 -0
- package/src/components/custom-show/index.tsx +31 -0
- package/src/components/error-boundary/index.tsx +48 -0
- package/src/components/index.ts +11 -0
- package/src/hooks/async-guard.ts +53 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/observer.ts +236 -0
- package/src/hooks/state.ts +140 -0
- package/src/hooks/storage.ts +103 -0
- package/src/hooks/timer.ts +42 -0
- package/src/index.ts +3 -0
- package/src/test/emiter-test.ts +19 -0
- package/src/test/index.ts +35 -0
- package/src/test/retry-async-test.ts +8 -0
- package/src/utils/class-singleton.ts +23 -0
- package/src/utils/concurrency.ts +49 -0
- package/src/utils/debounce.ts +20 -0
- package/src/utils/deep-copy.ts +132 -0
- package/src/utils/dev.ts +16 -0
- package/src/utils/download.ts +39 -0
- package/src/utils/event-emitter/helpers.ts +80 -0
- package/src/utils/event-emitter/index.ts +171 -0
- package/src/utils/fetch-xhr/helpers.ts +85 -0
- package/src/utils/fetch-xhr/index.ts +103 -0
- package/src/utils/hash.ts +25 -0
- package/src/utils/index.ts +18 -0
- package/src/utils/is-deep-plain-equal.ts +45 -0
- package/src/utils/json-convert.ts +257 -0
- package/src/utils/micro-queue-scheduler.ts +38 -0
- package/src/utils/raf-interval.ts +42 -0
- package/src/utils/record-typed-map.ts +38 -0
- package/src/utils/retry-async.ts +30 -0
- package/src/utils/thenable.ts +30 -0
- package/tsconfig.json +43 -0
- package/types/scss.d.ts +10 -0
- package/vite.config.ts +51 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { g as e, h as t } from "./js/utils.CVb1iSAU.js";
|
|
2
|
+
import { useCallback as n, useEffect as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
3
|
+
//#region src/hooks/state.ts
|
|
4
|
+
function s(e) {
|
|
5
|
+
let t = a(e);
|
|
6
|
+
return [
|
|
7
|
+
n(() => t.current, []),
|
|
8
|
+
n((e) => t.current = e, []),
|
|
9
|
+
n((e) => e === void 0 ? t.current : t.current = e, [])
|
|
10
|
+
];
|
|
11
|
+
}
|
|
12
|
+
function c(e) {
|
|
13
|
+
let t = a(e);
|
|
14
|
+
return t.current !== e && (t.current = e), n(() => t.current, []);
|
|
15
|
+
}
|
|
16
|
+
function l({ initialValue: e, onChange: t, hasDiff: r = (e, t) => e !== t, onlyEvent: i }) {
|
|
17
|
+
let s = a(void 0), [l, u] = o(() => s.current = typeof e == "function" ? e() : e), d = c(t), f = n((e) => {
|
|
18
|
+
let t = typeof e == "function" ? e(s.current) : e;
|
|
19
|
+
r ?? (r = (e, t) => e !== t), r(s.current, t) && (d()?.(t), s.current = t, i || u(t));
|
|
20
|
+
}, [
|
|
21
|
+
d,
|
|
22
|
+
i,
|
|
23
|
+
u,
|
|
24
|
+
!!r
|
|
25
|
+
]);
|
|
26
|
+
return [
|
|
27
|
+
i ? void 0 : l,
|
|
28
|
+
f,
|
|
29
|
+
n(() => s.current, [])
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
var u = (e) => {
|
|
33
|
+
let [t, r] = o(), i = a(!1);
|
|
34
|
+
return [
|
|
35
|
+
t,
|
|
36
|
+
n((n) => {
|
|
37
|
+
e ?? (e = (e, t) => e !== t), n && e(t, n) && (i.current = !0, r(n));
|
|
38
|
+
}, [t, !!e]),
|
|
39
|
+
i
|
|
40
|
+
];
|
|
41
|
+
}, d = (e, t) => {
|
|
42
|
+
let r = a(void 0), i = a(e);
|
|
43
|
+
i.current = e;
|
|
44
|
+
let o = n(() => {
|
|
45
|
+
clearTimeout(r.current), r.current = setTimeout(() => {
|
|
46
|
+
i.current(), o?.();
|
|
47
|
+
}, t);
|
|
48
|
+
}, [t]);
|
|
49
|
+
return [o, n(() => clearTimeout(r.current), [r])];
|
|
50
|
+
}, f = (r, i) => {
|
|
51
|
+
let o = a(void 0);
|
|
52
|
+
return [n(() => {
|
|
53
|
+
t(o.current), o.current = e(r, i);
|
|
54
|
+
}, [r, i]), n(() => t(o.current), [o])];
|
|
55
|
+
}, p = (e, t = !1) => {
|
|
56
|
+
let i = a(), o = c(e);
|
|
57
|
+
return r(() => () => {
|
|
58
|
+
i.current?.disconnect?.(), i.current = void 0;
|
|
59
|
+
}, []), {
|
|
60
|
+
observe: n((e, n) => {
|
|
61
|
+
e && (i.current ?? (i.current = new MutationObserver((e, n) => {
|
|
62
|
+
o()?.(e, n), t && n.disconnect();
|
|
63
|
+
})), i.current?.observe?.(e, n));
|
|
64
|
+
}, [t, o]),
|
|
65
|
+
takeRecords: n(() => i.current?.takeRecords?.(), []),
|
|
66
|
+
disconnect: n(() => i.current?.disconnect?.(), [])
|
|
67
|
+
};
|
|
68
|
+
}, m = ({ callback: e, rootMargin: t = 100, threshold: o = 0, once: s = !1 }) => {
|
|
69
|
+
let l = a(), [d, f] = u(), p = c(e), m = i(() => ({
|
|
70
|
+
root: d,
|
|
71
|
+
rootMargin: `${t}px`,
|
|
72
|
+
threshold: o
|
|
73
|
+
}), [
|
|
74
|
+
d,
|
|
75
|
+
t,
|
|
76
|
+
o
|
|
77
|
+
]), h = a(m);
|
|
78
|
+
r(() => () => {
|
|
79
|
+
l.current?.disconnect?.(), l.current = void 0;
|
|
80
|
+
}, [m]);
|
|
81
|
+
let g = n((e) => {
|
|
82
|
+
e && (h.current !== m && (l.current?.disconnect?.(), l.current = void 0, h.current = m), l.current ?? (l.current = new IntersectionObserver((e, t) => {
|
|
83
|
+
e.forEach((e) => {
|
|
84
|
+
e.isIntersecting && (p()?.(e.target, d, t), s && t.unobserve?.(e.target));
|
|
85
|
+
});
|
|
86
|
+
}, m)), l.current?.unobserve?.(e), l.current?.observe?.(e));
|
|
87
|
+
}, [
|
|
88
|
+
m,
|
|
89
|
+
s,
|
|
90
|
+
p
|
|
91
|
+
]), _ = n((e) => e && l.current?.unobserve?.(e), []), v = n(() => l.current?.takeRecords?.(), []);
|
|
92
|
+
return {
|
|
93
|
+
rootRef: d,
|
|
94
|
+
setRootRef: f,
|
|
95
|
+
observe: g,
|
|
96
|
+
unobserve: _,
|
|
97
|
+
disconnect: n(() => l.current?.disconnect?.(), []),
|
|
98
|
+
takeRecords: v
|
|
99
|
+
};
|
|
100
|
+
}, h = (e, t = !1) => {
|
|
101
|
+
let i = a(), o = c(e);
|
|
102
|
+
return r(() => () => {
|
|
103
|
+
i.current?.disconnect?.(), i.current = void 0;
|
|
104
|
+
}, []), {
|
|
105
|
+
observe: n((e, n) => {
|
|
106
|
+
e && (i.current ?? (i.current = new ResizeObserver((e, n) => {
|
|
107
|
+
e.forEach((e) => {
|
|
108
|
+
o()?.(e, n);
|
|
109
|
+
}), t && n.disconnect();
|
|
110
|
+
})), i.current?.unobserve?.(e), i.current?.observe?.(e, n));
|
|
111
|
+
}, [t, o]),
|
|
112
|
+
unobserve: n((e) => e && i.current?.unobserve?.(e), []),
|
|
113
|
+
disconnect: n(() => i.current?.disconnect?.(), [])
|
|
114
|
+
};
|
|
115
|
+
}, g = ({ key: e, initialValue: t, hasDiff: i, onChange: a, storage: o = localStorage, checkType: s = () => !0, beforeunload: c }) => {
|
|
116
|
+
let [u, d] = l({
|
|
117
|
+
initialValue: () => {
|
|
118
|
+
try {
|
|
119
|
+
let n = o.getItem(e), r = n ? JSON.parse(n) : t;
|
|
120
|
+
return s(r) ? r : t;
|
|
121
|
+
} catch (e) {
|
|
122
|
+
return console.warn("初始化出错,已使用默认值", e), t;
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
hasDiff: i,
|
|
126
|
+
onChange: a
|
|
127
|
+
}), f = n((t) => {
|
|
128
|
+
try {
|
|
129
|
+
d((n) => {
|
|
130
|
+
let r = t instanceof Function ? t(n) : t, i = JSON.stringify(r);
|
|
131
|
+
return o.setItem(e, i), window.dispatchEvent(new StorageEvent("storage", {
|
|
132
|
+
key: e,
|
|
133
|
+
newValue: i,
|
|
134
|
+
storageArea: o
|
|
135
|
+
})), r;
|
|
136
|
+
});
|
|
137
|
+
} catch (e) {
|
|
138
|
+
console.error("持久化储存错误", e);
|
|
139
|
+
}
|
|
140
|
+
}, [
|
|
141
|
+
e,
|
|
142
|
+
o,
|
|
143
|
+
d
|
|
144
|
+
]);
|
|
145
|
+
return r(() => {
|
|
146
|
+
let n = (n) => {
|
|
147
|
+
if (!(n.storageArea !== o || n.key !== e)) try {
|
|
148
|
+
d(n.newValue ? JSON.parse(n.newValue) : t);
|
|
149
|
+
} catch (e) {
|
|
150
|
+
console.error("storage事件处理出错", e);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
return window.addEventListener("storage", n), () => window.removeEventListener("storage", n);
|
|
154
|
+
}, [
|
|
155
|
+
e,
|
|
156
|
+
o,
|
|
157
|
+
t,
|
|
158
|
+
d
|
|
159
|
+
]), r(() => {
|
|
160
|
+
c && window.addEventListener("beforeunload", c);
|
|
161
|
+
}, []), [u, f];
|
|
162
|
+
}, _ = (e, t, r) => {
|
|
163
|
+
let [i, s] = o(!1), l = a(i), u = c(t), d = n((e) => {
|
|
164
|
+
l.current = e, s(e), u()?.(e);
|
|
165
|
+
}, [
|
|
166
|
+
l,
|
|
167
|
+
s,
|
|
168
|
+
u
|
|
169
|
+
]), f = c(e);
|
|
170
|
+
return [i, n((...e) => l.current ? (console.clog(r || "正在提交中,请稍后再试"), Promise.resolve(void 0)) : (d(!0), new Promise((t, n) => {
|
|
171
|
+
try {
|
|
172
|
+
t(f()?.(...e));
|
|
173
|
+
} catch (e) {
|
|
174
|
+
n(e);
|
|
175
|
+
}
|
|
176
|
+
}).finally(() => {
|
|
177
|
+
d(!1);
|
|
178
|
+
})), [
|
|
179
|
+
f,
|
|
180
|
+
r,
|
|
181
|
+
d
|
|
182
|
+
])];
|
|
183
|
+
};
|
|
184
|
+
//#endregion
|
|
185
|
+
export { _ as useAsyncActionLock, u as useCreateSafeRef, l as useDistinctState, m as useIntersectionObserver, d as useInterval, c as useLatestCallback, p as useMutationObserver, f as useRAfInterval, h as useResizeObserver, s as useStaticState, g as useStorage };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { S as e, T as t, _ as n, a as r, b as i, c as a, d as o, f as s, g as c, h as l, i as u, l as d, m as f, n as p, o as m, p as h, r as g, s as _, t as v, u as y, v as b, w as x, x as S, y as C } from "./js/utils.CVb1iSAU.js";
|
|
2
|
+
import { useAsyncActionLock as w, useCreateSafeRef as T, useDistinctState as E, useIntersectionObserver as D, useInterval as O, useLatestCallback as k, useMutationObserver as A, useRAfInterval as j, useResizeObserver as M, useStaticState as N, useStorage as P } from "./hooks.esm.js";
|
|
3
|
+
import { i as F, n as I, r as L, t as R } from "./js/components.nFDoAkCq.js";
|
|
4
|
+
export { I as AsyncCustomShow, F as Carousel, e as ConcurrencyController, y as ConvertMode, L as CustomShow, d as CustomTimeoutError, R as ErrorBoundary, u as EventEmitter, r as RecordTypedMap, b as blobDownload, C as browserNativeDownload, l as clearRAfInterval, o as convertCamel2Pascal, s as convertCamel2Snake, h as convertPascal2Camel, f as convertSnake2Camel, m as createMicroQueueScheduler, S as debounce, n as deepClone, a as fetchXHR, v as isDeepPlainEqual, p as isNil, x as promiseTry, c as rAfInterval, g as retryAsync, t as safeAwait, _ as singleton, i as stringToHash, w as useAsyncActionLock, T as useCreateSafeRef, E as useDistinctState, D as useIntersectionObserver, O as useInterval, k as useLatestCallback, A as useMutationObserver, j as useRAfInterval, M as useResizeObserver, N as useStaticState, P as useStorage };
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { C as e } from "./utils.CVb1iSAU.js";
|
|
2
|
+
import { useCreateSafeRef as t, useRAfInterval as n } from "../hooks.esm.js";
|
|
3
|
+
import { Component as r, cloneElement as i, forwardRef as a, useCallback as o, useEffect as s, useImperativeHandle as c, useMemo as l, useRef as u, useState as d } from "react";
|
|
4
|
+
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
5
|
+
import '../css/components.C24nnsjt.css';//#region src/components/carousel/hooks.ts
|
|
6
|
+
var h = (e, t) => {
|
|
7
|
+
e.style.cssText = `transition-duration: 0s; --index: ${t}`, e.clientLeft, e.style.cssText = "";
|
|
8
|
+
}, g = (e, t) => {
|
|
9
|
+
let n = e.previousElementSibling;
|
|
10
|
+
if (!n) return;
|
|
11
|
+
let [r, i] = t;
|
|
12
|
+
n.children[0]?.classList.toggle("show", r), n.children[1]?.classList.toggle("show", i);
|
|
13
|
+
}, _ = (e, t, n) => {
|
|
14
|
+
e.style.setProperty("--index", `${t}`);
|
|
15
|
+
let r = e.parentElement;
|
|
16
|
+
if (!r) return;
|
|
17
|
+
let i = r.parentElement?.nextElementSibling;
|
|
18
|
+
i && (i.querySelector(".active")?.classList.remove("active"), i.children[t >= i.children.length ? 0 : t]?.classList.add("active")), g(r, n);
|
|
19
|
+
}, v = ({ showArrow: e, length: t, cardWidth: n, wrapperRef: r }) => {
|
|
20
|
+
let i = l(() => {
|
|
21
|
+
let e = (r?.parentElement?.parentElement?.clientWidth || n) ?? 0;
|
|
22
|
+
return n ? Math.floor(e / n) : 1;
|
|
23
|
+
}, [r, n]);
|
|
24
|
+
return o((n) => {
|
|
25
|
+
if (e !== "auto") return [!0, !0];
|
|
26
|
+
let r;
|
|
27
|
+
return r = t > i ? n + i - 1 < t - 1 : !1, [n > 0, r];
|
|
28
|
+
}, [
|
|
29
|
+
i,
|
|
30
|
+
t,
|
|
31
|
+
e
|
|
32
|
+
]);
|
|
33
|
+
}, y = ({ length: e, loop: n, showArrow: r, cardWidth: i, onNonLoopEnd: a, offsetOnEnd: c = 0 }) => {
|
|
34
|
+
let l = e, d = u(0), [f, p, m] = t();
|
|
35
|
+
c = ~~c, c = c < 0 || c >= e ? 0 : c;
|
|
36
|
+
let y = v({
|
|
37
|
+
showArrow: r,
|
|
38
|
+
length: e,
|
|
39
|
+
cardWidth: i,
|
|
40
|
+
wrapperRef: f
|
|
41
|
+
});
|
|
42
|
+
s(() => {
|
|
43
|
+
let e = f?.parentElement;
|
|
44
|
+
r !== "auto" || !e || g(e, y(d.current));
|
|
45
|
+
}, [e]);
|
|
46
|
+
let b = o((t) => {
|
|
47
|
+
if (!f) return;
|
|
48
|
+
n && (d.current >= l && t !== "prev" ? (d.current = 0, h(f, d.current)) : d.current <= 0 && t === "prev" && (d.current = l, h(f, d.current))), t === "prev" ? d.current-- : d.current++;
|
|
49
|
+
let r = y(d.current);
|
|
50
|
+
_(f, d.current, r), !n && a && d.current === e - c - 1 && a(t ?? "next", d.current, e, c);
|
|
51
|
+
}, [
|
|
52
|
+
e,
|
|
53
|
+
n,
|
|
54
|
+
f,
|
|
55
|
+
y,
|
|
56
|
+
c,
|
|
57
|
+
a,
|
|
58
|
+
l
|
|
59
|
+
]), x = o((t) => {
|
|
60
|
+
let r = d.current;
|
|
61
|
+
d.current = t < 0 ? 0 : t > e ? e : t;
|
|
62
|
+
let i = y(d.current);
|
|
63
|
+
if (f && _(f, d.current, i), !n && a) {
|
|
64
|
+
let t = r < d.current ? "next" : "prev", n = e - c - 1;
|
|
65
|
+
(d.current >= n && r < n || d.current <= n && r > n) && a(t, d.current, e, c);
|
|
66
|
+
}
|
|
67
|
+
}, [
|
|
68
|
+
e,
|
|
69
|
+
n,
|
|
70
|
+
f,
|
|
71
|
+
y,
|
|
72
|
+
c,
|
|
73
|
+
a
|
|
74
|
+
]), S = o(() => d.current, []);
|
|
75
|
+
return s(() => x(d.current), [f]), [
|
|
76
|
+
p,
|
|
77
|
+
b,
|
|
78
|
+
x,
|
|
79
|
+
S,
|
|
80
|
+
m
|
|
81
|
+
];
|
|
82
|
+
}, b = (() => {
|
|
83
|
+
let e = Math.random().toString(36).slice(2), t = 0;
|
|
84
|
+
return () => `${e}-${++t}`;
|
|
85
|
+
})(), x = (e, t, n) => l(() => {
|
|
86
|
+
if (!Array.isArray(e) || !e.length) throw Error("Carousel children must be an array");
|
|
87
|
+
if (t) {
|
|
88
|
+
let t = e[0], n = [...e];
|
|
89
|
+
return n.push(i(t, { key: b() })), n;
|
|
90
|
+
}
|
|
91
|
+
return e;
|
|
92
|
+
}, [n === "child" ? e : e?.length, t]), S = {
|
|
93
|
+
carousel: "_carousel_1ryaf_1",
|
|
94
|
+
wrapper: "_wrapper_1ryaf_13",
|
|
95
|
+
inner: "_inner_1ryaf_13",
|
|
96
|
+
arrow: "_arrow_1ryaf_36",
|
|
97
|
+
left: "_left_1ryaf_48",
|
|
98
|
+
right: "_right_1ryaf_49",
|
|
99
|
+
indicator: "_indicator_1ryaf_85"
|
|
100
|
+
}, C = a(({ cardWidth: e, cardHeight: t, wrapperWidth: r, wrapperHeight: i, gapSize: a, loop: o = !0, duration: l = 6e3, autoPlay: u = !0, showArrow: d = "always", indicatorType: h = "line", className: g, style: _, children: v, rerender: b = "length", onNonLoopEnd: C, offsetOnEnd: w = 0, arrows: T }, E) => {
|
|
101
|
+
let D = x(v, o, b), [O, k, A, j] = y({
|
|
102
|
+
length: v.length,
|
|
103
|
+
loop: o,
|
|
104
|
+
showArrow: d,
|
|
105
|
+
cardWidth: e,
|
|
106
|
+
onNonLoopEnd: C,
|
|
107
|
+
offsetOnEnd: w
|
|
108
|
+
}), [M, N] = n(k, l);
|
|
109
|
+
return s(() => (u && M(), N), [
|
|
110
|
+
M,
|
|
111
|
+
N,
|
|
112
|
+
u
|
|
113
|
+
]), c(E, () => ({
|
|
114
|
+
run: M,
|
|
115
|
+
stop: N,
|
|
116
|
+
stepChange: k,
|
|
117
|
+
jumpChange: A,
|
|
118
|
+
getCurrentIndex: j
|
|
119
|
+
}), [
|
|
120
|
+
M,
|
|
121
|
+
N,
|
|
122
|
+
k,
|
|
123
|
+
A,
|
|
124
|
+
j
|
|
125
|
+
]), /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ m("div", {
|
|
126
|
+
className: `${S.carousel} ${g ?? ""}`,
|
|
127
|
+
style: {
|
|
128
|
+
..._,
|
|
129
|
+
"--wrapperWidth": r,
|
|
130
|
+
"--wrapperHeight": i,
|
|
131
|
+
"--cardWidth": e,
|
|
132
|
+
"--cardHeight": t,
|
|
133
|
+
"--gapSize": a
|
|
134
|
+
},
|
|
135
|
+
onMouseEnter: N,
|
|
136
|
+
onMouseLeave: u ? M : void 0,
|
|
137
|
+
children: [/* @__PURE__ */ m("div", {
|
|
138
|
+
className: `${S.arrow} ${d}`,
|
|
139
|
+
children: [T?.[0] ? T[0]({
|
|
140
|
+
onClick: () => k("prev"),
|
|
141
|
+
className: S.left
|
|
142
|
+
}) : /* @__PURE__ */ p("i", {
|
|
143
|
+
className: S.left,
|
|
144
|
+
onClick: () => k("prev")
|
|
145
|
+
}), T?.[1] ? T[1]({
|
|
146
|
+
onClick: () => k(),
|
|
147
|
+
className: S.right
|
|
148
|
+
}) : /* @__PURE__ */ p("i", {
|
|
149
|
+
className: S.right,
|
|
150
|
+
onClick: () => k()
|
|
151
|
+
})]
|
|
152
|
+
}), /* @__PURE__ */ p("div", {
|
|
153
|
+
className: S.wrapper,
|
|
154
|
+
children: /* @__PURE__ */ p("div", {
|
|
155
|
+
className: S.inner,
|
|
156
|
+
ref: O,
|
|
157
|
+
children: D
|
|
158
|
+
})
|
|
159
|
+
})]
|
|
160
|
+
}), /* @__PURE__ */ p("div", {
|
|
161
|
+
className: `${S.indicator} ${h}`,
|
|
162
|
+
children: v.map((e, t) => /* @__PURE__ */ p("i", { onClick: (e) => {
|
|
163
|
+
e.stopPropagation(), A(t);
|
|
164
|
+
} }, t))
|
|
165
|
+
})] });
|
|
166
|
+
});
|
|
167
|
+
C.displayName = "Carousel";
|
|
168
|
+
//#endregion
|
|
169
|
+
//#region src/components/custom-show/index.tsx
|
|
170
|
+
function w({ when: e, fallback: t = void 0, children: n }) {
|
|
171
|
+
return /* @__PURE__ */ p(f, { children: e ? n : t });
|
|
172
|
+
}
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/components/async-custom-show/index.tsx
|
|
175
|
+
function T({ when: e, fallback: t, children: n }) {
|
|
176
|
+
let [r, i] = d(void 0);
|
|
177
|
+
return s(() => {
|
|
178
|
+
e && Promise.resolve(e).then(i);
|
|
179
|
+
}, [e]), /* @__PURE__ */ p(f, { children: r ? n(r) : t });
|
|
180
|
+
}
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/components/error-boundary/index.tsx
|
|
183
|
+
var E = class extends r {
|
|
184
|
+
constructor(...t) {
|
|
185
|
+
super(...t), e(this, "state", { hasError: !1 }), e(this, "msg", this.props.msg ?? "组件加载失败");
|
|
186
|
+
}
|
|
187
|
+
static getDerivedStateFromError() {
|
|
188
|
+
return { hasError: !0 };
|
|
189
|
+
}
|
|
190
|
+
componentDidCatch(e, t) {
|
|
191
|
+
console.error(`${this.msg}:`, e, t);
|
|
192
|
+
}
|
|
193
|
+
render() {
|
|
194
|
+
return this.state.hasError ? this.props.fallback : this.props.children;
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
//#endregion
|
|
198
|
+
export { C as i, T as n, w as r, E as t };
|