@choice-ui/react 1.9.7 → 1.9.8
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/components/button/dist/index.d.ts +9 -2
- package/dist/components/button/dist/index.js +19 -45
- package/dist/components/checkbox/dist/index.d.ts +1 -10
- package/dist/components/checkbox/dist/index.js +5 -49
- package/dist/components/code-block/dist/index.d.ts +14 -11
- package/dist/components/code-block/dist/index.js +93 -120
- package/dist/components/colors/dist/index.d.ts +6 -39
- package/dist/components/colors/src/color-image-paint/color-image-paint.js +2 -2
- package/dist/components/dropdown/dist/index.d.ts +0 -6
- package/dist/components/dropdown/dist/index.js +10 -20
- package/dist/components/emoji-picker/dist/index.d.ts +1 -30
- package/dist/components/emoji-picker/dist/index.js +44 -148
- package/dist/components/form/src/adapters/range-adapter.js +2 -2
- package/dist/components/icon-button/dist/index.d.ts +1 -1
- package/dist/components/icon-button/dist/index.js +0 -39
- package/dist/components/list/dist/index.d.ts +1 -1
- package/dist/components/md-render/dist/index.d.ts +1 -2
- package/dist/components/md-render/dist/index.js +9 -5
- package/dist/components/menus/dist/index.d.ts +0 -5
- package/dist/components/menus/dist/index.js +3 -32
- package/dist/components/modal/dist/index.js +2 -2
- package/dist/components/notifications/dist/index.d.ts +5 -1
- package/dist/components/numeric-input/dist/index.d.ts +10 -27
- package/dist/components/numeric-input/dist/index.js +23 -108
- package/dist/components/panel/dist/index.d.ts +16 -16
- package/dist/components/picture-preview/dist/index.d.ts +0 -5
- package/dist/components/picture-preview/dist/index.js +140 -287
- package/dist/components/popover/dist/index.d.ts +0 -5
- package/dist/components/popover/dist/index.js +2 -21
- package/dist/components/radio/dist/index.d.ts +1 -9
- package/dist/components/radio/dist/index.js +6 -50
- package/dist/components/range/dist/index.d.ts +20 -276
- package/dist/components/range/dist/index.js +616 -1044
- package/dist/components/scroll-area/dist/index.d.ts +27 -4
- package/dist/components/scroll-area/dist/index.js +123 -96
- package/dist/components/separator/dist/index.d.ts +8 -1
- package/dist/components/splitter/dist/index.d.ts +1 -1
- package/dist/components/text-field/dist/index.d.ts +3 -2
- package/dist/components/text-field/dist/index.js +19 -4
- package/dist/components/textarea/dist/index.js +1 -3
- package/dist/components/tooltip/dist/index.d.ts +0 -2
- package/dist/components/tooltip/dist/index.js +5 -23
- package/package.json +1 -1
- package/dist/components/toast/dist/index.d.ts +0 -274
- package/dist/components/virtual-select/dist/index.d.ts +0 -48
|
@@ -61,9 +61,9 @@ declare const ScrollArea: react.ForwardRefExoticComponent<ScrollAreaProps & reac
|
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
|
-
* Merged scroll state and visibility management hook
|
|
64
|
+
* Merged scroll state and visibility management hook - avoid duplicate scroll event listening
|
|
65
65
|
*/
|
|
66
|
-
declare function useScrollStateAndVisibility(viewport: HTMLDivElement | null
|
|
66
|
+
declare function useScrollStateAndVisibility(viewport: HTMLDivElement | null): {
|
|
67
67
|
scrollState: ScrollState;
|
|
68
68
|
isHovering: boolean;
|
|
69
69
|
isScrolling: boolean;
|
|
@@ -86,7 +86,7 @@ declare function useThumbStyle(scrollState: ScrollState, orientation: "vertical"
|
|
|
86
86
|
top?: undefined;
|
|
87
87
|
};
|
|
88
88
|
/**
|
|
89
|
-
* High-performance thumb drag hook
|
|
89
|
+
* 🚀 High-performance thumb drag hook - optimize drag responsiveness and performance
|
|
90
90
|
*/
|
|
91
91
|
declare function useThumbDrag(viewport: HTMLDivElement | null, scrollState: ScrollState, orientation: "vertical" | "horizontal"): {
|
|
92
92
|
isDragging: boolean;
|
|
@@ -102,4 +102,27 @@ declare function useHasOverflow(scrollState: ScrollState, orientation: "vertical
|
|
|
102
102
|
*/
|
|
103
103
|
declare function useScrollbarShouldShow(type: ScrollbarVisibilityType, hasOverflow: boolean, isScrolling: boolean, isHovering: boolean): boolean;
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
interface PerformanceMetrics {
|
|
106
|
+
averageFrameTime: number;
|
|
107
|
+
droppedFrames: number;
|
|
108
|
+
maxFrameTime: number;
|
|
109
|
+
scrollEventFrequency: number;
|
|
110
|
+
updateFrequency: number;
|
|
111
|
+
}
|
|
112
|
+
interface PerformanceMonitorOptions {
|
|
113
|
+
enabled?: boolean;
|
|
114
|
+
frameTimeThreshold?: number;
|
|
115
|
+
logInterval?: number;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* 🔍 ScrollArea performance monitoring Hook
|
|
119
|
+
*
|
|
120
|
+
* Used to monitor and diagnose scroll performance issues, including:
|
|
121
|
+
* - Frame rate monitoring
|
|
122
|
+
* - Event frequency statistics
|
|
123
|
+
* - Performance bottleneck detection
|
|
124
|
+
* - Real-time performance reporting
|
|
125
|
+
*/
|
|
126
|
+
declare function useScrollPerformanceMonitor(viewport: HTMLDivElement | null, options?: PerformanceMonitorOptions): PerformanceMetrics | null;
|
|
127
|
+
|
|
128
|
+
export { ScrollArea, type ScrollAreaProps, type ScrollbarProps, type ThumbProps, useHasOverflow, useScrollPerformanceMonitor, useScrollStateAndVisibility, useScrollbarShouldShow, useThumbDrag, useThumbStyle };
|
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
import { forwardRef, useState, useId, useMemo, createContext, useCallback, useRef, useEffect, useContext } from "react";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { tcv, tcx } from "../../../shared/utils/tcx/tcx.js";
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function useScrollAreaStateContext() {
|
|
8
|
-
const context = useContext(ScrollAreaStateContext);
|
|
9
|
-
if (!context) {
|
|
10
|
-
throw new Error(ERROR_MESSAGE);
|
|
11
|
-
}
|
|
12
|
-
return context;
|
|
13
|
-
}
|
|
14
|
-
function useScrollAreaConfigContext() {
|
|
15
|
-
const context = useContext(ScrollAreaConfigContext);
|
|
4
|
+
var ScrollAreaContext = createContext(null);
|
|
5
|
+
function useScrollAreaContext() {
|
|
6
|
+
const context = useContext(ScrollAreaContext);
|
|
16
7
|
if (!context) {
|
|
17
|
-
throw new Error(
|
|
8
|
+
throw new Error("ScrollArea compound components must be used within ScrollArea");
|
|
18
9
|
}
|
|
19
10
|
return context;
|
|
20
11
|
}
|
|
21
|
-
function
|
|
22
|
-
const state = useScrollAreaStateContext();
|
|
23
|
-
const config = useScrollAreaConfigContext();
|
|
24
|
-
return { ...state, ...config };
|
|
25
|
-
}
|
|
26
|
-
function useScrollStateAndVisibility(viewport, content) {
|
|
12
|
+
function useScrollStateAndVisibility(viewport) {
|
|
27
13
|
const [scrollState, setScrollState] = useState({
|
|
28
14
|
scrollLeft: 0,
|
|
29
15
|
scrollTop: 0,
|
|
@@ -37,6 +23,8 @@ function useScrollStateAndVisibility(viewport, content) {
|
|
|
37
23
|
const scrollTimeoutRef = useRef();
|
|
38
24
|
const rafRef = useRef();
|
|
39
25
|
const resizeObserverRef = useRef();
|
|
26
|
+
const mutationObserverRef = useRef();
|
|
27
|
+
const mutationTimeoutRef = useRef();
|
|
40
28
|
const lastUpdateTimeRef = useRef(0);
|
|
41
29
|
const minUpdateIntervalRef = useRef(16);
|
|
42
30
|
const updateScrollState = useCallback(() => {
|
|
@@ -48,36 +36,36 @@ function useScrollStateAndVisibility(viewport, content) {
|
|
|
48
36
|
cancelAnimationFrame(rafRef.current);
|
|
49
37
|
}
|
|
50
38
|
rafRef.current = requestAnimationFrame(() => {
|
|
51
|
-
rafRef.current = void 0;
|
|
52
39
|
updateScrollState();
|
|
53
40
|
});
|
|
54
41
|
return;
|
|
55
42
|
}
|
|
56
43
|
if (rafRef.current) {
|
|
57
44
|
cancelAnimationFrame(rafRef.current);
|
|
58
|
-
rafRef.current = void 0;
|
|
59
45
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
46
|
+
rafRef.current = requestAnimationFrame(() => {
|
|
47
|
+
const newState = {
|
|
48
|
+
scrollLeft: viewport.scrollLeft,
|
|
49
|
+
scrollTop: viewport.scrollTop,
|
|
50
|
+
scrollWidth: viewport.scrollWidth,
|
|
51
|
+
scrollHeight: viewport.scrollHeight,
|
|
52
|
+
clientWidth: viewport.clientWidth,
|
|
53
|
+
clientHeight: viewport.clientHeight
|
|
54
|
+
};
|
|
55
|
+
setScrollState((prevState) => {
|
|
56
|
+
const scrollLeftChanged = Math.abs(prevState.scrollLeft - newState.scrollLeft) > 0.5;
|
|
57
|
+
const scrollTopChanged = Math.abs(prevState.scrollTop - newState.scrollTop) > 0.5;
|
|
58
|
+
const scrollWidthChanged = prevState.scrollWidth !== newState.scrollWidth;
|
|
59
|
+
const scrollHeightChanged = prevState.scrollHeight !== newState.scrollHeight;
|
|
60
|
+
const clientWidthChanged = prevState.clientWidth !== newState.clientWidth;
|
|
61
|
+
const clientHeightChanged = prevState.clientHeight !== newState.clientHeight;
|
|
62
|
+
const hasChanges = scrollLeftChanged || scrollTopChanged || scrollWidthChanged || scrollHeightChanged || clientWidthChanged || clientHeightChanged;
|
|
63
|
+
if (hasChanges) {
|
|
64
|
+
lastUpdateTimeRef.current = now;
|
|
65
|
+
return newState;
|
|
66
|
+
}
|
|
67
|
+
return prevState;
|
|
68
|
+
});
|
|
81
69
|
});
|
|
82
70
|
}, [viewport]);
|
|
83
71
|
const delayedUpdateScrollState = useCallback(() => {
|
|
@@ -114,19 +102,54 @@ function useScrollStateAndVisibility(viewport, content) {
|
|
|
114
102
|
passive: true,
|
|
115
103
|
signal,
|
|
116
104
|
capture: false
|
|
105
|
+
// Avoid unnecessary event capture
|
|
117
106
|
});
|
|
118
107
|
window.addEventListener("resize", handleResize, {
|
|
119
108
|
passive: true,
|
|
120
109
|
signal
|
|
121
110
|
});
|
|
122
111
|
if (window.ResizeObserver) {
|
|
123
|
-
resizeObserverRef.current = new ResizeObserver(() => {
|
|
124
|
-
|
|
112
|
+
resizeObserverRef.current = new ResizeObserver((entries) => {
|
|
113
|
+
for (const entry of entries) {
|
|
114
|
+
if (entry.target === viewport) {
|
|
115
|
+
updateScrollState();
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
125
119
|
});
|
|
126
120
|
resizeObserverRef.current.observe(viewport);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
121
|
+
}
|
|
122
|
+
if (window.MutationObserver) {
|
|
123
|
+
mutationObserverRef.current = new MutationObserver((mutations) => {
|
|
124
|
+
const hasLayoutChanges = mutations.some((mutation) => {
|
|
125
|
+
if (mutation.type === "childList") {
|
|
126
|
+
return mutation.addedNodes.length > 0 || mutation.removedNodes.length > 0;
|
|
127
|
+
}
|
|
128
|
+
if (mutation.type === "attributes") {
|
|
129
|
+
const attr = mutation.attributeName;
|
|
130
|
+
return attr === "style" || attr === "class";
|
|
131
|
+
}
|
|
132
|
+
return mutation.type === "characterData";
|
|
133
|
+
});
|
|
134
|
+
if (!hasLayoutChanges) return;
|
|
135
|
+
if (mutationTimeoutRef.current) {
|
|
136
|
+
clearTimeout(mutationTimeoutRef.current);
|
|
137
|
+
}
|
|
138
|
+
mutationTimeoutRef.current = window.setTimeout(() => {
|
|
139
|
+
updateScrollState();
|
|
140
|
+
}, 16);
|
|
141
|
+
});
|
|
142
|
+
mutationObserverRef.current.observe(viewport, {
|
|
143
|
+
childList: true,
|
|
144
|
+
subtree: true,
|
|
145
|
+
attributes: true,
|
|
146
|
+
attributeFilter: ["style", "class"],
|
|
147
|
+
// Only listen to attributes that affect layout
|
|
148
|
+
characterData: true,
|
|
149
|
+
characterDataOldValue: false,
|
|
150
|
+
// No need for old value, improve performance
|
|
151
|
+
attributeOldValue: false
|
|
152
|
+
});
|
|
130
153
|
}
|
|
131
154
|
delayedUpdateScrollState();
|
|
132
155
|
return () => {
|
|
@@ -135,6 +158,10 @@ function useScrollStateAndVisibility(viewport, content) {
|
|
|
135
158
|
clearTimeout(scrollTimeoutRef.current);
|
|
136
159
|
scrollTimeoutRef.current = void 0;
|
|
137
160
|
}
|
|
161
|
+
if (mutationTimeoutRef.current) {
|
|
162
|
+
clearTimeout(mutationTimeoutRef.current);
|
|
163
|
+
mutationTimeoutRef.current = void 0;
|
|
164
|
+
}
|
|
138
165
|
if (rafRef.current) {
|
|
139
166
|
cancelAnimationFrame(rafRef.current);
|
|
140
167
|
rafRef.current = void 0;
|
|
@@ -143,8 +170,12 @@ function useScrollStateAndVisibility(viewport, content) {
|
|
|
143
170
|
resizeObserverRef.current.disconnect();
|
|
144
171
|
resizeObserverRef.current = void 0;
|
|
145
172
|
}
|
|
173
|
+
if (mutationObserverRef.current) {
|
|
174
|
+
mutationObserverRef.current.disconnect();
|
|
175
|
+
mutationObserverRef.current = void 0;
|
|
176
|
+
}
|
|
146
177
|
};
|
|
147
|
-
}, [viewport,
|
|
178
|
+
}, [viewport, handleScroll, delayedUpdateScrollState]);
|
|
148
179
|
const handleMouseEnter = useCallback(() => setIsHovering(true), []);
|
|
149
180
|
const handleMouseLeave = useCallback(() => setIsHovering(false), []);
|
|
150
181
|
return {
|
|
@@ -198,13 +229,16 @@ function useThumbDrag(viewport, scrollState, orientation) {
|
|
|
198
229
|
const isDragging = useRef(false);
|
|
199
230
|
const startPos = useRef(0);
|
|
200
231
|
const startScroll = useRef(0);
|
|
232
|
+
const rafId = useRef();
|
|
201
233
|
const cleanupRef = useRef(null);
|
|
202
|
-
const scrollStateRef = useRef(scrollState);
|
|
203
|
-
scrollStateRef.current = scrollState;
|
|
204
234
|
const dragContextRef = useRef(null);
|
|
205
235
|
useEffect(() => {
|
|
206
236
|
return () => {
|
|
207
237
|
isDragging.current = false;
|
|
238
|
+
if (rafId.current) {
|
|
239
|
+
cancelAnimationFrame(rafId.current);
|
|
240
|
+
rafId.current = void 0;
|
|
241
|
+
}
|
|
208
242
|
if (cleanupRef.current) {
|
|
209
243
|
cleanupRef.current();
|
|
210
244
|
cleanupRef.current = null;
|
|
@@ -214,21 +248,13 @@ function useThumbDrag(viewport, scrollState, orientation) {
|
|
|
214
248
|
const handleMouseDown = useCallback(
|
|
215
249
|
(e) => {
|
|
216
250
|
if (!viewport) return;
|
|
217
|
-
const currentScrollState = scrollStateRef.current;
|
|
218
251
|
const target = e.currentTarget;
|
|
219
252
|
const scrollbar = target.closest('[role="scrollbar"]');
|
|
220
253
|
if (!scrollbar) return;
|
|
221
254
|
const scrollbarRect = scrollbar.getBoundingClientRect();
|
|
222
|
-
const scrollableRange = orientation === "vertical" ? Math.max(0,
|
|
255
|
+
const scrollableRange = orientation === "vertical" ? Math.max(0, scrollState.scrollHeight - scrollState.clientHeight) : Math.max(0, scrollState.scrollWidth - scrollState.clientWidth);
|
|
223
256
|
const scrollbarRange = orientation === "vertical" ? scrollbarRect.height : scrollbarRect.width;
|
|
224
257
|
if (scrollableRange <= 0 || scrollbarRange <= 0) return;
|
|
225
|
-
const thumbFraction = Math.max(
|
|
226
|
-
0.1,
|
|
227
|
-
orientation === "vertical" ? currentScrollState.clientHeight / currentScrollState.scrollHeight : currentScrollState.clientWidth / currentScrollState.scrollWidth
|
|
228
|
-
);
|
|
229
|
-
const thumbSizePixels = scrollbarRange * thumbFraction;
|
|
230
|
-
const effectiveTrackRange = scrollbarRange - thumbSizePixels;
|
|
231
|
-
if (effectiveTrackRange <= 0) return;
|
|
232
258
|
dragContextRef.current = {
|
|
233
259
|
scrollbarRect,
|
|
234
260
|
scrollableRange,
|
|
@@ -236,26 +262,34 @@ function useThumbDrag(viewport, scrollState, orientation) {
|
|
|
236
262
|
};
|
|
237
263
|
isDragging.current = true;
|
|
238
264
|
startPos.current = orientation === "vertical" ? e.clientY : e.clientX;
|
|
239
|
-
startScroll.current = orientation === "vertical" ?
|
|
240
|
-
const scrollRatio = scrollableRange /
|
|
265
|
+
startScroll.current = orientation === "vertical" ? scrollState.scrollTop : scrollState.scrollLeft;
|
|
266
|
+
const scrollRatio = scrollableRange / scrollbarRange;
|
|
241
267
|
const handleMouseMove = (e2) => {
|
|
242
268
|
if (!isDragging.current || !viewport || !dragContextRef.current) return;
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
const scrollDelta = delta * scrollRatio;
|
|
246
|
-
const newScrollValue = Math.max(
|
|
247
|
-
0,
|
|
248
|
-
Math.min(startScroll.current + scrollDelta, dragContextRef.current.scrollableRange)
|
|
249
|
-
);
|
|
250
|
-
if (orientation === "vertical") {
|
|
251
|
-
viewport.scrollTop = newScrollValue;
|
|
252
|
-
} else {
|
|
253
|
-
viewport.scrollLeft = newScrollValue;
|
|
269
|
+
if (rafId.current) {
|
|
270
|
+
cancelAnimationFrame(rafId.current);
|
|
254
271
|
}
|
|
272
|
+
rafId.current = requestAnimationFrame(() => {
|
|
273
|
+
const currentPos = orientation === "vertical" ? e2.clientY : e2.clientX;
|
|
274
|
+
const delta = currentPos - startPos.current;
|
|
275
|
+
const scrollDelta = delta * scrollRatio;
|
|
276
|
+
const newScrollValue = Math.max(
|
|
277
|
+
0,
|
|
278
|
+
Math.min(startScroll.current + scrollDelta, dragContextRef.current.scrollableRange)
|
|
279
|
+
);
|
|
280
|
+
if (orientation === "vertical") {
|
|
281
|
+
viewport.scrollTop = newScrollValue;
|
|
282
|
+
} else {
|
|
283
|
+
viewport.scrollLeft = newScrollValue;
|
|
284
|
+
}
|
|
285
|
+
});
|
|
255
286
|
};
|
|
256
287
|
const handleMouseUp = () => {
|
|
257
288
|
isDragging.current = false;
|
|
258
289
|
dragContextRef.current = null;
|
|
290
|
+
if (rafId.current) {
|
|
291
|
+
cancelAnimationFrame(rafId.current);
|
|
292
|
+
}
|
|
259
293
|
document.removeEventListener("mousemove", handleMouseMove);
|
|
260
294
|
document.removeEventListener("mouseup", handleMouseUp);
|
|
261
295
|
cleanupRef.current = null;
|
|
@@ -269,7 +303,7 @@ function useThumbDrag(viewport, scrollState, orientation) {
|
|
|
269
303
|
document.addEventListener("mouseup", handleMouseUp, { passive: true });
|
|
270
304
|
e.preventDefault();
|
|
271
305
|
},
|
|
272
|
-
[viewport, orientation]
|
|
306
|
+
[viewport, orientation, scrollState]
|
|
273
307
|
);
|
|
274
308
|
return {
|
|
275
309
|
isDragging: isDragging.current,
|
|
@@ -575,8 +609,6 @@ var ScrollAreaScrollbar = forwardRef(
|
|
|
575
609
|
scrollbarXId,
|
|
576
610
|
scrollbarYId
|
|
577
611
|
} = useScrollAreaContext();
|
|
578
|
-
const scrollStateRef = useRef(scrollState);
|
|
579
|
-
scrollStateRef.current = scrollState;
|
|
580
612
|
const hasOverflow = useHasOverflow(scrollState, orientation);
|
|
581
613
|
const shouldShow = useScrollbarShouldShow(type, hasOverflow, isScrolling, isHovering);
|
|
582
614
|
const scrollPercentage = useMemo(() => {
|
|
@@ -587,23 +619,15 @@ var ScrollAreaScrollbar = forwardRef(
|
|
|
587
619
|
const maxScroll = scrollState.scrollWidth - scrollState.clientWidth;
|
|
588
620
|
return maxScroll > 0 ? Math.round(scrollState.scrollLeft / maxScroll * 100) : 0;
|
|
589
621
|
}
|
|
590
|
-
}, [
|
|
591
|
-
orientation,
|
|
592
|
-
scrollState.scrollTop,
|
|
593
|
-
scrollState.scrollLeft,
|
|
594
|
-
scrollState.scrollHeight,
|
|
595
|
-
scrollState.clientHeight,
|
|
596
|
-
scrollState.scrollWidth,
|
|
597
|
-
scrollState.clientWidth
|
|
598
|
-
]);
|
|
622
|
+
}, [scrollState, orientation]);
|
|
599
623
|
const handleTrackClick = useCallback(
|
|
600
624
|
(e) => {
|
|
601
625
|
if (!viewport) return;
|
|
602
626
|
if (e.target === e.currentTarget) {
|
|
603
|
-
handleScrollbarTrackClick(e, viewport,
|
|
627
|
+
handleScrollbarTrackClick(e, viewport, scrollState, orientation);
|
|
604
628
|
}
|
|
605
629
|
},
|
|
606
|
-
[viewport, orientation]
|
|
630
|
+
[viewport, scrollState, orientation]
|
|
607
631
|
);
|
|
608
632
|
const tv = useMemo(
|
|
609
633
|
() => ScrollTv({
|
|
@@ -722,7 +746,7 @@ var ScrollAreaRoot = forwardRef(
|
|
|
722
746
|
const viewportId = `scroll-viewport${reactId}`;
|
|
723
747
|
const scrollbarXId = `scroll-x${reactId}`;
|
|
724
748
|
const scrollbarYId = `scroll-y${reactId}`;
|
|
725
|
-
const { scrollState, isHovering, isScrolling, handleMouseEnter, handleMouseLeave } = useScrollStateAndVisibility(viewport
|
|
749
|
+
const { scrollState, isHovering, isScrolling, handleMouseEnter, handleMouseLeave } = useScrollStateAndVisibility(viewport);
|
|
726
750
|
const staticConfig = useMemo(
|
|
727
751
|
() => ({
|
|
728
752
|
orientation,
|
|
@@ -733,14 +757,11 @@ var ScrollAreaRoot = forwardRef(
|
|
|
733
757
|
}),
|
|
734
758
|
[orientation, scrollbarMode, hoverBoundary, variant, type]
|
|
735
759
|
);
|
|
736
|
-
const
|
|
737
|
-
() => ({ scrollState, isHovering, isScrolling }),
|
|
738
|
-
[scrollState, isHovering, isScrolling]
|
|
739
|
-
);
|
|
740
|
-
const configValue = useMemo(
|
|
760
|
+
const contextValue = useMemo(
|
|
741
761
|
() => ({
|
|
742
762
|
content,
|
|
743
763
|
orientation: staticConfig.orientation,
|
|
764
|
+
scrollState,
|
|
744
765
|
scrollbarMode: staticConfig.scrollbarMode,
|
|
745
766
|
hoverBoundary: staticConfig.hoverBoundary,
|
|
746
767
|
scrollbarX,
|
|
@@ -756,6 +777,9 @@ var ScrollAreaRoot = forwardRef(
|
|
|
756
777
|
variant: staticConfig.variant,
|
|
757
778
|
viewport,
|
|
758
779
|
type: staticConfig.type,
|
|
780
|
+
isHovering,
|
|
781
|
+
isScrolling,
|
|
782
|
+
// Add ID-related values
|
|
759
783
|
rootId,
|
|
760
784
|
viewportId,
|
|
761
785
|
scrollbarXId,
|
|
@@ -763,11 +787,14 @@ var ScrollAreaRoot = forwardRef(
|
|
|
763
787
|
}),
|
|
764
788
|
[
|
|
765
789
|
content,
|
|
790
|
+
scrollState,
|
|
766
791
|
scrollbarX,
|
|
767
792
|
scrollbarY,
|
|
768
793
|
thumbX,
|
|
769
794
|
thumbY,
|
|
770
795
|
viewport,
|
|
796
|
+
isHovering,
|
|
797
|
+
isScrolling,
|
|
771
798
|
staticConfig,
|
|
772
799
|
rootId,
|
|
773
800
|
viewportId,
|
|
@@ -832,7 +859,7 @@ var ScrollAreaRoot = forwardRef(
|
|
|
832
859
|
}
|
|
833
860
|
return scrollbars;
|
|
834
861
|
}, [orientation]);
|
|
835
|
-
return /* @__PURE__ */ jsx(
|
|
862
|
+
return /* @__PURE__ */ jsx(ScrollAreaContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs(
|
|
836
863
|
"div",
|
|
837
864
|
{
|
|
838
865
|
ref,
|
|
@@ -848,13 +875,13 @@ var ScrollAreaRoot = forwardRef(
|
|
|
848
875
|
autoScrollbars
|
|
849
876
|
]
|
|
850
877
|
}
|
|
851
|
-
) })
|
|
878
|
+
) });
|
|
852
879
|
}
|
|
853
880
|
);
|
|
854
881
|
ScrollAreaRoot.displayName = "ScrollArea.Root";
|
|
855
882
|
var ScrollAreaViewport = forwardRef(
|
|
856
883
|
({ className, children, ...props }, ref) => {
|
|
857
|
-
const { setViewport, orientation, viewportId } =
|
|
884
|
+
const { setViewport, orientation, viewportId } = useScrollAreaContext();
|
|
858
885
|
const scrollClass = useMemo(() => {
|
|
859
886
|
switch (orientation) {
|
|
860
887
|
case "horizontal":
|
|
@@ -891,7 +918,7 @@ var ScrollAreaViewport = forwardRef(
|
|
|
891
918
|
ScrollAreaViewport.displayName = "ScrollArea.Viewport";
|
|
892
919
|
var ScrollAreaContent = forwardRef(
|
|
893
920
|
({ as: As = "div", className, children, ...props }, ref) => {
|
|
894
|
-
const { setContent, orientation } =
|
|
921
|
+
const { setContent, orientation } = useScrollAreaContext();
|
|
895
922
|
const setRef = useCallback(
|
|
896
923
|
(node) => {
|
|
897
924
|
setContent(node);
|
|
@@ -2,10 +2,17 @@ import * as react from 'react';
|
|
|
2
2
|
|
|
3
3
|
type SeparatorOrientation = "horizontal" | "vertical";
|
|
4
4
|
interface SeparatorProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
/**
|
|
6
|
+
* Separator direction
|
|
7
|
+
* @default "horizontal"
|
|
8
|
+
*/
|
|
5
9
|
orientation?: SeparatorOrientation;
|
|
10
|
+
/**
|
|
11
|
+
* Whether to use decorative separator (not read by screen readers)
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
6
14
|
decorative?: boolean;
|
|
7
15
|
variant?: "default" | "light" | "dark" | "reset";
|
|
8
|
-
children?: React.ReactNode;
|
|
9
16
|
}
|
|
10
17
|
/**
|
|
11
18
|
* Separator - Separator component
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Allotment as Splitter, AllotmentHandle as SplitterHandle
|
|
1
|
+
export { AllotmentProps, Allotment as Splitter, AllotmentHandle as SplitterHandle } from 'allotment';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Description } from '../../description/src';
|
|
2
1
|
import { InputProps } from '../../input/src';
|
|
3
2
|
import { Label } from '../../label/src';
|
|
4
3
|
import { default as react__default, HTMLProps, ReactNode } from 'react';
|
|
@@ -11,11 +10,13 @@ interface FieldAddonProps extends HTMLProps<HTMLDivElement> {
|
|
|
11
10
|
}
|
|
12
11
|
declare const FieldAddon: react.MemoExoticComponent<react.ForwardRefExoticComponent<Omit<FieldAddonProps, "ref"> & react.RefAttributes<HTMLDivElement>>>;
|
|
13
12
|
|
|
13
|
+
declare const FieldDescription: react.MemoExoticComponent<react.ForwardRefExoticComponent<Omit<HTMLProps<HTMLDivElement>, "ref"> & react.RefAttributes<HTMLDivElement>>>;
|
|
14
|
+
|
|
14
15
|
interface TextFieldProps extends Omit<InputProps, "children"> {
|
|
15
16
|
children?: ReactNode;
|
|
16
17
|
}
|
|
17
18
|
interface TextFieldComponent extends react__default.ForwardRefExoticComponent<TextFieldProps & react__default.RefAttributes<HTMLInputElement>> {
|
|
18
|
-
Description: typeof
|
|
19
|
+
Description: typeof FieldDescription;
|
|
19
20
|
Label: typeof Label;
|
|
20
21
|
Prefix: typeof FieldAddon;
|
|
21
22
|
Suffix: typeof FieldAddon;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Description } from "../../description/dist/index.js";
|
|
2
1
|
import { Input } from "../../input/dist/index.js";
|
|
3
2
|
import { Label } from "../../label/dist/index.js";
|
|
4
|
-
import { forwardRef, Children, isValidElement, useId, cloneElement
|
|
3
|
+
import { forwardRef, memo, Children, isValidElement, useId, cloneElement } from "react";
|
|
5
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
5
|
import { tcv, tcx } from "../../../shared/utils/tcx/tcx.js";
|
|
7
6
|
var FieldAddon = memo(
|
|
@@ -18,6 +17,17 @@ var FieldAddon = memo(
|
|
|
18
17
|
})
|
|
19
18
|
);
|
|
20
19
|
FieldAddon.displayName = "FieldAddon";
|
|
20
|
+
var FieldDescription = memo(
|
|
21
|
+
forwardRef(function FieldDescription2(props, ref) {
|
|
22
|
+
return /* @__PURE__ */ jsx(
|
|
23
|
+
"div",
|
|
24
|
+
{
|
|
25
|
+
ref,
|
|
26
|
+
...props
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
})
|
|
30
|
+
);
|
|
21
31
|
var TextFieldTv = tcv({
|
|
22
32
|
slots: {
|
|
23
33
|
container: ["flex min-w-0 flex-col items-start gap-2"],
|
|
@@ -31,7 +41,12 @@ var TextFieldTv = tcv({
|
|
|
31
41
|
input: "[grid-area:input]",
|
|
32
42
|
prefix: "[grid-area:prefix]",
|
|
33
43
|
suffix: "[grid-area:suffix]",
|
|
34
|
-
description:
|
|
44
|
+
description: [
|
|
45
|
+
"text-body-medium mt-1",
|
|
46
|
+
"px-0.5",
|
|
47
|
+
"break-words whitespace-pre-wrap",
|
|
48
|
+
"text-secondary-foreground"
|
|
49
|
+
]
|
|
35
50
|
},
|
|
36
51
|
variants: {
|
|
37
52
|
variant: {
|
|
@@ -242,7 +257,7 @@ var TextField = Object.assign(TextFieldBase, {
|
|
|
242
257
|
Prefix: PrefixComponent,
|
|
243
258
|
Suffix: SuffixComponent,
|
|
244
259
|
Label,
|
|
245
|
-
Description
|
|
260
|
+
Description: FieldDescription
|
|
246
261
|
});
|
|
247
262
|
export {
|
|
248
263
|
TextField
|
|
@@ -10,7 +10,6 @@ interface TooltipProps {
|
|
|
10
10
|
className?: string;
|
|
11
11
|
content?: React.ReactNode;
|
|
12
12
|
disabled?: boolean;
|
|
13
|
-
interactive?: boolean;
|
|
14
13
|
offset?: number;
|
|
15
14
|
onOpenChange?: (open: boolean) => void;
|
|
16
15
|
open?: boolean;
|
|
@@ -24,7 +23,6 @@ interface TooltipProps {
|
|
|
24
23
|
withArrow?: boolean;
|
|
25
24
|
}
|
|
26
25
|
interface TooltipContentProps extends React.HTMLProps<HTMLDivElement> {
|
|
27
|
-
interactive?: boolean;
|
|
28
26
|
portalId?: string;
|
|
29
27
|
variant?: "default" | "light";
|
|
30
28
|
withArrow?: boolean;
|
|
@@ -128,15 +128,7 @@ var TooltipArrow = forwardRef(function TooltipArrow2({ className, variant = "def
|
|
|
128
128
|
});
|
|
129
129
|
var TooltipContent = forwardRef(
|
|
130
130
|
function TooltipContent2(props, propRef) {
|
|
131
|
-
const {
|
|
132
|
-
className,
|
|
133
|
-
withArrow = true,
|
|
134
|
-
variant = "default",
|
|
135
|
-
children,
|
|
136
|
-
portalId,
|
|
137
|
-
interactive = true,
|
|
138
|
-
...rest
|
|
139
|
-
} = props;
|
|
131
|
+
const { className, withArrow = true, variant = "default", children, portalId, ...rest } = props;
|
|
140
132
|
const state = useTooltipState();
|
|
141
133
|
const ref = useMergeRefs([state.refs.setFloating, propRef]);
|
|
142
134
|
const { isInstantPhase, currentId } = useDelayGroup(state.context, {
|
|
@@ -165,27 +157,19 @@ var TooltipContent = forwardRef(
|
|
|
165
157
|
});
|
|
166
158
|
const tv = useMemo(() => tooltipContentVariants({ variant }), [variant]);
|
|
167
159
|
if (state.disabled || !isMounted) return null;
|
|
168
|
-
const floatingProps = state.getFloatingProps(rest);
|
|
169
160
|
return /* @__PURE__ */ jsx(FloatingPortal, { id: portalId, children: /* @__PURE__ */ jsx(
|
|
170
161
|
"div",
|
|
171
162
|
{
|
|
172
163
|
ref,
|
|
173
|
-
style:
|
|
174
|
-
|
|
175
|
-
pointerEvents: interactive ? void 0 : "none"
|
|
176
|
-
},
|
|
177
|
-
...floatingProps,
|
|
164
|
+
style: state.floatingStyles,
|
|
165
|
+
...state.getFloatingProps(rest),
|
|
178
166
|
className: "z-tooltip",
|
|
179
167
|
children: /* @__PURE__ */ jsxs(
|
|
180
168
|
"div",
|
|
181
169
|
{
|
|
182
170
|
className: tcx(tv.root({ className })),
|
|
183
171
|
"data-state": state.open ? "open" : "closed",
|
|
184
|
-
style:
|
|
185
|
-
...styles,
|
|
186
|
-
pointerEvents: interactive ? void 0 : "none",
|
|
187
|
-
cursor: interactive ? void 0 : "default"
|
|
188
|
-
},
|
|
172
|
+
style: styles,
|
|
189
173
|
children: [
|
|
190
174
|
children,
|
|
191
175
|
withArrow && /* @__PURE__ */ jsx(TooltipArrow, { variant })
|
|
@@ -288,8 +272,7 @@ function TooltipRoot(props) {
|
|
|
288
272
|
withArrow = true,
|
|
289
273
|
variant = "default",
|
|
290
274
|
offset: offset2 = 8,
|
|
291
|
-
portalId = PORTAL_ROOT_ID
|
|
292
|
-
interactive = true
|
|
275
|
+
portalId = PORTAL_ROOT_ID
|
|
293
276
|
} = props;
|
|
294
277
|
const tooltip = useTooltip({
|
|
295
278
|
placement,
|
|
@@ -308,7 +291,6 @@ function TooltipRoot(props) {
|
|
|
308
291
|
variant,
|
|
309
292
|
portalId,
|
|
310
293
|
className,
|
|
311
|
-
interactive,
|
|
312
294
|
children: [
|
|
313
295
|
content,
|
|
314
296
|
shortcut && /* @__PURE__ */ jsx(
|
package/package.json
CHANGED