@wordpress/components 25.3.0 → 25.5.0
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/CHANGELOG.md +31 -0
- package/build/border-control/border-control-dropdown/component.js +8 -10
- package/build/border-control/border-control-dropdown/component.js.map +1 -1
- package/build/button/index.native.js +9 -6
- package/build/button/index.native.js.map +1 -1
- package/build/color-palette/index.js +2 -2
- package/build/color-palette/index.js.map +1 -1
- package/build/focal-point-picker/index.native.js +6 -4
- package/build/focal-point-picker/index.native.js.map +1 -1
- package/build/form-token-field/styles.js +4 -2
- package/build/form-token-field/styles.js.map +1 -1
- package/build/item-group/item/hook.js +1 -1
- package/build/item-group/item/hook.js.map +1 -1
- package/build/item-group/styles.js +13 -10
- package/build/item-group/styles.js.map +1 -1
- package/build/menu-items-choice/index.js +1 -0
- package/build/menu-items-choice/index.js.map +1 -1
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/bottom-sheet-navigation-context.native.js +3 -1
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/bottom-sheet-navigation-context.native.js.map +1 -1
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +50 -44
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +13 -20
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
- package/build/mobile/bottom-sheet/index.native.js +3 -1
- package/build/mobile/bottom-sheet/index.native.js.map +1 -1
- package/build/mobile/image/index.native.js +4 -3
- package/build/mobile/image/index.native.js.map +1 -1
- package/build/mobile/link-picker/link-picker-results.native.js +2 -1
- package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
- package/build/mobile/segmented-control/index.native.js +7 -7
- package/build/mobile/segmented-control/index.native.js.map +1 -1
- package/build/modal/index.js +14 -1
- package/build/modal/index.js.map +1 -1
- package/build/navigator/navigator-provider/component.js +18 -10
- package/build/navigator/navigator-provider/component.js.map +1 -1
- package/build/private-apis.js +4 -1
- package/build/private-apis.js.map +1 -1
- package/build/progress-bar/index.js +54 -0
- package/build/progress-bar/index.js.map +1 -0
- package/build/progress-bar/styles.js +69 -0
- package/build/progress-bar/styles.js.map +1 -0
- package/build/progress-bar/types.js +6 -0
- package/build/progress-bar/types.js.map +1 -0
- package/build/query-controls/index.js +1 -0
- package/build/query-controls/index.js.map +1 -1
- package/build/query-controls/index.native.js +1 -0
- package/build/query-controls/index.native.js.map +1 -1
- package/build/tab-panel/index.js +91 -58
- package/build/tab-panel/index.js.map +1 -1
- package/build/text-control/index.js +2 -2
- package/build/text-control/index.js.map +1 -1
- package/build/toolbar/toolbar-group/toolbar-group-container.native.js +10 -7
- package/build/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/component.js +8 -10
- package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
- package/build-module/button/index.native.js +8 -6
- package/build-module/button/index.native.js.map +1 -1
- package/build-module/color-palette/index.js +2 -2
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/focal-point-picker/index.native.js +6 -5
- package/build-module/focal-point-picker/index.native.js.map +1 -1
- package/build-module/form-token-field/styles.js +3 -2
- package/build-module/form-token-field/styles.js.map +1 -1
- package/build-module/item-group/item/hook.js +1 -1
- package/build-module/item-group/item/hook.js.map +1 -1
- package/build-module/item-group/styles.js +13 -11
- package/build-module/item-group/styles.js.map +1 -1
- package/build-module/menu-items-choice/index.js +1 -0
- package/build-module/menu-items-choice/index.js.map +1 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/bottom-sheet-navigation-context.native.js +3 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/bottom-sheet-navigation-context.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +43 -41
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +14 -20
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/index.native.js +3 -1
- package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
- package/build-module/mobile/image/index.native.js +4 -3
- package/build-module/mobile/image/index.native.js.map +1 -1
- package/build-module/mobile/link-picker/link-picker-results.native.js +2 -1
- package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
- package/build-module/mobile/segmented-control/index.native.js +7 -7
- package/build-module/mobile/segmented-control/index.native.js.map +1 -1
- package/build-module/modal/index.js +14 -1
- package/build-module/modal/index.js.map +1 -1
- package/build-module/navigator/navigator-provider/component.js +18 -10
- package/build-module/navigator/navigator-provider/component.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/progress-bar/index.js +41 -0
- package/build-module/progress-bar/index.js.map +1 -0
- package/build-module/progress-bar/styles.js +61 -0
- package/build-module/progress-bar/styles.js.map +1 -0
- package/build-module/progress-bar/types.js +2 -0
- package/build-module/progress-bar/types.js.map +1 -0
- package/build-module/query-controls/index.js +1 -0
- package/build-module/query-controls/index.js.map +1 -1
- package/build-module/query-controls/index.native.js +1 -0
- package/build-module/query-controls/index.native.js.map +1 -1
- package/build-module/tab-panel/index.js +88 -59
- package/build-module/tab-panel/index.js.map +1 -1
- package/build-module/text-control/index.js +2 -2
- package/build-module/text-control/index.js.map +1 -1
- package/build-module/toolbar/toolbar-group/toolbar-group-container.native.js +11 -7
- package/build-module/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -1
- package/build-style/style-rtl.css +3 -0
- package/build-style/style.css +3 -0
- package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
- package/build-types/form-token-field/styles.d.ts.map +1 -1
- package/build-types/item-group/item/hook.d.ts.map +1 -1
- package/build-types/item-group/stories/index.d.ts.map +1 -1
- package/build-types/item-group/styles.d.ts +1 -1
- package/build-types/item-group/styles.d.ts.map +1 -1
- package/build-types/menu-items-choice/index.d.ts.map +1 -1
- package/build-types/menu-items-choice/types.d.ts +5 -0
- package/build-types/menu-items-choice/types.d.ts.map +1 -1
- package/build-types/modal/index.d.ts.map +1 -1
- package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
- package/build-types/navigator/types.d.ts +3 -1
- package/build-types/navigator/types.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/progress-bar/index.d.ts +5 -0
- package/build-types/progress-bar/index.d.ts.map +1 -0
- package/build-types/progress-bar/stories/index.d.ts +12 -0
- package/build-types/progress-bar/stories/index.d.ts.map +1 -0
- package/build-types/progress-bar/styles.d.ts +18 -0
- package/build-types/progress-bar/styles.d.ts.map +1 -0
- package/build-types/progress-bar/test/index.d.ts +2 -0
- package/build-types/progress-bar/test/index.d.ts.map +1 -0
- package/build-types/progress-bar/types.d.ts +11 -0
- package/build-types/progress-bar/types.d.ts.map +1 -0
- package/build-types/query-controls/index.d.ts.map +1 -1
- package/build-types/tab-panel/index.d.ts.map +1 -1
- package/build-types/tab-panel/stories/index.d.ts +1 -0
- package/build-types/tab-panel/stories/index.d.ts.map +1 -1
- package/build-types/tab-panel/types.d.ts +1 -9
- package/build-types/tab-panel/types.d.ts.map +1 -1
- package/build-types/text-control/test/text-control.d.ts +2 -0
- package/build-types/text-control/test/text-control.d.ts.map +1 -0
- package/package.json +22 -22
- package/src/border-control/border-control-dropdown/component.tsx +7 -11
- package/src/border-control/test/index.js +6 -6
- package/src/button/index.native.js +9 -3
- package/src/button/style.native.scss +9 -0
- package/src/color-palette/index.tsx +2 -2
- package/src/color-palette/test/__snapshots__/index.tsx.snap +1 -1
- package/src/color-palette/test/index.tsx +1 -5
- package/src/draggable/test/index.native.js +4 -0
- package/src/focal-point-picker/index.native.js +6 -5
- package/src/form-token-field/styles.ts +2 -0
- package/src/item-group/item/hook.ts +2 -1
- package/src/item-group/stories/index.tsx +8 -3
- package/src/item-group/styles.ts +39 -28
- package/src/menu-item/README.md +7 -0
- package/src/menu-items-choice/index.tsx +1 -0
- package/src/menu-items-choice/types.ts +5 -0
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/bottom-sheet-navigation-context.native.js +1 -1
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +72 -53
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +15 -21
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/test/navigation-container.native.js +165 -119
- package/src/mobile/bottom-sheet/index.native.js +2 -0
- package/src/mobile/image/index.native.js +8 -6
- package/src/mobile/image/style.native.scss +5 -1
- package/src/mobile/link-picker/link-picker-results.native.js +1 -1
- package/src/mobile/link-settings/test/edit.native.js +37 -23
- package/src/mobile/segmented-control/index.native.js +11 -11
- package/src/modal/index.tsx +16 -0
- package/src/modal/test/index.tsx +33 -0
- package/src/navigator/navigator-provider/component.tsx +30 -23
- package/src/navigator/types.ts +4 -1
- package/src/placeholder/style.scss +5 -0
- package/src/private-apis.ts +2 -0
- package/src/progress-bar/README.md +30 -0
- package/src/progress-bar/index.tsx +45 -0
- package/src/progress-bar/stories/index.tsx +33 -0
- package/src/progress-bar/styles.ts +67 -0
- package/src/progress-bar/test/index.tsx +79 -0
- package/src/progress-bar/types.ts +11 -0
- package/src/query-controls/index.native.js +1 -0
- package/src/query-controls/index.tsx +1 -0
- package/src/tab-panel/index.tsx +121 -84
- package/src/tab-panel/stories/index.tsx +6 -0
- package/src/tab-panel/test/index.tsx +128 -109
- package/src/tab-panel/types.ts +1 -10
- package/src/text-control/index.tsx +2 -2
- package/src/text-control/test/text-control.tsx +61 -0
- package/src/toolbar/toolbar-group/style.native.scss +2 -3
- package/src/toolbar/toolbar-group/toolbar-group-container.native.js +12 -17
- package/src/tooltip/README.md +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -39,20 +39,25 @@ Default.args = {
|
|
|
39
39
|
children: (
|
|
40
40
|
[
|
|
41
41
|
{
|
|
42
|
-
children: 'First item',
|
|
42
|
+
children: 'First button item',
|
|
43
43
|
// eslint-disable-next-line no-alert
|
|
44
44
|
onClick: () => alert( 'First item clicked' ),
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
|
-
children: 'Second item',
|
|
47
|
+
children: 'Second button item',
|
|
48
48
|
// eslint-disable-next-line no-alert
|
|
49
49
|
onClick: () => alert( 'Second item clicked' ),
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
|
-
children: 'Third item',
|
|
52
|
+
children: 'Third button item',
|
|
53
53
|
// eslint-disable-next-line no-alert
|
|
54
54
|
onClick: () => alert( 'Third item clicked' ),
|
|
55
55
|
},
|
|
56
|
+
{
|
|
57
|
+
children: 'Anchor item',
|
|
58
|
+
as: 'a',
|
|
59
|
+
href: 'https://wordpress.org',
|
|
60
|
+
},
|
|
56
61
|
] as ItemProps[]
|
|
57
62
|
).map( mapPropsToItem ),
|
|
58
63
|
};
|
package/src/item-group/styles.ts
CHANGED
|
@@ -6,34 +6,45 @@ import { css } from '@emotion/react';
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { CONFIG, COLORS } from '../utils';
|
|
10
|
-
|
|
11
|
-
export const unstyledButton =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
9
|
+
import { CONFIG, COLORS, font } from '../utils';
|
|
10
|
+
|
|
11
|
+
export const unstyledButton = ( as: 'a' | 'button' ) => {
|
|
12
|
+
return css`
|
|
13
|
+
font-size: ${ font( 'default.fontSize' ) };
|
|
14
|
+
font-family: inherit;
|
|
15
|
+
appearance: none;
|
|
16
|
+
border: 1px solid transparent;
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
background: none;
|
|
19
|
+
text-align: start;
|
|
20
|
+
text-decoration: ${ as === 'a' ? 'none' : undefined };
|
|
21
|
+
|
|
22
|
+
svg,
|
|
23
|
+
path {
|
|
24
|
+
fill: currentColor;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&:hover {
|
|
28
|
+
color: ${ COLORS.ui.theme };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&:focus {
|
|
32
|
+
box-shadow: none;
|
|
33
|
+
outline: none;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&:focus-visible {
|
|
37
|
+
box-shadow: 0 0 0 var( --wp-admin-border-width-focus )
|
|
38
|
+
var(
|
|
39
|
+
--wp-components-color-accent,
|
|
40
|
+
var( --wp-admin-theme-color, ${ COLORS.ui.theme } )
|
|
41
|
+
);
|
|
42
|
+
// Windows high contrast mode.
|
|
43
|
+
outline: 2px solid transparent;
|
|
44
|
+
outline-offset: 0;
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
};
|
|
37
48
|
|
|
38
49
|
export const itemWrapper = css`
|
|
39
50
|
width: 100%;
|
package/src/menu-item/README.md
CHANGED
|
@@ -34,6 +34,13 @@ MenuItem supports the following props. Any additional props are passed through t
|
|
|
34
34
|
|
|
35
35
|
Element to render as child of button.
|
|
36
36
|
|
|
37
|
+
### `disabled`
|
|
38
|
+
|
|
39
|
+
- Type: `boolean`
|
|
40
|
+
- Required: No
|
|
41
|
+
|
|
42
|
+
Refer to documentation for [Button's `disabled` prop](/packages/components/src/button/README.md#disabled-boolean).
|
|
43
|
+
|
|
37
44
|
### `info`
|
|
38
45
|
|
|
39
46
|
- Type: `string`
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import type { ShortcutProps } from '../shortcut/types';
|
|
5
|
+
import type { ButtonAsButtonProps } from '../button/types';
|
|
5
6
|
|
|
6
7
|
export type MenuItemsChoiceProps = {
|
|
7
8
|
/**
|
|
@@ -38,6 +39,10 @@ export type MenuItemChoice = {
|
|
|
38
39
|
* Unique value for choice.
|
|
39
40
|
*/
|
|
40
41
|
value: string;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the menu item is disabled.
|
|
44
|
+
*/
|
|
45
|
+
disabled?: ButtonAsButtonProps[ 'disabled' ];
|
|
41
46
|
/**
|
|
42
47
|
* Additional information which will be rendered below the given label.
|
|
43
48
|
*/
|
package/src/mobile/bottom-sheet/bottom-sheet-navigation/bottom-sheet-navigation-context.native.js
CHANGED
|
@@ -6,7 +6,7 @@ import { createContext } from '@wordpress/element';
|
|
|
6
6
|
// Navigation context in BottomSheet is necessary for controlling the
|
|
7
7
|
// height of navigation container.
|
|
8
8
|
export const BottomSheetNavigationContext = createContext( {
|
|
9
|
-
currentHeight:
|
|
9
|
+
currentHeight: { value: 0 },
|
|
10
10
|
setHeight: () => {},
|
|
11
11
|
} );
|
|
12
12
|
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { View, Easing } from 'react-native';
|
|
5
4
|
import { NavigationContainer, DefaultTheme } from '@react-navigation/native';
|
|
6
5
|
import { createStackNavigator } from '@react-navigation/stack';
|
|
6
|
+
import Animated, {
|
|
7
|
+
Easing,
|
|
8
|
+
useAnimatedStyle,
|
|
9
|
+
useSharedValue,
|
|
10
|
+
withTiming,
|
|
11
|
+
} from 'react-native-reanimated';
|
|
7
12
|
|
|
8
13
|
/**
|
|
9
14
|
* WordPress dependencies
|
|
10
15
|
*/
|
|
11
16
|
import {
|
|
12
|
-
useState,
|
|
13
17
|
useContext,
|
|
14
18
|
useMemo,
|
|
15
19
|
useCallback,
|
|
@@ -23,11 +27,11 @@ import { usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
|
23
27
|
/**
|
|
24
28
|
* Internal dependencies
|
|
25
29
|
*/
|
|
26
|
-
import { performLayoutAnimation } from '../../layout-animation';
|
|
27
30
|
import {
|
|
28
31
|
BottomSheetNavigationContext,
|
|
29
32
|
BottomSheetNavigationProvider,
|
|
30
33
|
} from './bottom-sheet-navigation-context';
|
|
34
|
+
import { BottomSheetContext } from '../bottom-sheet-context';
|
|
31
35
|
|
|
32
36
|
import styles from './styles.scss';
|
|
33
37
|
|
|
@@ -57,7 +61,8 @@ const options = {
|
|
|
57
61
|
cardStyleInterpolator: fadeConfig,
|
|
58
62
|
};
|
|
59
63
|
|
|
60
|
-
const
|
|
64
|
+
const HEIGHT_ANIMATION_DURATION = 300;
|
|
65
|
+
const DEFAULT_HEIGHT = 1;
|
|
61
66
|
|
|
62
67
|
function BottomSheetNavigationContainer( {
|
|
63
68
|
children,
|
|
@@ -65,11 +70,14 @@ function BottomSheetNavigationContainer( {
|
|
|
65
70
|
main,
|
|
66
71
|
theme,
|
|
67
72
|
style,
|
|
73
|
+
testID,
|
|
68
74
|
} ) {
|
|
69
75
|
const Stack = useRef( createStackNavigator() ).current;
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
76
|
+
const navigationContext = useContext( BottomSheetNavigationContext );
|
|
77
|
+
const { maxHeight: sheetMaxHeight, isMaxHeightSet: isSheetMaxHeightSet } =
|
|
78
|
+
useContext( BottomSheetContext );
|
|
79
|
+
const currentHeight = useSharedValue(
|
|
80
|
+
navigationContext.currentHeight?.value || DEFAULT_HEIGHT
|
|
73
81
|
);
|
|
74
82
|
|
|
75
83
|
const backgroundStyle = usePreferredColorSchemeStyle(
|
|
@@ -77,47 +85,49 @@ function BottomSheetNavigationContainer( {
|
|
|
77
85
|
styles.backgroundDark
|
|
78
86
|
);
|
|
79
87
|
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
88
|
+
const defaultTheme = useMemo(
|
|
89
|
+
() => ( {
|
|
90
|
+
...DefaultTheme,
|
|
91
|
+
colors: {
|
|
92
|
+
...DefaultTheme.colors,
|
|
93
|
+
background: backgroundStyle.backgroundColor,
|
|
94
|
+
},
|
|
95
|
+
} ),
|
|
96
|
+
[ backgroundStyle.backgroundColor ]
|
|
97
|
+
);
|
|
98
|
+
const _theme = theme || defaultTheme;
|
|
87
99
|
|
|
88
100
|
const setHeight = useCallback(
|
|
89
101
|
( height ) => {
|
|
90
|
-
// The screen is fullHeight.
|
|
91
102
|
if (
|
|
92
|
-
|
|
93
|
-
|
|
103
|
+
height > DEFAULT_HEIGHT &&
|
|
104
|
+
Math.round( height ) !== Math.round( currentHeight.value )
|
|
94
105
|
) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
performLayoutAnimation( ANIMATION_DURATION );
|
|
109
|
-
setCurrentHeight( height );
|
|
106
|
+
// If max height is set in the bottom sheet, we clamp
|
|
107
|
+
// the new height using that value.
|
|
108
|
+
const newHeight = isSheetMaxHeightSet
|
|
109
|
+
? Math.min( sheetMaxHeight, height )
|
|
110
|
+
: height;
|
|
111
|
+
const shouldAnimate =
|
|
112
|
+
animate && currentHeight.value !== DEFAULT_HEIGHT;
|
|
113
|
+
|
|
114
|
+
if ( shouldAnimate ) {
|
|
115
|
+
currentHeight.value = withTiming( newHeight, {
|
|
116
|
+
duration: HEIGHT_ANIMATION_DURATION,
|
|
117
|
+
easing: Easing.out( Easing.cubic ),
|
|
118
|
+
} );
|
|
110
119
|
} else {
|
|
111
|
-
|
|
120
|
+
currentHeight.value = newHeight;
|
|
112
121
|
}
|
|
113
122
|
}
|
|
114
123
|
},
|
|
115
|
-
|
|
116
|
-
// see https://github.com/WordPress/gutenberg/pull/41166
|
|
117
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
118
|
-
[ currentHeight ]
|
|
124
|
+
[ animate, currentHeight, isSheetMaxHeightSet, sheetMaxHeight ]
|
|
119
125
|
);
|
|
120
126
|
|
|
127
|
+
const animatedStyles = useAnimatedStyle( () => ( {
|
|
128
|
+
height: currentHeight.value,
|
|
129
|
+
} ) );
|
|
130
|
+
|
|
121
131
|
const screens = useMemo( () => {
|
|
122
132
|
return Children.map( children, ( child ) => {
|
|
123
133
|
let screen = child;
|
|
@@ -136,38 +146,47 @@ function BottomSheetNavigationContainer( {
|
|
|
136
146
|
/>
|
|
137
147
|
);
|
|
138
148
|
} );
|
|
139
|
-
|
|
140
|
-
// see https://github.com/WordPress/gutenberg/pull/41166
|
|
141
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
142
|
-
}, [ children ] );
|
|
149
|
+
}, [ children, main ] );
|
|
143
150
|
|
|
144
151
|
return useMemo( () => {
|
|
145
152
|
return (
|
|
146
|
-
<View
|
|
153
|
+
<Animated.View
|
|
154
|
+
style={ [ style, animatedStyles ] }
|
|
155
|
+
testID={ testID }
|
|
156
|
+
>
|
|
147
157
|
<BottomSheetNavigationProvider
|
|
148
|
-
value={ {
|
|
149
|
-
setHeight,
|
|
150
|
-
currentHeight,
|
|
151
|
-
} }
|
|
158
|
+
value={ { setHeight, currentHeight } }
|
|
152
159
|
>
|
|
153
160
|
{ main ? (
|
|
154
161
|
<NavigationContainer theme={ _theme }>
|
|
155
|
-
<Stack.Navigator
|
|
162
|
+
<Stack.Navigator
|
|
163
|
+
screenOptions={ options }
|
|
164
|
+
detachInactiveScreens={ false }
|
|
165
|
+
>
|
|
156
166
|
{ screens }
|
|
157
167
|
</Stack.Navigator>
|
|
158
168
|
</NavigationContainer>
|
|
159
169
|
) : (
|
|
160
|
-
<Stack.Navigator
|
|
170
|
+
<Stack.Navigator
|
|
171
|
+
screenOptions={ options }
|
|
172
|
+
detachInactiveScreens={ false }
|
|
173
|
+
>
|
|
161
174
|
{ screens }
|
|
162
175
|
</Stack.Navigator>
|
|
163
176
|
) }
|
|
164
177
|
</BottomSheetNavigationProvider>
|
|
165
|
-
</View>
|
|
178
|
+
</Animated.View>
|
|
166
179
|
);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
180
|
+
}, [
|
|
181
|
+
_theme,
|
|
182
|
+
animatedStyles,
|
|
183
|
+
currentHeight,
|
|
184
|
+
main,
|
|
185
|
+
screens,
|
|
186
|
+
setHeight,
|
|
187
|
+
style,
|
|
188
|
+
testID,
|
|
189
|
+
] );
|
|
171
190
|
}
|
|
172
191
|
|
|
173
192
|
export default BottomSheetNavigationContainer;
|
|
@@ -6,13 +6,17 @@ import {
|
|
|
6
6
|
useNavigation,
|
|
7
7
|
useFocusEffect,
|
|
8
8
|
} from '@react-navigation/native';
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
ScrollView,
|
|
11
|
+
TouchableHighlight,
|
|
12
|
+
useWindowDimensions,
|
|
13
|
+
View,
|
|
14
|
+
} from 'react-native';
|
|
10
15
|
|
|
11
16
|
/**
|
|
12
17
|
* WordPress dependencies
|
|
13
18
|
*/
|
|
14
19
|
import { BottomSheetContext } from '@wordpress/components';
|
|
15
|
-
import { debounce } from '@wordpress/compose';
|
|
16
20
|
import { useRef, useCallback, useContext, useMemo } from '@wordpress/element';
|
|
17
21
|
|
|
18
22
|
/**
|
|
@@ -29,7 +33,7 @@ const BottomSheetNavigationScreen = ( {
|
|
|
29
33
|
name,
|
|
30
34
|
} ) => {
|
|
31
35
|
const navigation = useNavigation();
|
|
32
|
-
const
|
|
36
|
+
const maxHeight = useRef( 0 );
|
|
33
37
|
const isFocused = useIsFocused();
|
|
34
38
|
const {
|
|
35
39
|
onHandleHardwareButtonPress,
|
|
@@ -38,16 +42,10 @@ const BottomSheetNavigationScreen = ( {
|
|
|
38
42
|
listProps,
|
|
39
43
|
safeAreaBottomInset,
|
|
40
44
|
} = useContext( BottomSheetContext );
|
|
45
|
+
const { height: windowHeight } = useWindowDimensions();
|
|
41
46
|
|
|
42
47
|
const { setHeight } = useContext( BottomSheetNavigationContext );
|
|
43
48
|
|
|
44
|
-
// Disable reason: deferring this refactor to the native team.
|
|
45
|
-
// see https://github.com/WordPress/gutenberg/pull/41166
|
|
46
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
47
|
-
const setHeightDebounce = useCallback( debounce( setHeight, 10 ), [
|
|
48
|
-
setHeight,
|
|
49
|
-
] );
|
|
50
|
-
|
|
51
49
|
useFocusEffect(
|
|
52
50
|
useCallback( () => {
|
|
53
51
|
onHandleHardwareButtonPress( () => {
|
|
@@ -81,17 +79,14 @@ const BottomSheetNavigationScreen = ( {
|
|
|
81
79
|
useFocusEffect(
|
|
82
80
|
useCallback( () => {
|
|
83
81
|
if ( fullScreen ) {
|
|
84
|
-
setHeight(
|
|
82
|
+
setHeight( windowHeight );
|
|
85
83
|
setIsFullScreen( true );
|
|
86
|
-
} else if (
|
|
84
|
+
} else if ( maxHeight.current !== 0 ) {
|
|
87
85
|
setIsFullScreen( false );
|
|
88
|
-
setHeight(
|
|
86
|
+
setHeight( maxHeight.current );
|
|
89
87
|
}
|
|
90
88
|
return () => {};
|
|
91
|
-
|
|
92
|
-
// see https://github.com/WordPress/gutenberg/pull/41166
|
|
93
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
94
|
-
}, [ setHeight ] )
|
|
89
|
+
}, [ fullScreen, setHeight, setIsFullScreen, windowHeight ] )
|
|
95
90
|
);
|
|
96
91
|
|
|
97
92
|
const onLayout = ( { nativeEvent } ) => {
|
|
@@ -99,10 +94,9 @@ const BottomSheetNavigationScreen = ( {
|
|
|
99
94
|
return;
|
|
100
95
|
}
|
|
101
96
|
const { height } = nativeEvent.layout;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
setHeightDebounce( height );
|
|
97
|
+
if ( maxHeight.current !== height && isFocused ) {
|
|
98
|
+
maxHeight.current = height;
|
|
99
|
+
setHeight( height );
|
|
106
100
|
}
|
|
107
101
|
};
|
|
108
102
|
|