@thewhileloop/whileui 4.1.2 → 4.2.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/README.md +2 -1
- package/dist/components/select/select.js +7 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1490,7 +1490,8 @@ itself to the collision-available viewport, and wraps long option labels inside
|
|
|
1490
1490
|
| blurTintToken | `'surfaceElevated' \| 'surfaceTranslucent' \| 'card' \| 'popover'` | `'popover'` |
|
|
1491
1491
|
|
|
1492
1492
|
`SelectContent` keeps its listbox inside the safe area by default; pass `insets` only to
|
|
1493
|
-
change that margin.
|
|
1493
|
+
change that margin. A list taller than the screen scrolls inside the listbox on every
|
|
1494
|
+
platform. Inside a Dialog, Sheet or other WhileUI overlay it renders in that
|
|
1494
1495
|
overlay's layer automatically. Option values must be non-empty strings: the web
|
|
1495
1496
|
primitive rejects `""`, so model "none" as an explicit value such as `'none'`.
|
|
1496
1497
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { Platform, ScrollView, StyleSheet, View, } from 'react-native';
|
|
3
|
+
import { Platform, ScrollView, StyleSheet, useWindowDimensions, View, } from 'react-native';
|
|
4
4
|
import * as SelectPrimitive from '@rn-primitives/select';
|
|
5
5
|
import { FullWindowOverlay as RNFullWindowOverlay } from 'react-native-screens';
|
|
6
6
|
import { Text } from '../text';
|
|
@@ -68,6 +68,11 @@ const SelectContent = React.forwardRef(({ className, children, portalHost, posit
|
|
|
68
68
|
// without every caller reading the safe area itself.
|
|
69
69
|
const defaultInsets = useOverlayInsets();
|
|
70
70
|
const resolvedInsets = { ...defaultInsets, ...insets };
|
|
71
|
+
// Web caps the listbox with the primitive's available-height variable. Native has
|
|
72
|
+
// no equivalent: a list longer than the screen ran under the status bar with
|
|
73
|
+
// nothing to scroll, so the options get a scroll owner bounded by the insets.
|
|
74
|
+
const { height: windowHeight } = useWindowDimensions();
|
|
75
|
+
const nativeMaxHeight = windowHeight - resolvedInsets.top - resolvedInsets.bottom;
|
|
71
76
|
// Radix applies its collision variables to the listbox wrapper, while
|
|
72
77
|
// @rn-primitives renders our visual surface one level inside it. Keep the sizing
|
|
73
78
|
// on that surface as inline web CSS: the Viewport's own `width: 100%` otherwise
|
|
@@ -94,7 +99,7 @@ const SelectContent = React.forwardRef(({ className, children, portalHost, posit
|
|
|
94
99
|
}, className: cn('border-border relative z-50 overflow-hidden', frosted ? 'bg-transparent' : 'bg-popover', Platform.select({
|
|
95
100
|
web: cn('overflow-y-auto overflow-x-hidden', props.side === 'bottom' && 'translate-y-1', props.side === 'top' && '-translate-y-1'),
|
|
96
101
|
native: 'p-1',
|
|
97
|
-
}), className), ...props, children: [frostedSurface.overlay, _jsx(SelectPrimitive.Viewport, { className: "p-1", children: children })] }) }) }) }));
|
|
102
|
+
}), className), ...props, children: [frostedSurface.overlay, _jsx(SelectPrimitive.Viewport, { className: "p-1", children: Platform.OS === 'web' ? (children) : (_jsx(ScrollView, { style: { maxHeight: nativeMaxHeight }, bounces: false, keyboardShouldPersistTaps: "handled", children: children })) })] }) }) }) }));
|
|
98
103
|
});
|
|
99
104
|
SelectContent.displayName = 'SelectContent';
|
|
100
105
|
const SelectItem = React.forwardRef(({ className, children, style: styleProp, ...props }, ref) => {
|