donar 0.0.1 → 0.0.2

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.
Files changed (106) hide show
  1. package/README.md +2 -159
  2. package/package.json +2 -71
  3. package/.cspell/custom-dictionary.txt +0 -5
  4. package/.github/actions/base-check/action.yaml +0 -27
  5. package/.github/actions/env-setup/action.yaml +0 -74
  6. package/.github/workflows/pr-check.yaml +0 -33
  7. package/.github/workflows/release.yaml +0 -112
  8. package/.gitignore +0 -41
  9. package/.node-version +0 -1
  10. package/.npmignore +0 -7
  11. package/.vscode/extensions.json +0 -10
  12. package/.vscode/settings.json +0 -44
  13. package/LICENSE +0 -21
  14. package/commitlint.config.ts +0 -3
  15. package/cspell.json +0 -27
  16. package/dist/components.esm.js +0 -2
  17. package/dist/css/components.C24nnsjt.css +0 -1
  18. package/dist/hooks.esm.js +0 -185
  19. package/dist/index.esm.js +0 -4
  20. package/dist/js/components.nFDoAkCq.js +0 -198
  21. package/dist/js/utils.CVb1iSAU.js +0 -330
  22. package/dist/types/components.d.ts +0 -1
  23. package/dist/types/hooks.d.ts +0 -1
  24. package/dist/types/index.d.ts +0 -1
  25. package/dist/types/src/components/async-custom-show/index.d.ts +0 -22
  26. package/dist/types/src/components/carousel/hooks.d.ts +0 -74
  27. package/dist/types/src/components/carousel/index.d.ts +0 -88
  28. package/dist/types/src/components/custom-show/index.d.ts +0 -21
  29. package/dist/types/src/components/error-boundary/index.d.ts +0 -31
  30. package/dist/types/src/components/index.d.ts +0 -8
  31. package/dist/types/src/hooks/async-guard.d.ts +0 -9
  32. package/dist/types/src/hooks/index.d.ts +0 -5
  33. package/dist/types/src/hooks/observer.d.ts +0 -70
  34. package/dist/types/src/hooks/state.d.ts +0 -44
  35. package/dist/types/src/hooks/storage.d.ts +0 -25
  36. package/dist/types/src/hooks/timer.d.ts +0 -16
  37. package/dist/types/src/index.d.ts +0 -3
  38. package/dist/types/src/test/emiter-test.d.ts +0 -1
  39. package/dist/types/src/test/index.d.ts +0 -1
  40. package/dist/types/src/test/retry-async-test.d.ts +0 -1
  41. package/dist/types/src/utils/class-singleton.d.ts +0 -6
  42. package/dist/types/src/utils/concurrency.d.ts +0 -17
  43. package/dist/types/src/utils/debounce.d.ts +0 -8
  44. package/dist/types/src/utils/deep-copy.d.ts +0 -11
  45. package/dist/types/src/utils/dev.d.ts +0 -8
  46. package/dist/types/src/utils/download.d.ts +0 -15
  47. package/dist/types/src/utils/event-emitter/helpers.d.ts +0 -36
  48. package/dist/types/src/utils/event-emitter/index.d.ts +0 -65
  49. package/dist/types/src/utils/fetch-xhr/helpers.d.ts +0 -28
  50. package/dist/types/src/utils/fetch-xhr/index.d.ts +0 -25
  51. package/dist/types/src/utils/hash.d.ts +0 -8
  52. package/dist/types/src/utils/index.d.ts +0 -15
  53. package/dist/types/src/utils/is-deep-plain-equal.d.ts +0 -15
  54. package/dist/types/src/utils/json-convert.d.ts +0 -66
  55. package/dist/types/src/utils/micro-queue-scheduler.d.ts +0 -14
  56. package/dist/types/src/utils/raf-interval.d.ts +0 -16
  57. package/dist/types/src/utils/record-typed-map.d.ts +0 -27
  58. package/dist/types/src/utils/retry-async.d.ts +0 -9
  59. package/dist/types/src/utils/thenable.d.ts +0 -15
  60. package/dist/types/utils.d.ts +0 -1
  61. package/dist/utils.esm.js +0 -2
  62. package/eslint.config.ts +0 -48
  63. package/lint-staged.config.ts +0 -13
  64. package/oxfmt.config.ts +0 -14
  65. package/pnpm-workspace.yaml +0 -3
  66. package/scripts/sync-node-version/index.js +0 -31
  67. package/simple-git-hooks.js +0 -4
  68. package/src/components/async-custom-show/index.tsx +0 -37
  69. package/src/components/carousel/hooks.ts +0 -312
  70. package/src/components/carousel/index.module.scss +0 -163
  71. package/src/components/carousel/index.tsx +0 -215
  72. package/src/components/custom-show/index.tsx +0 -31
  73. package/src/components/error-boundary/index.tsx +0 -48
  74. package/src/components/index.ts +0 -11
  75. package/src/hooks/async-guard.ts +0 -53
  76. package/src/hooks/index.ts +0 -5
  77. package/src/hooks/observer.ts +0 -236
  78. package/src/hooks/state.ts +0 -140
  79. package/src/hooks/storage.ts +0 -103
  80. package/src/hooks/timer.ts +0 -42
  81. package/src/index.ts +0 -3
  82. package/src/test/emiter-test.ts +0 -19
  83. package/src/test/index.ts +0 -35
  84. package/src/test/retry-async-test.ts +0 -8
  85. package/src/utils/class-singleton.ts +0 -23
  86. package/src/utils/concurrency.ts +0 -49
  87. package/src/utils/debounce.ts +0 -20
  88. package/src/utils/deep-copy.ts +0 -132
  89. package/src/utils/dev.ts +0 -16
  90. package/src/utils/download.ts +0 -39
  91. package/src/utils/event-emitter/helpers.ts +0 -80
  92. package/src/utils/event-emitter/index.ts +0 -171
  93. package/src/utils/fetch-xhr/helpers.ts +0 -85
  94. package/src/utils/fetch-xhr/index.ts +0 -103
  95. package/src/utils/hash.ts +0 -25
  96. package/src/utils/index.ts +0 -18
  97. package/src/utils/is-deep-plain-equal.ts +0 -45
  98. package/src/utils/json-convert.ts +0 -257
  99. package/src/utils/micro-queue-scheduler.ts +0 -38
  100. package/src/utils/raf-interval.ts +0 -42
  101. package/src/utils/record-typed-map.ts +0 -38
  102. package/src/utils/retry-async.ts +0 -30
  103. package/src/utils/thenable.ts +0 -30
  104. package/tsconfig.json +0 -43
  105. package/types/scss.d.ts +0 -10
  106. package/vite.config.ts +0 -51
@@ -1 +0,0 @@
1
- ._carousel_1ryaf_1{width:100%;height:100%;position:relative;overflow:hidden}._carousel_1ryaf_1[style*=--wrapperWidth]{width:calc(var(--wrapperWidth) * 1px)}._carousel_1ryaf_1[style*=--wrapperHeight]{height:calc(var(--wrapperHeight) * 1px)}._carousel_1ryaf_1:not([style*=--cardHeight]) ._wrapper_1ryaf_13 ._inner_1ryaf_13{height:100%}._carousel_1ryaf_1[style*=--cardWidth] ._wrapper_1ryaf_13{width:calc(var(--cardWidth) * 1px)}._carousel_1ryaf_1[style*=--cardWidth] ._wrapper_1ryaf_13 ._inner_1ryaf_13{transform:translateX(calc(var(--index) * (var(--cardWidth) + var(--gapSize,0)) * -1px))}._carousel_1ryaf_1[style*=--cardWidth] ._wrapper_1ryaf_13 ._inner_1ryaf_13>*{flex:0 0 calc(var(--cardWidth) * 1px);height:100%}._carousel_1ryaf_1:not([style*=--cardWidth]) ._wrapper_1ryaf_13{width:100%}._carousel_1ryaf_1:not([style*=--cardWidth]) ._wrapper_1ryaf_13 ._inner_1ryaf_13{transform:translateX(calc((-100% + var(--gapSize,0) * -1px) * var(--index)))}._carousel_1ryaf_1:not([style*=--cardWidth]) ._wrapper_1ryaf_13 ._inner_1ryaf_13>*{flex:0 0 100%;height:100%}._carousel_1ryaf_1:hover>._arrow_1ryaf_36.hover{display:block}._carousel_1ryaf_1>._arrow_1ryaf_36.hover,._carousel_1ryaf_1>._arrow_1ryaf_36.none{display:none}._carousel_1ryaf_1>._arrow_1ryaf_36.always,._carousel_1ryaf_1>._arrow_1ryaf_36.auto{display:block}._carousel_1ryaf_1>._arrow_1ryaf_36 ._left_1ryaf_48,._carousel_1ryaf_1>._arrow_1ryaf_36 ._right_1ryaf_49{z-index:9;cursor:pointer;background:#fff url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgMCAyMSAyMCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgaWQ9ImRvd24iPgo8cGF0aCBpZD0iVW5pb24iIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNNi43OTE4MiA1Ljc2ODY1QzYuNDAyNzMgNS4zNzk1NiA2LjQwMjczIDQuNzQ4NzEgNi43OTE4MiA0LjM1OTYyTDcuNDk2MzQgMy42NTUxQzcuODg1NDMgMy4yNjYwMSA4LjUxNjI4IDMuMjY2MDEgOC45MDUzNyAzLjY1NTFMMTQuNTQxNSA5LjI5MTI0QzE0LjczNzEgOS40ODY4MyAxNC44MzQ0IDkuNzQzNSAxNC44MzMzIDkuOTk5ODVDMTQuODM0NCAxMC4yNTYyIDE0LjczNzEgMTAuNTEyOSAxNC41NDE1IDEwLjcwODVMOC45MDUzNyAxNi4zNDQ2QzguNTE2MjggMTYuNzMzNyA3Ljg4NTQzIDE2LjczMzcgNy40OTYzNCAxNi4zNDQ2TDYuNzkxODIgMTUuNjQwMUM2LjQwMjczIDE1LjI1MSA2LjQwMjczIDE0LjYyMDEgNi43OTE4MiAxNC4yMzExTDExLjAyMyA5Ljk5OTg1TDYuNzkxODIgNS43Njg2NVoiIGZpbGw9IiMwMDY2RkMiLz4KPC9nPgo8L3N2Zz4K) 50%/contain no-repeat content-box border-box;border:1px solid #dde2e9;border-radius:50%;width:20px;height:20px;padding:14px;display:none;position:absolute;top:50%;transform:translateY(-50%);box-shadow:0 15px 35px -2px #0000000d,0 5px 15px #0000000d}._carousel_1ryaf_1>._arrow_1ryaf_36>.show{display:block}._carousel_1ryaf_1>._arrow_1ryaf_36 ._left_1ryaf_48{left:12px;transform:translateY(-50%)rotate(180deg)}._carousel_1ryaf_1>._arrow_1ryaf_36 ._right_1ryaf_49{right:12px}._carousel_1ryaf_1 ._wrapper_1ryaf_13{height:100%}._carousel_1ryaf_1 ._wrapper_1ryaf_13 ._inner_1ryaf_13{gap:calc(var(--gapSize) * 1px);height:calc(var(--cardHeight) * 1px);transition:transform .3s;display:flex}._indicator_1ryaf_85{z-index:9;border-radius:8px;gap:8px;display:flex;position:absolute;bottom:-17px;left:50%;transform:translate(-50%)}._indicator_1ryaf_85.none{display:none}._indicator_1ryaf_85.line>i{background-color:var(--Gray-3,#e5e8ef);cursor:pointer;border-radius:8px;width:40px;height:5px}._indicator_1ryaf_85.line>i.active{background:var(--byte-plus-blue-brand-primary-60,#0066fc)}._indicator_1ryaf_85.dot>i{background-color:var(--Gray-3,#e5e8ef);cursor:pointer;border-radius:50%;width:6px;height:6px}._indicator_1ryaf_85.dot>i.active{background:var(--byte-plus-blue-brand-primary-60,#0066fc)}
package/dist/hooks.esm.js DELETED
@@ -1,185 +0,0 @@
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 };
package/dist/index.esm.js DELETED
@@ -1,4 +0,0 @@
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 };
@@ -1,198 +0,0 @@
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 };