@unicom-cloud/ui-common 0.1.18 → 0.1.20
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 +127 -191
- package/development/index.js +1 -1
- package/empty/index.js +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 +8 -7
- package/hooks/create-update-effect/index.d.ts +1 -1
- package/hooks/create-update-effect/index.js +9 -10
- package/hooks/create-use-storage-state/index.d.ts +2 -1
- package/hooks/create-use-storage-state/index.js +44 -35
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +82 -81
- package/hooks/use-async-effect/index.js +1 -1
- package/hooks/use-boolean/index.js +1 -1
- package/hooks/use-click-away/index.d.ts +2 -2
- package/hooks/use-click-away/index.js +7 -3
- package/hooks/use-computed-state/index.js +1 -1
- package/hooks/use-controllable-value/index.js +1 -1
- package/hooks/use-cookie-state/index.d.ts +34 -1
- package/hooks/use-cookie-state/index.js +16 -16
- package/hooks/use-count-down/index.js +1 -1
- package/hooks/use-counter/index.js +1 -1
- package/hooks/use-create/index.d.ts +4 -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 +1 -1
- package/hooks/use-effect-event/index.js +1 -1
- package/hooks/use-event/index.js +1 -1
- package/hooks/use-event-emitter/demo/demo1.d.ts +10 -0
- package/hooks/use-event-emitter/index.d.ts +8 -0
- package/hooks/use-event-emitter/index.js +26 -0
- package/hooks/use-event-listener/index.d.ts +3 -2
- package/hooks/use-event-listener/index.js +1 -1
- package/hooks/use-event-target/index.js +1 -1
- package/hooks/use-external/index.js +25 -24
- 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 +1 -1
- package/hooks/use-intersection-observer/index.js +1 -1
- package/hooks/use-intersection-observers/index.js +25 -25
- 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 +3 -3
- package/hooks/use-latest/index.js +1 -1
- package/hooks/use-listen-window-resize/index.d.ts +1 -1
- package/hooks/use-listen-window-resize/index.js +3 -3
- 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 +1 -1
- package/hooks/use-memo/index.js +1 -1
- package/hooks/use-memoized-fn/index.d.ts +1 -1
- package/hooks/use-memoized-fn/index.js +3 -3
- 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 +24 -24
- package/hooks/use-network/index.js +1 -1
- package/hooks/use-online-status/index.js +1 -1
- package/hooks/use-overflow-hidden/index.js +17 -16
- 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 -12
- 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 +1 -1
- 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 +1 -1
- package/hooks/use-request/src/useRequest.d.ts +6 -2
- 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 +25 -25
- 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 +1 -1
- package/hooks/use-state-with-promise/index.d.ts +11 -1
- package/hooks/use-state-with-promise/index.js +21 -20
- 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 +12 -11
- 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.d.ts +3 -1
- package/hooks/use-update/index.js +5 -5
- 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.d.ts +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/index.d.ts +1 -1
- package/index.js +574 -537
- package/package.json +1 -1
- package/progress/index.js +43 -43
- package/resize-observer/Collection.d.ts +2 -2
- package/resize-observer/Collection.js +1 -1
- package/resize-observer/SingleObserver.js +1 -1
- package/resize-observer/index.js +2 -2
- package/resize-observer/observerUtil.js +1 -1
- package/space/index.js +1 -1
- package/style/animation.less +16 -4
- package/style.css +1 -1
- package/suspense-fallback-test/index.js +1 -1
- package/test.d.ts +0 -0
- package/test.js +5 -0
- package/timer/index.js +1 -1
- package/transition/Transition.d.ts +11 -0
- package/transition/Transition.js +92 -0
- package/transition/TransitionCSS.d.ts +11 -0
- package/transition/TransitionCSS.js +33 -0
- package/transition/TransitionGroup.d.ts +11 -0
- package/transition/TransitionGroup.js +62 -0
- package/transition/TransitionStyle.d.ts +11 -0
- package/transition/TransitionStyle.js +46 -0
- package/transition/constants.d.ts +43 -0
- package/transition/constants.js +46 -0
- package/transition/index.d.ts +12 -0
- package/transition/index.js +12 -0
- package/transition/interface.d.ts +192 -0
- package/transition/utils.d.ts +19 -0
- package/transition/utils.js +97 -0
- 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.js +1 -1
- package/utils/copy.js +1 -1
- package/utils/date.js +1 -1
- package/utils/dayjs.d.ts +1 -1
- package/utils/dayjs.js +19 -13
- package/utils/dom.js +15 -15
- 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 +6 -4
- package/utils/findRootElement.js +2 -2
- package/utils/findScrollParent.js +1 -1
- package/utils/getHighlightText.js +1 -1
- package/utils/getHotkeyHandler.js +1 -1
- package/utils/getScrollBarHeight.d.ts +3 -0
- package/utils/getScrollBarHeight.js +7 -0
- package/utils/getScrollBarSize.d.ts +3 -0
- package/utils/getScrollBarSize.js +10 -0
- package/utils/getScrollBarWidth.d.ts +3 -0
- package/utils/getScrollBarWidth.js +7 -0
- package/utils/getStringLength.js +1 -1
- package/utils/include.js +1 -1
- package/utils/index.d.ts +3 -0
- package/utils/index.js +277 -269
- package/utils/intersectionObserver.js +1 -1
- package/utils/is.d.ts +8 -7
- package/utils/is.js +23 -20
- package/utils/keyboardCode.js +1 -1
- package/utils/lodash.js +1 -1
- package/utils/math.js +1 -1
- package/utils/mergeProps.js +1 -1
- package/utils/mergedToString.js +1 -1
- package/utils/mutationObserver.js +1 -1
- package/utils/omit.d.ts +5 -1
- package/utils/omit.js +4 -8
- package/utils/pad.js +1 -1
- package/utils/pick.d.ts +4 -1
- package/utils/pick.js +5 -10
- package/utils/pinyin.js +1 -1
- package/utils/react19Adapter.js +1 -1
- package/utils/ref.js +2 -2
- package/utils/resizeObserver.js +21 -21
- 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 +11 -14
- package/motion/CSSMotion.d.ts +0 -77
- package/motion/CSSMotion.js +0 -76
- package/motion/CSSMotionList.d.ts +0 -34
- package/motion/CSSMotionList.js +0 -82
- package/motion/context.d.ts +0 -9
- package/motion/context.js +0 -14
- package/motion/hooks/useDomMotionEvents.d.ts +0 -3
- package/motion/hooks/useDomMotionEvents.js +0 -19
- package/motion/hooks/useNextFrame.d.ts +0 -7
- package/motion/hooks/useNextFrame.js +0 -22
- package/motion/hooks/useStatus.d.ts +0 -5
- package/motion/hooks/useStatus.js +0 -92
- package/motion/hooks/useStepQueue.d.ts +0 -8
- package/motion/hooks/useStepQueue.js +0 -39
- package/motion/index.d.ts +0 -9
- package/motion/index.js +0 -9
- package/motion/interface.d.ts +0 -22
- package/motion/interface.js +0 -6
- package/motion/util/diff.d.ts +0 -20
- package/motion/util/diff.js +0 -50
- package/motion/util/motion.d.ts +0 -10
- package/motion/util/motion.js +0 -37
- package/transition-group/CSSTransition.d.ts +0 -97
- package/transition-group/CSSTransition.js +0 -73
- package/transition-group/ChildMapping.d.ts +0 -27
- package/transition-group/ChildMapping.js +0 -61
- package/transition-group/PqbCSSTransition.d.ts +0 -4
- package/transition-group/PqbCSSTransition.js +0 -34
- package/transition-group/ReplaceTransition.d.ts +0 -23
- package/transition-group/ReplaceTransition.js +0 -38
- package/transition-group/SwitchTransition.d.ts +0 -88
- package/transition-group/SwitchTransition.js +0 -84
- package/transition-group/Transition.d.ts +0 -130
- package/transition-group/Transition.js +0 -139
- package/transition-group/TransitionGroup.d.ts +0 -31
- package/transition-group/TransitionGroup.js +0 -54
- package/transition-group/TransitionGroupContext.d.ts +0 -3
- package/transition-group/TransitionGroupContext.js +0 -7
- package/transition-group/index.d.ts +0 -9
- package/transition-group/index.js +0 -11
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* A transition component inspired by the excellent
|
|
4
|
-
* [ng-animate](https://docs.angularjs.org/api/ngAnimate) library, you should
|
|
5
|
-
* use it if you're using CSS transitions or animations. It's built upon the
|
|
6
|
-
* [`Transition`](https://reactcommunity.org/react-transition-group/transition)
|
|
7
|
-
* component, so it inherits all of its props.
|
|
8
|
-
*
|
|
9
|
-
* `CSSTransition` applies a pair of class names during the `appear`, `enter`,
|
|
10
|
-
* and `exit` states of the transition. The first class is applied and then a
|
|
11
|
-
* second `*-active` class in order to activate the CSS transition. After the
|
|
12
|
-
* transition, matching `*-done` class names are applied to persist the
|
|
13
|
-
* transition state.
|
|
14
|
-
*
|
|
15
|
-
* ```jsx
|
|
16
|
-
* function App() {
|
|
17
|
-
* const [inProp, setInProp] = useState(false);
|
|
18
|
-
* const refElement = useRef(null);
|
|
19
|
-
* return (
|
|
20
|
-
* <div>
|
|
21
|
-
* <CSSTransition refElement={refElement} in={inProp} timeout={200} classNames="my-element">
|
|
22
|
-
* <div ref={refElement}>
|
|
23
|
-
* {"I'll receive my-element-* classes"}
|
|
24
|
-
* </div>
|
|
25
|
-
* </CSSTransition>
|
|
26
|
-
* <button type="button" onClick={() => setInProp(true)}>
|
|
27
|
-
* Click to Enter
|
|
28
|
-
* </button>
|
|
29
|
-
* </div>
|
|
30
|
-
* );
|
|
31
|
-
* }
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
* When the `in` prop is set to `true`, the child component will first receive
|
|
35
|
-
* the class `example-enter`, then the `example-enter-active` will be added in
|
|
36
|
-
* the next tick. `CSSTransition` [forces a
|
|
37
|
-
* reflow](https://github.com/reactjs/react-transition-group/blob/5007303e729a74be66a21c3e2205e4916821524b/src/CSSTransition.js#L208-L215)
|
|
38
|
-
* between before adding the `example-enter-active`. This is an important trick
|
|
39
|
-
* because it allows us to transition between `example-enter` and
|
|
40
|
-
* `example-enter-active` even though they were added immediately one after
|
|
41
|
-
* another. Most notably, this is what makes it possible for us to animate
|
|
42
|
-
* _appearance_.
|
|
43
|
-
*
|
|
44
|
-
* ```css
|
|
45
|
-
* .my-element-enter {
|
|
46
|
-
* opacity: 0;
|
|
47
|
-
* }
|
|
48
|
-
* .my-element-enter-active {
|
|
49
|
-
* opacity: 1;
|
|
50
|
-
* transition: opacity 200ms;
|
|
51
|
-
* }
|
|
52
|
-
* .my-element-exit {
|
|
53
|
-
* opacity: 1;
|
|
54
|
-
* }
|
|
55
|
-
* .my-element-exit-active {
|
|
56
|
-
* opacity: 0;
|
|
57
|
-
* transition: opacity 200ms;
|
|
58
|
-
* }
|
|
59
|
-
* ```
|
|
60
|
-
*
|
|
61
|
-
* `*-active` classes represent which styles you want to animate **to**, so it's
|
|
62
|
-
* important to add `transition` declaration only to them, otherwise transitions
|
|
63
|
-
* might not behave as intended! This might not be obvious when the transitions
|
|
64
|
-
* are symmetrical, i.e. when `*-enter-active` is the same as `*-exit`, like in
|
|
65
|
-
* the example above (minus `transition`), but it becomes apparent in more
|
|
66
|
-
* complex transitions.
|
|
67
|
-
*
|
|
68
|
-
* **Note**: If you're using the
|
|
69
|
-
* [`appear`](http://reactcommunity.org/react-transition-group/transition#Transition-prop-appear)
|
|
70
|
-
* prop, make sure to define styles for `.appear-*` classes as well.
|
|
71
|
-
*/
|
|
72
|
-
declare class CSSTransition extends React.Component {
|
|
73
|
-
static defaultProps: {
|
|
74
|
-
classNames: string;
|
|
75
|
-
};
|
|
76
|
-
appliedClasses: {
|
|
77
|
-
appear: {};
|
|
78
|
-
enter: {};
|
|
79
|
-
exit: {};
|
|
80
|
-
};
|
|
81
|
-
onEnter: (maybeElement: any, maybeAppearing: any) => void;
|
|
82
|
-
onEntering: (maybeElement: any, maybeAppearing: any) => void;
|
|
83
|
-
onEntered: (maybeElement: any, maybeAppearing: any) => void;
|
|
84
|
-
onExit: (maybeElement: any) => void;
|
|
85
|
-
onExiting: (maybeElement: any) => void;
|
|
86
|
-
onExited: (maybeElement: any) => void;
|
|
87
|
-
resolveArguments: (maybeElement: any, maybeAppearing: any) => any[];
|
|
88
|
-
getClassNames: (type: any) => {
|
|
89
|
-
baseClassName: any;
|
|
90
|
-
activeClassName: any;
|
|
91
|
-
doneClassName: any;
|
|
92
|
-
};
|
|
93
|
-
addClass(element: any, type: any, phase: any): void;
|
|
94
|
-
removeClasses(element: any, type: any): void;
|
|
95
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
96
|
-
}
|
|
97
|
-
export default CSSTransition;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/* 潘启宝 2026-03-24 15:26:24 星期二 */
|
|
2
|
-
import { isFunction as e, isString as t } from "../utils/is.js";
|
|
3
|
-
import { forceReflow as n } from "../utils/dom.js";
|
|
4
|
-
import r from "../utils/findRootElement.js";
|
|
5
|
-
import i from "./Transition.js";
|
|
6
|
-
import a from "react";
|
|
7
|
-
import { jsx as o } from "react/jsx-runtime";
|
|
8
|
-
//#region components/common/transition-group/CSSTransition.tsx
|
|
9
|
-
function s(e, n, r = "add") {
|
|
10
|
-
e instanceof Element && n && t(n) && n.split(" ").filter(Boolean).forEach((t, n, i) => {
|
|
11
|
-
e.classList[r](t);
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
var c = class extends a.Component {
|
|
15
|
-
constructor(...n) {
|
|
16
|
-
super(...n), this.appliedClasses = {
|
|
17
|
-
appear: {},
|
|
18
|
-
enter: {},
|
|
19
|
-
exit: {}
|
|
20
|
-
}, this.onEnter = (t, n) => {
|
|
21
|
-
let [r, i] = this.resolveArguments(t, n);
|
|
22
|
-
this.removeClasses(r, "exit"), this.addClass(r, i ? "appear" : "enter", "base"), e(this.props.onEnter) && this.props.onEnter(r, n);
|
|
23
|
-
}, this.onEntering = (t, n) => {
|
|
24
|
-
let [r, i] = this.resolveArguments(t, n), a = i ? "appear" : "enter";
|
|
25
|
-
this.addClass(r, a, "active"), e(this.props.onEntering) && this.props.onEntering(r, n);
|
|
26
|
-
}, this.onEntered = (t, n) => {
|
|
27
|
-
let [r, i] = this.resolveArguments(t, n), a = i ? "appear" : "enter";
|
|
28
|
-
this.removeClasses(r, a), this.addClass(r, a, "done"), e(this.props.onEntered) && this.props.onEntered(r, n);
|
|
29
|
-
}, this.onExit = (t) => {
|
|
30
|
-
let [n] = this.resolveArguments(t);
|
|
31
|
-
this.removeClasses(n, "appear"), this.removeClasses(n, "enter"), this.addClass(n, "exit", "base"), e(this.props.onExit) && this.props.onExit(n);
|
|
32
|
-
}, this.onExiting = (t) => {
|
|
33
|
-
let [n] = this.resolveArguments(t);
|
|
34
|
-
this.addClass(n, "exit", "active"), e(this.props.onExiting) && this.props.onExiting(n);
|
|
35
|
-
}, this.onExited = (t) => {
|
|
36
|
-
let [n] = this.resolveArguments(t);
|
|
37
|
-
this.removeClasses(n, "exit"), this.addClass(n, "exit", "done"), e(this.props.onExited) && this.props.onExited(n);
|
|
38
|
-
}, this.resolveArguments = (e, t) => [r(this.props.refElement) || e, t], this.getClassNames = (e) => {
|
|
39
|
-
let { classNames: n } = this.props, r = t(n), i = r && n ? `${n}-` : "", a = r ? `${i}${e}` : n[e];
|
|
40
|
-
return {
|
|
41
|
-
baseClassName: a,
|
|
42
|
-
activeClassName: r ? `${a}-active` : n[`${e}Active`],
|
|
43
|
-
doneClassName: r ? `${a}-done` : n[`${e}Done`]
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
static {
|
|
48
|
-
this.defaultProps = { classNames: "" };
|
|
49
|
-
}
|
|
50
|
-
addClass(e, t, r) {
|
|
51
|
-
let i = this.getClassNames(t)[`${r}ClassName`], { doneClassName: a } = this.getClassNames("enter");
|
|
52
|
-
t === "appear" && r === "done" && a && (i += ` ${a}`), r === "active" && e && n(e), i && (this.appliedClasses[t][r] = i, s(e, i, "add"));
|
|
53
|
-
}
|
|
54
|
-
removeClasses(e, t) {
|
|
55
|
-
let { base: n, active: r, done: i } = this.appliedClasses[t];
|
|
56
|
-
this.appliedClasses[t] = {}, n && s(e, n, "remove"), r && s(e, r, "remove"), i && s(e, i, "remove");
|
|
57
|
-
}
|
|
58
|
-
render() {
|
|
59
|
-
let { classNames: e, ...t } = this.props;
|
|
60
|
-
return /* @__PURE__ */ o(i, {
|
|
61
|
-
...t,
|
|
62
|
-
onEnter: this.onEnter,
|
|
63
|
-
onEntered: this.onEntered,
|
|
64
|
-
onEntering: this.onEntering,
|
|
65
|
-
onExit: this.onExit,
|
|
66
|
-
onExiting: this.onExiting,
|
|
67
|
-
onExited: this.onExited
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
//#endregion
|
|
72
|
-
export { c as default };
|
|
73
|
-
/* 独立思考,明辨是非 */
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Given `this.props.children`, return an object mapping key to child.
|
|
3
|
-
*
|
|
4
|
-
* @param {*} children `this.props.children`
|
|
5
|
-
* @return {object} Mapping of key to child
|
|
6
|
-
*/
|
|
7
|
-
export declare function getChildMapping(children: any, mapFn: any): any;
|
|
8
|
-
/**
|
|
9
|
-
* When you're adding or removing children some may be added or removed in the
|
|
10
|
-
* same render pass. We want to show *both* since we want to simultaneously
|
|
11
|
-
* animate elements in and out. This function takes a previous set of keys
|
|
12
|
-
* and a new set of keys and merges them with its best guess of the correct
|
|
13
|
-
* ordering. In the future we may expose some of the utilities in
|
|
14
|
-
* ReactMultiChild to make this easy, but for now React itself does not
|
|
15
|
-
* directly have this concept of the union of prevChildren and nextChildren
|
|
16
|
-
* so we implement it here.
|
|
17
|
-
*
|
|
18
|
-
* @param {object} prev prev children as returned from
|
|
19
|
-
* `ReactTransitionChildMapping.getChildMapping()`.
|
|
20
|
-
* @param {object} next next children as returned from
|
|
21
|
-
* `ReactTransitionChildMapping.getChildMapping()`.
|
|
22
|
-
* @return {object} a key set that contains all keys in `prev` and all keys
|
|
23
|
-
* in `next` in a reasonable order.
|
|
24
|
-
*/
|
|
25
|
-
export declare function mergeChildMappings(prev: any, next: any): {};
|
|
26
|
-
export declare function getInitialChildMapping(props: any, onExited: any): any;
|
|
27
|
-
export declare function getNextChildMapping(nextProps: any, prevChildMapping: any, onExited: any): {};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/* 潘启宝 2026-03-24 15:26:24 星期二 */
|
|
2
|
-
import { Children as e, cloneElement as t, isValidElement as n } from "react";
|
|
3
|
-
//#region components/common/transition-group/ChildMapping.ts
|
|
4
|
-
function r(t, r) {
|
|
5
|
-
let i = (e) => r && n(e) ? r(e) : e, a = Object.create(null);
|
|
6
|
-
return t && e.map(t, (e) => e).forEach((e) => {
|
|
7
|
-
a[e.key] = i(e);
|
|
8
|
-
}), a;
|
|
9
|
-
}
|
|
10
|
-
function i(e, t) {
|
|
11
|
-
e ||= {}, t ||= {};
|
|
12
|
-
function n(n) {
|
|
13
|
-
return n in t ? t[n] : e[n];
|
|
14
|
-
}
|
|
15
|
-
let r = Object.create(null), i = [];
|
|
16
|
-
for (let n in e) n in t ? i.length && (r[n] = i, i = []) : i.push(n);
|
|
17
|
-
let a, o = {};
|
|
18
|
-
for (let e in t) {
|
|
19
|
-
if (r[e]) for (a = 0; a < r[e].length; a++) {
|
|
20
|
-
let t = r[e][a];
|
|
21
|
-
o[r[e][a]] = n(t);
|
|
22
|
-
}
|
|
23
|
-
o[e] = n(e);
|
|
24
|
-
}
|
|
25
|
-
for (a = 0; a < i.length; a++) o[i[a]] = n(i[a]);
|
|
26
|
-
return o;
|
|
27
|
-
}
|
|
28
|
-
function a(e, t, n) {
|
|
29
|
-
return n[t] == null ? e.props[t] : n[t];
|
|
30
|
-
}
|
|
31
|
-
function o(e, n) {
|
|
32
|
-
return r(e.children, (r) => t(r, {
|
|
33
|
-
onExited: n.bind(null, r),
|
|
34
|
-
in: !0,
|
|
35
|
-
appear: a(r, "appear", e),
|
|
36
|
-
enter: a(r, "enter", e),
|
|
37
|
-
exit: a(r, "exit", e)
|
|
38
|
-
}));
|
|
39
|
-
}
|
|
40
|
-
function s(e, o, s) {
|
|
41
|
-
let c = r(e.children), l = i(o, c);
|
|
42
|
-
return Object.keys(l).forEach((r) => {
|
|
43
|
-
let i = l[r];
|
|
44
|
-
if (!n(i)) return;
|
|
45
|
-
let u = r in o, d = r in c, f = o[r], p = n(f) && !f.props.in;
|
|
46
|
-
d && (!u || p) ? l[r] = t(i, {
|
|
47
|
-
onExited: s.bind(null, i),
|
|
48
|
-
in: !0,
|
|
49
|
-
exit: a(i, "exit", e),
|
|
50
|
-
enter: a(i, "enter", e)
|
|
51
|
-
}) : !d && u && !p ? l[r] = t(i, { in: !1 }) : d && u && n(f) && (l[r] = t(i, {
|
|
52
|
-
onExited: s.bind(null, i),
|
|
53
|
-
in: f.props.in,
|
|
54
|
-
exit: a(i, "exit", e),
|
|
55
|
-
enter: a(i, "enter", e)
|
|
56
|
-
}));
|
|
57
|
-
}), l;
|
|
58
|
-
}
|
|
59
|
-
//#endregion
|
|
60
|
-
export { r as getChildMapping, o as getInitialChildMapping, s as getNextChildMapping, i as mergeChildMappings };
|
|
61
|
-
/* 独立思考,明辨是非 */
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/* 潘启宝 2026-03-24 15:26:24 星期二 */
|
|
2
|
-
import { isUndefined as e } from "../utils/is.js";
|
|
3
|
-
import { supportRef as t } from "../utils/ref.js";
|
|
4
|
-
import n from "../utils/findRootElement.js";
|
|
5
|
-
import { callbackOriginRef as r } from "../utils/callbackOriginRef.js";
|
|
6
|
-
import i from "./CSSTransition.js";
|
|
7
|
-
import { cloneElement as a, isValidElement as o, useMemo as s, useRef as c } from "react";
|
|
8
|
-
import { jsx as l } from "react/jsx-runtime";
|
|
9
|
-
//#region components/common/transition-group/PqbCSSTransition.tsx
|
|
10
|
-
function u(u) {
|
|
11
|
-
let { children: d, ...f } = u, p = c(void 0), m = c(void 0), h = s(() => e(u.refElement) && t(d) && o(d) ? (m.current = !0, a(d, { ref(e) {
|
|
12
|
-
p.current = n(e), r(d, e);
|
|
13
|
-
} })) : (m.current = !1, d), [d, u.refElement]);
|
|
14
|
-
return m.current && [
|
|
15
|
-
"onEnter",
|
|
16
|
-
"onEntering",
|
|
17
|
-
"onEntered",
|
|
18
|
-
"onExit",
|
|
19
|
-
"onExiting",
|
|
20
|
-
"onExited"
|
|
21
|
-
].forEach((e) => {
|
|
22
|
-
let t = u[e];
|
|
23
|
-
t && (f[e] = (e, ...n) => {
|
|
24
|
-
t(p.current || e, ...n);
|
|
25
|
-
});
|
|
26
|
-
}), /* @__PURE__ */ l(i, {
|
|
27
|
-
...f,
|
|
28
|
-
refElement: m.current ? p : void 0,
|
|
29
|
-
children: h
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
//#endregion
|
|
33
|
-
export { u as PqbCSSTransition, u as default };
|
|
34
|
-
/* 独立思考,明辨是非 */
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* The `<ReplaceTransition>` component is a specialized `Transition` component
|
|
4
|
-
* that animates between two children.
|
|
5
|
-
*
|
|
6
|
-
* ```jsx
|
|
7
|
-
* <ReplaceTransition in>
|
|
8
|
-
* <Fade><div>I appear first</div></Fade>
|
|
9
|
-
* <Fade><div>I replace the above</div></Fade>
|
|
10
|
-
* </ReplaceTransition>
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
declare class ReplaceTransition extends React.Component {
|
|
14
|
-
handleEnter: (...args: any[]) => void;
|
|
15
|
-
handleEntering: (...args: any[]) => void;
|
|
16
|
-
handleEntered: (...args: any[]) => void;
|
|
17
|
-
handleExit: (...args: any[]) => void;
|
|
18
|
-
handleExiting: (...args: any[]) => void;
|
|
19
|
-
handleExited: (...args: any[]) => void;
|
|
20
|
-
handleLifecycle(handler: any, idx: any, originalArgs: any): void;
|
|
21
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
22
|
-
}
|
|
23
|
-
export default ReplaceTransition;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/* 潘启宝 2026-03-24 15:26:24 星期二 */
|
|
2
|
-
import e from "../utils/findRootElement.js";
|
|
3
|
-
import t from "./TransitionGroup.js";
|
|
4
|
-
import n from "react";
|
|
5
|
-
import { jsx as r } from "react/jsx-runtime";
|
|
6
|
-
//#region components/common/transition-group/ReplaceTransition.tsx
|
|
7
|
-
var i = class extends n.Component {
|
|
8
|
-
constructor(...e) {
|
|
9
|
-
super(...e), this.handleEnter = (...e) => this.handleLifecycle("onEnter", 0, e), this.handleEntering = (...e) => this.handleLifecycle("onEntering", 0, e), this.handleEntered = (...e) => this.handleLifecycle("onEntered", 0, e), this.handleExit = (...e) => this.handleLifecycle("onExit", 1, e), this.handleExiting = (...e) => this.handleLifecycle("onExiting", 1, e), this.handleExited = (...e) => this.handleLifecycle("onExited", 1, e);
|
|
10
|
-
}
|
|
11
|
-
handleLifecycle(t, r, i) {
|
|
12
|
-
let { children: a } = this.props, o = n.Children.toArray(a)[r];
|
|
13
|
-
if (o.props[t] && o.props[t](...i), this.props[t]) {
|
|
14
|
-
let n = e(o.props.refElement) || e(this);
|
|
15
|
-
this.props[t](n);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
render() {
|
|
19
|
-
let { children: e, in: i, ...a } = this.props, [o, s] = n.Children.toArray(e);
|
|
20
|
-
return delete a.onEnter, delete a.onEntering, delete a.onEntered, delete a.onExit, delete a.onExiting, delete a.onExited, /* @__PURE__ */ r(t, {
|
|
21
|
-
...a,
|
|
22
|
-
children: i ? n.cloneElement(o, {
|
|
23
|
-
key: "first",
|
|
24
|
-
onEnter: this.handleEnter,
|
|
25
|
-
onEntering: this.handleEntering,
|
|
26
|
-
onEntered: this.handleEntered
|
|
27
|
-
}) : n.cloneElement(s, {
|
|
28
|
-
key: "second",
|
|
29
|
-
onEnter: this.handleExit,
|
|
30
|
-
onEntering: this.handleExiting,
|
|
31
|
-
onEntered: this.handleExited
|
|
32
|
-
})
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
//#endregion
|
|
37
|
-
export { i as default };
|
|
38
|
-
/* 独立思考,明辨是非 */
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Enum of modes for SwitchTransition component
|
|
4
|
-
* @enum { string }
|
|
5
|
-
*/
|
|
6
|
-
export declare const modes: {
|
|
7
|
-
out: string;
|
|
8
|
-
in: string;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* A transition component inspired by the [vue transition modes](https://vuejs.org/v2/guide/transitions.html#Transition-Modes).
|
|
12
|
-
* You can use it when you want to control the render between state transitions.
|
|
13
|
-
* Based on the selected mode and the child's key which is the `Transition` or `CSSTransition` component, the `SwitchTransition` makes a consistent transition between them.
|
|
14
|
-
*
|
|
15
|
-
* If the `out-in` mode is selected, the `SwitchTransition` waits until the old child leaves and then inserts a new child.
|
|
16
|
-
* If the `in-out` mode is selected, the `SwitchTransition` inserts a new child first, waits for the new child to enter and then removes the old child.
|
|
17
|
-
*
|
|
18
|
-
* **Note**: If you want the animation to happen simultaneously
|
|
19
|
-
* (that is, to have the old child removed and a new child inserted **at the same time**),
|
|
20
|
-
* you should use
|
|
21
|
-
* [`TransitionGroup`](https://reactcommunity.org/react-transition-group/transition-group)
|
|
22
|
-
* instead.
|
|
23
|
-
*
|
|
24
|
-
* ```jsx
|
|
25
|
-
* function App() {
|
|
26
|
-
* const [state, setState] = useState(false);
|
|
27
|
-
* const refHello = useRef(null);
|
|
28
|
-
* const refGoodbye = useRef(null);
|
|
29
|
-
* const refElement = state ? refGoodbye : refHello;
|
|
30
|
-
* return (
|
|
31
|
-
* <SwitchTransition>
|
|
32
|
-
* <CSSTransition
|
|
33
|
-
* key={state ? "Goodbye, world!" : "Hello, world!"}
|
|
34
|
-
* refElement={refElement}
|
|
35
|
-
* addEndListener={(element, done) => element.addEventListener("transitionend", done, false)}
|
|
36
|
-
* classNames='fade'
|
|
37
|
-
* >
|
|
38
|
-
* <button ref={refElement} onClick={() => setState(state => !state)}>
|
|
39
|
-
* {state ? "Goodbye, world!" : "Hello, world!"}
|
|
40
|
-
* </button>
|
|
41
|
-
* </CSSTransition>
|
|
42
|
-
* </SwitchTransition>
|
|
43
|
-
* );
|
|
44
|
-
* }
|
|
45
|
-
* ```
|
|
46
|
-
*
|
|
47
|
-
* ```css
|
|
48
|
-
* .fade-enter{
|
|
49
|
-
* opacity: 0;
|
|
50
|
-
* }
|
|
51
|
-
* .fade-exit{
|
|
52
|
-
* opacity: 1;
|
|
53
|
-
* }
|
|
54
|
-
* .fade-enter-active{
|
|
55
|
-
* opacity: 1;
|
|
56
|
-
* }
|
|
57
|
-
* .fade-exit-active{
|
|
58
|
-
* opacity: 0;
|
|
59
|
-
* }
|
|
60
|
-
* .fade-enter-active,
|
|
61
|
-
* .fade-exit-active{
|
|
62
|
-
* transition: opacity 500ms;
|
|
63
|
-
* }
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
declare class SwitchTransition extends React.Component {
|
|
67
|
-
state: {
|
|
68
|
-
status: string;
|
|
69
|
-
current: null;
|
|
70
|
-
};
|
|
71
|
-
appeared: boolean;
|
|
72
|
-
componentDidMount(): void;
|
|
73
|
-
static getDerivedStateFromProps(props: any, state: any): {
|
|
74
|
-
current: null;
|
|
75
|
-
status?: undefined;
|
|
76
|
-
} | {
|
|
77
|
-
status: string;
|
|
78
|
-
current?: undefined;
|
|
79
|
-
} | {
|
|
80
|
-
current: React.FunctionComponentElement<{
|
|
81
|
-
in: boolean;
|
|
82
|
-
}>;
|
|
83
|
-
status?: undefined;
|
|
84
|
-
};
|
|
85
|
-
changeState: (status: any, current?: null) => void;
|
|
86
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
87
|
-
}
|
|
88
|
-
export default SwitchTransition;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/* 潘启宝 2026-03-24 15:26:24 星期二 */
|
|
2
|
-
import e from "./TransitionGroupContext.js";
|
|
3
|
-
import { ENTERED as t, ENTERING as n, EXITING as r } from "./Transition.js";
|
|
4
|
-
import i from "react";
|
|
5
|
-
import { jsx as a } from "react/jsx-runtime";
|
|
6
|
-
//#region components/common/transition-group/SwitchTransition.tsx
|
|
7
|
-
function o(e, t) {
|
|
8
|
-
return !(e === t || i.isValidElement(e) && i.isValidElement(t) && e.key != null && e.key === t.key);
|
|
9
|
-
}
|
|
10
|
-
var s = {
|
|
11
|
-
out: "out-in",
|
|
12
|
-
in: "in-out"
|
|
13
|
-
}, c = (e, t, n) => (...r) => {
|
|
14
|
-
e.props[t] && e.props[t](...r), n();
|
|
15
|
-
}, l = {
|
|
16
|
-
[s.out]: ({ current: e, changeState: t }) => i.cloneElement(e, {
|
|
17
|
-
in: !1,
|
|
18
|
-
onExited: c(e, "onExited", () => {
|
|
19
|
-
t(n, null);
|
|
20
|
-
})
|
|
21
|
-
}),
|
|
22
|
-
[s.in]: ({ current: e, changeState: t, children: r }) => [e, i.cloneElement(r, {
|
|
23
|
-
in: !0,
|
|
24
|
-
onEntered: c(r, "onEntered", () => {
|
|
25
|
-
t(n);
|
|
26
|
-
})
|
|
27
|
-
})]
|
|
28
|
-
}, u = {
|
|
29
|
-
[s.out]: ({ children: e, changeState: n }) => i.cloneElement(e, {
|
|
30
|
-
in: !0,
|
|
31
|
-
onEntered: c(e, "onEntered", () => {
|
|
32
|
-
n(t, i.cloneElement(e, { in: !0 }));
|
|
33
|
-
})
|
|
34
|
-
}),
|
|
35
|
-
[s.in]: ({ current: e, children: n, changeState: r }) => [i.cloneElement(e, {
|
|
36
|
-
in: !1,
|
|
37
|
-
onExited: c(e, "onExited", () => {
|
|
38
|
-
r(t, i.cloneElement(n, { in: !0 }));
|
|
39
|
-
})
|
|
40
|
-
}), i.cloneElement(n, { in: !0 })]
|
|
41
|
-
}, d = class extends i.Component {
|
|
42
|
-
constructor(...e) {
|
|
43
|
-
super(...e), this.state = {
|
|
44
|
-
status: t,
|
|
45
|
-
current: null
|
|
46
|
-
}, this.appeared = !1, this.changeState = (e, t = this.state.current) => {
|
|
47
|
-
this.setState({
|
|
48
|
-
status: e,
|
|
49
|
-
current: t
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
componentDidMount() {
|
|
54
|
-
this.appeared = !0;
|
|
55
|
-
}
|
|
56
|
-
static getDerivedStateFromProps(e, t) {
|
|
57
|
-
return e.children == null ? { current: null } : t.status === "entering" && e.mode === s.in ? { status: n } : t.current && o(t.current, e.children) ? { status: r } : { current: i.cloneElement(e.children, { in: !0 }) };
|
|
58
|
-
}
|
|
59
|
-
render() {
|
|
60
|
-
let { props: { children: i, mode: o }, state: { status: s, current: c } } = this, d = {
|
|
61
|
-
children: i,
|
|
62
|
-
current: c,
|
|
63
|
-
changeState: this.changeState,
|
|
64
|
-
status: s
|
|
65
|
-
}, f;
|
|
66
|
-
switch (s) {
|
|
67
|
-
case n:
|
|
68
|
-
f = u[o](d);
|
|
69
|
-
break;
|
|
70
|
-
case r:
|
|
71
|
-
f = l[o](d);
|
|
72
|
-
break;
|
|
73
|
-
case t: f = c;
|
|
74
|
-
}
|
|
75
|
-
return /* @__PURE__ */ a(e.Provider, {
|
|
76
|
-
value: { isMounting: !this.appeared },
|
|
77
|
-
children: f
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
d.defaultProps = { mode: s.out };
|
|
82
|
-
//#endregion
|
|
83
|
-
export { d as default, s as modes };
|
|
84
|
-
/* 独立思考,明辨是非 */
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export declare const UNMOUNTED = "unmounted";
|
|
3
|
-
export declare const EXITED = "exited";
|
|
4
|
-
export declare const ENTERING = "entering";
|
|
5
|
-
export declare const ENTERED = "entered";
|
|
6
|
-
export declare const EXITING = "exiting";
|
|
7
|
-
/**
|
|
8
|
-
* The Transition component lets you describe a transition from one component
|
|
9
|
-
* state to another _over time_ with a simple declarative API. Most commonly
|
|
10
|
-
* it's used to animate the mounting and unmounting of a component, but can also
|
|
11
|
-
* be used to describe in-place transition states as well.
|
|
12
|
-
*
|
|
13
|
-
* ---
|
|
14
|
-
*
|
|
15
|
-
* **Note**: `Transition` is a platform-agnostic base component. If you're using
|
|
16
|
-
* transitions in CSS, you'll probably want to use
|
|
17
|
-
* [`CSSTransition`](https://reactcommunity.org/react-transition-group/css-transition)
|
|
18
|
-
* instead. It inherits all the features of `Transition`, but contains
|
|
19
|
-
* additional features necessary to play nice with CSS transitions (hence the
|
|
20
|
-
* name of the component).
|
|
21
|
-
*
|
|
22
|
-
* ---
|
|
23
|
-
*
|
|
24
|
-
* By default the `Transition` component does not alter the behavior of the
|
|
25
|
-
* component it renders, it only tracks "enter" and "exit" states for the
|
|
26
|
-
* components. It's up to you to give meaning and effect to those states. For
|
|
27
|
-
* example we can add styles to a component when it enters or exits:
|
|
28
|
-
*
|
|
29
|
-
* ```jsx
|
|
30
|
-
* import { Transition } from 'react-transition-group';
|
|
31
|
-
* import { useRef } from 'react';
|
|
32
|
-
*
|
|
33
|
-
* const duration = 300;
|
|
34
|
-
*
|
|
35
|
-
* const defaultStyle = {
|
|
36
|
-
* transition: `opacity ${duration}ms ease-in-out`,
|
|
37
|
-
* opacity: 0,
|
|
38
|
-
* }
|
|
39
|
-
*
|
|
40
|
-
* const transitionStyles = {
|
|
41
|
-
* entering: { opacity: 1 },
|
|
42
|
-
* entered: { opacity: 1 },
|
|
43
|
-
* exiting: { opacity: 0 },
|
|
44
|
-
* exited: { opacity: 0 },
|
|
45
|
-
* };
|
|
46
|
-
*
|
|
47
|
-
* function Fade({ in: inProp }) {
|
|
48
|
-
* const refElement = useRef(null);
|
|
49
|
-
* return (
|
|
50
|
-
* <Transition refElement={refElement} in={inProp} timeout={duration}>
|
|
51
|
-
* {state => (
|
|
52
|
-
* <div ref={refElement} style={{
|
|
53
|
-
* ...defaultStyle,
|
|
54
|
-
* ...transitionStyles[state]
|
|
55
|
-
* }}>
|
|
56
|
-
* I'm a fade Transition!
|
|
57
|
-
* </div>
|
|
58
|
-
* )}
|
|
59
|
-
* </Transition>
|
|
60
|
-
* );
|
|
61
|
-
* }
|
|
62
|
-
* ```
|
|
63
|
-
*
|
|
64
|
-
* There are 4 main states a Transition can be in:
|
|
65
|
-
* - `'entering'`
|
|
66
|
-
* - `'entered'`
|
|
67
|
-
* - `'exiting'`
|
|
68
|
-
* - `'exited'`
|
|
69
|
-
*
|
|
70
|
-
* Transition state is toggled via the `in` prop. When `true` the component
|
|
71
|
-
* begins the "Enter" stage. During this stage, the component will shift from
|
|
72
|
-
* its current transition state, to `'entering'` for the duration of the
|
|
73
|
-
* transition and then to the `'entered'` stage once it's complete. Let's take
|
|
74
|
-
* the following example (we'll use the
|
|
75
|
-
* [useState](https://reactjs.org/docs/hooks-reference.html#usestate) hook):
|
|
76
|
-
*
|
|
77
|
-
* ```jsx
|
|
78
|
-
* import { Transition } from 'react-transition-group';
|
|
79
|
-
* import { useState, useRef } from 'react';
|
|
80
|
-
*
|
|
81
|
-
* function App() {
|
|
82
|
-
* const [inProp, setInProp] = useState(false);
|
|
83
|
-
* const refElement = useRef(null);
|
|
84
|
-
* return (
|
|
85
|
-
* <div>
|
|
86
|
-
* <Transition refElement={refElement} in={inProp} timeout={500}>
|
|
87
|
-
* {state => ()}
|
|
88
|
-
* </Transition>
|
|
89
|
-
* <button onClick={() => setInProp(true)}>
|
|
90
|
-
* Click to Enter
|
|
91
|
-
* </button>
|
|
92
|
-
* </div>
|
|
93
|
-
* );
|
|
94
|
-
* }
|
|
95
|
-
* ```
|
|
96
|
-
*
|
|
97
|
-
* When the button is clicked the component will shift to the `'entering'` state
|
|
98
|
-
* and stay there for 500ms (the value of `timeout`) before it finally switches
|
|
99
|
-
* to `'entered'`.
|
|
100
|
-
*
|
|
101
|
-
* When `in` is `false` the same thing happens except the state moves from
|
|
102
|
-
* `'exiting'` to `'exited'`.
|
|
103
|
-
*/
|
|
104
|
-
declare class Transition extends React.Component {
|
|
105
|
-
#private;
|
|
106
|
-
static contextType: React.Context<null>;
|
|
107
|
-
constructor(props: any, context: any);
|
|
108
|
-
static getDerivedStateFromProps({ in: nextIn }: {
|
|
109
|
-
in: any;
|
|
110
|
-
}, prevState: any): {
|
|
111
|
-
status: string;
|
|
112
|
-
} | null;
|
|
113
|
-
componentDidMount(): void;
|
|
114
|
-
componentDidUpdate(prevProps: any): void;
|
|
115
|
-
componentWillUnmount(): void;
|
|
116
|
-
getTimeouts(): {
|
|
117
|
-
exit: any;
|
|
118
|
-
enter: any;
|
|
119
|
-
appear: any;
|
|
120
|
-
};
|
|
121
|
-
updateStatus(mounting: boolean | undefined, nextStatus: any): void;
|
|
122
|
-
performEnter(mounting: any): void;
|
|
123
|
-
performExit(): void;
|
|
124
|
-
cancelNextCallback(): void;
|
|
125
|
-
safeSetState(nextState: any, callback: any): void;
|
|
126
|
-
setNextCallback(callback: any): any;
|
|
127
|
-
onTransitionEnd(timeout: any, handler: any): void;
|
|
128
|
-
render(): import("react/jsx-runtime").JSX.Element | null;
|
|
129
|
-
}
|
|
130
|
-
export default Transition;
|