@mks2508/mks-ui 0.2.1 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react-ui/hooks/Animation/UseAutoHeight.js +7 -7
- package/dist/react-ui/hooks/DOM/UseIsInView.js +3 -3
- package/dist/react-ui/hooks/Formatting/UseListFormat.d.ts +49 -0
- package/dist/react-ui/hooks/Formatting/UseListFormat.d.ts.map +1 -0
- package/dist/react-ui/hooks/Formatting/UseListFormat.js +105 -0
- package/dist/react-ui/hooks/State/UseControlledState.js +4 -4
- package/dist/react-ui/hooks/State/UseDataState.js +5 -5
- package/dist/react-ui/hooks/index.d.ts +2 -0
- package/dist/react-ui/hooks/index.d.ts.map +1 -1
- package/dist/react-ui/hooks/index.js +1 -0
- package/dist/react-ui/index.js +22 -2
- package/dist/react-ui/lib/get-strict-context.js +3 -3
- package/dist/react-ui/primitives/CountingNumber/index.js +3 -3
- package/dist/react-ui/primitives/Highlight/index.js +26 -26
- package/dist/react-ui/primitives/Slot/index.js +3 -3
- package/dist/react-ui/primitives/index.d.ts +1 -0
- package/dist/react-ui/primitives/index.d.ts.map +1 -1
- package/dist/react-ui/primitives/index.js +18 -0
- package/dist/react-ui/primitives/waapi/Morph/Morph.types.d.ts +76 -0
- package/dist/react-ui/primitives/waapi/Morph/Morph.types.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Morph/MorphContext.d.ts +11 -0
- package/dist/react-ui/primitives/waapi/Morph/MorphContext.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Morph/MorphContext.js +19 -0
- package/dist/react-ui/primitives/waapi/Morph/index.d.ts +23 -0
- package/dist/react-ui/primitives/waapi/Morph/index.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Morph/index.js +45 -0
- package/dist/react-ui/primitives/waapi/Morph/techniques/index.d.ts +12 -0
- package/dist/react-ui/primitives/waapi/Morph/techniques/index.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Morph/techniques/useCSSGridMorph.d.ts +38 -0
- package/dist/react-ui/primitives/waapi/Morph/techniques/useCSSGridMorph.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Morph/techniques/useCSSGridMorph.js +78 -0
- package/dist/react-ui/primitives/waapi/Morph/techniques/useFLIPClipPath.d.ts +23 -0
- package/dist/react-ui/primitives/waapi/Morph/techniques/useFLIPClipPath.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Morph/techniques/useFLIPClipPath.js +140 -0
- package/dist/react-ui/primitives/waapi/Morph/techniques/useViewTransitions.d.ts +28 -0
- package/dist/react-ui/primitives/waapi/Morph/techniques/useViewTransitions.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Morph/techniques/useViewTransitions.js +77 -0
- package/dist/react-ui/primitives/waapi/Morph/useMorph.d.ts +27 -0
- package/dist/react-ui/primitives/waapi/Morph/useMorph.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Morph/useMorph.js +86 -0
- package/dist/react-ui/primitives/waapi/Reorder/Reorder.types.d.ts +168 -0
- package/dist/react-ui/primitives/waapi/Reorder/Reorder.types.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Reorder/index.d.ts +25 -0
- package/dist/react-ui/primitives/waapi/Reorder/index.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Reorder/index.js +186 -0
- package/dist/react-ui/primitives/waapi/Reorder/useReorder.d.ts +26 -0
- package/dist/react-ui/primitives/waapi/Reorder/useReorder.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Reorder/useReorder.js +48 -0
- package/dist/react-ui/primitives/waapi/Reorder/useReorderPresence.d.ts +33 -0
- package/dist/react-ui/primitives/waapi/Reorder/useReorderPresence.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Reorder/useReorderPresence.js +137 -0
- package/dist/react-ui/primitives/waapi/Reorder/utils/separatorCoordination.d.ts +47 -0
- package/dist/react-ui/primitives/waapi/Reorder/utils/separatorCoordination.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Reorder/utils/separatorCoordination.js +72 -0
- package/dist/react-ui/primitives/waapi/SlidingNumber/SlidingNumber.styles.d.ts +10 -0
- package/dist/react-ui/primitives/waapi/SlidingNumber/SlidingNumber.styles.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/SlidingNumber/SlidingNumber.types.d.ts +74 -0
- package/dist/react-ui/primitives/waapi/SlidingNumber/SlidingNumber.types.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/SlidingNumber/index.d.ts +33 -0
- package/dist/react-ui/primitives/waapi/SlidingNumber/index.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/SlidingNumber/index.js +354 -0
- package/dist/react-ui/primitives/waapi/SlidingText/SlidingText.styles.d.ts +25 -0
- package/dist/react-ui/primitives/waapi/SlidingText/SlidingText.styles.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/SlidingText/SlidingText.types.d.ts +57 -0
- package/dist/react-ui/primitives/waapi/SlidingText/SlidingText.types.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/SlidingText/index.d.ts +26 -0
- package/dist/react-ui/primitives/waapi/SlidingText/index.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/SlidingText/index.js +105 -0
- package/dist/react-ui/primitives/waapi/core/animationConstants.d.ts +156 -0
- package/dist/react-ui/primitives/waapi/core/animationConstants.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/core/animationConstants.js +180 -0
- package/dist/react-ui/primitives/waapi/core/index.d.ts +16 -0
- package/dist/react-ui/primitives/waapi/core/index.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/core/index.js +5 -0
- package/dist/react-ui/primitives/waapi/core/types.d.ts +143 -0
- package/dist/react-ui/primitives/waapi/core/types.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/core/useAnimationOrchestrator.d.ts +32 -0
- package/dist/react-ui/primitives/waapi/core/useAnimationOrchestrator.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/core/useAnimationOrchestrator.js +322 -0
- package/dist/react-ui/primitives/waapi/core/useElementRegistry.d.ts +21 -0
- package/dist/react-ui/primitives/waapi/core/useElementRegistry.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/core/useElementRegistry.js +65 -0
- package/dist/react-ui/primitives/waapi/core/useFLIPAnimation.d.ts +20 -0
- package/dist/react-ui/primitives/waapi/core/useFLIPAnimation.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/core/useFLIPAnimation.js +99 -0
- package/dist/react-ui/primitives/waapi/core/usePositionCapture.d.ts +24 -0
- package/dist/react-ui/primitives/waapi/core/usePositionCapture.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/core/usePositionCapture.js +75 -0
- package/dist/react-ui/primitives/waapi/index.d.ts +33 -0
- package/dist/react-ui/primitives/waapi/index.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/index.js +18 -0
- package/dist/react-ui/ui/Accordion/index.js +3 -3
- package/dist/react-ui/ui/Button/index.js +8 -8
- package/dist/react-ui/ui/Combobox/index.js +2 -2
- package/dist/react-ui/ui/DataCard/DataCard.styles.d.ts +35 -0
- package/dist/react-ui/ui/DataCard/DataCard.styles.d.ts.map +1 -0
- package/dist/react-ui/ui/DataCard/DataCard.styles.js +114 -0
- package/dist/react-ui/ui/DataCard/DataCard.types.d.ts +135 -0
- package/dist/react-ui/ui/DataCard/DataCard.types.d.ts.map +1 -0
- package/dist/react-ui/ui/DataCard/index.d.ts +129 -0
- package/dist/react-ui/ui/DataCard/index.d.ts.map +1 -0
- package/dist/react-ui/ui/DataCard/index.js +276 -0
- package/dist/react-ui/ui/Menu/index.js +2 -2
- package/dist/react-ui/ui/Switch/index.js +3 -3
- package/dist/react-ui/ui/Tabs/index.js +3 -3
- package/dist/react-ui/ui/TextFlow/TextFlow.styles.d.ts +16 -0
- package/dist/react-ui/ui/TextFlow/TextFlow.styles.d.ts.map +1 -0
- package/dist/react-ui/ui/TextFlow/TextFlow.types.d.ts +101 -0
- package/dist/react-ui/ui/TextFlow/TextFlow.types.d.ts.map +1 -0
- package/dist/react-ui/ui/TextFlow/index.d.ts +26 -0
- package/dist/react-ui/ui/TextFlow/index.d.ts.map +1 -0
- package/dist/react-ui/ui/TextFlow/index.js +187 -0
- package/dist/react-ui/ui/index.d.ts +2 -1
- package/dist/react-ui/ui/index.d.ts.map +1 -1
- package/dist/react-ui/ui/index.js +3 -1
- package/package.json +6 -2
- package/src/react-ui/hooks/Formatting/UseListFormat.ts +134 -0
- package/src/react-ui/hooks/index.ts +3 -0
- package/src/react-ui/primitives/index.ts +3 -0
- package/src/react-ui/primitives/waapi/Morph/Morph.types.ts +106 -0
- package/src/react-ui/primitives/waapi/Morph/MorphContext.tsx +21 -0
- package/src/react-ui/primitives/waapi/Morph/index.tsx +56 -0
- package/src/react-ui/primitives/waapi/Morph/techniques/index.ts +12 -0
- package/src/react-ui/primitives/waapi/Morph/techniques/useCSSGridMorph.ts +88 -0
- package/src/react-ui/primitives/waapi/Morph/techniques/useFLIPClipPath.ts +175 -0
- package/src/react-ui/primitives/waapi/Morph/techniques/useViewTransitions.ts +86 -0
- package/src/react-ui/primitives/waapi/Morph/useMorph.ts +100 -0
- package/src/react-ui/primitives/waapi/Reorder/Reorder.types.ts +177 -0
- package/src/react-ui/primitives/waapi/Reorder/index.tsx +260 -0
- package/src/react-ui/primitives/waapi/Reorder/useReorder.ts +46 -0
- package/src/react-ui/primitives/waapi/Reorder/useReorderPresence.ts +208 -0
- package/src/react-ui/primitives/waapi/Reorder/utils/separatorCoordination.ts +104 -0
- package/src/react-ui/primitives/waapi/SlidingNumber/SlidingNumber.styles.ts +14 -0
- package/src/react-ui/primitives/waapi/SlidingNumber/SlidingNumber.types.ts +84 -0
- package/src/react-ui/primitives/waapi/SlidingNumber/index.tsx +474 -0
- package/src/react-ui/primitives/waapi/SlidingText/SlidingText.styles.ts +32 -0
- package/src/react-ui/primitives/waapi/SlidingText/SlidingText.types.ts +69 -0
- package/src/react-ui/primitives/waapi/SlidingText/index.tsx +140 -0
- package/src/react-ui/primitives/waapi/core/animationConstants.ts +215 -0
- package/src/react-ui/primitives/waapi/core/index.ts +53 -0
- package/src/react-ui/primitives/waapi/core/types.ts +200 -0
- package/src/react-ui/primitives/waapi/core/useAnimationOrchestrator.ts +429 -0
- package/src/react-ui/primitives/waapi/core/useElementRegistry.ts +80 -0
- package/src/react-ui/primitives/waapi/core/useFLIPAnimation.ts +137 -0
- package/src/react-ui/primitives/waapi/core/usePositionCapture.ts +105 -0
- package/src/react-ui/primitives/waapi/index.ts +116 -0
- package/src/react-ui/styles/animations.css +369 -0
- package/src/react-ui/ui/DataCard/DataCard.styles.ts +150 -0
- package/src/react-ui/ui/DataCard/DataCard.types.ts +146 -0
- package/src/react-ui/ui/DataCard/index.tsx +406 -0
- package/src/react-ui/ui/TextFlow/TextFlow.styles.ts +36 -0
- package/src/react-ui/ui/TextFlow/TextFlow.types.ts +118 -0
- package/src/react-ui/ui/TextFlow/index.tsx +276 -0
- package/src/react-ui/ui/index.ts +4 -1
- /package/dist/react-ui/components/MorphingPopover/{morphing-popover.module-CgbYV_HS.css → morphing-popover.module-BycNI8nU.css} +0 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { useReorder } from "./useReorder.js";
|
|
2
|
+
import { Children, cloneElement, isValidElement, useCallback, useEffect, useLayoutEffect, useMemo, useRef } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/react-ui/primitives/waapi/Reorder/useReorderPresence.ts
|
|
5
|
+
/**
|
|
6
|
+
* Hook for managing presence animations in reorderable lists.
|
|
7
|
+
*
|
|
8
|
+
* Follows the pattern where elements stay in DOM until animation completes.
|
|
9
|
+
* Consumer must keep items in their state until onAnimationComplete fires.
|
|
10
|
+
* No "ghost" cloning — animations run on actual DOM elements.
|
|
11
|
+
*
|
|
12
|
+
* @param children - React children with unique keys
|
|
13
|
+
* @param config - Presence animation configuration
|
|
14
|
+
* @returns Presence API with presentChildren, triggerExit, and state queries
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* const [items, setItems] = useState(INITIAL_ITEMS);
|
|
19
|
+
*
|
|
20
|
+
* const { presentChildren, triggerExit } = useReorderPresence(
|
|
21
|
+
* items.map(item => <div key={item.id}>{item.name}</div>),
|
|
22
|
+
* {
|
|
23
|
+
* onAnimationComplete: (id) => {
|
|
24
|
+
* setItems(prev => prev.filter(item => item.id !== id));
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* );
|
|
28
|
+
*
|
|
29
|
+
* const handleDelete = (id: string) => {
|
|
30
|
+
* triggerExit(id);
|
|
31
|
+
* };
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
function useReorderPresence(children, config = {}) {
|
|
35
|
+
const { autoAnimate = true, stagger, enterDuration, exitDuration, flipDuration, enterEasing, exitEasing, flipEasing } = config;
|
|
36
|
+
const configRef = useRef(config);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
configRef.current = config;
|
|
39
|
+
}, [config]);
|
|
40
|
+
const exitingIdsRef = useRef(/* @__PURE__ */ new Set());
|
|
41
|
+
const enteringIdsRef = useRef(/* @__PURE__ */ new Set());
|
|
42
|
+
const prevKeysRef = useRef(/* @__PURE__ */ new Set());
|
|
43
|
+
const getStaggerDelay = useCallback((index, type) => {
|
|
44
|
+
if (!stagger) return 0;
|
|
45
|
+
if (typeof stagger === "number") return stagger * index;
|
|
46
|
+
return (stagger[type] ?? 0) * index;
|
|
47
|
+
}, [stagger]);
|
|
48
|
+
const reorder = useReorder({
|
|
49
|
+
enterDuration,
|
|
50
|
+
exitDuration,
|
|
51
|
+
flipDuration,
|
|
52
|
+
enterEasing,
|
|
53
|
+
exitEasing,
|
|
54
|
+
flipEasing,
|
|
55
|
+
onComplete: useCallback((id) => {
|
|
56
|
+
exitingIdsRef.current.delete(id);
|
|
57
|
+
configRef.current.onAnimationComplete?.(id);
|
|
58
|
+
}, [])
|
|
59
|
+
});
|
|
60
|
+
const currentKeys = useMemo(() => {
|
|
61
|
+
const keys = /* @__PURE__ */ new Set();
|
|
62
|
+
Children.forEach(children, (child) => {
|
|
63
|
+
if (isValidElement(child) && child.key != null) keys.add(String(child.key));
|
|
64
|
+
});
|
|
65
|
+
return keys;
|
|
66
|
+
}, [children]);
|
|
67
|
+
useLayoutEffect(() => {
|
|
68
|
+
const prevKeys = prevKeysRef.current;
|
|
69
|
+
const added = [];
|
|
70
|
+
currentKeys.forEach((key) => {
|
|
71
|
+
if (!prevKeys.has(key) && !enteringIdsRef.current.has(key)) added.push(key);
|
|
72
|
+
});
|
|
73
|
+
if (added.length > 0) added.forEach((key, index) => {
|
|
74
|
+
const delay = getStaggerDelay(index, "enter");
|
|
75
|
+
const processEnter = () => {
|
|
76
|
+
enteringIdsRef.current.add(key);
|
|
77
|
+
configRef.current.onItemEnter?.(key);
|
|
78
|
+
requestAnimationFrame(() => {
|
|
79
|
+
reorder.startItemEnter(key).then(() => {
|
|
80
|
+
enteringIdsRef.current.delete(key);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
if (delay > 0) setTimeout(processEnter, delay);
|
|
85
|
+
else processEnter();
|
|
86
|
+
});
|
|
87
|
+
prevKeysRef.current = new Set(currentKeys);
|
|
88
|
+
}, [
|
|
89
|
+
currentKeys,
|
|
90
|
+
autoAnimate,
|
|
91
|
+
reorder,
|
|
92
|
+
getStaggerDelay
|
|
93
|
+
]);
|
|
94
|
+
const triggerExit = useCallback((id) => {
|
|
95
|
+
if (exitingIdsRef.current.has(id)) return;
|
|
96
|
+
if (!reorder.registry.has(id)) return;
|
|
97
|
+
exitingIdsRef.current.add(id);
|
|
98
|
+
configRef.current.onItemExit?.(id);
|
|
99
|
+
reorder.startItemExit(id);
|
|
100
|
+
}, [reorder]);
|
|
101
|
+
const isExiting = useCallback((id) => {
|
|
102
|
+
return exitingIdsRef.current.has(id);
|
|
103
|
+
}, []);
|
|
104
|
+
const isEntering = useCallback((id) => {
|
|
105
|
+
return enteringIdsRef.current.has(id);
|
|
106
|
+
}, []);
|
|
107
|
+
const getExitingIds = useCallback(() => {
|
|
108
|
+
return Array.from(exitingIdsRef.current);
|
|
109
|
+
}, []);
|
|
110
|
+
const getEnteringIds = useCallback(() => {
|
|
111
|
+
return Array.from(enteringIdsRef.current);
|
|
112
|
+
}, []);
|
|
113
|
+
return {
|
|
114
|
+
presentChildren: useMemo(() => {
|
|
115
|
+
const result = [];
|
|
116
|
+
Children.forEach(children, (child) => {
|
|
117
|
+
if (!isValidElement(child)) {
|
|
118
|
+
result.push(child);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const key = child.key != null ? String(child.key) : null;
|
|
122
|
+
if (key != null && exitingIdsRef.current.has(key)) result.push(cloneElement(child, { "data-reorder-state": "exiting" }));
|
|
123
|
+
else result.push(child);
|
|
124
|
+
});
|
|
125
|
+
return result;
|
|
126
|
+
}, [children]),
|
|
127
|
+
triggerExit,
|
|
128
|
+
isExiting,
|
|
129
|
+
isEntering,
|
|
130
|
+
exitingIds: getExitingIds(),
|
|
131
|
+
enteringIds: getEnteringIds(),
|
|
132
|
+
reorder
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
//#endregion
|
|
137
|
+
export { useReorderPresence };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for separator animation coordination.
|
|
3
|
+
*
|
|
4
|
+
* When a token exits, determines which separators should animate:
|
|
5
|
+
* 1. The exiting token's own separator (if it has one)
|
|
6
|
+
* 2. If the exiting token is the last visible, the previous token's separator
|
|
7
|
+
*
|
|
8
|
+
* @module primitives/waapi/Reorder/utils/separatorCoordination
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Calculate which separator IDs should animate along with an exiting item.
|
|
12
|
+
*
|
|
13
|
+
* Logic:
|
|
14
|
+
* - If the exiting item is NOT the last in the list, animate its own separator
|
|
15
|
+
* - If the exiting item IS the last in the list, animate the previous item's separator
|
|
16
|
+
* (because the previous item will become the new last and shouldn't have a separator)
|
|
17
|
+
*
|
|
18
|
+
* @param exitingId - The ID of the item being removed
|
|
19
|
+
* @param currentKeys - Set of all current (non-exiting) item keys
|
|
20
|
+
* @param exitingIds - Set of all currently exiting item IDs
|
|
21
|
+
* @param orderedKeys - Array of keys in render order
|
|
22
|
+
* @returns Array of separator IDs to animate
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* // Items: [A, B, C, D] with separators after A, B, C
|
|
27
|
+
* // Removing C (not last):
|
|
28
|
+
* calculateSeparatorCoordination('C', {'A','B','D'}, {'C'}, ['A','B','C','D'])
|
|
29
|
+
* // Returns: ['C'] - animate C's separator
|
|
30
|
+
*
|
|
31
|
+
* // Removing D (last item):
|
|
32
|
+
* calculateSeparatorCoordination('D', {'A','B','C'}, {'D'}, ['A','B','C','D'])
|
|
33
|
+
* // Returns: ['C'] - animate C's separator (C becomes new last)
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function calculateSeparatorCoordination(exitingId: string, currentKeys: Set<string>, exitingIds: Set<string>, orderedKeys: string[]): string[];
|
|
37
|
+
/**
|
|
38
|
+
* Determine if a separator should be visible based on position and animation state.
|
|
39
|
+
*
|
|
40
|
+
* @param _tokenId - The token ID to check (unused, kept for API compatibility)
|
|
41
|
+
* @param tokenIndex - Index of the token in the visible list
|
|
42
|
+
* @param totalVisible - Total number of visible tokens
|
|
43
|
+
* @param separatorPhase - Current animation phase of the separator
|
|
44
|
+
* @returns Whether the separator should be rendered
|
|
45
|
+
*/
|
|
46
|
+
export declare function shouldShowSeparator(_tokenId: string, tokenIndex: number, totalVisible: number, separatorPhase?: 'idle' | 'exit-coordinated' | 'flip-coordinated' | 'completed'): boolean;
|
|
47
|
+
//# sourceMappingURL=separatorCoordination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"separatorCoordination.d.ts","sourceRoot":"","sources":["../../../../../../src/react-ui/primitives/waapi/Reorder/utils/separatorCoordination.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,EACxB,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,EACvB,WAAW,EAAE,MAAM,EAAE,GACpB,MAAM,EAAE,CA2BV;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,cAAc,CAAC,EAAE,MAAM,GAAG,kBAAkB,GAAG,kBAAkB,GAAG,WAAW,GAC9E,OAAO,CAmBT"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//#region src/react-ui/primitives/waapi/Reorder/utils/separatorCoordination.ts
|
|
2
|
+
/**
|
|
3
|
+
* Utility functions for separator animation coordination.
|
|
4
|
+
*
|
|
5
|
+
* When a token exits, determines which separators should animate:
|
|
6
|
+
* 1. The exiting token's own separator (if it has one)
|
|
7
|
+
* 2. If the exiting token is the last visible, the previous token's separator
|
|
8
|
+
*
|
|
9
|
+
* @module primitives/waapi/Reorder/utils/separatorCoordination
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Calculate which separator IDs should animate along with an exiting item.
|
|
13
|
+
*
|
|
14
|
+
* Logic:
|
|
15
|
+
* - If the exiting item is NOT the last in the list, animate its own separator
|
|
16
|
+
* - If the exiting item IS the last in the list, animate the previous item's separator
|
|
17
|
+
* (because the previous item will become the new last and shouldn't have a separator)
|
|
18
|
+
*
|
|
19
|
+
* @param exitingId - The ID of the item being removed
|
|
20
|
+
* @param currentKeys - Set of all current (non-exiting) item keys
|
|
21
|
+
* @param exitingIds - Set of all currently exiting item IDs
|
|
22
|
+
* @param orderedKeys - Array of keys in render order
|
|
23
|
+
* @returns Array of separator IDs to animate
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* // Items: [A, B, C, D] with separators after A, B, C
|
|
28
|
+
* // Removing C (not last):
|
|
29
|
+
* calculateSeparatorCoordination('C', {'A','B','D'}, {'C'}, ['A','B','C','D'])
|
|
30
|
+
* // Returns: ['C'] - animate C's separator
|
|
31
|
+
*
|
|
32
|
+
* // Removing D (last item):
|
|
33
|
+
* calculateSeparatorCoordination('D', {'A','B','C'}, {'D'}, ['A','B','C','D'])
|
|
34
|
+
* // Returns: ['C'] - animate C's separator (C becomes new last)
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
function calculateSeparatorCoordination(exitingId, currentKeys, exitingIds, orderedKeys) {
|
|
38
|
+
const additionalSeparators = [];
|
|
39
|
+
const visibleKeys = orderedKeys.filter((key) => currentKeys.has(key) || exitingIds.has(key));
|
|
40
|
+
const indexInVisible = visibleKeys.indexOf(exitingId);
|
|
41
|
+
if (indexInVisible === -1) return additionalSeparators;
|
|
42
|
+
const isLastVisible = indexInVisible === visibleKeys.length - 1;
|
|
43
|
+
if (indexInVisible < visibleKeys.length - 1) additionalSeparators.push(exitingId);
|
|
44
|
+
if (isLastVisible && indexInVisible > 0) {
|
|
45
|
+
const previousKey = visibleKeys[indexInVisible - 1];
|
|
46
|
+
if (previousKey && !exitingIds.has(previousKey)) additionalSeparators.push(previousKey);
|
|
47
|
+
}
|
|
48
|
+
return additionalSeparators;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Determine if a separator should be visible based on position and animation state.
|
|
52
|
+
*
|
|
53
|
+
* @param _tokenId - The token ID to check (unused, kept for API compatibility)
|
|
54
|
+
* @param tokenIndex - Index of the token in the visible list
|
|
55
|
+
* @param totalVisible - Total number of visible tokens
|
|
56
|
+
* @param separatorPhase - Current animation phase of the separator
|
|
57
|
+
* @returns Whether the separator should be rendered
|
|
58
|
+
*/
|
|
59
|
+
function shouldShowSeparator(_tokenId, tokenIndex, totalVisible, separatorPhase) {
|
|
60
|
+
if (tokenIndex >= totalVisible - 1) return false;
|
|
61
|
+
if (!separatorPhase) return true;
|
|
62
|
+
switch (separatorPhase) {
|
|
63
|
+
case "idle":
|
|
64
|
+
case "exit-coordinated":
|
|
65
|
+
case "flip-coordinated": return true;
|
|
66
|
+
case "completed": return false;
|
|
67
|
+
default: return true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
export { calculateSeparatorCoordination, shouldShowSeparator };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { StyleSlots } from '../../../../core/types';
|
|
2
|
+
/**
|
|
3
|
+
* Style slots for SlidingNumber component
|
|
4
|
+
*/
|
|
5
|
+
export type SlidingNumberSlot = 'root';
|
|
6
|
+
/**
|
|
7
|
+
* Base styles for SlidingNumber component
|
|
8
|
+
*/
|
|
9
|
+
export declare const slidingNumberBaseStyles: StyleSlots<SlidingNumberSlot>;
|
|
10
|
+
//# sourceMappingURL=SlidingNumber.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SlidingNumber.styles.d.ts","sourceRoot":"","sources":["../../../../../src/react-ui/primitives/waapi/SlidingNumber/SlidingNumber.styles.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,UAAU,CAAC,iBAAiB,CAEjE,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format options for number display using Intl.NumberFormat
|
|
3
|
+
*/
|
|
4
|
+
export interface IFormatOptions {
|
|
5
|
+
/** Number formatting style */
|
|
6
|
+
style?: 'decimal' | 'currency' | 'percent';
|
|
7
|
+
/** Currency code (required when style is 'currency') */
|
|
8
|
+
currency?: string;
|
|
9
|
+
/** Locale for formatting (e.g., 'en-US', 'es-ES') */
|
|
10
|
+
locale?: string;
|
|
11
|
+
/** Minimum fraction digits */
|
|
12
|
+
minimumFractionDigits?: number;
|
|
13
|
+
/** Maximum fraction digits */
|
|
14
|
+
maximumFractionDigits?: number;
|
|
15
|
+
/** Whether to use grouping separators */
|
|
16
|
+
useGrouping?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Props for SlidingNumber component
|
|
20
|
+
*
|
|
21
|
+
* Animated number transitions with format preservation using WAAPI slot-machine-style animation.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* // Basic counter
|
|
26
|
+
* <SlidingNumber value={1234} duration={700} />
|
|
27
|
+
*
|
|
28
|
+
* // Currency
|
|
29
|
+
* <SlidingNumber
|
|
30
|
+
* value={99.99}
|
|
31
|
+
* format={{ style: 'currency', currency: 'USD' }}
|
|
32
|
+
* />
|
|
33
|
+
*
|
|
34
|
+
* // With motion blur
|
|
35
|
+
* <SlidingNumber value={500} motionBlur={true} digitHeight={60} />
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export interface ISlidingNumberProps {
|
|
39
|
+
/** The numeric value to display */
|
|
40
|
+
value: number;
|
|
41
|
+
/** Animation duration in milliseconds */
|
|
42
|
+
duration?: number;
|
|
43
|
+
/** Font size for the number display */
|
|
44
|
+
fontSize?: string;
|
|
45
|
+
/** Font weight for the number display */
|
|
46
|
+
fontWeight?: string;
|
|
47
|
+
/** Text color */
|
|
48
|
+
color?: string;
|
|
49
|
+
/** Height of each digit row in pixels */
|
|
50
|
+
digitHeight?: number;
|
|
51
|
+
/** Delay between digit animations in milliseconds */
|
|
52
|
+
stagger?: number;
|
|
53
|
+
/** Enable motion blur effect during animation */
|
|
54
|
+
motionBlur?: boolean;
|
|
55
|
+
/** Number formatting options */
|
|
56
|
+
format?: IFormatOptions;
|
|
57
|
+
/**
|
|
58
|
+
* Animation direction trend
|
|
59
|
+
* - 1: Always animate upward (increasing)
|
|
60
|
+
* - -1: Always animate downward (decreasing)
|
|
61
|
+
* - 0: Auto (shorter path)
|
|
62
|
+
*/
|
|
63
|
+
trend?: -1 | 0 | 1;
|
|
64
|
+
/** Physics-based animation configuration */
|
|
65
|
+
animationConfig?: {
|
|
66
|
+
/** Overshoot amount (higher = more bounce) */
|
|
67
|
+
overshoot?: number;
|
|
68
|
+
/** Mass of the animated object */
|
|
69
|
+
mass?: number;
|
|
70
|
+
/** Spring stiffness */
|
|
71
|
+
stiffness?: number;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=SlidingNumber.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SlidingNumber.types.d.ts","sourceRoot":"","sources":["../../../../../src/react-ui/primitives/waapi/SlidingNumber/SlidingNumber.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,8BAA8B;IAC9B,KAAK,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;IAC3C,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,8BAA8B;IAC9B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,yCAAyC;IACzC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,mBAAmB;IAClC,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IAEd,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,yCAAyC;IACzC,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,iBAAiB;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,yCAAyC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,iDAAiD;IACjD,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,gCAAgC;IAChC,MAAM,CAAC,EAAE,cAAc,CAAC;IAExB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAEnB,4CAA4C;IAC5C,eAAe,CAAC,EAAE;QAChB,8CAA8C;QAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,kCAAkC;QAClC,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,uBAAuB;QACvB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ISlidingNumberProps, IFormatOptions } from './SlidingNumber.types';
|
|
3
|
+
/**
|
|
4
|
+
* SlidingNumber - Animated number transitions with format preservation
|
|
5
|
+
*
|
|
6
|
+
* Uses WAAPI slot-machine-style animation with optional motion blur.
|
|
7
|
+
* Supports Intl.NumberFormat for currency, percentage, and decimal formatting.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* // Basic counter
|
|
12
|
+
* <SlidingNumber value={1234} />
|
|
13
|
+
*
|
|
14
|
+
* // Currency with animation
|
|
15
|
+
* <SlidingNumber
|
|
16
|
+
* value={99.99}
|
|
17
|
+
* format={{ style: 'currency', currency: 'USD' }}
|
|
18
|
+
* duration={700}
|
|
19
|
+
* />
|
|
20
|
+
*
|
|
21
|
+
* // Percentage
|
|
22
|
+
* <SlidingNumber
|
|
23
|
+
* value={75.5}
|
|
24
|
+
* format={{ style: 'percent' }}
|
|
25
|
+
* />
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const SlidingNumber: {
|
|
29
|
+
({ value, duration, fontSize, fontWeight, color, digitHeight, stagger, motionBlur, format, trend, animationConfig, }: ISlidingNumberProps): React.ReactElement;
|
|
30
|
+
displayName: string;
|
|
31
|
+
};
|
|
32
|
+
export type { ISlidingNumberProps, IFormatOptions };
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/react-ui/primitives/waapi/SlidingNumber/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsD,MAAM,OAAO,CAAC;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGjF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,aAAa;0HAYvB,mBAAmB,GAAG,KAAK,CAAC,YAAY;;CA4E1C,CAAC;AAkWF,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,CAAC"}
|