@wordpress/components 27.0.0 → 27.1.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.
Files changed (208) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/build/base-control/index.native.js.map +1 -1
  3. package/build/border-box-control/border-box-control/component.js.map +1 -1
  4. package/build/border-box-control/border-box-control-split-controls/component.js.map +1 -1
  5. package/build/border-control/border-control-dropdown/component.js.map +1 -1
  6. package/build/button/index.js +2 -2
  7. package/build/button/index.js.map +1 -1
  8. package/build/button/index.native.js.map +1 -1
  9. package/build/confirm-dialog/component.js.map +1 -1
  10. package/build/custom-select-control-v2/default-component/index.js.map +1 -1
  11. package/build/custom-select-control-v2/index.js +2 -2
  12. package/build/custom-select-control-v2/index.js.map +1 -1
  13. package/build/custom-select-control-v2/types.js.map +1 -1
  14. package/build/draggable/index.native.js +2 -2
  15. package/build/draggable/index.native.js.map +1 -1
  16. package/build/dropdown-menu/index.native.js.map +1 -1
  17. package/build/flex/flex/hook.js +1 -1
  18. package/build/flex/flex/hook.js.map +1 -1
  19. package/build/font-size-picker/index.native.js.map +1 -1
  20. package/build/form-token-field/index.js.map +1 -1
  21. package/build/h-stack/hook.js +6 -1
  22. package/build/h-stack/hook.js.map +1 -1
  23. package/build/mobile/bottom-sheet/button.native.js.map +1 -1
  24. package/build/mobile/bottom-sheet/index.native.js.map +1 -1
  25. package/build/mobile/bottom-sheet/range-cell.native.js.map +1 -1
  26. package/build/mobile/bottom-sheet/stepper-cell/index.native.js.map +1 -1
  27. package/build/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
  28. package/build/mobile/bottom-sheet-text-control/index.native.js.map +1 -1
  29. package/build/mobile/gradient/index.native.js.map +1 -1
  30. package/build/mobile/image/index.native.js +4 -13
  31. package/build/mobile/image/index.native.js.map +1 -1
  32. package/build/mobile/media-edit/index.native.js.map +1 -1
  33. package/build/palette-edit/index.js.map +1 -1
  34. package/build/query-controls/index.native.js.map +1 -1
  35. package/build/range-control/index.js.map +1 -1
  36. package/build/search-control/index.native.js.map +1 -1
  37. package/build/snackbar/index.js +3 -2
  38. package/build/snackbar/index.js.map +1 -1
  39. package/build/snackbar/list.js +2 -1
  40. package/build/snackbar/list.js.map +1 -1
  41. package/build/snackbar/types.js.map +1 -1
  42. package/build/tabs/index.js +7 -7
  43. package/build/tabs/index.js.map +1 -1
  44. package/build/tabs/types.js.map +1 -1
  45. package/build/utils/hooks/index.js +0 -7
  46. package/build/utils/hooks/index.js.map +1 -1
  47. package/build-module/base-control/index.native.js.map +1 -1
  48. package/build-module/border-box-control/border-box-control/component.js.map +1 -1
  49. package/build-module/border-box-control/border-box-control-split-controls/component.js.map +1 -1
  50. package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
  51. package/build-module/button/index.js +2 -2
  52. package/build-module/button/index.js.map +1 -1
  53. package/build-module/button/index.native.js.map +1 -1
  54. package/build-module/confirm-dialog/component.js.map +1 -1
  55. package/build-module/custom-select-control-v2/default-component/index.js.map +1 -1
  56. package/build-module/custom-select-control-v2/index.js +1 -1
  57. package/build-module/custom-select-control-v2/index.js.map +1 -1
  58. package/build-module/custom-select-control-v2/types.js.map +1 -1
  59. package/build-module/draggable/index.native.js +2 -2
  60. package/build-module/draggable/index.native.js.map +1 -1
  61. package/build-module/dropdown-menu/index.native.js.map +1 -1
  62. package/build-module/flex/flex/hook.js +1 -1
  63. package/build-module/flex/flex/hook.js.map +1 -1
  64. package/build-module/font-size-picker/index.native.js.map +1 -1
  65. package/build-module/form-token-field/index.js.map +1 -1
  66. package/build-module/h-stack/hook.js +6 -1
  67. package/build-module/h-stack/hook.js.map +1 -1
  68. package/build-module/mobile/bottom-sheet/button.native.js.map +1 -1
  69. package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
  70. package/build-module/mobile/bottom-sheet/range-cell.native.js.map +1 -1
  71. package/build-module/mobile/bottom-sheet/stepper-cell/index.native.js.map +1 -1
  72. package/build-module/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
  73. package/build-module/mobile/bottom-sheet-text-control/index.native.js.map +1 -1
  74. package/build-module/mobile/gradient/index.native.js.map +1 -1
  75. package/build-module/mobile/image/index.native.js +6 -15
  76. package/build-module/mobile/image/index.native.js.map +1 -1
  77. package/build-module/mobile/media-edit/index.native.js.map +1 -1
  78. package/build-module/palette-edit/index.js.map +1 -1
  79. package/build-module/query-controls/index.native.js.map +1 -1
  80. package/build-module/range-control/index.js.map +1 -1
  81. package/build-module/search-control/index.native.js.map +1 -1
  82. package/build-module/snackbar/index.js +3 -2
  83. package/build-module/snackbar/index.js.map +1 -1
  84. package/build-module/snackbar/list.js +2 -1
  85. package/build-module/snackbar/list.js.map +1 -1
  86. package/build-module/snackbar/types.js.map +1 -1
  87. package/build-module/tabs/index.js +7 -7
  88. package/build-module/tabs/index.js.map +1 -1
  89. package/build-module/tabs/types.js.map +1 -1
  90. package/build-module/utils/hooks/index.js +0 -1
  91. package/build-module/utils/hooks/index.js.map +1 -1
  92. package/build-style/style-rtl.css +8 -1
  93. package/build-style/style.css +8 -1
  94. package/build-types/custom-select-control-v2/default-component/index.d.ts +2 -1
  95. package/build-types/custom-select-control-v2/default-component/index.d.ts.map +1 -1
  96. package/build-types/custom-select-control-v2/index.d.ts +1 -1
  97. package/build-types/custom-select-control-v2/index.d.ts.map +1 -1
  98. package/build-types/custom-select-control-v2/legacy-component/test/index.d.ts +2 -0
  99. package/build-types/custom-select-control-v2/legacy-component/test/index.d.ts.map +1 -0
  100. package/build-types/custom-select-control-v2/stories/default.story.d.ts +4 -3
  101. package/build-types/custom-select-control-v2/stories/default.story.d.ts.map +1 -1
  102. package/build-types/custom-select-control-v2/stories/legacy.story.d.ts +2 -2
  103. package/build-types/custom-select-control-v2/stories/legacy.story.d.ts.map +1 -1
  104. package/build-types/custom-select-control-v2/types.d.ts +0 -1
  105. package/build-types/custom-select-control-v2/types.d.ts.map +1 -1
  106. package/build-types/flex/flex/hook.d.ts +2 -3
  107. package/build-types/flex/flex/hook.d.ts.map +1 -1
  108. package/build-types/h-stack/hook.d.ts +2 -4
  109. package/build-types/h-stack/hook.d.ts.map +1 -1
  110. package/build-types/navigation/stories/utils/hide-if-empty.d.ts.map +1 -1
  111. package/build-types/radio-group/stories/index.story.d.ts.map +1 -1
  112. package/build-types/snackbar/index.d.ts +5 -2
  113. package/build-types/snackbar/index.d.ts.map +1 -1
  114. package/build-types/snackbar/list.d.ts.map +1 -1
  115. package/build-types/snackbar/test/index.d.ts +2 -0
  116. package/build-types/snackbar/test/index.d.ts.map +1 -0
  117. package/build-types/snackbar/test/list.d.ts +2 -0
  118. package/build-types/snackbar/test/list.d.ts.map +1 -0
  119. package/build-types/snackbar/types.d.ts +18 -2
  120. package/build-types/snackbar/types.d.ts.map +1 -1
  121. package/build-types/tabs/index.d.ts +1 -1
  122. package/build-types/tabs/types.d.ts +1 -1
  123. package/build-types/utils/hooks/index.d.ts +0 -1
  124. package/build-types/v-stack/hook.d.ts +2 -4
  125. package/build-types/v-stack/hook.d.ts.map +1 -1
  126. package/package.json +19 -19
  127. package/src/base-control/index.native.js +1 -1
  128. package/src/base-control/test/index.tsx +1 -1
  129. package/src/border-box-control/border-box-control/component.tsx +1 -1
  130. package/src/border-box-control/border-box-control-split-controls/component.tsx +4 -4
  131. package/src/border-control/border-control-dropdown/component.tsx +1 -1
  132. package/src/button/index.native.js +1 -1
  133. package/src/button/index.tsx +1 -1
  134. package/src/button/style.scss +1 -3
  135. package/src/circular-option-picker/test/index.tsx +2 -4
  136. package/src/combobox-control/test/index.tsx +1 -1
  137. package/src/confirm-dialog/component.tsx +1 -1
  138. package/src/confirm-dialog/test/index.tsx +5 -21
  139. package/src/custom-select-control-v2/default-component/index.tsx +4 -1
  140. package/src/custom-select-control-v2/index.tsx +1 -1
  141. package/src/custom-select-control-v2/legacy-component/test/index.tsx +457 -0
  142. package/src/custom-select-control-v2/stories/legacy.story.tsx +5 -6
  143. package/src/custom-select-control-v2/test/index.tsx +279 -749
  144. package/src/custom-select-control-v2/types.ts +0 -1
  145. package/src/disabled/test/index.tsx +1 -1
  146. package/src/draggable/index.native.js +2 -2
  147. package/src/draggable/test/index.native.js +6 -2
  148. package/src/dropdown-menu/index.native.js +2 -2
  149. package/src/flex/flex/hook.ts +1 -1
  150. package/src/font-size-picker/index.native.js +2 -2
  151. package/src/form-token-field/index.tsx +1 -1
  152. package/src/h-stack/hook.tsx +2 -1
  153. package/src/h-stack/test/index.tsx +10 -0
  154. package/src/item-group/test/index.js +2 -2
  155. package/src/mobile/bottom-sheet/bottom-sheet-navigation/test/navigation-container.native.js +10 -15
  156. package/src/mobile/bottom-sheet/button.native.js +1 -5
  157. package/src/mobile/bottom-sheet/index.native.js +2 -2
  158. package/src/mobile/bottom-sheet/range-cell.native.js +1 -1
  159. package/src/mobile/bottom-sheet/stepper-cell/index.native.js +2 -2
  160. package/src/mobile/bottom-sheet-select-control/index.native.js +1 -1
  161. package/src/mobile/bottom-sheet-text-control/index.native.js +1 -1
  162. package/src/mobile/gradient/index.native.js +1 -1
  163. package/src/mobile/image/index.native.js +8 -23
  164. package/src/mobile/media-edit/index.native.js +1 -1
  165. package/src/modal/test/index.tsx +1 -1
  166. package/src/navigation/stories/utils/hide-if-empty.tsx +2 -6
  167. package/src/palette-edit/index.tsx +2 -2
  168. package/src/popover/test/index.tsx +1 -4
  169. package/src/query-controls/index.native.js +2 -2
  170. package/src/radio-group/stories/index.story.tsx +1 -0
  171. package/src/range-control/index.tsx +3 -3
  172. package/src/range-control/test/index.tsx +2 -2
  173. package/src/search-control/index.native.js +1 -1
  174. package/src/snackbar/index.tsx +5 -2
  175. package/src/snackbar/list.tsx +6 -1
  176. package/src/snackbar/stories/list.story.tsx +0 -3
  177. package/src/snackbar/test/index.tsx +267 -0
  178. package/src/snackbar/test/list.tsx +46 -0
  179. package/src/snackbar/types.ts +31 -3
  180. package/src/tabs/README.md +18 -18
  181. package/src/tabs/index.tsx +7 -7
  182. package/src/tabs/stories/index.story.tsx +1 -1
  183. package/src/tabs/test/index.tsx +30 -30
  184. package/src/tabs/types.ts +1 -1
  185. package/src/toggle-group-control/test/index.tsx +1 -1
  186. package/src/tools-panel/stories/index.story.tsx +8 -8
  187. package/src/tools-panel/test/index.tsx +10 -28
  188. package/src/tooltip/style.scss +2 -1
  189. package/src/tooltip/test/index.native.js +3 -3
  190. package/src/tree-grid/test/index.tsx +1 -1
  191. package/src/utils/hooks/index.js +0 -1
  192. package/src/v-stack/test/index.tsx +10 -0
  193. package/tsconfig.tsbuildinfo +1 -1
  194. package/build/custom-select-control-v2/legacy-adapter.js +0 -29
  195. package/build/custom-select-control-v2/legacy-adapter.js.map +0 -1
  196. package/build/utils/hooks/use-latest-ref.js +0 -33
  197. package/build/utils/hooks/use-latest-ref.js.map +0 -1
  198. package/build-module/custom-select-control-v2/legacy-adapter.js +0 -21
  199. package/build-module/custom-select-control-v2/legacy-adapter.js.map +0 -1
  200. package/build-module/utils/hooks/use-latest-ref.js +0 -27
  201. package/build-module/utils/hooks/use-latest-ref.js.map +0 -1
  202. package/build-types/custom-select-control-v2/legacy-adapter.d.ts +0 -6
  203. package/build-types/custom-select-control-v2/legacy-adapter.d.ts.map +0 -1
  204. package/build-types/utils/hooks/use-latest-ref.d.ts +0 -15
  205. package/build-types/utils/hooks/use-latest-ref.d.ts.map +0 -1
  206. package/src/custom-select-control-v2/legacy-adapter.tsx +0 -25
  207. package/src/utils/hooks/test/use-latest-ref.js +0 -119
  208. package/src/utils/hooks/use-latest-ref.ts +0 -29
@@ -92,7 +92,6 @@ type LegacyOnChangeObject = {
92
92
  };
93
93
 
94
94
  export type LegacyCustomSelectProps = {
95
- children?: never;
96
95
  /**
97
96
  * Optional classname for the component.
98
97
  */
@@ -94,7 +94,7 @@ describe( 'Disabled', () => {
94
94
  'This is contentEditable.'
95
95
  );
96
96
 
97
- rerender( <MaybeDisable isDisabled={ true } /> );
97
+ rerender( <MaybeDisable isDisabled /> );
98
98
  expect( getInput() ).toHaveValue( 'This is input.' );
99
99
  expect( getContentEditable() ).toHaveTextContent(
100
100
  'This is contentEditable.'
@@ -63,7 +63,7 @@ const Draggable = ( {
63
63
  useAnimatedReaction(
64
64
  () => isDragging.value,
65
65
  ( result, previous ) => {
66
- if ( result === previous || previous === null ) {
66
+ if ( result === previous ) {
67
67
  return;
68
68
  }
69
69
 
@@ -75,7 +75,7 @@ const Draggable = ( {
75
75
  id: draggingId.value,
76
76
  } );
77
77
  }
78
- } else if ( onDragEnd ) {
78
+ } else if ( previous !== null && onDragEnd ) {
79
79
  onDragEnd( {
80
80
  x: lastPosition.x.value,
81
81
  y: lastPosition.y.value,
@@ -28,10 +28,12 @@ const TouchEventType = {
28
28
  // For testing, we mock the "requestAnimationFrame" so it calls the callback passed instantly.
29
29
  let requestAnimationFrameCopy;
30
30
  beforeEach( () => {
31
+ jest.useFakeTimers();
31
32
  requestAnimationFrameCopy = global.requestAnimationFrame;
32
33
  global.requestAnimationFrame = ( callback ) => callback();
33
34
  } );
34
35
  afterEach( () => {
36
+ jest.useRealTimers();
35
37
  global.requestAnimationFrame = requestAnimationFrameCopy;
36
38
  } );
37
39
 
@@ -43,7 +45,7 @@ describe( 'Draggable', () => {
43
45
  <Draggable>
44
46
  <DraggableTrigger
45
47
  id={ triggerId }
46
- enabled={ true }
48
+ enabled
47
49
  minDuration={ 500 }
48
50
  onLongPress={ onLongPress }
49
51
  testID="draggableTrigger"
@@ -58,6 +60,7 @@ describe( 'Draggable', () => {
58
60
  { oldState: State.BEGAN, state: State.ACTIVE },
59
61
  { state: State.ACTIVE },
60
62
  ] );
63
+ jest.runOnlyPendingTimers();
61
64
 
62
65
  expect( onLongPress ).toHaveBeenCalledTimes( 1 );
63
66
  expect( onLongPress ).toHaveBeenCalledWith( triggerId );
@@ -93,6 +96,7 @@ describe( 'Draggable', () => {
93
96
  { oldState: State.BEGAN, state: State.ACTIVE },
94
97
  { state: State.ACTIVE },
95
98
  ] );
99
+ jest.runOnlyPendingTimers();
96
100
  fireGestureHandler( draggable, [
97
101
  // TOUCHES_DOWN event is only received on ACTIVE state, so we have to fire it manually.
98
102
  { oldState: State.BEGAN, state: State.ACTIVE },
@@ -112,7 +116,7 @@ describe( 'Draggable', () => {
112
116
  ] );
113
117
  // TODO(jest-console): Fix the warning and remove the expect below.
114
118
  expect( console ).toHaveWarnedWith(
115
- '[Reanimated] You can not use setGestureState in non-worklet function.'
119
+ '[Reanimated] setGestureState() cannot be used with Jest.'
116
120
  );
117
121
 
118
122
  expect( onDragStart ).toHaveBeenCalledTimes( 1 );
@@ -108,7 +108,7 @@ function DropdownMenu( {
108
108
  renderContent={ ( { isOpen, onClose, ...props } ) => {
109
109
  return (
110
110
  <BottomSheet
111
- hideHeader={ true }
111
+ hideHeader
112
112
  isVisible={ isOpen }
113
113
  onClose={ onClose }
114
114
  >
@@ -135,7 +135,7 @@ function DropdownMenu( {
135
135
  } }
136
136
  editable={ false }
137
137
  icon={ control.icon }
138
- leftAlign={ true }
138
+ leftAlign
139
139
  isSelected={ control.isActive }
140
140
  separatorType={
141
141
  Platform.OS === 'android'
@@ -22,7 +22,7 @@ import type { FlexProps } from '../types';
22
22
 
23
23
  function useDeprecatedProps(
24
24
  props: WordPressComponentProps< FlexProps, 'div' >
25
- ): WordPressComponentProps< FlexProps, 'div' > {
25
+ ): Omit< typeof props, 'isReversed' > {
26
26
  const { isReversed, ...otherProps } = props;
27
27
 
28
28
  if ( typeof isReversed !== 'undefined' ) {
@@ -111,7 +111,7 @@ function FontSizePicker( {
111
111
  separatorType="none"
112
112
  label={ __( 'Default' ) }
113
113
  onPress={ onChangeValue( undefined ) }
114
- leftAlign={ true }
114
+ leftAlign
115
115
  key={ 'default' }
116
116
  accessibilityRole={ 'button' }
117
117
  accessibilityLabel={ __( 'Selected: Default' ) }
@@ -137,7 +137,7 @@ function FontSizePicker( {
137
137
  label={ item.name }
138
138
  subLabel={ item.sizePx }
139
139
  onPress={ onChangeValue( item.sizePx ) }
140
- leftAlign={ true }
140
+ leftAlign
141
141
  key={ index }
142
142
  accessibilityRole={ 'button' }
143
143
  accessibilityLabel={
@@ -711,7 +711,7 @@ export function FormTokenField( props: FormTokenFieldProps ) {
711
711
  justify="flex-start"
712
712
  align="center"
713
713
  gap={ 1 }
714
- wrap={ true }
714
+ wrap
715
715
  __next40pxDefaultSize={ __next40pxDefaultSize }
716
716
  hasTokens={ !! value.length }
717
717
  >
@@ -47,7 +47,8 @@ export function useHStack( props: WordPressComponentProps< Props, 'div' > ) {
47
47
  gap: spacing,
48
48
  };
49
49
 
50
- const flexProps = useFlex( propsForFlex );
50
+ // Omit `isColumn` because it's not used in HStack.
51
+ const { isColumn, ...flexProps } = useFlex( propsForFlex );
51
52
 
52
53
  return flexProps;
53
54
  }
@@ -39,4 +39,14 @@ describe( 'props', () => {
39
39
  );
40
40
  expect( container ).toMatchSnapshot();
41
41
  } );
42
+
43
+ test( 'should not pass through invalid props to the `as` component', () => {
44
+ const AsComponent = ( props: JSX.IntrinsicElements[ 'div' ] ) => {
45
+ return <div { ...props } />;
46
+ };
47
+
48
+ render( <HStack as={ AsComponent }>foobar</HStack> );
49
+
50
+ expect( console ).not.toHaveErrored();
51
+ } );
42
52
  } );
@@ -29,7 +29,7 @@ describe( 'ItemGroup', () => {
29
29
  );
30
30
 
31
31
  const { container: withBorders } = render(
32
- <ItemGroup isBordered={ true }>
32
+ <ItemGroup isBordered>
33
33
  <Item>Code is poetry</Item>
34
34
  </ItemGroup>
35
35
  );
@@ -63,7 +63,7 @@ describe( 'ItemGroup', () => {
63
63
  );
64
64
 
65
65
  const { container: separatedItems } = render(
66
- <ItemGroup isSeparated={ true }>
66
+ <ItemGroup isSeparated>
67
67
  <Item>Code is poetry</Item>
68
68
  </ItemGroup>
69
69
  );
@@ -2,12 +2,7 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { Text } from 'react-native';
5
- import {
6
- render,
7
- fireEvent,
8
- withReanimatedTimer,
9
- advanceAnimationByTime,
10
- } from 'test/helpers';
5
+ import { act, render, fireEvent, withReanimatedTimer } from 'test/helpers';
11
6
  import { useNavigation } from '@react-navigation/native';
12
7
 
13
8
  /**
@@ -63,7 +58,7 @@ it( 'animates height transitioning from non-full-screen to non-full-screen', asy
63
58
  screen.getByTestId( 'navigation-screen-test-screen-1' ),
64
59
  screen1Layout
65
60
  );
66
- advanceAnimationByTime( 1 );
61
+ act( () => jest.advanceTimersByTime( 1 ) );
67
62
  expect( navigationContainer ).toHaveAnimatedStyle( screen1Layout );
68
63
 
69
64
  // Navigate to screen 2
@@ -75,7 +70,7 @@ it( 'animates height transitioning from non-full-screen to non-full-screen', asy
75
70
  );
76
71
  // The animation takes 300 ms, so we wait that time plus 1 ms
77
72
  // to the completion.
78
- advanceAnimationByTime( 301 );
73
+ act( () => jest.advanceTimersByTime( 301 ) );
79
74
  expect( navigationContainer ).toHaveAnimatedStyle( screen2Layout );
80
75
  } ) );
81
76
 
@@ -105,14 +100,14 @@ it( 'animates height transitioning from non-full-screen to full-screen', async (
105
100
  screen.getByTestId( 'navigation-screen-test-screen-1' ),
106
101
  screen1Layout
107
102
  );
108
- advanceAnimationByTime( 1 );
103
+ act( () => jest.advanceTimersByTime( 1 ) );
109
104
  expect( navigationContainer ).toHaveAnimatedStyle( screen1Layout );
110
105
 
111
106
  // Navigate to screen 2
112
107
  fireEvent.press( screen.getByText( /test-screen-1/ ) );
113
108
  // The animation takes 300 ms, so we wait that time plus 1 ms
114
109
  // to the completion.
115
- advanceAnimationByTime( 301 );
110
+ act( () => jest.advanceTimersByTime( 301 ) );
116
111
  expect( navigationContainer ).toHaveAnimatedStyle( {
117
112
  height: WINDOW_HEIGHT,
118
113
  } );
@@ -144,14 +139,14 @@ it( 'animates height transitioning from full-screen to non-full-screen', async (
144
139
  screen.getByTestId( 'navigation-screen-test-screen-1' ),
145
140
  screen1Layout
146
141
  );
147
- advanceAnimationByTime( 1 );
142
+ act( () => jest.advanceTimersByTime( 1 ) );
148
143
  expect( navigationContainer ).toHaveAnimatedStyle( screen1Layout );
149
144
 
150
145
  // Navigate to screen 2
151
146
  fireEvent.press( screen.getByText( /test-screen-1/ ) );
152
147
  // The animation takes 300 ms, so we wait that time plus 1 ms
153
148
  // to the completion.
154
- advanceAnimationByTime( 301 );
149
+ act( () => jest.advanceTimersByTime( 301 ) );
155
150
  expect( navigationContainer ).toHaveAnimatedStyle( {
156
151
  height: WINDOW_HEIGHT,
157
152
  } );
@@ -160,7 +155,7 @@ it( 'animates height transitioning from full-screen to non-full-screen', async (
160
155
  fireEvent.press( await screen.findByText( /test-screen-2/ ) );
161
156
  // The animation takes 300 ms, so we wait that time plus 1 ms
162
157
  // to the completion.
163
- advanceAnimationByTime( 301 );
158
+ act( () => jest.advanceTimersByTime( 301 ) );
164
159
  expect( navigationContainer ).toHaveAnimatedStyle( screen1Layout );
165
160
  } ) );
166
161
 
@@ -187,7 +182,7 @@ it( 'does not animate height transitioning from full-screen to full-screen', asy
187
182
 
188
183
  // First height value should be set without animation, but we need
189
184
  // to wait for a frame to let animated styles be updated.
190
- advanceAnimationByTime( 1 );
185
+ act( () => jest.advanceTimersByTime( 1 ) );
191
186
  expect( navigationContainer ).toHaveAnimatedStyle( {
192
187
  height: WINDOW_HEIGHT,
193
188
  } );
@@ -195,7 +190,7 @@ it( 'does not animate height transitioning from full-screen to full-screen', asy
195
190
  // Navigate to screen 2
196
191
  fireEvent.press( screen.getByText( /test-screen-1/ ) );
197
192
  // We wait some milliseconds to check if height has changed.
198
- advanceAnimationByTime( 10 );
193
+ act( () => jest.advanceTimersByTime( 10 ) );
199
194
  expect( navigationContainer ).toHaveAnimatedStyle( {
200
195
  height: WINDOW_HEIGHT,
201
196
  } );
@@ -9,11 +9,7 @@ import { TouchableOpacity, View, Text } from 'react-native';
9
9
  import styles from './styles.scss';
10
10
 
11
11
  const BottomSheetButton = ( { onPress, disabled, text, color } ) => (
12
- <TouchableOpacity
13
- accessible={ true }
14
- onPress={ onPress }
15
- disabled={ disabled }
16
- >
12
+ <TouchableOpacity accessible onPress={ onPress } disabled={ disabled }>
17
13
  <View style={ { flexDirection: 'row', justifyContent: 'center' } }>
18
14
  <Text style={ { ...styles.buttonText, color } }>{ text }</Text>
19
15
  </View>
@@ -540,8 +540,8 @@ class BottomSheet extends Component {
540
540
  }
541
541
  onAccessibilityEscape={ this.onCloseBottomSheet }
542
542
  testID="bottom-sheet"
543
- hardwareAccelerated={ true }
544
- useNativeDriverForBackdrop={ true }
543
+ hardwareAccelerated
544
+ useNativeDriverForBackdrop
545
545
  { ...rest }
546
546
  >
547
547
  <KeyboardAvoidingView
@@ -181,7 +181,7 @@ class BottomSheetRangeCell extends Component {
181
181
 
182
182
  return (
183
183
  <View
184
- accessible={ true }
184
+ accessible
185
185
  accessibilityRole="adjustable"
186
186
  accessibilityActions={ [
187
187
  { name: 'increment' },
@@ -174,7 +174,7 @@ class BottomSheetStepperCell extends Component {
174
174
 
175
175
  return (
176
176
  <View
177
- accessible={ true }
177
+ accessible
178
178
  accessibilityRole="adjustable"
179
179
  accessibilityLabel={ accessibilityLabel }
180
180
  accessibilityHint={ getAccessibilityHint() }
@@ -214,7 +214,7 @@ class BottomSheetStepperCell extends Component {
214
214
  icon={ icon }
215
215
  label={ label }
216
216
  labelStyle={ labelStyle }
217
- leftAlign={ true }
217
+ leftAlign
218
218
  separatorType={ separatorType }
219
219
  disabled={ disabled }
220
220
  >
@@ -91,7 +91,7 @@ const BottomSheetSelectControl = ( {
91
91
  label={ item.label }
92
92
  icon={ item.icon }
93
93
  onPress={ onChangeValue( item.value ) }
94
- leftAlign={ true }
94
+ leftAlign
95
95
  key={ index }
96
96
  accessibilityRole={ 'button' }
97
97
  accessibilityLabel={
@@ -82,7 +82,7 @@ const BottomSheetTextControl = ( {
82
82
  label={ label }
83
83
  onChangeText={ ( text ) => onChange( text ) }
84
84
  defaultValue={ initialValue }
85
- multiline={ true }
85
+ multiline
86
86
  placeholder={ placeholder }
87
87
  placeholderTextColor={ '#87a6bc' }
88
88
  style={ textEditorStyle }
@@ -135,7 +135,7 @@ function Gradient( {
135
135
  return (
136
136
  <RNLinearGradient
137
137
  colors={ colors }
138
- useAngle={ true }
138
+ useAngle
139
139
  angle={ getGradientAngle( gradientValue ) }
140
140
  locations={ locations }
141
141
  angleCenter={ angleCenter }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { Animated, Image as RNImage, Text, View } from 'react-native';
4
+ import { Image as RNImage, Text, View } from 'react-native';
5
5
  import FastImage from 'react-native-fast-image';
6
6
 
7
7
  /**
@@ -11,7 +11,7 @@ import { __ } from '@wordpress/i18n';
11
11
  import { Icon } from '@wordpress/components';
12
12
  import { image, offline } from '@wordpress/icons';
13
13
  import { usePreferredColorSchemeStyle } from '@wordpress/compose';
14
- import { useEffect, useState, useRef, Platform } from '@wordpress/element';
14
+ import { useEffect, useState, Platform } from '@wordpress/element';
15
15
 
16
16
  /**
17
17
  * Internal dependencies
@@ -218,19 +218,8 @@ const ImageComponent = ( {
218
218
  focalPoint && styles.focalPointContainer,
219
219
  ];
220
220
 
221
- const opacityValue = useRef( new Animated.Value( 1 ) ).current;
222
-
223
- useEffect( () => {
224
- Animated.timing( opacityValue, {
225
- toValue: isUploadInProgress ? 0.3 : 1,
226
- duration: 100,
227
- useNativeDriver: true,
228
- } ).start();
229
- }, [ isUploadInProgress, opacityValue ] );
230
-
231
221
  const imageStyles = [
232
222
  {
233
- opacity: opacityValue,
234
223
  height: containerSize?.height,
235
224
  },
236
225
  ! resizeMode && {
@@ -300,13 +289,9 @@ const ImageComponent = ( {
300
289
  key={ url }
301
290
  style={ imageContainerStyles }
302
291
  >
303
- { isSelected &&
304
- highlightSelected &&
305
- ! (
306
- isUploadInProgress ||
307
- isUploadFailed ||
308
- isUploadPaused
309
- ) && <View style={ imageSelectedStyles } /> }
292
+ { isSelected && highlightSelected && (
293
+ <View style={ imageSelectedStyles } />
294
+ ) }
310
295
 
311
296
  { ! imageData ? (
312
297
  <View style={ placeholderStyles }>
@@ -319,7 +304,7 @@ const ImageComponent = ( {
319
304
  { Platform.isAndroid && (
320
305
  <>
321
306
  { networkImageLoaded && networkURL && (
322
- <Animated.Image
307
+ <Image
323
308
  style={ imageStyles }
324
309
  fadeDuration={ 0 }
325
310
  source={ { uri: networkURL } }
@@ -331,7 +316,7 @@ const ImageComponent = ( {
331
316
  />
332
317
  ) }
333
318
  { ! networkImageLoaded && ! networkURL && (
334
- <Animated.Image
319
+ <Image
335
320
  style={ imageStyles }
336
321
  fadeDuration={ 0 }
337
322
  source={ { uri: localURL } }
@@ -345,7 +330,7 @@ const ImageComponent = ( {
345
330
  ) }
346
331
  { Platform.isIOS && (
347
332
  <>
348
- <Animated.Image
333
+ <Image
349
334
  style={ imageStyles }
350
335
  source={ {
351
336
  uri:
@@ -103,7 +103,7 @@ export class MediaEdit extends Component {
103
103
  hideCancelButton
104
104
  ref={ ( instance ) => ( this.picker = instance ) }
105
105
  options={ this.getMediaOptionsItems() }
106
- leftAlign={ true }
106
+ leftAlign
107
107
  onChange={ this.onPickerSelect }
108
108
  // translators: %s: block title e.g: "Paragraph".
109
109
  title={ __( 'Media options' ) }
@@ -335,7 +335,7 @@ describe( 'Modal', () => {
335
335
  it( 'should focus the Modal dialog when `true` passed as value for `focusOnMount` prop', async () => {
336
336
  const user = userEvent.setup();
337
337
 
338
- render( <FocusMountDemo focusOnMount={ true } /> );
338
+ render( <FocusMountDemo focusOnMount /> );
339
339
 
340
340
  const opener = screen.getByRole( 'button', {
341
341
  name: 'Toggle Modal',
@@ -42,11 +42,7 @@ export const HideIfEmptyStory: StoryFn< typeof Navigation > = ( {
42
42
  />
43
43
  </NavigationMenu>
44
44
 
45
- <NavigationMenu
46
- menu="root-sub-1"
47
- parentMenu="root"
48
- isEmpty={ true }
49
- />
45
+ <NavigationMenu menu="root-sub-1" parentMenu="root" isEmpty />
50
46
  <NavigationMenu
51
47
  menu="root-sub-2"
52
48
  parentMenu="root"
@@ -57,7 +53,7 @@ export const HideIfEmptyStory: StoryFn< typeof Navigation > = ( {
57
53
  <NavigationMenu
58
54
  menu="root-sub-1-sub-1"
59
55
  parentMenu="root-sub-1"
60
- isEmpty={ true }
56
+ isEmpty
61
57
  />
62
58
  </Navigation>
63
59
 
@@ -592,14 +592,14 @@ export function PaletteEdit( {
592
592
  gradients={ gradients }
593
593
  onChange={ onSelectPaletteItem }
594
594
  clearable={ false }
595
- disableCustomGradients={ true }
595
+ disableCustomGradients
596
596
  />
597
597
  ) : (
598
598
  <ColorPalette
599
599
  colors={ colors }
600
600
  onChange={ onSelectPaletteItem }
601
601
  clearable={ false }
602
- disableCustomColors={ true }
602
+ disableCustomColors
603
603
  />
604
604
  ) ) }
605
605
  </>
@@ -182,10 +182,7 @@ describe( 'Popover', () => {
182
182
  describe( 'focus behavior', () => {
183
183
  it( 'should focus the popover container when opened', async () => {
184
184
  render(
185
- <Popover
186
- focusOnMount={ true }
187
- data-testid="popover-element"
188
- >
185
+ <Popover focusOnMount data-testid="popover-element">
189
186
  Popover content
190
187
  </Popover>
191
188
  );
@@ -69,7 +69,7 @@ const QueryControls = memo(
69
69
  value={ `${ orderBy }/${ order }` }
70
70
  options={ options }
71
71
  onChange={ onChange }
72
- hideCancelButton={ true }
72
+ hideCancelButton
73
73
  />
74
74
  ) }
75
75
  { onCategoryChange && (
@@ -79,7 +79,7 @@ const QueryControls = memo(
79
79
  noOptionLabel={ _x( 'All', 'categories' ) }
80
80
  selectedCategoryId={ selectedCategoryId }
81
81
  onChange={ onCategoryChange }
82
- hideCancelButton={ true }
82
+ hideCancelButton
83
83
  />
84
84
  ) }
85
85
  { onNumberOfItemsChange && (
@@ -16,6 +16,7 @@ import { useState } from '@wordpress/element';
16
16
 
17
17
  const meta: Meta< typeof RadioGroup > = {
18
18
  title: 'Components (Deprecated)/RadioGroup',
19
+ id: 'components-radiogroup',
19
20
  component: RadioGroup,
20
21
  // @ts-expect-error - See https://github.com/storybookjs/storybook/issues/23170
21
22
  subcomponents: { Radio },
@@ -253,7 +253,7 @@ function UnforwardedRangeControl(
253
253
  value={ inputSliderValue ?? undefined }
254
254
  />
255
255
  <RangeRail
256
- aria-hidden={ true }
256
+ aria-hidden
257
257
  disabled={ disabled }
258
258
  marks={ marks }
259
259
  max={ max }
@@ -263,7 +263,7 @@ function UnforwardedRangeControl(
263
263
  value={ rangeFillValue }
264
264
  />
265
265
  <Track
266
- aria-hidden={ true }
266
+ aria-hidden
267
267
  className="components-range-control__track"
268
268
  disabled={ disabled }
269
269
  style={ { width: fillValueOffset } }
@@ -275,7 +275,7 @@ function UnforwardedRangeControl(
275
275
  disabled={ disabled }
276
276
  >
277
277
  <Thumb
278
- aria-hidden={ true }
278
+ aria-hidden
279
279
  isFocused={ isThumbFocused }
280
280
  disabled={ disabled }
281
281
  />
@@ -297,7 +297,7 @@ describe( 'RangeControl', () => {
297
297
  render(
298
298
  <RangeControl
299
299
  initialPosition={ 10 }
300
- allowReset={ true }
300
+ allowReset
301
301
  onChange={ spy }
302
302
  resetFallbackValue={ 33 }
303
303
  />
@@ -320,7 +320,7 @@ describe( 'RangeControl', () => {
320
320
  initialPosition={ undefined }
321
321
  min={ 0 }
322
322
  max={ 100 }
323
- allowReset={ true }
323
+ allowReset
324
324
  resetFallbackValue={ undefined }
325
325
  />
326
326
  );
@@ -235,7 +235,7 @@ function SearchControl( {
235
235
  <Text
236
236
  onPress={ onCancel }
237
237
  style={ cancelButtonTextStyle }
238
- accessible={ true }
238
+ accessible
239
239
  accessibilityRole={ 'button' }
240
240
  accessibilityLabel={ __( 'Cancel search' ) }
241
241
  accessibilityHint={ __( 'Cancel search' ) }
@@ -138,9 +138,12 @@ function UnforwardedSnackbar(
138
138
  className={ classes }
139
139
  onClick={ ! explicitDismiss ? dismissMe : undefined }
140
140
  tabIndex={ 0 }
141
- role={ ! explicitDismiss ? 'button' : '' }
141
+ role={ ! explicitDismiss ? 'button' : undefined }
142
142
  onKeyPress={ ! explicitDismiss ? dismissMe : undefined }
143
- aria-label={ ! explicitDismiss ? __( 'Dismiss this notice' ) : '' }
143
+ aria-label={
144
+ ! explicitDismiss ? __( 'Dismiss this notice' ) : undefined
145
+ }
146
+ data-testid="snackbar"
144
147
  >
145
148
  <div className={ snackbarContentClassnames }>
146
149
  { icon && (
@@ -73,7 +73,12 @@ export function SnackbarList( {
73
73
  ( notice: SnackbarListProps[ 'notices' ][ number ] ) => () =>
74
74
  onRemove?.( notice.id );
75
75
  return (
76
- <div className={ className } tabIndex={ -1 } ref={ listRef }>
76
+ <div
77
+ className={ className }
78
+ tabIndex={ -1 }
79
+ ref={ listRef }
80
+ data-testid="snackbar-list"
81
+ >
77
82
  { children }
78
83
  <AnimatePresence>
79
84
  { notices.map( ( notice ) => {
@@ -70,7 +70,6 @@ Default.args = {
70
70
  },
71
71
  ],
72
72
  content: 'Post published.',
73
- isDismissible: true,
74
73
  explicitDismiss: false,
75
74
  },
76
75
  {
@@ -83,7 +82,6 @@ Default.args = {
83
82
  },
84
83
  ],
85
84
  content: 'Post updated.',
86
- isDismissible: true,
87
85
  explicitDismiss: false,
88
86
  },
89
87
  {
@@ -91,7 +89,6 @@ Default.args = {
91
89
  spokenMessage: 'All content copied.',
92
90
  actions: [],
93
91
  content: 'All content copied.',
94
- isDismissible: true,
95
92
  explicitDismiss: false,
96
93
  },
97
94
  ],