@vellira-ui/react-native 2.94.0 → 2.95.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.
Files changed (2) hide show
  1. package/dist/index.js +86 -65
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -740,57 +740,60 @@ function useThemeStyles(createStyles) {
740
740
  }
741
741
  //#endregion
742
742
  //#region src/components/Accordion/Accordion.styles.ts
743
- const createStyles$23 = (theme) => StyleSheet.create({
744
- root: {
745
- width: "100%",
746
- overflow: "hidden",
747
- borderWidth: 1,
748
- borderColor: theme.semantic.border.muted,
749
- borderRadius: theme.tokens.radius.lg,
750
- backgroundColor: theme.semantic.surface.default
751
- },
752
- rootDisabled: { opacity: .7 },
753
- item: {
754
- borderBottomWidth: 1,
755
- borderBottomColor: theme.semantic.border.muted
756
- },
757
- trigger: {
758
- minHeight: theme.tokens.spacing[10],
759
- justifyContent: "center",
760
- paddingHorizontal: theme.tokens.spacing[4],
761
- paddingVertical: theme.tokens.spacing[3],
762
- backgroundColor: theme.semantic.surface.default
763
- },
764
- triggerExpanded: { backgroundColor: theme.semantic.surface.subtle },
765
- triggerPressed: { backgroundColor: theme.semantic.surface.muted },
766
- triggerDisabled: { backgroundColor: theme.semantic.surface.subtle },
767
- triggerContent: {
768
- flexDirection: "row",
769
- alignItems: "center",
770
- justifyContent: "space-between",
771
- gap: theme.tokens.spacing[3]
772
- },
773
- triggerText: {
774
- flex: 1,
775
- color: theme.semantic.text.primary,
776
- fontSize: theme.tokens.typography.size.md,
777
- fontWeight: theme.tokens.typography.weight.medium,
778
- lineHeight: theme.tokens.typography.lineHeight.md
779
- },
780
- triggerTextDisabled: { color: theme.semantic.text.disabled },
781
- indicator: {
782
- width: theme.tokens.spacing[4],
783
- height: theme.tokens.spacing[4],
784
- alignItems: "center",
785
- justifyContent: "center"
786
- },
787
- indicatorExpanded: { transform: [{ rotate: "180deg" }] },
788
- content: {
789
- padding: theme.tokens.spacing[4],
790
- backgroundColor: theme.semantic.surface.subtle
791
- },
792
- contentHidden: { display: "none" }
793
- });
743
+ const createStyles$23 = (theme) => {
744
+ const accordion = theme.components.accordion;
745
+ return StyleSheet.create({
746
+ root: {
747
+ width: "100%",
748
+ overflow: "hidden",
749
+ borderWidth: 1,
750
+ borderColor: accordion.root.border,
751
+ borderRadius: theme.tokens.radius.lg,
752
+ backgroundColor: accordion.root.bg
753
+ },
754
+ rootDisabled: { opacity: .7 },
755
+ item: {
756
+ borderBottomWidth: 1,
757
+ borderBottomColor: accordion.divider
758
+ },
759
+ trigger: {
760
+ minHeight: theme.tokens.spacing[10],
761
+ justifyContent: "center",
762
+ paddingHorizontal: theme.tokens.spacing[4],
763
+ paddingVertical: theme.tokens.spacing[3],
764
+ backgroundColor: accordion.trigger.default.bg
765
+ },
766
+ triggerExpanded: { backgroundColor: accordion.trigger.expanded.bg },
767
+ triggerPressed: { backgroundColor: accordion.trigger.pressed.bg },
768
+ triggerDisabled: { backgroundColor: accordion.trigger.disabled.bg },
769
+ triggerContent: {
770
+ flexDirection: "row",
771
+ alignItems: "center",
772
+ justifyContent: "space-between",
773
+ gap: theme.tokens.spacing[3]
774
+ },
775
+ triggerText: {
776
+ flex: 1,
777
+ color: accordion.trigger.default.fg,
778
+ fontSize: theme.tokens.typography.size.md,
779
+ fontWeight: theme.tokens.typography.weight.medium,
780
+ lineHeight: theme.tokens.typography.lineHeight.md
781
+ },
782
+ triggerTextDisabled: { color: accordion.trigger.disabled.fg },
783
+ indicator: {
784
+ width: theme.tokens.spacing[4],
785
+ height: theme.tokens.spacing[4],
786
+ alignItems: "center",
787
+ justifyContent: "center"
788
+ },
789
+ indicatorExpanded: { transform: [{ rotate: "180deg" }] },
790
+ content: {
791
+ padding: theme.tokens.spacing[4],
792
+ backgroundColor: accordion.content.bg
793
+ },
794
+ contentHidden: { display: "none" }
795
+ });
796
+ };
794
797
  //#endregion
795
798
  //#region src/components/Accordion/Content/AccordionContent.tsx
796
799
  function AccordionContent({ children, forceMount = false, hidden = false }) {
@@ -817,6 +820,7 @@ function AccordionItem({ children }) {
817
820
  function AccordionTrigger({ children, disabled = false, expanded = false, onActivate }) {
818
821
  const { theme } = useTheme();
819
822
  const styles = createStyles$23(theme);
823
+ const accordionTokens = theme.components.accordion;
820
824
  return /* @__PURE__ */ jsx(Pressable, {
821
825
  disabled,
822
826
  accessibilityRole: "button",
@@ -844,7 +848,7 @@ function AccordionTrigger({ children, disabled = false, expanded = false, onActi
844
848
  children: /* @__PURE__ */ jsx(ChevronDown, {
845
849
  width: 16,
846
850
  height: 16,
847
- color: disabled ? theme.semantic.text.disabled : theme.semantic.text.secondary
851
+ color: disabled ? accordionTokens.trigger.disabled.fg : accordionTokens.indicator
848
852
  })
849
853
  })]
850
854
  })
@@ -857,8 +861,14 @@ function AccordionRoot({ children, type = "single", value, defaultValue, onValue
857
861
  const styles = createStyles$23(theme);
858
862
  const isControlled = value !== void 0;
859
863
  const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue ?? (type === "multiple" ? [] : ""));
860
- const selectedValues = (isControlled ? value : uncontrolledValue) ?? [];
861
- const expandedValues = Array.isArray(selectedValues) ? selectedValues : selectedValues ? [selectedValues] : [];
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
+ ]);
862
872
  const selectValue = useCallback((itemValue) => {
863
873
  if (disabled) return;
864
874
  const isExpanded = expandedValues.includes(itemValue);
@@ -917,6 +927,7 @@ const useDropdownContext = () => {
917
927
  DropdownContext.displayName = "DropdownContext";
918
928
  //#endregion
919
929
  //#region src/components/Dropdown/Content/DropdownContent.styles.ts
930
+ const getDropdownBackdropBackgroundColor = (theme, presentation) => presentation === "popover" ? "transparent" : theme.semantic.overlay.backdrop;
920
931
  const createStyles$22 = (theme) => StyleSheet.create({
921
932
  modalRoot: { flex: 1 },
922
933
  sheet: { justifyContent: "flex-end" },
@@ -926,10 +937,7 @@ const createStyles$22 = (theme) => StyleSheet.create({
926
937
  padding: theme.tokens.spacing[4]
927
938
  },
928
939
  popover: { flex: 1 },
929
- backdrop: {
930
- ...StyleSheet.absoluteFill,
931
- backgroundColor: theme.semantic.overlay.backdrop
932
- },
940
+ backdrop: { ...StyleSheet.absoluteFill },
933
941
  menu: {
934
942
  maxHeight: "50%",
935
943
  overflow: "hidden",
@@ -1001,7 +1009,7 @@ const createStyles$22 = (theme) => StyleSheet.create({
1001
1009
  const nativePointerEventsBoxNone$1 = Platform.OS === "web" ? void 0 : { pointerEvents: "box-none" };
1002
1010
  const webPointerEventsBoxNone$1 = Platform.OS === "web" ? { pointerEvents: "box-none" } : void 0;
1003
1011
  function DropdownContent({ children, contentStyle, accessibilityLabel }) {
1004
- 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();
1005
1013
  const { theme } = useTheme();
1006
1014
  const styles = useThemeStyles(createStyles$22);
1007
1015
  const colorPalette = theme.components.dropdown[color];
@@ -1017,11 +1025,12 @@ function DropdownContent({ children, contentStyle, accessibilityLabel }) {
1017
1025
  };
1018
1026
  }, []);
1019
1027
  useEffect(() => {
1028
+ if (Platform.OS === "web") return;
1020
1029
  if (!open) {
1021
1030
  animation.setValue(0);
1022
1031
  return;
1023
1032
  }
1024
- if (reduceMotion || Platform.OS === "web") {
1033
+ if (reduceMotion) {
1025
1034
  animation.setValue(1);
1026
1035
  return;
1027
1036
  }
@@ -1037,11 +1046,15 @@ function DropdownContent({ children, contentStyle, accessibilityLabel }) {
1037
1046
  isSheet,
1038
1047
  reduceMotion
1039
1048
  ]);
1040
- const backdropAnimatedStyle = useMemo(() => ({ opacity: animation.interpolate({
1041
- inputRange: [0, 1],
1042
- outputRange: [0, 1]
1043
- }) }), [animation]);
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]);
1044
1056
  const menuAnimatedStyle = useMemo(() => {
1057
+ if (Platform.OS === "web") return;
1045
1058
  const translateY = animation.interpolate({
1046
1059
  inputRange: [0, 1],
1047
1060
  outputRange: isSheet ? [24, 0] : [-6, 0]
@@ -1070,6 +1083,7 @@ function DropdownContent({ children, contentStyle, accessibilityLabel }) {
1070
1083
  ...nativePointerEventsBoxNone$1,
1071
1084
  style: [
1072
1085
  styles.backdrop,
1086
+ { backgroundColor: getDropdownBackdropBackgroundColor(theme, presentation) },
1073
1087
  backdropAnimatedStyle,
1074
1088
  webPointerEventsBoxNone$1
1075
1089
  ],
@@ -1083,6 +1097,7 @@ function DropdownContent({ children, contentStyle, accessibilityLabel }) {
1083
1097
  style: [
1084
1098
  styles.menu,
1085
1099
  styles[`${presentation}Menu`],
1100
+ isPopover && !positionReady && { opacity: 0 },
1086
1101
  { borderColor: colorPalette.content.border },
1087
1102
  isPopover && {
1088
1103
  position: "absolute",
@@ -1421,6 +1436,7 @@ function computeFloatingPosition({ reference, floating, boundary, placement, off
1421
1436
  //#endregion
1422
1437
  //#region src/managers/FloatingManager/useNativeFloatingPosition.ts
1423
1438
  function useNativeFloatingPosition(placement = "top", offset = 8) {
1439
+ const [isPositioned, setIsPositioned] = useState(false);
1424
1440
  const [result, setResult] = useState({
1425
1441
  position: {
1426
1442
  top: 0,
@@ -1441,6 +1457,7 @@ function useNativeFloatingPosition(placement = "top", offset = 8) {
1441
1457
  const triggerNode = triggerRef.current;
1442
1458
  const containerNode = containerRef?.current;
1443
1459
  if (!triggerNode || typeof triggerNode.measureInWindow !== "function") {
1460
+ setIsPositioned(false);
1444
1461
  setResult((current) => ({
1445
1462
  ...current,
1446
1463
  position: {
@@ -1468,6 +1485,7 @@ function useNativeFloatingPosition(placement = "top", offset = 8) {
1468
1485
  offset
1469
1486
  });
1470
1487
  setResult(nextResult);
1488
+ setIsPositioned(measuredSize.width > 0 && measuredSize.height > 0);
1471
1489
  };
1472
1490
  if (!containerNode || typeof containerNode.measureInWindow !== "function") {
1473
1491
  const window = Dimensions.get("window");
@@ -1489,6 +1507,7 @@ function useNativeFloatingPosition(placement = "top", offset = 8) {
1489
1507
  if (lastTriggerRef.current) updatePosition(lastTriggerRef.current, lastContainerRef.current ?? void 0, nextSize);
1490
1508
  }, [updatePosition]);
1491
1509
  return {
1510
+ isPositioned,
1492
1511
  position: result.position,
1493
1512
  arrowPosition: result.arrowPosition,
1494
1513
  placement: result.placement,
@@ -1890,7 +1909,7 @@ function DropdownRoot({ children, label = "Menu", trigger, icon, arrowIcon, show
1890
1909
  const resolvedPresentation = useOverlayPresentation(presentation);
1891
1910
  const contentStyleFromSlot = parsed.contentProps?.style;
1892
1911
  const contentPresentation = (parsed.contentProps?.presentation === "auto" ? void 0 : parsed.contentProps?.presentation) ?? resolvedPresentation;
1893
- const { position, updatePosition, onFloatingLayout } = useNativeFloatingPosition(placement, offset);
1912
+ const { isPositioned: positionReady, position, updatePosition, onFloatingLayout } = useNativeFloatingPosition(placement, offset);
1894
1913
  const { isOpen, closeDropdown, toggleDropdown } = useDropdown({
1895
1914
  items: navigableItems,
1896
1915
  open,
@@ -1972,6 +1991,7 @@ function DropdownRoot({ children, label = "Menu", trigger, icon, arrowIcon, show
1972
1991
  color,
1973
1992
  size,
1974
1993
  presentation: contentPresentation,
1994
+ positionReady,
1975
1995
  position,
1976
1996
  zIndex: dismiss.zIndex,
1977
1997
  searchable: isSearchable,
@@ -2000,6 +2020,7 @@ function DropdownRoot({ children, label = "Menu", trigger, icon, arrowIcon, show
2000
2020
  loading,
2001
2021
  onFloatingLayout,
2002
2022
  position,
2023
+ positionReady,
2003
2024
  resolvedSearchPlaceholder,
2004
2025
  resolvedSearchValue,
2005
2026
  searchAccessibilityLabel,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellira-ui/react-native",
3
- "version": "2.94.0",
3
+ "version": "2.95.1",
4
4
  "description": "React Native components for Vellira Design System",
5
5
  "keywords": [
6
6
  "vellira",