@unicom-cloud/ui-common 0.1.20 → 0.1.21
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/.virtual/_rolldown/runtime.js +1 -1
- package/.vite/manifest.json +40 -10
- package/development/index.js +1 -1
- package/development/interface.d.ts +1 -1
- package/empty/index.js +1 -1
- package/empty/interface.d.ts +1 -1
- package/flex/index.js +1 -1
- package/flex/utils.js +1 -1
- package/higher-order/index.js +1 -1
- package/higher-order/with-speech-synthesis/index.js +1 -1
- package/hooks/create-deep-compare-effect/index.js +1 -1
- package/hooks/create-update-effect/index.js +1 -1
- package/hooks/create-use-storage-state/index.js +1 -1
- package/hooks/index.js +1 -1
- package/hooks/use-async-effect/index.js +1 -1
- package/hooks/use-boolean/index.js +1 -1
- package/hooks/use-click-away/index.js +1 -1
- package/hooks/use-computed-state/index.js +1 -1
- package/hooks/use-controllable-value/index.js +1 -1
- package/hooks/use-cookie-state/index.js +1 -1
- package/hooks/use-count-down/index.js +1 -1
- package/hooks/use-counter/index.js +1 -1
- package/hooks/use-create/index.js +1 -1
- package/hooks/use-creation/index.js +1 -1
- package/hooks/use-debounce/index.js +1 -1
- package/hooks/use-debounce-effect/index.js +1 -1
- package/hooks/use-debounce-fn/index.js +1 -1
- package/hooks/use-deep-compare-effect/index.js +1 -1
- package/hooks/use-deep-compare-layout-effect/index.js +1 -1
- package/hooks/use-document-visibility/index.js +1 -1
- package/hooks/use-drag/index.js +1 -1
- package/hooks/use-drop/index.js +3 -3
- package/hooks/use-effect-event/index.js +13 -12
- package/hooks/use-event/index.js +1 -1
- package/hooks/use-event-emitter/index.js +1 -1
- package/hooks/use-event-listener/index.js +1 -1
- package/hooks/use-event-target/index.js +1 -1
- package/hooks/use-external/index.js +1 -1
- package/hooks/use-favicon/index.js +1 -1
- package/hooks/use-focus-within/index.js +1 -1
- package/hooks/use-force-update/index.js +1 -1
- package/hooks/use-fullscreen/index.js +1 -1
- package/hooks/use-get-state/index.js +1 -1
- package/hooks/use-history-travel/index.js +1 -1
- package/hooks/use-hover/index.js +1 -1
- package/hooks/use-id/index.js +1 -1
- package/hooks/use-in-view/index.js +1 -1
- package/hooks/use-in-viewport/index.js +1 -1
- package/hooks/use-infinite-scroll/index.js +54 -53
- package/hooks/use-intersection-observer/index.js +1 -1
- package/hooks/use-intersection-observers/index.js +1 -1
- package/hooks/use-interval/index.js +1 -1
- package/hooks/use-is-first-render/index.js +1 -1
- package/hooks/use-isomorphic-layout-effect/index.js +1 -1
- package/hooks/use-key-press/index.js +1 -1
- package/hooks/use-keyboard-event/index.js +1 -1
- package/hooks/use-latest/index.js +1 -1
- package/hooks/use-listen-window-resize/index.js +1 -1
- package/hooks/use-local-storage-state/index.js +1 -1
- package/hooks/use-lock-fn/index.js +1 -1
- package/hooks/use-long-press/index.js +1 -1
- package/hooks/use-map/index.js +1 -1
- package/hooks/use-media/index.js +12 -11
- package/hooks/use-memo/index.js +1 -1
- package/hooks/use-memoized-fn/index.js +1 -1
- package/hooks/use-merge-props/index.js +1 -1
- package/hooks/use-merge-value/index.js +1 -1
- package/hooks/use-mobile/index.js +1 -1
- package/hooks/use-mount/index.js +1 -1
- package/hooks/use-mouse/index.js +1 -1
- package/hooks/use-move/index.js +1 -1
- package/hooks/use-mutation-observer/index.js +1 -1
- package/hooks/use-mutation-observers/index.js +1 -1
- package/hooks/use-network/index.js +1 -1
- package/hooks/use-online-status/index.js +1 -1
- package/hooks/use-overflow-hidden/index.js +2 -2
- package/hooks/use-override-ref/index.js +1 -1
- package/hooks/use-pagination/index.js +1 -1
- package/hooks/use-paste-image/index.js +1 -1
- package/hooks/use-persist-callback/index.js +1 -1
- package/hooks/use-prefers-color-scheme-dark/index.js +1 -1
- package/hooks/use-previous/index.js +1 -1
- package/hooks/use-raf-interval/index.js +1 -1
- package/hooks/use-raf-state/index.js +1 -1
- package/hooks/use-raf-timeout/index.js +1 -1
- package/hooks/use-reactive/index.js +1 -1
- package/hooks/use-ref-latest/index.js +1 -1
- package/hooks/use-refs/index.js +13 -13
- package/hooks/use-request/index.js +1 -1
- package/hooks/use-request/src/Fetch.js +1 -1
- package/hooks/use-request/src/plugins/useAutoRunPlugin.js +1 -1
- package/hooks/use-request/src/plugins/useCachePlugin.js +1 -1
- package/hooks/use-request/src/plugins/useDebouncePlugin.js +20 -19
- package/hooks/use-request/src/plugins/useLoadingDelayPlugin.js +1 -1
- package/hooks/use-request/src/plugins/usePollingPlugin.js +1 -1
- package/hooks/use-request/src/plugins/useRefreshOnWindowFocusPlugin.js +1 -1
- package/hooks/use-request/src/plugins/useRetryPlugin.js +1 -1
- package/hooks/use-request/src/plugins/useThrottlePlugin.js +18 -17
- package/hooks/use-request/src/useRequest.js +1 -1
- package/hooks/use-request/src/useRequestImplement.js +1 -1
- package/hooks/use-request/src/utils/cache.js +1 -1
- package/hooks/use-request/src/utils/cachePromise.js +1 -1
- package/hooks/use-request/src/utils/cacheSubscribe.js +1 -1
- package/hooks/use-request/src/utils/isDocumentVisible.js +1 -1
- package/hooks/use-request/src/utils/isOnline.js +1 -1
- package/hooks/use-request/src/utils/limit.js +1 -1
- package/hooks/use-request/src/utils/subscribeFocus.js +1 -1
- package/hooks/use-request/src/utils/subscribeReVisible.js +1 -1
- package/hooks/use-reset-state/index.js +1 -1
- package/hooks/use-resize-observer/index.js +1 -1
- package/hooks/use-resize-observers/index.js +1 -1
- package/hooks/use-responsive/index.js +1 -1
- package/hooks/use-safe-state/index.js +1 -1
- package/hooks/use-scroll/index.js +1 -1
- package/hooks/use-selections/index.js +1 -1
- package/hooks/use-session-storage-state/index.js +1 -1
- package/hooks/use-set/index.js +1 -1
- package/hooks/use-set-state/index.js +1 -1
- package/hooks/use-size/index.js +1 -1
- package/hooks/use-state-callback/index.js +11 -9
- package/hooks/use-state-with-promise/index.js +1 -1
- package/hooks/use-sync-state/index.js +1 -1
- package/hooks/use-text-selection/index.js +1 -1
- package/hooks/use-theme/index.js +1 -1
- package/hooks/use-throttle/index.js +1 -1
- package/hooks/use-throttle-effect/index.js +1 -1
- package/hooks/use-throttle-fn/index.js +1 -1
- package/hooks/use-timeout/index.js +1 -1
- package/hooks/use-title/index.js +1 -1
- package/hooks/use-toggle/index.js +1 -1
- package/hooks/use-tracked-effect/index.js +1 -1
- package/hooks/use-unmount/index.js +1 -1
- package/hooks/use-unmounted-ref/index.js +1 -1
- package/hooks/use-update/index.js +1 -1
- package/hooks/use-update-effect/index.js +1 -1
- package/hooks/use-update-layout-effect/index.js +1 -1
- package/hooks/use-url-state/index.js +1 -1
- package/hooks/use-virtual-list/index.js +1 -1
- package/hooks/use-watch/index.js +1 -1
- package/hooks/use-web-socket/index.js +1 -1
- package/hooks/use-why-did-you-update/index.js +1 -1
- package/hooks/use-window-size/index.js +1 -1
- package/hooks/utils/createEffectWithTarget.js +1 -1
- package/hooks/utils/depsAreSame.js +1 -1
- package/hooks/utils/depsEqual.js +1 -1
- package/hooks/utils/domTarget.js +1 -1
- package/hooks/utils/getDocumentOrShadow.js +1 -1
- package/hooks/utils/index.js +1 -1
- package/hooks/utils/isAppleDevice.js +1 -1
- package/hooks/utils/isBrowser.js +1 -1
- package/hooks/utils/isDev.js +1 -1
- package/hooks/utils/rect.js +1 -1
- package/hooks/utils/useDeepCompareWithTarget.js +1 -1
- package/hooks/utils/useEffectWithTarget.js +1 -1
- package/hooks/utils/useIsomorphicLayoutEffectWithTarget.js +1 -1
- package/hooks/utils/useLayoutEffectWithTarget.js +1 -1
- package/icons/file/index.js +1 -1
- package/icons/file/interface.d.ts +1 -1
- package/index.js +586 -579
- package/interface.d.ts +3 -0
- package/package.json +1 -1
- package/progress/index.js +1 -1
- package/resize-observer/Collection.js +1 -1
- package/resize-observer/SingleObserver.js +1 -1
- package/resize-observer/index.js +1 -1
- package/resize-observer/observerUtil.js +1 -1
- package/space/index.js +49 -48
- package/space/interface.d.ts +1 -1
- package/suspense-fallback-test/index.js +1 -1
- package/test.js +1 -1
- package/timer/index.js +25 -23
- package/timer/interface.d.ts +1 -1
- package/transition/Transition.js +71 -61
- package/transition/TransitionCSS.js +32 -23
- package/transition/TransitionGroup.d.ts +3 -3
- package/transition/TransitionGroup.js +44 -49
- package/transition/TransitionStyle.js +29 -38
- package/transition/constants.d.ts +8 -2
- package/transition/constants.js +32 -30
- package/transition/index.d.ts +3 -5
- package/transition/index.js +9 -9
- package/transition/interface.d.ts +22 -17
- package/transition/utils.d.ts +2 -1
- package/transition/utils.js +69 -67
- package/utils/callOrReturn.js +1 -1
- package/utils/callbackOriginRef.js +1 -1
- package/utils/caseName.js +1 -1
- package/utils/className.js +1 -1
- package/utils/constant.d.ts +2 -0
- package/utils/constant.js +3 -3
- package/utils/copy.js +1 -1
- package/utils/date.js +1 -1
- package/utils/dayjs.js +1 -1
- package/utils/dom.js +1 -1
- package/utils/emitter.js +1 -1
- package/utils/fileRead.js +1 -1
- package/utils/fileToDataURL.js +1 -1
- package/utils/fillNBSP.js +1 -1
- package/utils/findRootElement.d.ts +1 -1
- package/utils/findRootElement.js +1 -1
- package/utils/findScrollParent.js +1 -1
- package/utils/getHighlightText.js +2 -2
- package/utils/getHotkeyHandler.js +1 -1
- package/utils/getScrollBarHeight.js +1 -1
- package/utils/getScrollBarSize.js +16 -6
- package/utils/getScrollBarWidth.js +1 -1
- package/utils/getStringLength.js +1 -1
- package/utils/include.js +1 -1
- package/utils/index.js +289 -282
- package/utils/intersectionObserver.js +1 -1
- package/utils/is.d.ts +2 -2
- package/utils/is.js +15 -15
- package/utils/keyboardCode.js +1 -1
- package/utils/lodash.js +1 -1
- package/utils/math.js +1 -1
- package/utils/mergeProps.js +8 -7
- package/utils/mergedToString.js +1 -1
- package/utils/mutationObserver.js +1 -1
- package/utils/omit.js +1 -1
- package/utils/pad.js +1 -1
- package/utils/pick.js +1 -1
- package/utils/pinyin.js +1 -1
- package/utils/react19Adapter.js +1 -1
- package/utils/ref.js +1 -1
- package/utils/resizeObserver.js +1 -1
- package/utils/saveAs.js +1 -1
- package/utils/screenfull.js +1 -1
- package/utils/scrollIntoViewIfNeeded.js +1 -1
- package/utils/setCreateRoot.js +1 -1
- package/utils/setDarkTheme.js +1 -1
- package/utils/setDir.js +1 -1
- package/utils/setPrimaryColor.js +1 -1
- package/utils/setTheme.js +1 -1
- package/utils/string.js +1 -1
- package/utils/style.js +1 -1
- package/utils/throttleByRaf.js +1 -1
- package/utils/throttleByRaf2.js +1 -1
- package/utils/tinycolor.js +1 -1
- package/utils/toArray.js +1 -1
- package/utils/tree.js +1 -1
- package/utils/tween.js +1 -1
- package/utils/uuid.js +1 -1
- package/utils/validate.js +1 -1
- package/utils/warning.js +1 -1
- package/version/index.js +8 -8
package/interface.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@unicom-cloud/ui-common","version":"0.1.
|
|
1
|
+
{"name":"@unicom-cloud/ui-common","version":"0.1.21","dependencies":{"@unicom-cloud/utils":"^0.1.0","@unicom-cloud/icons":"^0.1.0"},"peerDependencies":{"dayjs":"^1.11.19","lodash":"^4.18.1","react":"^18.3.1","react-dom":"^18.3.1","react-is":"^18.3.1"},"type":"module","types":"types/index.d.ts","main":"./index.js","bin":{"ui":"./test.js"},"publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"}}
|
package/progress/index.js
CHANGED
package/resize-observer/index.js
CHANGED
package/space/index.js
CHANGED
|
@@ -1,73 +1,74 @@
|
|
|
1
|
-
/* 潘启宝 2026-04-
|
|
2
|
-
import e from "../
|
|
3
|
-
import t from "../
|
|
4
|
-
import n from "../utils/
|
|
5
|
-
import r from "../
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
/* 潘启宝 2026-04-23 09:23:27 星期四 */
|
|
2
|
+
import { isPresent as e } from "../utils/is.js";
|
|
3
|
+
import t from "../hooks/use-merge-props/index.js";
|
|
4
|
+
import n from "../utils/className.js";
|
|
5
|
+
import r from "../utils/toArray.js";
|
|
6
|
+
import i from "../flex/index.js";
|
|
7
|
+
import { Fragment as a, forwardRef as o, useImperativeHandle as s, useRef as c } from "react";
|
|
8
|
+
import { UI_COMMON_PREFIX as l } from "@unicom-cloud/utils/constant/ui";
|
|
9
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
9
10
|
//#region components/common/space/index.tsx
|
|
10
|
-
var
|
|
11
|
+
var f = {
|
|
11
12
|
gap: "small",
|
|
12
13
|
direction: "horizontal"
|
|
13
14
|
};
|
|
14
|
-
function
|
|
15
|
-
let { className:
|
|
15
|
+
function p(o, p) {
|
|
16
|
+
let { className: m, style: h, children: g, size: _, gap: v, direction: y, justifyContent: b, align: x, alignItems: S, wrap: C, separator: w, rtl: T, legacy: E, ...D } = t(o, f, {}), O = `${l}-space`, k = [
|
|
16
17
|
"horizontal",
|
|
17
18
|
"row-reverse",
|
|
18
19
|
"row"
|
|
19
|
-
].includes(
|
|
20
|
+
].includes(y);
|
|
20
21
|
[
|
|
21
22
|
"vertical",
|
|
22
23
|
"column-reverse",
|
|
23
24
|
"column"
|
|
24
|
-
].includes(
|
|
25
|
-
let
|
|
25
|
+
].includes(y);
|
|
26
|
+
let A = {
|
|
26
27
|
horizontal: "row",
|
|
27
28
|
vertical: "column"
|
|
28
|
-
}[
|
|
29
|
+
}[y] ?? y, j = E ? {
|
|
29
30
|
start: "flex-start",
|
|
30
31
|
end: "flex-end"
|
|
31
|
-
} : {},
|
|
32
|
-
|
|
33
|
-
let
|
|
34
|
-
[`${
|
|
35
|
-
[`${
|
|
36
|
-
[`${
|
|
37
|
-
[`${
|
|
38
|
-
},
|
|
39
|
-
return
|
|
40
|
-
return
|
|
41
|
-
} })), /* @__PURE__ */
|
|
42
|
-
ref:
|
|
43
|
-
style:
|
|
44
|
-
className:
|
|
45
|
-
gap:
|
|
46
|
-
wrap:
|
|
47
|
-
justifyContent:
|
|
48
|
-
alignItems:
|
|
49
|
-
direction:
|
|
50
|
-
rtl:
|
|
32
|
+
} : {}, M = j[b] ?? b, N = S ?? x ?? (k ? "center" : void 0);
|
|
33
|
+
N = j[N] ?? N;
|
|
34
|
+
let P = n(O, {
|
|
35
|
+
[`${O}-${y}`]: y,
|
|
36
|
+
[`${O}-justify-content-${M}`]: M,
|
|
37
|
+
[`${O}-align-items-${N}`]: N,
|
|
38
|
+
[`${O}-rtl`]: T
|
|
39
|
+
}, C ? `${O}-wrap` : `${O}-no-wrap`, m), F = r(g), I = c(null);
|
|
40
|
+
return s(p, () => ({ getRootElement() {
|
|
41
|
+
return I.current.getRootElement();
|
|
42
|
+
} })), /* @__PURE__ */ u(i, {
|
|
43
|
+
ref: I,
|
|
44
|
+
style: h,
|
|
45
|
+
className: P,
|
|
46
|
+
gap: v ?? _,
|
|
47
|
+
wrap: C,
|
|
48
|
+
justifyContent: M,
|
|
49
|
+
alignItems: N,
|
|
50
|
+
direction: A,
|
|
51
|
+
rtl: T,
|
|
51
52
|
inline: !0,
|
|
52
|
-
...
|
|
53
|
-
children:
|
|
54
|
-
let
|
|
55
|
-
return /* @__PURE__ */
|
|
56
|
-
className: `${
|
|
57
|
-
children:
|
|
58
|
-
}), /* @__PURE__ */
|
|
59
|
-
className: `${
|
|
60
|
-
children:
|
|
61
|
-
})] },
|
|
53
|
+
...D,
|
|
54
|
+
children: F.map((t, n) => {
|
|
55
|
+
let r = t?.key ?? n;
|
|
56
|
+
return /* @__PURE__ */ d(a, { children: [e(w) && n > 0 && /* @__PURE__ */ u("div", {
|
|
57
|
+
className: `${O}-item-separator`,
|
|
58
|
+
children: w
|
|
59
|
+
}), /* @__PURE__ */ u("div", {
|
|
60
|
+
className: `${O}-item`,
|
|
61
|
+
children: t
|
|
62
|
+
})] }, r);
|
|
62
63
|
})
|
|
63
64
|
});
|
|
64
65
|
}
|
|
65
|
-
var
|
|
66
|
+
var m = o(p), h = o((e, t) => /* @__PURE__ */ u(m, {
|
|
66
67
|
...e,
|
|
67
68
|
ref: t,
|
|
68
69
|
direction: "vertical"
|
|
69
70
|
}));
|
|
70
|
-
|
|
71
|
+
h.displayName = "SpaceVertical", m.Vertical = h;
|
|
71
72
|
//#endregion
|
|
72
|
-
export {
|
|
73
|
+
export { h as SpaceVertical, m as default };
|
|
73
74
|
/* 独立思考,明辨是非 */
|
package/space/interface.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type JustifyContent = 'start' | 'end' | 'center' | 'space-between';
|
|
|
5
5
|
export type Direction = 'vertical' | 'horizontal';
|
|
6
6
|
export interface SpaceProps {
|
|
7
7
|
style?: CSSProperties;
|
|
8
|
-
className?: string
|
|
8
|
+
className?: string;
|
|
9
9
|
/**
|
|
10
10
|
* @zh 交叉轴方向对齐方式
|
|
11
11
|
* @deprecated 请用 alignItems 属性替代
|
package/test.js
CHANGED
package/timer/index.js
CHANGED
|
@@ -1,37 +1,39 @@
|
|
|
1
|
-
/* 潘启宝 2026-04-
|
|
1
|
+
/* 潘启宝 2026-04-23 09:23:27 星期四 */
|
|
2
2
|
import { isFunction as e } from "../utils/is.js";
|
|
3
|
-
import t from "../utils/
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
3
|
+
import { DAYJS_DEFAULT_FORMAT_WITH_TIME as t } from "../utils/constant.js";
|
|
4
|
+
import n from "../utils/className.js";
|
|
5
|
+
import "../utils/index.js";
|
|
6
|
+
import { forwardRef as r, useEffect as i, useImperativeHandle as a, useRef as o, useState as s } from "react";
|
|
7
|
+
import c from "dayjs";
|
|
8
|
+
import { UI_COMMON_PREFIX as l } from "@unicom-cloud/utils/constant/ui";
|
|
9
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
8
10
|
//#region components/common/timer/index.tsx
|
|
9
|
-
function
|
|
10
|
-
let { style:
|
|
11
|
-
function
|
|
12
|
-
return
|
|
11
|
+
function d(r, d) {
|
|
12
|
+
let { style: f, className: p, format: m = `${t} dddd`, callback: h, ...g } = r, _ = `${l}-timer`, [v, y] = s({ time: b() });
|
|
13
|
+
function b() {
|
|
14
|
+
return c().format(m);
|
|
13
15
|
}
|
|
14
|
-
|
|
16
|
+
i(() => {
|
|
15
17
|
let t = n();
|
|
16
|
-
function n(r =
|
|
17
|
-
return e(
|
|
18
|
-
|
|
18
|
+
function n(r = b()) {
|
|
19
|
+
return e(h) && h(r), window.requestAnimationFrame(() => {
|
|
20
|
+
y({ time: r }), t = n();
|
|
19
21
|
});
|
|
20
22
|
}
|
|
21
23
|
return () => {
|
|
22
24
|
window.cancelAnimationFrame(t);
|
|
23
25
|
};
|
|
24
26
|
}, []);
|
|
25
|
-
let
|
|
26
|
-
return
|
|
27
|
-
return
|
|
28
|
-
} })), /* @__PURE__ */
|
|
29
|
-
ref:
|
|
30
|
-
className:
|
|
31
|
-
children:
|
|
27
|
+
let x = o(null);
|
|
28
|
+
return a(d, () => ({ getRootElement() {
|
|
29
|
+
return x.current;
|
|
30
|
+
} })), /* @__PURE__ */ u("div", {
|
|
31
|
+
ref: x,
|
|
32
|
+
className: n(_, p),
|
|
33
|
+
children: v.time
|
|
32
34
|
});
|
|
33
35
|
}
|
|
34
|
-
var
|
|
36
|
+
var f = r(d);
|
|
35
37
|
//#endregion
|
|
36
|
-
export {
|
|
38
|
+
export { f as default };
|
|
37
39
|
/* 独立思考,明辨是非 */
|
package/timer/interface.d.ts
CHANGED
package/transition/Transition.js
CHANGED
|
@@ -1,92 +1,102 @@
|
|
|
1
|
-
/* 潘启宝 2026-04-
|
|
1
|
+
/* 潘启宝 2026-04-23 09:23:27 星期四 */
|
|
2
2
|
import { isFunction as e, isNull as t, isUndefined as n } from "../utils/is.js";
|
|
3
3
|
import r from "../hooks/use-latest/index.js";
|
|
4
4
|
import i from "../hooks/use-create/index.js";
|
|
5
5
|
import a from "../hooks/use-update-effect/index.js";
|
|
6
|
-
import { forceReflow as
|
|
7
|
-
import
|
|
6
|
+
import { forceReflow as o } from "../utils/dom.js";
|
|
7
|
+
import ee from "../utils/findRootElement.js";
|
|
8
8
|
import s from "../hooks/use-update-layout-effect/index.js";
|
|
9
|
-
import { defaults as
|
|
10
|
-
import
|
|
9
|
+
import { defaults as te } from "../utils/lodash.js";
|
|
10
|
+
import c from "../hooks/use-is-first-render/index.js";
|
|
11
11
|
import "../hooks/index.js";
|
|
12
|
-
import {
|
|
13
|
-
import { getDurations as
|
|
14
|
-
import
|
|
12
|
+
import { TRANSITION_ADD_END_LISTENER_KEY as l, TRANSITION_ALWAYS_MOUNTED_KEY as u, TRANSITION_DEFAULT_PROPS as d, TRANSITION_DURATION_KEY as ne, TRANSITION_EVENT_MAP as f, TRANSITION_EVENT_NAME_KEY as p, TRANSITION_MOUNT_ON_ENTER_KEY as re, TRANSITION_NEXT_PHASE_KEY as ie, TRANSITION_PHASE_APPEAR as m, TRANSITION_PHASE_APPEAR_DONE as h, TRANSITION_PHASE_ENTER as g, TRANSITION_PHASE_ENTER_DONE as _, TRANSITION_PHASE_EXIT as v, TRANSITION_PHASE_EXIT_DONE as y, TRANSITION_UNMOUNT_ON_EXIT_KEY as b } from "./constants.js";
|
|
13
|
+
import { getDurations as ae, isActivePhaseHandler as oe, isAppearPhaseHandler as se, isEnterPhaseHandler as ce, isExitDonePhaseHandler as le, isExitPhaseHandler as x } from "./utils.js";
|
|
14
|
+
import S, { useDeferredValue as ue, useEffect as C, useLayoutEffect as w, useRef as T, useState as E, useTransition as D } from "react";
|
|
15
15
|
//#region components/common/transition/Transition.tsx
|
|
16
|
-
var {
|
|
17
|
-
function
|
|
18
|
-
let
|
|
19
|
-
i(() => {});
|
|
20
|
-
let U =
|
|
21
|
-
"unmountOnExit" in
|
|
22
|
-
let
|
|
23
|
-
|
|
16
|
+
var { setTimeout: O, clearTimeout: k, requestAnimationFrame: A, cancelAnimationFrame: j } = window, M = { ...d };
|
|
17
|
+
function N(d) {
|
|
18
|
+
let S = te({}, d, M), N = "hasShown", P = "refElement", { children: F, in: I, [m]: L, [g]: R, [v]: z, [ne]: B = 500, [u]: de, [l]: fe, [re]: V, [b]: H, [P]: pe } = S;
|
|
19
|
+
i(() => {}), c();
|
|
20
|
+
let U = T({ [N]: I }), W = U.current[N], G = de;
|
|
21
|
+
"unmountOnExit" in S && !n(H) && (G = !H);
|
|
22
|
+
let K = "mountOnEnter" in S && !n(V);
|
|
23
|
+
K && (W || (G = !V));
|
|
24
|
+
let [me, he] = E(() => X(ve())), { phase: q, destroy: J } = me, Y = ue(J, J), [ge, _e] = D();
|
|
25
|
+
r(q);
|
|
26
|
+
function ve() {
|
|
27
|
+
let e = y;
|
|
28
|
+
return I && (e = L ? m : h), e;
|
|
29
|
+
}
|
|
30
|
+
function X(e) {
|
|
24
31
|
return {
|
|
25
32
|
phase: e,
|
|
26
|
-
destroy:
|
|
33
|
+
destroy: ye(e)
|
|
27
34
|
};
|
|
28
|
-
}), { phase: K, destroy: q } = le, J = S(q), [de, fe] = se();
|
|
29
|
-
r(K);
|
|
30
|
-
function pe() {
|
|
31
|
-
let e = M;
|
|
32
|
-
return x && (e = T ? w : E), e;
|
|
33
35
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
function X(e) {
|
|
38
|
-
return G ? void 0 : y(e);
|
|
36
|
+
function Z() {
|
|
37
|
+
let { [P]: e } = S;
|
|
38
|
+
return ee(e);
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
...t,
|
|
43
|
-
phase: e,
|
|
44
|
-
destroy: X(e)
|
|
45
|
-
})));
|
|
40
|
+
function ye(e) {
|
|
41
|
+
return G ? void 0 : le(e);
|
|
46
42
|
}
|
|
47
43
|
function Q(t) {
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
if (t) {
|
|
45
|
+
{
|
|
46
|
+
let n = Z(), { onBeforePhaseChange: r } = S;
|
|
47
|
+
e(r) && r(t, n), o(n);
|
|
48
|
+
}
|
|
49
|
+
he((e) => ({
|
|
50
|
+
...e,
|
|
51
|
+
...X(t)
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
50
54
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return
|
|
57
|
-
}, [
|
|
58
|
-
let
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
w(() => {
|
|
56
|
+
if (!(K && !V && !W)) {
|
|
57
|
+
let t = f[q]?.[p], { [t]: n } = S;
|
|
58
|
+
e(n) && n(Z());
|
|
59
|
+
}
|
|
60
|
+
return () => {};
|
|
61
|
+
}, [q]), a(() => {
|
|
62
|
+
let { onAfterPhaseChange: t } = S;
|
|
63
|
+
return e(t) && t(q, Z()), () => {};
|
|
64
|
+
}, [q]), s(() => {
|
|
65
|
+
let e, t = x(q);
|
|
66
|
+
return I ? (U.current[N] = !0, t && (e = R ? g : _)) : t || (e = z ? v : y), Q(e || q), () => {};
|
|
67
|
+
}, [I]), C(() => {
|
|
68
|
+
let { [l]: n } = S, r = null, i = null, a = f[q]?.[ie];
|
|
69
|
+
if (a && q !== a) if (oe(q)) if (e(n)) n(q, (e) => {
|
|
70
|
+
Q(e || a);
|
|
71
|
+
}, Z());
|
|
62
72
|
else {
|
|
63
|
-
let e =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}, t,
|
|
73
|
+
let e = ae(B), t = e[g];
|
|
74
|
+
t = se(q) ? e[m] : ce(q) ? e[g] : x(q) ? e[v] : e[g], r = O((e) => {
|
|
75
|
+
Q(e || a);
|
|
76
|
+
}, t, a);
|
|
67
77
|
}
|
|
68
|
-
else
|
|
69
|
-
|
|
78
|
+
else i = A(() => {
|
|
79
|
+
Q(a);
|
|
70
80
|
});
|
|
71
81
|
return () => {
|
|
72
|
-
t(
|
|
82
|
+
t(r) || k(r), t(i) || j(i);
|
|
73
83
|
};
|
|
74
|
-
}, [
|
|
84
|
+
}, [q]), s(() => () => {}, []), w(() => () => {}, []), a(() => () => {}, []), C(() => () => {}, []);
|
|
75
85
|
{
|
|
76
86
|
let e = !0;
|
|
77
|
-
if (n(
|
|
87
|
+
if (n(J) || (z ? I ? J && (e = !1) : Y && (e = !1) : I || Y && (e = !1)), !e) return null;
|
|
78
88
|
}
|
|
79
|
-
let $ =
|
|
89
|
+
let $ = F;
|
|
80
90
|
if (e($)) {
|
|
81
|
-
let e = Object.keys(
|
|
91
|
+
let e = Object.keys(f).reduce((e, t, n, r) => ({
|
|
82
92
|
...e,
|
|
83
|
-
[t]:
|
|
93
|
+
[t]: q === t
|
|
84
94
|
}), {});
|
|
85
|
-
$ = $(e,
|
|
95
|
+
$ = $(e, q);
|
|
86
96
|
}
|
|
87
97
|
return $;
|
|
88
98
|
}
|
|
89
|
-
var
|
|
99
|
+
var P = S.memo(N);
|
|
90
100
|
//#endregion
|
|
91
|
-
export {
|
|
101
|
+
export { P as Transition, P as default };
|
|
92
102
|
/* 独立思考,明辨是非 */
|
|
@@ -1,33 +1,42 @@
|
|
|
1
|
-
/* 潘启宝 2026-04-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { TRANSITION_CSS_CLASS_NAMES_SUFFIX as
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
1
|
+
/* 潘启宝 2026-04-23 09:23:27 星期四 */
|
|
2
|
+
import { isPlainObject as e, isString as t, isStringAndExist as n } from "../utils/is.js";
|
|
3
|
+
import r from "../utils/className.js";
|
|
4
|
+
import { TRANSITION_CSS_CLASS_NAMES_SUFFIX as i, TRANSITION_PHASE_APPEAR as a } from "./constants.js";
|
|
5
|
+
import { fallbackAppearToEnter as o, isAppearPhaseHandler as s } from "./utils.js";
|
|
6
|
+
import { Transition as c } from "./Transition.js";
|
|
7
|
+
import l, { cloneElement as u, isValidElement as d } from "react";
|
|
8
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
8
9
|
//#region components/common/transition/TransitionCSS.tsx
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (!
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
function p(c) {
|
|
11
|
+
let { children: l, classNames: f = "", phase: p, [a]: m } = c;
|
|
12
|
+
if (!d(l)) return null;
|
|
13
|
+
if (!f) return l;
|
|
14
|
+
let h = "";
|
|
15
|
+
if (t(f)) {
|
|
16
|
+
let e = i[p];
|
|
17
|
+
n(e) && (h = `${f}-${e}`);
|
|
18
|
+
} else if (e(f)) {
|
|
19
|
+
let e = { ...f };
|
|
20
|
+
m && s(p) && Object.assign(e, o(e)), h = e[p] ?? "";
|
|
21
|
+
}
|
|
22
|
+
if (!n(h)) return l;
|
|
23
|
+
let { className: g } = l.props;
|
|
24
|
+
return u(l, { className: r(g, h) });
|
|
18
25
|
}
|
|
19
|
-
function
|
|
20
|
-
let { children: t, classNames: n, ...r } = e;
|
|
21
|
-
return /* @__PURE__ */
|
|
26
|
+
function m(e) {
|
|
27
|
+
let { children: t, classNames: n = "", ...r } = e;
|
|
28
|
+
return /* @__PURE__ */ f(c, {
|
|
22
29
|
...r,
|
|
23
|
-
children: (e,
|
|
30
|
+
children: (e, i) => /* @__PURE__ */ f(p, {
|
|
31
|
+
...r,
|
|
24
32
|
classNames: n,
|
|
25
|
-
phase:
|
|
33
|
+
phase: i,
|
|
26
34
|
children: t
|
|
27
35
|
})
|
|
28
36
|
});
|
|
29
37
|
}
|
|
30
|
-
var
|
|
38
|
+
var h = l.memo(m);
|
|
39
|
+
h.displayName = "TransitionCSS";
|
|
31
40
|
//#endregion
|
|
32
|
-
export {
|
|
41
|
+
export { h as TransitionCSS, h as default };
|
|
33
42
|
/* 独立思考,明辨是非 */
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { TransitionGroupProps } from './interface';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* 并在元素进入和退出 DOM
|
|
6
|
-
*
|
|
4
|
+
* TransitionGroup 组件用于管理一组 Transition 子元素
|
|
5
|
+
* 并在元素进入和退出 DOM 时自动应用过渡动画。
|
|
6
|
+
* 该组件可用于为多个元素设置动画,控制它们在容器中的显示和移除。
|
|
7
7
|
*/
|
|
8
8
|
declare function Component(baseProps: TransitionGroupProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>[];
|
|
9
9
|
declare const TransitionGroup: React.MemoExoticComponent<typeof Component>;
|
|
@@ -1,62 +1,57 @@
|
|
|
1
|
-
/* 潘启宝 2026-04-
|
|
2
|
-
import e from "../
|
|
1
|
+
/* 潘启宝 2026-04-23 09:23:27 星期四 */
|
|
2
|
+
import { isNumber as e } from "../utils/is.js";
|
|
3
3
|
import { defaults as t } from "../utils/lodash.js";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
4
|
+
import n from "../hooks/use-is-first-render/index.js";
|
|
5
|
+
import "../hooks/index.js";
|
|
6
|
+
import { TRANSITION_ALWAYS_MOUNTED_KEY as r, TRANSITION_DEFAULT_PROPS as i, TRANSITION_DURATION_KEY as a, TRANSITION_PHASE_APPEAR as o, TRANSITION_PHASE_ENTER as s, TRANSITION_PHASE_EXIT as c } from "./constants.js";
|
|
7
|
+
import { getDurations as l } from "./utils.js";
|
|
8
|
+
import u, { Children as d, cloneElement as f, isValidElement as p, useEffect as m, useRef as h } from "react";
|
|
7
9
|
//#region components/common/transition/TransitionGroup.tsx
|
|
8
|
-
var {
|
|
9
|
-
|
|
10
|
-
[
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
let { children: r, [d]: i = !0, [m]: o = !0, [_]: f = !0, duration: p = 500, alwaysMounted: h = !1 } = t({}, n, A), g = u(!1), v = u([]), y = [], b = [], x = {}, S = [];
|
|
17
|
-
s.toArray(r).forEach((e, t, n) => {
|
|
18
|
-
l(e) && (x[e.key] = S.length, S.push(e));
|
|
19
|
-
});
|
|
20
|
-
function C(e, t) {
|
|
21
|
-
let { alwaysMounted: n = h, duration: r = p, [d]: a = i, [m]: s = o, [_]: l = f } = e.props ?? {}, u = c(e, {
|
|
22
|
-
in: !t,
|
|
23
|
-
alwaysMounted: n,
|
|
24
|
-
duration: r,
|
|
25
|
-
[_]: l,
|
|
26
|
-
[m]: s,
|
|
27
|
-
[d]: g.current ? s : a
|
|
10
|
+
var { setTimeout: g, clearTimeout: _, requestAnimationFrame: v, cancelAnimationFrame: y } = window, b = { ...i };
|
|
11
|
+
function x(i) {
|
|
12
|
+
let { children: u, [o]: v = !0, [s]: y = !0, [c]: x = !0, [a]: S = 500, [r]: C = !1 } = t({}, i, b), w = n(), T = h([]), E = [], D = [], O = d.toArray(u).filter((e, t, n) => p(e));
|
|
13
|
+
function k(t, n) {
|
|
14
|
+
let i = t.props ?? {}, { [r]: l = C, [a]: u = S, [o]: d = v, [s]: p = y, [c]: m = x } = i;
|
|
15
|
+
E.push({
|
|
16
|
+
element: t,
|
|
17
|
+
removeTimeout: n
|
|
28
18
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
let h = {
|
|
20
|
+
...i,
|
|
21
|
+
in: !e(n),
|
|
22
|
+
[r]: l,
|
|
23
|
+
[a]: u,
|
|
24
|
+
[c]: m,
|
|
25
|
+
[s]: p,
|
|
26
|
+
[o]: w ? d : p
|
|
27
|
+
};
|
|
28
|
+
D.push(f(t, h));
|
|
33
29
|
}
|
|
34
|
-
function
|
|
35
|
-
let {
|
|
36
|
-
return
|
|
37
|
-
let
|
|
30
|
+
function A(e) {
|
|
31
|
+
let { [r]: t = C, [a]: n = S, [o]: i = v, [s]: u = y, [c]: d = x } = e.props ?? {}, f = l(n)[c];
|
|
32
|
+
return g(() => {
|
|
33
|
+
let t = T.current.findIndex((t, n, r) => {
|
|
38
34
|
let { element: i } = t ?? {};
|
|
39
|
-
return i.key === e.key;
|
|
35
|
+
return i === e || i.key === e.key;
|
|
40
36
|
});
|
|
41
|
-
|
|
42
|
-
},
|
|
37
|
+
t === -1 || T.current.splice(t, 1);
|
|
38
|
+
}, f);
|
|
43
39
|
}
|
|
44
|
-
let
|
|
45
|
-
|
|
46
|
-
let { element:
|
|
47
|
-
if (
|
|
40
|
+
let j = 0;
|
|
41
|
+
T.current.forEach((t, n, i) => {
|
|
42
|
+
let { element: l, removeTimeout: u } = t ?? {}, d = e(u), { [r]: f = C, [a]: p = S, [o]: m = v, [s]: h = y, [c]: g = x } = l.props ?? {}, b = O.findIndex((e, t, n) => e === l || e.key === l.key);
|
|
43
|
+
if (b === -1) d ? k(l, u) : g && k(l, A(l));
|
|
48
44
|
else {
|
|
49
|
-
|
|
50
|
-
for (let e =
|
|
45
|
+
d && _(u);
|
|
46
|
+
for (let e = j; e <= b; e += 1) k(O[e]);
|
|
51
47
|
}
|
|
52
|
-
|
|
48
|
+
j = Math.max(j, b + 1);
|
|
53
49
|
});
|
|
54
|
-
for (let e =
|
|
55
|
-
return
|
|
56
|
-
g.current = !0;
|
|
57
|
-
}, []), v.current = y, b;
|
|
50
|
+
for (let e = j; e < O.length; e += 1) k(O[e]);
|
|
51
|
+
return T.current = E, m(() => () => {}, []), D;
|
|
58
52
|
}
|
|
59
|
-
var
|
|
53
|
+
var S = u.memo(x);
|
|
54
|
+
S.displayName = "TransitionGroup";
|
|
60
55
|
//#endregion
|
|
61
|
-
export {
|
|
56
|
+
export { S as TransitionGroup, S as default };
|
|
62
57
|
/* 独立思考,明辨是非 */
|