Skip to content

Commit

Permalink
Merge pull request #2279 from gluestack/main
Browse files Browse the repository at this point in the history
Backmerge Main -> Patch
  • Loading branch information
Viraj-10 authored Jul 9, 2024
2 parents 11459a6 + dd90283 commit 3c9709c
Show file tree
Hide file tree
Showing 18 changed files with 126 additions and 67 deletions.
6 changes: 3 additions & 3 deletions example/storybook-nativewind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
"@expo/webpack-config": "^0.17.2",
"@geometricpanda/storybook-addon-iframe": "^0.2.2",
"@gluestack-style/animation-resolver": "^1.0.4",
"@gluestack-style/react": "^1.0.56",
"@gluestack-style/react": "^1.0.57",
"@gluestack-ui/config": "^1.1.19",
"@gluestack-ui/themed": "^1.1.33",
"@gluestack-ui/themed": "^1.1.34",
"@gluestack/design-system": "^0.5.36",
"@gorhom/bottom-sheet": "^5.0.0-alpha.10",
"@legendapp/motion": "^2.2.0",
Expand All @@ -44,7 +44,7 @@
"@react-aria/separator": "^3.3.0",
"@react-aria/utils": "^3.15.0",
"@react-native-aria/button": "^0.2.7",
"@react-native-aria/overlays": "^0.3.12",
"@react-native-aria/overlays": "^0.3.14",
"@react-native-aria/separator": "^0.2.6",
"@react-native-async-storage/async-storage": "~1.17.3",
"@react-native-community/datetimepicker": "6.5.2",
Expand Down
2 changes: 1 addition & 1 deletion example/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@react-aria/separator": "^3.3.0",
"@react-aria/utils": "^3.15.0",
"@react-native-aria/button": "^0.2.7",
"@react-native-aria/overlays": "0.3.12",
"@react-native-aria/overlays": "0.3.14",
"@react-native-aria/separator": "^0.2.6",
"@react-native-async-storage/async-storage": "~1.17.3",
"@react-native-community/datetimepicker": "6.5.2",
Expand Down
10 changes: 5 additions & 5 deletions packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@expo/html-elements": "latest",
"@gluestack-style/animation-resolver": "1.0.4",
"@gluestack-style/legend-motion-animation-driver": "1.0.3",
"@gluestack-style/react": "1.0.56",
"@gluestack-style/react": "1.0.57",
"@gluestack-ui/accordion": "1.0.5",
"@gluestack-ui/actionsheet": "0.2.43",
"@gluestack-ui/alert": "0.1.15",
Expand All @@ -55,7 +55,7 @@
"@gluestack-ui/menu": "0.2.34",
"@gluestack-ui/modal": "0.1.34",
"@gluestack-ui/overlay": "0.1.14",
"@gluestack-ui/popover": "0.1.35",
"@gluestack-ui/popover": "0.1.36",
"@gluestack-ui/pressable": "0.1.16",
"@gluestack-ui/progress": "0.1.15",
"@gluestack-ui/provider": "0.1.12",
Expand All @@ -66,14 +66,14 @@
"@gluestack-ui/switch": "0.1.22",
"@gluestack-ui/tabs": "0.1.16",
"@gluestack-ui/textarea": "0.1.23",
"@gluestack-ui/themed": "1.1.33",
"@gluestack-ui/themed": "1.1.34",
"@gluestack-ui/toast": "1.0.5",
"@gluestack-ui/tooltip": "0.1.31",
"@legendapp/motion": "latest"
},
"peerDependencies": {
"@gluestack-style/react": ">=1.0.56",
"@gluestack-ui/themed": ">=1.1.33"
"@gluestack-style/react": ">=1.0.57",
"@gluestack-ui/themed": ">=1.1.34"
},
"release-it": {
"git": {
Expand Down
12 changes: 12 additions & 0 deletions packages/react-native-aria/overlays/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @react-native-aria/overlays

## 0.3.14

### Patch Changes

- feat: overlay release

## 0.3.13

### Patch Changes

- feat: added flip state to popover

## 0.3.12

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-aria/overlays/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-aria/overlays",
"version": "0.3.12",
"version": "0.3.14",
"description": "Overlay utilities. Part of react-native-aria",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
9 changes: 9 additions & 0 deletions packages/react-native-aria/overlays/src/useOverlayPosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export function useOverlayPosition(props: AriaPositionProps) {
placement: position.placement,
arrowProps: arrowPropsWithStatusBarHeight,
updatePosition,
isFlipped: position.isFlipped,
};

if (position.maxHeight !== undefined) {
Expand Down Expand Up @@ -239,6 +240,7 @@ export interface PositionResult {
arrowOffsetTop?: number;
maxHeight?: number;
placement: PlacementAxis | undefined;
isFlipped?: boolean;
}

const calculatePosition = (opts: any): PositionResult => {
Expand Down Expand Up @@ -309,6 +311,7 @@ function calculatePositionInternal(
isContainerPositioned
);
let normalizedOffset = offset;
let isFlipped = false;
let space = getAvailableSpace(
boundaryDimensions,
containerOffsetWithBoundary,
Expand Down Expand Up @@ -343,10 +346,15 @@ function calculatePositionInternal(

// If the available space for the flipped position is greater than the original available space, flip.
if (flippedSpace > space) {
isFlipped = true;
placementInfo = flippedPlacementInfo;
position = flippedPosition;
normalizedOffset = offset;
} else {
isFlipped = false;
}
} else {
isFlipped = false;
}

let delta = getDelta(
Expand Down Expand Up @@ -404,6 +412,7 @@ function calculatePositionInternal(
arrowOffsetLeft: arrowPosition.left,
arrowOffsetTop: arrowPosition.top,
placement: placementInfo.placement,
isFlipped,
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// @ts-nocheck
/* eslint @typescript-eslint/no-unused-vars: 2 */

/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -209,14 +211,8 @@ function computePosition(
containerOffsetWithBoundary: Offset,
isContainerPositioned: boolean
) {
let {
placement,
crossPlacement,
axis,
crossAxis,
size,
crossSize,
} = placementInfo;
let { placement, crossPlacement, axis, crossAxis, size, crossSize } =
placementInfo;
let position: Position = {};

// button position
Expand Down Expand Up @@ -280,22 +276,22 @@ function getMaxHeight(
) {
return position.top != null
? // We want the distance between the top of the overlay to the bottom of the boundary
Math.max(
0,
boundaryDimensions.height +
boundaryDimensions.top +
boundaryDimensions.scroll.top - // this is the bottom of the boundary
(containerOffsetWithBoundary.top + position.top) - // this is the top of the overlay
(margins.top + margins.bottom + padding) // save additional space for margin and padding
)
Math.max(
0,
boundaryDimensions.height +
boundaryDimensions.top +
boundaryDimensions.scroll.top - // this is the bottom of the boundary
(containerOffsetWithBoundary.top + position.top) - // this is the top of the overlay
(margins.top + margins.bottom + padding) // save additional space for margin and padding
)
: // We want the distance between the top of the trigger to the top of the boundary
Math.max(
0,
childOffset.top +
containerOffsetWithBoundary.top - // this is the top of the trigger
(boundaryDimensions.top + boundaryDimensions.scroll.top) - // this is the top of the boundary
(margins.top + margins.bottom + padding) // save additional space for margin and padding
);
Math.max(
0,
childOffset.top +
containerOffsetWithBoundary.top - // this is the top of the trigger
(boundaryDimensions.top + boundaryDimensions.scroll.top) - // this is the top of the boundary
(margins.top + margins.bottom + padding) // save additional space for margin and padding
);
}

function getAvailableSpace(
Expand All @@ -311,26 +307,26 @@ function getAvailableSpace(
return Math.max(
0,
childOffset[axis] -
boundaryDimensions[axis] -
boundaryDimensions.scroll[axis] +
containerOffsetWithBoundary[axis] -
margins[axis] -
margins[FLIPPED_DIRECTION[axis]] -
padding
boundaryDimensions[axis] -
boundaryDimensions.scroll[axis] +
containerOffsetWithBoundary[axis] -
margins[axis] -
margins[FLIPPED_DIRECTION[axis]] -
padding
);
}

return Math.max(
0,
boundaryDimensions[size] +
boundaryDimensions[axis] +
boundaryDimensions.scroll[axis] -
containerOffsetWithBoundary[axis] -
childOffset[axis] -
childOffset[size] -
margins[axis] -
margins[FLIPPED_DIRECTION[axis]] -
padding
boundaryDimensions[axis] +
boundaryDimensions.scroll[axis] -
containerOffsetWithBoundary[axis] -
childOffset[axis] -
childOffset[size] -
margins[axis] -
margins[FLIPPED_DIRECTION[axis]] -
padding
);
}

Expand All @@ -350,14 +346,9 @@ export function calculatePositionInternal(
shouldOverlapWithTrigger: boolean
): PositionResult {
let placementInfo = parsePlacement(placementInput);
let {
size,
crossAxis,
crossSize,
placement,
crossPlacement,
axis,
} = placementInfo;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let { size, crossAxis, crossSize, placement, crossPlacement, axis } =
placementInfo;
let position = computePosition(
childOffset,
boundaryDimensions,
Expand All @@ -368,7 +359,7 @@ export function calculatePositionInternal(
containerOffsetWithBoundary,
isContainerPositioned
);

let isFlipped = false;
let normalizedOffset = offset;
let space = getAvailableSpace(
boundaryDimensions,
Expand Down Expand Up @@ -405,10 +396,15 @@ export function calculatePositionInternal(

// If the available space for the flipped position is greater than the original available space, flip.
if (flippedSpace > space) {
isFlipped = true;
placementInfo = flippedPlacementInfo;
position = flippedPosition;
normalizedOffset = offset;
} else {
isFlipped = false;
}
} else {
isFlipped = false;
}

let delta = getDelta(
Expand Down Expand Up @@ -465,6 +461,7 @@ export function calculatePositionInternal(
arrowOffsetLeft: arrowPosition.left,
arrowOffsetTop: arrowPosition.top,
placement: placementInfo.placement,
isFlipped,
};
}

Expand Down Expand Up @@ -502,7 +499,8 @@ export function calculatePosition(opts: PositionOpts): PositionResult {
let overlaySize: Offset = getOffset(overlayNode);
const matrix = getComputedStyle(overlayNode).getPropertyValue('transform');
const transform = matrix;
const regex = /matrix\((-?\d*\.?\d+),\s*(-?\d*\.?\d+),\s*(-?\d*\.?\d+),\s*(-?\d*\.?\d+),\s*(-?\d*\.?\d+),\s*(-?\d*\.?\d+)\)/;
const regex =
/matrix\((-?\d*\.?\d+),\s*(-?\d*\.?\d+),\s*(-?\d*\.?\d+),\s*(-?\d*\.?\d+),\s*(-?\d*\.?\d+),\s*(-?\d*\.?\d+)\)/;
const matches = transform.match(regex);
let scaleX = 1;
let scaleY = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ interface PositionAria {
placement: PlacementAxis;
/** Updates the position of the overlay. */
updatePosition(): void;
/** Whether the overlay is flipped. */
isFlipped: boolean;
}

// @ts-ignore
Expand Down Expand Up @@ -139,9 +141,11 @@ export function useOverlayPosition(props: AriaPositionProps): PositionAria {
shouldOverlapWithTrigger,
})
);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, deps);

// Update position when anything changes
// eslint-disable-next-line react-hooks/exhaustive-deps
useLayoutEffect(updatePosition, deps);

// Update position on window resize
Expand Down Expand Up @@ -224,6 +228,7 @@ export function useOverlayPosition(props: AriaPositionProps): PositionAria {
top: position.arrowOffsetTop,
},
},
isFlipped: position.isFlipped,
updatePosition,
};
}
Expand Down
6 changes: 6 additions & 0 deletions packages/styled/react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @gluestack-style/react

## 1.0.57

### Patch Changes

- feat: added flip state to popover

## 1.0.56

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/styled/react/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@gluestack-style/react",
"description": "A universal & performant styling library for React Native, Next.js & React",
"version": "1.0.56",
"version": "1.0.57",
"keywords": [
"React Native",
"Next.js",
Expand Down
1 change: 1 addition & 0 deletions packages/styled/react/src/core/styled-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export const reservedKeys: Record<string, reservedKeyType> = {
indeterminate: { key: ':indeterminate', isState: true },
checked: { key: ':checked', isState: true },
readOnly: { key: ':readOnly', isState: true },
flip: { key: ':flip', isState: true },

required: { key: ':required', isState: true },
invalid: { key: ':invalid', isState: true },
Expand Down
2 changes: 1 addition & 1 deletion packages/styled/react/src/resolver/getWeightBaseOnPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ export function getWeightBaseOnPath(path: Path) {
indeterminate: 1,
checked: 1,
readOnly: 1,
flip: 1,

required: 2,
invalid: 2,

focus: 3,
focusVisible: 4,
hover: 5,
Expand Down
8 changes: 8 additions & 0 deletions packages/themed/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @gluestack-ui/themed

## 1.1.34

### Patch Changes

- Updated dependencies
- @gluestack-ui/popover@0.1.36
- @gluestack-style/react@1.0.57

## 1.1.33

### Patch Changes
Expand Down
Loading

0 comments on commit 3c9709c

Please sign in to comment.