@nick-skriabin/glyph 0.1.8 → 0.1.10
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/index.cjs +15 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +15 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1984,7 +1984,8 @@ function Input(props) {
|
|
|
1984
1984
|
placeholder,
|
|
1985
1985
|
style,
|
|
1986
1986
|
focusedStyle,
|
|
1987
|
-
multiline
|
|
1987
|
+
multiline,
|
|
1988
|
+
autoFocus
|
|
1988
1989
|
} = props;
|
|
1989
1990
|
const [internalValue, setInternalValue] = React15.useState(defaultValue);
|
|
1990
1991
|
const [cursorPos, setCursorPos] = React15.useState(defaultValue.length);
|
|
@@ -2035,6 +2036,16 @@ function Input(props) {
|
|
|
2035
2036
|
if (!focusCtx || !focusIdRef.current || !nodeRef.current) return;
|
|
2036
2037
|
return focusCtx.register(focusIdRef.current, nodeRef.current);
|
|
2037
2038
|
}, [focusCtx]);
|
|
2039
|
+
const autoFocusedRef = React15.useRef(false);
|
|
2040
|
+
React15.useEffect(() => {
|
|
2041
|
+
if (autoFocus && !autoFocusedRef.current && focusCtx && focusIdRef.current) {
|
|
2042
|
+
autoFocusedRef.current = true;
|
|
2043
|
+
const fid = focusIdRef.current;
|
|
2044
|
+
queueMicrotask(() => {
|
|
2045
|
+
focusCtx.requestFocus(fid);
|
|
2046
|
+
});
|
|
2047
|
+
}
|
|
2048
|
+
}, [autoFocus, focusCtx]);
|
|
2038
2049
|
React15.useEffect(() => {
|
|
2039
2050
|
if (!focusCtx || !focusIdRef.current) return;
|
|
2040
2051
|
const fid = focusIdRef.current;
|
|
@@ -2459,6 +2470,7 @@ function ScrollView({
|
|
|
2459
2470
|
const viewportHeight = viewportLayout.innerHeight;
|
|
2460
2471
|
const contentHeight = contentLayout.height;
|
|
2461
2472
|
const maxOffset = Math.max(0, contentHeight - viewportHeight);
|
|
2473
|
+
const effectiveOffset = Math.max(0, Math.min(offset, maxOffset));
|
|
2462
2474
|
const setOffset = React15.useCallback(
|
|
2463
2475
|
(next) => {
|
|
2464
2476
|
const clamped = Math.max(0, Math.min(next, maxOffset));
|
|
@@ -2563,7 +2575,7 @@ function ScrollView({
|
|
|
2563
2575
|
};
|
|
2564
2576
|
const innerStyle = {
|
|
2565
2577
|
position: "absolute",
|
|
2566
|
-
top: -
|
|
2578
|
+
top: -effectiveOffset,
|
|
2567
2579
|
left: 0,
|
|
2568
2580
|
right: 0,
|
|
2569
2581
|
flexDirection: "column",
|
|
@@ -2579,7 +2591,7 @@ function ScrollView({
|
|
|
2579
2591
|
const scrollbarVisible = showScrollbar && isScrollable;
|
|
2580
2592
|
const thumbHeight = Math.max(1, Math.floor(viewportHeight / contentHeight * viewportHeight));
|
|
2581
2593
|
const scrollableRange = contentHeight - viewportHeight;
|
|
2582
|
-
const thumbPosition = scrollableRange > 0 ? Math.floor(
|
|
2594
|
+
const thumbPosition = scrollableRange > 0 ? Math.floor(effectiveOffset / scrollableRange * (viewportHeight - thumbHeight)) : 0;
|
|
2583
2595
|
const scrollbarChars = [];
|
|
2584
2596
|
if (scrollbarVisible) {
|
|
2585
2597
|
for (let i = 0; i < viewportHeight; i++) {
|