@vellira-ui/react-native 2.95.0 → 2.95.2
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.js +30 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -861,8 +861,14 @@ function AccordionRoot({ children, type = "single", value, defaultValue, onValue
|
|
|
861
861
|
const styles = createStyles$23(theme);
|
|
862
862
|
const isControlled = value !== void 0;
|
|
863
863
|
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue ?? (type === "multiple" ? [] : ""));
|
|
864
|
-
const
|
|
865
|
-
|
|
864
|
+
const expandedValues = useMemo(() => {
|
|
865
|
+
const selectedValues = (isControlled ? value : uncontrolledValue) ?? [];
|
|
866
|
+
return Array.isArray(selectedValues) ? selectedValues : selectedValues ? [selectedValues] : [];
|
|
867
|
+
}, [
|
|
868
|
+
isControlled,
|
|
869
|
+
uncontrolledValue,
|
|
870
|
+
value
|
|
871
|
+
]);
|
|
866
872
|
const selectValue = useCallback((itemValue) => {
|
|
867
873
|
if (disabled) return;
|
|
868
874
|
const isExpanded = expandedValues.includes(itemValue);
|
|
@@ -921,6 +927,7 @@ const useDropdownContext = () => {
|
|
|
921
927
|
DropdownContext.displayName = "DropdownContext";
|
|
922
928
|
//#endregion
|
|
923
929
|
//#region src/components/Dropdown/Content/DropdownContent.styles.ts
|
|
930
|
+
const getDropdownBackdropBackgroundColor = (theme, presentation) => presentation === "popover" ? "transparent" : theme.semantic.overlay.backdrop;
|
|
924
931
|
const createStyles$22 = (theme) => StyleSheet.create({
|
|
925
932
|
modalRoot: { flex: 1 },
|
|
926
933
|
sheet: { justifyContent: "flex-end" },
|
|
@@ -930,10 +937,7 @@ const createStyles$22 = (theme) => StyleSheet.create({
|
|
|
930
937
|
padding: theme.tokens.spacing[4]
|
|
931
938
|
},
|
|
932
939
|
popover: { flex: 1 },
|
|
933
|
-
backdrop: {
|
|
934
|
-
...StyleSheet.absoluteFill,
|
|
935
|
-
backgroundColor: theme.semantic.overlay.backdrop
|
|
936
|
-
},
|
|
940
|
+
backdrop: { ...StyleSheet.absoluteFill },
|
|
937
941
|
menu: {
|
|
938
942
|
maxHeight: "50%",
|
|
939
943
|
overflow: "hidden",
|
|
@@ -1005,7 +1009,7 @@ const createStyles$22 = (theme) => StyleSheet.create({
|
|
|
1005
1009
|
const nativePointerEventsBoxNone$1 = Platform.OS === "web" ? void 0 : { pointerEvents: "box-none" };
|
|
1006
1010
|
const webPointerEventsBoxNone$1 = Platform.OS === "web" ? { pointerEvents: "box-none" } : void 0;
|
|
1007
1011
|
function DropdownContent({ children, contentStyle, accessibilityLabel }) {
|
|
1008
|
-
const { open, color, presentation, zIndex, position, searchable, searchValue, searchPlaceholder, searchAccessibilityLabel, requestClose, getOutsidePressProps, onSearchChange, onFloatingLayout } = useDropdownContext();
|
|
1012
|
+
const { open, color, presentation, positionReady, zIndex, position, searchable, searchValue, searchPlaceholder, searchAccessibilityLabel, requestClose, getOutsidePressProps, onSearchChange, onFloatingLayout } = useDropdownContext();
|
|
1009
1013
|
const { theme } = useTheme();
|
|
1010
1014
|
const styles = useThemeStyles(createStyles$22);
|
|
1011
1015
|
const colorPalette = theme.components.dropdown[color];
|
|
@@ -1021,11 +1025,12 @@ function DropdownContent({ children, contentStyle, accessibilityLabel }) {
|
|
|
1021
1025
|
};
|
|
1022
1026
|
}, []);
|
|
1023
1027
|
useEffect(() => {
|
|
1028
|
+
if (Platform.OS === "web") return;
|
|
1024
1029
|
if (!open) {
|
|
1025
1030
|
animation.setValue(0);
|
|
1026
1031
|
return;
|
|
1027
1032
|
}
|
|
1028
|
-
if (reduceMotion
|
|
1033
|
+
if (reduceMotion) {
|
|
1029
1034
|
animation.setValue(1);
|
|
1030
1035
|
return;
|
|
1031
1036
|
}
|
|
@@ -1041,11 +1046,15 @@ function DropdownContent({ children, contentStyle, accessibilityLabel }) {
|
|
|
1041
1046
|
isSheet,
|
|
1042
1047
|
reduceMotion
|
|
1043
1048
|
]);
|
|
1044
|
-
const backdropAnimatedStyle = useMemo(() =>
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1049
|
+
const backdropAnimatedStyle = useMemo(() => {
|
|
1050
|
+
if (Platform.OS === "web") return;
|
|
1051
|
+
return { opacity: animation.interpolate({
|
|
1052
|
+
inputRange: [0, 1],
|
|
1053
|
+
outputRange: [0, 1]
|
|
1054
|
+
}) };
|
|
1055
|
+
}, [animation]);
|
|
1048
1056
|
const menuAnimatedStyle = useMemo(() => {
|
|
1057
|
+
if (Platform.OS === "web") return;
|
|
1049
1058
|
const translateY = animation.interpolate({
|
|
1050
1059
|
inputRange: [0, 1],
|
|
1051
1060
|
outputRange: isSheet ? [24, 0] : [-6, 0]
|
|
@@ -1074,6 +1083,7 @@ function DropdownContent({ children, contentStyle, accessibilityLabel }) {
|
|
|
1074
1083
|
...nativePointerEventsBoxNone$1,
|
|
1075
1084
|
style: [
|
|
1076
1085
|
styles.backdrop,
|
|
1086
|
+
{ backgroundColor: getDropdownBackdropBackgroundColor(theme, presentation) },
|
|
1077
1087
|
backdropAnimatedStyle,
|
|
1078
1088
|
webPointerEventsBoxNone$1
|
|
1079
1089
|
],
|
|
@@ -1087,6 +1097,7 @@ function DropdownContent({ children, contentStyle, accessibilityLabel }) {
|
|
|
1087
1097
|
style: [
|
|
1088
1098
|
styles.menu,
|
|
1089
1099
|
styles[`${presentation}Menu`],
|
|
1100
|
+
isPopover && !positionReady && { opacity: 0 },
|
|
1090
1101
|
{ borderColor: colorPalette.content.border },
|
|
1091
1102
|
isPopover && {
|
|
1092
1103
|
position: "absolute",
|
|
@@ -1425,6 +1436,7 @@ function computeFloatingPosition({ reference, floating, boundary, placement, off
|
|
|
1425
1436
|
//#endregion
|
|
1426
1437
|
//#region src/managers/FloatingManager/useNativeFloatingPosition.ts
|
|
1427
1438
|
function useNativeFloatingPosition(placement = "top", offset = 8) {
|
|
1439
|
+
const [isPositioned, setIsPositioned] = useState(false);
|
|
1428
1440
|
const [result, setResult] = useState({
|
|
1429
1441
|
position: {
|
|
1430
1442
|
top: 0,
|
|
@@ -1445,6 +1457,7 @@ function useNativeFloatingPosition(placement = "top", offset = 8) {
|
|
|
1445
1457
|
const triggerNode = triggerRef.current;
|
|
1446
1458
|
const containerNode = containerRef?.current;
|
|
1447
1459
|
if (!triggerNode || typeof triggerNode.measureInWindow !== "function") {
|
|
1460
|
+
setIsPositioned(false);
|
|
1448
1461
|
setResult((current) => ({
|
|
1449
1462
|
...current,
|
|
1450
1463
|
position: {
|
|
@@ -1472,6 +1485,7 @@ function useNativeFloatingPosition(placement = "top", offset = 8) {
|
|
|
1472
1485
|
offset
|
|
1473
1486
|
});
|
|
1474
1487
|
setResult(nextResult);
|
|
1488
|
+
setIsPositioned(measuredSize.width > 0 && measuredSize.height > 0);
|
|
1475
1489
|
};
|
|
1476
1490
|
if (!containerNode || typeof containerNode.measureInWindow !== "function") {
|
|
1477
1491
|
const window = Dimensions.get("window");
|
|
@@ -1493,6 +1507,7 @@ function useNativeFloatingPosition(placement = "top", offset = 8) {
|
|
|
1493
1507
|
if (lastTriggerRef.current) updatePosition(lastTriggerRef.current, lastContainerRef.current ?? void 0, nextSize);
|
|
1494
1508
|
}, [updatePosition]);
|
|
1495
1509
|
return {
|
|
1510
|
+
isPositioned,
|
|
1496
1511
|
position: result.position,
|
|
1497
1512
|
arrowPosition: result.arrowPosition,
|
|
1498
1513
|
placement: result.placement,
|
|
@@ -1894,7 +1909,7 @@ function DropdownRoot({ children, label = "Menu", trigger, icon, arrowIcon, show
|
|
|
1894
1909
|
const resolvedPresentation = useOverlayPresentation(presentation);
|
|
1895
1910
|
const contentStyleFromSlot = parsed.contentProps?.style;
|
|
1896
1911
|
const contentPresentation = (parsed.contentProps?.presentation === "auto" ? void 0 : parsed.contentProps?.presentation) ?? resolvedPresentation;
|
|
1897
|
-
const { position, updatePosition, onFloatingLayout } = useNativeFloatingPosition(placement, offset);
|
|
1912
|
+
const { isPositioned: positionReady, position, updatePosition, onFloatingLayout } = useNativeFloatingPosition(placement, offset);
|
|
1898
1913
|
const { isOpen, closeDropdown, toggleDropdown } = useDropdown({
|
|
1899
1914
|
items: navigableItems,
|
|
1900
1915
|
open,
|
|
@@ -1976,6 +1991,7 @@ function DropdownRoot({ children, label = "Menu", trigger, icon, arrowIcon, show
|
|
|
1976
1991
|
color,
|
|
1977
1992
|
size,
|
|
1978
1993
|
presentation: contentPresentation,
|
|
1994
|
+
positionReady,
|
|
1979
1995
|
position,
|
|
1980
1996
|
zIndex: dismiss.zIndex,
|
|
1981
1997
|
searchable: isSearchable,
|
|
@@ -2004,6 +2020,7 @@ function DropdownRoot({ children, label = "Menu", trigger, icon, arrowIcon, show
|
|
|
2004
2020
|
loading,
|
|
2005
2021
|
onFloatingLayout,
|
|
2006
2022
|
position,
|
|
2023
|
+
positionReady,
|
|
2007
2024
|
resolvedSearchPlaceholder,
|
|
2008
2025
|
resolvedSearchValue,
|
|
2009
2026
|
searchAccessibilityLabel,
|